react-window 2.0.0-alpha.2 → 2.0.0-alpha.4

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.
Files changed (29) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/react-window.cjs +1 -1
  3. package/dist/react-window.d.ts +5 -5
  4. package/dist/react-window.js +349 -336
  5. package/docs/assets/index-BsBvdJUI.css +1 -0
  6. package/docs/assets/index-D8tyZCWm.js +67 -0
  7. package/docs/generated/code-snippets/CellComponent.json +2 -2
  8. package/docs/generated/code-snippets/FixedHeightList.json +2 -2
  9. package/docs/generated/code-snippets/FixedHeightRowComponent.json +2 -2
  10. package/docs/generated/code-snippets/FlexboxLayout.json +2 -2
  11. package/docs/generated/code-snippets/Grid.json +2 -2
  12. package/docs/generated/code-snippets/ListVariableRowHeights.json +2 -2
  13. package/docs/generated/code-snippets/columnWidth.json +2 -2
  14. package/docs/generated/code-snippets/gridRefClickEventHandler.json +2 -2
  15. package/docs/generated/code-snippets/listRefClickEventHandler.json +2 -2
  16. package/docs/generated/code-snippets/rowHeight.json +2 -2
  17. package/docs/generated/code-snippets/useGridCallbackRef.json +2 -2
  18. package/docs/generated/code-snippets/useGridRef.json +2 -2
  19. package/docs/generated/code-snippets/useGridRefImport.json +1 -1
  20. package/docs/generated/code-snippets/useListCallbackRef.json +2 -2
  21. package/docs/generated/code-snippets/useListRef.json +2 -2
  22. package/docs/generated/code-snippets/useListRefImport.json +1 -1
  23. package/docs/generated/js-docs/Grid.json +44 -28
  24. package/docs/generated/js-docs/List.json +1 -1
  25. package/docs/index.html +2 -2
  26. package/docs/stats.html +1 -1
  27. package/package.json +1 -1
  28. package/docs/assets/index-BMf3NlnJ.css +0 -1
  29. package/docs/assets/index-BPRxcSBS.js +0 -67
@@ -1,7 +1,7 @@
1
1
  import { jsx as j } from "react/jsx-runtime";
2
- import { useLayoutEffect as J, useEffect as P, useMemo as M, useState as $, useCallback as R, memo as V, useImperativeHandle as U, createElement as F, useRef as Y } from "react";
3
- const q = typeof window < "u" ? J : P;
4
- function W(t) {
2
+ import { useLayoutEffect as D, useEffect as W, useMemo as k, useState as L, useRef as B, useCallback as P, memo as N, useImperativeHandle as Y, createElement as q } from "react";
3
+ const U = typeof window < "u" ? D : W;
4
+ function V(t) {
5
5
  if (t !== void 0)
6
6
  switch (typeof t) {
7
7
  case "number":
@@ -13,431 +13,441 @@ function W(t) {
13
13
  }
14
14
  }
15
15
  }
16
- function K({
16
+ function J({
17
17
  box: t,
18
- defaultHeight: r,
19
- defaultWidth: l,
18
+ defaultHeight: o,
19
+ defaultWidth: n,
20
20
  disabled: s,
21
21
  element: e,
22
- mode: i,
23
- style: n
22
+ mode: f,
23
+ style: l
24
24
  }) {
25
- const { styleHeight: c, styleWidth: o } = M(
25
+ const { styleHeight: c, styleWidth: r } = k(
26
26
  () => ({
27
- styleHeight: W(n?.height),
28
- styleWidth: W(n?.width)
27
+ styleHeight: V(l?.height),
28
+ styleWidth: V(l?.width)
29
29
  }),
30
- [n?.height, n?.width]
31
- ), [f, p] = $({
32
- height: r,
33
- width: l
34
- }), I = s || i === "only-height" && c !== void 0 || i === "only-width" && o !== void 0 || c !== void 0 && o !== void 0;
35
- return q(() => {
30
+ [l?.height, l?.width]
31
+ ), [u, w] = L({
32
+ height: o,
33
+ width: n
34
+ }), I = s || f === "only-height" && c !== void 0 || f === "only-width" && r !== void 0 || c !== void 0 && r !== void 0;
35
+ return U(() => {
36
36
  if (e === null || I)
37
37
  return;
38
- const b = new ResizeObserver((y) => {
39
- for (const w of y) {
40
- const { contentRect: d, target: x } = w;
41
- e === x && p((z) => z.height === d.height && z.width === d.width ? z : {
42
- height: d.height,
43
- width: d.width
38
+ const O = new ResizeObserver((S) => {
39
+ for (const m of S) {
40
+ const { contentRect: a, target: b } = m;
41
+ e === b && w((d) => d.height === a.height && d.width === a.width ? d : {
42
+ height: a.height,
43
+ width: a.width
44
44
  });
45
45
  }
46
46
  });
47
- return b.observe(e, { box: t }), () => {
48
- b?.unobserve(e);
47
+ return O.observe(e, { box: t }), () => {
48
+ O?.unobserve(e);
49
49
  };
50
- }, [t, I, e, c, o]), M(
50
+ }, [t, I, e, c, r]), k(
51
51
  () => ({
52
- height: c ?? f.height,
53
- width: o ?? f.width
52
+ height: c ?? u.height,
53
+ width: r ?? u.width
54
54
  }),
55
- [f, c, o]
55
+ [u, c, r]
56
56
  );
57
57
  }
58
- function E(t, r = "Assertion error") {
58
+ function $(t, o = "Assertion error") {
59
59
  if (!t)
60
- throw console.error(r), Error(r);
60
+ throw console.error(o), Error(o);
61
61
  }
62
- function Q({
62
+ function K({
63
63
  cachedBounds: t,
64
- itemCount: r,
65
- itemSize: l
64
+ itemCount: o,
65
+ itemSize: n
66
66
  }) {
67
- if (typeof l == "number")
68
- return r * l;
67
+ if (typeof n == "number")
68
+ return o * n;
69
69
  if (t.size > 0) {
70
70
  const s = t.get(t.size - 1);
71
- E(s !== void 0, "Unexpected bounds cache miss");
71
+ $(s !== void 0, "Unexpected bounds cache miss");
72
72
  const e = (s.scrollOffset + s.size) / t.size;
73
- return r * e;
73
+ return o * e;
74
74
  } else
75
75
  return 0;
76
76
  }
77
- function X({
77
+ function Q({
78
78
  align: t,
79
- cachedBounds: r,
80
- index: l,
79
+ cachedBounds: o,
80
+ index: n,
81
81
  itemCount: s,
82
82
  containerScrollOffset: e,
83
- containerSize: i
83
+ containerSize: f
84
84
  }) {
85
- const n = r.get(s - 1).scrollOffset, c = n + n - i, o = Math.max(
85
+ const l = o.get(s - 1).scrollOffset, c = l + l - f, r = Math.max(
86
86
  0,
87
- r.get(l + 1).scrollOffset - i
88
- ), f = Math.min(
89
- n,
90
- r.get(l).scrollOffset
87
+ o.get(n + 1).scrollOffset - f
88
+ ), u = Math.min(
89
+ l,
90
+ o.get(n).scrollOffset
91
91
  );
92
- switch (t === "smart" && (e >= o && e <= f ? t = "auto" : t = "center"), t) {
92
+ switch (t === "smart" && (e >= r && e <= u ? t = "auto" : t = "center"), t) {
93
93
  case "start":
94
- return Math.min(c, f);
94
+ return Math.min(c, u);
95
95
  case "end":
96
- return o;
96
+ return r;
97
97
  case "center": {
98
- const p = Math.round(
99
- o + (f - o) / 2
98
+ const w = Math.round(
99
+ r + (u - r) / 2
100
100
  );
101
- return p < Math.ceil(i / 2) ? 0 : p > c ? c : p;
101
+ return w < Math.ceil(f / 2) ? 0 : w > c ? c : w;
102
102
  }
103
103
  case "auto":
104
104
  default:
105
- return e >= o && e <= f ? e : e < o ? o : f;
105
+ return e >= r && e <= u ? e : e < r ? r : u;
106
106
  }
107
107
  }
108
- function Z({
108
+ function X({
109
109
  cachedBounds: t,
110
- containerScrollOffset: r,
111
- containerSize: l,
110
+ containerScrollOffset: o,
111
+ containerSize: n,
112
112
  itemCount: s,
113
113
  overscanCount: e
114
114
  }) {
115
- const i = s - 1;
116
- let n = 0, c = -1, o = 0;
117
- for (; o < i; ) {
118
- const f = t.get(o);
119
- if (f.scrollOffset + f.size > r)
115
+ const f = s - 1;
116
+ let l = 0, c = -1, r = 0;
117
+ for (; r < f; ) {
118
+ const u = t.get(r);
119
+ if (u.scrollOffset + u.size > o)
120
120
  break;
121
- o++;
121
+ r++;
122
122
  }
123
- for (n = o, n = Math.max(0, n - e); o < i; ) {
124
- const f = t.get(o);
125
- if (f.scrollOffset + f.size >= r + l)
123
+ for (l = r, l = Math.max(0, l - e); r < f; ) {
124
+ const u = t.get(r);
125
+ if (u.scrollOffset + u.size >= o + n)
126
126
  break;
127
- o++;
127
+ r++;
128
128
  }
129
- return c = Math.min(i, o), c = Math.min(s - 1, c + e), n < 0 ? [0, -1] : [n, c];
129
+ return c = Math.min(f, r), c = Math.min(s - 1, c + e), l < 0 ? [0, -1] : [l, c];
130
130
  }
131
- function _({
131
+ function Z({
132
132
  itemCount: t,
133
- itemProps: r,
134
- itemSize: l
133
+ itemProps: o,
134
+ itemSize: n
135
135
  }) {
136
136
  const s = /* @__PURE__ */ new Map();
137
137
  return {
138
138
  get(e) {
139
- for (E(e < t, `Invalid index ${e}`); s.size - 1 < e; ) {
140
- const n = s.size, c = typeof l == "number" ? l : l(n, r);
141
- if (n === 0)
142
- s.set(n, {
139
+ for ($(e < t, `Invalid index ${e}`); s.size - 1 < e; ) {
140
+ const l = s.size, c = typeof n == "number" ? n : n(l, o);
141
+ if (l === 0)
142
+ s.set(l, {
143
143
  size: c,
144
144
  scrollOffset: 0
145
145
  });
146
146
  else {
147
- const o = s.get(n - 1);
148
- E(
149
- o !== void 0,
147
+ const r = s.get(l - 1);
148
+ $(
149
+ r !== void 0,
150
150
  `Unexpected bounds cache miss for index ${e}`
151
- ), s.set(n, {
152
- scrollOffset: o.scrollOffset + o.size,
151
+ ), s.set(l, {
152
+ scrollOffset: r.scrollOffset + r.size,
153
153
  size: c
154
154
  });
155
155
  }
156
156
  }
157
- const i = s.get(e);
158
- return E(
159
- i !== void 0,
157
+ const f = s.get(e);
158
+ return $(
159
+ f !== void 0,
160
160
  `Unexpected bounds cache miss for index ${e}`
161
- ), i;
161
+ ), f;
162
162
  },
163
- set(e, i) {
164
- s.set(e, i);
163
+ set(e, f) {
164
+ s.set(e, f);
165
165
  },
166
166
  get size() {
167
167
  return s.size;
168
168
  }
169
169
  };
170
170
  }
171
- function N({
171
+ function tt({
172
172
  itemCount: t,
173
- itemProps: r,
174
- itemSize: l
173
+ itemProps: o,
174
+ itemSize: n
175
175
  }) {
176
- return M(
177
- () => _({
176
+ return k(
177
+ () => Z({
178
178
  itemCount: t,
179
- itemProps: r,
180
- itemSize: l
179
+ itemProps: o,
180
+ itemSize: n
181
181
  }),
182
- [t, r, l]
182
+ [t, o, n]
183
183
  );
184
184
  }
185
+ function et(t) {
186
+ const o = B(() => {
187
+ throw new Error("Cannot call an event handler while rendering.");
188
+ });
189
+ return U(() => {
190
+ o.current = t;
191
+ }, [t]), P((n) => o.current?.(n), [o]);
192
+ }
185
193
  function G({
186
194
  containerElement: t,
187
- containerStyle: r,
188
- defaultContainerSize: l = 0,
195
+ containerStyle: o,
196
+ defaultContainerSize: n = 0,
189
197
  direction: s,
190
198
  itemCount: e,
191
- itemProps: i,
192
- itemSize: n,
199
+ itemProps: f,
200
+ itemSize: l,
193
201
  overscanCount: c
194
202
  }) {
195
- const [o, f] = $([0, -1]), [p, I] = [
196
- Math.min(e - 1, o[0]),
197
- Math.min(e - 1, o[1])
198
- ], { height: b = l, width: y = l } = K({
199
- defaultHeight: s === "vertical" ? l : void 0,
200
- defaultWidth: s === "horizontal" ? l : void 0,
203
+ const [r, u] = L([0, -1]), [w, I] = [
204
+ Math.min(e - 1, r[0]),
205
+ Math.min(e - 1, r[1])
206
+ ], { height: O = n, width: S = n } = J({
207
+ defaultHeight: s === "vertical" ? n : void 0,
208
+ defaultWidth: s === "horizontal" ? n : void 0,
201
209
  element: t,
202
210
  mode: s === "vertical" ? "only-height" : "only-width",
203
- style: r
204
- }), w = s === "vertical" ? b : y, d = N({
211
+ style: o
212
+ }), m = s === "vertical" ? O : S, a = tt({
205
213
  itemCount: e,
206
- itemProps: i,
207
- itemSize: n
208
- }), x = R(
209
- (u) => d.get(u),
210
- [d]
211
- ), z = R(
212
- () => Q({
213
- cachedBounds: d,
214
+ itemProps: f,
215
+ itemSize: l
216
+ }), b = P(
217
+ (i) => a.get(i),
218
+ [a]
219
+ ), d = P(
220
+ () => K({
221
+ cachedBounds: a,
214
222
  itemCount: e,
215
- itemSize: n
223
+ itemSize: l
216
224
  }),
217
- [d, e, n]
218
- ), h = R(
219
- (u) => Z({
220
- cachedBounds: d,
221
- containerScrollOffset: u,
222
- containerSize: w,
225
+ [a, e, l]
226
+ ), E = P(
227
+ (i) => X({
228
+ cachedBounds: a,
229
+ containerScrollOffset: i,
230
+ containerSize: m,
223
231
  itemCount: e,
224
232
  overscanCount: c
225
233
  }),
226
- [d, w, e, c]
234
+ [a, m, e, c]
227
235
  );
228
- q(() => {
229
- const u = (s === "vertical" ? t?.scrollTop : t?.scrollLeft) ?? 0;
230
- f(h(u));
231
- }, [t, s, h]);
232
- const a = R(
236
+ U(() => {
237
+ const i = (s === "vertical" ? t?.scrollTop : t?.scrollLeft) ?? 0;
238
+ u(E(i));
239
+ }, [t, s, E]);
240
+ const g = et(
233
241
  ({
234
- align: u = "auto",
235
- behavior: O = "auto",
236
- containerScrollOffset: m,
237
- index: g
242
+ align: i = "auto",
243
+ behavior: p = "auto",
244
+ containerScrollOffset: z,
245
+ index: x
238
246
  }) => {
239
- const S = X({
240
- align: u,
241
- cachedBounds: d,
242
- containerScrollOffset: m,
243
- containerSize: w,
244
- index: g,
247
+ const h = Q({
248
+ align: i,
249
+ cachedBounds: a,
250
+ containerScrollOffset: z,
251
+ containerSize: m,
252
+ index: x,
245
253
  itemCount: e
246
254
  });
247
255
  s === "horizontal" ? t?.scrollTo({
248
- left: S,
249
- behavior: O || void 0
256
+ left: h,
257
+ behavior: p || void 0
250
258
  }) : t?.scrollTo({
251
- behavior: O || void 0,
252
- top: S
259
+ behavior: p || void 0,
260
+ top: h
253
261
  });
254
- },
255
- [d, t, w, s, e]
262
+ }
256
263
  );
257
264
  return {
258
- getCellBounds: x,
259
- getEstimatedHeight: z,
265
+ getCellBounds: b,
266
+ getEstimatedHeight: d,
260
267
  onScroll: () => {
261
- const u = h(
268
+ const i = E(
262
269
  (s === "vertical" ? t?.scrollTop : t?.scrollLeft) ?? 0
263
270
  );
264
- (u[0] !== p || u[1] !== I) && f(u);
271
+ (i[0] !== w || i[1] !== I) && u(i);
265
272
  },
266
- scrollToIndex: a,
267
- startIndex: p,
273
+ scrollToIndex: g,
274
+ startIndex: w,
268
275
  stopIndex: I
269
276
  };
270
277
  }
271
278
  function A(t) {
272
- return M(() => t, Object.values(t));
279
+ return k(() => t, Object.values(t));
273
280
  }
274
- function B(t, r) {
275
- if (t === r)
281
+ function F(t, o) {
282
+ if (t === o)
276
283
  return !0;
277
- if (!!t != !!r || (E(t !== void 0), E(r !== void 0), Object.keys(t).length !== Object.keys(r).length))
284
+ if (!!t != !!o || ($(t !== void 0), $(o !== void 0), Object.keys(t).length !== Object.keys(o).length))
278
285
  return !1;
279
- for (const l in t)
280
- if (!Object.is(r[l], t[l]))
286
+ for (const n in t)
287
+ if (!Object.is(o[n], t[n]))
281
288
  return !1;
282
289
  return !0;
283
290
  }
284
- function D(t, r) {
285
- const { style: l, ...s } = t, { style: e, ...i } = r;
286
- return B(l, e) && B(s, i);
291
+ function _(t, o) {
292
+ const { style: n, ...s } = t, { style: e, ...f } = o;
293
+ return F(n, e) && F(s, f);
287
294
  }
288
- function et({
295
+ const C = () => {
296
+ };
297
+ function rt({
289
298
  cellComponent: t,
290
- cellProps: r,
291
- className: l,
299
+ cellProps: o,
300
+ className: n,
292
301
  columnCount: s,
293
302
  columnWidth: e,
294
- defaultHeight: i = 0,
295
- defaultWidth: n = 0,
303
+ defaultHeight: f = 0,
304
+ defaultWidth: l = 0,
296
305
  gridRef: c,
297
- onCellsRendered: o,
298
- overscanCount: f = 3,
299
- rowCount: p,
300
- rowHeight: I,
301
- style: b,
302
- ...y
306
+ onCellsRendered: r,
307
+ onScroll: u = C,
308
+ overscanCount: w = 3,
309
+ rowCount: I,
310
+ rowHeight: O,
311
+ style: S,
312
+ ...m
303
313
  }) {
304
- const w = A(r), d = M(
305
- () => V(t, D),
314
+ const a = A(o), b = k(
315
+ () => N(t, _),
306
316
  [t]
307
- ), [x, z] = $(null), h = G({
308
- containerElement: x,
309
- defaultContainerSize: n,
317
+ ), [d, E] = L(null), g = G({
318
+ containerElement: d,
319
+ defaultContainerSize: l,
310
320
  direction: "horizontal",
311
321
  itemCount: s,
312
- itemProps: w,
322
+ itemProps: a,
313
323
  itemSize: e,
314
- overscanCount: f
315
- }), a = G({
316
- containerElement: x,
317
- defaultContainerSize: i,
324
+ overscanCount: w
325
+ }), i = G({
326
+ containerElement: d,
327
+ defaultContainerSize: f,
318
328
  direction: "vertical",
319
- itemCount: p,
320
- itemProps: w,
321
- itemSize: I,
322
- overscanCount: f
323
- }), { startIndex: u, stopIndex: O } = h, { startIndex: m, stopIndex: g } = a;
324
- U(
329
+ itemCount: I,
330
+ itemProps: a,
331
+ itemSize: O,
332
+ overscanCount: w
333
+ }), { startIndex: p, stopIndex: z } = g, { startIndex: x, stopIndex: h } = i;
334
+ Y(
325
335
  c,
326
336
  () => ({
327
337
  get element() {
328
- return x;
338
+ return d;
329
339
  },
330
340
  scrollToCell({
331
- behavior: T = "auto",
332
- columnAlign: v = "auto",
333
- columnIndex: H,
334
- rowAlign: k = "auto",
335
- rowIndex: L
341
+ behavior: v = "auto",
342
+ columnAlign: y = "auto",
343
+ columnIndex: T,
344
+ rowAlign: H = "auto",
345
+ rowIndex: R
336
346
  }) {
337
- a?.scrollToIndex({
338
- align: k,
339
- behavior: T,
340
- containerScrollOffset: x?.scrollTop ?? 0,
341
- index: L
342
- }), h?.scrollToIndex({
343
- align: v,
344
- behavior: T,
345
- containerScrollOffset: x?.scrollLeft ?? 0,
346
- index: H
347
+ i?.scrollToIndex({
348
+ align: H,
349
+ behavior: v,
350
+ containerScrollOffset: d?.scrollTop ?? 0,
351
+ index: R
352
+ }), g?.scrollToIndex({
353
+ align: y,
354
+ behavior: v,
355
+ containerScrollOffset: d?.scrollLeft ?? 0,
356
+ index: T
347
357
  });
348
358
  },
349
359
  scrollToColumn({
350
- align: T = "auto",
351
- behavior: v = "auto",
352
- index: H
360
+ align: v = "auto",
361
+ behavior: y = "auto",
362
+ index: T
353
363
  }) {
354
- h?.scrollToIndex({
355
- align: T,
356
- behavior: v,
357
- containerScrollOffset: x?.scrollLeft ?? 0,
358
- index: H
364
+ g?.scrollToIndex({
365
+ align: v,
366
+ behavior: y,
367
+ containerScrollOffset: d?.scrollLeft ?? 0,
368
+ index: T
359
369
  });
360
370
  },
361
371
  scrollToRow({
362
- align: T = "auto",
363
- behavior: v = "auto",
364
- index: H
372
+ align: v = "auto",
373
+ behavior: y = "auto",
374
+ index: T
365
375
  }) {
366
- a?.scrollToIndex({
367
- align: T,
368
- behavior: v,
369
- containerScrollOffset: x?.scrollTop ?? 0,
370
- index: H
376
+ i?.scrollToIndex({
377
+ align: v,
378
+ behavior: y,
379
+ containerScrollOffset: d?.scrollTop ?? 0,
380
+ index: T
371
381
  });
372
382
  }
373
383
  }),
374
- [h, x, a]
375
- ), P(() => {
376
- u >= 0 && O >= 0 && m >= 0 && g >= 0 && o && o({
377
- columnStartIndex: u,
378
- columnStopIndex: O,
379
- rowStartIndex: m,
380
- rowStopIndex: g
384
+ [g, d, i]
385
+ ), W(() => {
386
+ p >= 0 && z >= 0 && x >= 0 && h >= 0 && r && r({
387
+ columnStartIndex: p,
388
+ columnStopIndex: z,
389
+ rowStartIndex: x,
390
+ rowStopIndex: h
381
391
  });
382
392
  }, [
383
- o,
384
- u,
385
- O,
386
- m,
387
- g
393
+ r,
394
+ p,
395
+ z,
396
+ x,
397
+ h
388
398
  ]);
389
- const S = M(() => {
390
- const T = [];
391
- if (h && s > 0 && a && p > 0)
392
- for (let v = m; v <= g; v++) {
393
- const H = a.getCellBounds(v);
394
- for (let k = u; k <= O; k++) {
395
- const L = h.getCellBounds(k);
396
- T.push(
397
- /* @__PURE__ */ F(
398
- d,
399
+ const M = k(() => {
400
+ const v = [];
401
+ if (g && s > 0 && i && I > 0)
402
+ for (let y = x; y <= h; y++) {
403
+ const T = i.getCellBounds(y);
404
+ for (let H = p; H <= z; H++) {
405
+ const R = g.getCellBounds(H);
406
+ v.push(
407
+ /* @__PURE__ */ q(
408
+ b,
399
409
  {
400
- ...w,
401
- columnIndex: k,
402
- key: `${v}-${k}`,
403
- rowIndex: v,
410
+ ...a,
411
+ columnIndex: H,
412
+ key: `${y}-${H}`,
413
+ rowIndex: y,
404
414
  style: {
405
415
  position: "absolute",
406
416
  left: 0,
407
- transform: `translate(${L.scrollOffset}px, ${H.scrollOffset}px)`,
408
- height: H.size,
409
- width: L.size
417
+ transform: `translate(${R.scrollOffset}px, ${T.scrollOffset}px)`,
418
+ height: T.size,
419
+ width: R.size
410
420
  }
411
421
  }
412
422
  )
413
423
  );
414
424
  }
415
425
  }
416
- return T;
426
+ return v;
417
427
  }, [
418
- d,
419
- w,
428
+ b,
429
+ a,
420
430
  s,
421
- u,
422
- O,
423
- h,
424
431
  p,
425
- m,
432
+ z,
426
433
  g,
427
- a
434
+ I,
435
+ x,
436
+ h,
437
+ i
428
438
  ]);
429
439
  return /* @__PURE__ */ j(
430
440
  "div",
431
441
  {
432
442
  role: "grid",
433
- ...y,
434
- className: l,
435
- onScroll: () => {
436
- h.onScroll(), a.onScroll();
443
+ ...m,
444
+ className: n,
445
+ onScroll: (v) => {
446
+ g.onScroll(), i.onScroll(), u(v);
437
447
  },
438
- ref: z,
448
+ ref: E,
439
449
  style: {
440
- ...b,
450
+ ...S,
441
451
  maxHeight: "100%",
442
452
  maxWidth: "100%",
443
453
  flexGrow: 1,
@@ -446,112 +456,115 @@ function et({
446
456
  children: /* @__PURE__ */ j(
447
457
  "div",
448
458
  {
449
- className: l,
459
+ className: n,
450
460
  style: {
451
461
  position: "relative",
452
- height: a?.getEstimatedHeight(),
453
- width: h?.getEstimatedHeight()
462
+ height: i?.getEstimatedHeight(),
463
+ width: g?.getEstimatedHeight()
454
464
  },
455
- children: S
465
+ children: M
456
466
  }
457
467
  )
458
468
  }
459
469
  );
460
470
  }
461
- const st = $, ot = Y;
462
- function rt({
471
+ const nt = L, lt = B;
472
+ function it({
463
473
  className: t,
464
- defaultHeight: r = 0,
465
- listRef: l,
474
+ defaultHeight: o = 0,
475
+ listRef: n,
466
476
  onRowsRendered: s,
467
- overscanCount: e = 3,
468
- rowComponent: i,
469
- rowCount: n,
470
- rowHeight: c,
471
- rowProps: o,
472
- style: f,
473
- ...p
477
+ onScroll: e = C,
478
+ overscanCount: f = 3,
479
+ rowComponent: l,
480
+ rowCount: c,
481
+ rowHeight: r,
482
+ rowProps: u,
483
+ style: w,
484
+ ...I
474
485
  }) {
475
- const I = A(o), b = M(
476
- () => V(i, D),
477
- [i]
478
- ), [y, w] = $(null), {
479
- getCellBounds: d,
480
- getEstimatedHeight: x,
481
- onScroll: z,
482
- scrollToIndex: h,
483
- startIndex: a,
484
- stopIndex: u
486
+ const O = A(u), S = k(
487
+ () => N(l, _),
488
+ [l]
489
+ ), [m, a] = L(null), {
490
+ getCellBounds: b,
491
+ getEstimatedHeight: d,
492
+ onScroll: E,
493
+ scrollToIndex: g,
494
+ startIndex: i,
495
+ stopIndex: p
485
496
  } = G({
486
- containerElement: y,
487
- defaultContainerSize: r,
497
+ containerElement: m,
498
+ defaultContainerSize: o,
488
499
  direction: "vertical",
489
- itemCount: n,
490
- itemProps: I,
491
- itemSize: c,
492
- overscanCount: e
500
+ itemCount: c,
501
+ itemProps: O,
502
+ itemSize: r,
503
+ overscanCount: f
493
504
  });
494
- U(
495
- l,
505
+ Y(
506
+ n,
496
507
  () => ({
497
508
  get element() {
498
- return y;
509
+ return m;
499
510
  },
500
511
  scrollToRow({
501
- align: m = "auto",
502
- behavior: g = "auto",
503
- index: S
512
+ align: x = "auto",
513
+ behavior: h = "auto",
514
+ index: M
504
515
  }) {
505
- h({
506
- align: m,
507
- behavior: g,
508
- containerScrollOffset: y?.scrollTop ?? 0,
509
- index: S
516
+ g({
517
+ align: x,
518
+ behavior: h,
519
+ containerScrollOffset: m?.scrollTop ?? 0,
520
+ index: M
510
521
  });
511
522
  }
512
523
  }),
513
- [y, h]
514
- ), P(() => {
515
- a >= 0 && u >= 0 && s && s({
516
- startIndex: a,
517
- stopIndex: u
524
+ [m, g]
525
+ ), W(() => {
526
+ i >= 0 && p >= 0 && s && s({
527
+ startIndex: i,
528
+ stopIndex: p
518
529
  });
519
- }, [s, a, u]);
520
- const O = M(() => {
521
- const m = [];
522
- if (n > 0)
523
- for (let g = a; g <= u; g++) {
524
- const S = d(g);
525
- m.push(
526
- /* @__PURE__ */ F(
527
- b,
530
+ }, [s, i, p]);
531
+ const z = k(() => {
532
+ const x = [];
533
+ if (c > 0)
534
+ for (let h = i; h <= p; h++) {
535
+ const M = b(h);
536
+ x.push(
537
+ /* @__PURE__ */ q(
538
+ S,
528
539
  {
529
- ...I,
530
- key: g,
531
- index: g,
540
+ ...O,
541
+ key: h,
542
+ index: h,
532
543
  style: {
533
544
  position: "absolute",
534
545
  left: 0,
535
- transform: `translateY(${S.scrollOffset}px)`,
536
- height: S.size,
546
+ transform: `translateY(${M.scrollOffset}px)`,
547
+ height: M.size,
537
548
  width: "100%"
538
549
  }
539
550
  }
540
551
  )
541
552
  );
542
553
  }
543
- return m;
544
- }, [b, d, n, I, a, u]);
554
+ return x;
555
+ }, [S, b, c, O, i, p]);
545
556
  return /* @__PURE__ */ j(
546
557
  "div",
547
558
  {
548
559
  role: "list",
549
- ...p,
560
+ ...I,
550
561
  className: t,
551
- onScroll: z,
552
- ref: w,
562
+ onScroll: (x) => {
563
+ E(), e(x);
564
+ },
565
+ ref: a,
553
566
  style: {
554
- ...f,
567
+ ...w,
555
568
  maxHeight: "100%",
556
569
  flexGrow: 1,
557
570
  overflowY: "auto"
@@ -561,22 +574,22 @@ function rt({
561
574
  {
562
575
  className: t,
563
576
  style: {
564
- height: x(),
577
+ height: d(),
565
578
  position: "relative",
566
579
  width: "100%"
567
580
  },
568
- children: O
581
+ children: z
569
582
  }
570
583
  )
571
584
  }
572
585
  );
573
586
  }
574
- const lt = $, nt = Y;
587
+ const ct = L, ft = B;
575
588
  export {
576
- et as Grid,
577
- rt as List,
578
- st as useGridCallbackRef,
579
- ot as useGridRef,
580
- lt as useListCallbackRef,
581
- nt as useListRef
589
+ rt as Grid,
590
+ it as List,
591
+ nt as useGridCallbackRef,
592
+ lt as useGridRef,
593
+ ct as useListCallbackRef,
594
+ ft as useListRef
582
595
  };