1 | import { coerceNumberProperty, coerceElement, coerceBooleanProperty } from '@angular/cdk/coercion';
|
2 | import * as i0 from '@angular/core';
|
3 | import { InjectionToken, forwardRef, Directive, Input, Injectable, Optional, Inject, inject, Component, ViewEncapsulation, ChangeDetectionStrategy, Output, ViewChild, SkipSelf, ElementRef, NgModule } from '@angular/core';
|
4 | import { Subject, of, Observable, fromEvent, animationFrameScheduler, asapScheduler, Subscription, isObservable } from 'rxjs';
|
5 | import { distinctUntilChanged, auditTime, filter, takeUntil, startWith, pairwise, switchMap, shareReplay } from 'rxjs/operators';
|
6 | import * as i1 from '@angular/cdk/platform';
|
7 | import { getRtlScrollAxisType, supportsScrollBehavior, Platform } from '@angular/cdk/platform';
|
8 | import { DOCUMENT } from '@angular/common';
|
9 | import * as i2 from '@angular/cdk/bidi';
|
10 | import { BidiModule } from '@angular/cdk/bidi';
|
11 | import * as i2$1 from '@angular/cdk/collections';
|
12 | import { isDataSource, ArrayDataSource, _VIEW_REPEATER_STRATEGY, _RecycleViewRepeaterStrategy } from '@angular/cdk/collections';
|
13 |
|
14 |
|
15 | const VIRTUAL_SCROLL_STRATEGY = new InjectionToken('VIRTUAL_SCROLL_STRATEGY');
|
16 |
|
17 |
|
18 | class FixedSizeVirtualScrollStrategy {
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 | constructor(itemSize, minBufferPx, maxBufferPx) {
|
25 | this._scrolledIndexChange = new Subject();
|
26 |
|
27 | this.scrolledIndexChange = this._scrolledIndexChange.pipe(distinctUntilChanged());
|
28 |
|
29 | this._viewport = null;
|
30 | this._itemSize = itemSize;
|
31 | this._minBufferPx = minBufferPx;
|
32 | this._maxBufferPx = maxBufferPx;
|
33 | }
|
34 | |
35 |
|
36 |
|
37 |
|
38 | attach(viewport) {
|
39 | this._viewport = viewport;
|
40 | this._updateTotalContentSize();
|
41 | this._updateRenderedRange();
|
42 | }
|
43 |
|
44 | detach() {
|
45 | this._scrolledIndexChange.complete();
|
46 | this._viewport = null;
|
47 | }
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | updateItemAndBufferSize(itemSize, minBufferPx, maxBufferPx) {
|
55 | if (maxBufferPx < minBufferPx && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
56 | throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');
|
57 | }
|
58 | this._itemSize = itemSize;
|
59 | this._minBufferPx = minBufferPx;
|
60 | this._maxBufferPx = maxBufferPx;
|
61 | this._updateTotalContentSize();
|
62 | this._updateRenderedRange();
|
63 | }
|
64 |
|
65 | onContentScrolled() {
|
66 | this._updateRenderedRange();
|
67 | }
|
68 |
|
69 | onDataLengthChanged() {
|
70 | this._updateTotalContentSize();
|
71 | this._updateRenderedRange();
|
72 | }
|
73 |
|
74 | onContentRendered() {
|
75 |
|
76 | }
|
77 |
|
78 | onRenderedOffsetChanged() {
|
79 |
|
80 | }
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 | scrollToIndex(index, behavior) {
|
87 | if (this._viewport) {
|
88 | this._viewport.scrollToOffset(index * this._itemSize, behavior);
|
89 | }
|
90 | }
|
91 |
|
92 | _updateTotalContentSize() {
|
93 | if (!this._viewport) {
|
94 | return;
|
95 | }
|
96 | this._viewport.setTotalContentSize(this._viewport.getDataLength() * this._itemSize);
|
97 | }
|
98 |
|
99 | _updateRenderedRange() {
|
100 | if (!this._viewport) {
|
101 | return;
|
102 | }
|
103 | const renderedRange = this._viewport.getRenderedRange();
|
104 | const newRange = { start: renderedRange.start, end: renderedRange.end };
|
105 | const viewportSize = this._viewport.getViewportSize();
|
106 | const dataLength = this._viewport.getDataLength();
|
107 | let scrollOffset = this._viewport.measureScrollOffset();
|
108 |
|
109 | let firstVisibleIndex = this._itemSize > 0 ? scrollOffset / this._itemSize : 0;
|
110 |
|
111 | if (newRange.end > dataLength) {
|
112 |
|
113 | const maxVisibleItems = Math.ceil(viewportSize / this._itemSize);
|
114 | const newVisibleIndex = Math.max(0, Math.min(firstVisibleIndex, dataLength - maxVisibleItems));
|
115 |
|
116 |
|
117 | if (firstVisibleIndex != newVisibleIndex) {
|
118 | firstVisibleIndex = newVisibleIndex;
|
119 | scrollOffset = newVisibleIndex * this._itemSize;
|
120 | newRange.start = Math.floor(firstVisibleIndex);
|
121 | }
|
122 | newRange.end = Math.max(0, Math.min(dataLength, newRange.start + maxVisibleItems));
|
123 | }
|
124 | const startBuffer = scrollOffset - newRange.start * this._itemSize;
|
125 | if (startBuffer < this._minBufferPx && newRange.start != 0) {
|
126 | const expandStart = Math.ceil((this._maxBufferPx - startBuffer) / this._itemSize);
|
127 | newRange.start = Math.max(0, newRange.start - expandStart);
|
128 | newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + (viewportSize + this._minBufferPx) / this._itemSize));
|
129 | }
|
130 | else {
|
131 | const endBuffer = newRange.end * this._itemSize - (scrollOffset + viewportSize);
|
132 | if (endBuffer < this._minBufferPx && newRange.end != dataLength) {
|
133 | const expandEnd = Math.ceil((this._maxBufferPx - endBuffer) / this._itemSize);
|
134 | if (expandEnd > 0) {
|
135 | newRange.end = Math.min(dataLength, newRange.end + expandEnd);
|
136 | newRange.start = Math.max(0, Math.floor(firstVisibleIndex - this._minBufferPx / this._itemSize));
|
137 | }
|
138 | }
|
139 | }
|
140 | this._viewport.setRenderedRange(newRange);
|
141 | this._viewport.setRenderedContentOffset(this._itemSize * newRange.start);
|
142 | this._scrolledIndexChange.next(Math.floor(firstVisibleIndex));
|
143 | }
|
144 | }
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | function _fixedSizeVirtualScrollStrategyFactory(fixedSizeDir) {
|
152 | return fixedSizeDir._scrollStrategy;
|
153 | }
|
154 |
|
155 | class CdkFixedSizeVirtualScroll {
|
156 | constructor() {
|
157 | this._itemSize = 20;
|
158 | this._minBufferPx = 100;
|
159 | this._maxBufferPx = 200;
|
160 |
|
161 | this._scrollStrategy = new FixedSizeVirtualScrollStrategy(this.itemSize, this.minBufferPx, this.maxBufferPx);
|
162 | }
|
163 |
|
164 | get itemSize() {
|
165 | return this._itemSize;
|
166 | }
|
167 | set itemSize(value) {
|
168 | this._itemSize = coerceNumberProperty(value);
|
169 | }
|
170 | |
171 |
|
172 |
|
173 |
|
174 | get minBufferPx() {
|
175 | return this._minBufferPx;
|
176 | }
|
177 | set minBufferPx(value) {
|
178 | this._minBufferPx = coerceNumberProperty(value);
|
179 | }
|
180 | |
181 |
|
182 |
|
183 | get maxBufferPx() {
|
184 | return this._maxBufferPx;
|
185 | }
|
186 | set maxBufferPx(value) {
|
187 | this._maxBufferPx = coerceNumberProperty(value);
|
188 | }
|
189 | ngOnChanges() {
|
190 | this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
|
191 | }
|
192 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFixedSizeVirtualScroll, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
193 | static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkFixedSizeVirtualScroll, isStandalone: true, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: { itemSize: "itemSize", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx" }, providers: [
|
194 | {
|
195 | provide: VIRTUAL_SCROLL_STRATEGY,
|
196 | useFactory: _fixedSizeVirtualScrollStrategyFactory,
|
197 | deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],
|
198 | },
|
199 | ], usesOnChanges: true, ngImport: i0 }); }
|
200 | }
|
201 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkFixedSizeVirtualScroll, decorators: [{
|
202 | type: Directive,
|
203 | args: [{
|
204 | selector: 'cdk-virtual-scroll-viewport[itemSize]',
|
205 | standalone: true,
|
206 | providers: [
|
207 | {
|
208 | provide: VIRTUAL_SCROLL_STRATEGY,
|
209 | useFactory: _fixedSizeVirtualScrollStrategyFactory,
|
210 | deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],
|
211 | },
|
212 | ],
|
213 | }]
|
214 | }], propDecorators: { itemSize: [{
|
215 | type: Input
|
216 | }], minBufferPx: [{
|
217 | type: Input
|
218 | }], maxBufferPx: [{
|
219 | type: Input
|
220 | }] } });
|
221 |
|
222 |
|
223 | const DEFAULT_SCROLL_TIME = 20;
|
224 |
|
225 |
|
226 |
|
227 |
|
228 | class ScrollDispatcher {
|
229 | constructor(_ngZone, _platform, document) {
|
230 | this._ngZone = _ngZone;
|
231 | this._platform = _platform;
|
232 |
|
233 | this._scrolled = new Subject();
|
234 |
|
235 | this._globalSubscription = null;
|
236 |
|
237 | this._scrolledCount = 0;
|
238 | |
239 |
|
240 |
|
241 |
|
242 | this.scrollContainers = new Map();
|
243 | this._document = document;
|
244 | }
|
245 | |
246 |
|
247 |
|
248 |
|
249 |
|
250 | register(scrollable) {
|
251 | if (!this.scrollContainers.has(scrollable)) {
|
252 | this.scrollContainers.set(scrollable, scrollable.elementScrolled().subscribe(() => this._scrolled.next(scrollable)));
|
253 | }
|
254 | }
|
255 | |
256 |
|
257 |
|
258 |
|
259 | deregister(scrollable) {
|
260 | const scrollableReference = this.scrollContainers.get(scrollable);
|
261 | if (scrollableReference) {
|
262 | scrollableReference.unsubscribe();
|
263 | this.scrollContainers.delete(scrollable);
|
264 | }
|
265 | }
|
266 | |
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 | scrolled(auditTimeInMs = DEFAULT_SCROLL_TIME) {
|
277 | if (!this._platform.isBrowser) {
|
278 | return of();
|
279 | }
|
280 | return new Observable((observer) => {
|
281 | if (!this._globalSubscription) {
|
282 | this._addGlobalListener();
|
283 | }
|
284 |
|
285 |
|
286 | const subscription = auditTimeInMs > 0
|
287 | ? this._scrolled.pipe(auditTime(auditTimeInMs)).subscribe(observer)
|
288 | : this._scrolled.subscribe(observer);
|
289 | this._scrolledCount++;
|
290 | return () => {
|
291 | subscription.unsubscribe();
|
292 | this._scrolledCount--;
|
293 | if (!this._scrolledCount) {
|
294 | this._removeGlobalListener();
|
295 | }
|
296 | };
|
297 | });
|
298 | }
|
299 | ngOnDestroy() {
|
300 | this._removeGlobalListener();
|
301 | this.scrollContainers.forEach((_, container) => this.deregister(container));
|
302 | this._scrolled.complete();
|
303 | }
|
304 | |
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 | ancestorScrolled(elementOrElementRef, auditTimeInMs) {
|
311 | const ancestors = this.getAncestorScrollContainers(elementOrElementRef);
|
312 | return this.scrolled(auditTimeInMs).pipe(filter(target => {
|
313 | return !target || ancestors.indexOf(target) > -1;
|
314 | }));
|
315 | }
|
316 |
|
317 | getAncestorScrollContainers(elementOrElementRef) {
|
318 | const scrollingContainers = [];
|
319 | this.scrollContainers.forEach((_subscription, scrollable) => {
|
320 | if (this._scrollableContainsElement(scrollable, elementOrElementRef)) {
|
321 | scrollingContainers.push(scrollable);
|
322 | }
|
323 | });
|
324 | return scrollingContainers;
|
325 | }
|
326 |
|
327 | _getWindow() {
|
328 | return this._document.defaultView || window;
|
329 | }
|
330 |
|
331 | _scrollableContainsElement(scrollable, elementOrElementRef) {
|
332 | let element = coerceElement(elementOrElementRef);
|
333 | let scrollableElement = scrollable.getElementRef().nativeElement;
|
334 |
|
335 |
|
336 | do {
|
337 | if (element == scrollableElement) {
|
338 | return true;
|
339 | }
|
340 | } while ((element = element.parentElement));
|
341 | return false;
|
342 | }
|
343 |
|
344 | _addGlobalListener() {
|
345 | this._globalSubscription = this._ngZone.runOutsideAngular(() => {
|
346 | const window = this._getWindow();
|
347 | return fromEvent(window.document, 'scroll').subscribe(() => this._scrolled.next());
|
348 | });
|
349 | }
|
350 |
|
351 | _removeGlobalListener() {
|
352 | if (this._globalSubscription) {
|
353 | this._globalSubscription.unsubscribe();
|
354 | this._globalSubscription = null;
|
355 | }
|
356 | }
|
357 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollDispatcher, deps: [{ token: i0.NgZone }, { token: i1.Platform }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
358 | static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollDispatcher, providedIn: 'root' }); }
|
359 | }
|
360 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollDispatcher, decorators: [{
|
361 | type: Injectable,
|
362 | args: [{ providedIn: 'root' }]
|
363 | }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i1.Platform }, { type: undefined, decorators: [{
|
364 | type: Optional
|
365 | }, {
|
366 | type: Inject,
|
367 | args: [DOCUMENT]
|
368 | }] }]; } });
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 | class CdkScrollable {
|
376 | constructor(elementRef, scrollDispatcher, ngZone, dir) {
|
377 | this.elementRef = elementRef;
|
378 | this.scrollDispatcher = scrollDispatcher;
|
379 | this.ngZone = ngZone;
|
380 | this.dir = dir;
|
381 | this._destroyed = new Subject();
|
382 | this._elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(this.elementRef.nativeElement, 'scroll')
|
383 | .pipe(takeUntil(this._destroyed))
|
384 | .subscribe(observer)));
|
385 | }
|
386 | ngOnInit() {
|
387 | this.scrollDispatcher.register(this);
|
388 | }
|
389 | ngOnDestroy() {
|
390 | this.scrollDispatcher.deregister(this);
|
391 | this._destroyed.next();
|
392 | this._destroyed.complete();
|
393 | }
|
394 |
|
395 | elementScrolled() {
|
396 | return this._elementScrolled;
|
397 | }
|
398 |
|
399 | getElementRef() {
|
400 | return this.elementRef;
|
401 | }
|
402 | |
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 | scrollTo(options) {
|
411 | const el = this.elementRef.nativeElement;
|
412 | const isRtl = this.dir && this.dir.value == 'rtl';
|
413 |
|
414 | if (options.left == null) {
|
415 | options.left = isRtl ? options.end : options.start;
|
416 | }
|
417 | if (options.right == null) {
|
418 | options.right = isRtl ? options.start : options.end;
|
419 | }
|
420 |
|
421 | if (options.bottom != null) {
|
422 | options.top =
|
423 | el.scrollHeight - el.clientHeight - options.bottom;
|
424 | }
|
425 |
|
426 | if (isRtl && getRtlScrollAxisType() != 0 ) {
|
427 | if (options.left != null) {
|
428 | options.right =
|
429 | el.scrollWidth - el.clientWidth - options.left;
|
430 | }
|
431 | if (getRtlScrollAxisType() == 2 ) {
|
432 | options.left = options.right;
|
433 | }
|
434 | else if (getRtlScrollAxisType() == 1 ) {
|
435 | options.left = options.right ? -options.right : options.right;
|
436 | }
|
437 | }
|
438 | else {
|
439 | if (options.right != null) {
|
440 | options.left =
|
441 | el.scrollWidth - el.clientWidth - options.right;
|
442 | }
|
443 | }
|
444 | this._applyScrollToOptions(options);
|
445 | }
|
446 | _applyScrollToOptions(options) {
|
447 | const el = this.elementRef.nativeElement;
|
448 | if (supportsScrollBehavior()) {
|
449 | el.scrollTo(options);
|
450 | }
|
451 | else {
|
452 | if (options.top != null) {
|
453 | el.scrollTop = options.top;
|
454 | }
|
455 | if (options.left != null) {
|
456 | el.scrollLeft = options.left;
|
457 | }
|
458 | }
|
459 | }
|
460 | |
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 | measureScrollOffset(from) {
|
470 | const LEFT = 'left';
|
471 | const RIGHT = 'right';
|
472 | const el = this.elementRef.nativeElement;
|
473 | if (from == 'top') {
|
474 | return el.scrollTop;
|
475 | }
|
476 | if (from == 'bottom') {
|
477 | return el.scrollHeight - el.clientHeight - el.scrollTop;
|
478 | }
|
479 |
|
480 | const isRtl = this.dir && this.dir.value == 'rtl';
|
481 | if (from == 'start') {
|
482 | from = isRtl ? RIGHT : LEFT;
|
483 | }
|
484 | else if (from == 'end') {
|
485 | from = isRtl ? LEFT : RIGHT;
|
486 | }
|
487 | if (isRtl && getRtlScrollAxisType() == 2 ) {
|
488 |
|
489 |
|
490 | if (from == LEFT) {
|
491 | return el.scrollWidth - el.clientWidth - el.scrollLeft;
|
492 | }
|
493 | else {
|
494 | return el.scrollLeft;
|
495 | }
|
496 | }
|
497 | else if (isRtl && getRtlScrollAxisType() == 1 ) {
|
498 |
|
499 |
|
500 | if (from == LEFT) {
|
501 | return el.scrollLeft + el.scrollWidth - el.clientWidth;
|
502 | }
|
503 | else {
|
504 | return -el.scrollLeft;
|
505 | }
|
506 | }
|
507 | else {
|
508 |
|
509 |
|
510 | if (from == LEFT) {
|
511 | return el.scrollLeft;
|
512 | }
|
513 | else {
|
514 | return el.scrollWidth - el.clientWidth - el.scrollLeft;
|
515 | }
|
516 | }
|
517 | }
|
518 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollable, deps: [{ token: i0.ElementRef }, { token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
519 | static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkScrollable, isStandalone: true, selector: "[cdk-scrollable], [cdkScrollable]", ngImport: i0 }); }
|
520 | }
|
521 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollable, decorators: [{
|
522 | type: Directive,
|
523 | args: [{
|
524 | selector: '[cdk-scrollable], [cdkScrollable]',
|
525 | standalone: true,
|
526 | }]
|
527 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
|
528 | type: Optional
|
529 | }] }]; } });
|
530 |
|
531 |
|
532 | const DEFAULT_RESIZE_TIME = 20;
|
533 |
|
534 |
|
535 |
|
536 |
|
537 | class ViewportRuler {
|
538 | constructor(_platform, ngZone, document) {
|
539 | this._platform = _platform;
|
540 |
|
541 | this._change = new Subject();
|
542 |
|
543 | this._changeListener = (event) => {
|
544 | this._change.next(event);
|
545 | };
|
546 | this._document = document;
|
547 | ngZone.runOutsideAngular(() => {
|
548 | if (_platform.isBrowser) {
|
549 | const window = this._getWindow();
|
550 |
|
551 |
|
552 | window.addEventListener('resize', this._changeListener);
|
553 | window.addEventListener('orientationchange', this._changeListener);
|
554 | }
|
555 |
|
556 |
|
557 | this.change().subscribe(() => (this._viewportSize = null));
|
558 | });
|
559 | }
|
560 | ngOnDestroy() {
|
561 | if (this._platform.isBrowser) {
|
562 | const window = this._getWindow();
|
563 | window.removeEventListener('resize', this._changeListener);
|
564 | window.removeEventListener('orientationchange', this._changeListener);
|
565 | }
|
566 | this._change.complete();
|
567 | }
|
568 |
|
569 | getViewportSize() {
|
570 | if (!this._viewportSize) {
|
571 | this._updateViewportSize();
|
572 | }
|
573 | const output = { width: this._viewportSize.width, height: this._viewportSize.height };
|
574 |
|
575 | if (!this._platform.isBrowser) {
|
576 | this._viewportSize = null;
|
577 | }
|
578 | return output;
|
579 | }
|
580 |
|
581 | getViewportRect() {
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 | const scrollPosition = this.getViewportScrollPosition();
|
592 | const { width, height } = this.getViewportSize();
|
593 | return {
|
594 | top: scrollPosition.top,
|
595 | left: scrollPosition.left,
|
596 | bottom: scrollPosition.top + height,
|
597 | right: scrollPosition.left + width,
|
598 | height,
|
599 | width,
|
600 | };
|
601 | }
|
602 |
|
603 | getViewportScrollPosition() {
|
604 |
|
605 |
|
606 | if (!this._platform.isBrowser) {
|
607 | return { top: 0, left: 0 };
|
608 | }
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 | const document = this._document;
|
616 | const window = this._getWindow();
|
617 | const documentElement = document.documentElement;
|
618 | const documentRect = documentElement.getBoundingClientRect();
|
619 | const top = -documentRect.top ||
|
620 | document.body.scrollTop ||
|
621 | window.scrollY ||
|
622 | documentElement.scrollTop ||
|
623 | 0;
|
624 | const left = -documentRect.left ||
|
625 | document.body.scrollLeft ||
|
626 | window.scrollX ||
|
627 | documentElement.scrollLeft ||
|
628 | 0;
|
629 | return { top, left };
|
630 | }
|
631 | |
632 |
|
633 |
|
634 |
|
635 |
|
636 | change(throttleTime = DEFAULT_RESIZE_TIME) {
|
637 | return throttleTime > 0 ? this._change.pipe(auditTime(throttleTime)) : this._change;
|
638 | }
|
639 |
|
640 | _getWindow() {
|
641 | return this._document.defaultView || window;
|
642 | }
|
643 |
|
644 | _updateViewportSize() {
|
645 | const window = this._getWindow();
|
646 | this._viewportSize = this._platform.isBrowser
|
647 | ? { width: window.innerWidth, height: window.innerHeight }
|
648 | : { width: 0, height: 0 };
|
649 | }
|
650 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ViewportRuler, deps: [{ token: i1.Platform }, { token: i0.NgZone }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
651 | static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ViewportRuler, providedIn: 'root' }); }
|
652 | }
|
653 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ViewportRuler, decorators: [{
|
654 | type: Injectable,
|
655 | args: [{ providedIn: 'root' }]
|
656 | }], ctorParameters: function () { return [{ type: i1.Platform }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
657 | type: Optional
|
658 | }, {
|
659 | type: Inject,
|
660 | args: [DOCUMENT]
|
661 | }] }]; } });
|
662 |
|
663 | const VIRTUAL_SCROLLABLE = new InjectionToken('VIRTUAL_SCROLLABLE');
|
664 |
|
665 |
|
666 |
|
667 | class CdkVirtualScrollable extends CdkScrollable {
|
668 | constructor(elementRef, scrollDispatcher, ngZone, dir) {
|
669 | super(elementRef, scrollDispatcher, ngZone, dir);
|
670 | }
|
671 | |
672 |
|
673 |
|
674 |
|
675 |
|
676 | measureViewportSize(orientation) {
|
677 | const viewportEl = this.elementRef.nativeElement;
|
678 | return orientation === 'horizontal' ? viewportEl.clientWidth : viewportEl.clientHeight;
|
679 | }
|
680 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollable, deps: [{ token: i0.ElementRef }, { token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
681 | static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollable, usesInheritance: true, ngImport: i0 }); }
|
682 | }
|
683 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollable, decorators: [{
|
684 | type: Directive
|
685 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
|
686 | type: Optional
|
687 | }] }]; } });
|
688 |
|
689 |
|
690 | function rangesEqual(r1, r2) {
|
691 | return r1.start == r2.start && r1.end == r2.end;
|
692 | }
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 | const SCROLL_SCHEDULER = typeof requestAnimationFrame !== 'undefined' ? animationFrameScheduler : asapScheduler;
|
699 |
|
700 | class CdkVirtualScrollViewport extends CdkVirtualScrollable {
|
701 |
|
702 | get orientation() {
|
703 | return this._orientation;
|
704 | }
|
705 | set orientation(orientation) {
|
706 | if (this._orientation !== orientation) {
|
707 | this._orientation = orientation;
|
708 | this._calculateSpacerSize();
|
709 | }
|
710 | }
|
711 | |
712 |
|
713 |
|
714 |
|
715 | get appendOnly() {
|
716 | return this._appendOnly;
|
717 | }
|
718 | set appendOnly(value) {
|
719 | this._appendOnly = coerceBooleanProperty(value);
|
720 | }
|
721 | constructor(elementRef, _changeDetectorRef, ngZone, _scrollStrategy, dir, scrollDispatcher, viewportRuler, scrollable) {
|
722 | super(elementRef, scrollDispatcher, ngZone, dir);
|
723 | this.elementRef = elementRef;
|
724 | this._changeDetectorRef = _changeDetectorRef;
|
725 | this._scrollStrategy = _scrollStrategy;
|
726 | this.scrollable = scrollable;
|
727 | this._platform = inject(Platform);
|
728 |
|
729 | this._detachedSubject = new Subject();
|
730 |
|
731 | this._renderedRangeSubject = new Subject();
|
732 | this._orientation = 'vertical';
|
733 | this._appendOnly = false;
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 | this.scrolledIndexChange = new Observable((observer) => this._scrollStrategy.scrolledIndexChange.subscribe(index => Promise.resolve().then(() => this.ngZone.run(() => observer.next(index)))));
|
740 |
|
741 | this.renderedRangeStream = this._renderedRangeSubject;
|
742 | |
743 |
|
744 |
|
745 | this._totalContentSize = 0;
|
746 |
|
747 | this._totalContentWidth = '';
|
748 |
|
749 | this._totalContentHeight = '';
|
750 |
|
751 | this._renderedRange = { start: 0, end: 0 };
|
752 |
|
753 | this._dataLength = 0;
|
754 |
|
755 | this._viewportSize = 0;
|
756 |
|
757 | this._renderedContentOffset = 0;
|
758 | |
759 |
|
760 |
|
761 |
|
762 | this._renderedContentOffsetNeedsRewrite = false;
|
763 |
|
764 | this._isChangeDetectionPending = false;
|
765 |
|
766 | this._runAfterChangeDetection = [];
|
767 |
|
768 | this._viewportChanges = Subscription.EMPTY;
|
769 | if (!_scrollStrategy && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
770 | throw Error('Error: cdk-virtual-scroll-viewport requires the "itemSize" property to be set.');
|
771 | }
|
772 | this._viewportChanges = viewportRuler.change().subscribe(() => {
|
773 | this.checkViewportSize();
|
774 | });
|
775 | if (!this.scrollable) {
|
776 |
|
777 | this.elementRef.nativeElement.classList.add('cdk-virtual-scrollable');
|
778 | this.scrollable = this;
|
779 | }
|
780 | }
|
781 | ngOnInit() {
|
782 |
|
783 | if (!this._platform.isBrowser) {
|
784 | return;
|
785 | }
|
786 | if (this.scrollable === this) {
|
787 | super.ngOnInit();
|
788 | }
|
789 |
|
790 |
|
791 |
|
792 |
|
793 | this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
|
794 | this._measureViewportSize();
|
795 | this._scrollStrategy.attach(this);
|
796 | this.scrollable
|
797 | .elementScrolled()
|
798 | .pipe(
|
799 |
|
800 | startWith(null),
|
801 |
|
802 |
|
803 |
|
804 | auditTime(0, SCROLL_SCHEDULER))
|
805 | .subscribe(() => this._scrollStrategy.onContentScrolled());
|
806 | this._markChangeDetectionNeeded();
|
807 | }));
|
808 | }
|
809 | ngOnDestroy() {
|
810 | this.detach();
|
811 | this._scrollStrategy.detach();
|
812 |
|
813 | this._renderedRangeSubject.complete();
|
814 | this._detachedSubject.complete();
|
815 | this._viewportChanges.unsubscribe();
|
816 | super.ngOnDestroy();
|
817 | }
|
818 |
|
819 | attach(forOf) {
|
820 | if (this._forOf && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
821 | throw Error('CdkVirtualScrollViewport is already attached.');
|
822 | }
|
823 |
|
824 |
|
825 |
|
826 | this.ngZone.runOutsideAngular(() => {
|
827 | this._forOf = forOf;
|
828 | this._forOf.dataStream.pipe(takeUntil(this._detachedSubject)).subscribe(data => {
|
829 | const newLength = data.length;
|
830 | if (newLength !== this._dataLength) {
|
831 | this._dataLength = newLength;
|
832 | this._scrollStrategy.onDataLengthChanged();
|
833 | }
|
834 | this._doChangeDetection();
|
835 | });
|
836 | });
|
837 | }
|
838 |
|
839 | detach() {
|
840 | this._forOf = null;
|
841 | this._detachedSubject.next();
|
842 | }
|
843 |
|
844 | getDataLength() {
|
845 | return this._dataLength;
|
846 | }
|
847 |
|
848 | getViewportSize() {
|
849 | return this._viewportSize;
|
850 | }
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 | getRenderedRange() {
|
857 | return this._renderedRange;
|
858 | }
|
859 | measureBoundingClientRectWithScrollOffset(from) {
|
860 | return this.getElementRef().nativeElement.getBoundingClientRect()[from];
|
861 | }
|
862 | |
863 |
|
864 |
|
865 |
|
866 | setTotalContentSize(size) {
|
867 | if (this._totalContentSize !== size) {
|
868 | this._totalContentSize = size;
|
869 | this._calculateSpacerSize();
|
870 | this._markChangeDetectionNeeded();
|
871 | }
|
872 | }
|
873 |
|
874 | setRenderedRange(range) {
|
875 | if (!rangesEqual(this._renderedRange, range)) {
|
876 | if (this.appendOnly) {
|
877 | range = { start: 0, end: Math.max(this._renderedRange.end, range.end) };
|
878 | }
|
879 | this._renderedRangeSubject.next((this._renderedRange = range));
|
880 | this._markChangeDetectionNeeded(() => this._scrollStrategy.onContentRendered());
|
881 | }
|
882 | }
|
883 | |
884 |
|
885 |
|
886 | getOffsetToRenderedContentStart() {
|
887 | return this._renderedContentOffsetNeedsRewrite ? null : this._renderedContentOffset;
|
888 | }
|
889 | |
890 |
|
891 |
|
892 |
|
893 | setRenderedContentOffset(offset, to = 'to-start') {
|
894 |
|
895 | offset = this.appendOnly && to === 'to-start' ? 0 : offset;
|
896 |
|
897 |
|
898 | const isRtl = this.dir && this.dir.value == 'rtl';
|
899 | const isHorizontal = this.orientation == 'horizontal';
|
900 | const axis = isHorizontal ? 'X' : 'Y';
|
901 | const axisDirection = isHorizontal && isRtl ? -1 : 1;
|
902 | let transform = `translate${axis}(${Number(axisDirection * offset)}px)`;
|
903 | this._renderedContentOffset = offset;
|
904 | if (to === 'to-end') {
|
905 | transform += ` translate${axis}(-100%)`;
|
906 |
|
907 |
|
908 |
|
909 | this._renderedContentOffsetNeedsRewrite = true;
|
910 | }
|
911 | if (this._renderedContentTransform != transform) {
|
912 |
|
913 |
|
914 | this._renderedContentTransform = transform;
|
915 | this._markChangeDetectionNeeded(() => {
|
916 | if (this._renderedContentOffsetNeedsRewrite) {
|
917 | this._renderedContentOffset -= this.measureRenderedContentSize();
|
918 | this._renderedContentOffsetNeedsRewrite = false;
|
919 | this.setRenderedContentOffset(this._renderedContentOffset);
|
920 | }
|
921 | else {
|
922 | this._scrollStrategy.onRenderedOffsetChanged();
|
923 | }
|
924 | });
|
925 | }
|
926 | }
|
927 | |
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 | scrollToOffset(offset, behavior = 'auto') {
|
935 | const options = { behavior };
|
936 | if (this.orientation === 'horizontal') {
|
937 | options.start = offset;
|
938 | }
|
939 | else {
|
940 | options.top = offset;
|
941 | }
|
942 | this.scrollable.scrollTo(options);
|
943 | }
|
944 | |
945 |
|
946 |
|
947 |
|
948 |
|
949 | scrollToIndex(index, behavior = 'auto') {
|
950 | this._scrollStrategy.scrollToIndex(index, behavior);
|
951 | }
|
952 | |
953 |
|
954 |
|
955 |
|
956 |
|
957 | measureScrollOffset(from) {
|
958 |
|
959 | let measureScrollOffset;
|
960 | if (this.scrollable == this) {
|
961 | measureScrollOffset = (_from) => super.measureScrollOffset(_from);
|
962 | }
|
963 | else {
|
964 | measureScrollOffset = (_from) => this.scrollable.measureScrollOffset(_from);
|
965 | }
|
966 | return Math.max(0, measureScrollOffset(from ?? (this.orientation === 'horizontal' ? 'start' : 'top')) -
|
967 | this.measureViewportOffset());
|
968 | }
|
969 | |
970 |
|
971 |
|
972 |
|
973 | measureViewportOffset(from) {
|
974 | let fromRect;
|
975 | const LEFT = 'left';
|
976 | const RIGHT = 'right';
|
977 | const isRtl = this.dir?.value == 'rtl';
|
978 | if (from == 'start') {
|
979 | fromRect = isRtl ? RIGHT : LEFT;
|
980 | }
|
981 | else if (from == 'end') {
|
982 | fromRect = isRtl ? LEFT : RIGHT;
|
983 | }
|
984 | else if (from) {
|
985 | fromRect = from;
|
986 | }
|
987 | else {
|
988 | fromRect = this.orientation === 'horizontal' ? 'left' : 'top';
|
989 | }
|
990 | const scrollerClientRect = this.scrollable.measureBoundingClientRectWithScrollOffset(fromRect);
|
991 | const viewportClientRect = this.elementRef.nativeElement.getBoundingClientRect()[fromRect];
|
992 | return viewportClientRect - scrollerClientRect;
|
993 | }
|
994 |
|
995 | measureRenderedContentSize() {
|
996 | const contentEl = this._contentWrapper.nativeElement;
|
997 | return this.orientation === 'horizontal' ? contentEl.offsetWidth : contentEl.offsetHeight;
|
998 | }
|
999 | |
1000 |
|
1001 |
|
1002 |
|
1003 | measureRangeSize(range) {
|
1004 | if (!this._forOf) {
|
1005 | return 0;
|
1006 | }
|
1007 | return this._forOf.measureRangeSize(range, this.orientation);
|
1008 | }
|
1009 |
|
1010 | checkViewportSize() {
|
1011 |
|
1012 | this._measureViewportSize();
|
1013 | this._scrollStrategy.onDataLengthChanged();
|
1014 | }
|
1015 |
|
1016 | _measureViewportSize() {
|
1017 | this._viewportSize = this.scrollable.measureViewportSize(this.orientation);
|
1018 | }
|
1019 |
|
1020 | _markChangeDetectionNeeded(runAfter) {
|
1021 | if (runAfter) {
|
1022 | this._runAfterChangeDetection.push(runAfter);
|
1023 | }
|
1024 |
|
1025 |
|
1026 | if (!this._isChangeDetectionPending) {
|
1027 | this._isChangeDetectionPending = true;
|
1028 | this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
|
1029 | this._doChangeDetection();
|
1030 | }));
|
1031 | }
|
1032 | }
|
1033 |
|
1034 | _doChangeDetection() {
|
1035 | this._isChangeDetectionPending = false;
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 | this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;
|
1041 |
|
1042 |
|
1043 |
|
1044 | this.ngZone.run(() => this._changeDetectorRef.markForCheck());
|
1045 | const runAfterChangeDetection = this._runAfterChangeDetection;
|
1046 | this._runAfterChangeDetection = [];
|
1047 | for (const fn of runAfterChangeDetection) {
|
1048 | fn();
|
1049 | }
|
1050 | }
|
1051 |
|
1052 | _calculateSpacerSize() {
|
1053 | this._totalContentHeight =
|
1054 | this.orientation === 'horizontal' ? '' : `${this._totalContentSize}px`;
|
1055 | this._totalContentWidth =
|
1056 | this.orientation === 'horizontal' ? `${this._totalContentSize}px` : '';
|
1057 | }
|
1058 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollViewport, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: VIRTUAL_SCROLL_STRATEGY, optional: true }, { token: i2.Directionality, optional: true }, { token: ScrollDispatcher }, { token: ViewportRuler }, { token: VIRTUAL_SCROLLABLE, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
1059 | static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollViewport, isStandalone: true, selector: "cdk-virtual-scroll-viewport", inputs: { orientation: "orientation", appendOnly: "appendOnly" }, outputs: { scrolledIndexChange: "scrolledIndexChange" }, host: { properties: { "class.cdk-virtual-scroll-orientation-horizontal": "orientation === \"horizontal\"", "class.cdk-virtual-scroll-orientation-vertical": "orientation !== \"horizontal\"" }, classAttribute: "cdk-virtual-scroll-viewport" }, providers: [
|
1060 | {
|
1061 | provide: CdkScrollable,
|
1062 | useFactory: (virtualScrollable, viewport) => virtualScrollable || viewport,
|
1063 | deps: [[new Optional(), new Inject(VIRTUAL_SCROLLABLE)], CdkVirtualScrollViewport],
|
1064 | },
|
1065 | ], viewQueries: [{ propertyName: "_contentWrapper", first: true, predicate: ["contentWrapper"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<!--\n Wrap the rendered content in an element that will be used to offset it based on the scroll\n position.\n-->\n<div #contentWrapper class=\"cdk-virtual-scroll-content-wrapper\">\n <ng-content></ng-content>\n</div>\n<!--\n Spacer used to force the scrolling container to the correct size for the *total* number of items\n so that the scrollbar captures the size of the entire data set.\n-->\n<div class=\"cdk-virtual-scroll-spacer\"\n [style.width]=\"_totalContentWidth\" [style.height]=\"_totalContentHeight\"></div>\n", styles: ["cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
1066 | }
|
1067 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollViewport, decorators: [{
|
1068 | type: Component,
|
1069 | args: [{ selector: 'cdk-virtual-scroll-viewport', host: {
|
1070 | 'class': 'cdk-virtual-scroll-viewport',
|
1071 | '[class.cdk-virtual-scroll-orientation-horizontal]': 'orientation === "horizontal"',
|
1072 | '[class.cdk-virtual-scroll-orientation-vertical]': 'orientation !== "horizontal"',
|
1073 | }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, providers: [
|
1074 | {
|
1075 | provide: CdkScrollable,
|
1076 | useFactory: (virtualScrollable, viewport) => virtualScrollable || viewport,
|
1077 | deps: [[new Optional(), new Inject(VIRTUAL_SCROLLABLE)], CdkVirtualScrollViewport],
|
1078 | },
|
1079 | ], template: "<!--\n Wrap the rendered content in an element that will be used to offset it based on the scroll\n position.\n-->\n<div #contentWrapper class=\"cdk-virtual-scroll-content-wrapper\">\n <ng-content></ng-content>\n</div>\n<!--\n Spacer used to force the scrolling container to the correct size for the *total* number of items\n so that the scrollbar captures the size of the entire data set.\n-->\n<div class=\"cdk-virtual-scroll-spacer\"\n [style.width]=\"_totalContentWidth\" [style.height]=\"_totalContentHeight\"></div>\n", styles: ["cdk-virtual-scroll-viewport{display:block;position:relative;transform:translateZ(0)}.cdk-virtual-scrollable{overflow:auto;will-change:scroll-position;contain:strict;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{height:1px;transform-origin:0 0;flex:0 0 auto}[dir=rtl] .cdk-virtual-scroll-spacer{transform-origin:100% 0}"] }]
|
1080 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
1081 | type: Optional
|
1082 | }, {
|
1083 | type: Inject,
|
1084 | args: [VIRTUAL_SCROLL_STRATEGY]
|
1085 | }] }, { type: i2.Directionality, decorators: [{
|
1086 | type: Optional
|
1087 | }] }, { type: ScrollDispatcher }, { type: ViewportRuler }, { type: CdkVirtualScrollable, decorators: [{
|
1088 | type: Optional
|
1089 | }, {
|
1090 | type: Inject,
|
1091 | args: [VIRTUAL_SCROLLABLE]
|
1092 | }] }]; }, propDecorators: { orientation: [{
|
1093 | type: Input
|
1094 | }], appendOnly: [{
|
1095 | type: Input
|
1096 | }], scrolledIndexChange: [{
|
1097 | type: Output
|
1098 | }], _contentWrapper: [{
|
1099 | type: ViewChild,
|
1100 | args: ['contentWrapper', { static: true }]
|
1101 | }] } });
|
1102 |
|
1103 |
|
1104 | function getOffset(orientation, direction, node) {
|
1105 | const el = node;
|
1106 | if (!el.getBoundingClientRect) {
|
1107 | return 0;
|
1108 | }
|
1109 | const rect = el.getBoundingClientRect();
|
1110 | if (orientation === 'horizontal') {
|
1111 | return direction === 'start' ? rect.left : rect.right;
|
1112 | }
|
1113 | return direction === 'start' ? rect.top : rect.bottom;
|
1114 | }
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 | class CdkVirtualForOf {
|
1120 |
|
1121 | get cdkVirtualForOf() {
|
1122 | return this._cdkVirtualForOf;
|
1123 | }
|
1124 | set cdkVirtualForOf(value) {
|
1125 | this._cdkVirtualForOf = value;
|
1126 | if (isDataSource(value)) {
|
1127 | this._dataSourceChanges.next(value);
|
1128 | }
|
1129 | else {
|
1130 |
|
1131 | this._dataSourceChanges.next(new ArrayDataSource(isObservable(value) ? value : Array.from(value || [])));
|
1132 | }
|
1133 | }
|
1134 | |
1135 |
|
1136 |
|
1137 |
|
1138 | get cdkVirtualForTrackBy() {
|
1139 | return this._cdkVirtualForTrackBy;
|
1140 | }
|
1141 | set cdkVirtualForTrackBy(fn) {
|
1142 | this._needsUpdate = true;
|
1143 | this._cdkVirtualForTrackBy = fn
|
1144 | ? (index, item) => fn(index + (this._renderedRange ? this._renderedRange.start : 0), item)
|
1145 | : undefined;
|
1146 | }
|
1147 |
|
1148 | set cdkVirtualForTemplate(value) {
|
1149 | if (value) {
|
1150 | this._needsUpdate = true;
|
1151 | this._template = value;
|
1152 | }
|
1153 | }
|
1154 | |
1155 |
|
1156 |
|
1157 |
|
1158 | get cdkVirtualForTemplateCacheSize() {
|
1159 | return this._viewRepeater.viewCacheSize;
|
1160 | }
|
1161 | set cdkVirtualForTemplateCacheSize(size) {
|
1162 | this._viewRepeater.viewCacheSize = coerceNumberProperty(size);
|
1163 | }
|
1164 | constructor(
|
1165 | /** The view container to add items to. */
|
1166 | _viewContainerRef,
|
1167 | /** The template to use when stamping out new items. */
|
1168 | _template,
|
1169 | /** The set of available differs. */
|
1170 | _differs,
|
1171 | /** The strategy used to render items in the virtual scroll viewport. */
|
1172 | _viewRepeater,
|
1173 | /** The virtual scrolling viewport that these items are being rendered in. */
|
1174 | _viewport, ngZone) {
|
1175 | this._viewContainerRef = _viewContainerRef;
|
1176 | this._template = _template;
|
1177 | this._differs = _differs;
|
1178 | this._viewRepeater = _viewRepeater;
|
1179 | this._viewport = _viewport;
|
1180 |
|
1181 | this.viewChange = new Subject();
|
1182 |
|
1183 | this._dataSourceChanges = new Subject();
|
1184 |
|
1185 | this.dataStream = this._dataSourceChanges.pipe(
|
1186 |
|
1187 | startWith(null),
|
1188 |
|
1189 | pairwise(),
|
1190 |
|
1191 |
|
1192 |
|
1193 | switchMap(([prev, cur]) => this._changeDataSource(prev, cur)),
|
1194 |
|
1195 | shareReplay(1));
|
1196 |
|
1197 | this._differ = null;
|
1198 |
|
1199 | this._needsUpdate = false;
|
1200 | this._destroyed = new Subject();
|
1201 | this.dataStream.subscribe(data => {
|
1202 | this._data = data;
|
1203 | this._onRenderedDataChange();
|
1204 | });
|
1205 | this._viewport.renderedRangeStream.pipe(takeUntil(this._destroyed)).subscribe(range => {
|
1206 | this._renderedRange = range;
|
1207 | if (this.viewChange.observers.length) {
|
1208 | ngZone.run(() => this.viewChange.next(this._renderedRange));
|
1209 | }
|
1210 | this._onRenderedDataChange();
|
1211 | });
|
1212 | this._viewport.attach(this);
|
1213 | }
|
1214 | |
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 | measureRangeSize(range, orientation) {
|
1220 | if (range.start >= range.end) {
|
1221 | return 0;
|
1222 | }
|
1223 | if ((range.start < this._renderedRange.start || range.end > this._renderedRange.end) &&
|
1224 | (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
1225 | throw Error(`Error: attempted to measure an item that isn't rendered.`);
|
1226 | }
|
1227 |
|
1228 | const renderedStartIndex = range.start - this._renderedRange.start;
|
1229 |
|
1230 | const rangeLen = range.end - range.start;
|
1231 |
|
1232 |
|
1233 | let firstNode;
|
1234 | let lastNode;
|
1235 |
|
1236 | for (let i = 0; i < rangeLen; i++) {
|
1237 | const view = this._viewContainerRef.get(i + renderedStartIndex);
|
1238 | if (view && view.rootNodes.length) {
|
1239 | firstNode = lastNode = view.rootNodes[0];
|
1240 | break;
|
1241 | }
|
1242 | }
|
1243 |
|
1244 | for (let i = rangeLen - 1; i > -1; i--) {
|
1245 | const view = this._viewContainerRef.get(i + renderedStartIndex);
|
1246 | if (view && view.rootNodes.length) {
|
1247 | lastNode = view.rootNodes[view.rootNodes.length - 1];
|
1248 | break;
|
1249 | }
|
1250 | }
|
1251 | return firstNode && lastNode
|
1252 | ? getOffset(orientation, 'end', lastNode) - getOffset(orientation, 'start', firstNode)
|
1253 | : 0;
|
1254 | }
|
1255 | ngDoCheck() {
|
1256 | if (this._differ && this._needsUpdate) {
|
1257 |
|
1258 |
|
1259 |
|
1260 | const changes = this._differ.diff(this._renderedItems);
|
1261 | if (!changes) {
|
1262 | this._updateContext();
|
1263 | }
|
1264 | else {
|
1265 | this._applyChanges(changes);
|
1266 | }
|
1267 | this._needsUpdate = false;
|
1268 | }
|
1269 | }
|
1270 | ngOnDestroy() {
|
1271 | this._viewport.detach();
|
1272 | this._dataSourceChanges.next(undefined);
|
1273 | this._dataSourceChanges.complete();
|
1274 | this.viewChange.complete();
|
1275 | this._destroyed.next();
|
1276 | this._destroyed.complete();
|
1277 | this._viewRepeater.detach();
|
1278 | }
|
1279 |
|
1280 | _onRenderedDataChange() {
|
1281 | if (!this._renderedRange) {
|
1282 | return;
|
1283 | }
|
1284 | this._renderedItems = this._data.slice(this._renderedRange.start, this._renderedRange.end);
|
1285 | if (!this._differ) {
|
1286 |
|
1287 |
|
1288 | this._differ = this._differs.find(this._renderedItems).create((index, item) => {
|
1289 | return this.cdkVirtualForTrackBy ? this.cdkVirtualForTrackBy(index, item) : item;
|
1290 | });
|
1291 | }
|
1292 | this._needsUpdate = true;
|
1293 | }
|
1294 |
|
1295 | _changeDataSource(oldDs, newDs) {
|
1296 | if (oldDs) {
|
1297 | oldDs.disconnect(this);
|
1298 | }
|
1299 | this._needsUpdate = true;
|
1300 | return newDs ? newDs.connect(this) : of();
|
1301 | }
|
1302 |
|
1303 | _updateContext() {
|
1304 | const count = this._data.length;
|
1305 | let i = this._viewContainerRef.length;
|
1306 | while (i--) {
|
1307 | const view = this._viewContainerRef.get(i);
|
1308 | view.context.index = this._renderedRange.start + i;
|
1309 | view.context.count = count;
|
1310 | this._updateComputedContextProperties(view.context);
|
1311 | view.detectChanges();
|
1312 | }
|
1313 | }
|
1314 |
|
1315 | _applyChanges(changes) {
|
1316 | this._viewRepeater.applyChanges(changes, this._viewContainerRef, (record, _adjustedPreviousIndex, currentIndex) => this._getEmbeddedViewArgs(record, currentIndex), record => record.item);
|
1317 |
|
1318 | changes.forEachIdentityChange((record) => {
|
1319 | const view = this._viewContainerRef.get(record.currentIndex);
|
1320 | view.context.$implicit = record.item;
|
1321 | });
|
1322 |
|
1323 | const count = this._data.length;
|
1324 | let i = this._viewContainerRef.length;
|
1325 | while (i--) {
|
1326 | const view = this._viewContainerRef.get(i);
|
1327 | view.context.index = this._renderedRange.start + i;
|
1328 | view.context.count = count;
|
1329 | this._updateComputedContextProperties(view.context);
|
1330 | }
|
1331 | }
|
1332 |
|
1333 | _updateComputedContextProperties(context) {
|
1334 | context.first = context.index === 0;
|
1335 | context.last = context.index === context.count - 1;
|
1336 | context.even = context.index % 2 === 0;
|
1337 | context.odd = !context.even;
|
1338 | }
|
1339 | _getEmbeddedViewArgs(record, index) {
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 | return {
|
1345 | templateRef: this._template,
|
1346 | context: {
|
1347 | $implicit: record.item,
|
1348 |
|
1349 |
|
1350 | cdkVirtualForOf: this._cdkVirtualForOf,
|
1351 | index: -1,
|
1352 | count: -1,
|
1353 | first: false,
|
1354 | last: false,
|
1355 | odd: false,
|
1356 | even: false,
|
1357 | },
|
1358 | index,
|
1359 | };
|
1360 | }
|
1361 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualForOf, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: i0.IterableDiffers }, { token: _VIEW_REPEATER_STRATEGY }, { token: CdkVirtualScrollViewport, skipSelf: true }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
|
1362 | static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualForOf, isStandalone: true, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: { cdkVirtualForOf: "cdkVirtualForOf", cdkVirtualForTrackBy: "cdkVirtualForTrackBy", cdkVirtualForTemplate: "cdkVirtualForTemplate", cdkVirtualForTemplateCacheSize: "cdkVirtualForTemplateCacheSize" }, providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }], ngImport: i0 }); }
|
1363 | }
|
1364 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualForOf, decorators: [{
|
1365 | type: Directive,
|
1366 | args: [{
|
1367 | selector: '[cdkVirtualFor][cdkVirtualForOf]',
|
1368 | providers: [{ provide: _VIEW_REPEATER_STRATEGY, useClass: _RecycleViewRepeaterStrategy }],
|
1369 | standalone: true,
|
1370 | }]
|
1371 | }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i0.IterableDiffers }, { type: i2$1._RecycleViewRepeaterStrategy, decorators: [{
|
1372 | type: Inject,
|
1373 | args: [_VIEW_REPEATER_STRATEGY]
|
1374 | }] }, { type: CdkVirtualScrollViewport, decorators: [{
|
1375 | type: SkipSelf
|
1376 | }] }, { type: i0.NgZone }]; }, propDecorators: { cdkVirtualForOf: [{
|
1377 | type: Input
|
1378 | }], cdkVirtualForTrackBy: [{
|
1379 | type: Input
|
1380 | }], cdkVirtualForTemplate: [{
|
1381 | type: Input
|
1382 | }], cdkVirtualForTemplateCacheSize: [{
|
1383 | type: Input
|
1384 | }] } });
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 | class CdkVirtualScrollableElement extends CdkVirtualScrollable {
|
1390 | constructor(elementRef, scrollDispatcher, ngZone, dir) {
|
1391 | super(elementRef, scrollDispatcher, ngZone, dir);
|
1392 | }
|
1393 | measureBoundingClientRectWithScrollOffset(from) {
|
1394 | return (this.getElementRef().nativeElement.getBoundingClientRect()[from] -
|
1395 | this.measureScrollOffset(from));
|
1396 | }
|
1397 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableElement, deps: [{ token: i0.ElementRef }, { token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
1398 | static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollableElement, isStandalone: true, selector: "[cdkVirtualScrollingElement]", host: { classAttribute: "cdk-virtual-scrollable" }, providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableElement }], usesInheritance: true, ngImport: i0 }); }
|
1399 | }
|
1400 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableElement, decorators: [{
|
1401 | type: Directive,
|
1402 | args: [{
|
1403 | selector: '[cdkVirtualScrollingElement]',
|
1404 | providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableElement }],
|
1405 | standalone: true,
|
1406 | host: {
|
1407 | 'class': 'cdk-virtual-scrollable',
|
1408 | },
|
1409 | }]
|
1410 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
|
1411 | type: Optional
|
1412 | }] }]; } });
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 | class CdkVirtualScrollableWindow extends CdkVirtualScrollable {
|
1418 | constructor(scrollDispatcher, ngZone, dir) {
|
1419 | super(new ElementRef(document.documentElement), scrollDispatcher, ngZone, dir);
|
1420 | this._elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(document, 'scroll').pipe(takeUntil(this._destroyed)).subscribe(observer)));
|
1421 | }
|
1422 | measureBoundingClientRectWithScrollOffset(from) {
|
1423 | return this.getElementRef().nativeElement.getBoundingClientRect()[from];
|
1424 | }
|
1425 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableWindow, deps: [{ token: ScrollDispatcher }, { token: i0.NgZone }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
1426 | static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: CdkVirtualScrollableWindow, isStandalone: true, selector: "cdk-virtual-scroll-viewport[scrollWindow]", providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableWindow }], usesInheritance: true, ngImport: i0 }); }
|
1427 | }
|
1428 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkVirtualScrollableWindow, decorators: [{
|
1429 | type: Directive,
|
1430 | args: [{
|
1431 | selector: 'cdk-virtual-scroll-viewport[scrollWindow]',
|
1432 | providers: [{ provide: VIRTUAL_SCROLLABLE, useExisting: CdkVirtualScrollableWindow }],
|
1433 | standalone: true,
|
1434 | }]
|
1435 | }], ctorParameters: function () { return [{ type: ScrollDispatcher }, { type: i0.NgZone }, { type: i2.Directionality, decorators: [{
|
1436 | type: Optional
|
1437 | }] }]; } });
|
1438 |
|
1439 | class CdkScrollableModule {
|
1440 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
1441 | static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule, imports: [CdkScrollable], exports: [CdkScrollable] }); }
|
1442 | static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule }); }
|
1443 | }
|
1444 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: CdkScrollableModule, decorators: [{
|
1445 | type: NgModule,
|
1446 | args: [{
|
1447 | exports: [CdkScrollable],
|
1448 | imports: [CdkScrollable],
|
1449 | }]
|
1450 | }] });
|
1451 |
|
1452 |
|
1453 |
|
1454 | class ScrollingModule {
|
1455 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
1456 | static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, imports: [BidiModule, CdkScrollableModule, CdkVirtualScrollViewport,
|
1457 | CdkFixedSizeVirtualScroll,
|
1458 | CdkVirtualForOf,
|
1459 | CdkVirtualScrollableWindow,
|
1460 | CdkVirtualScrollableElement], exports: [BidiModule, CdkScrollableModule, CdkFixedSizeVirtualScroll,
|
1461 | CdkVirtualForOf,
|
1462 | CdkVirtualScrollViewport,
|
1463 | CdkVirtualScrollableWindow,
|
1464 | CdkVirtualScrollableElement] }); }
|
1465 | static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, imports: [BidiModule,
|
1466 | CdkScrollableModule, BidiModule, CdkScrollableModule] }); }
|
1467 | }
|
1468 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: ScrollingModule, decorators: [{
|
1469 | type: NgModule,
|
1470 | args: [{
|
1471 | imports: [
|
1472 | BidiModule,
|
1473 | CdkScrollableModule,
|
1474 | CdkVirtualScrollViewport,
|
1475 | CdkFixedSizeVirtualScroll,
|
1476 | CdkVirtualForOf,
|
1477 | CdkVirtualScrollableWindow,
|
1478 | CdkVirtualScrollableElement,
|
1479 | ],
|
1480 | exports: [
|
1481 | BidiModule,
|
1482 | CdkScrollableModule,
|
1483 | CdkFixedSizeVirtualScroll,
|
1484 | CdkVirtualForOf,
|
1485 | CdkVirtualScrollViewport,
|
1486 | CdkVirtualScrollableWindow,
|
1487 | CdkVirtualScrollableElement,
|
1488 | ],
|
1489 | }]
|
1490 | }] });
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 | export { CdkFixedSizeVirtualScroll, CdkScrollable, CdkScrollableModule, CdkVirtualForOf, CdkVirtualScrollViewport, CdkVirtualScrollable, CdkVirtualScrollableElement, CdkVirtualScrollableWindow, DEFAULT_RESIZE_TIME, DEFAULT_SCROLL_TIME, FixedSizeVirtualScrollStrategy, ScrollDispatcher, ScrollingModule, VIRTUAL_SCROLLABLE, VIRTUAL_SCROLL_STRATEGY, ViewportRuler, _fixedSizeVirtualScrollStrategyFactory };
|
1497 |
|