react-window 2.4.1 → 2.5.1

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