UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

37 lines (36 loc) • 1.06 kB
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 } from "react/jsx-runtime"; import { NumberField as a, Numeral as o } from "@mitcsutt/kiln-ui"; //#region src/components/fields/FormNumberField/FormNumberField.tsx var s = r()(function({ warn: r, excluded: s, onBlur: c, ...l }) { let u = n({ ...l, warn: r, excluded: s, accepts: t.numberOrNull, empty: null }); return u.mode === "view" ? /* @__PURE__ */ i(e, { label: l.label, children: u.value === null ? void 0 : /* @__PURE__ */ i(o, { value: u.value, format: l.formatOptions, locale: l.locale }) }) : /* @__PURE__ */ i(a, { ...l, ...u.fieldProps, ref: u.ref, value: u.value, onValueChange: u.setValue, onBlur: (e) => { c?.(e), u.onBlur(); } }); }); //#endregion export { s as FormNumberField }; //# sourceMappingURL=FormNumberField.js.map