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