UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

44 lines (43 loc) 1.12 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 { TextField as g } from "./textfield.js"; const G = ({ name: t, valueComponent: r, ariaLabelMessage: o, keyLabel: n = "Key" }) => { const p = v(), [{ value: l }, , { setValue: u }] = y(t), c = Object.entries(l).map(([e, a]) => ({ key: e, value: a })), d = [n, r.props.label]; return /* @__PURE__ */ s(x, { name: t, columns: d, type: "datagrid", children: c.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: (i) => { const m = { ...l, [e.key]: i.target.value }; u(m); }, "aria-label": o ? p.formatMessage(o, { key: e.key }) : void 0 }) ] }, e.key)) }); }; export { G as DataMap, G as default };