UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

51 lines (50 loc) • 2.14 kB
import { type ComboboxFieldMultipleProps as UiComboboxFieldMultipleProps } from '@mitcsutt/kiln-ui'; import type { ControlledKeys } from '../internal/controlledKeys.js'; import { type CommonFieldProps } from '../../../hooks/useFieldBinding.js'; import { type FieldOption } from '../../../kit/contracts.js'; import { type OptionsLoader } from '../../../hooks/useOptions.js'; /** The base value of a multi-select option (§7.2 `multiSelect`: no booleans). */ export type MultiSelectValue = string | number; export interface FormMultiSelectFieldProps extends Omit<UiComboboxFieldMultipleProps, ControlledKeys | 'options' | 'multiple' | 'creatable' | 'inputValue' | 'defaultInputValue'>, CommonFieldProps<readonly MultiSelectValue[]> { options?: readonly FieldOption<MultiSelectValue>[]; /** * Async search. Pairs with `reloadOn`/`minQueryLength`; implies `filter="none"`. * * @privateRemarks Design reference §7.4. */ loadOptions?: OptionsLoader<MultiSelectValue>; /** Sibling field paths whose values reload (and re-key the cache of) `loadOptions`. */ reloadOn?: readonly string[]; minQueryLength?: number; } /** * A searchable multiple choice, a combobox whose chosen values become removable chips. * * @remarks * It renders kiln-ui's {@link ComboboxField | ComboboxField} with `multiple`. * * @example In a schema * ```json * { * "kind": "multiSelect", * "name": "stops", * "label": "Favourite stops", * "maxSelected": 3, * "options": [ * { * "value": "harbour", * "label": "Harbour Square" * } * ] * } * ``` * * @value an array of the options' value type * @empty `[]` * * @privateRemarks * A searchable multiple choice (§7.2 `multiSelect`): the ui combobox in `multiple` mode, chosen * values shown as removable chips. Static `options` or async `loadOptions` (`useOptions`); not * `creatable` (free text is single-choice only). Empty is `[]`. */ export declare const FormMultiSelectField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").OptionsContract<MultiSelectValue>, FormMultiSelectFieldProps>;