@vectoriox/iox-builder 2.3.2 → 2.3.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.
@@ -4772,9 +4772,7 @@ class BuilderComponent {
4772
4772
  this.selectedItem = event.node;
4773
4773
  this.overlayService.setSelect(event.element, event.node.type, this.activeMode, event.node, event.componentRef);
4774
4774
  this.selectPanel(PanelTypes.STYLES);
4775
- const symbolAncestor = this.findSymbolAncestorOf(event.node, this.layout)
4776
- ?? this.findSymbolAncestorOf(event.node, this.globalElements);
4777
- this.panelEventService.emit(PanelEventTypes.ELEMENT_SELECT, { node: event.node, componentRef: event.componentRef, symbolAncestor });
4775
+ this._emitElementSelect(event.node, event.componentRef);
4778
4776
  }
4779
4777
  _selectAfterDrop(node) {
4780
4778
  // Wait one tick for Angular to render the new component and register it
@@ -4786,9 +4784,7 @@ class BuilderComponent {
4786
4784
  this.selectedItem = node;
4787
4785
  this.overlayService.setSelect(ref.element, node.type, this.activeMode, node, ref.componentRef);
4788
4786
  this.selectPanel(PanelTypes.STYLES);
4789
- const symbolAncestor = this.findSymbolAncestorOf(node, this.layout)
4790
- ?? this.findSymbolAncestorOf(node, this.globalElements);
4791
- this.panelEventService.emit(PanelEventTypes.ELEMENT_SELECT, { node, componentRef: ref.componentRef, symbolAncestor });
4787
+ this._emitElementSelect(node, ref.componentRef);
4792
4788
  });
4793
4789
  }
4794
4790
  handleMouseEnter(event) {
@@ -4812,9 +4808,7 @@ class BuilderComponent {
4812
4808
  this.selectedItem = node;
4813
4809
  const ref = this.overlayService.getNodeRef(node);
4814
4810
  if (ref) {
4815
- const symbolAncestor = this.findSymbolAncestorOf(node, this.layout)
4816
- ?? this.findSymbolAncestorOf(node, this.globalElements);
4817
- this.panelEventService.emit(PanelEventTypes.ELEMENT_SELECT, { node, componentRef: ref.componentRef, symbolAncestor });
4811
+ this._emitElementSelect(node, ref.componentRef);
4818
4812
  }
4819
4813
  this.selectPanel(PanelTypes.STYLES);
4820
4814
  }
@@ -4900,7 +4894,7 @@ class BuilderComponent {
4900
4894
  if (ref) {
4901
4895
  this.selectedItem = parentNode;
4902
4896
  this.overlayService.setSelect(ref.element, parentNode.type, this.activeMode, parentNode, ref.componentRef);
4903
- this.panelEventService.emit(PanelEventTypes.ELEMENT_SELECT, { node: parentNode, componentRef: ref.componentRef });
4897
+ this._emitElementSelect(parentNode, ref.componentRef);
4904
4898
  }
4905
4899
  }
4906
4900
  else {
@@ -5129,6 +5123,28 @@ class BuilderComponent {
5129
5123
  }
5130
5124
  return null;
5131
5125
  }
5126
+ /** Nearest Repeater ancestor of `target` (or null). A node inside a repeater renders in ITEM
5127
+ * scope, so the bindings panel needs the repeater to sample its current item (e.g. bind an
5128
+ * Image to a `gallery` string item). Prefers the innermost repeater when nested. */
5129
+ findRepeaterAncestorOf(target, nodes) {
5130
+ for (const node of nodes) {
5131
+ if (node === target)
5132
+ return null;
5133
+ if (node.children?.length && this.findNodeInTree(target, node.children)) {
5134
+ return this.findRepeaterAncestorOf(target, node.children)
5135
+ ?? (node.type === 'Repeater' ? node : null);
5136
+ }
5137
+ }
5138
+ return null;
5139
+ }
5140
+ /** Emit ELEMENT_SELECT with the ancestors the panels need (symbol + repeater item scope). */
5141
+ _emitElementSelect(node, componentRef) {
5142
+ const symbolAncestor = this.findSymbolAncestorOf(node, this.layout)
5143
+ ?? this.findSymbolAncestorOf(node, this.globalElements);
5144
+ const repeaterAncestor = this.findRepeaterAncestorOf(node, this.layout)
5145
+ ?? this.findRepeaterAncestorOf(node, this.globalElements);
5146
+ this.panelEventService.emit(PanelEventTypes.ELEMENT_SELECT, { node, componentRef, symbolAncestor, repeaterAncestor });
5147
+ }
5132
5148
  handlePanelEvents(panelEvent) {
5133
5149
  if (panelEvent.type === PanelEventTypes.PANEL_CLOSE) {
5134
5150
  this.isPanelOpen = false;