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

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