@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
187 lines (186 loc) • 6.92 kB
JavaScript
import { jsxs as a, jsx as t } from "react/jsx-runtime";
import { useFormikContext as h } from "formik";
import { isEqual as b } from "lodash";
import { useLayoutEffect as v, useContext as g } from "react";
import { useIntl as u, FormattedMessage as E } from "react-intl";
import V from "../../components/builder/label.js";
import y from "../../components/builder/description.js";
import C from "../../components/builder/tooltip.js";
import { BuilderContext as S } from "../../context.js";
import { Tabs as T, TabList as F, TabPanel as e } from "../../components/formio/tabs.js";
import "clsx";
import { useErrorChecker as w } from "../../utils/errors.js";
/* empty css */
import "@floating-ui/react";
/* empty css */
import "../../components/formio/textfield.js";
import "../../components/formio/datefield.js";
import "../../components/formio/datetimefield.js";
import "../../components/formio/timefield.js";
/* empty css */
import "react-select";
import { Radio as M } from "../../components/formio/radio.js";
import "dompurify";
import "../../components/formio/textarea.js";
import "../../components/formio/datagrid.js";
/* empty css */
import { LABELS as m } from "../../components/builder/messages.js";
import D, { useDeriveComponentKey as I } from "../../components/builder/key.js";
import x from "../../components/builder/hidden.js";
import L from "../../components/builder/clear-on-hide.js";
import O from "../../components/builder/is-sensitive-data.js";
import P from "../../components/builder/presentation-config.js";
import "../addressNL/index.js";
import "../bsn/index.js";
import "../checkbox/index.js";
import "../children/index.js";
import "../columns/index.js";
import "../content/index.js";
import "../cosignV1/index.js";
import "../cosignV2/index.js";
import "../currency/index.js";
import "../customerProfile/index.js";
import "../date/index.js";
import "../datetime/index.js";
import "../editgrid/index.js";
import "../email/index.js";
import "../fieldset/index.js";
import "../file/index.js";
import "../iban/index.js";
import "../licenseplate/index.js";
import "../map/index.js";
import "../npFamilyMembers/index.js";
import "../number/index.js";
import "../partners/index.js";
import "../phonenumber/index.js";
import "../postcode/index.js";
import "./index.js";
import "../select/index.js";
import "../selectboxes/index.js";
import "../signature/index.js";
import "../softRequiredErrors/index.js";
import "../textarea/index.js";
import "../textfield/index.js";
import "../time/index.js";
import "@ckeditor/ckeditor5-react";
import "../../components/CKEditor.js";
/* empty css */
import R from "../../components/builder/simple-conditional.js";
import k from "../../components/builder/validate/required.js";
import q from "../../components/builder/validate/validator-select.js";
import A, { useManageValidatorsTranslations as H } from "../../components/builder/validate/i18n.js";
import K from "../../components/builder/registration/registration-attribute.js";
import "react-use";
import "../../components/builder/prefill/identifierRole.js";
import { ComponentTranslations as B } from "../../components/builder/i18n.js";
import { Basic as j, Advanced as J, Validation as z, Registration as G, Translations as N } from "../../components/builder/tabs.js";
import { ValuesConfig as Q } from "../../components/builder/values/values-config.js";
/* empty css */
import { ValuesTranslations as U } from "../../components/builder/values/i18n.js";
import { checkIsManualOptions as W } from "./helpers.js";
const X = () => {
const o = u(), [s, n] = I(), {
values: r,
setFieldValue: f
} = h(), {
hasAnyError: i
} = w(), {
openForms: {
dataSrc: p
},
defaultValue: d
} = r;
H(["required"]);
const l = W(r), c = l ? r.values || [] : [];
return v(() => {
p !== "variable" || b(d, {}) || f("defaultValue", "");
}, [p]), /* @__PURE__ */ a(T, { children: [
/* @__PURE__ */ a(F, { children: [
/* @__PURE__ */ t(j, { hasErrors: i("label", "key", "description", "tooltip", "showInSummary", "showInEmail", "showInPDF", "hidden", "clearOnHide", "isSensitiveData", "openForms.dataSrc", "openForms.itemsExpression", "values", "defaultValue") }),
/* @__PURE__ */ t(J, { hasErrors: i("conditional") }),
/* @__PURE__ */ t(z, { hasErrors: i("validate") }),
/* @__PURE__ */ t(G, { hasErrors: i("registration") }),
/* @__PURE__ */ t(N, { hasErrors: i("openForms.translations") })
] }),
/* @__PURE__ */ a(e, { children: [
/* @__PURE__ */ t(V, {}),
/* @__PURE__ */ t(D, { isManuallySetRef: s, generatedValue: n }),
/* @__PURE__ */ t(y, {}),
/* @__PURE__ */ t(C, {}),
/* @__PURE__ */ t(P, {}),
/* @__PURE__ */ t(x, {}),
/* @__PURE__ */ t(L, {}),
/* @__PURE__ */ t(O, {}),
/* @__PURE__ */ t(Q, { name: "values", withOptionDescription: !0 }),
l && /* @__PURE__ */ t(Y, { options: c })
] }),
/* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(R, {}) }),
/* @__PURE__ */ a(e, { children: [
/* @__PURE__ */ t(k, {}),
/* @__PURE__ */ t(q, {}),
/* @__PURE__ */ t(A, {})
] }),
/* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(K, {}) }),
/* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(B, { propertyLabels: {
label: o.formatMessage(m.label),
description: o.formatMessage(m.description),
tooltip: o.formatMessage(m.tooltip)
}, children: /* @__PURE__ */ t(U, { name: "values", withOptionDescription: !0 }) }) })
] });
};
X.defaultValues = {
// basic tab
label: "",
key: "",
description: "",
tooltip: "",
showInSummary: !0,
showInEmail: !1,
showInPDF: !0,
hidden: !1,
clearOnHide: !0,
isSensitiveData: !1,
openForms: {
dataSrc: "manual",
translations: {}
},
values: [{
value: "",
label: ""
}],
// TODO: check that the initial values are set based on component.values
// TODO: at some point we can allow an itemsExpression for this too
defaultValue: "",
// Advanced tab
conditional: {
show: void 0,
when: "",
eq: ""
},
// Validation tab
validate: {
required: !1,
plugins: []
},
translatedErrors: {},
registration: {
attribute: ""
}
};
const Y = ({
options: o
}) => {
const s = u(), {
formType: n
} = g(S), r = s.formatMessage({
id: "FffJxu",
defaultMessage: [{
type: 0,
value: "This will be the initial value for this field before user interaction."
}]
});
return n === "appointment" ? null : /* @__PURE__ */ t(M, { name: "defaultValue", options: o, label: /* @__PURE__ */ t(E, { ...m.defaultValue }), tooltip: r, isClearable: !0 });
};
export {
X as default
};