@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
50 lines (49 loc) • 2.68 kB
TypeScript
import { type DateTimeFieldProps as UiDateTimeFieldProps, type TextFieldProps as UiTextFieldProps } from '@mitcsutt/kiln-ui';
import type { ControlledKeys } from '../internal/controlledKeys.js';
import { type CommonFieldProps } from '../../../hooks/useFieldBinding.js';
export interface FormDateTimeFieldProps extends Omit<UiTextFieldProps, ControlledKeys | 'type' | 'min' | 'max' | 'inputMode' | 'showCount' | 'maxLength'>, Pick<UiDateTimeFieldProps, 'granularity' | 'hourCycle' | 'isDateDisabled' | 'firstDayOfWeek' | 'locale' | 'clearable' | 'labels'>, CommonFieldProps<string> {
/** Earliest value, ISO (YYYY-MM-DDTHH:mm). */
min?: string;
/** Latest value, ISO (YYYY-MM-DDTHH:mm). */
max?: string;
/**
* `native`: the platform's own `datetime-local` input. `calendar`: kiln-ui's
* {@link DateTimeField | DateTimeField}, the date and time typed part by part in the locale's
* order with a calendar to pick the day from. `segmented`: the same typed parts without the
* calendar. The value is the same wall-clock ISO date-time whichever you choose.
* `granularity`, `hourCycle`, `isDateDisabled`, `firstDayOfWeek`, `locale`, `clearable` and
* `labels` apply to `calendar` and `segmented` only, and the text input's own props (`step`,
* `placeholder`, `leading`) to `native` only.
*/
picker?: 'native' | 'calendar' | 'segmented';
}
/**
* A date and time bound to an ISO string: the platform's date-time input, or kiln-ui's typed date
* and time with a calendar.
*
* @remarks
* By default it renders kiln-ui's {@link TextField | TextField} with `type="datetime-local"`.
* `picker="calendar"` swaps in kiln-ui's {@link DateTimeField | DateTimeField}: the same theme in
* every browser, the parts in the locale's order and on its clock, and a calendar for the day.
* Either way the value is a wall-clock time with no zone, like `datetime-local`'s.
*
* @example In a schema
* ```json
* {
* "kind": "dateTime",
* "name": "pickup",
* "label": "Pick-up time",
* "picker": "calendar"
* }
* ```
*
* @value `string` (`YYYY-MM-DDTHH:mm`)
* @empty `''`
*
* @privateRemarks
* A native `datetime-local` input bound to an ISO `YYYY-MM-DDTHH:mm` string (§7.2). Empty is
* `''`. The picker is opt-in (Appendix A.6), so a field without `picker` renders exactly as
* before. ui `DateTimeField`'s `timeZone` isn't offered: it turns the value into a UTC instant,
* which this field's value contract and view mode don't describe.
*/
export declare const FormDateTimeField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").ExactContract<string>, FormDateTimeFieldProps>;