UNPKG

@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) • 2.13 kB
import { type TextFieldProps as UiTextFieldProps, type TimeFieldProps as UiTimeFieldProps } from '@mitcsutt/kiln-ui'; import type { ControlledKeys } from '../internal/controlledKeys.js'; import { type CommonFieldProps } from '../../../hooks/useFieldBinding.js'; export interface FormTimeFieldProps extends Omit<UiTextFieldProps, ControlledKeys | 'type' | 'min' | 'max' | 'inputMode' | 'showCount' | 'maxLength'>, Pick<UiTimeFieldProps, 'granularity' | 'hourCycle' | 'locale' | 'clearable' | 'labels'>, CommonFieldProps<string> { /** Earliest value, ISO (HH:mm). */ min?: string; /** Latest value, ISO (HH:mm). */ max?: string; /** * `native`: the platform's own time input. `segmented`: kiln-ui's * {@link TimeField | TimeField}, the hour and minute typed part by part on the locale's 12- or * 24-hour clock. The value is the same 24-hour ISO time whichever you choose. `granularity`, * `hourCycle`, `locale`, `clearable` and `labels` apply to `segmented` only, and the text * input's own props (`step`, `placeholder`, `leading`) to `native` only. */ picker?: 'native' | 'segmented'; } /** * A time bound to an ISO time string: the platform's time input, or kiln-ui's typed time. * * @remarks * By default it renders kiln-ui's {@link TextField | TextField} with `type="time"`. * `picker="segmented"` swaps in kiln-ui's {@link TimeField | TimeField}: the same theme in every * browser, with `hourCycle` to choose the 12- or 24-hour clock. The value stays on the 24-hour * clock either way. * * @example In a schema * ```json * { * "kind": "time", * "name": "departs", * "label": "Departs", * "picker": "segmented", * "hourCycle": 12 * } * ``` * * @value `string` (`HH:mm`) * @empty `''` * * @privateRemarks * A native time input bound to an ISO `HH:mm` string (§7.2). Empty is `''`. The picker is * opt-in (Appendix A.6), so a field without `picker` renders exactly as before. */ export declare const FormTimeField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").ExactContract<string>, FormTimeFieldProps>;