react-window 2.4.1 → 2.5.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,8 +1,8 @@
1
1
  "use client";
2
- import { jsx as re } from "react/jsx-runtime";
3
- import { useLayoutEffect as Te, useEffect as ie, useState as M, useSyncExternalStore as Re, useMemo as N, useRef as H, useCallback as U, memo as ge, useImperativeHandle as xe, createElement as le, Fragment as ue } from "react";
4
- const W = typeof window < "u" ? Te : ie;
5
- function we(e) {
2
+ import { jsx as de } from "react/jsx-runtime";
3
+ import { useLayoutEffect as Ne, useEffect as le, useState as j, useSyncExternalStore as Be, useMemo as C, useRef as U, useCallback as Y, memo as Te, useImperativeHandle as Le, createElement as ve, Fragment as be } from "react";
4
+ const _ = typeof window < "u" ? Ne : le;
5
+ function Me(e) {
6
6
  let t = e;
7
7
  for (; t; ) {
8
8
  if (t.dir)
@@ -12,29 +12,29 @@ function we(e) {
12
12
  return !1;
13
13
  }
14
14
  function Ae(e, t) {
15
- const [s, o] = M(t === "rtl");
16
- return W(() => {
17
- t ? o(t === "rtl") : e && o(we(e));
18
- }, [t, e]), s;
15
+ const [r, o] = j(t === "rtl");
16
+ return _(() => {
17
+ t ? o(t === "rtl") : e && o(Me(e));
18
+ }, [t, e]), r;
19
19
  }
20
- function Me() {
20
+ function Pe() {
21
21
  return () => {
22
22
  };
23
23
  }
24
- function Ie() {
25
- return Re(
26
- Me,
24
+ function Ee() {
25
+ return Be(
26
+ Pe,
27
27
  () => !1,
28
28
  () => !0
29
29
  );
30
30
  }
31
- function ae(e) {
31
+ function J(e) {
32
32
  return e?.ownerDocument.defaultView ?? window;
33
33
  }
34
- function Oe(e) {
35
- return ae(e).ResizeObserver ?? (typeof ResizeObserver < "u" ? ResizeObserver : void 0);
34
+ function pe(e) {
35
+ return J(e).ResizeObserver ?? (typeof ResizeObserver < "u" ? ResizeObserver : void 0);
36
36
  }
37
- function de(e) {
37
+ function xe(e) {
38
38
  if (e !== void 0)
39
39
  switch (typeof e) {
40
40
  case "number":
@@ -46,172 +46,258 @@ function de(e) {
46
46
  }
47
47
  }
48
48
  }
49
- function Le({
49
+ function _e({
50
50
  box: e,
51
51
  defaultHeight: t,
52
- defaultWidth: s,
52
+ defaultWidth: r,
53
53
  disabled: o,
54
- element: r,
55
- mode: n,
56
- style: i
54
+ element: s,
55
+ mode: i,
56
+ style: n
57
57
  }) {
58
- const { styleHeight: l, styleWidth: a } = N(
58
+ const { styleHeight: u, styleWidth: v } = C(
59
59
  () => ({
60
- styleHeight: de(i?.height),
61
- styleWidth: de(i?.width)
60
+ styleHeight: xe(n?.height),
61
+ styleWidth: xe(n?.width)
62
62
  }),
63
- [i?.height, i?.width]
64
- ), [v, f] = M({
63
+ [n?.height, n?.width]
64
+ ), [h, f] = j({
65
65
  height: t,
66
- width: s
67
- }), c = o || n === "only-height" && l !== void 0 || n === "only-width" && a !== void 0 || l !== void 0 && a !== void 0;
68
- return W(() => {
69
- if (r === null || c)
66
+ width: r
67
+ }), d = o || i === "only-height" && u !== void 0 || i === "only-width" && v !== void 0 || u !== void 0 && v !== void 0;
68
+ return _(() => {
69
+ if (s === null || d)
70
70
  return;
71
- const u = Oe(r);
72
- if (!u)
71
+ const a = pe(s);
72
+ if (!a)
73
73
  return;
74
- const p = new u((d) => {
75
- for (const x of d) {
76
- const { contentRect: h, target: O } = x;
77
- r === O && f((g) => g.height === h.height && g.width === h.width ? g : {
78
- height: h.height,
79
- width: h.width
74
+ const l = new a((c) => {
75
+ for (const g of c) {
76
+ const { contentRect: w, target: b } = g;
77
+ s === b && f((x) => x.height === w.height && x.width === w.width ? x : {
78
+ height: w.height,
79
+ width: w.width
80
80
  });
81
81
  }
82
82
  });
83
- return p.observe(r, { box: e }), () => {
84
- p?.unobserve(r);
83
+ return l.observe(s, { box: e }), () => {
84
+ l?.unobserve(s);
85
85
  };
86
- }, [e, c, r, l, a]), N(
86
+ }, [e, d, s, u, v]), C(
87
87
  () => ({
88
- height: l ?? v.height,
89
- width: a ?? v.width
88
+ height: u ?? h.height,
89
+ width: v ?? h.width
90
90
  }),
91
- [v, l, a]
91
+ [h, u, v]
92
92
  );
93
93
  }
94
- function ee(e) {
95
- const t = H(() => {
94
+ function ie(e) {
95
+ const t = U(() => {
96
96
  throw new Error("Cannot call an event handler while rendering.");
97
97
  });
98
- return W(() => {
98
+ return _(() => {
99
99
  t.current = e;
100
- }, [e]), U((...s) => t.current?.(...s), [t]);
100
+ }, [e]), Y((...r) => t.current?.(...r), [t]);
101
101
  }
102
- const he = /* @__PURE__ */ new WeakMap();
103
- function Ee(e = !1, t = document) {
104
- let s = he.get(t);
105
- if (s === void 0 || e) {
106
- const o = t.createElement("div"), r = o.style;
107
- r.width = "50px", r.height = "50px", r.overflow = "scroll", r.direction = "rtl";
108
- const n = t.createElement("div"), i = n.style;
109
- i.width = "100px", i.height = "100px", o.appendChild(n), t.body.appendChild(o), o.scrollLeft > 0 ? s = "positive-descending" : (o.scrollLeft = 1, o.scrollLeft === 0 ? s = "negative" : s = "positive-ascending"), t.body.removeChild(o), he.set(t, s);
102
+ const me = /* @__PURE__ */ new WeakMap();
103
+ function Ue(e = !1, t = document) {
104
+ let r = me.get(t);
105
+ if (r === void 0 || e) {
106
+ const o = t.createElement("div"), s = o.style;
107
+ s.width = "50px", s.height = "50px", s.overflow = "scroll", s.direction = "rtl";
108
+ const i = t.createElement("div"), n = i.style;
109
+ n.width = "100px", n.height = "100px", o.appendChild(i), t.body.appendChild(o), o.scrollLeft > 0 ? r = "positive-descending" : (o.scrollLeft = 1, o.scrollLeft === 0 ? r = "negative" : r = "positive-ascending"), t.body.removeChild(o), me.set(t, r);
110
110
  }
111
- return s;
111
+ return r;
112
112
  }
113
- function C({
113
+ function ne({
114
114
  containerElement: e,
115
115
  direction: t,
116
- isRtl: s,
116
+ isRtl: r,
117
117
  scrollOffset: o
118
118
  }) {
119
- if (t === "horizontal" && s)
120
- switch (Ee(!1, e?.ownerDocument ?? document)) {
119
+ if (t === "horizontal" && r)
120
+ switch (Ue(!1, e?.ownerDocument ?? document)) {
121
121
  case "negative":
122
122
  return -o;
123
123
  case "positive-descending": {
124
124
  if (e) {
125
- const { clientWidth: r, scrollWidth: n } = e;
126
- return n - r - o;
125
+ const { clientWidth: s, scrollWidth: i } = e;
126
+ return i - s - o;
127
127
  }
128
128
  break;
129
129
  }
130
130
  }
131
131
  return o;
132
132
  }
133
- function $(e, t = "Assertion error") {
133
+ function De({
134
+ container: e,
135
+ element: t,
136
+ onChange: r
137
+ }) {
138
+ const o = J(t), s = pe(t), i = o.MutationObserver ?? (typeof MutationObserver < "u" ? MutationObserver : void 0), n = s ? new s(r) : void 0, u = (d) => !d.isConnected || (d.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0, v = i ? new i((d) => {
139
+ d.some(
140
+ (l) => Array.from(l.addedNodes).some(u) || // Removed nodes preceded the element if the node after them still does (or contains the element)
141
+ l.removedNodes.length > 0 && l.nextSibling !== null && u(l.nextSibling)
142
+ ) && (f(), r());
143
+ }) : void 0, h = /* @__PURE__ */ new Set(), f = () => {
144
+ for (const a of h)
145
+ n?.unobserve(a);
146
+ h.clear(), v?.disconnect();
147
+ let d = t;
148
+ for (; d !== e; ) {
149
+ const a = d.parentElement;
150
+ if (a === null)
151
+ break;
152
+ if (n)
153
+ for (let l = d.previousElementSibling; l !== null; l = l.previousElementSibling)
154
+ h.add(l), n.observe(l);
155
+ v?.observe(a, { childList: !0 }), d = a;
156
+ }
157
+ };
158
+ return f(), () => {
159
+ n?.disconnect(), v?.disconnect();
160
+ };
161
+ }
162
+ function ce(e) {
163
+ return e.window === e;
164
+ }
165
+ function $e(e, t) {
166
+ return t === "window" ? e ? J(e) : null : t ?? null;
167
+ }
168
+ function we(e, t) {
169
+ return ce(e) ? t === "vertical" ? e.scrollY : e.scrollX : t === "vertical" ? e.scrollTop : e.scrollLeft;
170
+ }
171
+ function je(e, t) {
172
+ const r = ce(e) ? e.document.scrollingElement ?? e.document.documentElement : e;
173
+ return t === "vertical" ? r.scrollHeight - r.clientHeight : r.scrollWidth - r.clientWidth;
174
+ }
175
+ function ae(e, t) {
176
+ e && typeof e.scrollTo == "function" && e.scrollTo(t);
177
+ }
178
+ function qe(e, t) {
179
+ const { overflowX: r, overflowY: o } = J(e).getComputedStyle(e), s = t === "vertical" ? o : r;
180
+ return s === "visible" || s === "clip" ? !1 : t === "vertical" ? e.scrollHeight - e.clientHeight > 1 : e.scrollWidth - e.clientWidth > 1;
181
+ }
182
+ function Ie({
183
+ containerElement: e,
184
+ direction: t,
185
+ isRtl: r,
186
+ scrollTarget: o
187
+ }) {
188
+ const s = t === "vertical";
189
+ let i, n;
190
+ if (ce(o)) {
191
+ const { documentElement: x } = o.document;
192
+ i = 0, n = s ? x.clientHeight : x.clientWidth;
193
+ } else {
194
+ const x = o.getBoundingClientRect();
195
+ i = s ? x.top + o.clientTop : x.left + o.clientLeft, n = s ? o.clientHeight : o.clientWidth;
196
+ }
197
+ const u = i + n, v = e.getBoundingClientRect(), h = s ? v.top + e.clientTop : v.left + e.clientLeft, f = s ? e.clientHeight : e.clientWidth, d = h + f, a = ne({
198
+ containerElement: e,
199
+ direction: t,
200
+ isRtl: r,
201
+ scrollOffset: s ? e.scrollTop : e.scrollLeft
202
+ }), c = !s && r ? d - u : i - h, g = c + n, w = Math.max(0, c), b = Math.min(f, g);
203
+ return {
204
+ offset: a + w,
205
+ size: Math.max(0, b - w),
206
+ viewportOffset: a + c,
207
+ viewportSize: n
208
+ };
209
+ }
210
+ function Oe({
211
+ direction: e,
212
+ isRtl: t,
213
+ scrollTarget: r,
214
+ viewportSize: o
215
+ }) {
216
+ const s = ce(r) ? r.document.documentElement : r, i = J(s).getComputedStyle(s), n = (h) => {
217
+ const f = parseFloat(h ?? "");
218
+ return !Number.isFinite(f) || f < 0 ? 0 : h.endsWith("px") ? f : h.endsWith("%") ? f * o / 100 : 0;
219
+ };
220
+ if (e === "vertical")
221
+ return {
222
+ end: n(i.scrollPaddingBottom),
223
+ start: n(i.scrollPaddingTop)
224
+ };
225
+ const u = n(i.scrollPaddingLeft), v = n(i.scrollPaddingRight);
226
+ return t ? { end: u, start: v } : { end: v, start: u };
227
+ }
228
+ function Z(e, t = "Assertion error") {
134
229
  if (!e)
135
230
  throw console.error(t), Error(t);
136
231
  }
137
- function J(e, t) {
232
+ function se(e, t) {
138
233
  if (e === t)
139
234
  return !0;
140
- if (!!e != !!t || ($(e !== void 0), $(t !== void 0), Object.keys(e).length !== Object.keys(t).length))
235
+ if (!!e != !!t || (Z(e !== void 0), Z(t !== void 0), Object.keys(e).length !== Object.keys(t).length))
141
236
  return !1;
142
- for (const s in e)
143
- if (!Object.hasOwn(t, s) || !Object.is(t[s], e[s]))
237
+ for (const r in e)
238
+ if (!Object.hasOwn(t, r) || !Object.is(t[r], e[r]))
144
239
  return !1;
145
240
  return !0;
146
241
  }
147
- function me({
242
+ function We({
148
243
  cachedBounds: e,
149
244
  itemCount: t,
150
- itemSize: s
245
+ itemSize: r
151
246
  }) {
152
247
  if (t === 0)
153
248
  return 0;
154
- if (typeof s == "number")
155
- return t * s;
249
+ if (typeof r == "number")
250
+ return t * r;
156
251
  {
157
252
  const o = e.get(
158
253
  e.size === 0 ? 0 : e.size - 1
159
254
  );
160
- $(o !== void 0, "Unexpected bounds cache miss");
161
- const r = (o.scrollOffset + o.size) / e.size;
162
- return t * r;
255
+ Z(o !== void 0, "Unexpected bounds cache miss");
256
+ const s = (o.scrollOffset + o.size) / e.size;
257
+ return t * s;
163
258
  }
164
259
  }
165
- function Ve({
260
+ function Se({
166
261
  align: e,
167
262
  cachedBounds: t,
168
- index: s,
169
- itemCount: o,
170
- itemSize: r,
263
+ clamp: r = !0,
264
+ index: o,
265
+ itemCount: s,
266
+ itemSize: i,
171
267
  containerScrollOffset: n,
172
- containerSize: i
268
+ containerSize: u
173
269
  }) {
174
- if (s < 0 || s >= o)
175
- throw RangeError(`Invalid index specified: ${s}`, {
176
- cause: `Index ${s} is not within the range of 0 - ${o - 1}`
270
+ if (o < 0 || o >= s)
271
+ throw RangeError(`Invalid index specified: ${o}`, {
272
+ cause: `Index ${o} is not within the range of 0 - ${s - 1}`
177
273
  });
178
- const l = t.get(s), a = me({
274
+ const v = t.get(o), h = We({
179
275
  cachedBounds: t,
180
- itemCount: o,
181
- itemSize: r
182
- }), v = Math.max(
183
- 0,
184
- Math.min(a - i, l.scrollOffset)
185
- ), f = Math.max(
186
- 0,
187
- l.scrollOffset - i + l.size
188
- ), c = l.size > i ? n >= l.scrollOffset && n <= f : n >= f && n <= l.scrollOffset;
189
- switch (e === "smart" && (e = c ? "auto" : "center"), e) {
276
+ itemCount: s,
277
+ itemSize: i
278
+ }), f = (c) => r ? Math.max(0, Math.min(h - u, c)) : c, d = f(v.scrollOffset), a = r ? Math.max(0, v.scrollOffset - u + v.size) : v.scrollOffset - u + v.size, l = v.size > u ? n >= v.scrollOffset && n <= a : n >= a && n <= v.scrollOffset;
279
+ switch (e === "smart" && (e = l ? "auto" : "center"), e) {
190
280
  case "start":
191
- return v;
281
+ return d;
192
282
  case "end":
193
- return f;
283
+ return a;
194
284
  case "center":
195
- return Math.max(
196
- 0,
197
- Math.min(
198
- a - i,
199
- l.scrollOffset + l.size / 2 - i / 2
200
- )
285
+ return f(
286
+ v.scrollOffset + v.size / 2 - u / 2
201
287
  );
202
288
  case "auto":
203
289
  default:
204
- return c ? n : n < f ? f : v;
290
+ return l ? n : n < a ? a : d;
205
291
  }
206
292
  }
207
- function ce({
293
+ function fe({
208
294
  cachedBounds: e,
209
295
  containerScrollOffset: t,
210
- containerSize: s,
296
+ containerSize: r,
211
297
  itemCount: o,
212
- overscanCount: r
298
+ overscanCount: s
213
299
  }) {
214
- const n = o - 1;
300
+ const i = o - 1;
215
301
  if (o === 0)
216
302
  return {
217
303
  startIndexVisible: 0,
@@ -219,1027 +305,1297 @@ function ce({
219
305
  startIndexOverscan: 0,
220
306
  stopIndexOverscan: -1
221
307
  };
222
- let i, l;
223
- const { itemSize: a } = e;
224
- if (a !== void 0)
225
- a > 0 ? (i = Math.max(
308
+ let n, u;
309
+ const { itemSize: v } = e;
310
+ if (v !== void 0)
311
+ v > 0 ? (n = Math.max(
226
312
  0,
227
- Math.min(n, Math.floor(t / a))
228
- ), l = Math.max(
229
- i,
313
+ Math.min(i, Math.floor(t / v))
314
+ ), u = Math.max(
315
+ n,
230
316
  Math.min(
231
- n,
232
- Math.ceil((t + s) / a) - 1
317
+ i,
318
+ Math.ceil((t + r) / v) - 1
233
319
  )
234
- )) : (i = 0, l = 0);
320
+ )) : (n = 0, u = 0);
235
321
  else {
236
- let v = 0, f = Math.min(n, Math.max(0, e.size - 1));
237
- for (; v < f; ) {
238
- const c = Math.floor((v + f) / 2), u = e.get(c);
239
- u.scrollOffset + u.size > t ? f = c : v = c + 1;
322
+ let h = 0, f = Math.min(i, Math.max(0, e.size - 1));
323
+ for (; h < f; ) {
324
+ const d = Math.floor((h + f) / 2), a = e.get(d);
325
+ a.scrollOffset + a.size > t ? f = d : h = d + 1;
240
326
  }
241
- for (; v < n; ) {
242
- const c = e.get(v);
243
- if (c.scrollOffset + c.size > t) break;
244
- v++;
327
+ for (; h < i; ) {
328
+ const d = e.get(h);
329
+ if (d.scrollOffset + d.size > t) break;
330
+ h++;
245
331
  }
246
- for (i = v, l = v; l < n; ) {
247
- const c = e.get(l);
248
- if (c.scrollOffset + c.size >= t + s)
332
+ for (n = h, u = h; u < i; ) {
333
+ const d = e.get(u);
334
+ if (d.scrollOffset + d.size >= t + r)
249
335
  break;
250
- l++;
336
+ u++;
251
337
  }
252
338
  }
253
339
  return {
254
- startIndexVisible: i,
255
- stopIndexVisible: l,
256
- startIndexOverscan: Math.max(0, i - r),
257
- stopIndexOverscan: Math.min(n, l + r)
340
+ startIndexVisible: n,
341
+ stopIndexVisible: u,
342
+ startIndexOverscan: Math.max(0, n - s),
343
+ stopIndexOverscan: Math.min(i, u + s)
258
344
  };
259
345
  }
260
- function ke({
346
+ function Ce({
261
347
  itemCount: e,
262
348
  itemProps: t,
263
- itemSize: s
349
+ itemSize: r
264
350
  }) {
265
351
  const o = /* @__PURE__ */ new Map();
266
352
  return {
267
- itemSize: typeof s == "number" ? s : void 0,
268
- get(r) {
269
- if ($(r < e, `Invalid index ${r}`), typeof s == "number")
270
- return $(r >= 0, `Invalid index ${r}`), { size: s, scrollOffset: r * s };
271
- for (; o.size - 1 < r; ) {
272
- const i = o.size, l = s(i, t);
273
- if (i === 0)
274
- o.set(i, {
275
- size: l,
353
+ itemSize: typeof r == "number" ? r : void 0,
354
+ get(s) {
355
+ if (Z(s < e, `Invalid index ${s}`), typeof r == "number")
356
+ return Z(s >= 0, `Invalid index ${s}`), { size: r, scrollOffset: s * r };
357
+ for (; o.size - 1 < s; ) {
358
+ const n = o.size, u = r(n, t);
359
+ if (n === 0)
360
+ o.set(n, {
361
+ size: u,
276
362
  scrollOffset: 0
277
363
  });
278
364
  else {
279
- const a = o.get(i - 1);
280
- $(
281
- a !== void 0,
282
- `Unexpected bounds cache miss for index ${r}`
283
- ), o.set(i, {
284
- scrollOffset: a.scrollOffset + a.size,
285
- size: l
365
+ const v = o.get(n - 1);
366
+ Z(
367
+ v !== void 0,
368
+ `Unexpected bounds cache miss for index ${s}`
369
+ ), o.set(n, {
370
+ scrollOffset: v.scrollOffset + v.size,
371
+ size: u
286
372
  });
287
373
  }
288
374
  }
289
- const n = o.get(r);
290
- return $(
291
- n !== void 0,
292
- `Unexpected bounds cache miss for index ${r}`
293
- ), n;
375
+ const i = o.get(s);
376
+ return Z(
377
+ i !== void 0,
378
+ `Unexpected bounds cache miss for index ${s}`
379
+ ), i;
294
380
  },
295
- set(r, n) {
296
- o.set(r, n);
381
+ set(s, i) {
382
+ o.set(s, i);
297
383
  },
298
384
  get size() {
299
385
  return o.size;
300
386
  }
301
387
  };
302
388
  }
303
- function Fe({
389
+ function Ge({
304
390
  itemCount: e,
305
391
  itemProps: t,
306
- itemSize: s
392
+ itemSize: r
307
393
  }) {
308
- return N(
309
- () => ke({
394
+ return C(
395
+ () => Ce({
310
396
  itemCount: e,
311
397
  itemProps: t,
312
- itemSize: s
398
+ itemSize: r
313
399
  }),
314
- [e, t, s]
400
+ [e, t, r]
315
401
  );
316
402
  }
317
- function We({
403
+ function Xe({
318
404
  containerSize: e,
319
405
  itemSize: t
320
406
  }) {
321
- let s;
407
+ let r;
322
408
  switch (typeof t) {
323
409
  case "string": {
324
- $(
410
+ Z(
325
411
  t.endsWith("%"),
326
412
  `Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`
327
- ), $(
413
+ ), Z(
328
414
  e !== void 0,
329
415
  "Container size must be defined if a percentage item size is specified"
330
- ), s = e * parseFloat(t) / 100;
416
+ ), r = e * parseFloat(t) / 100;
331
417
  break;
332
418
  }
333
419
  default: {
334
- s = t;
420
+ r = t;
335
421
  break;
336
422
  }
337
423
  }
338
- return typeof s == "number" && !(Number.isFinite(s) && s > 0) && (s = 0), s;
424
+ return typeof r == "number" && !(Number.isFinite(r) && r > 0) && (r = 0), r;
339
425
  }
340
- function fe({
426
+ function he({
341
427
  containerElement: e,
342
428
  containerStyle: t,
343
- defaultContainerSize: s = 0,
429
+ defaultContainerSize: r = 0,
344
430
  defaultScrollOffset: o = 0,
345
- direction: r,
346
- isRtl: n = !1,
347
- itemCount: i,
348
- itemProps: l,
349
- itemSize: a,
350
- onResize: v,
351
- overscanCount: f
431
+ direction: s,
432
+ isRtl: i = !1,
433
+ itemCount: n,
434
+ itemProps: u,
435
+ itemSize: v,
436
+ onResize: h,
437
+ overscanCount: f,
438
+ scrollElement: d
352
439
  }) {
353
- const { height: c = s, width: u = s } = Le({
354
- defaultHeight: r === "vertical" ? s : void 0,
355
- defaultWidth: r === "horizontal" ? s : void 0,
440
+ const a = d !== void 0, l = a ? $e(e, d) : e, { height: c = r, width: g = r } = _e({
441
+ defaultHeight: s === "vertical" ? r : void 0,
442
+ defaultWidth: s === "horizontal" ? r : void 0,
356
443
  element: e,
357
- mode: r === "vertical" ? "only-height" : "only-width",
444
+ mode: s === "vertical" ? "only-height" : "only-width",
358
445
  style: t
359
- }), p = H({
446
+ }), w = U({
360
447
  height: 0,
361
448
  width: 0
362
- }), d = r === "vertical" ? c : u, x = We({ containerSize: d, itemSize: a });
363
- W(() => {
364
- if (typeof v == "function") {
365
- const b = p.current;
366
- (b.height !== c || b.width !== u) && (v({ height: c, width: u }, { ...b }), b.height = c, b.width = u);
449
+ }), [b, x] = j(r), m = a ? b : s === "vertical" ? c : g, V = Xe({ containerSize: m, itemSize: v });
450
+ _(() => {
451
+ if (typeof h == "function") {
452
+ const S = w.current;
453
+ (S.height !== c || S.width !== g) && (h({ height: c, width: g }, { ...S }), S.height = c, S.width = g);
367
454
  }
368
- }, [c, v, u]);
369
- const h = Fe({
370
- itemCount: i,
371
- itemProps: l,
372
- itemSize: x
373
- }), O = Ie(), [g] = M(
374
- () => O ? 0 : o
375
- ), D = U(
376
- (b) => h.get(b),
377
- [h]
378
- ), [z, X] = M(
379
- () => ce({
380
- cachedBounds: h,
381
- containerScrollOffset: g,
382
- containerSize: d,
383
- itemCount: i,
455
+ }, [c, h, g]);
456
+ const z = Ge({
457
+ itemCount: n,
458
+ itemProps: u,
459
+ itemSize: V
460
+ }), N = Ee(), [L] = j(
461
+ () => N || a ? 0 : o
462
+ ), B = Y(
463
+ (S) => z.get(S),
464
+ [z]
465
+ ), [F, G] = j(
466
+ () => fe({
467
+ cachedBounds: z,
468
+ containerScrollOffset: L,
469
+ containerSize: m,
470
+ itemCount: n,
384
471
  overscanCount: f
385
472
  })
386
473
  ), {
387
- startIndexVisible: L,
388
- startIndexOverscan: j,
389
- stopIndexVisible: I,
390
- stopIndexOverscan: te
474
+ startIndexVisible: P,
475
+ startIndexOverscan: Q,
476
+ stopIndexVisible: te,
477
+ stopIndexOverscan: R
391
478
  } = {
392
- startIndexVisible: Math.min(i - 1, z.startIndexVisible),
393
- startIndexOverscan: Math.min(i - 1, z.startIndexOverscan),
394
- stopIndexVisible: Math.min(i - 1, z.stopIndexVisible),
395
- stopIndexOverscan: Math.min(i - 1, z.stopIndexOverscan)
396
- }, A = U(
397
- () => me({
398
- cachedBounds: h,
399
- itemCount: i,
400
- itemSize: x
479
+ startIndexVisible: Math.min(n - 1, F.startIndexVisible),
480
+ startIndexOverscan: Math.min(n - 1, F.startIndexOverscan),
481
+ stopIndexVisible: Math.min(n - 1, F.stopIndexVisible),
482
+ stopIndexOverscan: Math.min(n - 1, F.stopIndexOverscan)
483
+ }, I = Y(
484
+ () => We({
485
+ cachedBounds: z,
486
+ itemCount: n,
487
+ itemSize: V
401
488
  }),
402
- [h, i, x]
403
- ), q = U(
404
- (b) => {
405
- const w = C({
489
+ [z, n, V]
490
+ ), H = Y(
491
+ (S) => {
492
+ const p = ne({
406
493
  containerElement: e,
407
- direction: r,
408
- isRtl: n,
409
- scrollOffset: b
494
+ direction: s,
495
+ isRtl: i,
496
+ scrollOffset: S
410
497
  });
411
- return ce({
412
- cachedBounds: h,
413
- containerScrollOffset: w,
414
- containerSize: d,
415
- itemCount: i,
498
+ return fe({
499
+ cachedBounds: z,
500
+ containerScrollOffset: p,
501
+ containerSize: m,
502
+ itemCount: n,
416
503
  overscanCount: f
417
504
  });
418
505
  },
419
506
  [
420
- h,
507
+ z,
421
508
  e,
422
- d,
423
- r,
424
- n,
509
+ m,
510
+ s,
425
511
  i,
512
+ n,
426
513
  f
427
514
  ]
428
- ), Q = H(!1);
429
- W(() => {
430
- if (!e || i === 0 || Q.current || (Q.current = !0, o <= 0))
515
+ ), O = U(!1);
516
+ _(() => {
517
+ if (!e || n === 0 || a || O.current || (O.current = !0, o <= 0))
431
518
  return;
432
- const b = r === "horizontal" && we(e);
433
- if (C({
519
+ const S = s === "horizontal" && Me(e);
520
+ if (ne({
434
521
  containerElement: e,
435
- direction: r,
436
- isRtl: b,
437
- scrollOffset: r === "vertical" ? e.scrollTop : e.scrollLeft
522
+ direction: s,
523
+ isRtl: S,
524
+ scrollOffset: s === "vertical" ? e.scrollTop : e.scrollLeft
438
525
  }) !== 0)
439
526
  return;
440
- const y = C({
527
+ const M = ne({
441
528
  containerElement: e,
442
- direction: r,
443
- isRtl: b,
529
+ direction: s,
530
+ isRtl: S,
444
531
  scrollOffset: o
445
532
  });
446
533
  typeof e.scrollTo == "function" ? e.scrollTo({
447
534
  behavior: "instant",
448
- [r === "vertical" ? "top" : "left"]: y
449
- }) : r === "vertical" ? e.scrollTop = y : e.scrollLeft = y;
450
- }, [e, i]), W(() => {
451
- const b = e ? q(
452
- r === "vertical" ? e.scrollTop : e.scrollLeft
453
- ) : ce({
454
- cachedBounds: h,
455
- containerScrollOffset: g,
456
- containerSize: d,
457
- itemCount: i,
535
+ [s === "vertical" ? "top" : "left"]: M
536
+ }) : s === "vertical" ? e.scrollTop = M : e.scrollLeft = M;
537
+ }, [e, n]), _(() => {
538
+ if (a && e && l)
539
+ return;
540
+ const S = e && !a ? H(
541
+ s === "vertical" ? e.scrollTop : e.scrollLeft
542
+ ) : fe({
543
+ cachedBounds: z,
544
+ containerScrollOffset: L,
545
+ containerSize: m,
546
+ itemCount: n,
458
547
  overscanCount: f
459
548
  });
460
- X((w) => J(b, w) ? w : b);
549
+ G((p) => se(S, p) ? p : S);
461
550
  }, [
462
- h,
551
+ z,
463
552
  e,
464
- d,
465
- r,
466
- q,
467
- g,
468
- i,
469
- f
470
- ]), W(() => {
471
- if (!e)
553
+ m,
554
+ s,
555
+ H,
556
+ L,
557
+ a,
558
+ n,
559
+ f,
560
+ l
561
+ ]), _(() => {
562
+ if (!e || a)
472
563
  return;
473
- const b = () => {
474
- X((w) => {
475
- const { scrollLeft: y, scrollTop: T } = e, E = C({
564
+ const S = () => {
565
+ G((p) => {
566
+ const { scrollLeft: M, scrollTop: k } = e, A = ne({
476
567
  containerElement: e,
477
- direction: r,
478
- isRtl: n,
479
- scrollOffset: r === "vertical" ? T : y
480
- }), V = ce({
481
- cachedBounds: h,
482
- containerScrollOffset: E,
483
- containerSize: d,
484
- itemCount: i,
568
+ direction: s,
569
+ isRtl: i,
570
+ scrollOffset: s === "vertical" ? k : M
571
+ }), D = fe({
572
+ cachedBounds: z,
573
+ containerScrollOffset: A,
574
+ containerSize: m,
575
+ itemCount: n,
485
576
  overscanCount: f
486
577
  });
487
- return J(V, w) ? w : V;
578
+ return se(D, p) ? p : D;
488
579
  });
489
580
  };
490
- return e.addEventListener("scroll", b), () => {
491
- e.removeEventListener("scroll", b);
581
+ return e.addEventListener("scroll", S), () => {
582
+ e.removeEventListener("scroll", S);
492
583
  };
493
584
  }, [
494
- h,
585
+ z,
495
586
  e,
496
- d,
497
- r,
498
- n,
587
+ m,
588
+ s,
499
589
  i,
590
+ a,
591
+ n,
500
592
  f
501
593
  ]);
502
- const m = ee(
594
+ const K = ie(() => {
595
+ if (!e || !l)
596
+ return;
597
+ const { offset: S, size: p, viewportSize: M } = Ie({
598
+ containerElement: e,
599
+ direction: s,
600
+ isRtl: i,
601
+ scrollTarget: l
602
+ });
603
+ x(M);
604
+ const k = fe({
605
+ cachedBounds: z,
606
+ containerScrollOffset: S,
607
+ containerSize: p,
608
+ itemCount: n,
609
+ overscanCount: f
610
+ });
611
+ G((A) => se(k, A) ? A : k);
612
+ });
613
+ _(() => {
614
+ a && K();
615
+ }), _(() => {
616
+ if (!a || !e || !l)
617
+ return;
618
+ const S = J(e), p = () => K();
619
+ l.addEventListener("scroll", p, { passive: !0 }), e.addEventListener("scroll", p, { passive: !0 }), S.addEventListener("resize", p);
620
+ let M;
621
+ const k = pe(e);
622
+ k && !ce(l) && (M = new k(p), M.observe(l));
623
+ const A = De({
624
+ container: ce(l) ? l.document.documentElement : l,
625
+ element: e,
626
+ onChange: p
627
+ });
628
+ return () => {
629
+ l.removeEventListener("scroll", p), e.removeEventListener("scroll", p), S.removeEventListener("resize", p), M?.disconnect(), A();
630
+ };
631
+ }, [
632
+ e,
633
+ a,
634
+ l,
635
+ K
636
+ ]);
637
+ const re = ie(
503
638
  ({
504
- align: b = "auto",
505
- containerScrollOffset: w,
506
- index: y
639
+ align: S = "auto",
640
+ index: p
507
641
  }) => {
508
- let T = Ve({
509
- align: b,
510
- cachedBounds: h,
511
- containerScrollOffset: C({
642
+ const M = ({
643
+ clamp: E,
644
+ containerScrollOffset: W,
645
+ containerSize: T,
646
+ padding: y
647
+ }) => {
648
+ if (y.start === 0 && y.end === 0)
649
+ return Se({
650
+ align: S,
651
+ cachedBounds: z,
652
+ clamp: E,
653
+ containerScrollOffset: W,
654
+ containerSize: T,
655
+ index: p,
656
+ itemCount: n,
657
+ itemSize: V
658
+ });
659
+ const $ = Se({
660
+ align: S,
661
+ cachedBounds: z,
662
+ clamp: !1,
663
+ containerScrollOffset: W + y.start,
664
+ containerSize: Math.max(
665
+ 0,
666
+ T - y.start - y.end
667
+ ),
668
+ index: p,
669
+ itemCount: n,
670
+ itemSize: V
671
+ }) - y.start;
672
+ return E ? Math.max(0, Math.min(I() - T, $)) : $;
673
+ };
674
+ if (a && e && l && !qe(e, s)) {
675
+ const { viewportOffset: E, viewportSize: W } = Ie({
512
676
  containerElement: e,
513
- direction: r,
514
- isRtl: n,
515
- scrollOffset: w
677
+ direction: s,
678
+ isRtl: i,
679
+ scrollTarget: l
680
+ }), y = M({
681
+ clamp: !1,
682
+ containerScrollOffset: E,
683
+ containerSize: W,
684
+ padding: Oe({
685
+ direction: s,
686
+ isRtl: i,
687
+ scrollTarget: l,
688
+ viewportSize: W
689
+ })
690
+ }) - E, $ = s === "horizontal" && i ? -y : y;
691
+ return {
692
+ scrollOffset: we(l, s) + $,
693
+ scrollTarget: l
694
+ };
695
+ }
696
+ const k = e ? s === "vertical" ? e.scrollTop : e.scrollLeft : 0, A = a && e ? s === "vertical" ? e.clientHeight : e.clientWidth : m;
697
+ let D = M({
698
+ clamp: !0,
699
+ containerScrollOffset: ne({
700
+ containerElement: e,
701
+ direction: s,
702
+ isRtl: i,
703
+ scrollOffset: k
516
704
  }),
517
- containerSize: d,
518
- index: y,
519
- itemCount: i,
520
- itemSize: x
705
+ containerSize: A,
706
+ padding: e ? Oe({
707
+ direction: s,
708
+ isRtl: i,
709
+ scrollTarget: e,
710
+ viewportSize: A
711
+ }) : { end: 0, start: 0 }
521
712
  });
522
- if (e) {
523
- if (T = C({
713
+ if (e && (!a || l)) {
714
+ if (D = ne({
524
715
  containerElement: e,
525
- direction: r,
526
- isRtl: n,
527
- scrollOffset: T
528
- }), typeof e.scrollTo != "function") {
529
- const E = q(T);
530
- J(z, E) || X(E);
716
+ direction: s,
717
+ isRtl: i,
718
+ scrollOffset: D
719
+ }), !a && typeof e.scrollTo != "function") {
720
+ const E = H(D);
721
+ se(F, E) || G(E);
531
722
  }
532
- return T;
723
+ return { scrollOffset: D, scrollTarget: e };
533
724
  }
534
725
  }
535
726
  );
536
727
  return {
537
- getCellBounds: D,
538
- getEstimatedSize: A,
539
- scrollToIndex: m,
540
- startIndexOverscan: j,
541
- startIndexVisible: L,
542
- stopIndexOverscan: te,
543
- stopIndexVisible: I
728
+ getCellBounds: B,
729
+ getEstimatedSize: I,
730
+ getScrollPositionForIndex: re,
731
+ scrollTarget: l,
732
+ startIndexOverscan: Q,
733
+ startIndexVisible: P,
734
+ stopIndexOverscan: R,
735
+ stopIndexVisible: te
544
736
  };
545
737
  }
546
- function ze(e) {
547
- const [t, s] = M(e);
548
- return J(t, e) ? t : (s(e), e);
738
+ function Ve(e) {
739
+ const [t, r] = j(e);
740
+ return se(t, e) ? t : (r(e), e);
549
741
  }
550
- function ye(e, t) {
742
+ function Fe(e, t) {
551
743
  const {
552
- ariaAttributes: s,
744
+ ariaAttributes: r,
553
745
  style: o,
554
- ...r
746
+ ...s
555
747
  } = e, {
556
- ariaAttributes: n,
557
- style: i,
558
- ...l
748
+ ariaAttributes: i,
749
+ style: n,
750
+ ...u
559
751
  } = t;
560
- return J(s, n) && J(o, i) && J(r, l);
752
+ return se(r, i) && se(o, n) && se(s, u);
561
753
  }
562
- function Ne({
754
+ function et({
563
755
  cellComponent: e,
564
756
  cellProps: t,
565
- children: s,
757
+ children: r,
566
758
  className: o,
567
- columnCount: r,
568
- columnKey: n,
569
- columnWidth: i,
570
- defaultHeight: l = 0,
571
- defaultScrollLeft: a = 0,
572
- defaultScrollTop: v = 0,
759
+ columnCount: s,
760
+ columnKey: i,
761
+ columnWidth: n,
762
+ defaultHeight: u = 0,
763
+ defaultScrollLeft: v = 0,
764
+ defaultScrollTop: h = 0,
573
765
  defaultWidth: f = 0,
574
- dir: c,
575
- gridRef: u,
576
- onCellsRendered: p,
577
- onResize: d,
578
- overscanCount: x = 3,
579
- rowCount: h,
580
- rowHeight: O,
581
- rowKey: g,
582
- style: D,
766
+ dir: d,
767
+ gridRef: a,
768
+ onCellsRendered: l,
769
+ onResize: c,
770
+ overscanCount: g = 3,
771
+ rowCount: w,
772
+ rowHeight: b,
773
+ rowKey: x,
774
+ scrollElement: m,
775
+ style: V,
583
776
  tagName: z = "div",
584
- ...X
777
+ ...N
585
778
  }) {
586
- const L = ze(t), j = N(
587
- () => ge(e, ye),
779
+ const L = Ve(t), B = C(
780
+ () => Te(e, Fe),
588
781
  [e]
589
- ), [I, te] = M(null), A = Ae(I, c), {
590
- getCellBounds: q,
591
- getEstimatedSize: Q,
592
- startIndexOverscan: m,
593
- startIndexVisible: b,
594
- scrollToIndex: w,
595
- stopIndexOverscan: y,
596
- stopIndexVisible: T
597
- } = fe({
598
- containerElement: I,
599
- containerStyle: D,
782
+ ), [F, G] = j(null), P = Ae(F, d), {
783
+ getCellBounds: Q,
784
+ getEstimatedSize: te,
785
+ startIndexOverscan: R,
786
+ startIndexVisible: I,
787
+ getScrollPositionForIndex: H,
788
+ stopIndexOverscan: O,
789
+ stopIndexVisible: K
790
+ } = he({
791
+ containerElement: F,
792
+ containerStyle: V,
600
793
  defaultContainerSize: f,
601
- defaultScrollOffset: a,
794
+ defaultScrollOffset: v,
602
795
  direction: "horizontal",
603
- isRtl: A,
604
- itemCount: r,
796
+ isRtl: P,
797
+ itemCount: s,
605
798
  itemProps: L,
606
- itemSize: i,
607
- onResize: d,
608
- overscanCount: x
799
+ itemSize: n,
800
+ onResize: c,
801
+ overscanCount: g,
802
+ scrollElement: m
609
803
  }), {
610
- getCellBounds: E,
611
- getEstimatedSize: V,
612
- startIndexOverscan: Z,
613
- startIndexVisible: ne,
614
- scrollToIndex: K,
615
- stopIndexOverscan: G,
616
- stopIndexVisible: k
617
- } = fe({
618
- containerElement: I,
619
- containerStyle: D,
620
- defaultContainerSize: l,
621
- defaultScrollOffset: v,
804
+ getCellBounds: re,
805
+ getEstimatedSize: S,
806
+ startIndexOverscan: p,
807
+ startIndexVisible: M,
808
+ getScrollPositionForIndex: k,
809
+ stopIndexOverscan: A,
810
+ stopIndexVisible: D
811
+ } = he({
812
+ containerElement: F,
813
+ containerStyle: V,
814
+ defaultContainerSize: u,
815
+ defaultScrollOffset: h,
622
816
  direction: "vertical",
623
- itemCount: h,
817
+ itemCount: w,
624
818
  itemProps: L,
625
- itemSize: O,
626
- onResize: d,
627
- overscanCount: x
819
+ itemSize: b,
820
+ onResize: c,
821
+ overscanCount: g,
822
+ scrollElement: m
628
823
  });
629
- xe(
630
- u,
824
+ Le(
825
+ a,
631
826
  () => ({
632
827
  get element() {
633
- return I;
828
+ return F;
634
829
  },
635
830
  scrollToCell({
636
- behavior: F = "auto",
637
- columnAlign: S = "auto",
638
- columnIndex: _,
639
- rowAlign: Y = "auto",
640
- rowIndex: B
831
+ behavior: T = "auto",
832
+ columnAlign: y = "auto",
833
+ columnIndex: $,
834
+ rowAlign: q = "auto",
835
+ rowIndex: ee
641
836
  }) {
642
- const se = w({
643
- align: S,
644
- containerScrollOffset: I?.scrollLeft ?? 0,
645
- index: _
646
- }), Se = K({
647
- align: Y,
648
- containerScrollOffset: I?.scrollTop ?? 0,
649
- index: B
650
- });
651
- typeof I?.scrollTo == "function" && I.scrollTo({
652
- behavior: F,
653
- left: se,
654
- top: Se
837
+ const X = H({
838
+ align: y,
839
+ index: $
840
+ }), oe = k({
841
+ align: q,
842
+ index: ee
655
843
  });
844
+ X && oe && X.scrollTarget === oe.scrollTarget ? ae(oe.scrollTarget, {
845
+ behavior: T,
846
+ left: X.scrollOffset,
847
+ top: oe.scrollOffset
848
+ }) : (X && ae(X.scrollTarget, {
849
+ behavior: T,
850
+ left: X.scrollOffset
851
+ }), oe && ae(oe.scrollTarget, {
852
+ behavior: T,
853
+ top: oe.scrollOffset
854
+ }));
656
855
  },
657
856
  scrollToColumn({
658
- align: F = "auto",
659
- behavior: S = "auto",
660
- index: _
857
+ align: T = "auto",
858
+ behavior: y = "auto",
859
+ index: $
661
860
  }) {
662
- const Y = w({
663
- align: F,
664
- containerScrollOffset: I?.scrollLeft ?? 0,
665
- index: _
666
- });
667
- typeof I?.scrollTo == "function" && I.scrollTo({
668
- behavior: S,
669
- left: Y
861
+ const q = H({ align: T, index: $ });
862
+ q && ae(q.scrollTarget, {
863
+ behavior: y,
864
+ left: q.scrollOffset
670
865
  });
671
866
  },
672
867
  scrollToRow({
673
- align: F = "auto",
674
- behavior: S = "auto",
675
- index: _
868
+ align: T = "auto",
869
+ behavior: y = "auto",
870
+ index: $
676
871
  }) {
677
- const Y = K({
678
- align: F,
679
- containerScrollOffset: I?.scrollTop ?? 0,
680
- index: _
681
- });
682
- typeof I?.scrollTo == "function" && I.scrollTo({
683
- behavior: S,
684
- top: Y
872
+ const q = k({ align: T, index: $ });
873
+ q && ae(q.scrollTarget, {
874
+ behavior: y,
875
+ top: q.scrollOffset
685
876
  });
686
877
  }
687
878
  }),
688
- [I, w, K]
689
- ), ie(() => {
690
- m >= 0 && y >= 0 && Z >= 0 && G >= 0 && p && p(
879
+ [F, H, k]
880
+ ), le(() => {
881
+ R >= 0 && O >= 0 && p >= 0 && A >= 0 && l && l(
691
882
  {
692
- columnStartIndex: b,
693
- columnStopIndex: T,
694
- rowStartIndex: ne,
695
- rowStopIndex: k
883
+ columnStartIndex: I,
884
+ columnStopIndex: K,
885
+ rowStartIndex: M,
886
+ rowStopIndex: D
696
887
  },
697
888
  {
698
- columnStartIndex: m,
699
- columnStopIndex: y,
700
- rowStartIndex: Z,
701
- rowStopIndex: G
889
+ columnStartIndex: R,
890
+ columnStopIndex: O,
891
+ rowStartIndex: p,
892
+ rowStopIndex: A
702
893
  }
703
894
  );
704
895
  }, [
896
+ l,
897
+ R,
898
+ I,
899
+ O,
900
+ K,
705
901
  p,
706
- m,
707
- b,
708
- y,
709
- T,
710
- Z,
711
- ne,
712
- G,
713
- k
902
+ M,
903
+ A,
904
+ D
714
905
  ]);
715
- const R = N(() => {
716
- const F = [];
717
- if (r > 0 && h > 0)
718
- for (let S = Z; S <= G; S++) {
719
- const _ = E(S), Y = [];
720
- for (let B = m; B <= y; B++) {
721
- const se = q(B);
722
- Y.push(
723
- /* @__PURE__ */ le(
724
- j,
906
+ const E = C(() => {
907
+ const T = [];
908
+ if (s > 0 && w > 0)
909
+ for (let y = p; y <= A; y++) {
910
+ const $ = re(y), q = [];
911
+ for (let ee = R; ee <= O; ee++) {
912
+ const X = Q(ee);
913
+ q.push(
914
+ /* @__PURE__ */ ve(
915
+ B,
725
916
  {
726
917
  ...L,
727
918
  ariaAttributes: {
728
- "aria-colindex": B + 1,
919
+ "aria-colindex": ee + 1,
729
920
  role: "gridcell"
730
921
  },
731
- columnIndex: B,
732
- key: n ? n({
733
- columnIndex: B,
922
+ columnIndex: ee,
923
+ key: i ? i({
924
+ columnIndex: ee,
734
925
  data: L,
735
- rowIndex: S
736
- }) : B,
737
- rowIndex: S,
926
+ rowIndex: y
927
+ }) : ee,
928
+ rowIndex: y,
738
929
  style: {
739
930
  position: "absolute",
740
- left: A ? void 0 : 0,
741
- right: A ? 0 : void 0,
742
- transform: `translate(${A ? -se.scrollOffset : se.scrollOffset}px, ${_.scrollOffset}px)`,
743
- height: _.size,
744
- width: se.size
931
+ left: P ? void 0 : 0,
932
+ right: P ? 0 : void 0,
933
+ transform: `translate(${P ? -X.scrollOffset : X.scrollOffset}px, ${$.scrollOffset}px)`,
934
+ height: $.size,
935
+ width: X.size
745
936
  }
746
937
  }
747
938
  )
748
939
  );
749
940
  }
750
- F.push(
751
- /* @__PURE__ */ re(
941
+ T.push(
942
+ /* @__PURE__ */ de(
752
943
  "div",
753
944
  {
754
945
  role: "row",
755
- "aria-rowindex": S + 1,
756
- children: Y
946
+ "aria-rowindex": y + 1,
947
+ children: q
757
948
  },
758
- g ? g({
949
+ x ? x({
759
950
  data: L,
760
- rowIndex: S
761
- }) : S
951
+ rowIndex: y
952
+ }) : y
762
953
  )
763
954
  );
764
955
  }
765
- return F;
956
+ return T;
766
957
  }, [
767
- j,
958
+ B,
768
959
  L,
769
- r,
770
- n,
771
- m,
772
- y,
773
- q,
774
- E,
775
- A,
776
- h,
777
- g,
778
- Z,
779
- G
780
- ]), P = /* @__PURE__ */ re(
960
+ s,
961
+ i,
962
+ R,
963
+ O,
964
+ Q,
965
+ re,
966
+ P,
967
+ w,
968
+ x,
969
+ p,
970
+ A
971
+ ]), W = /* @__PURE__ */ de(
781
972
  "div",
782
973
  {
783
974
  "aria-hidden": !0,
784
975
  style: {
785
- height: V(),
786
- width: Q(),
976
+ height: S(),
977
+ width: te(),
787
978
  zIndex: -1
788
979
  }
789
980
  }
790
981
  );
791
- return le(
982
+ return ve(
792
983
  z,
793
984
  {
794
- "aria-colcount": r,
795
- "aria-rowcount": h,
985
+ "aria-colcount": s,
986
+ "aria-rowcount": w,
796
987
  role: "grid",
797
- ...X,
988
+ ...N,
798
989
  className: o,
799
- dir: c,
800
- ref: te,
990
+ dir: d,
991
+ ref: G,
801
992
  style: {
802
993
  position: "relative",
803
- maxHeight: "100%",
804
- maxWidth: "100%",
994
+ // Grids that scroll with an outer element render at their full height,
995
+ // and at their full width unless constrained by their parent (in which case columns scroll within the grid)
996
+ ...m === void 0 && {
997
+ maxHeight: "100%",
998
+ maxWidth: "100%"
999
+ },
805
1000
  flexGrow: 1,
806
1001
  overflow: "auto",
807
- ...D
1002
+ ...V
808
1003
  }
809
1004
  },
810
- R,
811
- s,
812
- P
1005
+ E,
1006
+ r,
1007
+ W
813
1008
  );
814
1009
  }
815
- const qe = M, Ge = H;
816
- function $e({
817
- callback: e,
818
- element: t,
819
- enabled: s = !0
820
- }) {
821
- const o = ee(e);
822
- ie(() => {
823
- if (!s || !t)
824
- return;
825
- const r = ae(t);
826
- let n = r.requestAnimationFrame(() => {
827
- n = r.requestAnimationFrame(o);
828
- });
829
- return () => {
830
- r.cancelAnimationFrame(n);
831
- };
832
- }, [t, s, o]);
1010
+ const tt = j, st = U, He = "data-react-window-index", Ye = "data-index";
1011
+ function ge(e) {
1012
+ const t = e.getAttribute(He) ?? e.getAttribute(Ye);
1013
+ return t !== null && /^\d+$/.test(t) ? Number(t) : void 0;
833
1014
  }
834
- function He(e) {
835
- return e != null && typeof e == "object" && "getAverageRowHeight" in e && typeof e.getAverageRowHeight == "function";
836
- }
837
- function je({
838
- element: e,
839
- getCellBounds: t,
840
- isDynamicRowHeight: s,
841
- rowCount: o,
842
- rowElements: r,
843
- scrollToIndex: n
1015
+ function ke({
1016
+ direction: e,
1017
+ element: t,
1018
+ getCellBounds: r,
1019
+ isDynamicSize: o,
1020
+ itemCount: s,
1021
+ itemElements: i,
1022
+ scrollTarget: n,
1023
+ getScrollPositionForIndex: u
844
1024
  }) {
845
- const i = H(null), l = H(
1025
+ const v = e === "vertical", h = U(null), f = U(
846
1026
  void 0
847
- ), a = ee(() => {
848
- i.current = null, l.current !== void 0 && (l.current.view.cancelAnimationFrame(l.current.id), l.current = void 0);
849
- }), v = ee(() => {
850
- const c = ae(e);
851
- l.current = {
852
- id: c.requestAnimationFrame(f),
1027
+ ), d = ie(() => {
1028
+ h.current = null, f.current !== void 0 && (f.current.view.cancelAnimationFrame(f.current.id), f.current = void 0);
1029
+ }), a = ie(() => {
1030
+ const c = J(t);
1031
+ f.current = {
1032
+ id: c.requestAnimationFrame(l),
853
1033
  view: c
854
1034
  };
855
- }), f = ee(() => {
856
- l.current = void 0;
857
- const c = i.current;
1035
+ }), l = ie(() => {
1036
+ f.current = void 0;
1037
+ const c = h.current;
858
1038
  if (!c) return;
859
- if (!e || !s || c.index >= o || performance.now() >= c.deadline) {
860
- a();
1039
+ if (!t || !o || c.index >= s || performance.now() >= c.deadline) {
1040
+ d();
861
1041
  return;
862
1042
  }
863
- const u = n({
1043
+ const g = u({
864
1044
  align: c.align,
865
- containerScrollOffset: e.scrollTop,
866
1045
  index: c.index
867
1046
  });
868
- if (u !== void 0) {
869
- const p = Math.max(
1047
+ if (g !== void 0) {
1048
+ const { scrollOffset: w, scrollTarget: b } = g, x = Math.max(
870
1049
  0,
871
- Math.min(u, e.scrollHeight - e.clientHeight)
1050
+ Math.min(w, je(b, e))
872
1051
  );
873
- if (Math.abs(p - e.scrollTop) > 1)
874
- c.stableFrames = 0, e.scrollTo({ behavior: "instant", top: p });
1052
+ if (Math.abs(x - we(b, e)) > 1)
1053
+ c.stableFrames = 0, b.scrollTo({
1054
+ behavior: "instant",
1055
+ [v ? "top" : "left"]: x
1056
+ });
875
1057
  else {
876
- const d = r.current;
877
- if (!(d.some(
878
- (O) => O.getAttribute(oe) === `${c.index}`
879
- ) && d.every((O) => {
880
- const g = Number(O.getAttribute(oe));
881
- return Math.abs(
882
- t(g).size - O.offsetHeight
883
- ) <= 1;
1058
+ const m = i.current;
1059
+ if (!(m.some(
1060
+ (N) => ge(N) === c.index
1061
+ ) && m.every((N) => {
1062
+ const L = ge(N);
1063
+ if (L === void 0 || L >= s)
1064
+ return !0;
1065
+ const B = v ? N.offsetHeight : N.offsetWidth;
1066
+ return Math.abs(r(L).size - B) <= 1;
884
1067
  })))
885
1068
  c.stableFrames = 0;
886
1069
  else if (++c.stableFrames >= 2) {
887
- a();
1070
+ d();
888
1071
  return;
889
1072
  }
890
1073
  }
891
1074
  }
892
- v();
1075
+ a();
893
1076
  });
894
- return W(() => {
895
- if (!e) return;
896
- const c = (u) => {
897
- switch (u.key) {
1077
+ return _(() => {
1078
+ const c = n ?? t;
1079
+ if (!c) return;
1080
+ const g = (w) => {
1081
+ switch (w.key) {
898
1082
  case "ArrowUp":
899
1083
  case "ArrowDown":
1084
+ case "ArrowLeft":
1085
+ case "ArrowRight":
900
1086
  case "PageUp":
901
1087
  case "PageDown":
902
1088
  case "Home":
903
1089
  case "End":
904
1090
  case " ":
905
- a();
1091
+ d();
906
1092
  }
907
1093
  };
908
- return e.addEventListener("wheel", a, { passive: !0 }), e.addEventListener("touchstart", a, { passive: !0 }), e.addEventListener("pointerdown", a), e.addEventListener("keydown", c), () => {
909
- a(), e.removeEventListener("wheel", a), e.removeEventListener("touchstart", a), e.removeEventListener("pointerdown", a), e.removeEventListener("keydown", c);
1094
+ return c.addEventListener("wheel", d, { passive: !0 }), c.addEventListener("touchstart", d, { passive: !0 }), c.addEventListener("pointerdown", d), c.addEventListener("keydown", g), () => {
1095
+ d(), c.removeEventListener("wheel", d), c.removeEventListener("touchstart", d), c.removeEventListener("pointerdown", d), c.removeEventListener("keydown", g);
910
1096
  };
911
- }, [a, e]), U(
1097
+ }, [d, t, n]), Y(
912
1098
  ({
913
1099
  align: c = "auto",
914
- behavior: u = "auto",
915
- index: p
1100
+ behavior: g = "auto",
1101
+ index: w
916
1102
  }) => {
917
- s && c === "smart" && (c = n({
918
- align: "auto",
919
- containerScrollOffset: e?.scrollTop ?? 0,
920
- index: p
921
- }) === (e?.scrollTop ?? 0) ? "auto" : "center");
922
- const d = n({
923
- align: c,
924
- containerScrollOffset: e?.scrollTop ?? 0,
925
- index: p
926
- });
927
- a(), typeof e?.scrollTo == "function" && (s && (i.current = {
928
- align: c,
929
- index: p,
930
- deadline: performance.now() + 1e3,
931
- stableFrames: 0
932
- }, v()), e.scrollTo({
933
- behavior: s ? "instant" : u,
934
- top: d
935
- }));
1103
+ if (o && c === "smart") {
1104
+ const x = u({ align: "auto", index: w });
1105
+ c = x === void 0 || x.scrollOffset === we(x.scrollTarget, e) ? "auto" : "center";
1106
+ }
1107
+ const b = u({ align: c, index: w });
1108
+ if (d(), b && typeof b.scrollTarget.scrollTo == "function") {
1109
+ const { scrollOffset: x, scrollTarget: m } = b;
1110
+ o && (h.current = {
1111
+ align: c,
1112
+ index: w,
1113
+ deadline: performance.now() + 1e3,
1114
+ stableFrames: 0
1115
+ }, a()), m.scrollTo({
1116
+ behavior: o ? "instant" : g,
1117
+ [v ? "top" : "left"]: x
1118
+ });
1119
+ }
936
1120
  },
937
1121
  [
938
- a,
1122
+ d,
939
1123
  e,
940
- s,
1124
+ o,
941
1125
  v,
942
- n
1126
+ a,
1127
+ u
943
1128
  ]
944
1129
  );
945
1130
  }
946
- const oe = "data-react-window-index", ve = "data-react-window-sizer";
947
- function _e({
1131
+ function Ze({
1132
+ callback: e,
1133
+ element: t,
1134
+ enabled: r = !0
1135
+ }) {
1136
+ const o = ie(e);
1137
+ le(() => {
1138
+ if (!r || !t)
1139
+ return;
1140
+ const s = J(t);
1141
+ let i = s.requestAnimationFrame(() => {
1142
+ i = s.requestAnimationFrame(o);
1143
+ });
1144
+ return () => {
1145
+ s.cancelAnimationFrame(i);
1146
+ };
1147
+ }, [t, r, o]);
1148
+ }
1149
+ function ue(e) {
1150
+ return e != null && typeof e == "object" && "getAverageRowHeight" in e && typeof e.getAverageRowHeight == "function";
1151
+ }
1152
+ const ze = "data-react-window-sizer";
1153
+ function rt({
948
1154
  children: e,
949
1155
  className: t,
950
- defaultHeight: s = 0,
1156
+ defaultHeight: r = 0,
951
1157
  defaultScrollOffset: o = 0,
952
- listRef: r,
953
- onResize: n,
954
- onRowsRendered: i,
955
- overscanCount: l = 3,
956
- rowComponent: a,
957
- rowCount: v,
1158
+ listRef: s,
1159
+ onResize: i,
1160
+ onRowsRendered: n,
1161
+ overscanCount: u = 3,
1162
+ rowComponent: v,
1163
+ rowCount: h,
958
1164
  rowHeight: f,
959
- rowKey: c,
960
- rowProps: u,
961
- tagName: p = "div",
962
- style: d,
963
- ...x
1165
+ rowKey: d,
1166
+ rowProps: a,
1167
+ scrollElement: l,
1168
+ tagName: c = "div",
1169
+ style: g,
1170
+ ...w
964
1171
  }) {
965
- const h = ze(u), O = N(
966
- () => ge(a, ye),
967
- [a]
968
- ), [g, D] = M(null), z = He(f), X = N(() => z ? (k) => f.getRowHeight(k) ?? f.getAverageRowHeight() : f, [z, f]), L = Ie(), [j, I] = M(
1172
+ const b = Ve(a), x = C(
1173
+ () => Te(v, Fe),
1174
+ [v]
1175
+ ), [m, V] = j(null), z = ue(f), N = C(() => z ? (E) => f.getRowHeight(E) ?? f.getAverageRowHeight() : f, [z, f]), L = Ee(), [B, F] = j(
969
1176
  () => L && z
970
- ), te = H(f);
971
- W(() => {
972
- j && te.current !== f && I(!1);
973
- }, [j, f]), $e({
974
- callback: () => I(!1),
975
- element: g,
976
- enabled: j
1177
+ ), G = U(f);
1178
+ _(() => {
1179
+ B && G.current !== f && F(!1);
1180
+ }, [B, f]), Ze({
1181
+ callback: () => F(!1),
1182
+ element: m,
1183
+ enabled: B
977
1184
  });
978
1185
  const {
979
- getCellBounds: A,
980
- getEstimatedSize: q,
981
- scrollToIndex: Q,
982
- startIndexOverscan: m,
983
- startIndexVisible: b,
984
- stopIndexOverscan: w,
985
- stopIndexVisible: y
986
- } = fe({
987
- containerElement: g,
988
- containerStyle: d,
989
- defaultContainerSize: s,
1186
+ getCellBounds: P,
1187
+ getEstimatedSize: Q,
1188
+ scrollTarget: te,
1189
+ getScrollPositionForIndex: R,
1190
+ startIndexOverscan: I,
1191
+ startIndexVisible: H,
1192
+ stopIndexOverscan: O,
1193
+ stopIndexVisible: K
1194
+ } = he({
1195
+ containerElement: m,
1196
+ containerStyle: g,
1197
+ defaultContainerSize: r,
990
1198
  defaultScrollOffset: o,
991
1199
  direction: "vertical",
992
- itemCount: v,
993
- itemProps: h,
994
- itemSize: X,
995
- onResize: n,
996
- overscanCount: l
997
- }), T = H([]), E = je({
998
- element: g,
999
- getCellBounds: A,
1000
- isDynamicRowHeight: z,
1001
- rowCount: v,
1002
- rowElements: T,
1003
- scrollToIndex: Q
1200
+ itemCount: h,
1201
+ itemProps: b,
1202
+ itemSize: N,
1203
+ onResize: i,
1204
+ overscanCount: u,
1205
+ scrollElement: l
1206
+ }), re = U([]), S = ke({
1207
+ direction: "vertical",
1208
+ element: m,
1209
+ getCellBounds: P,
1210
+ isDynamicSize: z,
1211
+ itemCount: h,
1212
+ itemElements: re,
1213
+ scrollTarget: te,
1214
+ getScrollPositionForIndex: R
1004
1215
  });
1005
- xe(
1006
- r,
1216
+ Le(
1217
+ s,
1007
1218
  () => ({
1008
1219
  get element() {
1009
- return g;
1220
+ return m;
1010
1221
  },
1011
- scrollToRow: E
1222
+ scrollToRow: S
1012
1223
  }),
1013
- [g, E]
1014
- ), W(() => {
1015
- if (!g)
1224
+ [m, S]
1225
+ ), _(() => {
1226
+ if (!m)
1016
1227
  return;
1017
- const k = Array.from(g.children).slice(
1228
+ const E = Array.from(m.children).slice(
1018
1229
  0,
1019
- m < 0 ? 0 : w - m + 1
1020
- ).filter((R, P) => {
1021
- if (R.hasAttribute(ve))
1230
+ I < 0 ? 0 : O - I + 1
1231
+ ).filter((W, T) => {
1232
+ if (W.hasAttribute(ze))
1022
1233
  return !1;
1023
- const F = `${m + P}`;
1024
- return R.setAttribute(oe, F), !0;
1234
+ const y = `${I + T}`;
1235
+ return W.setAttribute(He, y), !0;
1025
1236
  });
1026
- if (T.current = k, z)
1027
- return f.observeRowElements(k);
1237
+ if (re.current = E, z)
1238
+ return f.observeRowElements(E);
1028
1239
  }, [
1029
- O,
1030
- g,
1240
+ x,
1241
+ m,
1031
1242
  z,
1032
- v,
1033
- f,
1034
- c,
1035
1243
  h,
1036
- m,
1037
- w
1038
- ]), ie(() => {
1039
- m >= 0 && w >= 0 && i && i(
1244
+ f,
1245
+ d,
1246
+ b,
1247
+ I,
1248
+ O
1249
+ ]), le(() => {
1250
+ I >= 0 && O >= 0 && n && n(
1040
1251
  {
1041
- startIndex: b,
1042
- stopIndex: y
1252
+ startIndex: H,
1253
+ stopIndex: K
1043
1254
  },
1044
1255
  {
1045
- startIndex: m,
1046
- stopIndex: w
1256
+ startIndex: I,
1257
+ stopIndex: O
1047
1258
  }
1048
1259
  );
1049
1260
  }, [
1050
- i,
1051
- m,
1052
- b,
1053
- w,
1054
- y
1261
+ n,
1262
+ I,
1263
+ H,
1264
+ O,
1265
+ K
1055
1266
  ]);
1056
- const V = j && z && m === 0, Z = N(() => {
1057
- const k = [];
1058
- if (v > 0)
1059
- for (let R = m; R <= w; R++) {
1060
- const P = A(R);
1061
- k.push(
1062
- /* @__PURE__ */ le(
1063
- O,
1267
+ const p = B && z && I === 0, M = C(() => {
1268
+ const E = [];
1269
+ if (h > 0)
1270
+ for (let W = I; W <= O; W++) {
1271
+ const T = P(W);
1272
+ E.push(
1273
+ /* @__PURE__ */ ve(
1274
+ x,
1064
1275
  {
1065
- ...h,
1276
+ ...b,
1066
1277
  ariaAttributes: {
1067
- "aria-posinset": R + 1,
1068
- "aria-setsize": v,
1278
+ "aria-posinset": W + 1,
1279
+ "aria-setsize": h,
1069
1280
  role: "listitem"
1070
1281
  },
1071
- key: c ? c(R, h) : R,
1072
- index: R,
1073
- style: V ? { width: "100%" } : {
1282
+ key: d ? d(W, b) : W,
1283
+ index: W,
1284
+ style: p ? { width: "100%" } : {
1074
1285
  position: "absolute",
1075
1286
  left: 0,
1076
- transform: `translateY(${P.scrollOffset}px)`,
1287
+ transform: `translateY(${T.scrollOffset}px)`,
1077
1288
  // In case of dynamic row heights, don't specify a height style
1078
1289
  // otherwise a default/estimated height would mask the actual height
1079
- height: z ? void 0 : P.size,
1290
+ height: z ? void 0 : T.size,
1080
1291
  width: "100%"
1081
1292
  }
1082
1293
  }
1083
1294
  )
1084
1295
  );
1085
1296
  }
1086
- return k;
1297
+ return E;
1087
1298
  }, [
1088
- O,
1089
- A,
1299
+ x,
1300
+ P,
1090
1301
  z,
1091
- V,
1092
- v,
1093
- c,
1302
+ p,
1094
1303
  h,
1095
- m,
1096
- w
1097
- ]), ne = /* @__PURE__ */ re(
1304
+ d,
1305
+ b,
1306
+ I,
1307
+ O
1308
+ ]), k = /* @__PURE__ */ de(
1098
1309
  "div",
1099
1310
  {
1100
1311
  "aria-hidden": !0,
1101
- [ve]: "",
1312
+ [ze]: "",
1102
1313
  style: {
1103
1314
  // Rows rendered in flow layout already take up space
1104
- position: V ? "absolute" : void 0,
1105
- top: V ? 0 : void 0,
1106
- height: q(),
1315
+ position: p ? "absolute" : void 0,
1316
+ top: p ? 0 : void 0,
1317
+ height: Q(),
1107
1318
  width: "100%",
1108
1319
  zIndex: -1
1109
1320
  }
1110
1321
  },
1111
1322
  "sizer"
1112
- ), K = /* @__PURE__ */ re(ue, { children: e }, "children"), G = /* @__PURE__ */ re(ue, { children: Z }, "rows");
1113
- return le(
1114
- p,
1323
+ ), A = /* @__PURE__ */ de(be, { children: e }, "children"), D = /* @__PURE__ */ de(be, { children: M }, "rows");
1324
+ return ve(
1325
+ c,
1115
1326
  {
1116
1327
  role: "list",
1117
- ...x,
1328
+ ...w,
1118
1329
  className: t,
1119
- ref: D,
1330
+ ref: V,
1120
1331
  style: {
1121
1332
  position: "relative",
1122
- maxHeight: "100%",
1123
1333
  flexGrow: 1,
1124
- overflowY: "auto",
1125
- ...d
1334
+ // Lists that scroll with an outer element render at their full height (and must not clip sticky rows)
1335
+ ...l === void 0 && {
1336
+ maxHeight: "100%",
1337
+ overflowY: "auto"
1338
+ },
1339
+ ...g
1126
1340
  }
1127
1341
  },
1128
- ...V ? [K, G] : [G, K],
1129
- ne
1342
+ ...p ? [A, D] : [D, A],
1343
+ k
1130
1344
  );
1131
1345
  }
1132
- function pe(e) {
1346
+ function ye(e) {
1133
1347
  const t = /* @__PURE__ */ new Map();
1134
- return e !== void 0 && e.forEach((s, o) => {
1135
- Number.isFinite(s) && s > 0 && t.set(o, s);
1348
+ return e !== void 0 && e.forEach((r, o) => {
1349
+ Number.isFinite(r) && r > 0 && t.set(o, r);
1136
1350
  }), t;
1137
1351
  }
1138
- function Ye({
1352
+ function ot({
1139
1353
  defaultRowHeight: e,
1140
1354
  initialRowHeights: t,
1141
- key: s
1355
+ key: r
1142
1356
  }) {
1143
- const [o, r] = M(() => ({
1144
- key: s,
1145
- map: pe(t)
1357
+ const [o, s] = j(() => ({
1358
+ key: r,
1359
+ map: ye(t)
1146
1360
  }));
1147
- o.key !== s && r({
1148
- key: s,
1149
- map: pe(t)
1361
+ o.key !== r && s({
1362
+ key: r,
1363
+ map: ye(t)
1150
1364
  });
1151
- const { map: n } = o, i = U(() => {
1152
- let u = 0;
1153
- return n.forEach((p) => {
1154
- u += p;
1155
- }), u === 0 ? e : u / n.size;
1156
- }, [e, n]), l = U(
1157
- (u) => {
1158
- const p = n.get(u);
1159
- return p !== void 0 ? p : e;
1365
+ const { map: i } = o, n = Y(() => {
1366
+ let a = 0;
1367
+ return i.forEach((l) => {
1368
+ a += l;
1369
+ }), a === 0 ? e : a / i.size;
1370
+ }, [e, i]), u = Y(
1371
+ (a) => {
1372
+ const l = i.get(a);
1373
+ return l !== void 0 ? l : e;
1160
1374
  },
1161
- [e, n]
1162
- ), a = U((u, p) => {
1163
- r((d) => {
1164
- if (d.map.get(u) === p)
1165
- return d;
1166
- const x = new Map(d.map);
1167
- return x.set(u, p), {
1168
- ...d,
1169
- map: x
1375
+ [e, i]
1376
+ ), v = Y((a, l) => {
1377
+ s((c) => {
1378
+ if (c.map.get(a) === l)
1379
+ return c;
1380
+ const g = new Map(c.map);
1381
+ return g.set(a, l), {
1382
+ ...c,
1383
+ map: g
1170
1384
  };
1171
1385
  });
1172
- }, []), v = ee(
1173
- (u) => {
1174
- u.length !== 0 && u.forEach((p) => {
1175
- const { borderBoxSize: d, target: x } = p, h = x.getAttribute(oe);
1176
- $(
1177
- h !== null,
1178
- `Invalid ${oe} attribute value`
1179
- );
1180
- const O = parseInt(h), { blockSize: g } = d[0];
1181
- g && a(O, g);
1386
+ }, []), h = ie(
1387
+ (a) => {
1388
+ a.length !== 0 && a.forEach((l) => {
1389
+ const { borderBoxSize: c, target: g } = l, w = ge(g);
1390
+ if (w === void 0)
1391
+ return;
1392
+ const { blockSize: b } = c[0];
1393
+ b && v(w, b);
1182
1394
  });
1183
1395
  }
1184
- ), f = H(null);
1185
- ie(
1396
+ ), f = U(null);
1397
+ le(
1186
1398
  () => () => {
1187
1399
  f.current?.resizeObserver.disconnect(), f.current = null;
1188
1400
  },
1189
1401
  []
1190
1402
  );
1191
- const c = U(
1192
- (u) => {
1193
- const p = [];
1194
- return u.forEach((d) => {
1195
- const x = ae(d);
1196
- if (f.current?.view !== x) {
1403
+ const d = Y(
1404
+ (a) => {
1405
+ const l = [];
1406
+ return a.forEach((c) => {
1407
+ const g = J(c);
1408
+ if (f.current?.view !== g) {
1197
1409
  f.current?.resizeObserver.disconnect();
1198
- const O = Oe(d);
1199
- f.current = O ? {
1200
- resizeObserver: new O(v),
1201
- view: x
1410
+ const b = pe(c);
1411
+ f.current = b ? {
1412
+ resizeObserver: new b(h),
1413
+ view: g
1202
1414
  } : null;
1203
1415
  }
1204
- const h = f.current?.resizeObserver;
1205
- h && (h.observe(d), p.push([d, h]));
1416
+ const w = f.current?.resizeObserver;
1417
+ w && (w.observe(c), l.push([c, w]));
1206
1418
  }), () => {
1207
- p.forEach(
1208
- ([d, x]) => x.unobserve(d)
1419
+ l.forEach(
1420
+ ([c, g]) => g.unobserve(c)
1209
1421
  );
1210
1422
  };
1211
1423
  },
1212
- [v]
1424
+ [h]
1425
+ );
1426
+ return C(
1427
+ () => ({
1428
+ getAverageRowHeight: n,
1429
+ getRowHeight: u,
1430
+ setRowHeight: v,
1431
+ observeRowElements: d
1432
+ }),
1433
+ [n, u, v, d]
1213
1434
  );
1214
- return N(
1435
+ }
1436
+ const nt = j, it = U, Je = {};
1437
+ function lt({
1438
+ count: e,
1439
+ defaultScrollOffset: t = 0,
1440
+ defaultSize: r = 0,
1441
+ dir: o,
1442
+ direction: s = "vertical",
1443
+ element: i,
1444
+ itemSize: n,
1445
+ onItemsRendered: u,
1446
+ overscanCount: v = 3,
1447
+ scrollElement: h
1448
+ }) {
1449
+ const f = ue(n);
1450
+ Z(
1451
+ !f || s === "vertical",
1452
+ "Dynamic item sizes are only supported for vertical content"
1453
+ );
1454
+ const d = C(() => ue(n) ? (R) => n.getRowHeight(R) ?? n.getAverageRowHeight() : n, [n]), a = Ae(i, o), {
1455
+ getCellBounds: l,
1456
+ getEstimatedSize: c,
1457
+ scrollTarget: g,
1458
+ getScrollPositionForIndex: w,
1459
+ startIndexOverscan: b,
1460
+ startIndexVisible: x,
1461
+ stopIndexOverscan: m,
1462
+ stopIndexVisible: V
1463
+ } = he({
1464
+ containerElement: i,
1465
+ defaultContainerSize: r,
1466
+ defaultScrollOffset: t,
1467
+ direction: s,
1468
+ isRtl: s === "horizontal" && a,
1469
+ itemCount: e,
1470
+ itemProps: Je,
1471
+ itemSize: d,
1472
+ onResize: void 0,
1473
+ overscanCount: v,
1474
+ scrollElement: h
1475
+ }), z = U(/* @__PURE__ */ new Set()), N = U(/* @__PURE__ */ new WeakSet()), L = U([]), B = U({ dynamicRowHeight: null, unobserve: /* @__PURE__ */ new Map() }), F = Y((R) => {
1476
+ R !== null && z.current.add(R);
1477
+ }, []), G = i;
1478
+ _(() => {
1479
+ const R = z.current, I = B.current, H = ue(n) ? n : null;
1480
+ I.dynamicRowHeight?.observeRowElements !== H?.observeRowElements && (I.unobserve.forEach((O) => O()), I.unobserve.clear()), I.dynamicRowHeight = H, R.forEach((O) => {
1481
+ if (!O.isConnected)
1482
+ R.delete(O), I.unobserve.get(O)?.(), I.unobserve.delete(O);
1483
+ else if (H && // Like List, measure items once the element has mounted
1484
+ // (e.g. so the dynamic row height cache has finished mounting too)
1485
+ G !== null && !I.unobserve.has(O)) {
1486
+ if (ge(O) === void 0) {
1487
+ N.current.has(O) || (N.current.add(O), console.warn(
1488
+ "useVirtualizer: Items passed to measureElement must specify their index with a data-index attribute",
1489
+ O
1490
+ ));
1491
+ return;
1492
+ }
1493
+ I.unobserve.set(
1494
+ O,
1495
+ H.observeRowElements([O])
1496
+ );
1497
+ }
1498
+ }), L.current = Array.from(R);
1499
+ }), le(() => {
1500
+ const R = B.current;
1501
+ return () => {
1502
+ R.unobserve.forEach((I) => I()), R.unobserve.clear(), R.dynamicRowHeight = null;
1503
+ };
1504
+ }, []);
1505
+ const P = ke({
1506
+ direction: s,
1507
+ element: i,
1508
+ getCellBounds: l,
1509
+ isDynamicSize: f,
1510
+ itemCount: e,
1511
+ itemElements: L,
1512
+ scrollTarget: g,
1513
+ getScrollPositionForIndex: w
1514
+ });
1515
+ le(() => {
1516
+ b >= 0 && m >= 0 && u && u(
1517
+ { startIndex: x, stopIndex: V },
1518
+ { startIndex: b, stopIndex: m }
1519
+ );
1520
+ }, [
1521
+ u,
1522
+ b,
1523
+ x,
1524
+ m,
1525
+ V
1526
+ ]);
1527
+ const Q = C(() => {
1528
+ const R = [];
1529
+ if (e > 0)
1530
+ for (let I = b; I <= m; I++) {
1531
+ const { scrollOffset: H, size: O } = l(I);
1532
+ R.push({ index: I, offset: H, size: O });
1533
+ }
1534
+ return R;
1535
+ }, [e, l, b, m]), te = c();
1536
+ return C(
1215
1537
  () => ({
1216
- getAverageRowHeight: i,
1217
- getRowHeight: l,
1218
- setRowHeight: a,
1219
- observeRowElements: c
1538
+ items: Q,
1539
+ measureElement: F,
1540
+ scrollToIndex: P,
1541
+ totalSize: te,
1542
+ visibleRange: {
1543
+ startIndex: x,
1544
+ stopIndex: V
1545
+ }
1220
1546
  }),
1221
- [i, l, a, c]
1547
+ [
1548
+ Q,
1549
+ F,
1550
+ P,
1551
+ x,
1552
+ V,
1553
+ te
1554
+ ]
1222
1555
  );
1223
1556
  }
1224
- const De = M, Xe = H, be = /* @__PURE__ */ new WeakMap();
1225
- function Ze(e = !1, t = typeof document < "u" ? document : void 0) {
1557
+ function ct(e, {
1558
+ delay: t = 150
1559
+ } = {}) {
1560
+ const [r, o] = j(!1);
1561
+ return _(() => {
1562
+ if (!e)
1563
+ return;
1564
+ const s = e === "window" ? window : J(e), i = e === "window" ? s : e, n = "onscrollend" in s;
1565
+ let u, v = 0;
1566
+ const h = () => {
1567
+ performance.now() - v >= t ? (u = void 0, o(!1)) : u = s.requestAnimationFrame(h);
1568
+ }, f = () => {
1569
+ o(!0), n || (v = performance.now(), u === void 0 && (u = s.requestAnimationFrame(h)));
1570
+ }, d = () => {
1571
+ o(!1);
1572
+ };
1573
+ return i.addEventListener("scroll", f, { passive: !0 }), n && i.addEventListener("scrollend", d), () => {
1574
+ i.removeEventListener("scroll", f), i.removeEventListener("scrollend", d), u !== void 0 && s.cancelAnimationFrame(u), o(!1);
1575
+ };
1576
+ }, [t, e]), r;
1577
+ }
1578
+ const Re = /* @__PURE__ */ new WeakMap();
1579
+ function at(e = !1, t = typeof document < "u" ? document : void 0) {
1226
1580
  if (t === void 0)
1227
1581
  return 0;
1228
- let s = be.get(t);
1229
- if (s === void 0 || e) {
1230
- const o = t.createElement("div"), r = o.style;
1231
- r.width = "50px", r.height = "50px", r.overflow = "scroll", t.body.appendChild(o), s = o.offsetWidth - o.clientWidth, t.body.removeChild(o), be.set(t, s);
1582
+ let r = Re.get(t);
1583
+ if (r === void 0 || e) {
1584
+ const o = t.createElement("div"), s = o.style;
1585
+ s.width = "50px", s.height = "50px", s.overflow = "scroll", t.body.appendChild(o), r = o.offsetWidth - o.clientWidth, t.body.removeChild(o), Re.set(t, r);
1232
1586
  }
1233
- return s;
1587
+ return r;
1234
1588
  }
1235
1589
  export {
1236
- Ne as Grid,
1237
- _e as List,
1238
- Ze as getScrollbarSize,
1239
- Ye as useDynamicRowHeight,
1240
- qe as useGridCallbackRef,
1241
- Ge as useGridRef,
1242
- De as useListCallbackRef,
1243
- Xe as useListRef
1590
+ et as Grid,
1591
+ rt as List,
1592
+ at as getScrollbarSize,
1593
+ ot as useDynamicRowHeight,
1594
+ tt as useGridCallbackRef,
1595
+ st as useGridRef,
1596
+ ct as useIsScrolling,
1597
+ nt as useListCallbackRef,
1598
+ it as useListRef,
1599
+ lt as useVirtualizer
1244
1600
  };
1245
1601
  //# sourceMappingURL=react-window.js.map