UNPKG

@tomino/dynamic-form-semantic-ui

Version:

Semantic UI form renderer based on dynamic form generation

65 lines 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const common_1 = require("../../semantic/tests/common"); const editor_state_1 = require("../editor_state"); const catalogue_1 = require("../catalogue"); const catalogue_editor_1 = require("../../catalogue_editor"); const editor_context_1 = require("../editor_context"); const formDefintion = { control: 'Stack', props: { gap: '12px' }, elements: [ { control: 'FormEditor', props: { formSource: { source: 'form' }, schemaSource: { source: 'schema' }, theme: 'light', editorHeight: '400px' } } ] }; describe('Form Editor', () => { const Component = common_1.prepareComponent(formDefintion, { type: 'object', properties: { schema: { type: 'string' }, form: { type: 'string' } } }, { form: JSON.stringify({ control: 'Form', elements: [{ props: { text: 'Yah!', control: 'Text' }, control: 'Text' }] }), schema: JSON.stringify({ type: 'object', properties: { name: { type: 'string', title: 'name' }, age: { type: 'number', title: 'age' }, car: { type: 'object', title: 'car', properties: { model: { type: 'string', title: 'model' }, year: { type: 'number', title: 'year' } } } } }) }, { addEditor: true, showReadOnly: false }); const editorContext = new editor_state_1.EditorState(catalogue_1.catalogue, catalogue_editor_1.catalogueEditor, {}); const Wrapper = () => (React.createElement(editor_context_1.EditorContext.Provider, { value: editorContext }, React.createElement(Component, null))); return { component: Wrapper }; }); //# sourceMappingURL=form_editor.test.js.map