@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
47 lines (46 loc) • 2 kB
TypeScript
import { type ComboboxFieldSingleProps as UiComboboxFieldSingleProps } 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 combobox option (§7.2 `combobox`: no booleans — free text is a string). */
export type ComboboxValue = string | number;
export interface FormComboboxFieldProps extends Omit<UiComboboxFieldSingleProps, ControlledKeys | 'options' | 'multiple' | 'inputValue' | 'defaultInputValue'>, CommonFieldProps<ComboboxValue | null> {
options?: readonly FieldOption<ComboboxValue>[];
/**
* Async search. Pairs with `reloadOn`/`minQueryLength`; implies `filter="none"`.
*
* @privateRemarks Design reference §7.4.
*/
loadOptions?: OptionsLoader<ComboboxValue>;
/** Sibling field paths whose values reload (and re-key the cache of) `loadOptions`. */
reloadOn?: readonly string[];
minQueryLength?: number;
}
/**
* A searchable single choice, from fixed `options` or loaded as you type.
*
* @remarks
* It renders kiln-ui's {@link ComboboxField | ComboboxField}.
*
* @example In a schema
* ```json
* {
* "kind": "combobox",
* "name": "stop",
* "label": "Stop",
* "optionsFrom": {
* "loader": "stops"
* }
* }
* ```
*
* @value the options' value type, or `null`
* @empty `null`
*
* @privateRemarks
* A searchable single choice (§7.2 `combobox`). Static `options` or async `loadOptions` (debounced,
* cached, aborts a superseded request — `useOptions`). `creatable` allows free text; the typed
* value becomes the field value (kept as a string). Empty is `null`.
*/
export declare const FormComboboxField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").OptionContract<ComboboxValue>, FormComboboxFieldProps>;