UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

52 lines (51 loc) 1.5 kB
import { jsxs as a, jsx as r, Fragment as p } from "react/jsx-runtime"; import h from "clsx"; import { useFormikContext as x, Field as d } from "formik"; import { useValidationErrors as k } from "../../utils/errors.js"; import b from "./component.js"; import n from "./description.js"; import u from "./tooltip.js"; const F = ({ name: e, label: s, onChange: o, optionDescription: t, disabled: c = !1 }) => { const { getFieldProps: i } = x(), { onChange: l } = i(e), { hasErrors: m } = k(e); return /* @__PURE__ */ a(p, { children: [ /* @__PURE__ */ r(d, { name: e, as: "input", type: "checkbox", className: h("form-check-input", { "is-invalid": m }), onChange: (f) => { l(f), o == null || o(f); }, disabled: c }), /* @__PURE__ */ r("span", { children: s }), t && /* @__PURE__ */ r(n, { text: t }) ] }); }, I = ({ name: e, label: s, required: o = !1, tooltip: t = "", description: c = "", onChange: i, optionDescription: l, disabled: m = !1 }) => /* @__PURE__ */ a(b, { field: e, required: o, type: "checkbox", children: [ /* @__PURE__ */ r("div", { className: "form-check checkbox", children: /* @__PURE__ */ a("label", { className: "form-check-label", children: [ /* @__PURE__ */ r(F, { name: e, label: s, onChange: i, optionDescription: l, disabled: m }), t && " ", /* @__PURE__ */ r(u, { text: t }) ] }) }), c && /* @__PURE__ */ r(n, { text: c }) ] }); export { F as CheckboxInput, I as default };