import type { ReactElement } from "react"; import { type CategorizedFilters, type FilterBarLocalization, type HasSingleSelection, type TransformedPresetFilterOptions, type TransformedSortingOptions } from "./FilterBarProps.type"; type FilterBarProps = { /** * A list of grouped filters to be displayed in the FilterBar. * * This is an array with items shaped as: * ```ts * type CategorizedFilter = { * key: string; * label: string; * options: TransformedFilterOptions; * } * ``` * * You can choose to manually create this option or use the `getFilterGroups` helper function that will do the same * for you based on your data. * * @example * * If you decided to use the `getFilterGroups` function: * * * ```ts * const items = []; // any list of object you are working with * * // the list of filter generators, the `filterValuePredicate` will be the displayed * // value in the filter dropdown, so you can map and transform it to any custom string if necessary, or use * // the value from the object entry * * const filterGenerators: FilterGenerator[] = [ * { * id: "brand", * label: "Brand", * filterValuePredicate: (tshirt) => tshirt.brand, * }, * { * id: "size", * label: "Size", * filterValuePredicate: (tshirt) => tshirt.size, * }, * { * id: "color", * label: "Color", * filterValuePredicate: (tshirt) => tshirt.color, * }, * ]; * * const categorizedFilters = getFilterGroups(items, filterGenerators); * ``` * * * A compliant entry in the `categorizedFilters` has a shape like the object below: * * * ```json * { * "key": "color", * "label": "Color", * "options": [ * { * "isChecked": false, * "id": "yellow", * "label": "yellow", * "value": "yellow" * }, * { * "isChecked": false, * "id": "red", * "label": "red", * "value": "red" * }, * { * "isChecked": false, * "id": "green", * "label": "green", * "value": "green" * } * ] * } *``` */ categorizedFilters: CategorizedFilters; /** * Whether to hide the active filters section when no filters are applied. * Works by checking if any of the filters have an `isChecked` value set to `true`. * * This defaults to `true`. */ hideActiveFiltersWhenEmpty?: boolean; /** * For more details, see {@link TransformedSortingOptions}. */ onFilterChange: (updatedFilters: CategorizedFilters) => void; sortingOptions: TransformedSortingOptions; onSortingChange?: (updatedSortingOptions: TransformedSortingOptions) => void; presetFilterOptions?: TransformedPresetFilterOptions; onPresetFilterChange?: (updatedPresetFilterOptions: TransformedPresetFilterOptions) => void; /** * See {@link FilterBarLocalization}. */ localization: FilterBarLocalization; /** * Quick way to change the order of the preset filters and sorting options. * * @default ["presetFilters", "divider", "sorting"] */ menuOrder?: ["presetFilters", "divider", "sorting"] | ["sorting", "divider", "presetFilters"]; } & HasSingleSelection; export declare const FilterBar: ({ localization, categorizedFilters, sortingOptions, presetFilterOptions, hideActiveFiltersWhenEmpty, menuOrder, ...props }: FilterBarProps) => ReactElement | null; export {};