@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
57 lines (56 loc) • 1.63 kB
JavaScript
import { FieldView as e } from "../FieldView/FieldView.js";
import { accepts as t } from "../../../kit/accepts.js";
import { useFieldBinding as n } from "../../../hooks/useFieldBinding.js";
import { defineField as r } from "../../../kit/contracts.js";
import { pickerFieldProps as i } from "../internal/pickerProps.js";
import { formatDateTime as a } from "../internal/formatTemporal.js";
import { jsx as o } from "react/jsx-runtime";
import { DateTimeField as s, TextField as c } from "@mitcsutt/kiln-ui";
//#region src/components/fields/FormDateTimeField/FormDateTimeField.tsx
var l = r()(function({ warn: r, excluded: l, onBlur: u, picker: d = "native", granularity: f, hourCycle: p, isDateDisabled: m, firstDayOfWeek: h, locale: g, clearable: _, labels: v, ...y }) {
let b = n({
...y,
warn: r,
excluded: l,
accepts: t.string,
empty: ""
});
if (b.mode === "view") return /* @__PURE__ */ o(e, {
label: y.label,
children: a(b.value, g, p)
});
let x = b.value ?? "";
return d === "native" ? /* @__PURE__ */ o(c, {
...y,
...b.fieldProps,
type: "datetime-local",
ref: b.ref,
value: x,
onValueChange: b.setValue,
onBlur: (e) => {
u?.(e), b.onBlur();
}
}) : /* @__PURE__ */ o(s, {
...i(y),
...b.fieldProps,
ref: b.ref,
value: x,
onValueChange: b.setValue,
min: y.min,
max: y.max,
granularity: f,
hourCycle: p,
isDateDisabled: m,
firstDayOfWeek: h,
locale: g,
clearable: _,
labels: v,
calendar: d === "calendar",
onBlur: (e) => {
u?.(e), b.onBlur();
}
});
});
//#endregion
export { l as FormDateTimeField };
//# sourceMappingURL=FormDateTimeField.js.map