@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
75 lines (74 loc) • 2.2 kB
JavaScript
import { jsx as a } from "react/jsx-runtime";
import { useContext as x } 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 { Radio as O } from "../../components/formio/radio.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: n
} = r, {
required: u = !1
} = n || {}, {
getReferenceListsTableItems: d
} = x(I), {
value: c = [],
loading: v,
error: t
} = g(async () => {
var s, 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 d(((s = r.openForms) == null ? void 0 : s.service) || "", ((o = r.openForms) == null ? void 0 : o.code) || "");
return e ? h(e, i) : [];
}
return (r == null ? void 0 : r.values) || [];
}, [r]);
if (t)
throw t;
return /* @__PURE__ */ a(O, { name: m, options: c, label: p, tooltip: f, required: u, description: l, isLoading: v });
};
export {
H as default
};