UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

75 lines (74 loc) 2.25 kB
import { jsx as m } from "react/jsx-runtime"; import { useContext as g } from "react"; import { useIntl as b } from "react-intl"; import { useAsync as h } from "react-use"; import { transformItems as I } 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 O } from "../../context.js"; import "@formio/vanilla-text-mask"; import "formiojs"; import "lodash"; /* empty css */ import k from "../../components/formio/select.js"; import "dompurify"; import "../../components/formio/datagrid.js"; import { checkIsVariableOptions as w, checkIsReferenceListsOptions as C } from "./helpers.js"; const K = ({ component: e }) => { const i = b(), { key: l, label: p, description: f, tooltip: u, validate: n, multiple: d } = e, { required: c = !1 } = n || {}, { getReferenceListsTableItems: v } = g(O), { value: x = [], loading: y, error: t } = h(async () => { var s, o, a; if (w(e)) 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(e.openForms.itemsExpression), code: (r) => /* @__PURE__ */ m("code", { children: r }) }) }]; if (C(e)) { const r = await v(((s = e.openForms) == null ? void 0 : s.service) || "", ((o = e.openForms) == null ? void 0 : o.code) || ""); return r ? I(r, i) : []; } return ((a = e == null ? void 0 : e.data) == null ? void 0 : a.values) || []; }, [e]); if (t) throw t; return /* @__PURE__ */ m(k, { name: l, options: x, label: p, tooltip: u, required: c, description: f, isMulti: !!d, isClearable: !0, isLoading: y }); }; export { K as default };