Usage
Memoizes a PowerSearch configuration built from typed field definitions and returns it along with an applyFilters function for client-side filtering. Automatically maps field types (string, number, boolean, date, enum, etc.) to their canonical operators and provides an efficient predicate evaluator to filter datasets.
tsimport {usePowerSearchConfig} from '@astryxdesign/core/PowerSearch'
Best practices
| Guidance | Practices |
|---|---|
| Do | Declare field definitions as const outside the component or memoize them so usePowerSearchConfig only recalculates when needed. |
| Do | Pass the returned config to PowerSearch and use applyFilters to compute the filtered data rows for a Table or List. |
| Don't | Recreate field definitions inline on every render without as const or memoization. |
Parameters
| Param | Type | Description |
|---|---|---|
definitionsrequired | ReadonlyArray<> | Typed field definitions (key, type, label, enumValues) used to build PowerSearch fields and operators. |
configName | string | Optional name for the PowerSearchConfig object (defaults to "PowerSearchConfig"). |
Returns
| Field | Type | Description |
|---|---|---|
| config | Memoized PowerSearch configuration object with fields and type-appropriate operators. | |
| applyFilters | <T extends <D>>(filters: ReadonlyArray<>, data: ReadonlyArray<T>) => T[] | Client-side filtering helper that filters a dataset using the active PowerSearch filter rules. |
Examples
Common configurations, variations, and states.A people directory with a PowerSearch bar over a Table: typed field definitions feed usePowerSearchConfig, returning the search config and an applyFilters helper that updates Table rows.
Use with shadcn
Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.
This install URL expires with the draft preview.bashnpx shadcn@4.19.0 add https://astryx-l64m0m99l-fbopensource.vercel.app/shadcn/hooks/use-power-search-config.json