UNPKG

@mitcsutt/kiln-forms

Version:

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

49 lines (48 loc) • 2.38 kB
import { type DateFieldProps as UiDateFieldProps, type TextFieldProps as UiTextFieldProps } from '@mitcsutt/kiln-ui'; import type { ControlledKeys } from '../internal/controlledKeys.js'; import { type CommonFieldProps } from '../../../hooks/useFieldBinding.js'; export interface FormDateFieldProps extends Omit<UiTextFieldProps, ControlledKeys | 'type' | 'min' | 'max' | 'inputMode' | 'showCount' | 'maxLength'>, Pick<UiDateFieldProps, 'isDateDisabled' | 'firstDayOfWeek' | 'locale' | 'timeZone' | 'clearable' | 'labels'>, CommonFieldProps<string> { /** Earliest value, ISO (YYYY-MM-DD). */ min?: string; /** Latest value, ISO (YYYY-MM-DD). */ max?: string; /** * `native`: the platform's own date input. `calendar`: kiln-ui's * {@link DateField | DateField}, typed part by part in the locale's order with a calendar to * pick from. `segmented`: the same typed parts without the calendar. The value is the same ISO * date whichever you choose. `isDateDisabled`, `firstDayOfWeek`, `locale`, `timeZone`, * `clearable` and `labels` apply to `calendar` and `segmented` only, and the text input's own * props (`placeholder`, `leading`, `autoComplete`) to `native` only. */ picker?: 'native' | 'calendar' | 'segmented'; } /** * A date bound to an ISO date string: the platform's date input, or kiln-ui's typed date with a * calendar. * * @remarks * By default it renders kiln-ui's {@link TextField | TextField} with `type="date"`, so the * platform's own date picker does the work. `picker="calendar"` swaps in kiln-ui's * {@link DateField | DateField} instead: the same theme in every browser, the parts in the * locale's order, and days outside `min`/`max` or ruled out by `isDateDisabled` that can't be * picked. * * @example In a schema * ```json * { * "kind": "date", * "name": "travelDate", * "label": "Travel date", * "min": "2026-10-01", * "picker": "calendar" * } * ``` * * @value `string` (`YYYY-MM-DD`) * @empty `''` * * @privateRemarks * A native date input bound to an ISO `YYYY-MM-DD` 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 FormDateField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").ExactContract<string>, FormDateFieldProps>;