@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
194 lines (193 loc) • 7.16 kB
JavaScript
import { jsxs as a, jsx as e } 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 o } from "../../components/formio/tabs.js";
import "clsx";
import { useErrorChecker as I } from "../../utils/errors.js";
/* empty css */
import "@floating-ui/react";
/* empty css */
import "@formio/vanilla-text-mask";
import "formiojs";
import k from "../../components/formio/checkbox.js";
import "lodash";
/* empty css */
import x from "../../components/formio/select.js";
import "dompurify";
import "../../components/formio/datagrid.js";
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 "@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";
/* 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: t,
setValues: l
} = M(), {
hasAnyError: i
} = I(), {
formType: m
} = y(C), u = m === "appointment";
return Z(["required"]), v(() => {
var c, g;
const b = t.defaultZoom || (t == null ? void 0 : t.initialCenter) || ((c = t == null ? void 0 : t.initialCenter) == null ? void 0 : c.lat) || ((g = t == null ? void 0 : t.initialCenter) == null ? void 0 : g.lng);
t.useConfigDefaultMapSettings && b && l({
...t,
defaultZoom: void 0,
initialCenter: void 0
});
}), /* @__PURE__ */ a(D, { children: [
/* @__PURE__ */ a(w, { children: [
/* @__PURE__ */ e(U, { hasErrors: i("label", "key", "description", "tooltip", "showInSummary", "showInEmail", "showInPDF", "hidden", "clearOnHide", "isSensitiveData") }),
/* @__PURE__ */ e(W, { hasErrors: i("conditional") }),
/* @__PURE__ */ e(X, { hasErrors: i("validate") }),
/* @__PURE__ */ e(h, { hasErrors: i("useConfigDefaultMapSettings", "defaultZoom", "initialCenter", "interactions"), hidden: u, children: /* @__PURE__ */ e(p, { id: "wJ7Yha", defaultMessage: [{
type: 0,
value: "Map settings"
}] }) }),
/* @__PURE__ */ e(h, { hasErrors: i("tileLayerIdentifier", "overlays"), hidden: u, children: /* @__PURE__ */ e(p, { id: "0eRdLf", defaultMessage: [{
type: 0,
value: "Layers"
}] }) }),
/* @__PURE__ */ e(J, { hasErrors: i("registration") }),
/* @__PURE__ */ e(Y, { hasErrors: i("openForms.translations") })
] }),
/* @__PURE__ */ a(o, { children: [
/* @__PURE__ */ e(T, {}),
/* @__PURE__ */ e(A, { isManuallySetRef: n, generatedValue: s }),
/* @__PURE__ */ e(E, {}),
/* @__PURE__ */ e(L, {}),
/* @__PURE__ */ e(R, {}),
/* @__PURE__ */ e(V, {}),
/* @__PURE__ */ e(O, {}),
/* @__PURE__ */ e(P, {})
] }),
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(B, {}) }),
/* @__PURE__ */ a(o, { children: [
/* @__PURE__ */ e(H, {}),
/* @__PURE__ */ e(K, {}),
/* @__PURE__ */ e(q, {})
] }),
/* @__PURE__ */ a(o, { children: [
/* @__PURE__ */ e(G, {}),
/* @__PURE__ */ e($, {}),
!t.useConfigDefaultMapSettings && /* @__PURE__ */ e(N, {})
] }),
/* @__PURE__ */ a(o, { children: [
/* @__PURE__ */ e(ee, {}),
/* @__PURE__ */ e(Q, {})
] }),
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(z, {}) }),
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(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__ */ e(k, { name: "useConfigDefaultMapSettings", label: /* @__PURE__ */ e(p, { id: "z7HXSS", defaultMessage: [{
type: 0,
value: "Use globally configured map component settings"
}] }), tooltip: n });
}, ee = () => {
const {
getMapTileLayers: r
} = y(C), n = f(), {
value: s,
loading: t,
error: l
} = S(async () => await r(), []);
if (l)
throw l;
const i = 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__ */ e(x, { name: "tileLayerIdentifier", label: /* @__PURE__ */ e(p, { id: "fB4Vug", defaultMessage: [{
type: 0,
value: "Background"
}] }), isClearable: !0, tooltip: i, isLoading: t, options: s == null ? void 0 : s.map((m) => ({
label: m.label,
value: m.identifier
})) });
};
export {
_ as default
};