UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

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