react-window 2.0.0-alpha.5 → 2.0.0-alpha.6

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,435 +1,508 @@
1
- import { jsx as R } from "react/jsx-runtime";
2
- import { useLayoutEffect as Y, useEffect as U, useMemo as H, useState as L, useRef as W, useCallback as G, memo as q, useImperativeHandle as A, createElement as _ } from "react";
3
- const V = typeof window < "u" ? Y : U;
4
- function F(t) {
5
- if (t !== void 0)
6
- switch (typeof t) {
1
+ import { jsx as U } from "react/jsx-runtime";
2
+ import { useLayoutEffect as K, useEffect as A, useMemo as E, useState as H, useRef as V, useCallback as G, memo as Q, useImperativeHandle as X, createElement as Z } from "react";
3
+ const F = typeof window < "u" ? K : A;
4
+ function P(e) {
5
+ if (e !== void 0)
6
+ switch (typeof e) {
7
7
  case "number":
8
- return t;
8
+ return e;
9
9
  case "string": {
10
- if (t.endsWith("px"))
11
- return parseFloat(t);
10
+ if (e.endsWith("px"))
11
+ return parseFloat(e);
12
12
  break;
13
13
  }
14
14
  }
15
15
  }
16
- function K({
17
- box: t,
18
- defaultHeight: s,
19
- defaultWidth: n,
20
- disabled: r,
21
- element: e,
16
+ function te({
17
+ box: e,
18
+ defaultHeight: t,
19
+ defaultWidth: s,
20
+ disabled: i,
21
+ element: o,
22
22
  mode: f,
23
- style: i
23
+ style: n
24
24
  }) {
25
- const { styleHeight: c, styleWidth: o } = H(
25
+ const { styleHeight: c, styleWidth: r } = E(
26
26
  () => ({
27
- styleHeight: F(i?.height),
28
- styleWidth: F(i?.width)
27
+ styleHeight: P(n?.height),
28
+ styleWidth: P(n?.width)
29
29
  }),
30
- [i?.height, i?.width]
31
- ), [u, m] = L({
32
- height: s,
33
- width: n
34
- }), z = r || f === "only-height" && c !== void 0 || f === "only-width" && o !== void 0 || c !== void 0 && o !== void 0;
35
- return V(() => {
36
- if (e === null || z)
30
+ [n?.height, n?.width]
31
+ ), [d, h] = H({
32
+ height: t,
33
+ width: s
34
+ }), m = i || f === "only-height" && c !== void 0 || f === "only-width" && r !== void 0 || c !== void 0 && r !== void 0;
35
+ return F(() => {
36
+ if (o === null || m)
37
37
  return;
38
- const O = new ResizeObserver((x) => {
39
- for (const v of x) {
40
- const { contentRect: w, target: I } = v;
41
- e === I && m((h) => h.height === w.height && h.width === w.width ? h : {
38
+ const b = new ResizeObserver((v) => {
39
+ for (const a of v) {
40
+ const { contentRect: w, target: g } = a;
41
+ o === g && h((u) => u.height === w.height && u.width === w.width ? u : {
42
42
  height: w.height,
43
43
  width: w.width
44
44
  });
45
45
  }
46
46
  });
47
- return O.observe(e, { box: t }), () => {
48
- O?.unobserve(e);
47
+ return b.observe(o, { box: e }), () => {
48
+ b?.unobserve(o);
49
49
  };
50
- }, [t, z, e, c, o]), H(
50
+ }, [e, m, o, c, r]), E(
51
51
  () => ({
52
- height: c ?? u.height,
53
- width: o ?? u.width
52
+ height: c ?? d.height,
53
+ width: r ?? d.width
54
54
  }),
55
- [u, c, o]
55
+ [d, c, r]
56
56
  );
57
57
  }
58
- function Q(t) {
59
- const s = W(() => {
58
+ function se(e) {
59
+ const t = V(() => {
60
60
  throw new Error("Cannot call an event handler while rendering.");
61
61
  });
62
- return V(() => {
63
- s.current = t;
64
- }, [t]), G((n) => s.current?.(n), [s]);
62
+ return F(() => {
63
+ t.current = e;
64
+ }, [e]), G((s) => t.current?.(s), [t]);
65
65
  }
66
- function $(t, s = "Assertion error") {
67
- if (!t)
68
- throw console.error(s), Error(s);
66
+ function $(e, t = "Assertion error") {
67
+ if (!e)
68
+ throw console.error(t), Error(t);
69
69
  }
70
- function X({
71
- cachedBounds: t,
72
- itemCount: s,
73
- itemSize: n
70
+ function _({
71
+ cachedBounds: e,
72
+ itemCount: t,
73
+ itemSize: s
74
74
  }) {
75
- if (typeof n == "number")
76
- return s * n;
77
- if (t.size > 0) {
78
- const r = t.get(t.size - 1);
79
- $(r !== void 0, "Unexpected bounds cache miss");
80
- const e = (r.scrollOffset + r.size) / t.size;
81
- return s * e;
82
- } else
75
+ if (t === 0)
83
76
  return 0;
77
+ if (typeof s == "number")
78
+ return t * s;
79
+ {
80
+ const i = e.get(
81
+ e.size === 0 ? 0 : e.size - 1
82
+ );
83
+ $(i !== void 0, "Unexpected bounds cache miss");
84
+ const o = (i.scrollOffset + i.size) / e.size;
85
+ return t * o;
86
+ }
84
87
  }
85
- function Z({
86
- align: t,
87
- cachedBounds: s,
88
- index: n,
89
- itemCount: r,
90
- containerScrollOffset: e,
91
- containerSize: f
88
+ function oe({
89
+ align: e,
90
+ cachedBounds: t,
91
+ index: s,
92
+ itemCount: i,
93
+ itemSize: o,
94
+ containerScrollOffset: f,
95
+ containerSize: n
92
96
  }) {
93
- const i = s.get(r - 1).scrollOffset, c = i + i - f, o = Math.max(
97
+ const c = _({
98
+ cachedBounds: t,
99
+ itemCount: i,
100
+ itemSize: o
101
+ }), r = t.get(s), d = Math.max(
94
102
  0,
95
- s.get(n + 1).scrollOffset - f
96
- ), u = Math.min(
97
- i,
98
- s.get(n).scrollOffset
103
+ Math.min(c - n, r.scrollOffset)
104
+ ), h = Math.max(
105
+ 0,
106
+ r.scrollOffset - n + r.size
99
107
  );
100
- switch (t === "smart" && (e >= o && e <= u ? t = "auto" : t = "center"), t) {
108
+ switch (e === "smart" && (f >= h && f <= d ? e = "auto" : e = "center"), e) {
101
109
  case "start":
102
- return Math.min(c, u);
110
+ return d;
103
111
  case "end":
104
- return o;
105
- case "center": {
106
- const m = Math.round(
107
- o + (u - o) / 2
108
- );
109
- return m < Math.ceil(f / 2) ? 0 : m > c ? c : m;
110
- }
112
+ return h;
113
+ case "center":
114
+ return r.scrollOffset <= n / 2 ? 0 : r.scrollOffset + r.size / 2 >= c - n / 2 ? c - n : r.scrollOffset + r.size / 2 - n / 2;
111
115
  case "auto":
112
116
  default:
113
- return e >= o && e <= u ? e : e < o ? o : u;
117
+ return f >= h && f <= d ? f : f < h ? h : d;
114
118
  }
115
119
  }
116
- function tt({
117
- cachedBounds: t,
118
- containerScrollOffset: s,
119
- containerSize: n,
120
- itemCount: r,
121
- overscanCount: e
120
+ function D({
121
+ cachedBounds: e,
122
+ containerScrollOffset: t,
123
+ containerSize: s,
124
+ itemCount: i,
125
+ overscanCount: o
122
126
  }) {
123
- const f = r - 1;
124
- let i = 0, c = -1, o = 0;
125
- for (; o < f; ) {
126
- const u = t.get(o);
127
- if (u.scrollOffset + u.size > s)
127
+ const f = i - 1;
128
+ let n = 0, c = -1, r = 0;
129
+ for (; r < f; ) {
130
+ const d = e.get(r);
131
+ if (d.scrollOffset + d.size > t)
128
132
  break;
129
- o++;
133
+ r++;
130
134
  }
131
- for (i = o, i = Math.max(0, i - e); o < f; ) {
132
- const u = t.get(o);
133
- if (u.scrollOffset + u.size >= s + n)
135
+ for (n = r, n = Math.max(0, n - o); r < f; ) {
136
+ const d = e.get(r);
137
+ if (d.scrollOffset + d.size >= t + s)
134
138
  break;
135
- o++;
139
+ r++;
136
140
  }
137
- return c = Math.min(f, o), c = Math.min(r - 1, c + e), i < 0 ? [0, -1] : [i, c];
141
+ return c = Math.min(f, r), c = Math.min(i - 1, c + o), n < 0 ? [0, -1] : [n, c];
138
142
  }
139
- function et({
140
- itemCount: t,
141
- itemProps: s,
142
- itemSize: n
143
+ function re({
144
+ itemCount: e,
145
+ itemProps: t,
146
+ itemSize: s
143
147
  }) {
144
- const r = /* @__PURE__ */ new Map();
148
+ const i = /* @__PURE__ */ new Map();
145
149
  return {
146
- get(e) {
147
- for ($(e < t, `Invalid index ${e}`); r.size - 1 < e; ) {
148
- const i = r.size, c = typeof n == "number" ? n : n(i, s);
149
- if (i === 0)
150
- r.set(i, {
150
+ get(o) {
151
+ for ($(o < e, `Invalid index ${o}`); i.size - 1 < o; ) {
152
+ const n = i.size;
153
+ let c;
154
+ switch (typeof s) {
155
+ case "function": {
156
+ c = s(n, t);
157
+ break;
158
+ }
159
+ case "number": {
160
+ c = s;
161
+ break;
162
+ }
163
+ }
164
+ if (n === 0)
165
+ i.set(n, {
151
166
  size: c,
152
167
  scrollOffset: 0
153
168
  });
154
169
  else {
155
- const o = r.get(i - 1);
170
+ const r = i.get(n - 1);
156
171
  $(
157
- o !== void 0,
158
- `Unexpected bounds cache miss for index ${e}`
159
- ), r.set(i, {
160
- scrollOffset: o.scrollOffset + o.size,
172
+ r !== void 0,
173
+ `Unexpected bounds cache miss for index ${o}`
174
+ ), i.set(n, {
175
+ scrollOffset: r.scrollOffset + r.size,
161
176
  size: c
162
177
  });
163
178
  }
164
179
  }
165
- const f = r.get(e);
180
+ const f = i.get(o);
166
181
  return $(
167
182
  f !== void 0,
168
- `Unexpected bounds cache miss for index ${e}`
183
+ `Unexpected bounds cache miss for index ${o}`
169
184
  ), f;
170
185
  },
171
- set(e, f) {
172
- r.set(e, f);
186
+ set(o, f) {
187
+ i.set(o, f);
173
188
  },
174
189
  get size() {
175
- return r.size;
190
+ return i.size;
176
191
  }
177
192
  };
178
193
  }
179
- function st({
180
- itemCount: t,
181
- itemProps: s,
182
- itemSize: n
194
+ function ie({
195
+ itemCount: e,
196
+ itemProps: t,
197
+ itemSize: s
183
198
  }) {
184
- return H(
185
- () => et({
186
- itemCount: t,
187
- itemProps: s,
188
- itemSize: n
199
+ return E(
200
+ () => re({
201
+ itemCount: e,
202
+ itemProps: t,
203
+ itemSize: s
189
204
  }),
190
- [t, s, n]
205
+ [e, t, s]
191
206
  );
192
207
  }
193
- function B({
194
- containerElement: t,
195
- containerStyle: s,
196
- defaultContainerSize: n = 0,
197
- direction: r,
198
- itemCount: e,
208
+ function ne({
209
+ containerSize: e,
210
+ itemSize: t
211
+ }) {
212
+ let s;
213
+ switch (typeof t) {
214
+ case "string": {
215
+ $(
216
+ t.endsWith("%"),
217
+ `Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`
218
+ ), $(
219
+ e !== void 0,
220
+ "Container size must be defined if a percentage item size is specified"
221
+ ), s = e * parseInt(t) / 100;
222
+ break;
223
+ }
224
+ default: {
225
+ s = t;
226
+ break;
227
+ }
228
+ }
229
+ return s;
230
+ }
231
+ function q({
232
+ containerElement: e,
233
+ containerStyle: t,
234
+ defaultContainerSize: s = 0,
235
+ direction: i,
236
+ itemCount: o,
199
237
  itemProps: f,
200
- itemSize: i,
238
+ itemSize: n,
201
239
  onResize: c,
202
- overscanCount: o
240
+ overscanCount: r
203
241
  }) {
204
- const [u, m] = L([0, -1]), [z, O] = [
205
- Math.min(e - 1, u[0]),
206
- Math.min(e - 1, u[1])
207
- ], { height: x = n, width: v = n } = K({
208
- defaultHeight: r === "vertical" ? n : void 0,
209
- defaultWidth: r === "horizontal" ? n : void 0,
210
- element: t,
211
- mode: r === "vertical" ? "only-height" : "only-width",
212
- style: s
213
- }), w = W({
242
+ const [d, h] = H([0, -1]), [m, b] = [
243
+ Math.min(o - 1, d[0]),
244
+ Math.min(o - 1, d[1])
245
+ ], { height: v = s, width: a = s } = te({
246
+ defaultHeight: i === "vertical" ? s : void 0,
247
+ defaultWidth: i === "horizontal" ? s : void 0,
248
+ element: e,
249
+ mode: i === "vertical" ? "only-height" : "only-width",
250
+ style: t
251
+ }), w = V({
214
252
  height: 0,
215
253
  width: 0
216
- });
217
- Y(() => {
254
+ }), g = i === "vertical" ? v : a, u = ne({ containerSize: g, itemSize: n });
255
+ K(() => {
218
256
  if (typeof c == "function") {
219
257
  const l = w.current;
220
- (l.height !== x || l.width !== v) && (c({ height: x, width: v }, { ...l }), l.height = x, l.width = v);
258
+ (l.height !== v || l.width !== a) && (c({ height: v, width: a }, { ...l }), l.height = v, l.width = a);
221
259
  }
222
- }, [x, c, v]);
223
- const I = r === "vertical" ? x : v, h = st({
224
- itemCount: e,
260
+ }, [v, c, a]);
261
+ const p = ie({
262
+ itemCount: o,
225
263
  itemProps: f,
226
- itemSize: i
227
- }), y = G(
228
- (l) => h.get(l),
229
- [h]
230
- ), P = G(
231
- () => X({
232
- cachedBounds: h,
233
- itemCount: e,
234
- itemSize: i
264
+ itemSize: u
265
+ }), O = G(
266
+ (l) => p.get(l),
267
+ [p]
268
+ ), T = G(
269
+ () => _({
270
+ cachedBounds: p,
271
+ itemCount: o,
272
+ itemSize: u
235
273
  }),
236
- [h, e, i]
237
- ), a = G(
238
- (l) => tt({
239
- cachedBounds: h,
274
+ [p, o, u]
275
+ ), y = G(
276
+ (l) => D({
277
+ cachedBounds: p,
240
278
  containerScrollOffset: l,
241
- containerSize: I,
242
- itemCount: e,
243
- overscanCount: o
279
+ containerSize: g,
280
+ itemCount: o,
281
+ overscanCount: r
244
282
  }),
245
- [h, I, e, o]
283
+ [p, g, o, r]
246
284
  );
247
- V(() => {
248
- const l = (r === "vertical" ? t?.scrollTop : t?.scrollLeft) ?? 0;
249
- m(a(l));
250
- }, [t, r, a]);
251
- const d = Q(
285
+ F(() => {
286
+ const l = (i === "vertical" ? e?.scrollTop : e?.scrollLeft) ?? 0;
287
+ h(y(l));
288
+ }, [e, i, y]), F(() => {
289
+ if (!e)
290
+ return;
291
+ const l = () => {
292
+ h((x) => {
293
+ const R = i === "vertical" ? e.scrollTop : e.scrollLeft, I = D({
294
+ cachedBounds: p,
295
+ containerScrollOffset: R,
296
+ containerSize: g,
297
+ itemCount: o,
298
+ overscanCount: r
299
+ });
300
+ return I[0] === x[0] && I[1] === x[1] ? x : I;
301
+ });
302
+ };
303
+ return e.addEventListener("scroll", l), () => {
304
+ e.removeEventListener("scroll", l);
305
+ };
306
+ }, [
307
+ p,
308
+ e,
309
+ g,
310
+ i,
311
+ o,
312
+ r
313
+ ]);
314
+ const S = se(
252
315
  ({
253
316
  align: l = "auto",
254
- behavior: T = "auto",
255
- containerScrollOffset: p,
256
- index: g
317
+ behavior: x = "auto",
318
+ containerScrollOffset: R,
319
+ index: I
257
320
  }) => {
258
- const k = Z({
321
+ const W = oe({
259
322
  align: l,
260
- cachedBounds: h,
261
- containerScrollOffset: p,
262
- containerSize: I,
263
- index: g,
264
- itemCount: e
265
- });
266
- r === "horizontal" ? t?.scrollTo({
267
- left: k,
268
- behavior: T || void 0
269
- }) : t?.scrollTo({
270
- behavior: T || void 0,
271
- top: k
323
+ cachedBounds: p,
324
+ containerScrollOffset: R,
325
+ containerSize: g,
326
+ index: I,
327
+ itemCount: o,
328
+ itemSize: u
272
329
  });
330
+ if (e)
331
+ if (typeof e.scrollTo == "function")
332
+ i === "horizontal" ? e.scrollTo({
333
+ left: W,
334
+ behavior: x || void 0
335
+ }) : e.scrollTo({
336
+ behavior: x || void 0,
337
+ top: W
338
+ });
339
+ else {
340
+ const k = y(W);
341
+ (k[0] !== m || k[1] !== b) && h(k);
342
+ }
273
343
  }
274
344
  );
275
345
  return {
276
- getCellBounds: y,
277
- getEstimatedHeight: P,
278
- onScroll: () => {
279
- const l = a(
280
- (r === "vertical" ? t?.scrollTop : t?.scrollLeft) ?? 0
281
- );
282
- (l[0] !== z || l[1] !== O) && m(l);
283
- },
284
- scrollToIndex: d,
285
- startIndex: z,
286
- stopIndex: O
346
+ getCellBounds: O,
347
+ getEstimatedSize: T,
348
+ scrollToIndex: S,
349
+ startIndex: m,
350
+ stopIndex: b
287
351
  };
288
352
  }
289
- function C(t) {
290
- return H(() => t, Object.values(t));
353
+ function N(e) {
354
+ return E(() => e, Object.values(e));
291
355
  }
292
- function N(t, s) {
293
- if (t === s)
356
+ function J(e, t) {
357
+ if (e === t)
294
358
  return !0;
295
- if (!!t != !!s || ($(t !== void 0), $(s !== void 0), Object.keys(t).length !== Object.keys(s).length))
359
+ if (!!e != !!t || ($(e !== void 0), $(t !== void 0), Object.keys(e).length !== Object.keys(t).length))
296
360
  return !1;
297
- for (const n in t)
298
- if (!Object.is(s[n], t[n]))
361
+ for (const s in e)
362
+ if (!Object.is(t[s], e[s]))
299
363
  return !1;
300
364
  return !0;
301
365
  }
302
- function D(t, s) {
303
- const { style: n, ...r } = t, { style: e, ...f } = s;
304
- return N(n, e) && N(r, f);
366
+ function C(e, t) {
367
+ const { style: s, ...i } = e, { style: o, ...f } = t;
368
+ return J(s, o) && J(i, f);
305
369
  }
306
- const J = () => {
307
- };
308
- function nt({
309
- cellComponent: t,
310
- cellProps: s,
311
- className: n,
312
- columnCount: r,
313
- columnWidth: e,
370
+ function fe({
371
+ cellComponent: e,
372
+ cellProps: t,
373
+ className: s,
374
+ columnCount: i,
375
+ columnWidth: o,
314
376
  defaultHeight: f = 0,
315
- defaultWidth: i = 0,
377
+ defaultWidth: n = 0,
316
378
  gridRef: c,
317
- onCellsRendered: o,
318
- onResize: u,
319
- onScroll: m = J,
320
- overscanCount: z = 3,
321
- rowCount: O,
322
- rowHeight: x,
379
+ onCellsRendered: r,
380
+ onResize: d,
381
+ overscanCount: h = 3,
382
+ rowCount: m,
383
+ rowHeight: b,
323
384
  style: v,
324
- ...w
385
+ ...a
325
386
  }) {
326
- const I = C(s), h = H(
327
- () => q(t, D),
328
- [t]
329
- ), [y, P] = L(null), a = B({
330
- containerElement: y,
331
- defaultContainerSize: i,
387
+ const w = N(t), g = E(
388
+ () => Q(e, C),
389
+ [e]
390
+ ), [u, p] = H(null), {
391
+ getCellBounds: O,
392
+ getEstimatedSize: T,
393
+ startIndex: y,
394
+ scrollToIndex: S,
395
+ stopIndex: l
396
+ } = q({
397
+ containerElement: u,
398
+ defaultContainerSize: n,
332
399
  direction: "horizontal",
333
- itemCount: r,
334
- itemProps: I,
335
- itemSize: e,
336
- onResize: u,
337
- overscanCount: z
338
- }), d = B({
339
- containerElement: y,
400
+ itemCount: i,
401
+ itemProps: w,
402
+ itemSize: o,
403
+ onResize: d,
404
+ overscanCount: h
405
+ }), {
406
+ getCellBounds: x,
407
+ getEstimatedSize: R,
408
+ startIndex: I,
409
+ scrollToIndex: W,
410
+ stopIndex: k
411
+ } = q({
412
+ containerElement: u,
340
413
  defaultContainerSize: f,
341
414
  direction: "vertical",
342
- itemCount: O,
343
- itemProps: I,
344
- itemSize: x,
345
- onResize: u,
346
- overscanCount: z
347
- }), { startIndex: l, stopIndex: T } = a, { startIndex: p, stopIndex: g } = d;
348
- A(
415
+ itemCount: m,
416
+ itemProps: w,
417
+ itemSize: b,
418
+ onResize: d,
419
+ overscanCount: h
420
+ });
421
+ X(
349
422
  c,
350
423
  () => ({
351
424
  get element() {
352
- return y;
425
+ return u;
353
426
  },
354
427
  scrollToCell({
355
- behavior: b = "auto",
356
- columnAlign: S = "auto",
357
- columnIndex: E,
358
- rowAlign: M = "auto",
428
+ behavior: L = "auto",
429
+ columnAlign: z = "auto",
430
+ columnIndex: M,
431
+ rowAlign: B = "auto",
359
432
  rowIndex: j
360
433
  }) {
361
- d?.scrollToIndex({
362
- align: M,
363
- behavior: b,
364
- containerScrollOffset: y?.scrollTop ?? 0,
434
+ W({
435
+ align: B,
436
+ behavior: L,
437
+ containerScrollOffset: u?.scrollTop ?? 0,
365
438
  index: j
366
- }), a?.scrollToIndex({
367
- align: S,
368
- behavior: b,
369
- containerScrollOffset: y?.scrollLeft ?? 0,
370
- index: E
439
+ }), S({
440
+ align: z,
441
+ behavior: L,
442
+ containerScrollOffset: u?.scrollLeft ?? 0,
443
+ index: M
371
444
  });
372
445
  },
373
446
  scrollToColumn({
374
- align: b = "auto",
375
- behavior: S = "auto",
376
- index: E
447
+ align: L = "auto",
448
+ behavior: z = "auto",
449
+ index: M
377
450
  }) {
378
- a?.scrollToIndex({
379
- align: b,
380
- behavior: S,
381
- containerScrollOffset: y?.scrollLeft ?? 0,
382
- index: E
451
+ S({
452
+ align: L,
453
+ behavior: z,
454
+ containerScrollOffset: u?.scrollLeft ?? 0,
455
+ index: M
383
456
  });
384
457
  },
385
458
  scrollToRow({
386
- align: b = "auto",
387
- behavior: S = "auto",
388
- index: E
459
+ align: L = "auto",
460
+ behavior: z = "auto",
461
+ index: M
389
462
  }) {
390
- d?.scrollToIndex({
391
- align: b,
392
- behavior: S,
393
- containerScrollOffset: y?.scrollTop ?? 0,
394
- index: E
463
+ W({
464
+ align: L,
465
+ behavior: z,
466
+ containerScrollOffset: u?.scrollTop ?? 0,
467
+ index: M
395
468
  });
396
469
  }
397
470
  }),
398
- [a, y, d]
399
- ), U(() => {
400
- l >= 0 && T >= 0 && p >= 0 && g >= 0 && o && o({
401
- columnStartIndex: l,
402
- columnStopIndex: T,
403
- rowStartIndex: p,
404
- rowStopIndex: g
471
+ [u, S, W]
472
+ ), A(() => {
473
+ y >= 0 && l >= 0 && I >= 0 && k >= 0 && r && r({
474
+ columnStartIndex: y,
475
+ columnStopIndex: l,
476
+ rowStartIndex: I,
477
+ rowStopIndex: k
405
478
  });
406
479
  }, [
407
- o,
480
+ r,
481
+ y,
408
482
  l,
409
- T,
410
- p,
411
- g
483
+ I,
484
+ k
412
485
  ]);
413
- const k = H(() => {
414
- const b = [];
415
- if (a && r > 0 && d && O > 0)
416
- for (let S = p; S <= g; S++) {
417
- const E = d.getCellBounds(S);
418
- for (let M = l; M <= T; M++) {
419
- const j = a.getCellBounds(M);
420
- b.push(
421
- /* @__PURE__ */ _(
422
- h,
486
+ const ee = E(() => {
487
+ const L = [];
488
+ if (i > 0 && m > 0)
489
+ for (let z = I; z <= k; z++) {
490
+ const M = x(z);
491
+ for (let B = y; B <= l; B++) {
492
+ const j = O(B);
493
+ L.push(
494
+ /* @__PURE__ */ Z(
495
+ g,
423
496
  {
424
- ...I,
425
- columnIndex: M,
426
- key: `${S}-${M}`,
427
- rowIndex: S,
497
+ ...w,
498
+ columnIndex: B,
499
+ key: `${z}-${B}`,
500
+ rowIndex: z,
428
501
  style: {
429
502
  position: "absolute",
430
503
  left: 0,
431
- transform: `translate(${j.scrollOffset}px, ${E.scrollOffset}px)`,
432
- height: E.size,
504
+ transform: `translate(${j.scrollOffset}px, ${M.scrollOffset}px)`,
505
+ height: m > 1 ? M.size : "100%",
433
506
  width: j.size
434
507
  }
435
508
  }
@@ -437,175 +510,179 @@ function nt({
437
510
  );
438
511
  }
439
512
  }
440
- return b;
513
+ return L;
441
514
  }, [
442
- h,
443
- I,
444
- r,
515
+ g,
516
+ w,
517
+ i,
518
+ y,
445
519
  l,
446
- T,
447
- a,
448
520
  O,
449
- p,
450
- g,
451
- d
521
+ x,
522
+ m,
523
+ I,
524
+ k
452
525
  ]);
453
- return /* @__PURE__ */ R(
526
+ return /* @__PURE__ */ U(
454
527
  "div",
455
528
  {
456
529
  role: "grid",
457
- ...w,
458
- className: n,
459
- onScroll: (b) => {
460
- a.onScroll(), d.onScroll(), m(b);
461
- },
462
- ref: P,
530
+ ...a,
531
+ className: s,
532
+ ref: p,
463
533
  style: {
534
+ width: "100%",
535
+ height: "100%",
464
536
  ...v,
465
537
  maxHeight: "100%",
466
538
  maxWidth: "100%",
467
539
  flexGrow: 1,
468
540
  overflow: "auto"
469
541
  },
470
- children: /* @__PURE__ */ R(
542
+ children: /* @__PURE__ */ U(
471
543
  "div",
472
544
  {
473
- className: n,
545
+ className: s,
474
546
  style: {
475
547
  position: "relative",
476
- height: d?.getEstimatedHeight(),
477
- width: a?.getEstimatedHeight()
548
+ height: R(),
549
+ width: T()
478
550
  },
479
- children: k
551
+ children: ee
480
552
  }
481
553
  )
482
554
  }
483
555
  );
484
556
  }
485
- const lt = L, it = W;
486
- function ct({
487
- className: t,
488
- defaultHeight: s = 0,
489
- listRef: n,
490
- onResize: r,
491
- onRowsRendered: e,
492
- onScroll: f = J,
493
- overscanCount: i = 3,
494
- rowComponent: c,
495
- rowCount: o,
496
- rowHeight: u,
497
- rowProps: m,
498
- style: z,
499
- ...O
557
+ const de = H, ue = V;
558
+ function he({
559
+ className: e,
560
+ defaultHeight: t = 0,
561
+ listRef: s,
562
+ onResize: i,
563
+ onRowsRendered: o,
564
+ overscanCount: f = 3,
565
+ rowComponent: n,
566
+ rowCount: c,
567
+ rowHeight: r,
568
+ rowProps: d,
569
+ style: h,
570
+ ...m
500
571
  }) {
501
- const x = C(m), v = H(
502
- () => q(c, D),
503
- [c]
504
- ), [w, I] = L(null), {
505
- getCellBounds: h,
506
- getEstimatedHeight: y,
507
- onScroll: P,
508
- scrollToIndex: a,
509
- startIndex: d,
510
- stopIndex: l
511
- } = B({
512
- containerElement: w,
513
- defaultContainerSize: s,
572
+ const b = N(d), v = E(
573
+ () => Q(n, C),
574
+ [n]
575
+ ), [a, w] = H(null), {
576
+ getCellBounds: g,
577
+ getEstimatedSize: u,
578
+ scrollToIndex: p,
579
+ startIndex: O,
580
+ stopIndex: T
581
+ } = q({
582
+ containerElement: a,
583
+ defaultContainerSize: t,
514
584
  direction: "vertical",
515
- itemCount: o,
516
- itemProps: x,
517
- itemSize: u,
518
- onResize: r,
519
- overscanCount: i
585
+ itemCount: c,
586
+ itemProps: b,
587
+ itemSize: r,
588
+ onResize: i,
589
+ overscanCount: f
520
590
  });
521
- A(
522
- n,
591
+ X(
592
+ s,
523
593
  () => ({
524
594
  get element() {
525
- return w;
595
+ return a;
526
596
  },
527
597
  scrollToRow({
528
- align: p = "auto",
529
- behavior: g = "auto",
530
- index: k
598
+ align: S = "auto",
599
+ behavior: l = "auto",
600
+ index: x
531
601
  }) {
532
- a({
533
- align: p,
534
- behavior: g,
535
- containerScrollOffset: w?.scrollTop ?? 0,
536
- index: k
602
+ p({
603
+ align: S,
604
+ behavior: l,
605
+ containerScrollOffset: a?.scrollTop ?? 0,
606
+ index: x
537
607
  });
538
608
  }
539
609
  }),
540
- [w, a]
541
- ), U(() => {
542
- d >= 0 && l >= 0 && e && e({
543
- startIndex: d,
544
- stopIndex: l
610
+ [a, p]
611
+ ), A(() => {
612
+ O >= 0 && T >= 0 && o && o({
613
+ startIndex: O,
614
+ stopIndex: T
545
615
  });
546
- }, [e, d, l]);
547
- const T = H(() => {
548
- const p = [];
549
- if (o > 0)
550
- for (let g = d; g <= l; g++) {
551
- const k = h(g);
552
- p.push(
553
- /* @__PURE__ */ _(
616
+ }, [o, O, T]);
617
+ const y = E(() => {
618
+ const S = [];
619
+ if (c > 0)
620
+ for (let l = O; l <= T; l++) {
621
+ const x = g(l);
622
+ S.push(
623
+ /* @__PURE__ */ Z(
554
624
  v,
555
625
  {
556
- ...x,
557
- key: g,
558
- index: g,
626
+ ...b,
627
+ key: l,
628
+ index: l,
559
629
  style: {
560
630
  position: "absolute",
561
631
  left: 0,
562
- transform: `translateY(${k.scrollOffset}px)`,
563
- height: k.size,
632
+ transform: `translateY(${x.scrollOffset}px)`,
633
+ height: x.size,
564
634
  width: "100%"
565
635
  }
566
636
  }
567
637
  )
568
638
  );
569
639
  }
570
- return p;
571
- }, [v, h, o, x, d, l]);
572
- return /* @__PURE__ */ R(
640
+ return S;
641
+ }, [v, g, c, b, O, T]);
642
+ return /* @__PURE__ */ U(
573
643
  "div",
574
644
  {
575
645
  role: "list",
576
- ...O,
577
- className: t,
578
- onScroll: (p) => {
579
- P(), f(p);
580
- },
581
- ref: I,
646
+ ...m,
647
+ className: e,
648
+ ref: w,
582
649
  style: {
583
- ...z,
650
+ ...h,
584
651
  maxHeight: "100%",
585
652
  flexGrow: 1,
586
653
  overflowY: "auto"
587
654
  },
588
- children: /* @__PURE__ */ R(
655
+ children: /* @__PURE__ */ U(
589
656
  "div",
590
657
  {
591
- className: t,
658
+ className: e,
592
659
  style: {
593
- height: y(),
660
+ height: u(),
594
661
  position: "relative",
595
662
  width: "100%"
596
663
  },
597
- children: T
664
+ children: y
598
665
  }
599
666
  )
600
667
  }
601
668
  );
602
669
  }
603
- const ft = L, ut = W;
670
+ const ae = H, ge = V;
671
+ let Y = -1;
672
+ function pe(e = !1) {
673
+ if (Y === -1 || e) {
674
+ const t = document.createElement("div"), s = t.style;
675
+ s.width = "50px", s.height = "50px", s.overflow = "scroll", document.body.appendChild(t), Y = t.offsetWidth - t.clientWidth, document.body.removeChild(t);
676
+ }
677
+ return Y;
678
+ }
604
679
  export {
605
- nt as Grid,
606
- ct as List,
607
- lt as useGridCallbackRef,
608
- it as useGridRef,
609
- ft as useListCallbackRef,
610
- ut as useListRef
680
+ fe as Grid,
681
+ he as List,
682
+ pe as getScrollbarSize,
683
+ de as useGridCallbackRef,
684
+ ue as useGridRef,
685
+ ae as useListCallbackRef,
686
+ ge as useListRef
611
687
  };
688
+ //# sourceMappingURL=react-window.js.map