UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

60 lines (59 loc) 1.7 kB
import { jsx as l } from "react/jsx-runtime"; import { useFormikContext as m } from "formik"; import { debounce as d, camelCase as y } from "lodash"; import { useRef as g, useEffect as C, useContext as c } from "react"; import { FormattedMessage as F } from "react-intl"; import { BuilderContext as p } from "../../context.js"; import "../formio/tabs.js"; import "clsx"; /* empty css */ import "@floating-ui/react"; /* empty css */ import { TextFieldMultiple as x } from "../formio/textfield.js"; /* empty css */ import "react-select"; import "dompurify"; import "../formio/datagrid.js"; const K = (e) => { const { uniquifyKey: r } = c(p), t = e.title || e.label || e.placeholder || e.type; return r(y(t)); }, H = () => { const { values: e, status: r = {}, setFieldValue: t } = m(), o = g(!1), s = d(t, 50), { isNew: n = !1 } = r, u = e.key, i = K(e); return C(() => { if (!(!n || i === u)) return o.current || (s.cancel(), s("key", i)), () => { s.cancel(); }; }, [t, n, o, i, u]), [o, i]; }, O = ({ isManuallySetRef: e, generatedValue: r }) => { const { setFieldValue: t, getFieldProps: o } = m(), { formType: s } = c(p), n = "key", u = o(n); return /* @__PURE__ */ l(x, { name: n, label: /* @__PURE__ */ l(F, { id: "+0eHh2", defaultMessage: [{ type: 0, value: "Property Name" }] }), onChange: (a) => { const { value: f } = a.target; f ? (e.current = !0, u.onChange(a)) : (t("key", r), e.current = !1); }, required: !0, readOnly: s === "appointment" }); }; export { O as default, H as useDeriveComponentKey };