@vectoriox/iox-builder 1.2.6 → 1.2.8

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.
@@ -290,6 +290,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
290
290
  type: Injectable
291
291
  }] });
292
292
 
293
+ function deepCloneNode(node) {
294
+ const clone = JSON.parse(JSON.stringify(node));
295
+ regenerateIds(clone);
296
+ return clone;
297
+ }
298
+ function regenerateIds(node) {
299
+ node.id = Math.random().toString(36).substr(2, 9);
300
+ node.styleId = undefined;
301
+ (node.children || []).forEach(regenerateIds);
302
+ }
293
303
  class DragEngineService {
294
304
  constructor(registry) {
295
305
  this.registry = registry;
@@ -357,8 +367,15 @@ class DragEngineService {
357
367
  sourceData.splice(srcIdx, 1);
358
368
  this.getCdr(payload.sourceId)?.detectChanges();
359
369
  }
370
+ children.splice(insertIndex, 0, item);
371
+ }
372
+ else {
373
+ // Source not in the drop-zone registry → came from an external panel
374
+ // (e.g. the built-in blocks panel stores one pre-built node object and
375
+ // reuses it across drags). Deep-clone with fresh IDs so each drop
376
+ // produces a fully independent node, preventing shared CSS rules.
377
+ children.splice(insertIndex, 0, deepCloneNode(item));
360
378
  }
361
- children.splice(insertIndex, 0, item);
362
379
  cdr.detectChanges();
363
380
  afterDrop?.();
364
381
  return;
@@ -3384,7 +3401,7 @@ class BuilderRepeaterComponent {
3384
3401
  const changedNode = event.data?.node;
3385
3402
  if (!changedNode || !this.items.length)
3386
3403
  return;
3387
- if (this.children.some(c => c === changedNode || c.id === changedNode.id)) {
3404
+ if (this.isInTemplate(changedNode)) {
3388
3405
  this.refreshPreviews();
3389
3406
  }
3390
3407
  });
@@ -3419,6 +3436,11 @@ class BuilderRepeaterComponent {
3419
3436
  }
3420
3437
  });
3421
3438
  }
3439
+ isInTemplate(target) {
3440
+ const search = (nodes) => nodes.some(c => c === target || c.id === target.id ||
3441
+ (c.children?.length ? search(c.children) : false));
3442
+ return search(this.children);
3443
+ }
3422
3444
  refreshPreviews() {
3423
3445
  if (!this.items.length || !this.children.length) {
3424
3446
  this.previewRows = [];
@@ -3628,7 +3650,7 @@ class BuilderButtonBlockComponent {
3628
3650
  </ng-container>
3629
3651
  </div>
3630
3652
  </button>
3631
- `, isInline: true, styles: [".button-block-root{font:inherit;color:inherit;text-decoration:none;box-sizing:border-box}.button-block-placeholder{flex:1;display:flex;align-items:center;justify-content:center;color:#64748b66;font-size:12px;pointer-events:none;-webkit-user-select:none;user-select:none}.button-block-child{min-width:0}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: RenderDirective, selector: "[ioxRender]", inputs: ["ioxRender"], outputs: ["onClick", "onMouseEnter", "onMouseLeave"] }, { kind: "directive", type: IoxDraggableDirective, selector: "[ioxDraggable]", inputs: ["ioxDragData", "ioxDragSourceId"] }, { kind: "directive", type: IoxDropzoneDirective, selector: "[ioxDropzone]", inputs: ["ioxDropzoneId", "ioxDropzoneData", "ioxDropzonePostDrop"], outputs: ["ioxDrop"] }] }); }
3653
+ `, isInline: true, styles: [".button-block-root{width:100%;font:inherit;color:inherit;text-decoration:none;box-sizing:border-box}.button-block-placeholder{flex:1;display:flex;align-items:center;justify-content:center;color:#64748b66;font-size:12px;pointer-events:none;-webkit-user-select:none;user-select:none}.button-block-child{min-width:0}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: RenderDirective, selector: "[ioxRender]", inputs: ["ioxRender"], outputs: ["onClick", "onMouseEnter", "onMouseLeave"] }, { kind: "directive", type: IoxDraggableDirective, selector: "[ioxDraggable]", inputs: ["ioxDragData", "ioxDragSourceId"] }, { kind: "directive", type: IoxDropzoneDirective, selector: "[ioxDropzone]", inputs: ["ioxDropzoneId", "ioxDropzoneData", "ioxDropzonePostDrop"], outputs: ["ioxDrop"] }] }); }
3632
3654
  }
3633
3655
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BuilderButtonBlockComponent, decorators: [{
3634
3656
  type: Component,
@@ -3657,7 +3679,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImpo
3657
3679
  </ng-container>
3658
3680
  </div>
3659
3681
  </button>
3660
- `, standalone: false, styles: [".button-block-root{font:inherit;color:inherit;text-decoration:none;box-sizing:border-box}.button-block-placeholder{flex:1;display:flex;align-items:center;justify-content:center;color:#64748b66;font-size:12px;pointer-events:none;-webkit-user-select:none;user-select:none}.button-block-child{min-width:0}\n"] }]
3682
+ `, standalone: false, styles: [".button-block-root{width:100%;font:inherit;color:inherit;text-decoration:none;box-sizing:border-box}.button-block-placeholder{flex:1;display:flex;align-items:center;justify-content:center;color:#64748b66;font-size:12px;pointer-events:none;-webkit-user-select:none;user-select:none}.button-block-child{min-width:0}\n"] }]
3661
3683
  }], ctorParameters: () => [{ type: DragEngineService }, { type: i0.ChangeDetectorRef }], propDecorators: { children: [{
3662
3684
  type: Input
3663
3685
  }], style: [{