jupiter-dynamic-forms 1.20.5 → 1.20.6

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.
package/dist/index.mjs CHANGED
@@ -3087,8 +3087,28 @@ function narrowByPreferredOccurrence(candidates, ctx) {
3087
3087
  });
3088
3088
  return result;
3089
3089
  }
3090
+ function narrowToDirectChildOfDescendantAnchor(candidates, variable, ctx) {
3091
+ var _a, _b;
3092
+ if (variable.bindAsSequence)
3093
+ return candidates;
3094
+ if (new Set(candidates.map((candidate) => candidate.conceptId)).size <= 1)
3095
+ return candidates;
3096
+ const relationFilter = variable.filters.find(
3097
+ (filter2) => filter2.type === "CONCEPT_RELATION" && filter2.attributes["axis"] === "descendant"
3098
+ );
3099
+ const anchorQName = relationFilter == null ? void 0 : relationFilter.attributes["qname"];
3100
+ const linkrole = relationFilter == null ? void 0 : relationFilter.attributes["linkrole"];
3101
+ const anchorConceptId = anchorQName && linkrole ? (_a = ctx.conceptIdByQNamePerRole.get(linkrole)) == null ? void 0 : _a.get(anchorQName) : void 0;
3102
+ const directChildren = new Set(anchorConceptId && linkrole ? ((_b = ctx.childrenByRole.get(linkrole)) == null ? void 0 : _b.get(anchorConceptId)) || [] : []);
3103
+ if (directChildren.size === 0)
3104
+ return candidates;
3105
+ return candidates.filter((candidate) => directChildren.has(candidate.conceptId));
3106
+ }
3090
3107
  function resolveFormulaVariable(variable, ctx) {
3091
- const matched = narrowByPreferredOccurrence(narrowToCurrentPeriod(resolveMatchedCandidates(variable, ctx), variable, ctx), ctx);
3108
+ const matched = narrowByPreferredOccurrence(
3109
+ narrowToDirectChildOfDescendantAnchor(narrowToCurrentPeriod(resolveMatchedCandidates(variable, ctx), variable, ctx), variable, ctx),
3110
+ ctx
3111
+ );
3092
3112
  const values = matched.map((candidate) => {
3093
3113
  var _a;
3094
3114
  return resolveRawValue((_a = ctx.formData[candidate.conceptId]) == null ? void 0 : _a[candidate.columnId]);