@progress/kendo-react-grid 14.2.0 → 14.2.1-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.
- package/VirtualScroll.d.ts +1 -0
- package/VirtualScroll.js +1 -1
- package/VirtualScroll.mjs +26 -22
- package/dist/cdn/js/kendo-react-grid.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +17 -17
package/VirtualScroll.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare class VirtualScroll implements VirtualScrollInterface {
|
|
|
35
35
|
scrollHandler(e: React.SyntheticEvent<HTMLDivElement>): void;
|
|
36
36
|
update(): void;
|
|
37
37
|
private loadPage;
|
|
38
|
+
private loadPageWithBuffer;
|
|
38
39
|
private translate;
|
|
39
40
|
private changePage;
|
|
40
41
|
private adjustScroll;
|
package/VirtualScroll.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),n=require("./utils/index.js");function f(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const d=f(c),g=.3;class u{constructor(){this.table=null,this.tableBody=null,this.container=null,this.scrollHeightContainer=null,this.total=0,this.scrollableVirtual=!1,this.pageSize=0,this.PageChange=null,this.fixedScroll=!1,this.tableTransform="",this.reactVersion=Number.parseFloat(d.version),this.scrollSyncing=!1,this.firstToLoad=0,this.lastScrollTop=0,this.firstLoaded=0,this.lastLoaded=0,this.scrollHandler=this.scrollHandler.bind(this)}reset(){if(this.firstToLoad=0,this.firstLoaded=0,this.lastLoaded=0,this.rowHeightService=void 0,this.fixedScroll){this.lastScrollTop=this.container?this.container.scrollTop:0;return}this.container&&this.container.scrollTop!==0&&(this.scrollSyncing=!0,this.container.scrollTop=0,this.lastScrollTop=0,this.translate(0,!0))}scrollHandler(t){if(this.scrollSyncing){this.scrollSyncing=!1;return}if(!this.scrollableVirtual||!this.container||!this.table||!this.rowHeightService||!this.container)return;const e=this.container.scrollTop,i=this.lastScrollTop>=e,o=!i;this.lastScrollTop=e;const a=this.container.offsetHeight;let s=this.rowHeightService.index(e);const l=this.rowHeightService.index(e+a),h=Math.max(s+this.pageSize-this.total,0);s=Math.max(s-h,0),o&&l>=this.lastLoaded&&this.lastLoaded<this.total-1?(this.firstToLoad=s,this.loadPage(t)):(i&&s<this.firstToLoad||s>this.lastLoaded||l<this.firstLoaded)&&this.loadPageWithBuffer(s,h,i,t)}update(){var e;const t=this.getItemHeights();if(this.firstLoaded>this.firstToLoad){const i=Math.min(this.firstLoaded-this.firstToLoad,this.pageSize),o=this.getTotalHeight(i,t),a=this.getExpectedTotalHeight(i),s=o-a;s!==0&&this.adjustScroll(s)}(e=this.rowHeightService)==null||e.update(this.firstToLoad,t),this.setScrollHeightContainerHeight(),this.firstLoaded=this.firstToLoad,this.lastLoaded=this.firstLoaded+t.length-1}loadPage(t){this.rowHeightService&&(this.translate(this.rowHeightService.offset(this.firstToLoad)),this.changePage(this.firstToLoad,t))}loadPageWithBuffer(t,e,i,o){const a=i?Math.max(Math.floor(this.pageSize*g)-e,0):0;this.firstToLoad=Math.max(t-a,0),this.loadPage(o)}translate(t,e){this.scrollableVirtual&&this.table&&(this.reactVersion<=17||e?this.table.style.transform="translateY("+t+"px)":this.tableTransform="translateY("+t+"px)")}changePage(t,e){this.PageChange&&this.PageChange({skip:Math.max(0,t),take:this.pageSize},e)}adjustScroll(t){this.scrollSyncing=!0,this.container&&(this.container.scrollTop+=t)}setScrollHeightContainerHeight(){var t;if(this.scrollableVirtual&&this.scrollHeightContainer){let e=((t=this.rowHeightService)==null?void 0:t.totalHeight())||0;e=n.firefox?Math.min(n.firefoxMaxHeight,e):e,this.scrollHeightContainer.style.height=e+"px"}}getItemHeights(){const t=[];return this.tableBody&&Array.from(this.tableBody.children).forEach(e=>{const i=e.getBoundingClientRect().height;e.classList.contains("k-detail-row")?t[t.length-1]+=i:t.push(i)}),t}getTotalHeight(t,e){return e.slice(0,t).reduce((i,o)=>i+o,0)}getExpectedTotalHeight(t){const e=this.rowHeightService;if(!e)return 0;const i=this.firstToLoad+(t-1);return e.offset(i)+e.height(i)-e.offset(this.firstToLoad)}}exports.VirtualScroll=u;
|
package/VirtualScroll.mjs
CHANGED
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import { firefox as
|
|
8
|
+
import * as l from "react";
|
|
9
|
+
import { firefox as n, firefoxMaxHeight as c } from "./utils/index.mjs";
|
|
10
|
+
const f = 0.3;
|
|
10
11
|
class u {
|
|
11
12
|
constructor() {
|
|
12
|
-
this.table = null, this.tableBody = null, this.container = null, this.scrollHeightContainer = null, this.total = 0, this.scrollableVirtual = !1, this.pageSize = 0, this.PageChange = null, this.fixedScroll = !1, this.tableTransform = "", this.reactVersion = Number.parseFloat(
|
|
13
|
+
this.table = null, this.tableBody = null, this.container = null, this.scrollHeightContainer = null, this.total = 0, this.scrollableVirtual = !1, this.pageSize = 0, this.PageChange = null, this.fixedScroll = !1, this.tableTransform = "", this.reactVersion = Number.parseFloat(l.version), this.scrollSyncing = !1, this.firstToLoad = 0, this.lastScrollTop = 0, this.firstLoaded = 0, this.lastLoaded = 0, this.scrollHandler = this.scrollHandler.bind(this);
|
|
13
14
|
}
|
|
14
15
|
reset() {
|
|
15
|
-
this.firstToLoad = 0, this.firstLoaded = 0, this.lastLoaded = 0, this.rowHeightService = void 0,
|
|
16
|
+
if (this.firstToLoad = 0, this.firstLoaded = 0, this.lastLoaded = 0, this.rowHeightService = void 0, this.fixedScroll) {
|
|
17
|
+
this.lastScrollTop = this.container ? this.container.scrollTop : 0;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.container && this.container.scrollTop !== 0 && (this.scrollSyncing = !0, this.container.scrollTop = 0, this.lastScrollTop = 0, this.translate(0, !0));
|
|
16
21
|
}
|
|
17
22
|
scrollHandler(t) {
|
|
18
23
|
if (this.scrollSyncing) {
|
|
@@ -21,30 +26,29 @@ class u {
|
|
|
21
26
|
}
|
|
22
27
|
if (!this.scrollableVirtual || !this.container || !this.table || !this.rowHeightService || !this.container)
|
|
23
28
|
return;
|
|
24
|
-
const i = this.container.scrollTop,
|
|
29
|
+
const i = this.container.scrollTop, s = this.lastScrollTop >= i, o = !s;
|
|
25
30
|
this.lastScrollTop = i;
|
|
26
|
-
const
|
|
27
|
-
let
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
this.firstToLoad = s, this.loadPage(t);
|
|
31
|
-
else if (e && s < this.firstToLoad) {
|
|
32
|
-
const l = Math.max(Math.floor(this.pageSize * 0.3) - h, 0);
|
|
33
|
-
this.firstToLoad = Math.max(s - l, 0), this.loadPage(t);
|
|
34
|
-
}
|
|
31
|
+
const a = this.container.offsetHeight;
|
|
32
|
+
let e = this.rowHeightService.index(i);
|
|
33
|
+
const h = this.rowHeightService.index(i + a), r = Math.max(e + this.pageSize - this.total, 0);
|
|
34
|
+
e = Math.max(e - r, 0), o && h >= this.lastLoaded && this.lastLoaded < this.total - 1 ? (this.firstToLoad = e, this.loadPage(t)) : (s && e < this.firstToLoad || e > this.lastLoaded || h < this.firstLoaded) && this.loadPageWithBuffer(e, r, s, t);
|
|
35
35
|
}
|
|
36
36
|
update() {
|
|
37
37
|
var i;
|
|
38
38
|
const t = this.getItemHeights();
|
|
39
39
|
if (this.firstLoaded > this.firstToLoad) {
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const s = Math.min(this.firstLoaded - this.firstToLoad, this.pageSize), o = this.getTotalHeight(s, t), a = this.getExpectedTotalHeight(s), e = o - a;
|
|
41
|
+
e !== 0 && this.adjustScroll(e);
|
|
42
42
|
}
|
|
43
43
|
(i = this.rowHeightService) == null || i.update(this.firstToLoad, t), this.setScrollHeightContainerHeight(), this.firstLoaded = this.firstToLoad, this.lastLoaded = this.firstLoaded + t.length - 1;
|
|
44
44
|
}
|
|
45
45
|
loadPage(t) {
|
|
46
46
|
this.rowHeightService && (this.translate(this.rowHeightService.offset(this.firstToLoad)), this.changePage(this.firstToLoad, t));
|
|
47
47
|
}
|
|
48
|
+
loadPageWithBuffer(t, i, s, o) {
|
|
49
|
+
const a = s ? Math.max(Math.floor(this.pageSize * f) - i, 0) : 0;
|
|
50
|
+
this.firstToLoad = Math.max(t - a, 0), this.loadPage(o);
|
|
51
|
+
}
|
|
48
52
|
translate(t, i) {
|
|
49
53
|
this.scrollableVirtual && this.table && (this.reactVersion <= 17 || i ? this.table.style.transform = "translateY(" + t + "px)" : this.tableTransform = "translateY(" + t + "px)");
|
|
50
54
|
}
|
|
@@ -64,25 +68,25 @@ class u {
|
|
|
64
68
|
var t;
|
|
65
69
|
if (this.scrollableVirtual && this.scrollHeightContainer) {
|
|
66
70
|
let i = ((t = this.rowHeightService) == null ? void 0 : t.totalHeight()) || 0;
|
|
67
|
-
i =
|
|
71
|
+
i = n ? Math.min(c, i) : i, this.scrollHeightContainer.style.height = i + "px";
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
getItemHeights() {
|
|
71
75
|
const t = [];
|
|
72
76
|
return this.tableBody && Array.from(this.tableBody.children).forEach((i) => {
|
|
73
|
-
const
|
|
74
|
-
i.classList.contains("k-detail-row") ? t[t.length - 1] +=
|
|
77
|
+
const s = i.getBoundingClientRect().height;
|
|
78
|
+
i.classList.contains("k-detail-row") ? t[t.length - 1] += s : t.push(s);
|
|
75
79
|
}), t;
|
|
76
80
|
}
|
|
77
81
|
getTotalHeight(t, i) {
|
|
78
|
-
return i.slice(0, t).reduce((
|
|
82
|
+
return i.slice(0, t).reduce((s, o) => s + o, 0);
|
|
79
83
|
}
|
|
80
84
|
getExpectedTotalHeight(t) {
|
|
81
85
|
const i = this.rowHeightService;
|
|
82
86
|
if (!i)
|
|
83
87
|
return 0;
|
|
84
|
-
const
|
|
85
|
-
return i.offset(
|
|
88
|
+
const s = this.firstToLoad + (t - 1);
|
|
89
|
+
return i.offset(s) + i.height(s) - i.offset(this.firstToLoad);
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
export {
|