@progress/kendo-react-grid 5.11.0 → 5.11.1-dev.202302071533

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.
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VirtualScrollFixed = exports.RowHeightService = void 0;
4
+ var React = require("react");
5
+ /**
6
+ * @hidden
7
+ */
8
+ var RowHeightService = /** @class */ (function () {
9
+ function RowHeightService(total, rowHeight, detailRowHeight, data) {
10
+ if (total === void 0) { total = 0; }
11
+ this.total = total;
12
+ this.offsets = [];
13
+ this.heights = [];
14
+ var agg = 0;
15
+ for (var idx = 0; idx < total; idx++) {
16
+ this.offsets.push(agg);
17
+ var currHeight = (data && data[idx].expanded && data[idx].rowType === 'data') ? detailRowHeight : rowHeight;
18
+ agg += currHeight;
19
+ this.heights.push(currHeight);
20
+ }
21
+ }
22
+ RowHeightService.prototype.height = function (rowIndex) {
23
+ return this.heights[rowIndex];
24
+ };
25
+ RowHeightService.prototype.index = function (position) {
26
+ if (position < 0) {
27
+ return undefined;
28
+ }
29
+ var result = this.offsets.reduce(function (prev, current, idx) {
30
+ if (prev !== undefined) {
31
+ return prev;
32
+ }
33
+ else if (current === position) {
34
+ return idx;
35
+ }
36
+ else if (current > position) {
37
+ return idx - 1;
38
+ }
39
+ return undefined;
40
+ }, undefined);
41
+ return result === undefined ? this.total - 1 : result;
42
+ };
43
+ RowHeightService.prototype.offset = function (rowIndex) {
44
+ return this.offsets[rowIndex];
45
+ };
46
+ RowHeightService.prototype.totalHeight = function () {
47
+ var lastOffset = this.offsets[this.offsets.length - 1];
48
+ var lastHeight = this.heights[this.heights.length - 1];
49
+ return lastOffset + lastHeight;
50
+ // return this.heights.reduce((prev, curr) => prev + curr, 0);
51
+ };
52
+ return RowHeightService;
53
+ }());
54
+ exports.RowHeightService = RowHeightService;
55
+ /**
56
+ * @hidden
57
+ */
58
+ var VirtualScrollFixed = /** @class */ (function () {
59
+ function VirtualScrollFixed(_cached) {
60
+ this.table = null;
61
+ this.containerHeight = 0;
62
+ this.topCacheCount = 0;
63
+ this.attendedSkip = 0;
64
+ this.propsSkip = 0;
65
+ this.total = 0;
66
+ this.scrollableVirtual = false;
67
+ this.realSkip = 0;
68
+ this.pageSize = 0;
69
+ this.PageChange = null;
70
+ this.tableBodyRef = React.createRef();
71
+ this.fixedScroll = false;
72
+ this.askedSkip = undefined;
73
+ this.containerRef = React.createRef();
74
+ this.tableTransform = '';
75
+ this.scrollSyncing = false;
76
+ this.lastLoaded = 0;
77
+ this.firstLoaded = 0;
78
+ this.lastScrollTop = 0;
79
+ this.reactVersion = Number.parseFloat(React.version);
80
+ this.firstLoaded = this.pageSize;
81
+ this.lastLoaded = this.realSkip + this.pageSize;
82
+ this.scrollHandler = this.scrollHandler.bind(this);
83
+ }
84
+ Object.defineProperty(VirtualScrollFixed.prototype, "container", {
85
+ get: function () {
86
+ return this.containerRef.current;
87
+ },
88
+ enumerable: false,
89
+ configurable: true
90
+ });
91
+ VirtualScrollFixed.prototype.translate = function (dY, forceSet) {
92
+ if (this.scrollableVirtual && this.table) {
93
+ if (this.reactVersion <= 17 || forceSet) {
94
+ this.table.style.transform = 'translateY(' + dY + 'px)';
95
+ }
96
+ else {
97
+ this.tableTransform = 'translateY(' + dY + 'px)';
98
+ }
99
+ }
100
+ };
101
+ VirtualScrollFixed.prototype.changePage = function (skip, e) {
102
+ if (this.PageChange) {
103
+ this.PageChange({ skip: Math.max(0, skip), take: this.pageSize }, e);
104
+ }
105
+ };
106
+ VirtualScrollFixed.prototype.reset = function () {
107
+ this.scrollSyncing = true;
108
+ if (this.fixedScroll) {
109
+ return;
110
+ }
111
+ if (this.container) {
112
+ this.container.scrollTop = 0;
113
+ }
114
+ this.translate(0, true);
115
+ };
116
+ VirtualScrollFixed.prototype.scrollHandler = function (e) {
117
+ if (!this.scrollableVirtual || !this.container || !this.table ||
118
+ !this.rowHeightService || !this.containerRef.current) {
119
+ return;
120
+ }
121
+ if (this.scrollSyncing) {
122
+ this.scrollSyncing = false;
123
+ return;
124
+ }
125
+ var scrollTop = this.container.scrollTop;
126
+ var up = this.lastScrollTop >= scrollTop;
127
+ var down = !up;
128
+ this.lastScrollTop = scrollTop;
129
+ var firstItemIndex = this.rowHeightService.index(scrollTop);
130
+ var firstItemOffset = this.rowHeightService.offset(firstItemIndex);
131
+ var offsetHeight = this.containerRef.current.offsetHeight;
132
+ var lastItemIndex = this.rowHeightService.index(scrollTop + offsetHeight);
133
+ if (down && lastItemIndex >= this.lastLoaded && this.lastLoaded < this.total) {
134
+ var overflow = (firstItemIndex + this.pageSize) - this.total;
135
+ if (overflow > 0) {
136
+ firstItemIndex = firstItemIndex - overflow;
137
+ firstItemOffset = this.rowHeightService.offset(firstItemIndex);
138
+ }
139
+ this.firstLoaded = firstItemIndex;
140
+ this.translate(firstItemOffset);
141
+ var nextTake = this.firstLoaded + this.pageSize;
142
+ this.lastLoaded = Math.min(nextTake, this.total);
143
+ this.changePage(this.firstLoaded, e);
144
+ }
145
+ else if (up && firstItemIndex < this.firstLoaded) {
146
+ var nonVisibleBuffer = Math.floor(this.pageSize * 0.3);
147
+ this.firstLoaded = Math.max(firstItemIndex - nonVisibleBuffer, 0);
148
+ this.translate(this.rowHeightService.offset(this.firstLoaded));
149
+ this.lastLoaded = Math.min(this.firstLoaded + this.pageSize, this.total);
150
+ this.changePage(this.firstLoaded, e);
151
+ }
152
+ };
153
+ return VirtualScrollFixed;
154
+ }());
155
+ exports.VirtualScrollFixed = VirtualScrollFixed;
@@ -212,6 +212,10 @@ export interface GridProps extends KendoReactComponentBaseProps {
212
212
  * Defines the row height and forces an equal height to all rows ([see example]({% slug scrollmodes_grid %})).
213
213
  */
214
214
  rowHeight?: number;
215
+ /**
216
+ * Defines the detail row height and forces an equal height to all detail rows.
217
+ */
218
+ detailRowHeight?: number;
215
219
  /**
216
220
  * Specifies a React element that will be cloned and rendered inside the detail rows of the currently expanded items ([see example]({% slug hierarchy_grid %})). An item will be rendered as expanded if the value of its `expandField` is `true`.
217
221
  */
@@ -0,0 +1,27 @@
1
+ import { Page } from '../paging/Page';
2
+ import { SyntheticEvent, RefObject } from 'react';
3
+ import { RowHeightService } from '../VirtualScrollFixed';
4
+ /**
5
+ * @hidden
6
+ */
7
+ export interface VirtualScrollInterface {
8
+ get container(): HTMLDivElement | null;
9
+ askedSkip: number | undefined;
10
+ total: number;
11
+ reset: () => void;
12
+ table: HTMLTableElement | null;
13
+ tableBodyRef: RefObject<HTMLTableSectionElement>;
14
+ fixedScroll: boolean;
15
+ PageChange: ((event: Page, syntheticEvent: SyntheticEvent<any>) => void) | null;
16
+ realSkip: number;
17
+ pageSize: number;
18
+ scrollableVirtual: boolean;
19
+ propsSkip: number;
20
+ topCacheCount: number;
21
+ attendedSkip: number;
22
+ containerHeight: number;
23
+ containerRef: RefObject<HTMLDivElement>;
24
+ scrollHandler(e: SyntheticEvent<HTMLDivElement>): void;
25
+ rowHeightService?: RowHeightService;
26
+ tableTransform: string;
27
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,7 +8,7 @@ exports.packageMetadata = {
8
8
  name: '@progress/kendo-react-grid',
9
9
  productName: 'KendoReact',
10
10
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
11
- publishDate: 1675429179,
11
+ publishDate: 1675783223,
12
12
  version: '',
13
13
  licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
14
14
  };