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