From da7afa4525850712083f5f9c8956da0fdb0c90a0 Mon Sep 17 00:00:00 2001 From: Edgar Mueller Date: Tue, 24 Oct 2017 23:50:01 +0200 Subject: [PATCH] Release 2.1.0-alpha.2 --- dist/dist/ts-build/actions.d.ts | 25 ++ dist/dist/ts-build/core.d.ts | 75 ++++ dist/dist/ts-build/core/renderer.d.ts | 20 ++ dist/dist/ts-build/core/runtime.d.ts | 75 ++++ dist/dist/ts-build/core/schema.service.d.ts | 158 +++++++++ .../ts-build/core/schema.service.impl.d.ts | 24 ++ dist/dist/ts-build/core/styling.registry.d.ts | 69 ++++ dist/dist/ts-build/core/testers.d.ts | 90 +++++ .../dist/ts-build/core/uischema.registry.d.ts | 63 ++++ .../example/MaterializedBooleanControl.d.ts | 6 + .../example/MaterializedEnumControl.d.ts | 7 + dist/dist/ts-build/example/example.d.ts | 13 + dist/dist/ts-build/example/index.d.ts | 19 + .../dist/ts-build/example/style.switcher.d.ts | 1 + .../ts-build/example/templates/Rating.d.ts | 16 + .../ts-build/example/templates/arrays.d.ts | 0 .../example/templates/categorization.d.ts | 0 .../dist/ts-build/example/templates/day2.d.ts | 0 .../dist/ts-build/example/templates/day4.d.ts | 0 .../dist/ts-build/example/templates/day5.d.ts | 0 .../dist/ts-build/example/templates/day6.d.ts | 0 .../ts-build/example/templates/dynamic.d.ts | 0 .../ts-build/example/templates/dynamic2.d.ts | 0 .../ts-build/example/templates/ecore.d.ts | 0 .../example/templates/generate-ui.d.ts | 0 .../ts-build/example/templates/generate.d.ts | 0 .../ts-build/example/templates/layout.d.ts | 0 .../example/templates/masterdetail.d.ts | 0 .../ts-build/example/templates/person.d.ts | 0 .../example/templates/rating.control.d.ts | 14 + .../ts-build/example/templates/resolve.d.ts | 0 .../dist/ts-build/example/templates/rule.d.ts | 0 .../example/templates/uischema-registry.d.ts | 0 .../dist/ts-build/example/theme.switcher.d.ts | 1 + dist/dist/ts-build/generators/schema-gen.d.ts | 8 + .../ts-build/generators/ui-schema-gen.d.ts | 9 + dist/dist/ts-build/index.d.ts | 11 + dist/dist/ts-build/json-forms.d.ts | 52 +++ dist/dist/ts-build/models/jsonSchema.d.ts | 132 +++++++ dist/dist/ts-build/models/uischema.d.ts | 191 ++++++++++ dist/dist/ts-build/path.util.d.ts | 70 ++++ dist/dist/ts-build/reducers/common.d.ts | 12 + dist/dist/ts-build/reducers/index.d.ts | 7 + dist/dist/ts-build/reducers/renderers.d.ts | 13 + dist/dist/ts-build/reducers/validation.d.ts | 9 + dist/dist/ts-build/renderers/JSX.d.ts | 1 + .../renderers/additional/array-renderer.d.ts | 18 + .../additional/categorization-renderer.d.ts | 14 + .../renderers/additional/label.renderer.d.ts | 18 + .../additional/table-array.control.d.ts | 18 + .../renderers/additional/tree-renderer.d.ts | 56 +++ .../ts-build/renderers/controls/Control.d.ts | 18 + .../renderers/controls/boolean.control.d.ts | 12 + .../renderers/controls/date.control.d.ts | 12 + .../renderers/controls/enum.control.d.ts | 12 + .../renderers/controls/integer.control.d.ts | 12 + .../renderers/controls/number.control.d.ts | 12 + .../renderers/controls/text.control.d.ts | 12 + .../renderers/controls/textarea.control.d.ts | 16 + .../ts-build/renderers/dispatch-renderer.d.ts | 26 ++ dist/dist/ts-build/renderers/index.d.ts | 19 + dist/dist/ts-build/renderers/label.util.d.ts | 9 + .../renderers/layouts/group.layout.d.ts | 13 + .../renderers/layouts/horizontal.layout.d.ts | 15 + .../renderers/layouts/vertical.layout.d.ts | 15 + .../ts-build/renderers/renderer.util.d.ts | 52 +++ .../ts-build/renderers/unknown.renderer.d.ts | 4 + dist/dist/ts-build/src/actions.d.ts | 25 ++ dist/dist/ts-build/src/core.d.ts | 75 ++++ dist/dist/ts-build/src/core/renderer.d.ts | 20 ++ dist/dist/ts-build/src/core/runtime.d.ts | 75 ++++ .../ts-build/src/core/schema.service.d.ts | 158 +++++++++ .../src/core/schema.service.impl.d.ts | 24 ++ .../ts-build/src/core/styling.registry.d.ts | 69 ++++ dist/dist/ts-build/src/core/testers.d.ts | 90 +++++ .../ts-build/src/core/uischema.registry.d.ts | 63 ++++ .../ts-build/src/generators/schema-gen.d.ts | 8 + .../src/generators/ui-schema-gen.d.ts | 9 + dist/dist/ts-build/src/index.d.ts | 11 + dist/dist/ts-build/src/json-forms.d.ts | 52 +++ dist/dist/ts-build/src/models/jsonSchema.d.ts | 132 +++++++ dist/dist/ts-build/src/models/uischema.d.ts | 191 ++++++++++ dist/dist/ts-build/src/path.util.d.ts | 70 ++++ dist/dist/ts-build/src/reducers/common.d.ts | 12 + dist/dist/ts-build/src/reducers/index.d.ts | 7 + .../dist/ts-build/src/reducers/renderers.d.ts | 13 + .../ts-build/src/reducers/validation.d.ts | 9 + dist/dist/ts-build/src/renderers/JSX.d.ts | 1 + .../renderers/additional/array-renderer.d.ts | 18 + .../additional/categorization-renderer.d.ts | 14 + .../renderers/additional/label.renderer.d.ts | 18 + .../additional/table-array.control.d.ts | 18 + .../renderers/additional/tree-renderer.d.ts | 56 +++ .../src/renderers/controls/Control.d.ts | 18 + .../renderers/controls/boolean.control.d.ts | 12 + .../src/renderers/controls/date.control.d.ts | 12 + .../src/renderers/controls/enum.control.d.ts | 12 + .../renderers/controls/integer.control.d.ts | 12 + .../renderers/controls/number.control.d.ts | 12 + .../src/renderers/controls/text.control.d.ts | 12 + .../renderers/controls/textarea.control.d.ts | 16 + .../src/renderers/dispatch-renderer.d.ts | 26 ++ dist/dist/ts-build/src/renderers/index.d.ts | 19 + .../ts-build/src/renderers/label.util.d.ts | 9 + .../src/renderers/layouts/group.layout.d.ts | 13 + .../renderers/layouts/horizontal.layout.d.ts | 15 + .../renderers/layouts/vertical.layout.d.ts | 15 + .../ts-build/src/renderers/renderer.util.d.ts | 52 +++ .../src/renderers/unknown.renderer.d.ts | 4 + dist/dist/ts-build/src/store.d.ts | 5 + dist/dist/ts-build/store.d.ts | 5 + dist/icons/drive.png | Bin 0 -> 346 bytes dist/icons/folder.png | Bin 0 -> 537 bytes dist/icons/page.png | Bin 0 -> 635 bytes dist/ts-build/actions.d.ts | 25 ++ dist/ts-build/actions.js | 44 +++ dist/ts-build/actions.js.map | 1 + dist/ts-build/core.d.ts | 75 ++++ dist/ts-build/core.js | 109 ++++++ dist/ts-build/core.js.map | 1 + dist/ts-build/core/renderer.d.ts | 20 ++ dist/ts-build/core/renderer.js | 94 +++++ dist/ts-build/core/renderer.js.map | 1 + dist/ts-build/core/runtime.d.ts | 75 ++++ dist/ts-build/core/runtime.js | 104 ++++++ dist/ts-build/core/runtime.js.map | 1 + dist/ts-build/core/schema.service.d.ts | 158 +++++++++ dist/ts-build/core/schema.service.impl.d.ts | 24 ++ dist/ts-build/core/schema.service.impl.js | 244 +++++++++++++ dist/ts-build/core/schema.service.impl.js.map | 1 + dist/ts-build/core/schema.service.js | 145 ++++++++ dist/ts-build/core/schema.service.js.map | 1 + dist/ts-build/core/styling.registry.d.ts | 69 ++++ dist/ts-build/core/styling.registry.js | 59 ++++ dist/ts-build/core/styling.registry.js.map | 1 + dist/ts-build/core/testers.d.ts | 90 +++++ dist/ts-build/core/testers.js | 175 ++++++++++ dist/ts-build/core/testers.js.map | 1 + dist/ts-build/core/uischema.registry.d.ts | 63 ++++ dist/ts-build/core/uischema.registry.js | 57 +++ dist/ts-build/core/uischema.registry.js.map | 1 + dist/ts-build/generators/schema-gen.d.ts | 8 + dist/ts-build/generators/schema-gen.js | 128 +++++++ dist/ts-build/generators/schema-gen.js.map | 1 + dist/ts-build/generators/ui-schema-gen.d.ts | 9 + dist/ts-build/generators/ui-schema-gen.js | 121 +++++++ dist/ts-build/generators/ui-schema-gen.js.map | 1 + dist/ts-build/index.d.ts | 11 + dist/ts-build/index.js | 16 + dist/ts-build/index.js.map | 1 + dist/ts-build/json-forms.d.ts | 52 +++ dist/ts-build/json-forms.js | 169 +++++++++ dist/ts-build/json-forms.js.map | 1 + dist/ts-build/models/jsonSchema.d.ts | 132 +++++++ dist/ts-build/models/jsonSchema.js | 26 ++ dist/ts-build/models/jsonSchema.js.map | 1 + dist/ts-build/models/uischema.d.ts | 191 ++++++++++ dist/ts-build/models/uischema.js | 25 ++ dist/ts-build/models/uischema.js.map | 1 + dist/ts-build/path.util.d.ts | 70 ++++ dist/ts-build/path.util.js | 178 ++++++++++ dist/ts-build/path.util.js.map | 1 + dist/ts-build/reducers/common.d.ts | 12 + dist/ts-build/reducers/common.js | 55 +++ dist/ts-build/reducers/common.js.map | 1 + dist/ts-build/reducers/index.d.ts | 7 + dist/ts-build/reducers/index.js | 19 + dist/ts-build/reducers/index.js.map | 1 + dist/ts-build/reducers/renderers.d.ts | 13 + dist/ts-build/reducers/renderers.js | 16 + dist/ts-build/reducers/renderers.js.map | 1 + dist/ts-build/reducers/validation.d.ts | 9 + dist/ts-build/reducers/validation.js | 50 +++ dist/ts-build/reducers/validation.js.map | 1 + dist/ts-build/renderers/JSX.d.ts | 1 + dist/ts-build/renderers/JSX.js | 7 + dist/ts-build/renderers/JSX.js.map | 1 + .../renderers/additional/array-renderer.d.ts | 18 + .../renderers/additional/array-renderer.js | 92 +++++ .../additional/array-renderer.js.map | 1 + .../additional/categorization-renderer.d.ts | 14 + .../additional/categorization-renderer.js | 104 ++++++ .../additional/categorization-renderer.js.map | 1 + .../renderers/additional/label.renderer.d.ts | 18 + .../renderers/additional/label.renderer.js | 54 +++ .../additional/label.renderer.js.map | 1 + .../additional/table-array.control.d.ts | 18 + .../additional/table-array.control.js | 114 ++++++ .../additional/table-array.control.js.map | 1 + .../renderers/additional/tree-renderer.d.ts | 56 +++ .../renderers/additional/tree-renderer.js | 329 ++++++++++++++++++ .../renderers/additional/tree-renderer.js.map | 1 + dist/ts-build/renderers/controls/Control.d.ts | 18 + dist/ts-build/renderers/controls/Control.js | 27 ++ .../renderers/controls/Control.js.map | 1 + .../renderers/controls/boolean.control.d.ts | 12 + .../renderers/controls/boolean.control.js | 42 +++ .../renderers/controls/boolean.control.js.map | 1 + .../renderers/controls/date.control.d.ts | 12 + .../renderers/controls/date.control.js | 44 +++ .../renderers/controls/date.control.js.map | 1 + .../renderers/controls/enum.control.d.ts | 12 + .../renderers/controls/enum.control.js | 47 +++ .../renderers/controls/enum.control.js.map | 1 + .../renderers/controls/integer.control.d.ts | 12 + .../renderers/controls/integer.control.js | 43 +++ .../renderers/controls/integer.control.js.map | 1 + .../renderers/controls/number.control.d.ts | 12 + .../renderers/controls/number.control.js | 43 +++ .../renderers/controls/number.control.js.map | 1 + .../renderers/controls/text.control.d.ts | 12 + .../renderers/controls/text.control.js | 42 +++ .../renderers/controls/text.control.js.map | 1 + .../renderers/controls/textarea.control.d.ts | 16 + .../renderers/controls/textarea.control.js | 48 +++ .../controls/textarea.control.js.map | 1 + .../ts-build/renderers/dispatch-renderer.d.ts | 26 ++ dist/ts-build/renderers/dispatch-renderer.js | 23 ++ .../renderers/dispatch-renderer.js.map | 1 + dist/ts-build/renderers/index.d.ts | 19 + dist/ts-build/renderers/index.js | 25 ++ dist/ts-build/renderers/index.js.map | 1 + dist/ts-build/renderers/label.util.d.ts | 9 + dist/ts-build/renderers/label.util.js | 67 ++++ dist/ts-build/renderers/label.util.js.map | 1 + .../renderers/layouts/group.layout.d.ts | 13 + .../renderers/layouts/group.layout.js | 43 +++ .../renderers/layouts/group.layout.js.map | 1 + .../renderers/layouts/horizontal.layout.d.ts | 15 + .../renderers/layouts/horizontal.layout.js | 40 +++ .../layouts/horizontal.layout.js.map | 1 + .../renderers/layouts/vertical.layout.d.ts | 15 + .../renderers/layouts/vertical.layout.js | 40 +++ .../renderers/layouts/vertical.layout.js.map | 1 + dist/ts-build/renderers/renderer.util.d.ts | 52 +++ dist/ts-build/renderers/renderer.util.js | 98 ++++++ dist/ts-build/renderers/renderer.util.js.map | 1 + dist/ts-build/renderers/unknown.renderer.d.ts | 4 + dist/ts-build/renderers/unknown.renderer.js | 26 ++ .../renderers/unknown.renderer.js.map | 1 + dist/ts-build/store.d.ts | 5 + dist/ts-build/store.js | 32 ++ dist/ts-build/store.js.map | 1 + 243 files changed, 7890 insertions(+) create mode 100644 dist/dist/ts-build/actions.d.ts create mode 100644 dist/dist/ts-build/core.d.ts create mode 100644 dist/dist/ts-build/core/renderer.d.ts create mode 100644 dist/dist/ts-build/core/runtime.d.ts create mode 100644 dist/dist/ts-build/core/schema.service.d.ts create mode 100644 dist/dist/ts-build/core/schema.service.impl.d.ts create mode 100644 dist/dist/ts-build/core/styling.registry.d.ts create mode 100644 dist/dist/ts-build/core/testers.d.ts create mode 100644 dist/dist/ts-build/core/uischema.registry.d.ts create mode 100644 dist/dist/ts-build/example/MaterializedBooleanControl.d.ts create mode 100644 dist/dist/ts-build/example/MaterializedEnumControl.d.ts create mode 100644 dist/dist/ts-build/example/example.d.ts create mode 100644 dist/dist/ts-build/example/index.d.ts create mode 100644 dist/dist/ts-build/example/style.switcher.d.ts create mode 100644 dist/dist/ts-build/example/templates/Rating.d.ts create mode 100644 dist/dist/ts-build/example/templates/arrays.d.ts create mode 100644 dist/dist/ts-build/example/templates/categorization.d.ts create mode 100644 dist/dist/ts-build/example/templates/day2.d.ts create mode 100644 dist/dist/ts-build/example/templates/day4.d.ts create mode 100644 dist/dist/ts-build/example/templates/day5.d.ts create mode 100644 dist/dist/ts-build/example/templates/day6.d.ts create mode 100644 dist/dist/ts-build/example/templates/dynamic.d.ts create mode 100644 dist/dist/ts-build/example/templates/dynamic2.d.ts create mode 100644 dist/dist/ts-build/example/templates/ecore.d.ts create mode 100644 dist/dist/ts-build/example/templates/generate-ui.d.ts create mode 100644 dist/dist/ts-build/example/templates/generate.d.ts create mode 100644 dist/dist/ts-build/example/templates/layout.d.ts create mode 100644 dist/dist/ts-build/example/templates/masterdetail.d.ts create mode 100644 dist/dist/ts-build/example/templates/person.d.ts create mode 100644 dist/dist/ts-build/example/templates/rating.control.d.ts create mode 100644 dist/dist/ts-build/example/templates/resolve.d.ts create mode 100644 dist/dist/ts-build/example/templates/rule.d.ts create mode 100644 dist/dist/ts-build/example/templates/uischema-registry.d.ts create mode 100644 dist/dist/ts-build/example/theme.switcher.d.ts create mode 100644 dist/dist/ts-build/generators/schema-gen.d.ts create mode 100644 dist/dist/ts-build/generators/ui-schema-gen.d.ts create mode 100644 dist/dist/ts-build/index.d.ts create mode 100644 dist/dist/ts-build/json-forms.d.ts create mode 100644 dist/dist/ts-build/models/jsonSchema.d.ts create mode 100644 dist/dist/ts-build/models/uischema.d.ts create mode 100644 dist/dist/ts-build/path.util.d.ts create mode 100644 dist/dist/ts-build/reducers/common.d.ts create mode 100644 dist/dist/ts-build/reducers/index.d.ts create mode 100644 dist/dist/ts-build/reducers/renderers.d.ts create mode 100644 dist/dist/ts-build/reducers/validation.d.ts create mode 100644 dist/dist/ts-build/renderers/JSX.d.ts create mode 100644 dist/dist/ts-build/renderers/additional/array-renderer.d.ts create mode 100644 dist/dist/ts-build/renderers/additional/categorization-renderer.d.ts create mode 100644 dist/dist/ts-build/renderers/additional/label.renderer.d.ts create mode 100644 dist/dist/ts-build/renderers/additional/table-array.control.d.ts create mode 100644 dist/dist/ts-build/renderers/additional/tree-renderer.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/Control.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/boolean.control.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/date.control.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/enum.control.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/integer.control.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/number.control.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/text.control.d.ts create mode 100644 dist/dist/ts-build/renderers/controls/textarea.control.d.ts create mode 100644 dist/dist/ts-build/renderers/dispatch-renderer.d.ts create mode 100644 dist/dist/ts-build/renderers/index.d.ts create mode 100644 dist/dist/ts-build/renderers/label.util.d.ts create mode 100644 dist/dist/ts-build/renderers/layouts/group.layout.d.ts create mode 100644 dist/dist/ts-build/renderers/layouts/horizontal.layout.d.ts create mode 100644 dist/dist/ts-build/renderers/layouts/vertical.layout.d.ts create mode 100644 dist/dist/ts-build/renderers/renderer.util.d.ts create mode 100644 dist/dist/ts-build/renderers/unknown.renderer.d.ts create mode 100644 dist/dist/ts-build/src/actions.d.ts create mode 100644 dist/dist/ts-build/src/core.d.ts create mode 100644 dist/dist/ts-build/src/core/renderer.d.ts create mode 100644 dist/dist/ts-build/src/core/runtime.d.ts create mode 100644 dist/dist/ts-build/src/core/schema.service.d.ts create mode 100644 dist/dist/ts-build/src/core/schema.service.impl.d.ts create mode 100644 dist/dist/ts-build/src/core/styling.registry.d.ts create mode 100644 dist/dist/ts-build/src/core/testers.d.ts create mode 100644 dist/dist/ts-build/src/core/uischema.registry.d.ts create mode 100644 dist/dist/ts-build/src/generators/schema-gen.d.ts create mode 100644 dist/dist/ts-build/src/generators/ui-schema-gen.d.ts create mode 100644 dist/dist/ts-build/src/index.d.ts create mode 100644 dist/dist/ts-build/src/json-forms.d.ts create mode 100644 dist/dist/ts-build/src/models/jsonSchema.d.ts create mode 100644 dist/dist/ts-build/src/models/uischema.d.ts create mode 100644 dist/dist/ts-build/src/path.util.d.ts create mode 100644 dist/dist/ts-build/src/reducers/common.d.ts create mode 100644 dist/dist/ts-build/src/reducers/index.d.ts create mode 100644 dist/dist/ts-build/src/reducers/renderers.d.ts create mode 100644 dist/dist/ts-build/src/reducers/validation.d.ts create mode 100644 dist/dist/ts-build/src/renderers/JSX.d.ts create mode 100644 dist/dist/ts-build/src/renderers/additional/array-renderer.d.ts create mode 100644 dist/dist/ts-build/src/renderers/additional/categorization-renderer.d.ts create mode 100644 dist/dist/ts-build/src/renderers/additional/label.renderer.d.ts create mode 100644 dist/dist/ts-build/src/renderers/additional/table-array.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/additional/tree-renderer.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/Control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/boolean.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/date.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/enum.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/integer.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/number.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/text.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/controls/textarea.control.d.ts create mode 100644 dist/dist/ts-build/src/renderers/dispatch-renderer.d.ts create mode 100644 dist/dist/ts-build/src/renderers/index.d.ts create mode 100644 dist/dist/ts-build/src/renderers/label.util.d.ts create mode 100644 dist/dist/ts-build/src/renderers/layouts/group.layout.d.ts create mode 100644 dist/dist/ts-build/src/renderers/layouts/horizontal.layout.d.ts create mode 100644 dist/dist/ts-build/src/renderers/layouts/vertical.layout.d.ts create mode 100644 dist/dist/ts-build/src/renderers/renderer.util.d.ts create mode 100644 dist/dist/ts-build/src/renderers/unknown.renderer.d.ts create mode 100644 dist/dist/ts-build/src/store.d.ts create mode 100644 dist/dist/ts-build/store.d.ts create mode 100644 dist/icons/drive.png create mode 100644 dist/icons/folder.png create mode 100644 dist/icons/page.png create mode 100644 dist/ts-build/actions.d.ts create mode 100644 dist/ts-build/actions.js create mode 100644 dist/ts-build/actions.js.map create mode 100644 dist/ts-build/core.d.ts create mode 100644 dist/ts-build/core.js create mode 100644 dist/ts-build/core.js.map create mode 100644 dist/ts-build/core/renderer.d.ts create mode 100644 dist/ts-build/core/renderer.js create mode 100644 dist/ts-build/core/renderer.js.map create mode 100644 dist/ts-build/core/runtime.d.ts create mode 100644 dist/ts-build/core/runtime.js create mode 100644 dist/ts-build/core/runtime.js.map create mode 100644 dist/ts-build/core/schema.service.d.ts create mode 100644 dist/ts-build/core/schema.service.impl.d.ts create mode 100644 dist/ts-build/core/schema.service.impl.js create mode 100644 dist/ts-build/core/schema.service.impl.js.map create mode 100644 dist/ts-build/core/schema.service.js create mode 100644 dist/ts-build/core/schema.service.js.map create mode 100644 dist/ts-build/core/styling.registry.d.ts create mode 100644 dist/ts-build/core/styling.registry.js create mode 100644 dist/ts-build/core/styling.registry.js.map create mode 100644 dist/ts-build/core/testers.d.ts create mode 100644 dist/ts-build/core/testers.js create mode 100644 dist/ts-build/core/testers.js.map create mode 100644 dist/ts-build/core/uischema.registry.d.ts create mode 100644 dist/ts-build/core/uischema.registry.js create mode 100644 dist/ts-build/core/uischema.registry.js.map create mode 100644 dist/ts-build/generators/schema-gen.d.ts create mode 100644 dist/ts-build/generators/schema-gen.js create mode 100644 dist/ts-build/generators/schema-gen.js.map create mode 100644 dist/ts-build/generators/ui-schema-gen.d.ts create mode 100644 dist/ts-build/generators/ui-schema-gen.js create mode 100644 dist/ts-build/generators/ui-schema-gen.js.map create mode 100644 dist/ts-build/index.d.ts create mode 100644 dist/ts-build/index.js create mode 100644 dist/ts-build/index.js.map create mode 100644 dist/ts-build/json-forms.d.ts create mode 100644 dist/ts-build/json-forms.js create mode 100644 dist/ts-build/json-forms.js.map create mode 100644 dist/ts-build/models/jsonSchema.d.ts create mode 100644 dist/ts-build/models/jsonSchema.js create mode 100644 dist/ts-build/models/jsonSchema.js.map create mode 100644 dist/ts-build/models/uischema.d.ts create mode 100644 dist/ts-build/models/uischema.js create mode 100644 dist/ts-build/models/uischema.js.map create mode 100644 dist/ts-build/path.util.d.ts create mode 100644 dist/ts-build/path.util.js create mode 100644 dist/ts-build/path.util.js.map create mode 100644 dist/ts-build/reducers/common.d.ts create mode 100644 dist/ts-build/reducers/common.js create mode 100644 dist/ts-build/reducers/common.js.map create mode 100644 dist/ts-build/reducers/index.d.ts create mode 100644 dist/ts-build/reducers/index.js create mode 100644 dist/ts-build/reducers/index.js.map create mode 100644 dist/ts-build/reducers/renderers.d.ts create mode 100644 dist/ts-build/reducers/renderers.js create mode 100644 dist/ts-build/reducers/renderers.js.map create mode 100644 dist/ts-build/reducers/validation.d.ts create mode 100644 dist/ts-build/reducers/validation.js create mode 100644 dist/ts-build/reducers/validation.js.map create mode 100644 dist/ts-build/renderers/JSX.d.ts create mode 100644 dist/ts-build/renderers/JSX.js create mode 100644 dist/ts-build/renderers/JSX.js.map create mode 100644 dist/ts-build/renderers/additional/array-renderer.d.ts create mode 100644 dist/ts-build/renderers/additional/array-renderer.js create mode 100644 dist/ts-build/renderers/additional/array-renderer.js.map create mode 100644 dist/ts-build/renderers/additional/categorization-renderer.d.ts create mode 100644 dist/ts-build/renderers/additional/categorization-renderer.js create mode 100644 dist/ts-build/renderers/additional/categorization-renderer.js.map create mode 100644 dist/ts-build/renderers/additional/label.renderer.d.ts create mode 100644 dist/ts-build/renderers/additional/label.renderer.js create mode 100644 dist/ts-build/renderers/additional/label.renderer.js.map create mode 100644 dist/ts-build/renderers/additional/table-array.control.d.ts create mode 100644 dist/ts-build/renderers/additional/table-array.control.js create mode 100644 dist/ts-build/renderers/additional/table-array.control.js.map create mode 100644 dist/ts-build/renderers/additional/tree-renderer.d.ts create mode 100644 dist/ts-build/renderers/additional/tree-renderer.js create mode 100644 dist/ts-build/renderers/additional/tree-renderer.js.map create mode 100644 dist/ts-build/renderers/controls/Control.d.ts create mode 100644 dist/ts-build/renderers/controls/Control.js create mode 100644 dist/ts-build/renderers/controls/Control.js.map create mode 100644 dist/ts-build/renderers/controls/boolean.control.d.ts create mode 100644 dist/ts-build/renderers/controls/boolean.control.js create mode 100644 dist/ts-build/renderers/controls/boolean.control.js.map create mode 100644 dist/ts-build/renderers/controls/date.control.d.ts create mode 100644 dist/ts-build/renderers/controls/date.control.js create mode 100644 dist/ts-build/renderers/controls/date.control.js.map create mode 100644 dist/ts-build/renderers/controls/enum.control.d.ts create mode 100644 dist/ts-build/renderers/controls/enum.control.js create mode 100644 dist/ts-build/renderers/controls/enum.control.js.map create mode 100644 dist/ts-build/renderers/controls/integer.control.d.ts create mode 100644 dist/ts-build/renderers/controls/integer.control.js create mode 100644 dist/ts-build/renderers/controls/integer.control.js.map create mode 100644 dist/ts-build/renderers/controls/number.control.d.ts create mode 100644 dist/ts-build/renderers/controls/number.control.js create mode 100644 dist/ts-build/renderers/controls/number.control.js.map create mode 100644 dist/ts-build/renderers/controls/text.control.d.ts create mode 100644 dist/ts-build/renderers/controls/text.control.js create mode 100644 dist/ts-build/renderers/controls/text.control.js.map create mode 100644 dist/ts-build/renderers/controls/textarea.control.d.ts create mode 100644 dist/ts-build/renderers/controls/textarea.control.js create mode 100644 dist/ts-build/renderers/controls/textarea.control.js.map create mode 100644 dist/ts-build/renderers/dispatch-renderer.d.ts create mode 100644 dist/ts-build/renderers/dispatch-renderer.js create mode 100644 dist/ts-build/renderers/dispatch-renderer.js.map create mode 100644 dist/ts-build/renderers/index.d.ts create mode 100644 dist/ts-build/renderers/index.js create mode 100644 dist/ts-build/renderers/index.js.map create mode 100644 dist/ts-build/renderers/label.util.d.ts create mode 100644 dist/ts-build/renderers/label.util.js create mode 100644 dist/ts-build/renderers/label.util.js.map create mode 100644 dist/ts-build/renderers/layouts/group.layout.d.ts create mode 100644 dist/ts-build/renderers/layouts/group.layout.js create mode 100644 dist/ts-build/renderers/layouts/group.layout.js.map create mode 100644 dist/ts-build/renderers/layouts/horizontal.layout.d.ts create mode 100644 dist/ts-build/renderers/layouts/horizontal.layout.js create mode 100644 dist/ts-build/renderers/layouts/horizontal.layout.js.map create mode 100644 dist/ts-build/renderers/layouts/vertical.layout.d.ts create mode 100644 dist/ts-build/renderers/layouts/vertical.layout.js create mode 100644 dist/ts-build/renderers/layouts/vertical.layout.js.map create mode 100644 dist/ts-build/renderers/renderer.util.d.ts create mode 100644 dist/ts-build/renderers/renderer.util.js create mode 100644 dist/ts-build/renderers/renderer.util.js.map create mode 100644 dist/ts-build/renderers/unknown.renderer.d.ts create mode 100644 dist/ts-build/renderers/unknown.renderer.js create mode 100644 dist/ts-build/renderers/unknown.renderer.js.map create mode 100644 dist/ts-build/store.d.ts create mode 100644 dist/ts-build/store.js create mode 100644 dist/ts-build/store.js.map diff --git a/dist/dist/ts-build/actions.d.ts b/dist/dist/ts-build/actions.d.ts new file mode 100644 index 000000000..6e5804277 --- /dev/null +++ b/dist/dist/ts-build/actions.d.ts @@ -0,0 +1,25 @@ +import { ThunkAction } from 'redux-thunk'; +import { JsonFormsRendererConstructable } from './renderers/renderer.util'; +import { RankedTester } from './core/testers'; +export declare const INIT = "INIT"; +export declare const UPDATE_DATA = "UPDATE"; +export declare const UPDATE_UI = "UPDATE_UI"; +export declare const VALIDATE = "VALIDATE"; +export declare const SHOW = "SHOW"; +export declare const HIDE = "HIDE"; +export declare const ENABLE = "ENABLE"; +export declare const DISABLE = "DISABLE"; +export declare const ADD_RENDERER = "ADD_RENDERER"; +export declare const REMOVE_RENDERER = "REMOVE_RENDERER"; +export declare const update: (path: string, updater: (any: any) => any) => ThunkAction; +export declare const validate: () => (dispatch: any, getState: any) => void; +export declare const registerRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { + type: string; + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}; +export declare const unregisterRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { + type: string; + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}; diff --git a/dist/dist/ts-build/core.d.ts b/dist/dist/ts-build/core.d.ts new file mode 100644 index 000000000..bd6626521 --- /dev/null +++ b/dist/dist/ts-build/core.d.ts @@ -0,0 +1,75 @@ +import { UISchemaElement } from './models/uischema'; +import { JsonSchema } from './models/jsonSchema'; +import { UISchemaRegistry } from './core/uischema.registry'; +import { StylingRegistry } from './core/styling.registry'; +import { SchemaService } from './core/schema.service'; +import { Store } from 'redux'; +/** + * Represents a JSONForms service. + */ +export interface JsonFormService { + /** + * Disposes this service. + */ + dispose(): void; +} +export declare class JsonFormsConfig { + private _identifyingProp; + setIdentifyingProp(propName: string): void; + getIdentifyingProp(): any; + shouldGenerateIdentifier(): boolean; +} +/** + * Encapsulates instantiation logic of a JSONForms service. + */ +export interface JsonFormsServiceConstructable { + /** + * Constructor logic. + * + * @param {store} + * @param {JsonSchema} dataSchema the JSON schema describing the data + * @param {UISchemaElement} uiSchema the UI schema to be rendered + */ + new (store: Store, dataSchema: JsonSchema, uiSchema: UISchemaElement): JsonFormService; +} +/** + * Global JSONForms object that holds services and registries. + */ +export declare class JsonForms { + private static _config; + private static _schemaService; + static renderers: any[]; + static jsonFormsServices: JsonFormsServiceConstructable[]; + static uischemaRegistry: UISchemaRegistry; + static stylingRegistry: StylingRegistry; + static modelMapping: any; + static schema: JsonSchema; + static readonly schemaService: SchemaService; + static readonly config: JsonFormsConfig; + /** + * Uses the model mapping to filter all objects that are associated with the type + * defined by the given schema id. If there is no applicable mapping, + * we assume that no mapping is necessary and do not filter out affected data objects. + * + * @param objects the list of data objects to filter + * @param schemaId The id of the JsonSchema defining the type to filter for + * @return The filtered data objects or all objects if there is no applicable mapping + */ + static filterObjectsByType: (objects: Object[], schemaId: string) => Object[]; + /** + * Uses the model mapping to find the schema id defining the type of the given object. + * If no schema id can be determined either because the object is empty, there is no model + * mapping, or the object does not contain a mappable property. + * TODO expected behavior? + * + * @param object The object whose type is determined + * @return The schema id of the object or null if it could not be determined + */ + static getSchemaIdForObject: (object: Object) => string; +} +/** + * Annotation for registering a class as JSONForms service. + * @param config + * @constructor + */ +export declare const JsonFormsServiceElement: (config: any) => (cls: JsonFormsServiceConstructable) => void; diff --git a/dist/dist/ts-build/core/renderer.d.ts b/dist/dist/ts-build/core/renderer.d.ts new file mode 100644 index 000000000..05cfe5d4b --- /dev/null +++ b/dist/dist/ts-build/core/renderer.d.ts @@ -0,0 +1,20 @@ +import Component from 'inferno-component'; +import { JsonSchema } from '../models/jsonSchema'; +import { Scopable, UISchemaElement } from '../models/uischema'; +import { JsonFormsStore } from '../json-forms'; +export declare const convertToClassName: (value: string) => string; +export declare const getValue: (data: any, controlElement: Scopable, prefix?: string) => any; +export interface RendererProps { + uischema: UISchemaElement; + store: JsonFormsStore; + schema: JsonSchema; +} +export interface RendererState { + selected?: any; +} +export declare class Renderer

extends Component { +} +export declare const isVisible: (props: any, state: any) => boolean; +export declare const isEnabled: (props: any, state: any) => boolean; +export declare const evalVisibility: (uischema: UISchemaElement, data: any) => boolean; +export declare const evalEnablement: (uischema: UISchemaElement, data: any) => boolean; diff --git a/dist/dist/ts-build/core/runtime.d.ts b/dist/dist/ts-build/core/runtime.d.ts new file mode 100644 index 000000000..c68727d99 --- /dev/null +++ b/dist/dist/ts-build/core/runtime.d.ts @@ -0,0 +1,75 @@ +/** + * The different types of runtime related changes. + */ +export declare enum RUNTIME_TYPE { + VALIDATION_ERROR = 0, + VISIBLE = 1, + ENABLED = 2, +} +/** + * A listener that is notified about any runtime related changes. + */ +export interface RuntimeListener { + /** + * Called when a runtime related property changes. + * @param {RUNTIME_TYPE} type the type of runtime change + */ + runtimeUpdated(type: RUNTIME_TYPE): void; +} +/** + * A runtime object holds information about runtime related properties + * of a rendered UI schema element, like the visible/disabled state and + * possible validation errors. + */ +export declare class Runtime { + private validationErrorMessages; + private isVisible; + private isEnabled; + private listeners; + /** + * Whether the element is visible. + * @return {boolean} true, if the element is visible, false otherwise + */ + /** + * Set the visibility state of the element + * @param {boolean} visible whether the element should be visible + */ + visible: boolean; + /** + * Whether the element is enabled. + * @return {boolean} true, if the element is enabled, false otherwise + */ + /** + * Set the enabled state of the element + * @param {boolean} enabled whether the element should be enabled + */ + enabled: boolean; + /** + * Returns the validation errors associated with the element. + * @return {Array} the validation errors + */ + /** + * Set the validation errors. + * + * @param {string[]} validationErrors the validation errors + */ + validationErrors: string[]; + /** + * Add the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be added + */ + registerRuntimeListener(listener: RuntimeListener): void; + /** + * Remove the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be removed + */ + deregisterRuntimeListener(listener: RuntimeListener): void; + /** + * Notifies any runtime listeners about a runtime change. + * + * @param {RUNTIME_TYPE} type the runtime type + */ + private notifyRuntimeListeners(type); +} diff --git a/dist/dist/ts-build/core/schema.service.d.ts b/dist/dist/ts-build/core/schema.service.d.ts new file mode 100644 index 000000000..fe4e2afa0 --- /dev/null +++ b/dist/dist/ts-build/core/schema.service.d.ts @@ -0,0 +1,158 @@ +import { JsonSchema } from '../models/jsonSchema'; +/** + * A Property wraps a JsonSchema and provides additional information + * like a label and the property key. + */ +export interface Property { + /** + * The label is a text donating a human readable name of the schema the property describes. + */ + readonly label: string; + /** + * The property is a text donating the schema key from which this property was created. + */ + readonly property: string; + /** + * The schema is the JsonSchema this property describes. + */ + readonly schema: JsonSchema; +} +/** + * A ContainmentProperty extends the Property and provides methods + * which allow to modify containment data. + * @see Property + */ +export interface ContainmentProperty extends Property { + /** + * This allows to add data to the containment. + * @param data The object to add to + * @return a function that expects the element to be added and optionally the value next to which + * the new value is added. insertAfter defines whether the new value should be added + * after or before the neighbourValue. If no neighbour value is provided or it does not + * exist in the containment, the valueToAdd is inserted at the end. + */ + addToData(data: Object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; + /** + * This allows to delete data from the containment. + * The result is a function accepting the value to delete. + * @param data The object to delete from + * @return function accepting the value to delete + */ + deleteFromData(data: Object): (valueToDelete: object) => void; + /** + * This allows to retrieve the data of the containment. + * @param data The object the containment is in + * @return The containment value (e.g. an array) + */ + getData(data: Object): Object; +} +/** + * A ReferenceProperty extends the Property and provides methods + * which allow to modify reference data. + */ +export interface ReferenceProperty extends Property { + /** + * The schema of the referenced elements. + */ + readonly targetSchema: JsonSchema; + /** + * This allows to set the reference. + * @param root The root object, needed for matching the valueToAdd + * @param data The object to add to + * @param valueToAdd The object to add + */ + addToData(root: Object, data: Object, valueToAdd: object): void; + /** + * This allows to retrieve the data of the reference. + * @param root The root object, needed for finding the value to retrieve + * @param data The object the reference is in + * @return The referenced value + */ + getData(root: Object, data: Object): Object; + /** + * Returns all possible objects which can be referenced by this property. + * + * @param root The root data object needed for finding the values + * @return The array of data objects which are possible reference targets + * for this reference property. + */ + findReferenceTargets(rootData: Object): Object[]; + /** + * Resolves a reference value for this Reference by using the given porpertyValue to + * identify the referenced Object. + * + * @param rootData The root data object needed for finding the referenced value. + * @param propertyValue The property value identifying the referenced data object. + * @return The resolved data object or null if it coiuld not be resolved. + */ + resolveReference(rootData: Object, propertyValue: string): Object; +} +export declare class ContainmentPropertyImpl implements ContainmentProperty { + private innerSchema; + private key; + private name; + private addFunction; + private deleteFunction; + private getFunction; + constructor(innerSchema: JsonSchema, key: string, name: string, addFunction: (data: object) => (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void, deleteFunction: (data: object) => (valueToDelete: object) => void, getFunction: (data: object) => Object); + readonly label: string; + readonly schema: JsonSchema; + readonly property: string; + addToData(data: object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; + deleteFromData(data: object): (valueToDelete: object) => void; + getData(data: object): Object; +} +export declare class ReferencePropertyImpl implements ReferenceProperty { + private innerSchema; + private innerTargetSchema; + private key; + private name; + private pathToContainment; + private identifyingProperty; + private addFunction; + private getFunction; + constructor(innerSchema: JsonSchema, innerTargetSchema: JsonSchema, key: string, name: string, pathToContainment: string, identifyingProperty: string, addFunction: (root: object, data: object, valueToAdd: object) => void, getFunction: (root: object, data: object) => Object); + readonly label: string; + readonly schema: JsonSchema; + readonly property: string; + readonly targetSchema: JsonSchema; + addToData(root: object, data: object, valueToAdd: object): void; + getData(root: object, data: object): Object; + findReferenceTargets(rootData: Object): Object[]; + resolveReference(rootData: Object, propertyValue: string): Object; +} +export declare const isContainmentProperty: (property: Property) => property is ContainmentProperty; +export declare const isReferenceProperty: (property: Property) => property is ReferenceProperty; +/** + * The Schema Service allows to retrieve containments and references. + */ +export interface SchemaService { + /** + * Retrieves an array of containment properties based on the provided schema. + * @param schema The schema to check for containments + * @return The array of {@link ContainmentProperty} or empty if no containments are available + * @see ContainmentProperty + */ + getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; + /** + * Checks whether a containment properties are available in the provided schema. + * @param schema The schema to check for containments + * @return true if containment properties are available, false otherwise + * @see {@link getContainmentProperties} + */ + hasContainmentProperties(schema: JsonSchema): boolean; + /** + * Retieves a self contained schema. + * @param parentSchema The schema to use for resolvement + * @param refPath The path to resolve + * @return a JsonSchema that is self-contained + */ + getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; + /** + * Retrieves an array of reference properties based on the provided schema. + * @param schema The schema to check for references + * @return The array of {@link ReferenceProperty} or empty if no references are available + * @see ReferenceProperty + */ + getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; +} diff --git a/dist/dist/ts-build/core/schema.service.impl.d.ts b/dist/dist/ts-build/core/schema.service.impl.d.ts new file mode 100644 index 000000000..7c2b5774e --- /dev/null +++ b/dist/dist/ts-build/core/schema.service.impl.d.ts @@ -0,0 +1,24 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ContainmentProperty, ReferenceProperty, SchemaService } from './schema.service'; +export declare class SchemaServiceImpl implements SchemaService { + private rootSchema; + private selfContainedSchemas; + constructor(rootSchema: JsonSchema); + getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; + hasContainmentProperties(schema: JsonSchema): boolean; + getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; + getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; + private getContainment(key, name, schema, rootSchema, isInContainment, addFunction, deleteFunction, getFunction); + /** + * Makes the given JsonSchema self-contained. This means all referenced definitions + * are contained in the schema's definitions block and references equal to + * outerReference are set to root ('#'). + * + * @param schema The current schema to make self contained + * @param outerSchema The root schema to which missing definitions are added + * @param outerReference The reference which is considered to be self ('#') + * @param includedDefs The list of definitions which were already added to the outer schema + */ + private selfContainSchema(schema, outerSchema, outerReference, includedDefs?); + private copyAndResolveInner(resolved, innerRef, outerSchema, outerReference, includedDefs); +} diff --git a/dist/dist/ts-build/core/styling.registry.d.ts b/dist/dist/ts-build/core/styling.registry.d.ts new file mode 100644 index 000000000..982767c6e --- /dev/null +++ b/dist/dist/ts-build/core/styling.registry.d.ts @@ -0,0 +1,69 @@ +export declare type ClassNames = string[] | ((...args: any[]) => string[]); +/** + * A style associates a name with a list of CSS class names. + */ +export interface Style { + name: string; + classNames: ClassNames; +} +/** + * A registry of all available styles. + * A style may be used to alter the appearance of certain elements during + * the render process. + */ +export interface StylingRegistry { + /** + * Register a style. + * If a style with the given name already exists, it will be overwritten. + * + * @param styleName the name of the style + * @param classNames CSS class names to be applied + */ + register(styleName: string, classNames: string[]): void; + /** + * Register a style. + * If a style with the given name already exists, it will be overwritten. + * + * @param style the style to be registered + */ + register(style: Style): void; + /** + * Register multiple styles at once. + * + * @param styles an array of styles to be registered + */ + registerMany(styles: Style[]): void; + /** + * Deregister a style. + * + * @param styleName the name of the style to be un-registered + */ + deregister(styleName: string): void; + /** + * Obtain the CSS class name associated with the given style name. + * @param styleName the name whose CSS class names should be obtained + * @return {Array} an array containing the CSS class names, + * if the style exists, an empty array otherwise + */ + get(styleName: string, ...args: any[]): string[]; + /** + * Obtain the CSS class name associated with the given style name. + * @param styleName the name whose CSS class names should be obtained + * @return a string containing the CSS class name separated by whitespace, if the style exists, + * empty string otherwise + */ + getAsClassName(styleName: string, ...args: any[]): string; +} +/** + * Styling registry implementation. + */ +export declare class StylingRegistryImpl implements StylingRegistry { + protected styles: Style[]; + constructor(styles?: Style[]); + register(style: Style): void; + register(name: string, classNames: ClassNames): void; + registerMany(styles: Style[]): void; + deregister(styleName: any): void; + get(styleName: string, ...args: any[]): string[]; + getAsClassName(styleName: string, ...args: any[]): string; +} diff --git a/dist/dist/ts-build/core/testers.d.ts b/dist/dist/ts-build/core/testers.d.ts new file mode 100644 index 000000000..7aeb24d6a --- /dev/null +++ b/dist/dist/ts-build/core/testers.d.ts @@ -0,0 +1,90 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ControlElement, Scopable, UISchemaElement } from '../models/uischema'; +/** + * A tester is a function that receives an UI schema and a JSON schema and returns a boolean. + */ +export declare type Tester = (uischema: UISchemaElement, schema: JsonSchema) => boolean; +/** + * A ranked tester associates a tester with a number. + */ +export declare type RankedTester = (uischema: UISchemaElement, schema: JsonSchema) => number; +export declare const isControl: (uischema: any) => uischema is ControlElement; +export declare const isScopable: (uischema: any) => uischema is Scopable; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and applies + * the given predicate + * + * @param {(JsonSchema) => boolean} predicate the predicate that should be + * applied to the resolved sub-schema + */ +export declare const schemaMatches: (predicate: (schema: JsonSchema) => boolean) => Tester; +export declare const schemaSubPathMatches: (subPath: string, predicate: (schema: JsonSchema) => boolean) => Tester; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the type of the sub-schema matches the expected one. + * + * @param {string} expectedType the expected type of the resolved sub-schema + */ +export declare const schemaTypeIs: (expectedType: string) => Tester; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the format of the sub-schema matches the expected one. + * + * @param {string} expectedFormat the expected format of the resolved sub-schema + */ +export declare const formatIs: (expectedFormat: string) => Tester; +/** + * Checks whether the given UI schema has the expected type. + * + * @param {string} expected the expected UI schema type + */ +export declare const uiTypeIs: (expected: string) => Tester; +/** + * Checks whether the given UI schema has an option with the given + * name and whether it has the expected value. If no options property + * is set, returns false. + * + * @param {string} optionName the name of the option to check + * @param {any} optionValue the expected value of the option + */ +export declare const optionIs: (optionName: string, optionValue: any) => Tester; +/** + * Only applicable for Controls. + * + * Checks whether the scope $ref of a control ends with the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +export declare const refEndsWith: (expected: string) => Tester; +/** + * Only applicable for Controls. + * + * Checks whether the last segment of the scope $ref matches the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +export declare const refEndIs: (expected: string) => Tester; +/** + * A tester that allow composing other testers by && them. + * + * @param {Array} testers the testers to be composed + */ +export declare const and: (...testers: Tester[]) => Tester; +/** + * Create a ranked tester that will associate a number with a given tester, if the + * latter returns true. + * + * @param {number} rank the rank to be returned in case the tester returns true + * @param {Tester} tester a tester + */ +export declare const rankWith: (rank: number, tester: Tester) => (uischema: UISchemaElement, schema: JsonSchema) => number; +export declare const withIncreasedRank: (by: number, rankedTester: RankedTester) => (uischema: UISchemaElement, schema: JsonSchema) => number; diff --git a/dist/dist/ts-build/core/uischema.registry.d.ts b/dist/dist/ts-build/core/uischema.registry.d.ts new file mode 100644 index 000000000..304018f62 --- /dev/null +++ b/dist/dist/ts-build/core/uischema.registry.d.ts @@ -0,0 +1,63 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { UISchemaElement } from '../models/uischema'; +/** + * A registry of UI schemas. This registry can be utilized whenever + * multiple UI schemas are applicable for a given JSON schema in order + * to resolve ambiguity. + */ +export interface UISchemaRegistry { + /** + * Register a UI schema. + * + * @param {UISchemaElement} uiSchema the UI schema to be registered + * @param {UISchemaTester} tester the tester that determines whether + * the given UI schema should be used + */ + register(uiSchema: UISchemaElement, tester: UISchemaTester): void; + /** + * Deregister a UI schema. + * + * @param {UISchemaElement} uiSchema the UI schema to be unregistered + * @param {UISchemaTester} tester + */ + deregister(uiSchema: UISchemaElement, tester: UISchemaTester): void; + /** + * Find the UI schema that is most applicable for the given JSON schema + * and data. + * @param {JsonSchema} schema the JSON schema for which to find a UI schema + * @param {any} data the data for which to find a UI schema + */ + findMostApplicableUISchema(schema: JsonSchema, data: any): UISchemaElement; +} +/** + * A tester that returns a priority number when a JSON schema and some data, + * which determines how likely the associated UI schema will be used to + * render the JSON schema/data. The higher the returned number, the more likely + * the associated UI schema will be used. + */ +export declare type UISchemaTester = (schema: JsonSchema, data: any) => number; +/** + * Constant that indicates that a tester is not capable of handling + * a combination of schema/data. + * @type {number} + */ +export declare const NOT_APPLICABLE = -1; +/** + * Implementation of the UI schema registry. + */ +export declare class UISchemaRegistryImpl implements UISchemaRegistry { + private registry; + constructor(); + /** + * @inheritDoc + */ + register(uischema: UISchemaElement, tester: UISchemaTester): void; + /** + * @inheritDoc + */ + deregister(uischema: UISchemaElement, tester: UISchemaTester): void; + /** + * @inheritDoc + */ + findMostApplicableUISchema(schema: JsonSchema, data: any): UISchemaElement; +} diff --git a/dist/dist/ts-build/example/MaterializedBooleanControl.d.ts b/dist/dist/ts-build/example/MaterializedBooleanControl.d.ts new file mode 100644 index 000000000..cc6e25902 --- /dev/null +++ b/dist/dist/ts-build/example/MaterializedBooleanControl.d.ts @@ -0,0 +1,6 @@ +import { Control, ControlProps } from '../src/renderers/controls/Control'; +export declare class MaterializedBooleanControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/example/MaterializedEnumControl.d.ts b/dist/dist/ts-build/example/MaterializedEnumControl.d.ts new file mode 100644 index 000000000..6f7ef5a47 --- /dev/null +++ b/dist/dist/ts-build/example/MaterializedEnumControl.d.ts @@ -0,0 +1,7 @@ +import { EnumControl } from '../src/renderers/controls/enum.control'; +export declare class MaterializedEnumControl extends EnumControl { + componentDidMount(): void; + componentDidUpdate(): void; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/example/example.d.ts b/dist/dist/ts-build/example/example.d.ts new file mode 100644 index 000000000..2fe4706f8 --- /dev/null +++ b/dist/dist/ts-build/example/example.d.ts @@ -0,0 +1,13 @@ +import { JsonSchema } from '../src/models/jsonSchema'; +import { UISchemaElement } from '../src/models/uischema'; +export interface ExampleDescription { + name: string; + label: string; + data: any; + schema: JsonSchema; + uiSchema: UISchemaElement; + setupCallback?(div: HTMLDivElement): void; +} +export declare const registerExamples: (examples: ExampleDescription[]) => void; +export declare const changeExample: (selectedExample: string) => void; +export declare const createExampleSelection: () => HTMLSelectElement; diff --git a/dist/dist/ts-build/example/index.d.ts b/dist/dist/ts-build/example/index.d.ts new file mode 100644 index 000000000..66441a929 --- /dev/null +++ b/dist/dist/ts-build/example/index.d.ts @@ -0,0 +1,19 @@ +import './templates/arrays'; +import './templates/day2'; +import './templates/day4'; +import './templates/day5'; +import './templates/day6'; +import './templates/generate'; +import './templates/generate-ui'; +import './templates/layout'; +import './templates/person'; +import './templates/rule'; +import './templates/dynamic'; +import './templates/dynamic2'; +import './templates/categorization'; +import './templates/masterdetail'; +import './templates/resolve'; +import './templates/uischema-registry'; +import './templates/ecore'; +import './MaterializedEnumControl'; +import './MaterializedBooleanControl'; diff --git a/dist/dist/ts-build/example/style.switcher.d.ts b/dist/dist/ts-build/example/style.switcher.d.ts new file mode 100644 index 000000000..2ec57633a --- /dev/null +++ b/dist/dist/ts-build/example/style.switcher.d.ts @@ -0,0 +1 @@ +export declare const createStyleSelection: (selectExampleElement: HTMLSelectElement) => void; diff --git a/dist/dist/ts-build/example/templates/Rating.d.ts b/dist/dist/ts-build/example/templates/Rating.d.ts new file mode 100644 index 000000000..3c73cbd1a --- /dev/null +++ b/dist/dist/ts-build/example/templates/Rating.d.ts @@ -0,0 +1,16 @@ +import Component from 'inferno-component'; +export interface RatingState { + rating: number; + hoverAt: number | null; +} +export interface RatingProps { + onClick: any; + value: number; +} +export declare class Rating extends Component { + constructor(props: any); + handleMouseOver(idx: any): void; + handleMouseOut(): void; + handleClick(idx: any): void; + render(): any; +} diff --git a/dist/dist/ts-build/example/templates/arrays.d.ts b/dist/dist/ts-build/example/templates/arrays.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/categorization.d.ts b/dist/dist/ts-build/example/templates/categorization.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/day2.d.ts b/dist/dist/ts-build/example/templates/day2.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/day4.d.ts b/dist/dist/ts-build/example/templates/day4.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/day5.d.ts b/dist/dist/ts-build/example/templates/day5.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/day6.d.ts b/dist/dist/ts-build/example/templates/day6.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/dynamic.d.ts b/dist/dist/ts-build/example/templates/dynamic.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/dynamic2.d.ts b/dist/dist/ts-build/example/templates/dynamic2.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/ecore.d.ts b/dist/dist/ts-build/example/templates/ecore.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/generate-ui.d.ts b/dist/dist/ts-build/example/templates/generate-ui.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/generate.d.ts b/dist/dist/ts-build/example/templates/generate.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/layout.d.ts b/dist/dist/ts-build/example/templates/layout.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/masterdetail.d.ts b/dist/dist/ts-build/example/templates/masterdetail.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/person.d.ts b/dist/dist/ts-build/example/templates/person.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/rating.control.d.ts b/dist/dist/ts-build/example/templates/rating.control.d.ts new file mode 100644 index 000000000..5a3eddd11 --- /dev/null +++ b/dist/dist/ts-build/example/templates/rating.control.d.ts @@ -0,0 +1,14 @@ +import { RankedTester } from '../../src/core/testers'; +import { Control, ControlProps } from '../../src/renderers/controls/Control'; +/** + * Default tester for integer controls. + * @type {RankedTester} + */ +export declare const ratingControlTester: RankedTester; +export declare class RatingControl extends Control { + /** + * @inheritDoc + */ + render(): any; + private onClick(ev); +} diff --git a/dist/dist/ts-build/example/templates/resolve.d.ts b/dist/dist/ts-build/example/templates/resolve.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/rule.d.ts b/dist/dist/ts-build/example/templates/rule.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/templates/uischema-registry.d.ts b/dist/dist/ts-build/example/templates/uischema-registry.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/dist/dist/ts-build/example/theme.switcher.d.ts b/dist/dist/ts-build/example/theme.switcher.d.ts new file mode 100644 index 000000000..d43e0f44f --- /dev/null +++ b/dist/dist/ts-build/example/theme.switcher.d.ts @@ -0,0 +1 @@ +export declare const createThemeSelection: () => void; diff --git a/dist/dist/ts-build/generators/schema-gen.d.ts b/dist/dist/ts-build/generators/schema-gen.d.ts new file mode 100644 index 000000000..09fbbe035 --- /dev/null +++ b/dist/dist/ts-build/generators/schema-gen.d.ts @@ -0,0 +1,8 @@ +import { JsonSchema } from '../models/jsonSchema'; +/** + * Generate a JSON schema based on the given data and any additional options. + * @param {Object} instance the data to create a JSON schema for + * @param {any} options any additional options that may alter the generated JSON schema + * @returns {JsonSchema} the generated schema + */ +export declare const generateJsonSchema: (instance: Object, options?: any) => JsonSchema; diff --git a/dist/dist/ts-build/generators/ui-schema-gen.d.ts b/dist/dist/ts-build/generators/ui-schema-gen.d.ts new file mode 100644 index 000000000..503e84fb1 --- /dev/null +++ b/dist/dist/ts-build/generators/ui-schema-gen.d.ts @@ -0,0 +1,9 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { UISchemaElement } from '../models/uischema'; +/** + * Generate a default UI schema. + * @param {JsonSchema} jsonSchema the JSON schema to generated a UI schema for + * @param {string} layoutType the desired layout type for the root layout + * of the generated UI schema + */ +export declare const generateDefaultUISchema: (jsonSchema: JsonSchema, layoutType?: string, prefix?: string) => UISchemaElement; diff --git a/dist/dist/ts-build/index.d.ts b/dist/dist/ts-build/index.d.ts new file mode 100644 index 000000000..d7e7ccc46 --- /dev/null +++ b/dist/dist/ts-build/index.d.ts @@ -0,0 +1,11 @@ +export * from './core'; +export * from './json-forms'; +export * from './path.util'; +export * from './core/renderer'; +export * from './core/runtime'; +export * from './core/schema.service'; +export * from './core/styling.registry'; +export * from './core/testers'; +export * from './models/uischema'; +export * from './models/jsonSchema'; +export * from './renderers'; diff --git a/dist/dist/ts-build/json-forms.d.ts b/dist/dist/ts-build/json-forms.d.ts new file mode 100644 index 000000000..4cda24a83 --- /dev/null +++ b/dist/dist/ts-build/json-forms.d.ts @@ -0,0 +1,52 @@ +import './renderers'; +import { UISchemaElement } from './models/uischema'; +import { JsonSchema } from './models/jsonSchema'; +import { Store } from 'redux'; +export interface JsonFormsStore extends Store { +} +/** + * HTML element that represents the entry point + */ +export declare class JsonFormsElement extends HTMLElement { + private dataObject; + private uischema; + private dataschema; + schemaPromise: Promise; + private allowDynamicUpdate; + store: Store; + /** + * Constructor. + */ + constructor(); + /** + * Called when this element is inserted into a document. + */ + connectedCallback(): void; + /** + * Set the data to be rendered. + * @param {Object} data the data to be rendered + */ + data: Object; + /** + * Returns the UI schema to be rendered. + * + * @returns {UISchemaElement} the UI schema to be rendered + */ + /** + * Set the UI schema. + * @param {UISchemaElement} uischema the UI schema element to be set + */ + uiSchema: UISchemaElement; + /** + * Returns the JSON schema that describes the data to be rendered. + * + * @returns {JsonSchema} the JSON schema that describes the data to be rendered + */ + /** + * Set the JSON data schema that describes the data to be rendered. + * @param {JsonSchema} dataSchema the data schema to be rendered + */ + dataSchema: JsonSchema; + private render(); + private instantiateSchemaIfNeeded(schema); +} diff --git a/dist/dist/ts-build/models/jsonSchema.d.ts b/dist/dist/ts-build/models/jsonSchema.d.ts new file mode 100644 index 000000000..51d748cac --- /dev/null +++ b/dist/dist/ts-build/models/jsonSchema.d.ts @@ -0,0 +1,132 @@ +/** + * MIT License + * + * Copyright (c) 2016 Richard Adams (https://github.com/enriched) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +export interface JsonSchema { + $ref?: string; + /** + * This is important because it tells refs where + * the root of the document is located + */ + id?: string; + /** + * It is recommended that the meta-schema is + * included in the root of any JSON Schema + */ + $schema?: JsonSchema; + /** + * Title of the schema + */ + title?: string; + /** + * Schema description + */ + description?: string; + /** + * Default json for the object represented by + * this schema + */ + 'default'?: any; + /** + * The value must be a multiple of the number + * (e.g. 10 is a multiple of 5) + */ + multipleOf?: number; + maximum?: number; + /** + * If true maximum must be > value, >= otherwise + */ + exclusiveMaximum?: boolean; + minimum?: number; + /** + * If true minimum must be < value, <= otherwise + */ + exclusiveMinimum?: boolean; + maxLength?: number; + minLength?: number; + /** + * This is a regex string that the value must + * conform to + */ + pattern?: string; + additionalItems?: boolean | JsonSchema; + items?: JsonSchema | JsonSchema[]; + maxItems?: number; + minItems?: number; + uniqueItems?: boolean; + maxProperties?: number; + minProperties?: number; + required?: string[]; + additionalProperties?: boolean | JsonSchema; + /** + * Holds simple JSON Schema definitions for + * referencing from elsewhere. + */ + definitions?: { + [key: string]: JsonSchema; + }; + /** + * The keys that can exist on the object with the + * json schema that should validate their value + */ + properties?: { + [property: string]: JsonSchema; + }; + /** + * The key of this object is a regex for which + * properties the schema applies to + */ + patternProperties?: { + [pattern: string]: JsonSchema; + }; + /** + * If the key is present as a property then the + * string of properties must also be present. + * If the value is a JSON Schema then it must + * also be valid for the object if the key is + * present. + */ + dependencies?: { + [key: string]: JsonSchema | string[]; + }; + /** + * Enumerates the values that this schema can be + * e.g. + * {"type": "string", + * "enum": ["red", "green", "blue"]} + */ + 'enum'?: any[]; + /** + * The basic type of this schema, can be one of + * [string, number, object, array, boolean, null] + * or an array of the acceptable types + */ + type?: string | string[]; + allOf?: JsonSchema[]; + anyOf?: JsonSchema[]; + oneOf?: JsonSchema[]; + /** + * The entity being validated must not match this schema + */ + not?: JsonSchema; + format?: string; +} diff --git a/dist/dist/ts-build/models/uischema.d.ts b/dist/dist/ts-build/models/uischema.d.ts new file mode 100644 index 000000000..282a8fbcc --- /dev/null +++ b/dist/dist/ts-build/models/uischema.d.ts @@ -0,0 +1,191 @@ +import { Runtime } from '../core/runtime'; +/** + * A rule that may be attached to any UI schema element. + */ +export interface Rule { + /** + * The effect of the rule + */ + effect: RuleEffect; + /** + * The condition of the rule that must evaluate to true in order + * to trigger the effect. + */ + condition: Condition; +} +/** + * The different rule effects. + */ +export declare enum RuleEffect { + /** + * Effect that hides the associated element. + */ + HIDE = "HIDE", + /** + * Effect that shows the associated element. + */ + SHOW = "SHOW", + /** + * Effect that enables the associated element. + */ + ENABLE = "ENABLE", + /** + * Effect that disables the associated element. + */ + DISABLE = "DISABLE", +} +/** + * Represents a condition to be evaluated. + */ +export interface Condition { + /** + * A string describing the type of condition + */ + type: string; +} +/** + * A leaf condition. + */ +export interface LeafCondition extends Condition { + /** + * The sub schema the condition is bound to. + */ + scope: { + $ref: string; + }; + /** + * The expected value when evaluating the condition + */ + expectedValue: any; +} +/** + * Common base interface for any UI schema element. + */ +export interface UISchemaElement { + /** + * The type of this UI schema element. + */ + type: string; + /** + * An optional rule. + */ + rule?: Rule; + /** + * Any additional options. + */ + options?: any; + /** + * Runtime object that encapsulates runtime state. + */ + runtime?: Runtime; +} +/** + * Represents a layout element which can order its children + * in a specific way. + */ +export interface Layout extends UISchemaElement { + /** + * The child elements of this layout. + */ + elements: UISchemaElement[]; +} +/** + * A layout which orders its child elements vertically (i.e. from top to bottom). + */ +export interface VerticalLayout extends Layout { + type: 'VerticalLayout'; +} +/** + * A layout which orders its children horizontally (i.e. from left to right). + */ +export interface HorizontalLayout extends Layout { + type: 'HorizontalLayout'; +} +/** + * A group resembles a vertical layout, but additionally might have a label. + * This layout is useful when grouping different elements by a certain criteria. + */ +export interface GroupLayout extends Layout { + type: 'Group'; + /** + * The label of this group layout. + */ + label?: string; +} +/** + * Represents an object that can be used to configure a label. + */ +export interface ILabelObject { + /** + * An optional text to be displayed. + */ + text?: string; + /** + * Optional property that determines whether to show this label. + */ + show?: boolean; +} +/** + * A label element. + */ +export interface LabelElement extends UISchemaElement { + type: 'Label'; + /** + * The text of label. + */ + text: string; +} +export interface Scopable { + /** + * The scope that determines to which part of the schema the control + * should be bound to. The $ref property is just a regular JSON pointer. + */ + scope: { + $ref: string; + }; +} +/** + * A control element. The scope property of the control determines + * to which part of the schema the control should be bound. + */ +export interface ControlElement extends UISchemaElement, Scopable { + type: 'Control'; + /** + * An optional label that will be associated with the control + */ + label?: string | boolean | ILabelObject; +} +export interface MasterDetailLayout extends UISchemaElement, Scopable { + type: 'MasterDetailLayout'; + /** + * An optional label that will be associated with the control + */ + label?: string | boolean | ILabelObject; +} +/** + * The category layout. + */ +export interface Category extends Layout { + type: 'Category'; + /** + * The label associated with this category layout. + */ + label: string; +} +/** + * The categorization element, which may have children elements. + * A child element may either be itself a Categorization or a Category, hence + * the categorization element can be used to represent recursive structures like trees. + */ +export interface Categorization extends UISchemaElement { + type: 'Categorization'; + /** + * The label of this categorization. + */ + label: string; + /** + * The child elements of this categorization which are either of type + * {@link Category} or {@link Categorization}. + */ + elements: (Category | Categorization)[]; +} diff --git a/dist/dist/ts-build/path.util.d.ts b/dist/dist/ts-build/path.util.d.ts new file mode 100644 index 000000000..aa90570c6 --- /dev/null +++ b/dist/dist/ts-build/path.util.d.ts @@ -0,0 +1,70 @@ +import { JsonSchema } from './models/jsonSchema'; +import { Scopable } from './models/uischema'; +export declare const compose: (path1: string, path2: string) => string; +/** + * Convert a schema path (i.e. JSON pointer) to an array by splitting + * at the '/' character and removing all schema-specific keywords. + * + * The returned value can be used to de-reference a root object by folding over it + * and derefercing the single segments to obtain a new object. + * + * + * @param {string} schemaPath the schema path to be converted + * @returns {string[]} an array containing only non-schema-specific segments + */ +export declare const toDataPathSegments: (schemaPath: string) => string[]; +/** + * Remove all schema-specific keywords (e.g. 'properties') from a given path. + * @example + * toDataPath('#/properties/foo/properties/bar') === '#/foo/bar') + * + * @param {string} schemaPath the schema path to be converted + * @returns {string} the path without schema-specific keywords + */ +export declare const toDataPath: (schemaPath: string) => string; +/** + * Resolve the given schema path against the given instance until the last + * segment. The returned value allows easy assignment of any new value. + * + * @example + * const pair = getValuePropertyPair(someData, someRef); + * pair.instance[pair.property] = someValue; + * + * @param {any} instance the instance to resolve the path against + * @param {string} schemaPath the schema path to be resolved + * @returns {{instance: string, property: string}} an object containing + * the resolved instance as well the last fragment of + */ +export declare const getValuePropertyPair: (instance: any, schemaPath: string) => { + instance: Object; + property: string; +}; +export declare const composeWithUi: (scopableUi: Scopable, path: string) => string; +export declare const resolveData: (data: any, path: any) => any; +/** + * Resolve the given schema path in order to obtain a subschema. + * @param {JsonSchema} schema the root schema from which to start + * @param {string} schemaPath the schema path to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +export declare const resolveSchema: (schema: JsonSchema, schemaPath: string) => JsonSchema; +/** + * Finds all references inside the given schema. + * + * @param schema The {@link JsonSchema} to find the references in + * @param result The initial result map, default: empty map (this parameter is used for recursion + * inside the function) + * @param resolveTuples Whether arrays of tuples should be considered; default: false + */ +export declare const findAllRefs: (schema: JsonSchema, result?: ReferenceSchemaMap, resolveTuples?: boolean) => ReferenceSchemaMap; +/** + * Normalizes the schema and resolves the given ref. + * + * @param {JsonSchema} full the JSON schema to resolved the reference against + * @param {string} reference the reference to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +export declare function retrieveResolvableSchema(full: JsonSchema, reference: string): JsonSchema; +export interface ReferenceSchemaMap { + [ref: string]: JsonSchema; +} diff --git a/dist/dist/ts-build/reducers/common.d.ts b/dist/dist/ts-build/reducers/common.d.ts new file mode 100644 index 000000000..79a24c35c --- /dev/null +++ b/dist/dist/ts-build/reducers/common.d.ts @@ -0,0 +1,12 @@ +export declare const commonStateReducer: (state: { + data: {}; + schema: {}; + uischema: {}; +}, action: any) => { + data: any; + schema: {}; + uischema: {}; +}; +export declare const extractData: (state: any) => any; +export declare const extractSchema: (state: any) => any; +export declare const extractUiSchema: (state: any) => any; diff --git a/dist/dist/ts-build/reducers/index.d.ts b/dist/dist/ts-build/reducers/index.d.ts new file mode 100644 index 000000000..5fe11dd29 --- /dev/null +++ b/dist/dist/ts-build/reducers/index.d.ts @@ -0,0 +1,7 @@ +import { Reducer } from 'redux'; +export declare const appReducer: Reducer; +export declare const getData: (state: any) => any; +export declare const getSchema: (state: any) => any; +export declare const getUiSchema: (state: any) => any; +export declare const getRuntime: (state: any) => any; +export declare const getValidation: (state: any) => any; diff --git a/dist/dist/ts-build/reducers/renderers.d.ts b/dist/dist/ts-build/reducers/renderers.d.ts new file mode 100644 index 000000000..c021a1d16 --- /dev/null +++ b/dist/dist/ts-build/reducers/renderers.d.ts @@ -0,0 +1,13 @@ +import { JsonFormsRendererConstructable } from '../renderers/renderer.util'; +import { RankedTester } from '../core/testers'; +export declare const rendererReducer: (state: { + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}[], {type, tester, renderer}: { + type: any; + tester: any; + renderer: any; +}) => { + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}[]; diff --git a/dist/dist/ts-build/reducers/validation.d.ts b/dist/dist/ts-build/reducers/validation.d.ts new file mode 100644 index 000000000..ede95f29b --- /dev/null +++ b/dist/dist/ts-build/reducers/validation.d.ts @@ -0,0 +1,9 @@ +import { ErrorObject, ValidateFunction } from 'ajv'; +import { JsonSchema } from '../models/jsonSchema'; +export interface ValidationState { + errors: ErrorObject[]; + validator: ValidateFunction; + schema: JsonSchema; +} +export declare const validationReducer: (state: ValidationState, action: any) => ValidationState; +export declare const errorAt: (instancePath: any) => (state: any) => any[]; diff --git a/dist/dist/ts-build/renderers/JSX.d.ts b/dist/dist/ts-build/renderers/JSX.d.ts new file mode 100644 index 000000000..464c711a3 --- /dev/null +++ b/dist/dist/ts-build/renderers/JSX.d.ts @@ -0,0 +1 @@ +export declare const JSX: any; diff --git a/dist/dist/ts-build/renderers/additional/array-renderer.d.ts b/dist/dist/ts-build/renderers/additional/array-renderer.d.ts new file mode 100644 index 000000000..4964eb3bd --- /dev/null +++ b/dist/dist/ts-build/renderers/additional/array-renderer.d.ts @@ -0,0 +1,18 @@ +import { Renderer } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +export declare const getStyle: (styleName: string) => string; +/** + * Default tester for an array control. + * @type {RankedTester} + */ +export declare const arrayTester: RankedTester; +export declare class ArrayControlRenderer extends Renderer { + addNewItem(path: string): void; + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/additional/categorization-renderer.d.ts b/dist/dist/ts-build/renderers/additional/categorization-renderer.d.ts new file mode 100644 index 000000000..7ae621c8d --- /dev/null +++ b/dist/dist/ts-build/renderers/additional/categorization-renderer.d.ts @@ -0,0 +1,14 @@ +import { RankedTester } from '../../core/testers'; +import { Category } from '../../models/uischema'; +/** + * Default tester for a categorization. + * @type {RankedTester} + */ +export declare const categorizationTester: RankedTester; +export interface CategorizationState { + selected: { + category: Category; + }; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/additional/label.renderer.d.ts b/dist/dist/ts-build/renderers/additional/label.renderer.d.ts new file mode 100644 index 000000000..b50eded1c --- /dev/null +++ b/dist/dist/ts-build/renderers/additional/label.renderer.d.ts @@ -0,0 +1,18 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a label. + * @type {RankedTester} + */ +export declare const labelRendererTester: RankedTester; +/** + * Default renderer for a label. + */ +export declare class LabelRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/additional/table-array.control.d.ts b/dist/dist/ts-build/renderers/additional/table-array.control.d.ts new file mode 100644 index 000000000..760216525 --- /dev/null +++ b/dist/dist/ts-build/renderers/additional/table-array.control.d.ts @@ -0,0 +1,18 @@ +import { Renderer } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +/** + * Alternative tester for an array that also checks whether the 'table' + * option is set. + * @type {RankedTester} + */ +export declare const tableArrayTester: RankedTester; +export declare class TableArrayControl extends Renderer { + addNewItem(path: string): void; + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/additional/tree-renderer.d.ts b/dist/dist/ts-build/renderers/additional/tree-renderer.d.ts new file mode 100644 index 000000000..f45f018bd --- /dev/null +++ b/dist/dist/ts-build/renderers/additional/tree-renderer.d.ts @@ -0,0 +1,56 @@ +import { Renderer } from '../../core/renderer'; +import { JsonSchema } from '../../models/jsonSchema'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +/** + * Default tester for a master-detail layout. + * @type {RankedTester} + */ +export declare const treeMasterDetailTester: RankedTester; +export interface TreeMasterDetailState { + selected: { + schema: JsonSchema; + data: any; + path: string; + }; +} +export declare class TreeMasterDetail extends Renderer { + componentWillMount(): void; + render(): any; + openDialog(ev: Event, schema: JsonSchema, parentPath: string): void; + private closeDialog(); + private addToRoot(); + private renderMaster(schema); + /** + * Expands the given array of root elements by expanding every element. + * It is assumed that the roor elements do not support drag and drop. + * Based on this, a delete function is created for every element. + * + * @param data the array to expand + * @param schema the {@link JsonSchema} defining the elements' type + */ + private expandRootArray(schema); + /** + * Expands the given data array by expanding every element. + * If the parent data containing the array is provided, + * a suitable delete function for the expanded elements is created. + * + * @param data the array to expand + * @param property the {@link ContainmentProperty} defining the property that the array belongs to + * @param parentData the data containing the array as a property + */ + private expandArray(data, property, path, parentData?); + private getNamingFunction(schema); + /** + * Renders a data object as a

  • child element of the given
      list. + * + * @param data The rendered data + * @param schema The schema describing the rendered data's type + * @param deleteFunction A function to delete the data from the model + */ + private expandObject(scopedPath, schema, deleteFunction); + private propHasData(prop, data); + private renderChildren(prop, parentPath, parentSchema, parentData); +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/controls/Control.d.ts b/dist/dist/ts-build/renderers/controls/Control.d.ts new file mode 100644 index 000000000..e3682c7f6 --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/Control.d.ts @@ -0,0 +1,18 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +export interface ControlClassNames { + input: string; + label: string; + wrapper: string; +} +export interface ControlProps extends RendererProps { + data: any; + path: string; + classNames: ControlClassNames; + id: string; + visible: boolean; + enabled: boolean; + label: string; +} +export declare class Control

      extends Renderer { + updateData(value: any): void; +} diff --git a/dist/dist/ts-build/renderers/controls/boolean.control.d.ts b/dist/dist/ts-build/renderers/controls/boolean.control.d.ts new file mode 100644 index 000000000..f69dae5b7 --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/boolean.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for boolean controls. + * @type {RankedTester} + */ +export declare const booleanControlTester: RankedTester; +export declare class BooleanControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/controls/date.control.d.ts b/dist/dist/ts-build/renderers/controls/date.control.d.ts new file mode 100644 index 000000000..dd1dfd926 --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/date.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for date controls. + * @type {RankedTester} + */ +export declare const dateControlTester: RankedTester; +export declare class DateControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/controls/enum.control.d.ts b/dist/dist/ts-build/renderers/controls/enum.control.d.ts new file mode 100644 index 000000000..15610cfd0 --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/enum.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for enum controls. + * @type {RankedTester} + */ +export declare const enumControlTester: RankedTester; +export declare class EnumControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/controls/integer.control.d.ts b/dist/dist/ts-build/renderers/controls/integer.control.d.ts new file mode 100644 index 000000000..de63cee88 --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/integer.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for integer controls. + * @type {RankedTester} + */ +export declare const integerControlTester: RankedTester; +export declare class IntegerControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/controls/number.control.d.ts b/dist/dist/ts-build/renderers/controls/number.control.d.ts new file mode 100644 index 000000000..93e9e3b8a --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/number.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for number controls. + * @type {RankedTester} + */ +export declare const numberControlTester: RankedTester; +export declare class NumberControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/controls/text.control.d.ts b/dist/dist/ts-build/renderers/controls/text.control.d.ts new file mode 100644 index 000000000..dc8559cc6 --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/text.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for text-based/string controls. + * @type {RankedTester} + */ +export declare const textControlTester: RankedTester; +export declare class TextControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/controls/textarea.control.d.ts b/dist/dist/ts-build/renderers/controls/textarea.control.d.ts new file mode 100644 index 000000000..82b6ebb81 --- /dev/null +++ b/dist/dist/ts-build/renderers/controls/textarea.control.d.ts @@ -0,0 +1,16 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Tester for a multi-line string control. + * @type {RankedTester} + */ +export declare const textAreaControlTester: RankedTester; +export declare class TextAreaControl extends Control { + render(): any; + /** + * @inheritDoc + */ + protected toInput(value: any): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/dispatch-renderer.d.ts b/dist/dist/ts-build/renderers/dispatch-renderer.d.ts new file mode 100644 index 000000000..17a144231 --- /dev/null +++ b/dist/dist/ts-build/renderers/dispatch-renderer.d.ts @@ -0,0 +1,26 @@ +import { UISchemaElement } from '../models/uischema'; +import { JsonSchema } from '../models/jsonSchema'; +import { RankedTester } from '../core/testers'; +export interface DispatchRendererProps { + /** + * The UI schema to be rendered. + */ + uischema: UISchemaElement; + /** + * The JSON schema that describes the data. + */ + schema: JsonSchema; + renderers: { + tester: RankedTester; + renderer: any; + }[]; + /** + * Optional instance path. Necessary when the actual data + * path can not be inferred via the UI schema element as + * it is the case with nested controls. + */ + path?: string; +} +export declare const DispatchRenderer: (props: DispatchRendererProps) => any; +export declare const JsonFormsRenderer: (props: DispatchRendererProps) => any; +export default JsonFormsRenderer; diff --git a/dist/dist/ts-build/renderers/index.d.ts b/dist/dist/ts-build/renderers/index.d.ts new file mode 100644 index 000000000..9ae0e921f --- /dev/null +++ b/dist/dist/ts-build/renderers/index.d.ts @@ -0,0 +1,19 @@ +export * from './label.util'; +export * from './renderer.util'; +export * from './controls/Control'; +export * from './controls/text.control'; +export * from './controls/boolean.control'; +export * from './controls/integer.control'; +export * from './controls/number.control'; +export * from './controls/date.control'; +export * from './controls/enum.control'; +export * from './controls/textarea.control'; +export * from './layouts/vertical.layout'; +export * from './layouts/horizontal.layout'; +export * from './layouts/group.layout'; +export * from './additional/array-renderer'; +export * from './additional/tree-renderer'; +export * from './additional/categorization-renderer'; +export * from './additional/table-array.control'; +export * from './additional/label.renderer'; +export * from './JSX'; diff --git a/dist/dist/ts-build/renderers/label.util.d.ts b/dist/dist/ts-build/renderers/label.util.d.ts new file mode 100644 index 000000000..952cdf9f4 --- /dev/null +++ b/dist/dist/ts-build/renderers/label.util.d.ts @@ -0,0 +1,9 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ControlElement, ILabelObject } from '../models/uischema'; +/** + * Return a label object based on the given JSON schema and control element. + * @param {JsonSchema} schema the JSON schema that the given control element is referring to + * @param {ControlElement} controlElement the UI schema to obtain a label object for + * @returns {ILabelObject} + */ +export declare const getElementLabelObject: (schema: JsonSchema, controlElement: ControlElement) => ILabelObject; diff --git a/dist/dist/ts-build/renderers/layouts/group.layout.d.ts b/dist/dist/ts-build/renderers/layouts/group.layout.d.ts new file mode 100644 index 000000000..d8d81a3d9 --- /dev/null +++ b/dist/dist/ts-build/renderers/layouts/group.layout.d.ts @@ -0,0 +1,13 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a group layout. + * + * @type {RankedTester} + */ +export declare const groupTester: RankedTester; +export declare class GroupLayoutRenderer extends Renderer { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/layouts/horizontal.layout.d.ts b/dist/dist/ts-build/renderers/layouts/horizontal.layout.d.ts new file mode 100644 index 000000000..458ac9b1b --- /dev/null +++ b/dist/dist/ts-build/renderers/layouts/horizontal.layout.d.ts @@ -0,0 +1,15 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a horizontal layout. + * @type {RankedTester} + */ +export declare const horizontalLayoutTester: RankedTester; +export declare class HorizontalLayoutRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/layouts/vertical.layout.d.ts b/dist/dist/ts-build/renderers/layouts/vertical.layout.d.ts new file mode 100644 index 000000000..0b7c4d070 --- /dev/null +++ b/dist/dist/ts-build/renderers/layouts/vertical.layout.d.ts @@ -0,0 +1,15 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a vertical layout. + * @type {RankedTester} + */ +export declare const verticalLayoutTester: RankedTester; +export declare class VerticalLayoutRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/renderers/renderer.util.d.ts b/dist/dist/ts-build/renderers/renderer.util.d.ts new file mode 100644 index 000000000..141a89eb8 --- /dev/null +++ b/dist/dist/ts-build/renderers/renderer.util.d.ts @@ -0,0 +1,52 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { Renderer, RendererProps } from '../core/renderer'; +import { RankedTester } from '../core/testers'; +import { UISchemaElement } from '../models/uischema'; +/** + * A renderer config that is used during renderer registration. + */ +export interface JsonFormsRendererConfig { + /** + * The tester that that determines how applicable + * the renderer is. + */ + tester: RankedTester; +} +export interface JsonFormsRendererConstructable { + new (props: RendererProps): Renderer; +} +/** + * Renderer annotation that defines the renderer as a custom elemeent + * and registers it with the renderer service. + * + * @param {JsonFormsRendererConfig} config the renderer config to be registered + * @constructor + */ +export declare const JsonFormsRenderer: (config: JsonFormsRendererConfig) => (cls: JsonFormsRendererConstructable) => void; +export declare const mapStateToLayoutProps: (state: any, ownProps: any) => { + renderers: any; + visible: any; + path: any; +}; +export declare const renderChildren: (elements: UISchemaElement[], schema: JsonSchema, childType: string, path: string) => any[]; +export declare const JsonFormsLayout: ({styleName, children, visible}: { + styleName: any; + children: any; + visible: any; +}) => any; +export declare const formatErrorMessage: (errors: any) => any; +export declare const registerStartupRenderer: (tester: RankedTester, renderer: any) => any; +export declare const mapStateToControlProps: (state: any, ownProps: any) => { + data: any; + errors: any[]; + classNames: { + wrapper: string; + input: string; + label: string; + }; + label: string; + visible: any; + enabled: any; + id: string; + path: string; +}; diff --git a/dist/dist/ts-build/renderers/unknown.renderer.d.ts b/dist/dist/ts-build/renderers/unknown.renderer.d.ts new file mode 100644 index 000000000..af10c6e42 --- /dev/null +++ b/dist/dist/ts-build/renderers/unknown.renderer.d.ts @@ -0,0 +1,4 @@ +import { Renderer, RendererProps } from '../core/renderer'; +export declare class UnknownRenderer extends Renderer { + render(): any; +} diff --git a/dist/dist/ts-build/src/actions.d.ts b/dist/dist/ts-build/src/actions.d.ts new file mode 100644 index 000000000..6e5804277 --- /dev/null +++ b/dist/dist/ts-build/src/actions.d.ts @@ -0,0 +1,25 @@ +import { ThunkAction } from 'redux-thunk'; +import { JsonFormsRendererConstructable } from './renderers/renderer.util'; +import { RankedTester } from './core/testers'; +export declare const INIT = "INIT"; +export declare const UPDATE_DATA = "UPDATE"; +export declare const UPDATE_UI = "UPDATE_UI"; +export declare const VALIDATE = "VALIDATE"; +export declare const SHOW = "SHOW"; +export declare const HIDE = "HIDE"; +export declare const ENABLE = "ENABLE"; +export declare const DISABLE = "DISABLE"; +export declare const ADD_RENDERER = "ADD_RENDERER"; +export declare const REMOVE_RENDERER = "REMOVE_RENDERER"; +export declare const update: (path: string, updater: (any: any) => any) => ThunkAction; +export declare const validate: () => (dispatch: any, getState: any) => void; +export declare const registerRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { + type: string; + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}; +export declare const unregisterRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { + type: string; + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}; diff --git a/dist/dist/ts-build/src/core.d.ts b/dist/dist/ts-build/src/core.d.ts new file mode 100644 index 000000000..bd6626521 --- /dev/null +++ b/dist/dist/ts-build/src/core.d.ts @@ -0,0 +1,75 @@ +import { UISchemaElement } from './models/uischema'; +import { JsonSchema } from './models/jsonSchema'; +import { UISchemaRegistry } from './core/uischema.registry'; +import { StylingRegistry } from './core/styling.registry'; +import { SchemaService } from './core/schema.service'; +import { Store } from 'redux'; +/** + * Represents a JSONForms service. + */ +export interface JsonFormService { + /** + * Disposes this service. + */ + dispose(): void; +} +export declare class JsonFormsConfig { + private _identifyingProp; + setIdentifyingProp(propName: string): void; + getIdentifyingProp(): any; + shouldGenerateIdentifier(): boolean; +} +/** + * Encapsulates instantiation logic of a JSONForms service. + */ +export interface JsonFormsServiceConstructable { + /** + * Constructor logic. + * + * @param {store} + * @param {JsonSchema} dataSchema the JSON schema describing the data + * @param {UISchemaElement} uiSchema the UI schema to be rendered + */ + new (store: Store, dataSchema: JsonSchema, uiSchema: UISchemaElement): JsonFormService; +} +/** + * Global JSONForms object that holds services and registries. + */ +export declare class JsonForms { + private static _config; + private static _schemaService; + static renderers: any[]; + static jsonFormsServices: JsonFormsServiceConstructable[]; + static uischemaRegistry: UISchemaRegistry; + static stylingRegistry: StylingRegistry; + static modelMapping: any; + static schema: JsonSchema; + static readonly schemaService: SchemaService; + static readonly config: JsonFormsConfig; + /** + * Uses the model mapping to filter all objects that are associated with the type + * defined by the given schema id. If there is no applicable mapping, + * we assume that no mapping is necessary and do not filter out affected data objects. + * + * @param objects the list of data objects to filter + * @param schemaId The id of the JsonSchema defining the type to filter for + * @return The filtered data objects or all objects if there is no applicable mapping + */ + static filterObjectsByType: (objects: Object[], schemaId: string) => Object[]; + /** + * Uses the model mapping to find the schema id defining the type of the given object. + * If no schema id can be determined either because the object is empty, there is no model + * mapping, or the object does not contain a mappable property. + * TODO expected behavior? + * + * @param object The object whose type is determined + * @return The schema id of the object or null if it could not be determined + */ + static getSchemaIdForObject: (object: Object) => string; +} +/** + * Annotation for registering a class as JSONForms service. + * @param config + * @constructor + */ +export declare const JsonFormsServiceElement: (config: any) => (cls: JsonFormsServiceConstructable) => void; diff --git a/dist/dist/ts-build/src/core/renderer.d.ts b/dist/dist/ts-build/src/core/renderer.d.ts new file mode 100644 index 000000000..05cfe5d4b --- /dev/null +++ b/dist/dist/ts-build/src/core/renderer.d.ts @@ -0,0 +1,20 @@ +import Component from 'inferno-component'; +import { JsonSchema } from '../models/jsonSchema'; +import { Scopable, UISchemaElement } from '../models/uischema'; +import { JsonFormsStore } from '../json-forms'; +export declare const convertToClassName: (value: string) => string; +export declare const getValue: (data: any, controlElement: Scopable, prefix?: string) => any; +export interface RendererProps { + uischema: UISchemaElement; + store: JsonFormsStore; + schema: JsonSchema; +} +export interface RendererState { + selected?: any; +} +export declare class Renderer

      extends Component { +} +export declare const isVisible: (props: any, state: any) => boolean; +export declare const isEnabled: (props: any, state: any) => boolean; +export declare const evalVisibility: (uischema: UISchemaElement, data: any) => boolean; +export declare const evalEnablement: (uischema: UISchemaElement, data: any) => boolean; diff --git a/dist/dist/ts-build/src/core/runtime.d.ts b/dist/dist/ts-build/src/core/runtime.d.ts new file mode 100644 index 000000000..c68727d99 --- /dev/null +++ b/dist/dist/ts-build/src/core/runtime.d.ts @@ -0,0 +1,75 @@ +/** + * The different types of runtime related changes. + */ +export declare enum RUNTIME_TYPE { + VALIDATION_ERROR = 0, + VISIBLE = 1, + ENABLED = 2, +} +/** + * A listener that is notified about any runtime related changes. + */ +export interface RuntimeListener { + /** + * Called when a runtime related property changes. + * @param {RUNTIME_TYPE} type the type of runtime change + */ + runtimeUpdated(type: RUNTIME_TYPE): void; +} +/** + * A runtime object holds information about runtime related properties + * of a rendered UI schema element, like the visible/disabled state and + * possible validation errors. + */ +export declare class Runtime { + private validationErrorMessages; + private isVisible; + private isEnabled; + private listeners; + /** + * Whether the element is visible. + * @return {boolean} true, if the element is visible, false otherwise + */ + /** + * Set the visibility state of the element + * @param {boolean} visible whether the element should be visible + */ + visible: boolean; + /** + * Whether the element is enabled. + * @return {boolean} true, if the element is enabled, false otherwise + */ + /** + * Set the enabled state of the element + * @param {boolean} enabled whether the element should be enabled + */ + enabled: boolean; + /** + * Returns the validation errors associated with the element. + * @return {Array} the validation errors + */ + /** + * Set the validation errors. + * + * @param {string[]} validationErrors the validation errors + */ + validationErrors: string[]; + /** + * Add the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be added + */ + registerRuntimeListener(listener: RuntimeListener): void; + /** + * Remove the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be removed + */ + deregisterRuntimeListener(listener: RuntimeListener): void; + /** + * Notifies any runtime listeners about a runtime change. + * + * @param {RUNTIME_TYPE} type the runtime type + */ + private notifyRuntimeListeners(type); +} diff --git a/dist/dist/ts-build/src/core/schema.service.d.ts b/dist/dist/ts-build/src/core/schema.service.d.ts new file mode 100644 index 000000000..fe4e2afa0 --- /dev/null +++ b/dist/dist/ts-build/src/core/schema.service.d.ts @@ -0,0 +1,158 @@ +import { JsonSchema } from '../models/jsonSchema'; +/** + * A Property wraps a JsonSchema and provides additional information + * like a label and the property key. + */ +export interface Property { + /** + * The label is a text donating a human readable name of the schema the property describes. + */ + readonly label: string; + /** + * The property is a text donating the schema key from which this property was created. + */ + readonly property: string; + /** + * The schema is the JsonSchema this property describes. + */ + readonly schema: JsonSchema; +} +/** + * A ContainmentProperty extends the Property and provides methods + * which allow to modify containment data. + * @see Property + */ +export interface ContainmentProperty extends Property { + /** + * This allows to add data to the containment. + * @param data The object to add to + * @return a function that expects the element to be added and optionally the value next to which + * the new value is added. insertAfter defines whether the new value should be added + * after or before the neighbourValue. If no neighbour value is provided or it does not + * exist in the containment, the valueToAdd is inserted at the end. + */ + addToData(data: Object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; + /** + * This allows to delete data from the containment. + * The result is a function accepting the value to delete. + * @param data The object to delete from + * @return function accepting the value to delete + */ + deleteFromData(data: Object): (valueToDelete: object) => void; + /** + * This allows to retrieve the data of the containment. + * @param data The object the containment is in + * @return The containment value (e.g. an array) + */ + getData(data: Object): Object; +} +/** + * A ReferenceProperty extends the Property and provides methods + * which allow to modify reference data. + */ +export interface ReferenceProperty extends Property { + /** + * The schema of the referenced elements. + */ + readonly targetSchema: JsonSchema; + /** + * This allows to set the reference. + * @param root The root object, needed for matching the valueToAdd + * @param data The object to add to + * @param valueToAdd The object to add + */ + addToData(root: Object, data: Object, valueToAdd: object): void; + /** + * This allows to retrieve the data of the reference. + * @param root The root object, needed for finding the value to retrieve + * @param data The object the reference is in + * @return The referenced value + */ + getData(root: Object, data: Object): Object; + /** + * Returns all possible objects which can be referenced by this property. + * + * @param root The root data object needed for finding the values + * @return The array of data objects which are possible reference targets + * for this reference property. + */ + findReferenceTargets(rootData: Object): Object[]; + /** + * Resolves a reference value for this Reference by using the given porpertyValue to + * identify the referenced Object. + * + * @param rootData The root data object needed for finding the referenced value. + * @param propertyValue The property value identifying the referenced data object. + * @return The resolved data object or null if it coiuld not be resolved. + */ + resolveReference(rootData: Object, propertyValue: string): Object; +} +export declare class ContainmentPropertyImpl implements ContainmentProperty { + private innerSchema; + private key; + private name; + private addFunction; + private deleteFunction; + private getFunction; + constructor(innerSchema: JsonSchema, key: string, name: string, addFunction: (data: object) => (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void, deleteFunction: (data: object) => (valueToDelete: object) => void, getFunction: (data: object) => Object); + readonly label: string; + readonly schema: JsonSchema; + readonly property: string; + addToData(data: object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; + deleteFromData(data: object): (valueToDelete: object) => void; + getData(data: object): Object; +} +export declare class ReferencePropertyImpl implements ReferenceProperty { + private innerSchema; + private innerTargetSchema; + private key; + private name; + private pathToContainment; + private identifyingProperty; + private addFunction; + private getFunction; + constructor(innerSchema: JsonSchema, innerTargetSchema: JsonSchema, key: string, name: string, pathToContainment: string, identifyingProperty: string, addFunction: (root: object, data: object, valueToAdd: object) => void, getFunction: (root: object, data: object) => Object); + readonly label: string; + readonly schema: JsonSchema; + readonly property: string; + readonly targetSchema: JsonSchema; + addToData(root: object, data: object, valueToAdd: object): void; + getData(root: object, data: object): Object; + findReferenceTargets(rootData: Object): Object[]; + resolveReference(rootData: Object, propertyValue: string): Object; +} +export declare const isContainmentProperty: (property: Property) => property is ContainmentProperty; +export declare const isReferenceProperty: (property: Property) => property is ReferenceProperty; +/** + * The Schema Service allows to retrieve containments and references. + */ +export interface SchemaService { + /** + * Retrieves an array of containment properties based on the provided schema. + * @param schema The schema to check for containments + * @return The array of {@link ContainmentProperty} or empty if no containments are available + * @see ContainmentProperty + */ + getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; + /** + * Checks whether a containment properties are available in the provided schema. + * @param schema The schema to check for containments + * @return true if containment properties are available, false otherwise + * @see {@link getContainmentProperties} + */ + hasContainmentProperties(schema: JsonSchema): boolean; + /** + * Retieves a self contained schema. + * @param parentSchema The schema to use for resolvement + * @param refPath The path to resolve + * @return a JsonSchema that is self-contained + */ + getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; + /** + * Retrieves an array of reference properties based on the provided schema. + * @param schema The schema to check for references + * @return The array of {@link ReferenceProperty} or empty if no references are available + * @see ReferenceProperty + */ + getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; +} diff --git a/dist/dist/ts-build/src/core/schema.service.impl.d.ts b/dist/dist/ts-build/src/core/schema.service.impl.d.ts new file mode 100644 index 000000000..7c2b5774e --- /dev/null +++ b/dist/dist/ts-build/src/core/schema.service.impl.d.ts @@ -0,0 +1,24 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ContainmentProperty, ReferenceProperty, SchemaService } from './schema.service'; +export declare class SchemaServiceImpl implements SchemaService { + private rootSchema; + private selfContainedSchemas; + constructor(rootSchema: JsonSchema); + getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; + hasContainmentProperties(schema: JsonSchema): boolean; + getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; + getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; + private getContainment(key, name, schema, rootSchema, isInContainment, addFunction, deleteFunction, getFunction); + /** + * Makes the given JsonSchema self-contained. This means all referenced definitions + * are contained in the schema's definitions block and references equal to + * outerReference are set to root ('#'). + * + * @param schema The current schema to make self contained + * @param outerSchema The root schema to which missing definitions are added + * @param outerReference The reference which is considered to be self ('#') + * @param includedDefs The list of definitions which were already added to the outer schema + */ + private selfContainSchema(schema, outerSchema, outerReference, includedDefs?); + private copyAndResolveInner(resolved, innerRef, outerSchema, outerReference, includedDefs); +} diff --git a/dist/dist/ts-build/src/core/styling.registry.d.ts b/dist/dist/ts-build/src/core/styling.registry.d.ts new file mode 100644 index 000000000..982767c6e --- /dev/null +++ b/dist/dist/ts-build/src/core/styling.registry.d.ts @@ -0,0 +1,69 @@ +export declare type ClassNames = string[] | ((...args: any[]) => string[]); +/** + * A style associates a name with a list of CSS class names. + */ +export interface Style { + name: string; + classNames: ClassNames; +} +/** + * A registry of all available styles. + * A style may be used to alter the appearance of certain elements during + * the render process. + */ +export interface StylingRegistry { + /** + * Register a style. + * If a style with the given name already exists, it will be overwritten. + * + * @param styleName the name of the style + * @param classNames CSS class names to be applied + */ + register(styleName: string, classNames: string[]): void; + /** + * Register a style. + * If a style with the given name already exists, it will be overwritten. + * + * @param style the style to be registered + */ + register(style: Style): void; + /** + * Register multiple styles at once. + * + * @param styles an array of styles to be registered + */ + registerMany(styles: Style[]): void; + /** + * Deregister a style. + * + * @param styleName the name of the style to be un-registered + */ + deregister(styleName: string): void; + /** + * Obtain the CSS class name associated with the given style name. + * @param styleName the name whose CSS class names should be obtained + * @return {Array} an array containing the CSS class names, + * if the style exists, an empty array otherwise + */ + get(styleName: string, ...args: any[]): string[]; + /** + * Obtain the CSS class name associated with the given style name. + * @param styleName the name whose CSS class names should be obtained + * @return a string containing the CSS class name separated by whitespace, if the style exists, + * empty string otherwise + */ + getAsClassName(styleName: string, ...args: any[]): string; +} +/** + * Styling registry implementation. + */ +export declare class StylingRegistryImpl implements StylingRegistry { + protected styles: Style[]; + constructor(styles?: Style[]); + register(style: Style): void; + register(name: string, classNames: ClassNames): void; + registerMany(styles: Style[]): void; + deregister(styleName: any): void; + get(styleName: string, ...args: any[]): string[]; + getAsClassName(styleName: string, ...args: any[]): string; +} diff --git a/dist/dist/ts-build/src/core/testers.d.ts b/dist/dist/ts-build/src/core/testers.d.ts new file mode 100644 index 000000000..7aeb24d6a --- /dev/null +++ b/dist/dist/ts-build/src/core/testers.d.ts @@ -0,0 +1,90 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ControlElement, Scopable, UISchemaElement } from '../models/uischema'; +/** + * A tester is a function that receives an UI schema and a JSON schema and returns a boolean. + */ +export declare type Tester = (uischema: UISchemaElement, schema: JsonSchema) => boolean; +/** + * A ranked tester associates a tester with a number. + */ +export declare type RankedTester = (uischema: UISchemaElement, schema: JsonSchema) => number; +export declare const isControl: (uischema: any) => uischema is ControlElement; +export declare const isScopable: (uischema: any) => uischema is Scopable; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and applies + * the given predicate + * + * @param {(JsonSchema) => boolean} predicate the predicate that should be + * applied to the resolved sub-schema + */ +export declare const schemaMatches: (predicate: (schema: JsonSchema) => boolean) => Tester; +export declare const schemaSubPathMatches: (subPath: string, predicate: (schema: JsonSchema) => boolean) => Tester; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the type of the sub-schema matches the expected one. + * + * @param {string} expectedType the expected type of the resolved sub-schema + */ +export declare const schemaTypeIs: (expectedType: string) => Tester; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the format of the sub-schema matches the expected one. + * + * @param {string} expectedFormat the expected format of the resolved sub-schema + */ +export declare const formatIs: (expectedFormat: string) => Tester; +/** + * Checks whether the given UI schema has the expected type. + * + * @param {string} expected the expected UI schema type + */ +export declare const uiTypeIs: (expected: string) => Tester; +/** + * Checks whether the given UI schema has an option with the given + * name and whether it has the expected value. If no options property + * is set, returns false. + * + * @param {string} optionName the name of the option to check + * @param {any} optionValue the expected value of the option + */ +export declare const optionIs: (optionName: string, optionValue: any) => Tester; +/** + * Only applicable for Controls. + * + * Checks whether the scope $ref of a control ends with the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +export declare const refEndsWith: (expected: string) => Tester; +/** + * Only applicable for Controls. + * + * Checks whether the last segment of the scope $ref matches the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +export declare const refEndIs: (expected: string) => Tester; +/** + * A tester that allow composing other testers by && them. + * + * @param {Array} testers the testers to be composed + */ +export declare const and: (...testers: Tester[]) => Tester; +/** + * Create a ranked tester that will associate a number with a given tester, if the + * latter returns true. + * + * @param {number} rank the rank to be returned in case the tester returns true + * @param {Tester} tester a tester + */ +export declare const rankWith: (rank: number, tester: Tester) => (uischema: UISchemaElement, schema: JsonSchema) => number; +export declare const withIncreasedRank: (by: number, rankedTester: RankedTester) => (uischema: UISchemaElement, schema: JsonSchema) => number; diff --git a/dist/dist/ts-build/src/core/uischema.registry.d.ts b/dist/dist/ts-build/src/core/uischema.registry.d.ts new file mode 100644 index 000000000..304018f62 --- /dev/null +++ b/dist/dist/ts-build/src/core/uischema.registry.d.ts @@ -0,0 +1,63 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { UISchemaElement } from '../models/uischema'; +/** + * A registry of UI schemas. This registry can be utilized whenever + * multiple UI schemas are applicable for a given JSON schema in order + * to resolve ambiguity. + */ +export interface UISchemaRegistry { + /** + * Register a UI schema. + * + * @param {UISchemaElement} uiSchema the UI schema to be registered + * @param {UISchemaTester} tester the tester that determines whether + * the given UI schema should be used + */ + register(uiSchema: UISchemaElement, tester: UISchemaTester): void; + /** + * Deregister a UI schema. + * + * @param {UISchemaElement} uiSchema the UI schema to be unregistered + * @param {UISchemaTester} tester + */ + deregister(uiSchema: UISchemaElement, tester: UISchemaTester): void; + /** + * Find the UI schema that is most applicable for the given JSON schema + * and data. + * @param {JsonSchema} schema the JSON schema for which to find a UI schema + * @param {any} data the data for which to find a UI schema + */ + findMostApplicableUISchema(schema: JsonSchema, data: any): UISchemaElement; +} +/** + * A tester that returns a priority number when a JSON schema and some data, + * which determines how likely the associated UI schema will be used to + * render the JSON schema/data. The higher the returned number, the more likely + * the associated UI schema will be used. + */ +export declare type UISchemaTester = (schema: JsonSchema, data: any) => number; +/** + * Constant that indicates that a tester is not capable of handling + * a combination of schema/data. + * @type {number} + */ +export declare const NOT_APPLICABLE = -1; +/** + * Implementation of the UI schema registry. + */ +export declare class UISchemaRegistryImpl implements UISchemaRegistry { + private registry; + constructor(); + /** + * @inheritDoc + */ + register(uischema: UISchemaElement, tester: UISchemaTester): void; + /** + * @inheritDoc + */ + deregister(uischema: UISchemaElement, tester: UISchemaTester): void; + /** + * @inheritDoc + */ + findMostApplicableUISchema(schema: JsonSchema, data: any): UISchemaElement; +} diff --git a/dist/dist/ts-build/src/generators/schema-gen.d.ts b/dist/dist/ts-build/src/generators/schema-gen.d.ts new file mode 100644 index 000000000..09fbbe035 --- /dev/null +++ b/dist/dist/ts-build/src/generators/schema-gen.d.ts @@ -0,0 +1,8 @@ +import { JsonSchema } from '../models/jsonSchema'; +/** + * Generate a JSON schema based on the given data and any additional options. + * @param {Object} instance the data to create a JSON schema for + * @param {any} options any additional options that may alter the generated JSON schema + * @returns {JsonSchema} the generated schema + */ +export declare const generateJsonSchema: (instance: Object, options?: any) => JsonSchema; diff --git a/dist/dist/ts-build/src/generators/ui-schema-gen.d.ts b/dist/dist/ts-build/src/generators/ui-schema-gen.d.ts new file mode 100644 index 000000000..503e84fb1 --- /dev/null +++ b/dist/dist/ts-build/src/generators/ui-schema-gen.d.ts @@ -0,0 +1,9 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { UISchemaElement } from '../models/uischema'; +/** + * Generate a default UI schema. + * @param {JsonSchema} jsonSchema the JSON schema to generated a UI schema for + * @param {string} layoutType the desired layout type for the root layout + * of the generated UI schema + */ +export declare const generateDefaultUISchema: (jsonSchema: JsonSchema, layoutType?: string, prefix?: string) => UISchemaElement; diff --git a/dist/dist/ts-build/src/index.d.ts b/dist/dist/ts-build/src/index.d.ts new file mode 100644 index 000000000..d7e7ccc46 --- /dev/null +++ b/dist/dist/ts-build/src/index.d.ts @@ -0,0 +1,11 @@ +export * from './core'; +export * from './json-forms'; +export * from './path.util'; +export * from './core/renderer'; +export * from './core/runtime'; +export * from './core/schema.service'; +export * from './core/styling.registry'; +export * from './core/testers'; +export * from './models/uischema'; +export * from './models/jsonSchema'; +export * from './renderers'; diff --git a/dist/dist/ts-build/src/json-forms.d.ts b/dist/dist/ts-build/src/json-forms.d.ts new file mode 100644 index 000000000..4cda24a83 --- /dev/null +++ b/dist/dist/ts-build/src/json-forms.d.ts @@ -0,0 +1,52 @@ +import './renderers'; +import { UISchemaElement } from './models/uischema'; +import { JsonSchema } from './models/jsonSchema'; +import { Store } from 'redux'; +export interface JsonFormsStore extends Store { +} +/** + * HTML element that represents the entry point + */ +export declare class JsonFormsElement extends HTMLElement { + private dataObject; + private uischema; + private dataschema; + schemaPromise: Promise; + private allowDynamicUpdate; + store: Store; + /** + * Constructor. + */ + constructor(); + /** + * Called when this element is inserted into a document. + */ + connectedCallback(): void; + /** + * Set the data to be rendered. + * @param {Object} data the data to be rendered + */ + data: Object; + /** + * Returns the UI schema to be rendered. + * + * @returns {UISchemaElement} the UI schema to be rendered + */ + /** + * Set the UI schema. + * @param {UISchemaElement} uischema the UI schema element to be set + */ + uiSchema: UISchemaElement; + /** + * Returns the JSON schema that describes the data to be rendered. + * + * @returns {JsonSchema} the JSON schema that describes the data to be rendered + */ + /** + * Set the JSON data schema that describes the data to be rendered. + * @param {JsonSchema} dataSchema the data schema to be rendered + */ + dataSchema: JsonSchema; + private render(); + private instantiateSchemaIfNeeded(schema); +} diff --git a/dist/dist/ts-build/src/models/jsonSchema.d.ts b/dist/dist/ts-build/src/models/jsonSchema.d.ts new file mode 100644 index 000000000..51d748cac --- /dev/null +++ b/dist/dist/ts-build/src/models/jsonSchema.d.ts @@ -0,0 +1,132 @@ +/** + * MIT License + * + * Copyright (c) 2016 Richard Adams (https://github.com/enriched) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +export interface JsonSchema { + $ref?: string; + /** + * This is important because it tells refs where + * the root of the document is located + */ + id?: string; + /** + * It is recommended that the meta-schema is + * included in the root of any JSON Schema + */ + $schema?: JsonSchema; + /** + * Title of the schema + */ + title?: string; + /** + * Schema description + */ + description?: string; + /** + * Default json for the object represented by + * this schema + */ + 'default'?: any; + /** + * The value must be a multiple of the number + * (e.g. 10 is a multiple of 5) + */ + multipleOf?: number; + maximum?: number; + /** + * If true maximum must be > value, >= otherwise + */ + exclusiveMaximum?: boolean; + minimum?: number; + /** + * If true minimum must be < value, <= otherwise + */ + exclusiveMinimum?: boolean; + maxLength?: number; + minLength?: number; + /** + * This is a regex string that the value must + * conform to + */ + pattern?: string; + additionalItems?: boolean | JsonSchema; + items?: JsonSchema | JsonSchema[]; + maxItems?: number; + minItems?: number; + uniqueItems?: boolean; + maxProperties?: number; + minProperties?: number; + required?: string[]; + additionalProperties?: boolean | JsonSchema; + /** + * Holds simple JSON Schema definitions for + * referencing from elsewhere. + */ + definitions?: { + [key: string]: JsonSchema; + }; + /** + * The keys that can exist on the object with the + * json schema that should validate their value + */ + properties?: { + [property: string]: JsonSchema; + }; + /** + * The key of this object is a regex for which + * properties the schema applies to + */ + patternProperties?: { + [pattern: string]: JsonSchema; + }; + /** + * If the key is present as a property then the + * string of properties must also be present. + * If the value is a JSON Schema then it must + * also be valid for the object if the key is + * present. + */ + dependencies?: { + [key: string]: JsonSchema | string[]; + }; + /** + * Enumerates the values that this schema can be + * e.g. + * {"type": "string", + * "enum": ["red", "green", "blue"]} + */ + 'enum'?: any[]; + /** + * The basic type of this schema, can be one of + * [string, number, object, array, boolean, null] + * or an array of the acceptable types + */ + type?: string | string[]; + allOf?: JsonSchema[]; + anyOf?: JsonSchema[]; + oneOf?: JsonSchema[]; + /** + * The entity being validated must not match this schema + */ + not?: JsonSchema; + format?: string; +} diff --git a/dist/dist/ts-build/src/models/uischema.d.ts b/dist/dist/ts-build/src/models/uischema.d.ts new file mode 100644 index 000000000..282a8fbcc --- /dev/null +++ b/dist/dist/ts-build/src/models/uischema.d.ts @@ -0,0 +1,191 @@ +import { Runtime } from '../core/runtime'; +/** + * A rule that may be attached to any UI schema element. + */ +export interface Rule { + /** + * The effect of the rule + */ + effect: RuleEffect; + /** + * The condition of the rule that must evaluate to true in order + * to trigger the effect. + */ + condition: Condition; +} +/** + * The different rule effects. + */ +export declare enum RuleEffect { + /** + * Effect that hides the associated element. + */ + HIDE = "HIDE", + /** + * Effect that shows the associated element. + */ + SHOW = "SHOW", + /** + * Effect that enables the associated element. + */ + ENABLE = "ENABLE", + /** + * Effect that disables the associated element. + */ + DISABLE = "DISABLE", +} +/** + * Represents a condition to be evaluated. + */ +export interface Condition { + /** + * A string describing the type of condition + */ + type: string; +} +/** + * A leaf condition. + */ +export interface LeafCondition extends Condition { + /** + * The sub schema the condition is bound to. + */ + scope: { + $ref: string; + }; + /** + * The expected value when evaluating the condition + */ + expectedValue: any; +} +/** + * Common base interface for any UI schema element. + */ +export interface UISchemaElement { + /** + * The type of this UI schema element. + */ + type: string; + /** + * An optional rule. + */ + rule?: Rule; + /** + * Any additional options. + */ + options?: any; + /** + * Runtime object that encapsulates runtime state. + */ + runtime?: Runtime; +} +/** + * Represents a layout element which can order its children + * in a specific way. + */ +export interface Layout extends UISchemaElement { + /** + * The child elements of this layout. + */ + elements: UISchemaElement[]; +} +/** + * A layout which orders its child elements vertically (i.e. from top to bottom). + */ +export interface VerticalLayout extends Layout { + type: 'VerticalLayout'; +} +/** + * A layout which orders its children horizontally (i.e. from left to right). + */ +export interface HorizontalLayout extends Layout { + type: 'HorizontalLayout'; +} +/** + * A group resembles a vertical layout, but additionally might have a label. + * This layout is useful when grouping different elements by a certain criteria. + */ +export interface GroupLayout extends Layout { + type: 'Group'; + /** + * The label of this group layout. + */ + label?: string; +} +/** + * Represents an object that can be used to configure a label. + */ +export interface ILabelObject { + /** + * An optional text to be displayed. + */ + text?: string; + /** + * Optional property that determines whether to show this label. + */ + show?: boolean; +} +/** + * A label element. + */ +export interface LabelElement extends UISchemaElement { + type: 'Label'; + /** + * The text of label. + */ + text: string; +} +export interface Scopable { + /** + * The scope that determines to which part of the schema the control + * should be bound to. The $ref property is just a regular JSON pointer. + */ + scope: { + $ref: string; + }; +} +/** + * A control element. The scope property of the control determines + * to which part of the schema the control should be bound. + */ +export interface ControlElement extends UISchemaElement, Scopable { + type: 'Control'; + /** + * An optional label that will be associated with the control + */ + label?: string | boolean | ILabelObject; +} +export interface MasterDetailLayout extends UISchemaElement, Scopable { + type: 'MasterDetailLayout'; + /** + * An optional label that will be associated with the control + */ + label?: string | boolean | ILabelObject; +} +/** + * The category layout. + */ +export interface Category extends Layout { + type: 'Category'; + /** + * The label associated with this category layout. + */ + label: string; +} +/** + * The categorization element, which may have children elements. + * A child element may either be itself a Categorization or a Category, hence + * the categorization element can be used to represent recursive structures like trees. + */ +export interface Categorization extends UISchemaElement { + type: 'Categorization'; + /** + * The label of this categorization. + */ + label: string; + /** + * The child elements of this categorization which are either of type + * {@link Category} or {@link Categorization}. + */ + elements: (Category | Categorization)[]; +} diff --git a/dist/dist/ts-build/src/path.util.d.ts b/dist/dist/ts-build/src/path.util.d.ts new file mode 100644 index 000000000..aa90570c6 --- /dev/null +++ b/dist/dist/ts-build/src/path.util.d.ts @@ -0,0 +1,70 @@ +import { JsonSchema } from './models/jsonSchema'; +import { Scopable } from './models/uischema'; +export declare const compose: (path1: string, path2: string) => string; +/** + * Convert a schema path (i.e. JSON pointer) to an array by splitting + * at the '/' character and removing all schema-specific keywords. + * + * The returned value can be used to de-reference a root object by folding over it + * and derefercing the single segments to obtain a new object. + * + * + * @param {string} schemaPath the schema path to be converted + * @returns {string[]} an array containing only non-schema-specific segments + */ +export declare const toDataPathSegments: (schemaPath: string) => string[]; +/** + * Remove all schema-specific keywords (e.g. 'properties') from a given path. + * @example + * toDataPath('#/properties/foo/properties/bar') === '#/foo/bar') + * + * @param {string} schemaPath the schema path to be converted + * @returns {string} the path without schema-specific keywords + */ +export declare const toDataPath: (schemaPath: string) => string; +/** + * Resolve the given schema path against the given instance until the last + * segment. The returned value allows easy assignment of any new value. + * + * @example + * const pair = getValuePropertyPair(someData, someRef); + * pair.instance[pair.property] = someValue; + * + * @param {any} instance the instance to resolve the path against + * @param {string} schemaPath the schema path to be resolved + * @returns {{instance: string, property: string}} an object containing + * the resolved instance as well the last fragment of + */ +export declare const getValuePropertyPair: (instance: any, schemaPath: string) => { + instance: Object; + property: string; +}; +export declare const composeWithUi: (scopableUi: Scopable, path: string) => string; +export declare const resolveData: (data: any, path: any) => any; +/** + * Resolve the given schema path in order to obtain a subschema. + * @param {JsonSchema} schema the root schema from which to start + * @param {string} schemaPath the schema path to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +export declare const resolveSchema: (schema: JsonSchema, schemaPath: string) => JsonSchema; +/** + * Finds all references inside the given schema. + * + * @param schema The {@link JsonSchema} to find the references in + * @param result The initial result map, default: empty map (this parameter is used for recursion + * inside the function) + * @param resolveTuples Whether arrays of tuples should be considered; default: false + */ +export declare const findAllRefs: (schema: JsonSchema, result?: ReferenceSchemaMap, resolveTuples?: boolean) => ReferenceSchemaMap; +/** + * Normalizes the schema and resolves the given ref. + * + * @param {JsonSchema} full the JSON schema to resolved the reference against + * @param {string} reference the reference to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +export declare function retrieveResolvableSchema(full: JsonSchema, reference: string): JsonSchema; +export interface ReferenceSchemaMap { + [ref: string]: JsonSchema; +} diff --git a/dist/dist/ts-build/src/reducers/common.d.ts b/dist/dist/ts-build/src/reducers/common.d.ts new file mode 100644 index 000000000..79a24c35c --- /dev/null +++ b/dist/dist/ts-build/src/reducers/common.d.ts @@ -0,0 +1,12 @@ +export declare const commonStateReducer: (state: { + data: {}; + schema: {}; + uischema: {}; +}, action: any) => { + data: any; + schema: {}; + uischema: {}; +}; +export declare const extractData: (state: any) => any; +export declare const extractSchema: (state: any) => any; +export declare const extractUiSchema: (state: any) => any; diff --git a/dist/dist/ts-build/src/reducers/index.d.ts b/dist/dist/ts-build/src/reducers/index.d.ts new file mode 100644 index 000000000..5fe11dd29 --- /dev/null +++ b/dist/dist/ts-build/src/reducers/index.d.ts @@ -0,0 +1,7 @@ +import { Reducer } from 'redux'; +export declare const appReducer: Reducer; +export declare const getData: (state: any) => any; +export declare const getSchema: (state: any) => any; +export declare const getUiSchema: (state: any) => any; +export declare const getRuntime: (state: any) => any; +export declare const getValidation: (state: any) => any; diff --git a/dist/dist/ts-build/src/reducers/renderers.d.ts b/dist/dist/ts-build/src/reducers/renderers.d.ts new file mode 100644 index 000000000..c021a1d16 --- /dev/null +++ b/dist/dist/ts-build/src/reducers/renderers.d.ts @@ -0,0 +1,13 @@ +import { JsonFormsRendererConstructable } from '../renderers/renderer.util'; +import { RankedTester } from '../core/testers'; +export declare const rendererReducer: (state: { + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}[], {type, tester, renderer}: { + type: any; + tester: any; + renderer: any; +}) => { + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}[]; diff --git a/dist/dist/ts-build/src/reducers/validation.d.ts b/dist/dist/ts-build/src/reducers/validation.d.ts new file mode 100644 index 000000000..ede95f29b --- /dev/null +++ b/dist/dist/ts-build/src/reducers/validation.d.ts @@ -0,0 +1,9 @@ +import { ErrorObject, ValidateFunction } from 'ajv'; +import { JsonSchema } from '../models/jsonSchema'; +export interface ValidationState { + errors: ErrorObject[]; + validator: ValidateFunction; + schema: JsonSchema; +} +export declare const validationReducer: (state: ValidationState, action: any) => ValidationState; +export declare const errorAt: (instancePath: any) => (state: any) => any[]; diff --git a/dist/dist/ts-build/src/renderers/JSX.d.ts b/dist/dist/ts-build/src/renderers/JSX.d.ts new file mode 100644 index 000000000..464c711a3 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/JSX.d.ts @@ -0,0 +1 @@ +export declare const JSX: any; diff --git a/dist/dist/ts-build/src/renderers/additional/array-renderer.d.ts b/dist/dist/ts-build/src/renderers/additional/array-renderer.d.ts new file mode 100644 index 000000000..4964eb3bd --- /dev/null +++ b/dist/dist/ts-build/src/renderers/additional/array-renderer.d.ts @@ -0,0 +1,18 @@ +import { Renderer } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +export declare const getStyle: (styleName: string) => string; +/** + * Default tester for an array control. + * @type {RankedTester} + */ +export declare const arrayTester: RankedTester; +export declare class ArrayControlRenderer extends Renderer { + addNewItem(path: string): void; + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/additional/categorization-renderer.d.ts b/dist/dist/ts-build/src/renderers/additional/categorization-renderer.d.ts new file mode 100644 index 000000000..7ae621c8d --- /dev/null +++ b/dist/dist/ts-build/src/renderers/additional/categorization-renderer.d.ts @@ -0,0 +1,14 @@ +import { RankedTester } from '../../core/testers'; +import { Category } from '../../models/uischema'; +/** + * Default tester for a categorization. + * @type {RankedTester} + */ +export declare const categorizationTester: RankedTester; +export interface CategorizationState { + selected: { + category: Category; + }; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/additional/label.renderer.d.ts b/dist/dist/ts-build/src/renderers/additional/label.renderer.d.ts new file mode 100644 index 000000000..b50eded1c --- /dev/null +++ b/dist/dist/ts-build/src/renderers/additional/label.renderer.d.ts @@ -0,0 +1,18 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a label. + * @type {RankedTester} + */ +export declare const labelRendererTester: RankedTester; +/** + * Default renderer for a label. + */ +export declare class LabelRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/additional/table-array.control.d.ts b/dist/dist/ts-build/src/renderers/additional/table-array.control.d.ts new file mode 100644 index 000000000..760216525 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/additional/table-array.control.d.ts @@ -0,0 +1,18 @@ +import { Renderer } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +/** + * Alternative tester for an array that also checks whether the 'table' + * option is set. + * @type {RankedTester} + */ +export declare const tableArrayTester: RankedTester; +export declare class TableArrayControl extends Renderer { + addNewItem(path: string): void; + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/additional/tree-renderer.d.ts b/dist/dist/ts-build/src/renderers/additional/tree-renderer.d.ts new file mode 100644 index 000000000..f45f018bd --- /dev/null +++ b/dist/dist/ts-build/src/renderers/additional/tree-renderer.d.ts @@ -0,0 +1,56 @@ +import { Renderer } from '../../core/renderer'; +import { JsonSchema } from '../../models/jsonSchema'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +/** + * Default tester for a master-detail layout. + * @type {RankedTester} + */ +export declare const treeMasterDetailTester: RankedTester; +export interface TreeMasterDetailState { + selected: { + schema: JsonSchema; + data: any; + path: string; + }; +} +export declare class TreeMasterDetail extends Renderer { + componentWillMount(): void; + render(): any; + openDialog(ev: Event, schema: JsonSchema, parentPath: string): void; + private closeDialog(); + private addToRoot(); + private renderMaster(schema); + /** + * Expands the given array of root elements by expanding every element. + * It is assumed that the roor elements do not support drag and drop. + * Based on this, a delete function is created for every element. + * + * @param data the array to expand + * @param schema the {@link JsonSchema} defining the elements' type + */ + private expandRootArray(schema); + /** + * Expands the given data array by expanding every element. + * If the parent data containing the array is provided, + * a suitable delete function for the expanded elements is created. + * + * @param data the array to expand + * @param property the {@link ContainmentProperty} defining the property that the array belongs to + * @param parentData the data containing the array as a property + */ + private expandArray(data, property, path, parentData?); + private getNamingFunction(schema); + /** + * Renders a data object as a

    • child element of the given
        list. + * + * @param data The rendered data + * @param schema The schema describing the rendered data's type + * @param deleteFunction A function to delete the data from the model + */ + private expandObject(scopedPath, schema, deleteFunction); + private propHasData(prop, data); + private renderChildren(prop, parentPath, parentSchema, parentData); +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/controls/Control.d.ts b/dist/dist/ts-build/src/renderers/controls/Control.d.ts new file mode 100644 index 000000000..e3682c7f6 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/Control.d.ts @@ -0,0 +1,18 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +export interface ControlClassNames { + input: string; + label: string; + wrapper: string; +} +export interface ControlProps extends RendererProps { + data: any; + path: string; + classNames: ControlClassNames; + id: string; + visible: boolean; + enabled: boolean; + label: string; +} +export declare class Control

        extends Renderer { + updateData(value: any): void; +} diff --git a/dist/dist/ts-build/src/renderers/controls/boolean.control.d.ts b/dist/dist/ts-build/src/renderers/controls/boolean.control.d.ts new file mode 100644 index 000000000..f69dae5b7 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/boolean.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for boolean controls. + * @type {RankedTester} + */ +export declare const booleanControlTester: RankedTester; +export declare class BooleanControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/controls/date.control.d.ts b/dist/dist/ts-build/src/renderers/controls/date.control.d.ts new file mode 100644 index 000000000..dd1dfd926 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/date.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for date controls. + * @type {RankedTester} + */ +export declare const dateControlTester: RankedTester; +export declare class DateControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/controls/enum.control.d.ts b/dist/dist/ts-build/src/renderers/controls/enum.control.d.ts new file mode 100644 index 000000000..15610cfd0 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/enum.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for enum controls. + * @type {RankedTester} + */ +export declare const enumControlTester: RankedTester; +export declare class EnumControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/controls/integer.control.d.ts b/dist/dist/ts-build/src/renderers/controls/integer.control.d.ts new file mode 100644 index 000000000..de63cee88 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/integer.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for integer controls. + * @type {RankedTester} + */ +export declare const integerControlTester: RankedTester; +export declare class IntegerControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/controls/number.control.d.ts b/dist/dist/ts-build/src/renderers/controls/number.control.d.ts new file mode 100644 index 000000000..93e9e3b8a --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/number.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for number controls. + * @type {RankedTester} + */ +export declare const numberControlTester: RankedTester; +export declare class NumberControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/controls/text.control.d.ts b/dist/dist/ts-build/src/renderers/controls/text.control.d.ts new file mode 100644 index 000000000..dc8559cc6 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/text.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for text-based/string controls. + * @type {RankedTester} + */ +export declare const textControlTester: RankedTester; +export declare class TextControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/controls/textarea.control.d.ts b/dist/dist/ts-build/src/renderers/controls/textarea.control.d.ts new file mode 100644 index 000000000..82b6ebb81 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/controls/textarea.control.d.ts @@ -0,0 +1,16 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Tester for a multi-line string control. + * @type {RankedTester} + */ +export declare const textAreaControlTester: RankedTester; +export declare class TextAreaControl extends Control { + render(): any; + /** + * @inheritDoc + */ + protected toInput(value: any): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/dispatch-renderer.d.ts b/dist/dist/ts-build/src/renderers/dispatch-renderer.d.ts new file mode 100644 index 000000000..17a144231 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/dispatch-renderer.d.ts @@ -0,0 +1,26 @@ +import { UISchemaElement } from '../models/uischema'; +import { JsonSchema } from '../models/jsonSchema'; +import { RankedTester } from '../core/testers'; +export interface DispatchRendererProps { + /** + * The UI schema to be rendered. + */ + uischema: UISchemaElement; + /** + * The JSON schema that describes the data. + */ + schema: JsonSchema; + renderers: { + tester: RankedTester; + renderer: any; + }[]; + /** + * Optional instance path. Necessary when the actual data + * path can not be inferred via the UI schema element as + * it is the case with nested controls. + */ + path?: string; +} +export declare const DispatchRenderer: (props: DispatchRendererProps) => any; +export declare const JsonFormsRenderer: (props: DispatchRendererProps) => any; +export default JsonFormsRenderer; diff --git a/dist/dist/ts-build/src/renderers/index.d.ts b/dist/dist/ts-build/src/renderers/index.d.ts new file mode 100644 index 000000000..9ae0e921f --- /dev/null +++ b/dist/dist/ts-build/src/renderers/index.d.ts @@ -0,0 +1,19 @@ +export * from './label.util'; +export * from './renderer.util'; +export * from './controls/Control'; +export * from './controls/text.control'; +export * from './controls/boolean.control'; +export * from './controls/integer.control'; +export * from './controls/number.control'; +export * from './controls/date.control'; +export * from './controls/enum.control'; +export * from './controls/textarea.control'; +export * from './layouts/vertical.layout'; +export * from './layouts/horizontal.layout'; +export * from './layouts/group.layout'; +export * from './additional/array-renderer'; +export * from './additional/tree-renderer'; +export * from './additional/categorization-renderer'; +export * from './additional/table-array.control'; +export * from './additional/label.renderer'; +export * from './JSX'; diff --git a/dist/dist/ts-build/src/renderers/label.util.d.ts b/dist/dist/ts-build/src/renderers/label.util.d.ts new file mode 100644 index 000000000..952cdf9f4 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/label.util.d.ts @@ -0,0 +1,9 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ControlElement, ILabelObject } from '../models/uischema'; +/** + * Return a label object based on the given JSON schema and control element. + * @param {JsonSchema} schema the JSON schema that the given control element is referring to + * @param {ControlElement} controlElement the UI schema to obtain a label object for + * @returns {ILabelObject} + */ +export declare const getElementLabelObject: (schema: JsonSchema, controlElement: ControlElement) => ILabelObject; diff --git a/dist/dist/ts-build/src/renderers/layouts/group.layout.d.ts b/dist/dist/ts-build/src/renderers/layouts/group.layout.d.ts new file mode 100644 index 000000000..d8d81a3d9 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/layouts/group.layout.d.ts @@ -0,0 +1,13 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a group layout. + * + * @type {RankedTester} + */ +export declare const groupTester: RankedTester; +export declare class GroupLayoutRenderer extends Renderer { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/layouts/horizontal.layout.d.ts b/dist/dist/ts-build/src/renderers/layouts/horizontal.layout.d.ts new file mode 100644 index 000000000..458ac9b1b --- /dev/null +++ b/dist/dist/ts-build/src/renderers/layouts/horizontal.layout.d.ts @@ -0,0 +1,15 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a horizontal layout. + * @type {RankedTester} + */ +export declare const horizontalLayoutTester: RankedTester; +export declare class HorizontalLayoutRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/layouts/vertical.layout.d.ts b/dist/dist/ts-build/src/renderers/layouts/vertical.layout.d.ts new file mode 100644 index 000000000..0b7c4d070 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/layouts/vertical.layout.d.ts @@ -0,0 +1,15 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a vertical layout. + * @type {RankedTester} + */ +export declare const verticalLayoutTester: RankedTester; +export declare class VerticalLayoutRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/dist/ts-build/src/renderers/renderer.util.d.ts b/dist/dist/ts-build/src/renderers/renderer.util.d.ts new file mode 100644 index 000000000..d0bc5033e --- /dev/null +++ b/dist/dist/ts-build/src/renderers/renderer.util.d.ts @@ -0,0 +1,52 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { Renderer, RendererProps } from '../core/renderer'; +import { RankedTester } from '../core/testers'; +import { UISchemaElement } from '../models/uischema'; +/** + * A renderer config that is used during renderer registration. + */ +export interface JsonFormsRendererConfig { + /** + * The tester that that determines how applicable + * the renderer is. + */ + tester: RankedTester; +} +export interface JsonFormsRendererConstructable { + new (props: RendererProps): Renderer; +} +/** + * Renderer annotation that defines the renderer as a custom elemeent + * and registers it with the renderer service. + * + * @param {JsonFormsRendererConfig} config the renderer config to be registered + * @constructor + */ +export declare const JsonFormsRenderer: (config: JsonFormsRendererConfig) => (cls: JsonFormsRendererConstructable) => void; +export declare const mapStateToLayoutProps: (state: any, ownProps: any) => { + renderers: any; + visible: any; + path: any; +}; +export declare const renderChildren: (elements: UISchemaElement[], schema: JsonSchema, childType: string, path: string) => any[]; +export declare const JsonFormsLayout: ({styleName, children, visible}: { + styleName: any; + children: any; + visible: any; +}) => any; +export declare const formatErrorMessage: (errors: any) => any; +export declare const registerStartupRenderer: (tester: RankedTester, renderer: any) => any; +export declare const mapStateToControlProps: (state: any, ownProps: any) => { + data: any; + errors: any[]; + classNames: { + wrapper: string; + input: string; + label: string; + }; + label: string; + visible: any; + enabled: any; + controlId: string; + path: string; +}; diff --git a/dist/dist/ts-build/src/renderers/unknown.renderer.d.ts b/dist/dist/ts-build/src/renderers/unknown.renderer.d.ts new file mode 100644 index 000000000..af10c6e42 --- /dev/null +++ b/dist/dist/ts-build/src/renderers/unknown.renderer.d.ts @@ -0,0 +1,4 @@ +import { Renderer, RendererProps } from '../core/renderer'; +export declare class UnknownRenderer extends Renderer { + render(): any; +} diff --git a/dist/dist/ts-build/src/store.d.ts b/dist/dist/ts-build/src/store.d.ts new file mode 100644 index 000000000..93722b1a6 --- /dev/null +++ b/dist/dist/ts-build/src/store.d.ts @@ -0,0 +1,5 @@ +import { JsonFormsStore } from './json-forms'; +import { JsonSchema } from './models/jsonSchema'; +import { UISchemaElement } from './models/uischema'; +export declare const createJsonFormsStore: (initialState: any) => JsonFormsStore; +export declare const initJsonFormsStore: (data: any, schema: JsonSchema, uischema: UISchemaElement) => JsonFormsStore; diff --git a/dist/dist/ts-build/store.d.ts b/dist/dist/ts-build/store.d.ts new file mode 100644 index 000000000..93722b1a6 --- /dev/null +++ b/dist/dist/ts-build/store.d.ts @@ -0,0 +1,5 @@ +import { JsonFormsStore } from './json-forms'; +import { JsonSchema } from './models/jsonSchema'; +import { UISchemaElement } from './models/uischema'; +export declare const createJsonFormsStore: (initialState: any) => JsonFormsStore; +export declare const initJsonFormsStore: (data: any, schema: JsonSchema, uischema: UISchemaElement) => JsonFormsStore; diff --git a/dist/icons/drive.png b/dist/icons/drive.png new file mode 100644 index 0000000000000000000000000000000000000000..37b7c9b27d39acaaecf06951b024ac08afbfd4d2 GIT binary patch literal 346 zcmV-g0j2(lP)`6pHR4C7- zkv&QTK@f$%UVGNSAB4p~7X&kJu`rW(3s2w)1kd9QoMeZ&fx$)tn+OJimk zjCT$JD?{UrQ?3~v=-g&C?-zWP;E3TkpyGrhTDFaQSzpwKU?tq9Uh&CO=Y?-R7%>t` z!bl_(!*h(_r3OLS;FuM!k+?!xBDEihL=?r53TBrP2>202N!*Y~*dL6MvS5Ku!P&n9 sT@vv>?encL=G!4ixo5^&>-PTUFAyGx1U4B=kpKVy07*qoM6N<$g0$g{=l}o! literal 0 HcmV?d00001 diff --git a/dist/icons/folder.png b/dist/icons/folder.png new file mode 100644 index 0000000000000000000000000000000000000000..784e8fa48234f4f64b6922a6758f254ee0ca08ec GIT binary patch literal 537 zcmV+!0_OdRP)x(K@^6+>g^d@v4;gkbWsEoXE%32*i1tcpTNXd5CcIl)ECgqz|2rE6EW}s7R?kl za1q`0GCkMruC6-2LANtwVlsgzsp4?{@7$`KBv!G66>Vie3h?3OmEEkjwdLG0PgLVi z`!N((f$A@n17Ldj#`};0I3@iHJ5M{#IZz|UIYRm4(!uV7eYIYIwQf&}_2J~}>pQ^n z6o8--^T(=hkBNQ_k{-_GWE;FMW7!p}f{NG3nHZ{D5<3d8&tLh%a4AqqnjMkr3m&fkMdECD3N5}Unig5wy40;>lo4j~k+e}v)` zR6)J8Mk*u=SpB`p6o)7j?S0T@9?bz#m@l>gc*zk__|*!FMcHwP!gwLJvS~9c0px8E zW0)+jEP);68^d)m`eN0o>(5%D`Q(1;j>g@G;xlf`0VBQ`PFY?6)!N&f?*K}$p; zB!U=NBn{eB8${1}&-2_L*HuZp@ZP1@clS@cHp)4iM1ewzw59vko7eMM{e9z|%NNdX z0V;`?KKSzTCvTm5bc{L^CIKLUxc2X{i{ISz$8Sgf{q)1nXTP{`{s?9mQ$4&hPiKC- zY8q7(Y1Xu5iCf33=O4Vy(+|zQ?rW#gkKB0f%}?+6{G*qT22|DQB-73`YzA{N4W^=s zq0kQYcbtFfz zLz)H<&|z(Y4k any) => ThunkAction; +export declare const validate: () => (dispatch: any, getState: any) => void; +export declare const registerRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { + type: string; + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}; +export declare const unregisterRenderer: (tester: RankedTester, renderer: JsonFormsRendererConstructable) => { + type: string; + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}; diff --git a/dist/ts-build/actions.js b/dist/ts-build/actions.js new file mode 100644 index 000000000..cac54226d --- /dev/null +++ b/dist/ts-build/actions.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_1 = require("./reducers/index"); +exports.INIT = 'INIT'; +exports.UPDATE_DATA = 'UPDATE'; +exports.UPDATE_UI = 'UPDATE_UI'; +exports.VALIDATE = 'VALIDATE'; +exports.SHOW = 'SHOW'; +exports.HIDE = 'HIDE'; +exports.ENABLE = 'ENABLE'; +exports.DISABLE = 'DISABLE'; +exports.ADD_RENDERER = 'ADD_RENDERER'; +exports.REMOVE_RENDERER = 'REMOVE_RENDERER'; +// TODO: fix typings +exports.update = function (path, updater) { + return function (dispatch, getState) { + dispatch({ + type: exports.UPDATE_DATA, + path: path, + updater: updater + }); + dispatch({ + type: exports.VALIDATE, + data: index_1.getData(getState()) + }); + }; +}; +exports.validate = function () { return function (dispatch, getState) { + dispatch({ + type: exports.VALIDATE, + data: index_1.getData(getState()) + }); +}; }; +exports.registerRenderer = function (tester, renderer) { return ({ + type: exports.ADD_RENDERER, + tester: tester, + renderer: renderer +}); }; +exports.unregisterRenderer = function (tester, renderer) { return ({ + type: exports.REMOVE_RENDERER, + tester: tester, + renderer: renderer +}); }; +//# sourceMappingURL=actions.js.map \ No newline at end of file diff --git a/dist/ts-build/actions.js.map b/dist/ts-build/actions.js.map new file mode 100644 index 000000000..114894645 --- /dev/null +++ b/dist/ts-build/actions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":";;AACA,0CAA2C;AAI9B,QAAA,IAAI,GAAG,MAAM,CAAC;AACd,QAAA,WAAW,GAAG,QAAQ,CAAC;AACvB,QAAA,SAAS,GAAG,WAAW,CAAC;AACxB,QAAA,QAAQ,GAAG,UAAU,CAAC;AACtB,QAAA,IAAI,GAAG,MAAM,CAAC;AACd,QAAA,IAAI,GAAG,MAAM,CAAC;AACd,QAAA,MAAM,GAAG,QAAQ,CAAC;AAClB,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEjD,oBAAoB;AACP,QAAA,MAAM,GACjB,UAAC,IAAY,EAAE,OAAqB;IAClC,OAAA,UAAC,QAAQ,EAAE,QAAQ;QACjB,QAAQ,CACN;YACE,IAAI,EAAE,mBAAW;YACjB,IAAI,MAAA;YACJ,OAAO,SAAA;SACR,CACF,CAAC;QACF,QAAQ,CACN;YACE,IAAI,EAAE,gBAAQ;YACd,IAAI,EAAE,eAAO,CAAC,QAAQ,EAAE,CAAC;SAC1B,CACF,CAAC;IACJ,CAAC;AAdD,CAcC,CAAC;AAEO,QAAA,QAAQ,GAAG,cAAM,OAAA,UAAC,QAAQ,EAAE,QAAQ;IAC/C,QAAQ,CAAC;QACP,IAAI,EAAE,gBAAQ;QACd,IAAI,EAAE,eAAO,CAAC,QAAQ,EAAE,CAAC;KAC1B,CAAC,CAAC;AACL,CAAC,EAL6B,CAK7B,CAAC;AAEW,QAAA,gBAAgB,GAAG,UAC9B,MAAoB,EACpB,QAAwC,IACrC,OAAA,CAAC;IACJ,IAAI,EAAE,oBAAY;IAClB,MAAM,QAAA;IACN,QAAQ,UAAA;CACT,CAAC,EAJG,CAIH,CAAC;AAEU,QAAA,kBAAkB,GAAG,UAChC,MAAoB,EACpB,QAAwC,IACrC,OAAA,CAAC;IACJ,IAAI,EAAE,uBAAe;IACrB,MAAM,QAAA;IACN,QAAQ,UAAA;CACT,CAAC,EAJG,CAIH,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/core.d.ts b/dist/ts-build/core.d.ts new file mode 100644 index 000000000..bd6626521 --- /dev/null +++ b/dist/ts-build/core.d.ts @@ -0,0 +1,75 @@ +import { UISchemaElement } from './models/uischema'; +import { JsonSchema } from './models/jsonSchema'; +import { UISchemaRegistry } from './core/uischema.registry'; +import { StylingRegistry } from './core/styling.registry'; +import { SchemaService } from './core/schema.service'; +import { Store } from 'redux'; +/** + * Represents a JSONForms service. + */ +export interface JsonFormService { + /** + * Disposes this service. + */ + dispose(): void; +} +export declare class JsonFormsConfig { + private _identifyingProp; + setIdentifyingProp(propName: string): void; + getIdentifyingProp(): any; + shouldGenerateIdentifier(): boolean; +} +/** + * Encapsulates instantiation logic of a JSONForms service. + */ +export interface JsonFormsServiceConstructable { + /** + * Constructor logic. + * + * @param {store} + * @param {JsonSchema} dataSchema the JSON schema describing the data + * @param {UISchemaElement} uiSchema the UI schema to be rendered + */ + new (store: Store, dataSchema: JsonSchema, uiSchema: UISchemaElement): JsonFormService; +} +/** + * Global JSONForms object that holds services and registries. + */ +export declare class JsonForms { + private static _config; + private static _schemaService; + static renderers: any[]; + static jsonFormsServices: JsonFormsServiceConstructable[]; + static uischemaRegistry: UISchemaRegistry; + static stylingRegistry: StylingRegistry; + static modelMapping: any; + static schema: JsonSchema; + static readonly schemaService: SchemaService; + static readonly config: JsonFormsConfig; + /** + * Uses the model mapping to filter all objects that are associated with the type + * defined by the given schema id. If there is no applicable mapping, + * we assume that no mapping is necessary and do not filter out affected data objects. + * + * @param objects the list of data objects to filter + * @param schemaId The id of the JsonSchema defining the type to filter for + * @return The filtered data objects or all objects if there is no applicable mapping + */ + static filterObjectsByType: (objects: Object[], schemaId: string) => Object[]; + /** + * Uses the model mapping to find the schema id defining the type of the given object. + * If no schema id can be determined either because the object is empty, there is no model + * mapping, or the object does not contain a mappable property. + * TODO expected behavior? + * + * @param object The object whose type is determined + * @return The schema id of the object or null if it could not be determined + */ + static getSchemaIdForObject: (object: Object) => string; +} +/** + * Annotation for registering a class as JSONForms service. + * @param config + * @constructor + */ +export declare const JsonFormsServiceElement: (config: any) => (cls: JsonFormsServiceConstructable) => void; diff --git a/dist/ts-build/core.js b/dist/ts-build/core.js new file mode 100644 index 000000000..8991512b8 --- /dev/null +++ b/dist/ts-build/core.js @@ -0,0 +1,109 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var uischema_registry_1 = require("./core/uischema.registry"); +var styling_registry_1 = require("./core/styling.registry"); +var schema_service_impl_1 = require("./core/schema.service.impl"); +var JsonFormsConfig = /** @class */ (function () { + function JsonFormsConfig() { + } + JsonFormsConfig.prototype.setIdentifyingProp = function (propName) { + this._identifyingProp = propName; + }; + JsonFormsConfig.prototype.getIdentifyingProp = function () { + return this._identifyingProp; + }; + JsonFormsConfig.prototype.shouldGenerateIdentifier = function () { + return this._identifyingProp !== undefined; + }; + return JsonFormsConfig; +}()); +exports.JsonFormsConfig = JsonFormsConfig; +/** + * Global JSONForms object that holds services and registries. + */ +var JsonForms = /** @class */ (function () { + function JsonForms() { + } + Object.defineProperty(JsonForms, "schema", { + set: function (schema) { + JsonForms._schemaService = new schema_service_impl_1.SchemaServiceImpl(schema); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JsonForms, "schemaService", { + get: function () { + if (this._schemaService === undefined) { + console.error('Schema service has not been initialized'); + } + return this._schemaService; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JsonForms, "config", { + get: function () { + return this._config; + }, + enumerable: true, + configurable: true + }); + JsonForms._config = new JsonFormsConfig(); + JsonForms.renderers = []; + JsonForms.jsonFormsServices = []; + JsonForms.uischemaRegistry = new uischema_registry_1.UISchemaRegistryImpl(); + JsonForms.stylingRegistry = new styling_registry_1.StylingRegistryImpl(); + /** + * Uses the model mapping to filter all objects that are associated with the type + * defined by the given schema id. If there is no applicable mapping, + * we assume that no mapping is necessary and do not filter out affected data objects. + * + * @param objects the list of data objects to filter + * @param schemaId The id of the JsonSchema defining the type to filter for + * @return The filtered data objects or all objects if there is no applicable mapping + */ + JsonForms.filterObjectsByType = function (objects, schemaId) { + return objects.filter(function (value) { + var valueSchemaId = JsonForms.getSchemaIdForObject(value); + if (valueSchemaId === null) { + return true; + } + return valueSchemaId === schemaId; + }); + }; + /** + * Uses the model mapping to find the schema id defining the type of the given object. + * If no schema id can be determined either because the object is empty, there is no model + * mapping, or the object does not contain a mappable property. + * TODO expected behavior? + * + * @param object The object whose type is determined + * @return The schema id of the object or null if it could not be determined + */ + JsonForms.getSchemaIdForObject = function (object) { + if (JsonForms.modelMapping !== undefined && !_.isEmpty(object)) { + var mappingAttribute = JsonForms.modelMapping.attribute; + if (!_.isEmpty(mappingAttribute)) { + var mappingValue = object[mappingAttribute]; + var schemaElementId = JsonForms.modelMapping.mapping[mappingValue]; + return !_.isEmpty(schemaElementId) ? schemaElementId : null; + } + } + return null; + }; + return JsonForms; +}()); +exports.JsonForms = JsonForms; +/** + * Annotation for registering a class as JSONForms service. + * @param config + * @constructor + */ +// Disable rule because it is used as an decorator +// tslint:disable:variable-name +exports.JsonFormsServiceElement = function (config) { return function (cls) { + JsonForms.jsonFormsServices.push(cls); +}; }; +// tslint:enable:variable-name +//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/dist/ts-build/core.js.map b/dist/ts-build/core.js.map new file mode 100644 index 000000000..1928bde1f --- /dev/null +++ b/dist/ts-build/core.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAG5B,8DAAkF;AAClF,4DAA+E;AAE/E,kEAA+D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E,CAAC,CAAC,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC,IAAI,CAAC;YACd,CAAC;YAED,MAAM,CAAC,aAAa,KAAK,QAAQ,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAA;IAED;;;;;;;;OAQG;IACI,8BAAoB,GAAG,UAAC,MAAc;QAC3C,EAAE,CAAC,CAAC,SAAS,CAAC,YAAY,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/D,IAAM,gBAAgB,GAAG,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC;YAC1D,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAM,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;gBAC9C,IAAM,eAAe,GAAW,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBAE7E,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;YAC9D,CAAC;QACH,CAAC;QAED,MAAM,CAAC,IAAI,CAAC;IACd,CAAC,CAAA;IACH,gBAAC;CAAA,AAjED,IAiEC;AAjEY,8BAAS;AAmEtB;;;;GAIG;AACH,kDAAkD;AAClD,+BAA+B;AAClB,QAAA,uBAAuB,GAAG,UAAA,MAAM,IAAI,OAAA,UAAC,GAAkC;IAClF,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC,EAFgD,CAEhD,CAAC;AACF,8BAA8B"} \ No newline at end of file diff --git a/dist/ts-build/core/renderer.d.ts b/dist/ts-build/core/renderer.d.ts new file mode 100644 index 000000000..05cfe5d4b --- /dev/null +++ b/dist/ts-build/core/renderer.d.ts @@ -0,0 +1,20 @@ +import Component from 'inferno-component'; +import { JsonSchema } from '../models/jsonSchema'; +import { Scopable, UISchemaElement } from '../models/uischema'; +import { JsonFormsStore } from '../json-forms'; +export declare const convertToClassName: (value: string) => string; +export declare const getValue: (data: any, controlElement: Scopable, prefix?: string) => any; +export interface RendererProps { + uischema: UISchemaElement; + store: JsonFormsStore; + schema: JsonSchema; +} +export interface RendererState { + selected?: any; +} +export declare class Renderer

        extends Component { +} +export declare const isVisible: (props: any, state: any) => boolean; +export declare const isEnabled: (props: any, state: any) => boolean; +export declare const evalVisibility: (uischema: UISchemaElement, data: any) => boolean; +export declare const evalEnablement: (uischema: UISchemaElement, data: any) => boolean; diff --git a/dist/ts-build/core/renderer.js b/dist/ts-build/core/renderer.js new file mode 100644 index 000000000..b0f66a5bf --- /dev/null +++ b/dist/ts-build/core/renderer.js @@ -0,0 +1,94 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var inferno_component_1 = require("inferno-component"); +var uischema_1 = require("../models/uischema"); +var path_util_1 = require("../path.util"); +var index_1 = require("../reducers/index"); +exports.convertToClassName = function (value) { + var result = value.replace('#', 'root'); + result = result.replace(new RegExp('/', 'g'), '_'); + return result; +}; +exports.getValue = function (data, controlElement, prefix) { + if (prefix === void 0) { prefix = ''; } + if (_.isEmpty(controlElement)) { + return undefined; + } + var path = _.isEmpty(prefix) ? + controlElement.scope.$ref : + prefix + controlElement.scope.$ref.substr(1); + var pair = path_util_1.getValuePropertyPair(data, path); + if (pair.property === undefined) { + return pair.instance; + } + return pair.instance[pair.property]; +}; +var Renderer = /** @class */ (function (_super) { + __extends(Renderer, _super); + function Renderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Renderer; +}(inferno_component_1.default)); +exports.Renderer = Renderer; +// TODO: pass in uischema and data instead of props and state +exports.isVisible = function (props, state) { + if (props.uischema.rule) { + return exports.evalVisibility(props.uischema, index_1.getData(state)); + } + return true; +}; +exports.isEnabled = function (props, state) { + if (props.uischema.rule) { + return exports.evalEnablement(props.uischema, index_1.getData(state)); + } + return true; +}; +exports.evalVisibility = function (uischema, data) { + // TODO condition evaluation should be done somewhere else + if (!_.has(uischema, 'rule.condition')) { + return true; + } + var condition = uischema.rule.condition; + var ref = condition.scope.$ref; + var pair = path_util_1.getValuePropertyPair(data, ref); + var value = pair.instance[pair.property]; + var equals = value === condition.expectedValue; + switch (uischema.rule.effect) { + case uischema_1.RuleEffect.HIDE: return !equals; + case uischema_1.RuleEffect.SHOW: return equals; + default: + // visible by default + return true; + } +}; +exports.evalEnablement = function (uischema, data) { + if (!_.has(uischema, 'rule.condition')) { + return true; + } + // TODO condition evaluation should be done somewhere else + var condition = uischema.rule.condition; + var ref = condition.scope.$ref; + var pair = path_util_1.getValuePropertyPair(data, ref); + var value = pair.instance[pair.property]; + var equals = value === condition.expectedValue; + switch (uischema.rule.effect) { + case uischema_1.RuleEffect.DISABLE: return !equals; + case uischema_1.RuleEffect.ENABLE: return equals; + default: + // enabled by default + return true; + } +}; +//# sourceMappingURL=renderer.js.map \ No newline at end of file diff --git a/dist/ts-build/core/renderer.js.map b/dist/ts-build/core/renderer.js.map new file mode 100644 index 000000000..bb0557a05 --- /dev/null +++ b/dist/ts-build/core/renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/core/renderer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0BAA4B;AAC5B,uDAA0C;AAE1C,+CAA0F;AAC1F,0CAAoD;AAEpD,2CAA4C;AAE/B,QAAA,kBAAkB,GAAG,UAAC,KAAa;IAC9C,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,EAAE,IAAS;IAEjE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED,0DAA0D;IAC1D,IAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,SAA0B,CAAC;IAC3D,IAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;IACjC,IAAM,IAAI,GAAG,gCAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC7C,IAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAM,MAAM,GAAG,KAAK,KAAK,SAAS,CAAC,aAAa,CAAC;IAEjD,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7B,KAAK,qBAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC;QACxC,KAAK,qBAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACtC;YACE,qBAAqB;YACrB,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;AACH,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/core/runtime.d.ts b/dist/ts-build/core/runtime.d.ts new file mode 100644 index 000000000..c68727d99 --- /dev/null +++ b/dist/ts-build/core/runtime.d.ts @@ -0,0 +1,75 @@ +/** + * The different types of runtime related changes. + */ +export declare enum RUNTIME_TYPE { + VALIDATION_ERROR = 0, + VISIBLE = 1, + ENABLED = 2, +} +/** + * A listener that is notified about any runtime related changes. + */ +export interface RuntimeListener { + /** + * Called when a runtime related property changes. + * @param {RUNTIME_TYPE} type the type of runtime change + */ + runtimeUpdated(type: RUNTIME_TYPE): void; +} +/** + * A runtime object holds information about runtime related properties + * of a rendered UI schema element, like the visible/disabled state and + * possible validation errors. + */ +export declare class Runtime { + private validationErrorMessages; + private isVisible; + private isEnabled; + private listeners; + /** + * Whether the element is visible. + * @return {boolean} true, if the element is visible, false otherwise + */ + /** + * Set the visibility state of the element + * @param {boolean} visible whether the element should be visible + */ + visible: boolean; + /** + * Whether the element is enabled. + * @return {boolean} true, if the element is enabled, false otherwise + */ + /** + * Set the enabled state of the element + * @param {boolean} enabled whether the element should be enabled + */ + enabled: boolean; + /** + * Returns the validation errors associated with the element. + * @return {Array} the validation errors + */ + /** + * Set the validation errors. + * + * @param {string[]} validationErrors the validation errors + */ + validationErrors: string[]; + /** + * Add the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be added + */ + registerRuntimeListener(listener: RuntimeListener): void; + /** + * Remove the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be removed + */ + deregisterRuntimeListener(listener: RuntimeListener): void; + /** + * Notifies any runtime listeners about a runtime change. + * + * @param {RUNTIME_TYPE} type the runtime type + */ + private notifyRuntimeListeners(type); +} diff --git a/dist/ts-build/core/runtime.js b/dist/ts-build/core/runtime.js new file mode 100644 index 000000000..ac341eb0c --- /dev/null +++ b/dist/ts-build/core/runtime.js @@ -0,0 +1,104 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * The different types of runtime related changes. + */ +var RUNTIME_TYPE; +(function (RUNTIME_TYPE) { + RUNTIME_TYPE[RUNTIME_TYPE["VALIDATION_ERROR"] = 0] = "VALIDATION_ERROR"; + RUNTIME_TYPE[RUNTIME_TYPE["VISIBLE"] = 1] = "VISIBLE"; + RUNTIME_TYPE[RUNTIME_TYPE["ENABLED"] = 2] = "ENABLED"; +})(RUNTIME_TYPE = exports.RUNTIME_TYPE || (exports.RUNTIME_TYPE = {})); +/** + * A runtime object holds information about runtime related properties + * of a rendered UI schema element, like the visible/disabled state and + * possible validation errors. + */ +var Runtime = /** @class */ (function () { + function Runtime() { + this.isVisible = true; + this.isEnabled = true; + this.listeners = []; + } + Object.defineProperty(Runtime.prototype, "visible", { + /** + * Whether the element is visible. + * @return {boolean} true, if the element is visible, false otherwise + */ + get: function () { return this.isVisible; }, + /** + * Set the visibility state of the element + * @param {boolean} visible whether the element should be visible + */ + set: function (visible) { + this.isVisible = visible; + this.notifyRuntimeListeners(RUNTIME_TYPE.VISIBLE); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Runtime.prototype, "enabled", { + /** + * Whether the element is enabled. + * @return {boolean} true, if the element is enabled, false otherwise + */ + get: function () { return this.isEnabled; }, + /** + * Set the enabled state of the element + * @param {boolean} enabled whether the element should be enabled + */ + set: function (enabled) { + this.isEnabled = enabled; + this.notifyRuntimeListeners(RUNTIME_TYPE.ENABLED); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Runtime.prototype, "validationErrors", { + /** + * Returns the validation errors associated with the element. + * @return {Array} the validation errors + */ + get: function () { return this.validationErrorMessages; }, + /** + * Set the validation errors. + * + * @param {string[]} validationErrors the validation errors + */ + set: function (validationErrors) { + this.validationErrorMessages = validationErrors; + this.notifyRuntimeListeners(RUNTIME_TYPE.VALIDATION_ERROR); + }, + enumerable: true, + configurable: true + }); + /** + * Add the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be added + */ + Runtime.prototype.registerRuntimeListener = function (listener) { + this.listeners.push(listener); + }; + /** + * Remove the given runtime listener. + * + * @param {RuntimeListener} listener the runtime listener to be removed + */ + Runtime.prototype.deregisterRuntimeListener = function (listener) { + this.listeners.splice(this.listeners.indexOf(listener), 1); + }; + /** + * Notifies any runtime listeners about a runtime change. + * + * @param {RUNTIME_TYPE} type the runtime type + */ + Runtime.prototype.notifyRuntimeListeners = function (type) { + this.listeners.forEach(function (listener) { + listener.runtimeUpdated(type); + }); + }; + return Runtime; +}()); +exports.Runtime = Runtime; +//# sourceMappingURL=runtime.js.map \ No newline at end of file diff --git a/dist/ts-build/core/runtime.js.map b/dist/ts-build/core/runtime.js.map new file mode 100644 index 000000000..8fc0074d9 --- /dev/null +++ b/dist/ts-build/core/runtime.js.map @@ -0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C,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,2CAAyB,GAAzB,UAA0B,QAAyB;QACjD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACK,wCAAsB,GAA9B,UAA+B,IAAkB;QAC/C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAA,QAAQ;YAC7B,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IACH,cAAC;AAAD,CAAC,AAhFD,IAgFC;AAhFY,0BAAO"} \ No newline at end of file diff --git a/dist/ts-build/core/schema.service.d.ts b/dist/ts-build/core/schema.service.d.ts new file mode 100644 index 000000000..fe4e2afa0 --- /dev/null +++ b/dist/ts-build/core/schema.service.d.ts @@ -0,0 +1,158 @@ +import { JsonSchema } from '../models/jsonSchema'; +/** + * A Property wraps a JsonSchema and provides additional information + * like a label and the property key. + */ +export interface Property { + /** + * The label is a text donating a human readable name of the schema the property describes. + */ + readonly label: string; + /** + * The property is a text donating the schema key from which this property was created. + */ + readonly property: string; + /** + * The schema is the JsonSchema this property describes. + */ + readonly schema: JsonSchema; +} +/** + * A ContainmentProperty extends the Property and provides methods + * which allow to modify containment data. + * @see Property + */ +export interface ContainmentProperty extends Property { + /** + * This allows to add data to the containment. + * @param data The object to add to + * @return a function that expects the element to be added and optionally the value next to which + * the new value is added. insertAfter defines whether the new value should be added + * after or before the neighbourValue. If no neighbour value is provided or it does not + * exist in the containment, the valueToAdd is inserted at the end. + */ + addToData(data: Object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; + /** + * This allows to delete data from the containment. + * The result is a function accepting the value to delete. + * @param data The object to delete from + * @return function accepting the value to delete + */ + deleteFromData(data: Object): (valueToDelete: object) => void; + /** + * This allows to retrieve the data of the containment. + * @param data The object the containment is in + * @return The containment value (e.g. an array) + */ + getData(data: Object): Object; +} +/** + * A ReferenceProperty extends the Property and provides methods + * which allow to modify reference data. + */ +export interface ReferenceProperty extends Property { + /** + * The schema of the referenced elements. + */ + readonly targetSchema: JsonSchema; + /** + * This allows to set the reference. + * @param root The root object, needed for matching the valueToAdd + * @param data The object to add to + * @param valueToAdd The object to add + */ + addToData(root: Object, data: Object, valueToAdd: object): void; + /** + * This allows to retrieve the data of the reference. + * @param root The root object, needed for finding the value to retrieve + * @param data The object the reference is in + * @return The referenced value + */ + getData(root: Object, data: Object): Object; + /** + * Returns all possible objects which can be referenced by this property. + * + * @param root The root data object needed for finding the values + * @return The array of data objects which are possible reference targets + * for this reference property. + */ + findReferenceTargets(rootData: Object): Object[]; + /** + * Resolves a reference value for this Reference by using the given porpertyValue to + * identify the referenced Object. + * + * @param rootData The root data object needed for finding the referenced value. + * @param propertyValue The property value identifying the referenced data object. + * @return The resolved data object or null if it coiuld not be resolved. + */ + resolveReference(rootData: Object, propertyValue: string): Object; +} +export declare class ContainmentPropertyImpl implements ContainmentProperty { + private innerSchema; + private key; + private name; + private addFunction; + private deleteFunction; + private getFunction; + constructor(innerSchema: JsonSchema, key: string, name: string, addFunction: (data: object) => (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void, deleteFunction: (data: object) => (valueToDelete: object) => void, getFunction: (data: object) => Object); + readonly label: string; + readonly schema: JsonSchema; + readonly property: string; + addToData(data: object): (valueToAdd: object, neighbourValue?: object, insertAfter?: boolean) => void; + deleteFromData(data: object): (valueToDelete: object) => void; + getData(data: object): Object; +} +export declare class ReferencePropertyImpl implements ReferenceProperty { + private innerSchema; + private innerTargetSchema; + private key; + private name; + private pathToContainment; + private identifyingProperty; + private addFunction; + private getFunction; + constructor(innerSchema: JsonSchema, innerTargetSchema: JsonSchema, key: string, name: string, pathToContainment: string, identifyingProperty: string, addFunction: (root: object, data: object, valueToAdd: object) => void, getFunction: (root: object, data: object) => Object); + readonly label: string; + readonly schema: JsonSchema; + readonly property: string; + readonly targetSchema: JsonSchema; + addToData(root: object, data: object, valueToAdd: object): void; + getData(root: object, data: object): Object; + findReferenceTargets(rootData: Object): Object[]; + resolveReference(rootData: Object, propertyValue: string): Object; +} +export declare const isContainmentProperty: (property: Property) => property is ContainmentProperty; +export declare const isReferenceProperty: (property: Property) => property is ReferenceProperty; +/** + * The Schema Service allows to retrieve containments and references. + */ +export interface SchemaService { + /** + * Retrieves an array of containment properties based on the provided schema. + * @param schema The schema to check for containments + * @return The array of {@link ContainmentProperty} or empty if no containments are available + * @see ContainmentProperty + */ + getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; + /** + * Checks whether a containment properties are available in the provided schema. + * @param schema The schema to check for containments + * @return true if containment properties are available, false otherwise + * @see {@link getContainmentProperties} + */ + hasContainmentProperties(schema: JsonSchema): boolean; + /** + * Retieves a self contained schema. + * @param parentSchema The schema to use for resolvement + * @param refPath The path to resolve + * @return a JsonSchema that is self-contained + */ + getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; + /** + * Retrieves an array of reference properties based on the provided schema. + * @param schema The schema to check for references + * @return The array of {@link ReferenceProperty} or empty if no references are available + * @see ReferenceProperty + */ + getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; +} diff --git a/dist/ts-build/core/schema.service.impl.d.ts b/dist/ts-build/core/schema.service.impl.d.ts new file mode 100644 index 000000000..7c2b5774e --- /dev/null +++ b/dist/ts-build/core/schema.service.impl.d.ts @@ -0,0 +1,24 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ContainmentProperty, ReferenceProperty, SchemaService } from './schema.service'; +export declare class SchemaServiceImpl implements SchemaService { + private rootSchema; + private selfContainedSchemas; + constructor(rootSchema: JsonSchema); + getContainmentProperties(schema: JsonSchema): ContainmentProperty[]; + hasContainmentProperties(schema: JsonSchema): boolean; + getSelfContainedSchema(parentSchema: JsonSchema, refPath: string): JsonSchema; + getReferenceProperties(schema: JsonSchema): ReferenceProperty[]; + private getContainment(key, name, schema, rootSchema, isInContainment, addFunction, deleteFunction, getFunction); + /** + * Makes the given JsonSchema self-contained. This means all referenced definitions + * are contained in the schema's definitions block and references equal to + * outerReference are set to root ('#'). + * + * @param schema The current schema to make self contained + * @param outerSchema The root schema to which missing definitions are added + * @param outerReference The reference which is considered to be self ('#') + * @param includedDefs The list of definitions which were already added to the outer schema + */ + private selfContainSchema(schema, outerSchema, outerReference, includedDefs?); + private copyAndResolveInner(resolved, innerRef, outerSchema, outerReference, includedDefs); +} diff --git a/dist/ts-build/core/schema.service.impl.js b/dist/ts-build/core/schema.service.impl.js new file mode 100644 index 000000000..ebce2d4a9 --- /dev/null +++ b/dist/ts-build/core/schema.service.impl.js @@ -0,0 +1,244 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var path_util_1 = require("../path.util"); +var schema_service_1 = require("./schema.service"); +var uuid = require("uuid"); +var core_1 = require("../core"); +var path_util_2 = require("../path.util"); +var isObject = function (schema) { + return schema.properties !== undefined; +}; +var isArray = function (schema) { + return schema.items !== undefined; +}; +var deepCopy = function (object) { + return JSON.parse(JSON.stringify(object)); +}; +var addToArray = function (key, identifyingProperty) { + return function (data) { + return function (valueToAdd, neighbourValue, insertAfter) { + if (insertAfter === void 0) { insertAfter = true; } + if (data[key] === undefined) { + data[key] = []; + } + if (!_.isEmpty(identifyingProperty)) { + valueToAdd[identifyingProperty] = uuid.v4(); + } + var childArray = data[key]; + if (neighbourValue !== undefined && neighbourValue !== null) { + var index = childArray.indexOf(neighbourValue); + if (insertAfter) { + if (index >= 0 && index < (childArray.length - 1)) { + childArray.splice(index + 1, 0, valueToAdd); + return; + } + // TODO proper logging + console.warn('Could not add the new value after the given neighbour value. ' + + 'The new value was added at the end.'); + } + else { + if (index >= 0) { + childArray.splice(index, 0, valueToAdd); + return; + } + // TODO proper logging + console.warn('The given neighbour value could not be found. ' + + 'The new value was added at the end.'); + } + } + // default behavior: add at the end + childArray.push(valueToAdd); + }; + }; +}; +var deleteFromArray = function (key) { return function (data) { return function (valueToDelete) { + var childArray = data[key]; + if (!childArray) { + return; + } + var indexToDelete = childArray.indexOf(valueToDelete); + childArray.splice(indexToDelete, 1); +}; }; }; +var getArray = function (key) { return function (data) { + return data[key]; +}; }; +var addReference = function (schema, variable, pathToContainment) { + return function (root, data, toAdd) { + var containment = pathToContainment + .split('/') + .reduce(function (elem, path) { + if (path === '#' || path === '') { + return elem; + } + return elem[path]; + }, root); + var index = containment.indexOf(toAdd); + if (schema.properties[variable].type === 'array') { + if (!data[variable]) { + data[variable] = []; + } + data[variable].push(index); + } + else { + data[variable] = index; + } + }; +}; +var getReference = function (href, variable, variableWrapped) { + return function (root, data) { + var variableValue = data[variable]; + var pathToObject = href.replace(variableWrapped, variableValue); + return pathToObject + .split('/') + .reduce(function (elem, path) { + if (path === '#') { + return elem; + } + return elem[path]; + }, root); + }; +}; +var SchemaServiceImpl = /** @class */ (function () { + function SchemaServiceImpl(rootSchema) { + this.rootSchema = rootSchema; + this.selfContainedSchemas = {}; + if (_.isEmpty(rootSchema.id)) { + rootSchema.id = '#generatedRootID'; + } + this.selfContainedSchemas[rootSchema.id] = this.rootSchema; + } + SchemaServiceImpl.prototype.getContainmentProperties = function (schema) { + return this.getContainment('root', 'root', schema, schema, false, null, null, null); + }; + SchemaServiceImpl.prototype.hasContainmentProperties = function (schema) { + return this.getContainmentProperties(schema).length !== 0; + }; + SchemaServiceImpl.prototype.getSelfContainedSchema = function (parentSchema, refPath) { + var schema = path_util_1.resolveSchema(parentSchema, refPath); + schema = deepCopy(schema); + if (_.isEmpty(schema.id)) { + schema.id = '#' + refPath; + } + if (this.selfContainedSchemas.hasOwnProperty(schema.id)) { + return this.selfContainedSchemas[schema.id]; + } + this.selfContainSchema(schema, schema, refPath); + this.selfContainedSchemas[schema.id] = schema; + return schema; + }; + SchemaServiceImpl.prototype.getReferenceProperties = function (schema) { + var _this = this; + if (schema.$ref !== undefined) { + return this.getReferenceProperties(this.getSelfContainedSchema(this.rootSchema, schema.$ref)); + } + // tslint:disable:no-string-literal + if (schema['links']) { + var links = schema['links']; + // tslint:enable:no-string-literal + var result_1 = []; + links.forEach(function (link) { + if (_.isEmpty(link.targetSchema) || _.isEmpty(link.href)) { + // FIXME log + return; + } + var targetSchema; + if (link.targetSchema.$ref !== undefined) { + targetSchema = _this.getSelfContainedSchema(_this.rootSchema, link.targetSchema.$ref); + } + else { + targetSchema = link.targetSchema; + } + var href = link.href; + var variableWrapped = href.match(/\{.*\}/)[0]; + var pathToContainment = href.split(/\{.*\}/)[0]; + var variable = variableWrapped.substring(1, variableWrapped.length - 1); + result_1.push(new schema_service_1.ReferencePropertyImpl(schema.properties[variable], targetSchema, variable, variable, pathToContainment.substring(0, pathToContainment.length - 1), core_1.JsonForms.config.getIdentifyingProp(), addReference(schema, variable, pathToContainment), getReference(href, variable, variableWrapped))); + }); + return result_1; + } + if (schema.anyOf !== undefined) { + return schema.anyOf.reduce(function (prev, cur) { return prev.concat(_this.getReferenceProperties(cur)); }, []); + } + return []; + }; + SchemaServiceImpl.prototype.getContainment = function (key, name, schema, rootSchema, isInContainment, addFunction, deleteFunction, getFunction) { + var _this = this; + if (schema.$ref !== undefined) { + return this.getContainment(key, schema.$ref === '#' ? undefined : schema.$ref.substring(schema.$ref.lastIndexOf('/') + 1), this.getSelfContainedSchema(rootSchema, schema.$ref), rootSchema, isInContainment, addFunction, deleteFunction, getFunction); + } + if (isObject(schema)) { + return isInContainment ? [ + new schema_service_1.ContainmentPropertyImpl(schema, key, name, addFunction, deleteFunction, getFunction) + ] : Object.keys(schema.properties) + .reduce(function (prev, cur) { + return prev.concat(_this.getContainment(cur, cur, schema.properties[cur], rootSchema, false, addFunction, deleteFunction, getFunction)); + }, []); + } + if (isArray(schema) && !Array.isArray(schema.items)) { + return this.getContainment(key, name, schema.items, rootSchema, true, addToArray(key, core_1.JsonForms.config.getIdentifyingProp()), deleteFromArray(key), getArray(key)); + } + if (schema.anyOf !== undefined) { + return schema.anyOf + .reduce(function (prev, cur) { + return prev.concat(_this.getContainment(key, undefined, cur, rootSchema, isInContainment, addFunction, deleteFunction, getFunction)); + }, []); + } + return []; + }; + /** + * Makes the given JsonSchema self-contained. This means all referenced definitions + * are contained in the schema's definitions block and references equal to + * outerReference are set to root ('#'). + * + * @param schema The current schema to make self contained + * @param outerSchema The root schema to which missing definitions are added + * @param outerReference The reference which is considered to be self ('#') + * @param includedDefs The list of definitions which were already added to the outer schema + */ + SchemaServiceImpl.prototype.selfContainSchema = function (schema, outerSchema, outerReference, includedDefs) { + var _this = this; + if (includedDefs === void 0) { includedDefs = ['#']; } + // Step 1: get all used references + var allInnerRefs = path_util_2.findAllRefs(schema); + Object.keys(allInnerRefs).forEach(function (innerRef) { + var resolved = path_util_1.resolveSchema(_this.rootSchema, innerRef); + // Step 2: recognize refs to outer self and set to '#' + if (innerRef === outerReference || resolved.id === schema.id) { + if (allInnerRefs[innerRef] !== undefined) { + if (!_.isEmpty(allInnerRefs[innerRef].$ref)) { + allInnerRefs[innerRef].$ref = '#'; + } + } + return; + } + // Step 3: add definitions for non-existant refs to definitions block + if (includedDefs.indexOf(innerRef) > -1) { + // definition was already added to schema + return; + } + if (!_.isEmpty(resolved.anyOf)) { + resolved.anyOf.forEach(function (inner) { + _this.copyAndResolveInner(inner, innerRef, outerSchema, outerReference, includedDefs); + }); + } + else { + _this.copyAndResolveInner(resolved, innerRef, outerSchema, outerReference, includedDefs); + } + }); + }; + SchemaServiceImpl.prototype.copyAndResolveInner = function (resolved, innerRef, outerSchema, outerReference, includedDefs) { + // get a copy of the referenced type's schema + var definitionSchema = deepCopy(resolved); + if (outerSchema.definitions === undefined || outerSchema.definitions === null) { + outerSchema.definitions = {}; + } + var defName = innerRef.substr(innerRef.lastIndexOf('/') + 1); + outerSchema.definitions[defName] = definitionSchema; + includedDefs.push(innerRef); + this.selfContainSchema(definitionSchema, outerSchema, outerReference, includedDefs); + }; + return SchemaServiceImpl; +}()); +exports.SchemaServiceImpl = SchemaServiceImpl; +//# sourceMappingURL=schema.service.impl.js.map \ No newline at end of file diff --git a/dist/ts-build/core/schema.service.impl.js.map b/dist/ts-build/core/schema.service.impl.js.map new file mode 100644 index 000000000..45cae8bd4 --- /dev/null +++ b/dist/ts-build/core/schema.service.impl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.service.impl.js","sourceRoot":"","sources":["../../../src/core/schema.service.impl.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAE5B,0CAA6C;AAC7C,mDAM0B;AAC1B,2BAA6B;AAC7B,gCAAoC;AACpC,0CAA2C;AAE3C,IAAM,QAAQ,GAAG,UAAC,MAAkB;IAClC,MAAM,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC;AACzC,CAAC,CAAC;AACF,IAAM,OAAO,GAAG,UAAC,MAAkB;IACjC,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC,CAAC;AACF,IAAM,QAAQ,GAAG,UAAI,MAAS;IAC5B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAM,CAAC;AACjD,CAAC,CAAC;AAEF,IAAM,UAAU,GACZ,UAAC,GAAW,EAAE,mBAA4B;IAC1C,OAAA,UAAC,IAAY;QACb,OAAA,UAAC,UAAkB,EAAE,cAAuB,EAAE,WAAkB;YAAlB,4BAAA,EAAA,kBAAkB;YAClE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;gBAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACjB,CAAC;YACD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;gBACpC,UAAU,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;YAC9C,CAAC;YACD,IAA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A4B,QAAoB,EAAE,QAAgB,EAAE,WAAuB,EAC/D,cAAsB,EAAE,YAAsB;QACxE,6CAA6C;QAC7C,IAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC5C,EAAE,CAAC,CAAC,WAAW,CAAC,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC;YAC9E,WAAW,CAAC,WAAW,GAAG,EAAE,CAAC;QAC/B,CAAC;QACD,IAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/D,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC;QACpD,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE5B,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;IACtF,CAAC;IACH,wBAAC;AAAD,CAAC,AA5MD,IA4MC;AA5MY,8CAAiB"} \ No newline at end of file diff --git a/dist/ts-build/core/schema.service.js b/dist/ts-build/core/schema.service.js new file mode 100644 index 000000000..9571dc48f --- /dev/null +++ b/dist/ts-build/core/schema.service.js @@ -0,0 +1,145 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var core_1 = require("../core"); +var ContainmentPropertyImpl = /** @class */ (function () { + function ContainmentPropertyImpl(innerSchema, key, name, addFunction, deleteFunction, getFunction) { + this.innerSchema = innerSchema; + this.key = key; + this.name = name; + this.addFunction = addFunction; + this.deleteFunction = deleteFunction; + this.getFunction = getFunction; + } + Object.defineProperty(ContainmentPropertyImpl.prototype, "label", { + get: function () { + return _.find([ + this.innerSchema.title, + this.name, + this.innerSchema.id, + this.key + ], function (n) { return !_.isEmpty(n); }); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ContainmentPropertyImpl.prototype, "schema", { + get: function () { + return this.innerSchema; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ContainmentPropertyImpl.prototype, "property", { + get: function () { + return this.key; + }, + enumerable: true, + configurable: true + }); + ContainmentPropertyImpl.prototype.addToData = function (data) { + return this.addFunction(data); + }; + ContainmentPropertyImpl.prototype.deleteFromData = function (data) { + return this.deleteFunction(data); + }; + ContainmentPropertyImpl.prototype.getData = function (data) { + return this.getFunction(data); + }; + return ContainmentPropertyImpl; +}()); +exports.ContainmentPropertyImpl = ContainmentPropertyImpl; +var ReferencePropertyImpl = /** @class */ (function () { + function ReferencePropertyImpl(innerSchema, innerTargetSchema, key, name, pathToContainment, identifyingProperty, addFunction, getFunction) { + this.innerSchema = innerSchema; + this.innerTargetSchema = innerTargetSchema; + this.key = key; + this.name = name; + this.pathToContainment = pathToContainment; + this.identifyingProperty = identifyingProperty; + this.addFunction = addFunction; + this.getFunction = getFunction; + } + Object.defineProperty(ReferencePropertyImpl.prototype, "label", { + get: function () { + return _.find([ + this.innerSchema.title, + this.name, + this.innerSchema.id, + this.key + ], function (n) { return !_.isEmpty(n); }); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ReferencePropertyImpl.prototype, "schema", { + get: function () { + return this.innerSchema; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ReferencePropertyImpl.prototype, "property", { + get: function () { + return this.key; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ReferencePropertyImpl.prototype, "targetSchema", { + get: function () { + return this.innerTargetSchema; + }, + enumerable: true, + configurable: true + }); + ReferencePropertyImpl.prototype.addToData = function (root, data, valueToAdd) { + this.addFunction(root, data, valueToAdd); + }; + ReferencePropertyImpl.prototype.getData = function (root, data) { + return this.getFunction(root, data); + }; + ReferencePropertyImpl.prototype.findReferenceTargets = function (rootData) { + var candidates = this.pathToContainment + .split('/') + .reduce(function (prev, cur) { + if (cur === '#') { + return prev; + } + return prev[cur]; + }, rootData); + if (!_.isEmpty(candidates)) { + return core_1.JsonForms.filterObjectsByType(candidates, this.targetSchema.id); + } + return []; + }; + ReferencePropertyImpl.prototype.resolveReference = function (rootData, propertyValue) { + var _this = this; + if (_.isEmpty(propertyValue) || _.isEmpty(this.identifyingProperty)) { + return null; + } + // get all objects that could be referenced. + var candidates = this.findReferenceTargets(rootData); + // use identifying property to identify the referenced property by the given propertyValue + var resultList = candidates.filter(function (value) { + return value[_this.identifyingProperty] === propertyValue; + }); + if (_.isEmpty(resultList)) { + return null; + } + if (resultList.length > 1) { + throw Error('There was more than one possible reference target with value \'' + propertyValue + + '\' in the identifying property \'' + this.identifyingProperty + '\'.'); + } + return _.first(resultList); + }; + return ReferencePropertyImpl; +}()); +exports.ReferencePropertyImpl = ReferencePropertyImpl; +exports.isContainmentProperty = function (property) { + return property instanceof ContainmentPropertyImpl; +}; +exports.isReferenceProperty = function (property) { + return property instanceof ReferencePropertyImpl; +}; +//# sourceMappingURL=schema.service.js.map \ No newline at end of file diff --git a/dist/ts-build/core/schema.service.js.map b/dist/ts-build/core/schema.service.js.map new file mode 100644 index 000000000..905589867 --- /dev/null +++ b/dist/ts-build/core/schema.service.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.service.js","sourceRoot":"","sources":["../../../src/core/schema.service.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAE5B,gCAAoC;AA6FpC;IACE,iCAAoB,WAAuB,EACvB,GAAW,EACX,IAAY,EACZ,WAE8D,EAC9D,cAAiE,EACjE,WAAqC;QAPrC,gBAAW,GAAX,WAAW,CAAY;QACvB,QAAG,GAAH,GAAG,CAAQ;QACX,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAEmD;QAC9D,mBAAc,GAAd,cAAc,CAAmD;QACjE,gBAAW,GAAX,WAAW,CAA0B;IAAG,CAAC;IAC7D,sBAAI,0CAAK;aAAT;YACE,MAAM,CAAC,CAAC,CAAC,IAAI,CACX;gBACE,IAAI,CAAC,WAAW,CAAC,KAAK;gBACtB,IAAI,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AAC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/core/styling.registry.d.ts b/dist/ts-build/core/styling.registry.d.ts new file mode 100644 index 000000000..982767c6e --- /dev/null +++ b/dist/ts-build/core/styling.registry.d.ts @@ -0,0 +1,69 @@ +export declare type ClassNames = string[] | ((...args: any[]) => string[]); +/** + * A style associates a name with a list of CSS class names. + */ +export interface Style { + name: string; + classNames: ClassNames; +} +/** + * A registry of all available styles. + * A style may be used to alter the appearance of certain elements during + * the render process. + */ +export interface StylingRegistry { + /** + * Register a style. + * If a style with the given name already exists, it will be overwritten. + * + * @param styleName the name of the style + * @param classNames CSS class names to be applied + */ + register(styleName: string, classNames: string[]): void; + /** + * Register a style. + * If a style with the given name already exists, it will be overwritten. + * + * @param style the style to be registered + */ + register(style: Style): void; + /** + * Register multiple styles at once. + * + * @param styles an array of styles to be registered + */ + registerMany(styles: Style[]): void; + /** + * Deregister a style. + * + * @param styleName the name of the style to be un-registered + */ + deregister(styleName: string): void; + /** + * Obtain the CSS class name associated with the given style name. + * @param styleName the name whose CSS class names should be obtained + * @return {Array} an array containing the CSS class names, + * if the style exists, an empty array otherwise + */ + get(styleName: string, ...args: any[]): string[]; + /** + * Obtain the CSS class name associated with the given style name. + * @param styleName the name whose CSS class names should be obtained + * @return a string containing the CSS class name separated by whitespace, if the style exists, + * empty string otherwise + */ + getAsClassName(styleName: string, ...args: any[]): string; +} +/** + * Styling registry implementation. + */ +export declare class StylingRegistryImpl implements StylingRegistry { + protected styles: Style[]; + constructor(styles?: Style[]); + register(style: Style): void; + register(name: string, classNames: ClassNames): void; + registerMany(styles: Style[]): void; + deregister(styleName: any): void; + get(styleName: string, ...args: any[]): string[]; + getAsClassName(styleName: string, ...args: any[]): string; +} diff --git a/dist/ts-build/core/styling.registry.js b/dist/ts-build/core/styling.registry.js new file mode 100644 index 000000000..b5224e37f --- /dev/null +++ b/dist/ts-build/core/styling.registry.js @@ -0,0 +1,59 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +/** + * Styling registry implementation. + */ +var StylingRegistryImpl = /** @class */ (function () { + function StylingRegistryImpl(styles) { + if (styles === void 0) { styles = []; } + this.styles = styles; + } + StylingRegistryImpl.prototype.register = function (style, classNames) { + if (typeof style === 'string') { + this.deregister(style); + this.styles.push({ name: style, classNames: classNames }); + } + else { + this.deregister(style.name); + this.styles.push(style); + } + }; + StylingRegistryImpl.prototype.registerMany = function (styles) { + var _this = this; + styles.forEach(function (style) { + _this.register(style.name, style.classNames); + }); + }; + StylingRegistryImpl.prototype.deregister = function (styleName) { + _.remove(this.styles, function (style) { return style.name === styleName; }); + }; + StylingRegistryImpl.prototype.get = function (styleName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var foundStyle = _.find(this.styles, function (style) { return style.name === styleName; }); + if (!_.isEmpty(foundStyle) && typeof foundStyle.classNames === 'function') { + return foundStyle.classNames(args); + } + else if (!_.isEmpty(foundStyle)) { + return foundStyle.classNames; + } + return []; + }; + StylingRegistryImpl.prototype.getAsClassName = function (styleName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var styles = this.get(styleName, args); + if (_.isEmpty(styles)) { + return ''; + } + return _.join(styles, ' '); + }; + return StylingRegistryImpl; +}()); +exports.StylingRegistryImpl = StylingRegistryImpl; +//# sourceMappingURL=styling.registry.js.map \ No newline at end of file diff --git a/dist/ts-build/core/styling.registry.js.map b/dist/ts-build/core/styling.registry.js.map new file mode 100644 index 000000000..cce489f53 --- /dev/null +++ b/dist/ts-build/core/styling.registry.js.map @@ -0,0 +1 @@ +{"version":3,"file":"styling.registry.js","sourceRoot":"","sources":["../../../src/core/styling.registry.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAmE5B;;GAEG;AACH;IAEI,6BAAsB,MAAoB;QAApB,uBAAA,EAAA,WAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAI,CAAC;IAI/C,s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C,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAE,UAAU,CAAC,UAAuB,CAAC;QAC/C,CAAC;QAED,MAAM,CAAC,EAAE,CAAC;IACd,CAAC;IAED,4CAAc,GAAd,UAAe,SAAiB;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;QAC5C,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACzC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpB,MAAM,CAAC,EAAE,CAAC;QACd,CAAC;QAED,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IAEL,0BAAC;AAAD,CAAC,AA9CD,IA8CC;AA9CY,kDAAmB"} \ No newline at end of file diff --git a/dist/ts-build/core/testers.d.ts b/dist/ts-build/core/testers.d.ts new file mode 100644 index 000000000..7aeb24d6a --- /dev/null +++ b/dist/ts-build/core/testers.d.ts @@ -0,0 +1,90 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ControlElement, Scopable, UISchemaElement } from '../models/uischema'; +/** + * A tester is a function that receives an UI schema and a JSON schema and returns a boolean. + */ +export declare type Tester = (uischema: UISchemaElement, schema: JsonSchema) => boolean; +/** + * A ranked tester associates a tester with a number. + */ +export declare type RankedTester = (uischema: UISchemaElement, schema: JsonSchema) => number; +export declare const isControl: (uischema: any) => uischema is ControlElement; +export declare const isScopable: (uischema: any) => uischema is Scopable; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and applies + * the given predicate + * + * @param {(JsonSchema) => boolean} predicate the predicate that should be + * applied to the resolved sub-schema + */ +export declare const schemaMatches: (predicate: (schema: JsonSchema) => boolean) => Tester; +export declare const schemaSubPathMatches: (subPath: string, predicate: (schema: JsonSchema) => boolean) => Tester; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the type of the sub-schema matches the expected one. + * + * @param {string} expectedType the expected type of the resolved sub-schema + */ +export declare const schemaTypeIs: (expectedType: string) => Tester; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the format of the sub-schema matches the expected one. + * + * @param {string} expectedFormat the expected format of the resolved sub-schema + */ +export declare const formatIs: (expectedFormat: string) => Tester; +/** + * Checks whether the given UI schema has the expected type. + * + * @param {string} expected the expected UI schema type + */ +export declare const uiTypeIs: (expected: string) => Tester; +/** + * Checks whether the given UI schema has an option with the given + * name and whether it has the expected value. If no options property + * is set, returns false. + * + * @param {string} optionName the name of the option to check + * @param {any} optionValue the expected value of the option + */ +export declare const optionIs: (optionName: string, optionValue: any) => Tester; +/** + * Only applicable for Controls. + * + * Checks whether the scope $ref of a control ends with the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +export declare const refEndsWith: (expected: string) => Tester; +/** + * Only applicable for Controls. + * + * Checks whether the last segment of the scope $ref matches the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +export declare const refEndIs: (expected: string) => Tester; +/** + * A tester that allow composing other testers by && them. + * + * @param {Array} testers the testers to be composed + */ +export declare const and: (...testers: Tester[]) => Tester; +/** + * Create a ranked tester that will associate a number with a given tester, if the + * latter returns true. + * + * @param {number} rank the rank to be returned in case the tester returns true + * @param {Tester} tester a tester + */ +export declare const rankWith: (rank: number, tester: Tester) => (uischema: UISchemaElement, schema: JsonSchema) => number; +export declare const withIncreasedRank: (by: number, rankedTester: RankedTester) => (uischema: UISchemaElement, schema: JsonSchema) => number; diff --git a/dist/ts-build/core/testers.js b/dist/ts-build/core/testers.js new file mode 100644 index 000000000..a422823b4 --- /dev/null +++ b/dist/ts-build/core/testers.js @@ -0,0 +1,175 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var path_util_1 = require("../path.util"); +var uischema_registry_1 = require("./uischema.registry"); +exports.isControl = function (uischema) { + return !_.isEmpty(uischema) && uischema.scope !== undefined; +}; +exports.isScopable = function (uischema) { + return !_.isEmpty(uischema) && uischema.scope !== undefined; +}; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and applies + * the given predicate + * + * @param {(JsonSchema) => boolean} predicate the predicate that should be + * applied to the resolved sub-schema + */ +exports.schemaMatches = function (predicate) { + return function (uischema, schema) { + if (_.isEmpty(uischema) || !exports.isControl(uischema)) { + return false; + } + var schemaPath = uischema.scope.$ref; + if (_.isEmpty(schemaPath)) { + return false; + } + var currentDataSchema = path_util_1.resolveSchema(schema, schemaPath); + while (!_.isEmpty(currentDataSchema) && !_.isEmpty(currentDataSchema.$ref)) { + currentDataSchema = path_util_1.resolveSchema(schema, currentDataSchema.$ref); + } + if (currentDataSchema === undefined) { + return false; + } + return predicate(currentDataSchema); + }; +}; +exports.schemaSubPathMatches = function (subPath, predicate) { + return function (uischema, schema) { + if (_.isEmpty(uischema) || !exports.isControl(uischema)) { + return false; + } + var schemaPath = uischema.scope.$ref; + if (_.isEmpty(schemaPath)) { + return false; + } + var currentDataSchema = path_util_1.resolveSchema(schema, schemaPath + "/" + subPath); + while (!_.isEmpty(currentDataSchema.$ref)) { + currentDataSchema = path_util_1.resolveSchema(schema, currentDataSchema.$ref); + } + if (currentDataSchema === undefined) { + return false; + } + return predicate(currentDataSchema); + }; +}; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the type of the sub-schema matches the expected one. + * + * @param {string} expectedType the expected type of the resolved sub-schema + */ +exports.schemaTypeIs = function (expectedType) { return exports.schemaMatches(function (schema) { + return !_.isEmpty(schema) && schema.type === expectedType; +}); }; +/** + * Only applicable for Controls. + * + * This function checks whether the given UI schema is of type Control + * and if so, resolves the sub-schema referenced by the control and checks + * whether the format of the sub-schema matches the expected one. + * + * @param {string} expectedFormat the expected format of the resolved sub-schema + */ +exports.formatIs = function (expectedFormat) { return exports.schemaMatches(function (schema) { + return !_.isEmpty(schema) + && schema.format === expectedFormat + && schema.type === 'string'; +}); }; +/** + * Checks whether the given UI schema has the expected type. + * + * @param {string} expected the expected UI schema type + */ +exports.uiTypeIs = function (expected) { + return function (uischema) { + return !_.isEmpty(uischema) && uischema.type === expected; + }; +}; +/** + * Checks whether the given UI schema has an option with the given + * name and whether it has the expected value. If no options property + * is set, returns false. + * + * @param {string} optionName the name of the option to check + * @param {any} optionValue the expected value of the option + */ +exports.optionIs = function (optionName, optionValue) { + return function (uischema) { + var options = uischema.options; + return !_.isEmpty(options) && options[optionName] === optionValue; + }; +}; +/** + * Only applicable for Controls. + * + * Checks whether the scope $ref of a control ends with the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +exports.refEndsWith = function (expected) { + return function (uischema) { + if (_.isEmpty(expected) || !exports.isControl(uischema)) { + return false; + } + return _.endsWith(uischema.scope.$ref, expected); + }; +}; +/** + * Only applicable for Controls. + * + * Checks whether the last segment of the scope $ref matches the expected string. + * + * @param {string} expected the expected ending of the $ref value + */ +exports.refEndIs = function (expected) { + return function (uischema) { + if (_.isEmpty(expected) || !exports.isControl(uischema)) { + return false; + } + var schemaPath = uischema.scope.$ref; + return !_.isEmpty(schemaPath) && _.last(schemaPath.split('/')) === expected; + }; +}; +/** + * A tester that allow composing other testers by && them. + * + * @param {Array} testers the testers to be composed + */ +exports.and = function () { + var testers = []; + for (var _i = 0; _i < arguments.length; _i++) { + testers[_i] = arguments[_i]; + } + return function (uischema, schema) { + return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema); }, true); + }; +}; +/** + * Create a ranked tester that will associate a number with a given tester, if the + * latter returns true. + * + * @param {number} rank the rank to be returned in case the tester returns true + * @param {Tester} tester a tester + */ +exports.rankWith = function (rank, tester) { + return function (uischema, schema) { + if (tester(uischema, schema)) { + return rank; + } + return uischema_registry_1.NOT_APPLICABLE; + }; +}; +exports.withIncreasedRank = function (by, rankedTester) { + return function (uischema, schema) { + return rankedTester(uischema, schema) + by; + }; +}; +//# sourceMappingURL=testers.js.map \ No newline at end of file diff --git a/dist/ts-build/core/testers.js.map b/dist/ts-build/core/testers.js.map new file mode 100644 index 000000000..711e3a0a6 --- /dev/null +++ b/dist/ts-build/core/testers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testers.js","sourceRoot":"","sources":["../../../src/core/testers.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAG5B,0CAA6C;AAC7C,yDAAqD;AAYxC,QAAA,SAAS,GAAG,UAAC,QAAa;IACrC,OAAA,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;AAApD,CAAoD,CAAC;AAE1C,QAAA,UAAU,GAAG,UAAC,QAAa;IACtC,OAAA,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;AAApD,CAAoD,CAAC;AAEvD;;;;;;;;;GASG;AACU,QAAA,aAAa,GAAG,UAAC,SAA0C;IACpE,OAAA,UAAC,QAAyB,EAAE,MAAkB;QAC1C,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QACD,IAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QACvC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QACD,I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CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,CAAC,kCAAc,CAAC;IAC1B,CAAC;AAND,CAMC,CAAC;AAEO,QAAA,iBAAiB,GAAG,UAAC,EAAU,EAAE,YAA0B;IACtE,OAAA,UAAC,QAAyB,EAAE,MAAkB;QAC5C,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;IAC/C,CAAC;AAFC,CAED,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/core/uischema.registry.d.ts b/dist/ts-build/core/uischema.registry.d.ts new file mode 100644 index 000000000..304018f62 --- /dev/null +++ b/dist/ts-build/core/uischema.registry.d.ts @@ -0,0 +1,63 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { UISchemaElement } from '../models/uischema'; +/** + * A registry of UI schemas. This registry can be utilized whenever + * multiple UI schemas are applicable for a given JSON schema in order + * to resolve ambiguity. + */ +export interface UISchemaRegistry { + /** + * Register a UI schema. + * + * @param {UISchemaElement} uiSchema the UI schema to be registered + * @param {UISchemaTester} tester the tester that determines whether + * the given UI schema should be used + */ + register(uiSchema: UISchemaElement, tester: UISchemaTester): void; + /** + * Deregister a UI schema. + * + * @param {UISchemaElement} uiSchema the UI schema to be unregistered + * @param {UISchemaTester} tester + */ + deregister(uiSchema: UISchemaElement, tester: UISchemaTester): void; + /** + * Find the UI schema that is most applicable for the given JSON schema + * and data. + * @param {JsonSchema} schema the JSON schema for which to find a UI schema + * @param {any} data the data for which to find a UI schema + */ + findMostApplicableUISchema(schema: JsonSchema, data: any): UISchemaElement; +} +/** + * A tester that returns a priority number when a JSON schema and some data, + * which determines how likely the associated UI schema will be used to + * render the JSON schema/data. The higher the returned number, the more likely + * the associated UI schema will be used. + */ +export declare type UISchemaTester = (schema: JsonSchema, data: any) => number; +/** + * Constant that indicates that a tester is not capable of handling + * a combination of schema/data. + * @type {number} + */ +export declare const NOT_APPLICABLE = -1; +/** + * Implementation of the UI schema registry. + */ +export declare class UISchemaRegistryImpl implements UISchemaRegistry { + private registry; + constructor(); + /** + * @inheritDoc + */ + register(uischema: UISchemaElement, tester: UISchemaTester): void; + /** + * @inheritDoc + */ + deregister(uischema: UISchemaElement, tester: UISchemaTester): void; + /** + * @inheritDoc + */ + findMostApplicableUISchema(schema: JsonSchema, data: any): UISchemaElement; +} diff --git a/dist/ts-build/core/uischema.registry.js b/dist/ts-build/core/uischema.registry.js new file mode 100644 index 000000000..9962ed36d --- /dev/null +++ b/dist/ts-build/core/uischema.registry.js @@ -0,0 +1,57 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var ui_schema_gen_1 = require("../generators/ui-schema-gen"); +/** + * Constant that indicates that a tester is not capable of handling + * a combination of schema/data. + * @type {number} + */ +exports.NOT_APPLICABLE = -1; +/** + * Default UI schema definition that always returns 0 as its priority. + * @type {UISchemaDefinition} + */ +var NO_UISCHEMA_DEFINITION = { + uischema: null, + tester: function (schema) { return 0; } +}; +/** + * Implementation of the UI schema registry. + */ +var UISchemaRegistryImpl = /** @class */ (function () { + function UISchemaRegistryImpl() { + this.registry = []; + this.registry.push(NO_UISCHEMA_DEFINITION); + } + /** + * @inheritDoc + */ + UISchemaRegistryImpl.prototype.register = function (uischema, tester) { + this.registry.push({ uischema: uischema, tester: tester }); + }; + /** + * @inheritDoc + */ + UISchemaRegistryImpl.prototype.deregister = function (uischema, tester) { + this.registry = _.filter(this.registry, function (el) { + // compare testers via strict equality + return el.tester !== tester || !_.eq(el.uischema, uischema); + }); + }; + /** + * @inheritDoc + */ + UISchemaRegistryImpl.prototype.findMostApplicableUISchema = function (schema, data) { + var bestSchema = _.maxBy(this.registry, function (renderer) { + return renderer.tester(schema, data); + }); + if (bestSchema === NO_UISCHEMA_DEFINITION) { + return ui_schema_gen_1.generateDefaultUISchema(schema); + } + return bestSchema.uischema; + }; + return UISchemaRegistryImpl; +}()); +exports.UISchemaRegistryImpl = UISchemaRegistryImpl; +//# sourceMappingURL=uischema.registry.js.map \ No newline at end of file diff --git a/dist/ts-build/core/uischema.registry.js.map b/dist/ts-build/core/uischema.registry.js.map new file mode 100644 index 000000000..8e85cd8f1 --- /dev/null +++ b/dist/ts-build/core/uischema.registry.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uischema.registry.js","sourceRoot":"","sources":["../../../src/core/uischema.registry.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAC5B,6DAAsE;AAoDtE;;;;GAIG;AACU,QAAA,cAAc,GAAG,CAAC,CAAC,CAAC;AAEjC;;;GAGG;AACH,IAAM,sBAAsB,GAAuB;IAC/C,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,UAAA,MAAM,IAAI,OAAA,CAAC,EAAD,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH;IAEI;QADQ,aAAQ,GAAyB,EAAE,CAAC;QAExC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,uCAAQ,GAAR,UAAS,QAAyB,EAAE,MAAsB;QACtD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAC,QAAQ,UAAA,EAAE,MAAM,QAAA,EAAC,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,yCAAU,GAAV,UAAW,QAAyB,EAAE,MAAsB;QACxD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAA,EAAE;YACtC,sCAAsC;YACtC,OAAA,EAAE,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAApD,CAAoD,CACvD,CAAC;IACN,CAAC;IAED;;OAEG;IACH,yDAA0B,GAA1B,UAA2B,MAAkB,EAAE,IAAS;QACpD,IAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAA,QAAQ;YAC9C,OAAA,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;QAA7B,CAA6B,CAChC,CAAC;QACF,EAAE,CAAC,CAAC,UAAU,KAAK,sBAAsB,CAAC,CAAC,CAAC;YACxC,MAAM,CAAC,uCAAuB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC/B,CAAC;IACL,2BAAC;AAAD,CAAC,AApCD,IAoCC;AApCY,oDAAoB"} \ No newline at end of file diff --git a/dist/ts-build/generators/schema-gen.d.ts b/dist/ts-build/generators/schema-gen.d.ts new file mode 100644 index 000000000..09fbbe035 --- /dev/null +++ b/dist/ts-build/generators/schema-gen.d.ts @@ -0,0 +1,8 @@ +import { JsonSchema } from '../models/jsonSchema'; +/** + * Generate a JSON schema based on the given data and any additional options. + * @param {Object} instance the data to create a JSON schema for + * @param {any} options any additional options that may alter the generated JSON schema + * @returns {JsonSchema} the generated schema + */ +export declare const generateJsonSchema: (instance: Object, options?: any) => JsonSchema; diff --git a/dist/ts-build/generators/schema-gen.js b/dist/ts-build/generators/schema-gen.js new file mode 100644 index 000000000..59224b7c4 --- /dev/null +++ b/dist/ts-build/generators/schema-gen.js @@ -0,0 +1,128 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ADDITIONAL_PROPERTIES = 'additionalProperties'; +var REQUIRED_PROPERTIES = 'required'; +var distinct = function (array, discriminator) { + var known = {}; + return array.filter(function (item) { + var discriminatorValue = discriminator(item); + if (known.hasOwnProperty(discriminatorValue)) { + return false; + } + else { + known[discriminatorValue] = true; + return true; + } + }); +}; +var Gen = /** @class */ (function () { + function Gen(findOption) { + var _this = this; + this.findOption = findOption; + this.schemaObject = function (data) { + var props = _this.properties(data); + var schema = { + 'type': 'object', + 'properties': props, + 'additionalProperties': _this.findOption(props)(ADDITIONAL_PROPERTIES) + }; + var required = _this.findOption(props)(REQUIRED_PROPERTIES); + if (required.length > 0) { + schema.required = required; + } + return schema; + }; + this.properties = function (data) { + var emptyProps = {}; + return Object + .keys(data) + .reduce(function (acc, propName) { + acc[propName] = _this.property(data[propName]); + return acc; + }, emptyProps); + }; + this.property = function (data) { + switch (typeof data) { + case 'string': + return { 'type': 'string' }; + case 'boolean': + return { 'type': 'boolean' }; + case 'number': + if (Number.isInteger(data)) { + return { 'type': 'integer' }; + } + return { 'type': 'number' }; + case 'object': + if (data == null) { + return { 'type': 'null' }; + } + return _this.schemaObjectOrArray(data); + default: + return {}; + } + }; + this.schemaObjectOrArray = function (data) { + if (data instanceof Array) { + return _this.schemaArray(data); + } + else { + return _this.schemaObject(data); + } + }; + this.schemaArray = function (data) { + if (data.length > 0) { + var allProperties = data.map(_this.property); + var uniqueProperties = distinct(allProperties, function (prop) { return JSON.stringify(prop); }); + if (uniqueProperties.length === 1) { + return { + 'type': 'array', + 'items': uniqueProperties[0] + }; + } + else { + return { + 'type': 'array', + 'items': { + 'oneOf': uniqueProperties + } + }; + } + } + else { + return { + 'type': 'array', + 'items': {} + }; + } + }; + } + return Gen; +}()); +/** + * Generate a JSON schema based on the given data and any additional options. + * @param {Object} instance the data to create a JSON schema for + * @param {any} options any additional options that may alter the generated JSON schema + * @returns {JsonSchema} the generated schema + */ +exports.generateJsonSchema = function (instance, options) { + if (options === void 0) { options = {}; } + var findOption = function (props) { return function (optionName) { + switch (optionName) { + case ADDITIONAL_PROPERTIES: + if (options.hasOwnProperty(ADDITIONAL_PROPERTIES)) { + return options[ADDITIONAL_PROPERTIES]; + } + return true; + case REQUIRED_PROPERTIES: + if (options.hasOwnProperty(REQUIRED_PROPERTIES)) { + return options[REQUIRED_PROPERTIES](props); + } + return Object.keys(props); + default: + return; + } + }; }; + var gen = new Gen(findOption); + return gen.schemaObject(instance); +}; +//# sourceMappingURL=schema-gen.js.map \ No newline at end of file diff --git a/dist/ts-build/generators/schema-gen.js.map b/dist/ts-build/generators/schema-gen.js.map new file mode 100644 index 000000000..327485098 --- /dev/null +++ b/dist/ts-build/generators/schema-gen.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema-gen.js","sourceRoot":"","sources":["../../../src/generators/schema-gen.ts"],"names":[],"mappings":";;AAGA,IAAM,qBAAqB,GAAG,sBAAsB,CAAC;AACrD,IAAM,mBAAmB,GAAK,UAAU,CAAC;AAIzC,IAAM,QAAQ,GAAG,UAAC,KAAY,EAAE,aAAoC;IAChE,IAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAA,IAAI;QACpB,IAAM,kBAAkB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAC/C,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;YAC3C,MAAM,CAAC,KAAK,CAAC;QACjB,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,KAAK,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC;YAEjC,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF;IAEI,aAAoB,UAA8D;QAAlF,iBAEC;QAFmB,eAAU,GAAV,UAAU,CAAoD;QAIlF,iBAAY,GAAG,UAAC,IAAY;YACxB,IAAM,KAAK,GAAG,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YACpC,IAAM,MAAM,GAAe;gBACvB,MAAM,EAAE,QAAQ;gBAChB,YAAY,EAAE,KAAK;gBACnB,sBAAsB,EAAE,KAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC;aACxE,CAAC;YACF,IAAM,QAAQ,GAAG,KAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,mBAAmB,CAAC,CAAC;YAC7D,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBACtB,MAAM,CAAC,QAAQ,GAAG,QAAQ,C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AU,CAAC,CAAC,CAAC;YACjB,KAAK,qBAAqB;gBACtB,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;oBAChD,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;gBAC1C,CAAC;gBAED,MAAM,CAAC,IAAI,CAAC;YAChB,KAAK,mBAAmB;gBACpB,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;oBAC9C,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC/C,CAAC;gBAED,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9B;gBACI,MAAM,CAAC;QACf,CAAC;IACL,CAAC,EAjBqC,CAiBrC,CAAC;IAEN,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAEhC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/generators/ui-schema-gen.d.ts b/dist/ts-build/generators/ui-schema-gen.d.ts new file mode 100644 index 000000000..503e84fb1 --- /dev/null +++ b/dist/ts-build/generators/ui-schema-gen.d.ts @@ -0,0 +1,9 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { UISchemaElement } from '../models/uischema'; +/** + * Generate a default UI schema. + * @param {JsonSchema} jsonSchema the JSON schema to generated a UI schema for + * @param {string} layoutType the desired layout type for the root layout + * of the generated UI schema + */ +export declare const generateDefaultUISchema: (jsonSchema: JsonSchema, layoutType?: string, prefix?: string) => UISchemaElement; diff --git a/dist/ts-build/generators/ui-schema-gen.js b/dist/ts-build/generators/ui-schema-gen.js new file mode 100644 index 000000000..9ac356ab8 --- /dev/null +++ b/dist/ts-build/generators/ui-schema-gen.js @@ -0,0 +1,121 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +/** + * Creates a new ILayout. + * @param layoutType The type of the laoyut + * @returns the new ILayout + */ +var createLayout = function (layoutType) { return ({ + type: layoutType, + elements: [] +}); }; +/** + * Derives the type of the jsonSchema element + */ +var deriveType = function (jsonSchema) { + if (!_.isEmpty(jsonSchema) && + !_.isEmpty(jsonSchema.type) && + typeof jsonSchema.type === 'string') { + return jsonSchema.type; + } + if (!_.isEmpty(jsonSchema) && + (!_.isEmpty(jsonSchema.properties) || !_.isEmpty(jsonSchema.additionalProperties))) { + return 'object'; + } + if (!_.isEmpty(jsonSchema) && !_.isEmpty(jsonSchema.items)) { + return 'array'; + } + // ignore all remaining cases + return 'null'; +}; +/** + * Creates a IControlObject with the given label referencing the given ref + */ +var createControlElement = function (label, ref) { return ({ + type: 'Control', + label: label, + scope: { + $ref: ref + } +}); }; +var isLayout = function (uischema) { + return uischema.elements !== undefined; +}; +/** + * Wraps the given {@code uiSchema} in a Layout if there is none already. + * @param uiSchema The ui schema to wrap in a layout. + * @param layoutType The type of the layout to create. + * @returns the wrapped uiSchema. + */ +var wrapInLayoutIfNecessary = function (uischema, layoutType) { + if (!_.isEmpty(uischema) && !isLayout(uischema)) { + var verticalLayout = createLayout(layoutType); + verticalLayout.elements.push(uischema); + return verticalLayout; + } + return uischema; +}; +/** + * Adds the given {@code labelName} to the {@code layout} if it exists + * @param layout + * The layout which is to receive the label + * @param labelName + * The name of the schema + */ +var addLabel = function (layout, labelName) { + if (!_.isEmpty(labelName)) { + // add label with name + var label = { + type: 'Label', + text: _.startCase(labelName) + }; + layout.elements.push(label); + } +}; +var generateUISchema = function (jsonSchema, schemaElements, currentRef, schemaName, layoutType) { + var type = deriveType(jsonSchema); + switch (type) { + case 'object': + var layout_1 = createLayout(layoutType); + schemaElements.push(layout_1); + addLabel(layout_1, schemaName); + if (!_.isEmpty(jsonSchema.properties)) { + // traverse properties + var nextRef_1 = currentRef + '/properties'; + Object.keys(jsonSchema.properties).map(function (propName) { + var value = jsonSchema.properties[propName]; + generateUISchema(value, layout_1.elements, nextRef_1 + "/" + propName, propName, layoutType); + }); + } + return layout_1; + case 'array': // array items will be handled by the array control itself + /* falls through */ + case 'string': + /* falls through */ + case 'number': + /* falls through */ + case 'integer': + /* falls through */ + case 'boolean': + var controlObject = createControlElement(_.startCase(schemaName), currentRef); + schemaElements.push(controlObject); + return controlObject; + case 'null': + return null; + default: + throw new Error('Unknown type: ' + JSON.stringify(jsonSchema)); + } +}; +/** + * Generate a default UI schema. + * @param {JsonSchema} jsonSchema the JSON schema to generated a UI schema for + * @param {string} layoutType the desired layout type for the root layout + * of the generated UI schema + */ +exports.generateDefaultUISchema = function (jsonSchema, layoutType, prefix) { + if (layoutType === void 0) { layoutType = 'VerticalLayout'; } + if (prefix === void 0) { prefix = '#'; } + return wrapInLayoutIfNecessary(generateUISchema(jsonSchema, [], prefix, '', layoutType), layoutType); +}; +//# sourceMappingURL=ui-schema-gen.js.map \ No newline at end of file diff --git a/dist/ts-build/generators/ui-schema-gen.js.map b/dist/ts-build/generators/ui-schema-gen.js.map new file mode 100644 index 000000000..634a31acb --- /dev/null +++ b/dist/ts-build/generators/ui-schema-gen.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ui-schema-gen.js","sourceRoot":"","sources":["../../../src/generators/ui-schema-gen.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAK5B;;;;GAIG;AACH,IAAM,YAAY,GAAG,UAAC,UAAkB,IAAa,OAAA,CAAC;IAClD,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,EAAE;CACf,CAAC,EAHmD,CAGnD,CAAC;AAEH;;GAEG;AACH,IAAM,UAAU,GAAG,UAAC,UAAsB;IACtC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QACtB,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;QAC3B,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,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ACN,CAAC,CAAC,CAAC;YACP,CAAC;YAED,MAAM,CAAC,QAAM,CAAC;QAElB,KAAK,OAAO,CAAC,CAAC,0DAA0D;QACxE,mBAAmB;QACnB,KAAK,QAAQ,CAAC;QACd,mBAAmB;QACnB,KAAK,QAAQ,CAAC;QACd,mBAAmB;QACnB,KAAK,SAAS,CAAC;QACf,mBAAmB;QACnB,KAAK,SAAS;YACV,IAAM,aAAa,GAAmB,oBAAoB,CACtD,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,EACvB,UAAU,CACb,CAAC;YACF,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAEnC,MAAM,CAAC,aAAa,CAAC;QACzB,KAAK,MAAM;YACP,MAAM,CAAC,IAAI,CAAC;QAChB;YACI,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACvE,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,uBAAuB,GAChC,UAAC,UAAsB,EAAE,UAA6B,EAAE,MAAY;IAA3C,2BAAA,EAAA,6BAA6B;IAAE,uBAAA,EAAA,YAAY;IAChE,OAAA,uBAAuB,CACnB,gBAAgB,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,CAAC,EACxD,UAAU,CAAC;AAFf,CAEe,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/index.d.ts b/dist/ts-build/index.d.ts new file mode 100644 index 000000000..d7e7ccc46 --- /dev/null +++ b/dist/ts-build/index.d.ts @@ -0,0 +1,11 @@ +export * from './core'; +export * from './json-forms'; +export * from './path.util'; +export * from './core/renderer'; +export * from './core/runtime'; +export * from './core/schema.service'; +export * from './core/styling.registry'; +export * from './core/testers'; +export * from './models/uischema'; +export * from './models/jsonSchema'; +export * from './renderers'; diff --git a/dist/ts-build/index.js b/dist/ts-build/index.js new file mode 100644 index 000000000..6f7421abc --- /dev/null +++ b/dist/ts-build/index.js @@ -0,0 +1,16 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./core")); +__export(require("./json-forms")); +__export(require("./path.util")); +__export(require("./core/renderer")); +__export(require("./core/runtime")); +__export(require("./core/schema.service")); +__export(require("./core/styling.registry")); +__export(require("./core/testers")); +__export(require("./models/uischema")); +__export(require("./renderers")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/ts-build/index.js.map b/dist/ts-build/index.js.map new file mode 100644 index 000000000..17f4b2ab0 --- /dev/null +++ b/dist/ts-build/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4BAAuB;AACvB,kCAA6B;AAC7B,iCAA4B;AAC5B,qCAAgC;AAChC,oCAA+B;AAC/B,2CAAsC;AACtC,6CAAwC;AACxC,oCAA+B;AAC/B,uCAAkC;AAElC,iCAA4B"} \ No newline at end of file diff --git a/dist/ts-build/json-forms.d.ts b/dist/ts-build/json-forms.d.ts new file mode 100644 index 000000000..4cda24a83 --- /dev/null +++ b/dist/ts-build/json-forms.d.ts @@ -0,0 +1,52 @@ +import './renderers'; +import { UISchemaElement } from './models/uischema'; +import { JsonSchema } from './models/jsonSchema'; +import { Store } from 'redux'; +export interface JsonFormsStore extends Store { +} +/** + * HTML element that represents the entry point + */ +export declare class JsonFormsElement extends HTMLElement { + private dataObject; + private uischema; + private dataschema; + schemaPromise: Promise; + private allowDynamicUpdate; + store: Store; + /** + * Constructor. + */ + constructor(); + /** + * Called when this element is inserted into a document. + */ + connectedCallback(): void; + /** + * Set the data to be rendered. + * @param {Object} data the data to be rendered + */ + data: Object; + /** + * Returns the UI schema to be rendered. + * + * @returns {UISchemaElement} the UI schema to be rendered + */ + /** + * Set the UI schema. + * @param {UISchemaElement} uischema the UI schema element to be set + */ + uiSchema: UISchemaElement; + /** + * Returns the JSON schema that describes the data to be rendered. + * + * @returns {JsonSchema} the JSON schema that describes the data to be rendered + */ + /** + * Set the JSON data schema that describes the data to be rendered. + * @param {JsonSchema} dataSchema the data schema to be rendered + */ + dataSchema: JsonSchema; + private render(); + private instantiateSchemaIfNeeded(schema); +} diff --git a/dist/ts-build/json-forms.js b/dist/ts-build/json-forms.js new file mode 100644 index 000000000..ccc485afe --- /dev/null +++ b/dist/ts-build/json-forms.js @@ -0,0 +1,169 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("./renderers/JSX"); +var inferno_1 = require("inferno"); +var JsonRefs = require("json-refs"); +var _ = require("lodash"); +require("./renderers"); +var core_1 = require("./core"); +var schema_gen_1 = require("./generators/schema-gen"); +var inferno_redux_1 = require("inferno-redux"); +var store_1 = require("./store"); +var dispatch_renderer_1 = require("./renderers/dispatch-renderer"); +/** + * Annotation that registered the given config and class as a custom element + * @param {CustomElementConfig} config the configuration object for the custom element + * @constructor + */ +// Usage as decorator +// tslint:disable:variable-name +var CustomElement = function (config) { return function (cls) { + // tslint:enable:variable-name + if (customElements.get(config.selector)) { + return; + } + customElements.define(config.selector, cls); +}; }; +/** + * HTML element that represents the entry point + */ +var JsonFormsElement = /** @class */ (function (_super) { + __extends(JsonFormsElement, _super); + /** + * Constructor. + */ + function JsonFormsElement() { + var _this = _super.call(this) || this; + _this.schemaPromise = null; + _this.allowDynamicUpdate = false; + return _this; + } + /** + * Called when this element is inserted into a document. + */ + JsonFormsElement.prototype.connectedCallback = function () { + this.allowDynamicUpdate = true; + this.render(); + }; + Object.defineProperty(JsonFormsElement.prototype, "data", { + /** + * Set the data to be rendered. + * @param {Object} data the data to be rendered + */ + set: function (data) { + this.dataObject = data; + // TODO + this.render(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JsonFormsElement.prototype, "uiSchema", { + /** + * Returns the UI schema to be rendered. + * + * @returns {UISchemaElement} the UI schema to be rendered + */ + get: function () { + if (!_.isEmpty(this.uischema)) { + return this.uischema; + } + return core_1.JsonForms.uischemaRegistry.findMostApplicableUISchema(this.dataSchema, this.dataObject); + }, + /** + * Set the UI schema. + * @param {UISchemaElement} uischema the UI schema element to be set + */ + set: function (uischema) { + this.uischema = uischema; + // TODO + this.render(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JsonFormsElement.prototype, "dataSchema", { + /** + * Returns the JSON schema that describes the data to be rendered. + * + * @returns {JsonSchema} the JSON schema that describes the data to be rendered + */ + get: function () { + if (!_.isEmpty(this.dataschema)) { + return this.dataschema; + } + return schema_gen_1.generateJsonSchema(this.dataObject); + }, + /** + * Set the JSON data schema that describes the data to be rendered. + * @param {JsonSchema} dataSchema the data schema to be rendered + */ + set: function (dataSchema) { + var _this = this; + this.schemaPromise = JsonRefs.resolveRefs(dataSchema, { includeInvalid: true }); + this.schemaPromise.then(function (result) { + _this.dataschema = result.resolved; + _this.schemaPromise = null; + _this.render(); + }); + }, + enumerable: true, + configurable: true + }); + JsonFormsElement.prototype.render = function () { + if (!this.allowDynamicUpdate) { + return; + } + if (this.schemaPromise !== null) { + return; + } + if (_.isEmpty(this.dataObject)) { + return; + } + var schema = this.dataSchema; + this.instantiateSchemaIfNeeded(schema); + var uischema = this.uiSchema; + this.store = store_1.initJsonFormsStore(this.dataObject, schema, uischema); + inferno_1.default.render(JSX_1.JSX.createElement(inferno_redux_1.Provider, { store: this.store }, + JSX_1.JSX.createElement(dispatch_renderer_1.default, { uischema: uischema, schema: schema })), this); + this.className = core_1.JsonForms.stylingRegistry.getAsClassName('json-forms'); + }; + JsonFormsElement.prototype.instantiateSchemaIfNeeded = function (schema) { + var parent = this.parentNode; + while (parent !== document.body && parent !== null) { + if (parent.nodeName === 'JSON-FORMS') { + return; + } + parent = parent.parentNode; + } + core_1.JsonForms.schema = schema; + }; + JsonFormsElement = __decorate([ + CustomElement({ + selector: 'json-forms' + }), + __metadata("design:paramtypes", []) + ], JsonFormsElement); + return JsonFormsElement; +}(HTMLElement)); +exports.JsonFormsElement = JsonFormsElement; +//# sourceMappingURL=json-forms.js.map \ No newline at end of file diff --git a/dist/ts-build/json-forms.js.map b/dist/ts-build/json-forms.js.map new file mode 100644 index 000000000..99a6a60ae --- /dev/null +++ b/dist/ts-build/json-forms.js.map @@ -0,0 +1 @@ +{"version":3,"file":"json-forms.js","sourceRoot":"","sources":["../../src/json-forms.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AACtC,mCAA8B;AAC9B,oCAAsC;AACtC,0BAA4B;AAC5B,uBAAqB;AAErB,+BAAmC;AAEnC,sDAA6D;AAE7D,+CAAyC;AACzC,iCAA6C;AAC7C,mEAA6D;AAS7D;;;;GAIG;AACH,qBAAqB;AACrB,+BAA+B;AAC/B,IAAM,aAAa,GAAG,UAAC,MAA2B,IAAK,OAAA,UAAA,GAAG;IAC1D,8BAA8B;IAC5B,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM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,MAAM,EAAE,MAAM,GAAI,CAC/C,EACX,IAAI,CACL,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,eAAe,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAC1E,CAAC;IAEO,oDAAyB,GAAjC,UAAkC,MAAkB;QAClD,IAAI,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7B,OAAO,MAAM,KAAK,QAAQ,CAAC,IAAI,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACnD,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC;gBACrC,MAAM,CAAC;YACT,CAAC;YACD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;QAC7B,CAAC;QACD,gBAAS,CAAC,MAAM,GAAG,MAAM,CAAC;IAC5B,CAAC;IA3HU,gBAAgB;QAH5B,aAAa,CAAC;YACb,QAAQ,EAAE,YAAY;SACvB,CAAC;;OACW,gBAAgB,CA4H5B;IAAD,uBAAC;CAAA,AA5HD,CAAsC,WAAW,GA4HhD;AA5HY,4CAAgB"} \ No newline at end of file diff --git a/dist/ts-build/models/jsonSchema.d.ts b/dist/ts-build/models/jsonSchema.d.ts new file mode 100644 index 000000000..51d748cac --- /dev/null +++ b/dist/ts-build/models/jsonSchema.d.ts @@ -0,0 +1,132 @@ +/** + * MIT License + * + * Copyright (c) 2016 Richard Adams (https://github.com/enriched) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +export interface JsonSchema { + $ref?: string; + /** + * This is important because it tells refs where + * the root of the document is located + */ + id?: string; + /** + * It is recommended that the meta-schema is + * included in the root of any JSON Schema + */ + $schema?: JsonSchema; + /** + * Title of the schema + */ + title?: string; + /** + * Schema description + */ + description?: string; + /** + * Default json for the object represented by + * this schema + */ + 'default'?: any; + /** + * The value must be a multiple of the number + * (e.g. 10 is a multiple of 5) + */ + multipleOf?: number; + maximum?: number; + /** + * If true maximum must be > value, >= otherwise + */ + exclusiveMaximum?: boolean; + minimum?: number; + /** + * If true minimum must be < value, <= otherwise + */ + exclusiveMinimum?: boolean; + maxLength?: number; + minLength?: number; + /** + * This is a regex string that the value must + * conform to + */ + pattern?: string; + additionalItems?: boolean | JsonSchema; + items?: JsonSchema | JsonSchema[]; + maxItems?: number; + minItems?: number; + uniqueItems?: boolean; + maxProperties?: number; + minProperties?: number; + required?: string[]; + additionalProperties?: boolean | JsonSchema; + /** + * Holds simple JSON Schema definitions for + * referencing from elsewhere. + */ + definitions?: { + [key: string]: JsonSchema; + }; + /** + * The keys that can exist on the object with the + * json schema that should validate their value + */ + properties?: { + [property: string]: JsonSchema; + }; + /** + * The key of this object is a regex for which + * properties the schema applies to + */ + patternProperties?: { + [pattern: string]: JsonSchema; + }; + /** + * If the key is present as a property then the + * string of properties must also be present. + * If the value is a JSON Schema then it must + * also be valid for the object if the key is + * present. + */ + dependencies?: { + [key: string]: JsonSchema | string[]; + }; + /** + * Enumerates the values that this schema can be + * e.g. + * {"type": "string", + * "enum": ["red", "green", "blue"]} + */ + 'enum'?: any[]; + /** + * The basic type of this schema, can be one of + * [string, number, object, array, boolean, null] + * or an array of the acceptable types + */ + type?: string | string[]; + allOf?: JsonSchema[]; + anyOf?: JsonSchema[]; + oneOf?: JsonSchema[]; + /** + * The entity being validated must not match this schema + */ + not?: JsonSchema; + format?: string; +} diff --git a/dist/ts-build/models/jsonSchema.js b/dist/ts-build/models/jsonSchema.js new file mode 100644 index 000000000..48e4fae3f --- /dev/null +++ b/dist/ts-build/models/jsonSchema.js @@ -0,0 +1,26 @@ +"use strict"; +/** + * MIT License + * + * Copyright (c) 2016 Richard Adams (https://github.com/enriched) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=jsonSchema.js.map \ No newline at end of file diff --git a/dist/ts-build/models/jsonSchema.js.map b/dist/ts-build/models/jsonSchema.js.map new file mode 100644 index 000000000..ad47aa352 --- /dev/null +++ b/dist/ts-build/models/jsonSchema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"jsonSchema.js","sourceRoot":"","sources":["../../../src/models/jsonSchema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"} \ No newline at end of file diff --git a/dist/ts-build/models/uischema.d.ts b/dist/ts-build/models/uischema.d.ts new file mode 100644 index 000000000..282a8fbcc --- /dev/null +++ b/dist/ts-build/models/uischema.d.ts @@ -0,0 +1,191 @@ +import { Runtime } from '../core/runtime'; +/** + * A rule that may be attached to any UI schema element. + */ +export interface Rule { + /** + * The effect of the rule + */ + effect: RuleEffect; + /** + * The condition of the rule that must evaluate to true in order + * to trigger the effect. + */ + condition: Condition; +} +/** + * The different rule effects. + */ +export declare enum RuleEffect { + /** + * Effect that hides the associated element. + */ + HIDE = "HIDE", + /** + * Effect that shows the associated element. + */ + SHOW = "SHOW", + /** + * Effect that enables the associated element. + */ + ENABLE = "ENABLE", + /** + * Effect that disables the associated element. + */ + DISABLE = "DISABLE", +} +/** + * Represents a condition to be evaluated. + */ +export interface Condition { + /** + * A string describing the type of condition + */ + type: string; +} +/** + * A leaf condition. + */ +export interface LeafCondition extends Condition { + /** + * The sub schema the condition is bound to. + */ + scope: { + $ref: string; + }; + /** + * The expected value when evaluating the condition + */ + expectedValue: any; +} +/** + * Common base interface for any UI schema element. + */ +export interface UISchemaElement { + /** + * The type of this UI schema element. + */ + type: string; + /** + * An optional rule. + */ + rule?: Rule; + /** + * Any additional options. + */ + options?: any; + /** + * Runtime object that encapsulates runtime state. + */ + runtime?: Runtime; +} +/** + * Represents a layout element which can order its children + * in a specific way. + */ +export interface Layout extends UISchemaElement { + /** + * The child elements of this layout. + */ + elements: UISchemaElement[]; +} +/** + * A layout which orders its child elements vertically (i.e. from top to bottom). + */ +export interface VerticalLayout extends Layout { + type: 'VerticalLayout'; +} +/** + * A layout which orders its children horizontally (i.e. from left to right). + */ +export interface HorizontalLayout extends Layout { + type: 'HorizontalLayout'; +} +/** + * A group resembles a vertical layout, but additionally might have a label. + * This layout is useful when grouping different elements by a certain criteria. + */ +export interface GroupLayout extends Layout { + type: 'Group'; + /** + * The label of this group layout. + */ + label?: string; +} +/** + * Represents an object that can be used to configure a label. + */ +export interface ILabelObject { + /** + * An optional text to be displayed. + */ + text?: string; + /** + * Optional property that determines whether to show this label. + */ + show?: boolean; +} +/** + * A label element. + */ +export interface LabelElement extends UISchemaElement { + type: 'Label'; + /** + * The text of label. + */ + text: string; +} +export interface Scopable { + /** + * The scope that determines to which part of the schema the control + * should be bound to. The $ref property is just a regular JSON pointer. + */ + scope: { + $ref: string; + }; +} +/** + * A control element. The scope property of the control determines + * to which part of the schema the control should be bound. + */ +export interface ControlElement extends UISchemaElement, Scopable { + type: 'Control'; + /** + * An optional label that will be associated with the control + */ + label?: string | boolean | ILabelObject; +} +export interface MasterDetailLayout extends UISchemaElement, Scopable { + type: 'MasterDetailLayout'; + /** + * An optional label that will be associated with the control + */ + label?: string | boolean | ILabelObject; +} +/** + * The category layout. + */ +export interface Category extends Layout { + type: 'Category'; + /** + * The label associated with this category layout. + */ + label: string; +} +/** + * The categorization element, which may have children elements. + * A child element may either be itself a Categorization or a Category, hence + * the categorization element can be used to represent recursive structures like trees. + */ +export interface Categorization extends UISchemaElement { + type: 'Categorization'; + /** + * The label of this categorization. + */ + label: string; + /** + * The child elements of this categorization which are either of type + * {@link Category} or {@link Categorization}. + */ + elements: (Category | Categorization)[]; +} diff --git a/dist/ts-build/models/uischema.js b/dist/ts-build/models/uischema.js new file mode 100644 index 000000000..5f3fdf144 --- /dev/null +++ b/dist/ts-build/models/uischema.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * The different rule effects. + */ +var RuleEffect; +(function (RuleEffect) { + /** + * Effect that hides the associated element. + */ + RuleEffect["HIDE"] = "HIDE"; + /** + * Effect that shows the associated element. + */ + RuleEffect["SHOW"] = "SHOW"; + /** + * Effect that enables the associated element. + */ + RuleEffect["ENABLE"] = "ENABLE"; + /** + * Effect that disables the associated element. + */ + RuleEffect["DISABLE"] = "DISABLE"; +})(RuleEffect = exports.RuleEffect || (exports.RuleEffect = {})); +//# sourceMappingURL=uischema.js.map \ No newline at end of file diff --git a/dist/ts-build/models/uischema.js.map b/dist/ts-build/models/uischema.js.map new file mode 100644 index 000000000..69e8f8f42 --- /dev/null +++ b/dist/ts-build/models/uischema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uischema.js","sourceRoot":"","sources":["../../../src/models/uischema.ts"],"names":[],"mappings":";;AAiBA;;GAEG;AACH,IAAY,UAiBX;AAjBD,WAAY,UAAU;IACpB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,+BAAiB,CAAA;IACjB;;OAEG;IACH,iCAAmB,CAAA;AACrB,CAAC,EAjBW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAiBrB"} \ No newline at end of file diff --git a/dist/ts-build/path.util.d.ts b/dist/ts-build/path.util.d.ts new file mode 100644 index 000000000..aa90570c6 --- /dev/null +++ b/dist/ts-build/path.util.d.ts @@ -0,0 +1,70 @@ +import { JsonSchema } from './models/jsonSchema'; +import { Scopable } from './models/uischema'; +export declare const compose: (path1: string, path2: string) => string; +/** + * Convert a schema path (i.e. JSON pointer) to an array by splitting + * at the '/' character and removing all schema-specific keywords. + * + * The returned value can be used to de-reference a root object by folding over it + * and derefercing the single segments to obtain a new object. + * + * + * @param {string} schemaPath the schema path to be converted + * @returns {string[]} an array containing only non-schema-specific segments + */ +export declare const toDataPathSegments: (schemaPath: string) => string[]; +/** + * Remove all schema-specific keywords (e.g. 'properties') from a given path. + * @example + * toDataPath('#/properties/foo/properties/bar') === '#/foo/bar') + * + * @param {string} schemaPath the schema path to be converted + * @returns {string} the path without schema-specific keywords + */ +export declare const toDataPath: (schemaPath: string) => string; +/** + * Resolve the given schema path against the given instance until the last + * segment. The returned value allows easy assignment of any new value. + * + * @example + * const pair = getValuePropertyPair(someData, someRef); + * pair.instance[pair.property] = someValue; + * + * @param {any} instance the instance to resolve the path against + * @param {string} schemaPath the schema path to be resolved + * @returns {{instance: string, property: string}} an object containing + * the resolved instance as well the last fragment of + */ +export declare const getValuePropertyPair: (instance: any, schemaPath: string) => { + instance: Object; + property: string; +}; +export declare const composeWithUi: (scopableUi: Scopable, path: string) => string; +export declare const resolveData: (data: any, path: any) => any; +/** + * Resolve the given schema path in order to obtain a subschema. + * @param {JsonSchema} schema the root schema from which to start + * @param {string} schemaPath the schema path to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +export declare const resolveSchema: (schema: JsonSchema, schemaPath: string) => JsonSchema; +/** + * Finds all references inside the given schema. + * + * @param schema The {@link JsonSchema} to find the references in + * @param result The initial result map, default: empty map (this parameter is used for recursion + * inside the function) + * @param resolveTuples Whether arrays of tuples should be considered; default: false + */ +export declare const findAllRefs: (schema: JsonSchema, result?: ReferenceSchemaMap, resolveTuples?: boolean) => ReferenceSchemaMap; +/** + * Normalizes the schema and resolves the given ref. + * + * @param {JsonSchema} full the JSON schema to resolved the reference against + * @param {string} reference the reference to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +export declare function retrieveResolvableSchema(full: JsonSchema, reference: string): JsonSchema; +export interface ReferenceSchemaMap { + [ref: string]: JsonSchema; +} diff --git a/dist/ts-build/path.util.js b/dist/ts-build/path.util.js new file mode 100644 index 000000000..4b246af0b --- /dev/null +++ b/dist/ts-build/path.util.js @@ -0,0 +1,178 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var isObject = function (schema) { + return schema.properties !== undefined; +}; +var isArray = function (schema) { + return schema.type === 'array' && schema.items !== undefined; +}; +exports.compose = function (path1, path2) { + var p1 = path1; + if (!_.isEmpty(path1) && !path2.startsWith('[')) { + p1 = path1 + '.'; + } + if (_.isEmpty(p1)) { + return path2; + } + else { + return "" + p1 + path2; + } +}; +/** + * Convert a schema path (i.e. JSON pointer) to an array by splitting + * at the '/' character and removing all schema-specific keywords. + * + * The returned value can be used to de-reference a root object by folding over it + * and derefercing the single segments to obtain a new object. + * + * + * @param {string} schemaPath the schema path to be converted + * @returns {string[]} an array containing only non-schema-specific segments + */ +exports.toDataPathSegments = function (schemaPath) { + var segments = schemaPath.split('/'); + var startFromRoot = segments[0] === '#' || segments[0] === ''; + if (startFromRoot) { + return segments.filter(function (segment, index) { + if (index === 0) { + return false; + } + else { + return index % 2 !== 1; + } + }); + } + return segments.filter(function (segment, index) { return index % 2 !== 0; }); +}; +/** + * Remove all schema-specific keywords (e.g. 'properties') from a given path. + * @example + * toDataPath('#/properties/foo/properties/bar') === '#/foo/bar') + * + * @param {string} schemaPath the schema path to be converted + * @returns {string} the path without schema-specific keywords + */ +exports.toDataPath = function (schemaPath) { + return exports.toDataPathSegments(schemaPath).join('/'); +}; +/** + * Resolve the given schema path against the given instance until the last + * segment. The returned value allows easy assignment of any new value. + * + * @example + * const pair = getValuePropertyPair(someData, someRef); + * pair.instance[pair.property] = someValue; + * + * @param {any} instance the instance to resolve the path against + * @param {string} schemaPath the schema path to be resolved + * @returns {{instance: string, property: string}} an object containing + * the resolved instance as well the last fragment of + */ +exports.getValuePropertyPair = function (instance, schemaPath) { + var validPathSegments = exports.toDataPathSegments(schemaPath); + var resolvedInstance = validPathSegments + .slice(0, validPathSegments.length - 1) + .map(function (segment) { return decodeURIComponent(segment); }) + .reduce(function (curInstance, decodedSegment) { + if (!curInstance.hasOwnProperty(decodedSegment)) { + curInstance[decodedSegment] = {}; + } + return curInstance[decodedSegment]; + }, instance); + return { + instance: resolvedInstance, + property: validPathSegments.length > 0 ? + decodeURIComponent(validPathSegments[validPathSegments.length - 1]) : undefined + }; +}; +exports.composeWithUi = function (scopableUi, path) { + var segments = exports.toDataPathSegments(scopableUi.scope.$ref); + return _.isEmpty(segments) ? path : exports.compose(path, segments.join('.')); +}; +exports.resolveData = function (data, path) { + return _.isEmpty(path) ? data : _.get(data, path); +}; +/** + * Resolve the given schema path in order to obtain a subschema. + * @param {JsonSchema} schema the root schema from which to start + * @param {string} schemaPath the schema path to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +exports.resolveSchema = function (schema, schemaPath) { + var validPathSegments = schemaPath.split('/'); + var invalidSegment = function (pathSegment) { return pathSegment === '#' || pathSegment === undefined || pathSegment === ''; }; + var resultSchema = validPathSegments.reduce(function (curSchema, pathSegment) { + return invalidSegment(pathSegment) ? curSchema : curSchema[pathSegment]; + }, schema); + if (resultSchema !== undefined && resultSchema.$ref !== undefined) { + return retrieveResolvableSchema(schema, resultSchema.$ref); + } + return resultSchema; +}; +/** + * Finds all references inside the given schema. + * + * @param schema The {@link JsonSchema} to find the references in + * @param result The initial result map, default: empty map (this parameter is used for recursion + * inside the function) + * @param resolveTuples Whether arrays of tuples should be considered; default: false + */ +exports.findAllRefs = function (schema, result, resolveTuples) { + if (result === void 0) { result = {}; } + if (resolveTuples === void 0) { resolveTuples = false; } + if (isObject(schema)) { + Object.keys(schema.properties).forEach(function (key) { + return exports.findAllRefs(schema.properties[key], result); + }); + } + if (isArray(schema)) { + if (Array.isArray(schema.items)) { + if (resolveTuples) { + schema.items.forEach(function (child) { return exports.findAllRefs(child, result); }); + } + } + else { + exports.findAllRefs(schema.items, result); + } + } + if (Array.isArray(schema.anyOf)) { + schema.anyOf.forEach(function (child) { return exports.findAllRefs(child, result); }); + } + if (schema.$ref !== undefined) { + result[schema.$ref] = schema; + } + // tslint:disable:no-string-literal + if (schema['links'] !== undefined) { + schema['links'].forEach(function (link) { + if (!_.isEmpty(link.targetSchema.$ref)) { + result[link.targetSchema.$ref] = schema; + } + else { + exports.findAllRefs(link.targetSchema, result); + } + }); + } + return result; +}; +/** + * Normalizes the schema and resolves the given ref. + * + * @param {JsonSchema} full the JSON schema to resolved the reference against + * @param {string} reference the reference to be resolved + * @returns {JsonSchema} the resolved sub-schema + */ +// disable rule because resolve is mutually recursive +// tslint:disable:only-arrow-functions +function retrieveResolvableSchema(full, reference) { + // tslint:enable:only-arrow-functions + var child = exports.resolveSchema(full, reference); + var allRefs = exports.findAllRefs(child); + var innerSelfReference = allRefs[reference]; + if (innerSelfReference !== undefined) { + innerSelfReference.$ref = '#'; + } + return child; +} +exports.retrieveResolvableSchema = retrieveResolvableSchema; +//# sourceMappingURL=path.util.js.map \ No newline at end of file diff --git a/dist/ts-build/path.util.js.map b/dist/ts-build/path.util.js.map new file mode 100644 index 000000000..3a6d92a9c --- /dev/null +++ b/dist/ts-build/path.util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"path.util.js","sourceRoot":"","sources":["../../src/path.util.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAI5B,IAAM,QAAQ,GAAG,UAAC,MAAkB;IAClC,MAAM,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC;AACzC,CAAC,CAAC;AACF,IAAM,OAAO,GAAG,UAAC,MAAkB;IACjC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC;AAC/D,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,UAAC,KAAa,EAAE,KAAa;IAClD,IAAI,EAAE,GAAG,KAAK,CAAC;IACf,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChD,EAAE,GAAG,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,KAAK,CAAC;IACf,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,MAAM,CAAC,KAAG,EAAE,GAAG,KAAO,CAAC;IACzB,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,kBAAkB,GAAG,UAAC,UAAkB;IACnD,IAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvC,IAAM,aAAa,GAAG,QAAQ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AC;QACrC,kBAAkB,CAAC,IAAI,GAAG,GAAG,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC;AACf,CAAC;AAVD,4DAUC"} \ No newline at end of file diff --git a/dist/ts-build/reducers/common.d.ts b/dist/ts-build/reducers/common.d.ts new file mode 100644 index 000000000..79a24c35c --- /dev/null +++ b/dist/ts-build/reducers/common.d.ts @@ -0,0 +1,12 @@ +export declare const commonStateReducer: (state: { + data: {}; + schema: {}; + uischema: {}; +}, action: any) => { + data: any; + schema: {}; + uischema: {}; +}; +export declare const extractData: (state: any) => any; +export declare const extractSchema: (state: any) => any; +export declare const extractUiSchema: (state: any) => any; diff --git a/dist/ts-build/reducers/common.js b/dist/ts-build/reducers/common.js new file mode 100644 index 000000000..b86df49a8 --- /dev/null +++ b/dist/ts-build/reducers/common.js @@ -0,0 +1,55 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var dot_prop_immutable_1 = require("dot-prop-immutable"); +var actions_1 = require("../actions"); +exports.commonStateReducer = function (state, action) { + if (state === void 0) { state = { + data: {}, + schema: {}, + uischema: {} + }; } + switch (action.type) { + case actions_1.INIT: + return { + data: action.data, + schema: state.schema, + uischema: state.uischema + }; + case actions_1.UPDATE_DATA: { + if (action.path === undefined || action.path === null) { + return state; + } + else if (action.path === '') { + // empty path is ok + var result = action.updater(state.data); + if (result === undefined || result === null) { + return { + data: state.data, + uischema: state.uischema, + schema: state.schema + }; + } + return { + data: result, + uischema: state.uischema, + schema: state.schema + }; + } + else { + var currData = dot_prop_immutable_1.get(state.data, action.path); + var newState = dot_prop_immutable_1.set(state.data, action.path, action.updater(currData)); + return { + data: newState, + uischema: state.uischema, + schema: state.schema + }; + } + } + default: + return state; + } +}; +exports.extractData = function (state) { return state.data; }; +exports.extractSchema = function (state) { return state.schema; }; +exports.extractUiSchema = function (state) { return state.uischema; }; +//# sourceMappingURL=common.js.map \ No newline at end of file diff --git a/dist/ts-build/reducers/common.js.map b/dist/ts-build/reducers/common.js.map new file mode 100644 index 000000000..3d15624cb --- /dev/null +++ b/dist/ts-build/reducers/common.js.map @@ -0,0 +1 @@ +{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/reducers/common.ts"],"names":[],"mappings":";;AAAA,yDAA8C;AAC9C,sCAA+C;AAElC,QAAA,kBAAkB,GAAG,UAChC,KAIC,EACD,MAAM;IALN,sBAAA,EAAA;QACE,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;KACb;IAGD,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpB,KAAK,cAAI;YACP,MAAM,CAAC;gBACL,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;aACzB,CAAC;QACJ,KAAK,qBAAW,EAAE,CAAC;YACjB,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;gBACtD,MAAM,CAAC,KAAK,CAAC;YACf,CAAC;YAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;gBAC9B,mBAAmB;gBACnB,IAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAE1C,EAAE,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC;oBAC5C,MAAM,CAAC;wBACL,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;wBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;qBACrB,CAAC;gBACJ,CAAC;gBAED,MAAM,CAAC;oBACL,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,KAAK,CAAC,QAAQ;oBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;iBACrB,CAAC;YACJ,CAAC;YAAC,IAAI,CAAC,CAAC;gBACN,IAAM,QAAQ,GAAG,wBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC9C,IAAM,QAAQ,GAAG,wBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAExE,MAAM,CAAC;oBACL,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,KAAK,CAAC,QAAQ;oBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;iBACrB,CAAC;YACJ,CAAC;QACH,CAAC;QACD;YACE,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEW,QAAA,WAAW,GAAG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,IAAI,EAAV,CAAU,CAAC;AAClC,QAAA,aAAa,GAAG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,EAAZ,CAAY,CAAC;AACtC,QAAA,eAAe,GAAG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,QAAQ,EAAd,CAAc,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/reducers/index.d.ts b/dist/ts-build/reducers/index.d.ts new file mode 100644 index 000000000..5fe11dd29 --- /dev/null +++ b/dist/ts-build/reducers/index.d.ts @@ -0,0 +1,7 @@ +import { Reducer } from 'redux'; +export declare const appReducer: Reducer; +export declare const getData: (state: any) => any; +export declare const getSchema: (state: any) => any; +export declare const getUiSchema: (state: any) => any; +export declare const getRuntime: (state: any) => any; +export declare const getValidation: (state: any) => any; diff --git a/dist/ts-build/reducers/index.js b/dist/ts-build/reducers/index.js new file mode 100644 index 000000000..d4d52fcb3 --- /dev/null +++ b/dist/ts-build/reducers/index.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var redux_1 = require("redux"); +var validation_1 = require("./validation"); +var renderers_1 = require("./renderers"); +var common_1 = require("./common"); +exports.appReducer = redux_1.combineReducers({ + 'common': common_1.commonStateReducer, + 'validation': validation_1.validationReducer, + 'renderers': renderers_1.rendererReducer +}); +exports.getData = function (state) { + return common_1.extractData(state.common); +}; +exports.getSchema = function (state) { return common_1.extractSchema(state.common); }; +exports.getUiSchema = function (state) { return common_1.extractUiSchema(state.common); }; +exports.getRuntime = function (state) { return state.runtime; }; +exports.getValidation = function (state) { return state.validation; }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/ts-build/reducers/index.js.map b/dist/ts-build/reducers/index.js.map new file mode 100644 index 000000000..1e9f124cd --- /dev/null +++ b/dist/ts-build/reducers/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reducers/index.ts"],"names":[],"mappings":";;AAAA,+BAAiD;AACjD,2CAAiD;AACjD,yCAA8C;AAC9C,mCAA2F;AAE9E,QAAA,UAAU,GAAiB,uBAAe,CACrD;IACE,QAAQ,EAAE,2BAAkB;IAC5B,YAAY,EAAE,8BAAiB;IAC/B,WAAW,EAAE,2BAAe;CAC7B,CACF,CAAC;AAEW,QAAA,OAAO,GAAG,UAAA,KAAK;IAC1B,MAAM,CAAC,oBAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC,CAAC;AAEW,QAAA,SAAS,GAAG,UAAA,KAAK,IAAI,OAAA,sBAAa,CAAC,KAAK,CAAC,MAAM,CAAC,EAA3B,CAA2B,CAAC;AACjD,QAAA,WAAW,GAAG,UAAA,KAAK,IAAI,OAAA,wBAAe,CAAC,KAAK,CAAC,MAAM,CAAC,EAA7B,CAA6B,CAAC;AACrD,QAAA,UAAU,GAAG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CAAC;AACpC,QAAA,aAAa,GAAG,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,UAAU,EAAhB,CAAgB,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/reducers/renderers.d.ts b/dist/ts-build/reducers/renderers.d.ts new file mode 100644 index 000000000..c021a1d16 --- /dev/null +++ b/dist/ts-build/reducers/renderers.d.ts @@ -0,0 +1,13 @@ +import { JsonFormsRendererConstructable } from '../renderers/renderer.util'; +import { RankedTester } from '../core/testers'; +export declare const rendererReducer: (state: { + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}[], {type, tester, renderer}: { + type: any; + tester: any; + renderer: any; +}) => { + tester: RankedTester; + renderer: JsonFormsRendererConstructable; +}[]; diff --git a/dist/ts-build/reducers/renderers.js b/dist/ts-build/reducers/renderers.js new file mode 100644 index 000000000..eab3db2a0 --- /dev/null +++ b/dist/ts-build/reducers/renderers.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var actions_1 = require("../actions"); +exports.rendererReducer = function (state, _a) { + if (state === void 0) { state = []; } + var type = _a.type, tester = _a.tester, renderer = _a.renderer; + switch (type) { + case actions_1.ADD_RENDERER: + return state.concat([{ tester: tester, renderer: renderer }]); + case actions_1.REMOVE_RENDERER: + return state.filter(function (t) { return t.tester !== tester; }); + default: + return state; + } +}; +//# sourceMappingURL=renderers.js.map \ No newline at end of file diff --git a/dist/ts-build/reducers/renderers.js.map b/dist/ts-build/reducers/renderers.js.map new file mode 100644 index 000000000..9cfe7c37c --- /dev/null +++ b/dist/ts-build/reducers/renderers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../../src/reducers/renderers.ts"],"names":[],"mappings":";;AAEA,sCAA2D;AAE9C,QAAA,eAAe,GAAG,UAC7B,KAAgF,EAChF,EAAwB;IADxB,sBAAA,EAAA,UAAgF;QAC/E,cAAI,EAAE,kBAAM,EAAE,sBAAQ;IACvB,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACb,KAAK,sBAAY;YACf,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAC,MAAM,QAAA,EAAE,QAAQ,UAAA,EAAC,CAAC,CAAC,CAAC;QAC5C,KAAK,yBAAe;YAClB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,KAAK,MAAM,EAAnB,CAAmB,CAAC,CAAC;QAChD;YACE,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/reducers/validation.d.ts b/dist/ts-build/reducers/validation.d.ts new file mode 100644 index 000000000..ede95f29b --- /dev/null +++ b/dist/ts-build/reducers/validation.d.ts @@ -0,0 +1,9 @@ +import { ErrorObject, ValidateFunction } from 'ajv'; +import { JsonSchema } from '../models/jsonSchema'; +export interface ValidationState { + errors: ErrorObject[]; + validator: ValidateFunction; + schema: JsonSchema; +} +export declare const validationReducer: (state: ValidationState, action: any) => ValidationState; +export declare const errorAt: (instancePath: any) => (state: any) => any[]; diff --git a/dist/ts-build/reducers/validation.js b/dist/ts-build/reducers/validation.js new file mode 100644 index 000000000..0f9f2cf6a --- /dev/null +++ b/dist/ts-build/reducers/validation.js @@ -0,0 +1,50 @@ +"use strict"; +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var AJV = require("ajv"); +var _ = require("lodash"); +var actions_1 = require("../actions"); +var ajv = new AJV({ allErrors: true, jsonPointers: true, errorDataPath: 'property' }); +var validate = function (validator, data) { + var valid = validator(data); + if (valid) { + return []; + } + return validator.errors; +}; +exports.validationReducer = function (state, action) { + if (state === void 0) { state = { + errors: [], + validator: function () { return true; }, + schema: {} + }; } + switch (action.type) { + // TODO: review use of actions + case actions_1.INIT: + return __assign({}, state, { schema: action.schema, validator: ajv.compile(action.schema) }); + case actions_1.VALIDATE: + var validator = state.validator; + if (validator === undefined) { + validator = ajv.compile(state.schema); + } + var errors = validate(validator, action.data).map(function (error) { + error.dataPath = error.dataPath.replace('/', '.').substr(1); + return error; + }); + return __assign({}, state, { validator: validator, + errors: errors }); + default: + return state; + } +}; +exports.errorAt = function (instancePath) { return function (state) { + return _.filter(state.errors, function (error) { return error.dataPath === instancePath; }); +}; }; +//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/dist/ts-build/reducers/validation.js.map b/dist/ts-build/reducers/validation.js.map new file mode 100644 index 000000000..6833782d7 --- /dev/null +++ b/dist/ts-build/reducers/validation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/reducers/validation.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,yBAA2B;AAC3B,0BAA4B;AAG5B,sCAA4C;AAC5C,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAC,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAC,CAAC,CAAC;AAEtF,IAAM,QAAQ,GAAG,UAAC,SAA2B,EAAE,IAAS;IACtD,IAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACV,MAAM,CAAC,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;AAC1B,CAAC,CAAC;AAQW,QAAA,iBAAiB,GAAG,UAC/B,KAIC,EACD,MAAM;IALN,sBAAA,EAAA;QACE,MAAM,EAAE,EAAmB;QAC3B,SAAS,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QACrB,MAAM,EAAE,EAAE;KACX;IAGD,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpB,8BAA8B;QAC9B,KAAK,cAAI;YACP,MAAM,cACC,KAAK,IACV,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IACrC;QACJ,KAAK,kBAAQ;YACX,IAAI,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YAChC,EAAE,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC;gBAC5B,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC;YAED,IAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAA,KAAK;gBACvD,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAE5D,MAAM,CAAC,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;YAEH,MAAM,cACD,KAAK,IACR,SAAS,WAAA;gBACT,MAAM,QAAA,IACN;QACJ;YACE,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,UAAA,YAAY,IAAI,OAAA,UAAC,KAAK;IAC3C,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,UAAC,KAAkB,IAAK,OAAA,KAAK,CAAC,QAAQ,KAAK,YAAY,EAA/B,CAA+B,CAAC,CAAC;AACzF,CAAC,EAFsC,CAEtC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/JSX.d.ts b/dist/ts-build/renderers/JSX.d.ts new file mode 100644 index 000000000..464c711a3 --- /dev/null +++ b/dist/ts-build/renderers/JSX.d.ts @@ -0,0 +1 @@ +export declare const JSX: any; diff --git a/dist/ts-build/renderers/JSX.js b/dist/ts-build/renderers/JSX.js new file mode 100644 index 000000000..156da6fb6 --- /dev/null +++ b/dist/ts-build/renderers/JSX.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var inferno_create_element_1 = require("inferno-create-element"); +exports.JSX = { + createElement: inferno_create_element_1.default +}; +//# sourceMappingURL=JSX.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/JSX.js.map b/dist/ts-build/renderers/JSX.js.map new file mode 100644 index 000000000..71d538cb9 --- /dev/null +++ b/dist/ts-build/renderers/JSX.js.map @@ -0,0 +1 @@ +{"version":3,"file":"JSX.js","sourceRoot":"","sources":["../../../src/renderers/JSX.ts"],"names":[],"mappings":";;AAAA,iEAA8C;AAEjC,QAAA,GAAG,GAAQ;IACtB,aAAa,EAAE,gCAAQ;CACxB,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/array-renderer.d.ts b/dist/ts-build/renderers/additional/array-renderer.d.ts new file mode 100644 index 000000000..4964eb3bd --- /dev/null +++ b/dist/ts-build/renderers/additional/array-renderer.d.ts @@ -0,0 +1,18 @@ +import { Renderer } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +export declare const getStyle: (styleName: string) => string; +/** + * Default tester for an array control. + * @type {RankedTester} + */ +export declare const arrayTester: RankedTester; +export declare class ArrayControlRenderer extends Renderer { + addNewItem(path: string): void; + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/additional/array-renderer.js b/dist/ts-build/renderers/additional/array-renderer.js new file mode 100644 index 000000000..e0adaac74 --- /dev/null +++ b/dist/ts-build/renderers/additional/array-renderer.js @@ -0,0 +1,92 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var _ = require("lodash"); +var renderer_1 = require("../../core/renderer"); +var testers_1 = require("../../core/testers"); +var path_util_1 = require("../../path.util"); +var label_util_1 = require("../label.util"); +var core_1 = require("../../core"); +var ui_schema_gen_1 = require("../../generators/ui-schema-gen"); +var actions_1 = require("../../actions"); +var inferno_redux_1 = require("inferno-redux"); +var index_1 = require("../../reducers/index"); +var dispatch_renderer_1 = require("../dispatch-renderer"); +var renderer_util_1 = require("../renderer.util"); +exports.getStyle = function (styleName) { + return core_1.JsonForms.stylingRegistry.getAsClassName(styleName); +}; +/** + * Default tester for an array control. + * @type {RankedTester} + */ +exports.arrayTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.schemaMatches(function (schema) { + return !_.isEmpty(schema) + && schema.type === 'array' + && !_.isEmpty(schema.items) + && !Array.isArray(schema.items); +} // we don't care about tuples +), testers_1.schemaSubPathMatches('items', function (schema) { + return schema.type === 'object'; +}))); +var ArrayControlRenderer = /** @class */ (function (_super) { + __extends(ArrayControlRenderer, _super); + function ArrayControlRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + ArrayControlRenderer.prototype.addNewItem = function (path) { + var element = {}; + this.props.dispatch(actions_1.update(path, function (array) { + if (array === undefined || array === null) { + return [element]; + } + var clone = _.clone(array); + clone.push(element); + return clone; + })); + }; + /** + * @inheritDoc + */ + ArrayControlRenderer.prototype.render = function () { + var _this = this; + var _a = this.props, schema = _a.schema, uischema = _a.uischema, data = _a.data, path = _a.path; + var controlElement = uischema; + var label = label_util_1.getElementLabelObject(schema, controlElement); + var resolvedSchema = path_util_1.resolveSchema(schema, controlElement.scope.$ref + '/items'); + var className = "control " + (renderer_1.convertToClassName(controlElement.scope.$ref)); + return (JSX_1.JSX.createElement("div", { className: className }, + JSX_1.JSX.createElement("fieldset", { className: exports.getStyle('array.layout') }, + JSX_1.JSX.createElement("legend", null, + JSX_1.JSX.createElement("button", { className: exports.getStyle('array.button'), onclick: function () { return _this.addNewItem(path); } }, "+"), + JSX_1.JSX.createElement("label", { className: 'array.label' }, label.show ? label.text : '')), + JSX_1.JSX.createElement("div", { className: core_1.JsonForms.stylingRegistry.getAsClassName('array.children') }, data ? data.map(function (child, index) { + var generatedUi = ui_schema_gen_1.generateDefaultUISchema(resolvedSchema, 'HorizontalLayout'); + var childPath = path_util_1.compose(path, index + ''); + return (JSX_1.JSX.createElement(dispatch_renderer_1.default, { schema: resolvedSchema, uischema: generatedUi, path: childPath })); + }) : JSX_1.JSX.createElement("p", null, "No data"))))); + }; + return ArrayControlRenderer; +}(renderer_1.Renderer)); +exports.ArrayControlRenderer = ArrayControlRenderer; +var mapStateToProps = function (state, ownProps) { + var path = path_util_1.composeWithUi(ownProps.uischema, ownProps.path); + return { + data: path_util_1.resolveData(index_1.getData(state), path), + uischema: ownProps.uischema, + schema: ownProps.schema, + path: path + }; +}; +exports.default = renderer_util_1.registerStartupRenderer(exports.arrayTester, inferno_redux_1.connect(mapStateToProps)(ArrayControlRenderer)); +//# sourceMappingURL=array-renderer.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/array-renderer.js.map b/dist/ts-build/renderers/additional/array-renderer.js.map new file mode 100644 index 000000000..3153abed1 --- /dev/null +++ b/dist/ts-build/renderers/additional/array-renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"array-renderer.js","sourceRoot":"","sources":["../../../../src/renderers/additional/array-renderer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,0BAA4B;AAC5B,gDAAmE;AACnE,8CAO4B;AAE5B,6CAAqF;AACrF,4CAAsD;AACtD,mCAAuC;AACvC,gEAAyE;AACzE,yCAAuC;AACvC,+CAAwC;AACxC,8CAA+C;AAC/C,0DAAoD;AAEpD,kDAA2D;AAE9C,QAAA,QAAQ,GAAG,UAAC,SAAiB;IACxC,OAAA,gBAAS,CAAC,e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D;AApEY,oDAAoB;AAsEjC,IAAM,eAAe,GAAG,UAAC,KAAK,EAAE,QAAQ;IACtC,IAAM,IAAI,GAAG,yBAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE7D,MAAM,CAAC;QACL,IAAI,EAAE,uBAAW,CAAC,eAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;QACvC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI,MAAA;KACL,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uCAAuB,CACpC,mBAAW,EACX,uBAAO,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAAC,CAC/C,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/categorization-renderer.d.ts b/dist/ts-build/renderers/additional/categorization-renderer.d.ts new file mode 100644 index 000000000..7ae621c8d --- /dev/null +++ b/dist/ts-build/renderers/additional/categorization-renderer.d.ts @@ -0,0 +1,14 @@ +import { RankedTester } from '../../core/testers'; +import { Category } from '../../models/uischema'; +/** + * Default tester for a categorization. + * @type {RankedTester} + */ +export declare const categorizationTester: RankedTester; +export interface CategorizationState { + selected: { + category: Category; + }; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/additional/categorization-renderer.js b/dist/ts-build/renderers/additional/categorization-renderer.js new file mode 100644 index 000000000..616012d55 --- /dev/null +++ b/dist/ts-build/renderers/additional/categorization-renderer.js @@ -0,0 +1,104 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var _ = require("lodash"); +var core_1 = require("../../core"); +var renderer_1 = require("../../core/renderer"); +var testers_1 = require("../../core/testers"); +var renderer_util_1 = require("../renderer.util"); +var inferno_redux_1 = require("inferno-redux"); +var dispatch_renderer_1 = require("../dispatch-renderer"); +var isCategorization = function (category) { + return category.type === 'Categorization'; +}; +/** + * Default tester for a categorization. + * @type {RankedTester} + */ +exports.categorizationTester = testers_1.rankWith(1, testers_1.and(testers_1.uiTypeIs('Categorization'), function (uischema) { + var hasCategory = function (element) { + if (_.isEmpty(element.elements)) { + return false; + } + return element.elements + .map(function (elem) { return isCategorization(elem) ? + hasCategory(elem) : + elem.type === 'Category'; }) + .reduce(function (prev, curr) { return prev && curr; }, true); + }; + return hasCategory(uischema); +})); +var CategorizationRenderer = /** @class */ (function (_super) { + __extends(CategorizationRenderer, _super); + function CategorizationRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @inheritDoc + */ + CategorizationRenderer.prototype.render = function () { + var _a = this.props, uischema = _a.uischema, visible = _a.visible, enabled = _a.enabled; + var controlElement = uischema; + var categorization = uischema; + var classNames = [].concat(core_1.JsonForms.stylingRegistry.getAsClassName('categorization')); + var masterClassNames = [].concat(core_1.JsonForms.stylingRegistry.getAsClassName('categorization.master')); + var detailClassNames = [].concat(core_1.JsonForms.stylingRegistry.getAsClassName('categorization.detail')); + return (JSX_1.JSX.createElement("fieldset", { className: classNames, hidden: visible === null || visible === undefined ? false : !visible, disabled: enabled === null || enabled === undefined ? false : !enabled }, + JSX_1.JSX.createElement("div", { className: masterClassNames }, this.createCategorization(categorization)), + JSX_1.JSX.createElement("div", { className: detailClassNames }, this.renderCategory(this.findCategory(controlElement))))); + }; + CategorizationRenderer.prototype.findCategory = function (categorization) { + var category = categorization.elements[0]; + if (this.state && this.state.selected) { + return this.state.selected.category; + } + if (isCategorization(category)) { + return this.findCategory(category); + } + return category; + }; + CategorizationRenderer.prototype.renderCategory = function (category) { + var _a = this.props, schema = _a.schema, path = _a.path; + // TODO: add selected style + if (category.elements === undefined) { + return (JSX_1.JSX.createElement("div", { id: 'categorization.detail' })); + } + return (JSX_1.JSX.createElement("div", { id: 'categorization.detail' }, category.elements.map(function (child) { + return (JSX_1.JSX.createElement(dispatch_renderer_1.default, { uischema: child, schema: schema, path: path })); + }))); + }; + CategorizationRenderer.prototype.createCategorization = function (categorization, depth) { + var _this = this; + if (depth === void 0) { depth = 0; } + return (JSX_1.JSX.createElement("ul", { className: core_1.JsonForms.stylingRegistry.getAsClassName('category.subcategories') }, categorization.elements.map(function (category) { + if (isCategorization(category)) { + return (JSX_1.JSX.createElement("li", { className: core_1.JsonForms.stylingRegistry.getAsClassName('category.group') }, + JSX_1.JSX.createElement("span", null, category.label), + _this.createCategorization(category, depth + 1))); + } + else { + return (JSX_1.JSX.createElement("li", { onClick: function () { + _this.setState({ + selected: { + category: category + } + }); + } }, + JSX_1.JSX.createElement("span", null, category.label))); + } + }))); + }; + return CategorizationRenderer; +}(renderer_1.Renderer)); +exports.default = renderer_util_1.registerStartupRenderer(exports.categorizationTester, inferno_redux_1.connect(renderer_util_1.mapStateToLayoutProps)(CategorizationRenderer)); +//# sourceMappingURL=categorization-renderer.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/categorization-renderer.js.map b/dist/ts-build/renderers/additional/categorization-renderer.js.map new file mode 100644 index 000000000..849bb69d6 --- /dev/null +++ b/dist/ts-build/renderers/additional/categorization-renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"categorization-renderer.js","sourceRoot":"","sources":["../../../../src/renderers/additional/categorization-renderer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,0BAA4B;AAC5B,mCAAuC;AACvC,gDAA8D;AAC9D,8CAA2E;AAE3E,kDAAkF;AAClF,+CAAwC;AACxC,0DAAoD;AAEpD,IAAM,gBAAgB,GAAG,UAAC,QAAmC;IAC3D,MAAM,CAAC,QAAQ,CAAC,IAAI,KAA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Q,GA+G5C;AAED,kBAAe,uCAAuB,CACpC,4BAAoB,EACpB,uBAAO,CAAC,qCAAqB,CAAC,CAAC,sBAAsB,CAAC,CACvD,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/label.renderer.d.ts b/dist/ts-build/renderers/additional/label.renderer.d.ts new file mode 100644 index 000000000..b50eded1c --- /dev/null +++ b/dist/ts-build/renderers/additional/label.renderer.d.ts @@ -0,0 +1,18 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a label. + * @type {RankedTester} + */ +export declare const labelRendererTester: RankedTester; +/** + * Default renderer for a label. + */ +export declare class LabelRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/additional/label.renderer.js b/dist/ts-build/renderers/additional/label.renderer.js new file mode 100644 index 000000000..211a2787a --- /dev/null +++ b/dist/ts-build/renderers/additional/label.renderer.js @@ -0,0 +1,54 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var inferno_redux_1 = require("inferno-redux"); +var _ = require("lodash"); +var renderer_1 = require("../../core/renderer"); +var testers_1 = require("../../core/testers"); +var core_1 = require("../../core"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for a label. + * @type {RankedTester} + */ +exports.labelRendererTester = testers_1.rankWith(1, testers_1.uiTypeIs('Label')); +/** + * Default renderer for a label. + */ +var LabelRenderer = /** @class */ (function (_super) { + __extends(LabelRenderer, _super); + function LabelRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @inheritDoc + */ + LabelRenderer.prototype.render = function () { + var _a = this.props, uischema = _a.uischema, visible = _a.visible; + var labelElement = uischema; + var classNames = [core_1.JsonForms.stylingRegistry.getAsClassName('label-control')]; + var isHidden = !visible; + return (JSX_1.JSX.createElement("label", { hidden: isHidden, className: classNames }, labelElement.text !== undefined && labelElement.text !== null ? + labelElement.text : '')); + }; + return LabelRenderer; +}(renderer_1.Renderer)); +exports.LabelRenderer = LabelRenderer; +var mapStateToProps = function (state, ownProps) { + var visible = _.has(ownProps, 'visible') ? ownProps.visible : renderer_1.isVisible(ownProps, state); + return { + visible: visible + }; +}; +exports.default = renderer_util_1.registerStartupRenderer(exports.labelRendererTester, inferno_redux_1.connect(mapStateToProps)(LabelRenderer)); +//# sourceMappingURL=label.renderer.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/label.renderer.js.map b/dist/ts-build/renderers/additional/label.renderer.js.map new file mode 100644 index 000000000..79bee3710 --- /dev/null +++ b/dist/ts-build/renderers/additional/label.renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"label.renderer.js","sourceRoot":"","sources":["../../../../src/renderers/additional/label.renderer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,+CAAwC;AACxC,0BAA4B;AAE5B,gDAAyE;AACzE,8CAAsE;AACtE,mCAAuC;AACvC,kDAA2D;AAE3D;;;GAGG;AACU,QAAA,mBAAmB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,kBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAEhF;;GAEG;AACH;IAAmC,iCAA6B;IAAhE;;IAoBA,CAAC;IAlBC;;OAEG;IACH,8BAAM,GAAN;QACQ,IAAA,eAAkC,EAAhC,sBAAQ,EAAE,oBAAO,CAAgB;QACzC,IAAM,YAAY,GAAiB,QAAwB,CAAC;QAC5D,IAAM,UAAU,GAAG,CAAC,gBAAS,CAAC,eAAe,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC;QAC/E,IAAM,QAAQ,GAAG,CAAC,OAAO,CAAC;QAE1B,MAAM,CAAC,CACL,mCAAO,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,IAE1C,YAAY,CAAC,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YAC7D,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAEpB,CACT,CAAC;IACJ,CAAC;IACH,oBAAC;AAAD,CAAC,AApBD,CAAmC,mBAAQ,GAoB1C;AApBY,sCAAa;AAsB1B,IAAM,eAAe,GAAG,UAAC,KAAK,EAAE,QAAQ;IACtC,IAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAE,oBAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE5F,MAAM,CAAC;QACL,OAAO,SAAA;KACR,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uCAAuB,CACpC,2BAAmB,EACnB,uBAAO,CAAC,eAAe,CAAC,CAAC,aAAa,CAAC,CACxC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/table-array.control.d.ts b/dist/ts-build/renderers/additional/table-array.control.d.ts new file mode 100644 index 000000000..760216525 --- /dev/null +++ b/dist/ts-build/renderers/additional/table-array.control.d.ts @@ -0,0 +1,18 @@ +import { Renderer } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +/** + * Alternative tester for an array that also checks whether the 'table' + * option is set. + * @type {RankedTester} + */ +export declare const tableArrayTester: RankedTester; +export declare class TableArrayControl extends Renderer { + addNewItem(path: string): void; + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/additional/table-array.control.js b/dist/ts-build/renderers/additional/table-array.control.js new file mode 100644 index 000000000..5cd0c7406 --- /dev/null +++ b/dist/ts-build/renderers/additional/table-array.control.js @@ -0,0 +1,114 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var _ = require("lodash"); +var inferno_redux_1 = require("inferno-redux"); +var core_1 = require("../../core"); +var renderer_1 = require("../../core/renderer"); +var testers_1 = require("../../core/testers"); +var label_util_1 = require("../label.util"); +var path_util_1 = require("../../path.util"); +var actions_1 = require("../../actions"); +var index_1 = require("../../reducers/index"); +var dispatch_renderer_1 = require("../dispatch-renderer"); +var renderer_util_1 = require("../renderer.util"); +/** + * Alternative tester for an array that also checks whether the 'table' + * option is set. + * @type {RankedTester} + */ +exports.tableArrayTester = testers_1.rankWith(10, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.optionIs('table', true), testers_1.schemaMatches(function (schema) { + return !_.isEmpty(schema) + && schema.type === 'array' + && !_.isEmpty(schema.items) + && !Array.isArray(schema.items) // we don't care about tuples + && schema.items.type === 'object'; +}))); +var TableArrayControl = /** @class */ (function (_super) { + __extends(TableArrayControl, _super); + function TableArrayControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + // TODO duplicate code + TableArrayControl.prototype.addNewItem = function (path) { + var element = {}; + this.props.dispatch(actions_1.update(path, function (array) { + if (array === undefined || array === null) { + return [element]; + } + var clone = _.clone(array); + clone.push(element); + return clone; + })); + }; + /** + * @inheritDoc + */ + TableArrayControl.prototype.render = function () { + var _this = this; + var _a = this.props, uischema = _a.uischema, schema = _a.schema, path = _a.path, data = _a.data; + var controlElement = uischema; + var tableClasses = [ + core_1.JsonForms.stylingRegistry.getAsClassName('array-table.table'), + "control " + renderer_1.convertToClassName(controlElement.scope.$ref) + ]; + var labelClass = core_1.JsonForms.stylingRegistry.getAsClassName('array-table.label'); + var buttonClass = core_1.JsonForms.stylingRegistry.getAsClassName('array-table.button'); + var headerClass = core_1.JsonForms.stylingRegistry.getAsClassName('array-table') + .concat(renderer_1.convertToClassName(controlElement.scope.$ref)); + var labelObject = label_util_1.getElementLabelObject(schema, controlElement); + var resolvedSchema = path_util_1.resolveSchema(schema, controlElement.scope.$ref + '/items'); + var createControlElement = function (key) { return ({ + type: 'Control', + label: false, + scope: { $ref: "#/properties/" + key } + }); }; + return (JSX_1.JSX.createElement("div", { className: tableClasses }, + JSX_1.JSX.createElement("header", { className: headerClass }, + JSX_1.JSX.createElement("label", { className: labelClass }, labelObject.show && labelObject.text), + JSX_1.JSX.createElement("button", { className: buttonClass, onclick: function () { return _this.addNewItem(path); } }, + "Add to ", + labelObject.text)), + JSX_1.JSX.createElement("table", null, + JSX_1.JSX.createElement("thead", null, + JSX_1.JSX.createElement("tr", null, _(resolvedSchema.properties) + .keys() + .filter(function (prop) { return resolvedSchema.properties[prop].type !== 'array'; }) + .map(function (prop) { return JSX_1.JSX.createElement("th", null, prop); }) + .value())), + JSX_1.JSX.createElement("tbody", null, data ? data.map(function (child, index) { + return (JSX_1.JSX.createElement("tr", null, _.chain(resolvedSchema.properties) + .keys() + .filter(function (prop) { return resolvedSchema.properties[prop].type !== 'array'; }) + .map(function (prop) { + var childPath = path_util_1.compose(path, index + ''); + return (JSX_1.JSX.createElement("td", null, + JSX_1.JSX.createElement(dispatch_renderer_1.default, { schema: resolvedSchema, uischema: createControlElement(prop), path: childPath }))); + }) + .value())); + }) : JSX_1.JSX.createElement("p", null, "No data"))))); + }; + return TableArrayControl; +}(renderer_1.Renderer)); +exports.TableArrayControl = TableArrayControl; +var mapStateToProps = function (state, ownProps) { + var path = path_util_1.composeWithUi(ownProps.uischema, ownProps.path); + return { + data: path_util_1.resolveData(index_1.getData(state), path), + uischema: ownProps.uischema, + schema: ownProps.schema, + path: path + }; +}; +exports.default = renderer_util_1.registerStartupRenderer(exports.tableArrayTester, inferno_redux_1.connect(mapStateToProps)(TableArrayControl)); +//# sourceMappingURL=table-array.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/table-array.control.js.map b/dist/ts-build/renderers/additional/table-array.control.js.map new file mode 100644 index 000000000..04bda50c4 --- /dev/null +++ b/dist/ts-build/renderers/additional/table-array.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"table-array.control.js","sourceRoot":"","sources":["../../../../src/renderers/additional/table-array.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,0BAA4B;AAC5B,+CAAwC;AACxC,mCAAuC;AACvC,gDAAmE;AACnE,8CAAoG;AAGpG,4CAAsD;AACtD,6CAAqF;AACrF,yCAAuC;AACvC,8CAA+C;AAC/C,0DAAoD;AAEpD,kDAA2D;AAE3D;;;;GAIG;AACU,QAAA,gBAAgB,GAAiB,kBAAQ,CAAC,EAAE,EAAE,aAAG,CAC1D,kBAAQ,CAAC,SAAS,CAAC,EACnB,kBAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,EACvB,uBAAa,CAAC,UAAA,MAAM;IAChB,OAAA,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;WACf,MAAM,CAAC,IAAI,KAAK,OAAO;WACvB,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;WACxB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,6BAA6B;WACzD,MAAM,CAAC,KAAoB,CAAC,IAAI,KAAK,QAAQ;AAJjD,CAIiD,CACpD,CAAC,CACL,CAAC;AAEF;IAAuC,qCAA4B;IAAnE;;IA2GA,CAAC;IAzGC,sBAAsB;IACtB,sCAAU,GAAV,UAAW,IAAY;QACrB,IAAM,OAAO,GAAG,EAAE,CAAC;QACnB,IAAI,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AM,CAAC,CACL;4BACE,wBAAC,2BAAgB,IACf,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC,EACpC,IAAI,EAAE,SAAS,GACf,CACC,CACN,CAAC;oBACJ,CAAC,CAAC;yBACD,KAAK,EAAE,CAET,CACN,CAAC;gBACJ,CAAC,CAAC,CAAE,CAAC,CAAC,6CAAc,CAEd,CACF,CACJ,CACP,CAAC;IACJ,CAAC;IACH,wBAAC;AAAD,CAAC,AA3GD,CAAuC,mBAAQ,GA2G9C;AA3GY,8CAAiB;AA6G9B,IAAM,eAAe,GAAG,UAAC,KAAK,EAAE,QAAQ;IACtC,IAAM,IAAI,GAAG,yBAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE7D,MAAM,CAAC;QACL,IAAI,EAAE,uBAAW,CAAC,eAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;QACvC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI,MAAA;KACL,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uCAAuB,CACpC,wBAAgB,EAChB,uBAAO,CAAC,eAAe,CAAC,CAAC,iBAAiB,CAAC,CAC5C,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/tree-renderer.d.ts b/dist/ts-build/renderers/additional/tree-renderer.d.ts new file mode 100644 index 000000000..f45f018bd --- /dev/null +++ b/dist/ts-build/renderers/additional/tree-renderer.d.ts @@ -0,0 +1,56 @@ +import { Renderer } from '../../core/renderer'; +import { JsonSchema } from '../../models/jsonSchema'; +import { RankedTester } from '../../core/testers'; +import { ControlProps } from '../controls/Control'; +/** + * Default tester for a master-detail layout. + * @type {RankedTester} + */ +export declare const treeMasterDetailTester: RankedTester; +export interface TreeMasterDetailState { + selected: { + schema: JsonSchema; + data: any; + path: string; + }; +} +export declare class TreeMasterDetail extends Renderer { + componentWillMount(): void; + render(): any; + openDialog(ev: Event, schema: JsonSchema, parentPath: string): void; + private closeDialog(); + private addToRoot(); + private renderMaster(schema); + /** + * Expands the given array of root elements by expanding every element. + * It is assumed that the roor elements do not support drag and drop. + * Based on this, a delete function is created for every element. + * + * @param data the array to expand + * @param schema the {@link JsonSchema} defining the elements' type + */ + private expandRootArray(schema); + /** + * Expands the given data array by expanding every element. + * If the parent data containing the array is provided, + * a suitable delete function for the expanded elements is created. + * + * @param data the array to expand + * @param property the {@link ContainmentProperty} defining the property that the array belongs to + * @param parentData the data containing the array as a property + */ + private expandArray(data, property, path, parentData?); + private getNamingFunction(schema); + /** + * Renders a data object as a

      • child element of the given
          list. + * + * @param data The rendered data + * @param schema The schema describing the rendered data's type + * @param deleteFunction A function to delete the data from the model + */ + private expandObject(scopedPath, schema, deleteFunction); + private propHasData(prop, data); + private renderChildren(prop, parentPath, parentSchema, parentData); +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/additional/tree-renderer.js b/dist/ts-build/renderers/additional/tree-renderer.js new file mode 100644 index 000000000..af3141dd5 --- /dev/null +++ b/dist/ts-build/renderers/additional/tree-renderer.js @@ -0,0 +1,329 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var inferno_1 = require("inferno"); +var core_1 = require("../../core"); +var renderer_1 = require("../../core/renderer"); +var _ = require("lodash"); +var path_util_1 = require("../../path.util"); +var testers_1 = require("../../core/testers"); +var actions_1 = require("../../actions"); +var ui_schema_gen_1 = require("../../generators/ui-schema-gen"); +var inferno_redux_1 = require("inferno-redux"); +var index_1 = require("../../reducers/index"); +var dispatch_renderer_1 = require("../dispatch-renderer"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for a master-detail layout. + * @type {RankedTester} + */ +exports.treeMasterDetailTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('MasterDetailLayout'), function (uischema) { + var control = uischema; + if (control.scope === undefined || control.scope === null) { + return false; + } + return !(control.scope.$ref === undefined || control.scope.$ref === null); +})); +var isNotTuple = function (schema) { return !Array.isArray(schema.items); }; +var TreeMasterDetail = /** @class */ (function (_super) { + __extends(TreeMasterDetail, _super); + function TreeMasterDetail() { + return _super !== null && _super.apply(this, arguments) || this; + } + TreeMasterDetail.prototype.componentWillMount = function () { + var _a = this.props, uischema = _a.uischema, data = _a.data, resolvedSchema = _a.resolvedSchema; + var controlElement = uischema; + if (_.isArray(data)) { + var dataPathSegments = path_util_1.toDataPathSegments(controlElement.scope.$ref); + var path = _.isEmpty(dataPathSegments) ? '' : dataPathSegments.join('.'); + this.setState({ + selected: { + schema: resolvedSchema.items, + data: data[0], + path: path_util_1.compose(path, '0') + } + }); + } + else { + this.setState({ + selected: { + schema: resolvedSchema, + data: data, + path: '' + } + }); + } + }; + TreeMasterDetail.prototype.render = function () { + var _this = this; + var _a = this.props, uischema = _a.uischema, resolvedSchema = _a.resolvedSchema, visible = _a.visible; + var controlElement = uischema; + var rootData = this.props.data; + return (JSX_1.JSX.createElement("div", { hidden: !visible, className: 'jsf-treeMasterDetail' }, + JSX_1.JSX.createElement("div", { className: 'jsf-treeMasterDetail-header' }, + JSX_1.JSX.createElement("label", null, typeof controlElement.label === 'string' ? controlElement.label : ''), + Array.isArray(rootData) && + JSX_1.JSX.createElement("button", { className: 'jsf-treeMasterDetail-add', onClick: function () { + _this.addToRoot(); + } }, "Add to root")), + JSX_1.JSX.createElement("div", { className: 'jsf-treeMasterDetail-content' }, + JSX_1.JSX.createElement("div", { className: 'jsf-treeMasterDetail-master' }, this.renderMaster(resolvedSchema)), + JSX_1.JSX.createElement("div", { className: 'jsf-treeMasterDetail-detail' }, this.state.selected ? + JSX_1.JSX.createElement(dispatch_renderer_1.default, { schema: this.state.selected.schema, path: this.state.selected.path, uischema: ui_schema_gen_1.generateDefaultUISchema(this.state.selected.schema) }) : 'Select an item')), + JSX_1.JSX.createElement("div", null, + JSX_1.JSX.createElement("dialog", { id: 'dialog' }, + JSX_1.JSX.createElement("label", null, "Select item to create"), + JSX_1.JSX.createElement("div", { id: 'dialog-content-container', className: 'content' }), + JSX_1.JSX.createElement("button", { className: 'jsf-treeMasterDetail-dialog-close', onClick: function () { + _this.closeDialog(); + } }, "Close"))))); + }; + // create dialog on demand + // open dialog + TreeMasterDetail.prototype.openDialog = function (ev, schema, parentPath) { + var dispatch = this.props.dispatch; + ev.stopPropagation(); + var dialog = document.getElementById('dialog'); + var vnodeContent = JSX_1.JSX.createElement("div", { className: 'dialog-content' }, core_1.JsonForms.schemaService.getContainmentProperties(schema) + .map(function (prop) { + return JSX_1.JSX.createElement("button", { className: core_1.JsonForms.stylingRegistry.get('button'), onClick: function () { + var newData = _.keys(prop.schema.properties).reduce(function (d, key) { + if (prop.schema.properties[key].default) { + d[key] = prop.schema.properties[key].default; + } + return d; + }, {}); + // prop.addToData(data)(newData); + dispatch(actions_1.update(path_util_1.compose(parentPath, prop.property), function (array) { + if (_.isEmpty(array)) { + return [newData]; + } + array.push(newData); + return array; + })); + dialog.close(); + } }, prop.label); + })); + // TODO + inferno_1.default.render(vnodeContent, document.getElementById('dialog-content-container')); + dialog.showModal(); + }; + TreeMasterDetail.prototype.closeDialog = function () { + var dialog = document.getElementById('dialog'); + dialog.close(); + }; + TreeMasterDetail.prototype.addToRoot = function () { + var _a = this.props, schema = _a.schema, dispatch = _a.dispatch, path = _a.path; + if (isNotTuple(schema)) { + dispatch(actions_1.update(path, function (data) { + var clone = data.slice(); + clone.push({}); + return clone; + })); + } + }; + TreeMasterDetail.prototype.renderMaster = function (schema) { + // TODO: so far no drag and drop support + if (schema.items !== undefined) { + return (JSX_1.JSX.createElement("ul", null, this.expandRootArray(schema.items))); + } + else { + return (JSX_1.JSX.createElement("ul", null, this.expandObject(this.props.path, schema, null))); + } + }; + /** + * Expands the given array of root elements by expanding every element. + * It is assumed that the roor elements do not support drag and drop. + * Based on this, a delete function is created for every element. + * + * @param data the array to expand + * @param schema the {@link JsonSchema} defining the elements' type + */ + TreeMasterDetail.prototype.expandRootArray = function (schema) { + var _this = this; + var _a = this.props, dispatch = _a.dispatch, path = _a.path; + var data = this.props.data; + if (data === undefined || data === null) { + return; + } + return data.map(function (element, index) { + var composedPath = path_util_1.compose(path, index + ''); + return _this.expandObject(composedPath, schema, function () { return dispatch(actions_1.update(path, function (d) { + var clone = d.slice(); + clone.splice(index, 1); + return clone; + })); }); + }); + }; + /** + * Expands the given data array by expanding every element. + * If the parent data containing the array is provided, + * a suitable delete function for the expanded elements is created. + * + * @param data the array to expand + * @param property the {@link ContainmentProperty} defining the property that the array belongs to + * @param parentData the data containing the array as a property + */ + TreeMasterDetail.prototype.expandArray = function (data, property, path, parentData) { + var _this = this; + if (data === undefined || data === null) { + return; + } + return data.map(function (element, index) { + var deleteFunction = null; + if (!_.isEmpty(parentData)) { + deleteFunction = function (d) { + property.deleteFromData(parentData)(d); + return parentData; + }; + } + var composedPath = path_util_1.compose(path, index.toString() + ''); + return _this.expandObject(composedPath, property.schema, deleteFunction); + }); + }; + TreeMasterDetail.prototype.getNamingFunction = function (schema) { + var uischema = this.props.uischema; + if (uischema.options !== undefined) { + var labelProvider_1 = uischema.options.labelProvider; + if (labelProvider_1 !== undefined && labelProvider_1[schema.id] !== undefined) { + return function (element) { + return element[labelProvider_1[schema.id]]; + }; + } + } + var namingKeys = Object.keys(schema.properties).filter(function (key) { return key === 'id' || key === 'name'; }); + if (namingKeys.length !== 0) { + return function (element) { return element[namingKeys[0]]; }; + } + return function (obj) { return JSON.stringify(obj); }; + }; + /** + * Renders a data object as a
        • child element of the given
            list. + * + * @param data The rendered data + * @param schema The schema describing the rendered data's type + * @param deleteFunction A function to delete the data from the model + */ + TreeMasterDetail.prototype.expandObject = function (scopedPath, schema, deleteFunction) { + var _this = this; + var _a = this.props, uischema = _a.uischema, rootData = _a.rootData; + var data = path_util_1.resolveData(rootData, scopedPath); + var liClasses = this.state.selected === data ? 'selected' : ''; + var vnode = (JSX_1.JSX.createElement("li", { className: liClasses }, + JSX_1.JSX.createElement("div", null, + _.has(uischema.options, 'imageProvider') ? + JSX_1.JSX.createElement("span", { className: "icon " + uischema.options.imageProvider[schema.id] }) : '', + JSX_1.JSX.createElement("span", { className: 'label', onClick: function (ev) { + _this.setState({ + selected: { + schema: schema, + data: data, + path: scopedPath + } + }); + } }, + JSX_1.JSX.createElement("span", null, this.getNamingFunction(schema)(data)), + core_1.JsonForms.schemaService.hasContainmentProperties(schema) ? + (JSX_1.JSX.createElement("span", { className: 'add', onClick: function (ev) { + _this.openDialog(ev, schema, scopedPath); + } }, '\u2795')) : '', + deleteFunction !== null && + JSX_1.JSX.createElement("span", { className: 'remove', onClick: function () { + deleteFunction(); + } }, '\u274C'))), + // render contained children of this element + core_1.JsonForms.schemaService.getContainmentProperties(schema) + .filter(function (prop) { return _this.propHasData(prop, data); }) + .map(function (prop) { return JSX_1.JSX.createElement("ul", null, _this.renderChildren(prop, scopedPath, schema, data)); }))); + // add a separate list for each containment property + core_1.JsonForms.schemaService.getContainmentProperties(schema).forEach(function (p) { + var id = p.schema.id; + if (id === undefined || id === null) { + // TODO proper logging + console.warn('The property\'s schema with label \'' + p.label + + '\' has no id. No Drag & Drop is possible.'); + return; + } + // FIXME: DND support + // FIXME: create child list and activate drag and drop + // registerDnDWithGroupId(this.treeNodeMapping, ul, id); + }); + return vnode; + }; + TreeMasterDetail.prototype.propHasData = function (prop, data) { + var uischema = this.props.uischema; + var sid = prop.schema.id; + if (sid === undefined || sid === null) { + // TODO proper logging + console.warn('The property\'s schema with label \'' + prop.label + + '\' has no id. No Drag & Drop is possible.'); + } + var propertyData = prop.getData(data); + /*tslint:disable:no-string-literal */ + if (uischema.options !== undefined && + uischema.options['modelMapping'] !== undefined + && !_.isEmpty(propertyData)) { + propertyData = propertyData.filter(function (value) { + // only use filter criterion if the checked value has the mapped attribute + if (value[uischema.options['modelMapping'].attribute]) { + return prop.schema.id === uischema.options['modelMapping'] + .mapping[value[uischema.options['modelMapping'].attribute]]; + } + return true; + }); + } + // TODO: remove check OR add id to test data (?) + return !_.isEmpty(propertyData); + }; + // TODO: update selected element once selection has been changed + TreeMasterDetail.prototype.renderChildren = function (prop, parentPath, parentSchema, parentData) { + var composedPath = path_util_1.compose(parentPath, prop.property); + var data = path_util_1.resolveData(this.props.data, composedPath); + var schema = prop.schema; + var array = data; + var key = prop.property; + var parentProperties = core_1.JsonForms.schemaService.getContainmentProperties(parentSchema); + for (var _i = 0, parentProperties_1 = parentProperties; _i < parentProperties_1.length; _i++) { + var property = parentProperties_1[_i]; + // If available, additionally use schema id to identify the correct property + if (!_.isEmpty(schema.id) && schema.id !== property.schema.id) { + continue; + } + if (key === property.property) { + return this.expandArray(array, property, composedPath, parentData); + } + } + // TODO proper logging + console.warn('Could not render children because no fitting property was found.'); + return undefined; + }; + return TreeMasterDetail; +}(renderer_1.Renderer)); +exports.TreeMasterDetail = TreeMasterDetail; +var mapStateToProps = function (state, ownProps) { + var path = path_util_1.compose(ownProps.path, path_util_1.toDataPathSegments(ownProps.uischema.scope.$ref).join('.')); + var visible = _.has(ownProps, 'visible') ? ownProps.visible : renderer_1.isVisible(ownProps, state); + var enabled = _.has(ownProps, 'enabled') ? ownProps.enabled : renderer_1.isEnabled(ownProps, state); + return { + rootData: index_1.getData(state), + data: path_util_1.resolveData(index_1.getData(state), path), + uischema: ownProps.uischema, + schema: ownProps.schema, + resolvedSchema: path_util_1.resolveSchema(ownProps.schema, ownProps.uischema.scope.$ref), + path: path, + visible: visible, + enabled: enabled + }; +}; +exports.default = renderer_util_1.registerStartupRenderer(exports.treeMasterDetailTester, inferno_redux_1.connect(mapStateToProps)(TreeMasterDetail)); +//# sourceMappingURL=tree-renderer.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/additional/tree-renderer.js.map b/dist/ts-build/renderers/additional/tree-renderer.js.map new file mode 100644 index 000000000..9545023a7 --- /dev/null +++ b/dist/ts-build/renderers/additional/tree-renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tree-renderer.js","sourceRoot":"","sources":["../../../../src/renderers/additional/tree-renderer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,mCAA8B;AAC9B,mCAAuC;AACvC,gDAAqE;AACrE,0BAA4B;AAE5B,6CAA0F;AAE1F,8CAA2E;AAE3E,yCAAuC;AACvC,gEAAyE;AACzE,+CAAwC;AACxC,8CAA+C;AAC/C,0DAAoD;AAEpD,kDAA2D;AAE3D;;;GAGG;AACU,QAAA,sBAAsB,GAC/B,kBAAQ,CACJ,CAAC,EACD,aAAG,CACC,kBAAQ,CAAC,oBAAoB,CAAC,EAC9B,UAAA,QAAQ;IACN,IAAM,OAAO,GAAG,QAA8B,CAAC;IAC/C,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC5E,CAAC,CACJ,CAAC,CAAC;AAEX,IAAM,UAAU,GAAG,UAAC,MAAkB,IAAK,OAAA,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAA5B,CAA4B,CAAC;AAUxE;IAAsC,oCAA6C;IAAnF;;IAkaA,CAAC;IAhaC,6CAAkB,GAAlB;QACQ,IAAA,eAA+C,EAA7C,sBAAQ,EAAE,cAAI,EAAE,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,MAAM;QACvB,cAAc,EAAE,yBAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC5E,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,OAAO,SAAA;KACR,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,uCAAuB,CACpC,8BAAsB,EACtB,uBAAO,CAAC,eAAe,CAAC,CAAC,gBAAgB,CAAC,CAC3C,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/Control.d.ts b/dist/ts-build/renderers/controls/Control.d.ts new file mode 100644 index 000000000..e3682c7f6 --- /dev/null +++ b/dist/ts-build/renderers/controls/Control.d.ts @@ -0,0 +1,18 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +export interface ControlClassNames { + input: string; + label: string; + wrapper: string; +} +export interface ControlProps extends RendererProps { + data: any; + path: string; + classNames: ControlClassNames; + id: string; + visible: boolean; + enabled: boolean; + label: string; +} +export declare class Control

            extends Renderer { + updateData(value: any): void; +} diff --git a/dist/ts-build/renderers/controls/Control.js b/dist/ts-build/renderers/controls/Control.js new file mode 100644 index 000000000..5984dbb1e --- /dev/null +++ b/dist/ts-build/renderers/controls/Control.js @@ -0,0 +1,27 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var renderer_1 = require("../../core/renderer"); +var actions_1 = require("../../actions"); +// const { data, classNames, controlId, visible, enabled, errors, label } = this.props; +var Control = /** @class */ (function (_super) { + __extends(Control, _super); + function Control() { + return _super !== null && _super.apply(this, arguments) || this; + } + Control.prototype.updateData = function (value) { + this.props.dispatch(actions_1.update(this.props.path, function () { return value; })); + }; + return Control; +}(renderer_1.Renderer)); +exports.Control = Control; +//# sourceMappingURL=Control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/Control.js.map b/dist/ts-build/renderers/controls/Control.js.map new file mode 100644 index 000000000..7c2654e8e --- /dev/null +++ b/dist/ts-build/renderers/controls/Control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/Control.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA8D;AAC9D,yCAAuC;AAkBvC,uFAAuF;AAEvF;IAAwD,2BAAc;IAAtE;;IAKA,CAAC;IAHC,4BAAU,GAAV,UAAW,KAAK;QACd,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC,CAAC;IAC5D,CAAC;IACH,cAAC;AAAD,CAAC,AALD,CAAwD,mBAAQ,GAK/D;AALY,0BAAO"} \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/boolean.control.d.ts b/dist/ts-build/renderers/controls/boolean.control.d.ts new file mode 100644 index 000000000..f69dae5b7 --- /dev/null +++ b/dist/ts-build/renderers/controls/boolean.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for boolean controls. + * @type {RankedTester} + */ +export declare const booleanControlTester: RankedTester; +export declare class BooleanControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/controls/boolean.control.js b/dist/ts-build/renderers/controls/boolean.control.js new file mode 100644 index 000000000..93807c61c --- /dev/null +++ b/dist/ts-build/renderers/controls/boolean.control.js @@ -0,0 +1,42 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var testers_1 = require("../../core/testers"); +var inferno_redux_1 = require("inferno-redux"); +var Control_1 = require("./Control"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for boolean controls. + * @type {RankedTester} + */ +exports.booleanControlTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.schemaTypeIs('boolean'))); +var BooleanControl = /** @class */ (function (_super) { + __extends(BooleanControl, _super); + function BooleanControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + BooleanControl.prototype.render = function () { + var _this = this; + var _a = this.props, data = _a.data, classNames = _a.classNames, id = _a.id, visible = _a.visible, enabled = _a.enabled, errors = _a.errors, label = _a.label; + var isValid = errors.length === 0; + var divClassNames = 'validation' + (isValid ? '' : ' validation_error'); + return (JSX_1.JSX.createElement("div", { className: classNames.wrapper }, + JSX_1.JSX.createElement("label", { for: id, className: classNames.label, "data-error": errors }, label), + JSX_1.JSX.createElement("input", { type: 'checkbox', checked: data, onClick: function (ev) { return _this.updateData(ev.target.checked === true); }, className: classNames.input, id: id, hidden: !visible, disabled: !enabled }), + JSX_1.JSX.createElement("div", { className: divClassNames }, !isValid ? renderer_util_1.formatErrorMessage(errors) : ''))); + }; + return BooleanControl; +}(Control_1.Control)); +exports.BooleanControl = BooleanControl; +exports.default = renderer_util_1.registerStartupRenderer(exports.booleanControlTester, inferno_redux_1.connect(renderer_util_1.mapStateToControlProps)(BooleanControl)); +//# sourceMappingURL=boolean.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/boolean.control.js.map b/dist/ts-build/renderers/controls/boolean.control.js.map new file mode 100644 index 000000000..334407307 --- /dev/null +++ b/dist/ts-build/renderers/controls/boolean.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"boolean.control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/boolean.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,8CAAyF;AACzF,+CAAwC;AACxC,qCAAkD;AAClD,kDAI0B;AAE1B;;;GAGG;AACU,QAAA,oBAAoB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,aAAG,CAC7D,kBAAQ,CAAC,SAAS,CAAC,EACnB,sBAAY,CAAC,SAAS,CAAC,CACxB,CAAC,CAAC;AAEL;IAAoC,kCAA2B;IAA/D;;IA0BA,CAAC;IAxBC,+BAAM,GAAN;QAAA,iBAuBC;QAtBO,IAAA,eAAsE,EAApE,cAAI,EAAE,0BAAU,EAAE,UAAE,EAAE,oBAAO,EAAE,oBAAO,EAAE,kBAAM,EAAE,gBAAK,CAAgB;QAC7E,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;QACpC,IAAM,aAAa,GAAG,YAAY,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;QAE1E,MAAM,CAAC,CACL,iCAAK,SAAS,EAAE,UAAU,CAAC,OAAO;YAChC,mCAAO,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,gBAAc,MAAM,IAC5D,KAAK,CACA;YACR,mCAAO,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,UAAA,EAAE,IAAI,OAAA,KAAI,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,EAA3C,CAA2C,EAC1D,SAAS,EAAE,UAAU,CAAC,KAAK,EAC3B,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,CAAC,OAAO,EAChB,QAAQ,EAAE,CAAC,OAAO,GACvB;YACF,iCAAK,SAAS,EAAE,aAAa,IAC1B,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACvC,CACF,CACP,CAAC;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA1BD,CAAoC,iBAAO,GA0B1C;AA1BY,wCAAc;AA4B3B,kBAAe,uCAAuB,CACpC,4BAAoB,EACpB,uBAAO,CAAC,sCAAsB,CAAC,CAAC,cAAc,CAAC,CAChD,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/date.control.d.ts b/dist/ts-build/renderers/controls/date.control.d.ts new file mode 100644 index 000000000..dd1dfd926 --- /dev/null +++ b/dist/ts-build/renderers/controls/date.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for date controls. + * @type {RankedTester} + */ +export declare const dateControlTester: RankedTester; +export declare class DateControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/controls/date.control.js b/dist/ts-build/renderers/controls/date.control.js new file mode 100644 index 000000000..a617618f3 --- /dev/null +++ b/dist/ts-build/renderers/controls/date.control.js @@ -0,0 +1,44 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var testers_1 = require("../../core/testers"); +var inferno_redux_1 = require("inferno-redux"); +var Control_1 = require("./Control"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for date controls. + * @type {RankedTester} + */ +exports.dateControlTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.formatIs('date'))); +var DateControl = /** @class */ (function (_super) { + __extends(DateControl, _super); + function DateControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + DateControl.prototype.render = function () { + var _this = this; + var _a = this.props, data = _a.data, classNames = _a.classNames, id = _a.id, visible = _a.visible, enabled = _a.enabled, errors = _a.errors, label = _a.label; + var isValid = errors.length === 0; + var divClassNames = 'validation' + (isValid ? '' : ' validation_error'); + return (JSX_1.JSX.createElement("div", { className: classNames.wrapper }, + JSX_1.JSX.createElement("label", { for: id, className: classNames.label, "data-error": errors }, label), + JSX_1.JSX.createElement("input", { type: 'date', value: data, onInput: function (ev) { + return _this.updateData(new Date(ev.target.value).toISOString().substr(0, 10)); + }, className: classNames.input, id: id, hidden: !visible, disabled: !enabled }), + JSX_1.JSX.createElement("div", { className: divClassNames }, !isValid ? renderer_util_1.formatErrorMessage(errors) : ''))); + }; + return DateControl; +}(Control_1.Control)); +exports.DateControl = DateControl; +exports.default = renderer_util_1.registerStartupRenderer(exports.dateControlTester, inferno_redux_1.connect(renderer_util_1.mapStateToControlProps)(DateControl)); +//# sourceMappingURL=date.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/date.control.js.map b/dist/ts-build/renderers/controls/date.control.js.map new file mode 100644 index 000000000..a23a663fb --- /dev/null +++ b/dist/ts-build/renderers/controls/date.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"date.control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/date.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,8CAAqF;AACrF,+CAAwC;AACxC,qCAAkD;AAClD,kDAI0B;AAE1B;;;GAGG;AACU,QAAA,iBAAiB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,aAAG,CAC1D,kBAAQ,CAAC,SAAS,CAAC,EACnB,kBAAQ,CAAC,MAAM,CAAC,CACjB,CAAC,CAAC;AAEL;IAAiC,+BAA2B;IAA5D;;IA4BA,CAAC;IA1BC,4BAAM,GAAN;QAAA,iB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.control.d.ts new file mode 100644 index 000000000..15610cfd0 --- /dev/null +++ b/dist/ts-build/renderers/controls/enum.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for enum controls. + * @type {RankedTester} + */ +export declare const enumControlTester: RankedTester; +export declare class EnumControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/controls/enum.control.js b/dist/ts-build/renderers/controls/enum.control.js new file mode 100644 index 000000000..dea16ac7c --- /dev/null +++ b/dist/ts-build/renderers/controls/enum.control.js @@ -0,0 +1,47 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var testers_1 = require("../../core/testers"); +var path_util_1 = require("../../path.util"); +var inferno_redux_1 = require("inferno-redux"); +var actions_1 = require("../../actions"); +var Control_1 = require("./Control"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for enum controls. + * @type {RankedTester} + */ +exports.enumControlTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.schemaMatches(function (schema) { return schema.hasOwnProperty('enum'); }))); +var EnumControl = /** @class */ (function (_super) { + __extends(EnumControl, _super); + function EnumControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + EnumControl.prototype.render = function () { + var _a = this.props, uischema = _a.uischema, schema = _a.schema, classNames = _a.classNames, id = _a.id, label = _a.label, visible = _a.visible, enabled = _a.enabled, data = _a.data, dispatch = _a.dispatch, path = _a.path, errors = _a.errors; + var isValid = errors.length === 0; + var options = path_util_1.resolveSchema(schema, uischema.scope.$ref).enum; + var divClassNames = 'validation' + (isValid ? '' : ' validation_error'); + return (JSX_1.JSX.createElement("div", { className: classNames.wrapper }, + JSX_1.JSX.createElement("label", { for: id, className: classNames.label, "data-error": errors }, label), + JSX_1.JSX.createElement("select", { className: classNames.input, hidden: !visible, disabled: !enabled, value: data, onInput: function (ev) { return dispatch(actions_1.update(path, function () { return ev.target.value; })); } }, [JSX_1.JSX.createElement("option", { value: '', selected: data === undefined })] + .concat(options.map(function (optionValue) { + return (JSX_1.JSX.createElement("option", { value: optionValue, label: optionValue, selected: data === optionValue }, optionValue)); + }))), + JSX_1.JSX.createElement("div", { className: divClassNames }, !isValid ? renderer_util_1.formatErrorMessage(errors) : ''))); + }; + return EnumControl; +}(Control_1.Control)); +exports.EnumControl = EnumControl; +exports.default = renderer_util_1.registerStartupRenderer(exports.enumControlTester, inferno_redux_1.connect(renderer_util_1.mapStateToControlProps)(EnumControl)); +//# sourceMappingURL=enum.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/enum.control.js.map b/dist/ts-build/renderers/controls/enum.control.js.map new file mode 100644 index 000000000..b0c051106 --- /dev/null +++ b/dist/ts-build/renderers/controls/enum.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"enum.control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/enum.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,8CAA0F;AAE1F,6CAAgD;AAChD,+CAAwC;AACxC,yCAAuC;AACvC,qCAAkD;AAClD,kDAI0B;AAE1B;;;GAGG;AACU,QAAA,iBAAiB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,aAAG,CAC1D,kBAAQ,CAAC,SAAS,CAAC,EACnB,uBAAa,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAA7B,CAA6B,CAAC,CACvD,CAAC,CAAC;AAEL;IAAiC,+BAA2B;IAA5D;;IA0DA,CAAC;IAxDC,4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a,IAC1B,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACvC,CACF,CACP,CAAC;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AA1DD,CAAiC,iBAAO,GA0DvC;AA1DY,kCAAW;AA4DxB,kBAAe,uCAAuB,CACpC,yBAAiB,EACjB,uBAAO,CAAC,sCAAsB,CAAC,CAAC,WAAW,CAAC,CAC7C,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/integer.control.d.ts b/dist/ts-build/renderers/controls/integer.control.d.ts new file mode 100644 index 000000000..de63cee88 --- /dev/null +++ b/dist/ts-build/renderers/controls/integer.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for integer controls. + * @type {RankedTester} + */ +export declare const integerControlTester: RankedTester; +export declare class IntegerControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/controls/integer.control.js b/dist/ts-build/renderers/controls/integer.control.js new file mode 100644 index 000000000..290455589 --- /dev/null +++ b/dist/ts-build/renderers/controls/integer.control.js @@ -0,0 +1,43 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var _ = require("lodash"); +var testers_1 = require("../../core/testers"); +var inferno_redux_1 = require("inferno-redux"); +var Control_1 = require("./Control"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for integer controls. + * @type {RankedTester} + */ +exports.integerControlTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.schemaTypeIs('integer'))); +var IntegerControl = /** @class */ (function (_super) { + __extends(IntegerControl, _super); + function IntegerControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + IntegerControl.prototype.render = function () { + var _this = this; + var _a = this.props, data = _a.data, classNames = _a.classNames, id = _a.id, visible = _a.visible, enabled = _a.enabled, errors = _a.errors, label = _a.label; + var isValid = errors.length === 0; + var divClassNames = 'validation' + (isValid ? '' : ' validation_error'); + return (JSX_1.JSX.createElement("div", { className: classNames.wrapper }, + JSX_1.JSX.createElement("label", { for: id, className: classNames.label, "data-error": errors }, label), + JSX_1.JSX.createElement("input", { type: 'number', step: '1', value: data, onInput: function (ev) { return _this.updateData(_.toInteger(ev.target.value)); }, className: classNames.input, id: id, hidden: !visible, disabled: !enabled }), + JSX_1.JSX.createElement("div", { className: divClassNames }, !isValid ? renderer_util_1.formatErrorMessage(errors) : ''))); + }; + return IntegerControl; +}(Control_1.Control)); +exports.IntegerControl = IntegerControl; +exports.default = renderer_util_1.registerStartupRenderer(exports.integerControlTester, inferno_redux_1.connect(renderer_util_1.mapStateToControlProps)(IntegerControl)); +//# sourceMappingURL=integer.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/integer.control.js.map b/dist/ts-build/renderers/controls/integer.control.js.map new file mode 100644 index 000000000..f2c6b20a1 --- /dev/null +++ b/dist/ts-build/renderers/controls/integer.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"integer.control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/integer.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,0BAA4B;AAC5B,8CAAyF;AACzF,+CAAwC;AACxC,qCAAkD;AAClD,kDAI0B;AAE1B;;;GAGG;AACU,QAAA,oBAAoB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,aAAG,CAC7D,kBAAQ,CAAC,SAAS,CAAC,EACnB,sBAAY,CAAC,SAAS,CAAC,CACxB,CAAC,CAAC;A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ers/controls/number.control.d.ts b/dist/ts-build/renderers/controls/number.control.d.ts new file mode 100644 index 000000000..93e9e3b8a --- /dev/null +++ b/dist/ts-build/renderers/controls/number.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for number controls. + * @type {RankedTester} + */ +export declare const numberControlTester: RankedTester; +export declare class NumberControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/controls/number.control.js b/dist/ts-build/renderers/controls/number.control.js new file mode 100644 index 000000000..800f4ea5f --- /dev/null +++ b/dist/ts-build/renderers/controls/number.control.js @@ -0,0 +1,43 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var _ = require("lodash"); +var testers_1 = require("../../core/testers"); +var inferno_redux_1 = require("inferno-redux"); +var Control_1 = require("./Control"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for number controls. + * @type {RankedTester} + */ +exports.numberControlTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.schemaTypeIs('number'))); +var NumberControl = /** @class */ (function (_super) { + __extends(NumberControl, _super); + function NumberControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + NumberControl.prototype.render = function () { + var _this = this; + var _a = this.props, data = _a.data, classNames = _a.classNames, id = _a.id, visible = _a.visible, enabled = _a.enabled, errors = _a.errors, label = _a.label; + var isValid = errors.length === 0; + var divClassNames = 'validation' + (isValid ? '' : ' validation_error'); + return (JSX_1.JSX.createElement("div", { className: classNames.wrapper }, + JSX_1.JSX.createElement("label", { for: id, className: classNames.label, "data-error": errors }, label), + JSX_1.JSX.createElement("input", { type: 'number', step: '0.1', value: data, onInput: function (ev) { return _this.updateData(_.toNumber(ev.target.value)); }, className: classNames.input, id: id, hidden: !visible, disabled: !enabled }), + JSX_1.JSX.createElement("div", { className: divClassNames }, !isValid ? renderer_util_1.formatErrorMessage(errors) : ''))); + }; + return NumberControl; +}(Control_1.Control)); +exports.NumberControl = NumberControl; +exports.default = renderer_util_1.registerStartupRenderer(exports.numberControlTester, inferno_redux_1.connect(renderer_util_1.mapStateToControlProps)(NumberControl)); +//# sourceMappingURL=number.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/number.control.js.map b/dist/ts-build/renderers/controls/number.control.js.map new file mode 100644 index 000000000..4b7b175a8 --- /dev/null +++ b/dist/ts-build/renderers/controls/number.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"number.control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/number.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,0BAA4B;AAC5B,8CAAyF;AACzF,+CAAwC;AACxC,qCAAkD;AAClD,kDAI0B;AAE1B;;;GAGG;AACU,QAAA,mBAAmB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,aAAG,CAC5D,kBAAQ,CAAC,SAAS,CAAC,EACnB,sBAAY,CAAC,QAAQ,CAAC,CACvB,CAAC,CAAC;AAEL;IAAmC,iCAA2B;IAA9D;;IA2BA,CAAC;IAzBC,8BAAM,GAAN;QAAA,iBAwBC;QAvBO,IAAA,eAAsE,EAApE,cAAI,EAAE,0BAAU,EAAE,UAAE,EAAE,oBAAO,EAAE,oBAAO,EAAE,kBAAM,EAAE,gBAAK,CAAgB;QAC7E,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;QACpC,IAAM,aAAa,GAAG,YAAY,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;QAE1E,MAAM,CAAC,CACL,iCAAK,SAAS,EAAE,UAAU,CAAC,OAAO;YAChC,mCAAO,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,gBAAc,MAAM,IAC5D,KAAK,CACA;YACR,mCAAO,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,KAAK,EACV,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,UAAA,EAAE,IAAI,OAAA,KAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAA5C,CAA4C,EAC3D,SAAS,EAAE,UAAU,CAAC,KAAK,EAC3B,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,CAAC,OAAO,EAChB,QAAQ,EAAE,CAAC,OAAO,GACvB;YACF,iCAAK,SAAS,EAAE,aAAa,IAC1B,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACvC,CACF,CACP,CAAC;IACJ,CAAC;IACH,oBAAC;AAAD,CAAC,AA3BD,CAAmC,iBAAO,GA2BzC;AA3BY,sCAAa;AA6B1B,kBAAe,uCAAuB,CACpC,2BAAmB,EACnB,uBAAO,CAAC,sCAAsB,CAAC,CAAC,aAAa,CAAC,CAC/C,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/text.control.d.ts b/dist/ts-build/renderers/controls/text.control.d.ts new file mode 100644 index 000000000..dc8559cc6 --- /dev/null +++ b/dist/ts-build/renderers/controls/text.control.d.ts @@ -0,0 +1,12 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Default tester for text-based/string controls. + * @type {RankedTester} + */ +export declare const textControlTester: RankedTester; +export declare class TextControl extends Control { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/controls/text.control.js b/dist/ts-build/renderers/controls/text.control.js new file mode 100644 index 000000000..8a510f20a --- /dev/null +++ b/dist/ts-build/renderers/controls/text.control.js @@ -0,0 +1,42 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var testers_1 = require("../../core/testers"); +var inferno_redux_1 = require("inferno-redux"); +var Control_1 = require("./Control"); +var renderer_util_1 = require("../renderer.util"); +/** + * Default tester for text-based/string controls. + * @type {RankedTester} + */ +exports.textControlTester = testers_1.rankWith(1, testers_1.isControl); +var TextControl = /** @class */ (function (_super) { + __extends(TextControl, _super); + function TextControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + TextControl.prototype.render = function () { + var _this = this; + var _a = this.props, data = _a.data, classNames = _a.classNames, id = _a.id, visible = _a.visible, enabled = _a.enabled, errors = _a.errors, label = _a.label; + var isValid = errors.length === 0; + var divClassNames = 'validation' + (isValid ? '' : ' validation_error'); + return (JSX_1.JSX.createElement("div", { className: classNames.wrapper }, + JSX_1.JSX.createElement("label", { for: id, className: classNames.label }, label), + JSX_1.JSX.createElement("input", { value: data, onInput: function (ev) { return _this.updateData(ev.target.value); }, className: classNames.input, id: id, hidden: !visible, disabled: !enabled }), + JSX_1.JSX.createElement("div", { className: divClassNames }, !isValid ? renderer_util_1.formatErrorMessage(errors) : ''))); + }; + return TextControl; +}(Control_1.Control)); +exports.TextControl = TextControl; +exports.default = renderer_util_1.registerStartupRenderer(exports.textControlTester, inferno_redux_1.connect(renderer_util_1.mapStateToControlProps)(TextControl)); +//# sourceMappingURL=text.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/text.control.js.map b/dist/ts-build/renderers/controls/text.control.js.map new file mode 100644 index 000000000..9cdce8eda --- /dev/null +++ b/dist/ts-build/renderers/controls/text.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"text.control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/text.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,8CAAuE;AACvE,+CAAwC;AACxC,qCAAkD;AAClD,kDAI0B;AAE1B;;;GAGG;AACU,QAAA,iBAAiB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,mBAAS,CAAC,CAAC;AAEtE;IAAiC,+BAA2B;IAA5D;;IAyBA,CAAC;IAvBC,4BAAM,GAAN;QAAA,iBAsBC;QArBO,IAAA,eAAsE,EAApE,cAAI,EAAE,0BAAU,EAAE,UAAE,EAAE,oBAAO,EAAE,oBAAO,EAAE,kBAAM,EAAE,gBAAK,CAAgB;QAC7E,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;QACpC,IAAM,aAAa,GAAG,YAAY,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;QAE1E,MAAM,CAAC,CACL,iCAAK,SAAS,EAAE,UAAU,CAAC,OAAO;YAChC,mCAAO,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,KAAK,IACxC,KAAK,CACA;YACR,mCAAO,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,UAAA,EAAE,IAAI,OAAA,KAAI,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAhC,CAAgC,EAC/C,SAAS,EAAE,UAAU,CAAC,KAAK,EAC3B,EAAE,EAAE,EAAE,EACN,MAAM,EAAE,CAAC,OAAO,EAChB,QAAQ,EAAE,CAAC,OAAO,GACvB;YACF,iCAAK,SAAS,EAAE,aAAa,IAC1B,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACvC,CACF,CACP,CAAC;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AAzBD,CAAiC,iBAAO,GAyBvC;AAzBY,kCAAW;AA2BxB,kBAAe,uCAAuB,CACpC,yBAAiB,EACjB,uBAAO,CAAC,sCAAsB,CAAC,CAAC,WAAW,CAAC,CAC7C,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/textarea.control.d.ts b/dist/ts-build/renderers/controls/textarea.control.d.ts new file mode 100644 index 000000000..82b6ebb81 --- /dev/null +++ b/dist/ts-build/renderers/controls/textarea.control.d.ts @@ -0,0 +1,16 @@ +import { RankedTester } from '../../core/testers'; +import { Control, ControlProps } from './Control'; +/** + * Tester for a multi-line string control. + * @type {RankedTester} + */ +export declare const textAreaControlTester: RankedTester; +export declare class TextAreaControl extends Control { + render(): any; + /** + * @inheritDoc + */ + protected toInput(value: any): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/controls/textarea.control.js b/dist/ts-build/renderers/controls/textarea.control.js new file mode 100644 index 000000000..eec44d4f4 --- /dev/null +++ b/dist/ts-build/renderers/controls/textarea.control.js @@ -0,0 +1,48 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var testers_1 = require("../../core/testers"); +var inferno_redux_1 = require("inferno-redux"); +var Control_1 = require("./Control"); +var renderer_util_1 = require("../renderer.util"); +/** + * Tester for a multi-line string control. + * @type {RankedTester} + */ +exports.textAreaControlTester = testers_1.rankWith(2, testers_1.and(testers_1.uiTypeIs('Control'), testers_1.optionIs('multi', true))); +var TextAreaControl = /** @class */ (function (_super) { + __extends(TextAreaControl, _super); + function TextAreaControl() { + return _super !== null && _super.apply(this, arguments) || this; + } + TextAreaControl.prototype.render = function () { + var _this = this; + var _a = this.props, data = _a.data, classNames = _a.classNames, id = _a.id, visible = _a.visible, enabled = _a.enabled, errors = _a.errors, label = _a.label; + var isValid = errors.length === 0; + var divClassNames = 'validation' + (isValid ? '' : ' validation_error'); + return (JSX_1.JSX.createElement("div", { className: classNames.wrapper }, + JSX_1.JSX.createElement("label", { for: id, className: classNames.label }, label), + JSX_1.JSX.createElement("textarea", { value: data, onInput: function (ev) { return _this.updateData(ev.target.value); }, className: classNames.input, id: id, hidden: !visible, disabled: !enabled }), + JSX_1.JSX.createElement("div", { className: divClassNames }, !isValid ? renderer_util_1.formatErrorMessage(errors) : ''))); + }; + /** + * @inheritDoc + */ + TextAreaControl.prototype.toInput = function (value) { + return (value === undefined || value === null) ? '' : value; + }; + return TextAreaControl; +}(Control_1.Control)); +exports.TextAreaControl = TextAreaControl; +exports.default = renderer_util_1.registerStartupRenderer(exports.textAreaControlTester, inferno_redux_1.connect(renderer_util_1.mapStateToControlProps)(TextAreaControl)); +//# sourceMappingURL=textarea.control.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/controls/textarea.control.js.map b/dist/ts-build/renderers/controls/textarea.control.js.map new file mode 100644 index 000000000..41e14b25c --- /dev/null +++ b/dist/ts-build/renderers/controls/textarea.control.js.map @@ -0,0 +1 @@ +{"version":3,"file":"textarea.control.js","sourceRoot":"","sources":["../../../../src/renderers/controls/textarea.control.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,8CAAqF;AACrF,+CAAwC;AACxC,qCAAkD;AAClD,kDAI0B;AAE1B;;;GAGG;AACU,QAAA,qBAAqB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,aAAG,CAC9D,kBAAQ,CAAC,SAAS,CAAC,EACnB,kBAAQ,CAAC,OAAO,EA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B,kBAAe,uCAAuB,CACpC,6BAAqB,EACrB,uBAAO,CAAC,sCAAsB,CAAC,CAAC,eAAe,CAAC,CACjD,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/dispatch-renderer.d.ts b/dist/ts-build/renderers/dispatch-renderer.d.ts new file mode 100644 index 000000000..17a144231 --- /dev/null +++ b/dist/ts-build/renderers/dispatch-renderer.d.ts @@ -0,0 +1,26 @@ +import { UISchemaElement } from '../models/uischema'; +import { JsonSchema } from '../models/jsonSchema'; +import { RankedTester } from '../core/testers'; +export interface DispatchRendererProps { + /** + * The UI schema to be rendered. + */ + uischema: UISchemaElement; + /** + * The JSON schema that describes the data. + */ + schema: JsonSchema; + renderers: { + tester: RankedTester; + renderer: any; + }[]; + /** + * Optional instance path. Necessary when the actual data + * path can not be inferred via the UI schema element as + * it is the case with nested controls. + */ + path?: string; +} +export declare const DispatchRenderer: (props: DispatchRendererProps) => any; +export declare const JsonFormsRenderer: (props: DispatchRendererProps) => any; +export default JsonFormsRenderer; diff --git a/dist/ts-build/renderers/dispatch-renderer.js b/dist/ts-build/renderers/dispatch-renderer.js new file mode 100644 index 000000000..d43c94565 --- /dev/null +++ b/dist/ts-build/renderers/dispatch-renderer.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("./JSX"); +var _ = require("lodash"); +var unknown_renderer_1 = require("./unknown.renderer"); +var inferno_redux_1 = require("inferno-redux"); +exports.DispatchRenderer = function (props) { + var uischema = props.uischema, path = props.path, schema = props.schema, renderers = props.renderers; + var renderer = _.maxBy(renderers, function (r) { return r.tester(uischema, schema); }); + if (renderer === undefined || renderer.tester(uischema, schema) === -1) { + return JSX_1.JSX.createElement(unknown_renderer_1.UnknownRenderer, null); + } + else { + var Render = renderer.renderer; + return (JSX_1.JSX.createElement(Render, { uischema: uischema, schema: schema, path: path, renderers: renderers })); + } +}; +var mapStateToProps = function (state) { return ({ + renderers: state.renderers || [] +}); }; +exports.JsonFormsRenderer = inferno_redux_1.connect(mapStateToProps, null)(exports.DispatchRenderer); +exports.default = exports.JsonFormsRenderer; +//# sourceMappingURL=dispatch-renderer.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/dispatch-renderer.js.map b/dist/ts-build/renderers/dispatch-renderer.js.map new file mode 100644 index 000000000..6715400b6 --- /dev/null +++ b/dist/ts-build/renderers/dispatch-renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dispatch-renderer.js","sourceRoot":"","sources":["../../../src/renderers/dispatch-renderer.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,0BAA4B;AAC5B,uDAAqD;AAIrD,+CAAwC;AAwB3B,QAAA,gBAAgB,GAAG,UAAC,KAA4B;IACnD,IAAA,yBAAQ,EAAE,iBAAI,EAAE,qBAAM,EAAE,2BAAS,CAAW;IACpD,IAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,EAA1B,CAA0B,CAAC,CAAC;IAErE,EAAE,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvE,MAAM,CAAC,wBAAC,kCAAe,OAAE,CAAC;IAC5B,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,IAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAEjC,MAAM,CAAC,CACL,wBAAC,MAAM,IACL,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,IAAM,eAAe,GAAG,UAAA,KAAK,IAAI,OAAA,CAAC;IAChC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,EAAE;CACjC,CAAC,EAF+B,CAE/B,CAAC;AAEU,QAAA,iBAAiB,GAAG,uBAAO,CACtC,eAAe,EACf,IAAI,CACL,CAAC,wBAAgB,CAAC,CAAC;AAEpB,kBAAe,yBAAiB,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/index.d.ts b/dist/ts-build/renderers/index.d.ts new file mode 100644 index 000000000..9ae0e921f --- /dev/null +++ b/dist/ts-build/renderers/index.d.ts @@ -0,0 +1,19 @@ +export * from './label.util'; +export * from './renderer.util'; +export * from './controls/Control'; +export * from './controls/text.control'; +export * from './controls/boolean.control'; +export * from './controls/integer.control'; +export * from './controls/number.control'; +export * from './controls/date.control'; +export * from './controls/enum.control'; +export * from './controls/textarea.control'; +export * from './layouts/vertical.layout'; +export * from './layouts/horizontal.layout'; +export * from './layouts/group.layout'; +export * from './additional/array-renderer'; +export * from './additional/tree-renderer'; +export * from './additional/categorization-renderer'; +export * from './additional/table-array.control'; +export * from './additional/label.renderer'; +export * from './JSX'; diff --git a/dist/ts-build/renderers/index.js b/dist/ts-build/renderers/index.js new file mode 100644 index 000000000..446c4c08b --- /dev/null +++ b/dist/ts-build/renderers/index.js @@ -0,0 +1,25 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./label.util")); +__export(require("./renderer.util")); +__export(require("./controls/Control")); +__export(require("./controls/text.control")); +__export(require("./controls/boolean.control")); +__export(require("./controls/integer.control")); +__export(require("./controls/number.control")); +__export(require("./controls/date.control")); +__export(require("./controls/enum.control")); +__export(require("./controls/textarea.control")); +__export(require("./layouts/vertical.layout")); +__export(require("./layouts/horizontal.layout")); +__export(require("./layouts/group.layout")); +__export(require("./additional/array-renderer")); +__export(require("./additional/tree-renderer")); +__export(require("./additional/categorization-renderer")); +__export(require("./additional/table-array.control")); +__export(require("./additional/label.renderer")); +__export(require("./JSX")); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/index.js.map b/dist/ts-build/renderers/index.js.map new file mode 100644 index 000000000..27294401f --- /dev/null +++ b/dist/ts-build/renderers/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/renderers/index.ts"],"names":[],"mappings":";;;;;AAAA,kCAA6B;AAC7B,qCAAgC;AAEhC,wCAAmC;AACnC,6CAAwC;AACxC,gDAA2C;AAC3C,gDAA2C;AAC3C,+CAA0C;AAC1C,6CAAwC;AACxC,6CAAwC;AACxC,iDAA4C;AAC5C,+CAA0C;AAC1C,iDAA4C;AAC5C,4CAAuC;AACvC,iDAA4C;AAC5C,gDAA2C;AAC3C,0DAAqD;AACrD,sDAAiD;AACjD,iDAA4C;AAE5C,2BAAsB"} \ No newline at end of file diff --git a/dist/ts-build/renderers/label.util.d.ts b/dist/ts-build/renderers/label.util.d.ts new file mode 100644 index 000000000..952cdf9f4 --- /dev/null +++ b/dist/ts-build/renderers/label.util.d.ts @@ -0,0 +1,9 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { ControlElement, ILabelObject } from '../models/uischema'; +/** + * Return a label object based on the given JSON schema and control element. + * @param {JsonSchema} schema the JSON schema that the given control element is referring to + * @param {ControlElement} controlElement the UI schema to obtain a label object for + * @returns {ILabelObject} + */ +export declare const getElementLabelObject: (schema: JsonSchema, controlElement: ControlElement) => ILabelObject; diff --git a/dist/ts-build/renderers/label.util.js b/dist/ts-build/renderers/label.util.js new file mode 100644 index 000000000..3fa97ae7a --- /dev/null +++ b/dist/ts-build/renderers/label.util.js @@ -0,0 +1,67 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _ = require("lodash"); +var path_util_1 = require("../path.util"); +var LabelObject = /** @class */ (function () { + function LabelObject(text, show) { + this.text = text; + this.show = show; + } + return LabelObject; +}()); +var deriveLabel = function (controlElement) { + if (controlElement.scope !== undefined) { + var ref = controlElement.scope.$ref; + var label = ref.substr(ref.lastIndexOf('/') + 1); + return _.startCase(label); + } + return ''; +}; +var getLabelObject = function (withLabel) { + var labelProperty = withLabel.label; + var derivedLabel = deriveLabel(withLabel); + if (typeof labelProperty === 'boolean') { + if (labelProperty) { + return new LabelObject(derivedLabel, labelProperty); + } + else { + return new LabelObject(derivedLabel, labelProperty); + } + } + else if (typeof labelProperty === 'string') { + return new LabelObject(labelProperty, true); + } + else if (typeof labelProperty === 'object') { + var show = labelProperty.hasOwnProperty('show') ? labelProperty.show : true; + var label = labelProperty.hasOwnProperty('text') ? + labelProperty.text : derivedLabel; + return new LabelObject(label, show); + } + else { + return new LabelObject(derivedLabel, true); + } +}; +var isRequired = function (schema, schemaPath) { + var pathSegments = schemaPath.split('/'); + var lastSegment = pathSegments[pathSegments.length - 1]; + var nextHigherSchemaSegments = pathSegments.slice(0, pathSegments.length - 2); + var nextHigherSchemaPath = nextHigherSchemaSegments.join('/'); + var nextHigherSchema = path_util_1.resolveSchema(schema, nextHigherSchemaPath); + return nextHigherSchema !== undefined + && nextHigherSchema.required !== undefined + && nextHigherSchema.required.indexOf(lastSegment) !== -1; +}; +/** + * Return a label object based on the given JSON schema and control element. + * @param {JsonSchema} schema the JSON schema that the given control element is referring to + * @param {ControlElement} controlElement the UI schema to obtain a label object for + * @returns {ILabelObject} + */ +exports.getElementLabelObject = function (schema, controlElement) { + var labelObject = getLabelObject(controlElement); + if (controlElement.scope !== undefined && isRequired(schema, controlElement.scope.$ref)) { + labelObject.text += '*'; + } + return labelObject; +}; +//# sourceMappingURL=label.util.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/label.util.js.map b/dist/ts-build/renderers/label.util.js.map new file mode 100644 index 000000000..843f646fe --- /dev/null +++ b/dist/ts-build/renderers/label.util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"label.util.js","sourceRoot":"","sources":["../../../src/renderers/label.util.ts"],"names":[],"mappings":";;AAAA,0BAA4B;AAI5B,0CAA6C;AAE7C;IAII,qBAAY,IAAY,EAAE,IAAa;QACnC,IA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S,IAAI,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACxF,WAAW,CAAC,IAAI,IAAI,GAAG,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,WAAW,CAAC;AACrB,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/layouts/group.layout.d.ts b/dist/ts-build/renderers/layouts/group.layout.d.ts new file mode 100644 index 000000000..d8d81a3d9 --- /dev/null +++ b/dist/ts-build/renderers/layouts/group.layout.d.ts @@ -0,0 +1,13 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a group layout. + * + * @type {RankedTester} + */ +export declare const groupTester: RankedTester; +export declare class GroupLayoutRenderer extends Renderer { + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/layouts/group.layout.js b/dist/ts-build/renderers/layouts/group.layout.js new file mode 100644 index 000000000..6ede4fca8 --- /dev/null +++ b/dist/ts-build/renderers/layouts/group.layout.js @@ -0,0 +1,43 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var _ = require("lodash"); +var core_1 = require("../../core"); +var renderer_1 = require("../../core/renderer"); +var testers_1 = require("../../core/testers"); +var renderer_util_1 = require("../renderer.util"); +var inferno_redux_1 = require("inferno-redux"); +/** + * Default tester for a group layout. + * + * @type {RankedTester} + */ +exports.groupTester = testers_1.rankWith(1, testers_1.uiTypeIs('Group')); +var GroupLayoutRenderer = /** @class */ (function (_super) { + __extends(GroupLayoutRenderer, _super); + function GroupLayoutRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + GroupLayoutRenderer.prototype.render = function () { + var _a = this.props, schema = _a.schema, uischema = _a.uischema, path = _a.path, visible = _a.visible; + var group = uischema; + return (JSX_1.JSX.createElement(renderer_util_1.JsonFormsLayout, { styleName: 'group-layout', visible: visible }, + !_.isEmpty(group.label) ? + JSX_1.JSX.createElement("legend", { className: core_1.JsonForms.stylingRegistry.getAsClassName('group.label') }, group.label) : '', + renderer_util_1.renderChildren(group.elements, schema, 'group-layout-item', path))); + }; + return GroupLayoutRenderer; +}(renderer_1.Renderer)); +exports.GroupLayoutRenderer = GroupLayoutRenderer; +exports.default = renderer_util_1.registerStartupRenderer(exports.groupTester, inferno_redux_1.connect(renderer_util_1.mapStateToLayoutProps)(GroupLayoutRenderer)); +//# sourceMappingURL=group.layout.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/layouts/group.layout.js.map b/dist/ts-build/renderers/layouts/group.layout.js.map new file mode 100644 index 000000000..bd859733d --- /dev/null +++ b/dist/ts-build/renderers/layouts/group.layout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"group.layout.js","sourceRoot":"","sources":["../../../../src/renderers/layouts/group.layout.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,0BAA4B;AAC5B,mCAAuC;AACvC,gDAA8D;AAC9D,8CAAsE;AAEtE,kDAAiH;AACjH,+CAAwC;AAExC;;;;GAIG;AACU,QAAA,WAAW,GAAiB,kBAAQ,CAAC,CAAC,EAAE,kBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAExE;IAAyC,uCAA6B;IAAtE;;IA4BA,CAAC;IA1BC,oCAAM,GAAN;QACQ,IAAA,eAAgD,EAA9C,kBAAM,EAAE,sBAAQ,EAAE,cAAI,EAAE,oBAAO,CAAgB;QACvD,IAAM,KAAK,GAAG,QAAuB,CAAC;QAEtC,MAAM,CAAC,CACL,wBAAC,+BAAe,IACd,SAAS,EAAC,cAAc,EACxB,OAAO,EAAE,OAAO;YAGd,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvB,oCAAQ,SAAS,EAAE,gBAAS,CAAC,eAAe,CAAC,cAAc,CAAC,aAAa,CAAC,IACvE,KAAK,CAAC,KAAK,CACL,CAAC,CAAC,CAAC,EAAE;YAGhB,8BAAc,CACZ,KAAK,CAAC,QAAQ,EACd,MAAM,EACN,mBAAmB,EACnB,IAAI,CACL,CAEa,CACnB,CAAC;IACJ,CAAC;IACH,0BAAC;AAAD,CAAC,AA5BD,CAAyC,mBAAQ,GA4BhD;AA5BY,kDAAmB;AA6BhC,kBAAe,uCAAuB,CACpC,mBAAW,EACX,uBAAO,CAAC,qCAAqB,CAAC,CAAC,mBAAmB,CAAC,CACpD,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/layouts/horizontal.layout.d.ts b/dist/ts-build/renderers/layouts/horizontal.layout.d.ts new file mode 100644 index 000000000..458ac9b1b --- /dev/null +++ b/dist/ts-build/renderers/layouts/horizontal.layout.d.ts @@ -0,0 +1,15 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a horizontal layout. + * @type {RankedTester} + */ +export declare const horizontalLayoutTester: RankedTester; +export declare class HorizontalLayoutRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/layouts/horizontal.layout.js b/dist/ts-build/renderers/layouts/horizontal.layout.js new file mode 100644 index 000000000..7ab37afc8 --- /dev/null +++ b/dist/ts-build/renderers/layouts/horizontal.layout.js @@ -0,0 +1,40 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var renderer_1 = require("../../core/renderer"); +var testers_1 = require("../../core/testers"); +var renderer_util_1 = require("../renderer.util"); +var inferno_redux_1 = require("inferno-redux"); +/** + * Default tester for a horizontal layout. + * @type {RankedTester} + */ +exports.horizontalLayoutTester = testers_1.rankWith(1, testers_1.uiTypeIs('HorizontalLayout')); +var HorizontalLayoutRenderer = /** @class */ (function (_super) { + __extends(HorizontalLayoutRenderer, _super); + function HorizontalLayoutRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @inheritDoc + */ + HorizontalLayoutRenderer.prototype.render = function () { + var _a = this.props, schema = _a.schema, uischema = _a.uischema, path = _a.path, visible = _a.visible; + var horizontalLayout = uischema; + return (JSX_1.JSX.createElement(renderer_util_1.JsonFormsLayout, { styleName: 'horizontal-layout', visible: visible }, renderer_util_1.renderChildren(horizontalLayout.elements, schema, 'horizontal-layout-item', path))); + }; + return HorizontalLayoutRenderer; +}(renderer_1.Renderer)); +exports.HorizontalLayoutRenderer = HorizontalLayoutRenderer; +exports.default = renderer_util_1.registerStartupRenderer(exports.horizontalLayoutTester, inferno_redux_1.connect(renderer_util_1.mapStateToLayoutProps)(HorizontalLayoutRenderer)); +//# sourceMappingURL=horizontal.layout.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/layouts/horizontal.layout.js.map b/dist/ts-build/renderers/layouts/horizontal.layout.js.map new file mode 100644 index 000000000..06bf54f1b --- /dev/null +++ b/dist/ts-build/renderers/layouts/horizontal.layout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"horizontal.layout.js","sourceRoot":"","sources":["../../../../src/renderers/layouts/horizontal.layout.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,gDAA8D;AAC9D,8CAAsE;AAEtE,kDAAiH;AAEjH,+CAAwC;AACxC;;;GAGG;AACU,QAAA,sBAAsB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,kBAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAE9F;IAA8C,4CAA6B;IAA3E;;IAyBA,CAAC;IAvBC;;OAEG;IACH,yCAAM,GAAN;QACQ,IAAA,eAAgD,EAA9C,kBAAM,EAAE,sBAAQ,EAAE,cAAI,EAAE,oBAAO,CAAgB;QACvD,IAAM,gBAAgB,GAAG,QAA4B,CAAC;QAEtD,MAAM,CAAC,CACL,wBAAC,+BAAe,IACd,SAAS,EAAC,mBAAmB,EAC7B,OAAO,EAAE,OAAO,IAGd,8BAAc,CACZ,gBAAgB,CAAC,QAAQ,EACzB,MAAM,EACN,wBAAwB,EACxB,IAAI,CACL,CAEa,CACnB,CAAC;IACJ,CAAC;IACH,+BAAC;AAAD,CAAC,AAzBD,CAA8C,mBAAQ,GAyBrD;AAzBY,4DAAwB;AA2BrC,kBAAe,uCAAuB,CACpC,8BAAsB,EACtB,uBAAO,CAAC,qCAAqB,CAAC,CAAC,wBAAwB,CAAC,CACzD,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/layouts/vertical.layout.d.ts b/dist/ts-build/renderers/layouts/vertical.layout.d.ts new file mode 100644 index 000000000..0b7c4d070 --- /dev/null +++ b/dist/ts-build/renderers/layouts/vertical.layout.d.ts @@ -0,0 +1,15 @@ +import { Renderer, RendererProps } from '../../core/renderer'; +import { RankedTester } from '../../core/testers'; +/** + * Default tester for a vertical layout. + * @type {RankedTester} + */ +export declare const verticalLayoutTester: RankedTester; +export declare class VerticalLayoutRenderer extends Renderer { + /** + * @inheritDoc + */ + render(): any; +} +declare const _default: any; +export default _default; diff --git a/dist/ts-build/renderers/layouts/vertical.layout.js b/dist/ts-build/renderers/layouts/vertical.layout.js new file mode 100644 index 000000000..8092471e8 --- /dev/null +++ b/dist/ts-build/renderers/layouts/vertical.layout.js @@ -0,0 +1,40 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("../JSX"); +var renderer_1 = require("../../core/renderer"); +var testers_1 = require("../../core/testers"); +var renderer_util_1 = require("../renderer.util"); +var inferno_redux_1 = require("inferno-redux"); +/** + * Default tester for a vertical layout. + * @type {RankedTester} + */ +exports.verticalLayoutTester = testers_1.rankWith(1, testers_1.uiTypeIs('VerticalLayout')); +var VerticalLayoutRenderer = /** @class */ (function (_super) { + __extends(VerticalLayoutRenderer, _super); + function VerticalLayoutRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @inheritDoc + */ + VerticalLayoutRenderer.prototype.render = function () { + var _a = this.props, schema = _a.schema, uischema = _a.uischema, path = _a.path, visible = _a.visible; + var verticalLayout = uischema; + return (JSX_1.JSX.createElement(renderer_util_1.JsonFormsLayout, { styleName: 'vertical-layout', visible: visible }, renderer_util_1.renderChildren(verticalLayout.elements, schema, 'vertical-layout-item', path))); + }; + return VerticalLayoutRenderer; +}(renderer_1.Renderer)); +exports.VerticalLayoutRenderer = VerticalLayoutRenderer; +exports.default = renderer_util_1.registerStartupRenderer(exports.verticalLayoutTester, inferno_redux_1.connect(renderer_util_1.mapStateToLayoutProps)(VerticalLayoutRenderer)); +//# sourceMappingURL=vertical.layout.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/layouts/vertical.layout.js.map b/dist/ts-build/renderers/layouts/vertical.layout.js.map new file mode 100644 index 000000000..aac5e9fc1 --- /dev/null +++ b/dist/ts-build/renderers/layouts/vertical.layout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vertical.layout.js","sourceRoot":"","sources":["../../../../src/renderers/layouts/vertical.layout.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8BAA6B;AAC7B,gDAA8D;AAC9D,8CAAsE;AAEtE,kDAAiH;AAEjH,+CAAwC;AAExC;;;GAGG;AACU,QAAA,oBAAoB,GAAiB,kBAAQ,CAAC,CAAC,EAAE,kBAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAE1F;IAA4C,0CAA6B;IAAzE;;IAyBA,CAAC;IAvBC;;OAEG;IACH,uCAAM,GAAN;QACQ,IAAA,eAAgD,EAA9C,kBAAM,EAAE,sBAAQ,EAAE,cAAI,EAAE,oBAAO,CAAgB;QACvD,IAAM,cAAc,GAAG,QAA0B,CAAC;QAElD,MAAM,CAAC,CACL,wBAAC,+BAAe,IACd,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,OAAO,IAGb,8BAAc,CACZ,cAAc,CAAC,QAAQ,EACvB,MAAM,EACN,sBAAsB,EACtB,IAAI,CACL,CAEa,CACpB,CAAC;IACJ,CAAC;IACH,6BAAC;AAAD,CAAC,AAzBD,CAA4C,mBAAQ,GAyBnD;AAzBY,wDAAsB;AA2BnC,kBAAe,uCAAuB,CACpC,4BAAoB,EACpB,uBAAO,CAAC,qCAAqB,CAAC,CAAC,sBAAsB,CAAC,CACvD,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/renderer.util.d.ts b/dist/ts-build/renderers/renderer.util.d.ts new file mode 100644 index 000000000..141a89eb8 --- /dev/null +++ b/dist/ts-build/renderers/renderer.util.d.ts @@ -0,0 +1,52 @@ +import { JsonSchema } from '../models/jsonSchema'; +import { Renderer, RendererProps } from '../core/renderer'; +import { RankedTester } from '../core/testers'; +import { UISchemaElement } from '../models/uischema'; +/** + * A renderer config that is used during renderer registration. + */ +export interface JsonFormsRendererConfig { + /** + * The tester that that determines how applicable + * the renderer is. + */ + tester: RankedTester; +} +export interface JsonFormsRendererConstructable { + new (props: RendererProps): Renderer; +} +/** + * Renderer annotation that defines the renderer as a custom elemeent + * and registers it with the renderer service. + * + * @param {JsonFormsRendererConfig} config the renderer config to be registered + * @constructor + */ +export declare const JsonFormsRenderer: (config: JsonFormsRendererConfig) => (cls: JsonFormsRendererConstructable) => void; +export declare const mapStateToLayoutProps: (state: any, ownProps: any) => { + renderers: any; + visible: any; + path: any; +}; +export declare const renderChildren: (elements: UISchemaElement[], schema: JsonSchema, childType: string, path: string) => any[]; +export declare const JsonFormsLayout: ({styleName, children, visible}: { + styleName: any; + children: any; + visible: any; +}) => any; +export declare const formatErrorMessage: (errors: any) => any; +export declare const registerStartupRenderer: (tester: RankedTester, renderer: any) => any; +export declare const mapStateToControlProps: (state: any, ownProps: any) => { + data: any; + errors: any[]; + classNames: { + wrapper: string; + input: string; + label: string; + }; + label: string; + visible: any; + enabled: any; + id: string; + path: string; +}; diff --git a/dist/ts-build/renderers/renderer.util.js b/dist/ts-build/renderers/renderer.util.js new file mode 100644 index 000000000..8205c6597 --- /dev/null +++ b/dist/ts-build/renderers/renderer.util.js @@ -0,0 +1,98 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("./JSX"); +var core_1 = require("../core"); +var renderer_1 = require("../core/renderer"); +var _ = require("lodash"); +var dispatch_renderer_1 = require("./dispatch-renderer"); +var path_util_1 = require("../path.util"); +var label_util_1 = require("./label.util"); +var validation_1 = require("../reducers/validation"); +var index_1 = require("../reducers/index"); +/** + * Renderer annotation that defines the renderer as a custom elemeent + * and registers it with the renderer service. + * + * @param {JsonFormsRendererConfig} config the renderer config to be registered + * @constructor + */ +// Used as annotation +// tslint:disable:variable-name +exports.JsonFormsRenderer = function (config) { + return function (cls) { + exports.registerStartupRenderer(config.tester, cls); + }; +}; +// tslint:enable:variable-name +exports.mapStateToLayoutProps = function (state, ownProps) { + var visible = _.has(ownProps, 'visible') ? ownProps.visible : renderer_1.isVisible(ownProps, state); + return { + renderers: state.renderers, + visible: visible, + path: ownProps.path + }; +}; +exports.renderChildren = function (elements, schema, childType, path) { + if (_.isEmpty(elements)) { + return []; + } + return elements.map(function (child) { + var classes = core_1.JsonForms.stylingRegistry.get(childType, elements.length) + .concat([childType]) + .join(' '); + return (JSX_1.JSX.createElement("div", { className: classes }, + JSX_1.JSX.createElement(dispatch_renderer_1.default, { uischema: child, schema: schema, path: path }))); + }); +}; +// tslint:disable:variable-name +exports.JsonFormsLayout = function (_a) { + var styleName = _a.styleName, children = _a.children, visible = _a.visible; + // tslint:enable:variable-name + var classNames = core_1.JsonForms.stylingRegistry.getAsClassName(styleName); + return (JSX_1.JSX.createElement("div", { className: classNames, hidden: visible === undefined || visible === null ? false : !visible }, children)); +}; +exports.formatErrorMessage = function (errors) { + if (errors === undefined || errors === null) { + return ''; + } + return errors.join('\n'); +}; +exports.registerStartupRenderer = function (tester, renderer) { + core_1.JsonForms.renderers.push({ + tester: tester, + renderer: renderer + }); + return renderer; +}; +exports.mapStateToControlProps = function (state, ownProps) { + var path = path_util_1.composeWithUi(ownProps.uischema, ownProps.path); + var visible = _.has(ownProps, 'visible') ? ownProps.visible : renderer_1.isVisible(ownProps, state); + var enabled = _.has(ownProps, 'enabled') ? ownProps.enabled : renderer_1.isEnabled(ownProps, state); + var labelObject = label_util_1.getElementLabelObject(ownProps.schema, ownProps.uischema); + var label = labelObject.show ? labelObject.text : ''; + var errors = validation_1.errorAt(path)(index_1.getValidation(state)).map(function (error) { return error.message; }); + var isValid = _.isEmpty(errors); + var controlElement = ownProps.uischema; + var id = _.has(controlElement.scope, '$ref') ? controlElement.scope.$ref : ''; + var styles = core_1.JsonForms.stylingRegistry.get('control'); + var classNames = !_.isEmpty(controlElement.scope) ? + styles.concat(["" + renderer_1.convertToClassName(controlElement.scope.$ref)]) : ['']; + var inputClassName = ['validate'] + .concat(isValid ? 'valid' : 'invalid'); + var labelClass = core_1.JsonForms.stylingRegistry.getAsClassName('control.label'); + return { + data: path_util_1.resolveData(index_1.getData(state), path), + errors: errors, + classNames: { + wrapper: classNames.join(' '), + input: inputClassName.join(' '), + label: labelClass + }, + label: label, + visible: visible, + enabled: enabled, + id: id, + path: path, + }; +}; +//# sourceMappingURL=renderer.util.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/renderer.util.js.map b/dist/ts-build/renderers/renderer.util.js.map new file mode 100644 index 000000000..e84867985 --- /dev/null +++ b/dist/ts-build/renderers/renderer.util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"renderer.util.js","sourceRoot":"","sources":["../../../src/renderers/renderer.util.tsx"],"names":[],"mappings":";;AACA,6BAA4B;AAC5B,gCAAoC;AACpC,6CAM0B;AAG1B,0BAA4B;AAC5B,yDAAmD;AACnD,0CAA0D;AAC1D,2CAAqD;AACrD,qDAAiD;AACjD,2CAA2D;AAkB3D;;;;;;GAMG;AACH,qBAAqB;AACrB,+BAA+B;AAClB,QAAA,iBAAiB,GAC1B,UAAC,MAA+B;IAC9B,OAAA,UAAC,GAAmC;QAClC,+BAAuB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;AAFD,CAEC,CAAC;AACR,8BAA8B;AAEjB,QAAA,qBAAqB,GAAG,UAAC,KAAK,EAAE,QAAQ;IACnD,IAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAE,oBAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE5F,MAAM,CAAC;QACL,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,OAAO,SAAA;QACP,IAAI,EAAE,QAAQ,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,cAAc,GAAG,UAC5B,QAA2B,EAC3B,MAAkB,EAClB,SAAiB,EACjB,IAAY;IAGZ,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,CAAC,EAAE,CAAC;IACZ,CAA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CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxD,IAAM,UAAU,GAAa,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CACX,CAAC,KAAG,6BAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAG,CAAC,CACrD,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACX,IAAM,cAAc,GAClB,CAAC,UAAU,CAAC;SACT,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAM,UAAU,GAAG,gBAAS,CAAC,eAAe,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAE7E,MAAM,CAAC;QACL,IAAI,EAAE,uBAAW,CAAC,eAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;QACvC,MAAM,QAAA;QACN,UAAU,EAAE;YACV,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;YAC7B,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC;YAC/B,KAAK,EAAE,UAAU;SAClB;QACD,KAAK,OAAA;QACL,OAAO,SAAA;QACP,OAAO,SAAA;QACP,EAAE,IAAA;QACF,IAAI,MAAA;KACL,CAAC;AACJ,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/ts-build/renderers/unknown.renderer.d.ts b/dist/ts-build/renderers/unknown.renderer.d.ts new file mode 100644 index 000000000..af10c6e42 --- /dev/null +++ b/dist/ts-build/renderers/unknown.renderer.d.ts @@ -0,0 +1,4 @@ +import { Renderer, RendererProps } from '../core/renderer'; +export declare class UnknownRenderer extends Renderer { + render(): any; +} diff --git a/dist/ts-build/renderers/unknown.renderer.js b/dist/ts-build/renderers/unknown.renderer.js new file mode 100644 index 000000000..6d2d770e9 --- /dev/null +++ b/dist/ts-build/renderers/unknown.renderer.js @@ -0,0 +1,26 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var JSX_1 = require("./JSX"); +var renderer_1 = require("../core/renderer"); +var UnknownRenderer = /** @class */ (function (_super) { + __extends(UnknownRenderer, _super); + function UnknownRenderer() { + return _super !== null && _super.apply(this, arguments) || this; + } + UnknownRenderer.prototype.render = function () { + return (JSX_1.JSX.createElement("div", { style: { color: 'red' } }, "No applicable renderer found.")); + }; + return UnknownRenderer; +}(renderer_1.Renderer)); +exports.UnknownRenderer = UnknownRenderer; +//# sourceMappingURL=unknown.renderer.js.map \ No newline at end of file diff --git a/dist/ts-build/renderers/unknown.renderer.js.map b/dist/ts-build/renderers/unknown.renderer.js.map new file mode 100644 index 000000000..7766f0439 --- /dev/null +++ b/dist/ts-build/renderers/unknown.renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"unknown.renderer.js","sourceRoot":"","sources":["../../../src/renderers/unknown.renderer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAA4B;AAC5B,6CAA2D;AAE3D;IAAqC,mCAA6B;IAAlE;;IASA,CAAC;IAPC,gCAAM,GAAN;QACE,MAAM,CAAC,CACL,iCAAK,KAAK,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC,oCAEpB,CACP,CAAC;IACJ,CAAC;IACH,sBAAC;AAAD,CAAC,AATD,CAAqC,mBAAQ,GAS5C;AATY,0CAAe"} \ No newline at end of file diff --git a/dist/ts-build/store.d.ts b/dist/ts-build/store.d.ts new file mode 100644 index 000000000..93722b1a6 --- /dev/null +++ b/dist/ts-build/store.d.ts @@ -0,0 +1,5 @@ +import { JsonFormsStore } from './json-forms'; +import { JsonSchema } from './models/jsonSchema'; +import { UISchemaElement } from './models/uischema'; +export declare const createJsonFormsStore: (initialState: any) => JsonFormsStore; +export declare const initJsonFormsStore: (data: any, schema: JsonSchema, uischema: UISchemaElement) => JsonFormsStore; diff --git a/dist/ts-build/store.js b/dist/ts-build/store.js new file mode 100644 index 000000000..d5d748db8 --- /dev/null +++ b/dist/ts-build/store.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var redux_thunk_1 = require("redux-thunk"); +var index_1 = require("./reducers/index"); +var redux_1 = require("redux"); +var core_1 = require("./core"); +var actions_1 = require("./actions"); +exports.createJsonFormsStore = function (initialState) { + // TODO: typing + var store = redux_1.createStore(index_1.appReducer, initialState, redux_1.applyMiddleware(redux_thunk_1.default)); + return store; +}; +exports.initJsonFormsStore = function (data, schema, uischema) { + var store = exports.createJsonFormsStore({ + common: { + data: data + }, + renderers: core_1.JsonForms.renderers + }); + store.dispatch({ + type: actions_1.INIT, + data: data, + schema: schema, + uischema: uischema + }); + store.dispatch({ + type: actions_1.VALIDATE, + data: data + }); + return store; +}; +//# sourceMappingURL=store.js.map \ No newline at end of file diff --git a/dist/ts-build/store.js.map b/dist/ts-build/store.js.map new file mode 100644 index 000000000..acc2a75d2 --- /dev/null +++ b/dist/ts-build/store.js.map @@ -0,0 +1 @@ +{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":";;AAAA,2CAAgC;AAChC,0CAA8C;AAC9C,+BAAqD;AAErD,+BAAmC;AACnC,qCAA2C;AAI9B,QAAA,oBAAoB,GAAG,UAAC,YAAY;IAC/C,eAAe;IACf,IAAM,KAAK,GAAG,mBAAW,CACvB,kBAAU,EACV,YAAY,EACZ,uBAAe,CAAC,qBAAK,CAAC,CACvB,CAAC;IAEF,MAAM,CAAC,KAAuB,CAAC;AACjC,CAAC,CAAC;AAEW,QAAA,kBAAkB,GAC7B,UAAC,IAAS,EAAE,MAAkB,EAAE,QAAyB;IAEzD,IAAM,KAAK,GAAG,4BAAoB,CAAC;QACjC,MAAM,EAAE;YACN,IAAI,MAAA;SACL;QACD,SAAS,EAAE,gBAAS,CAAC,SAAS;KAC/B,CAAC,CAAC;IAEH,KAAK,CAAC,QAAQ,CAAC;QACb,IAAI,EAAE,cAAI;QACV,IAAI,MAAA;QACJ,MAAM,QAAA;QACN,QAAQ,UAAA;KACT,CAAC,CAAC;IAEH,KAAK,CAAC,QAAQ,CAAC;QACb,IAAI,EAAE,kBAAQ;QACd,IAAI,MAAA;KACL,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC;AACf,CAAC,CAAC"} \ No newline at end of file