@pumpkin-tech/pumpkin-tech-ng 0.2.62 → 0.2.63
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.
|
@@ -9610,15 +9610,57 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9610
9610
|
}] } });
|
|
9611
9611
|
|
|
9612
9612
|
class PtechPopoverComponent {
|
|
9613
|
+
host;
|
|
9614
|
+
cdr;
|
|
9613
9615
|
contentTemplate;
|
|
9616
|
+
panel;
|
|
9614
9617
|
position = 'auto';
|
|
9615
9618
|
trigger = 'click';
|
|
9616
9619
|
align = 'start';
|
|
9617
9620
|
dark = false;
|
|
9618
9621
|
opened = false;
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
+
closeOnScroll = true;
|
|
9623
|
+
closeOnResize = true;
|
|
9624
|
+
viewportSafe = true;
|
|
9625
|
+
viewportMargin = 12;
|
|
9626
|
+
openedChange = new EventEmitter();
|
|
9627
|
+
panelStyle = {};
|
|
9628
|
+
shouldUpdatePosition = false;
|
|
9629
|
+
constructor(host, cdr) {
|
|
9630
|
+
this.host = host;
|
|
9631
|
+
this.cdr = cdr;
|
|
9632
|
+
}
|
|
9633
|
+
ngOnChanges(changes) {
|
|
9634
|
+
if (changes['opened'] && this.opened) {
|
|
9635
|
+
this.markPositionForUpdate();
|
|
9636
|
+
}
|
|
9637
|
+
}
|
|
9638
|
+
ngAfterViewChecked() {
|
|
9639
|
+
if (!this.opened || !this.shouldUpdatePosition)
|
|
9640
|
+
return;
|
|
9641
|
+
this.shouldUpdatePosition = false;
|
|
9642
|
+
this.updatePanelPosition();
|
|
9643
|
+
}
|
|
9644
|
+
onWindowScroll() {
|
|
9645
|
+
if (this.closeOnScroll)
|
|
9646
|
+
this.close();
|
|
9647
|
+
}
|
|
9648
|
+
onWindowResize() {
|
|
9649
|
+
if (this.closeOnResize) {
|
|
9650
|
+
this.close();
|
|
9651
|
+
return;
|
|
9652
|
+
}
|
|
9653
|
+
this.markPositionForUpdate();
|
|
9654
|
+
}
|
|
9655
|
+
open() {
|
|
9656
|
+
this.setOpened(true);
|
|
9657
|
+
}
|
|
9658
|
+
close() {
|
|
9659
|
+
this.setOpened(false);
|
|
9660
|
+
}
|
|
9661
|
+
toggle() {
|
|
9662
|
+
this.setOpened(!this.opened);
|
|
9663
|
+
}
|
|
9622
9664
|
onClick() {
|
|
9623
9665
|
if (this.trigger === 'click')
|
|
9624
9666
|
this.toggle();
|
|
@@ -9631,15 +9673,95 @@ class PtechPopoverComponent {
|
|
|
9631
9673
|
if (this.trigger === 'hover')
|
|
9632
9674
|
this.close();
|
|
9633
9675
|
}
|
|
9634
|
-
|
|
9635
|
-
|
|
9676
|
+
setOpened(opened) {
|
|
9677
|
+
if (this.opened === opened)
|
|
9678
|
+
return;
|
|
9679
|
+
this.opened = opened;
|
|
9680
|
+
this.openedChange.emit(this.opened);
|
|
9681
|
+
if (opened) {
|
|
9682
|
+
this.markPositionForUpdate();
|
|
9683
|
+
}
|
|
9684
|
+
else {
|
|
9685
|
+
this.panelStyle = {};
|
|
9686
|
+
}
|
|
9687
|
+
this.cdr.markForCheck();
|
|
9688
|
+
}
|
|
9689
|
+
markPositionForUpdate() {
|
|
9690
|
+
this.shouldUpdatePosition = true;
|
|
9691
|
+
this.cdr.markForCheck();
|
|
9692
|
+
}
|
|
9693
|
+
updatePanelPosition() {
|
|
9694
|
+
if (!this.viewportSafe || !this.panel?.nativeElement)
|
|
9695
|
+
return;
|
|
9696
|
+
const panel = this.panel.nativeElement;
|
|
9697
|
+
const anchor = this.host.nativeElement.querySelector('.anchor');
|
|
9698
|
+
if (!anchor)
|
|
9699
|
+
return;
|
|
9700
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
9701
|
+
const panelRect = panel.getBoundingClientRect();
|
|
9702
|
+
const viewportWidth = window.innerWidth;
|
|
9703
|
+
const viewportHeight = window.innerHeight;
|
|
9704
|
+
const margin = Math.max(0, this.viewportMargin);
|
|
9705
|
+
const gap = 8;
|
|
9706
|
+
const width = Math.min(panelRect.width, viewportWidth - margin * 2);
|
|
9707
|
+
const height = Math.min(panelRect.height, viewportHeight - margin * 2);
|
|
9708
|
+
let top = this.resolveTop(anchorRect, height, viewportHeight, margin, gap);
|
|
9709
|
+
let left = this.resolveLeft(anchorRect, width, viewportWidth, margin);
|
|
9710
|
+
top = this.clamp(top, margin, viewportHeight - height - margin);
|
|
9711
|
+
left = this.clamp(left, margin, viewportWidth - width - margin);
|
|
9712
|
+
this.panelStyle = {
|
|
9713
|
+
position: 'fixed',
|
|
9714
|
+
top: `${top}px`,
|
|
9715
|
+
left: `${left}px`,
|
|
9716
|
+
right: 'auto',
|
|
9717
|
+
bottom: 'auto',
|
|
9718
|
+
width: `${width}px`,
|
|
9719
|
+
maxWidth: `calc(100vw - ${margin * 2}px)`,
|
|
9720
|
+
maxHeight: `calc(100vh - ${margin * 2}px)`,
|
|
9721
|
+
overflow: 'auto',
|
|
9722
|
+
transform: 'none',
|
|
9723
|
+
};
|
|
9724
|
+
this.cdr.markForCheck();
|
|
9725
|
+
}
|
|
9726
|
+
resolveTop(anchor, panelHeight, viewportHeight, margin, gap) {
|
|
9727
|
+
if (this.position === 'top')
|
|
9728
|
+
return anchor.top - panelHeight - gap;
|
|
9729
|
+
if (this.position === 'left' || this.position === 'right')
|
|
9730
|
+
return anchor.top;
|
|
9731
|
+
const bottomTop = anchor.bottom + gap;
|
|
9732
|
+
const topTop = anchor.top - panelHeight - gap;
|
|
9733
|
+
if (this.position === 'auto' && bottomTop + panelHeight > viewportHeight - margin && topTop >= margin) {
|
|
9734
|
+
return topTop;
|
|
9735
|
+
}
|
|
9736
|
+
return bottomTop;
|
|
9737
|
+
}
|
|
9738
|
+
resolveLeft(anchor, panelWidth, viewportWidth, margin) {
|
|
9739
|
+
if (this.position === 'left')
|
|
9740
|
+
return anchor.left - panelWidth - 8;
|
|
9741
|
+
if (this.position === 'right')
|
|
9742
|
+
return anchor.right + 8;
|
|
9743
|
+
if (this.align === 'end')
|
|
9744
|
+
return anchor.right - panelWidth;
|
|
9745
|
+
if (this.align === 'center')
|
|
9746
|
+
return anchor.left + (anchor.width - panelWidth) / 2;
|
|
9747
|
+
return anchor.left;
|
|
9748
|
+
}
|
|
9749
|
+
clamp(value, min, max) {
|
|
9750
|
+
if (max < min)
|
|
9751
|
+
return min;
|
|
9752
|
+
return Math.min(Math.max(value, min), max);
|
|
9753
|
+
}
|
|
9754
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechPopoverComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
9755
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: PtechPopoverComponent, isStandalone: true, selector: "ptech-popover", inputs: { position: "position", trigger: "trigger", align: "align", dark: "dark", opened: "opened", closeOnScroll: "closeOnScroll", closeOnResize: "closeOnResize", viewportSafe: "viewportSafe", viewportMargin: "viewportMargin" }, outputs: { openedChange: "openedChange" }, host: { listeners: { "window:scroll": "onWindowScroll()", "window:resize": "onWindowResize()" } }, queries: [{ propertyName: "contentTemplate", first: true, predicate: ["content"], descendants: true }], viewQueries: [{ propertyName: "panel", first: true, predicate: ["panel"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
9636
9756
|
<span class="anchor"
|
|
9637
9757
|
(click)="onClick()"
|
|
9638
9758
|
(mouseenter)="onMouseEnter()"
|
|
9639
9759
|
(mouseleave)="onMouseLeave()">
|
|
9640
9760
|
<ng-content select="[trigger]"></ng-content>
|
|
9641
9761
|
<span class="panel"
|
|
9762
|
+
#panel
|
|
9642
9763
|
*ngIf="opened"
|
|
9764
|
+
[ngStyle]="panelStyle"
|
|
9643
9765
|
[class.dark]="dark"
|
|
9644
9766
|
[class.top]="position === 'top'"
|
|
9645
9767
|
[class.bottom]="position === 'bottom' || position === 'auto'"
|
|
@@ -9653,7 +9775,7 @@ class PtechPopoverComponent {
|
|
|
9653
9775
|
<ng-template #projected><ng-content></ng-content></ng-template>
|
|
9654
9776
|
</span>
|
|
9655
9777
|
</span>
|
|
9656
|
-
`, isInline: true, styles: [":host{display:inline-block;position:relative}.anchor{position:relative;display:inline-flex}.panel{position:absolute;z-index:1000;min-width:180px;max-width:min(360px,calc(100vw - 24px));padding:10px 12px;border-radius:8px;background:var(--app-surface, #fff);color:var(--app-text, inherit);border:1px solid var(--app-border-color, rgba(0,0,0,.12));box-shadow:0 14px 36px #0000002e}.panel.dark{background:#1f2937;color:#fff;border-color:#ffffff1f}.bottom{top:calc(100% + 8px);left:0}.top{bottom:calc(100% + 8px);left:0}.left{right:calc(100% + 8px);top:0}.right{left:calc(100% + 8px);top:0}.bottom.align-end,.top.align-end{left:auto;right:0}.bottom.align-center,.top.align-center{left:50%;transform:translate(-50%)}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
9778
|
+
`, isInline: true, styles: [":host{display:inline-block;position:relative}.anchor{position:relative;display:inline-flex}.panel{position:absolute;z-index:1000;min-width:180px;max-width:min(360px,calc(100vw - 24px));padding:10px 12px;border-radius:8px;background:var(--app-surface, #fff);color:var(--app-text, inherit);border:1px solid var(--app-border-color, rgba(0,0,0,.12));box-shadow:0 14px 36px #0000002e}.panel.dark{background:#1f2937;color:#fff;border-color:#ffffff1f}.bottom{top:calc(100% + 8px);left:0}.top{bottom:calc(100% + 8px);left:0}.left{right:calc(100% + 8px);top:0}.right{left:calc(100% + 8px);top:0}.bottom.align-end,.top.align-end{left:auto;right:0}.bottom.align-center,.top.align-center{left:50%;transform:translate(-50%)}\n"], dependencies: [{ kind: "ngmodule", type: CoreMaterialModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
9657
9779
|
}
|
|
9658
9780
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechPopoverComponent, decorators: [{
|
|
9659
9781
|
type: Component,
|
|
@@ -9664,7 +9786,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9664
9786
|
(mouseleave)="onMouseLeave()">
|
|
9665
9787
|
<ng-content select="[trigger]"></ng-content>
|
|
9666
9788
|
<span class="panel"
|
|
9789
|
+
#panel
|
|
9667
9790
|
*ngIf="opened"
|
|
9791
|
+
[ngStyle]="panelStyle"
|
|
9668
9792
|
[class.dark]="dark"
|
|
9669
9793
|
[class.top]="position === 'top'"
|
|
9670
9794
|
[class.bottom]="position === 'bottom' || position === 'auto'"
|
|
@@ -9679,9 +9803,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9679
9803
|
</span>
|
|
9680
9804
|
</span>
|
|
9681
9805
|
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:inline-block;position:relative}.anchor{position:relative;display:inline-flex}.panel{position:absolute;z-index:1000;min-width:180px;max-width:min(360px,calc(100vw - 24px));padding:10px 12px;border-radius:8px;background:var(--app-surface, #fff);color:var(--app-text, inherit);border:1px solid var(--app-border-color, rgba(0,0,0,.12));box-shadow:0 14px 36px #0000002e}.panel.dark{background:#1f2937;color:#fff;border-color:#ffffff1f}.bottom{top:calc(100% + 8px);left:0}.top{bottom:calc(100% + 8px);left:0}.left{right:calc(100% + 8px);top:0}.right{left:calc(100% + 8px);top:0}.bottom.align-end,.top.align-end{left:auto;right:0}.bottom.align-center,.top.align-center{left:50%;transform:translate(-50%)}\n"] }]
|
|
9682
|
-
}], propDecorators: { contentTemplate: [{
|
|
9806
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { contentTemplate: [{
|
|
9683
9807
|
type: ContentChild,
|
|
9684
9808
|
args: ['content', { static: false }]
|
|
9809
|
+
}], panel: [{
|
|
9810
|
+
type: ViewChild,
|
|
9811
|
+
args: ['panel']
|
|
9685
9812
|
}], position: [{
|
|
9686
9813
|
type: Input
|
|
9687
9814
|
}], trigger: [{
|
|
@@ -9692,6 +9819,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9692
9819
|
type: Input
|
|
9693
9820
|
}], opened: [{
|
|
9694
9821
|
type: Input
|
|
9822
|
+
}], closeOnScroll: [{
|
|
9823
|
+
type: Input
|
|
9824
|
+
}], closeOnResize: [{
|
|
9825
|
+
type: Input
|
|
9826
|
+
}], viewportSafe: [{
|
|
9827
|
+
type: Input
|
|
9828
|
+
}], viewportMargin: [{
|
|
9829
|
+
type: Input
|
|
9830
|
+
}], openedChange: [{
|
|
9831
|
+
type: Output
|
|
9832
|
+
}], onWindowScroll: [{
|
|
9833
|
+
type: HostListener,
|
|
9834
|
+
args: ['window:scroll']
|
|
9835
|
+
}], onWindowResize: [{
|
|
9836
|
+
type: HostListener,
|
|
9837
|
+
args: ['window:resize']
|
|
9695
9838
|
}] } });
|
|
9696
9839
|
|
|
9697
9840
|
class PtechWidgetMenuComponent {
|