20.6.10 • Published 9 days ago

@stenajs-webui/filter v20.6.10

Weekly downloads
-
License
MIT
Repository
github
Last release
9 days ago

stenajs-webui/filter

This package contains components and functionality that makes it easy to create custom filters in a drawer, and an overview row containing chips.

This package is alpha. API:s will most likely change, and more features added. If you use it, be ready for breaking changes.

The section

A section is one expandable part of the filter. The filter can consist of many sections. Each section can how none, one or many chips.

The context

The filter components access state, dispatch and actions. These are fetched from context, so any filter components must be wrapped with

<SearchFilterContext actions={actions} state={state} dispatch={dispatch}>
  <SearchFilterButton/>
  <SearchFilterChips>
    <SectionChips {...stuff} />
  </SearchFilterChips>
  <SearchFilterDrawer>
    ... sections
  </SearchFilterDrawer>

If you are only using local state (no Redux, persistence, etc), you can use SearchFilterLocalStateContext. It will automatically setup actions, state and dispatch.

<SearchFilterLocalStateContext<FormModel>
  initialFormModel={{ startDate: undefined, endDate: undefined }}
>
  ... same as above
</SearchFilterLocalStateContext>

If you use SearchFilterLocalStateContext, you can use this to access filter state.

const state = useSearchFilterState();

Custom sections

You can create custom sections easily.

const MySection = (...props) => (
  <SearchFilterSection sectionId={sectionId} loading={loading} error={error}>
    <ChipMultiSelect
      options={filteredOptions}
      value={listValue}
      onValueChange={onValueChangeInternal}
      inputValue={text}
      onInputChange={setText}
    />
  </SearchFilterSection>
);

See source code for examples.

Ready-to-use sections

There are sections available ready to use.

More will be made available as the filter package matures.

DateRangeCalendarSection

Add the section to the drawer.

<DateRangeCalendarSection
  sectionId={"comparisonDate"}
  {...createDateRangeSectionProps(state.formModel, "startDate", "endDate")}
/>

And add the chips.

<SectionChips
  sectionId={"comparisonDate"}
  emptyChipLabel={"No dates"}
  {...createChipsPropsForDateRange(state.formModel, "startDate", "endDate")}
/>

ChipMultiSelectSection

Add the section to the drawer. This section does not have a helper method for creating props.

They must be specified manually. This might change.

<ChipMultiSelectSection
  sectionId={"divisions"}
  loading={false}
  options={divisionOptions}
  value={state.formModel.divisions}
  onValueChange={(divisions) =>
    dispatch(actions.setFormModelFields({ divisions }))
  }
/>

And add the chips.

<SectionChips
  sectionId={"divisions"}
  emptyChipLabel={"All division"}
  {...createChipsPropsForBooleanRecord(
    state.formModel,
    "divisions",
    divisionOptions
  )}
/>

In this example, state.formModel.divisions must be a BooleanRecord.

Another section for BooleanRecord is SimpleCheckboxListSection. They are API compatible and are interchangeable.

<SimpleCheckboxListSection
  sectionId={"divisions"}
  loading={false}
  options={divisionOptions}
  value={state.formModel.divisions}
  onValueChange={(divisions) =>
    dispatch(actions.setFormModelFields({ divisions }))
  }
/>

Chips

You can add all chips for a section using the SectionChips component.

<SectionChips
  sectionId={"divisions"}
  emptyChipLabel={"All division"}
  {...createChipsPropsForBooleanRecord(
    state.formModel,
    "divisions",
    divisionOptions
  )}
/>

Manual chips

If you need more manual control over each chip, you can add them individually.

{
  myList.map(({ value, label }) => (
    <SearchFilterChip
      key={value}
      label={label ?? sectionId}
      sectionId={sectionId}
      onClickRemove={onClickRemoveOnChip}
      value={value}
    />
  ));
}

If you need a chip to indicate no selection, you can use EmptyChip.

<EmptyChip sectionId={sectionId} label={emptyChipLabel} />
20.6.10

9 days ago

20.6.9

10 days ago

20.6.8

20 days ago

20.6.7

20 days ago

20.6.6

20 days ago

20.6.5

21 days ago

20.6.4

27 days ago

20.6.3

2 months ago

20.6.2

2 months ago

20.6.1

2 months ago

20.5.5

2 months ago

20.6.0

2 months ago

20.5.4

2 months ago

20.5.3

2 months ago

20.5.2

3 months ago

20.5.1

3 months ago

20.4.3

3 months ago

20.4.2

3 months ago

20.5.0

3 months ago

20.4.1

3 months ago

20.3.1

3 months ago

20.3.0

3 months ago

20.4.0

3 months ago

20.2.0

3 months ago

20.0.3

3 months ago

20.1.0

3 months ago

20.0.1

3 months ago

20.0.2

3 months ago

19.0.5

4 months ago

20.0.0

3 months ago

19.0.3

4 months ago

19.0.4

4 months ago

19.0.2

4 months ago

19.0.1

4 months ago

19.0.0

4 months ago

19.0.0-next.76

5 months ago

19.0.0-next.75

5 months ago

19.0.0-next.74

5 months ago

19.0.0-next.73

5 months ago

19.0.0-next.72

5 months ago

19.0.0-next.71

5 months ago

19.0.0-next.69

5 months ago

19.0.0-next.70

5 months ago

19.0.0-next.68

5 months ago

19.0.0-next.59

6 months ago

19.0.0-next.58

6 months ago

19.0.0-next.57

6 months ago

19.0.0-next.56

6 months ago

19.0.0-next.55

6 months ago

19.0.0-next.54

6 months ago

19.0.0-next.53

6 months ago

19.0.0-next.52

6 months ago

19.0.0-next.51

6 months ago

19.0.0-next.50

6 months ago

19.0.0-next.67

5 months ago

19.0.0-next.66

5 months ago

19.0.0-next.65

5 months ago

19.0.0-next.64

6 months ago

19.0.0-next.63

6 months ago

19.0.0-next.62

6 months ago

19.0.0-next.61

6 months ago

19.0.0-next.60

6 months ago

19.0.0-next.38

6 months ago

18.9.3

8 months ago

19.0.0-next.37

6 months ago

18.9.2

8 months ago

19.0.0-next.36

7 months ago

18.9.1

8 months ago

19.0.0-next.35

7 months ago

18.9.0

8 months ago

19.0.0-next.34

7 months ago

19.0.0-next.33

7 months ago

19.0.0-next.32

7 months ago

19.0.0-next.31

7 months ago

19.0.0-next.30

7 months ago

18.10.0

8 months ago

18.10.1

8 months ago

19.0.0-next.29

7 months ago

19.0.0-next.28

7 months ago

19.0.0-next.49

6 months ago

19.0.0-next.48

6 months ago

19.0.0-next.47

6 months ago

19.0.0-next.46

6 months ago

19.0.0-next.45

6 months ago

19.0.0-next.44

6 months ago

19.0.0-next.43

6 months ago

19.0.0-next.42

6 months ago

19.0.0-next.41

6 months ago

19.0.0-next.40

6 months ago

19.0.0-next.39

6 months ago

19.0.0-next.16

7 months ago

19.0.0-next.15

7 months ago

19.0.0-next.14

7 months ago

19.0.0-next.13

7 months ago

19.0.0-next.12

7 months ago

18.8.0

8 months ago

19.0.0-next.11

7 months ago

18.11.0

8 months ago

18.11.1

8 months ago

19.0.0-next.27

7 months ago

19.0.0-next.26

7 months ago

19.0.0-next.25

7 months ago

19.0.0-next.24

7 months ago

19.0.0-next.23

7 months ago

19.0.0-next.22

7 months ago

19.0.0-next.21

7 months ago

19.0.0-next.20

7 months ago

19.0.0-next.1

8 months ago

19.0.0-next.0

8 months ago

19.0.0-next.9

7 months ago

19.0.0-next.8

7 months ago

19.0.0-next.7

7 months ago

19.0.0-next.6

7 months ago

19.0.0-next.5

7 months ago

19.0.0-next.19

7 months ago

19.0.0-next.4

7 months ago

19.0.0-next.18

7 months ago

19.0.0-next.3

7 months ago

19.0.0-next.17

7 months ago

19.0.0-next.2

8 months ago

18.7.2

8 months ago

18.12.0

8 months ago

18.12.1

7 months ago

18.12.2

6 months ago

18.12.3

6 months ago

18.11.2-next.0

8 months ago

18.12.1-next.0

8 months ago

18.7.1

11 months ago

18.6.1

12 months ago

18.6.0

1 year ago

18.7.0

11 months ago

18.5.0

1 year ago

18.4.2

1 year ago

18.4.1

1 year ago

18.2.0

1 year ago

18.1.2

1 year ago

18.1.1

1 year ago

18.1.0

1 year ago

18.4.0

1 year ago

18.0.3

1 year ago

18.0.2

1 year ago

18.3.0

1 year ago

18.0.1

1 year ago

18.0.0

1 year ago

17.31.0

1 year ago

17.32.0

1 year ago

17.33.0

1 year ago

17.34.0

1 year ago

17.30.7

1 year ago

17.30.0

1 year ago

17.30.4

1 year ago

17.30.3

1 year ago

17.30.2

1 year ago

17.30.1

1 year ago

17.30.6

1 year ago

17.30.5

1 year ago

17.29.0

1 year ago

17.29.1

1 year ago

17.28.0

1 year ago

17.28.1

1 year ago

17.24.0

2 years ago

17.26.0

2 years ago

17.20.0

2 years ago

17.22.0

2 years ago

17.19.0

2 years ago

17.19.1

2 years ago

17.27.1

1 year ago

17.23.1

2 years ago

17.25.0

2 years ago

17.27.0

1 year ago

17.21.0

2 years ago

17.23.0

2 years ago

17.18.3

2 years ago

17.18.0

2 years ago

17.18.1

2 years ago

17.18.2

2 years ago

17.14.0

2 years ago

17.16.0

2 years ago

17.17.0

2 years ago

17.13.0

2 years ago

17.13.1

2 years ago

17.15.0

2 years ago

17.13.2

2 years ago

17.13.3

2 years ago

17.12.1

2 years ago

17.12.0

2 years ago

15.7.0

2 years ago

17.10.0

2 years ago

17.10.1

2 years ago

17.3.0

2 years ago

17.1.2

2 years ago

17.1.1

2 years ago

17.5.0

2 years ago

17.1.0

2 years ago

17.7.0

2 years ago

17.9.0

2 years ago

16.1.0

2 years ago

17.11.0

2 years ago

17.2.0

2 years ago

17.4.1

2 years ago

17.4.0

2 years ago

17.0.0

2 years ago

17.6.0

2 years ago

17.8.0

2 years ago

16.0.0

2 years ago

15.6.0

2 years ago

15.5.8

2 years ago

15.5.7

2 years ago

15.5.9

2 years ago

15.5.10

2 years ago

15.5.0

2 years ago

15.4.1

2 years ago

15.4.0

2 years ago

15.5.2

2 years ago

15.5.1

2 years ago

15.5.4

2 years ago

15.5.3

2 years ago

15.5.6

2 years ago

15.5.5

2 years ago

15.3.2

2 years ago

15.3.1

2 years ago

15.2.0

2 years ago

15.2.1

2 years ago

15.3.0

2 years ago

15.0.2

2 years ago

15.0.3

2 years ago

15.0.0

2 years ago

15.0.0-alpha.10

2 years ago

15.1.0

2 years ago

15.0.1

2 years ago

15.0.0-alpha.9

2 years ago

15.0.0-alpha.8

2 years ago

15.0.0-alpha.7

2 years ago

15.0.0-alpha.6

2 years ago

15.0.0-alpha.5

2 years ago

15.0.0-alpha.4

2 years ago

15.0.0-alpha.3

2 years ago

15.0.0-alpha.2

2 years ago

15.0.0-alpha.1

2 years ago

15.0.0-alpha.0

2 years ago

14.2.0

2 years ago