UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

78 lines (77 loc) 2.56 kB
import { jsx as e, jsxs as f } from "react/jsx-runtime"; import { useField as c } from "formik"; import { isEqual as g } from "lodash"; import { useContext as n, useEffect as b } from "react"; import { useIntl as C, FormattedMessage as m, defineMessage as M } from "react-intl"; import { BuilderContext as p } from "../../../context.js"; import { Tabs as T, TabList as v, Tab as E, TabPanel as y } from "../../formio/tabs.js"; import "clsx"; /* empty css */ import "@floating-ui/react"; /* empty css */ import { TextFieldMultiple as h } from "../../formio/textfield.js"; import L from "../../formio/panel.js"; import "react-select"; import "dompurify"; import "../../formio/datagrid.js"; import { DataMap as x } from "../../formio/datamap.js"; function W(r, s = "") { const i = `${s}${s ? "." : ""}translatedErrors`, { supportedLanguageCodes: t } = n(p), [{ value: o }, , { setValue: u }] = c(i); b(() => { const l = o ? { ...o } : Object.fromEntries(t.map((a) => [a, {}])), d = Object.fromEntries(r.map((a) => [a, ""])); for (const a of t) l[a] = { ...d, ...l[a] }; g(l, o) || u(l); }, [r, o]); } const z = () => { const r = C(), { supportedLanguageCodes: s } = n(p), i = r.formatMessage({ id: "D5DCv0", defaultMessage: [{ type: 0, value: "Custom error messages for this component and their translations" }] }); return /* @__PURE__ */ e(L, { title: /* @__PURE__ */ e(m, { id: "ve3rsH", defaultMessage: [{ type: 0, value: "Custom error messages" }] }), tooltip: i, collapsible: !0, initialCollapsed: !0, children: /* @__PURE__ */ f(T, { children: [ /* @__PURE__ */ e(v, { children: s.map((t) => /* @__PURE__ */ e(E, { children: t.toUpperCase() }, t)) }), s.map((t) => /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(x, { name: `translatedErrors.${t}`, keyLabel: /* @__PURE__ */ e(m, { id: "OlPsaw", defaultMessage: [{ type: 0, value: "Error code" }] }), ariaLabelMessage: M({ id: "hEVgKd", defaultMessage: [{ type: 0, value: 'Error message for "' }, { type: 1, value: "key" }, { type: 0, value: '"' }] }), valueComponent: /* @__PURE__ */ e(h, { name: "message", label: /* @__PURE__ */ e(m, { id: "k9tAyW", defaultMessage: [{ type: 0, value: "Error message" }] }) }) }) }, t)) ] }) }); }; export { z as default, W as useManageValidatorsTranslations };