@jsonforms/core 3.0.0-alpha.0 → 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/README.md +1 -1
  2. package/docs/assets/js/search.json +1 -1
  3. package/docs/enums/ruleeffect.html +4 -4
  4. package/docs/globals.html +1095 -703
  5. package/docs/index.html +70 -43
  6. package/docs/interfaces/addcellrendereraction.html +3 -3
  7. package/docs/interfaces/addrendereraction.html +3 -3
  8. package/docs/interfaces/adduischemaaction.html +3 -3
  9. package/docs/interfaces/andcondition.html +2 -2
  10. package/docs/interfaces/arraycontrolprops.html +22 -22
  11. package/docs/interfaces/arraylayoutprops.html +22 -22
  12. package/docs/interfaces/categorization.html +5 -5
  13. package/docs/interfaces/category.html +5 -5
  14. package/docs/interfaces/cellprops.html +14 -14
  15. package/docs/interfaces/combinatorrendererprops.html +13 -13
  16. package/docs/interfaces/combinatorsubschemarenderinfo.html +3 -3
  17. package/docs/interfaces/composablecondition.html +2 -2
  18. package/docs/interfaces/condition.html +1 -1
  19. package/docs/interfaces/controlelement.html +5 -5
  20. package/docs/interfaces/controlprops.html +17 -17
  21. package/docs/interfaces/controlstate.html +2 -2
  22. package/docs/interfaces/controlwithdetailprops.html +18 -18
  23. package/docs/interfaces/dispatchcellprops.html +13 -13
  24. package/docs/interfaces/dispatchcellstateprops.html +13 -13
  25. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  26. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  27. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  28. package/docs/interfaces/enumcellprops.html +15 -15
  29. package/docs/interfaces/enumoption.html +2 -2
  30. package/docs/interfaces/formatted.html +2 -2
  31. package/docs/interfaces/grouplayout.html +5 -5
  32. package/docs/interfaces/horizontallayout.html +4 -4
  33. package/docs/interfaces/initaction.html +6 -6
  34. package/docs/interfaces/initactionoptions.html +3 -3
  35. package/docs/interfaces/jsonformscellrendererregistryentry.html +2 -2
  36. package/docs/interfaces/jsonformscore.html +7 -7
  37. package/docs/interfaces/jsonformsdefaultdataregistryentry.html +2 -2
  38. package/docs/interfaces/jsonformsextendedstate.html +1 -1
  39. package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
  40. package/docs/interfaces/jsonformsprops.html +9 -9
  41. package/docs/interfaces/jsonformsrendererregistryentry.html +2 -2
  42. package/docs/interfaces/jsonformsstate.html +1 -1
  43. package/docs/interfaces/jsonformsstore.html +5 -5
  44. package/docs/interfaces/jsonformssubstates.html +18 -8
  45. package/docs/interfaces/jsonformsuischemaregistryentry.html +2 -2
  46. package/docs/interfaces/labeldescription.html +2 -2
  47. package/docs/interfaces/labelelement.html +4 -4
  48. package/docs/interfaces/layout.html +4 -4
  49. package/docs/interfaces/layoutprops.html +10 -10
  50. package/docs/interfaces/leafcondition.html +3 -3
  51. package/docs/interfaces/orcondition.html +2 -2
  52. package/docs/interfaces/ownpropsofcell.html +10 -10
  53. package/docs/interfaces/ownpropsofcontrol.html +9 -9
  54. package/docs/interfaces/ownpropsofenum.html +1 -1
  55. package/docs/interfaces/ownpropsofenumcell.html +11 -11
  56. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  57. package/docs/interfaces/ownpropsoflayout.html +9 -9
  58. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  59. package/docs/interfaces/ownpropsofrenderer.html +8 -8
  60. package/docs/interfaces/registerdefaultdataaction.html +3 -3
  61. package/docs/interfaces/removecellrendereraction.html +3 -3
  62. package/docs/interfaces/removerendereraction.html +3 -3
  63. package/docs/interfaces/removeuischemaaction.html +2 -2
  64. package/docs/interfaces/rendererprops.html +9 -9
  65. package/docs/interfaces/rule.html +2 -2
  66. package/docs/interfaces/schemabasedcondition.html +3 -3
  67. package/docs/interfaces/scopable.html +1 -1
  68. package/docs/interfaces/setajvaction.html +3 -3
  69. package/docs/interfaces/setconfigaction.html +2 -2
  70. package/docs/interfaces/setlocaleaction.html +3 -3
  71. package/docs/interfaces/setschemaaction.html +2 -2
  72. package/docs/interfaces/{setlocalizedschemasaction.html → settranslatoraction.html} +29 -15
  73. package/docs/interfaces/setuischemaaction.html +2 -2
  74. package/docs/interfaces/setvalidationmodeaction.html +2 -2
  75. package/docs/interfaces/statepropsofarraycontrol.html +18 -18
  76. package/docs/interfaces/statepropsofarraylayout.html +18 -18
  77. package/docs/interfaces/statepropsofcell.html +13 -13
  78. package/docs/interfaces/statepropsofcombinator.html +12 -12
  79. package/docs/interfaces/statepropsofcontrol.html +16 -16
  80. package/docs/interfaces/statepropsofcontrolwithdetail.html +17 -17
  81. package/docs/interfaces/statepropsofenumcell.html +14 -14
  82. package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
  83. package/docs/interfaces/statepropsoflayout.html +10 -10
  84. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  85. package/docs/interfaces/statepropsofrenderer.html +9 -9
  86. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  87. package/docs/interfaces/uischemaelement.html +3 -3
  88. package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
  89. package/docs/interfaces/updateaction.html +3 -3
  90. package/docs/interfaces/updatecoreaction.html +6 -6
  91. package/docs/interfaces/updateerrorsaction.html +2 -2
  92. package/docs/interfaces/{setlocalizeduischemasaction.html → updatei18naction.html} +43 -15
  93. package/docs/interfaces/verticallayout.html +4 -4
  94. package/docs/interfaces/withclassname.html +1 -1
  95. package/lib/Helpers.d.ts +5 -0
  96. package/lib/actions/actions.d.ts +181 -0
  97. package/lib/actions/index.d.ts +1 -178
  98. package/lib/configDefault.d.ts +6 -6
  99. package/lib/generators/Generate.d.ts +6 -0
  100. package/lib/generators/index.d.ts +3 -10
  101. package/lib/generators/schema.d.ts +8 -8
  102. package/lib/generators/uischema.d.ts +12 -13
  103. package/lib/i18n/i18nTypes.d.ts +15 -0
  104. package/lib/i18n/i18nUtil.d.ts +18 -0
  105. package/lib/i18n/index.d.ts +2 -0
  106. package/lib/index.d.ts +11 -23
  107. package/lib/jsonforms-core.cjs.js +2445 -0
  108. package/lib/jsonforms-core.cjs.js.map +1 -0
  109. package/lib/jsonforms-core.esm.js +2164 -0
  110. package/lib/jsonforms-core.esm.js.map +1 -0
  111. package/lib/models/draft4.d.ts +198 -198
  112. package/lib/models/index.d.ts +5 -0
  113. package/lib/models/jsonSchema.d.ts +3 -3
  114. package/lib/models/jsonSchema4.d.ts +110 -110
  115. package/lib/models/jsonSchema7.d.ts +119 -119
  116. package/lib/models/uischema.d.ts +201 -201
  117. package/lib/reducers/cells.d.ts +11 -11
  118. package/lib/reducers/config.d.ts +3 -3
  119. package/lib/reducers/core.d.ts +24 -23
  120. package/lib/reducers/default-data.d.ts +10 -10
  121. package/lib/reducers/i18n.d.ts +8 -11
  122. package/lib/reducers/index.d.ts +9 -47
  123. package/lib/reducers/reducers.d.ts +29 -0
  124. package/lib/reducers/renderers.d.ts +10 -10
  125. package/lib/reducers/selectors.d.ts +15 -0
  126. package/lib/reducers/uischemas.d.ts +10 -10
  127. package/lib/store.d.ts +53 -56
  128. package/lib/testers/index.d.ts +1 -204
  129. package/lib/testers/testers.d.ts +203 -0
  130. package/lib/util/Formatted.d.ts +19 -19
  131. package/lib/util/array.d.ts +3 -3
  132. package/lib/util/cell.d.ts +79 -79
  133. package/lib/util/combinators.d.ts +10 -11
  134. package/lib/util/ids.d.ts +3 -3
  135. package/lib/util/index.d.ts +15 -49
  136. package/lib/util/label.d.ts +9 -10
  137. package/lib/util/path.d.ts +25 -24
  138. package/lib/util/renderer.d.ts +398 -395
  139. package/lib/util/resolvers.d.ts +25 -25
  140. package/lib/util/runtime.d.ts +18 -19
  141. package/lib/util/schema.d.ts +1 -1
  142. package/lib/util/type.d.ts +174 -174
  143. package/lib/util/uischema.d.ts +5 -5
  144. package/lib/util/util.d.ts +31 -0
  145. package/lib/util/validator.d.ts +3 -2
  146. package/package.json +18 -14
  147. package/rollup.config.js +44 -0
  148. package/{lib/models/jsonSchema4.js → src/Helpers.ts} +16 -8
  149. package/src/actions/actions.ts +345 -0
  150. package/src/actions/index.ts +1 -310
  151. package/src/configDefault.ts +1 -0
  152. package/{lib/util/validator.js → src/generators/Generate.ts} +18 -11
  153. package/src/generators/index.ts +3 -21
  154. package/src/generators/schema.ts +1 -1
  155. package/src/generators/uischema.ts +4 -4
  156. package/src/i18n/i18nTypes.ts +17 -0
  157. package/src/i18n/i18nUtil.ts +105 -0
  158. package/src/i18n/index.ts +2 -0
  159. package/src/index.ts +7 -31
  160. package/src/models/draft4.ts +1 -0
  161. package/{lib/util/type.js → src/models/index.ts} +10 -7
  162. package/src/models/jsonSchema.ts +1 -0
  163. package/src/models/uischema.ts +1 -0
  164. package/src/reducers/cells.ts +2 -1
  165. package/src/reducers/config.ts +2 -1
  166. package/src/reducers/core.ts +74 -52
  167. package/src/reducers/default-data.ts +2 -1
  168. package/src/reducers/i18n.ts +42 -35
  169. package/src/reducers/index.ts +9 -154
  170. package/src/reducers/reducers.ts +128 -0
  171. package/src/reducers/renderers.ts +2 -1
  172. package/src/reducers/selectors.ts +65 -0
  173. package/src/reducers/uischemas.ts +4 -2
  174. package/src/store.ts +11 -8
  175. package/src/testers/index.ts +1 -516
  176. package/src/testers/testers.ts +547 -0
  177. package/src/util/Formatted.ts +1 -0
  178. package/src/util/array.ts +25 -0
  179. package/src/util/cell.ts +45 -10
  180. package/src/util/combinators.ts +2 -4
  181. package/src/util/ids.ts +1 -0
  182. package/src/util/index.ts +11 -123
  183. package/src/util/label.ts +2 -2
  184. package/src/util/path.ts +4 -1
  185. package/src/util/renderer.ts +139 -66
  186. package/src/util/resolvers.ts +2 -1
  187. package/src/util/runtime.ts +3 -2
  188. package/src/util/schema.ts +26 -1
  189. package/src/util/uischema.ts +2 -1
  190. package/src/util/util.ts +127 -0
  191. package/src/util/validator.ts +5 -8
  192. package/stats.html +3279 -0
  193. package/{lib/configDefault.js → test/i18n/i18nUtil.test.ts} +25 -24
  194. package/test/reducers/core.test.ts +31 -44
  195. package/test/util/cell.test.ts +2 -2
  196. package/test/util/renderer.test.ts +543 -31
  197. package/docs/interfaces/labels.html +0 -157
  198. package/lib/actions/index.js +0 -125
  199. package/lib/actions/index.js.map +0 -1
  200. package/lib/configDefault.js.map +0 -1
  201. package/lib/generators/index.js +0 -12
  202. package/lib/generators/index.js.map +0 -1
  203. package/lib/generators/schema.js +0 -152
  204. package/lib/generators/schema.js.map +0 -1
  205. package/lib/generators/uischema.js +0 -167
  206. package/lib/generators/uischema.js.map +0 -1
  207. package/lib/index.js +0 -45
  208. package/lib/index.js.map +0 -1
  209. package/lib/jsonforms-core.js +0 -19
  210. package/lib/jsonforms-core.js.map +0 -1
  211. package/lib/models/draft4.js +0 -173
  212. package/lib/models/draft4.js.map +0 -1
  213. package/lib/models/jsonSchema.js +0 -3
  214. package/lib/models/jsonSchema.js.map +0 -1
  215. package/lib/models/jsonSchema4.js.map +0 -1
  216. package/lib/models/jsonSchema7.js +0 -30
  217. package/lib/models/jsonSchema7.js.map +0 -1
  218. package/lib/models/uischema.js +0 -31
  219. package/lib/models/uischema.js.map +0 -1
  220. package/lib/reducers/cells.js +0 -16
  221. package/lib/reducers/cells.js.map +0 -1
  222. package/lib/reducers/config.js +0 -44
  223. package/lib/reducers/config.js.map +0 -1
  224. package/lib/reducers/core.js +0 -259
  225. package/lib/reducers/core.js.map +0 -1
  226. package/lib/reducers/default-data.js +0 -42
  227. package/lib/reducers/default-data.js.map +0 -1
  228. package/lib/reducers/i18n.js +0 -66
  229. package/lib/reducers/i18n.js.map +0 -1
  230. package/lib/reducers/index.js +0 -92
  231. package/lib/reducers/index.js.map +0 -1
  232. package/lib/reducers/renderers.js +0 -17
  233. package/lib/reducers/renderers.js.map +0 -1
  234. package/lib/reducers/uischemas.js +0 -57
  235. package/lib/reducers/uischemas.js.map +0 -1
  236. package/lib/store.js +0 -3
  237. package/lib/store.js.map +0 -1
  238. package/lib/testers/index.js +0 -402
  239. package/lib/testers/index.js.map +0 -1
  240. package/lib/util/Formatted.js +0 -3
  241. package/lib/util/Formatted.js.map +0 -1
  242. package/lib/util/array.js +0 -19
  243. package/lib/util/array.js.map +0 -1
  244. package/lib/util/cell.js +0 -133
  245. package/lib/util/cell.js.map +0 -1
  246. package/lib/util/combinators.js +0 -56
  247. package/lib/util/combinators.js.map +0 -1
  248. package/lib/util/ids.js +0 -50
  249. package/lib/util/ids.js.map +0 -1
  250. package/lib/util/index.js +0 -132
  251. package/lib/util/index.js.map +0 -1
  252. package/lib/util/label.js +0 -70
  253. package/lib/util/label.js.map +0 -1
  254. package/lib/util/path.js +0 -84
  255. package/lib/util/path.js.map +0 -1
  256. package/lib/util/renderer.js +0 -447
  257. package/lib/util/renderer.js.map +0 -1
  258. package/lib/util/resolvers.js +0 -165
  259. package/lib/util/resolvers.js.map +0 -1
  260. package/lib/util/runtime.js +0 -159
  261. package/lib/util/runtime.js.map +0 -1
  262. package/lib/util/schema.js +0 -16
  263. package/lib/util/schema.js.map +0 -1
  264. package/lib/util/type.js.map +0 -1
  265. package/lib/util/uischema.js +0 -52
  266. package/lib/util/uischema.js.map +0 -1
  267. package/lib/util/validator.js.map +0 -1
  268. package/webpack.build.js +0 -13
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- /*
5
- The MIT License
6
-
7
- Copyright (c) 2017-2019 EclipseSource Munich
8
- https://github.com/eclipsesource/jsonforms
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in
18
- all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
- THE SOFTWARE.
27
- */
28
- var actions_1 = require("../actions");
29
- var __1 = require("..");
30
- var initState = {
31
- locale: undefined,
32
- localizedSchemas: new Map(),
33
- localizedUISchemas: new Map()
34
- };
35
- exports.i18nReducer = function (state, action) {
36
- if (state === void 0) { state = initState; }
37
- switch (action.type) {
38
- case actions_1.SET_LOCALIZED_SCHEMAS:
39
- return tslib_1.__assign(tslib_1.__assign({}, state), { localizedSchemas: action.localizedSchemas });
40
- case __1.SET_LOCALIZED_UISCHEMAS:
41
- return tslib_1.__assign(tslib_1.__assign({}, state), { localizedUISchemas: action.localizedUISchemas });
42
- case actions_1.SET_LOCALE:
43
- return tslib_1.__assign(tslib_1.__assign({}, state), { locale: action.locale === undefined ? navigator.languages[0] : action.locale });
44
- default:
45
- return state;
46
- }
47
- };
48
- exports.fetchLocale = function (state) {
49
- if (state === undefined) {
50
- return undefined;
51
- }
52
- return state.locale;
53
- };
54
- exports.findLocalizedSchema = function (locale) { return function (state) {
55
- if (state === undefined) {
56
- return undefined;
57
- }
58
- return state.localizedSchemas.get(locale);
59
- }; };
60
- exports.findLocalizedUISchema = function (locale) { return function (state) {
61
- if (state === undefined) {
62
- return undefined;
63
- }
64
- return state.localizedUISchemas.get(locale);
65
- }; };
66
- //# sourceMappingURL=i18n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/reducers/i18n.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;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OAAO,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,EAPwD,CAOxD,CAAC"}
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var core_1 = require("./core");
5
- exports.coreReducer = core_1.coreReducer;
6
- exports.errorsAt = core_1.errorsAt;
7
- var default_data_1 = require("./default-data");
8
- var default_data_2 = require("../reducers/default-data");
9
- var renderers_1 = require("./renderers");
10
- exports.rendererReducer = renderers_1.rendererReducer;
11
- var uischemas_1 = require("./uischemas");
12
- exports.findMatchingUISchema = uischemas_1.findMatchingUISchema;
13
- exports.uischemaRegistryReducer = uischemas_1.uischemaRegistryReducer;
14
- var i18n_1 = require("./i18n");
15
- exports.i18nReducer = i18n_1.i18nReducer;
16
- var generators_1 = require("../generators");
17
- var cells_1 = require("./cells");
18
- exports.cellReducer = cells_1.cellReducer;
19
- var config_1 = require("./config");
20
- exports.configReducer = config_1.configReducer;
21
- var get_1 = tslib_1.__importDefault(require("lodash/get"));
22
- exports.jsonFormsReducerConfig = {
23
- core: core_1.coreReducer,
24
- renderers: renderers_1.rendererReducer,
25
- cells: cells_1.cellReducer,
26
- config: config_1.configReducer,
27
- uischemas: uischemas_1.uischemaRegistryReducer,
28
- defaultData: default_data_2.defaultDataReducer,
29
- i18n: i18n_1.i18nReducer
30
- };
31
- exports.getData = function (state) {
32
- return core_1.extractData(get_1.default(state, 'jsonforms.core'));
33
- };
34
- exports.getSchema = function (state) {
35
- return core_1.extractSchema(get_1.default(state, 'jsonforms.core'));
36
- };
37
- exports.getUiSchema = function (state) {
38
- return core_1.extractUiSchema(get_1.default(state, 'jsonforms.core'));
39
- };
40
- exports.getAjv = function (state) { return core_1.extractAjv(get_1.default(state, 'jsonforms.core')); };
41
- exports.getDefaultData = function (state) {
42
- return default_data_1.extractDefaultData(get_1.default(state, 'jsonforms.defaultData'));
43
- };
44
- exports.getRenderers = function (state) { return get_1.default(state, 'jsonforms.renderers'); };
45
- exports.getCells = function (state) { return get_1.default(state, 'jsonforms.cells'); };
46
- exports.getUISchemas = function (state) { return get_1.default(state, 'jsonforms.uischemas'); };
47
- /**
48
- * Finds a registered UI schema to use, if any.
49
- * @param schema the JSON schema describing the data to be rendered
50
- * @param schemaPath the according schema path
51
- * @param path the instance path
52
- * @param fallbackLayoutType the type of the layout to use
53
- * @param control may be checked for embedded inline uischema options
54
- */
55
- exports.findUISchema = function (uischemas, schema, schemaPath, path, fallbackLayoutType, control, rootSchema) {
56
- if (fallbackLayoutType === void 0) { fallbackLayoutType = 'VerticalLayout'; }
57
- // handle options
58
- if (control && control.options && control.options.detail) {
59
- if (typeof control.options.detail === 'string') {
60
- if (control.options.detail.toUpperCase() === 'GENERATE') {
61
- // force generation of uischema
62
- return generators_1.Generate.uiSchema(schema, fallbackLayoutType);
63
- }
64
- }
65
- else if (typeof control.options.detail === 'object') {
66
- // check if detail is a valid uischema
67
- if (control.options.detail.type &&
68
- typeof control.options.detail.type === 'string') {
69
- return control.options.detail;
70
- }
71
- }
72
- }
73
- // default
74
- var uiSchema = uischemas_1.findMatchingUISchema(uischemas)(schema, schemaPath, path);
75
- if (uiSchema === undefined) {
76
- return generators_1.Generate.uiSchema(schema, fallbackLayoutType, '#', rootSchema);
77
- }
78
- return uiSchema;
79
- };
80
- exports.getErrorAt = function (instancePath, schema) { return function (state) {
81
- return core_1.errorAt(instancePath, schema)(state.jsonforms.core);
82
- }; };
83
- exports.getSubErrorsAt = function (instancePath, schema) { return function (state) { return core_1.subErrorsAt(instancePath, schema)(state.jsonforms.core); }; };
84
- exports.getConfig = function (state) { return state.jsonforms.config; };
85
- exports.getLocale = function (state) {
86
- return i18n_1.fetchLocale(get_1.default(state, 'jsonforms.i18n'));
87
- };
88
- exports.getLocalizedSchema = function (locale) { return function (state) { return i18n_1.findLocalizedSchema(locale)(get_1.default(state, 'jsonforms.i18n')); }; };
89
- exports.getLocalizedUISchema = function (locale) { return function (state) {
90
- return i18n_1.findLocalizedUISchema(locale)(get_1.default(state, 'jsonforms.i18n'));
91
- }; };
92
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":";;;AAyBA,+BAWgB;AAiCd,sBA3CA,kBAAW,CA2CA;AA2FJ,mBApIP,eAAQ,CAoIO;AA3HjB,+CAGwB;AACxB,yDAA8D;AAC9D,yCAA8E;AAyB5E,0BAzBuC,2BAAe,CAyBvC;AAvBjB,yCAKqB;AAyBnB,+BA7BA,gCAAoB,CA6BA;AADpB,kCA1BA,mCAAuB,CA0BA;AAvBzB,+BAKgB;AAed,sBAhBA,kBAAW,CAgBA;AAbb,4CAAyC;AAIzC,iCAAsC;AAOpC,sBAPO,mBAAW,CAOP;AANb,mCAAyC;AASvC,wBATO,sBAAa,CASP;AARf,2DAA6B;AAgBhB,QAAA,sBAAsB,GAAG;IACpC,IAAI,EAAE,kBAAW;IACjB,SAAS,EAAE,2BAAe;IAC1B,KAAK,EAAE,mBAAW;IAClB,MAAM,EAAE,sBAAa;IACrB,SAAS,EAAE,mCAAuB;IAClC,WAAW,EAAE,iCAAkB;IAC/B,IAAI,EAAE,kBAAW;CAClB,CAAC;AAEW,QAAA,OAAO,GAAG,UAAC,KAAqB;IAC3C,OAAA,kBAAW,CAAC,aAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAAzC,CAAyC,CAAC;AAC/B,QAAA,SAAS,GAAG,UAAC,KAAqB;IAC7C,OAAA,oBAAa,CAAC,aAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAA3C,CAA2C,CAAC;AACjC,QAAA,WAAW,GAAG,UAAC,KAAqB;IAC/C,OAAA,sBAAe,CAAC,aAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAA7C,CAA6C,CAAC;AACnC,QAAA,MAAM,GAAG,UACpB,KAAqB,IACb,O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,QAAA,oBAAoB,GAAG,UAAC,MAAc,IAAK,OAAA,UACtD,KAAqB;IAErB,OAAA,4BAAqB,CAAC,MAAM,CAAC,CAAC,aAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAA3D,CAA2D,EAHL,CAGK,CAAC"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var actions_1 = require("../actions");
4
- exports.rendererReducer = function (state, action) {
5
- if (state === void 0) { state = []; }
6
- switch (action.type) {
7
- case actions_1.ADD_RENDERER:
8
- return state.concat([
9
- { tester: action.tester, renderer: action.renderer }
10
- ]);
11
- case actions_1.REMOVE_RENDERER:
12
- return state.filter(function (t) { return t.tester !== action.tester; });
13
- default:
14
- return state;
15
- }
16
- };
17
- //# sourceMappingURL=renderers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderers.js","sourceRoot":"","sources":["../../src/reducers/renderers.ts"],"names":[],"mappings":";;AAyBA,sCAKoB;AAUP,QAAA,eAAe,GAA2E,UACrG,KAAU,EACV,MAAM;IADN,sBAAA,EAAA,UAAU;IAGV,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,sBAAY;YACf,OAAO,KAAK,CAAC,MAAM,CAAC;gBAClB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;aACrD,CAAC,CAAC;QACL,KAAK,yBAAe;YAClB,OAAO,KAAK,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAA1B,CAA0B,CAAC,CAAC;QACvD;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC,CAAC"}
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- /*
5
- The MIT License
6
-
7
- Copyright (c) 2017-2019 EclipseSource Munich
8
- https://github.com/eclipsesource/jsonforms
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in
18
- all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
- THE SOFTWARE.
27
- */
28
- var maxBy_1 = tslib_1.__importDefault(require("lodash/maxBy"));
29
- var remove_1 = tslib_1.__importDefault(require("lodash/remove"));
30
- var actions_1 = require("../actions");
31
- var __1 = require("..");
32
- exports.uischemaRegistryReducer = function (state, action) {
33
- if (state === void 0) { state = []; }
34
- switch (action.type) {
35
- case actions_1.ADD_UI_SCHEMA:
36
- return state
37
- .slice()
38
- .concat({ tester: action.tester, uischema: action.uischema });
39
- case actions_1.REMOVE_UI_SCHEMA:
40
- var copy = state.slice();
41
- remove_1.default(copy, function (entry) { return entry.tester === action.tester; });
42
- return copy;
43
- default:
44
- return state;
45
- }
46
- };
47
- exports.findMatchingUISchema = function (state) { return function (jsonSchema, schemaPath, path) {
48
- var match = maxBy_1.default(state, function (entry) {
49
- return entry.tester(jsonSchema, schemaPath, path);
50
- });
51
- if (match !== undefined &&
52
- match.tester(jsonSchema, schemaPath, path) !== __1.NOT_APPLICABLE) {
53
- return match.uischema;
54
- }
55
- return undefined;
56
- }; };
57
- //# sourceMappingURL=uischemas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uischemas.js","sourceRoot":"","sources":["../../src/reducers/uischemas.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,+DAAiC;AACjC,iEAAmC;AACnC,sCAA8E;AAC9E,wBAAiE;AAcpD,QAAA,uBAAuB,GAA+D,UACjG,KAAU,EACV,MAAM;IADN,sBAAA,EAAA,UAAU;IAGV,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,uBAAa;YAChB,OAAO,KAAK;iBACT,KAAK,EAAE;iBACP,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClE,KAAK,0BAAgB;YACnB,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3B,gBAAM,CAAC,IAAI,EAAE,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAA9B,CAA8B,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC;QACd;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC,CAAC;AAEW,QAAA,oBAAoB,GAAG,UAClC,KAAuC,IACpC,OAAA,UACH,UAAsB,EACtB,UAAkB,EAClB,IAAY;IAEZ,IAAM,KAAK,GAAG,eAAK,CAAC,KAAK,EAAE,UAAA,KAAK;QAC9B,OAAA,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC;IAA1C,CAA0C,CAC3C,CAAC;IACF,IACE,KAAK,KAAK,SAAS;QACnB,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,kBAAc,EAC7D;QACA,OAAO,KAAK,CAAC,QAAQ,CAAC;KACvB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,EAfI,CAeJ,CAAC"}
package/lib/store.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=store.js.map
package/lib/store.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":""}
@@ -1,402 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- /*
5
- The MIT License
6
-
7
- Copyright (c) 2017-2019 EclipseSource Munich
8
- https://github.com/eclipsesource/jsonforms
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in
18
- all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
- THE SOFTWARE.
27
- */
28
- var isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
29
- var get_1 = tslib_1.__importDefault(require("lodash/get"));
30
- var endsWith_1 = tslib_1.__importDefault(require("lodash/endsWith"));
31
- var last_1 = tslib_1.__importDefault(require("lodash/last"));
32
- var isArray_1 = tslib_1.__importDefault(require("lodash/isArray"));
33
- var reduce_1 = tslib_1.__importDefault(require("lodash/reduce"));
34
- var toPairs_1 = tslib_1.__importDefault(require("lodash/toPairs"));
35
- var includes_1 = tslib_1.__importDefault(require("lodash/includes"));
36
- var resolvers_1 = require("../util/resolvers");
37
- var util_1 = require("../util");
38
- /**
39
- * Constant that indicates that a tester is not capable of handling
40
- * a combination of schema/data.
41
- * @type {number}
42
- */
43
- exports.NOT_APPLICABLE = -1;
44
- exports.isControl = function (uischema) {
45
- return !isEmpty_1.default(uischema) && uischema.scope !== undefined;
46
- };
47
- /**
48
- * Only applicable for Controls.
49
- *
50
- * This function checks whether the given UI schema is of type Control
51
- * and if so, resolves the sub-schema referenced by the control and applies
52
- * the given predicate
53
- *
54
- * @param {(JsonSchema) => boolean} predicate the predicate that should be
55
- * applied to the resolved sub-schema
56
- */
57
- exports.schemaMatches = function (predicate) { return function (uischema, schema) {
58
- if (isEmpty_1.default(uischema) || !exports.isControl(uischema)) {
59
- return false;
60
- }
61
- if (isEmpty_1.default(schema)) {
62
- return false;
63
- }
64
- var schemaPath = uischema.scope;
65
- if (isEmpty_1.default(schemaPath)) {
66
- return false;
67
- }
68
- var currentDataSchema = schema;
69
- if (util_1.hasType(schema, 'object')) {
70
- currentDataSchema = resolvers_1.resolveSchema(schema, schemaPath);
71
- }
72
- if (currentDataSchema === undefined) {
73
- return false;
74
- }
75
- return predicate(currentDataSchema);
76
- }; };
77
- exports.schemaSubPathMatches = function (subPath, predicate) { return function (uischema, schema) {
78
- if (isEmpty_1.default(uischema) || !exports.isControl(uischema)) {
79
- return false;
80
- }
81
- var schemaPath = uischema.scope;
82
- var currentDataSchema = schema;
83
- if (util_1.hasType(schema, 'object')) {
84
- currentDataSchema = resolvers_1.resolveSchema(schema, schemaPath);
85
- }
86
- currentDataSchema = get_1.default(currentDataSchema, subPath);
87
- if (currentDataSchema === undefined) {
88
- return false;
89
- }
90
- return predicate(currentDataSchema);
91
- }; };
92
- /**
93
- * Only applicable for Controls.
94
- *
95
- * This function checks whether the given UI schema is of type Control
96
- * and if so, resolves the sub-schema referenced by the control and checks
97
- * whether the type of the sub-schema matches the expected one.
98
- *
99
- * @param {string} expectedType the expected type of the resolved sub-schema
100
- */
101
- exports.schemaTypeIs = function (expectedType) {
102
- return exports.schemaMatches(function (schema) { return !isEmpty_1.default(schema) && util_1.hasType(schema, expectedType); });
103
- };
104
- /**
105
- * Only applicable for Controls.
106
- *
107
- * This function checks whether the given UI schema is of type Control
108
- * and if so, resolves the sub-schema referenced by the control and checks
109
- * whether the format of the sub-schema matches the expected one.
110
- *
111
- * @param {string} expectedFormat the expected format of the resolved sub-schema
112
- */
113
- exports.formatIs = function (expectedFormat) {
114
- return exports.schemaMatches(function (schema) {
115
- return !isEmpty_1.default(schema) &&
116
- schema.format === expectedFormat &&
117
- schema.type === 'string';
118
- });
119
- };
120
- /**
121
- * Checks whether the given UI schema has the expected type.
122
- *
123
- * @param {string} expected the expected UI schema type
124
- */
125
- exports.uiTypeIs = function (expected) { return function (uischema) { return !isEmpty_1.default(uischema) && uischema.type === expected; }; };
126
- /**
127
- * Checks whether the given UI schema has an option with the given
128
- * name and whether it has the expected value. If no options property
129
- * is set, returns false.
130
- *
131
- * @param {string} optionName the name of the option to check
132
- * @param {any} optionValue the expected value of the option
133
- */
134
- exports.optionIs = function (optionName, optionValue) { return function (uischema) {
135
- if (isEmpty_1.default(uischema)) {
136
- return false;
137
- }
138
- var options = uischema.options;
139
- return !isEmpty_1.default(options) && options[optionName] === optionValue;
140
- }; };
141
- /**
142
- * Only applicable for Controls.
143
- *
144
- * Checks whether the scope of a control ends with the expected string.
145
- *
146
- * @param {string} expected the expected ending of the reference
147
- */
148
- exports.scopeEndsWith = function (expected) { return function (uischema) {
149
- if (isEmpty_1.default(expected) || !exports.isControl(uischema)) {
150
- return false;
151
- }
152
- return endsWith_1.default(uischema.scope, expected);
153
- }; };
154
- /**
155
- * Only applicable for Controls.
156
- *
157
- * Checks whether the last segment of the scope matches the expected string.
158
- *
159
- * @param {string} expected the expected ending of the reference
160
- */
161
- exports.scopeEndIs = function (expected) { return function (uischema) {
162
- if (isEmpty_1.default(expected) || !exports.isControl(uischema)) {
163
- return false;
164
- }
165
- var schemaPath = uischema.scope;
166
- return !isEmpty_1.default(schemaPath) && last_1.default(schemaPath.split('/')) === expected;
167
- }; };
168
- /**
169
- * A tester that allow composing other testers by && them.
170
- *
171
- * @param {Array<Tester>} testers the testers to be composed
172
- */
173
- exports.and = function () {
174
- var testers = [];
175
- for (var _i = 0; _i < arguments.length; _i++) {
176
- testers[_i] = arguments[_i];
177
- }
178
- return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema); }, true); };
179
- };
180
- /**
181
- * A tester that allow composing other testers by || them.
182
- *
183
- * @param {Array<Tester>} testers the testers to be composed
184
- */
185
- exports.or = function () {
186
- var testers = [];
187
- for (var _i = 0; _i < arguments.length; _i++) {
188
- testers[_i] = arguments[_i];
189
- }
190
- return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema); }, false); };
191
- };
192
- /**
193
- * Create a ranked tester that will associate a number with a given tester, if the
194
- * latter returns true.
195
- *
196
- * @param {number} rank the rank to be returned in case the tester returns true
197
- * @param {Tester} tester a tester
198
- */
199
- exports.rankWith = function (rank, tester) { return function (uischema, schema) {
200
- if (tester(uischema, schema)) {
201
- return rank;
202
- }
203
- return exports.NOT_APPLICABLE;
204
- }; };
205
- exports.withIncreasedRank = function (by, rankedTester) { return function (uischema, schema) {
206
- var rank = rankedTester(uischema, schema);
207
- if (rank === exports.NOT_APPLICABLE) {
208
- return exports.NOT_APPLICABLE;
209
- }
210
- return rank + by;
211
- }; };
212
- /**
213
- * Default tester for boolean.
214
- * @type {RankedTester}
215
- */
216
- exports.isBooleanControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('boolean'));
217
- // TODO: rather check for properties property
218
- exports.isObjectControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('object'));
219
- exports.isAllOfControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('allOf'); }));
220
- exports.isAnyOfControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('anyOf'); }));
221
- exports.isOneOfControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('oneOf'); }));
222
- /**
223
- * Tests whether the given UI schema is of type Control and if the schema
224
- * has a 'date' format.
225
- * @type {Tester}
226
- */
227
- exports.isDateControl = exports.and(exports.uiTypeIs('Control'), exports.formatIs('date'));
228
- /**
229
- * Tests whether the given UI schema is of type Control and if the schema
230
- * has an enum.
231
- * @type {Tester}
232
- */
233
- exports.isEnumControl = exports.and(exports.uiTypeIs('Control'), exports.or(exports.schemaMatches(function (schema) { return schema.hasOwnProperty('enum'); }), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('const'); })));
234
- /**
235
- * Tests whether the given UI schema is of type Control and if the schema
236
- * has an enum based on oneOf.
237
- * @type {Tester}
238
- */
239
- exports.isOneOfEnumControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) {
240
- return schema.hasOwnProperty('oneOf') &&
241
- schema.oneOf.every(function (s) { return s.const !== undefined; });
242
- }));
243
- /**
244
- * Tests whether the given UI schema is of type Control and if the schema
245
- * is of type integer
246
- * @type {Tester}
247
- */
248
- exports.isIntegerControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('integer'));
249
- /**
250
- * Tests whether the given UI schema is of type Control and if the schema
251
- * is of type number
252
- * @type {Tester}
253
- */
254
- exports.isNumberControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('number'));
255
- /**
256
- * Tests whether the given UI schema is of type Control and if the schema
257
- * is of type string
258
- * @type {Tester}
259
- */
260
- exports.isStringControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('string'));
261
- /**
262
- * Tests whether the given UI schema is of type Control and if is has
263
- * a 'multi' option.
264
- * @type {Tester}
265
- */
266
- exports.isMultiLineControl = exports.and(exports.uiTypeIs('Control'), exports.optionIs('multi', true));
267
- /**
268
- * Tests whether the given UI schema is of type Control and if the schema
269
- * has a 'time' format.
270
- * @type {Tester}
271
- */
272
- exports.isTimeControl = exports.and(exports.uiTypeIs('Control'), exports.formatIs('time'));
273
- /**
274
- * Tests whether the given UI schema is of type Control and if the schema
275
- * has a 'date-time' format.
276
- * @type {Tester}
277
- */
278
- exports.isDateTimeControl = exports.and(exports.uiTypeIs('Control'), exports.formatIs('date-time'));
279
- /**
280
- * Tests whether the given schema is an array of objects.
281
- * @type {Tester}
282
- */
283
- exports.isObjectArray = exports.and(exports.schemaMatches(function (schema) { return util_1.hasType(schema, 'array') && !Array.isArray(schema.items); } // we don't care about tuples
284
- ), exports.schemaSubPathMatches('items', function (schema) { return util_1.hasType(schema, 'object'); }));
285
- /**
286
- * Tests whether the given UI schema is of type Control and if the schema
287
- * is an array of objects.
288
- * @type {Tester}
289
- */
290
- exports.isObjectArrayControl = exports.and(exports.uiTypeIs('Control'), exports.isObjectArray);
291
- var traverse = function (any, pred) {
292
- if (isArray_1.default(any)) {
293
- return reduce_1.default(any, function (acc, el) { return acc || traverse(el, pred); }, false);
294
- }
295
- if (pred(any)) {
296
- return true;
297
- }
298
- if (any.items) {
299
- return traverse(any.items, pred);
300
- }
301
- if (any.properties) {
302
- return reduce_1.default(toPairs_1.default(any.properties), function (acc, _a) {
303
- var _key = _a[0], val = _a[1];
304
- return acc || traverse(val, pred);
305
- }, false);
306
- }
307
- return false;
308
- };
309
- exports.isObjectArrayWithNesting = function (uischema, schema) {
310
- if (!exports.uiTypeIs('Control')(uischema, schema)) {
311
- return false;
312
- }
313
- var schemaPath = uischema.scope;
314
- var resolvedSchema = resolvers_1.resolveSchema(schema, schemaPath);
315
- var wantedNestingByType = {
316
- object: 2,
317
- array: 1
318
- };
319
- if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
320
- // check if nested arrays
321
- if (traverse(resolvedSchema.items, function (val) {
322
- if (val === schema) {
323
- return false;
324
- }
325
- // we don't support multiple types
326
- if (typeof val.type !== 'string') {
327
- return true;
328
- }
329
- var typeCount = wantedNestingByType[val.type];
330
- if (typeCount === undefined) {
331
- return false;
332
- }
333
- wantedNestingByType[val.type] = typeCount - 1;
334
- return wantedNestingByType[val.type] === 0;
335
- })) {
336
- return true;
337
- }
338
- // check if uischema options detail is set
339
- if (uischema.options && uischema.options.detail) {
340
- if (typeof uischema.options.detail === 'string') {
341
- return uischema.options.detail.toUpperCase() !== 'DEFAULT';
342
- }
343
- else if (typeof uischema.options.detail === 'object' &&
344
- uischema.options.detail.type) {
345
- return true;
346
- }
347
- }
348
- }
349
- return false;
350
- };
351
- /**
352
- * Synonym for isObjectArrayControl
353
- */
354
- exports.isArrayObjectControl = exports.isObjectArrayControl;
355
- /**
356
- * Tests whether the given UI schema is of type Control and if the schema
357
- * is an array of a primitive type.
358
- * @type {Tester}
359
- */
360
- exports.isPrimitiveArrayControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return util_1.deriveTypes(schema).length !== 0 && !Array.isArray(schema.items); } // we don't care about tuples
361
- ), exports.schemaSubPathMatches('items', function (schema) {
362
- var types = util_1.deriveTypes(schema);
363
- return (types.length === 1 &&
364
- includes_1.default(['integer', 'number', 'boolean', 'string'], types[0]));
365
- }));
366
- /**
367
- * Tests whether a given UI schema is of type Control,
368
- * if the schema is of type number or integer and
369
- * whether the schema defines a numerical range with a default value.
370
- * @type {Tester}
371
- */
372
- exports.isRangeControl = exports.and(exports.uiTypeIs('Control'), exports.or(exports.schemaTypeIs('number'), exports.schemaTypeIs('integer')), exports.schemaMatches(function (schema) {
373
- return schema.hasOwnProperty('maximum') &&
374
- schema.hasOwnProperty('minimum') &&
375
- schema.hasOwnProperty('default');
376
- }), exports.optionIs('slider', true));
377
- /**
378
- * Tests whether the given UI schema is of type Control, if the schema
379
- * is of type string and has option format
380
- * @type {Tester}
381
- */
382
- exports.isNumberFormatControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('integer'), exports.optionIs('format', true));
383
- exports.isCategorization = function (category) { return category.type === 'Categorization'; };
384
- exports.isCategory = function (uischema) {
385
- return uischema.type === 'Category';
386
- };
387
- exports.hasCategory = function (categorization) {
388
- if (isEmpty_1.default(categorization.elements)) {
389
- return false;
390
- }
391
- // all children of the categorization have to be categories
392
- return categorization.elements
393
- .map(function (elem) {
394
- return exports.isCategorization(elem) ? exports.hasCategory(elem) : exports.isCategory(elem);
395
- })
396
- .reduce(function (prev, curr) { return prev && curr; }, true);
397
- };
398
- exports.categorizationHasCategory = function (uischema) {
399
- return exports.hasCategory(uischema);
400
- };
401
- exports.not = function (tester) { return function (uischema, schema) { return !tester(uischema, schema); }; };
402
- //# sourceMappingURL=index.js.map