npm.io
1.1.0 • Published 3 years ago

pg-filters

Licence
ISC
Version
1.1.0
Deps
1
Size
42 kB
Vulns
0
Weekly
0

pg-filters

Functions

searchData

Filters data by using a single search string and matching its value with all the filters. Only uses Textand Number filters.

Parameter Type Usage
data any[] List of objects that need to be filtered.
filters Filter[] List of filters that will be used to filter data.
search string What the user entered in the search box.
filterData

Filters data by using the filters.

Parameter Type Usage
data any[] List of objects that need to be filtered.
filters Filter[] List of filters that will be used to filter data.
getActiveFilters

Returns all the filters that have a value.

Parameter Type Usage
filters Filter[] Filters to be evaluated.
resetFilters

Resets the value of the filters to their original state.

Parameter Type Usage
filters Filter[] Filters to be reset.
restoreFiltersFromStorage

Restores filters from a JSON storage, converting each field to its original state.

Parameter Type Usage
storage string JSON storage.

Filter Object

Field Usage Required
field Must match the field name inside the filtered object. ✓
label Used to show the filter's name to the user.
inputType Specifies the type of input that the user will interact with. Available types are Text, Number, Dropdown, MultiSelect, Calendar, CalendarRange and Checkbox ✓
filterType Specifies the method that will be used to filter.
value Used to compare values with the filtered object. User input goes there.
options Used to populate a filter with options. Should only be used with Dropdown and MultiSelect.
empty Sets the empty value to be matched with when filtering using Dropdown and MultiSelect.
category Used to group fields together in a form.

Filter Types

Input Type Associated Filter Types Default
Number, Calendar Less, LessOrEqual, Equal, GreaterOrEqual, Greater. Equal
Checkbox True, False. True