ng-virtual-list 19.7.9 → 19.7.11
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.
|
@@ -316,7 +316,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
316
316
|
}]
|
|
317
317
|
}], ctorParameters: () => [] });
|
|
318
318
|
|
|
319
|
-
const ATTR_AREA_SELECTED = 'area-selected', TABINDEX = 'index', KEY_SPACE = " ", KEY_ARR_LEFT = "ArrowLeft", KEY_ARR_UP = "ArrowUp", KEY_ARR_RIGHT = "ArrowRight", KEY_ARR_DOWN = "ArrowDown";
|
|
319
|
+
const ATTR_AREA_SELECTED = 'area-selected', TABINDEX = 'index', KEY_SPACE = " ", KEY_ARR_LEFT = "ArrowLeft", KEY_ARR_UP = "ArrowUp", KEY_ARR_RIGHT = "ArrowRight", KEY_ARR_DOWN = "ArrowDown", EVENT_FOCUS_IN = 'focusin', EVENT_FOCUS_OUT = 'focusout', EVENT_KEY_DOWN = 'keydown';
|
|
320
320
|
/**
|
|
321
321
|
* Virtual list item component
|
|
322
322
|
* @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/components/ng-virtual-list-item.component.ts
|
|
@@ -391,22 +391,27 @@ class NgVirtualListItemComponent extends BaseVirtualListItemComponent {
|
|
|
391
391
|
super();
|
|
392
392
|
this._id = this._service.generateComponentId();
|
|
393
393
|
const $data = toObservable(this.data);
|
|
394
|
-
fromEvent(this.element,
|
|
394
|
+
fromEvent(this.element, EVENT_FOCUS_IN).pipe(takeUntilDestroyed(), tap(e => {
|
|
395
395
|
this.focus.set(true);
|
|
396
396
|
this.updateConfig(this._data);
|
|
397
397
|
this.updatePartStr(this._data, this._isSelected, this._isCollapsed);
|
|
398
398
|
})).subscribe(),
|
|
399
|
-
fromEvent(this.element,
|
|
399
|
+
fromEvent(this.element, EVENT_FOCUS_OUT).pipe(takeUntilDestroyed(), tap(e => {
|
|
400
400
|
this.focus.set(false);
|
|
401
401
|
this.updateConfig(this._data);
|
|
402
402
|
this.updatePartStr(this._data, this._isSelected, this._isCollapsed);
|
|
403
403
|
})).subscribe(),
|
|
404
|
-
fromEvent(this.element,
|
|
404
|
+
fromEvent(this.element, EVENT_KEY_DOWN).pipe(takeUntilDestroyed(), tap(e => {
|
|
405
405
|
switch (e.key) {
|
|
406
406
|
case KEY_SPACE: {
|
|
407
407
|
e.stopImmediatePropagation();
|
|
408
408
|
e.preventDefault();
|
|
409
|
-
this._service.
|
|
409
|
+
if (this._service.selectByClick) {
|
|
410
|
+
this._service.select(this._data);
|
|
411
|
+
}
|
|
412
|
+
if (this._service.collapseByClick) {
|
|
413
|
+
this._service.collapse(this._data);
|
|
414
|
+
}
|
|
410
415
|
break;
|
|
411
416
|
}
|
|
412
417
|
case KEY_ARR_LEFT:
|
|
@@ -1940,6 +1945,9 @@ const isMethodForSelecting = (src, expected) => {
|
|
|
1940
1945
|
};
|
|
1941
1946
|
|
|
1942
1947
|
const ROLE_LIST = 'list', ROLE_LIST_BOX = 'listbox';
|
|
1948
|
+
const validateScrollIteration = (value) => {
|
|
1949
|
+
return Number.isNaN(value) || (value < 0) ? 0 : value > MAX_SCROLL_TO_ITERATIONS ? MAX_SCROLL_TO_ITERATIONS : value;
|
|
1950
|
+
};
|
|
1943
1951
|
/**
|
|
1944
1952
|
* Virtual list component.
|
|
1945
1953
|
* Maximum performance for extremely large lists.
|
|
@@ -1987,7 +1995,7 @@ class NgVirtualListComponent {
|
|
|
1987
1995
|
onCollapse = output();
|
|
1988
1996
|
_itemsOptions = {
|
|
1989
1997
|
transform: (v) => {
|
|
1990
|
-
|
|
1998
|
+
// etc
|
|
1991
1999
|
return v;
|
|
1992
2000
|
},
|
|
1993
2001
|
};
|
|
@@ -2116,9 +2124,9 @@ class NgVirtualListComponent {
|
|
|
2116
2124
|
_scrollSize = signal(0);
|
|
2117
2125
|
_resizeObserver = null;
|
|
2118
2126
|
_resizeSnappedComponentHandler = () => {
|
|
2119
|
-
const list = this._list(), container = this._container(), snappedComponent = this._snapedDisplayComponent?.instance;
|
|
2127
|
+
const list = this._list(), container = this._container(), bounds = this._bounds(), snappedComponent = this._snapedDisplayComponent?.instance;
|
|
2120
2128
|
if (list && container && snappedComponent) {
|
|
2121
|
-
const isVertical = this._isVertical, listBounds = list.nativeElement.getBoundingClientRect(), listElement = list?.nativeElement, { width: lWidth, height: lHeight } = listElement?.getBoundingClientRect() ?? { width: 0, height: 0 }, { width, height } =
|
|
2129
|
+
const isVertical = this._isVertical, listBounds = list.nativeElement.getBoundingClientRect(), listElement = list?.nativeElement, { width: lWidth, height: lHeight } = listElement?.getBoundingClientRect() ?? { width: 0, height: 0 }, { width, height } = bounds ?? { width: 0, height: 0 }, isScrollable = isVertical ? container.nativeElement.scrollHeight > 0 : container.nativeElement.scrollWidth > 0;
|
|
2122
2130
|
let scrollBarSize = isVertical ? width - lWidth : height - lHeight, isScrollBarOverlap = true, overlapScrollBarSize = 0;
|
|
2123
2131
|
if (scrollBarSize === 0 && isScrollable) {
|
|
2124
2132
|
isScrollBarOverlap = true;
|
|
@@ -2215,11 +2223,14 @@ class NgVirtualListComponent {
|
|
|
2215
2223
|
this._trackBox.trackingPropertyName = v;
|
|
2216
2224
|
})).subscribe();
|
|
2217
2225
|
const $bounds = toObservable(this._bounds).pipe(filter(b => !!b)), $items = toObservable(this.items).pipe(map(i => !i ? [] : i)), $scrollSize = toObservable(this._scrollSize), $itemSize = toObservable(this.itemSize).pipe(map(v => v <= 0 ? DEFAULT_ITEM_SIZE : v)), $bufferSize = toObservable(this.bufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $maxBufferSize = toObservable(this.maxBufferSize).pipe(map(v => v < 0 ? DEFAULT_BUFFER_SIZE : v)), $itemConfigMap = toObservable(this.itemConfigMap).pipe(map(v => !v ? {} : v)), $snap = toObservable(this.snap), $isVertical = toObservable(this.direction).pipe(map(v => this.getIsVertical(v || DEFAULT_DIRECTION))), $dynamicSize = toObservable(this.dynamicSize), $enabledBufferOptimization = toObservable(this.enabledBufferOptimization), $snappingMethod = toObservable(this.snappingMethod).pipe(map(v => this.getIsSnappingMethodAdvanced(v || DEFAULT_SNAPPING_METHOD))), $methodForSelecting = toObservable(this.methodForSelecting), $selectedIds = toObservable(this.selectedIds), $collapsedIds = toObservable(this.collapsedIds), $collapsedItemIds = toObservable(this._collapsedItemIds), $actualItems = toObservable(this._actualItems), $cacheVersion = toObservable(this._cacheVersion);
|
|
2226
|
+
combineLatest([$items, $itemSize]).pipe(takeUntilDestroyed(), map(([items, itemSize]) => ({ items, itemSize })), tap(({ items, itemSize }) => {
|
|
2227
|
+
this._trackBox.resetCollection(items, itemSize);
|
|
2228
|
+
})).subscribe();
|
|
2218
2229
|
combineLatest([$items, $collapsedItemIds, $itemConfigMap]).pipe(takeUntilDestroyed(), tap(([items, collapsedIds, itemConfigMap]) => {
|
|
2219
2230
|
const hiddenItems = new CMap();
|
|
2220
2231
|
let isCollapsed = false;
|
|
2221
2232
|
for (let i = 0, l = items.length; i < l; i++) {
|
|
2222
|
-
const item = items[i], id =
|
|
2233
|
+
const item = items[i], id = item.id, group = (itemConfigMap[id]?.sticky ?? 0) > 0, collapsed = collapsedIds.includes(id);
|
|
2223
2234
|
if (group) {
|
|
2224
2235
|
isCollapsed = collapsed;
|
|
2225
2236
|
}
|
|
@@ -2455,7 +2466,7 @@ class NgVirtualListComponent {
|
|
|
2455
2466
|
* Behavior accepts the values "auto", "instant" and "smooth".
|
|
2456
2467
|
*/
|
|
2457
2468
|
scrollTo(id, behavior = BEHAVIOR_AUTO, iteration = 0) {
|
|
2458
|
-
this.scrollToExecutor(id, behavior, iteration
|
|
2469
|
+
this.scrollToExecutor(id, behavior, validateScrollIteration(iteration));
|
|
2459
2470
|
}
|
|
2460
2471
|
_scrollToRepeatExecutionTimeout;
|
|
2461
2472
|
clearScrollToRepeatExecutionTimeout() {
|
|
@@ -2528,13 +2539,13 @@ class NgVirtualListComponent {
|
|
|
2528
2539
|
*/
|
|
2529
2540
|
scrollToEnd(behavior = BEHAVIOR_INSTANT, iteration = 0) {
|
|
2530
2541
|
const items = this.items(), latItem = items[items.length > 0 ? items.length - 1 : 0];
|
|
2531
|
-
this.scrollTo(latItem.id, behavior, iteration
|
|
2542
|
+
this.scrollTo(latItem.id, behavior, validateScrollIteration(iteration));
|
|
2532
2543
|
}
|
|
2533
2544
|
_onContainerScrollHandler = (e) => {
|
|
2534
2545
|
const containerEl = this._container();
|
|
2535
2546
|
if (containerEl) {
|
|
2536
|
-
const scrollSize = (this._isVertical ? containerEl.nativeElement.scrollTop : containerEl.nativeElement.scrollLeft);
|
|
2537
|
-
this._trackBox.deltaDirection =
|
|
2547
|
+
const scrollSize = (this._isVertical ? containerEl.nativeElement.scrollTop : containerEl.nativeElement.scrollLeft), currentScollSize = this._scrollSize();
|
|
2548
|
+
this._trackBox.deltaDirection = currentScollSize > scrollSize ? -1 : currentScollSize < scrollSize ? 1 : 0;
|
|
2538
2549
|
const event = new ScrollEvent({
|
|
2539
2550
|
direction: this._trackBox.scrollDirection, container: containerEl.nativeElement,
|
|
2540
2551
|
list: this._list().nativeElement, delta: this._trackBox.delta,
|
|
@@ -2546,8 +2557,8 @@ class NgVirtualListComponent {
|
|
|
2546
2557
|
_onContainerScrollEndHandler = (e) => {
|
|
2547
2558
|
const containerEl = this._container();
|
|
2548
2559
|
if (containerEl) {
|
|
2549
|
-
const scrollSize = (this._isVertical ? containerEl.nativeElement.scrollTop : containerEl.nativeElement.scrollLeft);
|
|
2550
|
-
this._trackBox.deltaDirection =
|
|
2560
|
+
const scrollSize = (this._isVertical ? containerEl.nativeElement.scrollTop : containerEl.nativeElement.scrollLeft), currentScollSize = this._scrollSize();
|
|
2561
|
+
this._trackBox.deltaDirection = currentScollSize > scrollSize ? -1 : 0;
|
|
2551
2562
|
const event = new ScrollEvent({
|
|
2552
2563
|
direction: this._trackBox.scrollDirection, container: containerEl.nativeElement,
|
|
2553
2564
|
list: this._list().nativeElement, delta: this._trackBox.delta,
|