@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
45 lines (44 loc) • 1.19 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 { jsx as i, jsxs as a } from "react/jsx-runtime";
import { Numeral as o, RangeSliderField as s } from "@mitcsutt/kiln-ui";
//#region src/components/fields/FormRangeField/FormRangeField.tsx
var c = r()(function({ warn: r, excluded: c, onBlur: l, ...u }) {
let d = n({
...u,
warn: r,
excluded: c,
accepts: t.tuple2,
empty: [u.min ?? 0, u.max ?? 0]
});
return d.mode === "view" ? /* @__PURE__ */ a(e, {
label: u.label,
children: [
/* @__PURE__ */ i(o, {
value: d.value[0],
format: u.formatOptions,
locale: u.locale
}),
" – ",
/* @__PURE__ */ i(o, {
value: d.value[1],
format: u.formatOptions,
locale: u.locale
})
]
}) : /* @__PURE__ */ i(s, {
...u,
...d.fieldProps,
ref: d.ref,
value: d.value,
onValueChange: d.setValue,
onBlur: (e) => {
l?.(e), d.onBlur();
}
});
});
//#endregion
export { c as FormRangeField };
//# sourceMappingURL=FormRangeField.js.map