UNPKG

@tomino/dynamic-form-semantic-ui

Version:

Semantic UI form renderer based on dynamic form generation

37 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function addElements(properties) { let elements = []; for (let key of Object.getOwnPropertyNames(properties)) { let schema = properties[key]; if (schema.properties) { elements.push(createGroup(schema)); } else { elements.push(createElement(schema, key)); } } return elements; } function createElement(schema, key) { return { control: schema.control, props: { value: { source: key, label: schema.label } } }; } function createGroup(schema) { return { control: 'Group', props: { visible: { value: schema.visible }, label: schema.label }, elements: addElements(schema.properties) }; } function convertSchemaToForm(schema) { const definition = { props: { label: schema.label }, elements: addElements(schema.properties) }; return definition; } exports.convertSchemaToForm = convertSchemaToForm; //# sourceMappingURL=auto_schema.js.map