@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
76 lines (75 loc) • 2.58 kB
JavaScript
import { jsxs as y, jsx as t } from "react/jsx-runtime";
import { useFormikContext as C } from "formik";
import { Utils as g } from "formiojs";
import { useContext as u, useEffect as v } from "react";
import { FormattedMessage as r } from "react-intl";
import { usePrevious as x } from "react-use";
import { TextField as b } from "../formio/textfield.js";
import { BuilderContext as f } from "../../context.js";
import { getRegistryEntry as F } from "../../registry/index.js";
import { hasOwnProperty as w } from "../../types/index.js";
import "../formio/tabs.js";
import "clsx";
/* empty css */
import "@floating-ui/react";
/* empty css */
import M from "../formio/panel.js";
import q from "../formio/select.js";
import "dompurify";
import "../formio/datagrid.js";
import L from "./component-select.js";
const S = () => {
var a;
const {
getFormComponents: i
} = u(f), {
values: o,
setFieldValue: l
} = C(), m = (a = o == null ? void 0 : o.conditional) == null ? void 0 : a.when, n = m ? g.getComponent(i(), m, !1) : null, p = x(m);
if (v(() => {
const e = o == null ? void 0 : o.conditional;
if ((e == null ? void 0 : e.when) === "" && (e == null ? void 0 : e.eq) !== "") {
l("conditional.eq", "");
return;
}
p !== void 0 && p !== (e == null ? void 0 : e.when) && l("conditional.eq", "");
}, [o, l]), !n) return null;
const c = F(n), {
comparisonValue: d
} = c, h = d || b, s = {
name: "conditional.eq",
label: /* @__PURE__ */ t(r, { id: "6F2H6H", defaultMessage: [{
type: 0,
value: "Has the value"
}] })
};
return w(n, "multiple") && (s.multiple = n.multiple), /* @__PURE__ */ t(h, { ...s });
}, Q = () => {
const {
formType: i
} = u(f);
return i === "appointment" ? null : /* @__PURE__ */ y(M, { title: /* @__PURE__ */ t(r, { id: "ALLoNx", defaultMessage: [{
type: 0,
value: "Simple conditional"
}] }), children: [
/* @__PURE__ */ t(q, { name: "conditional.show", label: /* @__PURE__ */ t(r, { id: "3LdlNv", defaultMessage: [{
type: 0,
value: "This component should display"
}] }), options: [{
value: !0,
label: "True"
}, {
value: !1,
label: "False"
}], isClearable: !0 }),
/* @__PURE__ */ t(L, { name: "conditional.when", label: /* @__PURE__ */ t(r, { id: "ddDLRu", defaultMessage: [{
type: 0,
value: "When the form component"
}] }), isClearable: !0 }),
/* @__PURE__ */ t(S, {})
] });
};
export {
S as ComparisonValueInput,
Q as default
};