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