@jsonforms/core 3.7.0-alpha.1 → 3.7.0-alpha.3

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.
@@ -597,12 +597,12 @@ const isValidateFunctionCondition = (condition) => has(condition, 'validate') &&
597
597
  const getConditionScope = (condition, path) => {
598
598
  return composeWithUi(condition, path);
599
599
  };
600
- const evaluateCondition = (data, uischema, condition, path, ajv) => {
600
+ const evaluateCondition = (data, uischema, condition, path, ajv, config) => {
601
601
  if (isAndCondition(condition)) {
602
- return condition.conditions.reduce((acc, cur) => acc && evaluateCondition(data, uischema, cur, path, ajv), true);
602
+ return condition.conditions.reduce((acc, cur) => acc && evaluateCondition(data, uischema, cur, path, ajv, config), true);
603
603
  }
604
604
  else if (isOrCondition(condition)) {
605
- return condition.conditions.reduce((acc, cur) => acc || evaluateCondition(data, uischema, cur, path, ajv), false);
605
+ return condition.conditions.reduce((acc, cur) => acc || evaluateCondition(data, uischema, cur, path, ajv, config), false);
606
606
  }
607
607
  else if (isLeafCondition(condition)) {
608
608
  const value = resolveData(data, getConditionScope(condition, path));
@@ -622,6 +622,7 @@ const evaluateCondition = (data, uischema, condition, path, ajv) => {
622
622
  fullData: data,
623
623
  path,
624
624
  uischemaElement: uischema,
625
+ config,
625
626
  };
626
627
  return condition.validate(context);
627
628
  }
@@ -629,12 +630,12 @@ const evaluateCondition = (data, uischema, condition, path, ajv) => {
629
630
  return true;
630
631
  }
631
632
  };
632
- const isRuleFulfilled = (uischema, data, path, ajv) => {
633
+ const isRuleFulfilled = (uischema, data, path, ajv, config) => {
633
634
  const condition = uischema.rule.condition;
634
- return evaluateCondition(data, uischema, condition, path, ajv);
635
+ return evaluateCondition(data, uischema, condition, path, ajv, config);
635
636
  };
636
- const evalVisibility = (uischema, data, path = undefined, ajv) => {
637
- const fulfilled = isRuleFulfilled(uischema, data, path, ajv);
637
+ const evalVisibility = (uischema, data, path = undefined, ajv, config) => {
638
+ const fulfilled = isRuleFulfilled(uischema, data, path, ajv, config);
638
639
  switch (uischema.rule.effect) {
639
640
  case RuleEffect.HIDE:
640
641
  return !fulfilled;
@@ -644,8 +645,8 @@ const evalVisibility = (uischema, data, path = undefined, ajv) => {
644
645
  return true;
645
646
  }
646
647
  };
647
- const evalEnablement = (uischema, data, path = undefined, ajv) => {
648
- const fulfilled = isRuleFulfilled(uischema, data, path, ajv);
648
+ const evalEnablement = (uischema, data, path = undefined, ajv, config) => {
649
+ const fulfilled = isRuleFulfilled(uischema, data, path, ajv, config);
649
650
  switch (uischema.rule.effect) {
650
651
  case RuleEffect.DISABLE:
651
652
  return !fulfilled;
@@ -671,15 +672,15 @@ const hasEnableRule = (uischema) => {
671
672
  }
672
673
  return false;
673
674
  };
674
- const isVisible = (uischema, data, path = undefined, ajv) => {
675
+ const isVisible = (uischema, data, path = undefined, ajv, config) => {
675
676
  if (uischema.rule) {
676
- return evalVisibility(uischema, data, path, ajv);
677
+ return evalVisibility(uischema, data, path, ajv, config);
677
678
  }
678
679
  return true;
679
680
  };
680
- const isEnabled = (uischema, data, path = undefined, ajv) => {
681
+ const isEnabled = (uischema, data, path = undefined, ajv, config) => {
681
682
  if (uischema.rule) {
682
- return evalEnablement(uischema, data, path, ajv);
683
+ return evalEnablement(uischema, data, path, ajv, config);
683
684
  }
684
685
  return true;
685
686
  };
@@ -774,11 +775,11 @@ const Paths = {
774
775
  fromScoped,
775
776
  };
776
777
  const Runtime = {
777
- isEnabled(uischema, data, ajv) {
778
- return isEnabled(uischema, data, undefined, ajv);
778
+ isEnabled(uischema, data, ajv, config) {
779
+ return isEnabled(uischema, data, undefined, ajv, config);
779
780
  },
780
- isVisible(uischema, data, ajv) {
781
- return isVisible(uischema, data, undefined, ajv);
781
+ isVisible(uischema, data, ajv, config) {
782
+ return isVisible(uischema, data, undefined, ajv, config);
782
783
  },
783
784
  };
784
785
 
@@ -2005,7 +2006,7 @@ const isInherentlyEnabled = (state, ownProps, uischema, schema, rootData, config
2005
2006
  return false;
2006
2007
  }
2007
2008
  if (uischema && hasEnableRule(uischema)) {
2008
- return isEnabled(uischema, rootData, ownProps?.path, getAjv(state));
2009
+ return isEnabled(uischema, rootData, ownProps?.path, getAjv(state), config);
2009
2010
  }
2010
2011
  if (typeof uischema?.options?.readonly === 'boolean') {
2011
2012
  return !uischema.options.readonly;
@@ -2185,8 +2186,9 @@ const mapStateToControlProps = (state, ownProps) => {
2185
2186
  const { uischema } = ownProps;
2186
2187
  const rootData = getData(state);
2187
2188
  const path = composeWithUi(uischema, ownProps.path);
2189
+ const config = getConfig(state);
2188
2190
  const visible = ownProps.visible === undefined || hasShowRule(uischema)
2189
- ? isVisible(uischema, rootData, ownProps.path, getAjv(state))
2191
+ ? isVisible(uischema, rootData, ownProps.path, getAjv(state), config)
2190
2192
  : ownProps.visible;
2191
2193
  const controlElement = uischema;
2192
2194
  const id = ownProps.id;
@@ -2199,7 +2201,6 @@ const mapStateToControlProps = (state, ownProps) => {
2199
2201
  const data = Resolve.data(rootData, path);
2200
2202
  const labelDesc = createLabelDescriptionFrom(uischema, resolvedSchema);
2201
2203
  const label = labelDesc.show ? labelDesc.text : '';
2202
- const config = getConfig(state);
2203
2204
  const enabled = isInherentlyEnabled(state, ownProps, uischema, resolvedSchema || rootSchema, rootData, config);
2204
2205
  const schema = resolvedSchema ?? rootSchema;
2205
2206
  const t = getTranslator()(state);
@@ -2380,7 +2381,7 @@ const mapStateToLayoutProps = (state, ownProps) => {
2380
2381
  const rootData = getData(state);
2381
2382
  const { uischema } = ownProps;
2382
2383
  const visible = ownProps.visible === undefined || hasShowRule(uischema)
2383
- ? isVisible(ownProps.uischema, rootData, ownProps.path, getAjv(state))
2384
+ ? isVisible(ownProps.uischema, rootData, ownProps.path, getAjv(state), getConfig(state))
2384
2385
  : ownProps.visible;
2385
2386
  const data = Resolve.data(rootData, ownProps.path);
2386
2387
  const config = getConfig(state);
@@ -2495,7 +2496,7 @@ const mapStateToArrayLayoutProps = (state, ownProps) => {
2495
2496
  const mapStateToLabelProps = (state, props) => {
2496
2497
  const { uischema } = props;
2497
2498
  const visible = props.visible === undefined || hasShowRule(uischema)
2498
- ? isVisible(props.uischema, getData(state), props.path, getAjv(state))
2499
+ ? isVisible(props.uischema, getData(state), props.path, getAjv(state), getConfig(state))
2499
2500
  : props.visible;
2500
2501
  const text = uischema.text;
2501
2502
  const t = getTranslator()(state);
@@ -2541,11 +2542,11 @@ const computeChildLabel = (data, childPath, childLabelProp, schema, rootSchema,
2541
2542
  const mapStateToCellProps = (state, ownProps) => {
2542
2543
  const { id, schema, path, uischema, renderers, cells } = ownProps;
2543
2544
  const rootData = getData(state);
2545
+ const config = getConfig(state);
2544
2546
  const visible = ownProps.visible !== undefined
2545
2547
  ? ownProps.visible
2546
- : isVisible(uischema, rootData, undefined, getAjv(state));
2548
+ : isVisible(uischema, rootData, undefined, getAjv(state), config);
2547
2549
  const rootSchema = getSchema(state);
2548
- const config = getConfig(state);
2549
2550
  let enabled;
2550
2551
  if (state.jsonforms.readonly === true) {
2551
2552
  enabled = false;