@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
@@ -731,7 +731,7 @@ const rendererReducer = (state = [], action) => {
731
731
 
732
732
  const NOT_APPLICABLE = -1;
733
733
  const isControl = (uischema) => !isEmpty(uischema) && uischema.scope !== undefined;
734
- const schemaMatches = (predicate) => (uischema, schema) => {
734
+ const schemaMatches = (predicate) => (uischema, schema, rootSchema) => {
735
735
  if (isEmpty(uischema) || !isControl(uischema)) {
736
736
  return false;
737
737
  }
@@ -744,27 +744,27 @@ const schemaMatches = (predicate) => (uischema, schema) => {
744
744
  }
745
745
  let currentDataSchema = schema;
746
746
  if (hasType(schema, 'object')) {
747
- currentDataSchema = resolveSchema(schema, schemaPath);
747
+ currentDataSchema = resolveSchema(schema, schemaPath, rootSchema);
748
748
  }
749
749
  if (currentDataSchema === undefined) {
750
750
  return false;
751
751
  }
752
- return predicate(currentDataSchema);
752
+ return predicate(currentDataSchema, rootSchema);
753
753
  };
754
- const schemaSubPathMatches = (subPath, predicate) => (uischema, schema) => {
754
+ const schemaSubPathMatches = (subPath, predicate) => (uischema, schema, rootSchema) => {
755
755
  if (isEmpty(uischema) || !isControl(uischema)) {
756
756
  return false;
757
757
  }
758
758
  const schemaPath = uischema.scope;
759
759
  let currentDataSchema = schema;
760
760
  if (hasType(schema, 'object')) {
761
- currentDataSchema = resolveSchema(schema, schemaPath);
761
+ currentDataSchema = resolveSchema(schema, schemaPath, rootSchema);
762
762
  }
763
763
  currentDataSchema = get(currentDataSchema, subPath);
764
764
  if (currentDataSchema === undefined) {
765
765
  return false;
766
766
  }
767
- return predicate(currentDataSchema);
767
+ return predicate(currentDataSchema, rootSchema);
768
768
  };
769
769
  const schemaTypeIs = (expectedType) => schemaMatches(schema => !isEmpty(schema) && hasType(schema, expectedType));
770
770
  const formatIs = (expectedFormat) => schemaMatches(schema => !isEmpty(schema) &&
@@ -791,16 +791,16 @@ const scopeEndIs = (expected) => (uischema) => {
791
791
  const schemaPath = uischema.scope;
792
792
  return !isEmpty(schemaPath) && last(schemaPath.split('/')) === expected;
793
793
  };
794
- const and = (...testers) => (uischema, schema) => testers.reduce((acc, tester) => acc && tester(uischema, schema), true);
795
- const or = (...testers) => (uischema, schema) => testers.reduce((acc, tester) => acc || tester(uischema, schema), false);
796
- const rankWith = (rank, tester) => (uischema, schema) => {
797
- if (tester(uischema, schema)) {
794
+ const and = (...testers) => (uischema, schema, rootSchema) => testers.reduce((acc, tester) => acc && tester(uischema, schema, rootSchema), true);
795
+ const or = (...testers) => (uischema, schema, rootSchema) => testers.reduce((acc, tester) => acc || tester(uischema, schema, rootSchema), false);
796
+ const rankWith = (rank, tester) => (uischema, schema, rootSchema) => {
797
+ if (tester(uischema, schema, rootSchema)) {
798
798
  return rank;
799
799
  }
800
800
  return NOT_APPLICABLE;
801
801
  };
802
- const withIncreasedRank = (by, rankedTester) => (uischema, schema) => {
803
- const rank = rankedTester(uischema, schema);
802
+ const withIncreasedRank = (by, rankedTester) => (uischema, schema, rootSchema) => {
803
+ const rank = rankedTester(uischema, schema, rootSchema);
804
804
  if (rank === NOT_APPLICABLE) {
805
805
  return NOT_APPLICABLE;
806
806
  }
@@ -821,30 +821,39 @@ const isMultiLineControl = and(uiTypeIs('Control'), optionIs('multi', true));
821
821
  const isDateControl = and(uiTypeIs('Control'), or(formatIs('date'), optionIs('format', 'date')));
822
822
  const isTimeControl = and(uiTypeIs('Control'), or(formatIs('time'), optionIs('format', 'time')));
823
823
  const isDateTimeControl = and(uiTypeIs('Control'), or(formatIs('date-time'), optionIs('format', 'date-time')));
824
- const isObjectArray = and(schemaMatches(schema => hasType(schema, 'array') && !Array.isArray(schema.items)
825
- ), schemaSubPathMatches('items', schema => hasType(schema, 'object')));
824
+ const isObjectArray = and(schemaMatches((schema, rootSchema) => hasType(schema, 'array') && !Array.isArray(resolveSchema(schema, 'items', rootSchema))
825
+ ), schemaSubPathMatches('items', (schema, rootSchema) => {
826
+ const resolvedSchema = schema.$ref ? resolveSchema(rootSchema, schema.$ref, rootSchema) : schema;
827
+ return hasType(resolvedSchema, 'object');
828
+ }));
826
829
  const isObjectArrayControl = and(uiTypeIs('Control'), isObjectArray);
827
- const traverse = (any, pred) => {
830
+ const traverse = (any, pred, rootSchema) => {
828
831
  if (isArray(any)) {
829
- return reduce(any, (acc, el) => acc || traverse(el, pred), false);
832
+ return reduce(any, (acc, el) => acc || traverse(el, pred, rootSchema), false);
830
833
  }
831
834
  if (pred(any)) {
832
835
  return true;
833
836
  }
837
+ if (any.$ref) {
838
+ const toTraverse = resolveSchema(rootSchema, any.$ref, rootSchema);
839
+ if (toTraverse && !toTraverse.$ref) {
840
+ return traverse(toTraverse, pred, rootSchema);
841
+ }
842
+ }
834
843
  if (any.items) {
835
- return traverse(any.items, pred);
844
+ return traverse(any.items, pred, rootSchema);
836
845
  }
837
846
  if (any.properties) {
838
- return reduce(toPairs(any.properties), (acc, [_key, val]) => acc || traverse(val, pred), false);
847
+ return reduce(toPairs(any.properties), (acc, [_key, val]) => acc || traverse(val, pred, rootSchema), false);
839
848
  }
840
849
  return false;
841
850
  };
842
- const isObjectArrayWithNesting = (uischema, schema) => {
843
- if (!uiTypeIs('Control')(uischema, schema)) {
851
+ const isObjectArrayWithNesting = (uischema, schema, rootSchema) => {
852
+ if (!uiTypeIs('Control')(uischema, schema, rootSchema)) {
844
853
  return false;
845
854
  }
846
855
  const schemaPath = uischema.scope;
847
- const resolvedSchema = resolveSchema(schema, schemaPath);
856
+ const resolvedSchema = resolveSchema(schema, schemaPath, rootSchema ?? schema);
848
857
  const wantedNestingByType = {
849
858
  object: 2,
850
859
  array: 1
@@ -854,6 +863,9 @@ const isObjectArrayWithNesting = (uischema, schema) => {
854
863
  if (val === schema) {
855
864
  return false;
856
865
  }
866
+ if (val.$ref !== undefined) {
867
+ return false;
868
+ }
857
869
  if (typeof val.type !== 'string') {
858
870
  return true;
859
871
  }
@@ -863,7 +875,7 @@ const isObjectArrayWithNesting = (uischema, schema) => {
863
875
  }
864
876
  wantedNestingByType[val.type] = typeCount - 1;
865
877
  return wantedNestingByType[val.type] === 0;
866
- })) {
878
+ }, rootSchema)) {
867
879
  return true;
868
880
  }
869
881
  if (uischema.options && uischema.options.detail) {
@@ -879,9 +891,11 @@ const isObjectArrayWithNesting = (uischema, schema) => {
879
891
  return false;
880
892
  };
881
893
  const isArrayObjectControl = isObjectArrayControl;
882
- const isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(schema => deriveTypes(schema).length !== 0 && !Array.isArray(schema.items)
883
- ), schemaSubPathMatches('items', schema => {
884
- const types = deriveTypes(schema);
894
+ const isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches((schema, rootSchema) => deriveTypes(schema).length !== 0 &&
895
+ !Array.isArray(resolveSchema(schema, 'items', rootSchema))
896
+ ), schemaSubPathMatches('items', (schema, rootSchema) => {
897
+ const resolvedSchema = schema.$ref ? resolveSchema(rootSchema, schema.$ref, rootSchema) : schema;
898
+ const types = deriveTypes(resolvedSchema);
885
899
  return (types.length === 1 &&
886
900
  includes(['integer', 'number', 'boolean', 'string'], types[0]));
887
901
  }));
@@ -900,7 +914,7 @@ const hasCategory = (categorization) => {
900
914
  .reduce((prev, curr) => prev && curr, true);
901
915
  };
902
916
  const categorizationHasCategory = (uischema) => hasCategory(uischema);
903
- const not = (tester) => (uischema, schema) => !tester(uischema, schema);
917
+ const not = (tester) => (uischema, schema, rootSchema) => !tester(uischema, schema, rootSchema);
904
918
 
905
919
  var index$1 = /*#__PURE__*/Object.freeze({
906
920
  __proto__: null,
@@ -978,11 +992,14 @@ const jsonFormsReducerConfig = {
978
992
  defaultData: defaultDataReducer,
979
993
  i18n: i18nReducer,
980
994
  };
981
- const findUISchema = (uischemas, schema, schemaPath, path, fallbackLayoutType = 'VerticalLayout', control, rootSchema) => {
995
+ const findUISchema = (uischemas, schema, schemaPath, path, fallback = 'VerticalLayout', control, rootSchema) => {
982
996
  if (control && control.options && control.options.detail) {
983
997
  if (typeof control.options.detail === 'string') {
984
998
  if (control.options.detail.toUpperCase() === 'GENERATE') {
985
- return Generate.uiSchema(schema, fallbackLayoutType);
999
+ if (typeof fallback === "function") {
1000
+ return fallback();
1001
+ }
1002
+ return Generate.uiSchema(schema, fallback);
986
1003
  }
987
1004
  }
988
1005
  else if (typeof control.options.detail === 'object') {
@@ -994,7 +1011,10 @@ const findUISchema = (uischemas, schema, schemaPath, path, fallbackLayoutType =
994
1011
  }
995
1012
  const uiSchema = findMatchingUISchema(uischemas)(schema, schemaPath, path);
996
1013
  if (uiSchema === undefined) {
997
- return Generate.uiSchema(schema, fallbackLayoutType, '#', rootSchema);
1014
+ if (typeof fallback === 'function') {
1015
+ return fallback();
1016
+ }
1017
+ return Generate.uiSchema(schema, fallback, '#', rootSchema);
998
1018
  }
999
1019
  return uiSchema;
1000
1020
  };
@@ -1016,6 +1036,44 @@ const getRenderers = (state) => get(state, 'jsonforms.renderers');
1016
1036
  const getCells = (state) => get(state, 'jsonforms.cells');
1017
1037
  const getUISchemas = (state) => get(state, 'jsonforms.uischemas');
1018
1038
 
1039
+ const compose = (path1, path2) => {
1040
+ let p1 = path1;
1041
+ if (!isEmpty(path1) && !isEmpty(path2) && !path2.startsWith('[')) {
1042
+ p1 = path1 + '.';
1043
+ }
1044
+ if (isEmpty(p1)) {
1045
+ return path2;
1046
+ }
1047
+ else if (isEmpty(path2)) {
1048
+ return p1;
1049
+ }
1050
+ else {
1051
+ return `${p1}${path2}`;
1052
+ }
1053
+ };
1054
+ const toDataPathSegments = (schemaPath) => {
1055
+ const s = schemaPath
1056
+ .replace(/(anyOf|allOf|oneOf)\/[\d]\//g, '')
1057
+ .replace(/(then|else)\//g, '');
1058
+ const segments = s.split('/');
1059
+ const decodedSegments = segments.map(decode);
1060
+ const startFromRoot = decodedSegments[0] === '#' || decodedSegments[0] === '';
1061
+ const startIndex = startFromRoot ? 2 : 1;
1062
+ return range(startIndex, decodedSegments.length, 2).map(idx => decodedSegments[idx]);
1063
+ };
1064
+ const toDataPath = (schemaPath) => {
1065
+ return toDataPathSegments(schemaPath).join('.');
1066
+ };
1067
+ const composeWithUi = (scopableUi, path) => {
1068
+ const segments = toDataPathSegments(scopableUi.scope);
1069
+ if (isEmpty(segments) && path === undefined) {
1070
+ return '';
1071
+ }
1072
+ return isEmpty(segments) ? path : compose(path, segments.join('.'));
1073
+ };
1074
+ const encode = (segment) => segment?.replace(/~/g, '~0').replace(/\//g, '~1');
1075
+ const decode = (pointerSegment) => pointerSegment?.replace(/~1/g, '/').replace(/~0/, '~');
1076
+
1019
1077
  const isObjectSchema = (schema) => {
1020
1078
  return schema.properties !== undefined;
1021
1079
  };
@@ -1062,90 +1120,40 @@ const findAllRefs = (schema, result = {}, resolveTuples = false) => {
1062
1120
  };
1063
1121
  const invalidSegment = (pathSegment) => pathSegment === '#' || pathSegment === undefined || pathSegment === '';
1064
1122
  const resolveSchema = (schema, schemaPath, rootSchema) => {
1123
+ const segments = schemaPath?.split('/').map(decode);
1124
+ return resolveSchemaWithSegments(schema, segments, rootSchema);
1125
+ };
1126
+ const resolveSchemaWithSegments = (schema, pathSegments, rootSchema) => {
1065
1127
  if (isEmpty(schema)) {
1066
1128
  return undefined;
1067
1129
  }
1068
- const validPathSegments = schemaPath.split('/');
1069
- let resultSchema = schema;
1070
- for (let i = 0; i < validPathSegments.length; i++) {
1071
- let pathSegment = validPathSegments[i];
1072
- resultSchema =
1073
- resultSchema === undefined || resultSchema.$ref === undefined
1074
- ? resultSchema
1075
- : resolveSchema(schema, resultSchema.$ref);
1076
- if (invalidSegment(pathSegment)) {
1077
- continue;
1078
- }
1079
- let curSchema = get(resultSchema, pathSegment);
1080
- if (!curSchema) {
1081
- const schemas = [].concat(resultSchema?.oneOf ?? [], resultSchema?.allOf ?? [], resultSchema?.anyOf ?? []);
1082
- for (let item of schemas) {
1083
- curSchema = resolveSchema(item, validPathSegments.slice(i).join('/'));
1084
- if (curSchema) {
1085
- break;
1086
- }
1087
- }
1088
- if (curSchema) {
1089
- resultSchema = curSchema;
1090
- break;
1091
- }
1092
- }
1093
- resultSchema = curSchema;
1094
- }
1095
- if (resultSchema !== undefined && resultSchema.$ref !== undefined) {
1096
- try {
1097
- return retrieveResolvableSchema(schema, resultSchema.$ref);
1098
- }
1099
- catch (e) {
1100
- return retrieveResolvableSchema(rootSchema, resultSchema.$ref);
1101
- }
1102
- }
1103
- return resultSchema;
1104
- };
1105
- function retrieveResolvableSchema(full, reference) {
1106
- const child = resolveSchema(full, reference);
1107
- const allRefs = findAllRefs(child);
1108
- const innerSelfReference = allRefs[reference];
1109
- if (innerSelfReference !== undefined) {
1110
- innerSelfReference.$ref = '#';
1130
+ if (schema.$ref) {
1131
+ schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
1111
1132
  }
1112
- return child;
1113
- }
1114
-
1115
- const compose = (path1, path2) => {
1116
- let p1 = path1;
1117
- if (!isEmpty(path1) && !isEmpty(path2) && !path2.startsWith('[')) {
1118
- p1 = path1 + '.';
1119
- }
1120
- if (isEmpty(p1)) {
1121
- return path2;
1133
+ if (!pathSegments || pathSegments.length === 0) {
1134
+ return schema;
1122
1135
  }
1123
- else if (isEmpty(path2)) {
1124
- return p1;
1136
+ const [segment, ...remainingSegments] = pathSegments;
1137
+ if (invalidSegment(segment)) {
1138
+ return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
1125
1139
  }
1126
- else {
1127
- return `${p1}${path2}`;
1140
+ const singleSegmentResolveSchema = get(schema, segment);
1141
+ const resolvedSchema = resolveSchemaWithSegments(singleSegmentResolveSchema, remainingSegments, rootSchema);
1142
+ if (resolvedSchema) {
1143
+ return resolvedSchema;
1128
1144
  }
1129
- };
1130
- const toDataPathSegments = (schemaPath) => {
1131
- const s = schemaPath
1132
- .replace(/anyOf\/[\d]\//g, '')
1133
- .replace(/allOf\/[\d]\//g, '')
1134
- .replace(/oneOf\/[\d]\//g, '');
1135
- const segments = s.split('/');
1136
- const startFromRoot = segments[0] === '#' || segments[0] === '';
1137
- const startIndex = startFromRoot ? 2 : 1;
1138
- return range(startIndex, segments.length, 2).map(idx => segments[idx]);
1139
- };
1140
- const toDataPath = (schemaPath) => {
1141
- return toDataPathSegments(schemaPath).join('.');
1142
- };
1143
- const composeWithUi = (scopableUi, path) => {
1144
- const segments = toDataPathSegments(scopableUi.scope);
1145
- if (isEmpty(segments) && path === undefined) {
1146
- return '';
1145
+ if (segment === 'properties' || segment === 'items') {
1146
+ let alternativeResolveResult = undefined;
1147
+ const subSchemas = [].concat(schema.oneOf ?? [], schema.allOf ?? [], schema.anyOf ?? [], schema.then ?? [], schema.else ?? []);
1148
+ for (const subSchema of subSchemas) {
1149
+ alternativeResolveResult = resolveSchemaWithSegments(subSchema, [segment, ...remainingSegments], rootSchema);
1150
+ if (alternativeResolveResult) {
1151
+ break;
1152
+ }
1153
+ }
1154
+ return alternativeResolveResult;
1147
1155
  }
1148
- return isEmpty(segments) ? path : compose(path, segments.join('.'));
1156
+ return undefined;
1149
1157
  };
1150
1158
 
1151
1159
  const isOrCondition = (condition) => condition.type === 'OR';
@@ -1315,7 +1323,7 @@ const deriveLabel = (controlElement, schemaElement) => {
1315
1323
  }
1316
1324
  if (typeof controlElement.scope === 'string') {
1317
1325
  const ref = controlElement.scope;
1318
- const label = ref.substr(ref.lastIndexOf('/') + 1);
1326
+ const label = decode(ref.substr(ref.lastIndexOf('/') + 1));
1319
1327
  return startCase(label);
1320
1328
  }
1321
1329
  return '';
@@ -1345,30 +1353,6 @@ const labelDescription = (text, show) => ({
1345
1353
  show: show
1346
1354
  });
1347
1355
 
1348
- const createLabel = (subSchema, subSchemaIndex, keyword) => {
1349
- if (subSchema.title) {
1350
- return subSchema.title;
1351
- }
1352
- else {
1353
- return keyword + '-' + subSchemaIndex;
1354
- }
1355
- };
1356
- const resolveSubSchemas = (schema, rootSchema, keyword) => {
1357
- const schemas = schema[keyword];
1358
- if (schemas.findIndex(e => e.$ref !== undefined) !== -1) {
1359
- return {
1360
- ...schema,
1361
- [keyword]: schema[keyword].map(e => e.$ref ? resolveSchema(rootSchema, e.$ref) : e)
1362
- };
1363
- }
1364
- return schema;
1365
- };
1366
- const createCombinatorRenderInfos = (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) => combinatorSubSchemas.map((subSchema, subSchemaIndex) => ({
1367
- schema: subSchema,
1368
- uischema: findUISchema(uischemas, subSchema, control.scope, path, undefined, control, rootSchema),
1369
- label: createLabel(subSchema, subSchemaIndex, keyword)
1370
- }));
1371
-
1372
1356
  const isRequired = (schema, schemaPath, rootSchema) => {
1373
1357
  const pathSegments = schemaPath.split('/');
1374
1358
  const lastSegment = pathSegments[pathSegments.length - 1];
@@ -1648,7 +1632,8 @@ const mapStateToLayoutProps = (state, ownProps) => {
1648
1632
  data,
1649
1633
  uischema: ownProps.uischema,
1650
1634
  schema: ownProps.schema,
1651
- direction: ownProps.direction ?? getDirection(uischema)
1635
+ direction: ownProps.direction ?? getDirection(uischema),
1636
+ config
1652
1637
  };
1653
1638
  };
1654
1639
  const mapStateToJsonFormsRendererProps = (state, ownProps) => {
@@ -1675,18 +1660,8 @@ const controlDefaultProps = {
1675
1660
  errors: []
1676
1661
  };
1677
1662
  const mapStateToCombinatorRendererProps = (state, ownProps, keyword) => {
1678
- const { uischema } = ownProps;
1679
- const path = composeWithUi(uischema, ownProps.path);
1680
- const rootSchema = getSchema(state);
1681
- const resolvedSchema = Resolve.schema(ownProps.schema || rootSchema, uischema.scope, rootSchema);
1682
- const visible = ownProps.visible === undefined || hasShowRule(uischema)
1683
- ? isVisible(uischema, getData(state), ownProps.path, getAjv(state))
1684
- : ownProps.visible;
1685
- const id = ownProps.id;
1686
- const data = Resolve.data(getData(state), path);
1663
+ const { data, schema, ...props } = mapStateToControlProps(state, ownProps);
1687
1664
  const ajv = state.jsonforms.core.ajv;
1688
- const schema = resolvedSchema || rootSchema;
1689
- const _schema = resolveSubSchemas(schema, rootSchema, keyword);
1690
1665
  const structuralKeywords = [
1691
1666
  'required',
1692
1667
  'additionalProperties',
@@ -1700,9 +1675,9 @@ const mapStateToCombinatorRendererProps = (state, ownProps, keyword) => {
1700
1675
  !errors.find(e => structuralKeywords.indexOf(e.keyword) !== -1));
1701
1676
  };
1702
1677
  let indexOfFittingSchema;
1703
- for (let i = 0; i < _schema[keyword].length; i++) {
1678
+ for (let i = 0; i < schema[keyword]?.length; i++) {
1704
1679
  try {
1705
- const valFn = ajv.compile(_schema[keyword][i]);
1680
+ const valFn = ajv.compile(schema[keyword][i]);
1706
1681
  valFn(data);
1707
1682
  if (dataIsValid(valFn.errors)) {
1708
1683
  indexOfFittingSchema = i;
@@ -1715,14 +1690,10 @@ const mapStateToCombinatorRendererProps = (state, ownProps, keyword) => {
1715
1690
  }
1716
1691
  return {
1717
1692
  data,
1718
- path,
1719
1693
  schema,
1720
- rootSchema,
1721
- visible,
1722
- id,
1694
+ ...props,
1723
1695
  indexOfFittingSchema,
1724
- uischemas: state.jsonforms.uischemas,
1725
- uischema
1696
+ uischemas: getUISchemas(state)
1726
1697
  };
1727
1698
  };
1728
1699
  const mapStateToAllOfProps = (state, ownProps) => mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
@@ -1825,6 +1796,23 @@ const defaultMapDispatchToControlProps =
1825
1796
  };
1826
1797
  };
1827
1798
 
1799
+ const createLabel = (subSchema, subSchemaIndex, keyword) => {
1800
+ if (subSchema.title) {
1801
+ return subSchema.title;
1802
+ }
1803
+ else {
1804
+ return keyword + '-' + subSchemaIndex;
1805
+ }
1806
+ };
1807
+ const createCombinatorRenderInfos = (combinatorSubSchemas, rootSchema, keyword, control, path, uischemas) => combinatorSubSchemas.map((subSchema, subSchemaIndex) => {
1808
+ const schema = subSchema.$ref ? Resolve.schema(rootSchema, subSchema.$ref, rootSchema) : subSchema;
1809
+ return {
1810
+ schema,
1811
+ uischema: findUISchema(uischemas, schema, control.scope, path, undefined, control, rootSchema),
1812
+ label: createLabel(subSchema, subSchemaIndex, keyword)
1813
+ };
1814
+ });
1815
+
1828
1816
  const usedIds = new Set();
1829
1817
  const makeId = (idBase, iteration) => iteration <= 1 ? idBase : idBase + iteration.toString();
1830
1818
  const isUniqueId = (idBase, iteration) => {
@@ -1931,7 +1919,7 @@ const isCombinator = (jsonSchema) => {
1931
1919
  };
1932
1920
  const generateUISchema = (jsonSchema, schemaElements, currentRef, schemaName, layoutType, rootSchema) => {
1933
1921
  if (!isEmpty(jsonSchema) && jsonSchema.$ref !== undefined) {
1934
- return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref), schemaElements, currentRef, schemaName, layoutType, rootSchema);
1922
+ return generateUISchema(resolveSchema(rootSchema, jsonSchema.$ref, rootSchema), schemaElements, currentRef, schemaName, layoutType, rootSchema);
1935
1923
  }
1936
1924
  if (isCombinator(jsonSchema)) {
1937
1925
  const controlObject = createControlElement(currentRef);
@@ -1957,9 +1945,9 @@ const generateUISchema = (jsonSchema, schemaElements, currentRef, schemaName, la
1957
1945
  const nextRef = currentRef + '/properties';
1958
1946
  Object.keys(jsonSchema.properties).map(propName => {
1959
1947
  let value = jsonSchema.properties[propName];
1960
- const ref = `${nextRef}/${propName}`;
1948
+ const ref = `${nextRef}/${encode(propName)}`;
1961
1949
  if (value.$ref !== undefined) {
1962
- value = resolveSchema(rootSchema, value.$ref);
1950
+ value = resolveSchema(rootSchema, value.$ref, rootSchema);
1963
1951
  }
1964
1952
  generateUISchema(value, layout.elements, ref, propName, layoutType, rootSchema);
1965
1953
  });
@@ -2160,5 +2148,5 @@ const Helpers = {
2160
2148
  convertToValidClassName
2161
2149
  };
2162
2150
 
2163
- export { ADD_CELL, ADD_DEFAULT_DATA, ADD_RENDERER, ADD_UI_SCHEMA, index as Actions, Draft4, Generate, Helpers, INIT, NOT_APPLICABLE, Paths, REMOVE_CELL, REMOVE_DEFAULT_DATA, REMOVE_RENDERER, REMOVE_UI_SCHEMA, Resolve, RuleEffect, Runtime, SET_AJV, SET_CONFIG, SET_LOCALE, SET_SCHEMA, SET_TRANSLATOR, SET_UISCHEMA, SET_VALIDATION_MODE, index$1 as Test, UPDATE_CORE, UPDATE_DATA, UPDATE_ERRORS, UPDATE_I18N, VALIDATE, and, categorizationHasCategory, cellReducer, clearAllIds, compose, compose as composePaths, composeWithUi, computeLabel, configReducer, controlDefaultProps, convertToValidClassName, coreReducer, createAjv, createCleanLabel, createCombinatorRenderInfos, createControlElement, createDefaultValue, createId, createLabelDescriptionFrom, defaultDataReducer, defaultErrorTranslator, defaultJsonFormsI18nState, defaultMapDispatchToControlProps, defaultMapStateToEnumCellProps, defaultTranslator, deriveTypes, enumToEnumOptionMapper, errorAt, errorsAt, evalEnablement, evalVisibility, extractAjv, extractData, extractDefaultData, extractSchema, extractUiSchema, fetchErrorTranslator, fetchLocale, fetchTranslator, findAllRefs, findMatchingUISchema, findUISchema, formatErrorMessage, formatIs, generateDefaultUISchema, generateJsonSchema, getAjv, getCells, getCombinedErrorMessage, getConfig, getControlPath, getData, getDefaultData, getErrorAt, getErrorTranslator, getFirstPrimitiveProp, getI18nKey, getI18nKeyPrefix, getI18nKeyPrefixBySchema, getLocale, getRenderers, getSchema, getSubErrorsAt, getTranslator, getUISchemas, getUiSchema, hasCategory, hasEnableRule, hasShowRule, hasType, i18nReducer, init, isAllOfControl, isAnyOfControl, isArrayObjectControl, isBooleanControl, isCategorization, isCategory, isControl, isDateControl, isDateTimeControl, isDescriptionHidden, isEnabled, isEnumControl, isGroup, isInherentlyEnabled, isIntegerControl, isLayout, isMultiLineControl, isNumberControl, isNumberFormatControl, isObjectArray, isObjectArrayControl, isObjectArrayWithNesting, isObjectControl, isOneOfControl, isOneOfEnumControl, isPrimitiveArrayControl, isRangeControl, isStringControl, isTimeControl, isVisible, iterateSchema, jsonFormsReducerConfig, layoutDefaultProps, mapDispatchToArrayControlProps, mapDispatchToCellProps, mapDispatchToControlProps, mapDispatchToMultiEnumProps, mapStateToAllOfProps, mapStateToAnyOfProps, mapStateToArrayControlProps, mapStateToArrayLayoutProps, mapStateToCellProps, mapStateToCombinatorRendererProps, mapStateToControlProps, mapStateToControlWithDetailProps, mapStateToDispatchCellProps, mapStateToEnumControlProps, mapStateToJsonFormsRendererProps, mapStateToLayoutProps, mapStateToMasterListItemProps, mapStateToMultiEnumControlProps, mapStateToOneOfEnumCellProps, mapStateToOneOfEnumControlProps, mapStateToOneOfProps, moveDown, moveUp, not, oneOfToEnumOptionMapper, optionIs, or, rankWith, registerCell, registerDefaultData, registerRenderer, registerUISchema, removeId, rendererReducer, resolveData, resolveSchema, resolveSubSchemas, schemaMatches, schemaSubPathMatches, schemaTypeIs, scopeEndIs, scopeEndsWith, setAjv, setConfig, setLocale, setReadonly, setSchema, setTranslator, setUISchema, setValidationMode, showAsRequired, subErrorsAt, toDataPath, toDataPathSegments, transformPathToI18nPrefix, uiTypeIs, uischemaRegistryReducer, unregisterCell, unregisterDefaultData, unregisterRenderer, unregisterUISchema, unsetReadonly, update, updateCore, updateErrors, updateI18n, validate, withIncreasedRank };
2151
+ export { ADD_CELL, ADD_DEFAULT_DATA, ADD_RENDERER, ADD_UI_SCHEMA, index as Actions, Draft4, Generate, Helpers, INIT, NOT_APPLICABLE, Paths, REMOVE_CELL, REMOVE_DEFAULT_DATA, REMOVE_RENDERER, REMOVE_UI_SCHEMA, Resolve, RuleEffect, Runtime, SET_AJV, SET_CONFIG, SET_LOCALE, SET_SCHEMA, SET_TRANSLATOR, SET_UISCHEMA, SET_VALIDATION_MODE, index$1 as Test, UPDATE_CORE, UPDATE_DATA, UPDATE_ERRORS, UPDATE_I18N, VALIDATE, and, categorizationHasCategory, cellReducer, clearAllIds, compose, compose as composePaths, composeWithUi, computeLabel, configReducer, controlDefaultProps, convertToValidClassName, coreReducer, createAjv, createCleanLabel, createCombinatorRenderInfos, createControlElement, createDefaultValue, createId, createLabelDescriptionFrom, decode, defaultDataReducer, defaultErrorTranslator, defaultJsonFormsI18nState, defaultMapDispatchToControlProps, defaultMapStateToEnumCellProps, defaultTranslator, deriveTypes, encode, enumToEnumOptionMapper, errorAt, errorsAt, evalEnablement, evalVisibility, extractAjv, extractData, extractDefaultData, extractSchema, extractUiSchema, fetchErrorTranslator, fetchLocale, fetchTranslator, findAllRefs, findMatchingUISchema, findUISchema, formatErrorMessage, formatIs, generateDefaultUISchema, generateJsonSchema, getAjv, getCells, getCombinedErrorMessage, getConfig, getControlPath, getData, getDefaultData, getErrorAt, getErrorTranslator, getFirstPrimitiveProp, getI18nKey, getI18nKeyPrefix, getI18nKeyPrefixBySchema, getLocale, getRenderers, getSchema, getSubErrorsAt, getTranslator, getUISchemas, getUiSchema, hasCategory, hasEnableRule, hasShowRule, hasType, i18nReducer, init, isAllOfControl, isAnyOfControl, isArrayObjectControl, isBooleanControl, isCategorization, isCategory, isControl, isDateControl, isDateTimeControl, isDescriptionHidden, isEnabled, isEnumControl, isGroup, isInherentlyEnabled, isIntegerControl, isLayout, isMultiLineControl, isNumberControl, isNumberFormatControl, isObjectArray, isObjectArrayControl, isObjectArrayWithNesting, isObjectControl, isOneOfControl, isOneOfEnumControl, isPrimitiveArrayControl, isRangeControl, isStringControl, isTimeControl, isVisible, iterateSchema, jsonFormsReducerConfig, layoutDefaultProps, mapDispatchToArrayControlProps, mapDispatchToCellProps, mapDispatchToControlProps, mapDispatchToMultiEnumProps, mapStateToAllOfProps, mapStateToAnyOfProps, mapStateToArrayControlProps, mapStateToArrayLayoutProps, mapStateToCellProps, mapStateToCombinatorRendererProps, mapStateToControlProps, mapStateToControlWithDetailProps, mapStateToDispatchCellProps, mapStateToEnumControlProps, mapStateToJsonFormsRendererProps, mapStateToLayoutProps, mapStateToMasterListItemProps, mapStateToMultiEnumControlProps, mapStateToOneOfEnumCellProps, mapStateToOneOfEnumControlProps, mapStateToOneOfProps, moveDown, moveUp, not, oneOfToEnumOptionMapper, optionIs, or, rankWith, registerCell, registerDefaultData, registerRenderer, registerUISchema, removeId, rendererReducer, resolveData, resolveSchema, schemaMatches, schemaSubPathMatches, schemaTypeIs, scopeEndIs, scopeEndsWith, setAjv, setConfig, setLocale, setReadonly, setSchema, setTranslator, setUISchema, setValidationMode, showAsRequired, subErrorsAt, toDataPath, toDataPathSegments, transformPathToI18nPrefix, uiTypeIs, uischemaRegistryReducer, unregisterCell, unregisterDefaultData, unregisterRenderer, unregisterUISchema, unsetReadonly, update, updateCore, updateErrors, updateI18n, validate, withIncreasedRank };
2164
2152
  //# sourceMappingURL=jsonforms-core.esm.js.map