@jsonforms/core 3.0.0-beta.4 → 3.0.0-beta.5

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 (40) hide show
  1. package/docs/assets/js/search.json +1 -1
  2. package/docs/enums/ruleeffect.html +4 -4
  3. package/docs/globals.html +149 -29
  4. package/docs/index.html +25 -4
  5. package/docs/interfaces/andcondition.html +2 -2
  6. package/docs/interfaces/categorization.html +24 -16
  7. package/docs/interfaces/category.html +24 -16
  8. package/docs/interfaces/composablecondition.html +2 -2
  9. package/docs/interfaces/condition.html +1 -1
  10. package/docs/interfaces/controlelement.html +21 -16
  11. package/docs/interfaces/grouplayout.html +24 -12
  12. package/docs/interfaces/horizontallayout.html +4 -4
  13. package/docs/interfaces/internationalizable.html +1 -10
  14. package/docs/interfaces/labeldescription.html +2 -2
  15. package/docs/interfaces/labeled.html +182 -0
  16. package/docs/interfaces/labelelement.html +4 -4
  17. package/docs/interfaces/lableable.html +184 -0
  18. package/docs/interfaces/layout.html +4 -4
  19. package/docs/interfaces/leafcondition.html +9 -8
  20. package/docs/interfaces/orcondition.html +2 -2
  21. package/docs/interfaces/rule.html +2 -2
  22. package/docs/interfaces/schemabasedcondition.html +9 -8
  23. package/docs/interfaces/scopable.html +3 -9
  24. package/docs/interfaces/scoped.html +183 -0
  25. package/docs/interfaces/uischemaelement.html +3 -3
  26. package/docs/interfaces/verticallayout.html +4 -4
  27. package/lib/jsonforms-core.cjs.js +33 -16
  28. package/lib/jsonforms-core.cjs.js.map +1 -1
  29. package/lib/jsonforms-core.esm.js +23 -20
  30. package/lib/jsonforms-core.esm.js.map +1 -1
  31. package/lib/models/uischema.d.ts +34 -26
  32. package/lib/util/runtime.d.ts +1 -2
  33. package/lib/util/util.d.ts +6 -6
  34. package/package.json +2 -2
  35. package/src/models/uischema.ts +49 -26
  36. package/src/testers/testers.ts +9 -12
  37. package/src/util/path.ts +9 -5
  38. package/src/util/runtime.ts +1 -1
  39. package/src/util/util.ts +8 -8
  40. package/stats.html +1 -1
@@ -292,11 +292,13 @@ var RuleEffect;
292
292
  RuleEffect["ENABLE"] = "ENABLE";
293
293
  RuleEffect["DISABLE"] = "DISABLE";
294
294
  })(RuleEffect || (RuleEffect = {}));
295
- const isInternationalized = (element) => {
296
- return typeof element === 'object' && element !== null && typeof element.i18n === 'string';
297
- };
295
+ const isInternationalized = (element) => typeof element === 'object' && element !== null && typeof element.i18n === 'string';
298
296
  const isGroup = (layout) => layout.type === 'Group';
299
297
  const isLayout = (uischema) => uischema.elements !== undefined;
298
+ const isScopable = (obj) => obj && typeof obj === 'object';
299
+ const isScoped = (obj) => isScopable(obj) && typeof obj.scope === 'string';
300
+ const isLabelable = (obj) => obj && typeof obj === 'object';
301
+ const isLabeled = (obj) => isLabelable(obj) && ['string', 'object'].includes(typeof obj.label);
300
302
 
301
303
  const move = (array, index, delta) => {
302
304
  const newIndex = index + delta;
@@ -882,10 +884,7 @@ const isObjectArrayWithNesting = (uischema, schema, rootSchema) => {
882
884
  }
883
885
  const schemaPath = uischema.scope;
884
886
  const resolvedSchema = resolveSchema(schema, schemaPath, rootSchema ?? schema);
885
- const wantedNestingByType = {
886
- object: 2,
887
- array: 1
888
- };
887
+ let objectDepth = 0;
889
888
  if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
890
889
  if (traverse(resolvedSchema.items, val => {
891
890
  if (val === schema) {
@@ -894,15 +893,16 @@ const isObjectArrayWithNesting = (uischema, schema, rootSchema) => {
894
893
  if (val.$ref !== undefined) {
895
894
  return false;
896
895
  }
897
- if (typeof val.type !== 'string') {
898
- return true;
896
+ if (hasType(val, 'object')) {
897
+ objectDepth++;
898
+ if (objectDepth === 2) {
899
+ return true;
900
+ }
899
901
  }
900
- const typeCount = wantedNestingByType[val.type];
901
- if (typeCount === undefined) {
902
- return false;
902
+ if (hasType(val, 'array')) {
903
+ return true;
903
904
  }
904
- wantedNestingByType[val.type] = typeCount - 1;
905
- return wantedNestingByType[val.type] === 0;
905
+ return false;
906
906
  }, rootSchema)) {
907
907
  return true;
908
908
  }
@@ -1093,11 +1093,14 @@ const toDataPath = (schemaPath) => {
1093
1093
  return toDataPathSegments(schemaPath).join('.');
1094
1094
  };
1095
1095
  const composeWithUi = (scopableUi, path) => {
1096
+ if (!isScoped(scopableUi)) {
1097
+ return path ?? '';
1098
+ }
1096
1099
  const segments = toDataPathSegments(scopableUi.scope);
1097
- if (isEmpty(segments) && path === undefined) {
1098
- return '';
1100
+ if (isEmpty(segments)) {
1101
+ return path ?? '';
1099
1102
  }
1100
- return isEmpty(segments) ? path : compose(path, segments.join('.'));
1103
+ return compose(path, segments.join('.'));
1101
1104
  };
1102
1105
  const encode = (segment) => segment?.replace(/~/g, '~0').replace(/\//g, '~1');
1103
1106
  const decode = (pointerSegment) => pointerSegment?.replace(/~1/g, '/').replace(/~0/, '~');
@@ -1331,10 +1334,10 @@ const Resolve = {
1331
1334
  schema: resolveSchema,
1332
1335
  data: resolveData
1333
1336
  };
1334
- const fromScopable = (scopable) => toDataPathSegments(scopable.scope).join('.');
1337
+ const fromScoped = (scopable) => toDataPathSegments(scopable.scope).join('.');
1335
1338
  const Paths = {
1336
1339
  compose: compose,
1337
- fromScopable
1340
+ fromScoped
1338
1341
  };
1339
1342
  const Runtime = {
1340
1343
  isEnabled(uischema, data, ajv) {
@@ -2176,5 +2179,5 @@ const Helpers = {
2176
2179
  convertToValidClassName
2177
2180
  };
2178
2181
 
2179
- 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, isInternationalized, 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 };
2182
+ 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, isInternationalized, isLabelable, isLabeled, isLayout, isMultiLineControl, isNumberControl, isNumberFormatControl, isObjectArray, isObjectArrayControl, isObjectArrayWithNesting, isObjectControl, isOneOfControl, isOneOfEnumControl, isPrimitiveArrayControl, isRangeControl, isScopable, isScoped, 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 };
2180
2183
  //# sourceMappingURL=jsonforms-core.esm.js.map