adb-shared 7.0.4 → 7.0.5

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.
@@ -515,19 +515,20 @@ class AdbDropdownDirective {
515
515
  setMenuPosition(toggleButton, menu) {
516
516
  const buttonRect = toggleButton.getBoundingClientRect();
517
517
  const menuRect = menu.getBoundingClientRect();
518
+ const dropdownRect = toggleButton.parentElement.getBoundingClientRect();
518
519
  const spaceAbove = buttonRect.top;
519
520
  const spaceBelow = window.innerHeight - buttonRect.bottom;
520
- const spaceRight = window.innerWidth - buttonRect.left;
521
- const spaceLeft = buttonRect.right;
522
- let x = 0;
521
+ const spaceRight = window.innerWidth - buttonRect.right;
522
+ const spaceLeft = buttonRect.left;
523
+ let x = buttonRect.left - dropdownRect.left;
523
524
  let y = 0;
524
525
  // Open upwards if there isn't enough room below
525
526
  if (menuRect.height > spaceBelow && spaceAbove > spaceBelow) {
526
- y = -buttonRect.height - menuRect.height - 1;
527
+ y = -menuRect.height;
527
528
  }
528
529
  // Open towards the left if there isn't enough room to the right
529
530
  if (menuRect.width > spaceRight && spaceLeft > spaceRight) {
530
- x = buttonRect.width - menuRect.width;
531
+ x = buttonRect.right - dropdownRect.left - menuRect.width;
531
532
  }
532
533
  menu.style.transform = `translate3d(${x}px, ${y}px, 0px)`;
533
534
  }
@@ -547,6 +548,17 @@ class AdbDropdownDirective {
547
548
  this.expanded = false;
548
549
  }
549
550
  }
551
+ onResize() {
552
+ if (!this.expanded) {
553
+ return;
554
+ }
555
+ const node = this.elementRef.nativeElement.parentNode;
556
+ const toggleButton = node.querySelector('.dropdown-toggle');
557
+ const menu = node.querySelector('.dropdown-menu');
558
+ if (toggleButton && menu?.classList.contains('show')) {
559
+ this.setMenuPosition(toggleButton, menu);
560
+ }
561
+ }
550
562
  close() {
551
563
  const node = this.elementRef.nativeElement.parentNode;
552
564
  const menu = node.querySelector('.dropdown-menu');
@@ -557,7 +569,7 @@ class AdbDropdownDirective {
557
569
  return '' + Math.floor(Math.random() * Date.now());
558
570
  }
559
571
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: AdbDropdownDirective, deps: [{ token: i0.ElementRef }, { token: AdbDropdownService }], target: i0.ɵɵFactoryTarget.Directive });
560
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.21", type: AdbDropdownDirective, isStandalone: false, selector: "[adbDropdown]", inputs: { insideClickSignal: { classPropertyName: "insideClickSignal", publicName: "insideClick", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { adbDropdownSignal: "adbDropdown" }, host: { listeners: { "click": "onClick()", "document:click": "onCheckOutSideClick($event.target)" }, properties: { "id": "this.id", "attr.data-toggle": "this.dataToggle", "attr.aria-haspopup": "this.haspPopup", "attr.aria-expanded": "this.expanded", "attr.aria-controls": "this.dropId" } }, exportAs: ["adbDropdown"], ngImport: i0 });
572
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.21", type: AdbDropdownDirective, isStandalone: false, selector: "[adbDropdown]", inputs: { insideClickSignal: { classPropertyName: "insideClickSignal", publicName: "insideClick", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { adbDropdownSignal: "adbDropdown" }, host: { listeners: { "click": "onClick()", "document:click": "onCheckOutSideClick($event.target)", "window:resize": "onResize()" }, properties: { "id": "this.id", "attr.data-toggle": "this.dataToggle", "attr.aria-haspopup": "this.haspPopup", "attr.aria-expanded": "this.expanded", "attr.aria-controls": "this.dropId" } }, exportAs: ["adbDropdown"], ngImport: i0 });
561
573
  }
562
574
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: AdbDropdownDirective, decorators: [{
563
575
  type: Directive,
@@ -587,6 +599,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.21", ngImpo
587
599
  }], onCheckOutSideClick: [{
588
600
  type: HostListener,
589
601
  args: ['document:click', ['$event.target']]
602
+ }], onResize: [{
603
+ type: HostListener,
604
+ args: ['window:resize']
590
605
  }] } });
591
606
 
592
607
  class AdbDropdownModule {