@annalib/anna-core 7.2.4 → 7.2.6
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/annalib-anna-core.d.ts +5 -0
- package/esm2020/annalib-anna-core.mjs +5 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.mjs +35 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.mjs +22 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.mjs +21 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/constants/shared.constant.mjs +35 -0
- package/esm2020/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.mjs +282 -0
- package/esm2020/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.mjs +27 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-generic-data-type.model.mjs +2 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.mjs +2 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-manage-users.model.mjs +8 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-non-editable-gt-models.mjs +2 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-sort.model.mjs +7 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-tooltip.model.mjs +30 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.mjs +26 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.mjs +46 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.mjs +25 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.mjs +16 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-date-time-format.service.mjs +199 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-filter.service.mjs +469 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-generic-table.service.mjs +124 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-global-config.service.mjs +133 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-number-format.service.mjs +41 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-sort.service.mjs +147 -0
- package/esm2020/lib/anna-core.module.mjs +180 -0
- package/esm2020/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.mjs +101 -0
- package/esm2020/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.mjs +364 -0
- package/esm2020/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.mjs +1834 -0
- package/esm2020/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.mjs +69 -0
- package/esm2020/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.mjs +357 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.mjs +189 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.mjs +2 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.mjs +178 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/index.mjs +2 -0
- package/esm2020/public-api.mjs +50 -0
- package/fesm2015/annalib-anna-core.mjs +4875 -0
- package/fesm2015/annalib-anna-core.mjs.map +1 -0
- package/fesm2020/annalib-anna-core.mjs +4868 -0
- package/fesm2020/annalib-anna-core.mjs.map +1 -0
- package/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.d.ts +16 -0
- package/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.d.ts +11 -0
- package/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.d.ts +11 -0
- package/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/constants/shared.constant.d.ts +33 -0
- package/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.d.ts +34 -0
- package/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.d.ts +9 -0
- package/lib/anna-core-shared-lib/models/anna-generic-data-type.model.d.ts +16 -0
- package/{src/lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.ts → lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.d.ts} +9 -21
- package/lib/anna-core-shared-lib/models/anna-manage-users.model.d.ts +6 -0
- package/{src/lib/anna-core-shared-lib/models/anna-non-editable-gt-models.ts → lib/anna-core-shared-lib/models/anna-non-editable-gt-models.d.ts} +17 -28
- package/lib/anna-core-shared-lib/models/anna-sort.model.d.ts +11 -0
- package/lib/anna-core-shared-lib/models/anna-tooltip.model.d.ts +25 -0
- package/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.d.ts +9 -0
- package/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.d.ts +9 -0
- package/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.d.ts +9 -0
- package/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.d.ts +7 -0
- package/lib/anna-core-shared-lib/services/anna-date-time-format.service.d.ts +27 -0
- package/lib/anna-core-shared-lib/services/anna-filter.service.d.ts +74 -0
- package/lib/anna-core-shared-lib/services/anna-generic-table.service.d.ts +28 -0
- package/lib/anna-core-shared-lib/services/anna-global-config.service.d.ts +21 -0
- package/lib/anna-core-shared-lib/services/anna-number-format.service.d.ts +7 -0
- package/lib/anna-core-shared-lib/services/anna-sort.service.d.ts +16 -0
- package/lib/anna-core.module.d.ts +36 -0
- package/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.d.ts +34 -0
- package/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.d.ts +70 -0
- package/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.d.ts +283 -0
- package/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.d.ts +17 -0
- package/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.d.ts +141 -0
- package/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.d.ts +89 -0
- package/{src/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.ts → lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.d.ts} +0 -0
- package/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.d.ts +45 -0
- package/{src/lib/anna-generic-table-lib/directives/anna-virtual-table/index.ts → lib/anna-generic-table-lib/directives/anna-virtual-table/index.d.ts} +0 -0
- package/package.json +39 -19
- package/{src/public-api.ts → public-api.d.ts} +0 -28
- package/.browserslistrc +0 -16
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -14
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.html +0 -22
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.html +0 -33
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.ts +0 -28
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.html +0 -20
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.html +0 -3
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.scss +0 -17
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.spec.ts +0 -24
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.ts +0 -20
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.html +0 -23
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.html +0 -15
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.ts +0 -19
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.html +0 -14
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/constants/shared.constant.ts +0 -35
- package/src/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.ts +0 -307
- package/src/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.ts +0 -19
- package/src/lib/anna-core-shared-lib/models/anna-generic-data-type.model.ts +0 -19
- package/src/lib/anna-core-shared-lib/models/anna-manage-users.model.ts +0 -6
- package/src/lib/anna-core-shared-lib/models/anna-sort.model.ts +0 -13
- package/src/lib/anna-core-shared-lib/models/anna-tooltip.model.ts +0 -44
- package/src/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.ts +0 -20
- package/src/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.ts +0 -43
- package/src/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.ts +0 -19
- package/src/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.ts +0 -12
- package/src/lib/anna-core-shared-lib/services/anna-date-time-format.service.ts +0 -219
- package/src/lib/anna-core-shared-lib/services/anna-filter.service.ts +0 -563
- package/src/lib/anna-core-shared-lib/services/anna-generic-table.service.ts +0 -136
- package/src/lib/anna-core-shared-lib/services/anna-global-config.service.ts +0 -170
- package/src/lib/anna-core-shared-lib/services/anna-number-format.service.ts +0 -43
- package/src/lib/anna-core-shared-lib/services/anna-sort.service.ts +0 -179
- package/src/lib/anna-core.module.ts +0 -112
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.html +0 -46
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.scss +0 -153
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.spec.ts +0 -24
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.ts +0 -106
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.html +0 -129
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.scss +0 -275
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.spec.ts +0 -24
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.ts +0 -414
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.html +0 -1080
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.scss +0 -668
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.spec.ts +0 -25
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.ts +0 -2186
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.html +0 -10
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.scss +0 -1
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.spec.ts +0 -24
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.ts +0 -69
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.html +0 -13
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.scss +0 -88
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.spec.ts +0 -25
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.ts +0 -460
- package/src/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.ts +0 -237
- package/src/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.ts +0 -204
- package/src/test.ts +0 -27
- package/tsconfig.lib.json +0 -19
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { coerceNumberProperty, NumberInput } from "@angular/cdk/coercion";
|
|
2
|
-
import {
|
|
3
|
-
CdkVirtualScrollViewport,
|
|
4
|
-
VirtualScrollStrategy,
|
|
5
|
-
VIRTUAL_SCROLL_STRATEGY
|
|
6
|
-
} from "@angular/cdk/scrolling";
|
|
7
|
-
import { AfterContentInit, ContentChildren, Directive, forwardRef, Input, QueryList, SimpleChanges } from "@angular/core";
|
|
8
|
-
import { MatHeaderRowDef } from "@angular/material/table";
|
|
9
|
-
import { Subject } from "rxjs";
|
|
10
|
-
import { distinctUntilChanged } from "rxjs/operators";
|
|
11
|
-
import { AnnaFilterService } from '../../../anna-core-shared-lib/services/anna-filter.service';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A custom scroll strategy that accepts a static row height, static header height,
|
|
16
|
-
* and a buffer size. The strategy
|
|
17
|
-
*/
|
|
18
|
-
export class AnnaFixedRowSizeTableVirtualScrollStrategy
|
|
19
|
-
implements VirtualScrollStrategy {
|
|
20
|
-
|
|
21
|
-
viewport: CdkVirtualScrollViewport | null;
|
|
22
|
-
|
|
23
|
-
private buffer: number;
|
|
24
|
-
|
|
25
|
-
private headerHeight: number;
|
|
26
|
-
|
|
27
|
-
private rowHeight: number;
|
|
28
|
-
|
|
29
|
-
constructor(rowHeight: number, buffer: number, headerHeight: number) {
|
|
30
|
-
this.updateRowHeightAndBuffer(rowHeight, buffer, headerHeight);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private _scrolledIndexChange = new Subject<number>();
|
|
34
|
-
|
|
35
|
-
scrolledIndexChange = this._scrolledIndexChange.pipe(distinctUntilChanged());
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Attaches this scroll strategy to a viewport.
|
|
39
|
-
* @param viewport The viewport to attach this strategy to.
|
|
40
|
-
*/
|
|
41
|
-
attach(viewport: CdkVirtualScrollViewport): void {
|
|
42
|
-
this.viewport = viewport;
|
|
43
|
-
this.updateTotalContentSize();
|
|
44
|
-
this.updateRenderedRange();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Detaches this scroll strategy from the currently attached viewport.
|
|
49
|
-
*/
|
|
50
|
-
detach(): void {
|
|
51
|
-
this._scrolledIndexChange.complete();
|
|
52
|
-
this.viewport = null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
onContentScrolled(): void {
|
|
56
|
-
this.updateRenderedRange();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
onDataLengthChanged(): void {
|
|
60
|
-
this.updateTotalContentSize();
|
|
61
|
-
this.updateRenderedRange();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
onContentRendered(): void {
|
|
65
|
-
// This method is useful for virtual scroll strategies that measure the rendered
|
|
66
|
-
// content to determine its height. This scroll strategy assumes that rows have
|
|
67
|
-
// a static height, so there's no need to implement this method.
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
onRenderedOffsetChanged(): void {
|
|
71
|
-
// Similar to onContentRendered, this method is useful for virtual scroll strategies
|
|
72
|
-
// that need to track the offset as it changes. This scroll strategy is always able
|
|
73
|
-
// to calculate the correct offset from other values, so there's no need to implement
|
|
74
|
-
// this method.
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
scrollToIndex(index: number, behavior: ScrollBehavior): void {
|
|
78
|
-
this.viewport?.scrollToOffset(index * this.rowHeight, behavior);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Update the item size and buffer size.
|
|
83
|
-
* @param rowHeight The height of a row in the virtually scrolling table.
|
|
84
|
-
* @param buffer The number of rows to buffer outside the viewport.
|
|
85
|
-
* @param headerHeight The total height of the table header, including all header rows.
|
|
86
|
-
*/
|
|
87
|
-
updateRowHeightAndBuffer(rowHeight: number, buffer: number, headerHeight: number) {
|
|
88
|
-
this.rowHeight = rowHeight;
|
|
89
|
-
this.buffer = buffer;
|
|
90
|
-
this.headerHeight = headerHeight;
|
|
91
|
-
this.updateTotalContentSize();
|
|
92
|
-
this.updateRenderedRange();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
protected updateRenderedRange() {
|
|
96
|
-
if (!this.viewport) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const viewportSize = this.viewport.getViewportSize();
|
|
101
|
-
const dataLength = this.viewport.getDataLength();
|
|
102
|
-
const scrollOffset = this.viewport.measureScrollOffset();
|
|
103
|
-
|
|
104
|
-
// the index of the first item that would be at least partially visible in the viewport
|
|
105
|
-
let firstVisibleIndex = Math.floor((scrollOffset + this.headerHeight) / this.rowHeight);
|
|
106
|
-
|
|
107
|
-
// if the buffer size is 10 but the first visible item is at, say, index 7
|
|
108
|
-
// then the buffered items must be 7, because we don't have 10 items available to buffer.
|
|
109
|
-
const bufferedItems = Math.min(AnnaFilterService.bufferSize, firstVisibleIndex);
|
|
110
|
-
|
|
111
|
-
const itemsInViewport = Math.ceil(viewportSize / this.rowHeight);
|
|
112
|
-
const itemsToRender = itemsInViewport + this.buffer;
|
|
113
|
-
|
|
114
|
-
// Clamp the new range between 0 and dataLength
|
|
115
|
-
const newStart = Math.max(0, firstVisibleIndex - bufferedItems);
|
|
116
|
-
const newEnd = Math.min(dataLength, firstVisibleIndex + itemsToRender);
|
|
117
|
-
|
|
118
|
-
const newRange = {
|
|
119
|
-
start: newStart,
|
|
120
|
-
end: newEnd
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const newOffset = this.rowHeight * (firstVisibleIndex - bufferedItems);
|
|
124
|
-
this.viewport.setRenderedContentOffset(newOffset);
|
|
125
|
-
this.viewport.setRenderedRange(newRange);
|
|
126
|
-
this._scrolledIndexChange.next(Math.floor(firstVisibleIndex));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
protected updateTotalContentSize() {
|
|
130
|
-
this.viewport?.setTotalContentSize(this.viewport.getDataLength() * this.rowHeight);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
|
|
136
|
-
* `FixedSizeVirtualScrollStrategy` from the given directive.
|
|
137
|
-
* @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the
|
|
138
|
-
* `FixedSizeVirtualScrollStrategy` from.
|
|
139
|
-
*/
|
|
140
|
-
export function fixedSizeVirtualScrollStrategyFactory(
|
|
141
|
-
fixedSizeDir: AnnaFixedRowSizeTableVirtualScrollStrategyDirective
|
|
142
|
-
) {
|
|
143
|
-
return fixedSizeDir.scrollStrategy;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@Directive({
|
|
147
|
-
selector: "cdk-virtual-scroll-viewport[rowHeight], anna-table-virtual-scroll-viewport[rowHeight]",
|
|
148
|
-
providers: [
|
|
149
|
-
{
|
|
150
|
-
provide: VIRTUAL_SCROLL_STRATEGY,
|
|
151
|
-
useFactory: fixedSizeVirtualScrollStrategyFactory,
|
|
152
|
-
deps: [forwardRef(() => AnnaFixedRowSizeTableVirtualScrollStrategyDirective)]
|
|
153
|
-
}
|
|
154
|
-
]
|
|
155
|
-
})
|
|
156
|
-
export class AnnaFixedRowSizeTableVirtualScrollStrategyDirective implements AfterContentInit {
|
|
157
|
-
/** The height of rows in the table (in pixels). Defaults to 30. */
|
|
158
|
-
@Input()
|
|
159
|
-
set rowHeight(value: number) { this._rowHeight = coerceNumberProperty(value); }
|
|
160
|
-
get rowHeight(): number { return this._rowHeight; }
|
|
161
|
-
private _rowHeight = 30;
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* The height of header rows in the table (in pixels). Defaults to 30.
|
|
165
|
-
*/
|
|
166
|
-
@Input()
|
|
167
|
-
set headerRowHeight(value: number) { this._headerRowHeight = coerceNumberProperty(value); }
|
|
168
|
-
get headerRowHeight(): number { return this._headerRowHeight; }
|
|
169
|
-
private _headerRowHeight: number = 30;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* The number of buffered rows rendered beyond the viewport.
|
|
173
|
-
* If the number of buffered rows dips below this number, more rows will be rendered. Defaults to 20.
|
|
174
|
-
*/
|
|
175
|
-
@Input()
|
|
176
|
-
set buffer(value: number) {
|
|
177
|
-
this._buffer = coerceNumberProperty(value);}
|
|
178
|
-
get buffer(): number { return this._buffer; }
|
|
179
|
-
private _buffer = 20;
|
|
180
|
-
|
|
181
|
-
@Input()
|
|
182
|
-
set headerRows(value: number | null | undefined) { this._headerRows = coerceNumberProperty(value, undefined); }
|
|
183
|
-
get headerRows(): number | null | undefined { return this._headerRows; }
|
|
184
|
-
private _headerRows: number | null | undefined = null;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Using ContentChildren here fails to pick up row defs that are added programmatically,
|
|
188
|
-
* but we don't really have a way of handling that without accessing private methods of
|
|
189
|
-
* the CdkTable. Adding header row defs programmatically is uncommon, so ContentChildren
|
|
190
|
-
* is usually sufficient. The explicit `headerRows` input above allows the number of rows
|
|
191
|
-
* to be set by the developer to override the QueryList-driven behavior.
|
|
192
|
-
*/
|
|
193
|
-
@ContentChildren(MatHeaderRowDef) headerRowsQuery: QueryList<MatHeaderRowDef>;
|
|
194
|
-
|
|
195
|
-
private headerRowCount: number = 1;
|
|
196
|
-
|
|
197
|
-
/** The scroll strategy used by this directive. */
|
|
198
|
-
scrollStrategy = new AnnaFixedRowSizeTableVirtualScrollStrategy(
|
|
199
|
-
this.rowHeight,
|
|
200
|
-
this.buffer,
|
|
201
|
-
this.headerRowHeight * this.headerRowCount
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
ngOnChanges(change: SimpleChanges) {
|
|
205
|
-
if (this.headerRows != undefined || this.headerRowsQuery) {
|
|
206
|
-
this.handleChange();
|
|
207
|
-
}
|
|
208
|
-
if(change['buffer']?.previousValue != change['buffer']?.currentValue){
|
|
209
|
-
AnnaFilterService.bufferSize = this.buffer;
|
|
210
|
-
this.scrollStrategy = new AnnaFixedRowSizeTableVirtualScrollStrategy(
|
|
211
|
-
this.rowHeight,
|
|
212
|
-
this.buffer,
|
|
213
|
-
this.headerRowHeight * this.headerRowCount
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
ngAfterContentInit(): void {
|
|
219
|
-
this.headerRowsQuery.changes.subscribe(() => {
|
|
220
|
-
this.handleChange();
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
private handleChange(): void {
|
|
225
|
-
this.scrollStrategy.updateRowHeightAndBuffer(
|
|
226
|
-
this.rowHeight,
|
|
227
|
-
this.buffer,
|
|
228
|
-
// Use the explicit headerRows input value if set.
|
|
229
|
-
// Otherwise, fall back to the QueryList length.
|
|
230
|
-
this.headerRowHeight * (this._headerRows ?? this.headerRowsQuery.length)
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
static ngAcceptInputType_rowHeight: NumberInput;
|
|
235
|
-
static ngAcceptInputType_buffer: NumberInput;
|
|
236
|
-
static ngAcceptInputType_headerRowHeight: NumberInput;
|
|
237
|
-
}
|
package/src/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.ts
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { ArrayDataSource, CollectionViewer, isDataSource, ListRange } from "@angular/cdk/collections";
|
|
2
|
-
import { CdkVirtualScrollRepeater, CdkVirtualScrollViewport } from "@angular/cdk/scrolling";
|
|
3
|
-
import { CdkHeaderRowDef, CdkTable, DataSource, STICKY_POSITIONING_LISTENER, _CoalescedStyleScheduler, _COALESCED_STYLE_SCHEDULER } from "@angular/cdk/table";
|
|
4
|
-
import { ContentChildren, Directive, ElementRef, Inject, Input, NgIterable, NgZone, QueryList } from "@angular/core";
|
|
5
|
-
import { isObservable, Observable, of, Subject } from "rxjs";
|
|
6
|
-
import { map, pairwise, shareReplay, startWith, switchMap, takeUntil } from "rxjs/operators";
|
|
7
|
-
import { AnnaTableVirtualScrollViewportComponent } from '../../components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Directive that wraps a given data source in a "virtual" data source that emits
|
|
11
|
-
* the slice of the original data source that matches the range that should be rendered
|
|
12
|
-
* in the containing virtual scroll viewport.
|
|
13
|
-
*/
|
|
14
|
-
@Directive({
|
|
15
|
-
selector: '[mat-table][appVirtualDataSource], mat-table[appVirtualDataSource]',
|
|
16
|
-
providers: [{ provide: STICKY_POSITIONING_LISTENER, useExisting: AnnaVirtualTableDirective }]
|
|
17
|
-
})
|
|
18
|
-
export class AnnaVirtualTableDirective<T> implements CdkVirtualScrollRepeater<T>, CollectionViewer {
|
|
19
|
-
@Input('appVirtualDataSource')
|
|
20
|
-
set dataSource(value: DataSource<T> | Observable<T[]> | NgIterable<T> | null | undefined) {
|
|
21
|
-
this._dataSource = value;
|
|
22
|
-
if (isDataSource(value)) {
|
|
23
|
-
this.dataSourceChanges.next(value);
|
|
24
|
-
} else {
|
|
25
|
-
this.dataSourceChanges.next(new ArrayDataSource<T>(isObservable(value) ? value : Array.from(value || [])));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
get dataSource(): DataSource<T> | Observable<T[]> | NgIterable<T> | null | undefined {
|
|
29
|
-
return this._dataSource;
|
|
30
|
-
}
|
|
31
|
-
private _dataSource: DataSource<T> | Observable<T[]> | NgIterable<T> | null | undefined;
|
|
32
|
-
|
|
33
|
-
@ContentChildren(CdkHeaderRowDef) headerRowDefs: QueryList<CdkHeaderRowDef>;
|
|
34
|
-
|
|
35
|
-
private virtualizedDataStream = new Subject<T[] | ReadonlyArray<T>>();
|
|
36
|
-
|
|
37
|
-
private dataSourceChanges = new Subject<DataSource<T>>();
|
|
38
|
-
|
|
39
|
-
/** The raw, unvirtualized data stream. Emits whenever the data in the current DataSource changes. */
|
|
40
|
-
dataStream: Observable<T[] | ReadonlyArray<T>> = this.dataSourceChanges
|
|
41
|
-
.pipe(
|
|
42
|
-
// Start off with null data source.
|
|
43
|
-
startWith(null),
|
|
44
|
-
// Bundle up the previous and current data sources so we can work with both.
|
|
45
|
-
pairwise(),
|
|
46
|
-
// Use `changeDataSource` to disconnect from the previous data source and connect to the
|
|
47
|
-
// new one, passing back a stream of data changes which we run through `switchMap` to give
|
|
48
|
-
// us a data stream that emits the latest data from whatever the current data source is.
|
|
49
|
-
switchMap(([prev, cur]) => this.changeDataSource(prev, cur)),
|
|
50
|
-
// Replay the last emitted data when someone subscribes.
|
|
51
|
-
shareReplay(1));
|
|
52
|
-
|
|
53
|
-
viewChange = new Subject<ListRange>();
|
|
54
|
-
|
|
55
|
-
private data: T[] | readonly T[];
|
|
56
|
-
|
|
57
|
-
private destroyed$ = new Subject<void>();
|
|
58
|
-
|
|
59
|
-
private renderedItems: T[] | ReadonlyArray<T>;
|
|
60
|
-
|
|
61
|
-
private renderedRange: ListRange = { start: 0, end: 0 };
|
|
62
|
-
|
|
63
|
-
private isNativeHtmlTable: boolean = false;
|
|
64
|
-
|
|
65
|
-
constructor(
|
|
66
|
-
elementRef: ElementRef<HTMLElement>,
|
|
67
|
-
private viewport: CdkVirtualScrollViewport,
|
|
68
|
-
private table: CdkTable<T>,
|
|
69
|
-
ngZone: NgZone,
|
|
70
|
-
@Inject(_COALESCED_STYLE_SCHEDULER) private _coalescedStyleScheduler: _CoalescedStyleScheduler,
|
|
71
|
-
) {
|
|
72
|
-
table.dataSource = this.virtualizedDataStream;
|
|
73
|
-
this.isNativeHtmlTable = elementRef.nativeElement.tagName === 'TABLE';
|
|
74
|
-
this.dataStream.subscribe(data => {
|
|
75
|
-
this.data = data;
|
|
76
|
-
this.onRenderedDataChange();
|
|
77
|
-
});
|
|
78
|
-
viewport.renderedRangeStream.pipe(takeUntil(this.destroyed$)).subscribe((range: ListRange) => {
|
|
79
|
-
this.renderedRange = range;
|
|
80
|
-
ngZone.run(() => this.viewChange.next(range));
|
|
81
|
-
this.onRenderedDataChange();
|
|
82
|
-
});
|
|
83
|
-
viewport.attach(this);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
ngOnInit(): void {
|
|
87
|
-
// This is just a proof of concept, but the AnnaTableVirtualScrollViewportComponent uses `position: absolute` and `top: #px` instead of `transform: translateY(#px)` to position the viewport.
|
|
88
|
-
// This removes the need to account for the translation in the `top` of the sticky header rows.
|
|
89
|
-
if (this.viewport instanceof AnnaTableVirtualScrollViewportComponent) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
this.viewport.scrolledIndexChange
|
|
94
|
-
.pipe(
|
|
95
|
-
map(() => this.viewport.getOffsetToRenderedContentStart()),
|
|
96
|
-
takeUntil(this.destroyed$)
|
|
97
|
-
)
|
|
98
|
-
.subscribe((offset) => {
|
|
99
|
-
// We need to set the `style.top` property of the sticky header rows
|
|
100
|
-
// to the negative value of the virtual scroll viewport's offset, so
|
|
101
|
-
// make the offset negative.
|
|
102
|
-
offset = -offset;
|
|
103
|
-
|
|
104
|
-
const stickyStates: boolean[] = this.headerRowDefs.map(rowDef => rowDef.sticky);
|
|
105
|
-
|
|
106
|
-
// This logic is exactly the same as what's in the StickyStyler (literally copy + paste).
|
|
107
|
-
// The only difference is that the `stickyOffset` variable starts at the virtual scroll
|
|
108
|
-
// viewport container's offset instead of starting at zero.
|
|
109
|
-
const rows = this.table._getRenderedRows(this.table._headerRowOutlet);
|
|
110
|
-
const stickyOffsets: number[] = [];
|
|
111
|
-
const stickyCellHeights: (number|undefined)[] = [];
|
|
112
|
-
const elementsToStick: HTMLElement[][] = [];
|
|
113
|
-
for (let rowIndex = 0, stickyOffset = offset; rowIndex < rows.length; rowIndex++) {
|
|
114
|
-
stickyOffsets[rowIndex] = stickyOffset;
|
|
115
|
-
|
|
116
|
-
if (!stickyStates[rowIndex]) {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const row = rows[rowIndex];
|
|
121
|
-
elementsToStick[rowIndex] = this.isNativeHtmlTable ? Array.from(row.children) as HTMLElement[] : [row];
|
|
122
|
-
|
|
123
|
-
const height = row.getBoundingClientRect().height;
|
|
124
|
-
stickyOffset += height;
|
|
125
|
-
stickyCellHeights[rowIndex] = height;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Using the CoalescedStyleScheduler here is optional. It'll work without it,
|
|
129
|
-
// and CoalescedStyleScheduler is not public (yet?), so feel free to remove it.
|
|
130
|
-
this._coalescedStyleScheduler.schedule(() => {
|
|
131
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
132
|
-
if (!stickyStates[rowIndex]) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
for (const element of elementsToStick[rowIndex]) {
|
|
137
|
-
element.style.top = `${stickyOffsets[rowIndex]}px`;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
ngOnDestroy(): void {
|
|
145
|
-
this.destroyed$.next();
|
|
146
|
-
this.dataSourceChanges.complete();
|
|
147
|
-
this.virtualizedDataStream.complete();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/** React to scroll state changes in the viewport. */
|
|
151
|
-
private onRenderedDataChange() {
|
|
152
|
-
if (!this.renderedRange) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
this.renderedItems = this.data.slice(this.renderedRange.start, this.renderedRange.end + 1);
|
|
156
|
-
// delegate rendering to the table by emitting from the virtualizedDataStream
|
|
157
|
-
this.virtualizedDataStream.next(this.renderedItems);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** Swap out one data source for another. */
|
|
161
|
-
private changeDataSource(oldDataSource: DataSource<T> | null, newDs: DataSource<T> | null):
|
|
162
|
-
Observable<T[] | ReadonlyArray<T>> {
|
|
163
|
-
|
|
164
|
-
oldDataSource?.disconnect(this);
|
|
165
|
-
return newDs ? newDs.connect(this) : of();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* This method is only used by the experimental AutoSizeVirtualScrollStrategy.
|
|
170
|
-
* We're not using that strategy, but I've implemented it just to show how it oculd be done.
|
|
171
|
-
* I'm not actually sure if this works.
|
|
172
|
-
*/
|
|
173
|
-
measureRangeSize(range: ListRange, orientation: 'horizontal' | 'vertical'): number {
|
|
174
|
-
if (orientation === 'horizontal' || range.end < range.start) {
|
|
175
|
-
// virtual scrolling columns are not supported by this directive
|
|
176
|
-
return 0;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const renderedBodyRows = this.table._getRenderedRows(this.table._rowOutlet);
|
|
180
|
-
|
|
181
|
-
const firstRow: HTMLElement | undefined = renderedBodyRows[range.start];
|
|
182
|
-
const lastRow: HTMLElement | undefined = renderedBodyRows[range.end];
|
|
183
|
-
|
|
184
|
-
if (!firstRow || !lastRow) {
|
|
185
|
-
return 0;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// We need to include all header and footer rows in the sum, since they're always rendered
|
|
189
|
-
const renderedHeaderRows = this.table._getRenderedRows(this.table._headerRowOutlet);
|
|
190
|
-
const renderedFooterRows = this.table._getRenderedRows(this.table._footerRowOutlet);
|
|
191
|
-
|
|
192
|
-
// TODO (performance): Can we just measure the offset of the first and last items and do some math to avoid having to measure each row individually?
|
|
193
|
-
const headerHeight = renderedHeaderRows.reduce((sum: number, row: HTMLElement) => {
|
|
194
|
-
return sum += row.getBoundingClientRect().height;
|
|
195
|
-
}, 0);
|
|
196
|
-
const footerHeight = renderedFooterRows.reduce((sum: number, row: HTMLElement) => {
|
|
197
|
-
return sum += row.getBoundingClientRect().height;
|
|
198
|
-
}, 0);
|
|
199
|
-
|
|
200
|
-
const bodyHeight = lastRow.getBoundingClientRect().bottom - firstRow.getBoundingClientRect().top;
|
|
201
|
-
|
|
202
|
-
return headerHeight + footerHeight + bodyHeight;
|
|
203
|
-
}
|
|
204
|
-
}
|
package/src/test.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
-
|
|
3
|
-
import 'zone.js';
|
|
4
|
-
import 'zone.js/testing';
|
|
5
|
-
import { getTestBed } from '@angular/core/testing';
|
|
6
|
-
import {
|
|
7
|
-
BrowserDynamicTestingModule,
|
|
8
|
-
platformBrowserDynamicTesting
|
|
9
|
-
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
-
|
|
11
|
-
declare const require: {
|
|
12
|
-
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
-
<T>(id: string): T;
|
|
14
|
-
keys(): string[];
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// First, initialize the Angular testing environment.
|
|
19
|
-
getTestBed().initTestEnvironment(
|
|
20
|
-
BrowserDynamicTestingModule,
|
|
21
|
-
platformBrowserDynamicTesting(),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
// Then we find all the tests.
|
|
25
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
26
|
-
// And load the modules.
|
|
27
|
-
context.keys().map(context);
|
package/tsconfig.lib.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/lib",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"inlineSources": true,
|
|
9
|
-
"baseUrl": "./",
|
|
10
|
-
"types": [],
|
|
11
|
-
"paths": {
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"exclude": [
|
|
16
|
-
"src/test.ts",
|
|
17
|
-
"**/*.spec.ts"
|
|
18
|
-
]
|
|
19
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/spec",
|
|
6
|
-
"types": [
|
|
7
|
-
"jasmine"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"src/test.ts"
|
|
12
|
-
],
|
|
13
|
-
"include": [
|
|
14
|
-
"**/*.spec.ts",
|
|
15
|
-
"**/*.d.ts"
|
|
16
|
-
]
|
|
17
|
-
}
|