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