@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
56 lines (55 loc) • 1.55 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 { formatDate as a } from "../internal/formatTemporal.js";
import { jsx as o } from "react/jsx-runtime";
import { DateField as s, TextField as c } from "@mitcsutt/kiln-ui";
//#region src/components/fields/FormDateField/FormDateField.tsx
var l = r()(function({ warn: r, excluded: l, onBlur: u, picker: d = "native", isDateDisabled: f, firstDayOfWeek: p, locale: m, timeZone: h, clearable: g, labels: _, ...v }) {
let y = n({
...v,
warn: r,
excluded: l,
accepts: t.string,
empty: ""
});
if (y.mode === "view") return /* @__PURE__ */ o(e, {
label: v.label,
children: a(y.value, m)
});
let b = y.value ?? "";
return d === "native" ? /* @__PURE__ */ o(c, {
...v,
...y.fieldProps,
type: "date",
ref: y.ref,
value: b,
onValueChange: y.setValue,
onBlur: (e) => {
u?.(e), y.onBlur();
}
}) : /* @__PURE__ */ o(s, {
...i(v),
...y.fieldProps,
ref: y.ref,
value: b,
onValueChange: y.setValue,
min: v.min,
max: v.max,
isDateDisabled: f,
firstDayOfWeek: p,
locale: m,
timeZone: h,
clearable: g,
labels: _,
calendar: d === "calendar",
onBlur: (e) => {
u?.(e), y.onBlur();
}
});
});
//#endregion
export { l as FormDateField };
//# sourceMappingURL=FormDateField.js.map