import type { FormControlValidator } from '../../../forms/form/form.types.js'; import type { MessageTarget } from '../../../forms/validation/message-routing.js'; import type { FilterCompositionStore } from './filterCompositionStore.types.js'; /** * Registration descriptor for a custom control. * @internal */ export interface RegisterFilterCompositionField { /** Unique key for this control's slot in `state.custom`. */ id: string; /** Initial value, seeded into `state.custom` on mount if absent. */ defaultValue: T; /** * Per-field validators, run as part of the internal Form's apply-gating. * * @remarks When neither `validators` nor `focus` is provided the hook skips * form registration entirely. This is the correct pattern when the underlying * control is a Strato form component at the same `id` (e.g. `ToggleButtonGroup` * with `required`): the Strato control then owns its form slot exclusively and * its native validation is not silently overwritten. */ validators?: FormControlValidator[]; /** * Focuses the control when it is the first invalid field on apply * (focus-first-invalid). * * @remarks Omit when the control has genuinely nothing focusable, or when the * underlying control is a Strato form component at the same `id` (see * `validators` remarks). Without a focus callback an invalid field is silently * skipped during focus-first-invalid — only acceptable in those two cases. */ focus?: () => void; /** * Whether a change to this control's value re-applies immediately, once the * composition has already applied successfully at least once — the same * semantics as the built-in Timeframe / Segment auto-apply. * * @remarks Leave this at its `false` default for the common case: a control * that edits the `FilterField` (e.g. a facet calling * `store.filterField.addFilter(...)`) lands its change in a draft the user * reviews before pressing Apply. Set it only for a control whose value feeds * the query directly — e.g. a `ToggleButtonGroup` switching a mode — where * there is no draft to review, so waiting for Apply would be wrong. */ autoApply?: boolean; /** * Where `validators`' errors render. Defaults to `'field'` — the nearest * local `FormFieldMessages`, matching an ordinary form field. Pass `'form'` * for a control in the composition's top row (alongside `FilterField` / * `TimeframeSelector` / `SegmentSelector`) to promote its errors to the * composition's form-wide message outlet instead, the same placement those * built-in slots use. */ messageTarget?: MessageTarget | MessageTarget[]; } /** * Registers a custom control's value into the composition store, and its * validation into the internal Form, in one call. Works inside or outside the * `` subtree (pass an explicit `store` for the latter). * * When no store resolves, registration and every write are skipped and `value` * stays at `defaultValue`, so the control renders instead of crashing its host. * * @remarks Pass `focus` so the control can be reached by focus-first-invalid; * see {@link _RegisterFilterCompositionField.focus}. * * @internal */ export declare function useRegisterFilterComposition(field: RegisterFilterCompositionField, store?: FilterCompositionStore): { value: T; setValue: (value: T) => void; }; //# sourceMappingURL=useRegisterFilterComposition.d.ts.map