UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

230 lines (229 loc) 8.38 kB
import { jsxs as a, jsx as t } from "react/jsx-runtime"; import { useFormikContext as M } from "formik"; import { useContext as y, useEffect as v } from "react"; import { useIntl as f, FormattedMessage as p } from "react-intl"; import { useAsync as S } from "react-use"; import T from "../../components/builder/label.js"; import E from "../../components/builder/description.js"; import L from "../../components/builder/tooltip.js"; import { BuilderContext as C } from "../../context.js"; import { Tabs as D, TabList as w, Tab as h, TabPanel as e } from "../../components/formio/tabs.js"; import "clsx"; import { useErrorChecker as I } from "../../utils/errors.js"; /* empty css */ import "@floating-ui/react"; /* empty css */ import "../../components/formio/textfield.js"; import k from "../../components/formio/checkbox.js"; import "../../components/formio/datefield.js"; import "../../components/formio/datetimefield.js"; import "../../components/formio/timefield.js"; /* empty css */ import x from "../../components/formio/select.js"; import "dompurify"; import "../../components/formio/textarea.js"; import "../../components/formio/datagrid.js"; /* empty css */ import { LABELS as d } from "../../components/builder/messages.js"; import A, { useDeriveComponentKey as F } from "../../components/builder/key.js"; import V from "../../components/builder/hidden.js"; import O from "../../components/builder/clear-on-hide.js"; import P from "../../components/builder/is-sensitive-data.js"; import R 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 "./index.js"; import "../npFamilyMembers/index.js"; import "../number/index.js"; import "../partners/index.js"; import "../phonenumber/index.js"; import "../postcode/index.js"; import "../radio/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 B from "../../components/builder/simple-conditional.js"; import H from "../../components/builder/validate/required.js"; import K from "../../components/builder/validate/validator-select.js"; import q, { useManageValidatorsTranslations as Z } from "../../components/builder/validate/i18n.js"; import z from "../../components/builder/registration/registration-attribute.js"; import "../../components/builder/prefill/identifierRole.js"; import { ComponentTranslations as j } from "../../components/builder/i18n.js"; import { Basic as U, Advanced as W, Validation as X, Registration as J, 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 */ import G from "./interaction-configuration.js"; import N from "./map-configuration.js"; import Q from "./overlays.js"; const _ = () => { const r = f(), [n, s] = F(), { values: i, setValues: m } = M(), { hasAnyError: o } = I(), { formType: l } = y(C), u = l === "appointment"; return Z(["required"]), v(() => { var c, g; const b = i.defaultZoom || (i == null ? void 0 : i.initialCenter) || ((c = i == null ? void 0 : i.initialCenter) == null ? void 0 : c.lat) || ((g = i == null ? void 0 : i.initialCenter) == null ? void 0 : g.lng); i.useConfigDefaultMapSettings && b && m({ ...i, defaultZoom: void 0, initialCenter: void 0 }); }), /* @__PURE__ */ a(D, { children: [ /* @__PURE__ */ a(w, { children: [ /* @__PURE__ */ t(U, { hasErrors: o("label", "key", "description", "tooltip", "showInSummary", "showInEmail", "showInPDF", "hidden", "clearOnHide", "isSensitiveData") }), /* @__PURE__ */ t(W, { hasErrors: o("conditional") }), /* @__PURE__ */ t(X, { hasErrors: o("validate") }), /* @__PURE__ */ t(h, { hasErrors: o("useConfigDefaultMapSettings", "defaultZoom", "initialCenter", "interactions"), hidden: u, children: /* @__PURE__ */ t(p, { id: "wJ7Yha", defaultMessage: [{ type: 0, value: "Map settings" }] }) }), /* @__PURE__ */ t(h, { hasErrors: o("tileLayerIdentifier", "overlays"), hidden: u, children: /* @__PURE__ */ t(p, { id: "0eRdLf", defaultMessage: [{ type: 0, value: "Layers" }] }) }), /* @__PURE__ */ t(J, { hasErrors: o("registration") }), /* @__PURE__ */ t(Y, { hasErrors: o("openForms.translations") }) ] }), /* @__PURE__ */ a(e, { children: [ /* @__PURE__ */ t(T, {}), /* @__PURE__ */ t(A, { isManuallySetRef: n, generatedValue: s }), /* @__PURE__ */ t(E, {}), /* @__PURE__ */ t(L, {}), /* @__PURE__ */ t(R, {}), /* @__PURE__ */ t(V, {}), /* @__PURE__ */ t(O, {}), /* @__PURE__ */ t(P, {}) ] }), /* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(B, {}) }), /* @__PURE__ */ a(e, { children: [ /* @__PURE__ */ t(H, {}), /* @__PURE__ */ t(K, {}), /* @__PURE__ */ t(q, {}) ] }), /* @__PURE__ */ a(e, { children: [ /* @__PURE__ */ t(G, {}), /* @__PURE__ */ t($, {}), !i.useConfigDefaultMapSettings && /* @__PURE__ */ t(N, {}) ] }), /* @__PURE__ */ a(e, { children: [ /* @__PURE__ */ t(tt, {}), /* @__PURE__ */ t(Q, {}) ] }), /* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(z, {}) }), /* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(j, { propertyLabels: { label: r.formatMessage(d.label), description: r.formatMessage(d.description), tooltip: r.formatMessage(d.tooltip) } }) }) ] }); }; _.defaultValues = { // basic tab label: "", key: "", description: "", tooltip: "", showInSummary: !0, showInEmail: !1, showInPDF: !0, hidden: !1, clearOnHide: !0, isSensitiveData: !0, useConfigDefaultMapSettings: !1, defaultZoom: void 0, initialCenter: { lat: void 0, lng: void 0 }, tileLayerIdentifier: void 0, interactions: { polygon: !1, polyline: !1, marker: !0 }, // Advanced tab conditional: { show: void 0, when: "", eq: "" }, // Validation tab validate: { required: !1, plugins: [] }, translatedErrors: {}, // registration tab registration: { attribute: "" } }; const $ = () => { const n = f().formatMessage({ id: "oXOxWz", defaultMessage: [{ type: 0, value: "When this is checked, the map component settings configured in the global configuration will be used." }] }); return /* @__PURE__ */ t(k, { name: "useConfigDefaultMapSettings", label: /* @__PURE__ */ t(p, { id: "z7HXSS", defaultMessage: [{ type: 0, value: "Use globally configured map component settings" }] }), tooltip: n }); }, tt = () => { const { getMapTileLayers: r } = y(C), n = f(), { value: s, loading: i, error: m } = S(async () => await r(), []); if (m) throw m; const o = n.formatMessage({ id: "AAKF9b", defaultMessage: [{ type: 0, value: "Optionally specify an alternative background layer for the map component. This affects the map style at particular coordinates and zoom levels." }] }); return /* @__PURE__ */ t(x, { name: "tileLayerIdentifier", label: /* @__PURE__ */ t(p, { id: "fB4Vug", defaultMessage: [{ type: 0, value: "Background" }] }), isClearable: !0, tooltip: o, isLoading: i, options: s == null ? void 0 : s.map((l) => ({ label: l.label, value: l.identifier })) }); }; export { _ as default };