react-window 2.3.0 → 2.3.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/dist/react-window.cjs +1 -1
- package/dist/react-window.cjs.map +1 -1
- package/dist/react-window.js +77 -77
- package/dist/react-window.js.map +1 -1
- package/package.json +28 -28
package/dist/react-window.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as se } from "react/jsx-runtime";
|
|
3
|
-
import { useState as L, useLayoutEffect as
|
|
3
|
+
import { useState as L, useLayoutEffect as oe, useEffect as Z, useMemo as R, useRef as P, useCallback as B, memo as ae, useImperativeHandle as fe, createElement as Q } from "react";
|
|
4
4
|
function be(e) {
|
|
5
5
|
let t = e;
|
|
6
6
|
for (; t; ) {
|
|
@@ -12,11 +12,11 @@ function be(e) {
|
|
|
12
12
|
}
|
|
13
13
|
function Ie(e, t) {
|
|
14
14
|
const [s, r] = L(t === "rtl");
|
|
15
|
-
return
|
|
16
|
-
|
|
15
|
+
return oe(() => {
|
|
16
|
+
t ? r(t === "rtl") : e && r(be(e));
|
|
17
17
|
}, [t, e]), s;
|
|
18
18
|
}
|
|
19
|
-
const J = typeof window < "u" ?
|
|
19
|
+
const J = typeof window < "u" ? oe : Z;
|
|
20
20
|
function ce(e) {
|
|
21
21
|
if (e !== void 0)
|
|
22
22
|
switch (typeof e) {
|
|
@@ -35,7 +35,7 @@ function we({
|
|
|
35
35
|
defaultWidth: s,
|
|
36
36
|
disabled: r,
|
|
37
37
|
element: n,
|
|
38
|
-
mode:
|
|
38
|
+
mode: o,
|
|
39
39
|
style: l
|
|
40
40
|
}) {
|
|
41
41
|
const { styleHeight: f, styleWidth: a } = R(
|
|
@@ -44,10 +44,10 @@ function we({
|
|
|
44
44
|
styleWidth: ce(l?.width)
|
|
45
45
|
}),
|
|
46
46
|
[l?.height, l?.width]
|
|
47
|
-
), [
|
|
47
|
+
), [i, d] = L({
|
|
48
48
|
height: t,
|
|
49
49
|
width: s
|
|
50
|
-
}), c = r ||
|
|
50
|
+
}), c = r || o === "only-height" && f !== void 0 || o === "only-width" && a !== void 0 || f !== void 0 && a !== void 0;
|
|
51
51
|
return J(() => {
|
|
52
52
|
if (n === null || c)
|
|
53
53
|
return;
|
|
@@ -65,10 +65,10 @@ function we({
|
|
|
65
65
|
};
|
|
66
66
|
}, [e, c, n, f, a]), R(
|
|
67
67
|
() => ({
|
|
68
|
-
height: f ??
|
|
69
|
-
width: a ??
|
|
68
|
+
height: f ?? i.height,
|
|
69
|
+
width: a ?? i.width
|
|
70
70
|
}),
|
|
71
|
-
[
|
|
71
|
+
[i, f, a]
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
function de(e) {
|
|
@@ -101,8 +101,8 @@ function C({
|
|
|
101
101
|
return -r;
|
|
102
102
|
case "positive-descending": {
|
|
103
103
|
if (e) {
|
|
104
|
-
const { clientWidth: n, scrollLeft:
|
|
105
|
-
return l - n -
|
|
104
|
+
const { clientWidth: n, scrollLeft: o, scrollWidth: l } = e;
|
|
105
|
+
return l - n - o;
|
|
106
106
|
}
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
@@ -147,7 +147,7 @@ function Oe({
|
|
|
147
147
|
index: s,
|
|
148
148
|
itemCount: r,
|
|
149
149
|
itemSize: n,
|
|
150
|
-
containerScrollOffset:
|
|
150
|
+
containerScrollOffset: o,
|
|
151
151
|
containerSize: l
|
|
152
152
|
}) {
|
|
153
153
|
if (s < 0 || s >= r)
|
|
@@ -158,23 +158,23 @@ function Oe({
|
|
|
158
158
|
cachedBounds: t,
|
|
159
159
|
itemCount: r,
|
|
160
160
|
itemSize: n
|
|
161
|
-
}), a = t.get(s),
|
|
161
|
+
}), a = t.get(s), i = Math.max(
|
|
162
162
|
0,
|
|
163
163
|
Math.min(f - l, a.scrollOffset)
|
|
164
164
|
), d = Math.max(
|
|
165
165
|
0,
|
|
166
166
|
a.scrollOffset - l + a.size
|
|
167
167
|
);
|
|
168
|
-
switch (e === "smart" && (
|
|
168
|
+
switch (e === "smart" && (o >= d && o <= i ? e = "auto" : e = "center"), e) {
|
|
169
169
|
case "start":
|
|
170
|
-
return
|
|
170
|
+
return i;
|
|
171
171
|
case "end":
|
|
172
172
|
return d;
|
|
173
173
|
case "center":
|
|
174
174
|
return a.scrollOffset <= l / 2 ? 0 : a.scrollOffset + a.size / 2 >= f - l / 2 ? f - l : a.scrollOffset + a.size / 2 - l / 2;
|
|
175
175
|
case "auto":
|
|
176
176
|
default:
|
|
177
|
-
return
|
|
177
|
+
return o >= d && o <= i ? o : o < d ? d : i;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
function ee({
|
|
@@ -184,25 +184,25 @@ function ee({
|
|
|
184
184
|
itemCount: r,
|
|
185
185
|
overscanCount: n
|
|
186
186
|
}) {
|
|
187
|
-
const
|
|
188
|
-
let l = 0, f = -1, a = 0,
|
|
189
|
-
for (; d <
|
|
187
|
+
const o = r - 1;
|
|
188
|
+
let l = 0, f = -1, a = 0, i = -1, d = 0;
|
|
189
|
+
for (; d < o; ) {
|
|
190
190
|
const c = e.get(d);
|
|
191
191
|
if (c.scrollOffset + c.size > t)
|
|
192
192
|
break;
|
|
193
193
|
d++;
|
|
194
194
|
}
|
|
195
|
-
for (l = d, a = Math.max(0, l - n); d <
|
|
195
|
+
for (l = d, a = Math.max(0, l - n); d < o; ) {
|
|
196
196
|
const c = e.get(d);
|
|
197
197
|
if (c.scrollOffset + c.size >= t + s)
|
|
198
198
|
break;
|
|
199
199
|
d++;
|
|
200
200
|
}
|
|
201
|
-
return f = Math.min(
|
|
201
|
+
return f = Math.min(o, d), i = Math.min(r - 1, f + n), l < 0 && (l = 0, f = -1, a = 0, i = -1), {
|
|
202
202
|
startIndexVisible: l,
|
|
203
203
|
stopIndexVisible: f,
|
|
204
204
|
startIndexOverscan: a,
|
|
205
|
-
stopIndexOverscan:
|
|
205
|
+
stopIndexOverscan: i
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
208
|
function ye({
|
|
@@ -242,14 +242,14 @@ function ye({
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
const
|
|
245
|
+
const o = r.get(n);
|
|
246
246
|
return k(
|
|
247
|
-
|
|
247
|
+
o !== void 0,
|
|
248
248
|
`Unexpected bounds cache miss for index ${n}`
|
|
249
|
-
),
|
|
249
|
+
), o;
|
|
250
250
|
},
|
|
251
|
-
set(n,
|
|
252
|
-
r.set(n,
|
|
251
|
+
set(n, o) {
|
|
252
|
+
r.set(n, o);
|
|
253
253
|
},
|
|
254
254
|
get size() {
|
|
255
255
|
return r.size;
|
|
@@ -299,11 +299,11 @@ function re({
|
|
|
299
299
|
defaultContainerSize: s = 0,
|
|
300
300
|
direction: r,
|
|
301
301
|
isRtl: n = !1,
|
|
302
|
-
itemCount:
|
|
302
|
+
itemCount: o,
|
|
303
303
|
itemProps: l,
|
|
304
304
|
itemSize: f,
|
|
305
305
|
onResize: a,
|
|
306
|
-
overscanCount:
|
|
306
|
+
overscanCount: i
|
|
307
307
|
}) {
|
|
308
308
|
const { height: d = s, width: c = s } = we({
|
|
309
309
|
defaultHeight: r === "vertical" ? s : void 0,
|
|
@@ -315,14 +315,14 @@ function re({
|
|
|
315
315
|
height: 0,
|
|
316
316
|
width: 0
|
|
317
317
|
}), x = r === "vertical" ? d : c, I = Se({ containerSize: x, itemSize: f });
|
|
318
|
-
|
|
318
|
+
oe(() => {
|
|
319
319
|
if (typeof a == "function") {
|
|
320
320
|
const p = g.current;
|
|
321
321
|
(p.height !== d || p.width !== c) && (a({ height: d, width: c }, { ...p }), p.height = d, p.width = c);
|
|
322
322
|
}
|
|
323
323
|
}, [d, a, c]);
|
|
324
324
|
const h = ze({
|
|
325
|
-
itemCount:
|
|
325
|
+
itemCount: o,
|
|
326
326
|
itemProps: l,
|
|
327
327
|
itemSize: I
|
|
328
328
|
}), z = B(
|
|
@@ -334,8 +334,8 @@ function re({
|
|
|
334
334
|
// TODO Potentially support a defaultScrollOffset prop?
|
|
335
335
|
containerScrollOffset: 0,
|
|
336
336
|
containerSize: x,
|
|
337
|
-
itemCount:
|
|
338
|
-
overscanCount:
|
|
337
|
+
itemCount: o,
|
|
338
|
+
overscanCount: i
|
|
339
339
|
})
|
|
340
340
|
), {
|
|
341
341
|
startIndexVisible: T,
|
|
@@ -343,17 +343,17 @@ function re({
|
|
|
343
343
|
stopIndexVisible: D,
|
|
344
344
|
stopIndexOverscan: v
|
|
345
345
|
} = {
|
|
346
|
-
startIndexVisible: Math.min(
|
|
347
|
-
startIndexOverscan: Math.min(
|
|
348
|
-
stopIndexVisible: Math.min(
|
|
349
|
-
stopIndexOverscan: Math.min(
|
|
346
|
+
startIndexVisible: Math.min(o - 1, u.startIndexVisible),
|
|
347
|
+
startIndexOverscan: Math.min(o - 1, u.startIndexOverscan),
|
|
348
|
+
stopIndexVisible: Math.min(o - 1, u.stopIndexVisible),
|
|
349
|
+
stopIndexOverscan: Math.min(o - 1, u.stopIndexOverscan)
|
|
350
350
|
}, U = B(
|
|
351
351
|
() => ue({
|
|
352
352
|
cachedBounds: h,
|
|
353
|
-
itemCount:
|
|
353
|
+
itemCount: o,
|
|
354
354
|
itemSize: I
|
|
355
355
|
}),
|
|
356
|
-
[h,
|
|
356
|
+
[h, o, I]
|
|
357
357
|
), m = B(
|
|
358
358
|
(p) => {
|
|
359
359
|
const O = C({
|
|
@@ -366,8 +366,8 @@ function re({
|
|
|
366
366
|
cachedBounds: h,
|
|
367
367
|
containerScrollOffset: O,
|
|
368
368
|
containerSize: x,
|
|
369
|
-
itemCount:
|
|
370
|
-
overscanCount:
|
|
369
|
+
itemCount: o,
|
|
370
|
+
overscanCount: i
|
|
371
371
|
});
|
|
372
372
|
},
|
|
373
373
|
[
|
|
@@ -376,8 +376,8 @@ function re({
|
|
|
376
376
|
x,
|
|
377
377
|
r,
|
|
378
378
|
n,
|
|
379
|
-
|
|
380
|
-
|
|
379
|
+
o,
|
|
380
|
+
i
|
|
381
381
|
]
|
|
382
382
|
);
|
|
383
383
|
J(() => {
|
|
@@ -397,8 +397,8 @@ function re({
|
|
|
397
397
|
cachedBounds: h,
|
|
398
398
|
containerScrollOffset: b,
|
|
399
399
|
containerSize: x,
|
|
400
|
-
itemCount:
|
|
401
|
-
overscanCount:
|
|
400
|
+
itemCount: o,
|
|
401
|
+
overscanCount: i
|
|
402
402
|
});
|
|
403
403
|
return X(w, O) ? O : w;
|
|
404
404
|
});
|
|
@@ -411,8 +411,8 @@ function re({
|
|
|
411
411
|
e,
|
|
412
412
|
x,
|
|
413
413
|
r,
|
|
414
|
-
|
|
415
|
-
|
|
414
|
+
o,
|
|
415
|
+
i
|
|
416
416
|
]);
|
|
417
417
|
const G = de(
|
|
418
418
|
({
|
|
@@ -426,7 +426,7 @@ function re({
|
|
|
426
426
|
containerScrollOffset: O,
|
|
427
427
|
containerSize: x,
|
|
428
428
|
index: M,
|
|
429
|
-
itemCount:
|
|
429
|
+
itemCount: o,
|
|
430
430
|
itemSize: I
|
|
431
431
|
});
|
|
432
432
|
if (e) {
|
|
@@ -462,11 +462,11 @@ function pe(e, t) {
|
|
|
462
462
|
style: r,
|
|
463
463
|
...n
|
|
464
464
|
} = e, {
|
|
465
|
-
ariaAttributes:
|
|
465
|
+
ariaAttributes: o,
|
|
466
466
|
style: l,
|
|
467
467
|
...f
|
|
468
468
|
} = t;
|
|
469
|
-
return X(s,
|
|
469
|
+
return X(s, o) && X(r, l) && X(n, f);
|
|
470
470
|
}
|
|
471
471
|
function Ve({
|
|
472
472
|
cellComponent: e,
|
|
@@ -474,11 +474,11 @@ function Ve({
|
|
|
474
474
|
children: s,
|
|
475
475
|
className: r,
|
|
476
476
|
columnCount: n,
|
|
477
|
-
columnKey:
|
|
477
|
+
columnKey: o,
|
|
478
478
|
columnWidth: l,
|
|
479
479
|
defaultHeight: f = 0,
|
|
480
480
|
defaultWidth: a = 0,
|
|
481
|
-
dir:
|
|
481
|
+
dir: i,
|
|
482
482
|
gridRef: d,
|
|
483
483
|
onCellsRendered: c,
|
|
484
484
|
onResize: g,
|
|
@@ -493,7 +493,7 @@ function Ve({
|
|
|
493
493
|
const E = he(t), D = R(
|
|
494
494
|
() => ae(e, pe),
|
|
495
495
|
[e]
|
|
496
|
-
), [v, U] = L(null), m = Ie(v,
|
|
496
|
+
), [v, U] = L(null), m = Ie(v, i), {
|
|
497
497
|
getCellBounds: G,
|
|
498
498
|
getEstimatedSize: p,
|
|
499
499
|
startIndexOverscan: O,
|
|
@@ -516,7 +516,7 @@ function Ve({
|
|
|
516
516
|
getCellBounds: V,
|
|
517
517
|
getEstimatedSize: _,
|
|
518
518
|
startIndexOverscan: N,
|
|
519
|
-
startIndexVisible:
|
|
519
|
+
startIndexVisible: ie,
|
|
520
520
|
scrollToIndex: K,
|
|
521
521
|
stopIndexOverscan: Y,
|
|
522
522
|
stopIndexVisible: le
|
|
@@ -596,7 +596,7 @@ function Ve({
|
|
|
596
596
|
{
|
|
597
597
|
columnStartIndex: M,
|
|
598
598
|
columnStopIndex: w,
|
|
599
|
-
rowStartIndex:
|
|
599
|
+
rowStartIndex: ie,
|
|
600
600
|
rowStopIndex: le
|
|
601
601
|
},
|
|
602
602
|
{
|
|
@@ -613,7 +613,7 @@ function Ve({
|
|
|
613
613
|
b,
|
|
614
614
|
w,
|
|
615
615
|
N,
|
|
616
|
-
|
|
616
|
+
ie,
|
|
617
617
|
Y,
|
|
618
618
|
le
|
|
619
619
|
]);
|
|
@@ -634,7 +634,7 @@ function Ve({
|
|
|
634
634
|
role: "gridcell"
|
|
635
635
|
},
|
|
636
636
|
columnIndex: A,
|
|
637
|
-
key:
|
|
637
|
+
key: o ? o({
|
|
638
638
|
columnIndex: A,
|
|
639
639
|
data: E,
|
|
640
640
|
rowIndex: y
|
|
@@ -672,7 +672,7 @@ function Ve({
|
|
|
672
672
|
D,
|
|
673
673
|
E,
|
|
674
674
|
n,
|
|
675
|
-
|
|
675
|
+
o,
|
|
676
676
|
O,
|
|
677
677
|
b,
|
|
678
678
|
G,
|
|
@@ -701,7 +701,7 @@ function Ve({
|
|
|
701
701
|
role: "grid",
|
|
702
702
|
...T,
|
|
703
703
|
className: r,
|
|
704
|
-
dir:
|
|
704
|
+
dir: i,
|
|
705
705
|
ref: U,
|
|
706
706
|
style: {
|
|
707
707
|
position: "relative",
|
|
@@ -728,11 +728,11 @@ function Le({
|
|
|
728
728
|
defaultHeight: s = 0,
|
|
729
729
|
listRef: r,
|
|
730
730
|
onResize: n,
|
|
731
|
-
onRowsRendered:
|
|
731
|
+
onRowsRendered: o,
|
|
732
732
|
overscanCount: l = 3,
|
|
733
733
|
rowComponent: f,
|
|
734
734
|
rowCount: a,
|
|
735
|
-
rowHeight:
|
|
735
|
+
rowHeight: i,
|
|
736
736
|
rowKey: d,
|
|
737
737
|
rowProps: c,
|
|
738
738
|
tagName: g = "div",
|
|
@@ -742,7 +742,7 @@ function Le({
|
|
|
742
742
|
const h = he(c), z = R(
|
|
743
743
|
() => ae(f, pe),
|
|
744
744
|
[f]
|
|
745
|
-
), [u, j] = L(null), T = Te(
|
|
745
|
+
), [u, j] = L(null), T = Te(i), E = R(() => T ? (b) => i.getRowHeight(b) ?? i.getAverageRowHeight() : i, [T, i]), {
|
|
746
746
|
getCellBounds: D,
|
|
747
747
|
getEstimatedSize: v,
|
|
748
748
|
scrollToIndex: U,
|
|
@@ -794,15 +794,15 @@ function Le({
|
|
|
794
794
|
return w.setAttribute(ne, _), !0;
|
|
795
795
|
});
|
|
796
796
|
if (T)
|
|
797
|
-
return
|
|
797
|
+
return i.observeRowElements(b);
|
|
798
798
|
}, [
|
|
799
799
|
u,
|
|
800
800
|
T,
|
|
801
|
-
|
|
801
|
+
i,
|
|
802
802
|
m,
|
|
803
803
|
p
|
|
804
804
|
]), Z(() => {
|
|
805
|
-
m >= 0 && p >= 0 &&
|
|
805
|
+
m >= 0 && p >= 0 && o && o(
|
|
806
806
|
{
|
|
807
807
|
startIndex: G,
|
|
808
808
|
stopIndex: O
|
|
@@ -813,7 +813,7 @@ function Le({
|
|
|
813
813
|
}
|
|
814
814
|
);
|
|
815
815
|
}, [
|
|
816
|
-
|
|
816
|
+
o,
|
|
817
817
|
m,
|
|
818
818
|
G,
|
|
819
819
|
p,
|
|
@@ -902,7 +902,7 @@ function Me({
|
|
|
902
902
|
key: t,
|
|
903
903
|
map: /* @__PURE__ */ new Map()
|
|
904
904
|
});
|
|
905
|
-
const { map: n } = s,
|
|
905
|
+
const { map: n } = s, o = B(() => {
|
|
906
906
|
let c = 0;
|
|
907
907
|
return n.forEach((g) => {
|
|
908
908
|
c += g;
|
|
@@ -935,31 +935,31 @@ function Me({
|
|
|
935
935
|
u && f(z, u);
|
|
936
936
|
});
|
|
937
937
|
}
|
|
938
|
-
), [
|
|
938
|
+
), [i] = L(() => {
|
|
939
939
|
if (typeof ResizeObserver < "u")
|
|
940
940
|
return new ResizeObserver(a);
|
|
941
941
|
});
|
|
942
942
|
Z(() => {
|
|
943
|
-
if (
|
|
943
|
+
if (i)
|
|
944
944
|
return () => {
|
|
945
|
-
|
|
945
|
+
i.disconnect();
|
|
946
946
|
};
|
|
947
|
-
}, [
|
|
947
|
+
}, [i]);
|
|
948
948
|
const d = B(
|
|
949
|
-
(c) =>
|
|
950
|
-
c.forEach((g) =>
|
|
949
|
+
(c) => i ? (c.forEach((g) => i.observe(g)), () => {
|
|
950
|
+
c.forEach((g) => i.unobserve(g));
|
|
951
951
|
}) : () => {
|
|
952
952
|
},
|
|
953
|
-
[
|
|
953
|
+
[i]
|
|
954
954
|
);
|
|
955
955
|
return R(
|
|
956
956
|
() => ({
|
|
957
|
-
getAverageRowHeight:
|
|
957
|
+
getAverageRowHeight: o,
|
|
958
958
|
getRowHeight: l,
|
|
959
959
|
setRowHeight: f,
|
|
960
960
|
observeRowElements: d
|
|
961
961
|
}),
|
|
962
|
-
[
|
|
962
|
+
[o, l, f, d]
|
|
963
963
|
);
|
|
964
964
|
}
|
|
965
965
|
const $e = L, He = P;
|