@progress/kendo-react-dropdowns 7.5.0-develop.2 → 7.5.0-develop.21
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/AutoComplete/AutoComplete.js +1 -1
- package/AutoComplete/AutoComplete.mjs +30 -29
- package/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +62 -60
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +59 -57
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +188 -184
- package/DropDownTree/useDropdownWidth.js +1 -1
- package/DropDownTree/useDropdownWidth.mjs +12 -9
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +4 -5
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +92 -90
- package/common/AdaptiveMode.js +1 -1
- package/common/AdaptiveMode.mjs +10 -5
- package/common/DropDownBase.js +1 -1
- package/common/DropDownBase.mjs +63 -55
- package/common/ListFilter.js +1 -1
- package/common/ListFilter.mjs +31 -26
- package/common/VirtualScrollStatic.js +8 -0
- package/common/VirtualScrollStatic.mjs +77 -0
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/index.d.mts +27 -18
- package/index.d.ts +27 -18
- package/package-metadata.mjs +1 -1
- package/package.json +10 -10
- package/common/VirtualScroll.js +0 -8
- package/common/VirtualScroll.mjs +0 -75
package/common/DropDownBase.mjs
CHANGED
|
@@ -8,68 +8,68 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as m from "react";
|
|
10
10
|
import s from "prop-types";
|
|
11
|
-
import v from "./
|
|
11
|
+
import { VirtualScroll as v } from "./VirtualScrollStatic.mjs";
|
|
12
12
|
import { Navigation as y } from "./Navigation.mjs";
|
|
13
13
|
import { scrollToItem as S, areSame as g } from "./utils.mjs";
|
|
14
14
|
const a = class a {
|
|
15
15
|
constructor(n) {
|
|
16
|
-
this.wrapper = null, this.list = null, this.vs = new v(), this.navigation = new y(), this.handleItemClick = (i,
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
this.wrapper = null, this.list = null, this.vs = new v(), this.navigation = new y(), this.handleItemClick = (i, t) => {
|
|
17
|
+
const e = this.initState();
|
|
18
|
+
e.syntheticEvent = t, t.stopPropagation(), this.component.handleItemSelect(i, e), this.togglePopup(e), this.applyState(e);
|
|
19
19
|
}, this.handleFocus = (i) => {
|
|
20
20
|
if (!this.component.state.focused) {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const t = this.initState();
|
|
22
|
+
t.data.focused = !0, t.events.push({ type: "onFocus" }), t.syntheticEvent = i, this.applyState(t);
|
|
23
23
|
}
|
|
24
|
-
}, this.filterChanged = (i,
|
|
25
|
-
const { textField:
|
|
26
|
-
o &&
|
|
24
|
+
}, this.filterChanged = (i, t) => {
|
|
25
|
+
const { textField: e, filterable: o } = this.component.props;
|
|
26
|
+
o && t.events.push({
|
|
27
27
|
type: "onFilterChange",
|
|
28
28
|
filter: {
|
|
29
|
-
field:
|
|
29
|
+
field: e,
|
|
30
30
|
operator: "contains",
|
|
31
31
|
ignoreCase: !0,
|
|
32
32
|
value: i
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
}, this.togglePopup = (i) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
}, this.pageChange = (i,
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
}, this.scrollToVirtualItem = (i,
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
else if (i.skip + i.pageSize === i.total)
|
|
46
|
-
t.scrollToEnd();
|
|
36
|
+
const t = this.component.props, e = t.opened !== void 0 ? t.opened : this.component.state.opened;
|
|
37
|
+
t.opened === void 0 && (i.data.opened = !e), e ? i.events.push({ type: "onClose" }) : (i.events.push({ type: "onOpen" }), this.calculatePopupWidth());
|
|
38
|
+
}, this.pageChange = (i, t) => {
|
|
39
|
+
const e = this.initState();
|
|
40
|
+
e.syntheticEvent = t, this.triggerOnPageChange(e, i.skip, i.take), this.applyState(e);
|
|
41
|
+
}, this.scrollToVirtualItem = (i, t) => {
|
|
42
|
+
const e = this.vs;
|
|
43
|
+
if (i.skip === 0)
|
|
44
|
+
e.reset();
|
|
47
45
|
else {
|
|
48
|
-
let o =
|
|
49
|
-
o === 0 && (
|
|
46
|
+
let o = e.translate;
|
|
47
|
+
o === 0 && (e.calcScrollElementHeight(), o = e.itemHeight * i.skip, e.translateTo(o, !0)), t < 0 && o > 0 && (o += e.itemHeight * (i.pageSize / 4)), e.container && (e.container.scrollTop = o), this.scrollToItem(t, !0);
|
|
50
48
|
}
|
|
51
|
-
window.setTimeout(() => t.enabled = !0, 10);
|
|
52
49
|
}, this.scrollPopupByPageSize = (i) => {
|
|
53
|
-
var
|
|
54
|
-
const
|
|
55
|
-
|
|
50
|
+
var r, l, h, c, u, d;
|
|
51
|
+
const t = this.vs, e = (l = (r = this.list) == null ? void 0 : r.parentElement) == null ? void 0 : l.scrollTop, o = t.enabled && t.itemHeight ? t.itemHeight : this.list ? this.list.children[0].offsetHeight : 0, p = (c = (h = this.list) == null ? void 0 : h.parentElement) == null ? void 0 : c.offsetHeight;
|
|
52
|
+
e !== void 0 && p !== void 0 && ((d = (u = this.list) == null ? void 0 : u.parentElement) == null || d.scroll({ top: e + i * Math.floor(p / o) * o }));
|
|
56
53
|
}, this.renderScrollElement = () => {
|
|
57
54
|
const i = this.vs;
|
|
58
55
|
return i.enabled && /* @__PURE__ */ m.createElement(
|
|
59
56
|
"div",
|
|
60
57
|
{
|
|
61
|
-
ref: (
|
|
58
|
+
ref: (t) => i.scrollElement = t,
|
|
62
59
|
key: "scrollElementKey"
|
|
63
60
|
}
|
|
64
61
|
);
|
|
65
|
-
}, this.resetGroupStickyHeader = (i,
|
|
66
|
-
i !==
|
|
62
|
+
}, this.resetGroupStickyHeader = (i, t) => {
|
|
63
|
+
i !== t.state.group && t.setState({ ...t.state, group: i });
|
|
67
64
|
}, this.listBoxId = n.props.id + "list", this.guid = n.props.id, this.component = n, this.vs.PageChange = this.pageChange;
|
|
68
65
|
}
|
|
66
|
+
didUpdate() {
|
|
67
|
+
this.vs.listTransform && this.vs.list && (this.vs.list.style.transform = this.vs.listTransform, this.vs.listTransform = "");
|
|
68
|
+
}
|
|
69
69
|
didMount() {
|
|
70
|
-
const n = this.component.props, i = n.popupSettings || {},
|
|
70
|
+
const n = this.component.props, i = n.popupSettings || {}, t = n.style || {}, e = i.width;
|
|
71
71
|
let o = n.opened === !0;
|
|
72
|
-
|
|
72
|
+
e === void 0 && this.calculatePopupWidth(), n.dir === void 0 && t.direction === void 0 && (this.calculateDir(), o = !0), o && this.component.forceUpdate();
|
|
73
73
|
}
|
|
74
74
|
calculateDir() {
|
|
75
75
|
const n = this.component.element;
|
|
@@ -78,13 +78,17 @@ const a = class a {
|
|
|
78
78
|
calculatePopupWidth() {
|
|
79
79
|
this.wrapper && (this.popupWidth = this.wrapper.offsetWidth + "px");
|
|
80
80
|
}
|
|
81
|
-
scrollToItem(n, i,
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
81
|
+
scrollToItem(n, i, t) {
|
|
82
|
+
const e = this.list || this.vs.list;
|
|
83
|
+
if (!e && !t && setTimeout(() => {
|
|
84
84
|
this.scrollToItem(n, i, !0);
|
|
85
|
-
}, 10),
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
}, 10), n === 0 && i && this.vs.skip === 0) {
|
|
86
|
+
this.vs.reset();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (e && n >= 0) {
|
|
90
|
+
const o = this.vs, p = o.container || e.parentNode, r = i !== void 0 ? i : o.enabled;
|
|
91
|
+
S(p, e, n, o.translate, r);
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
initState() {
|
|
@@ -102,38 +106,42 @@ const a = class a {
|
|
|
102
106
|
target: this.component,
|
|
103
107
|
value: this.component.value
|
|
104
108
|
};
|
|
105
|
-
n.events.forEach((
|
|
106
|
-
const
|
|
107
|
-
delete
|
|
108
|
-
const o =
|
|
109
|
+
n.events.forEach((t) => {
|
|
110
|
+
const e = t.type;
|
|
111
|
+
delete t.type;
|
|
112
|
+
const o = e && this.component.props[e];
|
|
109
113
|
o && o.call(void 0, {
|
|
110
114
|
...i,
|
|
111
|
-
...
|
|
115
|
+
...t
|
|
112
116
|
});
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
|
-
triggerOnPageChange(n, i,
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const o = Math.min(Math.max(0, i), Math.max(0,
|
|
119
|
-
o !==
|
|
119
|
+
triggerOnPageChange(n, i, t) {
|
|
120
|
+
const e = this.component.props.virtual;
|
|
121
|
+
if (e) {
|
|
122
|
+
const o = Math.min(Math.max(0, i), Math.max(0, e.total - t));
|
|
123
|
+
o !== e.skip && n.events.push({
|
|
120
124
|
type: "onPageChange",
|
|
121
|
-
page: { skip: o, take:
|
|
125
|
+
page: { skip: o, take: t }
|
|
122
126
|
});
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
triggerPageChangeCornerItems(n, i) {
|
|
126
|
-
const
|
|
127
|
-
n && p && this.vs.enabled && (p.skip > 0 && g(n,
|
|
130
|
+
const t = this.component.props, { data: e = [], dataItemKey: o, virtual: p } = t, r = t.opened !== void 0 ? t.opened : this.component.state.opened;
|
|
131
|
+
n && p && this.vs.enabled && (p.skip > 0 && g(n, e[0], o) ? this.triggerOnPageChange(i, p.skip - 1, p.pageSize) : !r && p.skip + p.pageSize < p.total && g(n, e[e.length - 1], o) && this.triggerOnPageChange(i, p.skip + 1, p.pageSize));
|
|
128
132
|
}
|
|
129
133
|
getPopupSettings() {
|
|
130
134
|
return Object.assign({}, a.defaultProps.popupSettings, this.component.props.popupSettings);
|
|
131
135
|
}
|
|
136
|
+
getAdaptiveAnimation() {
|
|
137
|
+
const n = this.getPopupSettings();
|
|
138
|
+
return n.animate !== void 0 ? n.animate : !0;
|
|
139
|
+
}
|
|
132
140
|
getGroupedDataModernMode(n, i) {
|
|
133
|
-
|
|
134
|
-
return n.forEach((
|
|
135
|
-
n[o - 1] &&
|
|
136
|
-
}),
|
|
141
|
+
const t = [];
|
|
142
|
+
return n.forEach((e, o) => {
|
|
143
|
+
n[o - 1] && e[i] !== n[o - 1][i] && t.push({ [i]: e[i] }), t.push(n[o]);
|
|
144
|
+
}), t;
|
|
137
145
|
}
|
|
138
146
|
};
|
|
139
147
|
a.basicPropTypes = {
|
package/common/ListFilter.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 client";"use strict";const
|
|
8
|
+
"use client";"use strict";const m=require("react"),n=require("prop-types"),l=require("@progress/kendo-react-inputs"),p=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-common");function g(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const t=g(m),c=t.forwardRef((e,o)=>{const r=t.useRef(null),{renderListFilterWrapper:a=!1,renderPrefixSeparator:s=!1,...u}=e;t.useImperativeHandle(o,()=>r.current);const d=()=>t.createElement(t.Fragment,null,t.createElement(l.InputPrefix,null,t.createElement(b.IconWrap,{name:"search",icon:p.searchIcon,className:"k-input-icon"})),s&&t.createElement(l.InputSeparator,null)),i=t.createElement(l.TextBox,{...u,ref:r,className:"k-searchbox",value:e.value||"",onChange:e.onChange,onKeyDown:e.onKeyDown,tabIndex:e.tabIndex,onClick:f=>f.stopPropagation(),size:e.size,fillMode:e.fillMode,rounded:e.rounded,prefix:d});return a?t.createElement("div",{className:"k-list-filter"}," ",i," "):i});c.propTypes={value:n.oneOfType([n.string,n.number,n.array]),tabIndex:n.number,onChange:n.func,onKeyDown:n.func,size:n.oneOf([null,"small","medium","large"]),rounded:n.oneOf([null,"small","medium","large","full"]),fillMode:n.oneOf([null,"solid","flat","outline"]),renderListFilterWrapper:n.bool,renderPrefixSeparator:n.bool};c.displayName="KendoReactListFilter";const x=c;module.exports=x;
|
package/common/ListFilter.mjs
CHANGED
|
@@ -6,32 +6,35 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
9
|
+
import * as n from "react";
|
|
10
10
|
import e from "prop-types";
|
|
11
|
-
import { TextBox as
|
|
12
|
-
import { searchIcon as
|
|
13
|
-
import { IconWrap as
|
|
14
|
-
const t =
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
() =>
|
|
19
|
-
)
|
|
20
|
-
|
|
11
|
+
import { TextBox as f, InputPrefix as d, InputSeparator as p } from "@progress/kendo-react-inputs";
|
|
12
|
+
import { searchIcon as x } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { IconWrap as b } from "@progress/kendo-react-common";
|
|
14
|
+
const t = n.forwardRef((r, o) => {
|
|
15
|
+
const l = n.useRef(null), { renderListFilterWrapper: i = !1, renderPrefixSeparator: s = !1, ...m } = r;
|
|
16
|
+
n.useImperativeHandle(
|
|
17
|
+
o,
|
|
18
|
+
() => l.current
|
|
19
|
+
);
|
|
20
|
+
const u = () => /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(d, null, /* @__PURE__ */ n.createElement(b, { name: "search", icon: x, className: "k-input-icon" })), s && /* @__PURE__ */ n.createElement(p, null)), a = /* @__PURE__ */ n.createElement(
|
|
21
|
+
f,
|
|
21
22
|
{
|
|
22
|
-
...
|
|
23
|
-
ref:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
...m,
|
|
24
|
+
ref: l,
|
|
25
|
+
className: "k-searchbox",
|
|
26
|
+
value: r.value || "",
|
|
27
|
+
onChange: r.onChange,
|
|
28
|
+
onKeyDown: r.onKeyDown,
|
|
29
|
+
tabIndex: r.tabIndex,
|
|
30
|
+
onClick: (c) => c.stopPropagation(),
|
|
31
|
+
size: r.size,
|
|
32
|
+
fillMode: r.fillMode,
|
|
33
|
+
rounded: r.rounded,
|
|
34
|
+
prefix: u
|
|
33
35
|
}
|
|
34
|
-
)
|
|
36
|
+
);
|
|
37
|
+
return i ? /* @__PURE__ */ n.createElement("div", { className: "k-list-filter" }, " ", a, " ") : a;
|
|
35
38
|
});
|
|
36
39
|
t.propTypes = {
|
|
37
40
|
value: e.oneOfType([e.string, e.number, e.array]),
|
|
@@ -40,10 +43,12 @@ t.propTypes = {
|
|
|
40
43
|
onKeyDown: e.func,
|
|
41
44
|
size: e.oneOf([null, "small", "medium", "large"]),
|
|
42
45
|
rounded: e.oneOf([null, "small", "medium", "large", "full"]),
|
|
43
|
-
fillMode: e.oneOf([null, "solid", "flat", "outline"])
|
|
46
|
+
fillMode: e.oneOf([null, "solid", "flat", "outline"]),
|
|
47
|
+
renderListFilterWrapper: e.bool,
|
|
48
|
+
renderPrefixSeparator: e.bool
|
|
44
49
|
};
|
|
45
50
|
t.displayName = "KendoReactListFilter";
|
|
46
|
-
const
|
|
51
|
+
const E = t;
|
|
47
52
|
export {
|
|
48
|
-
|
|
53
|
+
E as default
|
|
49
54
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@progress/kendo-react-common"),u=require("react");function p(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const i in l)if(i!=="default"){const e=Object.getOwnPropertyDescriptor(l,i);Object.defineProperty(t,i,e.get?e:{enumerable:!0,get:()=>l[i]})}}return t.default=l,Object.freeze(t)}const S=p(u),m=17895697,c=typeof window!="undefined"&&/Firefox/.test(window.navigator.userAgent);class H{constructor(){this.table=null,this.total=0,this.enabled=!1,this.skip=0,this.pageSize=0,this.PageChange=null,this.scrollElement=null,this.listTransform="",this.itemHeight=0,this.containerHeight=0,this.reactVersion=Number.parseFloat(S.version),this.scrollSyncing=!1,this.lastLoaded=0,this.firstLoaded=0,this.lastScrollTop=0,this.listTranslate=0,this.list=null,this.container=null,this.calcScrollElementHeight=()=>{var h;this.scrollSyncing=!0;let t=!1;this.itemHeight=this.list?this.list.children[0].offsetHeight:this.itemHeight;const i=this.itemHeight*this.total-(((h=this.list)==null?void 0:h.offsetHeight)||0);this.containerHeight=c?Math.min(m,i):i;const e=this.containerHeight;return this.scrollElement&&(t=this.scrollElement.style.height!==e+"px",t&&(this.scrollElement.style.height=e+"px")),this.scrollSyncing=!1,t},this.scrollerRef=t=>{this.container=t,t&&(t.setAttribute("unselectable","on"),window.setTimeout(this.calcScrollElementHeight.bind(this),0))},this.getRowHeightService=n.memoizeOne((t,i)=>new n.RowHeightService(i,t,0)),this.firstLoaded=this.pageSize,this.lastLoaded=this.skip+this.pageSize,this.scrollHandler=this.scrollHandler.bind(this)}get translate(){return this.listTranslate}translateTo(t,i){this.listTranslate=t,this.enabled&&this.list&&(c||this.reactVersion<=17||i?this.list.style.transform="translateY("+t+"px)":this.listTransform="translateY("+t+"px)")}changePage(t,i){const e=Math.min(Math.max(0,t),this.total-this.pageSize);e!==this.skip&&this.PageChange&&this.PageChange({skip:e,take:this.pageSize},i)}reset(){this.container&&(this.calcScrollElementHeight(),this.container.scrollTop=0,this.translateTo(0,!0))}scrollToEnd(){if(this.container&&this.list){this.calcScrollElementHeight();const{scrollHeight:t,offsetHeight:i}=this.container;this.container.scrollTop=t,this.translateTo(t-i,!0)}}scrollHandler(t){if(!this.enabled||!this.container||!this.list)return;if(this.scrollSyncing){this.scrollSyncing=!1;return}this.rowHeightService=this.getRowHeightService(this.itemHeight,this.total);const i=this.container.scrollTop,e=this.lastScrollTop>=i,h=!e,f=Math.abs(i-this.lastScrollTop);this.lastScrollTop=i;let s=this.rowHeightService.index(i),r=this.rowHeightService.offset(s);const{offsetHeight:g}=this.container,d=this.rowHeightService.index(i+g);if(h&&d>=this.lastLoaded&&this.lastLoaded<this.total){const o=s+this.pageSize-this.total;o>0&&(s=s-o,r=this.rowHeightService.offset(s)),this.firstLoaded=s,this.translateTo(r);const a=this.firstLoaded+this.pageSize;this.lastLoaded=Math.min(a,this.total),this.changePage(this.firstLoaded,t)}else if(e&&s-1<=this.firstLoaded){const o=f===this.itemHeight;if(this.skip===0&&o)this.lastScrollTop=0,this.firstLoaded=0,this.lastLoaded=this.pageSize,this.container.scrollTop=0,this.translateTo(0,!0);else{const a=Math.floor(this.pageSize*.3);this.firstLoaded=Math.max(s-a,0),this.translateTo(this.rowHeightService.offset(this.firstLoaded)),this.lastLoaded=Math.min(this.firstLoaded+this.pageSize,this.total),this.changePage(this.firstLoaded,t)}}}}exports.VirtualScroll=H;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { memoizeOne as f, RowHeightService as d } from "@progress/kendo-react-common";
|
|
10
|
+
import * as p from "react";
|
|
11
|
+
const S = 17895697, r = typeof window != "undefined" && /Firefox/.test(window.navigator.userAgent);
|
|
12
|
+
class u {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.table = null, this.total = 0, this.enabled = !1, this.skip = 0, this.pageSize = 0, this.PageChange = null, this.scrollElement = null, this.listTransform = "", this.itemHeight = 0, this.containerHeight = 0, this.reactVersion = Number.parseFloat(p.version), this.scrollSyncing = !1, this.lastLoaded = 0, this.firstLoaded = 0, this.lastScrollTop = 0, this.listTranslate = 0, this.list = null, this.container = null, this.calcScrollElementHeight = () => {
|
|
15
|
+
var h;
|
|
16
|
+
this.scrollSyncing = !0;
|
|
17
|
+
let t = !1;
|
|
18
|
+
this.itemHeight = this.list ? this.list.children[0].offsetHeight : this.itemHeight;
|
|
19
|
+
const i = this.itemHeight * this.total - (((h = this.list) == null ? void 0 : h.offsetHeight) || 0);
|
|
20
|
+
this.containerHeight = r ? Math.min(S, i) : i;
|
|
21
|
+
const s = this.containerHeight;
|
|
22
|
+
return this.scrollElement && (t = this.scrollElement.style.height !== s + "px", t && (this.scrollElement.style.height = s + "px")), this.scrollSyncing = !1, t;
|
|
23
|
+
}, this.scrollerRef = (t) => {
|
|
24
|
+
this.container = t, t && (t.setAttribute("unselectable", "on"), window.setTimeout(this.calcScrollElementHeight.bind(this), 0));
|
|
25
|
+
}, this.getRowHeightService = f((t, i) => new d(i, t, 0)), this.firstLoaded = this.pageSize, this.lastLoaded = this.skip + this.pageSize, this.scrollHandler = this.scrollHandler.bind(this);
|
|
26
|
+
}
|
|
27
|
+
get translate() {
|
|
28
|
+
return this.listTranslate;
|
|
29
|
+
}
|
|
30
|
+
translateTo(t, i) {
|
|
31
|
+
this.listTranslate = t, this.enabled && this.list && (r || this.reactVersion <= 17 || i ? this.list.style.transform = "translateY(" + t + "px)" : this.listTransform = "translateY(" + t + "px)");
|
|
32
|
+
}
|
|
33
|
+
changePage(t, i) {
|
|
34
|
+
const s = Math.min(Math.max(0, t), this.total - this.pageSize);
|
|
35
|
+
s !== this.skip && this.PageChange && this.PageChange({ skip: s, take: this.pageSize }, i);
|
|
36
|
+
}
|
|
37
|
+
reset() {
|
|
38
|
+
this.container && (this.calcScrollElementHeight(), this.container.scrollTop = 0, this.translateTo(0, !0));
|
|
39
|
+
}
|
|
40
|
+
scrollToEnd() {
|
|
41
|
+
if (this.container && this.list) {
|
|
42
|
+
this.calcScrollElementHeight();
|
|
43
|
+
const { scrollHeight: t, offsetHeight: i } = this.container;
|
|
44
|
+
this.container.scrollTop = t, this.translateTo(t - i, !0);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
scrollHandler(t) {
|
|
48
|
+
if (!this.enabled || !this.container || !this.list)
|
|
49
|
+
return;
|
|
50
|
+
if (this.scrollSyncing) {
|
|
51
|
+
this.scrollSyncing = !1;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.rowHeightService = this.getRowHeightService(this.itemHeight, this.total);
|
|
55
|
+
const i = this.container.scrollTop, s = this.lastScrollTop >= i, h = !s, n = Math.abs(i - this.lastScrollTop);
|
|
56
|
+
this.lastScrollTop = i;
|
|
57
|
+
let e = this.rowHeightService.index(i), a = this.rowHeightService.offset(e);
|
|
58
|
+
const { offsetHeight: c } = this.container, g = this.rowHeightService.index(i + c);
|
|
59
|
+
if (h && g >= this.lastLoaded && this.lastLoaded < this.total) {
|
|
60
|
+
const l = e + this.pageSize - this.total;
|
|
61
|
+
l > 0 && (e = e - l, a = this.rowHeightService.offset(e)), this.firstLoaded = e, this.translateTo(a);
|
|
62
|
+
const o = this.firstLoaded + this.pageSize;
|
|
63
|
+
this.lastLoaded = Math.min(o, this.total), this.changePage(this.firstLoaded, t);
|
|
64
|
+
} else if (s && e - 1 <= this.firstLoaded) {
|
|
65
|
+
const l = n === this.itemHeight;
|
|
66
|
+
if (this.skip === 0 && l)
|
|
67
|
+
this.lastScrollTop = 0, this.firstLoaded = 0, this.lastLoaded = this.pageSize, this.container.scrollTop = 0, this.translateTo(0, !0);
|
|
68
|
+
else {
|
|
69
|
+
const o = Math.floor(this.pageSize * 0.3);
|
|
70
|
+
this.firstLoaded = Math.max(e - o, 0), this.translateTo(this.rowHeightService.offset(this.firstLoaded)), this.lastLoaded = Math.min(this.firstLoaded + this.pageSize, this.total), this.changePage(this.firstLoaded, t);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
u as VirtualScroll
|
|
77
|
+
};
|