@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
46 lines (45 loc) • 1.66 kB
TypeScript
import { type SelectFieldProps as UiSelectFieldProps } from '@mitcsutt/kiln-ui';
import type { ControlledKeys } from '../internal/controlledKeys.js';
import { type CommonFieldProps } from '../../../hooks/useFieldBinding.js';
import { type FieldOption, type Primitive } from '../../../kit/contracts.js';
export interface FormSelectFieldProps extends Omit<UiSelectFieldProps, ControlledKeys | 'options' | 'groups'>, CommonFieldProps<Primitive | null> {
/** Typed to the bound path's own value type in the typed shorthand. `group` → headed groups. */
options?: readonly FieldOption[];
/** Label of a first "no selection" row that sets the value to `null`. */
emptyOption?: string;
}
/**
* One choice from a dropdown. Option values keep their type, numbers and booleans come back as
* numbers and booleans.
*
* @remarks
* It renders kiln-ui's {@link SelectField | SelectField}.
*
* @example In a schema
* ```json
* {
* "kind": "select",
* "name": "pass",
* "label": "Pass",
* "placeholder": "Choose a pass",
* "options": [
* {
* "value": "week",
* "label": "Week"
* },
* {
* "value": "month",
* "label": "Month"
* }
* ]
* }
* ```
*
* @value the options' value type, or `null`
* @empty `null`
*
* @privateRemarks
* A single-choice dropdown (§7.2 `select`). Option values keep their primitive type (numbers and
* booleans round-trip through the string-only ui control, §7.3); empty is `null`.
*/
export declare const FormSelectField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").OptionContract<Primitive>, FormSelectFieldProps>;