@annalib/anna-core 7.2.4 → 7.2.5

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.
Files changed (156) hide show
  1. package/annalib-anna-core.d.ts +5 -0
  2. package/esm2020/annalib-anna-core.mjs +5 -0
  3. package/esm2020/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.mjs +15 -0
  4. package/esm2020/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.mjs +35 -0
  5. package/esm2020/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.mjs +15 -0
  6. package/esm2020/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.mjs +22 -0
  7. package/esm2020/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.mjs +15 -0
  8. package/esm2020/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.mjs +21 -0
  9. package/esm2020/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.mjs +15 -0
  10. package/esm2020/lib/anna-core-shared-lib/constants/shared.constant.mjs +35 -0
  11. package/esm2020/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.mjs +282 -0
  12. package/esm2020/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.mjs +27 -0
  13. package/esm2020/lib/anna-core-shared-lib/models/anna-generic-data-type.model.mjs +2 -0
  14. package/esm2020/lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.mjs +2 -0
  15. package/esm2020/lib/anna-core-shared-lib/models/anna-manage-users.model.mjs +8 -0
  16. package/esm2020/lib/anna-core-shared-lib/models/anna-non-editable-gt-models.mjs +2 -0
  17. package/esm2020/lib/anna-core-shared-lib/models/anna-sort.model.mjs +7 -0
  18. package/esm2020/lib/anna-core-shared-lib/models/anna-tooltip.model.mjs +30 -0
  19. package/esm2020/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.mjs +26 -0
  20. package/esm2020/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.mjs +46 -0
  21. package/esm2020/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.mjs +25 -0
  22. package/esm2020/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.mjs +16 -0
  23. package/esm2020/lib/anna-core-shared-lib/services/anna-date-time-format.service.mjs +199 -0
  24. package/esm2020/lib/anna-core-shared-lib/services/anna-filter.service.mjs +469 -0
  25. package/esm2020/lib/anna-core-shared-lib/services/anna-generic-table.service.mjs +124 -0
  26. package/esm2020/lib/anna-core-shared-lib/services/anna-global-config.service.mjs +133 -0
  27. package/esm2020/lib/anna-core-shared-lib/services/anna-number-format.service.mjs +41 -0
  28. package/esm2020/lib/anna-core-shared-lib/services/anna-sort.service.mjs +147 -0
  29. package/esm2020/lib/anna-core.module.mjs +180 -0
  30. package/esm2020/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.mjs +101 -0
  31. package/esm2020/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.mjs +364 -0
  32. package/esm2020/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.mjs +1834 -0
  33. package/esm2020/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.mjs +69 -0
  34. package/esm2020/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.mjs +357 -0
  35. 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
  36. package/esm2020/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.mjs +2 -0
  37. package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.mjs +178 -0
  38. package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/index.mjs +2 -0
  39. package/esm2020/public-api.mjs +50 -0
  40. package/fesm2015/annalib-anna-core.mjs +4875 -0
  41. package/fesm2015/annalib-anna-core.mjs.map +1 -0
  42. package/fesm2020/annalib-anna-core.mjs +4868 -0
  43. package/fesm2020/annalib-anna-core.mjs.map +1 -0
  44. package/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.d.ts +8 -0
  45. package/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.d.ts +16 -0
  46. package/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.d.ts +8 -0
  47. package/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.d.ts +11 -0
  48. package/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.d.ts +8 -0
  49. package/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.d.ts +11 -0
  50. package/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.d.ts +8 -0
  51. package/lib/anna-core-shared-lib/constants/shared.constant.d.ts +33 -0
  52. package/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.d.ts +34 -0
  53. package/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.d.ts +9 -0
  54. package/lib/anna-core-shared-lib/models/anna-generic-data-type.model.d.ts +16 -0
  55. 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
  56. package/lib/anna-core-shared-lib/models/anna-manage-users.model.d.ts +6 -0
  57. 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
  58. package/lib/anna-core-shared-lib/models/anna-sort.model.d.ts +11 -0
  59. package/lib/anna-core-shared-lib/models/anna-tooltip.model.d.ts +25 -0
  60. package/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.d.ts +9 -0
  61. package/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.d.ts +9 -0
  62. package/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.d.ts +9 -0
  63. package/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.d.ts +7 -0
  64. package/lib/anna-core-shared-lib/services/anna-date-time-format.service.d.ts +27 -0
  65. package/lib/anna-core-shared-lib/services/anna-filter.service.d.ts +74 -0
  66. package/lib/anna-core-shared-lib/services/anna-generic-table.service.d.ts +28 -0
  67. package/lib/anna-core-shared-lib/services/anna-global-config.service.d.ts +21 -0
  68. package/lib/anna-core-shared-lib/services/anna-number-format.service.d.ts +7 -0
  69. package/lib/anna-core-shared-lib/services/anna-sort.service.d.ts +16 -0
  70. package/lib/anna-core.module.d.ts +36 -0
  71. package/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.d.ts +34 -0
  72. package/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.d.ts +70 -0
  73. package/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.d.ts +283 -0
  74. package/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.d.ts +17 -0
  75. package/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.d.ts +141 -0
  76. 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
  77. 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
  78. package/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.d.ts +45 -0
  79. 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
  80. package/package.json +39 -19
  81. package/{src/public-api.ts → public-api.d.ts} +0 -28
  82. package/.browserslistrc +0 -16
  83. package/karma.conf.js +0 -44
  84. package/ng-package.json +0 -14
  85. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.html +0 -22
  86. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.scss +0 -0
  87. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.spec.ts +0 -25
  88. package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.ts +0 -16
  89. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.html +0 -33
  90. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.scss +0 -0
  91. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.spec.ts +0 -25
  92. package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.ts +0 -28
  93. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.html +0 -20
  94. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.scss +0 -0
  95. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.spec.ts +0 -25
  96. package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.ts +0 -16
  97. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.html +0 -3
  98. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.scss +0 -17
  99. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.spec.ts +0 -24
  100. package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.ts +0 -20
  101. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.html +0 -23
  102. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.scss +0 -0
  103. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.spec.ts +0 -25
  104. package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.ts +0 -16
  105. package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.html +0 -15
  106. package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.scss +0 -0
  107. 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
  108. package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.ts +0 -19
  109. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.html +0 -14
  110. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.scss +0 -0
  111. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.spec.ts +0 -25
  112. package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.ts +0 -16
  113. package/src/lib/anna-core-shared-lib/constants/shared.constant.ts +0 -35
  114. package/src/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.ts +0 -307
  115. package/src/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.ts +0 -19
  116. package/src/lib/anna-core-shared-lib/models/anna-generic-data-type.model.ts +0 -19
  117. package/src/lib/anna-core-shared-lib/models/anna-manage-users.model.ts +0 -6
  118. package/src/lib/anna-core-shared-lib/models/anna-sort.model.ts +0 -13
  119. package/src/lib/anna-core-shared-lib/models/anna-tooltip.model.ts +0 -44
  120. package/src/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.ts +0 -20
  121. package/src/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.ts +0 -43
  122. package/src/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.ts +0 -19
  123. package/src/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.ts +0 -12
  124. package/src/lib/anna-core-shared-lib/services/anna-date-time-format.service.ts +0 -219
  125. package/src/lib/anna-core-shared-lib/services/anna-filter.service.ts +0 -563
  126. package/src/lib/anna-core-shared-lib/services/anna-generic-table.service.ts +0 -136
  127. package/src/lib/anna-core-shared-lib/services/anna-global-config.service.ts +0 -170
  128. package/src/lib/anna-core-shared-lib/services/anna-number-format.service.ts +0 -43
  129. package/src/lib/anna-core-shared-lib/services/anna-sort.service.ts +0 -179
  130. package/src/lib/anna-core.module.ts +0 -112
  131. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.html +0 -46
  132. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.scss +0 -153
  133. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.spec.ts +0 -24
  134. package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.ts +0 -106
  135. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.html +0 -129
  136. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.scss +0 -275
  137. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.spec.ts +0 -24
  138. package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.ts +0 -414
  139. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.html +0 -1080
  140. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.scss +0 -668
  141. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.spec.ts +0 -25
  142. package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.ts +0 -2186
  143. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.html +0 -10
  144. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.scss +0 -1
  145. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.spec.ts +0 -24
  146. package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.ts +0 -69
  147. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.html +0 -13
  148. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.scss +0 -88
  149. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.spec.ts +0 -25
  150. package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.ts +0 -460
  151. 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
  152. package/src/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.ts +0 -204
  153. package/src/test.ts +0 -27
  154. package/tsconfig.lib.json +0 -19
  155. package/tsconfig.lib.prod.json +0 -10
  156. 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
- }
@@ -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
- }
@@ -1,10 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "./tsconfig.lib.json",
4
- "compilerOptions": {
5
- "declarationMap": false
6
- },
7
- "angularCompilerOptions": {
8
- "compilationMode": "partial"
9
- }
10
- }
@@ -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
- }