@vectoriox/iox-builder 1.6.12 → 1.6.13

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, inject, NgZone, EventEmitter, Output, Input, Directive, ChangeDetectionStrategy, Component, ViewChild, Optional, Inject, InjectionToken, ContentChildren, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
2
+ import { Injectable, inject, NgZone, EventEmitter, createComponent, Output, Input, Inject, Directive, ChangeDetectionStrategy, Component, ViewChild, Optional, InjectionToken, ContentChildren, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
3
3
  import * as i2 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
4
+ import { DOCUMENT, CommonModule } from '@angular/common';
5
5
  import * as i4$1 from '@angular/forms';
6
6
  import { FormsModule } from '@angular/forms';
7
7
  import * as i4 from '@angular/cdk/drag-drop';
@@ -2663,6 +2663,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
2663
2663
 
2664
2664
  // Module-level counter — unique drop-list ID per Section instance across the whole app session.
2665
2665
  let dropListCounter = 0;
2666
+ /**
2667
+ * Node types whose iox-ui component is a DIRECTIVE-HOST (element+attribute selector on the real
2668
+ * tag, e.g. `img[iox-img]`, `h1[iox-heading]`). The host IS the element, so we must NOT force an
2669
+ * inline `display:block` (it out-ranks both `:host` and the styleProps `.iox-node` rule — the same
2670
+ * bug the SSR engine hit). Mirrors the engine's DIRECTIVE_HOST_TYPES for the leaf/variable-tag set.
2671
+ * NOTE: Container/Section/List/ListItem render via iox-BUILDER wrapper components here (not
2672
+ * directive-hosts), so they are intentionally excluded.
2673
+ */
2674
+ const DIRECTIVE_HOST_TYPES = new Set([
2675
+ 'Image', 'Icon', 'Divider', 'Spacer', 'Button', 'Link', 'Heading', 'Text', 'ButtonBlock',
2676
+ ]);
2666
2677
  /**
2667
2678
  * RenderDirective — applied to <ng-container> to dynamically instantiate a
2668
2679
  * builder component with zero wrapper elements in the DOM.
@@ -2679,9 +2690,11 @@ let dropListCounter = 0;
2679
2690
  * </ng-container>
2680
2691
  */
2681
2692
  class RenderDirective {
2682
- constructor(vcr, injector, registryService, overlayService, styleRegistry, interactionEngine, cdr, panelEventService) {
2693
+ constructor(vcr, injector, envInjector, doc, registryService, overlayService, styleRegistry, interactionEngine, cdr, panelEventService) {
2683
2694
  this.vcr = vcr;
2684
2695
  this.injector = injector;
2696
+ this.envInjector = envInjector;
2697
+ this.doc = doc;
2685
2698
  this.registryService = registryService;
2686
2699
  this.overlayService = overlayService;
2687
2700
  this.styleRegistry = styleRegistry;
@@ -2694,6 +2707,26 @@ class RenderDirective {
2694
2707
  this.onMouseLeave = new EventEmitter();
2695
2708
  this.childSubs = [];
2696
2709
  }
2710
+ /**
2711
+ * Tag for a variable-tag directive-host (whose selector lists several tags, so
2712
+ * `vcr.createComponent` would always pick the first). Reads the value from the node's traits.
2713
+ * Returns null for fixed-tag hosts and non-directive-host components.
2714
+ */
2715
+ variableTag(node) {
2716
+ const traitVal = (name) => Object.values(node.traits || {}).find(t => t?.name === name)?.default;
2717
+ switch (node.type) {
2718
+ case 'Heading': {
2719
+ const l = traitVal('level');
2720
+ return ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(l) ? l : 'h2';
2721
+ }
2722
+ case 'Text':
2723
+ return traitVal('tag') === 'span' ? 'span' : 'p';
2724
+ case 'ButtonBlock':
2725
+ return traitVal('tag') === 'a' ? 'a' : 'button';
2726
+ default:
2727
+ return null;
2728
+ }
2729
+ }
2697
2730
  ngOnInit() {
2698
2731
  this.render(this.ioxRender);
2699
2732
  }
@@ -2735,7 +2768,23 @@ class RenderDirective {
2735
2768
  return;
2736
2769
  // vcr.createComponent inserts the new component's host element after the ng-container
2737
2770
  // comment anchor — directly inside the parent element. No wrapper div is created.
2738
- const componentRef = this.vcr.createComponent(componentClass, { injector: this.injector });
2771
+ // Variable-tag directive-hosts (Heading/Text/ButtonBlock) list every allowed tag in their
2772
+ // selector, so vcr.createComponent would always pick the FIRST — create them on an explicit
2773
+ // hostElement of the right tag and insert that view instead (mirrors the SSR engine).
2774
+ const tag = this.variableTag(node);
2775
+ let componentRef;
2776
+ if (tag) {
2777
+ const hostElement = this.doc.createElement(tag);
2778
+ componentRef = createComponent(componentClass, {
2779
+ environmentInjector: this.envInjector,
2780
+ elementInjector: this.injector,
2781
+ hostElement,
2782
+ });
2783
+ this.vcr.insert(componentRef.hostView);
2784
+ }
2785
+ else {
2786
+ componentRef = this.vcr.createComponent(componentClass, { injector: this.injector });
2787
+ }
2739
2788
  // Apply regular trait defaults (title, image, description, etc.)
2740
2789
  // Use setInput() (Angular 14+) — it marks the view dirty and
2741
2790
  // integrates with Angular's CD tracking, unlike direct assignment.
@@ -2806,9 +2855,11 @@ class RenderDirective {
2806
2855
  // For layout components the host element is <app-section>; for leaf components
2807
2856
  // it is e.g. <app-card>. Either way this is the correct inspectable element.
2808
2857
  const nativeEl = componentRef.location?.nativeElement ?? null;
2809
- // Custom element host defaults to display:inline. Set it to block so it
2810
- // participates properly in layout and CDK can capture its bounding rect.
2811
- if (nativeEl) {
2858
+ // Custom element host defaults to display:inline. Set it to block so it participates
2859
+ // properly in layout and CDK can capture its bounding rect. SKIP for directive-hosts: the
2860
+ // host is a real element with its own display, and an inline style here out-ranks both
2861
+ // `:host` and the styleProps `.iox-node` rule (it would e.g. force Link's <a> to block).
2862
+ if (nativeEl && !DIRECTIVE_HOST_TYPES.has(node.type)) {
2812
2863
  nativeEl.style.display = 'block';
2813
2864
  }
2814
2865
  // Preview clones (repeater/slider-generated rows) are display-only — only the
@@ -2875,7 +2926,7 @@ class RenderDirective {
2875
2926
  ref.instance[name] = value;
2876
2927
  }
2877
2928
  }
2878
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: RenderDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Injector }, { token: ComponentRegistryService }, { token: OverlayService }, { token: StyleRegistryService }, { token: InteractionEngineService }, { token: i0.ChangeDetectorRef }, { token: PanelEventService }], target: i0.ɵɵFactoryTarget.Directive }); }
2929
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: RenderDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Injector }, { token: i0.EnvironmentInjector }, { token: DOCUMENT }, { token: ComponentRegistryService }, { token: OverlayService }, { token: StyleRegistryService }, { token: InteractionEngineService }, { token: i0.ChangeDetectorRef }, { token: PanelEventService }], target: i0.ɵɵFactoryTarget.Directive }); }
2879
2930
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.11", type: RenderDirective, isStandalone: false, selector: "[ioxRender]", inputs: { ioxRender: "ioxRender" }, outputs: { onClick: "onClick", onMouseEnter: "onMouseEnter", onMouseLeave: "onMouseLeave" }, ngImport: i0 }); }
2880
2931
  }
2881
2932
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: RenderDirective, decorators: [{
@@ -2884,7 +2935,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
2884
2935
  selector: '[ioxRender]',
2885
2936
  standalone: false,
2886
2937
  }]
2887
- }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.Injector }, { type: ComponentRegistryService }, { type: OverlayService }, { type: StyleRegistryService }, { type: InteractionEngineService }, { type: i0.ChangeDetectorRef }, { type: PanelEventService }], propDecorators: { ioxRender: [{
2938
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.Injector }, { type: i0.EnvironmentInjector }, { type: Document, decorators: [{
2939
+ type: Inject,
2940
+ args: [DOCUMENT]
2941
+ }] }, { type: ComponentRegistryService }, { type: OverlayService }, { type: StyleRegistryService }, { type: InteractionEngineService }, { type: i0.ChangeDetectorRef }, { type: PanelEventService }], propDecorators: { ioxRender: [{
2888
2942
  type: Input
2889
2943
  }], onClick: [{
2890
2944
  type: Output