UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

75 lines (74 loc) 2.23 kB
import { jsx as a } from "react/jsx-runtime"; import { useContext as v } from "react"; import { useIntl as y } from "react-intl"; import { useAsync as g } from "react-use"; import { transformItems as h } from "../../components/builder/values/reference-lists/utils.js"; import "../../components/formio/tabs.js"; import "clsx"; import "formik"; /* empty css */ import "@floating-ui/react"; /* empty css */ import { BuilderContext as I } from "../../context.js"; import "@formio/vanilla-text-mask"; import "formiojs"; import "lodash"; /* empty css */ import "react-select"; import { SelectBoxes as O } from "../../components/formio/selectboxes.js"; import "dompurify"; import "../../components/formio/datagrid.js"; import { checkIsVariableOptions as b, checkIsReferenceListsOptions as k } from "./helpers.js"; const H = ({ component: r }) => { const i = y(), { key: m, label: p, description: l, tooltip: f, validate: u } = r, { required: d = !1 } = u || {}, { getReferenceListsTableItems: x } = v(I), { value: c = [], loading: n, error: s } = g(async () => { var t, o; if (b(r)) return [{ value: "itemsExpression", label: i.formatMessage({ id: "paY2Oa", defaultMessage: [{ type: 0, value: "Options from expression: " }, { type: 8, value: "code", children: [{ type: 1, value: "expression" }] }] }, { expression: JSON.stringify(r.openForms.itemsExpression), code: (e) => /* @__PURE__ */ a("code", { children: e }) }) }]; if (k(r)) { const e = await x(((t = r == null ? void 0 : r.openForms) == null ? void 0 : t.service) || "", ((o = r == null ? void 0 : r.openForms) == null ? void 0 : o.code) || ""); return e ? h(e, i) : []; } return r.values || []; }, [r]); if (s) throw s; return /* @__PURE__ */ a(O, { name: m, options: c, label: p, tooltip: f, required: d, description: l, isLoading: n }); }; export { H as default };