react-window 2.2.3 → 2.2.5-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.
@@ -1,5 +1,6 @@
1
- import { jsx as P } from "react/jsx-runtime";
2
- import { useState as H, useLayoutEffect as se, useEffect as J, useMemo as L, useRef as K, useCallback as U, memo as le, useImperativeHandle as ce, createElement as X } from "react";
1
+ "use client";
2
+ import { jsx as ee } from "react/jsx-runtime";
3
+ import { useState as M, useLayoutEffect as re, useEffect as J, useMemo as A, useRef as K, useCallback as D, memo as le, useImperativeHandle as ce, createElement as X } from "react";
3
4
  function xe(e) {
4
5
  let t = e;
5
6
  for (; t; ) {
@@ -10,13 +11,13 @@ function xe(e) {
10
11
  return !1;
11
12
  }
12
13
  function ve(e, t) {
13
- const [s, r] = H(t === "rtl");
14
- return se(() => {
14
+ const [s, r] = M(t === "rtl");
15
+ return re(() => {
15
16
  e && (t || r(xe(e)));
16
17
  }, [t, e]), s;
17
18
  }
18
- const q = typeof window < "u" ? se : J;
19
- function oe(e) {
19
+ const q = typeof window < "u" ? re : J;
20
+ function ie(e) {
20
21
  if (e !== void 0)
21
22
  switch (typeof e) {
22
23
  case "number":
@@ -28,7 +29,7 @@ function oe(e) {
28
29
  }
29
30
  }
30
31
  }
31
- function Ie({
32
+ function be({
32
33
  box: e,
33
34
  defaultHeight: t,
34
35
  defaultWidth: s,
@@ -37,37 +38,37 @@ function Ie({
37
38
  mode: o,
38
39
  style: i
39
40
  }) {
40
- const { styleHeight: f, styleWidth: l } = L(
41
+ const { styleHeight: f, styleWidth: l } = A(
41
42
  () => ({
42
- styleHeight: oe(i?.height),
43
- styleWidth: oe(i?.width)
43
+ styleHeight: ie(i?.height),
44
+ styleWidth: ie(i?.width)
44
45
  }),
45
46
  [i?.height, i?.width]
46
- ), [c, d] = H({
47
+ ), [a, d] = M({
47
48
  height: t,
48
49
  width: s
49
- }), a = r || o === "only-height" && f !== void 0 || o === "only-width" && l !== void 0 || f !== void 0 && l !== void 0;
50
+ }), c = r || o === "only-height" && f !== void 0 || o === "only-width" && l !== void 0 || f !== void 0 && l !== void 0;
50
51
  return q(() => {
51
- if (n === null || a)
52
+ if (n === null || c)
52
53
  return;
53
- const u = new ResizeObserver((I) => {
54
- for (const m of I) {
55
- const { contentRect: b, target: g } = m;
56
- n === g && d((w) => w.height === b.height && w.width === b.width ? w : {
57
- height: b.height,
58
- width: b.width
54
+ const h = new ResizeObserver((p) => {
55
+ for (const I of p) {
56
+ const { contentRect: u, target: w } = I;
57
+ n === w && d((m) => m.height === u.height && m.width === u.width ? m : {
58
+ height: u.height,
59
+ width: u.width
59
60
  });
60
61
  }
61
62
  });
62
- return u.observe(n, { box: e }), () => {
63
- u?.unobserve(n);
63
+ return h.observe(n, { box: e }), () => {
64
+ h?.unobserve(n);
64
65
  };
65
- }, [e, a, n, f, l]), L(
66
+ }, [e, c, n, f, l]), A(
66
67
  () => ({
67
- height: f ?? c.height,
68
- width: l ?? c.width
68
+ height: f ?? a.height,
69
+ width: l ?? a.width
69
70
  }),
70
- [c, f, l]
71
+ [a, f, l]
71
72
  );
72
73
  }
73
74
  function ae(e) {
@@ -76,17 +77,17 @@ function ae(e) {
76
77
  });
77
78
  return q(() => {
78
79
  t.current = e;
79
- }, [e]), U((s) => t.current?.(s), [t]);
80
+ }, [e]), D((s) => t.current?.(s), [t]);
80
81
  }
81
- let F = null;
82
- function be(e = !1) {
83
- if (F === null || e) {
82
+ let U = null;
83
+ function Ie(e = !1) {
84
+ if (U === null || e) {
84
85
  const t = document.createElement("div"), s = t.style;
85
86
  s.width = "50px", s.height = "50px", s.overflow = "scroll", s.direction = "rtl";
86
87
  const r = document.createElement("div"), n = r.style;
87
- return n.width = "100px", n.height = "100px", t.appendChild(r), document.body.appendChild(t), t.scrollLeft > 0 ? F = "positive-descending" : (t.scrollLeft = 1, t.scrollLeft === 0 ? F = "negative" : F = "positive-ascending"), document.body.removeChild(t), F;
88
+ return n.width = "100px", n.height = "100px", t.appendChild(r), document.body.appendChild(t), t.scrollLeft > 0 ? U = "positive-descending" : (t.scrollLeft = 1, t.scrollLeft === 0 ? U = "negative" : U = "positive-ascending"), document.body.removeChild(t), U;
88
89
  }
89
- return F;
90
+ return U;
90
91
  }
91
92
  function Z({
92
93
  containerElement: e,
@@ -95,7 +96,7 @@ function Z({
95
96
  scrollOffset: r
96
97
  }) {
97
98
  if (t === "horizontal" && s)
98
- switch (be()) {
99
+ switch (Ie()) {
99
100
  case "negative":
100
101
  return -r;
101
102
  case "positive-descending": {
@@ -108,14 +109,14 @@ function Z({
108
109
  }
109
110
  return r;
110
111
  }
111
- function $(e, t = "Assertion error") {
112
+ function L(e, t = "Assertion error") {
112
113
  if (!e)
113
114
  throw console.error(t), Error(t);
114
115
  }
115
116
  function Y(e, t) {
116
117
  if (e === t)
117
118
  return !0;
118
- if (!!e != !!t || ($(e !== void 0), $(t !== void 0), Object.keys(e).length !== Object.keys(t).length))
119
+ if (!!e != !!t || (L(e !== void 0), L(t !== void 0), Object.keys(e).length !== Object.keys(t).length))
119
120
  return !1;
120
121
  for (const s in e)
121
122
  if (!Object.is(t[s], e[s]))
@@ -135,7 +136,7 @@ function fe({
135
136
  const r = e.get(
136
137
  e.size === 0 ? 0 : e.size - 1
137
138
  );
138
- $(r !== void 0, "Unexpected bounds cache miss");
139
+ L(r !== void 0, "Unexpected bounds cache miss");
139
140
  const n = (r.scrollOffset + r.size) / e.size;
140
141
  return t * n;
141
142
  }
@@ -157,26 +158,26 @@ function we({
157
158
  cachedBounds: t,
158
159
  itemCount: r,
159
160
  itemSize: n
160
- }), l = t.get(s), c = Math.max(
161
+ }), l = t.get(s), a = Math.max(
161
162
  0,
162
163
  Math.min(f - i, l.scrollOffset)
163
164
  ), d = Math.max(
164
165
  0,
165
166
  l.scrollOffset - i + l.size
166
167
  );
167
- switch (e === "smart" && (o >= d && o <= c ? e = "auto" : e = "center"), e) {
168
+ switch (e === "smart" && (o >= d && o <= a ? e = "auto" : e = "center"), e) {
168
169
  case "start":
169
- return c;
170
+ return a;
170
171
  case "end":
171
172
  return d;
172
173
  case "center":
173
174
  return l.scrollOffset <= i / 2 ? 0 : l.scrollOffset + l.size / 2 >= f - i / 2 ? f - i : l.scrollOffset + l.size / 2 - i / 2;
174
175
  case "auto":
175
176
  default:
176
- return o >= d && o <= c ? o : o < d ? d : c;
177
+ return o >= d && o <= a ? o : o < d ? d : a;
177
178
  }
178
179
  }
179
- function ie({
180
+ function P({
180
181
  cachedBounds: e,
181
182
  containerScrollOffset: t,
182
183
  containerSize: s,
@@ -184,24 +185,24 @@ function ie({
184
185
  overscanCount: n
185
186
  }) {
186
187
  const o = r - 1;
187
- let i = 0, f = -1, l = 0, c = -1, d = 0;
188
+ let i = 0, f = -1, l = 0, a = -1, d = 0;
188
189
  for (; d < o; ) {
189
- const a = e.get(d);
190
- if (a.scrollOffset + a.size > t)
190
+ const c = e.get(d);
191
+ if (c.scrollOffset + c.size > t)
191
192
  break;
192
193
  d++;
193
194
  }
194
195
  for (i = d, l = Math.max(0, i - n); d < o; ) {
195
- const a = e.get(d);
196
- if (a.scrollOffset + a.size >= t + s)
196
+ const c = e.get(d);
197
+ if (c.scrollOffset + c.size >= t + s)
197
198
  break;
198
199
  d++;
199
200
  }
200
- return f = Math.min(o, d), c = Math.min(r - 1, f + n), i < 0 && (i = 0, f = -1, l = 0, c = -1), {
201
+ return f = Math.min(o, d), a = Math.min(r - 1, f + n), i < 0 && (i = 0, f = -1, l = 0, a = -1), {
201
202
  startIndexVisible: i,
202
203
  stopIndexVisible: f,
203
204
  startIndexOverscan: l,
204
- stopIndexOverscan: c
205
+ stopIndexOverscan: a
205
206
  };
206
207
  }
207
208
  function me({
@@ -212,7 +213,7 @@ function me({
212
213
  const r = /* @__PURE__ */ new Map();
213
214
  return {
214
215
  get(n) {
215
- for ($(n < e, `Invalid index ${n}`); r.size - 1 < n; ) {
216
+ for (L(n < e, `Invalid index ${n}`); r.size - 1 < n; ) {
216
217
  const i = r.size;
217
218
  let f;
218
219
  switch (typeof s) {
@@ -232,7 +233,7 @@ function me({
232
233
  });
233
234
  else {
234
235
  const l = r.get(i - 1);
235
- $(
236
+ L(
236
237
  l !== void 0,
237
238
  `Unexpected bounds cache miss for index ${n}`
238
239
  ), r.set(i, {
@@ -242,7 +243,7 @@ function me({
242
243
  }
243
244
  }
244
245
  const o = r.get(n);
245
- return $(
246
+ return L(
246
247
  o !== void 0,
247
248
  `Unexpected bounds cache miss for index ${n}`
248
249
  ), o;
@@ -260,7 +261,7 @@ function Oe({
260
261
  itemProps: t,
261
262
  itemSize: s
262
263
  }) {
263
- return L(
264
+ return A(
264
265
  () => me({
265
266
  itemCount: e,
266
267
  itemProps: t,
@@ -276,10 +277,10 @@ function ye({
276
277
  let s;
277
278
  switch (typeof t) {
278
279
  case "string": {
279
- $(
280
+ L(
280
281
  t.endsWith("%"),
281
282
  `Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`
282
- ), $(
283
+ ), L(
283
284
  e !== void 0,
284
285
  "Container size must be defined if a percentage item size is specified"
285
286
  ), s = e * parseInt(t) / 100;
@@ -292,7 +293,7 @@ function ye({
292
293
  }
293
294
  return s;
294
295
  }
295
- function ee({
296
+ function te({
296
297
  containerElement: e,
297
298
  containerStyle: t,
298
299
  defaultContainerSize: s = 0,
@@ -302,154 +303,157 @@ function ee({
302
303
  itemProps: i,
303
304
  itemSize: f,
304
305
  onResize: l,
305
- overscanCount: c
306
+ overscanCount: a
306
307
  }) {
307
- const [d, a] = H({
308
- startIndexVisible: 0,
309
- startIndexOverscan: 0,
310
- stopIndexVisible: -1,
311
- stopIndexOverscan: -1
312
- }), {
313
- startIndexVisible: u,
314
- startIndexOverscan: I,
315
- stopIndexVisible: m,
316
- stopIndexOverscan: b
317
- } = {
318
- startIndexVisible: Math.min(o - 1, d.startIndexVisible),
319
- startIndexOverscan: Math.min(o - 1, d.startIndexOverscan),
320
- stopIndexVisible: Math.min(o - 1, d.stopIndexVisible),
321
- stopIndexOverscan: Math.min(o - 1, d.stopIndexOverscan)
322
- }, { height: g = s, width: w = s } = Ie({
308
+ const { height: d = s, width: c = s } = be({
323
309
  defaultHeight: r === "vertical" ? s : void 0,
324
310
  defaultWidth: r === "horizontal" ? s : void 0,
325
311
  element: e,
326
312
  mode: r === "vertical" ? "only-height" : "only-width",
327
313
  style: t
328
- }), y = K({
314
+ }), h = K({
329
315
  height: 0,
330
316
  width: 0
331
- }), V = r === "vertical" ? g : w, h = ye({ containerSize: V, itemSize: f });
332
- se(() => {
317
+ }), p = r === "vertical" ? d : c, I = ye({ containerSize: p, itemSize: f });
318
+ re(() => {
333
319
  if (typeof l == "function") {
334
- const p = y.current;
335
- (p.height !== g || p.width !== w) && (l({ height: g, width: w }, { ...p }), p.height = g, p.width = w);
320
+ const g = h.current;
321
+ (g.height !== d || g.width !== c) && (l({ height: d, width: c }, { ...g }), g.height = d, g.width = c);
336
322
  }
337
- }, [g, l, w]);
338
- const z = Oe({
323
+ }, [d, l, c]);
324
+ const u = Oe({
339
325
  itemCount: o,
340
326
  itemProps: i,
341
- itemSize: h
342
- }), k = U(
343
- (p) => z.get(p),
344
- [z]
345
- ), S = U(
327
+ itemSize: I
328
+ }), w = D(
329
+ (g) => u.get(g),
330
+ [u]
331
+ ), [m, O] = M(
332
+ () => P({
333
+ cachedBounds: u,
334
+ containerScrollOffset: 0,
335
+ containerSize: p,
336
+ itemCount: o,
337
+ overscanCount: a
338
+ })
339
+ ), {
340
+ startIndexVisible: G,
341
+ startIndexOverscan: x,
342
+ stopIndexVisible: F,
343
+ stopIndexOverscan: V
344
+ } = {
345
+ startIndexVisible: Math.min(o - 1, m.startIndexVisible),
346
+ startIndexOverscan: Math.min(o - 1, m.startIndexOverscan),
347
+ stopIndexVisible: Math.min(o - 1, m.stopIndexVisible),
348
+ stopIndexOverscan: Math.min(o - 1, m.stopIndexOverscan)
349
+ }, z = D(
346
350
  () => fe({
347
- cachedBounds: z,
351
+ cachedBounds: u,
348
352
  itemCount: o,
349
- itemSize: h
353
+ itemSize: I
350
354
  }),
351
- [z, o, h]
352
- ), W = U(
353
- (p) => {
354
- const T = Z({
355
+ [u, o, I]
356
+ ), $ = D(
357
+ (g) => {
358
+ const S = Z({
355
359
  containerElement: e,
356
360
  direction: r,
357
361
  isRtl: n,
358
- scrollOffset: p
362
+ scrollOffset: g
359
363
  });
360
- return ie({
361
- cachedBounds: z,
362
- containerScrollOffset: T,
363
- containerSize: V,
364
+ return P({
365
+ cachedBounds: u,
366
+ containerScrollOffset: S,
367
+ containerSize: p,
364
368
  itemCount: o,
365
- overscanCount: c
369
+ overscanCount: a
366
370
  });
367
371
  },
368
372
  [
369
- z,
373
+ u,
370
374
  e,
371
- V,
375
+ p,
372
376
  r,
373
377
  n,
374
378
  o,
375
- c
379
+ a
376
380
  ]
377
381
  );
378
382
  q(() => {
379
- const p = (r === "vertical" ? e?.scrollTop : e?.scrollLeft) ?? 0;
380
- a(W(p));
381
- }, [e, r, W]), q(() => {
383
+ const g = (r === "vertical" ? e?.scrollTop : e?.scrollLeft) ?? 0;
384
+ O($(g));
385
+ }, [e, r, $]), q(() => {
382
386
  if (!e)
383
387
  return;
384
- const p = () => {
385
- a((T) => {
386
- const { scrollLeft: R, scrollTop: v } = e, x = Z({
388
+ const g = () => {
389
+ O((S) => {
390
+ const { scrollLeft: E, scrollTop: b } = e, v = Z({
387
391
  containerElement: e,
388
392
  direction: r,
389
393
  isRtl: n,
390
- scrollOffset: r === "vertical" ? v : R
391
- }), A = ie({
392
- cachedBounds: z,
393
- containerScrollOffset: x,
394
- containerSize: V,
394
+ scrollOffset: r === "vertical" ? b : E
395
+ }), R = P({
396
+ cachedBounds: u,
397
+ containerScrollOffset: v,
398
+ containerSize: p,
395
399
  itemCount: o,
396
- overscanCount: c
400
+ overscanCount: a
397
401
  });
398
- return Y(A, T) ? T : A;
402
+ return Y(R, S) ? S : R;
399
403
  });
400
404
  };
401
- return e.addEventListener("scroll", p), () => {
402
- e.removeEventListener("scroll", p);
405
+ return e.addEventListener("scroll", g), () => {
406
+ e.removeEventListener("scroll", g);
403
407
  };
404
408
  }, [
405
- z,
409
+ u,
406
410
  e,
407
- V,
411
+ p,
408
412
  r,
409
413
  o,
410
- c
414
+ a
411
415
  ]);
412
- const O = ae(
416
+ const y = ae(
413
417
  ({
414
- align: p = "auto",
415
- containerScrollOffset: T,
416
- index: R
418
+ align: g = "auto",
419
+ containerScrollOffset: S,
420
+ index: E
417
421
  }) => {
418
- let v = we({
419
- align: p,
420
- cachedBounds: z,
421
- containerScrollOffset: T,
422
- containerSize: V,
423
- index: R,
422
+ let b = we({
423
+ align: g,
424
+ cachedBounds: u,
425
+ containerScrollOffset: S,
426
+ containerSize: p,
427
+ index: E,
424
428
  itemCount: o,
425
- itemSize: h
429
+ itemSize: I
426
430
  });
427
431
  if (e) {
428
- if (v = Z({
432
+ if (b = Z({
429
433
  containerElement: e,
430
434
  direction: r,
431
435
  isRtl: n,
432
- scrollOffset: v
436
+ scrollOffset: b
433
437
  }), typeof e.scrollTo != "function") {
434
- const x = W(v);
435
- Y(d, x) || a(x);
438
+ const v = $(b);
439
+ Y(m, v) || O(v);
436
440
  }
437
- return v;
441
+ return b;
438
442
  }
439
443
  }
440
444
  );
441
445
  return {
442
- getCellBounds: k,
443
- getEstimatedSize: S,
444
- scrollToIndex: O,
445
- startIndexOverscan: I,
446
- startIndexVisible: u,
447
- stopIndexOverscan: b,
448
- stopIndexVisible: m
446
+ getCellBounds: w,
447
+ getEstimatedSize: z,
448
+ scrollToIndex: y,
449
+ startIndexOverscan: x,
450
+ startIndexVisible: G,
451
+ stopIndexOverscan: V,
452
+ stopIndexVisible: F
449
453
  };
450
454
  }
451
455
  function de(e) {
452
- return L(() => e, Object.values(e));
456
+ return A(() => e, Object.values(e));
453
457
  }
454
458
  function ue(e, t) {
455
459
  const {
@@ -473,221 +477,219 @@ function Ee({
473
477
  defaultHeight: i = 0,
474
478
  defaultWidth: f = 0,
475
479
  dir: l,
476
- gridRef: c,
480
+ gridRef: a,
477
481
  onCellsRendered: d,
478
- onResize: a,
479
- overscanCount: u = 3,
480
- rowCount: I,
481
- rowHeight: m,
482
- style: b,
483
- tagName: g = "div",
484
- ...w
482
+ onResize: c,
483
+ overscanCount: h = 3,
484
+ rowCount: p,
485
+ rowHeight: I,
486
+ style: u,
487
+ tagName: w = "div",
488
+ ...m
485
489
  }) {
486
- const y = de(t), V = L(
490
+ const O = de(t), G = A(
487
491
  () => le(e, ue),
488
492
  [e]
489
- ), [h, z] = H(null), k = ve(h, l), {
490
- getCellBounds: S,
491
- getEstimatedSize: W,
492
- startIndexOverscan: O,
493
- startIndexVisible: p,
494
- scrollToIndex: T,
495
- stopIndexOverscan: R,
496
- stopIndexVisible: v
497
- } = ee({
498
- containerElement: h,
499
- containerStyle: b,
493
+ ), [x, F] = M(null), V = ve(x, l), {
494
+ getCellBounds: z,
495
+ getEstimatedSize: $,
496
+ startIndexOverscan: y,
497
+ startIndexVisible: g,
498
+ scrollToIndex: S,
499
+ stopIndexOverscan: E,
500
+ stopIndexVisible: b
501
+ } = te({
502
+ containerElement: x,
503
+ containerStyle: u,
500
504
  defaultContainerSize: f,
501
505
  direction: "horizontal",
502
- isRtl: k,
506
+ isRtl: V,
503
507
  itemCount: n,
504
- itemProps: y,
508
+ itemProps: O,
505
509
  itemSize: o,
506
- onResize: a,
507
- overscanCount: u
510
+ onResize: c,
511
+ overscanCount: h
508
512
  }), {
509
- getCellBounds: x,
510
- getEstimatedSize: A,
511
- startIndexOverscan: M,
512
- startIndexVisible: re,
513
+ getCellBounds: v,
514
+ getEstimatedSize: R,
515
+ startIndexOverscan: k,
516
+ startIndexVisible: ne,
513
517
  scrollToIndex: Q,
514
518
  stopIndexOverscan: _,
515
- stopIndexVisible: ne
516
- } = ee({
517
- containerElement: h,
518
- containerStyle: b,
519
+ stopIndexVisible: oe
520
+ } = te({
521
+ containerElement: x,
522
+ containerStyle: u,
519
523
  defaultContainerSize: i,
520
524
  direction: "vertical",
521
- itemCount: I,
522
- itemProps: y,
523
- itemSize: m,
524
- onResize: a,
525
- overscanCount: u
525
+ itemCount: p,
526
+ itemProps: O,
527
+ itemSize: I,
528
+ onResize: c,
529
+ overscanCount: h
526
530
  });
527
531
  ce(
528
- c,
532
+ a,
529
533
  () => ({
530
534
  get element() {
531
- return h;
535
+ return x;
532
536
  },
533
537
  scrollToCell({
534
- behavior: B = "auto",
535
- columnAlign: E = "auto",
536
- columnIndex: j,
537
- rowAlign: D = "auto",
538
- rowIndex: G
538
+ behavior: H = "auto",
539
+ columnAlign: T = "auto",
540
+ columnIndex: W,
541
+ rowAlign: B = "auto",
542
+ rowIndex: j
539
543
  }) {
540
- const N = T({
541
- align: E,
542
- containerScrollOffset: h?.scrollLeft ?? 0,
543
- index: j
544
+ const N = S({
545
+ align: T,
546
+ containerScrollOffset: x?.scrollLeft ?? 0,
547
+ index: W
544
548
  }), ge = Q({
545
- align: D,
546
- containerScrollOffset: h?.scrollTop ?? 0,
547
- index: G
549
+ align: B,
550
+ containerScrollOffset: x?.scrollTop ?? 0,
551
+ index: j
548
552
  });
549
- typeof h?.scrollTo == "function" && h.scrollTo({
550
- behavior: B,
553
+ typeof x?.scrollTo == "function" && x.scrollTo({
554
+ behavior: H,
551
555
  left: N,
552
556
  top: ge
553
557
  });
554
558
  },
555
559
  scrollToColumn({
556
- align: B = "auto",
557
- behavior: E = "auto",
558
- index: j
560
+ align: H = "auto",
561
+ behavior: T = "auto",
562
+ index: W
559
563
  }) {
560
- const D = T({
561
- align: B,
562
- containerScrollOffset: h?.scrollLeft ?? 0,
563
- index: j
564
+ const B = S({
565
+ align: H,
566
+ containerScrollOffset: x?.scrollLeft ?? 0,
567
+ index: W
564
568
  });
565
- typeof h?.scrollTo == "function" && h.scrollTo({
566
- behavior: E,
567
- left: D
569
+ typeof x?.scrollTo == "function" && x.scrollTo({
570
+ behavior: T,
571
+ left: B
568
572
  });
569
573
  },
570
574
  scrollToRow({
571
- align: B = "auto",
572
- behavior: E = "auto",
573
- index: j
575
+ align: H = "auto",
576
+ behavior: T = "auto",
577
+ index: W
574
578
  }) {
575
- const D = Q({
576
- align: B,
577
- containerScrollOffset: h?.scrollTop ?? 0,
578
- index: j
579
+ const B = Q({
580
+ align: H,
581
+ containerScrollOffset: x?.scrollTop ?? 0,
582
+ index: W
579
583
  });
580
- typeof h?.scrollTo == "function" && h.scrollTo({
581
- behavior: E,
582
- top: D
584
+ typeof x?.scrollTo == "function" && x.scrollTo({
585
+ behavior: T,
586
+ top: B
583
587
  });
584
588
  }
585
589
  }),
586
- [h, T, Q]
590
+ [x, S, Q]
587
591
  ), J(() => {
588
- O >= 0 && R >= 0 && M >= 0 && _ >= 0 && d && d(
592
+ y >= 0 && E >= 0 && k >= 0 && _ >= 0 && d && d(
589
593
  {
590
- columnStartIndex: p,
591
- columnStopIndex: v,
592
- rowStartIndex: re,
593
- rowStopIndex: ne
594
+ columnStartIndex: g,
595
+ columnStopIndex: b,
596
+ rowStartIndex: ne,
597
+ rowStopIndex: oe
594
598
  },
595
599
  {
596
- columnStartIndex: O,
597
- columnStopIndex: R,
598
- rowStartIndex: M,
600
+ columnStartIndex: y,
601
+ columnStopIndex: E,
602
+ rowStartIndex: k,
599
603
  rowStopIndex: _
600
604
  }
601
605
  );
602
606
  }, [
603
607
  d,
604
- O,
605
- p,
606
- R,
607
- v,
608
- M,
609
- re,
608
+ y,
609
+ g,
610
+ E,
611
+ b,
612
+ k,
613
+ ne,
610
614
  _,
611
- ne
615
+ oe
612
616
  ]);
613
- const he = L(() => {
614
- const B = [];
615
- if (n > 0 && I > 0)
616
- for (let E = M; E <= _; E++) {
617
- const j = x(E), D = [];
618
- for (let G = O; G <= R; G++) {
619
- const N = S(G);
620
- D.push(
617
+ const he = A(() => {
618
+ const H = [];
619
+ if (n > 0 && p > 0)
620
+ for (let T = k; T <= _; T++) {
621
+ const W = v(T), B = [];
622
+ for (let j = y; j <= E; j++) {
623
+ const N = z(j);
624
+ B.push(
621
625
  /* @__PURE__ */ X(
622
- V,
626
+ G,
623
627
  {
624
- ...y,
628
+ ...O,
625
629
  ariaAttributes: {
626
- "aria-colindex": G + 1,
630
+ "aria-colindex": j + 1,
627
631
  role: "gridcell"
628
632
  },
629
- columnIndex: G,
630
- key: G,
631
- rowIndex: E,
633
+ columnIndex: j,
634
+ key: j,
635
+ rowIndex: T,
632
636
  style: {
633
637
  position: "absolute",
634
- left: k ? void 0 : 0,
635
- right: k ? 0 : void 0,
636
- transform: `translate(${k ? -N.scrollOffset : N.scrollOffset}px, ${j.scrollOffset}px)`,
637
- height: j.size,
638
+ left: V ? void 0 : 0,
639
+ right: V ? 0 : void 0,
640
+ transform: `translate(${V ? -N.scrollOffset : N.scrollOffset}px, ${W.scrollOffset}px)`,
641
+ height: W.size,
638
642
  width: N.size
639
643
  }
640
644
  }
641
645
  )
642
646
  );
643
647
  }
644
- B.push(
645
- /* @__PURE__ */ P("div", { role: "row", "aria-rowindex": E + 1, children: D }, E)
648
+ H.push(
649
+ /* @__PURE__ */ ee("div", { role: "row", "aria-rowindex": T + 1, children: B }, T)
646
650
  );
647
651
  }
648
- return B;
652
+ return H;
649
653
  }, [
650
- V,
651
- y,
652
- n,
654
+ G,
653
655
  O,
654
- R,
655
- S,
656
- x,
656
+ n,
657
+ y,
658
+ E,
659
+ z,
660
+ v,
661
+ V,
662
+ p,
657
663
  k,
658
- I,
659
- M,
660
664
  _
661
- ]), pe = /* @__PURE__ */ P(
665
+ ]), pe = /* @__PURE__ */ ee(
662
666
  "div",
663
667
  {
664
668
  "aria-hidden": !0,
665
669
  style: {
666
- height: A(),
667
- width: W(),
670
+ height: R(),
671
+ width: $(),
668
672
  zIndex: -1
669
673
  }
670
674
  }
671
675
  );
672
676
  return X(
673
- g,
677
+ w,
674
678
  {
675
679
  "aria-colcount": n,
676
- "aria-rowcount": I,
680
+ "aria-rowcount": p,
677
681
  role: "grid",
678
- ...w,
682
+ ...m,
679
683
  className: r,
680
684
  dir: l,
681
- ref: z,
685
+ ref: F,
682
686
  style: {
683
687
  position: "relative",
684
- width: "100%",
685
- height: "100%",
686
688
  maxHeight: "100%",
687
689
  maxWidth: "100%",
688
690
  flexGrow: 1,
689
691
  overflow: "auto",
690
- ...b
692
+ ...u
691
693
  }
692
694
  },
693
695
  he,
@@ -695,11 +697,11 @@ function Ee({
695
697
  pe
696
698
  );
697
699
  }
698
- const Ve = H, Re = K;
700
+ const Re = M, Ve = K;
699
701
  function ze(e) {
700
702
  return e != null && typeof e == "object" && "getAverageRowHeight" in e && typeof e.getAverageRowHeight == "function";
701
703
  }
702
- const te = "data-react-window-index";
704
+ const se = "data-react-window-index";
703
705
  function Ae({
704
706
  children: e,
705
707
  className: t,
@@ -710,31 +712,31 @@ function Ae({
710
712
  overscanCount: i = 3,
711
713
  rowComponent: f,
712
714
  rowCount: l,
713
- rowHeight: c,
715
+ rowHeight: a,
714
716
  rowProps: d,
715
- tagName: a = "div",
716
- style: u,
717
- ...I
717
+ tagName: c = "div",
718
+ style: h,
719
+ ...p
718
720
  }) {
719
- const m = de(d), b = L(
721
+ const I = de(d), u = A(
720
722
  () => le(f, ue),
721
723
  [f]
722
- ), [g, w] = H(null), y = ze(c), V = L(() => y ? (v) => c.getRowHeight(v) ?? c.getAverageRowHeight() : c, [y, c]), {
723
- getCellBounds: h,
724
- getEstimatedSize: z,
725
- scrollToIndex: k,
726
- startIndexOverscan: S,
727
- startIndexVisible: W,
728
- stopIndexOverscan: O,
729
- stopIndexVisible: p
730
- } = ee({
731
- containerElement: g,
732
- containerStyle: u,
724
+ ), [w, m] = M(null), O = ze(a), G = A(() => O ? (b) => a.getRowHeight(b) ?? a.getAverageRowHeight() : a, [O, a]), {
725
+ getCellBounds: x,
726
+ getEstimatedSize: F,
727
+ scrollToIndex: V,
728
+ startIndexOverscan: z,
729
+ startIndexVisible: $,
730
+ stopIndexOverscan: y,
731
+ stopIndexVisible: g
732
+ } = te({
733
+ containerElement: w,
734
+ containerStyle: h,
733
735
  defaultContainerSize: s,
734
736
  direction: "vertical",
735
737
  itemCount: l,
736
- itemProps: m,
737
- itemSize: V,
738
+ itemProps: I,
739
+ itemSize: G,
738
740
  onResize: n,
739
741
  overscanCount: i
740
742
  });
@@ -742,135 +744,135 @@ function Ae({
742
744
  r,
743
745
  () => ({
744
746
  get element() {
745
- return g;
747
+ return w;
746
748
  },
747
749
  scrollToRow({
748
- align: v = "auto",
749
- behavior: x = "auto",
750
- index: A
750
+ align: b = "auto",
751
+ behavior: v = "auto",
752
+ index: R
751
753
  }) {
752
- const M = k({
753
- align: v,
754
- containerScrollOffset: g?.scrollTop ?? 0,
755
- index: A
754
+ const k = V({
755
+ align: b,
756
+ containerScrollOffset: w?.scrollTop ?? 0,
757
+ index: R
756
758
  });
757
- typeof g?.scrollTo == "function" && g.scrollTo({
758
- behavior: x,
759
- top: M
759
+ typeof w?.scrollTo == "function" && w.scrollTo({
760
+ behavior: v,
761
+ top: k
760
762
  });
761
763
  }
762
764
  }),
763
- [g, k]
765
+ [w, V]
764
766
  ), q(() => {
765
- if (!g)
767
+ if (!w)
766
768
  return;
767
- const v = Array.from(g.children).filter((x, A) => {
768
- if (x.hasAttribute("aria-hidden"))
769
+ const b = Array.from(w.children).filter((v, R) => {
770
+ if (v.hasAttribute("aria-hidden"))
769
771
  return !1;
770
- const M = `${S + A}`;
771
- return x.setAttribute(te, M), !0;
772
+ const k = `${z + R}`;
773
+ return v.setAttribute(se, k), !0;
772
774
  });
773
- if (y)
774
- return c.observeRowElements(v);
775
+ if (O)
776
+ return a.observeRowElements(b);
775
777
  }, [
776
- g,
777
- y,
778
- c,
779
- S,
780
- O
778
+ w,
779
+ O,
780
+ a,
781
+ z,
782
+ y
781
783
  ]), J(() => {
782
- S >= 0 && O >= 0 && o && o(
784
+ z >= 0 && y >= 0 && o && o(
783
785
  {
784
- startIndex: W,
785
- stopIndex: p
786
+ startIndex: $,
787
+ stopIndex: g
786
788
  },
787
789
  {
788
- startIndex: S,
789
- stopIndex: O
790
+ startIndex: z,
791
+ stopIndex: y
790
792
  }
791
793
  );
792
794
  }, [
793
795
  o,
794
- S,
795
- W,
796
- O,
797
- p
796
+ z,
797
+ $,
798
+ y,
799
+ g
798
800
  ]);
799
- const T = L(() => {
800
- const v = [];
801
+ const S = A(() => {
802
+ const b = [];
801
803
  if (l > 0)
802
- for (let x = S; x <= O; x++) {
803
- const A = h(x);
804
- v.push(
804
+ for (let v = z; v <= y; v++) {
805
+ const R = x(v);
806
+ b.push(
805
807
  /* @__PURE__ */ X(
806
- b,
808
+ u,
807
809
  {
808
- ...m,
810
+ ...I,
809
811
  ariaAttributes: {
810
- "aria-posinset": x + 1,
812
+ "aria-posinset": v + 1,
811
813
  "aria-setsize": l,
812
814
  role: "listitem"
813
815
  },
814
- key: x,
815
- index: x,
816
+ key: v,
817
+ index: v,
816
818
  style: {
817
819
  position: "absolute",
818
820
  left: 0,
819
- transform: `translateY(${A.scrollOffset}px)`,
821
+ transform: `translateY(${R.scrollOffset}px)`,
820
822
  // In case of dynamic row heights, don't specify a height style
821
823
  // otherwise a default/estimated height would mask the actual height
822
- height: y ? void 0 : A.size,
824
+ height: O ? void 0 : R.size,
823
825
  width: "100%"
824
826
  }
825
827
  }
826
828
  )
827
829
  );
828
830
  }
829
- return v;
831
+ return b;
830
832
  }, [
831
- b,
832
- h,
833
- y,
833
+ u,
834
+ x,
835
+ O,
834
836
  l,
835
- m,
836
- S,
837
- O
838
- ]), R = /* @__PURE__ */ P(
837
+ I,
838
+ z,
839
+ y
840
+ ]), E = /* @__PURE__ */ ee(
839
841
  "div",
840
842
  {
841
843
  "aria-hidden": !0,
842
844
  style: {
843
- height: z(),
845
+ height: F(),
844
846
  width: "100%",
845
847
  zIndex: -1
846
848
  }
847
849
  }
848
850
  );
849
851
  return X(
850
- a,
852
+ c,
851
853
  {
852
854
  role: "list",
853
- ...I,
855
+ ...p,
854
856
  className: t,
855
- ref: w,
857
+ ref: m,
856
858
  style: {
857
859
  position: "relative",
858
860
  maxHeight: "100%",
859
861
  flexGrow: 1,
860
862
  overflowY: "auto",
861
- ...u
863
+ ...h
862
864
  }
863
865
  },
864
- T,
866
+ S,
865
867
  e,
866
- R
868
+ E
867
869
  );
868
870
  }
869
871
  function ke({
870
872
  defaultRowHeight: e,
871
873
  key: t
872
874
  }) {
873
- const [s, r] = H({
875
+ const [s, r] = M({
874
876
  key: t,
875
877
  map: /* @__PURE__ */ new Map()
876
878
  });
@@ -878,52 +880,52 @@ function ke({
878
880
  key: t,
879
881
  map: /* @__PURE__ */ new Map()
880
882
  });
881
- const { map: n } = s, o = U(() => {
882
- let a = 0;
883
- return n.forEach((u) => {
884
- a += u;
885
- }), a === 0 ? e : a / n.size;
886
- }, [e, n]), i = U(
887
- (a) => {
888
- const u = n.get(a);
889
- return u !== void 0 ? u : (n.set(a, e), e);
883
+ const { map: n } = s, o = D(() => {
884
+ let c = 0;
885
+ return n.forEach((h) => {
886
+ c += h;
887
+ }), c === 0 ? e : c / n.size;
888
+ }, [e, n]), i = D(
889
+ (c) => {
890
+ const h = n.get(c);
891
+ return h !== void 0 ? h : (n.set(c, e), e);
890
892
  },
891
893
  [e, n]
892
- ), f = U((a, u) => {
893
- r((I) => {
894
- if (I.map.get(a) === u)
895
- return I;
896
- const m = new Map(I.map);
897
- return m.set(a, u), {
898
- ...I,
899
- map: m
894
+ ), f = D((c, h) => {
895
+ r((p) => {
896
+ if (p.map.get(c) === h)
897
+ return p;
898
+ const I = new Map(p.map);
899
+ return I.set(c, h), {
900
+ ...p,
901
+ map: I
900
902
  };
901
903
  });
902
904
  }, []), l = ae(
903
- (a) => {
904
- a.length !== 0 && a.forEach((u) => {
905
- const { borderBoxSize: I, target: m } = u, b = m.getAttribute(te);
906
- $(
907
- b !== null,
908
- `Invalid ${te} attribute value`
905
+ (c) => {
906
+ c.length !== 0 && c.forEach((h) => {
907
+ const { borderBoxSize: p, target: I } = h, u = I.getAttribute(se);
908
+ L(
909
+ u !== null,
910
+ `Invalid ${se} attribute value`
909
911
  );
910
- const g = parseInt(b), { blockSize: w } = I[0];
911
- w && f(g, w);
912
+ const w = parseInt(u), { blockSize: m } = p[0];
913
+ m && f(w, m);
912
914
  });
913
915
  }
914
- ), [c] = H(
916
+ ), [a] = M(
915
917
  () => new ResizeObserver(l)
916
918
  );
917
919
  J(() => () => {
918
- c.disconnect();
919
- }, [c]);
920
- const d = U(
921
- (a) => (a.forEach((u) => c.observe(u)), () => {
922
- a.forEach((u) => c.unobserve(u));
920
+ a.disconnect();
921
+ }, [a]);
922
+ const d = D(
923
+ (c) => (c.forEach((h) => a.observe(h)), () => {
924
+ c.forEach((h) => a.unobserve(h));
923
925
  }),
924
- [c]
926
+ [a]
925
927
  );
926
- return L(
928
+ return A(
927
929
  () => ({
928
930
  getAverageRowHeight: o,
929
931
  getRowHeight: i,
@@ -933,7 +935,7 @@ function ke({
933
935
  [o, i, f, d]
934
936
  );
935
937
  }
936
- const Le = H, Me = K;
938
+ const Le = M, Me = K;
937
939
  let C = -1;
938
940
  function $e(e = !1) {
939
941
  if (C === -1 || e) {
@@ -947,8 +949,8 @@ export {
947
949
  Ae as List,
948
950
  $e as getScrollbarSize,
949
951
  ke as useDynamicRowHeight,
950
- Ve as useGridCallbackRef,
951
- Re as useGridRef,
952
+ Re as useGridCallbackRef,
953
+ Ve as useGridRef,
952
954
  Le as useListCallbackRef,
953
955
  Me as useListRef
954
956
  };