@jsonforms/core 3.0.0-beta.1 → 3.0.0-beta.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 (67) hide show
  1. package/docs/assets/js/search.json +1 -1
  2. package/docs/globals.html +203 -161
  3. package/docs/index.html +7 -4
  4. package/docs/interfaces/arraycontrolprops.html +21 -21
  5. package/docs/interfaces/arraylayoutprops.html +21 -21
  6. package/docs/interfaces/cellprops.html +12 -12
  7. package/docs/interfaces/combinatorrendererprops.html +143 -36
  8. package/docs/interfaces/controlprops.html +16 -16
  9. package/docs/interfaces/controlstate.html +2 -2
  10. package/docs/interfaces/controlwithdetailprops.html +17 -17
  11. package/docs/interfaces/dispatchcellprops.html +10 -10
  12. package/docs/interfaces/dispatchcellstateprops.html +10 -10
  13. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  14. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  15. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  16. package/docs/interfaces/enumcellprops.html +13 -13
  17. package/docs/interfaces/enumoption.html +2 -2
  18. package/docs/interfaces/jsonformsprops.html +9 -9
  19. package/docs/interfaces/layoutprops.html +10 -10
  20. package/docs/interfaces/ownpropsofcell.html +9 -9
  21. package/docs/interfaces/ownpropsofcontrol.html +9 -12
  22. package/docs/interfaces/ownpropsofenum.html +1 -1
  23. package/docs/interfaces/ownpropsofenumcell.html +10 -10
  24. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  25. package/docs/interfaces/ownpropsoflayout.html +9 -9
  26. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  27. package/docs/interfaces/ownpropsofrenderer.html +8 -8
  28. package/docs/interfaces/rendererprops.html +9 -9
  29. package/docs/interfaces/statepropsofarraycontrol.html +17 -17
  30. package/docs/interfaces/statepropsofarraylayout.html +17 -17
  31. package/docs/interfaces/statepropsofcell.html +11 -11
  32. package/docs/interfaces/statepropsofcombinator.html +147 -40
  33. package/docs/interfaces/statepropsofcontrol.html +18 -15
  34. package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
  35. package/docs/interfaces/statepropsofenumcell.html +12 -12
  36. package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
  37. package/docs/interfaces/statepropsoflayout.html +10 -10
  38. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  39. package/docs/interfaces/statepropsofrenderer.html +9 -9
  40. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  41. package/docs/interfaces/withclassname.html +1 -1
  42. package/lib/jsonforms-core.cjs.js +160 -164
  43. package/lib/jsonforms-core.cjs.js.map +1 -1
  44. package/lib/jsonforms-core.esm.js +142 -154
  45. package/lib/jsonforms-core.esm.js.map +1 -1
  46. package/lib/reducers/reducers.d.ts +2 -2
  47. package/lib/testers/testers.d.ts +8 -7
  48. package/lib/util/combinators.d.ts +0 -1
  49. package/lib/util/path.d.ts +10 -0
  50. package/lib/util/renderer.d.ts +2 -2
  51. package/lib/util/resolvers.d.ts +1 -1
  52. package/lib/util/util.d.ts +1 -1
  53. package/package.json +2 -2
  54. package/src/generators/uischema.ts +4 -4
  55. package/src/reducers/reducers.ts +12 -4
  56. package/src/testers/testers.ts +60 -33
  57. package/src/util/combinators.ts +17 -32
  58. package/src/util/label.ts +2 -2
  59. package/src/util/path.ts +18 -6
  60. package/src/util/renderer.ts +14 -29
  61. package/src/util/resolvers.ts +57 -68
  62. package/src/util/util.ts +1 -1
  63. package/stats.html +1 -1
  64. package/test/generators/uischema.test.ts +18 -0
  65. package/test/testers.test.ts +208 -120
  66. package/test/util/path.test.ts +37 -20
  67. package/test/util/resolvers.test.ts +99 -8
@@ -125,7 +125,7 @@
125
125
  <aside class="tsd-sources">
126
126
  <p>Inherited from <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#cells">cells</a></p>
127
127
  <ul>
128
- <li>Defined in packages/core/src/util/renderer.ts:311</li>
128
+ <li>Defined in packages/core/src/util/renderer.ts:313</li>
129
129
  </ul>
130
130
  </aside>
131
131
  <div class="tsd-comment tsd-typography">
@@ -141,7 +141,7 @@
141
141
  <aside class="tsd-sources">
142
142
  <p>Inherited from <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#config">config</a></p>
143
143
  <ul>
144
- <li>Defined in packages/core/src/util/renderer.ts:271</li>
144
+ <li>Defined in packages/core/src/util/renderer.ts:273</li>
145
145
  </ul>
146
146
  </aside>
147
147
  <div class="tsd-comment tsd-typography">
@@ -157,7 +157,7 @@
157
157
  <aside class="tsd-sources">
158
158
  <p>Overrides <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#data">data</a></p>
159
159
  <ul>
160
- <li>Defined in packages/core/src/util/renderer.ts:329</li>
160
+ <li>Defined in packages/core/src/util/renderer.ts:331</li>
161
161
  </ul>
162
162
  </aside>
163
163
  <div class="tsd-comment tsd-typography">
@@ -173,7 +173,7 @@
173
173
  <aside class="tsd-sources">
174
174
  <p>Inherited from <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#enabled">enabled</a></p>
175
175
  <ul>
176
- <li>Defined in packages/core/src/util/renderer.ts:291</li>
176
+ <li>Defined in packages/core/src/util/renderer.ts:293</li>
177
177
  </ul>
178
178
  </aside>
179
179
  <div class="tsd-comment tsd-typography">
@@ -188,7 +188,7 @@
188
188
  <div class="tsd-signature tsd-kind-icon">errors<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
189
189
  <aside class="tsd-sources">
190
190
  <ul>
191
- <li>Defined in packages/core/src/util/renderer.ts:324</li>
191
+ <li>Defined in packages/core/src/util/renderer.ts:326</li>
192
192
  </ul>
193
193
  </aside>
194
194
  <div class="tsd-comment tsd-typography">
@@ -203,7 +203,7 @@
203
203
  <div class="tsd-signature tsd-kind-icon">id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
204
204
  <aside class="tsd-sources">
205
205
  <ul>
206
- <li>Defined in packages/core/src/util/renderer.ts:339</li>
206
+ <li>Defined in packages/core/src/util/renderer.ts:341</li>
207
207
  </ul>
208
208
  </aside>
209
209
  <div class="tsd-comment tsd-typography">
@@ -219,7 +219,7 @@
219
219
  <aside class="tsd-sources">
220
220
  <p>Inherited from <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#path">path</a></p>
221
221
  <ul>
222
- <li>Defined in packages/core/src/util/renderer.ts:300</li>
222
+ <li>Defined in packages/core/src/util/renderer.ts:302</li>
223
223
  </ul>
224
224
  </aside>
225
225
  <div class="tsd-comment tsd-typography">
@@ -235,7 +235,7 @@
235
235
  <aside class="tsd-sources">
236
236
  <p>Inherited from <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#renderers">renderers</a></p>
237
237
  <ul>
238
- <li>Defined in packages/core/src/util/renderer.ts:305</li>
238
+ <li>Defined in packages/core/src/util/renderer.ts:307</li>
239
239
  </ul>
240
240
  </aside>
241
241
  <div class="tsd-comment tsd-typography">
@@ -250,7 +250,7 @@
250
250
  <div class="tsd-signature tsd-kind-icon">root<wbr>Schema<span class="tsd-signature-symbol">:</span> <a href="../globals.html#jsonschema" class="tsd-signature-type">JsonSchema</a></div>
251
251
  <aside class="tsd-sources">
252
252
  <ul>
253
- <li>Defined in packages/core/src/util/renderer.ts:334</li>
253
+ <li>Defined in packages/core/src/util/renderer.ts:336</li>
254
254
  </ul>
255
255
  </aside>
256
256
  <div class="tsd-comment tsd-typography">
@@ -266,7 +266,7 @@
266
266
  <aside class="tsd-sources">
267
267
  <p>Inherited from <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#schema">schema</a></p>
268
268
  <ul>
269
- <li>Defined in packages/core/src/util/renderer.ts:281</li>
269
+ <li>Defined in packages/core/src/util/renderer.ts:283</li>
270
270
  </ul>
271
271
  </aside>
272
272
  <div class="tsd-comment tsd-typography">
@@ -282,7 +282,7 @@
282
282
  <aside class="tsd-sources">
283
283
  <p>Overrides <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#uischema">uischema</a></p>
284
284
  <ul>
285
- <li>Defined in packages/core/src/util/renderer.ts:319</li>
285
+ <li>Defined in packages/core/src/util/renderer.ts:321</li>
286
286
  </ul>
287
287
  </aside>
288
288
  </section>
@@ -293,7 +293,7 @@
293
293
  <aside class="tsd-sources">
294
294
  <p>Inherited from <a href="statepropsofrenderer.html">StatePropsOfRenderer</a>.<a href="statepropsofrenderer.html#visible">visible</a></p>
295
295
  <ul>
296
- <li>Defined in packages/core/src/util/renderer.ts:295</li>
296
+ <li>Defined in packages/core/src/util/renderer.ts:297</li>
297
297
  </ul>
298
298
  </aside>
299
299
  <div class="tsd-comment tsd-typography">
@@ -93,7 +93,7 @@
93
93
  <div class="tsd-signature tsd-kind-icon">class<wbr>Name<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
94
94
  <aside class="tsd-sources">
95
95
  <ul>
96
- <li>Defined in packages/core/src/util/renderer.ts:170</li>
96
+ <li>Defined in packages/core/src/util/renderer.ts:172</li>
97
97
  </ul>
98
98
  </aside>
99
99
  </section>
@@ -386,6 +386,16 @@ function __rest(s, e) {
386
386
  t[p[i]] = s[p[i]];
387
387
  }
388
388
  return t;
389
+ }
390
+
391
+ function __spreadArray(to, from, pack) {
392
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
393
+ if (ar || !(i in from)) {
394
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
395
+ ar[i] = from[i];
396
+ }
397
+ }
398
+ return to.concat(ar || Array.prototype.slice.call(from));
389
399
  }
390
400
 
391
401
  var cellReducer = function (state, _a) {
@@ -765,7 +775,7 @@ var NOT_APPLICABLE = -1;
765
775
  var isControl = function (uischema) {
766
776
  return !isEmpty__default["default"](uischema) && uischema.scope !== undefined;
767
777
  };
768
- var schemaMatches = function (predicate) { return function (uischema, schema) {
778
+ var schemaMatches = function (predicate) { return function (uischema, schema, rootSchema) {
769
779
  if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
770
780
  return false;
771
781
  }
@@ -778,27 +788,27 @@ var schemaMatches = function (predicate) { return function (uischema, schema) {
778
788
  }
779
789
  var currentDataSchema = schema;
780
790
  if (hasType(schema, 'object')) {
781
- currentDataSchema = resolveSchema(schema, schemaPath);
791
+ currentDataSchema = resolveSchema(schema, schemaPath, rootSchema);
782
792
  }
783
793
  if (currentDataSchema === undefined) {
784
794
  return false;
785
795
  }
786
- return predicate(currentDataSchema);
796
+ return predicate(currentDataSchema, rootSchema);
787
797
  }; };
788
- var schemaSubPathMatches = function (subPath, predicate) { return function (uischema, schema) {
798
+ var schemaSubPathMatches = function (subPath, predicate) { return function (uischema, schema, rootSchema) {
789
799
  if (isEmpty__default["default"](uischema) || !isControl(uischema)) {
790
800
  return false;
791
801
  }
792
802
  var schemaPath = uischema.scope;
793
803
  var currentDataSchema = schema;
794
804
  if (hasType(schema, 'object')) {
795
- currentDataSchema = resolveSchema(schema, schemaPath);
805
+ currentDataSchema = resolveSchema(schema, schemaPath, rootSchema);
796
806
  }
797
807
  currentDataSchema = get__default["default"](currentDataSchema, subPath);
798
808
  if (currentDataSchema === undefined) {
799
809
  return false;
800
810
  }
801
- return predicate(currentDataSchema);
811
+ return predicate(currentDataSchema, rootSchema);
802
812
  }; };
803
813
  var schemaTypeIs = function (expectedType) {
804
814
  return schemaMatches(function (schema) { return !isEmpty__default["default"](schema) && hasType(schema, expectedType); });
@@ -836,23 +846,23 @@ var and = function () {
836
846
  for (var _i = 0; _i < arguments.length; _i++) {
837
847
  testers[_i] = arguments[_i];
838
848
  }
839
- return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema); }, true); };
849
+ return function (uischema, schema, rootSchema) { return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema, rootSchema); }, true); };
840
850
  };
841
851
  var or = function () {
842
852
  var testers = [];
843
853
  for (var _i = 0; _i < arguments.length; _i++) {
844
854
  testers[_i] = arguments[_i];
845
855
  }
846
- return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema); }, false); };
856
+ return function (uischema, schema, rootSchema) { return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema, rootSchema); }, false); };
847
857
  };
848
- var rankWith = function (rank, tester) { return function (uischema, schema) {
849
- if (tester(uischema, schema)) {
858
+ var rankWith = function (rank, tester) { return function (uischema, schema, rootSchema) {
859
+ if (tester(uischema, schema, rootSchema)) {
850
860
  return rank;
851
861
  }
852
862
  return NOT_APPLICABLE;
853
863
  }; };
854
- var withIncreasedRank = function (by, rankedTester) { return function (uischema, schema) {
855
- var rank = rankedTester(uischema, schema);
864
+ var withIncreasedRank = function (by, rankedTester) { return function (uischema, schema, rootSchema) {
865
+ var rank = rankedTester(uischema, schema, rootSchema);
856
866
  if (rank === NOT_APPLICABLE) {
857
867
  return NOT_APPLICABLE;
858
868
  }
@@ -875,33 +885,42 @@ var isMultiLineControl = and(uiTypeIs('Control'), optionIs('multi', true));
875
885
  var isDateControl = and(uiTypeIs('Control'), or(formatIs('date'), optionIs('format', 'date')));
876
886
  var isTimeControl = and(uiTypeIs('Control'), or(formatIs('time'), optionIs('format', 'time')));
877
887
  var isDateTimeControl = and(uiTypeIs('Control'), or(formatIs('date-time'), optionIs('format', 'date-time')));
878
- var isObjectArray = and(schemaMatches(function (schema) { return hasType(schema, 'array') && !Array.isArray(schema.items); }
879
- ), schemaSubPathMatches('items', function (schema) { return hasType(schema, 'object'); }));
888
+ var isObjectArray = and(schemaMatches(function (schema, rootSchema) { return hasType(schema, 'array') && !Array.isArray(resolveSchema(schema, 'items', rootSchema)); }
889
+ ), schemaSubPathMatches('items', function (schema, rootSchema) {
890
+ var resolvedSchema = schema.$ref ? resolveSchema(rootSchema, schema.$ref, rootSchema) : schema;
891
+ return hasType(resolvedSchema, 'object');
892
+ }));
880
893
  var isObjectArrayControl = and(uiTypeIs('Control'), isObjectArray);
881
- var traverse = function (any, pred) {
894
+ var traverse = function (any, pred, rootSchema) {
882
895
  if (isArray__default["default"](any)) {
883
- return reduce__default["default"](any, function (acc, el) { return acc || traverse(el, pred); }, false);
896
+ return reduce__default["default"](any, function (acc, el) { return acc || traverse(el, pred, rootSchema); }, false);
884
897
  }
885
898
  if (pred(any)) {
886
899
  return true;
887
900
  }
901
+ if (any.$ref) {
902
+ var toTraverse = resolveSchema(rootSchema, any.$ref, rootSchema);
903
+ if (toTraverse && !toTraverse.$ref) {
904
+ return traverse(toTraverse, pred, rootSchema);
905
+ }
906
+ }
888
907
  if (any.items) {
889
- return traverse(any.items, pred);
908
+ return traverse(any.items, pred, rootSchema);
890
909
  }
891
910
  if (any.properties) {
892
911
  return reduce__default["default"](toPairs__default["default"](any.properties), function (acc, _a) {
893
912
  _a[0]; var val = _a[1];
894
- return acc || traverse(val, pred);
913
+ return acc || traverse(val, pred, rootSchema);
895
914
  }, false);
896
915
  }
897
916
  return false;
898
917
  };
899
- var isObjectArrayWithNesting = function (uischema, schema) {
900
- if (!uiTypeIs('Control')(uischema, schema)) {
918
+ var isObjectArrayWithNesting = function (uischema, schema, rootSchema) {
919
+ if (!uiTypeIs('Control')(uischema, schema, rootSchema)) {
901
920
  return false;
902
921
  }
903
922
  var schemaPath = uischema.scope;
904
- var resolvedSchema = resolveSchema(schema, schemaPath);
923
+ var resolvedSchema = resolveSchema(schema, schemaPath, rootSchema !== null && rootSchema !== void 0 ? rootSchema : schema);
905
924
  var wantedNestingByType = {
906
925
  object: 2,
907
926
  array: 1
@@ -911,6 +930,9 @@ var isObjectArrayWithNesting = function (uischema, schema) {
911
930
  if (val === schema) {
912
931
  return false;
913
932
  }
933
+ if (val.$ref !== undefined) {
934
+ return false;
935
+ }
914
936
  if (typeof val.type !== 'string') {
915
937
  return true;
916
938
  }
@@ -920,7 +942,7 @@ var isObjectArrayWithNesting = function (uischema, schema) {
920
942
  }
921
943
  wantedNestingByType[val.type] = typeCount - 1;
922
944
  return wantedNestingByType[val.type] === 0;
923
- })) {
945
+ }, rootSchema)) {
924
946
  return true;
925
947
  }
926
948
  if (uischema.options && uischema.options.detail) {
@@ -936,9 +958,13 @@ var isObjectArrayWithNesting = function (uischema, schema) {
936
958
  return false;
937
959
  };
938
960
  var isArrayObjectControl = isObjectArrayControl;
939
- var isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(function (schema) { return deriveTypes(schema).length !== 0 && !Array.isArray(schema.items); }
940
- ), schemaSubPathMatches('items', function (schema) {
941
- var types = deriveTypes(schema);
961
+ var isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(function (schema, rootSchema) {
962
+ return deriveTypes(schema).length !== 0 &&
963
+ !Array.isArray(resolveSchema(schema, 'items', rootSchema));
964
+ }
965
+ ), schemaSubPathMatches('items', function (schema, rootSchema) {
966
+ var resolvedSchema = schema.$ref ? resolveSchema(rootSchema, schema.$ref, rootSchema) : schema;
967
+ var types = deriveTypes(resolvedSchema);
942
968
  return (types.length === 1 &&
943
969
  includes__default["default"](['integer', 'number', 'boolean', 'string'], types[0]));
944
970
  }));
@@ -965,7 +991,7 @@ var hasCategory = function (categorization) {
965
991
  var categorizationHasCategory = function (uischema) {
966
992
  return hasCategory(uischema);
967
993
  };
968
- var not = function (tester) { return function (uischema, schema) { return !tester(uischema, schema); }; };
994
+ var not = function (tester) { return function (uischema, schema, rootSchema) { return !tester(uischema, schema, rootSchema); }; };
969
995
 
970
996
  var index$1 = /*#__PURE__*/Object.freeze({
971
997
  __proto__: null,
@@ -1046,12 +1072,15 @@ var jsonFormsReducerConfig = {
1046
1072
  defaultData: defaultDataReducer,
1047
1073
  i18n: i18nReducer,
1048
1074
  };
1049
- var findUISchema = function (uischemas, schema, schemaPath, path, fallbackLayoutType, control, rootSchema) {
1050
- if (fallbackLayoutType === void 0) { fallbackLayoutType = 'VerticalLayout'; }
1075
+ var findUISchema = function (uischemas, schema, schemaPath, path, fallback, control, rootSchema) {
1076
+ if (fallback === void 0) { fallback = 'VerticalLayout'; }
1051
1077
  if (control && control.options && control.options.detail) {
1052
1078
  if (typeof control.options.detail === 'string') {
1053
1079
  if (control.options.detail.toUpperCase() === 'GENERATE') {
1054
- return Generate.uiSchema(schema, fallbackLayoutType);
1080
+ if (typeof fallback === "function") {
1081
+ return fallback();
1082
+ }
1083
+ return Generate.uiSchema(schema, fallback);
1055
1084
  }
1056
1085
  }
1057
1086
  else if (typeof control.options.detail === 'object') {
@@ -1063,7 +1092,10 @@ var findUISchema = function (uischemas, schema, schemaPath, path, fallbackLayout
1063
1092
  }
1064
1093
  var uiSchema = findMatchingUISchema(uischemas)(schema, schemaPath, path);
1065
1094
  if (uiSchema === undefined) {
1066
- return Generate.uiSchema(schema, fallbackLayoutType, '#', rootSchema);
1095
+ if (typeof fallback === 'function') {
1096
+ return fallback();
1097
+ }
1098
+ return Generate.uiSchema(schema, fallback, '#', rootSchema);
1067
1099
  }
1068
1100
  return uiSchema;
1069
1101
  };
@@ -1095,6 +1127,44 @@ var getRenderers = function (state) { return get__default["default"](state, 'jso
1095
1127
  var getCells = function (state) { return get__default["default"](state, 'jsonforms.cells'); };
1096
1128
  var getUISchemas = function (state) { return get__default["default"](state, 'jsonforms.uischemas'); };
1097
1129
 
1130
+ var compose = function (path1, path2) {
1131
+ var p1 = path1;
1132
+ if (!isEmpty__default["default"](path1) && !isEmpty__default["default"](path2) && !path2.startsWith('[')) {
1133
+ p1 = path1 + '.';
1134
+ }
1135
+ if (isEmpty__default["default"](p1)) {
1136
+ return path2;
1137
+ }
1138
+ else if (isEmpty__default["default"](path2)) {
1139
+ return p1;
1140
+ }
1141
+ else {
1142
+ return "" + p1 + path2;
1143
+ }
1144
+ };
1145
+ var toDataPathSegments = function (schemaPath) {
1146
+ var s = schemaPath
1147
+ .replace(/(anyOf|allOf|oneOf)\/[\d]\//g, '')
1148
+ .replace(/(then|else)\//g, '');
1149
+ var segments = s.split('/');
1150
+ var decodedSegments = segments.map(decode);
1151
+ var startFromRoot = decodedSegments[0] === '#' || decodedSegments[0] === '';
1152
+ var startIndex = startFromRoot ? 2 : 1;
1153
+ return range__default["default"](startIndex, decodedSegments.length, 2).map(function (idx) { return decodedSegments[idx]; });
1154
+ };
1155
+ var toDataPath = function (schemaPath) {
1156
+ return toDataPathSegments(schemaPath).join('.');
1157
+ };
1158
+ var composeWithUi = function (scopableUi, path) {
1159
+ var segments = toDataPathSegments(scopableUi.scope);
1160
+ if (isEmpty__default["default"](segments) && path === undefined) {
1161
+ return '';
1162
+ }
1163
+ return isEmpty__default["default"](segments) ? path : compose(path, segments.join('.'));
1164
+ };
1165
+ var encode = function (segment) { return segment === null || segment === void 0 ? void 0 : segment.replace(/~/g, '~0').replace(/\//g, '~1'); };
1166
+ var decode = function (pointerSegment) { return pointerSegment === null || pointerSegment === void 0 ? void 0 : pointerSegment.replace(/~1/g, '/').replace(/~0/, '~'); };
1167
+
1098
1168
  var isObjectSchema = function (schema) {
1099
1169
  return schema.properties !== undefined;
1100
1170
  };
@@ -1147,92 +1217,42 @@ var invalidSegment = function (pathSegment) {
1147
1217
  return pathSegment === '#' || pathSegment === undefined || pathSegment === '';
1148
1218
  };
1149
1219
  var resolveSchema = function (schema, schemaPath, rootSchema) {
1150
- var _a, _b, _c;
1220
+ var segments = schemaPath === null || schemaPath === void 0 ? void 0 : schemaPath.split('/').map(decode);
1221
+ return resolveSchemaWithSegments(schema, segments, rootSchema);
1222
+ };
1223
+ var resolveSchemaWithSegments = function (schema, pathSegments, rootSchema) {
1224
+ var _a, _b, _c, _d, _e;
1151
1225
  if (isEmpty__default["default"](schema)) {
1152
1226
  return undefined;
1153
1227
  }
1154
- var validPathSegments = schemaPath.split('/');
1155
- var resultSchema = schema;
1156
- for (var i = 0; i < validPathSegments.length; i++) {
1157
- var pathSegment = validPathSegments[i];
1158
- resultSchema =
1159
- resultSchema === undefined || resultSchema.$ref === undefined
1160
- ? resultSchema
1161
- : resolveSchema(schema, resultSchema.$ref);
1162
- if (invalidSegment(pathSegment)) {
1163
- continue;
1164
- }
1165
- var curSchema = get__default["default"](resultSchema, pathSegment);
1166
- if (!curSchema) {
1167
- var schemas = [].concat((_a = resultSchema === null || resultSchema === void 0 ? void 0 : resultSchema.oneOf) !== null && _a !== void 0 ? _a : [], (_b = resultSchema === null || resultSchema === void 0 ? void 0 : resultSchema.allOf) !== null && _b !== void 0 ? _b : [], (_c = resultSchema === null || resultSchema === void 0 ? void 0 : resultSchema.anyOf) !== null && _c !== void 0 ? _c : []);
1168
- for (var _i = 0, schemas_1 = schemas; _i < schemas_1.length; _i++) {
1169
- var item = schemas_1[_i];
1170
- curSchema = resolveSchema(item, validPathSegments.slice(i).join('/'));
1171
- if (curSchema) {
1172
- break;
1173
- }
1174
- }
1175
- if (curSchema) {
1176
- resultSchema = curSchema;
1177
- break;
1178
- }
1179
- }
1180
- resultSchema = curSchema;
1181
- }
1182
- if (resultSchema !== undefined && resultSchema.$ref !== undefined) {
1183
- try {
1184
- return retrieveResolvableSchema(schema, resultSchema.$ref);
1185
- }
1186
- catch (e) {
1187
- return retrieveResolvableSchema(rootSchema, resultSchema.$ref);
1188
- }
1189
- }
1190
- return resultSchema;
1191
- };
1192
- function retrieveResolvableSchema(full, reference) {
1193
- var child = resolveSchema(full, reference);
1194
- var allRefs = findAllRefs(child);
1195
- var innerSelfReference = allRefs[reference];
1196
- if (innerSelfReference !== undefined) {
1197
- innerSelfReference.$ref = '#';
1228
+ if (schema.$ref) {
1229
+ schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
1198
1230
  }
1199
- return child;
1200
- }
1201
-
1202
- var compose = function (path1, path2) {
1203
- var p1 = path1;
1204
- if (!isEmpty__default["default"](path1) && !isEmpty__default["default"](path2) && !path2.startsWith('[')) {
1205
- p1 = path1 + '.';
1231
+ if (!pathSegments || pathSegments.length === 0) {
1232
+ return schema;
1206
1233
  }
1207
- if (isEmpty__default["default"](p1)) {
1208
- return path2;
1234
+ var segment = pathSegments[0], remainingSegments = pathSegments.slice(1);
1235
+ if (invalidSegment(segment)) {
1236
+ return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
1209
1237
  }
1210
- else if (isEmpty__default["default"](path2)) {
1211
- return p1;
1238
+ var singleSegmentResolveSchema = get__default["default"](schema, segment);
1239
+ var resolvedSchema = resolveSchemaWithSegments(singleSegmentResolveSchema, remainingSegments, rootSchema);
1240
+ if (resolvedSchema) {
1241
+ return resolvedSchema;
1212
1242
  }
1213
- else {
1214
- return "" + p1 + path2;
1215
- }
1216
- };
1217
- var toDataPathSegments = function (schemaPath) {
1218
- var s = schemaPath
1219
- .replace(/anyOf\/[\d]\//g, '')
1220
- .replace(/allOf\/[\d]\//g, '')
1221
- .replace(/oneOf\/[\d]\//g, '');
1222
- var segments = s.split('/');
1223
- var startFromRoot = segments[0] === '#' || segments[0] === '';
1224
- var startIndex = startFromRoot ? 2 : 1;
1225
- return range__default["default"](startIndex, segments.length, 2).map(function (idx) { return segments[idx]; });
1226
- };
1227
- var toDataPath = function (schemaPath) {
1228
- return toDataPathSegments(schemaPath).join('.');
1229
- };
1230
- var composeWithUi = function (scopableUi, path) {
1231
- var segments = toDataPathSegments(scopableUi.scope);
1232
- if (isEmpty__default["default"](segments) && path === undefined) {
1233
- return '';
1243
+ if (segment === 'properties' || segment === 'items') {
1244
+ var alternativeResolveResult = undefined;
1245
+ 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 : []);
1246
+ for (var _i = 0, subSchemas_1 = subSchemas; _i < subSchemas_1.length; _i++) {
1247
+ var subSchema = subSchemas_1[_i];
1248
+ alternativeResolveResult = resolveSchemaWithSegments(subSchema, __spreadArray([segment], remainingSegments), rootSchema);
1249
+ if (alternativeResolveResult) {
1250
+ break;
1251
+ }
1252
+ }
1253
+ return alternativeResolveResult;
1234
1254
  }
1235
- return isEmpty__default["default"](segments) ? path : compose(path, segments.join('.'));
1255
+ return undefined;
1236
1256
  };
1237
1257
 
1238
1258
  var isOrCondition = function (condition) {
@@ -1417,7 +1437,7 @@ var deriveLabel = function (controlElement, schemaElement) {
1417
1437
  }
1418
1438
  if (typeof controlElement.scope === 'string') {
1419
1439
  var ref = controlElement.scope;
1420
- var label = ref.substr(ref.lastIndexOf('/') + 1);
1440
+ var label = decode(ref.substr(ref.lastIndexOf('/') + 1));
1421
1441
  return startCase__default["default"](label);
1422
1442
  }
1423
1443
  return '';
@@ -1447,32 +1467,6 @@ var labelDescription = function (text, show) { return ({
1447
1467
  show: show
1448
1468
  }); };
1449
1469
 
1450
- var createLabel = function (subSchema, subSchemaIndex, keyword) {
1451
- if (subSchema.title) {
1452
- return subSchema.title;
1453
- }
1454
- else {
1455
- return keyword + '-' + subSchemaIndex;
1456
- }
1457
- };
1458
- var resolveSubSchemas = function (schema, rootSchema, keyword) {
1459
- var _a;
1460
- var schemas = schema[keyword];
1461
- if (schemas.findIndex(function (e) { return e.$ref !== undefined; }) !== -1) {
1462
- return __assign(__assign({}, schema), (_a = {}, _a[keyword] = schema[keyword].map(function (e) {
1463
- return e.$ref ? resolveSchema(rootSchema, e.$ref) : e;
1464
- }), _a));
1465
- }
1466
- return schema;
1467
- };
1468
- var createCombinatorRenderInfos = function (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) {
1469
- return combinatorSubSchemas.map(function (subSchema, subSchemaIndex) { return ({
1470
- schema: subSchema,
1471
- uischema: findUISchema(uischemas, subSchema, control.scope, path, undefined, control, rootSchema),
1472
- label: createLabel(subSchema, subSchemaIndex, keyword)
1473
- }); });
1474
- };
1475
-
1476
1470
  var isRequired = function (schema, schemaPath, rootSchema) {
1477
1471
  var pathSegments = schemaPath.split('/');
1478
1472
  var lastSegment = pathSegments[pathSegments.length - 1];
@@ -1735,7 +1729,7 @@ var mapStateToLayoutProps = function (state, ownProps) {
1735
1729
  var enabled = isInherentlyEnabled(state, ownProps, uischema, undefined,
1736
1730
  rootData, config);
1737
1731
  return __assign(__assign({}, layoutDefaultProps), { renderers: ownProps.renderers || getRenderers(state), cells: ownProps.cells || getCells(state), visible: visible,
1738
- enabled: enabled, path: ownProps.path, data: data, uischema: ownProps.uischema, schema: ownProps.schema, direction: (_a = ownProps.direction) !== null && _a !== void 0 ? _a : getDirection(uischema) });
1732
+ 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 });
1739
1733
  };
1740
1734
  var mapStateToJsonFormsRendererProps = function (state, ownProps) {
1741
1735
  var uischema = ownProps.uischema;
@@ -1758,18 +1752,9 @@ var mapStateToJsonFormsRendererProps = function (state, ownProps) {
1758
1752
  };
1759
1753
  var controlDefaultProps = __assign(__assign({}, layoutDefaultProps), { errors: [] });
1760
1754
  var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
1761
- var uischema = ownProps.uischema;
1762
- var path = composeWithUi(uischema, ownProps.path);
1763
- var rootSchema = getSchema(state);
1764
- var resolvedSchema = Resolve.schema(ownProps.schema || rootSchema, uischema.scope, rootSchema);
1765
- var visible = ownProps.visible === undefined || hasShowRule(uischema)
1766
- ? isVisible(uischema, getData(state), ownProps.path, getAjv(state))
1767
- : ownProps.visible;
1768
- var id = ownProps.id;
1769
- var data = Resolve.data(getData(state), path);
1755
+ var _a;
1756
+ var _b = mapStateToControlProps(state, ownProps), data = _b.data, schema = _b.schema, props = __rest(_b, ["data", "schema"]);
1770
1757
  var ajv = state.jsonforms.core.ajv;
1771
- var schema = resolvedSchema || rootSchema;
1772
- var _schema = resolveSubSchemas(schema, rootSchema, keyword);
1773
1758
  var structuralKeywords = [
1774
1759
  'required',
1775
1760
  'additionalProperties',
@@ -1783,9 +1768,9 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
1783
1768
  !errors.find(function (e) { return structuralKeywords.indexOf(e.keyword) !== -1; }));
1784
1769
  };
1785
1770
  var indexOfFittingSchema;
1786
- for (var i = 0; i < _schema[keyword].length; i++) {
1771
+ for (var i = 0; i < ((_a = schema[keyword]) === null || _a === void 0 ? void 0 : _a.length); i++) {
1787
1772
  try {
1788
- var valFn = ajv.compile(_schema[keyword][i]);
1773
+ var valFn = ajv.compile(schema[keyword][i]);
1789
1774
  valFn(data);
1790
1775
  if (dataIsValid(valFn.errors)) {
1791
1776
  indexOfFittingSchema = i;
@@ -1796,17 +1781,8 @@ var mapStateToCombinatorRendererProps = function (state, ownProps, keyword) {
1796
1781
  console.debug("Combinator subschema is not self contained, can't hand it over to AJV");
1797
1782
  }
1798
1783
  }
1799
- return {
1800
- data: data,
1801
- path: path,
1802
- schema: schema,
1803
- rootSchema: rootSchema,
1804
- visible: visible,
1805
- id: id,
1806
- indexOfFittingSchema: indexOfFittingSchema,
1807
- uischemas: state.jsonforms.uischemas,
1808
- uischema: uischema
1809
- };
1784
+ return __assign(__assign({ data: data,
1785
+ schema: schema }, props), { indexOfFittingSchema: indexOfFittingSchema, uischemas: getUISchemas(state) });
1810
1786
  };
1811
1787
  var mapStateToAllOfProps = function (state, ownProps) {
1812
1788
  return mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
@@ -1899,6 +1875,25 @@ function (dispatch, ownProps) {
1899
1875
  };
1900
1876
  };
1901
1877
 
1878
+ var createLabel = function (subSchema, subSchemaIndex, keyword) {
1879
+ if (subSchema.title) {
1880
+ return subSchema.title;
1881
+ }
1882
+ else {
1883
+ return keyword + '-' + subSchemaIndex;
1884
+ }
1885
+ };
1886
+ var createCombinatorRenderInfos = function (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) {
1887
+ return combinatorSubSchemas.map(function (subSchema, subSchemaIndex) {
1888
+ var schema = subSchema.$ref ? Resolve.schema(rootSchema, subSchema.$ref, rootSchema) : subSchema;
1889
+ return {
1890
+ schema: schema,
1891
+ uischema: findUISchema(uischemas, schema, control.scope, path, undefined, control, rootSchema),
1892
+ label: createLabel(subSchema, subSchemaIndex, keyword)
1893
+ };
1894
+ });
1895
+ };
1896
+
1902
1897
  var usedIds = new Set();
1903
1898
  var makeId = function (idBase, iteration) {
1904
1899
  return iteration <= 1 ? idBase : idBase + iteration.toString();
@@ -2002,7 +1997,7 @@ var isCombinator = function (jsonSchema) {
2002
1997
  };
2003
1998
  var generateUISchema = function (jsonSchema, schemaElements, currentRef, schemaName, layoutType, rootSchema) {
2004
1999
  if (!isEmpty__default["default"](jsonSchema) && jsonSchema.$ref !== undefined) {
2005
- return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref), schemaElements, currentRef, schemaName, layoutType, rootSchema);
2000
+ return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref, rootSchema), schemaElements, currentRef, schemaName, layoutType, rootSchema);
2006
2001
  }
2007
2002
  if (isCombinator(jsonSchema)) {
2008
2003
  var controlObject = createControlElement(currentRef);
@@ -2028,9 +2023,9 @@ var generateUISchema = function (jsonSchema, schemaElements, currentRef, schemaN
2028
2023
  var nextRef_1 = currentRef + '/properties';
2029
2024
  Object.keys(jsonSchema.properties).map(function (propName) {
2030
2025
  var value = jsonSchema.properties[propName];
2031
- var ref = nextRef_1 + "/" + propName;
2026
+ var ref = nextRef_1 + "/" + encode(propName);
2032
2027
  if (value.$ref !== undefined) {
2033
- value = resolveSchema(rootSchema, value.$ref);
2028
+ value = resolveSchema(rootSchema, value.$ref, rootSchema);
2034
2029
  }
2035
2030
  generateUISchema(value, layout_1.elements, ref, propName, layoutType, rootSchema);
2036
2031
  });
@@ -2288,6 +2283,7 @@ exports.createControlElement = createControlElement;
2288
2283
  exports.createDefaultValue = createDefaultValue;
2289
2284
  exports.createId = createId;
2290
2285
  exports.createLabelDescriptionFrom = createLabelDescriptionFrom;
2286
+ exports.decode = decode;
2291
2287
  exports.defaultDataReducer = defaultDataReducer;
2292
2288
  exports.defaultErrorTranslator = defaultErrorTranslator;
2293
2289
  exports.defaultJsonFormsI18nState = defaultJsonFormsI18nState;
@@ -2295,6 +2291,7 @@ exports.defaultMapDispatchToControlProps = defaultMapDispatchToControlProps;
2295
2291
  exports.defaultMapStateToEnumCellProps = defaultMapStateToEnumCellProps;
2296
2292
  exports.defaultTranslator = defaultTranslator;
2297
2293
  exports.deriveTypes = deriveTypes;
2294
+ exports.encode = encode;
2298
2295
  exports.enumToEnumOptionMapper = enumToEnumOptionMapper;
2299
2296
  exports.errorAt = errorAt;
2300
2297
  exports.errorsAt = errorsAt;
@@ -2410,7 +2407,6 @@ exports.removeId = removeId;
2410
2407
  exports.rendererReducer = rendererReducer;
2411
2408
  exports.resolveData = resolveData;
2412
2409
  exports.resolveSchema = resolveSchema;
2413
- exports.resolveSubSchemas = resolveSubSchemas;
2414
2410
  exports.schemaMatches = schemaMatches;
2415
2411
  exports.schemaSubPathMatches = schemaSubPathMatches;
2416
2412
  exports.schemaTypeIs = schemaTypeIs;