@jsonforms/core 3.4.0-alpha.0 → 3.4.0-alpha.2

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 (85) hide show
  1. package/lib/actions/actions.d.ts +3 -4
  2. package/lib/generators/Generate.d.ts +1 -1
  3. package/lib/i18n/i18nUtil.d.ts +1 -1
  4. package/lib/i18n/index.d.ts +2 -2
  5. package/lib/i18n/selectors.d.ts +7 -0
  6. package/lib/index.d.ts +1 -1
  7. package/lib/jsonforms-core.cjs.js +1922 -1917
  8. package/lib/jsonforms-core.cjs.js.map +1 -1
  9. package/lib/jsonforms-core.esm.js +1607 -1605
  10. package/lib/jsonforms-core.esm.js.map +1 -1
  11. package/lib/{util → mappers}/cell.d.ts +1 -3
  12. package/lib/{util → mappers}/combinators.d.ts +1 -1
  13. package/lib/mappers/index.d.ts +4 -0
  14. package/lib/{util → mappers}/renderer.d.ts +17 -6
  15. package/lib/mappers/util.d.ts +10 -0
  16. package/lib/models/uischema.d.ts +0 -8
  17. package/lib/reducers/cells.d.ts +1 -6
  18. package/lib/reducers/config.d.ts +1 -1
  19. package/lib/reducers/core.d.ts +7 -25
  20. package/lib/reducers/default-data.d.ts +3 -1
  21. package/lib/reducers/i18n.d.ts +2 -5
  22. package/lib/reducers/index.d.ts +0 -1
  23. package/lib/reducers/middleware.d.ts +1 -1
  24. package/lib/reducers/reducers.d.ts +8 -16
  25. package/lib/reducers/renderers.d.ts +2 -6
  26. package/lib/reducers/uischemas.d.ts +2 -6
  27. package/lib/store/index.d.ts +4 -0
  28. package/lib/store/jsonFormsCore.d.ts +19 -0
  29. package/lib/{store.d.ts → store/store.d.ts} +28 -3
  30. package/lib/testers/testers.d.ts +1 -0
  31. package/lib/util/errors.d.ts +5 -0
  32. package/lib/{Helpers.d.ts → util/helpers.d.ts} +1 -1
  33. package/lib/util/index.d.ts +2 -5
  34. package/lib/util/label.d.ts +1 -13
  35. package/lib/util/path.d.ts +6 -2
  36. package/lib/util/runtime.d.ts +1 -10
  37. package/lib/util/schema.d.ts +1 -1
  38. package/lib/util/uischema.d.ts +10 -7
  39. package/lib/util/util.d.ts +1 -2
  40. package/lib/util/validator.d.ts +2 -1
  41. package/package.json +1 -1
  42. package/src/actions/actions.ts +3 -4
  43. package/src/generators/Generate.ts +1 -1
  44. package/src/generators/uischema.ts +1 -3
  45. package/src/i18n/i18nUtil.ts +7 -4
  46. package/src/i18n/index.ts +2 -2
  47. package/src/i18n/selectors.ts +67 -0
  48. package/src/index.ts +1 -2
  49. package/src/{util → mappers}/cell.ts +19 -15
  50. package/src/{util → mappers}/combinators.ts +3 -2
  51. package/src/mappers/index.ts +29 -0
  52. package/src/{util → mappers}/renderer.ts +139 -33
  53. package/src/mappers/util.ts +43 -0
  54. package/src/models/uischema.ts +0 -29
  55. package/src/reducers/cells.ts +1 -7
  56. package/src/reducers/config.ts +1 -1
  57. package/src/reducers/core.ts +33 -200
  58. package/src/reducers/default-data.ts +8 -2
  59. package/src/reducers/i18n.ts +3 -27
  60. package/src/reducers/index.ts +0 -1
  61. package/src/reducers/middleware.ts +1 -1
  62. package/src/reducers/reducers.ts +3 -31
  63. package/src/reducers/renderers.ts +2 -7
  64. package/src/reducers/uischemas.ts +2 -12
  65. package/src/{util/array.ts → store/index.ts} +5 -19
  66. package/src/store/jsonFormsCore.ts +72 -0
  67. package/src/{store.ts → store/store.ts} +36 -8
  68. package/src/testers/testers.ts +6 -0
  69. package/src/util/errors.ts +142 -0
  70. package/src/{Helpers.ts → util/helpers.ts} +3 -2
  71. package/src/util/index.ts +2 -5
  72. package/src/util/label.ts +1 -98
  73. package/src/util/path.ts +12 -15
  74. package/src/util/runtime.ts +1 -44
  75. package/src/util/schema.ts +1 -1
  76. package/src/util/uischema.ts +52 -16
  77. package/src/util/util.ts +1 -9
  78. package/src/util/validator.ts +15 -1
  79. package/lib/reducers/selectors.d.ts +0 -15
  80. package/lib/util/array.d.ts +0 -3
  81. package/src/reducers/selectors.ts +0 -64
  82. /package/lib/{i18n → store}/i18nTypes.d.ts +0 -0
  83. /package/lib/{util → store}/type.d.ts +0 -0
  84. /package/src/{i18n → store}/i18nTypes.ts +0 -0
  85. /package/src/{util → store}/type.ts +0 -0
@@ -5,56 +5,55 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var isEmpty = require('lodash/isEmpty');
6
6
  var startCase = require('lodash/startCase');
7
7
  var keys = require('lodash/keys');
8
+ var range = require('lodash/range');
9
+ var get = require('lodash/get');
10
+ var has = require('lodash/has');
11
+ var find = require('lodash/find');
12
+ var isArray = require('lodash/isArray');
13
+ var includes = require('lodash/includes');
14
+ var Ajv = require('ajv');
15
+ var addFormats = require('ajv-formats');
16
+ var filter = require('lodash/filter');
17
+ var isEqual = require('lodash/isEqual');
8
18
  var merge = require('lodash/merge');
9
19
  var cloneDeep = require('lodash/cloneDeep');
10
20
  var setFp = require('lodash/fp/set');
11
21
  var unsetFp = require('lodash/fp/unset');
12
- var get = require('lodash/get');
13
- var filter = require('lodash/filter');
14
- var isEqual = require('lodash/isEqual');
15
- var isFunction = require('lodash/isFunction');
22
+ var lodash = require('lodash');
16
23
  var maxBy = require('lodash/maxBy');
17
24
  var remove = require('lodash/remove');
18
25
  var endsWith = require('lodash/endsWith');
19
26
  var last = require('lodash/last');
20
- var isArray = require('lodash/isArray');
21
27
  var reduce = require('lodash/reduce');
22
28
  var toPairs = require('lodash/toPairs');
23
- var includes = require('lodash/includes');
24
29
  var isUndefined = require('lodash/isUndefined');
25
- var find = require('lodash/find');
26
- var range = require('lodash/range');
27
- var has = require('lodash/has');
28
- var Ajv = require('ajv');
29
- var addFormats = require('ajv-formats');
30
30
 
31
31
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
32
32
 
33
33
  var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
34
34
  var startCase__default = /*#__PURE__*/_interopDefaultLegacy(startCase);
35
35
  var keys__default = /*#__PURE__*/_interopDefaultLegacy(keys);
36
+ var range__default = /*#__PURE__*/_interopDefaultLegacy(range);
37
+ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
38
+ var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
39
+ var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
40
+ var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
41
+ var includes__default = /*#__PURE__*/_interopDefaultLegacy(includes);
42
+ var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
43
+ var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);
44
+ var filter__default = /*#__PURE__*/_interopDefaultLegacy(filter);
45
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
36
46
  var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
37
47
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
38
48
  var setFp__default = /*#__PURE__*/_interopDefaultLegacy(setFp);
39
49
  var unsetFp__default = /*#__PURE__*/_interopDefaultLegacy(unsetFp);
40
- var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
41
- var filter__default = /*#__PURE__*/_interopDefaultLegacy(filter);
42
- var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
43
- var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);
44
50
  var maxBy__default = /*#__PURE__*/_interopDefaultLegacy(maxBy);
45
51
  var remove__default = /*#__PURE__*/_interopDefaultLegacy(remove);
46
52
  var endsWith__default = /*#__PURE__*/_interopDefaultLegacy(endsWith);
47
53
  var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
48
- var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
49
54
  var reduce__default = /*#__PURE__*/_interopDefaultLegacy(reduce);
50
55
  var toPairs__default = /*#__PURE__*/_interopDefaultLegacy(toPairs);
51
- var includes__default = /*#__PURE__*/_interopDefaultLegacy(includes);
52
56
  var isUndefined__default = /*#__PURE__*/_interopDefaultLegacy(isUndefined);
53
- var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
54
- var range__default = /*#__PURE__*/_interopDefaultLegacy(range);
55
- var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
56
- var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
57
- var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);
58
57
 
59
58
  var ADDITIONAL_PROPERTIES = 'additionalProperties';
60
59
  var REQUIRED_PROPERTIES = 'required';
@@ -179,199 +178,105 @@ instance, options) {
179
178
  return gen.schemaObject(instance);
180
179
  };
181
180
 
182
- var Draft4 = {
183
- id: 'http://json-schema.org/draft-04/schema#',
184
- $schema: 'http://json-schema.org/draft-04/schema#',
185
- description: 'Core schema meta-schema',
186
- definitions: {
187
- schemaArray: {
188
- type: 'array',
189
- minItems: 1,
190
- items: { $ref: '#' },
191
- },
192
- positiveInteger: {
193
- type: 'integer',
194
- minimum: 0,
195
- },
196
- positiveIntegerDefault0: {
197
- allOf: [{ $ref: '#/definitions/positiveInteger' }, { default: 0 }],
198
- },
199
- simpleTypes: {
200
- enum: [
201
- 'array',
202
- 'boolean',
203
- 'integer',
204
- 'null',
205
- 'number',
206
- 'object',
207
- 'string',
208
- ],
209
- },
210
- stringArray: {
211
- type: 'array',
212
- items: { type: 'string' },
213
- minItems: 1,
214
- uniqueItems: true,
215
- },
216
- },
217
- type: 'object',
218
- properties: {
219
- id: {
220
- type: 'string',
221
- format: 'uri',
222
- },
223
- $schema: {
224
- type: 'string',
225
- format: 'uri',
226
- },
227
- title: {
228
- type: 'string',
229
- },
230
- description: {
231
- type: 'string',
232
- },
233
- default: {},
234
- multipleOf: {
235
- type: 'number',
236
- minimum: 0,
237
- exclusiveMinimum: true,
238
- },
239
- maximum: {
240
- type: 'number',
241
- },
242
- exclusiveMaximum: {
243
- type: 'boolean',
244
- default: false,
245
- },
246
- minimum: {
247
- type: 'number',
248
- },
249
- exclusiveMinimum: {
250
- type: 'boolean',
251
- default: false,
252
- },
253
- maxLength: { $ref: '#/definitions/positiveInteger' },
254
- minLength: { $ref: '#/definitions/positiveIntegerDefault0' },
255
- pattern: {
256
- type: 'string',
257
- format: 'regex',
258
- },
259
- additionalItems: {
260
- anyOf: [{ type: 'boolean' }, { $ref: '#' }],
261
- default: {},
262
- },
263
- items: {
264
- anyOf: [{ $ref: '#' }, { $ref: '#/definitions/schemaArray' }],
265
- default: {},
266
- },
267
- maxItems: { $ref: '#/definitions/positiveInteger' },
268
- minItems: { $ref: '#/definitions/positiveIntegerDefault0' },
269
- uniqueItems: {
270
- type: 'boolean',
271
- default: false,
272
- },
273
- maxProperties: { $ref: '#/definitions/positiveInteger' },
274
- minProperties: { $ref: '#/definitions/positiveIntegerDefault0' },
275
- required: { $ref: '#/definitions/stringArray' },
276
- additionalProperties: {
277
- anyOf: [{ type: 'boolean' }, { $ref: '#' }],
278
- default: {},
279
- },
280
- definitions: {
281
- type: 'object',
282
- additionalProperties: { $ref: '#' },
283
- default: {},
284
- },
285
- properties: {
286
- type: 'object',
287
- additionalProperties: { $ref: '#' },
288
- default: {},
289
- },
290
- patternProperties: {
291
- type: 'object',
292
- additionalProperties: { $ref: '#' },
293
- default: {},
294
- },
295
- dependencies: {
296
- type: 'object',
297
- additionalProperties: {
298
- anyOf: [{ $ref: '#' }, { $ref: '#/definitions/stringArray' }],
299
- },
300
- },
301
- enum: {
302
- type: 'array',
303
- minItems: 1,
304
- uniqueItems: true,
305
- },
306
- type: {
307
- anyOf: [
308
- { $ref: '#/definitions/simpleTypes' },
309
- {
310
- type: 'array',
311
- items: { $ref: '#/definitions/simpleTypes' },
312
- minItems: 1,
313
- uniqueItems: true,
314
- },
315
- ],
316
- },
317
- allOf: { $ref: '#/definitions/schemaArray' },
318
- anyOf: { $ref: '#/definitions/schemaArray' },
319
- oneOf: { $ref: '#/definitions/schemaArray' },
320
- not: { $ref: '#' },
321
- },
322
- dependencies: {
323
- exclusiveMaximum: ['maximum'],
324
- exclusiveMinimum: ['minimum'],
325
- },
326
- default: {},
181
+ var usedIds = new Set();
182
+ var makeId = function (idBase, iteration) {
183
+ return iteration <= 1 ? idBase : idBase + iteration.toString();
327
184
  };
328
-
329
- exports.RuleEffect = void 0;
330
- (function (RuleEffect) {
331
- RuleEffect["HIDE"] = "HIDE";
332
- RuleEffect["SHOW"] = "SHOW";
333
- RuleEffect["ENABLE"] = "ENABLE";
334
- RuleEffect["DISABLE"] = "DISABLE";
335
- })(exports.RuleEffect || (exports.RuleEffect = {}));
336
- var isInternationalized = function (element) {
337
- return typeof element === 'object' &&
338
- element !== null &&
339
- typeof element.i18n === 'string';
185
+ var isUniqueId = function (idBase, iteration) {
186
+ var newID = makeId(idBase, iteration);
187
+ return !usedIds.has(newID);
340
188
  };
341
- var isGroup = function (layout) {
342
- return layout.type === 'Group';
189
+ var createId = function (proposedId) {
190
+ if (proposedId === undefined) {
191
+ proposedId = 'undefined';
192
+ }
193
+ var tries = 0;
194
+ while (!isUniqueId(proposedId, tries)) {
195
+ tries++;
196
+ }
197
+ var newID = makeId(proposedId, tries);
198
+ usedIds.add(newID);
199
+ return newID;
343
200
  };
344
- var isLayout = function (uischema) {
345
- return uischema.elements !== undefined;
201
+ var removeId = function (id) { return usedIds.delete(id); };
202
+ var clearAllIds = function () { return usedIds.clear(); };
203
+
204
+ var compose = function (path1, path2) {
205
+ var p1 = path1;
206
+ if (!isEmpty__default["default"](path1) && !isEmpty__default["default"](path2) && !path2.startsWith('[')) {
207
+ p1 = path1 + '.';
208
+ }
209
+ if (isEmpty__default["default"](p1)) {
210
+ return path2;
211
+ }
212
+ else if (isEmpty__default["default"](path2)) {
213
+ return p1;
214
+ }
215
+ else {
216
+ return "".concat(p1).concat(path2);
217
+ }
346
218
  };
347
- var isScopable = function (obj) {
348
- return !!obj && typeof obj === 'object';
219
+ var toDataPathSegments = function (schemaPath) {
220
+ var s = schemaPath
221
+ .replace(/(anyOf|allOf|oneOf)\/[\d]+\//g, '')
222
+ .replace(/(then|else)\//g, '');
223
+ var segments = s.split('/');
224
+ var decodedSegments = segments.map(decode);
225
+ var startFromRoot = decodedSegments[0] === '#' || decodedSegments[0] === '';
226
+ var startIndex = startFromRoot ? 2 : 1;
227
+ return range__default["default"](startIndex, decodedSegments.length, 2).map(function (idx) { return decodedSegments[idx]; });
349
228
  };
350
- var isScoped = function (obj) {
351
- return isScopable(obj) && typeof obj.scope === 'string';
229
+ var toDataPath = function (schemaPath) {
230
+ return toDataPathSegments(schemaPath).join('.');
352
231
  };
353
- var isLabelable = function (obj) {
354
- return !!obj && typeof obj === 'object';
232
+ var encode = function (segment) {
233
+ return segment === null || segment === void 0 ? void 0 : segment.replace(/~/g, '~0').replace(/\//g, '~1');
355
234
  };
356
- var isLabeled = function (obj) {
357
- return isLabelable(obj) && ['string', 'boolean'].includes(typeof obj.label);
235
+ var decode = function (pointerSegment) {
236
+ return pointerSegment === null || pointerSegment === void 0 ? void 0 : pointerSegment.replace(/~1/g, '/').replace(/~0/, '~');
237
+ };
238
+ var getPropPath = function (path) {
239
+ return "/properties/".concat(path
240
+ .split('.')
241
+ .map(function (p) { return encode(p); })
242
+ .join('/properties/'));
358
243
  };
359
- var isControlElement = function (uiSchema) { return uiSchema.type === 'Control'; };
360
244
 
361
- var move = function (array, index, delta) {
362
- var newIndex = index + delta;
363
- if (newIndex < 0 || newIndex >= array.length) {
364
- return;
245
+ var deriveLabel = function (controlElement, schemaElement) {
246
+ if (schemaElement && typeof schemaElement.title === 'string') {
247
+ return schemaElement.title;
365
248
  }
366
- var indexes = [index, newIndex].sort(function (a, b) { return a - b; });
367
- array.splice(indexes[0], 2, array[indexes[1]], array[indexes[0]]);
249
+ if (typeof controlElement.scope === 'string') {
250
+ var ref = controlElement.scope;
251
+ var label = decode(ref.substr(ref.lastIndexOf('/') + 1));
252
+ return startCase__default["default"](label);
253
+ }
254
+ return '';
368
255
  };
369
- var moveUp = function (array, toMove) {
370
- move(array, toMove, -1);
256
+ var createCleanLabel = function (label) {
257
+ return startCase__default["default"](label.replace('_', ' '));
371
258
  };
372
- var moveDown = function (array, toMove) {
373
- move(array, toMove, 1);
259
+ var createLabelDescriptionFrom = function (withLabel, schema) {
260
+ var labelProperty = withLabel.label;
261
+ if (typeof labelProperty === 'boolean') {
262
+ return labelDescription(deriveLabel(withLabel, schema), labelProperty);
263
+ }
264
+ if (typeof labelProperty === 'string') {
265
+ return labelDescription(labelProperty, true);
266
+ }
267
+ if (typeof labelProperty === 'object') {
268
+ var label = typeof labelProperty.text === 'string'
269
+ ? labelProperty.text
270
+ : deriveLabel(withLabel, schema);
271
+ var show = typeof labelProperty.show === 'boolean' ? labelProperty.show : true;
272
+ return labelDescription(label, show);
273
+ }
274
+ return labelDescription(deriveLabel(withLabel, schema), true);
374
275
  };
276
+ var labelDescription = function (text, show) { return ({
277
+ text: text,
278
+ show: show,
279
+ }); };
375
280
 
376
281
  /******************************************************************************
377
282
  Copyright (c) Microsoft Corporation.
@@ -426,213 +331,543 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
426
331
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
427
332
  };
428
333
 
429
- var cellReducer = function (state, _a) {
430
- if (state === void 0) { state = []; }
431
- var type = _a.type, tester = _a.tester, cell = _a.cell;
432
- switch (type) {
433
- case ADD_CELL:
434
- return state.concat([{ tester: tester, cell: cell }]);
435
- case REMOVE_CELL:
436
- return state.filter(function (t) { return t.tester !== tester; });
437
- default:
438
- return state;
439
- }
440
- };
441
-
442
- var configDefault = {
443
- restrict: false,
444
- trim: false,
445
- showUnfocusedDescription: false,
446
- hideRequiredAsterisk: false,
334
+ var isObjectSchema$1 = function (schema) {
335
+ return schema.properties !== undefined;
447
336
  };
448
-
449
- var applyDefaultConfiguration = function (config) {
450
- if (config === void 0) { config = {}; }
451
- return merge__default["default"]({}, configDefault, config);
337
+ var isArraySchema = function (schema) {
338
+ return schema.type === 'array' && schema.items !== undefined;
452
339
  };
453
- var configReducer = function (state, action) {
454
- if (state === void 0) { state = applyDefaultConfiguration(); }
455
- switch (action.type) {
456
- case SET_CONFIG:
457
- return applyDefaultConfiguration(action.config);
458
- default:
459
- return state;
340
+ var resolveData = function (instance, dataPath) {
341
+ if (isEmpty__default["default"](dataPath)) {
342
+ return instance;
460
343
  }
344
+ var dataPathSegments = dataPath.split('.');
345
+ return dataPathSegments.reduce(function (curInstance, decodedSegment) {
346
+ if (!curInstance ||
347
+ !Object.prototype.hasOwnProperty.call(curInstance, decodedSegment)) {
348
+ return undefined;
349
+ }
350
+ return curInstance[decodedSegment];
351
+ }, instance);
461
352
  };
462
-
463
- var validate = function (validator, data) {
464
- if (validator === undefined) {
465
- return [];
466
- }
467
- var valid = validator(data);
468
- if (valid) {
469
- return [];
353
+ var findAllRefs = function (schema, result, resolveTuples) {
354
+ if (result === void 0) { result = {}; }
355
+ if (resolveTuples === void 0) { resolveTuples = false; }
356
+ if (isObjectSchema$1(schema)) {
357
+ Object.keys(schema.properties).forEach(function (key) {
358
+ return findAllRefs(schema.properties[key], result);
359
+ });
470
360
  }
471
- return validator.errors;
472
- };
473
- var initState = {
474
- data: {},
475
- schema: {},
476
- uischema: undefined,
477
- errors: [],
478
- validator: undefined,
479
- ajv: undefined,
480
- validationMode: 'ValidateAndShow',
481
- additionalErrors: [],
482
- };
483
- var getOrCreateAjv = function (state, action) {
484
- if (action) {
485
- if (hasAjvOption(action.options)) {
486
- return action.options.ajv;
487
- }
488
- else if (action.options !== undefined) {
489
- if (isFunction__default["default"](action.options.compile)) {
490
- return action.options;
361
+ if (isArraySchema(schema)) {
362
+ if (Array.isArray(schema.items)) {
363
+ if (resolveTuples) {
364
+ var items = schema.items;
365
+ items.forEach(function (child) { return findAllRefs(child, result); });
491
366
  }
492
367
  }
368
+ else {
369
+ findAllRefs(schema.items, result);
370
+ }
493
371
  }
494
- return state.ajv ? state.ajv : createAjv();
495
- };
496
- var hasAjvOption = function (option) {
497
- if (option) {
498
- return option.ajv !== undefined;
372
+ if (Array.isArray(schema.anyOf)) {
373
+ var anyOf = schema.anyOf;
374
+ anyOf.forEach(function (child) { return findAllRefs(child, result); });
499
375
  }
500
- return false;
501
- };
502
- var getValidationMode = function (state, action) {
503
- if (action && hasValidationModeOption(action.options)) {
504
- return action.options.validationMode;
376
+ if (schema.$ref !== undefined) {
377
+ result[schema.$ref] = schema;
505
378
  }
506
- return state.validationMode;
379
+ return result;
507
380
  };
508
- var hasValidationModeOption = function (option) {
509
- if (option) {
510
- return option.validationMode !== undefined;
511
- }
512
- return false;
381
+ var invalidSegment = function (pathSegment) {
382
+ return pathSegment === '#' || pathSegment === undefined || pathSegment === '';
513
383
  };
514
- var hasAdditionalErrorsOption = function (option) {
515
- if (option) {
516
- return option.additionalErrors !== undefined;
517
- }
518
- return false;
384
+ var resolveSchema = function (schema, schemaPath, rootSchema) {
385
+ var segments = schemaPath === null || schemaPath === void 0 ? void 0 : schemaPath.split('/').map(decode);
386
+ return resolveSchemaWithSegments(schema, segments, rootSchema);
519
387
  };
520
- var getAdditionalErrors = function (state, action) {
521
- if (action && hasAdditionalErrorsOption(action.options)) {
522
- return action.options.additionalErrors;
388
+ var resolveSchemaWithSegments = function (schema, pathSegments, rootSchema) {
389
+ var _a, _b, _c, _d, _e;
390
+ if (isEmpty__default["default"](schema)) {
391
+ return undefined;
523
392
  }
524
- return state.additionalErrors;
525
- };
526
- var coreReducer = function (state, action) {
527
- if (state === void 0) { state = initState; }
528
- switch (action.type) {
529
- case INIT: {
530
- var thisAjv = getOrCreateAjv(state, action);
531
- var validationMode = getValidationMode(state, action);
532
- var v = validationMode === 'NoValidation'
533
- ? undefined
534
- : thisAjv.compile(action.schema);
535
- var e = validate(v, action.data);
536
- var additionalErrors = getAdditionalErrors(state, action);
537
- return __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, additionalErrors: additionalErrors, errors: e, validator: v, ajv: thisAjv, validationMode: validationMode });
538
- }
539
- case UPDATE_CORE: {
540
- var thisAjv = getOrCreateAjv(state, action);
541
- var validationMode = getValidationMode(state, action);
542
- var validator = state.validator;
543
- var errors = state.errors;
544
- if (state.schema !== action.schema ||
545
- state.validationMode !== validationMode ||
546
- state.ajv !== thisAjv) {
547
- validator =
548
- validationMode === 'NoValidation'
549
- ? undefined
550
- : thisAjv.compile(action.schema);
551
- errors = validate(validator, action.data);
552
- }
553
- else if (state.data !== action.data) {
554
- errors = validate(validator, action.data);
393
+ if (schema.$ref) {
394
+ schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
395
+ }
396
+ if (!pathSegments || pathSegments.length === 0) {
397
+ return schema;
398
+ }
399
+ var segment = pathSegments[0], remainingSegments = pathSegments.slice(1);
400
+ if (invalidSegment(segment)) {
401
+ return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
402
+ }
403
+ var singleSegmentResolveSchema = get__default["default"](schema, segment);
404
+ var resolvedSchema = resolveSchemaWithSegments(singleSegmentResolveSchema, remainingSegments, rootSchema);
405
+ if (resolvedSchema) {
406
+ return resolvedSchema;
407
+ }
408
+ if (segment === 'properties' || segment === 'items') {
409
+ var alternativeResolveResult = undefined;
410
+ var subSchemas = [].concat((_a = schema.oneOf) !== null && _a !== void 0 ? _a : [], (_b = schema.allOf) !== null && _b !== void 0 ? _b : [], (_c = schema.anyOf) !== null && _c !== void 0 ? _c : [], (_d = schema.then) !== null && _d !== void 0 ? _d : [], (_e = schema.else) !== null && _e !== void 0 ? _e : []);
411
+ for (var _i = 0, subSchemas_1 = subSchemas; _i < subSchemas_1.length; _i++) {
412
+ var subSchema = subSchemas_1[_i];
413
+ alternativeResolveResult = resolveSchemaWithSegments(subSchema, __spreadArray([segment], remainingSegments, true), rootSchema);
414
+ if (alternativeResolveResult) {
415
+ break;
555
416
  }
556
- var additionalErrors = getAdditionalErrors(state, action);
557
- var stateChanged = state.data !== action.data ||
558
- state.schema !== action.schema ||
559
- state.uischema !== action.uischema ||
560
- state.ajv !== thisAjv ||
561
- state.errors !== errors ||
562
- state.validator !== validator ||
563
- state.validationMode !== validationMode ||
564
- state.additionalErrors !== additionalErrors;
565
- return stateChanged
566
- ? __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, ajv: thisAjv, errors: isEqual__default["default"](errors, state.errors) ? state.errors : errors, validator: validator, validationMode: validationMode, additionalErrors: additionalErrors }) : state;
567
- }
568
- case SET_AJV: {
569
- var currentAjv = action.ajv;
570
- var validator = state.validationMode === 'NoValidation'
571
- ? undefined
572
- : currentAjv.compile(state.schema);
573
- var errors = validate(validator, state.data);
574
- return __assign(__assign({}, state), { validator: validator, errors: errors });
575
- }
576
- case SET_SCHEMA: {
577
- var needsNewValidator = action.schema && state.ajv && state.validationMode !== 'NoValidation';
578
- var v = needsNewValidator
579
- ? state.ajv.compile(action.schema)
580
- : state.validator;
581
- var errors = validate(v, state.data);
582
- return __assign(__assign({}, state), { validator: v, schema: action.schema, errors: errors });
583
417
  }
584
- case SET_UISCHEMA: {
585
- return __assign(__assign({}, state), { uischema: action.uischema });
418
+ return alternativeResolveResult;
419
+ }
420
+ return undefined;
421
+ };
422
+
423
+ var Draft4 = {
424
+ id: 'http://json-schema.org/draft-04/schema#',
425
+ $schema: 'http://json-schema.org/draft-04/schema#',
426
+ description: 'Core schema meta-schema',
427
+ definitions: {
428
+ schemaArray: {
429
+ type: 'array',
430
+ minItems: 1,
431
+ items: { $ref: '#' },
432
+ },
433
+ positiveInteger: {
434
+ type: 'integer',
435
+ minimum: 0,
436
+ },
437
+ positiveIntegerDefault0: {
438
+ allOf: [{ $ref: '#/definitions/positiveInteger' }, { default: 0 }],
439
+ },
440
+ simpleTypes: {
441
+ enum: [
442
+ 'array',
443
+ 'boolean',
444
+ 'integer',
445
+ 'null',
446
+ 'number',
447
+ 'object',
448
+ 'string',
449
+ ],
450
+ },
451
+ stringArray: {
452
+ type: 'array',
453
+ items: { type: 'string' },
454
+ minItems: 1,
455
+ uniqueItems: true,
456
+ },
457
+ },
458
+ type: 'object',
459
+ properties: {
460
+ id: {
461
+ type: 'string',
462
+ format: 'uri',
463
+ },
464
+ $schema: {
465
+ type: 'string',
466
+ format: 'uri',
467
+ },
468
+ title: {
469
+ type: 'string',
470
+ },
471
+ description: {
472
+ type: 'string',
473
+ },
474
+ default: {},
475
+ multipleOf: {
476
+ type: 'number',
477
+ minimum: 0,
478
+ exclusiveMinimum: true,
479
+ },
480
+ maximum: {
481
+ type: 'number',
482
+ },
483
+ exclusiveMaximum: {
484
+ type: 'boolean',
485
+ default: false,
486
+ },
487
+ minimum: {
488
+ type: 'number',
489
+ },
490
+ exclusiveMinimum: {
491
+ type: 'boolean',
492
+ default: false,
493
+ },
494
+ maxLength: { $ref: '#/definitions/positiveInteger' },
495
+ minLength: { $ref: '#/definitions/positiveIntegerDefault0' },
496
+ pattern: {
497
+ type: 'string',
498
+ format: 'regex',
499
+ },
500
+ additionalItems: {
501
+ anyOf: [{ type: 'boolean' }, { $ref: '#' }],
502
+ default: {},
503
+ },
504
+ items: {
505
+ anyOf: [{ $ref: '#' }, { $ref: '#/definitions/schemaArray' }],
506
+ default: {},
507
+ },
508
+ maxItems: { $ref: '#/definitions/positiveInteger' },
509
+ minItems: { $ref: '#/definitions/positiveIntegerDefault0' },
510
+ uniqueItems: {
511
+ type: 'boolean',
512
+ default: false,
513
+ },
514
+ maxProperties: { $ref: '#/definitions/positiveInteger' },
515
+ minProperties: { $ref: '#/definitions/positiveIntegerDefault0' },
516
+ required: { $ref: '#/definitions/stringArray' },
517
+ additionalProperties: {
518
+ anyOf: [{ type: 'boolean' }, { $ref: '#' }],
519
+ default: {},
520
+ },
521
+ definitions: {
522
+ type: 'object',
523
+ additionalProperties: { $ref: '#' },
524
+ default: {},
525
+ },
526
+ properties: {
527
+ type: 'object',
528
+ additionalProperties: { $ref: '#' },
529
+ default: {},
530
+ },
531
+ patternProperties: {
532
+ type: 'object',
533
+ additionalProperties: { $ref: '#' },
534
+ default: {},
535
+ },
536
+ dependencies: {
537
+ type: 'object',
538
+ additionalProperties: {
539
+ anyOf: [{ $ref: '#' }, { $ref: '#/definitions/stringArray' }],
540
+ },
541
+ },
542
+ enum: {
543
+ type: 'array',
544
+ minItems: 1,
545
+ uniqueItems: true,
546
+ },
547
+ type: {
548
+ anyOf: [
549
+ { $ref: '#/definitions/simpleTypes' },
550
+ {
551
+ type: 'array',
552
+ items: { $ref: '#/definitions/simpleTypes' },
553
+ minItems: 1,
554
+ uniqueItems: true,
555
+ },
556
+ ],
557
+ },
558
+ allOf: { $ref: '#/definitions/schemaArray' },
559
+ anyOf: { $ref: '#/definitions/schemaArray' },
560
+ oneOf: { $ref: '#/definitions/schemaArray' },
561
+ not: { $ref: '#' },
562
+ },
563
+ dependencies: {
564
+ exclusiveMaximum: ['maximum'],
565
+ exclusiveMinimum: ['minimum'],
566
+ },
567
+ default: {},
568
+ };
569
+
570
+ exports.RuleEffect = void 0;
571
+ (function (RuleEffect) {
572
+ RuleEffect["HIDE"] = "HIDE";
573
+ RuleEffect["SHOW"] = "SHOW";
574
+ RuleEffect["ENABLE"] = "ENABLE";
575
+ RuleEffect["DISABLE"] = "DISABLE";
576
+ })(exports.RuleEffect || (exports.RuleEffect = {}));
577
+
578
+ var setReadonlyPropertyValue = function (value) {
579
+ return function (child) {
580
+ if (!child.options) {
581
+ child.options = {};
586
582
  }
587
- case UPDATE_DATA: {
588
- if (action.path === undefined || action.path === null) {
589
- return state;
590
- }
591
- else if (action.path === '') {
592
- var result = action.updater(cloneDeep__default["default"](state.data));
593
- var errors = validate(state.validator, result);
594
- return __assign(__assign({}, state), { data: result, errors: errors });
595
- }
596
- else {
597
- var oldData = get__default["default"](state.data, action.path);
598
- var newData = action.updater(cloneDeep__default["default"](oldData));
599
- var newState = void 0;
600
- if (newData !== undefined) {
601
- newState = setFp__default["default"](action.path, newData, state.data === undefined ? {} : state.data);
602
- }
603
- else {
604
- newState = unsetFp__default["default"](action.path, state.data === undefined ? {} : state.data);
605
- }
606
- var errors = validate(state.validator, newState);
607
- return __assign(__assign({}, state), { data: newState, errors: errors });
608
- }
583
+ child.options.readonly = value;
584
+ };
585
+ };
586
+ var setReadonly = function (uischema) {
587
+ iterateSchema(uischema, setReadonlyPropertyValue(true));
588
+ };
589
+ var unsetReadonly = function (uischema) {
590
+ iterateSchema(uischema, setReadonlyPropertyValue(false));
591
+ };
592
+ var iterateSchema = function (uischema, toApply) {
593
+ if (isEmpty__default["default"](uischema)) {
594
+ return;
595
+ }
596
+ if (isLayout(uischema)) {
597
+ uischema.elements.forEach(function (child) { return iterateSchema(child, toApply); });
598
+ return;
599
+ }
600
+ toApply(uischema);
601
+ };
602
+ var findUiControl = function (uiSchema, path) {
603
+ var _a;
604
+ if (isControlElement(uiSchema)) {
605
+ if (isScoped(uiSchema) && uiSchema.scope.endsWith(getPropPath(path))) {
606
+ return uiSchema;
609
607
  }
610
- case UPDATE_ERRORS: {
611
- return __assign(__assign({}, state), { errors: action.errors });
608
+ else if ((_a = uiSchema.options) === null || _a === void 0 ? void 0 : _a.detail) {
609
+ return findUiControl(uiSchema.options.detail, path);
612
610
  }
613
- case SET_VALIDATION_MODE: {
614
- if (state.validationMode === action.validationMode) {
615
- return state;
616
- }
617
- if (action.validationMode === 'NoValidation') {
618
- var errors = validate(undefined, state.data);
619
- return __assign(__assign({}, state), { errors: errors, validationMode: action.validationMode });
611
+ }
612
+ if (isLayout(uiSchema)) {
613
+ for (var _i = 0, _b = uiSchema.elements; _i < _b.length; _i++) {
614
+ var elem = _b[_i];
615
+ var result = findUiControl(elem, path);
616
+ if (result !== undefined)
617
+ return result;
618
+ }
619
+ }
620
+ return undefined;
621
+ };
622
+ var composeWithUi = function (scopableUi, path) {
623
+ if (!isScoped(scopableUi)) {
624
+ return path !== null && path !== void 0 ? path : '';
625
+ }
626
+ var segments = toDataPathSegments(scopableUi.scope);
627
+ if (isEmpty__default["default"](segments)) {
628
+ return path !== null && path !== void 0 ? path : '';
629
+ }
630
+ return compose(path, segments.join('.'));
631
+ };
632
+ var isInternationalized = function (element) {
633
+ return typeof element === 'object' &&
634
+ element !== null &&
635
+ typeof element.i18n === 'string';
636
+ };
637
+ var isGroup = function (layout) {
638
+ return layout.type === 'Group';
639
+ };
640
+ var isLayout = function (uischema) {
641
+ return uischema.elements !== undefined;
642
+ };
643
+ var isScopable = function (obj) {
644
+ return !!obj && typeof obj === 'object';
645
+ };
646
+ var isScoped = function (obj) {
647
+ return isScopable(obj) && typeof obj.scope === 'string';
648
+ };
649
+ var isLabelable = function (obj) {
650
+ return !!obj && typeof obj === 'object';
651
+ };
652
+ var isLabeled = function (obj) {
653
+ return isLabelable(obj) && ['string', 'boolean'].includes(typeof obj.label);
654
+ };
655
+ var isControlElement = function (uiSchema) { return uiSchema.type === 'Control'; };
656
+
657
+ var isOrCondition = function (condition) {
658
+ return condition.type === 'OR';
659
+ };
660
+ var isAndCondition = function (condition) {
661
+ return condition.type === 'AND';
662
+ };
663
+ var isLeafCondition = function (condition) {
664
+ return condition.type === 'LEAF';
665
+ };
666
+ var isSchemaCondition = function (condition) { return has__default["default"](condition, 'schema'); };
667
+ var getConditionScope = function (condition, path) {
668
+ return composeWithUi(condition, path);
669
+ };
670
+ var evaluateCondition = function (data, condition, path, ajv) {
671
+ if (isAndCondition(condition)) {
672
+ return condition.conditions.reduce(function (acc, cur) { return acc && evaluateCondition(data, cur, path, ajv); }, true);
673
+ }
674
+ else if (isOrCondition(condition)) {
675
+ return condition.conditions.reduce(function (acc, cur) { return acc || evaluateCondition(data, cur, path, ajv); }, false);
676
+ }
677
+ else if (isLeafCondition(condition)) {
678
+ var value = resolveData(data, getConditionScope(condition, path));
679
+ return value === condition.expectedValue;
680
+ }
681
+ else if (isSchemaCondition(condition)) {
682
+ var value = resolveData(data, getConditionScope(condition, path));
683
+ if (condition.failWhenUndefined && value === undefined) {
684
+ return false;
685
+ }
686
+ return ajv.validate(condition.schema, value);
687
+ }
688
+ else {
689
+ return true;
690
+ }
691
+ };
692
+ var isRuleFulfilled = function (uischema, data, path, ajv) {
693
+ var condition = uischema.rule.condition;
694
+ return evaluateCondition(data, condition, path, ajv);
695
+ };
696
+ var evalVisibility = function (uischema, data, path, ajv) {
697
+ if (path === void 0) { path = undefined; }
698
+ var fulfilled = isRuleFulfilled(uischema, data, path, ajv);
699
+ switch (uischema.rule.effect) {
700
+ case exports.RuleEffect.HIDE:
701
+ return !fulfilled;
702
+ case exports.RuleEffect.SHOW:
703
+ return fulfilled;
704
+ default:
705
+ return true;
706
+ }
707
+ };
708
+ var evalEnablement = function (uischema, data, path, ajv) {
709
+ if (path === void 0) { path = undefined; }
710
+ var fulfilled = isRuleFulfilled(uischema, data, path, ajv);
711
+ switch (uischema.rule.effect) {
712
+ case exports.RuleEffect.DISABLE:
713
+ return !fulfilled;
714
+ case exports.RuleEffect.ENABLE:
715
+ return fulfilled;
716
+ default:
717
+ return true;
718
+ }
719
+ };
720
+ var hasShowRule = function (uischema) {
721
+ if (uischema.rule &&
722
+ (uischema.rule.effect === exports.RuleEffect.SHOW ||
723
+ uischema.rule.effect === exports.RuleEffect.HIDE)) {
724
+ return true;
725
+ }
726
+ return false;
727
+ };
728
+ var hasEnableRule = function (uischema) {
729
+ if (uischema.rule &&
730
+ (uischema.rule.effect === exports.RuleEffect.ENABLE ||
731
+ uischema.rule.effect === exports.RuleEffect.DISABLE)) {
732
+ return true;
733
+ }
734
+ return false;
735
+ };
736
+ var isVisible = function (uischema, data, path, ajv) {
737
+ if (path === void 0) { path = undefined; }
738
+ if (uischema.rule) {
739
+ return evalVisibility(uischema, data, path, ajv);
740
+ }
741
+ return true;
742
+ };
743
+ var isEnabled = function (uischema, data, path, ajv) {
744
+ if (path === void 0) { path = undefined; }
745
+ if (uischema.rule) {
746
+ return evalEnablement(uischema, data, path, ajv);
747
+ }
748
+ return true;
749
+ };
750
+
751
+ var getFirstPrimitiveProp = function (schema) {
752
+ if (schema.properties) {
753
+ return find__default["default"](Object.keys(schema.properties), function (propName) {
754
+ var prop = schema.properties[propName];
755
+ return (prop.type === 'string' ||
756
+ prop.type === 'number' ||
757
+ prop.type === 'integer');
758
+ });
759
+ }
760
+ return undefined;
761
+ };
762
+ var isOneOfEnumSchema = function (schema) {
763
+ return !!schema &&
764
+ Object.prototype.hasOwnProperty.call(schema, 'oneOf') &&
765
+ schema.oneOf &&
766
+ schema.oneOf.every(function (s) { return s.const !== undefined; });
767
+ };
768
+ var isEnumSchema = function (schema) {
769
+ return !!schema &&
770
+ typeof schema === 'object' &&
771
+ (Object.prototype.hasOwnProperty.call(schema, 'enum') ||
772
+ Object.prototype.hasOwnProperty.call(schema, 'const'));
773
+ };
774
+
775
+ var convertDateToString = function (date, format) {
776
+ var dateString = date.toISOString();
777
+ if (format === 'date-time') {
778
+ return dateString;
779
+ }
780
+ else if (format === 'date') {
781
+ return dateString.split('T')[0];
782
+ }
783
+ else if (format === 'time') {
784
+ return dateString.split('T')[1].split('.')[0];
785
+ }
786
+ return dateString;
787
+ };
788
+ var convertToValidClassName = function (s) {
789
+ return s.replace('#', 'root').replace(new RegExp('/', 'g'), '_');
790
+ };
791
+ var hasType = function (jsonSchema, expected) {
792
+ return includes__default["default"](deriveTypes(jsonSchema), expected);
793
+ };
794
+ var deriveTypes = function (jsonSchema) {
795
+ if (isEmpty__default["default"](jsonSchema)) {
796
+ return [];
797
+ }
798
+ if (!isEmpty__default["default"](jsonSchema.type) && typeof jsonSchema.type === 'string') {
799
+ return [jsonSchema.type];
800
+ }
801
+ if (isArray__default["default"](jsonSchema.type)) {
802
+ return jsonSchema.type;
803
+ }
804
+ if (!isEmpty__default["default"](jsonSchema.properties) ||
805
+ !isEmpty__default["default"](jsonSchema.additionalProperties)) {
806
+ return ['object'];
807
+ }
808
+ if (!isEmpty__default["default"](jsonSchema.items)) {
809
+ return ['array'];
810
+ }
811
+ if (!isEmpty__default["default"](jsonSchema.enum)) {
812
+ var types_1 = new Set();
813
+ jsonSchema.enum.forEach(function (enumElement) {
814
+ if (typeof enumElement === 'string') {
815
+ types_1.add('string');
620
816
  }
621
- if (state.validationMode === 'NoValidation') {
622
- var validator = state.ajv.compile(state.schema);
623
- var errors = validate(validator, state.data);
624
- return __assign(__assign({}, state), { validator: validator, errors: errors, validationMode: action.validationMode });
817
+ else {
818
+ deriveTypes(enumElement).forEach(function (type) { return types_1.add(type); });
625
819
  }
626
- return __assign(__assign({}, state), { validationMode: action.validationMode });
820
+ });
821
+ return Array.from(types_1);
822
+ }
823
+ if (!isEmpty__default["default"](jsonSchema.allOf)) {
824
+ var allOfType = find__default["default"](jsonSchema.allOf, function (schema) { return deriveTypes(schema).length !== 0; });
825
+ if (allOfType) {
826
+ return deriveTypes(allOfType);
627
827
  }
628
- default:
629
- return state;
630
828
  }
829
+ return [];
631
830
  };
632
- var extractData = function (state) { return get__default["default"](state, 'data'); };
633
- var extractSchema = function (state) { return get__default["default"](state, 'schema'); };
634
- var extractUiSchema = function (state) { return get__default["default"](state, 'uischema'); };
635
- var extractAjv = function (state) { return get__default["default"](state, 'ajv'); };
831
+ var Resolve = {
832
+ schema: resolveSchema,
833
+ data: resolveData,
834
+ };
835
+ var fromScoped = function (scopable) {
836
+ return toDataPathSegments(scopable.scope).join('.');
837
+ };
838
+ var Paths = {
839
+ compose: compose,
840
+ fromScoped: fromScoped,
841
+ };
842
+ var Runtime = {
843
+ isEnabled: function (uischema, data, ajv) {
844
+ return isEnabled(uischema, data, undefined, ajv);
845
+ },
846
+ isVisible: function (uischema, data, ajv) {
847
+ return isVisible(uischema, data, undefined, ajv);
848
+ },
849
+ };
850
+
851
+ var createAjv = function (options) {
852
+ var ajv = new Ajv__default["default"](__assign({ allErrors: true, verbose: true, strict: false, addUsedSchema: false }, options));
853
+ addFormats__default["default"](ajv);
854
+ return ajv;
855
+ };
856
+ var validate = function (validator, data) {
857
+ if (validator === undefined) {
858
+ return [];
859
+ }
860
+ var valid = validator(data);
861
+ if (valid) {
862
+ return [];
863
+ }
864
+ return validator.errors;
865
+ };
866
+
867
+ var defaultDateFormat = 'YYYY-MM-DD';
868
+ var defaultTimeFormat = 'HH:mm:ss';
869
+ var defaultDateTimeFormat = 'YYYY-MM-DDTHH:mm:ss.sssZ';
870
+
636
871
  var getInvalidProperty = function (error) {
637
872
  switch (error.keyword) {
638
873
  case 'required':
@@ -667,7 +902,7 @@ var errorsAt = function (instancePath, schema, matchPath) {
667
902
  var result = matchPath(controlPath);
668
903
  var parentSchema = error.parentSchema;
669
904
  if (result &&
670
- !isObjectSchema$1(parentSchema) &&
905
+ !isObjectSchema(parentSchema) &&
671
906
  !isOneOfEnumSchema(parentSchema) &&
672
907
  combinatorPaths.findIndex(function (p) { return instancePath.startsWith(p); }) !== -1) {
673
908
  result = result && isEqual__default["default"](parentSchema, schema);
@@ -676,7 +911,7 @@ var errorsAt = function (instancePath, schema, matchPath) {
676
911
  });
677
912
  };
678
913
  };
679
- var isObjectSchema$1 = function (schema) {
914
+ var isObjectSchema = function (schema) {
680
915
  return (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' || !!(schema === null || schema === void 0 ? void 0 : schema.properties);
681
916
  };
682
917
  var filteredErrorKeywords = [
@@ -685,651 +920,720 @@ var filteredErrorKeywords = [
685
920
  'anyOf',
686
921
  'oneOf',
687
922
  ];
688
- var getErrorsAt = function (instancePath, schema, matchPath) {
689
- return function (state) {
690
- var _a, _b;
691
- var errors = (_a = state.errors) !== null && _a !== void 0 ? _a : [];
692
- var additionalErrors = (_b = state.additionalErrors) !== null && _b !== void 0 ? _b : [];
693
- return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide'
694
- ? additionalErrors
695
- : __spreadArray(__spreadArray([], errors, true), additionalErrors, true));
696
- };
697
- };
698
- var errorAt = function (instancePath, schema) {
699
- return getErrorsAt(instancePath, schema, function (path) { return path === instancePath; });
700
- };
701
- var subErrorsAt = function (instancePath, schema) {
702
- return getErrorsAt(instancePath, schema, function (path) {
703
- return path.startsWith(instancePath + '.');
704
- });
923
+ var formatErrorMessage = function (errors) {
924
+ if (errors === undefined || errors === null) {
925
+ return '';
926
+ }
927
+ return errors.join('\n');
705
928
  };
706
929
 
707
- var defaultDataReducer = function (state, action) {
708
- if (state === void 0) { state = []; }
709
- switch (action.type) {
710
- case ADD_DEFAULT_DATA:
711
- return state.concat([
712
- { schemaPath: action.schemaPath, data: action.data },
713
- ]);
714
- case REMOVE_DEFAULT_DATA:
715
- return state.filter(function (t) { return t.schemaPath !== action.schemaPath; });
716
- default:
717
- return state;
718
- }
930
+ var Helpers = {
931
+ createLabelDescriptionFrom: createLabelDescriptionFrom,
932
+ convertToValidClassName: convertToValidClassName,
719
933
  };
720
- var extractDefaultData = function (state) { return state; };
721
934
 
722
- var getI18nKeyPrefixBySchema = function (schema, uischema) {
723
- var _a;
724
- if (isInternationalized(uischema)) {
725
- return uischema.i18n;
935
+ var createLayout = function (layoutType) { return ({
936
+ type: layoutType,
937
+ elements: [],
938
+ }); };
939
+ var createControlElement = function (ref) { return ({
940
+ type: 'Control',
941
+ scope: ref,
942
+ }); };
943
+ var wrapInLayoutIfNecessary = function (uischema, layoutType) {
944
+ if (!isEmpty__default["default"](uischema) && !isLayout(uischema)) {
945
+ var verticalLayout = createLayout(layoutType);
946
+ verticalLayout.elements.push(uischema);
947
+ return verticalLayout;
726
948
  }
727
- return (_a = schema === null || schema === void 0 ? void 0 : schema.i18n) !== null && _a !== void 0 ? _a : undefined;
728
- };
729
- var transformPathToI18nPrefix = function (path) {
730
- return ((path === null || path === void 0 ? void 0 : path.split('.').filter(function (segment) { return !/^\d+$/.test(segment); }).join('.')) || 'root');
731
- };
732
- var getI18nKeyPrefix = function (schema, uischema, path) {
733
- var _a;
734
- return ((_a = getI18nKeyPrefixBySchema(schema, uischema)) !== null && _a !== void 0 ? _a : transformPathToI18nPrefix(path));
949
+ return uischema;
735
950
  };
736
- var getI18nKey = function (schema, uischema, path, key) {
737
- return "".concat(getI18nKeyPrefix(schema, uischema, path), ".").concat(key);
951
+ var addLabel = function (layout, labelName) {
952
+ if (!isEmpty__default["default"](labelName)) {
953
+ var fixedLabel = startCase__default["default"](labelName);
954
+ if (isGroup(layout)) {
955
+ layout.label = fixedLabel;
956
+ }
957
+ else {
958
+ var label = {
959
+ type: 'Label',
960
+ text: fixedLabel,
961
+ };
962
+ layout.elements.push(label);
963
+ }
964
+ }
738
965
  };
739
- var addI18nKeyToPrefix = function (i18nKeyPrefix, key) {
740
- return "".concat(i18nKeyPrefix, ".").concat(key);
966
+ var isCombinator = function (jsonSchema) {
967
+ return (!isEmpty__default["default"](jsonSchema) &&
968
+ (!isEmpty__default["default"](jsonSchema.oneOf) ||
969
+ !isEmpty__default["default"](jsonSchema.anyOf) ||
970
+ !isEmpty__default["default"](jsonSchema.allOf)));
741
971
  };
742
- var defaultTranslator = function (_id, defaultMessage) { return defaultMessage; };
743
- var defaultErrorTranslator = function (error, t, uischema) {
744
- var _a;
745
- var i18nKey = getI18nKey(error.parentSchema, uischema, getControlPath(error), "error.".concat(error.keyword));
746
- var specializedKeywordMessage = t(i18nKey, undefined, { error: error });
747
- if (specializedKeywordMessage !== undefined) {
748
- return specializedKeywordMessage;
972
+ var generateUISchema = function (jsonSchema, schemaElements, currentRef, schemaName, layoutType, rootSchema) {
973
+ if (!isEmpty__default["default"](jsonSchema) && jsonSchema.$ref !== undefined) {
974
+ return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref, rootSchema), schemaElements, currentRef, schemaName, layoutType, rootSchema);
749
975
  }
750
- var genericKeywordMessage = t("error.".concat(error.keyword), undefined, {
751
- error: error,
752
- });
753
- if (genericKeywordMessage !== undefined) {
754
- return genericKeywordMessage;
976
+ if (isCombinator(jsonSchema)) {
977
+ var controlObject = createControlElement(currentRef);
978
+ schemaElements.push(controlObject);
979
+ return controlObject;
755
980
  }
756
- var messageCustomization = t(error.message, undefined, { error: error });
757
- if (messageCustomization !== undefined) {
758
- return messageCustomization;
981
+ var types = deriveTypes(jsonSchema);
982
+ if (types.length === 0) {
983
+ return null;
759
984
  }
760
- if (error.keyword === 'required' &&
761
- ((_a = error.message) === null || _a === void 0 ? void 0 : _a.startsWith('must have required property'))) {
762
- return t('is a required property', 'is a required property', { error: error });
985
+ if (types.length > 1) {
986
+ var controlObject = createControlElement(currentRef);
987
+ schemaElements.push(controlObject);
988
+ return controlObject;
763
989
  }
764
- return error.message;
765
- };
766
- var getCombinedErrorMessage = function (errors, et, t, schema, uischema, path) {
767
- if (errors.length > 0 && t) {
768
- var customErrorKey = getI18nKey(schema, uischema, path, 'error.custom');
769
- var specializedErrorMessage = t(customErrorKey, undefined, {
770
- schema: schema,
771
- uischema: uischema,
772
- path: path,
773
- errors: errors,
774
- });
775
- if (specializedErrorMessage !== undefined) {
776
- return specializedErrorMessage;
990
+ if (currentRef === '#' && types[0] === 'object') {
991
+ var layout_1 = createLayout(layoutType);
992
+ schemaElements.push(layout_1);
993
+ if (jsonSchema.properties && keys__default["default"](jsonSchema.properties).length > 1) {
994
+ addLabel(layout_1, schemaName);
777
995
  }
996
+ if (!isEmpty__default["default"](jsonSchema.properties)) {
997
+ var nextRef_1 = currentRef + '/properties';
998
+ Object.keys(jsonSchema.properties).map(function (propName) {
999
+ var value = jsonSchema.properties[propName];
1000
+ var ref = "".concat(nextRef_1, "/").concat(encode(propName));
1001
+ if (value.$ref !== undefined) {
1002
+ value = resolveSchema(rootSchema, value.$ref, rootSchema);
1003
+ }
1004
+ generateUISchema(value, layout_1.elements, ref, propName, layoutType, rootSchema);
1005
+ });
1006
+ }
1007
+ return layout_1;
778
1008
  }
779
- return formatErrorMessage(errors.map(function (error) { return et(error, t, uischema); }));
780
- };
781
- var deriveLabelForUISchemaElement = function (uischema, t) {
782
- if (uischema.label === false) {
783
- return undefined;
784
- }
785
- if ((uischema.label === undefined ||
786
- uischema.label === null ||
787
- uischema.label === true) &&
788
- !isInternationalized(uischema)) {
789
- return undefined;
790
- }
791
- var stringifiedLabel = typeof uischema.label === 'string'
792
- ? uischema.label
793
- : JSON.stringify(uischema.label);
794
- var i18nKeyPrefix = getI18nKeyPrefixBySchema(undefined, uischema);
795
- var i18nKey = typeof i18nKeyPrefix === 'string'
796
- ? "".concat(i18nKeyPrefix, ".label")
797
- : stringifiedLabel;
798
- return t(i18nKey, stringifiedLabel, { uischema: uischema });
799
- };
800
- var getArrayTranslations = function (t, defaultTranslations, i18nKeyPrefix, label) {
801
- var translations = {};
802
- defaultTranslations.forEach(function (controlElement) {
803
- var key = addI18nKeyToPrefix(i18nKeyPrefix, controlElement.key);
804
- translations[controlElement.key] = t(key, controlElement.default(label));
805
- });
806
- return translations;
807
- };
808
- var getCombinatorTranslations = function (t, defaultTranslations, i18nKeyPrefix, label) {
809
- var translations = {};
810
- defaultTranslations.forEach(function (controlElement) {
811
- var key = addI18nKeyToPrefix(i18nKeyPrefix, controlElement.key);
812
- translations[controlElement.key] = t(key, controlElement.default(label));
813
- });
814
- return translations;
815
- };
816
-
817
- exports.ArrayTranslationEnum = void 0;
818
- (function (ArrayTranslationEnum) {
819
- ArrayTranslationEnum["addTooltip"] = "addTooltip";
820
- ArrayTranslationEnum["addAriaLabel"] = "addAriaLabel";
821
- ArrayTranslationEnum["removeTooltip"] = "removeTooltip";
822
- ArrayTranslationEnum["upAriaLabel"] = "upAriaLabel";
823
- ArrayTranslationEnum["downAriaLabel"] = "downAriaLabel";
824
- ArrayTranslationEnum["noSelection"] = "noSelection";
825
- ArrayTranslationEnum["removeAriaLabel"] = "removeAriaLabel";
826
- ArrayTranslationEnum["noDataMessage"] = "noDataMessage";
827
- ArrayTranslationEnum["deleteDialogTitle"] = "deleteDialogTitle";
828
- ArrayTranslationEnum["deleteDialogMessage"] = "deleteDialogMessage";
829
- ArrayTranslationEnum["deleteDialogAccept"] = "deleteDialogAccept";
830
- ArrayTranslationEnum["deleteDialogDecline"] = "deleteDialogDecline";
831
- ArrayTranslationEnum["up"] = "up";
832
- ArrayTranslationEnum["down"] = "down";
833
- })(exports.ArrayTranslationEnum || (exports.ArrayTranslationEnum = {}));
834
- var arrayDefaultTranslations = [
835
- {
836
- key: exports.ArrayTranslationEnum.addTooltip,
837
- default: function (input) { return (input ? "Add to ".concat(input) : 'Add'); },
838
- },
839
- {
840
- key: exports.ArrayTranslationEnum.addAriaLabel,
841
- default: function (input) { return (input ? "Add to ".concat(input, " button") : 'Add button'); },
842
- },
843
- { key: exports.ArrayTranslationEnum.removeTooltip, default: function () { return 'Delete'; } },
844
- { key: exports.ArrayTranslationEnum.removeAriaLabel, default: function () { return 'Delete button'; } },
845
- { key: exports.ArrayTranslationEnum.upAriaLabel, default: function () { return "Move item up"; } },
846
- { key: exports.ArrayTranslationEnum.up, default: function () { return 'Up'; } },
847
- { key: exports.ArrayTranslationEnum.down, default: function () { return 'Down'; } },
848
- { key: exports.ArrayTranslationEnum.downAriaLabel, default: function () { return "Move item down"; } },
849
- { key: exports.ArrayTranslationEnum.noDataMessage, default: function () { return 'No data'; } },
850
- { key: exports.ArrayTranslationEnum.noSelection, default: function () { return 'No selection'; } },
851
- {
852
- key: exports.ArrayTranslationEnum.deleteDialogTitle,
853
- default: function () { return 'Confirm Deletion'; },
854
- },
855
- {
856
- key: exports.ArrayTranslationEnum.deleteDialogMessage,
857
- default: function () { return 'Are you sure you want to delete the selected entry?'; },
858
- },
859
- { key: exports.ArrayTranslationEnum.deleteDialogAccept, default: function () { return 'Yes'; } },
860
- { key: exports.ArrayTranslationEnum.deleteDialogDecline, default: function () { return 'No'; } },
861
- ];
862
-
863
- exports.CombinatorTranslationEnum = void 0;
864
- (function (CombinatorTranslationEnum) {
865
- CombinatorTranslationEnum["clearDialogTitle"] = "clearDialogTitle";
866
- CombinatorTranslationEnum["clearDialogMessage"] = "clearDialogMessage";
867
- CombinatorTranslationEnum["clearDialogAccept"] = "clearDialogAccept";
868
- CombinatorTranslationEnum["clearDialogDecline"] = "clearDialogDecline";
869
- })(exports.CombinatorTranslationEnum || (exports.CombinatorTranslationEnum = {}));
870
- var combinatorDefaultTranslations = [
871
- {
872
- key: exports.CombinatorTranslationEnum.clearDialogTitle,
873
- default: function () { return 'Clear form?'; },
874
- },
875
- {
876
- key: exports.CombinatorTranslationEnum.clearDialogMessage,
877
- default: function () { return 'Your data will be cleared. Do you want to proceed?'; },
878
- },
879
- { key: exports.CombinatorTranslationEnum.clearDialogAccept, default: function () { return 'Yes'; } },
880
- { key: exports.CombinatorTranslationEnum.clearDialogDecline, default: function () { return 'No'; } },
881
- ];
1009
+ switch (types[0]) {
1010
+ case 'object':
1011
+ case 'array':
1012
+ case 'string':
1013
+ case 'number':
1014
+ case 'integer':
1015
+ case 'null':
1016
+ case 'boolean': {
1017
+ var controlObject = createControlElement(currentRef);
1018
+ schemaElements.push(controlObject);
1019
+ return controlObject;
1020
+ }
1021
+ default:
1022
+ throw new Error('Unknown type: ' + JSON.stringify(jsonSchema));
1023
+ }
1024
+ };
1025
+ var generateDefaultUISchema = function (jsonSchema, layoutType, prefix, rootSchema) {
1026
+ if (layoutType === void 0) { layoutType = 'VerticalLayout'; }
1027
+ if (prefix === void 0) { prefix = '#'; }
1028
+ if (rootSchema === void 0) { rootSchema = jsonSchema; }
1029
+ return wrapInLayoutIfNecessary(generateUISchema(jsonSchema, [], prefix, '', layoutType, rootSchema), layoutType);
1030
+ };
882
1031
 
883
- var defaultJsonFormsI18nState = {
884
- locale: 'en',
885
- translate: defaultTranslator,
886
- translateError: defaultErrorTranslator,
1032
+ var Generate = {
1033
+ jsonSchema: generateJsonSchema,
1034
+ uiSchema: generateDefaultUISchema,
1035
+ controlElement: createControlElement,
887
1036
  };
888
- var i18nReducer = function (state, action) {
889
- var _a, _b, _c, _d, _e, _f;
890
- if (state === void 0) { state = defaultJsonFormsI18nState; }
891
- switch (action.type) {
892
- case UPDATE_I18N: {
893
- var locale = (_a = action.locale) !== null && _a !== void 0 ? _a : defaultJsonFormsI18nState.locale;
894
- var translate = (_b = action.translator) !== null && _b !== void 0 ? _b : defaultJsonFormsI18nState.translate;
895
- var translateError = (_c = action.errorTranslator) !== null && _c !== void 0 ? _c : defaultJsonFormsI18nState.translateError;
896
- if (locale !== state.locale ||
897
- translate !== state.translate ||
898
- translateError !== state.translateError) {
899
- return __assign(__assign({}, state), { locale: locale, translate: translate, translateError: translateError });
900
- }
901
- return state;
1037
+
1038
+ var INIT = 'jsonforms/INIT';
1039
+ var UPDATE_CORE = 'jsonforms/UPDATE_CORE';
1040
+ var SET_AJV = 'jsonforms/SET_AJV';
1041
+ var UPDATE_DATA = 'jsonforms/UPDATE';
1042
+ var UPDATE_ERRORS = 'jsonforms/UPDATE_ERRORS';
1043
+ var VALIDATE = 'jsonforms/VALIDATE';
1044
+ var ADD_RENDERER = 'jsonforms/ADD_RENDERER';
1045
+ var REMOVE_RENDERER = 'jsonforms/REMOVE_RENDERER';
1046
+ var ADD_CELL = 'jsonforms/ADD_CELL';
1047
+ var REMOVE_CELL = 'jsonforms/REMOVE_CELL';
1048
+ var SET_CONFIG = 'jsonforms/SET_CONFIG';
1049
+ var ADD_UI_SCHEMA = 'jsonforms/ADD_UI_SCHEMA';
1050
+ var REMOVE_UI_SCHEMA = 'jsonforms/REMOVE_UI_SCHEMA';
1051
+ var SET_SCHEMA = 'jsonforms/SET_SCHEMA';
1052
+ var SET_UISCHEMA = 'jsonforms/SET_UISCHEMA';
1053
+ var SET_VALIDATION_MODE = 'jsonforms/SET_VALIDATION_MODE';
1054
+ var SET_LOCALE = 'jsonforms/SET_LOCALE';
1055
+ var SET_TRANSLATOR = 'jsonforms/SET_TRANSLATOR';
1056
+ var UPDATE_I18N = 'jsonforms/UPDATE_I18N';
1057
+ var ADD_DEFAULT_DATA = 'jsonforms/ADD_DEFAULT_DATA';
1058
+ var REMOVE_DEFAULT_DATA = 'jsonforms/REMOVE_DEFAULT_DATA';
1059
+ var isUpdateArrayContext = function (context) {
1060
+ if (!('type' in context)) {
1061
+ return false;
1062
+ }
1063
+ if (typeof context.type !== 'string') {
1064
+ return false;
1065
+ }
1066
+ switch (context.type) {
1067
+ case 'ADD': {
1068
+ return ('values' in context &&
1069
+ Array.isArray(context.values) &&
1070
+ context.values.length > 0);
1071
+ }
1072
+ case 'REMOVE': {
1073
+ return ('indices' in context &&
1074
+ Array.isArray(context.indices) &&
1075
+ context.indices.length > 0 &&
1076
+ context.indices.every(function (i) { return typeof i === 'number'; }));
1077
+ }
1078
+ case 'MOVE': {
1079
+ return ('moves' in context &&
1080
+ Array.isArray(context.moves) &&
1081
+ context.moves.length > 0 &&
1082
+ context.moves.every(function (m) {
1083
+ return typeof m === 'object' &&
1084
+ m !== null &&
1085
+ 'from' in m &&
1086
+ 'to' in m &&
1087
+ typeof m.from === 'number' &&
1088
+ typeof m.to === 'number';
1089
+ }));
902
1090
  }
903
- case SET_TRANSLATOR:
904
- return __assign(__assign({}, state), { translate: (_d = action.translator) !== null && _d !== void 0 ? _d : defaultTranslator, translateError: (_e = action.errorTranslator) !== null && _e !== void 0 ? _e : defaultErrorTranslator });
905
- case SET_LOCALE:
906
- return __assign(__assign({}, state), { locale: (_f = action.locale) !== null && _f !== void 0 ? _f : navigator.languages[0] });
907
1091
  default:
908
- return state;
1092
+ return false;
909
1093
  }
910
1094
  };
911
- var fetchLocale = function (state) {
912
- if (state === undefined) {
913
- return undefined;
914
- }
915
- return state.locale;
1095
+ var init = function (data, schema, uischema, options) {
1096
+ if (schema === void 0) { schema = generateJsonSchema(data); }
1097
+ return ({
1098
+ type: INIT,
1099
+ data: data,
1100
+ schema: schema,
1101
+ uischema: typeof uischema === 'object' ? uischema : generateDefaultUISchema(schema),
1102
+ options: options,
1103
+ });
916
1104
  };
917
- var fetchTranslator = function (state) {
918
- if (state === undefined) {
919
- return defaultTranslator;
920
- }
921
- return state.translate;
1105
+ var updateCore = function (data, schema, uischema, options) { return ({
1106
+ type: UPDATE_CORE,
1107
+ data: data,
1108
+ schema: schema,
1109
+ uischema: uischema,
1110
+ options: options,
1111
+ }); };
1112
+ var registerDefaultData = function (schemaPath, data) { return ({
1113
+ type: ADD_DEFAULT_DATA,
1114
+ schemaPath: schemaPath,
1115
+ data: data,
1116
+ }); };
1117
+ var unregisterDefaultData = function (schemaPath) { return ({
1118
+ type: REMOVE_DEFAULT_DATA,
1119
+ schemaPath: schemaPath,
1120
+ }); };
1121
+ var setAjv = function (ajv) { return ({
1122
+ type: SET_AJV,
1123
+ ajv: ajv,
1124
+ }); };
1125
+ var update = function (path, updater, context) { return ({
1126
+ type: UPDATE_DATA,
1127
+ path: path,
1128
+ updater: updater,
1129
+ context: context,
1130
+ }); };
1131
+ var updateErrors = function (errors) { return ({
1132
+ type: UPDATE_ERRORS,
1133
+ errors: errors,
1134
+ }); };
1135
+ var registerRenderer = function (tester, renderer) { return ({
1136
+ type: ADD_RENDERER,
1137
+ tester: tester,
1138
+ renderer: renderer,
1139
+ }); };
1140
+ var registerCell = function (tester, cell) { return ({
1141
+ type: ADD_CELL,
1142
+ tester: tester,
1143
+ cell: cell,
1144
+ }); };
1145
+ var unregisterCell = function (tester, cell) { return ({
1146
+ type: REMOVE_CELL,
1147
+ tester: tester,
1148
+ cell: cell,
1149
+ }); };
1150
+ var unregisterRenderer = function (tester, renderer) { return ({
1151
+ type: REMOVE_RENDERER,
1152
+ tester: tester,
1153
+ renderer: renderer,
1154
+ }); };
1155
+ var setConfig = function (config) { return ({
1156
+ type: SET_CONFIG,
1157
+ config: config,
1158
+ }); };
1159
+ var setValidationMode = function (validationMode) { return ({
1160
+ type: SET_VALIDATION_MODE,
1161
+ validationMode: validationMode,
1162
+ }); };
1163
+ var registerUISchema = function (tester, uischema) {
1164
+ return {
1165
+ type: ADD_UI_SCHEMA,
1166
+ tester: tester,
1167
+ uischema: uischema,
1168
+ };
922
1169
  };
923
- var fetchErrorTranslator = function (state) {
924
- if (state === undefined) {
925
- return defaultErrorTranslator;
926
- }
927
- return state.translateError;
1170
+ var unregisterUISchema = function (tester) {
1171
+ return {
1172
+ type: REMOVE_UI_SCHEMA,
1173
+ tester: tester,
1174
+ };
928
1175
  };
1176
+ var setLocale = function (locale) { return ({
1177
+ type: SET_LOCALE,
1178
+ locale: locale,
1179
+ }); };
1180
+ var setSchema = function (schema) { return ({
1181
+ type: SET_SCHEMA,
1182
+ schema: schema,
1183
+ }); };
1184
+ var setTranslator = function (translator, errorTranslator) { return ({
1185
+ type: SET_TRANSLATOR,
1186
+ translator: translator,
1187
+ errorTranslator: errorTranslator,
1188
+ }); };
1189
+ var updateI18n = function (locale, translator, errorTranslator) { return ({
1190
+ type: UPDATE_I18N,
1191
+ locale: locale,
1192
+ translator: translator,
1193
+ errorTranslator: errorTranslator,
1194
+ }); };
1195
+ var setUISchema = function (uischema) { return ({
1196
+ type: SET_UISCHEMA,
1197
+ uischema: uischema,
1198
+ }); };
1199
+
1200
+ var index$1 = /*#__PURE__*/Object.freeze({
1201
+ __proto__: null,
1202
+ INIT: INIT,
1203
+ UPDATE_CORE: UPDATE_CORE,
1204
+ SET_AJV: SET_AJV,
1205
+ UPDATE_DATA: UPDATE_DATA,
1206
+ UPDATE_ERRORS: UPDATE_ERRORS,
1207
+ VALIDATE: VALIDATE,
1208
+ ADD_RENDERER: ADD_RENDERER,
1209
+ REMOVE_RENDERER: REMOVE_RENDERER,
1210
+ ADD_CELL: ADD_CELL,
1211
+ REMOVE_CELL: REMOVE_CELL,
1212
+ SET_CONFIG: SET_CONFIG,
1213
+ ADD_UI_SCHEMA: ADD_UI_SCHEMA,
1214
+ REMOVE_UI_SCHEMA: REMOVE_UI_SCHEMA,
1215
+ SET_SCHEMA: SET_SCHEMA,
1216
+ SET_UISCHEMA: SET_UISCHEMA,
1217
+ SET_VALIDATION_MODE: SET_VALIDATION_MODE,
1218
+ SET_LOCALE: SET_LOCALE,
1219
+ SET_TRANSLATOR: SET_TRANSLATOR,
1220
+ UPDATE_I18N: UPDATE_I18N,
1221
+ ADD_DEFAULT_DATA: ADD_DEFAULT_DATA,
1222
+ REMOVE_DEFAULT_DATA: REMOVE_DEFAULT_DATA,
1223
+ isUpdateArrayContext: isUpdateArrayContext,
1224
+ init: init,
1225
+ updateCore: updateCore,
1226
+ registerDefaultData: registerDefaultData,
1227
+ unregisterDefaultData: unregisterDefaultData,
1228
+ setAjv: setAjv,
1229
+ update: update,
1230
+ updateErrors: updateErrors,
1231
+ registerRenderer: registerRenderer,
1232
+ registerCell: registerCell,
1233
+ unregisterCell: unregisterCell,
1234
+ unregisterRenderer: unregisterRenderer,
1235
+ setConfig: setConfig,
1236
+ setValidationMode: setValidationMode,
1237
+ registerUISchema: registerUISchema,
1238
+ unregisterUISchema: unregisterUISchema,
1239
+ setLocale: setLocale,
1240
+ setSchema: setSchema,
1241
+ setTranslator: setTranslator,
1242
+ updateI18n: updateI18n,
1243
+ setUISchema: setUISchema
1244
+ });
929
1245
 
930
- var rendererReducer = function (state, action) {
1246
+ var cellReducer = function (state, _a) {
931
1247
  if (state === void 0) { state = []; }
932
- switch (action.type) {
933
- case ADD_RENDERER:
934
- return state.concat([
935
- { tester: action.tester, renderer: action.renderer },
936
- ]);
937
- case REMOVE_RENDERER:
938
- return state.filter(function (t) { return t.tester !== action.tester; });
1248
+ var type = _a.type, tester = _a.tester, cell = _a.cell;
1249
+ switch (type) {
1250
+ case ADD_CELL:
1251
+ return state.concat([{ tester: tester, cell: cell }]);
1252
+ case REMOVE_CELL:
1253
+ return state.filter(function (t) { return t.tester !== tester; });
939
1254
  default:
940
1255
  return state;
941
1256
  }
942
1257
  };
943
1258
 
944
- var NOT_APPLICABLE = -1;
945
- var isControl = function (uischema) {
946
- return !isEmpty__default["default"](uischema) && uischema.scope !== undefined;
947
- };
948
- var schemaMatches = function (predicate) {
949
- return function (uischema, schema, context) {
950
- if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
951
- return false;
952
- }
953
- if (isEmpty__default["default"](schema)) {
954
- return false;
955
- }
956
- var schemaPath = uischema.scope;
957
- if (isEmpty__default["default"](schemaPath)) {
958
- return false;
959
- }
960
- var currentDataSchema = schema;
961
- if (hasType(schema, 'object')) {
962
- currentDataSchema = resolveSchema(schema, schemaPath, context === null || context === void 0 ? void 0 : context.rootSchema);
963
- }
964
- if (currentDataSchema === undefined) {
965
- return false;
966
- }
967
- return predicate(currentDataSchema, context === null || context === void 0 ? void 0 : context.rootSchema);
968
- };
969
- };
970
- var schemaSubPathMatches = function (subPath, predicate) {
971
- return function (uischema, schema, context) {
972
- if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
973
- return false;
974
- }
975
- var schemaPath = uischema.scope;
976
- var currentDataSchema = schema;
977
- if (hasType(schema, 'object')) {
978
- currentDataSchema = resolveSchema(schema, schemaPath, context === null || context === void 0 ? void 0 : context.rootSchema);
979
- }
980
- currentDataSchema = get__default["default"](currentDataSchema, subPath);
981
- if (currentDataSchema === undefined) {
982
- return false;
983
- }
984
- return predicate(currentDataSchema, context === null || context === void 0 ? void 0 : context.rootSchema);
985
- };
986
- };
987
- var schemaTypeIs = function (expectedType) {
988
- return schemaMatches(function (schema) { return !isEmpty__default["default"](schema) && hasType(schema, expectedType); });
989
- };
990
- var formatIs = function (expectedFormat) {
991
- return schemaMatches(function (schema) {
992
- return !isEmpty__default["default"](schema) &&
993
- schema.format === expectedFormat &&
994
- hasType(schema, 'string');
995
- });
996
- };
997
- var uiTypeIs = function (expected) {
998
- return function (uischema) {
999
- return !isEmpty__default["default"](uischema) && uischema.type === expected;
1000
- };
1259
+ var configDefault = {
1260
+ restrict: false,
1261
+ trim: false,
1262
+ showUnfocusedDescription: false,
1263
+ hideRequiredAsterisk: false,
1001
1264
  };
1002
- var optionIs = function (optionName, optionValue) {
1003
- return function (uischema) {
1004
- if (isEmpty__default["default"](uischema)) {
1005
- return false;
1006
- }
1007
- var options = uischema.options;
1008
- return !isEmpty__default["default"](options) && options[optionName] === optionValue;
1009
- };
1265
+
1266
+ var applyDefaultConfiguration = function (config) {
1267
+ if (config === void 0) { config = {}; }
1268
+ return merge__default["default"]({}, configDefault, config);
1010
1269
  };
1011
- var hasOption = function (optionName) {
1012
- return function (uischema) {
1013
- if (isEmpty__default["default"](uischema)) {
1014
- return false;
1015
- }
1016
- var options = uischema.options;
1017
- return !isEmpty__default["default"](options) && !isUndefined__default["default"](options[optionName]);
1018
- };
1270
+ var configReducer = function (state, action) {
1271
+ if (state === void 0) { state = applyDefaultConfiguration(); }
1272
+ switch (action.type) {
1273
+ case SET_CONFIG:
1274
+ return applyDefaultConfiguration(action.config);
1275
+ default:
1276
+ return state;
1277
+ }
1019
1278
  };
1020
- var scopeEndsWith = function (expected) {
1021
- return function (uischema) {
1022
- if (isEmpty__default["default"](expected) || !isControl(uischema)) {
1023
- return false;
1024
- }
1025
- return endsWith__default["default"](uischema.scope, expected);
1026
- };
1279
+
1280
+ var initState = {
1281
+ data: {},
1282
+ schema: {},
1283
+ uischema: undefined,
1284
+ errors: [],
1285
+ validator: undefined,
1286
+ ajv: undefined,
1287
+ validationMode: 'ValidateAndShow',
1288
+ additionalErrors: [],
1027
1289
  };
1028
- var scopeEndIs = function (expected) {
1029
- return function (uischema) {
1030
- if (isEmpty__default["default"](expected) || !isControl(uischema)) {
1031
- return false;
1032
- }
1033
- var schemaPath = uischema.scope;
1034
- return !isEmpty__default["default"](schemaPath) && last__default["default"](schemaPath.split('/')) === expected;
1035
- };
1290
+ var getValidationMode = function (state, action) {
1291
+ if (action && hasValidationModeOption(action.options)) {
1292
+ return action.options.validationMode;
1293
+ }
1294
+ return state.validationMode;
1036
1295
  };
1037
- var and = function () {
1038
- var testers = [];
1039
- for (var _i = 0; _i < arguments.length; _i++) {
1040
- testers[_i] = arguments[_i];
1296
+ var hasValidationModeOption = function (option) {
1297
+ if (option) {
1298
+ return option.validationMode !== undefined;
1041
1299
  }
1042
- return function (uischema, schema, context) {
1043
- return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema, context); }, true);
1044
- };
1300
+ return false;
1045
1301
  };
1046
- var or = function () {
1047
- var testers = [];
1048
- for (var _i = 0; _i < arguments.length; _i++) {
1049
- testers[_i] = arguments[_i];
1302
+ var hasAdditionalErrorsOption = function (option) {
1303
+ if (option) {
1304
+ return option.additionalErrors !== undefined;
1050
1305
  }
1051
- return function (uischema, schema, context) {
1052
- return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema, context); }, false);
1053
- };
1306
+ return false;
1054
1307
  };
1055
- var rankWith = function (rank, tester) {
1056
- return function (uischema, schema, context) {
1057
- if (tester(uischema, schema, context)) {
1058
- return rank;
1059
- }
1060
- return NOT_APPLICABLE;
1061
- };
1308
+ var getAdditionalErrors = function (state, action) {
1309
+ if (action && hasAdditionalErrorsOption(action.options)) {
1310
+ return action.options.additionalErrors;
1311
+ }
1312
+ return state.additionalErrors;
1062
1313
  };
1063
- var withIncreasedRank = function (by, rankedTester) {
1064
- return function (uischema, schema, context) {
1065
- var rank = rankedTester(uischema, schema, context);
1066
- if (rank === NOT_APPLICABLE) {
1067
- return NOT_APPLICABLE;
1314
+ var getOrCreateAjv = function (state, action) {
1315
+ if (action) {
1316
+ if (hasAjvOption(action.options)) {
1317
+ return action.options.ajv;
1068
1318
  }
1069
- return rank + by;
1070
- };
1071
- };
1072
- var isBooleanControl = and(uiTypeIs('Control'), schemaTypeIs('boolean'));
1073
- var isObjectControl = and(uiTypeIs('Control'), schemaTypeIs('object'));
1074
- var isAllOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
1075
- return Object.prototype.hasOwnProperty.call(schema, 'allOf');
1076
- }));
1077
- var isAnyOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
1078
- return Object.prototype.hasOwnProperty.call(schema, 'anyOf');
1079
- }));
1080
- var isOneOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
1081
- return Object.prototype.hasOwnProperty.call(schema, 'oneOf');
1082
- }));
1083
- var isEnumControl = and(uiTypeIs('Control'), schemaMatches(function (schema) { return isEnumSchema(schema); }));
1084
- var isOneOfEnumControl = and(uiTypeIs('Control'), schemaMatches(function (schema) { return isOneOfEnumSchema(schema); }));
1085
- var isIntegerControl = and(uiTypeIs('Control'), schemaTypeIs('integer'));
1086
- var isNumberControl = and(uiTypeIs('Control'), schemaTypeIs('number'));
1087
- var isStringControl = and(uiTypeIs('Control'), schemaTypeIs('string'));
1088
- var isMultiLineControl = and(uiTypeIs('Control'), optionIs('multi', true));
1089
- var isDateControl = and(uiTypeIs('Control'), or(formatIs('date'), optionIs('format', 'date')));
1090
- var isTimeControl = and(uiTypeIs('Control'), or(formatIs('time'), optionIs('format', 'time')));
1091
- var isDateTimeControl = and(uiTypeIs('Control'), or(formatIs('date-time'), optionIs('format', 'date-time')));
1092
- var isObjectArray = and(schemaMatches(function (schema, rootSchema) {
1093
- return hasType(schema, 'array') &&
1094
- !Array.isArray(resolveSchema(schema, 'items', rootSchema));
1095
- }
1096
- ), schemaSubPathMatches('items', function (schema, rootSchema) {
1097
- var resolvedSchema = schema.$ref
1098
- ? resolveSchema(rootSchema, schema.$ref, rootSchema)
1099
- : schema;
1100
- return hasType(resolvedSchema, 'object');
1101
- }));
1102
- var isObjectArrayControl = and(uiTypeIs('Control'), isObjectArray);
1103
- var traverse = function (any, pred, rootSchema) {
1104
- if (isArray__default["default"](any)) {
1105
- return reduce__default["default"](any, function (acc, el) { return acc || traverse(el, pred, rootSchema); }, false);
1106
- }
1107
- if (pred(any)) {
1108
- return true;
1109
- }
1110
- if (any.$ref) {
1111
- var toTraverse = resolveSchema(rootSchema, any.$ref, rootSchema);
1112
- if (toTraverse && !toTraverse.$ref) {
1113
- return traverse(toTraverse, pred, rootSchema);
1319
+ else if (action.options !== undefined) {
1320
+ if (lodash.isFunction(action.options.compile)) {
1321
+ return action.options;
1322
+ }
1114
1323
  }
1115
1324
  }
1116
- if (any.items) {
1117
- return traverse(any.items, pred, rootSchema);
1118
- }
1119
- if (any.properties) {
1120
- return reduce__default["default"](toPairs__default["default"](any.properties), function (acc, _a) {
1121
- _a[0]; var val = _a[1];
1122
- return acc || traverse(val, pred, rootSchema);
1123
- }, false);
1325
+ return state.ajv ? state.ajv : createAjv();
1326
+ };
1327
+ var hasAjvOption = function (option) {
1328
+ if (option) {
1329
+ return option.ajv !== undefined;
1124
1330
  }
1125
1331
  return false;
1126
1332
  };
1127
- var isObjectArrayWithNesting = function (uischema, schema, context) {
1128
- var _a;
1129
- if (!uiTypeIs('Control')(uischema, schema, context)) {
1130
- return false;
1131
- }
1132
- var schemaPath = uischema.scope;
1133
- var resolvedSchema = resolveSchema(schema, schemaPath, (_a = context === null || context === void 0 ? void 0 : context.rootSchema) !== null && _a !== void 0 ? _a : schema);
1134
- var objectDepth = 0;
1135
- if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
1136
- if (traverse(resolvedSchema.items, function (val) {
1137
- if (val === schema) {
1138
- return false;
1333
+ var coreReducer = function (state, action) {
1334
+ if (state === void 0) { state = initState; }
1335
+ switch (action.type) {
1336
+ case INIT: {
1337
+ var thisAjv = getOrCreateAjv(state, action);
1338
+ var validationMode = getValidationMode(state, action);
1339
+ var v = validationMode === 'NoValidation'
1340
+ ? undefined
1341
+ : thisAjv.compile(action.schema);
1342
+ var e = validate(v, action.data);
1343
+ var additionalErrors = getAdditionalErrors(state, action);
1344
+ return __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, additionalErrors: additionalErrors, errors: e, validator: v, ajv: thisAjv, validationMode: validationMode });
1345
+ }
1346
+ case UPDATE_CORE: {
1347
+ var thisAjv = getOrCreateAjv(state, action);
1348
+ var validationMode = getValidationMode(state, action);
1349
+ var validator = state.validator;
1350
+ var errors = state.errors;
1351
+ if (state.schema !== action.schema ||
1352
+ state.validationMode !== validationMode ||
1353
+ state.ajv !== thisAjv) {
1354
+ validator =
1355
+ validationMode === 'NoValidation'
1356
+ ? undefined
1357
+ : thisAjv.compile(action.schema);
1358
+ errors = validate(validator, action.data);
1139
1359
  }
1140
- if (val.$ref !== undefined) {
1141
- return false;
1360
+ else if (state.data !== action.data) {
1361
+ errors = validate(validator, action.data);
1142
1362
  }
1143
- if (val.anyOf || val.allOf) {
1144
- return true;
1363
+ var additionalErrors = getAdditionalErrors(state, action);
1364
+ var stateChanged = state.data !== action.data ||
1365
+ state.schema !== action.schema ||
1366
+ state.uischema !== action.uischema ||
1367
+ state.ajv !== thisAjv ||
1368
+ state.errors !== errors ||
1369
+ state.validator !== validator ||
1370
+ state.validationMode !== validationMode ||
1371
+ state.additionalErrors !== additionalErrors;
1372
+ return stateChanged
1373
+ ? __assign(__assign({}, state), { data: action.data, schema: action.schema, uischema: action.uischema, ajv: thisAjv, errors: isEqual__default["default"](errors, state.errors) ? state.errors : errors, validator: validator, validationMode: validationMode, additionalErrors: additionalErrors }) : state;
1374
+ }
1375
+ case SET_AJV: {
1376
+ var currentAjv = action.ajv;
1377
+ var validator = state.validationMode === 'NoValidation'
1378
+ ? undefined
1379
+ : currentAjv.compile(state.schema);
1380
+ var errors = validate(validator, state.data);
1381
+ return __assign(__assign({}, state), { validator: validator, errors: errors });
1382
+ }
1383
+ case SET_SCHEMA: {
1384
+ var needsNewValidator = action.schema && state.ajv && state.validationMode !== 'NoValidation';
1385
+ var v = needsNewValidator
1386
+ ? state.ajv.compile(action.schema)
1387
+ : state.validator;
1388
+ var errors = validate(v, state.data);
1389
+ return __assign(__assign({}, state), { validator: v, schema: action.schema, errors: errors });
1390
+ }
1391
+ case SET_UISCHEMA: {
1392
+ return __assign(__assign({}, state), { uischema: action.uischema });
1393
+ }
1394
+ case UPDATE_DATA: {
1395
+ if (action.path === undefined || action.path === null) {
1396
+ return state;
1145
1397
  }
1146
- if (val.oneOf && !isOneOfEnumSchema(val)) {
1147
- return true;
1398
+ else if (action.path === '') {
1399
+ var result = action.updater(cloneDeep__default["default"](state.data));
1400
+ var errors = validate(state.validator, result);
1401
+ return __assign(__assign({}, state), { data: result, errors: errors });
1148
1402
  }
1149
- if (hasType(val, 'object')) {
1150
- objectDepth++;
1151
- if (objectDepth === 2) {
1152
- return true;
1403
+ else {
1404
+ var oldData = get__default["default"](state.data, action.path);
1405
+ var newData = action.updater(cloneDeep__default["default"](oldData));
1406
+ var newState = void 0;
1407
+ if (newData !== undefined) {
1408
+ newState = setFp__default["default"](action.path, newData, state.data === undefined ? {} : state.data);
1153
1409
  }
1410
+ else {
1411
+ newState = unsetFp__default["default"](action.path, state.data === undefined ? {} : state.data);
1412
+ }
1413
+ var errors = validate(state.validator, newState);
1414
+ return __assign(__assign({}, state), { data: newState, errors: errors });
1154
1415
  }
1155
- if (hasType(val, 'array')) {
1156
- return true;
1157
- }
1158
- return false;
1159
- }, context === null || context === void 0 ? void 0 : context.rootSchema)) {
1160
- return true;
1161
1416
  }
1162
- if (uischema.options && uischema.options.detail) {
1163
- if (typeof uischema.options.detail === 'string') {
1164
- return uischema.options.detail.toUpperCase() !== 'DEFAULT';
1417
+ case UPDATE_ERRORS: {
1418
+ return __assign(__assign({}, state), { errors: action.errors });
1419
+ }
1420
+ case SET_VALIDATION_MODE: {
1421
+ if (state.validationMode === action.validationMode) {
1422
+ return state;
1165
1423
  }
1166
- else if (typeof uischema.options.detail === 'object' &&
1167
- uischema.options.detail.type) {
1168
- return true;
1424
+ if (action.validationMode === 'NoValidation') {
1425
+ var errors = validate(undefined, state.data);
1426
+ return __assign(__assign({}, state), { errors: errors, validationMode: action.validationMode });
1427
+ }
1428
+ if (state.validationMode === 'NoValidation') {
1429
+ var validator = state.ajv.compile(state.schema);
1430
+ var errors = validate(validator, state.data);
1431
+ return __assign(__assign({}, state), { validator: validator, errors: errors, validationMode: action.validationMode });
1169
1432
  }
1433
+ return __assign(__assign({}, state), { validationMode: action.validationMode });
1170
1434
  }
1435
+ default:
1436
+ return state;
1171
1437
  }
1172
- return false;
1173
- };
1174
- var isArrayObjectControl = isObjectArrayControl;
1175
- var isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(function (schema, rootSchema) {
1176
- return deriveTypes(schema).length !== 0 &&
1177
- !Array.isArray(resolveSchema(schema, 'items', rootSchema));
1178
- }
1179
- ), schemaSubPathMatches('items', function (schema, rootSchema) {
1180
- var resolvedSchema = schema.$ref
1181
- ? resolveSchema(rootSchema, schema.$ref, rootSchema)
1182
- : schema;
1183
- var types = deriveTypes(resolvedSchema);
1184
- return (types.length === 1 &&
1185
- includes__default["default"](['integer', 'number', 'boolean', 'string'], types[0]));
1186
- }));
1187
- var isRangeControl = and(uiTypeIs('Control'), or(schemaTypeIs('number'), schemaTypeIs('integer')), schemaMatches(function (schema) {
1188
- return Object.prototype.hasOwnProperty.call(schema, 'maximum') &&
1189
- Object.prototype.hasOwnProperty.call(schema, 'minimum') &&
1190
- Object.prototype.hasOwnProperty.call(schema, 'default');
1191
- }), optionIs('slider', true));
1192
- var isNumberFormatControl = and(uiTypeIs('Control'), schemaTypeIs('integer'), optionIs('format', true));
1193
- var isCategorization = function (category) { return category.type === 'Categorization'; };
1194
- var isCategory = function (uischema) {
1195
- return uischema.type === 'Category';
1196
1438
  };
1197
- var hasCategory = function (categorization) {
1198
- if (isEmpty__default["default"](categorization.elements)) {
1199
- return false;
1439
+
1440
+ var defaultDataReducer = function (state, action) {
1441
+ if (state === void 0) { state = []; }
1442
+ switch (action.type) {
1443
+ case ADD_DEFAULT_DATA:
1444
+ return state.concat([
1445
+ { schemaPath: action.schemaPath, data: action.data },
1446
+ ]);
1447
+ case REMOVE_DEFAULT_DATA:
1448
+ return state.filter(function (t) { return t.schemaPath !== action.schemaPath; });
1449
+ default:
1450
+ return state;
1200
1451
  }
1201
- return categorization.elements
1202
- .map(function (elem) {
1203
- return isCategorization(elem) ? hasCategory(elem) : isCategory(elem);
1204
- })
1205
- .reduce(function (prev, curr) { return prev && curr; }, true);
1206
1452
  };
1207
- var categorizationHasCategory = function (uischema) {
1208
- return hasCategory(uischema);
1209
- };
1210
- var not = function (tester) {
1211
- return function (uischema, schema, context) {
1212
- return !tester(uischema, schema, context);
1213
- };
1453
+ var getDefaultData = function (state) {
1454
+ return extractDefaultData(get__default["default"](state, 'jsonforms.defaultData'));
1214
1455
  };
1456
+ var extractDefaultData = function (state) { return state; };
1215
1457
 
1216
- var index$1 = /*#__PURE__*/Object.freeze({
1217
- __proto__: null,
1218
- NOT_APPLICABLE: NOT_APPLICABLE,
1219
- isControl: isControl,
1220
- schemaMatches: schemaMatches,
1221
- schemaSubPathMatches: schemaSubPathMatches,
1222
- schemaTypeIs: schemaTypeIs,
1223
- formatIs: formatIs,
1224
- uiTypeIs: uiTypeIs,
1225
- optionIs: optionIs,
1226
- hasOption: hasOption,
1227
- scopeEndsWith: scopeEndsWith,
1228
- scopeEndIs: scopeEndIs,
1229
- and: and,
1230
- or: or,
1231
- rankWith: rankWith,
1232
- withIncreasedRank: withIncreasedRank,
1233
- isBooleanControl: isBooleanControl,
1234
- isObjectControl: isObjectControl,
1235
- isAllOfControl: isAllOfControl,
1236
- isAnyOfControl: isAnyOfControl,
1237
- isOneOfControl: isOneOfControl,
1238
- isEnumControl: isEnumControl,
1239
- isOneOfEnumControl: isOneOfEnumControl,
1240
- isIntegerControl: isIntegerControl,
1241
- isNumberControl: isNumberControl,
1242
- isStringControl: isStringControl,
1243
- isMultiLineControl: isMultiLineControl,
1244
- isDateControl: isDateControl,
1245
- isTimeControl: isTimeControl,
1246
- isDateTimeControl: isDateTimeControl,
1247
- isObjectArray: isObjectArray,
1248
- isObjectArrayControl: isObjectArrayControl,
1249
- isObjectArrayWithNesting: isObjectArrayWithNesting,
1250
- isArrayObjectControl: isArrayObjectControl,
1251
- isPrimitiveArrayControl: isPrimitiveArrayControl,
1252
- isRangeControl: isRangeControl,
1253
- isNumberFormatControl: isNumberFormatControl,
1254
- isCategorization: isCategorization,
1255
- isCategory: isCategory,
1256
- hasCategory: hasCategory,
1257
- categorizationHasCategory: categorizationHasCategory,
1258
- not: not
1259
- });
1458
+ exports.ArrayTranslationEnum = void 0;
1459
+ (function (ArrayTranslationEnum) {
1460
+ ArrayTranslationEnum["addTooltip"] = "addTooltip";
1461
+ ArrayTranslationEnum["addAriaLabel"] = "addAriaLabel";
1462
+ ArrayTranslationEnum["removeTooltip"] = "removeTooltip";
1463
+ ArrayTranslationEnum["upAriaLabel"] = "upAriaLabel";
1464
+ ArrayTranslationEnum["downAriaLabel"] = "downAriaLabel";
1465
+ ArrayTranslationEnum["noSelection"] = "noSelection";
1466
+ ArrayTranslationEnum["removeAriaLabel"] = "removeAriaLabel";
1467
+ ArrayTranslationEnum["noDataMessage"] = "noDataMessage";
1468
+ ArrayTranslationEnum["deleteDialogTitle"] = "deleteDialogTitle";
1469
+ ArrayTranslationEnum["deleteDialogMessage"] = "deleteDialogMessage";
1470
+ ArrayTranslationEnum["deleteDialogAccept"] = "deleteDialogAccept";
1471
+ ArrayTranslationEnum["deleteDialogDecline"] = "deleteDialogDecline";
1472
+ ArrayTranslationEnum["up"] = "up";
1473
+ ArrayTranslationEnum["down"] = "down";
1474
+ })(exports.ArrayTranslationEnum || (exports.ArrayTranslationEnum = {}));
1475
+ var arrayDefaultTranslations = [
1476
+ {
1477
+ key: exports.ArrayTranslationEnum.addTooltip,
1478
+ default: function (input) { return (input ? "Add to ".concat(input) : 'Add'); },
1479
+ },
1480
+ {
1481
+ key: exports.ArrayTranslationEnum.addAriaLabel,
1482
+ default: function (input) { return (input ? "Add to ".concat(input, " button") : 'Add button'); },
1483
+ },
1484
+ { key: exports.ArrayTranslationEnum.removeTooltip, default: function () { return 'Delete'; } },
1485
+ { key: exports.ArrayTranslationEnum.removeAriaLabel, default: function () { return 'Delete button'; } },
1486
+ { key: exports.ArrayTranslationEnum.upAriaLabel, default: function () { return "Move item up"; } },
1487
+ { key: exports.ArrayTranslationEnum.up, default: function () { return 'Up'; } },
1488
+ { key: exports.ArrayTranslationEnum.down, default: function () { return 'Down'; } },
1489
+ { key: exports.ArrayTranslationEnum.downAriaLabel, default: function () { return "Move item down"; } },
1490
+ { key: exports.ArrayTranslationEnum.noDataMessage, default: function () { return 'No data'; } },
1491
+ { key: exports.ArrayTranslationEnum.noSelection, default: function () { return 'No selection'; } },
1492
+ {
1493
+ key: exports.ArrayTranslationEnum.deleteDialogTitle,
1494
+ default: function () { return 'Confirm Deletion'; },
1495
+ },
1496
+ {
1497
+ key: exports.ArrayTranslationEnum.deleteDialogMessage,
1498
+ default: function () { return 'Are you sure you want to delete the selected entry?'; },
1499
+ },
1500
+ { key: exports.ArrayTranslationEnum.deleteDialogAccept, default: function () { return 'Yes'; } },
1501
+ { key: exports.ArrayTranslationEnum.deleteDialogDecline, default: function () { return 'No'; } },
1502
+ ];
1260
1503
 
1261
- var uischemaRegistryReducer = function (state, action) {
1262
- if (state === void 0) { state = []; }
1263
- switch (action.type) {
1264
- case ADD_UI_SCHEMA:
1265
- return state
1266
- .slice()
1267
- .concat({ tester: action.tester, uischema: action.uischema });
1268
- case REMOVE_UI_SCHEMA: {
1269
- var copy = state.slice();
1270
- remove__default["default"](copy, function (entry) { return entry.tester === action.tester; });
1271
- return copy;
1272
- }
1273
- default:
1274
- return state;
1504
+ exports.CombinatorTranslationEnum = void 0;
1505
+ (function (CombinatorTranslationEnum) {
1506
+ CombinatorTranslationEnum["clearDialogTitle"] = "clearDialogTitle";
1507
+ CombinatorTranslationEnum["clearDialogMessage"] = "clearDialogMessage";
1508
+ CombinatorTranslationEnum["clearDialogAccept"] = "clearDialogAccept";
1509
+ CombinatorTranslationEnum["clearDialogDecline"] = "clearDialogDecline";
1510
+ })(exports.CombinatorTranslationEnum || (exports.CombinatorTranslationEnum = {}));
1511
+ var combinatorDefaultTranslations = [
1512
+ {
1513
+ key: exports.CombinatorTranslationEnum.clearDialogTitle,
1514
+ default: function () { return 'Clear form?'; },
1515
+ },
1516
+ {
1517
+ key: exports.CombinatorTranslationEnum.clearDialogMessage,
1518
+ default: function () { return 'Your data will be cleared. Do you want to proceed?'; },
1519
+ },
1520
+ { key: exports.CombinatorTranslationEnum.clearDialogAccept, default: function () { return 'Yes'; } },
1521
+ { key: exports.CombinatorTranslationEnum.clearDialogDecline, default: function () { return 'No'; } },
1522
+ ];
1523
+
1524
+ var getI18nKeyPrefixBySchema = function (schema, uischema) {
1525
+ var _a;
1526
+ if (isInternationalized(uischema)) {
1527
+ return uischema.i18n;
1275
1528
  }
1529
+ return (_a = schema === null || schema === void 0 ? void 0 : schema.i18n) !== null && _a !== void 0 ? _a : undefined;
1276
1530
  };
1277
- var findMatchingUISchema = function (state) {
1278
- return function (jsonSchema, schemaPath, path) {
1279
- var match = maxBy__default["default"](state, function (entry) {
1280
- return entry.tester(jsonSchema, schemaPath, path);
1531
+ var transformPathToI18nPrefix = function (path) {
1532
+ return ((path === null || path === void 0 ? void 0 : path.split('.').filter(function (segment) { return !/^\d+$/.test(segment); }).join('.')) || 'root');
1533
+ };
1534
+ var getI18nKeyPrefix = function (schema, uischema, path) {
1535
+ var _a;
1536
+ return ((_a = getI18nKeyPrefixBySchema(schema, uischema)) !== null && _a !== void 0 ? _a : transformPathToI18nPrefix(path));
1537
+ };
1538
+ var getI18nKey = function (schema, uischema, path, key) {
1539
+ return "".concat(getI18nKeyPrefix(schema, uischema, path), ".").concat(key);
1540
+ };
1541
+ var addI18nKeyToPrefix = function (i18nKeyPrefix, key) {
1542
+ return "".concat(i18nKeyPrefix, ".").concat(key);
1543
+ };
1544
+ var defaultTranslator = function (_id, defaultMessage) { return defaultMessage; };
1545
+ var defaultErrorTranslator = function (error, t, uischema) {
1546
+ var _a;
1547
+ var i18nKey = getI18nKey(error.parentSchema, uischema, getControlPath(error), "error.".concat(error.keyword));
1548
+ var specializedKeywordMessage = t(i18nKey, undefined, { error: error });
1549
+ if (specializedKeywordMessage !== undefined) {
1550
+ return specializedKeywordMessage;
1551
+ }
1552
+ var genericKeywordMessage = t("error.".concat(error.keyword), undefined, {
1553
+ error: error,
1554
+ });
1555
+ if (genericKeywordMessage !== undefined) {
1556
+ return genericKeywordMessage;
1557
+ }
1558
+ var messageCustomization = t(error.message, undefined, { error: error });
1559
+ if (messageCustomization !== undefined) {
1560
+ return messageCustomization;
1561
+ }
1562
+ if (error.keyword === 'required' &&
1563
+ ((_a = error.message) === null || _a === void 0 ? void 0 : _a.startsWith('must have required property'))) {
1564
+ return t('is a required property', 'is a required property', { error: error });
1565
+ }
1566
+ return error.message;
1567
+ };
1568
+ var getCombinedErrorMessage = function (errors, et, t, schema, uischema, path) {
1569
+ if (errors.length > 0 && t) {
1570
+ var customErrorKey = getI18nKey(schema, uischema, path, 'error.custom');
1571
+ var specializedErrorMessage = t(customErrorKey, undefined, {
1572
+ schema: schema,
1573
+ uischema: uischema,
1574
+ path: path,
1575
+ errors: errors,
1281
1576
  });
1282
- if (match !== undefined &&
1283
- match.tester(jsonSchema, schemaPath, path) !== NOT_APPLICABLE) {
1284
- return match.uischema;
1577
+ if (specializedErrorMessage !== undefined) {
1578
+ return specializedErrorMessage;
1285
1579
  }
1580
+ }
1581
+ return formatErrorMessage(errors.map(function (error) { return et(error, t, uischema); }));
1582
+ };
1583
+ var deriveLabelForUISchemaElement = function (uischema, t) {
1584
+ if (uischema.label === false) {
1286
1585
  return undefined;
1287
- };
1586
+ }
1587
+ if ((uischema.label === undefined ||
1588
+ uischema.label === null ||
1589
+ uischema.label === true) &&
1590
+ !isInternationalized(uischema)) {
1591
+ return undefined;
1592
+ }
1593
+ var stringifiedLabel = typeof uischema.label === 'string'
1594
+ ? uischema.label
1595
+ : JSON.stringify(uischema.label);
1596
+ var i18nKeyPrefix = getI18nKeyPrefixBySchema(undefined, uischema);
1597
+ var i18nKey = typeof i18nKeyPrefix === 'string'
1598
+ ? "".concat(i18nKeyPrefix, ".label")
1599
+ : stringifiedLabel;
1600
+ return t(i18nKey, stringifiedLabel, { uischema: uischema });
1601
+ };
1602
+ var getArrayTranslations = function (t, defaultTranslations, i18nKeyPrefix, label) {
1603
+ var translations = {};
1604
+ defaultTranslations.forEach(function (controlElement) {
1605
+ var key = addI18nKeyToPrefix(i18nKeyPrefix, controlElement.key);
1606
+ translations[controlElement.key] = t(key, controlElement.default(label));
1607
+ });
1608
+ return translations;
1609
+ };
1610
+ var getCombinatorTranslations = function (t, defaultTranslations, i18nKeyPrefix, label) {
1611
+ var translations = {};
1612
+ defaultTranslations.forEach(function (controlElement) {
1613
+ var key = addI18nKeyToPrefix(i18nKeyPrefix, controlElement.key);
1614
+ translations[controlElement.key] = t(key, controlElement.default(label));
1615
+ });
1616
+ return translations;
1288
1617
  };
1289
1618
 
1290
- var jsonFormsReducerConfig = {
1291
- core: coreReducer,
1292
- renderers: rendererReducer,
1293
- cells: cellReducer,
1294
- config: configReducer,
1295
- uischemas: uischemaRegistryReducer,
1296
- defaultData: defaultDataReducer,
1297
- i18n: i18nReducer,
1619
+ var fetchLocale = function (state) {
1620
+ if (state === undefined) {
1621
+ return undefined;
1622
+ }
1623
+ return state.locale;
1298
1624
  };
1299
- var findUISchema = function (uischemas, schema, schemaPath, path, fallback, control, rootSchema) {
1300
- if (fallback === void 0) { fallback = 'VerticalLayout'; }
1301
- if (control && control.options && control.options.detail) {
1302
- if (typeof control.options.detail === 'string') {
1303
- if (control.options.detail.toUpperCase() === 'GENERATE') {
1304
- if (typeof fallback === 'function') {
1305
- return fallback();
1306
- }
1307
- return Generate.uiSchema(schema, fallback, undefined, rootSchema);
1308
- }
1309
- }
1310
- else if (typeof control.options.detail === 'object') {
1311
- if (control.options.detail.type &&
1312
- typeof control.options.detail.type === 'string') {
1313
- return control.options.detail;
1314
- }
1315
- }
1625
+ var fetchTranslator = function (state) {
1626
+ if (state === undefined) {
1627
+ return defaultTranslator;
1316
1628
  }
1317
- var uiSchema = findMatchingUISchema(uischemas)(schema, schemaPath, path);
1318
- if (uiSchema === undefined) {
1319
- if (typeof fallback === 'function') {
1320
- return fallback();
1321
- }
1322
- return Generate.uiSchema(schema, fallback, '#', rootSchema);
1629
+ return state.translate;
1630
+ };
1631
+ var fetchErrorTranslator = function (state) {
1632
+ if (state === undefined) {
1633
+ return defaultErrorTranslator;
1323
1634
  }
1324
- return uiSchema;
1635
+ return state.translateError;
1325
1636
  };
1326
- var getErrorAt = function (instancePath, schema) { return function (state) {
1327
- return errorAt(instancePath, schema)(state.jsonforms.core);
1328
- }; };
1329
- var getSubErrorsAt = function (instancePath, schema) { return function (state) {
1330
- return subErrorsAt(instancePath, schema)(state.jsonforms.core);
1331
- }; };
1332
- var getConfig = function (state) { return state.jsonforms.config; };
1333
1637
  var getLocale = function (state) {
1334
1638
  return fetchLocale(get__default["default"](state, 'jsonforms.i18n'));
1335
1639
  };
@@ -1344,509 +1648,527 @@ var getErrorTranslator = function () {
1344
1648
  };
1345
1649
  };
1346
1650
 
1347
- var getData = function (state) {
1348
- return extractData(get__default["default"](state, 'jsonforms.core'));
1349
- };
1350
- var getSchema = function (state) {
1351
- return extractSchema(get__default["default"](state, 'jsonforms.core'));
1352
- };
1353
- var getUiSchema = function (state) {
1354
- return extractUiSchema(get__default["default"](state, 'jsonforms.core'));
1355
- };
1356
- var getAjv = function (state) {
1357
- return extractAjv(get__default["default"](state, 'jsonforms.core'));
1358
- };
1359
- var getDefaultData = function (state) {
1360
- return extractDefaultData(get__default["default"](state, 'jsonforms.defaultData'));
1361
- };
1362
- var getRenderers = function (state) { return get__default["default"](state, 'jsonforms.renderers'); };
1363
- var getCells = function (state) { return get__default["default"](state, 'jsonforms.cells'); };
1364
- var getUISchemas = function (state) { return get__default["default"](state, 'jsonforms.uischemas'); };
1365
-
1366
- var defaultMiddleware = function (state, action, defaultReducer) {
1367
- return defaultReducer(state, action);
1368
- };
1369
-
1370
- var compose = function (path1, path2) {
1371
- var p1 = path1;
1372
- if (!isEmpty__default["default"](path1) && !isEmpty__default["default"](path2) && !path2.startsWith('[')) {
1373
- p1 = path1 + '.';
1374
- }
1375
- if (isEmpty__default["default"](p1)) {
1376
- return path2;
1377
- }
1378
- else if (isEmpty__default["default"](path2)) {
1379
- return p1;
1380
- }
1381
- else {
1382
- return "".concat(p1).concat(path2);
1383
- }
1384
- };
1385
- var toDataPathSegments = function (schemaPath) {
1386
- var s = schemaPath
1387
- .replace(/(anyOf|allOf|oneOf)\/[\d]+\//g, '')
1388
- .replace(/(then|else)\//g, '');
1389
- var segments = s.split('/');
1390
- var decodedSegments = segments.map(decode);
1391
- var startFromRoot = decodedSegments[0] === '#' || decodedSegments[0] === '';
1392
- var startIndex = startFromRoot ? 2 : 1;
1393
- return range__default["default"](startIndex, decodedSegments.length, 2).map(function (idx) { return decodedSegments[idx]; });
1394
- };
1395
- var toDataPath = function (schemaPath) {
1396
- return toDataPathSegments(schemaPath).join('.');
1651
+ var defaultJsonFormsI18nState = {
1652
+ locale: 'en',
1653
+ translate: defaultTranslator,
1654
+ translateError: defaultErrorTranslator,
1397
1655
  };
1398
- var composeWithUi = function (scopableUi, path) {
1399
- if (!isScoped(scopableUi)) {
1400
- return path !== null && path !== void 0 ? path : '';
1401
- }
1402
- var segments = toDataPathSegments(scopableUi.scope);
1403
- if (isEmpty__default["default"](segments)) {
1404
- return path !== null && path !== void 0 ? path : '';
1656
+ var i18nReducer = function (state, action) {
1657
+ var _a, _b, _c, _d, _e, _f;
1658
+ if (state === void 0) { state = defaultJsonFormsI18nState; }
1659
+ switch (action.type) {
1660
+ case UPDATE_I18N: {
1661
+ var locale = (_a = action.locale) !== null && _a !== void 0 ? _a : defaultJsonFormsI18nState.locale;
1662
+ var translate = (_b = action.translator) !== null && _b !== void 0 ? _b : defaultJsonFormsI18nState.translate;
1663
+ var translateError = (_c = action.errorTranslator) !== null && _c !== void 0 ? _c : defaultJsonFormsI18nState.translateError;
1664
+ if (locale !== state.locale ||
1665
+ translate !== state.translate ||
1666
+ translateError !== state.translateError) {
1667
+ return __assign(__assign({}, state), { locale: locale, translate: translate, translateError: translateError });
1668
+ }
1669
+ return state;
1670
+ }
1671
+ case SET_TRANSLATOR:
1672
+ return __assign(__assign({}, state), { translate: (_d = action.translator) !== null && _d !== void 0 ? _d : defaultTranslator, translateError: (_e = action.errorTranslator) !== null && _e !== void 0 ? _e : defaultErrorTranslator });
1673
+ case SET_LOCALE:
1674
+ return __assign(__assign({}, state), { locale: (_f = action.locale) !== null && _f !== void 0 ? _f : navigator.languages[0] });
1675
+ default:
1676
+ return state;
1405
1677
  }
1406
- return compose(path, segments.join('.'));
1407
- };
1408
- var encode = function (segment) {
1409
- return segment === null || segment === void 0 ? void 0 : segment.replace(/~/g, '~0').replace(/\//g, '~1');
1410
- };
1411
- var decode = function (pointerSegment) {
1412
- return pointerSegment === null || pointerSegment === void 0 ? void 0 : pointerSegment.replace(/~1/g, '/').replace(/~0/, '~');
1413
1678
  };
1414
1679
 
1415
- var isObjectSchema = function (schema) {
1416
- return schema.properties !== undefined;
1680
+ var rendererReducer = function (state, action) {
1681
+ if (state === void 0) { state = []; }
1682
+ switch (action.type) {
1683
+ case ADD_RENDERER:
1684
+ return state.concat([
1685
+ { tester: action.tester, renderer: action.renderer },
1686
+ ]);
1687
+ case REMOVE_RENDERER:
1688
+ return state.filter(function (t) { return t.tester !== action.tester; });
1689
+ default:
1690
+ return state;
1691
+ }
1417
1692
  };
1418
- var isArraySchema = function (schema) {
1419
- return schema.type === 'array' && schema.items !== undefined;
1693
+
1694
+ var NOT_APPLICABLE = -1;
1695
+ var isControl = function (uischema) {
1696
+ return !isEmpty__default["default"](uischema) && uischema.scope !== undefined;
1420
1697
  };
1421
- var resolveData = function (instance, dataPath) {
1422
- if (isEmpty__default["default"](dataPath)) {
1423
- return instance;
1424
- }
1425
- var dataPathSegments = dataPath.split('.');
1426
- return dataPathSegments.reduce(function (curInstance, decodedSegment) {
1427
- if (!curInstance ||
1428
- !Object.prototype.hasOwnProperty.call(curInstance, decodedSegment)) {
1429
- return undefined;
1698
+ var schemaMatches = function (predicate) {
1699
+ return function (uischema, schema, context) {
1700
+ if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
1701
+ return false;
1430
1702
  }
1431
- return curInstance[decodedSegment];
1432
- }, instance);
1703
+ if (isEmpty__default["default"](schema)) {
1704
+ return false;
1705
+ }
1706
+ var schemaPath = uischema.scope;
1707
+ if (isEmpty__default["default"](schemaPath)) {
1708
+ return false;
1709
+ }
1710
+ var currentDataSchema = schema;
1711
+ if (hasType(schema, 'object')) {
1712
+ currentDataSchema = resolveSchema(schema, schemaPath, context === null || context === void 0 ? void 0 : context.rootSchema);
1713
+ }
1714
+ if (currentDataSchema === undefined) {
1715
+ return false;
1716
+ }
1717
+ return predicate(currentDataSchema, context === null || context === void 0 ? void 0 : context.rootSchema);
1718
+ };
1433
1719
  };
1434
- var findAllRefs = function (schema, result, resolveTuples) {
1435
- if (result === void 0) { result = {}; }
1436
- if (resolveTuples === void 0) { resolveTuples = false; }
1437
- if (isObjectSchema(schema)) {
1438
- Object.keys(schema.properties).forEach(function (key) {
1439
- return findAllRefs(schema.properties[key], result);
1440
- });
1441
- }
1442
- if (isArraySchema(schema)) {
1443
- if (Array.isArray(schema.items)) {
1444
- if (resolveTuples) {
1445
- var items = schema.items;
1446
- items.forEach(function (child) { return findAllRefs(child, result); });
1447
- }
1720
+ var schemaSubPathMatches = function (subPath, predicate) {
1721
+ return function (uischema, schema, context) {
1722
+ if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
1723
+ return false;
1448
1724
  }
1449
- else {
1450
- findAllRefs(schema.items, result);
1725
+ var schemaPath = uischema.scope;
1726
+ var currentDataSchema = schema;
1727
+ if (hasType(schema, 'object')) {
1728
+ currentDataSchema = resolveSchema(schema, schemaPath, context === null || context === void 0 ? void 0 : context.rootSchema);
1451
1729
  }
1452
- }
1453
- if (Array.isArray(schema.anyOf)) {
1454
- var anyOf = schema.anyOf;
1455
- anyOf.forEach(function (child) { return findAllRefs(child, result); });
1456
- }
1457
- if (schema.$ref !== undefined) {
1458
- result[schema.$ref] = schema;
1459
- }
1460
- return result;
1730
+ currentDataSchema = get__default["default"](currentDataSchema, subPath);
1731
+ if (currentDataSchema === undefined) {
1732
+ return false;
1733
+ }
1734
+ return predicate(currentDataSchema, context === null || context === void 0 ? void 0 : context.rootSchema);
1735
+ };
1461
1736
  };
1462
- var invalidSegment = function (pathSegment) {
1463
- return pathSegment === '#' || pathSegment === undefined || pathSegment === '';
1737
+ var schemaTypeIs = function (expectedType) {
1738
+ return schemaMatches(function (schema) { return !isEmpty__default["default"](schema) && hasType(schema, expectedType); });
1464
1739
  };
1465
- var resolveSchema = function (schema, schemaPath, rootSchema) {
1466
- var segments = schemaPath === null || schemaPath === void 0 ? void 0 : schemaPath.split('/').map(decode);
1467
- return resolveSchemaWithSegments(schema, segments, rootSchema);
1740
+ var formatIs = function (expectedFormat) {
1741
+ return schemaMatches(function (schema) {
1742
+ return !isEmpty__default["default"](schema) &&
1743
+ schema.format === expectedFormat &&
1744
+ hasType(schema, 'string');
1745
+ });
1468
1746
  };
1469
- var resolveSchemaWithSegments = function (schema, pathSegments, rootSchema) {
1470
- var _a, _b, _c, _d, _e;
1471
- if (isEmpty__default["default"](schema)) {
1472
- return undefined;
1473
- }
1474
- if (schema.$ref) {
1475
- schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
1476
- }
1477
- if (!pathSegments || pathSegments.length === 0) {
1478
- return schema;
1479
- }
1480
- var segment = pathSegments[0], remainingSegments = pathSegments.slice(1);
1481
- if (invalidSegment(segment)) {
1482
- return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
1483
- }
1484
- var singleSegmentResolveSchema = get__default["default"](schema, segment);
1485
- var resolvedSchema = resolveSchemaWithSegments(singleSegmentResolveSchema, remainingSegments, rootSchema);
1486
- if (resolvedSchema) {
1487
- return resolvedSchema;
1488
- }
1489
- if (segment === 'properties' || segment === 'items') {
1490
- var alternativeResolveResult = undefined;
1491
- var subSchemas = [].concat((_a = schema.oneOf) !== null && _a !== void 0 ? _a : [], (_b = schema.allOf) !== null && _b !== void 0 ? _b : [], (_c = schema.anyOf) !== null && _c !== void 0 ? _c : [], (_d = schema.then) !== null && _d !== void 0 ? _d : [], (_e = schema.else) !== null && _e !== void 0 ? _e : []);
1492
- for (var _i = 0, subSchemas_1 = subSchemas; _i < subSchemas_1.length; _i++) {
1493
- var subSchema = subSchemas_1[_i];
1494
- alternativeResolveResult = resolveSchemaWithSegments(subSchema, __spreadArray([segment], remainingSegments, true), rootSchema);
1495
- if (alternativeResolveResult) {
1496
- break;
1497
- }
1747
+ var uiTypeIs = function (expected) {
1748
+ return function (uischema) {
1749
+ return !isEmpty__default["default"](uischema) && uischema.type === expected;
1750
+ };
1751
+ };
1752
+ var optionIs = function (optionName, optionValue) {
1753
+ return function (uischema) {
1754
+ if (isEmpty__default["default"](uischema)) {
1755
+ return false;
1498
1756
  }
1499
- return alternativeResolveResult;
1500
- }
1501
- return undefined;
1757
+ var options = uischema.options;
1758
+ return !isEmpty__default["default"](options) && options[optionName] === optionValue;
1759
+ };
1502
1760
  };
1503
-
1504
- var isOrCondition = function (condition) {
1505
- return condition.type === 'OR';
1761
+ var hasOption = function (optionName) {
1762
+ return function (uischema) {
1763
+ if (isEmpty__default["default"](uischema)) {
1764
+ return false;
1765
+ }
1766
+ var options = uischema.options;
1767
+ return !isEmpty__default["default"](options) && !isUndefined__default["default"](options[optionName]);
1768
+ };
1506
1769
  };
1507
- var isAndCondition = function (condition) {
1508
- return condition.type === 'AND';
1770
+ var scopeEndsWith = function (expected) {
1771
+ return function (uischema) {
1772
+ if (isEmpty__default["default"](expected) || !isControl(uischema)) {
1773
+ return false;
1774
+ }
1775
+ return endsWith__default["default"](uischema.scope, expected);
1776
+ };
1509
1777
  };
1510
- var isLeafCondition = function (condition) {
1511
- return condition.type === 'LEAF';
1778
+ var scopeEndIs = function (expected) {
1779
+ return function (uischema) {
1780
+ if (isEmpty__default["default"](expected) || !isControl(uischema)) {
1781
+ return false;
1782
+ }
1783
+ var schemaPath = uischema.scope;
1784
+ return !isEmpty__default["default"](schemaPath) && last__default["default"](schemaPath.split('/')) === expected;
1785
+ };
1512
1786
  };
1513
- var isSchemaCondition = function (condition) { return has__default["default"](condition, 'schema'); };
1514
- var getConditionScope = function (condition, path) {
1515
- return composeWithUi(condition, path);
1787
+ var and = function () {
1788
+ var testers = [];
1789
+ for (var _i = 0; _i < arguments.length; _i++) {
1790
+ testers[_i] = arguments[_i];
1791
+ }
1792
+ return function (uischema, schema, context) {
1793
+ return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema, context); }, true);
1794
+ };
1516
1795
  };
1517
- var evaluateCondition = function (data, condition, path, ajv) {
1518
- if (isAndCondition(condition)) {
1519
- return condition.conditions.reduce(function (acc, cur) { return acc && evaluateCondition(data, cur, path, ajv); }, true);
1796
+ var or = function () {
1797
+ var testers = [];
1798
+ for (var _i = 0; _i < arguments.length; _i++) {
1799
+ testers[_i] = arguments[_i];
1520
1800
  }
1521
- else if (isOrCondition(condition)) {
1522
- return condition.conditions.reduce(function (acc, cur) { return acc || evaluateCondition(data, cur, path, ajv); }, false);
1801
+ return function (uischema, schema, context) {
1802
+ return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema, context); }, false);
1803
+ };
1804
+ };
1805
+ var rankWith = function (rank, tester) {
1806
+ return function (uischema, schema, context) {
1807
+ if (tester(uischema, schema, context)) {
1808
+ return rank;
1809
+ }
1810
+ return NOT_APPLICABLE;
1811
+ };
1812
+ };
1813
+ var withIncreasedRank = function (by, rankedTester) {
1814
+ return function (uischema, schema, context) {
1815
+ var rank = rankedTester(uischema, schema, context);
1816
+ if (rank === NOT_APPLICABLE) {
1817
+ return NOT_APPLICABLE;
1818
+ }
1819
+ return rank + by;
1820
+ };
1821
+ };
1822
+ var isBooleanControl = and(uiTypeIs('Control'), schemaTypeIs('boolean'));
1823
+ var isObjectControl = and(uiTypeIs('Control'), schemaTypeIs('object'));
1824
+ var isAllOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
1825
+ return Object.prototype.hasOwnProperty.call(schema, 'allOf');
1826
+ }));
1827
+ var isAnyOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
1828
+ return Object.prototype.hasOwnProperty.call(schema, 'anyOf');
1829
+ }));
1830
+ var isOneOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
1831
+ return Object.prototype.hasOwnProperty.call(schema, 'oneOf');
1832
+ }));
1833
+ var isEnumControl = and(uiTypeIs('Control'), schemaMatches(function (schema) { return isEnumSchema(schema); }));
1834
+ var isOneOfEnumControl = and(uiTypeIs('Control'), schemaMatches(function (schema) { return isOneOfEnumSchema(schema); }));
1835
+ var isIntegerControl = and(uiTypeIs('Control'), schemaTypeIs('integer'));
1836
+ var isNumberControl = and(uiTypeIs('Control'), schemaTypeIs('number'));
1837
+ var isStringControl = and(uiTypeIs('Control'), schemaTypeIs('string'));
1838
+ var isMultiLineControl = and(uiTypeIs('Control'), optionIs('multi', true));
1839
+ var isDateControl = and(uiTypeIs('Control'), or(formatIs('date'), optionIs('format', 'date')));
1840
+ var isTimeControl = and(uiTypeIs('Control'), or(formatIs('time'), optionIs('format', 'time')));
1841
+ var isDateTimeControl = and(uiTypeIs('Control'), or(formatIs('date-time'), optionIs('format', 'date-time')));
1842
+ var isObjectArray = and(schemaMatches(function (schema, rootSchema) {
1843
+ return hasType(schema, 'array') &&
1844
+ !Array.isArray(resolveSchema(schema, 'items', rootSchema));
1845
+ }
1846
+ ), schemaSubPathMatches('items', function (schema, rootSchema) {
1847
+ var resolvedSchema = schema.$ref
1848
+ ? resolveSchema(rootSchema, schema.$ref, rootSchema)
1849
+ : schema;
1850
+ return hasType(resolvedSchema, 'object');
1851
+ }));
1852
+ var isObjectArrayControl = and(uiTypeIs('Control'), isObjectArray);
1853
+ var traverse = function (any, pred, rootSchema) {
1854
+ if (isArray__default["default"](any)) {
1855
+ return reduce__default["default"](any, function (acc, el) { return acc || traverse(el, pred, rootSchema); }, false);
1523
1856
  }
1524
- else if (isLeafCondition(condition)) {
1525
- var value = resolveData(data, getConditionScope(condition, path));
1526
- return value === condition.expectedValue;
1857
+ if (pred(any)) {
1858
+ return true;
1527
1859
  }
1528
- else if (isSchemaCondition(condition)) {
1529
- var value = resolveData(data, getConditionScope(condition, path));
1530
- if (condition.failWhenUndefined && value === undefined) {
1531
- return false;
1860
+ if (any.$ref) {
1861
+ var toTraverse = resolveSchema(rootSchema, any.$ref, rootSchema);
1862
+ if (toTraverse && !toTraverse.$ref) {
1863
+ return traverse(toTraverse, pred, rootSchema);
1532
1864
  }
1533
- return ajv.validate(condition.schema, value);
1534
1865
  }
1535
- else {
1536
- return true;
1866
+ if (any.items) {
1867
+ return traverse(any.items, pred, rootSchema);
1537
1868
  }
1538
- };
1539
- var isRuleFulfilled = function (uischema, data, path, ajv) {
1540
- var condition = uischema.rule.condition;
1541
- return evaluateCondition(data, condition, path, ajv);
1542
- };
1543
- var evalVisibility = function (uischema, data, path, ajv) {
1544
- if (path === void 0) { path = undefined; }
1545
- var fulfilled = isRuleFulfilled(uischema, data, path, ajv);
1546
- switch (uischema.rule.effect) {
1547
- case exports.RuleEffect.HIDE:
1548
- return !fulfilled;
1549
- case exports.RuleEffect.SHOW:
1550
- return fulfilled;
1551
- default:
1552
- return true;
1869
+ if (any.properties) {
1870
+ return reduce__default["default"](toPairs__default["default"](any.properties), function (acc, _a) {
1871
+ _a[0]; var val = _a[1];
1872
+ return acc || traverse(val, pred, rootSchema);
1873
+ }, false);
1553
1874
  }
1875
+ return false;
1554
1876
  };
1555
- var evalEnablement = function (uischema, data, path, ajv) {
1556
- if (path === void 0) { path = undefined; }
1557
- var fulfilled = isRuleFulfilled(uischema, data, path, ajv);
1558
- switch (uischema.rule.effect) {
1559
- case exports.RuleEffect.DISABLE:
1560
- return !fulfilled;
1561
- case exports.RuleEffect.ENABLE:
1562
- return fulfilled;
1563
- default:
1564
- return true;
1877
+ var isObjectArrayWithNesting = function (uischema, schema, context) {
1878
+ var _a;
1879
+ if (!uiTypeIs('Control')(uischema, schema, context)) {
1880
+ return false;
1565
1881
  }
1566
- };
1567
- var hasShowRule = function (uischema) {
1568
- if (uischema.rule &&
1569
- (uischema.rule.effect === exports.RuleEffect.SHOW ||
1570
- uischema.rule.effect === exports.RuleEffect.HIDE)) {
1571
- return true;
1882
+ var schemaPath = uischema.scope;
1883
+ var resolvedSchema = resolveSchema(schema, schemaPath, (_a = context === null || context === void 0 ? void 0 : context.rootSchema) !== null && _a !== void 0 ? _a : schema);
1884
+ var objectDepth = 0;
1885
+ if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
1886
+ if (traverse(resolvedSchema.items, function (val) {
1887
+ if (val === schema) {
1888
+ return false;
1889
+ }
1890
+ if (val.$ref !== undefined) {
1891
+ return false;
1892
+ }
1893
+ if (val.anyOf || val.allOf) {
1894
+ return true;
1895
+ }
1896
+ if (val.oneOf && !isOneOfEnumSchema(val)) {
1897
+ return true;
1898
+ }
1899
+ if (hasType(val, 'object')) {
1900
+ objectDepth++;
1901
+ if (objectDepth === 2) {
1902
+ return true;
1903
+ }
1904
+ }
1905
+ if (hasType(val, 'array')) {
1906
+ return true;
1907
+ }
1908
+ return false;
1909
+ }, context === null || context === void 0 ? void 0 : context.rootSchema)) {
1910
+ return true;
1911
+ }
1912
+ if (uischema.options && uischema.options.detail) {
1913
+ if (typeof uischema.options.detail === 'string') {
1914
+ return uischema.options.detail.toUpperCase() !== 'DEFAULT';
1915
+ }
1916
+ else if (typeof uischema.options.detail === 'object' &&
1917
+ uischema.options.detail.type) {
1918
+ return true;
1919
+ }
1920
+ }
1572
1921
  }
1573
1922
  return false;
1574
1923
  };
1575
- var hasEnableRule = function (uischema) {
1576
- if (uischema.rule &&
1577
- (uischema.rule.effect === exports.RuleEffect.ENABLE ||
1578
- uischema.rule.effect === exports.RuleEffect.DISABLE)) {
1579
- return true;
1580
- }
1581
- return false;
1924
+ var isArrayObjectControl = isObjectArrayControl;
1925
+ var isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(function (schema, rootSchema) {
1926
+ return deriveTypes(schema).length !== 0 &&
1927
+ !Array.isArray(resolveSchema(schema, 'items', rootSchema));
1928
+ }
1929
+ ), schemaSubPathMatches('items', function (schema, rootSchema) {
1930
+ var resolvedSchema = schema.$ref
1931
+ ? resolveSchema(rootSchema, schema.$ref, rootSchema)
1932
+ : schema;
1933
+ var types = deriveTypes(resolvedSchema);
1934
+ return (types.length === 1 &&
1935
+ includes__default["default"](['integer', 'number', 'boolean', 'string'], types[0]));
1936
+ }));
1937
+ var isRangeControl = and(uiTypeIs('Control'), or(schemaTypeIs('number'), schemaTypeIs('integer')), schemaMatches(function (schema) {
1938
+ return Object.prototype.hasOwnProperty.call(schema, 'maximum') &&
1939
+ Object.prototype.hasOwnProperty.call(schema, 'minimum') &&
1940
+ Object.prototype.hasOwnProperty.call(schema, 'default');
1941
+ }), optionIs('slider', true));
1942
+ var isNumberFormatControl = and(uiTypeIs('Control'), schemaTypeIs('integer'), optionIs('format', true));
1943
+ var isCategorization = function (category) { return category.type === 'Categorization'; };
1944
+ var isCategory = function (uischema) {
1945
+ return uischema.type === 'Category';
1582
1946
  };
1583
- var isVisible = function (uischema, data, path, ajv) {
1584
- if (path === void 0) { path = undefined; }
1585
- if (uischema.rule) {
1586
- return evalVisibility(uischema, data, path, ajv);
1947
+ var hasCategory = function (categorization) {
1948
+ if (isEmpty__default["default"](categorization.elements)) {
1949
+ return false;
1587
1950
  }
1588
- return true;
1951
+ return categorization.elements
1952
+ .map(function (elem) {
1953
+ return isCategorization(elem) ? hasCategory(elem) : isCategory(elem);
1954
+ })
1955
+ .reduce(function (prev, curr) { return prev && curr; }, true);
1589
1956
  };
1590
- var isEnabled = function (uischema, data, path, ajv) {
1591
- if (path === void 0) { path = undefined; }
1592
- if (uischema.rule) {
1593
- return evalEnablement(uischema, data, path, ajv);
1594
- }
1595
- return true;
1957
+ var categorizationHasCategory = function (uischema) {
1958
+ return hasCategory(uischema);
1596
1959
  };
1597
- var isInherentlyEnabled = function (state, ownProps, uischema, schema, rootData, config) {
1598
- var _a, _b, _c;
1599
- if ((_a = state === null || state === void 0 ? void 0 : state.jsonforms) === null || _a === void 0 ? void 0 : _a.readonly) {
1600
- return false;
1601
- }
1602
- if (uischema && hasEnableRule(uischema)) {
1603
- return isEnabled(uischema, rootData, ownProps === null || ownProps === void 0 ? void 0 : ownProps.path, getAjv(state));
1604
- }
1605
- if (typeof ((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.readonly) === 'boolean') {
1606
- return !uischema.options.readonly;
1607
- }
1608
- if (typeof ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.readOnly) === 'boolean') {
1609
- return !uischema.options.readOnly;
1610
- }
1611
- if (typeof (config === null || config === void 0 ? void 0 : config.readonly) === 'boolean') {
1612
- return !config.readonly;
1613
- }
1614
- if (typeof (config === null || config === void 0 ? void 0 : config.readOnly) === 'boolean') {
1615
- return !config.readOnly;
1616
- }
1617
- if ((schema === null || schema === void 0 ? void 0 : schema.readOnly) === true) {
1618
- return false;
1619
- }
1620
- if (typeof (ownProps === null || ownProps === void 0 ? void 0 : ownProps.enabled) === 'boolean') {
1621
- return ownProps.enabled;
1622
- }
1623
- return true;
1960
+ var not = function (tester) {
1961
+ return function (uischema, schema, context) {
1962
+ return !tester(uischema, schema, context);
1963
+ };
1624
1964
  };
1625
1965
 
1626
- var convertDateToString = function (date, format) {
1627
- var dateString = date.toISOString();
1628
- if (format === 'date-time') {
1629
- return dateString;
1630
- }
1631
- else if (format === 'date') {
1632
- return dateString.split('T')[0];
1633
- }
1634
- else if (format === 'time') {
1635
- return dateString.split('T')[1].split('.')[0];
1966
+ var index = /*#__PURE__*/Object.freeze({
1967
+ __proto__: null,
1968
+ NOT_APPLICABLE: NOT_APPLICABLE,
1969
+ isControl: isControl,
1970
+ schemaMatches: schemaMatches,
1971
+ schemaSubPathMatches: schemaSubPathMatches,
1972
+ schemaTypeIs: schemaTypeIs,
1973
+ formatIs: formatIs,
1974
+ uiTypeIs: uiTypeIs,
1975
+ optionIs: optionIs,
1976
+ hasOption: hasOption,
1977
+ scopeEndsWith: scopeEndsWith,
1978
+ scopeEndIs: scopeEndIs,
1979
+ and: and,
1980
+ or: or,
1981
+ rankWith: rankWith,
1982
+ withIncreasedRank: withIncreasedRank,
1983
+ isBooleanControl: isBooleanControl,
1984
+ isObjectControl: isObjectControl,
1985
+ isAllOfControl: isAllOfControl,
1986
+ isAnyOfControl: isAnyOfControl,
1987
+ isOneOfControl: isOneOfControl,
1988
+ isEnumControl: isEnumControl,
1989
+ isOneOfEnumControl: isOneOfEnumControl,
1990
+ isIntegerControl: isIntegerControl,
1991
+ isNumberControl: isNumberControl,
1992
+ isStringControl: isStringControl,
1993
+ isMultiLineControl: isMultiLineControl,
1994
+ isDateControl: isDateControl,
1995
+ isTimeControl: isTimeControl,
1996
+ isDateTimeControl: isDateTimeControl,
1997
+ isObjectArray: isObjectArray,
1998
+ isObjectArrayControl: isObjectArrayControl,
1999
+ isObjectArrayWithNesting: isObjectArrayWithNesting,
2000
+ isArrayObjectControl: isArrayObjectControl,
2001
+ isPrimitiveArrayControl: isPrimitiveArrayControl,
2002
+ isRangeControl: isRangeControl,
2003
+ isNumberFormatControl: isNumberFormatControl,
2004
+ isCategorization: isCategorization,
2005
+ isCategory: isCategory,
2006
+ hasCategory: hasCategory,
2007
+ categorizationHasCategory: categorizationHasCategory,
2008
+ not: not
2009
+ });
2010
+
2011
+ var uischemaRegistryReducer = function (state, action) {
2012
+ if (state === void 0) { state = []; }
2013
+ switch (action.type) {
2014
+ case ADD_UI_SCHEMA:
2015
+ return state
2016
+ .slice()
2017
+ .concat({ tester: action.tester, uischema: action.uischema });
2018
+ case REMOVE_UI_SCHEMA: {
2019
+ var copy = state.slice();
2020
+ remove__default["default"](copy, function (entry) { return entry.tester === action.tester; });
2021
+ return copy;
2022
+ }
2023
+ default:
2024
+ return state;
1636
2025
  }
1637
- return dateString;
1638
- };
1639
- var convertToValidClassName = function (s) {
1640
- return s.replace('#', 'root').replace(new RegExp('/', 'g'), '_');
1641
2026
  };
1642
- var formatErrorMessage = function (errors) {
1643
- if (errors === undefined || errors === null) {
1644
- return '';
1645
- }
1646
- return errors.join('\n');
2027
+ var findMatchingUISchema = function (state) {
2028
+ return function (jsonSchema, schemaPath, path) {
2029
+ var match = maxBy__default["default"](state, function (entry) {
2030
+ return entry.tester(jsonSchema, schemaPath, path);
2031
+ });
2032
+ if (match !== undefined &&
2033
+ match.tester(jsonSchema, schemaPath, path) !== NOT_APPLICABLE) {
2034
+ return match.uischema;
2035
+ }
2036
+ return undefined;
2037
+ };
1647
2038
  };
1648
- var hasType = function (jsonSchema, expected) {
1649
- return includes__default["default"](deriveTypes(jsonSchema), expected);
2039
+
2040
+ var jsonFormsReducerConfig = {
2041
+ core: coreReducer,
2042
+ renderers: rendererReducer,
2043
+ cells: cellReducer,
2044
+ config: configReducer,
2045
+ uischemas: uischemaRegistryReducer,
2046
+ defaultData: defaultDataReducer,
2047
+ i18n: i18nReducer,
1650
2048
  };
1651
- var deriveTypes = function (jsonSchema) {
1652
- if (isEmpty__default["default"](jsonSchema)) {
1653
- return [];
1654
- }
1655
- if (!isEmpty__default["default"](jsonSchema.type) && typeof jsonSchema.type === 'string') {
1656
- return [jsonSchema.type];
1657
- }
1658
- if (isArray__default["default"](jsonSchema.type)) {
1659
- return jsonSchema.type;
1660
- }
1661
- if (!isEmpty__default["default"](jsonSchema.properties) ||
1662
- !isEmpty__default["default"](jsonSchema.additionalProperties)) {
1663
- return ['object'];
1664
- }
1665
- if (!isEmpty__default["default"](jsonSchema.items)) {
1666
- return ['array'];
1667
- }
1668
- if (!isEmpty__default["default"](jsonSchema.enum)) {
1669
- var types_1 = new Set();
1670
- jsonSchema.enum.forEach(function (enumElement) {
1671
- if (typeof enumElement === 'string') {
1672
- types_1.add('string');
2049
+ var findUISchema = function (uischemas, schema, schemaPath, path, fallback, control, rootSchema) {
2050
+ if (fallback === void 0) { fallback = 'VerticalLayout'; }
2051
+ if (control && control.options && control.options.detail) {
2052
+ if (typeof control.options.detail === 'string') {
2053
+ if (control.options.detail.toUpperCase() === 'GENERATE') {
2054
+ if (typeof fallback === 'function') {
2055
+ return fallback();
2056
+ }
2057
+ return Generate.uiSchema(schema, fallback, undefined, rootSchema);
1673
2058
  }
1674
- else {
1675
- deriveTypes(enumElement).forEach(function (type) { return types_1.add(type); });
2059
+ }
2060
+ else if (typeof control.options.detail === 'object') {
2061
+ if (control.options.detail.type &&
2062
+ typeof control.options.detail.type === 'string') {
2063
+ return control.options.detail;
1676
2064
  }
1677
- });
1678
- return Array.from(types_1);
2065
+ }
1679
2066
  }
1680
- if (!isEmpty__default["default"](jsonSchema.allOf)) {
1681
- var allOfType = find__default["default"](jsonSchema.allOf, function (schema) { return deriveTypes(schema).length !== 0; });
1682
- if (allOfType) {
1683
- return deriveTypes(allOfType);
2067
+ var uiSchema = findMatchingUISchema(uischemas)(schema, schemaPath, path);
2068
+ if (uiSchema === undefined) {
2069
+ if (typeof fallback === 'function') {
2070
+ return fallback();
1684
2071
  }
2072
+ return Generate.uiSchema(schema, fallback, '#', rootSchema);
1685
2073
  }
1686
- return [];
1687
- };
1688
- var Resolve = {
1689
- schema: resolveSchema,
1690
- data: resolveData,
1691
- };
1692
- var fromScoped = function (scopable) {
1693
- return toDataPathSegments(scopable.scope).join('.');
1694
- };
1695
- var Paths = {
1696
- compose: compose,
1697
- fromScoped: fromScoped,
1698
- };
1699
- var Runtime = {
1700
- isEnabled: function (uischema, data, ajv) {
1701
- return isEnabled(uischema, data, undefined, ajv);
1702
- },
1703
- isVisible: function (uischema, data, ajv) {
1704
- return isVisible(uischema, data, undefined, ajv);
1705
- },
2074
+ return uiSchema;
1706
2075
  };
1707
2076
 
1708
- var getFirstPrimitiveProp = function (schema) {
1709
- if (schema.properties) {
1710
- return find__default["default"](Object.keys(schema.properties), function (propName) {
1711
- var prop = schema.properties[propName];
1712
- return (prop.type === 'string' ||
1713
- prop.type === 'number' ||
1714
- prop.type === 'integer');
1715
- });
1716
- }
1717
- return undefined;
1718
- };
1719
- var isOneOfEnumSchema = function (schema) {
1720
- return !!schema &&
1721
- Object.prototype.hasOwnProperty.call(schema, 'oneOf') &&
1722
- schema.oneOf &&
1723
- schema.oneOf.every(function (s) { return s.const !== undefined; });
1724
- };
1725
- var isEnumSchema = function (schema) {
1726
- return !!schema &&
1727
- typeof schema === 'object' &&
1728
- (Object.prototype.hasOwnProperty.call(schema, 'enum') ||
1729
- Object.prototype.hasOwnProperty.call(schema, 'const'));
2077
+ var defaultMiddleware = function (state, action, defaultReducer) {
2078
+ return defaultReducer(state, action);
1730
2079
  };
1731
2080
 
1732
- var setReadonlyPropertyValue = function (value) {
1733
- return function (child) {
1734
- if (!child.options) {
1735
- child.options = {};
1736
- }
1737
- child.options.readonly = value;
2081
+ var getErrorsAt = function (instancePath, schema, matchPath) {
2082
+ return function (state) {
2083
+ var _a, _b;
2084
+ var errors = (_a = state.errors) !== null && _a !== void 0 ? _a : [];
2085
+ var additionalErrors = (_b = state.additionalErrors) !== null && _b !== void 0 ? _b : [];
2086
+ return errorsAt(instancePath, schema, matchPath)(state.validationMode === 'ValidateAndHide'
2087
+ ? additionalErrors
2088
+ : __spreadArray(__spreadArray([], errors, true), additionalErrors, true));
1738
2089
  };
1739
2090
  };
1740
- var setReadonly = function (uischema) {
1741
- iterateSchema(uischema, setReadonlyPropertyValue(true));
1742
- };
1743
- var unsetReadonly = function (uischema) {
1744
- iterateSchema(uischema, setReadonlyPropertyValue(false));
2091
+ var errorAt = function (instancePath, schema) {
2092
+ return getErrorsAt(instancePath, schema, function (path) { return path === instancePath; });
1745
2093
  };
1746
- var iterateSchema = function (uischema, toApply) {
1747
- if (isEmpty__default["default"](uischema)) {
1748
- return;
1749
- }
1750
- if (isLayout(uischema)) {
1751
- uischema.elements.forEach(function (child) { return iterateSchema(child, toApply); });
1752
- return;
1753
- }
1754
- toApply(uischema);
2094
+ var subErrorsAt = function (instancePath, schema) {
2095
+ return getErrorsAt(instancePath, schema, function (path) {
2096
+ return path.startsWith(instancePath + '.');
2097
+ });
1755
2098
  };
1756
- var getPropPath = function (path) {
1757
- return "/properties/".concat(path
1758
- .split('.')
1759
- .map(function (p) { return encode(p); })
1760
- .join('/properties/'));
2099
+ var getErrorAt = function (instancePath, schema) { return function (state) {
2100
+ return errorAt(instancePath, schema)(state.jsonforms.core);
2101
+ }; };
2102
+ var getSubErrorsAt = function (instancePath, schema) { return function (state) {
2103
+ return subErrorsAt(instancePath, schema)(state.jsonforms.core);
2104
+ }; };
2105
+ var getData = function (state) {
2106
+ return extractData(get__default["default"](state, 'jsonforms.core'));
1761
2107
  };
1762
- var findUiControl = function (uiSchema, path) {
1763
- var _a;
1764
- if (isControlElement(uiSchema)) {
1765
- if (isScoped(uiSchema) && uiSchema.scope.endsWith(getPropPath(path))) {
1766
- return uiSchema;
1767
- }
1768
- else if ((_a = uiSchema.options) === null || _a === void 0 ? void 0 : _a.detail) {
1769
- return findUiControl(uiSchema.options.detail, path);
1770
- }
1771
- }
1772
- if (isLayout(uiSchema)) {
1773
- for (var _i = 0, _b = uiSchema.elements; _i < _b.length; _i++) {
1774
- var elem = _b[_i];
1775
- var result = findUiControl(elem, path);
1776
- if (result !== undefined)
1777
- return result;
1778
- }
1779
- }
1780
- return undefined;
2108
+ var getSchema = function (state) {
2109
+ return extractSchema(get__default["default"](state, 'jsonforms.core'));
1781
2110
  };
1782
-
1783
- var deriveLabel = function (controlElement, schemaElement) {
1784
- if (schemaElement && typeof schemaElement.title === 'string') {
1785
- return schemaElement.title;
1786
- }
1787
- if (typeof controlElement.scope === 'string') {
1788
- var ref = controlElement.scope;
1789
- var label = decode(ref.substr(ref.lastIndexOf('/') + 1));
1790
- return startCase__default["default"](label);
1791
- }
1792
- return '';
2111
+ var getUiSchema = function (state) {
2112
+ return extractUiSchema(get__default["default"](state, 'jsonforms.core'));
1793
2113
  };
1794
- var createCleanLabel = function (label) {
1795
- return startCase__default["default"](label.replace('_', ' '));
2114
+ var getAjv = function (state) {
2115
+ return extractAjv(get__default["default"](state, 'jsonforms.core'));
1796
2116
  };
1797
- var createLabelDescriptionFrom = function (withLabel, schema) {
1798
- var labelProperty = withLabel.label;
1799
- if (typeof labelProperty === 'boolean') {
1800
- return labelDescription(deriveLabel(withLabel, schema), labelProperty);
2117
+ var getRenderers = function (state) { return get__default["default"](state, 'jsonforms.renderers'); };
2118
+ var getCells = function (state) { return get__default["default"](state, 'jsonforms.cells'); };
2119
+ var getUISchemas = function (state) { return get__default["default"](state, 'jsonforms.uischemas'); };
2120
+ var extractData = function (state) { return get__default["default"](state, 'data'); };
2121
+ var extractSchema = function (state) { return get__default["default"](state, 'schema'); };
2122
+ var extractUiSchema = function (state) { return get__default["default"](state, 'uischema'); };
2123
+ var extractAjv = function (state) { return get__default["default"](state, 'ajv'); };
2124
+ var getConfig = function (state) { return state.jsonforms.config; };
2125
+
2126
+ var isInherentlyEnabled = function (state, ownProps, uischema, schema, rootData, config) {
2127
+ var _a, _b, _c;
2128
+ if ((_a = state === null || state === void 0 ? void 0 : state.jsonforms) === null || _a === void 0 ? void 0 : _a.readonly) {
2129
+ return false;
1801
2130
  }
1802
- if (typeof labelProperty === 'string') {
1803
- return labelDescription(labelProperty, true);
2131
+ if (uischema && hasEnableRule(uischema)) {
2132
+ return isEnabled(uischema, rootData, ownProps === null || ownProps === void 0 ? void 0 : ownProps.path, getAjv(state));
1804
2133
  }
1805
- if (typeof labelProperty === 'object') {
1806
- var label = typeof labelProperty.text === 'string'
1807
- ? labelProperty.text
1808
- : deriveLabel(withLabel, schema);
1809
- var show = typeof labelProperty.show === 'boolean' ? labelProperty.show : true;
1810
- return labelDescription(label, show);
2134
+ if (typeof ((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.readonly) === 'boolean') {
2135
+ return !uischema.options.readonly;
1811
2136
  }
1812
- return labelDescription(deriveLabel(withLabel, schema), true);
1813
- };
1814
- var labelDescription = function (text, show) { return ({
1815
- text: text,
1816
- show: show,
1817
- }); };
1818
- var computeChildLabel = function (data, childPath, childLabelProp, schema, rootSchema, translateFct, uiSchema) {
1819
- var childData = Resolve.data(data, childPath);
1820
- if (!childLabelProp) {
1821
- childLabelProp = getFirstPrimitiveProp(schema);
2137
+ if (typeof ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.readOnly) === 'boolean') {
2138
+ return !uischema.options.readOnly;
1822
2139
  }
1823
- if (!childLabelProp) {
1824
- return '';
2140
+ if (typeof (config === null || config === void 0 ? void 0 : config.readonly) === 'boolean') {
2141
+ return !config.readonly;
1825
2142
  }
1826
- var currentValue = get__default["default"](childData, childLabelProp);
1827
- if (currentValue === undefined) {
1828
- return '';
2143
+ if (typeof (config === null || config === void 0 ? void 0 : config.readOnly) === 'boolean') {
2144
+ return !config.readOnly;
1829
2145
  }
1830
- var childSchema = Resolve.schema(schema, '#' + getPropPath(childLabelProp), rootSchema);
1831
- var enumOption = undefined;
1832
- if (isEnumSchema(childSchema)) {
1833
- enumOption = enumToEnumOptionMapper(currentValue, translateFct, getI18nKeyPrefix(childSchema, findUiControl(uiSchema, childLabelProp), childPath + '.' + childLabelProp));
2146
+ if ((schema === null || schema === void 0 ? void 0 : schema.readOnly) === true) {
2147
+ return false;
1834
2148
  }
1835
- else if (isOneOfEnumSchema(childSchema)) {
1836
- var oneOfArray = childSchema.oneOf;
1837
- var oneOfSchema = oneOfArray.find(function (e) {
1838
- return isEqual__default["default"](e.const, currentValue);
1839
- });
1840
- if (oneOfSchema) {
1841
- enumOption = oneOfToEnumOptionMapper(oneOfSchema, translateFct, getI18nKeyPrefix(oneOfSchema, undefined, childPath + '.' + childLabelProp));
1842
- }
2149
+ if (typeof (ownProps === null || ownProps === void 0 ? void 0 : ownProps.enabled) === 'boolean') {
2150
+ return ownProps.enabled;
1843
2151
  }
1844
- return enumOption ? enumOption.label : currentValue;
2152
+ return true;
1845
2153
  };
1846
2154
 
2155
+ var move = function (array, index, delta) {
2156
+ var newIndex = index + delta;
2157
+ if (newIndex < 0 || newIndex >= array.length) {
2158
+ return;
2159
+ }
2160
+ var indexes = [index, newIndex].sort(function (a, b) { return a - b; });
2161
+ array.splice(indexes[0], 2, array[indexes[1]], array[indexes[0]]);
2162
+ };
2163
+ var moveUp = function (array, toMove) {
2164
+ move(array, toMove, -1);
2165
+ };
2166
+ var moveDown = function (array, toMove) {
2167
+ move(array, toMove, 1);
2168
+ };
1847
2169
  var isRequired = function (schema, schemaPath, rootSchema) {
1848
2170
  var pathSegments = schemaPath.split('/');
1849
- var lastSegment = pathSegments[pathSegments.length - 1];
2171
+ var lastSegment = decode(pathSegments[pathSegments.length - 1]);
1850
2172
  var nextHigherSchemaSegments = pathSegments.slice(0, pathSegments.length - 2);
1851
2173
  var nextHigherSchemaPath = nextHigherSchemaSegments.join('/');
1852
2174
  var nextHigherSchema = Resolve.schema(schema, nextHigherSchemaPath, rootSchema);
@@ -2118,563 +2440,242 @@ var layoutDefaultProps = {
2118
2440
  visible: true,
2119
2441
  enabled: true,
2120
2442
  path: '',
2121
- direction: 'column',
2122
- };
2123
- var getDirection = function (uischema) {
2124
- if (uischema.type === 'HorizontalLayout') {
2125
- return 'row';
2126
- }
2127
- if (uischema.type === 'VerticalLayout') {
2128
- return 'column';
2129
- }
2130
- return layoutDefaultProps.direction;
2131
- };
2132
- var mapStateToLayoutProps = function (state, ownProps) {
2133
- var _a;
2134
- var rootData = getData(state);
2135
- var uischema = ownProps.uischema;
2136
- var visible = ownProps.visible === undefined || hasShowRule(uischema)
2137
- ? isVisible(ownProps.uischema, rootData, ownProps.path, getAjv(state))
2138
- : ownProps.visible;
2139
- var data = Resolve.data(rootData, ownProps.path);
2140
- var config = getConfig(state);
2141
- var enabled = isInherentlyEnabled(state, ownProps, uischema, undefined,
2142
- rootData, config);
2143
- var t = getTranslator()(state);
2144
- var label = isLabelable(uischema)
2145
- ? deriveLabelForUISchemaElement(uischema, t)
2146
- : undefined;
2147
- return __assign(__assign({}, layoutDefaultProps), { renderers: ownProps.renderers || getRenderers(state), cells: ownProps.cells || getCells(state), visible: visible, enabled: enabled, path: ownProps.path, data: data, uischema: ownProps.uischema, schema: ownProps.schema, direction: (_a = ownProps.direction) !== null && _a !== void 0 ? _a : getDirection(uischema), config: config, label: label });
2148
- };
2149
- var mapStateToJsonFormsRendererProps = function (state, ownProps) {
2150
- return {
2151
- renderers: ownProps.renderers || get__default["default"](state.jsonforms, 'renderers'),
2152
- cells: ownProps.cells || get__default["default"](state.jsonforms, 'cells'),
2153
- schema: ownProps.schema || getSchema(state),
2154
- rootSchema: getSchema(state),
2155
- uischema: ownProps.uischema || getUiSchema(state),
2156
- path: ownProps.path,
2157
- enabled: ownProps.enabled,
2158
- config: getConfig(state),
2159
- };
2160
- };
2161
- var controlDefaultProps = __assign(__assign({}, layoutDefaultProps), { errors: [] });
2162
- var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
2163
- var _a;
2164
- var _b = mapStateToControlProps(state, ownProps), data = _b.data, schema = _b.schema, rootSchema = _b.rootSchema, i18nKeyPrefix = _b.i18nKeyPrefix, label = _b.label, props = __rest(_b, ["data", "schema", "rootSchema", "i18nKeyPrefix", "label"]);
2165
- var ajv = state.jsonforms.core.ajv;
2166
- var t = getTranslator()(state);
2167
- var translations = getCombinatorTranslations(t, combinatorDefaultTranslations, i18nKeyPrefix, label);
2168
- var structuralKeywords = [
2169
- 'required',
2170
- 'additionalProperties',
2171
- 'type',
2172
- 'enum',
2173
- 'const',
2174
- ];
2175
- var dataIsValid = function (errors) {
2176
- return (!errors ||
2177
- errors.length === 0 ||
2178
- !errors.find(function (e) { return structuralKeywords.indexOf(e.keyword) !== -1; }));
2179
- };
2180
- var indexOfFittingSchema;
2181
- for (var i = 0; i < ((_a = schema[keyword]) === null || _a === void 0 ? void 0 : _a.length); i++) {
2182
- try {
2183
- var _schema = schema[keyword][i];
2184
- if (_schema.$ref) {
2185
- _schema = Resolve.schema(rootSchema, _schema.$ref, rootSchema);
2186
- }
2187
- var valFn = ajv.compile(_schema);
2188
- valFn(data);
2189
- if (dataIsValid(valFn.errors)) {
2190
- indexOfFittingSchema = i;
2191
- break;
2192
- }
2193
- }
2194
- catch (error) {
2195
- console.debug("Combinator subschema is not self contained, can't hand it over to AJV");
2196
- }
2197
- }
2198
- return __assign(__assign({ data: data, schema: schema, rootSchema: rootSchema }, props), { i18nKeyPrefix: i18nKeyPrefix, label: label, indexOfFittingSchema: indexOfFittingSchema, uischemas: getUISchemas(state), translations: translations });
2199
- };
2200
- var mapStateToAllOfProps = function (state, ownProps) {
2201
- return mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
2202
- };
2203
- var mapStateToAnyOfProps = function (state, ownProps) {
2204
- return mapStateToCombinatorRendererProps(state, ownProps, 'anyOf');
2205
- };
2206
- var mapStateToOneOfProps = function (state, ownProps) {
2207
- return mapStateToCombinatorRendererProps(state, ownProps, 'oneOf');
2208
- };
2209
- var mapStateToArrayLayoutProps = function (state, ownProps) {
2210
- var _a = mapStateToControlWithDetailProps(state, ownProps), path = _a.path, schema = _a.schema, uischema = _a.uischema, errors = _a.errors, i18nKeyPrefix = _a.i18nKeyPrefix, label = _a.label, props = __rest(_a, ["path", "schema", "uischema", "errors", "i18nKeyPrefix", "label"]);
2211
- var resolvedSchema = Resolve.schema(schema, 'items', props.rootSchema);
2212
- var t = getTranslator()(state);
2213
- var childErrors = getCombinedErrorMessage(getSubErrorsAt(path, resolvedSchema)(state), getErrorTranslator()(state), t, undefined, undefined, undefined);
2214
- var allErrors = errors +
2215
- (errors.length > 0 && childErrors.length > 0 ? '\n' : '') +
2216
- childErrors;
2217
- return __assign(__assign({}, props), { label: label, path: path, uischema: uischema, schema: resolvedSchema, data: props.data ? props.data.length : 0, errors: allErrors, minItems: schema.minItems, translations: getArrayTranslations(t, arrayDefaultTranslations, i18nKeyPrefix, label) });
2218
- };
2219
- var mapStateToLabelProps = function (state, props) {
2220
- var uischema = props.uischema;
2221
- var visible = props.visible === undefined || hasShowRule(uischema)
2222
- ? isVisible(props.uischema, getData(state), props.path, getAjv(state))
2223
- : props.visible;
2224
- var text = uischema.text;
2225
- var t = getTranslator()(state);
2226
- var i18nKeyPrefix = getI18nKeyPrefixBySchema(undefined, uischema);
2227
- var i18nKey = i18nKeyPrefix ? "".concat(i18nKeyPrefix, ".text") : text !== null && text !== void 0 ? text : '';
2228
- var i18nText = t(i18nKey, text, { uischema: uischema });
2229
- return {
2230
- text: i18nText,
2231
- visible: visible,
2232
- config: getConfig(state),
2233
- renderers: props.renderers || getRenderers(state),
2234
- cells: props.cells || getCells(state),
2235
- };
2236
- };
2237
-
2238
- var mapStateToCellProps = function (state, ownProps) {
2239
- var id = ownProps.id, schema = ownProps.schema, path = ownProps.path, uischema = ownProps.uischema, renderers = ownProps.renderers, cells = ownProps.cells;
2240
- var rootData = getData(state);
2241
- var visible = ownProps.visible !== undefined
2242
- ? ownProps.visible
2243
- : isVisible(uischema, rootData, undefined, getAjv(state));
2244
- var rootSchema = getSchema(state);
2245
- var config = getConfig(state);
2246
- var enabled;
2247
- if (state.jsonforms.readonly === true) {
2248
- enabled = false;
2249
- }
2250
- else if (typeof ownProps.enabled === 'boolean') {
2251
- enabled = ownProps.enabled;
2252
- }
2253
- else {
2254
- enabled = isInherentlyEnabled(state, ownProps, uischema, schema || rootSchema, rootData, config);
2255
- }
2256
- var t = getTranslator()(state);
2257
- var te = getErrorTranslator()(state);
2258
- var errors = getCombinedErrorMessage(getErrorAt(path, schema)(state), te, t, schema, uischema, path);
2259
- var isValid = isEmpty__default["default"](errors);
2260
- return {
2261
- data: Resolve.data(rootData, path),
2262
- visible: visible,
2263
- enabled: enabled,
2264
- id: id,
2265
- path: path,
2266
- errors: errors,
2267
- isValid: isValid,
2268
- schema: schema,
2269
- uischema: uischema,
2270
- config: getConfig(state),
2271
- rootSchema: rootSchema,
2272
- renderers: renderers,
2273
- cells: cells,
2274
- };
2275
- };
2276
- var mapStateToDispatchCellProps = function (state, ownProps) {
2277
- var props = mapStateToCellProps(state, ownProps);
2278
- ownProps.renderers; var cells = ownProps.cells, otherOwnProps = __rest(ownProps, ["renderers", "cells"]);
2279
- return __assign(__assign(__assign({}, props), otherOwnProps), { cells: cells || state.jsonforms.cells || [] });
2280
- };
2281
- var defaultMapStateToEnumCellProps = function (state, ownProps) {
2282
- var _a;
2283
- var props = mapStateToCellProps(state, ownProps);
2284
- var options = ownProps.options ||
2285
- ((_a = props.schema.enum) === null || _a === void 0 ? void 0 : _a.map(function (e) {
2286
- return enumToEnumOptionMapper(e, getTranslator()(state), getI18nKeyPrefix(props.schema, props.uischema, props.path));
2287
- })) ||
2288
- (props.schema.const && [
2289
- enumToEnumOptionMapper(props.schema.const, getTranslator()(state), getI18nKeyPrefix(props.schema, props.uischema, props.path)),
2290
- ]);
2291
- return __assign(__assign({}, props), { options: options });
2292
- };
2293
- var mapStateToOneOfEnumCellProps = function (state, ownProps) {
2294
- var _a;
2295
- var props = mapStateToCellProps(state, ownProps);
2296
- var options = ownProps.options ||
2297
- ((_a = props.schema.oneOf) === null || _a === void 0 ? void 0 : _a.map(function (oneOfSubSchema) {
2298
- return oneOfToEnumOptionMapper(oneOfSubSchema, getTranslator()(state), getI18nKeyPrefix(props.schema, props.uischema, props.path));
2299
- }));
2300
- return __assign(__assign({}, props), { options: options });
2301
- };
2302
- var mapDispatchToCellProps = mapDispatchToControlProps;
2303
- var defaultMapDispatchToControlProps =
2304
- function (dispatch, ownProps) {
2305
- var handleChange = mapDispatchToCellProps(dispatch).handleChange;
2306
- return {
2307
- handleChange: ownProps.handleChange || handleChange,
2308
- };
2309
- };
2310
-
2311
- var createCombinatorRenderInfos = function (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) {
2312
- return combinatorSubSchemas.map(function (subSchema, subSchemaIndex) {
2313
- var _a, _b;
2314
- var resolvedSubSchema = subSchema.$ref && Resolve.schema(rootSchema, subSchema.$ref, rootSchema);
2315
- var schema = resolvedSubSchema !== null && resolvedSubSchema !== void 0 ? resolvedSubSchema : subSchema;
2316
- return {
2317
- schema: schema,
2318
- uischema: findUISchema(uischemas, schema, control.scope, path, undefined, control, rootSchema),
2319
- label: (_b = (_a = subSchema.title) !== null && _a !== void 0 ? _a : resolvedSubSchema === null || resolvedSubSchema === void 0 ? void 0 : resolvedSubSchema.title) !== null && _b !== void 0 ? _b : "".concat(keyword, "-").concat(subSchemaIndex),
2320
- };
2321
- });
2322
- };
2323
-
2324
- var usedIds = new Set();
2325
- var makeId = function (idBase, iteration) {
2326
- return iteration <= 1 ? idBase : idBase + iteration.toString();
2327
- };
2328
- var isUniqueId = function (idBase, iteration) {
2329
- var newID = makeId(idBase, iteration);
2330
- return !usedIds.has(newID);
2331
- };
2332
- var createId = function (proposedId) {
2333
- if (proposedId === undefined) {
2334
- proposedId = 'undefined';
2443
+ direction: 'column',
2444
+ };
2445
+ var getDirection = function (uischema) {
2446
+ if (uischema.type === 'HorizontalLayout') {
2447
+ return 'row';
2335
2448
  }
2336
- var tries = 0;
2337
- while (!isUniqueId(proposedId, tries)) {
2338
- tries++;
2449
+ if (uischema.type === 'VerticalLayout') {
2450
+ return 'column';
2339
2451
  }
2340
- var newID = makeId(proposedId, tries);
2341
- usedIds.add(newID);
2342
- return newID;
2452
+ return layoutDefaultProps.direction;
2343
2453
  };
2344
- var removeId = function (id) { return usedIds.delete(id); };
2345
- var clearAllIds = function () { return usedIds.clear(); };
2346
-
2347
- var createAjv = function (options) {
2348
- var ajv = new Ajv__default["default"](__assign({ allErrors: true, verbose: true, strict: false, addUsedSchema: false }, options));
2349
- addFormats__default["default"](ajv);
2350
- return ajv;
2454
+ var mapStateToLayoutProps = function (state, ownProps) {
2455
+ var _a;
2456
+ var rootData = getData(state);
2457
+ var uischema = ownProps.uischema;
2458
+ var visible = ownProps.visible === undefined || hasShowRule(uischema)
2459
+ ? isVisible(ownProps.uischema, rootData, ownProps.path, getAjv(state))
2460
+ : ownProps.visible;
2461
+ var data = Resolve.data(rootData, ownProps.path);
2462
+ var config = getConfig(state);
2463
+ var enabled = isInherentlyEnabled(state, ownProps, uischema, undefined,
2464
+ rootData, config);
2465
+ var t = getTranslator()(state);
2466
+ var label = isLabelable(uischema)
2467
+ ? deriveLabelForUISchemaElement(uischema, t)
2468
+ : undefined;
2469
+ return __assign(__assign({}, layoutDefaultProps), { renderers: ownProps.renderers || getRenderers(state), cells: ownProps.cells || getCells(state), visible: visible, enabled: enabled, path: ownProps.path, data: data, uischema: ownProps.uischema, schema: ownProps.schema, direction: (_a = ownProps.direction) !== null && _a !== void 0 ? _a : getDirection(uischema), config: config, label: label });
2351
2470
  };
2352
-
2353
- var defaultDateFormat = 'YYYY-MM-DD';
2354
- var defaultTimeFormat = 'HH:mm:ss';
2355
- var defaultDateTimeFormat = 'YYYY-MM-DDTHH:mm:ss.sssZ';
2356
-
2357
- var createLayout = function (layoutType) { return ({
2358
- type: layoutType,
2359
- elements: [],
2360
- }); };
2361
- var createControlElement = function (ref) { return ({
2362
- type: 'Control',
2363
- scope: ref,
2364
- }); };
2365
- var wrapInLayoutIfNecessary = function (uischema, layoutType) {
2366
- if (!isEmpty__default["default"](uischema) && !isLayout(uischema)) {
2367
- var verticalLayout = createLayout(layoutType);
2368
- verticalLayout.elements.push(uischema);
2369
- return verticalLayout;
2370
- }
2371
- return uischema;
2471
+ var mapStateToJsonFormsRendererProps = function (state, ownProps) {
2472
+ return {
2473
+ renderers: ownProps.renderers || get__default["default"](state.jsonforms, 'renderers'),
2474
+ cells: ownProps.cells || get__default["default"](state.jsonforms, 'cells'),
2475
+ schema: ownProps.schema || getSchema(state),
2476
+ rootSchema: getSchema(state),
2477
+ uischema: ownProps.uischema || getUiSchema(state),
2478
+ path: ownProps.path,
2479
+ enabled: ownProps.enabled,
2480
+ config: getConfig(state),
2481
+ };
2372
2482
  };
2373
- var addLabel = function (layout, labelName) {
2374
- if (!isEmpty__default["default"](labelName)) {
2375
- var fixedLabel = startCase__default["default"](labelName);
2376
- if (isGroup(layout)) {
2377
- layout.label = fixedLabel;
2483
+ var controlDefaultProps = __assign(__assign({}, layoutDefaultProps), { errors: [] });
2484
+ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
2485
+ var _a;
2486
+ var _b = mapStateToControlProps(state, ownProps), data = _b.data, schema = _b.schema, rootSchema = _b.rootSchema, i18nKeyPrefix = _b.i18nKeyPrefix, label = _b.label, props = __rest(_b, ["data", "schema", "rootSchema", "i18nKeyPrefix", "label"]);
2487
+ var ajv = state.jsonforms.core.ajv;
2488
+ var t = getTranslator()(state);
2489
+ var translations = getCombinatorTranslations(t, combinatorDefaultTranslations, i18nKeyPrefix, label);
2490
+ var structuralKeywords = [
2491
+ 'required',
2492
+ 'additionalProperties',
2493
+ 'type',
2494
+ 'enum',
2495
+ 'const',
2496
+ ];
2497
+ var dataIsValid = function (errors) {
2498
+ return (!errors ||
2499
+ errors.length === 0 ||
2500
+ !errors.find(function (e) { return structuralKeywords.indexOf(e.keyword) !== -1; }));
2501
+ };
2502
+ var indexOfFittingSchema;
2503
+ for (var i = 0; i < ((_a = schema[keyword]) === null || _a === void 0 ? void 0 : _a.length); i++) {
2504
+ try {
2505
+ var _schema = schema[keyword][i];
2506
+ if (_schema.$ref) {
2507
+ _schema = Resolve.schema(rootSchema, _schema.$ref, rootSchema);
2508
+ }
2509
+ var valFn = ajv.compile(_schema);
2510
+ valFn(data);
2511
+ if (dataIsValid(valFn.errors)) {
2512
+ indexOfFittingSchema = i;
2513
+ break;
2514
+ }
2378
2515
  }
2379
- else {
2380
- var label = {
2381
- type: 'Label',
2382
- text: fixedLabel,
2383
- };
2384
- layout.elements.push(label);
2516
+ catch (error) {
2517
+ console.debug("Combinator subschema is not self contained, can't hand it over to AJV");
2385
2518
  }
2386
2519
  }
2520
+ return __assign(__assign({ data: data, schema: schema, rootSchema: rootSchema }, props), { i18nKeyPrefix: i18nKeyPrefix, label: label, indexOfFittingSchema: indexOfFittingSchema, uischemas: getUISchemas(state), translations: translations });
2387
2521
  };
2388
- var isCombinator = function (jsonSchema) {
2389
- return (!isEmpty__default["default"](jsonSchema) &&
2390
- (!isEmpty__default["default"](jsonSchema.oneOf) ||
2391
- !isEmpty__default["default"](jsonSchema.anyOf) ||
2392
- !isEmpty__default["default"](jsonSchema.allOf)));
2522
+ var mapStateToAllOfProps = function (state, ownProps) {
2523
+ return mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
2393
2524
  };
2394
- var generateUISchema = function (jsonSchema, schemaElements, currentRef, schemaName, layoutType, rootSchema) {
2395
- if (!isEmpty__default["default"](jsonSchema) && jsonSchema.$ref !== undefined) {
2396
- return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref, rootSchema), schemaElements, currentRef, schemaName, layoutType, rootSchema);
2397
- }
2398
- if (isCombinator(jsonSchema)) {
2399
- var controlObject = createControlElement(currentRef);
2400
- schemaElements.push(controlObject);
2401
- return controlObject;
2402
- }
2403
- var types = deriveTypes(jsonSchema);
2404
- if (types.length === 0) {
2405
- return null;
2406
- }
2407
- if (types.length > 1) {
2408
- var controlObject = createControlElement(currentRef);
2409
- schemaElements.push(controlObject);
2410
- return controlObject;
2411
- }
2412
- if (currentRef === '#' && types[0] === 'object') {
2413
- var layout_1 = createLayout(layoutType);
2414
- schemaElements.push(layout_1);
2415
- if (jsonSchema.properties && keys__default["default"](jsonSchema.properties).length > 1) {
2416
- addLabel(layout_1, schemaName);
2417
- }
2418
- if (!isEmpty__default["default"](jsonSchema.properties)) {
2419
- var nextRef_1 = currentRef + '/properties';
2420
- Object.keys(jsonSchema.properties).map(function (propName) {
2421
- var value = jsonSchema.properties[propName];
2422
- var ref = "".concat(nextRef_1, "/").concat(encode(propName));
2423
- if (value.$ref !== undefined) {
2424
- value = resolveSchema(rootSchema, value.$ref, rootSchema);
2425
- }
2426
- generateUISchema(value, layout_1.elements, ref, propName, layoutType, rootSchema);
2427
- });
2428
- }
2429
- return layout_1;
2430
- }
2431
- switch (types[0]) {
2432
- case 'object':
2433
- case 'array':
2434
- case 'string':
2435
- case 'number':
2436
- case 'integer':
2437
- case 'null':
2438
- case 'boolean': {
2439
- var controlObject = createControlElement(currentRef);
2440
- schemaElements.push(controlObject);
2441
- return controlObject;
2442
- }
2443
- default:
2444
- throw new Error('Unknown type: ' + JSON.stringify(jsonSchema));
2445
- }
2525
+ var mapStateToAnyOfProps = function (state, ownProps) {
2526
+ return mapStateToCombinatorRendererProps(state, ownProps, 'anyOf');
2446
2527
  };
2447
- var generateDefaultUISchema = function (jsonSchema, layoutType, prefix, rootSchema) {
2448
- if (layoutType === void 0) { layoutType = 'VerticalLayout'; }
2449
- if (prefix === void 0) { prefix = '#'; }
2450
- if (rootSchema === void 0) { rootSchema = jsonSchema; }
2451
- return wrapInLayoutIfNecessary(generateUISchema(jsonSchema, [], prefix, '', layoutType, rootSchema), layoutType);
2528
+ var mapStateToOneOfProps = function (state, ownProps) {
2529
+ return mapStateToCombinatorRendererProps(state, ownProps, 'oneOf');
2452
2530
  };
2453
-
2454
- var Generate = {
2455
- jsonSchema: generateJsonSchema,
2456
- uiSchema: generateDefaultUISchema,
2457
- controlElement: createControlElement,
2531
+ var mapStateToArrayLayoutProps = function (state, ownProps) {
2532
+ var _a = mapStateToControlWithDetailProps(state, ownProps), path = _a.path, schema = _a.schema, uischema = _a.uischema, errors = _a.errors, i18nKeyPrefix = _a.i18nKeyPrefix, label = _a.label, props = __rest(_a, ["path", "schema", "uischema", "errors", "i18nKeyPrefix", "label"]);
2533
+ var resolvedSchema = Resolve.schema(schema, 'items', props.rootSchema);
2534
+ var t = getTranslator()(state);
2535
+ var childErrors = getCombinedErrorMessage(getSubErrorsAt(path, resolvedSchema)(state), getErrorTranslator()(state), t, undefined, undefined, undefined);
2536
+ var allErrors = errors +
2537
+ (errors.length > 0 && childErrors.length > 0 ? '\n' : '') +
2538
+ childErrors;
2539
+ return __assign(__assign({}, props), { label: label, path: path, uischema: uischema, schema: resolvedSchema, data: props.data ? props.data.length : 0, errors: allErrors, minItems: schema.minItems, translations: getArrayTranslations(t, arrayDefaultTranslations, i18nKeyPrefix, label) });
2458
2540
  };
2459
-
2460
- var INIT = 'jsonforms/INIT';
2461
- var UPDATE_CORE = 'jsonforms/UPDATE_CORE';
2462
- var SET_AJV = 'jsonforms/SET_AJV';
2463
- var UPDATE_DATA = 'jsonforms/UPDATE';
2464
- var UPDATE_ERRORS = 'jsonforms/UPDATE_ERRORS';
2465
- var VALIDATE = 'jsonforms/VALIDATE';
2466
- var ADD_RENDERER = 'jsonforms/ADD_RENDERER';
2467
- var REMOVE_RENDERER = 'jsonforms/REMOVE_RENDERER';
2468
- var ADD_CELL = 'jsonforms/ADD_CELL';
2469
- var REMOVE_CELL = 'jsonforms/REMOVE_CELL';
2470
- var SET_CONFIG = 'jsonforms/SET_CONFIG';
2471
- var ADD_UI_SCHEMA = 'jsonforms/ADD_UI_SCHEMA';
2472
- var REMOVE_UI_SCHEMA = 'jsonforms/REMOVE_UI_SCHEMA';
2473
- var SET_SCHEMA = 'jsonforms/SET_SCHEMA';
2474
- var SET_UISCHEMA = 'jsonforms/SET_UISCHEMA';
2475
- var SET_VALIDATION_MODE = 'jsonforms/SET_VALIDATION_MODE';
2476
- var SET_LOCALE = 'jsonforms/SET_LOCALE';
2477
- var SET_TRANSLATOR = 'jsonforms/SET_TRANSLATOR';
2478
- var UPDATE_I18N = 'jsonforms/UPDATE_I18N';
2479
- var ADD_DEFAULT_DATA = 'jsonforms/ADD_DEFAULT_DATA';
2480
- var REMOVE_DEFAULT_DATA = 'jsonforms/REMOVE_DEFAULT_DATA';
2481
- var isUpdateArrayContext = function (context) {
2482
- if (!('type' in context)) {
2483
- return false;
2541
+ var mapStateToLabelProps = function (state, props) {
2542
+ var uischema = props.uischema;
2543
+ var visible = props.visible === undefined || hasShowRule(uischema)
2544
+ ? isVisible(props.uischema, getData(state), props.path, getAjv(state))
2545
+ : props.visible;
2546
+ var text = uischema.text;
2547
+ var t = getTranslator()(state);
2548
+ var i18nKeyPrefix = getI18nKeyPrefixBySchema(undefined, uischema);
2549
+ var i18nKey = i18nKeyPrefix ? "".concat(i18nKeyPrefix, ".text") : text !== null && text !== void 0 ? text : '';
2550
+ var i18nText = t(i18nKey, text, { uischema: uischema });
2551
+ return {
2552
+ text: i18nText,
2553
+ visible: visible,
2554
+ config: getConfig(state),
2555
+ renderers: props.renderers || getRenderers(state),
2556
+ cells: props.cells || getCells(state),
2557
+ };
2558
+ };
2559
+ var computeChildLabel = function (data, childPath, childLabelProp, schema, rootSchema, translateFct, uiSchema) {
2560
+ var childData = Resolve.data(data, childPath);
2561
+ if (!childLabelProp) {
2562
+ childLabelProp = getFirstPrimitiveProp(schema);
2484
2563
  }
2485
- if (typeof context.type !== 'string') {
2486
- return false;
2564
+ if (!childLabelProp) {
2565
+ return '';
2566
+ }
2567
+ var currentValue = get__default["default"](childData, childLabelProp);
2568
+ if (currentValue === undefined) {
2569
+ return '';
2570
+ }
2571
+ var childSchema = Resolve.schema(schema, '#' + getPropPath(childLabelProp), rootSchema);
2572
+ var enumOption = undefined;
2573
+ if (isEnumSchema(childSchema)) {
2574
+ enumOption = enumToEnumOptionMapper(currentValue, translateFct, getI18nKeyPrefix(childSchema, findUiControl(uiSchema, childLabelProp), childPath + '.' + childLabelProp));
2487
2575
  }
2488
- switch (context.type) {
2489
- case 'ADD': {
2490
- return ('values' in context &&
2491
- Array.isArray(context.values) &&
2492
- context.values.length > 0);
2493
- }
2494
- case 'REMOVE': {
2495
- return ('indices' in context &&
2496
- Array.isArray(context.indices) &&
2497
- context.indices.length > 0 &&
2498
- context.indices.every(function (i) { return typeof i === 'number'; }));
2499
- }
2500
- case 'MOVE': {
2501
- return ('moves' in context &&
2502
- Array.isArray(context.moves) &&
2503
- context.moves.length > 0 &&
2504
- context.moves.every(function (m) {
2505
- return typeof m === 'object' &&
2506
- m !== null &&
2507
- 'from' in m &&
2508
- 'to' in m &&
2509
- typeof m.from === 'number' &&
2510
- typeof m.to === 'number';
2511
- }));
2576
+ else if (isOneOfEnumSchema(childSchema)) {
2577
+ var oneOfArray = childSchema.oneOf;
2578
+ var oneOfSchema = oneOfArray.find(function (e) {
2579
+ return lodash.isEqual(e.const, currentValue);
2580
+ });
2581
+ if (oneOfSchema) {
2582
+ enumOption = oneOfToEnumOptionMapper(oneOfSchema, translateFct, getI18nKeyPrefix(oneOfSchema, undefined, childPath + '.' + childLabelProp));
2512
2583
  }
2513
- default:
2514
- return false;
2515
2584
  }
2585
+ return enumOption ? enumOption.label : currentValue;
2516
2586
  };
2517
- var init = function (data, schema, uischema, options) {
2518
- if (schema === void 0) { schema = generateJsonSchema(data); }
2519
- return ({
2520
- type: INIT,
2521
- data: data,
2522
- schema: schema,
2523
- uischema: typeof uischema === 'object' ? uischema : generateDefaultUISchema(schema),
2524
- options: options,
2525
- });
2526
- };
2527
- var updateCore = function (data, schema, uischema, options) { return ({
2528
- type: UPDATE_CORE,
2529
- data: data,
2530
- schema: schema,
2531
- uischema: uischema,
2532
- options: options,
2533
- }); };
2534
- var registerDefaultData = function (schemaPath, data) { return ({
2535
- type: ADD_DEFAULT_DATA,
2536
- schemaPath: schemaPath,
2537
- data: data,
2538
- }); };
2539
- var unregisterDefaultData = function (schemaPath) { return ({
2540
- type: REMOVE_DEFAULT_DATA,
2541
- schemaPath: schemaPath,
2542
- }); };
2543
- var setAjv = function (ajv) { return ({
2544
- type: SET_AJV,
2545
- ajv: ajv,
2546
- }); };
2547
- var update = function (path, updater, context) { return ({
2548
- type: UPDATE_DATA,
2549
- path: path,
2550
- updater: updater,
2551
- context: context,
2552
- }); };
2553
- var updateErrors = function (errors) { return ({
2554
- type: UPDATE_ERRORS,
2555
- errors: errors,
2556
- }); };
2557
- var registerRenderer = function (tester, renderer) { return ({
2558
- type: ADD_RENDERER,
2559
- tester: tester,
2560
- renderer: renderer,
2561
- }); };
2562
- var registerCell = function (tester, cell) { return ({
2563
- type: ADD_CELL,
2564
- tester: tester,
2565
- cell: cell,
2566
- }); };
2567
- var unregisterCell = function (tester, cell) { return ({
2568
- type: REMOVE_CELL,
2569
- tester: tester,
2570
- cell: cell,
2571
- }); };
2572
- var unregisterRenderer = function (tester, renderer) { return ({
2573
- type: REMOVE_RENDERER,
2574
- tester: tester,
2575
- renderer: renderer,
2576
- }); };
2577
- var setConfig = function (config) { return ({
2578
- type: SET_CONFIG,
2579
- config: config,
2580
- }); };
2581
- var setValidationMode = function (validationMode) { return ({
2582
- type: SET_VALIDATION_MODE,
2583
- validationMode: validationMode,
2584
- }); };
2585
- var registerUISchema = function (tester, uischema) {
2587
+
2588
+ var mapStateToCellProps = function (state, ownProps) {
2589
+ var id = ownProps.id, schema = ownProps.schema, path = ownProps.path, uischema = ownProps.uischema, renderers = ownProps.renderers, cells = ownProps.cells;
2590
+ var rootData = getData(state);
2591
+ var visible = ownProps.visible !== undefined
2592
+ ? ownProps.visible
2593
+ : isVisible(uischema, rootData, undefined, getAjv(state));
2594
+ var rootSchema = getSchema(state);
2595
+ var config = getConfig(state);
2596
+ var enabled;
2597
+ if (state.jsonforms.readonly === true) {
2598
+ enabled = false;
2599
+ }
2600
+ else if (typeof ownProps.enabled === 'boolean') {
2601
+ enabled = ownProps.enabled;
2602
+ }
2603
+ else {
2604
+ enabled = isInherentlyEnabled(state, ownProps, uischema, schema || rootSchema, rootData, config);
2605
+ }
2606
+ var t = getTranslator()(state);
2607
+ var te = getErrorTranslator()(state);
2608
+ var errors = getCombinedErrorMessage(getErrorAt(path, schema)(state), te, t, schema, uischema, path);
2609
+ var isValid = isEmpty__default["default"](errors);
2586
2610
  return {
2587
- type: ADD_UI_SCHEMA,
2588
- tester: tester,
2611
+ data: Resolve.data(rootData, path),
2612
+ visible: visible,
2613
+ enabled: enabled,
2614
+ id: id,
2615
+ path: path,
2616
+ errors: errors,
2617
+ isValid: isValid,
2618
+ schema: schema,
2589
2619
  uischema: uischema,
2620
+ config: getConfig(state),
2621
+ rootSchema: rootSchema,
2622
+ renderers: renderers,
2623
+ cells: cells,
2590
2624
  };
2591
2625
  };
2592
- var unregisterUISchema = function (tester) {
2626
+ var mapStateToDispatchCellProps = function (state, ownProps) {
2627
+ var props = mapStateToCellProps(state, ownProps);
2628
+ ownProps.renderers; var cells = ownProps.cells, otherOwnProps = __rest(ownProps, ["renderers", "cells"]);
2629
+ return __assign(__assign(__assign({}, props), otherOwnProps), { cells: cells || state.jsonforms.cells || [] });
2630
+ };
2631
+ var defaultMapStateToEnumCellProps = function (state, ownProps) {
2632
+ var _a;
2633
+ var props = mapStateToCellProps(state, ownProps);
2634
+ var options = ownProps.options ||
2635
+ ((_a = props.schema.enum) === null || _a === void 0 ? void 0 : _a.map(function (e) {
2636
+ return enumToEnumOptionMapper(e, getTranslator()(state), getI18nKeyPrefix(props.schema, props.uischema, props.path));
2637
+ })) ||
2638
+ (props.schema.const && [
2639
+ enumToEnumOptionMapper(props.schema.const, getTranslator()(state), getI18nKeyPrefix(props.schema, props.uischema, props.path)),
2640
+ ]);
2641
+ return __assign(__assign({}, props), { options: options });
2642
+ };
2643
+ var mapStateToOneOfEnumCellProps = function (state, ownProps) {
2644
+ var _a;
2645
+ var props = mapStateToCellProps(state, ownProps);
2646
+ var options = ownProps.options ||
2647
+ ((_a = props.schema.oneOf) === null || _a === void 0 ? void 0 : _a.map(function (oneOfSubSchema) {
2648
+ return oneOfToEnumOptionMapper(oneOfSubSchema, getTranslator()(state), getI18nKeyPrefix(props.schema, props.uischema, props.path));
2649
+ }));
2650
+ return __assign(__assign({}, props), { options: options });
2651
+ };
2652
+ var mapDispatchToCellProps = mapDispatchToControlProps;
2653
+ var defaultMapDispatchToControlProps =
2654
+ function (dispatch, ownProps) {
2655
+ var handleChange = mapDispatchToCellProps(dispatch).handleChange;
2593
2656
  return {
2594
- type: REMOVE_UI_SCHEMA,
2595
- tester: tester,
2657
+ handleChange: ownProps.handleChange || handleChange,
2596
2658
  };
2597
2659
  };
2598
- var setLocale = function (locale) { return ({
2599
- type: SET_LOCALE,
2600
- locale: locale,
2601
- }); };
2602
- var setSchema = function (schema) { return ({
2603
- type: SET_SCHEMA,
2604
- schema: schema,
2605
- }); };
2606
- var setTranslator = function (translator, errorTranslator) { return ({
2607
- type: SET_TRANSLATOR,
2608
- translator: translator,
2609
- errorTranslator: errorTranslator,
2610
- }); };
2611
- var updateI18n = function (locale, translator, errorTranslator) { return ({
2612
- type: UPDATE_I18N,
2613
- locale: locale,
2614
- translator: translator,
2615
- errorTranslator: errorTranslator,
2616
- }); };
2617
- var setUISchema = function (uischema) { return ({
2618
- type: SET_UISCHEMA,
2619
- uischema: uischema,
2620
- }); };
2621
-
2622
- var index = /*#__PURE__*/Object.freeze({
2623
- __proto__: null,
2624
- INIT: INIT,
2625
- UPDATE_CORE: UPDATE_CORE,
2626
- SET_AJV: SET_AJV,
2627
- UPDATE_DATA: UPDATE_DATA,
2628
- UPDATE_ERRORS: UPDATE_ERRORS,
2629
- VALIDATE: VALIDATE,
2630
- ADD_RENDERER: ADD_RENDERER,
2631
- REMOVE_RENDERER: REMOVE_RENDERER,
2632
- ADD_CELL: ADD_CELL,
2633
- REMOVE_CELL: REMOVE_CELL,
2634
- SET_CONFIG: SET_CONFIG,
2635
- ADD_UI_SCHEMA: ADD_UI_SCHEMA,
2636
- REMOVE_UI_SCHEMA: REMOVE_UI_SCHEMA,
2637
- SET_SCHEMA: SET_SCHEMA,
2638
- SET_UISCHEMA: SET_UISCHEMA,
2639
- SET_VALIDATION_MODE: SET_VALIDATION_MODE,
2640
- SET_LOCALE: SET_LOCALE,
2641
- SET_TRANSLATOR: SET_TRANSLATOR,
2642
- UPDATE_I18N: UPDATE_I18N,
2643
- ADD_DEFAULT_DATA: ADD_DEFAULT_DATA,
2644
- REMOVE_DEFAULT_DATA: REMOVE_DEFAULT_DATA,
2645
- isUpdateArrayContext: isUpdateArrayContext,
2646
- init: init,
2647
- updateCore: updateCore,
2648
- registerDefaultData: registerDefaultData,
2649
- unregisterDefaultData: unregisterDefaultData,
2650
- setAjv: setAjv,
2651
- update: update,
2652
- updateErrors: updateErrors,
2653
- registerRenderer: registerRenderer,
2654
- registerCell: registerCell,
2655
- unregisterCell: unregisterCell,
2656
- unregisterRenderer: unregisterRenderer,
2657
- setConfig: setConfig,
2658
- setValidationMode: setValidationMode,
2659
- registerUISchema: registerUISchema,
2660
- unregisterUISchema: unregisterUISchema,
2661
- setLocale: setLocale,
2662
- setSchema: setSchema,
2663
- setTranslator: setTranslator,
2664
- updateI18n: updateI18n,
2665
- setUISchema: setUISchema
2666
- });
2667
2660
 
2668
- var Helpers = {
2669
- createLabelDescriptionFrom: createLabelDescriptionFrom,
2670
- convertToValidClassName: convertToValidClassName,
2661
+ var createCombinatorRenderInfos = function (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) {
2662
+ return combinatorSubSchemas.map(function (subSchema, subSchemaIndex) {
2663
+ var _a, _b;
2664
+ var resolvedSubSchema = subSchema.$ref && Resolve.schema(rootSchema, subSchema.$ref, rootSchema);
2665
+ var schema = resolvedSubSchema !== null && resolvedSubSchema !== void 0 ? resolvedSubSchema : subSchema;
2666
+ return {
2667
+ schema: schema,
2668
+ uischema: findUISchema(uischemas, schema, control.scope, path, undefined, control, rootSchema),
2669
+ label: (_b = (_a = subSchema.title) !== null && _a !== void 0 ? _a : resolvedSubSchema === null || resolvedSubSchema === void 0 ? void 0 : resolvedSubSchema.title) !== null && _b !== void 0 ? _b : "".concat(keyword, "-").concat(subSchemaIndex),
2670
+ };
2671
+ });
2671
2672
  };
2672
2673
 
2673
2674
  exports.ADD_CELL = ADD_CELL;
2674
2675
  exports.ADD_DEFAULT_DATA = ADD_DEFAULT_DATA;
2675
2676
  exports.ADD_RENDERER = ADD_RENDERER;
2676
2677
  exports.ADD_UI_SCHEMA = ADD_UI_SCHEMA;
2677
- exports.Actions = index;
2678
+ exports.Actions = index$1;
2678
2679
  exports.Draft4 = Draft4;
2679
2680
  exports.Generate = Generate;
2680
2681
  exports.Helpers = Helpers;
@@ -2694,7 +2695,7 @@ exports.SET_SCHEMA = SET_SCHEMA;
2694
2695
  exports.SET_TRANSLATOR = SET_TRANSLATOR;
2695
2696
  exports.SET_UISCHEMA = SET_UISCHEMA;
2696
2697
  exports.SET_VALIDATION_MODE = SET_VALIDATION_MODE;
2697
- exports.Test = index$1;
2698
+ exports.Test = index;
2698
2699
  exports.UPDATE_CORE = UPDATE_CORE;
2699
2700
  exports.UPDATE_DATA = UPDATE_DATA;
2700
2701
  exports.UPDATE_ERRORS = UPDATE_ERRORS;
@@ -2760,6 +2761,7 @@ exports.formatErrorMessage = formatErrorMessage;
2760
2761
  exports.formatIs = formatIs;
2761
2762
  exports.generateDefaultUISchema = generateDefaultUISchema;
2762
2763
  exports.generateJsonSchema = generateJsonSchema;
2764
+ exports.getAdditionalErrors = getAdditionalErrors;
2763
2765
  exports.getAjv = getAjv;
2764
2766
  exports.getArrayTranslations = getArrayTranslations;
2765
2767
  exports.getCells = getCells;
@@ -2776,6 +2778,7 @@ exports.getI18nKey = getI18nKey;
2776
2778
  exports.getI18nKeyPrefix = getI18nKeyPrefix;
2777
2779
  exports.getI18nKeyPrefixBySchema = getI18nKeyPrefixBySchema;
2778
2780
  exports.getLocale = getLocale;
2781
+ exports.getOrCreateAjv = getOrCreateAjv;
2779
2782
  exports.getPropPath = getPropPath;
2780
2783
  exports.getRenderers = getRenderers;
2781
2784
  exports.getSchema = getSchema;
@@ -2783,6 +2786,7 @@ exports.getSubErrorsAt = getSubErrorsAt;
2783
2786
  exports.getTranslator = getTranslator;
2784
2787
  exports.getUISchemas = getUISchemas;
2785
2788
  exports.getUiSchema = getUiSchema;
2789
+ exports.getValidationMode = getValidationMode;
2786
2790
  exports.hasCategory = hasCategory;
2787
2791
  exports.hasEnableRule = hasEnableRule;
2788
2792
  exports.hasOption = hasOption;
@@ -2790,6 +2794,7 @@ exports.hasShowRule = hasShowRule;
2790
2794
  exports.hasType = hasType;
2791
2795
  exports.i18nReducer = i18nReducer;
2792
2796
  exports.init = init;
2797
+ exports.initState = initState;
2793
2798
  exports.isAllOfControl = isAllOfControl;
2794
2799
  exports.isAnyOfControl = isAnyOfControl;
2795
2800
  exports.isArrayObjectControl = isArrayObjectControl;