@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
83 lines (82 loc) • 2.75 kB
JavaScript
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 "../../formio/datefield.js";
import "../../formio/datetimefield.js";
import "../../formio/timefield.js";
import L from "../../formio/panel.js";
import "react-select";
import "dompurify";
import "../../formio/textarea.js";
import "../../formio/datagrid.js";
import { DataMap as x } from "../../formio/datamap.js";
/* empty css */
function R(o, r = "") {
const l = `${r}${r ? "." : ""}translatedErrors`, {
supportedLanguageCodes: t
} = n(p), [{
value: s
}, , {
setValue: u
}] = c(l);
b(() => {
const i = s ? {
...s
} : Object.fromEntries(t.map((a) => [a, {}])), d = Object.fromEntries(o.map((a) => [a, ""]));
for (const a of t)
i[a] = {
...d,
...i[a]
};
g(i, s) || u(i);
}, [o, s]);
}
const S = () => {
const o = C(), {
supportedLanguageCodes: r
} = n(p), l = o.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: l, collapsible: !0, initialCollapsed: !0, children: /* @__PURE__ */ f(T, { children: [
/* @__PURE__ */ e(v, { children: r.map((t) => /* @__PURE__ */ e(E, { children: t.toUpperCase() }, t)) }),
r.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 {
S as default,
R as useManageValidatorsTranslations
};