@impartner/design-components 1.0.3 → 1.0.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.
@@ -3560,13 +3560,17 @@ class ModalComponent {
3560
3560
  * Event emitted when the Modal content is accepted.
3561
3561
  */
3562
3562
  this.accept = new EventEmitter();
3563
- this._interactableId = this._interactionService.add(this);
3564
3563
  }
3565
3564
  /**
3566
3565
  * Determines if the Modal should be shown immediately.
3567
3566
  */
3568
3567
  set show(show) {
3569
- this._show = show;
3568
+ if (show) {
3569
+ this.open();
3570
+ }
3571
+ else {
3572
+ this.close();
3573
+ }
3570
3574
  }
3571
3575
  get interactableId() {
3572
3576
  return this._interactableId;
@@ -3590,6 +3594,7 @@ class ModalComponent {
3590
3594
  return !this.titleText && !this.dismissable;
3591
3595
  }
3592
3596
  ngOnInit() {
3597
+ this._interactableId = this._interactionService.add(this);
3593
3598
  if (this.dismissable === undefined && this.theme === ModalTheme.Working) {
3594
3599
  this.dismissable = true;
3595
3600
  }
@@ -3606,35 +3611,38 @@ class ModalComponent {
3606
3611
  !!this.dismissEl?.nativeElement?.firstChild?.disabled) {
3607
3612
  return;
3608
3613
  }
3609
- this._show = false;
3614
+ this.close();
3610
3615
  this.dismiss.emit(event);
3611
3616
  }
3612
3617
  handleDeny(event) {
3613
3618
  if (!!this.denyEl?.nativeElement?.firstChild?.disabled) {
3614
3619
  return;
3615
3620
  }
3616
- this._show = false;
3621
+ this.close();
3617
3622
  this.deny.emit(event);
3618
3623
  }
3619
3624
  handleAccept(event) {
3620
- console.log('this.acceptEl', this.acceptEl);
3621
3625
  if (!!this.acceptEl?.nativeElement?.firstChild?.disabled) {
3622
3626
  return;
3623
3627
  }
3624
- this._show = false;
3628
+ this.close();
3625
3629
  this.accept.emit(event);
3626
3630
  }
3627
3631
  /**
3628
- * Opens/shows the modal programmatically.
3632
+ * Opens/shows the modal. Can be used programmatically.
3629
3633
  */
3630
3634
  open() {
3635
+ if (this.backdrop) {
3636
+ this._interactionService.queueBackdrop(this.interactableId);
3637
+ }
3631
3638
  this._show = true;
3632
3639
  }
3633
3640
  /**
3634
- * Closes/hides the modal programmatically.
3641
+ * Closes/hides the modal. Can be used programmatically.
3635
3642
  */
3636
3643
  close() {
3637
3644
  this._show = false;
3645
+ this._interactionService.dequeueBackdrop(this.interactableId);
3638
3646
  }
3639
3647
  }
3640
3648
  ModalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ModalComponent, deps: [{ token: InteractionService }], target: i0.ɵɵFactoryTarget.Component });
@@ -3868,7 +3876,6 @@ class DropdownComponent {
3868
3876
  */
3869
3877
  this.buttonClick = new EventEmitter();
3870
3878
  this.classBtnGroup = true;
3871
- this._interactableId = this._interactionService.add(this);
3872
3879
  }
3873
3880
  get classDropdown() {
3874
3881
  return this.position === 'down';
@@ -3899,6 +3906,9 @@ class DropdownComponent {
3899
3906
  get shown() {
3900
3907
  return this.valid && this.show;
3901
3908
  }
3909
+ ngOnInit() {
3910
+ this._interactableId = this._interactionService.add(this);
3911
+ }
3902
3912
  ngOnDestroy() {
3903
3913
  this._interactionService.remove(this.interactableId);
3904
3914
  this._interactableId = 0;
@@ -8390,9 +8400,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
8390
8400
  class InteractionService {
8391
8401
  constructor() {
8392
8402
  this._interactables = [];
8403
+ this._backdropQueue = [];
8393
8404
  }
8394
8405
  get showBackdrop() {
8395
- return this._interactables.some(i => i instanceof ModalComponent && i.shown && i.backdrop);
8406
+ return this._backdropQueue.length > 0;
8396
8407
  }
8397
8408
  registerBackdrop(modalBackdrop) {
8398
8409
  // WARNING: there should only be 1 backdrop component, preferably loaded in the body
@@ -8414,8 +8425,12 @@ class InteractionService {
8414
8425
  }
8415
8426
  }
8416
8427
  add(interactable) {
8417
- if (interactable.interactableId > 0) {
8418
- return interactable.interactableId;
8428
+ const interactableId = interactable.interactableId;
8429
+ if (interactableId > 0) {
8430
+ if (!this._interactables.some(i => i.interactableId === interactableId)) {
8431
+ this._interactables.push(interactable);
8432
+ }
8433
+ return interactableId;
8419
8434
  }
8420
8435
  this._interactables.push(interactable);
8421
8436
  return this._interactables.length;
@@ -8425,6 +8440,7 @@ class InteractionService {
8425
8440
  return;
8426
8441
  }
8427
8442
  this._interactables.splice(interactableId - 1, 1);
8443
+ this.dequeueBackdrop(interactableId);
8428
8444
  }
8429
8445
  toggle(interactable) {
8430
8446
  if (interactable.interactableId <= 0 || interactable.show) {
@@ -8438,6 +8454,17 @@ class InteractionService {
8438
8454
  }
8439
8455
  return true;
8440
8456
  }
8457
+ queueBackdrop(interactableId) {
8458
+ if (!this._backdropQueue.includes(interactableId)) {
8459
+ this._backdropQueue.push(interactableId);
8460
+ }
8461
+ }
8462
+ dequeueBackdrop(interactableId) {
8463
+ const interactableIdIndex = this._backdropQueue.indexOf(interactableId);
8464
+ if (interactableIdIndex !== -1) {
8465
+ this._backdropQueue.splice(interactableIdIndex, 1);
8466
+ }
8467
+ }
8441
8468
  }
8442
8469
  InteractionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InteractionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
8443
8470
  InteractionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: InteractionService, providedIn: 'root' });