@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
28 lines (27 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const formik_1 = require("formik");
const formiojs_1 = require("formiojs");
const react_1 = require("react");
const context_1 = require("../../context");
const formio_1 = require("../formio");
function ComponentSelect(props) {
const { getFormComponents } = (0, react_1.useContext)(context_1.BuilderContext);
const { values } = (0, formik_1.useFormikContext)();
// Get all the components in the form from Formio
const options = props.options || [];
if (!props.options) {
formiojs_1.Utils.eachComponent(getFormComponents(), (component, path) => {
// FIXME: calculate path of the component properly instead of just using the key
if (('id' in values && component.id === values.id) || path === values.key)
return;
options.push({
value: path,
label: `${component.label || component.key} (${path})`,
});
});
}
return (0, jsx_runtime_1.jsx)(formio_1.Select, Object.assign({}, props, { valueProperty: "value", options: options }));
}
exports.default = ComponentSelect;