@sheinx/hooks 3.3.6-beta.3 → 3.3.6-beta.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BArFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAiJnB,MAAM;CAwFlD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -98,7 +98,9 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
98
98
|
topTimer: null,
|
99
99
|
controlScrollRate: null,
|
100
100
|
heightCallback: null,
|
101
|
-
preIndex: null
|
101
|
+
preIndex: null,
|
102
|
+
rowSpanRows: 0,
|
103
|
+
autoAddRows: 0
|
102
104
|
}),
|
103
105
|
context = _useRef.current;
|
104
106
|
var getTranslate = (0, _usePersistFn.usePersistFn)(function (left, top) {
|
@@ -149,6 +151,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
149
151
|
var top = 0;
|
150
152
|
var maxIndex = Math.max(props.data.length - rowsInView, 0);
|
151
153
|
for (var i = 0; i <= maxIndex; i++) {
|
154
|
+
context.rowSpanRows = 0;
|
152
155
|
sum += context.cachedHeight[i] || props.rowHeight;
|
153
156
|
var rowSpanHeight = 0;
|
154
157
|
if (rowSpanInfos) {
|
@@ -160,6 +163,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
160
163
|
}
|
161
164
|
for (var j = 0; j < siblingsIndexs.length; j++) {
|
162
165
|
var index = siblingsIndexs[j];
|
166
|
+
context.rowSpanRows += 1;
|
163
167
|
rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
|
164
168
|
}
|
165
169
|
}
|
@@ -250,6 +254,24 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
250
254
|
props.scrollRef.current.scrollTop = beforeHeight;
|
251
255
|
}
|
252
256
|
});
|
257
|
+
(0, _react.useEffect)(function () {
|
258
|
+
var scrollRefHeight = props.scrollRef.current ? props.scrollRef.current.clientHeight : 0;
|
259
|
+
var tableRefHeight = props.innerRef.current ? props.innerRef.current.clientHeight : 0;
|
260
|
+
var remainHeight = scrollRefHeight - tableRefHeight;
|
261
|
+
if (remainHeight > 0) {
|
262
|
+
var addonHeight = 0;
|
263
|
+
var addonCount = 0;
|
264
|
+
for (var i = startIndex + rowsInView; i < props.data.length; i++) {
|
265
|
+
var height = context.cachedHeight[i] || props.rowHeight;
|
266
|
+
addonHeight += height;
|
267
|
+
addonCount += 1;
|
268
|
+
if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
|
269
|
+
}
|
270
|
+
if (addonCount > 0) {
|
271
|
+
context.autoAddRows = addonCount;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}, []);
|
253
275
|
(0, _react.useEffect)(function () {
|
254
276
|
// 记录preIndex
|
255
277
|
context.preIndex = startIndex;
|
@@ -284,7 +306,8 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
284
306
|
cb();
|
285
307
|
}
|
286
308
|
}, [scrollHeight]);
|
287
|
-
var
|
309
|
+
var finalRowsInView = rowsInView + context.rowSpanRows + context.autoAddRows;
|
310
|
+
var renderData = props.disabled ? props.data : _toConsumableArray(props.data).slice(startIndex, startIndex + finalRowsInView);
|
288
311
|
return {
|
289
312
|
scrollHeight: scrollHeight,
|
290
313
|
startIndex: startIndex,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BArFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAiJnB,MAAM;CAwFlD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -92,7 +92,9 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
92
92
|
topTimer: null,
|
93
93
|
controlScrollRate: null,
|
94
94
|
heightCallback: null,
|
95
|
-
preIndex: null
|
95
|
+
preIndex: null,
|
96
|
+
rowSpanRows: 0,
|
97
|
+
autoAddRows: 0
|
96
98
|
}),
|
97
99
|
context = _useRef.current;
|
98
100
|
var getTranslate = usePersistFn(function (left, top) {
|
@@ -143,6 +145,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
143
145
|
var top = 0;
|
144
146
|
var maxIndex = Math.max(props.data.length - rowsInView, 0);
|
145
147
|
for (var i = 0; i <= maxIndex; i++) {
|
148
|
+
context.rowSpanRows = 0;
|
146
149
|
sum += context.cachedHeight[i] || props.rowHeight;
|
147
150
|
var rowSpanHeight = 0;
|
148
151
|
if (rowSpanInfos) {
|
@@ -154,6 +157,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
154
157
|
}
|
155
158
|
for (var j = 0; j < siblingsIndexs.length; j++) {
|
156
159
|
var index = siblingsIndexs[j];
|
160
|
+
context.rowSpanRows += 1;
|
157
161
|
rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
|
158
162
|
}
|
159
163
|
}
|
@@ -244,6 +248,24 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
244
248
|
props.scrollRef.current.scrollTop = beforeHeight;
|
245
249
|
}
|
246
250
|
});
|
251
|
+
useEffect(function () {
|
252
|
+
var scrollRefHeight = props.scrollRef.current ? props.scrollRef.current.clientHeight : 0;
|
253
|
+
var tableRefHeight = props.innerRef.current ? props.innerRef.current.clientHeight : 0;
|
254
|
+
var remainHeight = scrollRefHeight - tableRefHeight;
|
255
|
+
if (remainHeight > 0) {
|
256
|
+
var addonHeight = 0;
|
257
|
+
var addonCount = 0;
|
258
|
+
for (var i = startIndex + rowsInView; i < props.data.length; i++) {
|
259
|
+
var height = context.cachedHeight[i] || props.rowHeight;
|
260
|
+
addonHeight += height;
|
261
|
+
addonCount += 1;
|
262
|
+
if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
|
263
|
+
}
|
264
|
+
if (addonCount > 0) {
|
265
|
+
context.autoAddRows = addonCount;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}, []);
|
247
269
|
useEffect(function () {
|
248
270
|
// 记录preIndex
|
249
271
|
context.preIndex = startIndex;
|
@@ -278,7 +300,8 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
278
300
|
cb();
|
279
301
|
}
|
280
302
|
}, [scrollHeight]);
|
281
|
-
var
|
303
|
+
var finalRowsInView = rowsInView + context.rowSpanRows + context.autoAddRows;
|
304
|
+
var renderData = props.disabled ? props.data : _toConsumableArray(props.data).slice(startIndex, startIndex + finalRowsInView);
|
282
305
|
return {
|
283
306
|
scrollHeight: scrollHeight,
|
284
307
|
startIndex: startIndex,
|