@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
38 lines (37 loc) • 1.07 kB
JavaScript
import { getFormRuntime as e } from "../../../runtime/formRuntime.js";
import { FieldView as t } from "../FieldView/FieldView.js";
import { accepts as n } from "../../../kit/accepts.js";
import { useFieldBinding as r } from "../../../hooks/useFieldBinding.js";
import { defineField as i } from "../../../kit/contracts.js";
import { jsx as a } from "react/jsx-runtime";
import { SwitchField as o } from "@mitcsutt/kiln-ui";
//#region src/components/fields/FormSwitchField/FormSwitchField.tsx
var s = i()(function({ warn: i, excluded: s, onBlur: c, ...l }) {
let u = r({
...l,
warn: i,
excluded: s,
accepts: n.boolean,
empty: !1
});
if (u.mode === "view") {
let n = e(u.api.form).options.messages;
return /* @__PURE__ */ a(t, {
label: l.label,
children: u.value ? n.yes : n.no
});
}
return /* @__PURE__ */ a(o, {
...l,
...u.fieldProps,
ref: u.ref,
checked: u.value,
onCheckedChange: u.setValue,
onBlur: (e) => {
c?.(e), u.onBlur();
}
});
});
//#endregion
export { s as FormSwitchField };
//# sourceMappingURL=FormSwitchField.js.map