@progress/kendo-angular-grid 19.3.1-develop.3 → 20.0.0-develop.1

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 (42) hide show
  1. package/codemods/template-transformer/index.js +94 -0
  2. package/codemods/utils.js +553 -0
  3. package/codemods/v20/grid-kendogridgroupbinding.js +51 -0
  4. package/common/provider.service.d.ts +3 -2
  5. package/databinding.directive.d.ts +0 -3
  6. package/directives.d.ts +3 -4
  7. package/esm2022/common/error-messages.mjs +0 -6
  8. package/esm2022/common/provider.service.mjs +1 -0
  9. package/esm2022/data/data.iterators.mjs +0 -7
  10. package/esm2022/databinding.directive.mjs +4 -4
  11. package/esm2022/directives.mjs +0 -3
  12. package/esm2022/grid.component.mjs +63 -31
  13. package/esm2022/grid.module.mjs +15 -16
  14. package/esm2022/grouping/group-header.component.mjs +6 -3
  15. package/esm2022/index.mjs +0 -1
  16. package/esm2022/navigation/navigation-metadata.mjs +4 -2
  17. package/esm2022/navigation/navigation.service.mjs +4 -2
  18. package/esm2022/package-metadata.mjs +2 -2
  19. package/esm2022/pdf/pdf.component.mjs +16 -0
  20. package/esm2022/pdf/pdf.service.mjs +1 -0
  21. package/esm2022/rendering/list.component.mjs +188 -92
  22. package/esm2022/rendering/table-body.component.mjs +19 -5
  23. package/esm2022/scrolling/row-height.service.mjs +23 -65
  24. package/esm2022/scrolling/scroller.service.mjs +175 -35
  25. package/fesm2022/progress-kendo-angular-grid.mjs +508 -588
  26. package/grid.component.d.ts +6 -6
  27. package/grid.module.d.ts +14 -15
  28. package/grouping/group-header.component.d.ts +1 -1
  29. package/index.d.ts +0 -2
  30. package/navigation/navigation-metadata.d.ts +2 -1
  31. package/package.json +36 -21
  32. package/pdf/pdf.component.d.ts +1 -0
  33. package/pdf/pdf.service.d.ts +1 -0
  34. package/rendering/list.component.d.ts +11 -5
  35. package/rendering/table-body.component.d.ts +3 -2
  36. package/schematics/ngAdd/index.js +4 -4
  37. package/scrolling/row-height.service.d.ts +3 -8
  38. package/scrolling/scroller.service.d.ts +35 -9
  39. package/esm2022/grouping/group-scroll-binding.directive.mjs +0 -347
  40. package/esm2022/grouping/virtual-group-result.interface.mjs +0 -5
  41. package/grouping/group-scroll-binding.directive.d.ts +0 -85
  42. package/grouping/virtual-group-result.interface.d.ts +0 -18
@@ -2,26 +2,15 @@
2
2
  * Copyright © 2025 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- /**
6
- * @hidden
7
- */
8
- const update = (arr, idx, value) => ([
9
- ...arr.slice(0, idx + 1),
10
- ...(arr.slice(idx + 1).map(x => x + value))
11
- ]);
12
5
  /**
13
6
  * @hidden
14
7
  */
15
8
  export class RowHeightService {
16
9
  total;
17
- rowHeight;
18
- detailRowHeight;
19
10
  offsets = [];
20
11
  heights = [];
21
- constructor(total = 0, rowHeight, detailRowHeight) {
12
+ constructor(total = 0, rowHeight) {
22
13
  this.total = total;
23
- this.rowHeight = rowHeight;
24
- this.detailRowHeight = detailRowHeight;
25
14
  let agg = 0;
26
15
  for (let idx = 0; idx < total; idx++) {
27
16
  this.offsets.push(agg);
@@ -32,66 +21,35 @@ export class RowHeightService {
32
21
  height(rowIndex) {
33
22
  return this.heights[rowIndex];
34
23
  }
35
- expandDetail(rowIndex) {
36
- if (this.height(rowIndex) === this.rowHeight) {
37
- this.updateRowHeight(rowIndex, this.detailRowHeight);
38
- }
39
- }
40
- collapseDetail(rowIndex) {
41
- if (this.height(rowIndex) > this.rowHeight) {
42
- this.updateRowHeight(rowIndex, this.detailRowHeight * -1);
43
- }
44
- }
45
- isExpanded(rowIndex) {
46
- return this.height(rowIndex) > this.rowHeight;
47
- }
48
24
  index(position) {
49
- if (position < 0) {
50
- return undefined;
51
- }
52
- const result = this.offsets.reduce((prev, current, idx) => {
53
- if (prev !== undefined) {
54
- return prev;
55
- }
56
- else if (current === position) {
57
- return idx;
25
+ for (let i = 0; i < this.offsets.length; i++) {
26
+ if (position === this.offsets[i]) {
27
+ return i;
58
28
  }
59
- else if (current > position) {
60
- return idx - 1;
61
- }
62
- return undefined;
63
- }, undefined);
64
- return result === undefined ? this.total - 1 : result;
65
- }
66
- offset(rowIndex, adjustIndex = false) {
67
- if (adjustIndex) {
68
- let targetOffset = 0;
69
- let targetIndex = 0;
70
- for (let i = 0; i < rowIndex; i++) {
71
- targetOffset += this.rowHeight;
72
- targetIndex++;
73
- if (targetIndex === rowIndex) {
74
- return targetOffset;
75
- }
76
- if (this.isExpanded(i)) {
77
- targetOffset += this.detailRowHeight;
78
- targetIndex++;
79
- if (targetIndex === rowIndex) {
80
- return targetOffset;
81
- }
82
- }
29
+ if (position < this.offsets[i]) {
30
+ return i - 1;
83
31
  }
84
- return targetOffset;
85
32
  }
33
+ return this.total - 1;
34
+ }
35
+ offset(rowIndex) {
86
36
  return this.offsets[rowIndex];
87
37
  }
88
38
  totalHeight() {
89
- return this.heights.reduce((prev, curr) => prev + curr, 0);
90
- }
91
- updateRowHeight(rowIndex, value) {
92
- if (this.total > 0) {
93
- this.heights[rowIndex] += value;
94
- this.offsets = update(this.offsets, rowIndex, value);
39
+ if (!this.offsets.length) {
40
+ return 0;
41
+ }
42
+ const lastOffset = this.offsets[this.offsets.length - 1];
43
+ const lastHeight = this.heights[this.heights.length - 1];
44
+ return lastOffset + lastHeight;
45
+ }
46
+ update(startIndex, rowHeights) {
47
+ let agg = this.offsets[startIndex];
48
+ for (let i = startIndex; i < this.heights.length; i++) {
49
+ this.offsets[i] = agg;
50
+ const currHeight = rowHeights[i - startIndex] || this.heights[i];
51
+ agg += currHeight;
52
+ this.heights[i] = currHeight;
95
53
  }
96
54
  }
97
55
  }
@@ -2,15 +2,17 @@
2
2
  * Copyright © 2025 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { isDocumentAvailable } from '@progress/kendo-angular-common';
5
+ import { isFirefox, firefoxMaxHeight, isDocumentAvailable } from '@progress/kendo-angular-common';
6
6
  import { Observable, BehaviorSubject } from 'rxjs';
7
7
  /**
8
8
  * @hidden
9
9
  */
10
10
  export class ScrollAction {
11
11
  offset;
12
- constructor(offset) {
12
+ changeVirtualData;
13
+ constructor(offset, changeVirtualData) {
13
14
  this.offset = offset;
15
+ this.changeVirtualData = changeVirtualData;
14
16
  }
15
17
  }
16
18
  /**
@@ -35,16 +37,29 @@ const SCROLL_BOTTOM_THRESHOLD = 2;
35
37
  */
36
38
  export class ScrollerService {
37
39
  scrollObservable;
38
- firstLoaded = 0;
39
- lastLoaded;
40
- lastScrollTop;
41
- take;
42
- total;
40
+ ctx;
41
+ total = 0;
43
42
  rowHeightService;
43
+ table = null;
44
+ tableBody = null;
45
+ container = null;
46
+ scrollHeightContainer = null;
47
+ scrollableVirtual = false;
48
+ tableTransformOffset = 0;
49
+ virtualSkip = 0;
50
+ virtualPageSize = 0;
51
+ firstToLoad = 0;
52
+ lastLoaded = 0;
53
+ scrollSyncing = false;
54
+ take;
44
55
  scrollSubscription;
45
56
  subscription;
46
- constructor(scrollObservable) {
57
+ lastScrollTop = 0;
58
+ firstLoaded = 0;
59
+ expandedRows = {};
60
+ constructor(scrollObservable, ctx) {
47
61
  this.scrollObservable = scrollObservable;
62
+ this.ctx = ctx;
48
63
  }
49
64
  create(rowHeightService, skip, take, total) {
50
65
  this.rowHeightService = rowHeightService;
@@ -53,13 +68,50 @@ export class ScrollerService {
53
68
  this.take = take;
54
69
  this.total = total;
55
70
  this.lastScrollTop = 0;
56
- const subject = new BehaviorSubject(new ScrollAction(this.rowHeightService.offset(skip)));
71
+ const offset = this.rowHeightService.offset(skip);
72
+ const subject = new BehaviorSubject(new ScrollAction(offset, this.scrollableVirtual && (Boolean(this.ctx.grid?.pageable) || Boolean(this.ctx.grid?.group?.length))));
57
73
  this.subscription = Observable.create(observer => {
58
74
  this.unsubscribe();
59
75
  this.scrollSubscription = this.scrollObservable.subscribe(x => this.onScroll(x, observer));
60
76
  }).subscribe(x => subject.next(x));
61
77
  return subject;
62
78
  }
79
+ reset(skipScroll = false) {
80
+ if (!skipScroll) {
81
+ this.firstToLoad = 0;
82
+ this.firstLoaded = 0;
83
+ this.lastLoaded = 0;
84
+ this.virtualSkip = 0;
85
+ }
86
+ this.rowHeightService = undefined;
87
+ if (skipScroll) {
88
+ this.scrollSyncing = true;
89
+ }
90
+ if (!skipScroll && this.container && this.container.scrollTop !== 0) {
91
+ this.scrollSyncing = true;
92
+ this.container.scrollTop = 0;
93
+ this.lastScrollTop = 0;
94
+ this.translate(0, true);
95
+ this.tableTransformOffset = 0;
96
+ }
97
+ }
98
+ update(skipAdjust = false) {
99
+ const itemHeights = this.getItemHeights();
100
+ if (this.firstLoaded > this.firstToLoad) {
101
+ // Scrolled up
102
+ const count = Math.min(this.firstLoaded - this.firstToLoad, this.take);
103
+ const newItemsHeight = this.getTotalHeight(count, itemHeights);
104
+ const newItemsExpectedHeight = this.getExpectedTotalHeight(count);
105
+ const diff = newItemsHeight - newItemsExpectedHeight;
106
+ if (!skipAdjust && diff !== 0) {
107
+ this.adjustScroll(diff);
108
+ }
109
+ }
110
+ this.rowHeightService?.update(this.firstToLoad, itemHeights);
111
+ this.scrollHeightContainer && this.setScrollHeightContainerHeight();
112
+ this.firstLoaded = this.firstToLoad;
113
+ this.lastLoaded = this.firstLoaded + itemHeights.length - 1;
114
+ }
63
115
  destroy() {
64
116
  this.unsubscribe();
65
117
  if (this.subscription) {
@@ -67,42 +119,49 @@ export class ScrollerService {
67
119
  }
68
120
  }
69
121
  onScroll({ scrollTop, offsetHeight, scrollHeight, clientHeight }, observer) {
122
+ if (this.scrollSyncing) {
123
+ this.scrollSyncing = false;
124
+ return;
125
+ }
70
126
  if (!isDocumentAvailable() || (this.lastScrollTop === scrollTop)) {
71
127
  return;
72
128
  }
73
129
  const up = this.lastScrollTop >= scrollTop;
130
+ const down = !up;
74
131
  this.lastScrollTop = scrollTop;
75
132
  let firstItemIndex = this.rowHeightService.index(scrollTop);
76
- let firstItemOffset = this.rowHeightService.offset(firstItemIndex);
77
133
  const lastItemIndex = this.rowHeightService.index(scrollTop + offsetHeight);
78
- if (!up) {
79
- if (lastItemIndex >= this.lastLoaded && this.lastLoaded < this.total) {
80
- const overflow = (firstItemIndex + this.take) - this.total;
81
- if (overflow > 0) {
82
- firstItemIndex = firstItemIndex - overflow;
83
- firstItemOffset = this.rowHeightService.offset(firstItemIndex);
84
- }
85
- this.firstLoaded = firstItemIndex;
86
- observer.next(new ScrollAction(firstItemOffset));
87
- let nextTake = this.firstLoaded + this.take;
88
- this.lastLoaded = Math.min(nextTake, this.total);
89
- nextTake = nextTake > this.total ? this.total - this.firstLoaded : this.take;
90
- observer.next(new PageAction(this.firstLoaded, this.take));
91
- }
92
- else {
93
- const atBottom = scrollHeight - clientHeight - scrollTop < SCROLL_BOTTOM_THRESHOLD;
94
- if (atBottom) {
95
- observer.next(new ScrollBottomAction());
96
- }
134
+ const overflow = Math.max(firstItemIndex + (this.virtualPageSize || this.take) - this.total, 0);
135
+ firstItemIndex = Math.max(firstItemIndex - overflow, 0);
136
+ if (lastItemIndex < this.lastLoaded) {
137
+ this.lastLoaded = lastItemIndex;
138
+ }
139
+ if (down) {
140
+ const atBottom = scrollHeight - clientHeight - scrollTop < SCROLL_BOTTOM_THRESHOLD;
141
+ if (atBottom) {
142
+ observer.next(new ScrollBottomAction());
97
143
  }
98
144
  }
99
- if (up && firstItemIndex < this.firstLoaded) {
100
- const nonVisibleBuffer = Math.floor(this.take * 0.3);
101
- this.firstLoaded = Math.max(firstItemIndex - nonVisibleBuffer, 0);
102
- observer.next(new ScrollAction(this.rowHeightService.offset(this.firstLoaded)));
103
- this.lastLoaded = Math.min(this.firstLoaded + this.take, this.total);
104
- observer.next(new PageAction(this.firstLoaded, this.take));
145
+ if (!this.scrollableVirtual) {
146
+ return;
147
+ }
148
+ if (down && lastItemIndex >= this.lastLoaded && this.lastLoaded < this.total - 1) {
149
+ this.firstToLoad = firstItemIndex;
150
+ this.loadPage(observer);
151
+ }
152
+ else if (up && firstItemIndex < this.firstLoaded) {
153
+ const nonVisibleBuffer = Math.max(Math.floor((this.virtualPageSize || this.take) * 0.3) - overflow, 0);
154
+ this.firstToLoad = Math.max(firstItemIndex - nonVisibleBuffer, 0);
155
+ this.loadPage(observer);
156
+ }
157
+ }
158
+ loadPage(observer) {
159
+ if (!this.rowHeightService) {
160
+ return;
105
161
  }
162
+ this.translate(this.rowHeightService.offset(this.firstToLoad));
163
+ observer.next(new ScrollAction(this.rowHeightService.offset(this.firstToLoad)));
164
+ this.virtualPageChange(this.firstToLoad, observer);
106
165
  }
107
166
  unsubscribe() {
108
167
  if (this.scrollSubscription) {
@@ -110,4 +169,85 @@ export class ScrollerService {
110
169
  this.scrollSubscription = undefined;
111
170
  }
112
171
  }
172
+ translate(dY, forceSet) {
173
+ if (this.scrollableVirtual && this.table) {
174
+ if (forceSet) {
175
+ this.table.style.transform = 'translateY(' + dY + 'px)';
176
+ }
177
+ else {
178
+ this.tableTransformOffset = dY;
179
+ }
180
+ }
181
+ }
182
+ adjustScroll(scrollOffset, initialAdjust = false) {
183
+ if (Number.isNaN(scrollOffset)) {
184
+ return;
185
+ }
186
+ this.scrollSyncing = true;
187
+ if (this.container) {
188
+ if (initialAdjust) {
189
+ this.container.scrollTop = scrollOffset;
190
+ this.translate(scrollOffset, true);
191
+ this.tableTransformOffset = scrollOffset;
192
+ this.firstToLoad = this.rowHeightService.index(scrollOffset);
193
+ }
194
+ else {
195
+ this.container.scrollTop += scrollOffset;
196
+ }
197
+ }
198
+ }
199
+ isExpanded(rowIndex) {
200
+ return this.expandedRows[rowIndex] || false;
201
+ }
202
+ resetVirtualSkip = () => {
203
+ if (this.scrollableVirtual && this.virtualSkip) {
204
+ this.virtualSkip = 0;
205
+ }
206
+ };
207
+ setScrollHeightContainerHeight() {
208
+ if (this.scrollableVirtual) {
209
+ let containerHeight = this.rowHeightService?.totalHeight() || 0;
210
+ containerHeight = isFirefox ? Math.min(firefoxMaxHeight, containerHeight) : containerHeight;
211
+ this.scrollHeightContainer.style.height = containerHeight + 'px';
212
+ }
213
+ else {
214
+ this.scrollHeightContainer.style.height = '0';
215
+ }
216
+ }
217
+ getItemHeights() {
218
+ const result = [];
219
+ if (this.tableBody) {
220
+ Array.from(this.tableBody.children).forEach((item, index) => {
221
+ const itemHeight = item.getBoundingClientRect().height;
222
+ if (item.classList.contains('k-detail-row')) {
223
+ result[result.length - 1] += itemHeight;
224
+ this.expandedRows[index] = true;
225
+ }
226
+ else {
227
+ result.push(itemHeight);
228
+ }
229
+ });
230
+ }
231
+ return result;
232
+ }
233
+ getTotalHeight(count, itemHeights) {
234
+ return itemHeights.slice(0, count).reduce((sum, current) => sum + current, 0);
235
+ }
236
+ getExpectedTotalHeight(count) {
237
+ const service = this.rowHeightService;
238
+ if (!service) {
239
+ return 0;
240
+ }
241
+ const lastItemIndex = this.firstToLoad + (count - 1);
242
+ return service.offset(lastItemIndex) + service.height(lastItemIndex) - service.offset(this.firstToLoad);
243
+ }
244
+ virtualPageChange = (skip, observer) => {
245
+ if (this.ctx.grid.pageable || this.ctx.grid.group?.length) {
246
+ this.virtualSkip = skip;
247
+ observer.next(new ScrollAction(this.rowHeightService?.offset(skip) || 0, true));
248
+ }
249
+ else if (skip !== this.ctx.grid.skip) {
250
+ observer.next(new PageAction(Math.max(0, skip), this.take));
251
+ }
252
+ };
113
253
  }