@porscheinformatik/clr-addons 12.5.0 → 12.5.1
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.
- package/dropdown/clr-dropdown-overflow.directive.d.ts +10 -5
- package/esm2020/dropdown/clr-dropdown-overflow.directive.mjs +40 -7
- package/fesm2015/clr-addons.mjs +38 -7
- package/fesm2015/clr-addons.mjs.map +1 -1
- package/fesm2020/clr-addons.mjs +37 -7
- package/fesm2020/clr-addons.mjs.map +1 -1
- package/package.json +1 -1
package/fesm2020/clr-addons.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, NgModule, Injectable, EventEmitter, Input, Output, Directive, ViewChild,
|
|
2
|
+
import { Component, NgModule, Injectable, EventEmitter, Input, Output, Directive, ViewChild, ContentChildren, TemplateRef, ViewChildren, HostBinding, ElementRef, Renderer2, forwardRef, ContentChild, HostListener, InjectionToken, Inject, Optional } from '@angular/core';
|
|
3
3
|
import * as i2 from '@angular/common';
|
|
4
4
|
import { CommonModule, DOCUMENT } from '@angular/common';
|
|
5
5
|
import * as i3$1 from '@angular/forms';
|
|
6
6
|
import { FormsModule, NG_VALIDATORS, NgControl, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
7
7
|
import * as i1 from '@clr/angular';
|
|
8
|
-
import { ClarityModule, ClrFormsModule, ClrForm, ClrAlert, ClrAxis, ClrSide, ClrAlignment, ClrPopoverToggleService, ClrPopoverEventsService, ClrPopoverPositionService, ClrIconModule, ClrDropdownModule } from '@clr/angular';
|
|
8
|
+
import { ClarityModule, ClrFormsModule, ClrDropdown, ClrForm, ClrAlert, ClrAxis, ClrSide, ClrAlignment, ClrPopoverToggleService, ClrPopoverEventsService, ClrPopoverPositionService, ClrIconModule, ClrDropdownModule } from '@clr/angular';
|
|
9
9
|
import { Subject, BehaviorSubject, timer, asyncScheduler, interval, of, ReplaySubject, takeUntil as takeUntil$1 } from 'rxjs';
|
|
10
10
|
import { takeUntil, observeOn, take } from 'rxjs/operators';
|
|
11
11
|
import * as i3 from '@angular/router';
|
|
@@ -645,22 +645,49 @@ class ClrDropdownOverflowDirective {
|
|
|
645
645
|
this.elRef = elRef;
|
|
646
646
|
this.defaultItemMinHeightRem = 1.5;
|
|
647
647
|
this.marginBottomRem = 0.1;
|
|
648
|
+
this.destroy$ = new Subject();
|
|
648
649
|
}
|
|
649
|
-
|
|
650
|
-
|
|
650
|
+
ngAfterContentInit() {
|
|
651
|
+
// first trigger manually because the subscription lower only triggers after first change
|
|
652
|
+
if (!this.nestedDropdownChildren?.length) {
|
|
653
|
+
this.applyDropdownOverflowStyles();
|
|
654
|
+
}
|
|
655
|
+
this.nestedDropdownChildren.changes.pipe(takeUntil(this.destroy$)).subscribe((children) => {
|
|
656
|
+
// if there are any nested dropdowns, our overflow fix prevents those from showing and needs to be removed
|
|
657
|
+
if (!children?.length) {
|
|
658
|
+
this.applyDropdownOverflowStyles();
|
|
659
|
+
}
|
|
660
|
+
else if (children?.length) {
|
|
661
|
+
this.removeDropdownOverflowStyles();
|
|
662
|
+
}
|
|
663
|
+
});
|
|
651
664
|
}
|
|
652
|
-
|
|
665
|
+
ngOnDestroy() {
|
|
666
|
+
this.destroy$.next();
|
|
667
|
+
this.destroy$.complete();
|
|
668
|
+
}
|
|
669
|
+
applyDropdownOverflowStyles() {
|
|
653
670
|
// the vertical position of our element in the current window
|
|
654
671
|
const y = this.elRef.nativeElement.getBoundingClientRect().y;
|
|
655
672
|
const itemMinHeightPx = this.getItemMinHeight(this.clrDropdownMenuItemMinHeight);
|
|
656
673
|
// see https://stackoverflow.com/questions/22754315/for-loop-for-htmlcollection-elements
|
|
657
|
-
for (const item of this.
|
|
674
|
+
for (const item of this.getAllChildDropdownMenuItems()) {
|
|
658
675
|
item.style.minHeight = itemMinHeightPx + 'px';
|
|
659
676
|
}
|
|
660
677
|
this.elRef.nativeElement.style.maxHeight =
|
|
661
678
|
this.getMenuMaxHeight(this.clrDropdownMenuMaxHeight, window.innerHeight - y - this.convertRemToPixels(this.marginBottomRem)) + 'px';
|
|
662
679
|
this.elRef.nativeElement.style.overflowY = 'auto';
|
|
663
680
|
}
|
|
681
|
+
removeDropdownOverflowStyles() {
|
|
682
|
+
for (const item of this.getAllChildDropdownMenuItems()) {
|
|
683
|
+
item.style.minHeight = null;
|
|
684
|
+
}
|
|
685
|
+
this.elRef.nativeElement.style.maxHeight = null;
|
|
686
|
+
this.elRef.nativeElement.style.overflowY = null;
|
|
687
|
+
}
|
|
688
|
+
getAllChildDropdownMenuItems() {
|
|
689
|
+
return this.elRef.nativeElement.getElementsByClassName('dropdown-item');
|
|
690
|
+
}
|
|
664
691
|
getMenuMaxHeight(menuMaxHeightProvided, menuMaxHeightPx) {
|
|
665
692
|
if (menuMaxHeightProvided) {
|
|
666
693
|
const maxHeightPx = this.convertToPixels(menuMaxHeightProvided);
|
|
@@ -698,7 +725,7 @@ class ClrDropdownOverflowDirective {
|
|
|
698
725
|
}
|
|
699
726
|
}
|
|
700
727
|
ClrDropdownOverflowDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ClrDropdownOverflowDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
701
|
-
ClrDropdownOverflowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: ClrDropdownOverflowDirective, selector: "clr-dropdown-menu", inputs: { clrDropdownMenuMaxHeight: "clrDropdownMenuMaxHeight", clrDropdownMenuItemMinHeight: "clrDropdownMenuItemMinHeight" }, ngImport: i0 });
|
|
728
|
+
ClrDropdownOverflowDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: ClrDropdownOverflowDirective, selector: "clr-dropdown-menu", inputs: { clrDropdownMenuMaxHeight: "clrDropdownMenuMaxHeight", clrDropdownMenuItemMinHeight: "clrDropdownMenuItemMinHeight" }, queries: [{ propertyName: "nestedDropdownChildren", predicate: ClrDropdown, descendants: true }], ngImport: i0 });
|
|
702
729
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ClrDropdownOverflowDirective, decorators: [{
|
|
703
730
|
type: Directive,
|
|
704
731
|
args: [{ selector: 'clr-dropdown-menu' }]
|
|
@@ -706,6 +733,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
706
733
|
type: Input
|
|
707
734
|
}], clrDropdownMenuItemMinHeight: [{
|
|
708
735
|
type: Input
|
|
736
|
+
}], nestedDropdownChildren: [{
|
|
737
|
+
type: ContentChildren,
|
|
738
|
+
args: [ClrDropdown, { descendants: true }]
|
|
709
739
|
}] } });
|
|
710
740
|
|
|
711
741
|
/*
|