UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

48 lines (47 loc) • 2.5 kB
import { type DateRangePickerFieldProps as UiDateRangePickerFieldProps, type DateRangeValue } from '@mitcsutt/kiln-ui'; import type { ControlledKeys } from '../internal/controlledKeys.js'; import { type CommonFieldProps } from '../../../hooks/useFieldBinding.js'; export interface FormDateRangeFieldProps extends Omit<UiDateRangePickerFieldProps, ControlledKeys>, CommonFieldProps<DateRangeValue> { /** * `native`: kiln-ui's {@link DateRangeField | DateRangeField}, two native date inputs and the * platform's own picker. `calendar`: kiln-ui's {@link DateRangePickerField | DateRangePickerField}, * two typed date inputs and one calendar for the whole range, which also takes `granularity`, * `presets`, `clearable`, `isDateDisabled`, `firstDayOfWeek`, `locale`, `timeZone`, `hourCycle` * and `labels`. * * @defaultValue `'calendar'` when `presets` or a time `granularity` is set, otherwise `'native'` */ picker?: 'native' | 'calendar'; } /** * Two ISO dates bound to a `{ start, end }` path. * * @remarks * It renders kiln-ui's {@link DateRangeField | DateRangeField}: two native date inputs by default. * `picker="calendar"` renders {@link DateRangePickerField | DateRangePickerField} instead, which * types each end part by part and opens one two-month calendar for the whole range, `presets` lists ranges such as "Last 7 days" beside it, and `granularity="minute"` gives * each end a time. Either of the last two turns the calendar on by itself. * * @example In a schema * ```json * { * "kind": "dateRange", * "name": "trip", * "label": "Travel dates", * "startLabel": "First day", * "endLabel": "Last day", * "picker": "calendar" * } * ``` * * @value `{ start: string; end: string }` * @empty `{ start: '', end: '' }` * * @privateRemarks * Two ISO dates bound to a `{ start, end }` path (§7.2 `dateRange`). Empty is `{ start: '', end: * '' }`. View mode formats each side with `formatDate` (or, for an end with a time, * `formatDateTimeIn` on the field's `timeZone`), in its `locale` and `hourCycle`, and joins them with an en dash. `picker` * chooses between ui DateRangeField and DateRangePickerField, and every other ui prop passes * straight through; the native field doesn't get the picker's own props (Appendix A.6). */ export declare const FormDateRangeField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").ExactContract<DateRangeValue>, FormDateRangeFieldProps>;