@pumpkin-tech/pumpkin-tech-ng 0.2.67 → 0.2.69
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.
|
@@ -9608,6 +9608,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9608
9608
|
}] } });
|
|
9609
9609
|
|
|
9610
9610
|
class PtechTabsComponent {
|
|
9611
|
+
ngZone;
|
|
9611
9612
|
tabs;
|
|
9612
9613
|
tabsNav;
|
|
9613
9614
|
tabsNavComponent;
|
|
@@ -9621,6 +9622,18 @@ class PtechTabsComponent {
|
|
|
9621
9622
|
dragging = false;
|
|
9622
9623
|
suppressClick = false;
|
|
9623
9624
|
dragThreshold = 8;
|
|
9625
|
+
// Batches the drag's DOM writes to one per animation frame. Material's `scrollDistance`
|
|
9626
|
+
// setter forces two synchronous layout reflows per call (`_getMaxScrollDistance()` reads
|
|
9627
|
+
// scrollWidth/offsetWidth twice), so calling it once per raw pointermove - which can fire far
|
|
9628
|
+
// more often than the display refresh rate - saturates the main thread and makes the strip
|
|
9629
|
+
// visibly lag behind the pointer. Coalescing to rAF keeps at most 60-120 writes/sec regardless
|
|
9630
|
+
// of event rate, which is what actually restores 1:1 tracking.
|
|
9631
|
+
pendingScrollDistance = null;
|
|
9632
|
+
rafHandle = null;
|
|
9633
|
+
removeListeners = [];
|
|
9634
|
+
constructor(ngZone) {
|
|
9635
|
+
this.ngZone = ngZone;
|
|
9636
|
+
}
|
|
9624
9637
|
get projectedTabs() {
|
|
9625
9638
|
return this.tabs?.toArray() || [];
|
|
9626
9639
|
}
|
|
@@ -9629,6 +9642,42 @@ class PtechTabsComponent {
|
|
|
9629
9642
|
this.selectTab(this.allTabs[0]);
|
|
9630
9643
|
}
|
|
9631
9644
|
}
|
|
9645
|
+
ngAfterViewInit() {
|
|
9646
|
+
const nav = this.tabsNav?.nativeElement;
|
|
9647
|
+
if (!nav)
|
|
9648
|
+
return;
|
|
9649
|
+
// Attaching outside Angular's zone stops every pointermove from triggering a full
|
|
9650
|
+
// application change-detection tick (zone.js patches addEventListener, so a template
|
|
9651
|
+
// `(pointermove)` binding would otherwise schedule an `ApplicationRef.tick()` after each
|
|
9652
|
+
// event). The rAF callback scheduled from inside this same `runOutsideAngular` block also
|
|
9653
|
+
// stays outside the zone, so the whole drag gesture runs without touching Angular's CD at
|
|
9654
|
+
// all; we deliberately re-enter the zone once at the end (see `onPointerEnd`) to let
|
|
9655
|
+
// Material's paginator state (arrows, disabled bounds) resync normally.
|
|
9656
|
+
//
|
|
9657
|
+
// Native addEventListener (not Renderer2.listen, which has no options parameter) so we can
|
|
9658
|
+
// force `passive: false` on pointerdown/pointermove. Without that, a touch-sourced pointer
|
|
9659
|
+
// stream is fair game for the platform to mark passive by default depending on the host
|
|
9660
|
+
// app's own zone.js/event config - and a passive listener's `preventDefault()` is silently
|
|
9661
|
+
// dropped, letting the browser's own touch-gesture recognizer keep contesting the same
|
|
9662
|
+
// gesture our JS is already driving. Being explicit here removes that as a variable
|
|
9663
|
+
// regardless of what any consuming app configures elsewhere.
|
|
9664
|
+
this.ngZone.runOutsideAngular(() => {
|
|
9665
|
+
const addListener = (type, handler, passive) => {
|
|
9666
|
+
nav.addEventListener(type, handler, { passive });
|
|
9667
|
+
this.removeListeners.push(() => nav.removeEventListener(type, handler));
|
|
9668
|
+
};
|
|
9669
|
+
addListener('pointerdown', event => this.onPointerDown(event), false);
|
|
9670
|
+
addListener('pointermove', event => this.onPointerMove(event), false);
|
|
9671
|
+
addListener('pointerup', event => this.onPointerEnd(event), true);
|
|
9672
|
+
addListener('pointercancel', event => this.onPointerEnd(event), true);
|
|
9673
|
+
addListener('lostpointercapture', event => this.onPointerEnd(event), true);
|
|
9674
|
+
});
|
|
9675
|
+
}
|
|
9676
|
+
ngOnDestroy() {
|
|
9677
|
+
this.removeListeners.forEach(remove => remove());
|
|
9678
|
+
if (this.rafHandle !== null)
|
|
9679
|
+
cancelAnimationFrame(this.rafHandle);
|
|
9680
|
+
}
|
|
9632
9681
|
openTab(label, template, data, closeable = false, disabled = false, action) {
|
|
9633
9682
|
this.openTabs([{ label, template, data, closeable, disabled, action }]);
|
|
9634
9683
|
}
|
|
@@ -9691,13 +9740,14 @@ class PtechTabsComponent {
|
|
|
9691
9740
|
catch { /* synthetic/test pointer */ }
|
|
9692
9741
|
}
|
|
9693
9742
|
event.preventDefault();
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9743
|
+
// MatTabNav paginates by translating its internal tab list. The host nav itself has no
|
|
9744
|
+
// native scroll range, so changing nav.scrollLeft is a no-op in a real consumer. Using the
|
|
9745
|
+
// public scrollDistance API drives the same bounded position and arrow state as Material's
|
|
9746
|
+
// paginator while preserving click, focus and keyboard behavior. The actual write is
|
|
9747
|
+
// deferred to the next animation frame (see scheduleScrollFlush) so a burst of pointermove
|
|
9748
|
+
// events collapses into a single reflow-triggering call instead of one per event.
|
|
9749
|
+
this.pendingScrollDistance = this.pointerStartScrollDistance - deltaX;
|
|
9750
|
+
this.scheduleScrollFlush();
|
|
9701
9751
|
}
|
|
9702
9752
|
onPointerEnd(event) {
|
|
9703
9753
|
if (this.pointerId !== event.pointerId)
|
|
@@ -9713,6 +9763,31 @@ class PtechTabsComponent {
|
|
|
9713
9763
|
catch { /* pointer already released by the browser */ }
|
|
9714
9764
|
this.pointerId = null;
|
|
9715
9765
|
this.dragging = false;
|
|
9766
|
+
if (this.rafHandle !== null) {
|
|
9767
|
+
cancelAnimationFrame(this.rafHandle);
|
|
9768
|
+
this.rafHandle = null;
|
|
9769
|
+
}
|
|
9770
|
+
// Apply the final position immediately (don't wait another frame for the last pixel) and
|
|
9771
|
+
// hand control back to Angular's zone once so Material's deferred pagination bookkeeping
|
|
9772
|
+
// (arrow enabled/disabled, `ngAfterContentChecked`'s transform write) gets a real CD tick.
|
|
9773
|
+
this.flushScrollDistance();
|
|
9774
|
+
this.ngZone.run(() => { });
|
|
9775
|
+
}
|
|
9776
|
+
scheduleScrollFlush() {
|
|
9777
|
+
if (this.rafHandle !== null)
|
|
9778
|
+
return;
|
|
9779
|
+
this.rafHandle = requestAnimationFrame(() => {
|
|
9780
|
+
this.rafHandle = null;
|
|
9781
|
+
this.flushScrollDistance();
|
|
9782
|
+
});
|
|
9783
|
+
}
|
|
9784
|
+
flushScrollDistance() {
|
|
9785
|
+
if (this.pendingScrollDistance === null)
|
|
9786
|
+
return;
|
|
9787
|
+
if (this.tabsNavComponent) {
|
|
9788
|
+
this.tabsNavComponent.scrollDistance = this.pendingScrollDistance;
|
|
9789
|
+
}
|
|
9790
|
+
this.pendingScrollDistance = null;
|
|
9716
9791
|
}
|
|
9717
9792
|
closeTab(tab) {
|
|
9718
9793
|
const index = this.dynamicTabs.indexOf(tab);
|
|
@@ -9760,12 +9835,9 @@ class PtechTabsComponent {
|
|
|
9760
9835
|
tab.action = config.action;
|
|
9761
9836
|
return tab;
|
|
9762
9837
|
}
|
|
9763
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechTabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
9838
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechTabsComponent, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
9764
9839
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: PtechTabsComponent, isStandalone: true, selector: "ptech-tabs", inputs: { scrollable: "scrollable" }, outputs: { selectedTabChange: "selectedTabChange" }, queries: [{ propertyName: "tabs", predicate: PtechTabComponent }], viewQueries: [{ propertyName: "tabsNav", first: true, predicate: ["tabsNav"], descendants: true, read: ElementRef }, { propertyName: "tabsNavComponent", first: true, predicate: ["tabsNav"], descendants: true }], ngImport: i0, template: `
|
|
9765
|
-
<nav #tabsNav mat-tab-nav-bar [tabPanel]="tabPanel" class="ptech-tabs-nav" [class.scrollable]="scrollable"
|
|
9766
|
-
(pointerdown)="onPointerDown($event)" (pointermove)="onPointerMove($event)"
|
|
9767
|
-
(pointerup)="onPointerEnd($event)" (pointercancel)="onPointerEnd($event)"
|
|
9768
|
-
(lostpointercapture)="onPointerEnd($event)">
|
|
9840
|
+
<nav #tabsNav mat-tab-nav-bar [tabPanel]="tabPanel" class="ptech-tabs-nav" [class.scrollable]="scrollable">
|
|
9769
9841
|
<a mat-tab-link
|
|
9770
9842
|
*ngFor="let tab of projectedTabs; trackBy: trackByTab"
|
|
9771
9843
|
[active]="tab.active"
|
|
@@ -9802,10 +9874,7 @@ class PtechTabsComponent {
|
|
|
9802
9874
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechTabsComponent, decorators: [{
|
|
9803
9875
|
type: Component,
|
|
9804
9876
|
args: [{ selector: 'ptech-tabs', imports: [CoreMaterialModule, RouterModule, PtechTabComponent], template: `
|
|
9805
|
-
<nav #tabsNav mat-tab-nav-bar [tabPanel]="tabPanel" class="ptech-tabs-nav" [class.scrollable]="scrollable"
|
|
9806
|
-
(pointerdown)="onPointerDown($event)" (pointermove)="onPointerMove($event)"
|
|
9807
|
-
(pointerup)="onPointerEnd($event)" (pointercancel)="onPointerEnd($event)"
|
|
9808
|
-
(lostpointercapture)="onPointerEnd($event)">
|
|
9877
|
+
<nav #tabsNav mat-tab-nav-bar [tabPanel]="tabPanel" class="ptech-tabs-nav" [class.scrollable]="scrollable">
|
|
9809
9878
|
<a mat-tab-link
|
|
9810
9879
|
*ngFor="let tab of projectedTabs; trackBy: trackByTab"
|
|
9811
9880
|
[active]="tab.active"
|
|
@@ -9838,7 +9907,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9838
9907
|
</ng-container>
|
|
9839
9908
|
</mat-tab-nav-panel>
|
|
9840
9909
|
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:block}.ptech-tabs-nav{background:var(--ptech-tabs-background, transparent);border-bottom:1px solid var(--ptech-tab-border-color, var(--app-border-color, rgba(0,0,0,.12)));--mat-tab-background-color: var(--ptech-tabs-background, transparent);--mat-tab-foreground-color: var(--ptech-tab-color, var(--app-text-muted, rgba(0,0,0,.6)));--mat-tab-divider-color: var(--ptech-tab-border-color, transparent);--mat-tab-inactive-label-text-color: var(--ptech-tab-color, var(--app-text-muted, rgba(0,0,0,.6)));--mat-tab-inactive-focus-label-text-color: var(--ptech-tab-hover-color, var(--ptech-tab-active-color, var(--app-primary, #3f51b5)));--mat-tab-inactive-hover-label-text-color: var(--ptech-tab-hover-color, var(--ptech-tab-active-color, var(--app-primary, #3f51b5)));--mat-tab-inactive-ripple-color: var(--ptech-tab-color, var(--app-text-muted, rgba(0,0,0,.6)));--mat-tab-active-label-text-color: var(--ptech-tab-active-color, var(--app-primary, #3f51b5));--mat-tab-active-focus-label-text-color: var(--ptech-tab-active-color, var(--app-primary, #3f51b5));--mat-tab-active-hover-label-text-color: var(--ptech-tab-active-color, var(--app-primary, #3f51b5));--mat-tab-active-ripple-color: var(--ptech-tab-active-color, var(--app-primary, #3f51b5));--mat-tab-active-indicator-color: var(--ptech-tab-indicator-color, var(--ptech-tab-active-color, var(--app-primary, #3f51b5)));--mat-tab-active-focus-indicator-color: var(--ptech-tab-indicator-color, var(--ptech-tab-active-color, var(--app-primary, #3f51b5)));--mat-tab-active-hover-indicator-color: var(--ptech-tab-indicator-color, var(--ptech-tab-active-color, var(--app-primary, #3f51b5)));--mat-tab-disabled-ripple-color: var(--ptech-tab-disabled-color, var(--app-text-muted, rgba(0,0,0,.38)));--mat-tab-pagination-icon-color: var(--ptech-tab-icon-color, var(--ptech-tab-color, var(--app-text-muted, rgba(0,0,0,.6))))}.ptech-tabs-nav.scrollable{overflow-x:auto;overflow-y:hidden;overscroll-behavior-inline:contain;touch-action:pan-y;cursor:grab;scrollbar-width:thin}.ptech-tabs-nav.scrollable.dragging{cursor:grabbing;-webkit-user-select:none;user-select:none}.ptech-tabs-nav.scrollable.dragging ::ng-deep .mat-mdc-tab-list{transition:none!important}.ptech-tabs-panel{display:block;padding-top:var(--ptech-tabs-content-gap, 24px)}a[mat-tab-link]{display:inline-flex;align-items:center;gap:6px;min-width:max-content;color:var(--ptech-tab-color, var(--app-text-muted, rgba(0,0,0,.6)))}a[mat-tab-link] mat-icon{color:var(--ptech-tab-icon-color, var(--ptech-tab-color, var(--app-text-muted, rgba(0,0,0,.6))))}a[mat-tab-link].mdc-tab--active{color:var(--ptech-tab-active-color, var(--app-primary, #3f51b5))}a[mat-tab-link].mdc-tab--active mat-icon{color:var(--ptech-tab-active-color, var(--app-primary, #3f51b5))}a[mat-tab-link]:hover:not(.mat-mdc-tab-disabled):not(.mdc-tab--active){color:var(--ptech-tab-hover-color, var(--ptech-tab-active-color, var(--app-primary, #3f51b5)))}a[mat-tab-link]:focus-visible{outline:2px solid var(--ptech-tab-active-color, var(--app-primary, #3f51b5));outline-offset:-2px;border-radius:4px}a[mat-tab-link].mat-mdc-tab-disabled{color:var(--ptech-tab-disabled-color, var(--app-text-muted, rgba(0,0,0,.38)))!important;pointer-events:none}a[mat-tab-link].mat-mdc-tab-disabled mat-icon{color:var(--ptech-tab-disabled-color, var(--app-text-muted, rgba(0,0,0,.38)))!important}.badge{min-width:20px;height:20px;padding:0 6px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:var(--app-chip-bg, rgba(0,0,0,.08));font-size:12px}\n"] }]
|
|
9841
|
-
}], propDecorators: { tabs: [{
|
|
9910
|
+
}], ctorParameters: () => [{ type: i0.NgZone }], propDecorators: { tabs: [{
|
|
9842
9911
|
type: ContentChildren,
|
|
9843
9912
|
args: [PtechTabComponent]
|
|
9844
9913
|
}], tabsNav: [{
|