UNPKG

@mitcsutt/kiln-forms

Version:

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

48 lines (47 loc) • 1.45 kB
import { FieldView as e } from "../FieldView/FieldView.js"; import { useOptionMapping as t } from "../../../hooks/useOptionMapping.js"; import { accepts as n } from "../../../kit/accepts.js"; import { useFieldBinding as r } from "../../../hooks/useFieldBinding.js"; import { defineOptionField as i } from "../../../kit/contracts.js"; import { jsx as a } from "react/jsx-runtime"; import { ChoiceCardsField as o } from "@mitcsutt/kiln-ui"; //#region src/components/fields/FormChoiceCardsField/FormChoiceCardsField.tsx var s = i()(function({ warn: i, excluded: s, onBlur: c, options: l, optionMeta: u, ...d }) { let f = r({ ...d, warn: i, excluded: s, accepts: n.primitiveOrNull, empty: null }), p = t(l); if (f.mode === "view") return /* @__PURE__ */ a(e, { label: d.label, children: p.labelOf(f.value) }); let m = p.uiOptions.map((e) => { let t = { value: e.value, label: e.label }; e.description !== void 0 && (t.description = e.description), e.disabled !== void 0 && (t.disabled = e.disabled); let n = p.fromUi(e.value); return u && n !== null && (t.meta = u(n)), t; }); return /* @__PURE__ */ a(o, { ...d, ...f.fieldProps, ref: f.ref, type: "single", options: m, value: p.toUi(f.value), onValueChange: (e) => { f.setValue(p.fromUi(e)); }, onBlur: (e) => { c?.(e), f.onBlur(); } }); }); //#endregion export { s as FormChoiceCardsField }; //# sourceMappingURL=FormChoiceCardsField.js.map