@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
43 lines (42 loc) • 1.47 kB
TypeScript
import { type SegmentedFieldProps as UiSegmentedFieldProps } 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';
/** The base value of a segmented option (§7.2 `segmented`: no booleans). */
export type SegmentedValue = string | number;
export interface FormSegmentedFieldProps extends Omit<UiSegmentedFieldProps, ControlledKeys | 'options'>, CommonFieldProps<SegmentedValue | null> {
options?: readonly FieldOption<SegmentedValue>[];
}
/**
* One of two to five peers, as a segmented control.
*
* @remarks
* It renders kiln-ui's {@link SegmentedField | SegmentedField}.
*
* @example In a schema
* ```json
* {
* "kind": "segmented",
* "name": "journey",
* "label": "Journey",
* "options": [
* {
* "value": "single",
* "label": "Single"
* },
* {
* "value": "return",
* "label": "Return"
* }
* ]
* }
* ```
*
* @value the options' value type, or `null`
* @empty `null`
*
* @privateRemarks
* One choice from 2–5 peers, as a `SegmentedControl` (§7.2 `segmented`). Option values keep
* their primitive type; empty is `null`.
*/
export declare const FormSegmentedField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").OptionContract<SegmentedValue>, FormSegmentedFieldProps>;