UNPKG

@mitcsutt/kiln-forms

Version:

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

47 lines (46 loc) • 964 B
import { fieldContext as e } from "./contexts.js"; import { useMemo as t } from "react"; import { getBy as n, useSelector as r } from "@tanstack/react-form"; import { jsx as i } from "react/jsx-runtime"; //#region src/kit/viewField.tsx var a = () => void 0, o = Object.freeze({ errorMap: {}, errorSourceMap: {}, errors: [], isTouched: !1, isBlurred: !1, isDirty: !1, isPristine: !0, isValid: !0, isValidating: !1, isDefaultValue: !0 }); function s({ form: s, name: c, extend: l, children: u }) { let d = r(s.store, (e) => n(e.values, c)), f = t(() => ({ ...l, form: s, name: c, options: { name: c }, state: { value: d, meta: o }, handleChange: a, handleBlur: a, setValue: a, getValue: () => d, getMeta: () => o }), [ s, c, d, l ]); return /* @__PURE__ */ i(e.Provider, { value: f, children: typeof u == "function" ? u(f) : u }); } //#endregion export { s as ViewField }; //# sourceMappingURL=viewField.js.map