UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

44 lines (43 loc) 1.13 kB
import { jsx as s, jsxs as f } from "react/jsx-runtime"; import { useField as y } from "formik"; import k from "react"; import { useIntl as v } from "react-intl"; import { DataGrid as x, DataGridRow as b } from "./datagrid.js"; import { TextFieldMultiple as g } from "./textfield.js"; const G = ({ name: t, valueComponent: r, ariaLabelMessage: l, keyLabel: n = "Key" }) => { const p = v(), [{ value: o }, , { setValue: u }] = y(t), i = Object.entries(o).map(([e, a]) => ({ key: e, value: a })), c = [n, r.props.label]; return /* @__PURE__ */ s(x, { name: t, columns: c, type: "datagrid", children: i.map((e, a) => /* @__PURE__ */ f(b, { index: a, children: [ /* @__PURE__ */ s(g, { name: "key", readOnly: !0, value: e.key }), k.cloneElement(r, { ...r.props, label: "", value: e.value, onChange: (d) => { const m = { ...o, [e.key]: d.target.value }; u(m); }, "aria-label": l ? p.formatMessage(l, { key: e.key }) : void 0 }) ] }, e.key)) }); }; export { G as DataMap, G as default };