UNPKG

pagamio-frontend-commons-lib

Version:

Pagamio library for Frontend reusable components like the form engine and table container

53 lines (52 loc) 1.65 kB
import React from 'react'; import { type SelectOption } from '../../form-engine'; /** * Props for FilterList component */ interface FilterListProps<T extends SelectOption = SelectOption> { /** Array of options to display in the list */ options: T[]; /** Selected value for single-select mode */ selectedValue?: string; /** Array of selected values for multi-select mode */ selectedValues?: string[]; /** Input name attribute for radio buttons (required for single-select) */ name?: string; /** Whether the list allows multiple selections */ isMultiSelect?: boolean; /** Handler function called when a selection changes */ onChange: (value: string) => void; /** Prefix for input IDs to ensure uniqueness */ idPrefix: string; /** ItemsPerPage, the options list is paginated */ itemsPerPage?: number; } /** * FilterList component for displaying filterable, searchable lists of options * Supports both single-select (radio buttons) and multi-select (checkboxes) * Generic type T extends SelectOption to allow for custom option types * * @example * ```tsx * // Single-select mode * <FilterList * options={categoryOptions} * selectedValue={filters.categoryId} * name="category" * onChange={handleCategoryChange} * idPrefix="category" * /> * * // Multi-select mode * <FilterList * options={locationOptions} * selectedValues={filters.locations} * isMultiSelect={true} * onChange={handleLocationChange} * idPrefix="location" * /> * ``` */ declare const FilterList: React.FC<FilterListProps>; export default FilterList; export type { FilterListProps };