react-window 1.8.10 → 2.0.0-alpha.0
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/README.md +9 -161
- package/dist/react-window.cjs +22 -0
- package/dist/react-window.d.ts +217 -0
- package/dist/react-window.js +812 -0
- package/docs/assets/index-DlGpNu0r.css +1 -0
- package/docs/assets/index-fVOw1dKb.js +67 -0
- package/docs/data/addresses.json +7954 -0
- package/docs/data/contacts.json +4202 -0
- package/docs/data/names.json +1002 -0
- package/docs/favicon.svg +16 -0
- package/docs/generated/README.md +1 -0
- package/docs/generated/code-snippets/CellComponent.json +4 -0
- package/docs/generated/code-snippets/FixedHeightList.json +4 -0
- package/docs/generated/code-snippets/FixedHeightRowComponent.json +4 -0
- package/docs/generated/code-snippets/FlexboxLayout.json +4 -0
- package/docs/generated/code-snippets/Grid.json +4 -0
- package/docs/generated/code-snippets/ListVariableRowHeights.json +4 -0
- package/docs/generated/code-snippets/columnWidth.json +4 -0
- package/docs/generated/code-snippets/gridRefClickEventHandler.json +3 -0
- package/docs/generated/code-snippets/listRefClickEventHandler.json +3 -0
- package/docs/generated/code-snippets/rowHeight.json +4 -0
- package/docs/generated/code-snippets/useGridRef.json +4 -0
- package/docs/generated/code-snippets/useGridRefImport.json +3 -0
- package/docs/generated/code-snippets/useListRef.json +4 -0
- package/docs/generated/code-snippets/useListRefImport.json +3 -0
- package/docs/generated/js-docs/Grid.json +314 -0
- package/docs/generated/js-docs/List.json +266 -0
- package/docs/index.html +30 -0
- package/docs/og.html +42 -0
- package/docs/og.png +0 -0
- package/docs/stats.html +4949 -0
- package/docs/svgs/checkbox-checked.svg +1 -0
- package/docs/svgs/checkbox-indeterminate.svg +1 -0
- package/docs/svgs/checkbox-unchecked.svg +1 -0
- package/docs/svgs/github.svg +3 -0
- package/docs/svgs/npm.svg +1 -0
- package/docs/svgs/radio-checked.svg +1 -0
- package/docs/svgs/radio-unchecked.svg +1 -0
- package/package.json +70 -90
- package/LICENSE.md +0 -21
- package/dist/index-dev.umd.js +0 -2
- package/dist/index-dev.umd.js.map +0 -1
- package/dist/index-prod.umd.js +0 -2
- package/dist/index-prod.umd.js.map +0 -1
- package/dist/index.cjs.js +0 -2087
- package/dist/index.cjs.js.flow +0 -3
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -2076
- package/dist/index.esm.js.flow +0 -3
- package/dist/index.esm.js.map +0 -1
- package/src/FixedSizeGrid.js +0 -244
- package/src/FixedSizeList.js +0 -137
- package/src/VariableSizeGrid.js +0 -507
- package/src/VariableSizeList.js +0 -317
- package/src/areEqual.js +0 -18
- package/src/createGridComponent.js +0 -919
- package/src/createListComponent.js +0 -745
- package/src/domHelpers.js +0 -72
- package/src/index.js +0 -9
- package/src/shallowDiffers.js +0 -17
- package/src/shouldComponentUpdate.js +0 -16
- package/src/timer.js +0 -37
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
import Ee, { useLayoutEffect as ce, useEffect as Q, useMemo as y, useState as K, useSyncExternalStore as ge, memo as ae, useImperativeHandle as ue, createElement as fe, useRef as he } from "react";
|
|
2
|
+
var G = { exports: {} }, D = {};
|
|
3
|
+
/**
|
|
4
|
+
* @license React
|
|
5
|
+
* react-jsx-runtime.production.js
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
var re;
|
|
13
|
+
function xe() {
|
|
14
|
+
if (re) return D;
|
|
15
|
+
re = 1;
|
|
16
|
+
var i = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
17
|
+
function n(o, r, s) {
|
|
18
|
+
var c = null;
|
|
19
|
+
if (s !== void 0 && (c = "" + s), r.key !== void 0 && (c = "" + r.key), "key" in r) {
|
|
20
|
+
s = {};
|
|
21
|
+
for (var a in r)
|
|
22
|
+
a !== "key" && (s[a] = r[a]);
|
|
23
|
+
} else s = r;
|
|
24
|
+
return r = s.ref, {
|
|
25
|
+
$$typeof: i,
|
|
26
|
+
type: o,
|
|
27
|
+
key: c,
|
|
28
|
+
ref: r !== void 0 ? r : null,
|
|
29
|
+
props: s
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return D.Fragment = t, D.jsx = n, D.jsxs = n, D;
|
|
33
|
+
}
|
|
34
|
+
var U = {};
|
|
35
|
+
/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-jsx-runtime.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
var se;
|
|
45
|
+
function Te() {
|
|
46
|
+
return se || (se = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
|
+
function i(e) {
|
|
48
|
+
if (e == null) return null;
|
|
49
|
+
if (typeof e == "function")
|
|
50
|
+
return e.$$typeof === C ? null : e.displayName || e.name || null;
|
|
51
|
+
if (typeof e == "string") return e;
|
|
52
|
+
switch (e) {
|
|
53
|
+
case T:
|
|
54
|
+
return "Fragment";
|
|
55
|
+
case b:
|
|
56
|
+
return "Profiler";
|
|
57
|
+
case S:
|
|
58
|
+
return "StrictMode";
|
|
59
|
+
case I:
|
|
60
|
+
return "Suspense";
|
|
61
|
+
case f:
|
|
62
|
+
return "SuspenseList";
|
|
63
|
+
case Y:
|
|
64
|
+
return "Activity";
|
|
65
|
+
}
|
|
66
|
+
if (typeof e == "object")
|
|
67
|
+
switch (typeof e.tag == "number" && console.error(
|
|
68
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
+
), e.$$typeof) {
|
|
70
|
+
case w:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case P:
|
|
73
|
+
return (e.displayName || "Context") + ".Provider";
|
|
74
|
+
case A:
|
|
75
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
+
case W:
|
|
77
|
+
var l = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = l.displayName || l.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case v:
|
|
80
|
+
return l = e.displayName || null, l !== null ? l : i(e.type) || "Memo";
|
|
81
|
+
case $:
|
|
82
|
+
l = e._payload, e = e._init;
|
|
83
|
+
try {
|
|
84
|
+
return i(e(l));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function t(e) {
|
|
91
|
+
return "" + e;
|
|
92
|
+
}
|
|
93
|
+
function n(e) {
|
|
94
|
+
try {
|
|
95
|
+
t(e);
|
|
96
|
+
var l = !1;
|
|
97
|
+
} catch {
|
|
98
|
+
l = !0;
|
|
99
|
+
}
|
|
100
|
+
if (l) {
|
|
101
|
+
l = console;
|
|
102
|
+
var u = l.error, h = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return u.call(
|
|
104
|
+
l,
|
|
105
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
+
h
|
|
107
|
+
), t(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function o(e) {
|
|
111
|
+
if (e === T) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === $)
|
|
113
|
+
return "<...>";
|
|
114
|
+
try {
|
|
115
|
+
var l = i(e);
|
|
116
|
+
return l ? "<" + l + ">" : "<...>";
|
|
117
|
+
} catch {
|
|
118
|
+
return "<...>";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function r() {
|
|
122
|
+
var e = N.A;
|
|
123
|
+
return e === null ? null : e.getOwner();
|
|
124
|
+
}
|
|
125
|
+
function s() {
|
|
126
|
+
return Error("react-stack-top-frame");
|
|
127
|
+
}
|
|
128
|
+
function c(e) {
|
|
129
|
+
if (V.call(e, "key")) {
|
|
130
|
+
var l = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (l && l.isReactWarning) return !1;
|
|
132
|
+
}
|
|
133
|
+
return e.key !== void 0;
|
|
134
|
+
}
|
|
135
|
+
function a(e, l) {
|
|
136
|
+
function u() {
|
|
137
|
+
_ || (_ = !0, console.error(
|
|
138
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
+
l
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
u.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: u,
|
|
144
|
+
configurable: !0
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function g() {
|
|
148
|
+
var e = i(this.type);
|
|
149
|
+
return j[e] || (j[e] = !0, console.error(
|
|
150
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
|
+
}
|
|
153
|
+
function R(e, l, u, h, M, z, H, J) {
|
|
154
|
+
return u = z.ref, e = {
|
|
155
|
+
$$typeof: O,
|
|
156
|
+
type: e,
|
|
157
|
+
key: l,
|
|
158
|
+
props: z,
|
|
159
|
+
_owner: M
|
|
160
|
+
}, (u !== void 0 ? u : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
|
+
enumerable: !1,
|
|
162
|
+
get: g
|
|
163
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
164
|
+
configurable: !1,
|
|
165
|
+
enumerable: !1,
|
|
166
|
+
writable: !0,
|
|
167
|
+
value: 0
|
|
168
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
169
|
+
configurable: !1,
|
|
170
|
+
enumerable: !1,
|
|
171
|
+
writable: !0,
|
|
172
|
+
value: null
|
|
173
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
174
|
+
configurable: !1,
|
|
175
|
+
enumerable: !1,
|
|
176
|
+
writable: !0,
|
|
177
|
+
value: H
|
|
178
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
179
|
+
configurable: !1,
|
|
180
|
+
enumerable: !1,
|
|
181
|
+
writable: !0,
|
|
182
|
+
value: J
|
|
183
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
|
+
}
|
|
185
|
+
function k(e, l, u, h, M, z, H, J) {
|
|
186
|
+
var d = l.children;
|
|
187
|
+
if (d !== void 0)
|
|
188
|
+
if (h)
|
|
189
|
+
if (p(d)) {
|
|
190
|
+
for (h = 0; h < d.length; h++)
|
|
191
|
+
m(d[h]);
|
|
192
|
+
Object.freeze && Object.freeze(d);
|
|
193
|
+
} else
|
|
194
|
+
console.error(
|
|
195
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
|
+
);
|
|
197
|
+
else m(d);
|
|
198
|
+
if (V.call(l, "key")) {
|
|
199
|
+
d = i(e);
|
|
200
|
+
var L = Object.keys(l).filter(function(pe) {
|
|
201
|
+
return pe !== "key";
|
|
202
|
+
});
|
|
203
|
+
h = 0 < L.length ? "{key: someKey, " + L.join(": ..., ") + ": ...}" : "{key: someKey}", te[d + h] || (L = 0 < L.length ? "{" + L.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
205
|
+
let props = %s;
|
|
206
|
+
<%s {...props} />
|
|
207
|
+
React keys must be passed directly to JSX without using spread:
|
|
208
|
+
let props = %s;
|
|
209
|
+
<%s key={someKey} {...props} />`,
|
|
210
|
+
h,
|
|
211
|
+
d,
|
|
212
|
+
L,
|
|
213
|
+
d
|
|
214
|
+
), te[d + h] = !0);
|
|
215
|
+
}
|
|
216
|
+
if (d = null, u !== void 0 && (n(u), d = "" + u), c(l) && (n(l.key), d = "" + l.key), "key" in l) {
|
|
217
|
+
u = {};
|
|
218
|
+
for (var X in l)
|
|
219
|
+
X !== "key" && (u[X] = l[X]);
|
|
220
|
+
} else u = l;
|
|
221
|
+
return d && a(
|
|
222
|
+
u,
|
|
223
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
+
), R(
|
|
225
|
+
e,
|
|
226
|
+
d,
|
|
227
|
+
z,
|
|
228
|
+
M,
|
|
229
|
+
r(),
|
|
230
|
+
u,
|
|
231
|
+
H,
|
|
232
|
+
J
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function m(e) {
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === O && e._store && (e._store.validated = 1);
|
|
237
|
+
}
|
|
238
|
+
var x = Ee, O = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), P = Symbol.for("react.context"), W = Symbol.for("react.forward_ref"), I = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), v = Symbol.for("react.memo"), $ = Symbol.for("react.lazy"), Y = Symbol.for("react.activity"), C = Symbol.for("react.client.reference"), N = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, V = Object.prototype.hasOwnProperty, p = Array.isArray, E = console.createTask ? console.createTask : function() {
|
|
239
|
+
return null;
|
|
240
|
+
};
|
|
241
|
+
x = {
|
|
242
|
+
"react-stack-bottom-frame": function(e) {
|
|
243
|
+
return e();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var _, j = {}, F = x["react-stack-bottom-frame"].bind(
|
|
247
|
+
x,
|
|
248
|
+
s
|
|
249
|
+
)(), ee = E(o(s)), te = {};
|
|
250
|
+
U.Fragment = T, U.jsx = function(e, l, u, h, M) {
|
|
251
|
+
var z = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return k(
|
|
253
|
+
e,
|
|
254
|
+
l,
|
|
255
|
+
u,
|
|
256
|
+
!1,
|
|
257
|
+
h,
|
|
258
|
+
M,
|
|
259
|
+
z ? Error("react-stack-top-frame") : F,
|
|
260
|
+
z ? E(o(e)) : ee
|
|
261
|
+
);
|
|
262
|
+
}, U.jsxs = function(e, l, u, h, M) {
|
|
263
|
+
var z = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return k(
|
|
265
|
+
e,
|
|
266
|
+
l,
|
|
267
|
+
u,
|
|
268
|
+
!0,
|
|
269
|
+
h,
|
|
270
|
+
M,
|
|
271
|
+
z ? Error("react-stack-top-frame") : F,
|
|
272
|
+
z ? E(o(e)) : ee
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
}()), U;
|
|
276
|
+
}
|
|
277
|
+
var ne;
|
|
278
|
+
function we() {
|
|
279
|
+
return ne || (ne = 1, process.env.NODE_ENV === "production" ? G.exports = xe() : G.exports = Te()), G.exports;
|
|
280
|
+
}
|
|
281
|
+
var q = we();
|
|
282
|
+
function oe(i) {
|
|
283
|
+
if (i !== void 0)
|
|
284
|
+
switch (typeof i) {
|
|
285
|
+
case "number":
|
|
286
|
+
return i;
|
|
287
|
+
case "string": {
|
|
288
|
+
if (i.endsWith("px"))
|
|
289
|
+
return parseFloat(i);
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const Re = typeof window < "u" ? ce : Q;
|
|
295
|
+
function de({
|
|
296
|
+
box: i,
|
|
297
|
+
defaultHeight: t,
|
|
298
|
+
defaultWidth: n,
|
|
299
|
+
disabled: o,
|
|
300
|
+
element: r,
|
|
301
|
+
mode: s,
|
|
302
|
+
style: c
|
|
303
|
+
}) {
|
|
304
|
+
const { styleHeight: a, styleWidth: g } = y(
|
|
305
|
+
() => ({
|
|
306
|
+
styleHeight: oe(c?.height),
|
|
307
|
+
styleWidth: oe(c?.width)
|
|
308
|
+
}),
|
|
309
|
+
[c?.height, c?.width]
|
|
310
|
+
), [R, k] = K({
|
|
311
|
+
height: t,
|
|
312
|
+
width: n
|
|
313
|
+
}), m = o || s === "only-height" && a !== void 0 || s === "only-width" && g !== void 0 || a !== void 0 && g !== void 0;
|
|
314
|
+
return Re(() => {
|
|
315
|
+
if (r === null || m)
|
|
316
|
+
return;
|
|
317
|
+
const x = new ResizeObserver((O) => {
|
|
318
|
+
for (const w of O) {
|
|
319
|
+
const { contentRect: T, target: S } = w;
|
|
320
|
+
r === S && k((b) => b.height === T.height && b.width === T.width ? b : {
|
|
321
|
+
height: T.height,
|
|
322
|
+
width: T.width
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
return x.observe(r, { box: i }), () => {
|
|
327
|
+
x?.unobserve(r);
|
|
328
|
+
};
|
|
329
|
+
}, [i, m, r, a, g]), y(
|
|
330
|
+
() => ({
|
|
331
|
+
height: a ?? R.height,
|
|
332
|
+
width: g ?? R.width
|
|
333
|
+
}),
|
|
334
|
+
[R, a, g]
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
function me(i) {
|
|
338
|
+
return y(() => i, Object.values(i));
|
|
339
|
+
}
|
|
340
|
+
function B(i, t = "Assertion error") {
|
|
341
|
+
if (!i)
|
|
342
|
+
throw console.error(t), Error(t);
|
|
343
|
+
}
|
|
344
|
+
class Oe {
|
|
345
|
+
#e;
|
|
346
|
+
#l;
|
|
347
|
+
#s;
|
|
348
|
+
#c;
|
|
349
|
+
#o;
|
|
350
|
+
#r;
|
|
351
|
+
#u;
|
|
352
|
+
#t = 0;
|
|
353
|
+
#n = 0;
|
|
354
|
+
#i = 0;
|
|
355
|
+
#a = -1;
|
|
356
|
+
constructor({
|
|
357
|
+
count: t,
|
|
358
|
+
defaultSize: n,
|
|
359
|
+
direction: o,
|
|
360
|
+
element: r,
|
|
361
|
+
itemSize: s,
|
|
362
|
+
overscanCount: c
|
|
363
|
+
}) {
|
|
364
|
+
B(r), this.#e = /* @__PURE__ */ new Map(), this.#l = /* @__PURE__ */ new Set(), this.#s = t, this.#c = o, this.#o = r, this.#r = s, this.#u = c, this.#n = n ?? 0, this.#o.addEventListener("scroll", this.#h);
|
|
365
|
+
}
|
|
366
|
+
getEstimatedHeight() {
|
|
367
|
+
if (typeof this.#r == "number")
|
|
368
|
+
return this.#s * this.#r;
|
|
369
|
+
if (this.#e.size > 0) {
|
|
370
|
+
const t = this.#e.get(this.#e.size - 1);
|
|
371
|
+
B(t !== void 0, "Unexpected bounds cache miss");
|
|
372
|
+
const n = (t.scrollOffset + t.size) / this.#e.size;
|
|
373
|
+
return this.#s * n;
|
|
374
|
+
} else
|
|
375
|
+
return 0;
|
|
376
|
+
}
|
|
377
|
+
getIndices() {
|
|
378
|
+
return this.#i < 0 ? [0, -1] : [this.#i, this.#a];
|
|
379
|
+
}
|
|
380
|
+
getItemBounds(t) {
|
|
381
|
+
if (typeof this.#r == "number")
|
|
382
|
+
return {
|
|
383
|
+
scrollOffset: t * this.#r,
|
|
384
|
+
size: this.#r
|
|
385
|
+
};
|
|
386
|
+
for (; this.#e.size - 1 < t; ) {
|
|
387
|
+
const o = this.#e.size, r = typeof this.#r == "number" ? this.#r : this.#r(o);
|
|
388
|
+
if (o === 0)
|
|
389
|
+
this.#e.set(o, {
|
|
390
|
+
size: r,
|
|
391
|
+
scrollOffset: 0
|
|
392
|
+
});
|
|
393
|
+
else {
|
|
394
|
+
const s = this.#e.get(o - 1);
|
|
395
|
+
B(
|
|
396
|
+
s !== void 0,
|
|
397
|
+
`Unexpected bounds cache miss for index ${t}`
|
|
398
|
+
), this.#e.set(o, {
|
|
399
|
+
scrollOffset: s.scrollOffset + s.size,
|
|
400
|
+
size: r
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const n = this.#e.get(t);
|
|
405
|
+
return B(
|
|
406
|
+
n !== void 0,
|
|
407
|
+
`Unexpected bounds cache miss for index ${t}`
|
|
408
|
+
), n;
|
|
409
|
+
}
|
|
410
|
+
resize(t) {
|
|
411
|
+
this.#n = t, this.#f();
|
|
412
|
+
}
|
|
413
|
+
subscribe = (t) => (this.#l.add(t), () => {
|
|
414
|
+
this.#l.delete(t);
|
|
415
|
+
});
|
|
416
|
+
version = () => `${this.#i}-${this.#a}`;
|
|
417
|
+
scrollToIndex({
|
|
418
|
+
align: t = "auto",
|
|
419
|
+
behavior: n,
|
|
420
|
+
index: o
|
|
421
|
+
}) {
|
|
422
|
+
const r = this.#d(o, t);
|
|
423
|
+
this.#c === "horizontal" ? this.#o?.scrollTo({
|
|
424
|
+
left: r,
|
|
425
|
+
behavior: n || void 0
|
|
426
|
+
}) : this.#o?.scrollTo({
|
|
427
|
+
behavior: n || void 0,
|
|
428
|
+
top: r
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
scrollForTest(t) {
|
|
432
|
+
this.#t = t, this.#f();
|
|
433
|
+
}
|
|
434
|
+
#h = () => {
|
|
435
|
+
const { clientHeight: t, scrollHeight: n, scrollLeft: o, scrollTop: r, scrollWidth: s } = this.#o, c = this.#c === "vertical" ? r : o, a = this.#c === "vertical" ? n : s;
|
|
436
|
+
this.#t !== c && (this.#t = Math.max(
|
|
437
|
+
0,
|
|
438
|
+
Math.min(c, a - t)
|
|
439
|
+
), this.#f());
|
|
440
|
+
};
|
|
441
|
+
#d(t, n) {
|
|
442
|
+
const o = this.getItemBounds(this.#s - 1).scrollOffset, r = o + this.getItemBounds(this.#s - 1).scrollOffset - this.#n, s = Math.max(
|
|
443
|
+
0,
|
|
444
|
+
this.getItemBounds(t + 1).scrollOffset - this.#n
|
|
445
|
+
), c = Math.min(
|
|
446
|
+
o,
|
|
447
|
+
this.getItemBounds(t).scrollOffset
|
|
448
|
+
);
|
|
449
|
+
switch (n === "smart" && (this.#t >= s && this.#t <= c ? n = "auto" : n = "center"), n) {
|
|
450
|
+
case "start":
|
|
451
|
+
return Math.min(r, c);
|
|
452
|
+
case "end":
|
|
453
|
+
return s;
|
|
454
|
+
case "center": {
|
|
455
|
+
const a = Math.round(
|
|
456
|
+
s + (c - s) / 2
|
|
457
|
+
);
|
|
458
|
+
return a < Math.ceil(this.#n / 2) ? 0 : a > r ? r : a;
|
|
459
|
+
}
|
|
460
|
+
case "auto":
|
|
461
|
+
default:
|
|
462
|
+
return this.#t >= s && this.#t <= c ? this.#t : this.#t < s ? s : c;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
#m() {
|
|
466
|
+
this.#l.forEach((t) => t());
|
|
467
|
+
}
|
|
468
|
+
#f() {
|
|
469
|
+
const t = this.#s - 1;
|
|
470
|
+
let n = 0, o = -1, r = 0;
|
|
471
|
+
for (; r < t; ) {
|
|
472
|
+
const s = this.getItemBounds(r);
|
|
473
|
+
if (s.scrollOffset + s.size > this.#t)
|
|
474
|
+
break;
|
|
475
|
+
r++;
|
|
476
|
+
}
|
|
477
|
+
for (n = r, n = Math.max(0, n - this.#u); r < t; ) {
|
|
478
|
+
const s = this.getItemBounds(r);
|
|
479
|
+
if (s.scrollOffset + s.size >= this.#t + this.#n)
|
|
480
|
+
break;
|
|
481
|
+
r++;
|
|
482
|
+
}
|
|
483
|
+
o = Math.min(t, r), o = Math.min(this.#s - 1, o + this.#u), (this.#i !== n || this.#a !== o) && (this.#i = n, this.#a = o, this.#m());
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function Z({
|
|
487
|
+
count: i,
|
|
488
|
+
defaultSize: t,
|
|
489
|
+
direction: n,
|
|
490
|
+
element: o,
|
|
491
|
+
itemSize: r,
|
|
492
|
+
overscanCount: s,
|
|
493
|
+
size: c
|
|
494
|
+
}) {
|
|
495
|
+
const a = y(
|
|
496
|
+
() => o ? new Oe({
|
|
497
|
+
count: i,
|
|
498
|
+
defaultSize: t,
|
|
499
|
+
direction: n,
|
|
500
|
+
element: o,
|
|
501
|
+
itemSize: r,
|
|
502
|
+
overscanCount: s
|
|
503
|
+
}) : null,
|
|
504
|
+
[i, t, n, o, r, s]
|
|
505
|
+
);
|
|
506
|
+
return ce(() => {
|
|
507
|
+
c !== void 0 && a?.resize(c);
|
|
508
|
+
}, [c, a]), ge(
|
|
509
|
+
a?.subscribe ?? be,
|
|
510
|
+
a?.version ?? ie,
|
|
511
|
+
a?.version ?? ie
|
|
512
|
+
), a;
|
|
513
|
+
}
|
|
514
|
+
function be() {
|
|
515
|
+
return be;
|
|
516
|
+
}
|
|
517
|
+
function ie() {
|
|
518
|
+
return "";
|
|
519
|
+
}
|
|
520
|
+
function le(i, t) {
|
|
521
|
+
if (i === t)
|
|
522
|
+
return !0;
|
|
523
|
+
if (!!i != !!t || (B(i !== void 0), B(t !== void 0), Object.keys(i).length !== Object.keys(t).length))
|
|
524
|
+
return !1;
|
|
525
|
+
for (const n in i)
|
|
526
|
+
if (!Object.is(t[n], i[n]))
|
|
527
|
+
return !1;
|
|
528
|
+
return !0;
|
|
529
|
+
}
|
|
530
|
+
function ve(i, t) {
|
|
531
|
+
const { style: n, ...o } = i, { style: r, ...s } = t;
|
|
532
|
+
return le(n, r) && le(o, s);
|
|
533
|
+
}
|
|
534
|
+
function _e({
|
|
535
|
+
cellComponent: i,
|
|
536
|
+
cellProps: t,
|
|
537
|
+
className: n,
|
|
538
|
+
columnCount: o,
|
|
539
|
+
columnWidth: r,
|
|
540
|
+
defaultHeight: s,
|
|
541
|
+
defaultWidth: c,
|
|
542
|
+
gridRef: a,
|
|
543
|
+
onCellsRendered: g,
|
|
544
|
+
overscanCount: R = 3,
|
|
545
|
+
rowCount: k,
|
|
546
|
+
rowHeight: m,
|
|
547
|
+
style: x,
|
|
548
|
+
...O
|
|
549
|
+
}) {
|
|
550
|
+
const w = me(t), T = y(
|
|
551
|
+
() => ae(i, ve),
|
|
552
|
+
[i]
|
|
553
|
+
), [S, b] = K(null), { height: A = 0, width: P = 0 } = de({
|
|
554
|
+
defaultHeight: s,
|
|
555
|
+
defaultWidth: c,
|
|
556
|
+
element: S,
|
|
557
|
+
style: x
|
|
558
|
+
}), W = y(() => typeof r == "number" ? r : (p) => r(p, w), [r, w]), I = y(() => typeof m == "number" ? m : (p) => m(p, w), [m, w]), f = Z({
|
|
559
|
+
count: o,
|
|
560
|
+
defaultSize: c,
|
|
561
|
+
direction: "horizontal",
|
|
562
|
+
element: S,
|
|
563
|
+
itemSize: W,
|
|
564
|
+
overscanCount: R,
|
|
565
|
+
size: P
|
|
566
|
+
}), v = Z({
|
|
567
|
+
count: k,
|
|
568
|
+
defaultSize: s,
|
|
569
|
+
direction: "vertical",
|
|
570
|
+
element: S,
|
|
571
|
+
itemSize: I,
|
|
572
|
+
overscanCount: R,
|
|
573
|
+
size: A
|
|
574
|
+
}), [$, Y] = f?.getIndices() ?? [-1, 0], [C, N] = v?.getIndices() ?? [-1, 0];
|
|
575
|
+
ue(
|
|
576
|
+
a,
|
|
577
|
+
() => ({
|
|
578
|
+
get element() {
|
|
579
|
+
return S;
|
|
580
|
+
},
|
|
581
|
+
scrollToCell({
|
|
582
|
+
behavior: p = "auto",
|
|
583
|
+
columnAlign: E = "auto",
|
|
584
|
+
columnIndex: _,
|
|
585
|
+
rowAlign: j = "auto",
|
|
586
|
+
rowIndex: F
|
|
587
|
+
}) {
|
|
588
|
+
v?.scrollToIndex({
|
|
589
|
+
align: j,
|
|
590
|
+
behavior: p,
|
|
591
|
+
index: F
|
|
592
|
+
}), f?.scrollToIndex({
|
|
593
|
+
behavior: p,
|
|
594
|
+
align: E,
|
|
595
|
+
index: _
|
|
596
|
+
});
|
|
597
|
+
},
|
|
598
|
+
scrollToColumn({
|
|
599
|
+
align: p = "auto",
|
|
600
|
+
behavior: E = "auto",
|
|
601
|
+
index: _
|
|
602
|
+
}) {
|
|
603
|
+
f?.scrollToIndex({
|
|
604
|
+
align: p,
|
|
605
|
+
behavior: E,
|
|
606
|
+
index: _
|
|
607
|
+
});
|
|
608
|
+
},
|
|
609
|
+
scrollToRow({
|
|
610
|
+
align: p = "auto",
|
|
611
|
+
behavior: E = "auto",
|
|
612
|
+
index: _
|
|
613
|
+
}) {
|
|
614
|
+
v?.scrollToIndex({ align: p, behavior: E, index: _ });
|
|
615
|
+
}
|
|
616
|
+
}),
|
|
617
|
+
[f, S, v]
|
|
618
|
+
), Q(() => {
|
|
619
|
+
$ >= 0 && Y >= 0 && C >= 0 && N >= 0 && g && g({
|
|
620
|
+
columnStartIndex: $,
|
|
621
|
+
columnStopIndex: Y,
|
|
622
|
+
rowStartIndex: C,
|
|
623
|
+
rowStopIndex: N
|
|
624
|
+
});
|
|
625
|
+
}, [
|
|
626
|
+
g,
|
|
627
|
+
$,
|
|
628
|
+
Y,
|
|
629
|
+
C,
|
|
630
|
+
N
|
|
631
|
+
]);
|
|
632
|
+
const V = y(() => {
|
|
633
|
+
const p = [];
|
|
634
|
+
if (f && o > 0 && v && k > 0)
|
|
635
|
+
for (let E = C; E <= N; E++) {
|
|
636
|
+
const _ = v.getItemBounds(E);
|
|
637
|
+
for (let j = $; j <= Y; j++) {
|
|
638
|
+
const F = f.getItemBounds(j);
|
|
639
|
+
p.push(
|
|
640
|
+
/* @__PURE__ */ fe(
|
|
641
|
+
T,
|
|
642
|
+
{
|
|
643
|
+
...w,
|
|
644
|
+
columnIndex: j,
|
|
645
|
+
key: `${E}-${j}`,
|
|
646
|
+
rowIndex: E,
|
|
647
|
+
style: {
|
|
648
|
+
position: "absolute",
|
|
649
|
+
left: 0,
|
|
650
|
+
transform: `translate(${F.scrollOffset}px, ${_.scrollOffset}px)`,
|
|
651
|
+
height: _.size,
|
|
652
|
+
width: F.size
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
)
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return p;
|
|
660
|
+
}, [
|
|
661
|
+
T,
|
|
662
|
+
w,
|
|
663
|
+
o,
|
|
664
|
+
$,
|
|
665
|
+
Y,
|
|
666
|
+
f,
|
|
667
|
+
k,
|
|
668
|
+
C,
|
|
669
|
+
N,
|
|
670
|
+
v
|
|
671
|
+
]);
|
|
672
|
+
return /* @__PURE__ */ q.jsx(
|
|
673
|
+
"div",
|
|
674
|
+
{
|
|
675
|
+
role: "grid",
|
|
676
|
+
...O,
|
|
677
|
+
className: n,
|
|
678
|
+
ref: b,
|
|
679
|
+
style: {
|
|
680
|
+
...x,
|
|
681
|
+
maxHeight: "100%",
|
|
682
|
+
maxWidth: "100%",
|
|
683
|
+
flexGrow: 1,
|
|
684
|
+
overflow: "auto"
|
|
685
|
+
},
|
|
686
|
+
children: /* @__PURE__ */ q.jsx(
|
|
687
|
+
"div",
|
|
688
|
+
{
|
|
689
|
+
className: n,
|
|
690
|
+
style: {
|
|
691
|
+
position: "relative",
|
|
692
|
+
height: v?.getEstimatedHeight(),
|
|
693
|
+
width: f?.getEstimatedHeight()
|
|
694
|
+
},
|
|
695
|
+
children: V
|
|
696
|
+
}
|
|
697
|
+
)
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
const ye = he;
|
|
702
|
+
function ke({
|
|
703
|
+
className: i,
|
|
704
|
+
defaultHeight: t = 0,
|
|
705
|
+
listRef: n,
|
|
706
|
+
onRowsRendered: o,
|
|
707
|
+
overscanCount: r = 3,
|
|
708
|
+
rowComponent: s,
|
|
709
|
+
rowCount: c,
|
|
710
|
+
rowHeight: a,
|
|
711
|
+
rowProps: g,
|
|
712
|
+
style: R,
|
|
713
|
+
...k
|
|
714
|
+
}) {
|
|
715
|
+
const m = me(g), x = y(
|
|
716
|
+
() => ae(s, ve),
|
|
717
|
+
[s]
|
|
718
|
+
), [O, w] = K(null), { height: T = 0 } = de({
|
|
719
|
+
defaultHeight: t,
|
|
720
|
+
element: O,
|
|
721
|
+
mode: "only-height",
|
|
722
|
+
style: R
|
|
723
|
+
}), S = y(() => typeof a == "number" ? a : (I) => a(I, m), [a, m]), b = Z({
|
|
724
|
+
count: c,
|
|
725
|
+
defaultSize: t,
|
|
726
|
+
direction: "vertical",
|
|
727
|
+
element: O,
|
|
728
|
+
itemSize: S,
|
|
729
|
+
overscanCount: r,
|
|
730
|
+
size: T
|
|
731
|
+
}), [A, P] = b?.getIndices() ?? [-1, 0];
|
|
732
|
+
ue(
|
|
733
|
+
n,
|
|
734
|
+
() => ({
|
|
735
|
+
get element() {
|
|
736
|
+
return O;
|
|
737
|
+
},
|
|
738
|
+
scrollToRow({
|
|
739
|
+
align: I = "auto",
|
|
740
|
+
behavior: f = "auto",
|
|
741
|
+
index: v
|
|
742
|
+
}) {
|
|
743
|
+
b?.scrollToIndex({ align: I, behavior: f, index: v });
|
|
744
|
+
}
|
|
745
|
+
}),
|
|
746
|
+
[O, b]
|
|
747
|
+
), Q(() => {
|
|
748
|
+
A >= 0 && P >= 0 && o && o({
|
|
749
|
+
startIndex: A,
|
|
750
|
+
stopIndex: P
|
|
751
|
+
});
|
|
752
|
+
}, [o, A, P]);
|
|
753
|
+
const W = y(() => {
|
|
754
|
+
const I = [];
|
|
755
|
+
if (b && c > 0)
|
|
756
|
+
for (let f = A; f <= P; f++) {
|
|
757
|
+
const v = b.getItemBounds(f);
|
|
758
|
+
I.push(
|
|
759
|
+
/* @__PURE__ */ fe(
|
|
760
|
+
x,
|
|
761
|
+
{
|
|
762
|
+
...m,
|
|
763
|
+
key: f,
|
|
764
|
+
index: f,
|
|
765
|
+
style: {
|
|
766
|
+
position: "absolute",
|
|
767
|
+
left: 0,
|
|
768
|
+
transform: `translateY(${v.scrollOffset}px)`,
|
|
769
|
+
height: v.size,
|
|
770
|
+
width: "100%"
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
)
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
return I;
|
|
777
|
+
}, [x, c, m, A, P, b]);
|
|
778
|
+
return /* @__PURE__ */ q.jsx(
|
|
779
|
+
"div",
|
|
780
|
+
{
|
|
781
|
+
role: "list",
|
|
782
|
+
...k,
|
|
783
|
+
className: i,
|
|
784
|
+
ref: w,
|
|
785
|
+
style: {
|
|
786
|
+
...R,
|
|
787
|
+
maxHeight: "100%",
|
|
788
|
+
flexGrow: 1,
|
|
789
|
+
overflowY: "auto"
|
|
790
|
+
},
|
|
791
|
+
children: /* @__PURE__ */ q.jsx(
|
|
792
|
+
"div",
|
|
793
|
+
{
|
|
794
|
+
className: i,
|
|
795
|
+
style: {
|
|
796
|
+
height: b?.getEstimatedHeight(),
|
|
797
|
+
position: "relative",
|
|
798
|
+
width: "100%"
|
|
799
|
+
},
|
|
800
|
+
children: W
|
|
801
|
+
}
|
|
802
|
+
)
|
|
803
|
+
}
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
const Ie = he;
|
|
807
|
+
export {
|
|
808
|
+
_e as Grid,
|
|
809
|
+
ke as List,
|
|
810
|
+
ye as useGridRef,
|
|
811
|
+
Ie as useListRef
|
|
812
|
+
};
|