usePowerSearchConfig@astryxdesign/core v0.7.12 · usePowerSearchConfig

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.

ts
import {usePowerSearchConfig} from '@astryxdesign/core/PowerSearch'

Best practices

GuidancePractices
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

ParamTypeDescription
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

FieldTypeDescription
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.
usePowerSearchConfig — Filtered Directory Table
Open in Playground

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.
bash
npx shadcn@4.19.0 add https://astryx-l64m0m99l-fbopensource.vercel.app/shadcn/hooks/use-power-search-config.json