UNPKG

@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.48 kB
import { type ChipGroupFieldProps as UiChipGroupFieldProps } 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 chips option (§7.2 `chips`: no booleans). */ export type ChipsValue = string | number; type UiMultipleProps = Extract<UiChipGroupFieldProps, { type: 'multiple'; }>; export interface FormChipsFieldProps extends Omit<UiMultipleProps, ControlledKeys | 'options' | 'type'>, CommonFieldProps<readonly ChipsValue[]> { options?: readonly FieldOption<ChipsValue>[]; } /** * Any number of choices from a row of chips. * * @remarks * It renders kiln-ui's {@link ChipGroupField | ChipGroupField} with `type="multiple"`. * * @example In a schema * ```json * { * "kind": "chips", * "name": "days", * "label": "Days you travel", * "options": [ * { * "value": "mon", * "label": "Mon" * } * ] * } * ``` * * @value an array of the options' value type * @empty `[]` * * @privateRemarks * Any number of choices from a row of chips (§7.2 `chips`, ui `type="multiple"`). Option values * keep their primitive type; empty is `[]`. */ export declare const FormChipsField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").OptionsContract<ChipsValue>, FormChipsFieldProps>; export {};