@pumpkin-tech/pumpkin-tech-ng 0.2.67 → 0.2.68
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,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9608
9608
|
}] } });
|
|
9609
9609
|
|
|
9610
9610
|
class PtechTabsComponent {
|
|
9611
|
+
ngZone;
|
|
9612
|
+
renderer;
|
|
9611
9613
|
tabs;
|
|
9612
9614
|
tabsNav;
|
|
9613
9615
|
tabsNavComponent;
|
|
@@ -9621,6 +9623,19 @@ class PtechTabsComponent {
|
|
|
9621
9623
|
dragging = false;
|
|
9622
9624
|
suppressClick = false;
|
|
9623
9625
|
dragThreshold = 8;
|
|
9626
|
+
// Batches the drag's DOM writes to one per animation frame. Material's `scrollDistance`
|
|
9627
|
+
// setter forces two synchronous layout reflows per call (`_getMaxScrollDistance()` reads
|
|
9628
|
+
// scrollWidth/offsetWidth twice), so calling it once per raw pointermove - which can fire far
|
|
9629
|
+
// more often than the display refresh rate - saturates the main thread and makes the strip
|
|
9630
|
+
// visibly lag behind the pointer. Coalescing to rAF keeps at most 60-120 writes/sec regardless
|
|
9631
|
+
// of event rate, which is what actually restores 1:1 tracking.
|
|
9632
|
+
pendingScrollDistance = null;
|
|
9633
|
+
rafHandle = null;
|
|
9634
|
+
removeListeners = [];
|
|
9635
|
+
constructor(ngZone, renderer) {
|
|
9636
|
+
this.ngZone = ngZone;
|
|
9637
|
+
this.renderer = renderer;
|
|
9638
|
+
}
|
|
9624
9639
|
get projectedTabs() {
|
|
9625
9640
|
return this.tabs?.toArray() || [];
|
|
9626
9641
|
}
|
|
@@ -9629,6 +9644,26 @@ class PtechTabsComponent {
|
|
|
9629
9644
|
this.selectTab(this.allTabs[0]);
|
|
9630
9645
|
}
|
|
9631
9646
|
}
|
|
9647
|
+
ngAfterViewInit() {
|
|
9648
|
+
const nav = this.tabsNav?.nativeElement;
|
|
9649
|
+
if (!nav)
|
|
9650
|
+
return;
|
|
9651
|
+
// Attaching outside Angular's zone stops every pointermove from triggering a full
|
|
9652
|
+
// application change-detection tick (zone.js patches addEventListener, so a template
|
|
9653
|
+
// `(pointermove)` binding would otherwise schedule an `ApplicationRef.tick()` after each
|
|
9654
|
+
// event). The rAF callback scheduled from inside this same `runOutsideAngular` block also
|
|
9655
|
+
// stays outside the zone, so the whole drag gesture runs without touching Angular's CD at
|
|
9656
|
+
// all; we deliberately re-enter the zone once at the end (see `onPointerEnd`) to let
|
|
9657
|
+
// Material's paginator state (arrows, disabled bounds) resync normally.
|
|
9658
|
+
this.ngZone.runOutsideAngular(() => {
|
|
9659
|
+
this.removeListeners.push(this.renderer.listen(nav, 'pointerdown', (event) => this.onPointerDown(event)), this.renderer.listen(nav, 'pointermove', (event) => this.onPointerMove(event)), this.renderer.listen(nav, 'pointerup', (event) => this.onPointerEnd(event)), this.renderer.listen(nav, 'pointercancel', (event) => this.onPointerEnd(event)), this.renderer.listen(nav, 'lostpointercapture', (event) => this.onPointerEnd(event)));
|
|
9660
|
+
});
|
|
9661
|
+
}
|
|
9662
|
+
ngOnDestroy() {
|
|
9663
|
+
this.removeListeners.forEach(remove => remove());
|
|
9664
|
+
if (this.rafHandle !== null)
|
|
9665
|
+
cancelAnimationFrame(this.rafHandle);
|
|
9666
|
+
}
|
|
9632
9667
|
openTab(label, template, data, closeable = false, disabled = false, action) {
|
|
9633
9668
|
this.openTabs([{ label, template, data, closeable, disabled, action }]);
|
|
9634
9669
|
}
|
|
@@ -9691,13 +9726,14 @@ class PtechTabsComponent {
|
|
|
9691
9726
|
catch { /* synthetic/test pointer */ }
|
|
9692
9727
|
}
|
|
9693
9728
|
event.preventDefault();
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9729
|
+
// MatTabNav paginates by translating its internal tab list. The host nav itself has no
|
|
9730
|
+
// native scroll range, so changing nav.scrollLeft is a no-op in a real consumer. Using the
|
|
9731
|
+
// public scrollDistance API drives the same bounded position and arrow state as Material's
|
|
9732
|
+
// paginator while preserving click, focus and keyboard behavior. The actual write is
|
|
9733
|
+
// deferred to the next animation frame (see scheduleScrollFlush) so a burst of pointermove
|
|
9734
|
+
// events collapses into a single reflow-triggering call instead of one per event.
|
|
9735
|
+
this.pendingScrollDistance = this.pointerStartScrollDistance - deltaX;
|
|
9736
|
+
this.scheduleScrollFlush();
|
|
9701
9737
|
}
|
|
9702
9738
|
onPointerEnd(event) {
|
|
9703
9739
|
if (this.pointerId !== event.pointerId)
|
|
@@ -9713,6 +9749,31 @@ class PtechTabsComponent {
|
|
|
9713
9749
|
catch { /* pointer already released by the browser */ }
|
|
9714
9750
|
this.pointerId = null;
|
|
9715
9751
|
this.dragging = false;
|
|
9752
|
+
if (this.rafHandle !== null) {
|
|
9753
|
+
cancelAnimationFrame(this.rafHandle);
|
|
9754
|
+
this.rafHandle = null;
|
|
9755
|
+
}
|
|
9756
|
+
// Apply the final position immediately (don't wait another frame for the last pixel) and
|
|
9757
|
+
// hand control back to Angular's zone once so Material's deferred pagination bookkeeping
|
|
9758
|
+
// (arrow enabled/disabled, `ngAfterContentChecked`'s transform write) gets a real CD tick.
|
|
9759
|
+
this.flushScrollDistance();
|
|
9760
|
+
this.ngZone.run(() => { });
|
|
9761
|
+
}
|
|
9762
|
+
scheduleScrollFlush() {
|
|
9763
|
+
if (this.rafHandle !== null)
|
|
9764
|
+
return;
|
|
9765
|
+
this.rafHandle = requestAnimationFrame(() => {
|
|
9766
|
+
this.rafHandle = null;
|
|
9767
|
+
this.flushScrollDistance();
|
|
9768
|
+
});
|
|
9769
|
+
}
|
|
9770
|
+
flushScrollDistance() {
|
|
9771
|
+
if (this.pendingScrollDistance === null)
|
|
9772
|
+
return;
|
|
9773
|
+
if (this.tabsNavComponent) {
|
|
9774
|
+
this.tabsNavComponent.scrollDistance = this.pendingScrollDistance;
|
|
9775
|
+
}
|
|
9776
|
+
this.pendingScrollDistance = null;
|
|
9716
9777
|
}
|
|
9717
9778
|
closeTab(tab) {
|
|
9718
9779
|
const index = this.dynamicTabs.indexOf(tab);
|
|
@@ -9760,12 +9821,9 @@ class PtechTabsComponent {
|
|
|
9760
9821
|
tab.action = config.action;
|
|
9761
9822
|
return tab;
|
|
9762
9823
|
}
|
|
9763
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechTabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
9824
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechTabsComponent, deps: [{ token: i0.NgZone }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
|
|
9764
9825
|
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)">
|
|
9826
|
+
<nav #tabsNav mat-tab-nav-bar [tabPanel]="tabPanel" class="ptech-tabs-nav" [class.scrollable]="scrollable">
|
|
9769
9827
|
<a mat-tab-link
|
|
9770
9828
|
*ngFor="let tab of projectedTabs; trackBy: trackByTab"
|
|
9771
9829
|
[active]="tab.active"
|
|
@@ -9802,10 +9860,7 @@ class PtechTabsComponent {
|
|
|
9802
9860
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechTabsComponent, decorators: [{
|
|
9803
9861
|
type: Component,
|
|
9804
9862
|
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)">
|
|
9863
|
+
<nav #tabsNav mat-tab-nav-bar [tabPanel]="tabPanel" class="ptech-tabs-nav" [class.scrollable]="scrollable">
|
|
9809
9864
|
<a mat-tab-link
|
|
9810
9865
|
*ngFor="let tab of projectedTabs; trackBy: trackByTab"
|
|
9811
9866
|
[active]="tab.active"
|
|
@@ -9838,7 +9893,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
9838
9893
|
</ng-container>
|
|
9839
9894
|
</mat-tab-nav-panel>
|
|
9840
9895
|
`, 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: [{
|
|
9896
|
+
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.Renderer2 }], propDecorators: { tabs: [{
|
|
9842
9897
|
type: ContentChildren,
|
|
9843
9898
|
args: [PtechTabComponent]
|
|
9844
9899
|
}], tabsNav: [{
|