UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

58 lines (57 loc) 2.15 kB
import { jsxs as p, Fragment as n, jsx as t } from "react/jsx-runtime"; import { useFormikContext as m, getIn as l } from "formik"; import { useContext as f, useLayoutEffect as u } from "react"; import { BuilderContext as F } from "../../../context.js"; import { ItemsExpression as d } from "./items-expression.js"; import y from "./reference-lists/service.js"; import { ReferenceListsTableCode as v } from "./reference-lists/code.js"; import { ValuesSrc as b } from "./values-src.js"; import O from "./values-table.js"; function g({ name: r, withOptionDescription: a }) { const { formType: c } = f(F), { values: o, setFieldValue: e } = m(), { dataSrc: s } = o.openForms; return u(() => { switch (s) { case "manual": { Object.prototype.hasOwnProperty.call(o.openForms, "itemsExpression") && e("openForms.itemsExpression", void 0), Object.prototype.hasOwnProperty.call(o.openForms, "code") && e("openForms.code", void 0), Object.prototype.hasOwnProperty.call(o.openForms, "service") && e("openForms.service", void 0); const i = l(o, r); (!i || Array.isArray(i) && i.length === 0) && e(r, [{ value: "", label: "", openForms: { translations: {} } }]); break; } case "variable": { e(r, []), Object.prototype.hasOwnProperty.call(o.openForms, "code") && e("openForms.code", void 0), Object.prototype.hasOwnProperty.call(o.openForms, "service") && e("openForms.service", void 0); break; } case "referenceLists": { e(r, []), Object.prototype.hasOwnProperty.call(o.openForms, "itemsExpression") && e("openForms.itemsExpression", void 0); break; } } }, [s]), c === "appointment" ? null : /* @__PURE__ */ p(n, { children: [ /* @__PURE__ */ t(b, {}), s === "manual" && /* @__PURE__ */ t(O, { name: r, withOptionDescription: a }), s === "variable" && /* @__PURE__ */ t(d, {}), s === "referenceLists" && /* @__PURE__ */ p(n, { children: [ /* @__PURE__ */ t(y, {}), /* @__PURE__ */ t(v, {}) ] }) ] }); } export { g as ValuesConfig };