react-window 2.4.0 → 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 ne, useState as M, useSyncExternalStore as Re, useMemo as q, useRef as H, useCallback as U, memo as be, useImperativeHandle as xe, createElement as le, Fragment as ue } from "react";
4
- const W = typeof window < "u" ? Te : ne;
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,170 +46,256 @@ 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,
54
+ element: s,
55
55
  mode: i,
56
56
  style: n
57
57
  }) {
58
- const { styleHeight: l, styleWidth: a } = q(
58
+ const { styleHeight: u, styleWidth: v } = C(
59
59
  () => ({
60
- styleHeight: de(n?.height),
61
- styleWidth: de(n?.width)
60
+ styleHeight: xe(n?.height),
61
+ styleWidth: xe(n?.width)
62
62
  }),
63
63
  [n?.height, n?.width]
64
- ), [v, f] = M({
64
+ ), [h, f] = j({
65
65
  height: t,
66
- width: s
67
- }), c = o || i === "only-height" && l !== void 0 || i === "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((b) => b.height === h.height && b.width === h.width ? b : {
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]), q(
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";
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
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 ? s = "positive-descending" : (o.scrollLeft = 1, o.scrollLeft === 0 ? s = "negative" : s = "positive-ascending"), t.body.removeChild(o), he.set(t, s);
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: i } = e;
126
- return i - 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 ze({
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,
171
- containerScrollOffset: i,
172
- containerSize: n
263
+ clamp: r = !0,
264
+ index: o,
265
+ itemCount: s,
266
+ itemSize: i,
267
+ containerScrollOffset: n,
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 = ze({
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 - n, l.scrollOffset)
185
- ), f = Math.max(
186
- 0,
187
- l.scrollOffset - n + l.size
188
- ), c = l.size > n ? i >= l.scrollOffset && i <= f : i >= f && i <= 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 - n,
199
- l.scrollOffset + l.size / 2 - n / 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 ? i : i < 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
300
  const i = o - 1;
215
301
  if (o === 0)
@@ -219,1030 +305,1297 @@ function ce({
219
305
  startIndexOverscan: 0,
220
306
  stopIndexOverscan: -1
221
307
  };
222
- let n, l;
223
- const { itemSize: a } = e;
224
- if (a !== void 0 && a > 0)
225
- n = 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(i, Math.floor(t / a))
228
- ), l = Math.max(
313
+ Math.min(i, Math.floor(t / v))
314
+ ), u = Math.max(
229
315
  n,
230
316
  Math.min(
231
317
  i,
232
- Math.ceil((t + s) / a) - 1
318
+ Math.ceil((t + r) / v) - 1
233
319
  )
234
- );
320
+ )) : (n = 0, u = 0);
235
321
  else {
236
- let v = 0, f = Math.min(i, 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 < i; ) {
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 (n = v, l = v; l < i; ) {
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
340
  startIndexVisible: n,
255
- stopIndexVisible: l,
256
- startIndexOverscan: Math.max(0, n - r),
257
- stopIndexOverscan: Math.min(i, l + r)
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
- $(r >= 0, `Invalid index ${r}`);
271
- let n = o.get(r);
272
- return n === void 0 && (n = { size: s, scrollOffset: r * s }, o.set(r, n)), n;
273
- }
274
- for (; o.size - 1 < r; ) {
275
- const n = o.size, l = s(n, t);
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);
276
359
  if (n === 0)
277
360
  o.set(n, {
278
- size: l,
361
+ size: u,
279
362
  scrollOffset: 0
280
363
  });
281
364
  else {
282
- const a = o.get(n - 1);
283
- $(
284
- a !== void 0,
285
- `Unexpected bounds cache miss for index ${r}`
365
+ const v = o.get(n - 1);
366
+ Z(
367
+ v !== void 0,
368
+ `Unexpected bounds cache miss for index ${s}`
286
369
  ), o.set(n, {
287
- scrollOffset: a.scrollOffset + a.size,
288
- size: l
370
+ scrollOffset: v.scrollOffset + v.size,
371
+ size: u
289
372
  });
290
373
  }
291
374
  }
292
- const i = o.get(r);
293
- return $(
375
+ const i = o.get(s);
376
+ return Z(
294
377
  i !== void 0,
295
- `Unexpected bounds cache miss for index ${r}`
378
+ `Unexpected bounds cache miss for index ${s}`
296
379
  ), i;
297
380
  },
298
- set(r, i) {
299
- o.set(r, i);
381
+ set(s, i) {
382
+ o.set(s, i);
300
383
  },
301
384
  get size() {
302
385
  return o.size;
303
386
  }
304
387
  };
305
388
  }
306
- function Fe({
389
+ function Ge({
307
390
  itemCount: e,
308
391
  itemProps: t,
309
- itemSize: s
392
+ itemSize: r
310
393
  }) {
311
- return q(
312
- () => ke({
394
+ return C(
395
+ () => Ce({
313
396
  itemCount: e,
314
397
  itemProps: t,
315
- itemSize: s
398
+ itemSize: r
316
399
  }),
317
- [e, t, s]
400
+ [e, t, r]
318
401
  );
319
402
  }
320
- function We({
403
+ function Xe({
321
404
  containerSize: e,
322
405
  itemSize: t
323
406
  }) {
324
- let s;
407
+ let r;
325
408
  switch (typeof t) {
326
409
  case "string": {
327
- $(
410
+ Z(
328
411
  t.endsWith("%"),
329
412
  `Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`
330
- ), $(
413
+ ), Z(
331
414
  e !== void 0,
332
415
  "Container size must be defined if a percentage item size is specified"
333
- ), s = e * parseFloat(t) / 100;
416
+ ), r = e * parseFloat(t) / 100;
334
417
  break;
335
418
  }
336
419
  default: {
337
- s = t;
420
+ r = t;
338
421
  break;
339
422
  }
340
423
  }
341
- return s;
424
+ return typeof r == "number" && !(Number.isFinite(r) && r > 0) && (r = 0), r;
342
425
  }
343
- function fe({
426
+ function he({
344
427
  containerElement: e,
345
428
  containerStyle: t,
346
- defaultContainerSize: s = 0,
429
+ defaultContainerSize: r = 0,
347
430
  defaultScrollOffset: o = 0,
348
- direction: r,
431
+ direction: s,
349
432
  isRtl: i = !1,
350
433
  itemCount: n,
351
- itemProps: l,
352
- itemSize: a,
353
- onResize: v,
354
- overscanCount: f
434
+ itemProps: u,
435
+ itemSize: v,
436
+ onResize: h,
437
+ overscanCount: f,
438
+ scrollElement: d
355
439
  }) {
356
- const { height: c = s, width: u = s } = Le({
357
- defaultHeight: r === "vertical" ? s : void 0,
358
- 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,
359
443
  element: e,
360
- mode: r === "vertical" ? "only-height" : "only-width",
444
+ mode: s === "vertical" ? "only-height" : "only-width",
361
445
  style: t
362
- }), p = H({
446
+ }), w = U({
363
447
  height: 0,
364
448
  width: 0
365
- }), d = r === "vertical" ? c : u, x = We({ containerSize: d, itemSize: a });
366
- W(() => {
367
- if (typeof v == "function") {
368
- const g = p.current;
369
- (g.height !== c || g.width !== u) && (v({ height: c, width: u }, { ...g }), g.height = c, g.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);
370
454
  }
371
- }, [c, v, u]);
372
- const h = Fe({
455
+ }, [c, h, g]);
456
+ const z = Ge({
373
457
  itemCount: n,
374
- itemProps: l,
375
- itemSize: x
376
- }), O = Ie(), [b] = M(
377
- () => O ? 0 : o
378
- ), D = U(
379
- (g) => h.get(g),
380
- [h]
381
- ), [m, X] = M(
382
- () => ce({
383
- cachedBounds: h,
384
- containerScrollOffset: b,
385
- containerSize: d,
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,
386
470
  itemCount: n,
387
471
  overscanCount: f
388
472
  })
389
473
  ), {
390
- startIndexVisible: L,
391
- startIndexOverscan: j,
392
- stopIndexVisible: I,
393
- stopIndexOverscan: te
474
+ startIndexVisible: P,
475
+ startIndexOverscan: Q,
476
+ stopIndexVisible: te,
477
+ stopIndexOverscan: R
394
478
  } = {
395
- startIndexVisible: Math.min(n - 1, m.startIndexVisible),
396
- startIndexOverscan: Math.min(n - 1, m.startIndexOverscan),
397
- stopIndexVisible: Math.min(n - 1, m.stopIndexVisible),
398
- stopIndexOverscan: Math.min(n - 1, m.stopIndexOverscan)
399
- }, A = U(
400
- () => ze({
401
- cachedBounds: h,
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,
402
486
  itemCount: n,
403
- itemSize: x
487
+ itemSize: V
404
488
  }),
405
- [h, n, x]
406
- ), G = U(
407
- (g) => {
408
- const w = C({
489
+ [z, n, V]
490
+ ), H = Y(
491
+ (S) => {
492
+ const p = ne({
409
493
  containerElement: e,
410
- direction: r,
494
+ direction: s,
411
495
  isRtl: i,
412
- scrollOffset: g
496
+ scrollOffset: S
413
497
  });
414
- return ce({
415
- cachedBounds: h,
416
- containerScrollOffset: w,
417
- containerSize: d,
498
+ return fe({
499
+ cachedBounds: z,
500
+ containerScrollOffset: p,
501
+ containerSize: m,
418
502
  itemCount: n,
419
503
  overscanCount: f
420
504
  });
421
505
  },
422
506
  [
423
- h,
507
+ z,
424
508
  e,
425
- d,
426
- r,
509
+ m,
510
+ s,
427
511
  i,
428
512
  n,
429
513
  f
430
514
  ]
431
- ), Q = H(!1);
432
- W(() => {
433
- if (!e || n === 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))
434
518
  return;
435
- const g = r === "horizontal" && we(e);
436
- if (C({
519
+ const S = s === "horizontal" && Me(e);
520
+ if (ne({
437
521
  containerElement: e,
438
- direction: r,
439
- isRtl: g,
440
- scrollOffset: r === "vertical" ? e.scrollTop : e.scrollLeft
522
+ direction: s,
523
+ isRtl: S,
524
+ scrollOffset: s === "vertical" ? e.scrollTop : e.scrollLeft
441
525
  }) !== 0)
442
526
  return;
443
- const y = C({
527
+ const M = ne({
444
528
  containerElement: e,
445
- direction: r,
446
- isRtl: g,
529
+ direction: s,
530
+ isRtl: S,
447
531
  scrollOffset: o
448
532
  });
449
533
  typeof e.scrollTo == "function" ? e.scrollTo({
450
534
  behavior: "instant",
451
- [r === "vertical" ? "top" : "left"]: y
452
- }) : r === "vertical" ? e.scrollTop = y : e.scrollLeft = y;
453
- }, [e, n]), W(() => {
454
- const g = e ? G(
455
- r === "vertical" ? e.scrollTop : e.scrollLeft
456
- ) : ce({
457
- cachedBounds: h,
458
- containerScrollOffset: b,
459
- containerSize: d,
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,
460
546
  itemCount: n,
461
547
  overscanCount: f
462
548
  });
463
- X((w) => J(g, w) ? w : g);
549
+ G((p) => se(S, p) ? p : S);
464
550
  }, [
465
- h,
551
+ z,
466
552
  e,
467
- d,
468
- r,
469
- G,
470
- b,
553
+ m,
554
+ s,
555
+ H,
556
+ L,
557
+ a,
471
558
  n,
472
- f
473
- ]), W(() => {
474
- if (!e)
559
+ f,
560
+ l
561
+ ]), _(() => {
562
+ if (!e || a)
475
563
  return;
476
- const g = () => {
477
- X((w) => {
478
- const { scrollLeft: y, scrollTop: T } = e, E = C({
564
+ const S = () => {
565
+ G((p) => {
566
+ const { scrollLeft: M, scrollTop: k } = e, A = ne({
479
567
  containerElement: e,
480
- direction: r,
568
+ direction: s,
481
569
  isRtl: i,
482
- scrollOffset: r === "vertical" ? T : y
483
- }), V = ce({
484
- cachedBounds: h,
485
- containerScrollOffset: E,
486
- containerSize: d,
570
+ scrollOffset: s === "vertical" ? k : M
571
+ }), D = fe({
572
+ cachedBounds: z,
573
+ containerScrollOffset: A,
574
+ containerSize: m,
487
575
  itemCount: n,
488
576
  overscanCount: f
489
577
  });
490
- return J(V, w) ? w : V;
578
+ return se(D, p) ? p : D;
491
579
  });
492
580
  };
493
- return e.addEventListener("scroll", g), () => {
494
- e.removeEventListener("scroll", g);
581
+ return e.addEventListener("scroll", S), () => {
582
+ e.removeEventListener("scroll", S);
495
583
  };
496
584
  }, [
497
- h,
585
+ z,
498
586
  e,
499
- d,
500
- r,
587
+ m,
588
+ s,
501
589
  i,
590
+ a,
502
591
  n,
503
592
  f
504
593
  ]);
505
- const z = 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(
506
638
  ({
507
- align: g = "auto",
508
- containerScrollOffset: w,
509
- index: y
639
+ align: S = "auto",
640
+ index: p
510
641
  }) => {
511
- let T = Ve({
512
- align: g,
513
- cachedBounds: h,
514
- 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({
676
+ containerElement: e,
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({
515
700
  containerElement: e,
516
- direction: r,
701
+ direction: s,
517
702
  isRtl: i,
518
- scrollOffset: w
703
+ scrollOffset: k
519
704
  }),
520
- containerSize: d,
521
- index: y,
522
- itemCount: n,
523
- 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 }
524
712
  });
525
- if (e) {
526
- if (T = C({
713
+ if (e && (!a || l)) {
714
+ if (D = ne({
527
715
  containerElement: e,
528
- direction: r,
716
+ direction: s,
529
717
  isRtl: i,
530
- scrollOffset: T
531
- }), typeof e.scrollTo != "function") {
532
- const E = G(T);
533
- J(m, E) || X(E);
718
+ scrollOffset: D
719
+ }), !a && typeof e.scrollTo != "function") {
720
+ const E = H(D);
721
+ se(F, E) || G(E);
534
722
  }
535
- return T;
723
+ return { scrollOffset: D, scrollTarget: e };
536
724
  }
537
725
  }
538
726
  );
539
727
  return {
540
- getCellBounds: D,
541
- getEstimatedSize: A,
542
- scrollToIndex: z,
543
- startIndexOverscan: j,
544
- startIndexVisible: L,
545
- stopIndexOverscan: te,
546
- 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
547
736
  };
548
737
  }
549
- function me(e) {
550
- const [t, s] = M(e);
551
- 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);
552
741
  }
553
- function ye(e, t) {
742
+ function Fe(e, t) {
554
743
  const {
555
- ariaAttributes: s,
744
+ ariaAttributes: r,
556
745
  style: o,
557
- ...r
746
+ ...s
558
747
  } = e, {
559
748
  ariaAttributes: i,
560
749
  style: n,
561
- ...l
750
+ ...u
562
751
  } = t;
563
- return J(s, i) && J(o, n) && J(r, l);
752
+ return se(r, i) && se(o, n) && se(s, u);
564
753
  }
565
- function qe({
754
+ function et({
566
755
  cellComponent: e,
567
756
  cellProps: t,
568
- children: s,
757
+ children: r,
569
758
  className: o,
570
- columnCount: r,
759
+ columnCount: s,
571
760
  columnKey: i,
572
761
  columnWidth: n,
573
- defaultHeight: l = 0,
574
- defaultScrollLeft: a = 0,
575
- defaultScrollTop: v = 0,
762
+ defaultHeight: u = 0,
763
+ defaultScrollLeft: v = 0,
764
+ defaultScrollTop: h = 0,
576
765
  defaultWidth: f = 0,
577
- dir: c,
578
- gridRef: u,
579
- onCellsRendered: p,
580
- onResize: d,
581
- overscanCount: x = 3,
582
- rowCount: h,
583
- rowHeight: O,
584
- rowKey: b,
585
- style: D,
586
- tagName: m = "div",
587
- ...X
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,
776
+ tagName: z = "div",
777
+ ...N
588
778
  }) {
589
- const L = me(t), j = q(
590
- () => be(e, ye),
779
+ const L = Ve(t), B = C(
780
+ () => Te(e, Fe),
591
781
  [e]
592
- ), [I, te] = M(null), A = Ae(I, c), {
593
- getCellBounds: G,
594
- getEstimatedSize: Q,
595
- startIndexOverscan: z,
596
- startIndexVisible: g,
597
- scrollToIndex: w,
598
- stopIndexOverscan: y,
599
- stopIndexVisible: T
600
- } = fe({
601
- containerElement: I,
602
- 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,
603
793
  defaultContainerSize: f,
604
- defaultScrollOffset: a,
794
+ defaultScrollOffset: v,
605
795
  direction: "horizontal",
606
- isRtl: A,
607
- itemCount: r,
796
+ isRtl: P,
797
+ itemCount: s,
608
798
  itemProps: L,
609
799
  itemSize: n,
610
- onResize: d,
611
- overscanCount: x
800
+ onResize: c,
801
+ overscanCount: g,
802
+ scrollElement: m
612
803
  }), {
613
- getCellBounds: E,
614
- getEstimatedSize: V,
615
- startIndexOverscan: Z,
616
- startIndexVisible: ie,
617
- scrollToIndex: K,
618
- stopIndexOverscan: N,
619
- stopIndexVisible: k
620
- } = fe({
621
- containerElement: I,
622
- containerStyle: D,
623
- defaultContainerSize: l,
624
- 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,
625
816
  direction: "vertical",
626
- itemCount: h,
817
+ itemCount: w,
627
818
  itemProps: L,
628
- itemSize: O,
629
- onResize: d,
630
- overscanCount: x
819
+ itemSize: b,
820
+ onResize: c,
821
+ overscanCount: g,
822
+ scrollElement: m
631
823
  });
632
- xe(
633
- u,
824
+ Le(
825
+ a,
634
826
  () => ({
635
827
  get element() {
636
- return I;
828
+ return F;
637
829
  },
638
830
  scrollToCell({
639
- behavior: F = "auto",
640
- columnAlign: S = "auto",
641
- columnIndex: _,
642
- rowAlign: Y = "auto",
643
- rowIndex: B
831
+ behavior: T = "auto",
832
+ columnAlign: y = "auto",
833
+ columnIndex: $,
834
+ rowAlign: q = "auto",
835
+ rowIndex: ee
644
836
  }) {
645
- const se = w({
646
- align: S,
647
- containerScrollOffset: I?.scrollLeft ?? 0,
648
- index: _
649
- }), Se = K({
650
- align: Y,
651
- containerScrollOffset: I?.scrollTop ?? 0,
652
- index: B
653
- });
654
- typeof I?.scrollTo == "function" && I.scrollTo({
655
- behavior: F,
656
- left: se,
657
- top: Se
837
+ const X = H({
838
+ align: y,
839
+ index: $
840
+ }), oe = k({
841
+ align: q,
842
+ index: ee
658
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
+ }));
659
855
  },
660
856
  scrollToColumn({
661
- align: F = "auto",
662
- behavior: S = "auto",
663
- index: _
857
+ align: T = "auto",
858
+ behavior: y = "auto",
859
+ index: $
664
860
  }) {
665
- const Y = w({
666
- align: F,
667
- containerScrollOffset: I?.scrollLeft ?? 0,
668
- index: _
669
- });
670
- typeof I?.scrollTo == "function" && I.scrollTo({
671
- behavior: S,
672
- left: Y
861
+ const q = H({ align: T, index: $ });
862
+ q && ae(q.scrollTarget, {
863
+ behavior: y,
864
+ left: q.scrollOffset
673
865
  });
674
866
  },
675
867
  scrollToRow({
676
- align: F = "auto",
677
- behavior: S = "auto",
678
- index: _
868
+ align: T = "auto",
869
+ behavior: y = "auto",
870
+ index: $
679
871
  }) {
680
- const Y = K({
681
- align: F,
682
- containerScrollOffset: I?.scrollTop ?? 0,
683
- index: _
684
- });
685
- typeof I?.scrollTo == "function" && I.scrollTo({
686
- behavior: S,
687
- top: Y
872
+ const q = k({ align: T, index: $ });
873
+ q && ae(q.scrollTarget, {
874
+ behavior: y,
875
+ top: q.scrollOffset
688
876
  });
689
877
  }
690
878
  }),
691
- [I, w, K]
692
- ), ne(() => {
693
- z >= 0 && y >= 0 && Z >= 0 && N >= 0 && p && p(
879
+ [F, H, k]
880
+ ), le(() => {
881
+ R >= 0 && O >= 0 && p >= 0 && A >= 0 && l && l(
694
882
  {
695
- columnStartIndex: g,
696
- columnStopIndex: T,
697
- rowStartIndex: ie,
698
- rowStopIndex: k
883
+ columnStartIndex: I,
884
+ columnStopIndex: K,
885
+ rowStartIndex: M,
886
+ rowStopIndex: D
699
887
  },
700
888
  {
701
- columnStartIndex: z,
702
- columnStopIndex: y,
703
- rowStartIndex: Z,
704
- rowStopIndex: N
889
+ columnStartIndex: R,
890
+ columnStopIndex: O,
891
+ rowStartIndex: p,
892
+ rowStopIndex: A
705
893
  }
706
894
  );
707
895
  }, [
896
+ l,
897
+ R,
898
+ I,
899
+ O,
900
+ K,
708
901
  p,
709
- z,
710
- g,
711
- y,
712
- T,
713
- Z,
714
- ie,
715
- N,
716
- k
902
+ M,
903
+ A,
904
+ D
717
905
  ]);
718
- const R = q(() => {
719
- const F = [];
720
- if (r > 0 && h > 0)
721
- for (let S = Z; S <= N; S++) {
722
- const _ = E(S), Y = [];
723
- for (let B = z; B <= y; B++) {
724
- const se = G(B);
725
- Y.push(
726
- /* @__PURE__ */ le(
727
- 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,
728
916
  {
729
917
  ...L,
730
918
  ariaAttributes: {
731
- "aria-colindex": B + 1,
919
+ "aria-colindex": ee + 1,
732
920
  role: "gridcell"
733
921
  },
734
- columnIndex: B,
922
+ columnIndex: ee,
735
923
  key: i ? i({
736
- columnIndex: B,
924
+ columnIndex: ee,
737
925
  data: L,
738
- rowIndex: S
739
- }) : B,
740
- rowIndex: S,
926
+ rowIndex: y
927
+ }) : ee,
928
+ rowIndex: y,
741
929
  style: {
742
930
  position: "absolute",
743
- left: A ? void 0 : 0,
744
- right: A ? 0 : void 0,
745
- transform: `translate(${A ? -se.scrollOffset : se.scrollOffset}px, ${_.scrollOffset}px)`,
746
- height: _.size,
747
- 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
748
936
  }
749
937
  }
750
938
  )
751
939
  );
752
940
  }
753
- F.push(
754
- /* @__PURE__ */ re(
941
+ T.push(
942
+ /* @__PURE__ */ de(
755
943
  "div",
756
944
  {
757
945
  role: "row",
758
- "aria-rowindex": S + 1,
759
- children: Y
946
+ "aria-rowindex": y + 1,
947
+ children: q
760
948
  },
761
- b ? b({
949
+ x ? x({
762
950
  data: L,
763
- rowIndex: S
764
- }) : S
951
+ rowIndex: y
952
+ }) : y
765
953
  )
766
954
  );
767
955
  }
768
- return F;
956
+ return T;
769
957
  }, [
770
- j,
958
+ B,
771
959
  L,
772
- r,
960
+ s,
773
961
  i,
774
- z,
775
- y,
776
- G,
777
- E,
778
- A,
779
- h,
780
- b,
781
- Z,
782
- N
783
- ]), P = /* @__PURE__ */ re(
962
+ R,
963
+ O,
964
+ Q,
965
+ re,
966
+ P,
967
+ w,
968
+ x,
969
+ p,
970
+ A
971
+ ]), W = /* @__PURE__ */ de(
784
972
  "div",
785
973
  {
786
974
  "aria-hidden": !0,
787
975
  style: {
788
- height: V(),
789
- width: Q(),
976
+ height: S(),
977
+ width: te(),
790
978
  zIndex: -1
791
979
  }
792
980
  }
793
981
  );
794
- return le(
795
- m,
982
+ return ve(
983
+ z,
796
984
  {
797
- "aria-colcount": r,
798
- "aria-rowcount": h,
985
+ "aria-colcount": s,
986
+ "aria-rowcount": w,
799
987
  role: "grid",
800
- ...X,
988
+ ...N,
801
989
  className: o,
802
- dir: c,
803
- ref: te,
990
+ dir: d,
991
+ ref: G,
804
992
  style: {
805
993
  position: "relative",
806
- maxHeight: "100%",
807
- 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
+ },
808
1000
  flexGrow: 1,
809
1001
  overflow: "auto",
810
- ...D
1002
+ ...V
811
1003
  }
812
1004
  },
813
- R,
814
- s,
815
- P
1005
+ E,
1006
+ r,
1007
+ W
816
1008
  );
817
1009
  }
818
- const Ge = M, Ne = H;
819
- function $e({
820
- callback: e,
821
- element: t,
822
- enabled: s = !0
823
- }) {
824
- const o = ee(e);
825
- ne(() => {
826
- if (!s || !t)
827
- return;
828
- const r = ae(t);
829
- let i = r.requestAnimationFrame(() => {
830
- i = r.requestAnimationFrame(o);
831
- });
832
- return () => {
833
- r.cancelAnimationFrame(i);
834
- };
835
- }, [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;
836
1014
  }
837
- function He(e) {
838
- return e != null && typeof e == "object" && "getAverageRowHeight" in e && typeof e.getAverageRowHeight == "function";
839
- }
840
- function je({
841
- element: e,
842
- getCellBounds: t,
843
- isDynamicRowHeight: s,
844
- rowCount: o,
845
- rowElements: r,
846
- scrollToIndex: i
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
847
1024
  }) {
848
- const n = H(null), l = H(
1025
+ const v = e === "vertical", h = U(null), f = U(
849
1026
  void 0
850
- ), a = ee(() => {
851
- n.current = null, l.current !== void 0 && (l.current.view.cancelAnimationFrame(l.current.id), l.current = void 0);
852
- }), v = ee(() => {
853
- const c = ae(e);
854
- l.current = {
855
- 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),
856
1033
  view: c
857
1034
  };
858
- }), f = ee(() => {
859
- l.current = void 0;
860
- const c = n.current;
1035
+ }), l = ie(() => {
1036
+ f.current = void 0;
1037
+ const c = h.current;
861
1038
  if (!c) return;
862
- if (!e || !s || c.index >= o || performance.now() >= c.deadline) {
863
- a();
1039
+ if (!t || !o || c.index >= s || performance.now() >= c.deadline) {
1040
+ d();
864
1041
  return;
865
1042
  }
866
- const u = i({
1043
+ const g = u({
867
1044
  align: c.align,
868
- containerScrollOffset: e.scrollTop,
869
1045
  index: c.index
870
1046
  });
871
- if (u !== void 0) {
872
- const p = Math.max(
1047
+ if (g !== void 0) {
1048
+ const { scrollOffset: w, scrollTarget: b } = g, x = Math.max(
873
1049
  0,
874
- Math.min(u, e.scrollHeight - e.clientHeight)
1050
+ Math.min(w, je(b, e))
875
1051
  );
876
- if (Math.abs(p - e.scrollTop) > 1)
877
- 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
+ });
878
1057
  else {
879
- const d = r.current;
880
- if (!(d.some(
881
- (O) => O.getAttribute(oe) === `${c.index}`
882
- ) && d.every((O) => {
883
- const b = Number(O.getAttribute(oe));
884
- return Math.abs(
885
- t(b).size - O.offsetHeight
886
- ) <= 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;
887
1067
  })))
888
1068
  c.stableFrames = 0;
889
1069
  else if (++c.stableFrames >= 2) {
890
- a();
1070
+ d();
891
1071
  return;
892
1072
  }
893
1073
  }
894
1074
  }
895
- v();
1075
+ a();
896
1076
  });
897
- return W(() => {
898
- if (!e) return;
899
- const c = (u) => {
900
- switch (u.key) {
1077
+ return _(() => {
1078
+ const c = n ?? t;
1079
+ if (!c) return;
1080
+ const g = (w) => {
1081
+ switch (w.key) {
901
1082
  case "ArrowUp":
902
1083
  case "ArrowDown":
1084
+ case "ArrowLeft":
1085
+ case "ArrowRight":
903
1086
  case "PageUp":
904
1087
  case "PageDown":
905
1088
  case "Home":
906
1089
  case "End":
907
1090
  case " ":
908
- a();
1091
+ d();
909
1092
  }
910
1093
  };
911
- return e.addEventListener("wheel", a, { passive: !0 }), e.addEventListener("touchstart", a, { passive: !0 }), e.addEventListener("pointerdown", a), e.addEventListener("keydown", c), () => {
912
- 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);
913
1096
  };
914
- }, [a, e]), U(
1097
+ }, [d, t, n]), Y(
915
1098
  ({
916
1099
  align: c = "auto",
917
- behavior: u = "auto",
918
- index: p
1100
+ behavior: g = "auto",
1101
+ index: w
919
1102
  }) => {
920
- s && c === "smart" && (c = i({
921
- align: "auto",
922
- containerScrollOffset: e?.scrollTop ?? 0,
923
- index: p
924
- }) === (e?.scrollTop ?? 0) ? "auto" : "center");
925
- const d = i({
926
- align: c,
927
- containerScrollOffset: e?.scrollTop ?? 0,
928
- index: p
929
- });
930
- a(), typeof e?.scrollTo == "function" && (s && (n.current = {
931
- align: c,
932
- index: p,
933
- deadline: performance.now() + 1e3,
934
- stableFrames: 0
935
- }, v()), e.scrollTo({
936
- behavior: s ? "instant" : u,
937
- top: d
938
- }));
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
+ }
939
1120
  },
940
1121
  [
941
- a,
1122
+ d,
942
1123
  e,
943
- s,
1124
+ o,
944
1125
  v,
945
- i
1126
+ a,
1127
+ u
946
1128
  ]
947
1129
  );
948
1130
  }
949
- const oe = "data-react-window-index", ve = "data-react-window-sizer";
950
- 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({
951
1154
  children: e,
952
1155
  className: t,
953
- defaultHeight: s = 0,
1156
+ defaultHeight: r = 0,
954
1157
  defaultScrollOffset: o = 0,
955
- listRef: r,
1158
+ listRef: s,
956
1159
  onResize: i,
957
1160
  onRowsRendered: n,
958
- overscanCount: l = 3,
959
- rowComponent: a,
960
- rowCount: v,
1161
+ overscanCount: u = 3,
1162
+ rowComponent: v,
1163
+ rowCount: h,
961
1164
  rowHeight: f,
962
- rowKey: c,
963
- rowProps: u,
964
- tagName: p = "div",
965
- style: d,
966
- ...x
1165
+ rowKey: d,
1166
+ rowProps: a,
1167
+ scrollElement: l,
1168
+ tagName: c = "div",
1169
+ style: g,
1170
+ ...w
967
1171
  }) {
968
- const h = me(u), O = q(
969
- () => be(a, ye),
970
- [a]
971
- ), [b, D] = M(null), m = He(f), X = q(() => m ? (k) => f.getRowHeight(k) ?? f.getAverageRowHeight() : f, [m, f]), L = Ie(), [j, I] = M(
972
- () => L && m
973
- ), te = H(f);
974
- W(() => {
975
- j && te.current !== f && I(!1);
976
- }, [j, f]), $e({
977
- callback: () => I(!1),
978
- element: b,
979
- enabled: j
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(
1176
+ () => L && z
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
980
1184
  });
981
1185
  const {
982
- getCellBounds: A,
983
- getEstimatedSize: G,
984
- scrollToIndex: Q,
985
- startIndexOverscan: z,
986
- startIndexVisible: g,
987
- stopIndexOverscan: w,
988
- stopIndexVisible: y
989
- } = fe({
990
- containerElement: b,
991
- containerStyle: d,
992
- 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,
993
1198
  defaultScrollOffset: o,
994
1199
  direction: "vertical",
995
- itemCount: v,
996
- itemProps: h,
997
- itemSize: X,
1200
+ itemCount: h,
1201
+ itemProps: b,
1202
+ itemSize: N,
998
1203
  onResize: i,
999
- overscanCount: l
1000
- }), T = H([]), E = je({
1001
- element: b,
1002
- getCellBounds: A,
1003
- isDynamicRowHeight: m,
1004
- rowCount: v,
1005
- rowElements: T,
1006
- scrollToIndex: Q
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
1007
1215
  });
1008
- xe(
1009
- r,
1216
+ Le(
1217
+ s,
1010
1218
  () => ({
1011
1219
  get element() {
1012
- return b;
1220
+ return m;
1013
1221
  },
1014
- scrollToRow: E
1222
+ scrollToRow: S
1015
1223
  }),
1016
- [b, E]
1017
- ), W(() => {
1018
- if (!b)
1224
+ [m, S]
1225
+ ), _(() => {
1226
+ if (!m)
1019
1227
  return;
1020
- const k = Array.from(b.children).slice(
1228
+ const E = Array.from(m.children).slice(
1021
1229
  0,
1022
- z < 0 ? 0 : w - z + 1
1023
- ).filter((R, P) => {
1024
- if (R.hasAttribute(ve))
1230
+ I < 0 ? 0 : O - I + 1
1231
+ ).filter((W, T) => {
1232
+ if (W.hasAttribute(ze))
1025
1233
  return !1;
1026
- const F = `${z + P}`;
1027
- return R.setAttribute(oe, F), !0;
1234
+ const y = `${I + T}`;
1235
+ return W.setAttribute(He, y), !0;
1028
1236
  });
1029
- if (T.current = k, m)
1030
- return f.observeRowElements(k);
1237
+ if (re.current = E, z)
1238
+ return f.observeRowElements(E);
1031
1239
  }, [
1032
- O,
1033
- b,
1240
+ x,
1034
1241
  m,
1035
- v,
1036
- f,
1037
- c,
1038
- h,
1039
1242
  z,
1040
- w
1041
- ]), ne(() => {
1042
- z >= 0 && w >= 0 && n && n(
1243
+ h,
1244
+ f,
1245
+ d,
1246
+ b,
1247
+ I,
1248
+ O
1249
+ ]), le(() => {
1250
+ I >= 0 && O >= 0 && n && n(
1043
1251
  {
1044
- startIndex: g,
1045
- stopIndex: y
1252
+ startIndex: H,
1253
+ stopIndex: K
1046
1254
  },
1047
1255
  {
1048
- startIndex: z,
1049
- stopIndex: w
1256
+ startIndex: I,
1257
+ stopIndex: O
1050
1258
  }
1051
1259
  );
1052
1260
  }, [
1053
1261
  n,
1054
- z,
1055
- g,
1056
- w,
1057
- y
1262
+ I,
1263
+ H,
1264
+ O,
1265
+ K
1058
1266
  ]);
1059
- const V = j && m && z === 0, Z = q(() => {
1060
- const k = [];
1061
- if (v > 0)
1062
- for (let R = z; R <= w; R++) {
1063
- const P = A(R);
1064
- k.push(
1065
- /* @__PURE__ */ le(
1066
- 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,
1067
1275
  {
1068
- ...h,
1276
+ ...b,
1069
1277
  ariaAttributes: {
1070
- "aria-posinset": R + 1,
1071
- "aria-setsize": v,
1278
+ "aria-posinset": W + 1,
1279
+ "aria-setsize": h,
1072
1280
  role: "listitem"
1073
1281
  },
1074
- key: c ? c(R, h) : R,
1075
- index: R,
1076
- style: V ? { width: "100%" } : {
1282
+ key: d ? d(W, b) : W,
1283
+ index: W,
1284
+ style: p ? { width: "100%" } : {
1077
1285
  position: "absolute",
1078
1286
  left: 0,
1079
- transform: `translateY(${P.scrollOffset}px)`,
1287
+ transform: `translateY(${T.scrollOffset}px)`,
1080
1288
  // In case of dynamic row heights, don't specify a height style
1081
1289
  // otherwise a default/estimated height would mask the actual height
1082
- height: m ? void 0 : P.size,
1290
+ height: z ? void 0 : T.size,
1083
1291
  width: "100%"
1084
1292
  }
1085
1293
  }
1086
1294
  )
1087
1295
  );
1088
1296
  }
1089
- return k;
1297
+ return E;
1090
1298
  }, [
1091
- O,
1092
- A,
1093
- m,
1094
- V,
1095
- v,
1096
- c,
1097
- h,
1299
+ x,
1300
+ P,
1098
1301
  z,
1099
- w
1100
- ]), ie = /* @__PURE__ */ re(
1302
+ p,
1303
+ h,
1304
+ d,
1305
+ b,
1306
+ I,
1307
+ O
1308
+ ]), k = /* @__PURE__ */ de(
1101
1309
  "div",
1102
1310
  {
1103
1311
  "aria-hidden": !0,
1104
- [ve]: "",
1312
+ [ze]: "",
1105
1313
  style: {
1106
1314
  // Rows rendered in flow layout already take up space
1107
- position: V ? "absolute" : void 0,
1108
- top: V ? 0 : void 0,
1109
- height: G(),
1315
+ position: p ? "absolute" : void 0,
1316
+ top: p ? 0 : void 0,
1317
+ height: Q(),
1110
1318
  width: "100%",
1111
1319
  zIndex: -1
1112
1320
  }
1113
1321
  },
1114
1322
  "sizer"
1115
- ), K = /* @__PURE__ */ re(ue, { children: e }, "children"), N = /* @__PURE__ */ re(ue, { children: Z }, "rows");
1116
- return le(
1117
- p,
1323
+ ), A = /* @__PURE__ */ de(be, { children: e }, "children"), D = /* @__PURE__ */ de(be, { children: M }, "rows");
1324
+ return ve(
1325
+ c,
1118
1326
  {
1119
1327
  role: "list",
1120
- ...x,
1328
+ ...w,
1121
1329
  className: t,
1122
- ref: D,
1330
+ ref: V,
1123
1331
  style: {
1124
1332
  position: "relative",
1125
- maxHeight: "100%",
1126
1333
  flexGrow: 1,
1127
- overflowY: "auto",
1128
- ...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
1129
1340
  }
1130
1341
  },
1131
- ...V ? [K, N] : [N, K],
1132
- ie
1342
+ ...p ? [A, D] : [D, A],
1343
+ k
1133
1344
  );
1134
1345
  }
1135
- function pe(e) {
1346
+ function ye(e) {
1136
1347
  const t = /* @__PURE__ */ new Map();
1137
- return e !== void 0 && e.forEach((s, o) => {
1138
- 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);
1139
1350
  }), t;
1140
1351
  }
1141
- function Ye({
1352
+ function ot({
1142
1353
  defaultRowHeight: e,
1143
1354
  initialRowHeights: t,
1144
- key: s
1355
+ key: r
1145
1356
  }) {
1146
- const [o, r] = M(() => ({
1147
- key: s,
1148
- map: pe(t)
1357
+ const [o, s] = j(() => ({
1358
+ key: r,
1359
+ map: ye(t)
1149
1360
  }));
1150
- o.key !== s && r({
1151
- key: s,
1152
- map: pe(t)
1361
+ o.key !== r && s({
1362
+ key: r,
1363
+ map: ye(t)
1153
1364
  });
1154
- const { map: i } = o, n = U(() => {
1155
- let u = 0;
1156
- return i.forEach((p) => {
1157
- u += p;
1158
- }), u === 0 ? e : u / i.size;
1159
- }, [e, i]), l = U(
1160
- (u) => {
1161
- const p = i.get(u);
1162
- 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;
1163
1374
  },
1164
1375
  [e, i]
1165
- ), a = U((u, p) => {
1166
- r((d) => {
1167
- if (d.map.get(u) === p)
1168
- return d;
1169
- const x = new Map(d.map);
1170
- return x.set(u, p), {
1171
- ...d,
1172
- map: x
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
1173
1384
  };
1174
1385
  });
1175
- }, []), v = ee(
1176
- (u) => {
1177
- u.length !== 0 && u.forEach((p) => {
1178
- const { borderBoxSize: d, target: x } = p, h = x.getAttribute(oe);
1179
- $(
1180
- h !== null,
1181
- `Invalid ${oe} attribute value`
1182
- );
1183
- const O = parseInt(h), { blockSize: b } = d[0];
1184
- b && a(O, b);
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);
1185
1394
  });
1186
1395
  }
1187
- ), f = H(null);
1188
- ne(
1396
+ ), f = U(null);
1397
+ le(
1189
1398
  () => () => {
1190
1399
  f.current?.resizeObserver.disconnect(), f.current = null;
1191
1400
  },
1192
1401
  []
1193
1402
  );
1194
- const c = U(
1195
- (u) => {
1196
- const p = [];
1197
- return u.forEach((d) => {
1198
- const x = ae(d);
1199
- 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) {
1200
1409
  f.current?.resizeObserver.disconnect();
1201
- const O = Oe(d);
1202
- f.current = O ? {
1203
- resizeObserver: new O(v),
1204
- view: x
1410
+ const b = pe(c);
1411
+ f.current = b ? {
1412
+ resizeObserver: new b(h),
1413
+ view: g
1205
1414
  } : null;
1206
1415
  }
1207
- const h = f.current?.resizeObserver;
1208
- h && (h.observe(d), p.push([d, h]));
1416
+ const w = f.current?.resizeObserver;
1417
+ w && (w.observe(c), l.push([c, w]));
1209
1418
  }), () => {
1210
- p.forEach(
1211
- ([d, x]) => x.unobserve(d)
1419
+ l.forEach(
1420
+ ([c, g]) => g.unobserve(c)
1212
1421
  );
1213
1422
  };
1214
1423
  },
1215
- [v]
1424
+ [h]
1216
1425
  );
1217
- return q(
1426
+ return C(
1218
1427
  () => ({
1219
1428
  getAverageRowHeight: n,
1220
- getRowHeight: l,
1221
- setRowHeight: a,
1222
- observeRowElements: c
1429
+ getRowHeight: u,
1430
+ setRowHeight: v,
1431
+ observeRowElements: d
1432
+ }),
1433
+ [n, u, v, d]
1434
+ );
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(
1537
+ () => ({
1538
+ items: Q,
1539
+ measureElement: F,
1540
+ scrollToIndex: P,
1541
+ totalSize: te,
1542
+ visibleRange: {
1543
+ startIndex: x,
1544
+ stopIndex: V
1545
+ }
1223
1546
  }),
1224
- [n, l, a, c]
1547
+ [
1548
+ Q,
1549
+ F,
1550
+ P,
1551
+ x,
1552
+ V,
1553
+ te
1554
+ ]
1225
1555
  );
1226
1556
  }
1227
- const De = M, Xe = H, ge = /* @__PURE__ */ new WeakMap();
1228
- 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) {
1229
1580
  if (t === void 0)
1230
1581
  return 0;
1231
- let s = ge.get(t);
1232
- if (s === void 0 || e) {
1233
- const o = t.createElement("div"), r = o.style;
1234
- r.width = "50px", r.height = "50px", r.overflow = "scroll", t.body.appendChild(o), s = o.offsetWidth - o.clientWidth, t.body.removeChild(o), ge.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);
1235
1586
  }
1236
- return s;
1587
+ return r;
1237
1588
  }
1238
1589
  export {
1239
- qe as Grid,
1240
- _e as List,
1241
- Ze as getScrollbarSize,
1242
- Ye as useDynamicRowHeight,
1243
- Ge as useGridCallbackRef,
1244
- Ne as useGridRef,
1245
- De as useListCallbackRef,
1246
- 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
1247
1600
  };
1248
1601
  //# sourceMappingURL=react-window.js.map