@vectoriox/iox-builder 2.3.2 → 2.3.4

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.
@@ -2395,6 +2395,39 @@ function arraySchemaFields(properties) {
2395
2395
  }
2396
2396
  return out;
2397
2397
  }
2398
+ /**
2399
+ * Describe the ITEM shape of an array PROPERTY, straight from the schema — the authoritative source
2400
+ * (a resolved sample may be missing, or ambiguous). Given a resource's schema `properties` and the
2401
+ * dot-path to an array field (e.g. `gallery` or `info.items`):
2402
+ * - **object item** → its primitive leaf fields (flattened): `[{label:'url',value:'url'}, …]`.
2403
+ * - **primitive item** (`string[]`/`number[]`) → `isPrimitive:true` (caller offers "(the item value)").
2404
+ * - **can't tell** (many-relation whose items are related docs, or path not found) → both empty, so
2405
+ * the caller falls back to a resolved sample.
2406
+ * JSON-schema arrays store the item schema under `.items`; embedded objects under `.properties`.
2407
+ */
2408
+ function arrayItemSchemaFields(properties, arrayPath) {
2409
+ const parts = (arrayPath ?? '').split('.').filter(Boolean);
2410
+ let field = undefined;
2411
+ let cursor = properties ?? {};
2412
+ for (const part of parts) {
2413
+ field = cursor?.[part];
2414
+ if (!field)
2415
+ return { fields: [], isPrimitive: false };
2416
+ cursor = field.properties ?? field.items?.properties ?? {};
2417
+ }
2418
+ if (!field)
2419
+ return { fields: [], isPrimitive: false };
2420
+ const itemProps = field.items?.properties ?? (field.type === 'embedded' ? field.properties : undefined);
2421
+ if (itemProps && Object.keys(itemProps).length) {
2422
+ return { fields: flattenSchemaFields(itemProps), isPrimitive: false };
2423
+ }
2424
+ // Many-relation: items are related documents — needs the related schema, so let the caller sample.
2425
+ const relType = (field.rel?.type ?? '').toString().toLowerCase();
2426
+ if (field.type === 'rel' || relType.includes('many'))
2427
+ return { fields: [], isPrimitive: false };
2428
+ // Otherwise a primitive-item array (string[]/number[]/…): the item is bound as its own value.
2429
+ return { fields: [], isPrimitive: true };
2430
+ }
2398
2431
 
2399
2432
  /**
2400
2433
  * StyleRegistryService — manages a single <style> tag for the builder canvas.
@@ -4772,9 +4805,7 @@ class BuilderComponent {
4772
4805
  this.selectedItem = event.node;
4773
4806
  this.overlayService.setSelect(event.element, event.node.type, this.activeMode, event.node, event.componentRef);
4774
4807
  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 });
4808
+ this._emitElementSelect(event.node, event.componentRef);
4778
4809
  }
4779
4810
  _selectAfterDrop(node) {
4780
4811
  // Wait one tick for Angular to render the new component and register it
@@ -4786,9 +4817,7 @@ class BuilderComponent {
4786
4817
  this.selectedItem = node;
4787
4818
  this.overlayService.setSelect(ref.element, node.type, this.activeMode, node, ref.componentRef);
4788
4819
  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 });
4820
+ this._emitElementSelect(node, ref.componentRef);
4792
4821
  });
4793
4822
  }
4794
4823
  handleMouseEnter(event) {
@@ -4812,9 +4841,7 @@ class BuilderComponent {
4812
4841
  this.selectedItem = node;
4813
4842
  const ref = this.overlayService.getNodeRef(node);
4814
4843
  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 });
4844
+ this._emitElementSelect(node, ref.componentRef);
4818
4845
  }
4819
4846
  this.selectPanel(PanelTypes.STYLES);
4820
4847
  }
@@ -4900,7 +4927,7 @@ class BuilderComponent {
4900
4927
  if (ref) {
4901
4928
  this.selectedItem = parentNode;
4902
4929
  this.overlayService.setSelect(ref.element, parentNode.type, this.activeMode, parentNode, ref.componentRef);
4903
- this.panelEventService.emit(PanelEventTypes.ELEMENT_SELECT, { node: parentNode, componentRef: ref.componentRef });
4930
+ this._emitElementSelect(parentNode, ref.componentRef);
4904
4931
  }
4905
4932
  }
4906
4933
  else {
@@ -5129,6 +5156,28 @@ class BuilderComponent {
5129
5156
  }
5130
5157
  return null;
5131
5158
  }
5159
+ /** Nearest Repeater ancestor of `target` (or null). A node inside a repeater renders in ITEM
5160
+ * scope, so the bindings panel needs the repeater to sample its current item (e.g. bind an
5161
+ * Image to a `gallery` string item). Prefers the innermost repeater when nested. */
5162
+ findRepeaterAncestorOf(target, nodes) {
5163
+ for (const node of nodes) {
5164
+ if (node === target)
5165
+ return null;
5166
+ if (node.children?.length && this.findNodeInTree(target, node.children)) {
5167
+ return this.findRepeaterAncestorOf(target, node.children)
5168
+ ?? (node.type === 'Repeater' ? node : null);
5169
+ }
5170
+ }
5171
+ return null;
5172
+ }
5173
+ /** Emit ELEMENT_SELECT with the ancestors the panels need (symbol + repeater item scope). */
5174
+ _emitElementSelect(node, componentRef) {
5175
+ const symbolAncestor = this.findSymbolAncestorOf(node, this.layout)
5176
+ ?? this.findSymbolAncestorOf(node, this.globalElements);
5177
+ const repeaterAncestor = this.findRepeaterAncestorOf(node, this.layout)
5178
+ ?? this.findRepeaterAncestorOf(node, this.globalElements);
5179
+ this.panelEventService.emit(PanelEventTypes.ELEMENT_SELECT, { node, componentRef, symbolAncestor, repeaterAncestor });
5180
+ }
5132
5181
  handlePanelEvents(panelEvent) {
5133
5182
  if (panelEvent.type === PanelEventTypes.PANEL_CLOSE) {
5134
5183
  this.isPanelOpen = false;
@@ -8127,5 +8176,5 @@ class BuilderSpacerComponentConfig extends ComponentConfig {
8127
8176
  * Generated bundle index. Do not edit.
8128
8177
  */
8129
8178
 
8130
- export { ACTION_TYPE_OPTIONS, BackgroundGroupStyleConfig, BorderGroupStyleConfig, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderClipboardService, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDataSourceService, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderHistoryService, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderListComponentConfig, BuilderListItemComponentConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ComponentConfig, ComponentRegistryService, DEVICE_OPTIONS, DataSourceRegistryService, DataSourceType, DeviceMode, DimensionsGroupStyleConfig, DragEngineService, EASING_OPTIONS, EffectsGroupStyleConfig, GroupStyleConfig, INTERACTION_STATES, INVERSE_ACTION, IOX_DATA_SOURCE_ENDPOINTS, IOX_FONT_MANAGER, InteractionEngineService, InteractionPresetRegistryService, InteractionsPanelComponent, IoxBuilderModule, IoxDraggableDirective, IoxDropzoneDirective, LayerTreeComponent, LayoutGroupStyleConfig, ListGroupStyleConfig, NodeAction, OverlayComponent, OverlayService, PanelChildComponent, PanelComponent, PanelEventService, PanelEventTypes, PanelTypes, PositionGroupStyleConfig, PresetRegistryService, RELATIONAL_STATES, RELATIONAL_STATE_BASE, ROUTE_ANIMATION_OPTIONS, RenderDirective, RepeaterComponentConfig, SCREEN_WIDTH_OPTIONS, STRUCTURAL_STATES, SUPPORTED_STATES, SectionComponent, SectionComponentConfig, SizeGroupStyleConfig, SliderContainerComponent, SliderContainerConfig, SliderSlideComponent, SliderSlideConfig, SpacingGroupStyleConfig, StyleCategory, StyleRegistryService, TraitConfig as StyleTraitConfig, SymbolRegistryService, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, TypographyGroupStyleConfig, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, arraySchemaFields, buildFullStyleTraits, buildPresetStyleTraits, defaultPageSettings, flattenSchemaFields, generateNodeId, resolveTraitControllerType, resolveTraitOptions };
8179
+ export { ACTION_TYPE_OPTIONS, BackgroundGroupStyleConfig, BorderGroupStyleConfig, BuilderButtonBlockComponent, BuilderButtonComponentConfig, BuilderClipboardService, BuilderComponent, BuilderContainerComponent, BuilderContainerComponentConfig, BuilderDataSourceService, BuilderDividerComponentConfig, BuilderHeadingComponentConfig, BuilderHistoryService, BuilderIconComponentConfig, BuilderImageComponentConfig, BuilderLinkComponentConfig, BuilderLinkedContainerComponent, BuilderLinkedContainerConfig, BuilderListComponentConfig, BuilderListItemComponentConfig, BuilderMode, BuilderRepeaterComponent, BuilderSpacerComponentConfig, ButtonBlockComponentConfig, CardComponentConfig, ComponentConfig, ComponentRegistryService, DEVICE_OPTIONS, DataSourceRegistryService, DataSourceType, DeviceMode, DimensionsGroupStyleConfig, DragEngineService, EASING_OPTIONS, EffectsGroupStyleConfig, GroupStyleConfig, INTERACTION_STATES, INVERSE_ACTION, IOX_DATA_SOURCE_ENDPOINTS, IOX_FONT_MANAGER, InteractionEngineService, InteractionPresetRegistryService, InteractionsPanelComponent, IoxBuilderModule, IoxDraggableDirective, IoxDropzoneDirective, LayerTreeComponent, LayoutGroupStyleConfig, ListGroupStyleConfig, NodeAction, OverlayComponent, OverlayService, PanelChildComponent, PanelComponent, PanelEventService, PanelEventTypes, PanelTypes, PositionGroupStyleConfig, PresetRegistryService, RELATIONAL_STATES, RELATIONAL_STATE_BASE, ROUTE_ANIMATION_OPTIONS, RenderDirective, RepeaterComponentConfig, SCREEN_WIDTH_OPTIONS, STRUCTURAL_STATES, SUPPORTED_STATES, SectionComponent, SectionComponentConfig, SizeGroupStyleConfig, SliderContainerComponent, SliderContainerConfig, SliderSlideComponent, SliderSlideConfig, SpacingGroupStyleConfig, StyleCategory, StyleRegistryService, TraitConfig as StyleTraitConfig, SymbolRegistryService, TRIGGER_OPTIONS, TextBlockComponentConfig, ToolbarAction, ToolbarComponent, TraitConfig, TraitInputType, TypographyGroupStyleConfig, UNITS_ALL, UNITS_DEG, UNITS_FIXED, UNITS_NO_VW, ViewportService, ZOOM_OPTIONS, arrayItemSchemaFields, arraySchemaFields, buildFullStyleTraits, buildPresetStyleTraits, defaultPageSettings, flattenSchemaFields, generateNodeId, resolveTraitControllerType, resolveTraitOptions };
8131
8180
  //# sourceMappingURL=vectoriox-iox-builder.mjs.map