@jsonforms/core 3.7.0-alpha.0 → 3.7.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.
@@ -676,12 +676,16 @@ var isValidateFunctionCondition = function (condition) {
676
676
  var getConditionScope = function (condition, path) {
677
677
  return composeWithUi(condition, path);
678
678
  };
679
- var evaluateCondition = function (data, uischema, condition, path, ajv) {
679
+ var evaluateCondition = function (data, uischema, condition, path, ajv, config) {
680
680
  if (isAndCondition(condition)) {
681
- return condition.conditions.reduce(function (acc, cur) { return acc && evaluateCondition(data, uischema, cur, path, ajv); }, true);
681
+ return condition.conditions.reduce(function (acc, cur) {
682
+ return acc && evaluateCondition(data, uischema, cur, path, ajv, config);
683
+ }, true);
682
684
  }
683
685
  else if (isOrCondition(condition)) {
684
- return condition.conditions.reduce(function (acc, cur) { return acc || evaluateCondition(data, uischema, cur, path, ajv); }, false);
686
+ return condition.conditions.reduce(function (acc, cur) {
687
+ return acc || evaluateCondition(data, uischema, cur, path, ajv, config);
688
+ }, false);
685
689
  }
686
690
  else if (isLeafCondition(condition)) {
687
691
  var value = resolveData(data, getConditionScope(condition, path));
@@ -701,6 +705,7 @@ var evaluateCondition = function (data, uischema, condition, path, ajv) {
701
705
  fullData: data,
702
706
  path: path,
703
707
  uischemaElement: uischema,
708
+ config: config,
704
709
  };
705
710
  return condition.validate(context);
706
711
  }
@@ -708,13 +713,13 @@ var evaluateCondition = function (data, uischema, condition, path, ajv) {
708
713
  return true;
709
714
  }
710
715
  };
711
- var isRuleFulfilled = function (uischema, data, path, ajv) {
716
+ var isRuleFulfilled = function (uischema, data, path, ajv, config) {
712
717
  var condition = uischema.rule.condition;
713
- return evaluateCondition(data, uischema, condition, path, ajv);
718
+ return evaluateCondition(data, uischema, condition, path, ajv, config);
714
719
  };
715
- var evalVisibility = function (uischema, data, path, ajv) {
720
+ var evalVisibility = function (uischema, data, path, ajv, config) {
716
721
  if (path === void 0) { path = undefined; }
717
- var fulfilled = isRuleFulfilled(uischema, data, path, ajv);
722
+ var fulfilled = isRuleFulfilled(uischema, data, path, ajv, config);
718
723
  switch (uischema.rule.effect) {
719
724
  case exports.RuleEffect.HIDE:
720
725
  return !fulfilled;
@@ -724,9 +729,9 @@ var evalVisibility = function (uischema, data, path, ajv) {
724
729
  return true;
725
730
  }
726
731
  };
727
- var evalEnablement = function (uischema, data, path, ajv) {
732
+ var evalEnablement = function (uischema, data, path, ajv, config) {
728
733
  if (path === void 0) { path = undefined; }
729
- var fulfilled = isRuleFulfilled(uischema, data, path, ajv);
734
+ var fulfilled = isRuleFulfilled(uischema, data, path, ajv, config);
730
735
  switch (uischema.rule.effect) {
731
736
  case exports.RuleEffect.DISABLE:
732
737
  return !fulfilled;
@@ -752,17 +757,17 @@ var hasEnableRule = function (uischema) {
752
757
  }
753
758
  return false;
754
759
  };
755
- var isVisible = function (uischema, data, path, ajv) {
760
+ var isVisible = function (uischema, data, path, ajv, config) {
756
761
  if (path === void 0) { path = undefined; }
757
762
  if (uischema.rule) {
758
- return evalVisibility(uischema, data, path, ajv);
763
+ return evalVisibility(uischema, data, path, ajv, config);
759
764
  }
760
765
  return true;
761
766
  };
762
- var isEnabled = function (uischema, data, path, ajv) {
767
+ var isEnabled = function (uischema, data, path, ajv, config) {
763
768
  if (path === void 0) { path = undefined; }
764
769
  if (uischema.rule) {
765
- return evalEnablement(uischema, data, path, ajv);
770
+ return evalEnablement(uischema, data, path, ajv, config);
766
771
  }
767
772
  return true;
768
773
  };
@@ -865,11 +870,11 @@ var Paths = {
865
870
  fromScoped: fromScoped,
866
871
  };
867
872
  var Runtime = {
868
- isEnabled: function (uischema, data, ajv) {
869
- return isEnabled(uischema, data, undefined, ajv);
873
+ isEnabled: function (uischema, data, ajv, config) {
874
+ return isEnabled(uischema, data, undefined, ajv, config);
870
875
  },
871
- isVisible: function (uischema, data, ajv) {
872
- return isVisible(uischema, data, undefined, ajv);
876
+ isVisible: function (uischema, data, ajv, config) {
877
+ return isVisible(uischema, data, undefined, ajv, config);
873
878
  },
874
879
  };
875
880
 
@@ -2207,7 +2212,7 @@ var isInherentlyEnabled = function (state, ownProps, uischema, schema, rootData,
2207
2212
  return false;
2208
2213
  }
2209
2214
  if (uischema && hasEnableRule(uischema)) {
2210
- return isEnabled(uischema, rootData, ownProps === null || ownProps === void 0 ? void 0 : ownProps.path, getAjv(state));
2215
+ return isEnabled(uischema, rootData, ownProps === null || ownProps === void 0 ? void 0 : ownProps.path, getAjv(state), config);
2211
2216
  }
2212
2217
  if (typeof ((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.readonly) === 'boolean') {
2213
2218
  return !uischema.options.readonly;
@@ -2389,8 +2394,9 @@ var mapStateToControlProps = function (state, ownProps) {
2389
2394
  var uischema = ownProps.uischema;
2390
2395
  var rootData = getData(state);
2391
2396
  var path = composeWithUi(uischema, ownProps.path);
2397
+ var config = getConfig(state);
2392
2398
  var visible = ownProps.visible === undefined || hasShowRule(uischema)
2393
- ? isVisible(uischema, rootData, ownProps.path, getAjv(state))
2399
+ ? isVisible(uischema, rootData, ownProps.path, getAjv(state), config)
2394
2400
  : ownProps.visible;
2395
2401
  var controlElement = uischema;
2396
2402
  var id = ownProps.id;
@@ -2403,7 +2409,6 @@ var mapStateToControlProps = function (state, ownProps) {
2403
2409
  var data = Resolve.data(rootData, path);
2404
2410
  var labelDesc = createLabelDescriptionFrom(uischema, resolvedSchema);
2405
2411
  var label = labelDesc.show ? labelDesc.text : '';
2406
- var config = getConfig(state);
2407
2412
  var enabled = isInherentlyEnabled(state, ownProps, uischema, resolvedSchema || rootSchema, rootData, config);
2408
2413
  var schema = resolvedSchema !== null && resolvedSchema !== void 0 ? resolvedSchema : rootSchema;
2409
2414
  var t = getTranslator()(state);
@@ -2573,7 +2578,7 @@ var mapStateToLayoutProps = function (state, ownProps) {
2573
2578
  var rootData = getData(state);
2574
2579
  var uischema = ownProps.uischema;
2575
2580
  var visible = ownProps.visible === undefined || hasShowRule(uischema)
2576
- ? isVisible(ownProps.uischema, rootData, ownProps.path, getAjv(state))
2581
+ ? isVisible(ownProps.uischema, rootData, ownProps.path, getAjv(state), getConfig(state))
2577
2582
  : ownProps.visible;
2578
2583
  var data = Resolve.data(rootData, ownProps.path);
2579
2584
  var config = getConfig(state);
@@ -2656,7 +2661,7 @@ var mapStateToArrayLayoutProps = function (state, ownProps) {
2656
2661
  var mapStateToLabelProps = function (state, props) {
2657
2662
  var uischema = props.uischema;
2658
2663
  var visible = props.visible === undefined || hasShowRule(uischema)
2659
- ? isVisible(props.uischema, getData(state), props.path, getAjv(state))
2664
+ ? isVisible(props.uischema, getData(state), props.path, getAjv(state), getConfig(state))
2660
2665
  : props.visible;
2661
2666
  var text = uischema.text;
2662
2667
  var t = getTranslator()(state);
@@ -2704,11 +2709,11 @@ var computeChildLabel = function (data, childPath, childLabelProp, schema, rootS
2704
2709
  var mapStateToCellProps = function (state, ownProps) {
2705
2710
  var id = ownProps.id, schema = ownProps.schema, path = ownProps.path, uischema = ownProps.uischema, renderers = ownProps.renderers, cells = ownProps.cells;
2706
2711
  var rootData = getData(state);
2712
+ var config = getConfig(state);
2707
2713
  var visible = ownProps.visible !== undefined
2708
2714
  ? ownProps.visible
2709
- : isVisible(uischema, rootData, undefined, getAjv(state));
2715
+ : isVisible(uischema, rootData, undefined, getAjv(state), config);
2710
2716
  var rootSchema = getSchema(state);
2711
- var config = getConfig(state);
2712
2717
  var enabled;
2713
2718
  if (state.jsonforms.readonly === true) {
2714
2719
  enabled = false;