@ethlete/query 2.7.3 → 2.8.0
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/esm2020/lib/directives/infinity-query.directive.mjs +14 -8
- package/fesm2015/ethlete-query.mjs +12 -6
- package/fesm2015/ethlete-query.mjs.map +1 -1
- package/fesm2020/ethlete-query.mjs +12 -6
- package/fesm2020/ethlete-query.mjs.map +1 -1
- package/lib/directives/infinity-query.directive.d.ts +3 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as i1 from '@ethlete/core';
|
|
2
|
+
import { BehaviorSubjectWithSubscriberCount, getCookie, setCookie, deleteCookie, DestroyService, DelayableDirective, equal, clone } from '@ethlete/core';
|
|
3
|
+
import { Observable, filter, takeWhile, switchMap, of, BehaviorSubject, Subject, takeUntil, interval, startWith, finalize, tap, timer, map, combineLatest, fromEvent, debounceTime, take, concat, distinctUntilChanged } from 'rxjs';
|
|
3
4
|
import * as i0 from '@angular/core';
|
|
4
5
|
import { Directive, Input, InjectionToken, inject, ChangeDetectorRef, ViewContainerRef, TemplateRef, ErrorHandler, ElementRef } from '@angular/core';
|
|
5
6
|
import { FormGroup } from '@angular/forms';
|
|
@@ -1463,6 +1464,7 @@ class InfinityQueryDirective {
|
|
|
1463
1464
|
this._viewContainerRef = inject(ViewContainerRef);
|
|
1464
1465
|
this._mainTemplateRef = inject((TemplateRef));
|
|
1465
1466
|
this._errorHandler = inject(ErrorHandler);
|
|
1467
|
+
this._delayable = inject(DelayableDirective, { host: true });
|
|
1466
1468
|
this._data$ = new BehaviorSubject([]);
|
|
1467
1469
|
this._isMainViewCreated = false;
|
|
1468
1470
|
}
|
|
@@ -1498,15 +1500,15 @@ class InfinityQueryDirective {
|
|
|
1498
1500
|
}
|
|
1499
1501
|
_setupInfinityQuery(config) {
|
|
1500
1502
|
const instance = new InfinityQuery(config);
|
|
1501
|
-
instance.currentQuery$
|
|
1502
|
-
.pipe(
|
|
1503
|
+
combineLatest([instance.currentQuery$.pipe(switchQueryState()), this._delayable.isDelayed$])
|
|
1504
|
+
.pipe(tap(([state, isDelayed]) => {
|
|
1503
1505
|
this._viewContext.currentPage = instance.currentPage;
|
|
1504
1506
|
this._viewContext.totalPages = instance.totalPages;
|
|
1505
1507
|
this._viewContext.itemsPerPage = instance.itemsPerPage;
|
|
1506
1508
|
this._viewContext.canLoadMore =
|
|
1507
1509
|
(instance.totalPages && instance.currentPage && instance.totalPages > instance.currentPage) || false;
|
|
1508
1510
|
this._viewContext.currentCalculatedPage = instance.currentCalculatedPage;
|
|
1509
|
-
if (isQueryStateLoading(state)) {
|
|
1511
|
+
if (isQueryStateLoading(state) || isDelayed) {
|
|
1510
1512
|
this._viewContext.loading = true;
|
|
1511
1513
|
this._viewContext.error = null;
|
|
1512
1514
|
this._viewContext.isFirstLoad = this.context.infinityQuery === null;
|
|
@@ -1557,6 +1559,9 @@ class InfinityQueryDirective {
|
|
|
1557
1559
|
if (!this._infinityQueryInstance) {
|
|
1558
1560
|
return;
|
|
1559
1561
|
}
|
|
1562
|
+
if (this._viewContext.loading) {
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1560
1565
|
this._infinityQueryInstance.nextPage();
|
|
1561
1566
|
}
|
|
1562
1567
|
reset(newConfig) {
|
|
@@ -1587,7 +1592,7 @@ class InfinityQueryDirective {
|
|
|
1587
1592
|
}
|
|
1588
1593
|
}
|
|
1589
1594
|
InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1590
|
-
InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }, DestroyService], exportAs: ["infinityQuery"], ngImport: i0 });
|
|
1595
|
+
InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }, DestroyService], exportAs: ["infinityQuery"], hostDirectives: [{ directive: i1.DelayableDirective }], ngImport: i0 });
|
|
1591
1596
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: InfinityQueryDirective, decorators: [{
|
|
1592
1597
|
type: Directive,
|
|
1593
1598
|
args: [{
|
|
@@ -1596,6 +1601,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
1596
1601
|
exportAs: 'infinityQuery',
|
|
1597
1602
|
standalone: true,
|
|
1598
1603
|
providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }, DestroyService],
|
|
1604
|
+
hostDirectives: [DelayableDirective],
|
|
1599
1605
|
}]
|
|
1600
1606
|
}], propDecorators: { infinityQuery: [{
|
|
1601
1607
|
type: Input
|