@luscii-healthtech/web-ui 7.1.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CategorisedFilters, FilterGenerator, TransformedSortingOption } from "./FilterBarProps.type";
|
|
2
|
+
/**
|
|
3
|
+
* Generates the list of filters based on the data (see this as what you'd like to be filtered in your component).
|
|
4
|
+
*
|
|
5
|
+
* @param dataToGenerateFiltersFrom - The data (list of entities) that will be used to create the filters.
|
|
6
|
+
* @param groupers a list of functions used to create the filters dropdown
|
|
7
|
+
* @returns {CategorisedFilters} a list of filters properly grouped.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getFilterGroups<T extends unknown[]>(dataToGenerateFiltersFrom: T, groupers: FilterGenerator<T[number]>[]): CategorisedFilters;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param filterKey the key of the categorized filter (eg. color, size, brand) - which one of them are you gonna check.
|
|
13
|
+
* @param categorizedFilters the array of categorized filters the FilterBar component needs
|
|
14
|
+
* @param attributeGetter the getter to retrieve the attribute to be filtered on, this allow maximum flexibility on how to process
|
|
15
|
+
* filters on any level of nesting if necessary.
|
|
16
|
+
* @returns a predicate to be used in the filter function
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* const sizeFilterPredicate = createFilterPredicate<TShirtFromApi>("size", filtersOptions, (item) => item.meta.size);
|
|
20
|
+
* const filteredBySize = items.filter(sizeFilterPredicate);
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const createFilterPredicate: <T extends object>(filterKey: keyof T, categorizedFilters: CategorisedFilters, attributeGetter: (item: T) => string) => (item: T) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a sorting function to be used on a specific object attribute.
|
|
26
|
+
*
|
|
27
|
+
* @param getter the getter function to retrieve the attribute used in the sorting
|
|
28
|
+
* @param order if ascending or descending
|
|
29
|
+
* @returns the sorting comparer function to be used in Array.sort
|
|
30
|
+
*/
|
|
31
|
+
export declare const createSortingComparer: <T extends object>(getter: (item: T) => string | number, order?: "asc" | "desc") => (itemA: T, itemB: T) => number;
|
|
32
|
+
export declare const applySorting: <T extends object[]>(sortable: T, sortingOptions: TransformedSortingOption[]) => T;
|