UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

263 lines (262 loc) 9.38 kB
import { jsxs as i, jsx as e, Fragment as v } from "react/jsx-runtime"; import { Tabs as M, TabList as C, TabPanel as l, Tab as T } from "../../components/formio/tabs.js"; import "clsx"; import { useErrorChecker as E } from "../../utils/errors.js"; /* empty css */ import "@floating-ui/react"; import { useContext as m } from "react"; /* empty css */ import { TextFieldMultiple as y } from "../../components/formio/textfield.js"; import D from "../../components/formio/checkbox.js"; import "formik"; import { BuilderContext as d } from "../../context.js"; import { useIntl as g, FormattedMessage as r, defineMessage as F } from "react-intl"; import h from "../../components/formio/panel.js"; import x from "../../components/formio/select.js"; import "dompurify"; import "../../components/formio/datagrid.js"; import { DataMap as S } from "../../components/formio/datamap.js"; import w from "../../components/builder/label.js"; import I from "../../components/builder/description.js"; import L from "../../components/builder/tooltip.js"; import { LABELS as f } from "../../components/builder/messages.js"; import V, { useDeriveComponentKey as A } from "../../components/builder/key.js"; import k from "../../components/builder/hidden.js"; import P from "../../components/builder/clear-on-hide.js"; import R from "../../components/builder/is-sensitive-data.js"; import K from "../../components/builder/presentation-config.js"; import "formiojs"; import "@ckeditor/ckeditor5-react"; import "../../components/CKEditor.js"; /* empty css */ import q from "../../components/builder/simple-conditional.js"; import O from "../../components/builder/validate/required.js"; import $ from "../../components/builder/validate/validator-select.js"; import H, { useManageValidatorsTranslations as c } from "../../components/builder/validate/i18n.js"; import W 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 G, Validation as Q, Registration as U, Translations as Y } from "../../components/builder/tabs.js"; import "@open-formulieren/monaco-json-editor"; import "../../components/builder/values/values-src.js"; import "lodash"; /* empty css */ const b = ({ prefix: t, component: a, label: s, tooltip: o, placeholder: u }) => { const { supportedLanguageCodes: p } = m(d); return /* @__PURE__ */ i(v, { children: [ /* @__PURE__ */ e(y, { name: `${t}.${a}.validate.pattern`, label: s, tooltip: o, placeholder: u }), /* @__PURE__ */ i(M, { children: [ /* @__PURE__ */ e(C, { children: p.map((n) => /* @__PURE__ */ e(T, { children: n.toUpperCase() }, n)) }), p.map((n) => /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(S, { name: `${t}.${a}.translatedErrors.${n}`, keyLabel: /* @__PURE__ */ e(r, { id: "OlPsaw", defaultMessage: [{ type: 0, value: "Error code" }] }), ariaLabelMessage: F({ id: "hEVgKd", defaultMessage: [{ type: 0, value: 'Error message for "' }, { type: 1, value: "key" }, { type: 0, value: '"' }] }), valueComponent: /* @__PURE__ */ e(y, { name: "message", label: /* @__PURE__ */ e(r, { id: "k9tAyW", defaultMessage: [{ type: 0, value: "Error message" }] }) }) }) }, n)) ] }) ] }); }, Z = () => { const t = g(), { formType: a } = m(d), s = t.formatMessage({ id: "2sbkGI", defaultMessage: [{ type: 0, value: "When enabled, the street name and city are derived from the entered postcode and house number." }] }); return a === "appointment" ? null : /* @__PURE__ */ e(D, { name: "deriveAddress", label: /* @__PURE__ */ e(r, { id: "toTZ0C", defaultMessage: [{ type: 0, value: "Derive address" }] }), tooltip: s }); }, J = () => { const t = g(), { formType: a } = m(d), s = t.formatMessage({ id: "GsAN0n", defaultMessage: [{ type: 0, value: "Single column" }] }), o = t.formatMessage({ id: "T2dCIS", defaultMessage: [{ type: 0, value: "Double column" }] }); return a === "appointment" ? null : /* @__PURE__ */ e(x, { name: "layout", label: /* @__PURE__ */ e(r, { id: "Tw9+0D", defaultMessage: [{ type: 0, value: "Layout" }] }), options: [{ value: "singleColumn", label: s }, { value: "doubleColumn", label: o }], isClearable: !0 }); }, N = () => { const t = g(), [a, s] = A(), { hasAnyError: o } = E(), { formType: u } = m(d), p = u === "appointment"; return c(["required"]), c(["pattern"], "openForms.components.postcode"), c(["pattern"], "openForms.components.city"), /* @__PURE__ */ i(M, { children: [ /* @__PURE__ */ i(C, { children: [ /* @__PURE__ */ e(j, { hasErrors: o("label", "key", "description", "tooltip", "hidden", "clearOnHide", "isSensitiveData", "showInSummary", "showInEmail", "showInPDF") }), /* @__PURE__ */ e(G, { hasErrors: o("conditional") }), /* @__PURE__ */ e(Q, { hasErrors: o("validate") }), /* @__PURE__ */ e(U, { hasErrors: o("registration") }), /* @__PURE__ */ e(Y, { hasErrors: o("openForms.translations") }) ] }), /* @__PURE__ */ i(l, { children: [ /* @__PURE__ */ e(w, {}), /* @__PURE__ */ e(V, { isManuallySetRef: a, generatedValue: s }), /* @__PURE__ */ e(I, {}), /* @__PURE__ */ e(L, {}), /* @__PURE__ */ e(K, {}), /* @__PURE__ */ e(J, {}), /* @__PURE__ */ e(Z, {}), /* @__PURE__ */ e(k, {}), /* @__PURE__ */ e(P, {}), /* @__PURE__ */ e(R, {}) ] }), /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(q, {}) }), /* @__PURE__ */ i(l, { children: [ /* @__PURE__ */ e(O, {}), /* @__PURE__ */ e($, {}), /* @__PURE__ */ e(H, {}), !p && /* @__PURE__ */ i(v, { children: [ /* @__PURE__ */ e(h, { title: /* @__PURE__ */ e(r, { id: "rW1edF", defaultMessage: [{ type: 0, value: "Postcode" }] }), tooltip: t.formatMessage({ id: "0FD2pY", defaultMessage: [{ type: 0, value: "Validation for the postcode field" }] }), collapsible: !0, initialCollapsed: !0, children: /* @__PURE__ */ e(b, { prefix: "openForms.components", component: "postcode", label: /* @__PURE__ */ e(r, { id: "4DrI94", defaultMessage: [{ type: 0, value: "Regular expression for postcode" }] }), tooltip: t.formatMessage({ id: "WxwqZJ", defaultMessage: [{ type: 0, value: "The regular expression pattern test that the postcode field value must pass before the form can be submitted." }] }), placeholder: t.formatMessage({ id: "dD9O3Q", defaultMessage: [{ type: 0, value: "Regular expression for postcode" }] }) }) }), /* @__PURE__ */ e(h, { title: /* @__PURE__ */ e(r, { id: "fhVFUY", defaultMessage: [{ type: 0, value: "City" }] }), tooltip: t.formatMessage({ id: "mck25o", defaultMessage: [{ type: 0, value: "Validation for the city field" }] }), collapsible: !0, initialCollapsed: !0, children: /* @__PURE__ */ e(b, { prefix: "openForms.components", component: "city", label: /* @__PURE__ */ e(r, { id: "swKpQE", defaultMessage: [{ type: 0, value: "Regular expression for city" }] }), tooltip: t.formatMessage({ id: "osl4X2", defaultMessage: [{ type: 0, value: "The regular expression pattern test that the city field value must pass before the form can be submitted." }] }), placeholder: t.formatMessage({ id: "0D+m56", defaultMessage: [{ type: 0, value: "Regular expression for city" }] }) }) }) ] }) ] }), /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(W, {}) }), /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(B, { propertyLabels: { label: t.formatMessage(f.label), description: t.formatMessage(f.description), tooltip: t.formatMessage(f.tooltip) } }) }) ] }); }; N.defaultValues = { // basic tab label: "", key: "", description: "", tooltip: "", showInSummary: !0, showInEmail: !1, showInPDF: !0, hidden: !1, clearOnHide: !0, isSensitiveData: !0, deriveAddress: !1, layout: "doubleColumn", // Advanced tab conditional: { show: void 0, when: "", eq: "" }, // Validation tab validate: { required: !1, plugins: [] }, translatedErrors: {}, registration: { attribute: "" }, openForms: { translations: {}, components: { postcode: { validate: { pattern: "" }, translatedErrors: {} }, city: { validate: { pattern: "" }, translatedErrors: {} } } } }; export { b as SubcomponentValidation, N as default };