react-virtuoso 2.8.0-alpha.4 → 2.8.2

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.
Files changed (37) hide show
  1. package/dist/List.d.ts +261 -49
  2. package/dist/Table.d.ts +307 -95
  3. package/dist/alignToBottomSystem.d.ts +22 -2
  4. package/dist/{components/TableVirtuoso.d.ts → components.d.ts} +3443 -1300
  5. package/dist/followOutputSystem.d.ts +18 -2
  6. package/dist/groupedListSystem.d.ts +4 -0
  7. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
  8. package/dist/hooks/useScrollTop.d.ts +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +2 -8
  11. package/dist/index.js.map +1 -0
  12. package/dist/index.m.js +2 -0
  13. package/dist/index.m.js.map +1 -0
  14. package/dist/initialItemCountSystem.d.ts +26 -2
  15. package/dist/initialScrollTopSystem.d.ts +22 -2
  16. package/dist/initialTopMostItemIndexSystem.d.ts +13 -3
  17. package/dist/interfaces.d.ts +7 -1
  18. package/dist/listStateSystem.d.ts +22 -2
  19. package/dist/listSystem.d.ts +234 -22
  20. package/dist/scrollIntoViewSystem.d.ts +30 -2
  21. package/dist/scrollToIndexSystem.d.ts +4 -0
  22. package/dist/sizeSystem.d.ts +2 -0
  23. package/dist/topItemCountSystem.d.ts +22 -2
  24. package/dist/totalListHeightSystem.d.ts +22 -2
  25. package/dist/upwardScrollFixSystem.d.ts +27 -3
  26. package/package.json +5 -16
  27. package/dist/components/CompProps.d.ts +0 -2
  28. package/dist/components/GroupedVirtuoso.d.ts +0 -27
  29. package/dist/components/Virtuoso.d.ts +0 -205
  30. package/dist/components/VirtuosoGrid.d.ts +0 -93
  31. package/dist/components/index.d.ts +0 -4
  32. package/dist/react-virtuoso.cjs.development.js +0 -3871
  33. package/dist/react-virtuoso.cjs.development.js.map +0 -1
  34. package/dist/react-virtuoso.cjs.production.min.js +0 -2
  35. package/dist/react-virtuoso.cjs.production.min.js.map +0 -1
  36. package/dist/react-virtuoso.esm.js +0 -3845
  37. package/dist/react-virtuoso.esm.js.map +0 -1
@@ -1,3871 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactUrx = require('@virtuoso.dev/react-urx');
6
- var u = require('@virtuoso.dev/urx');
7
- var React = require('react');
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n["default"] = e;
24
- return n;
25
- }
26
-
27
- var u__namespace = /*#__PURE__*/_interopNamespace(u);
28
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
-
30
- function _extends() {
31
- _extends = Object.assign || function (target) {
32
- for (var i = 1; i < arguments.length; i++) {
33
- var source = arguments[i];
34
-
35
- for (var key in source) {
36
- if (Object.prototype.hasOwnProperty.call(source, key)) {
37
- target[key] = source[key];
38
- }
39
- }
40
- }
41
-
42
- return target;
43
- };
44
-
45
- return _extends.apply(this, arguments);
46
- }
47
-
48
- function _objectWithoutPropertiesLoose(source, excluded) {
49
- if (source == null) return {};
50
- var target = {};
51
- var sourceKeys = Object.keys(source);
52
- var key, i;
53
-
54
- for (i = 0; i < sourceKeys.length; i++) {
55
- key = sourceKeys[i];
56
- if (excluded.indexOf(key) >= 0) continue;
57
- target[key] = source[key];
58
- }
59
-
60
- return target;
61
- }
62
-
63
- function _unsupportedIterableToArray(o, minLen) {
64
- if (!o) return;
65
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
66
- var n = Object.prototype.toString.call(o).slice(8, -1);
67
- if (n === "Object" && o.constructor) n = o.constructor.name;
68
- if (n === "Map" || n === "Set") return Array.from(o);
69
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
70
- }
71
-
72
- function _arrayLikeToArray(arr, len) {
73
- if (len == null || len > arr.length) len = arr.length;
74
-
75
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
76
-
77
- return arr2;
78
- }
79
-
80
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
81
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
82
- if (it) return (it = it.call(o)).next.bind(it);
83
-
84
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
85
- if (it) o = it;
86
- var i = 0;
87
- return function () {
88
- if (i >= o.length) return {
89
- done: true
90
- };
91
- return {
92
- done: false,
93
- value: o[i++]
94
- };
95
- };
96
- }
97
-
98
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
99
- }
100
-
101
- var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
102
-
103
- var _CONSOLE_METHOD_MAP;
104
- exports.LogLevel = void 0;
105
-
106
- (function (LogLevel) {
107
- LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
108
- LogLevel[LogLevel["INFO"] = 1] = "INFO";
109
- LogLevel[LogLevel["WARN"] = 2] = "WARN";
110
- LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
111
- })(exports.LogLevel || (exports.LogLevel = {}));
112
-
113
- var CONSOLE_METHOD_MAP = (_CONSOLE_METHOD_MAP = {}, _CONSOLE_METHOD_MAP[exports.LogLevel.DEBUG] = 'debug', _CONSOLE_METHOD_MAP[exports.LogLevel.INFO] = 'log', _CONSOLE_METHOD_MAP[exports.LogLevel.WARN] = 'warn', _CONSOLE_METHOD_MAP[exports.LogLevel.ERROR] = 'error', _CONSOLE_METHOD_MAP);
114
-
115
- var getGlobalThis = function getGlobalThis() {
116
- return typeof globalThis === 'undefined' ? window : globalThis;
117
- };
118
-
119
- var loggerSystem = /*#__PURE__*/u__namespace.system(function () {
120
- var logLevel = u__namespace.statefulStream(exports.LogLevel.ERROR);
121
- var log = u__namespace.statefulStream(function (label, message, level) {
122
- var _getGlobalThis$VIRTUO;
123
-
124
- if (level === void 0) {
125
- level = exports.LogLevel.INFO;
126
- }
127
-
128
- var currentLevel = (_getGlobalThis$VIRTUO = getGlobalThis()['VIRTUOSO_LOG_LEVEL']) != null ? _getGlobalThis$VIRTUO : u__namespace.getValue(logLevel);
129
-
130
- if (level >= currentLevel) {
131
- // eslint-disable-next-line no-console
132
- console[CONSOLE_METHOD_MAP[level]]('%creact-virtuoso: %c%s %o', 'color: #0253b3; font-weight: bold', 'color: initial', label, message);
133
- }
134
- });
135
- return {
136
- log: log,
137
- logLevel: logLevel
138
- };
139
- }, [], {
140
- singleton: true
141
- });
142
-
143
- function useSizeWithElRef(callback, enabled) {
144
- if (enabled === void 0) {
145
- enabled = true;
146
- }
147
-
148
- var ref = React.useRef(null);
149
-
150
- var callbackRef = function callbackRef(_el) {
151
- };
152
-
153
- if (typeof ResizeObserver !== 'undefined') {
154
- var observer = new ResizeObserver(function (entries) {
155
- var element = entries[0].target;
156
-
157
- if (element.offsetParent !== null) {
158
- callback(element);
159
- }
160
- });
161
-
162
- callbackRef = function callbackRef(elRef) {
163
- if (elRef && enabled) {
164
- observer.observe(elRef);
165
- ref.current = elRef;
166
- } else {
167
- if (ref.current) {
168
- observer.unobserve(ref.current);
169
- }
170
-
171
- ref.current = null;
172
- }
173
- };
174
- }
175
-
176
- return {
177
- ref: ref,
178
- callbackRef: callbackRef
179
- };
180
- }
181
- function useSize(callback, enabled) {
182
- if (enabled === void 0) {
183
- enabled = true;
184
- }
185
-
186
- return useSizeWithElRef(callback, enabled).callbackRef;
187
- }
188
-
189
- function useChangedListContentsSizes(callback, itemSize, enabled, scrollContainerStateCallback, log, customScrollParent) {
190
- return useSize(function (el) {
191
- var ranges = getChangedChildSizes(el.children, itemSize, 'offsetHeight', log);
192
- var scrollableElement = el.parentElement;
193
-
194
- while (!scrollableElement.dataset['virtuosoScroller']) {
195
- scrollableElement = scrollableElement.parentElement;
196
- }
197
-
198
- var scrollTop = customScrollParent ? customScrollParent.scrollTop : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
199
- scrollableElement.firstElementChild.dataset['viewportType'] === 'window' ? window.pageYOffset || document.documentElement.scrollTop : scrollableElement.scrollTop;
200
- customScrollParent ? scrollContainerStateCallback([Math.max(scrollTop, 0), customScrollParent.scrollHeight]) : scrollContainerStateCallback([Math.max(scrollTop, 0), scrollableElement.scrollHeight]);
201
-
202
- if (ranges !== null) {
203
- callback(ranges);
204
- }
205
- }, enabled);
206
- }
207
-
208
- function getChangedChildSizes(children, itemSize, field, log) {
209
- var length = children.length;
210
-
211
- if (length === 0) {
212
- return null;
213
- }
214
-
215
- var results = [];
216
-
217
- for (var i = 0; i < length; i++) {
218
- var child = children.item(i);
219
-
220
- if (!child || child.dataset.index === undefined) {
221
- continue;
222
- }
223
-
224
- var index = parseInt(child.dataset.index);
225
- var knownSize = parseFloat(child.dataset.knownSize);
226
- var size = itemSize(child, field);
227
-
228
- if (size === 0) {
229
- log('Zero-sized element, this should not happen', {
230
- child: child
231
- }, exports.LogLevel.ERROR);
232
- }
233
-
234
- if (size === knownSize) {
235
- continue;
236
- }
237
-
238
- var lastResult = results[results.length - 1];
239
-
240
- if (results.length === 0 || lastResult.size !== size || lastResult.endIndex !== index - 1) {
241
- results.push({
242
- startIndex: index,
243
- endIndex: index,
244
- size: size
245
- });
246
- } else {
247
- results[results.length - 1].endIndex++;
248
- }
249
- }
250
-
251
- return results;
252
- }
253
-
254
- function correctItemSize(el, dimension) {
255
- return Math.round(el.getBoundingClientRect()[dimension]);
256
- }
257
-
258
- function approximatelyEqual(num1, num2) {
259
- return Math.abs(num1 - num2) < 1.01;
260
- }
261
-
262
- function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback, customScrollParent) {
263
- if (scrollerRefCallback === void 0) {
264
- scrollerRefCallback = u__namespace.noop;
265
- }
266
-
267
- var scrollerRef = React.useRef(null);
268
- var scrollTopTarget = React.useRef(null);
269
- var timeoutRef = React.useRef(null);
270
- var handler = React.useCallback(function (ev) {
271
- var el = ev.target;
272
- var scrollTop = el === window || el === document ? window.pageYOffset || document.documentElement.scrollTop : el.scrollTop;
273
- var scrollHeight = el === window ? document.documentElement.scrollHeight : el.scrollHeight;
274
- scrollContainerStateCallback([Math.max(scrollTop, 0), scrollHeight]);
275
-
276
- if (scrollTopTarget.current !== null) {
277
- if (scrollTop === scrollTopTarget.current || scrollTop <= 0 || scrollTop === el.scrollHeight - correctItemSize(el, 'height')) {
278
- scrollTopTarget.current = null;
279
- smoothScrollTargetReached(true);
280
-
281
- if (timeoutRef.current) {
282
- clearTimeout(timeoutRef.current);
283
- timeoutRef.current = null;
284
- }
285
- }
286
- }
287
- }, [scrollContainerStateCallback, smoothScrollTargetReached]);
288
- React.useEffect(function () {
289
- var localRef = customScrollParent ? customScrollParent : scrollerRef.current;
290
- scrollerRefCallback(customScrollParent ? customScrollParent : scrollerRef.current);
291
- handler({
292
- target: localRef
293
- });
294
- localRef.addEventListener('scroll', handler, {
295
- passive: true
296
- });
297
- return function () {
298
- scrollerRefCallback(null);
299
- localRef.removeEventListener('scroll', handler);
300
- };
301
- }, [scrollerRef, handler, scrollerElement, scrollerRefCallback, customScrollParent]);
302
-
303
- function scrollToCallback(location) {
304
- var scrollerElement = scrollerRef.current;
305
-
306
- if (!scrollerElement || 'offsetHeight' in scrollerElement && scrollerElement.offsetHeight === 0) {
307
- return;
308
- }
309
-
310
- var isSmooth = location.behavior === 'smooth';
311
- var offsetHeight;
312
- var scrollHeight;
313
- var scrollTop;
314
-
315
- if (scrollerElement === window) {
316
- // this is not a mistake
317
- scrollHeight = Math.max(correctItemSize(document.documentElement, 'height'), document.documentElement.scrollHeight);
318
- offsetHeight = window.innerHeight;
319
- scrollTop = document.documentElement.scrollTop;
320
- } else {
321
- scrollHeight = scrollerElement.scrollHeight;
322
- offsetHeight = correctItemSize(scrollerElement, 'height');
323
- scrollTop = scrollerElement.scrollTop;
324
- }
325
-
326
- var maxScrollTop = scrollHeight - offsetHeight;
327
- location.top = Math.ceil(Math.max(Math.min(maxScrollTop, location.top), 0)); // avoid system hanging because the DOM never called back
328
- // with the scrollTop
329
- // scroller is already at this location
330
-
331
- if (approximatelyEqual(offsetHeight, scrollHeight) || location.top === scrollTop) {
332
- scrollContainerStateCallback([scrollTop, scrollHeight]);
333
-
334
- if (isSmooth) {
335
- smoothScrollTargetReached(true);
336
- }
337
-
338
- return;
339
- }
340
-
341
- if (isSmooth) {
342
- scrollTopTarget.current = location.top;
343
-
344
- if (timeoutRef.current) {
345
- clearTimeout(timeoutRef.current);
346
- }
347
-
348
- timeoutRef.current = setTimeout(function () {
349
- timeoutRef.current = null;
350
- scrollTopTarget.current = null;
351
- smoothScrollTargetReached(true);
352
- }, 1000);
353
- } else {
354
- scrollTopTarget.current = null;
355
- }
356
-
357
- scrollerElement.scrollTo(location);
358
- }
359
-
360
- function scrollByCallback(location) {
361
- if (scrollTopTarget.current === null) {
362
- scrollerRef.current.scrollBy(location);
363
- }
364
- }
365
-
366
- return {
367
- scrollerRef: scrollerRef,
368
- scrollByCallback: scrollByCallback,
369
- scrollToCallback: scrollToCallback
370
- };
371
- }
372
-
373
- var domIOSystem = /*#__PURE__*/u__namespace.system(function () {
374
- var scrollContainerState = u__namespace.stream();
375
- var scrollTop = u__namespace.stream();
376
- var deviation = u__namespace.statefulStream(0);
377
- var smoothScrollTargetReached = u__namespace.stream();
378
- var statefulScrollTop = u__namespace.statefulStream(0);
379
- var viewportHeight = u__namespace.stream();
380
- var scrollHeight = u__namespace.stream();
381
- var headerHeight = u__namespace.statefulStream(0);
382
- var footerHeight = u__namespace.statefulStream(0);
383
- var scrollTo = u__namespace.stream();
384
- var scrollBy = u__namespace.stream();
385
- var scrollingInProgress = u__namespace.statefulStream(false);
386
- u__namespace.connect(u__namespace.pipe(scrollContainerState, u__namespace.map(function (_ref) {
387
- var scrollTop = _ref[0];
388
- return scrollTop;
389
- })), scrollTop);
390
- u__namespace.connect(u__namespace.pipe(scrollContainerState, u__namespace.map(function (_ref2) {
391
- var scrollHeight = _ref2[1];
392
- return scrollHeight;
393
- })), scrollHeight);
394
- u__namespace.connect(scrollTop, statefulScrollTop);
395
- return {
396
- // input
397
- scrollContainerState: scrollContainerState,
398
- scrollTop: scrollTop,
399
- viewportHeight: viewportHeight,
400
- headerHeight: headerHeight,
401
- footerHeight: footerHeight,
402
- scrollHeight: scrollHeight,
403
- smoothScrollTargetReached: smoothScrollTargetReached,
404
- // signals
405
- scrollTo: scrollTo,
406
- scrollBy: scrollBy,
407
- // state
408
- statefulScrollTop: statefulScrollTop,
409
- deviation: deviation,
410
- scrollingInProgress: scrollingInProgress
411
- };
412
- }, [], {
413
- singleton: true
414
- });
415
-
416
- var NIL_NODE = {
417
- lvl: 0
418
- };
419
-
420
- function newAANode(k, v, lvl, l, r) {
421
- if (l === void 0) {
422
- l = NIL_NODE;
423
- }
424
-
425
- if (r === void 0) {
426
- r = NIL_NODE;
427
- }
428
-
429
- return {
430
- k: k,
431
- v: v,
432
- lvl: lvl,
433
- l: l,
434
- r: r
435
- };
436
- }
437
-
438
- function empty(node) {
439
- return node === NIL_NODE;
440
- }
441
- function newTree() {
442
- return NIL_NODE;
443
- }
444
- function remove(node, key) {
445
- if (empty(node)) return NIL_NODE;
446
- var k = node.k,
447
- l = node.l,
448
- r = node.r;
449
-
450
- if (key === k) {
451
- if (empty(l)) {
452
- return r;
453
- } else if (empty(r)) {
454
- return l;
455
- } else {
456
- var _last = last(l),
457
- lastKey = _last[0],
458
- lastValue = _last[1];
459
-
460
- return adjust(clone(node, {
461
- k: lastKey,
462
- v: lastValue,
463
- l: deleteLast(l)
464
- }));
465
- }
466
- } else if (key < k) {
467
- return adjust(clone(node, {
468
- l: remove(l, key)
469
- }));
470
- } else {
471
- return adjust(clone(node, {
472
- r: remove(r, key)
473
- }));
474
- }
475
- }
476
- function findMaxKeyValue(node, value, field) {
477
- if (field === void 0) {
478
- field = 'k';
479
- }
480
-
481
- if (empty(node)) {
482
- return [-Infinity, undefined];
483
- }
484
-
485
- if (node[field] === value) {
486
- return [node.k, node.v];
487
- }
488
-
489
- if (node[field] < value) {
490
- var r = findMaxKeyValue(node.r, value, field);
491
-
492
- if (r[0] === -Infinity) {
493
- return [node.k, node.v];
494
- } else {
495
- return r;
496
- }
497
- }
498
-
499
- return findMaxKeyValue(node.l, value, field);
500
- }
501
- function insert(node, k, v) {
502
- if (empty(node)) {
503
- return newAANode(k, v, 1);
504
- }
505
-
506
- if (k === node.k) {
507
- return clone(node, {
508
- k: k,
509
- v: v
510
- });
511
- } else if (k < node.k) {
512
- return rebalance(clone(node, {
513
- l: insert(node.l, k, v)
514
- }));
515
- } else {
516
- return rebalance(clone(node, {
517
- r: insert(node.r, k, v)
518
- }));
519
- }
520
- }
521
- function walkWithin(node, start, end) {
522
- if (empty(node)) {
523
- return [];
524
- }
525
-
526
- var k = node.k,
527
- v = node.v,
528
- l = node.l,
529
- r = node.r;
530
- var result = [];
531
-
532
- if (k > start) {
533
- result = result.concat(walkWithin(l, start, end));
534
- }
535
-
536
- if (k >= start && k <= end) {
537
- result.push({
538
- k: k,
539
- v: v
540
- });
541
- }
542
-
543
- if (k <= end) {
544
- result = result.concat(walkWithin(r, start, end));
545
- }
546
-
547
- return result;
548
- }
549
- function walk(node) {
550
- if (empty(node)) {
551
- return [];
552
- }
553
-
554
- return [].concat(walk(node.l), [{
555
- k: node.k,
556
- v: node.v
557
- }], walk(node.r));
558
- }
559
-
560
- function last(node) {
561
- return empty(node.r) ? [node.k, node.v] : last(node.r);
562
- }
563
-
564
- function deleteLast(node) {
565
- return empty(node.r) ? node.l : adjust(clone(node, {
566
- r: deleteLast(node.r)
567
- }));
568
- }
569
-
570
- function clone(node, args) {
571
- return newAANode(args.k !== undefined ? args.k : node.k, args.v !== undefined ? args.v : node.v, args.lvl !== undefined ? args.lvl : node.lvl, args.l !== undefined ? args.l : node.l, args.r !== undefined ? args.r : node.r);
572
- }
573
-
574
- function isSingle(node) {
575
- return empty(node) || node.lvl > node.r.lvl;
576
- }
577
-
578
- function rebalance(node) {
579
- return split(skew(node));
580
- }
581
-
582
- function adjust(node) {
583
- var l = node.l,
584
- r = node.r,
585
- lvl = node.lvl;
586
-
587
- if (r.lvl >= lvl - 1 && l.lvl >= lvl - 1) {
588
- return node;
589
- } else if (lvl > r.lvl + 1) {
590
- if (isSingle(l)) {
591
- return skew(clone(node, {
592
- lvl: lvl - 1
593
- }));
594
- } else {
595
- if (!empty(l) && !empty(l.r)) {
596
- return clone(l.r, {
597
- l: clone(l, {
598
- r: l.r.l
599
- }),
600
- r: clone(node, {
601
- l: l.r.r,
602
- lvl: lvl - 1
603
- }),
604
- lvl: lvl
605
- });
606
- } else {
607
- throw new Error('Unexpected empty nodes');
608
- }
609
- }
610
- } else {
611
- if (isSingle(node)) {
612
- return split(clone(node, {
613
- lvl: lvl - 1
614
- }));
615
- } else {
616
- if (!empty(r) && !empty(r.l)) {
617
- var rl = r.l;
618
- var rlvl = isSingle(rl) ? r.lvl - 1 : r.lvl;
619
- return clone(rl, {
620
- l: clone(node, {
621
- r: rl.l,
622
- lvl: lvl - 1
623
- }),
624
- r: split(clone(r, {
625
- l: rl.r,
626
- lvl: rlvl
627
- })),
628
- lvl: rl.lvl + 1
629
- });
630
- } else {
631
- throw new Error('Unexpected empty nodes');
632
- }
633
- }
634
- }
635
- }
636
- function rangesWithin(node, startIndex, endIndex) {
637
- if (empty(node)) {
638
- return [];
639
- }
640
-
641
- var adjustedStart = findMaxKeyValue(node, startIndex)[0];
642
- return toRanges(walkWithin(node, adjustedStart, endIndex));
643
- }
644
- function arrayToRanges(items, parser) {
645
- var length = items.length;
646
-
647
- if (length === 0) {
648
- return [];
649
- }
650
-
651
- var _parser = parser(items[0]),
652
- start = _parser.index,
653
- value = _parser.value;
654
-
655
- var result = [];
656
-
657
- for (var i = 1; i < length; i++) {
658
- var _parser2 = parser(items[i]),
659
- nextIndex = _parser2.index,
660
- nextValue = _parser2.value;
661
-
662
- result.push({
663
- start: start,
664
- end: nextIndex - 1,
665
- value: value
666
- });
667
- start = nextIndex;
668
- value = nextValue;
669
- }
670
-
671
- result.push({
672
- start: start,
673
- end: Infinity,
674
- value: value
675
- });
676
- return result;
677
- }
678
-
679
- function toRanges(nodes) {
680
- return arrayToRanges(nodes, function (_ref) {
681
- var index = _ref.k,
682
- value = _ref.v;
683
- return {
684
- index: index,
685
- value: value
686
- };
687
- });
688
- }
689
-
690
- function split(node) {
691
- var r = node.r,
692
- lvl = node.lvl;
693
- return !empty(r) && !empty(r.r) && r.lvl === lvl && r.r.lvl === lvl ? clone(r, {
694
- l: clone(node, {
695
- r: r.l
696
- }),
697
- lvl: lvl + 1
698
- }) : node;
699
- }
700
-
701
- function skew(node) {
702
- var l = node.l;
703
- return !empty(l) && l.lvl === node.lvl ? clone(l, {
704
- r: clone(node, {
705
- l: l.r
706
- })
707
- }) : node;
708
- }
709
-
710
- function findIndexOfClosestSmallerOrEqual(items, value, comparator, start) {
711
- if (start === void 0) {
712
- start = 0;
713
- }
714
-
715
- var end = items.length - 1;
716
-
717
- while (start <= end) {
718
- var index = Math.floor((start + end) / 2);
719
- var item = items[index];
720
- var match = comparator(item, value);
721
-
722
- if (match === 0) {
723
- return index;
724
- }
725
-
726
- if (match === -1) {
727
- if (end - start < 2) {
728
- return index - 1;
729
- }
730
-
731
- end = index - 1;
732
- } else {
733
- if (end === start) {
734
- return index;
735
- }
736
-
737
- start = index + 1;
738
- }
739
- }
740
-
741
- throw new Error("Failed binary finding record in array - " + items.join(',') + ", searched for " + value);
742
- }
743
- function findClosestSmallerOrEqual(items, value, comparator) {
744
- return items[findIndexOfClosestSmallerOrEqual(items, value, comparator)];
745
- }
746
- function findRange(items, startValue, endValue, comparator) {
747
- var startIndex = findIndexOfClosestSmallerOrEqual(items, startValue, comparator);
748
- var endIndex = findIndexOfClosestSmallerOrEqual(items, endValue, comparator, startIndex);
749
- return items.slice(startIndex, endIndex + 1);
750
- }
751
-
752
- function rangeIncludes(refRange) {
753
- var size = refRange.size,
754
- startIndex = refRange.startIndex,
755
- endIndex = refRange.endIndex;
756
- return function (range) {
757
- return range.start === startIndex && (range.end === endIndex || range.end === Infinity) && range.value === size;
758
- };
759
- }
760
-
761
- function insertRanges(sizeTree, ranges) {
762
- var syncStart = empty(sizeTree) ? 0 : Infinity;
763
-
764
- for (var _iterator = _createForOfIteratorHelperLoose(ranges), _step; !(_step = _iterator()).done;) {
765
- var range = _step.value;
766
- var size = range.size,
767
- startIndex = range.startIndex,
768
- endIndex = range.endIndex;
769
- syncStart = Math.min(syncStart, startIndex);
770
-
771
- if (empty(sizeTree)) {
772
- sizeTree = insert(sizeTree, 0, size);
773
- continue;
774
- } // extend the range in both directions, so that we can get adjacent neighbours.
775
- // if the previous / next ones have the same value as the one we are about to insert,
776
- // we 'merge' them.
777
-
778
-
779
- var overlappingRanges = rangesWithin(sizeTree, startIndex - 1, endIndex + 1);
780
-
781
- if (overlappingRanges.some(rangeIncludes(range))) {
782
- continue;
783
- }
784
-
785
- var firstPassDone = false;
786
- var shouldInsert = false;
787
-
788
- for (var _iterator2 = _createForOfIteratorHelperLoose(overlappingRanges), _step2; !(_step2 = _iterator2()).done;) {
789
- var _step2$value = _step2.value,
790
- rangeStart = _step2$value.start,
791
- rangeEnd = _step2$value.end,
792
- rangeValue = _step2$value.value;
793
-
794
- // previous range
795
- if (!firstPassDone) {
796
- shouldInsert = rangeValue !== size;
797
- firstPassDone = true;
798
- } else {
799
- // remove the range if it starts within the new range OR if
800
- // it has the same value as it, in order to perform a merge
801
- if (endIndex >= rangeStart || size === rangeValue) {
802
- sizeTree = remove(sizeTree, rangeStart);
803
- }
804
- } // next range
805
-
806
-
807
- if (rangeEnd > endIndex && endIndex >= rangeStart) {
808
- if (rangeValue !== size) {
809
- sizeTree = insert(sizeTree, endIndex + 1, rangeValue);
810
- }
811
- }
812
- }
813
-
814
- if (shouldInsert) {
815
- sizeTree = insert(sizeTree, startIndex, size);
816
- }
817
- }
818
-
819
- return [sizeTree, syncStart];
820
- }
821
- function initialSizeState() {
822
- return {
823
- offsetTree: [],
824
- sizeTree: newTree(),
825
- groupOffsetTree: newTree(),
826
- lastIndex: 0,
827
- lastOffset: 0,
828
- lastSize: 0,
829
- groupIndices: []
830
- };
831
- }
832
- function indexComparator(_ref, index) {
833
- var itemIndex = _ref.index;
834
- return index === itemIndex ? 0 : index < itemIndex ? -1 : 1;
835
- }
836
- function offsetComparator(_ref2, offset) {
837
- var itemOffset = _ref2.offset;
838
- return offset === itemOffset ? 0 : offset < itemOffset ? -1 : 1;
839
- }
840
-
841
- function offsetPointParser(point) {
842
- return {
843
- index: point.index,
844
- value: point
845
- };
846
- }
847
-
848
- function rangesWithinOffsets(tree, startOffset, endOffset, minStartIndex) {
849
- if (minStartIndex === void 0) {
850
- minStartIndex = 0;
851
- }
852
-
853
- if (minStartIndex > 0) {
854
- startOffset = Math.max(startOffset, findClosestSmallerOrEqual(tree, minStartIndex, indexComparator).offset);
855
- }
856
-
857
- return arrayToRanges(findRange(tree, startOffset, endOffset, offsetComparator), offsetPointParser);
858
- }
859
- function sizeStateReducer(state, _ref3) {
860
- var ranges = _ref3[0],
861
- groupIndices = _ref3[1],
862
- log = _ref3[2];
863
-
864
- if (ranges.length > 0) {
865
- log('received item sizes', ranges, exports.LogLevel.DEBUG);
866
- }
867
-
868
- var sizeTree = state.sizeTree;
869
- var offsetTree = state.offsetTree;
870
- var newSizeTree = sizeTree;
871
- var syncStart = 0; // We receive probe item results from a group probe,
872
- // which should always pass an item and a group
873
- // the results contain two ranges, which we consider to mean that groups and items have different size
874
-
875
- if (groupIndices.length > 0 && empty(sizeTree) && ranges.length === 2) {
876
- var groupSize = ranges[0].size;
877
- var itemSize = ranges[1].size;
878
- newSizeTree = groupIndices.reduce(function (tree, groupIndex) {
879
- return insert(insert(tree, groupIndex, groupSize), groupIndex + 1, itemSize);
880
- }, newSizeTree);
881
- } else {
882
-
883
- var _insertRanges = insertRanges(newSizeTree, ranges);
884
-
885
- newSizeTree = _insertRanges[0];
886
- syncStart = _insertRanges[1];
887
- }
888
-
889
- if (newSizeTree === sizeTree) {
890
- return state;
891
- }
892
-
893
- var prevIndex = 0;
894
- var prevSize = 0;
895
- var prevAOffset = 0;
896
- var startAIndex = 0;
897
-
898
- if (syncStart !== 0) {
899
- startAIndex = findIndexOfClosestSmallerOrEqual(offsetTree, syncStart - 1, indexComparator);
900
- var offsetInfo = offsetTree[startAIndex];
901
- prevAOffset = offsetInfo.offset;
902
- var kv = findMaxKeyValue(newSizeTree, syncStart - 1);
903
- prevIndex = kv[0];
904
- prevSize = kv[1];
905
-
906
- if (offsetTree.length && offsetTree[startAIndex].size === findMaxKeyValue(newSizeTree, syncStart)[1]) {
907
- startAIndex -= 1;
908
- }
909
-
910
- offsetTree = offsetTree.slice(0, startAIndex + 1);
911
- } else {
912
- offsetTree = [];
913
- }
914
-
915
- for (var _iterator3 = _createForOfIteratorHelperLoose(rangesWithin(newSizeTree, syncStart, Infinity)), _step3; !(_step3 = _iterator3()).done;) {
916
- var _step3$value = _step3.value,
917
- startIndex = _step3$value.start,
918
- value = _step3$value.value;
919
- var aOffset = (startIndex - prevIndex) * prevSize + prevAOffset;
920
- offsetTree.push({
921
- offset: aOffset,
922
- size: value,
923
- index: startIndex
924
- });
925
- prevIndex = startIndex;
926
- prevAOffset = aOffset;
927
- prevSize = value;
928
- }
929
-
930
- return {
931
- sizeTree: newSizeTree,
932
- offsetTree: offsetTree,
933
- groupOffsetTree: groupIndices.reduce(function (tree, index) {
934
- return insert(tree, index, offsetOf(index, offsetTree));
935
- }, newTree()),
936
- lastIndex: prevIndex,
937
- lastOffset: prevAOffset,
938
- lastSize: prevSize,
939
- groupIndices: groupIndices
940
- };
941
- }
942
- function offsetOf(index, tree) {
943
- if (tree.length === 0) {
944
- return 0;
945
- }
946
-
947
- var _arrayBinarySearch$fi = findClosestSmallerOrEqual(tree, index, indexComparator),
948
- offset = _arrayBinarySearch$fi.offset,
949
- startIndex = _arrayBinarySearch$fi.index,
950
- size = _arrayBinarySearch$fi.size;
951
-
952
- return size * (index - startIndex) + offset;
953
- }
954
- function originalIndexFromItemIndex(itemIndex, sizes) {
955
- if (!hasGroups(sizes)) {
956
- return itemIndex;
957
- }
958
-
959
- var groupOffset = 0;
960
-
961
- while (sizes.groupIndices[groupOffset] <= itemIndex + groupOffset) {
962
- groupOffset++;
963
- } // we find the real item index, offsetting it by the number of group items before it
964
-
965
-
966
- return itemIndex + groupOffset;
967
- }
968
- function hasGroups(sizes) {
969
- return !empty(sizes.groupOffsetTree);
970
- }
971
- var SIZE_MAP = {
972
- offsetHeight: 'height',
973
- offsetWidth: 'width'
974
- };
975
- var sizeSystem = /*#__PURE__*/u__namespace.system(function (_ref4) {
976
- var log = _ref4[0].log;
977
- var sizeRanges = u__namespace.stream();
978
- var totalCount = u__namespace.stream();
979
- var statefulTotalCount = u__namespace.statefulStreamFromEmitter(totalCount, 0);
980
- var unshiftWith = u__namespace.stream();
981
- var firstItemIndex = u__namespace.statefulStream(0);
982
- var groupIndices = u__namespace.statefulStream([]);
983
- var fixedItemSize = u__namespace.statefulStream(undefined);
984
- var defaultItemSize = u__namespace.statefulStream(undefined);
985
- var itemSize = u__namespace.statefulStream(function (el, field) {
986
- return correctItemSize(el, SIZE_MAP[field]);
987
- });
988
- var data = u__namespace.statefulStream(undefined);
989
- var initial = initialSizeState();
990
- var sizes = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(sizeRanges, u__namespace.withLatestFrom(groupIndices, log), u__namespace.scan(sizeStateReducer, initial), u__namespace.distinctUntilChanged()), initial);
991
- u__namespace.connect(u__namespace.pipe(groupIndices, u__namespace.filter(function (indexes) {
992
- return indexes.length > 0;
993
- }), u__namespace.withLatestFrom(sizes), u__namespace.map(function (_ref5) {
994
- var groupIndices = _ref5[0],
995
- sizes = _ref5[1];
996
- var groupOffsetTree = groupIndices.reduce(function (tree, index, idx) {
997
- return insert(tree, index, offsetOf(index, sizes.offsetTree) || idx);
998
- }, newTree());
999
- return _extends({}, sizes, {
1000
- groupIndices: groupIndices,
1001
- groupOffsetTree: groupOffsetTree
1002
- });
1003
- })), sizes); // decreasing the total count should remove any existing entries
1004
- // beyond the last index - do this by publishing the default size as a range over them.
1005
-
1006
- u__namespace.connect(u__namespace.pipe(totalCount, u__namespace.withLatestFrom(sizes), u__namespace.filter(function (_ref6) {
1007
- var totalCount = _ref6[0],
1008
- lastIndex = _ref6[1].lastIndex;
1009
- return totalCount < lastIndex;
1010
- }), u__namespace.map(function (_ref7) {
1011
- var totalCount = _ref7[0],
1012
- _ref7$ = _ref7[1],
1013
- lastIndex = _ref7$.lastIndex,
1014
- lastSize = _ref7$.lastSize;
1015
- return [{
1016
- startIndex: totalCount,
1017
- endIndex: lastIndex,
1018
- size: lastSize
1019
- }];
1020
- })), sizeRanges);
1021
- u__namespace.connect(fixedItemSize, defaultItemSize);
1022
- var trackItemSizes = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(fixedItemSize, u__namespace.map(function (size) {
1023
- return size === undefined;
1024
- })), true);
1025
- u__namespace.connect(u__namespace.pipe(defaultItemSize, u__namespace.filter(function (value) {
1026
- return value !== undefined && empty(u__namespace.getValue(sizes).sizeTree);
1027
- }), u__namespace.map(function (size) {
1028
- return [{
1029
- startIndex: 0,
1030
- endIndex: 0,
1031
- size: size
1032
- }];
1033
- })), sizeRanges);
1034
- var listRefresh = u__namespace.streamFromEmitter(u__namespace.pipe(sizeRanges, u__namespace.withLatestFrom(sizes), u__namespace.scan(function (_ref8, _ref9) {
1035
- var oldSizes = _ref8.sizes;
1036
- var newSizes = _ref9[1];
1037
- return {
1038
- changed: newSizes !== oldSizes,
1039
- sizes: newSizes
1040
- };
1041
- }, {
1042
- changed: false,
1043
- sizes: initial
1044
- }), u__namespace.map(function (value) {
1045
- return value.changed;
1046
- })));
1047
- u__namespace.connect(u__namespace.pipe(firstItemIndex, u__namespace.scan(function (prev, next) {
1048
- return {
1049
- diff: prev.prev - next,
1050
- prev: next
1051
- };
1052
- }, {
1053
- diff: 0,
1054
- prev: 0
1055
- }), u__namespace.map(function (val) {
1056
- return val.diff;
1057
- }), u__namespace.filter(function (value) {
1058
- return value > 0;
1059
- })), unshiftWith);
1060
- u__namespace.subscribe(u__namespace.pipe(firstItemIndex, u__namespace.withLatestFrom(log)), function (_ref10) {
1061
- var index = _ref10[0],
1062
- log = _ref10[1];
1063
-
1064
- if (index < 0) {
1065
- log("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value", {
1066
- firstItemIndex: firstItemIndex
1067
- }, exports.LogLevel.ERROR);
1068
- }
1069
- }); // Capture the current list top item before the sizes get refreshed
1070
-
1071
- var beforeUnshiftWith = u__namespace.streamFromEmitter(unshiftWith);
1072
- u__namespace.connect(u__namespace.pipe(unshiftWith, u__namespace.withLatestFrom(sizes), u__namespace.map(function (_ref11) {
1073
- var unshiftWith = _ref11[0],
1074
- sizes = _ref11[1];
1075
-
1076
- if (sizes.groupIndices.length > 0) {
1077
- throw new Error('Virtuoso: prepending items does not work with groups');
1078
- }
1079
-
1080
- return walk(sizes.sizeTree).reduce(function (acc, _ref12) {
1081
- var index = _ref12.k,
1082
- size = _ref12.v;
1083
- return {
1084
- ranges: [].concat(acc.ranges, [{
1085
- startIndex: acc.prevIndex,
1086
- endIndex: index + unshiftWith - 1,
1087
- size: acc.prevSize
1088
- }]),
1089
- prevIndex: index + unshiftWith,
1090
- prevSize: size
1091
- };
1092
- }, {
1093
- ranges: [],
1094
- prevIndex: 0,
1095
- prevSize: sizes.lastSize
1096
- }).ranges;
1097
- })), sizeRanges);
1098
- return {
1099
- // input
1100
- data: data,
1101
- totalCount: totalCount,
1102
- sizeRanges: sizeRanges,
1103
- groupIndices: groupIndices,
1104
- defaultItemSize: defaultItemSize,
1105
- fixedItemSize: fixedItemSize,
1106
- unshiftWith: unshiftWith,
1107
- beforeUnshiftWith: beforeUnshiftWith,
1108
- firstItemIndex: firstItemIndex,
1109
- // output
1110
- sizes: sizes,
1111
- listRefresh: listRefresh,
1112
- statefulTotalCount: statefulTotalCount,
1113
- trackItemSizes: trackItemSizes,
1114
- itemSize: itemSize
1115
- };
1116
- }, /*#__PURE__*/u__namespace.tup(loggerSystem), {
1117
- singleton: true
1118
- });
1119
-
1120
- /* eslint-disable @typescript-eslint/no-unsafe-call */
1121
- var SUPPORTS_SCROLL_TO_OPTIONS = typeof document !== 'undefined' && 'scrollBehavior' in document.documentElement.style;
1122
- function normalizeIndexLocation(location) {
1123
- var result = typeof location === 'number' ? {
1124
- index: location
1125
- } : location;
1126
-
1127
- if (!result.align) {
1128
- result.align = 'start';
1129
- }
1130
-
1131
- if (!result.behavior || !SUPPORTS_SCROLL_TO_OPTIONS) {
1132
- result.behavior = 'auto';
1133
- }
1134
-
1135
- if (!result.offset) {
1136
- result.offset = 0;
1137
- }
1138
-
1139
- return result;
1140
- }
1141
- var scrollToIndexSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
1142
- var _ref$ = _ref[0],
1143
- sizes = _ref$.sizes,
1144
- totalCount = _ref$.totalCount,
1145
- listRefresh = _ref$.listRefresh,
1146
- _ref$2 = _ref[1],
1147
- scrollingInProgress = _ref$2.scrollingInProgress,
1148
- viewportHeight = _ref$2.viewportHeight,
1149
- scrollTo = _ref$2.scrollTo,
1150
- smoothScrollTargetReached = _ref$2.smoothScrollTargetReached,
1151
- headerHeight = _ref$2.headerHeight,
1152
- footerHeight = _ref$2.footerHeight,
1153
- log = _ref[2].log;
1154
- var scrollToIndex = u__namespace.stream();
1155
- var topListHeight = u__namespace.statefulStream(0);
1156
- var unsubscribeNextListRefresh = null;
1157
- var cleartTimeoutRef = null;
1158
- var unsubscribeListRefresh = null;
1159
-
1160
- function cleanup() {
1161
- if (unsubscribeNextListRefresh) {
1162
- unsubscribeNextListRefresh();
1163
- unsubscribeNextListRefresh = null;
1164
- }
1165
-
1166
- if (unsubscribeListRefresh) {
1167
- unsubscribeListRefresh();
1168
- unsubscribeListRefresh = null;
1169
- }
1170
-
1171
- if (cleartTimeoutRef) {
1172
- clearTimeout(cleartTimeoutRef);
1173
- cleartTimeoutRef = null;
1174
- }
1175
-
1176
- u__namespace.publish(scrollingInProgress, false);
1177
- }
1178
-
1179
- u__namespace.connect(u__namespace.pipe(scrollToIndex, u__namespace.withLatestFrom(sizes, viewportHeight, totalCount, topListHeight, headerHeight, footerHeight, log), u__namespace.map(function (_ref2) {
1180
- var location = _ref2[0],
1181
- sizes = _ref2[1],
1182
- viewportHeight = _ref2[2],
1183
- totalCount = _ref2[3],
1184
- topListHeight = _ref2[4],
1185
- headerHeight = _ref2[5],
1186
- footerHeight = _ref2[6],
1187
- log = _ref2[7];
1188
- var normalLocation = normalizeIndexLocation(location);
1189
- var align = normalLocation.align,
1190
- behavior = normalLocation.behavior,
1191
- offset = normalLocation.offset;
1192
- var lastIndex = totalCount - 1;
1193
- var index = normalLocation.index;
1194
-
1195
- if (index === 'LAST') {
1196
- index = lastIndex;
1197
- }
1198
-
1199
- index = originalIndexFromItemIndex(index, sizes);
1200
- index = Math.max(0, index, Math.min(lastIndex, index));
1201
- var top = offsetOf(index, sizes.offsetTree) + headerHeight;
1202
-
1203
- if (align === 'end') {
1204
- top = top - viewportHeight + findMaxKeyValue(sizes.sizeTree, index)[1];
1205
-
1206
- if (index === lastIndex) {
1207
- top += footerHeight;
1208
- }
1209
- } else if (align === 'center') {
1210
- top = top - viewportHeight / 2 + findMaxKeyValue(sizes.sizeTree, index)[1] / 2;
1211
- } else {
1212
- top -= topListHeight;
1213
- }
1214
-
1215
- if (offset) {
1216
- top += offset;
1217
- }
1218
-
1219
- var retry = function retry(listChanged) {
1220
- cleanup();
1221
-
1222
- if (listChanged) {
1223
- log('retrying to scroll to', {
1224
- location: location
1225
- }, exports.LogLevel.DEBUG);
1226
- u__namespace.publish(scrollToIndex, location);
1227
- } else {
1228
- log('list did not change, scroll successful', {}, exports.LogLevel.DEBUG);
1229
- }
1230
- };
1231
-
1232
- cleanup();
1233
-
1234
- if (behavior === 'smooth') {
1235
- var listChanged = false;
1236
- unsubscribeListRefresh = u__namespace.subscribe(listRefresh, function (changed) {
1237
- listChanged = listChanged || changed;
1238
- });
1239
- unsubscribeNextListRefresh = u__namespace.handleNext(smoothScrollTargetReached, function () {
1240
- retry(listChanged);
1241
- });
1242
- } else {
1243
- unsubscribeNextListRefresh = u__namespace.handleNext(u__namespace.pipe(listRefresh, watchChangesFor(50)), retry);
1244
- } // if the scroll jump is too small, the list won't get rerendered.
1245
- // clean this listener
1246
-
1247
-
1248
- cleartTimeoutRef = setTimeout(function () {
1249
- cleanup();
1250
- }, 1200);
1251
- u__namespace.publish(scrollingInProgress, true);
1252
- log('scrolling from index to', {
1253
- index: index,
1254
- top: top,
1255
- behavior: behavior
1256
- }, exports.LogLevel.DEBUG);
1257
- return {
1258
- top: top,
1259
- behavior: behavior
1260
- };
1261
- })), scrollTo);
1262
- return {
1263
- scrollToIndex: scrollToIndex,
1264
- topListHeight: topListHeight
1265
- };
1266
- }, /*#__PURE__*/u__namespace.tup(sizeSystem, domIOSystem, loggerSystem), {
1267
- singleton: true
1268
- });
1269
-
1270
- function watchChangesFor(limit) {
1271
- return function (done) {
1272
- var timeoutRef = setTimeout(function () {
1273
- done(false);
1274
- }, limit);
1275
- return function (value) {
1276
- if (value) {
1277
- done(true);
1278
- clearTimeout(timeoutRef);
1279
- }
1280
- };
1281
- };
1282
- }
1283
-
1284
- var UP = 'up';
1285
- var DOWN = 'down';
1286
- var NONE$1 = 'none';
1287
- var INITIAL_BOTTOM_STATE = {
1288
- atBottom: false,
1289
- notAtBottomBecause: 'NOT_SHOWING_LAST_ITEM',
1290
- state: {
1291
- offsetBottom: 0,
1292
- scrollTop: 0,
1293
- viewportHeight: 0,
1294
- scrollHeight: 0
1295
- }
1296
- };
1297
- var stateFlagsSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
1298
- var _ref$ = _ref[0],
1299
- scrollContainerState = _ref$.scrollContainerState,
1300
- scrollTop = _ref$.scrollTop,
1301
- viewportHeight = _ref$.viewportHeight,
1302
- headerHeight = _ref$.headerHeight,
1303
- footerHeight = _ref$.footerHeight,
1304
- scrollBy = _ref$.scrollBy;
1305
- var isAtBottom = u__namespace.statefulStream(false);
1306
- var isAtTop = u__namespace.statefulStream(true);
1307
- var atBottomStateChange = u__namespace.stream();
1308
- var atTopStateChange = u__namespace.stream();
1309
- var atBottomThreshold = u__namespace.statefulStream(4); // skip 1 to avoid an initial on/off flick
1310
-
1311
- var isScrolling = u__namespace.streamFromEmitter(u__namespace.pipe(u__namespace.merge(u__namespace.pipe(u__namespace.duc(scrollTop), u__namespace.skip(1), u__namespace.mapTo(true)), u__namespace.pipe(u__namespace.duc(scrollTop), u__namespace.skip(1), u__namespace.mapTo(false), u__namespace.debounceTime(100))), u__namespace.distinctUntilChanged()));
1312
- var isScrollingBy = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(u__namespace.merge(u__namespace.pipe(scrollBy, u__namespace.mapTo(true)), u__namespace.pipe(scrollBy, u__namespace.mapTo(false), u__namespace.debounceTime(200))), u__namespace.distinctUntilChanged()), false); // u.subscribe(isScrollingBy, (isScrollingBy) => console.log({ isScrollingBy }))
1313
-
1314
- u__namespace.connect(u__namespace.pipe(u__namespace.duc(scrollTop), u__namespace.map(function (top) {
1315
- return top === 0;
1316
- }), u__namespace.distinctUntilChanged()), isAtTop);
1317
- u__namespace.connect(isAtTop, atTopStateChange);
1318
- var atBottomState = u__namespace.streamFromEmitter(u__namespace.pipe(u__namespace.combineLatest(scrollContainerState, u__namespace.duc(viewportHeight), u__namespace.duc(headerHeight), u__namespace.duc(footerHeight), u__namespace.duc(atBottomThreshold)), u__namespace.scan(function (current, _ref2) {
1319
- var _ref2$ = _ref2[0],
1320
- scrollTop = _ref2$[0],
1321
- scrollHeight = _ref2$[1],
1322
- viewportHeight = _ref2[1],
1323
- atBottomThreshold = _ref2[4];
1324
- var isAtBottom = scrollTop + viewportHeight - scrollHeight > -atBottomThreshold;
1325
- var state = {
1326
- viewportHeight: viewportHeight,
1327
- scrollTop: scrollTop,
1328
- scrollHeight: scrollHeight
1329
- };
1330
-
1331
- if (isAtBottom) {
1332
- var atBottomBecause;
1333
- var scrollTopDelta;
1334
-
1335
- if (scrollTop > current.state.scrollTop) {
1336
- atBottomBecause = 'SCROLLED_DOWN';
1337
- scrollTopDelta = current.state.scrollTop - scrollTop;
1338
- } else {
1339
- atBottomBecause = 'SIZE_DECREASED';
1340
- scrollTopDelta = current.state.scrollTop - scrollTop || current.scrollTopDelta;
1341
- }
1342
-
1343
- return {
1344
- atBottom: true,
1345
- state: state,
1346
- atBottomBecause: atBottomBecause,
1347
- scrollTopDelta: scrollTopDelta
1348
- };
1349
- }
1350
-
1351
- var notAtBottomBecause;
1352
-
1353
- if (state.scrollHeight > current.state.scrollHeight) {
1354
- notAtBottomBecause = 'SIZE_INCREASED';
1355
- } else if (viewportHeight < current.state.viewportHeight) {
1356
- notAtBottomBecause = 'VIEWPORT_HEIGHT_DECREASING';
1357
- } else if (scrollTop < current.state.scrollTop) {
1358
- notAtBottomBecause = 'SCROLLING_UPWARDS';
1359
- } else {
1360
- notAtBottomBecause = 'NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM';
1361
- }
1362
-
1363
- return {
1364
- atBottom: false,
1365
- notAtBottomBecause: notAtBottomBecause,
1366
- state: state
1367
- };
1368
- }, INITIAL_BOTTOM_STATE), u__namespace.distinctUntilChanged(function (prev, next) {
1369
- return prev && prev.atBottom === next.atBottom;
1370
- })));
1371
- var lastJumpDueToItemResize = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(scrollContainerState, u__namespace.scan(function (current, _ref3) {
1372
- var scrollTop = _ref3[0],
1373
- scrollHeight = _ref3[1];
1374
-
1375
- if (current.scrollHeight !== scrollHeight) {
1376
- if (current.scrollTop !== scrollTop) {
1377
- return {
1378
- scrollHeight: scrollHeight,
1379
- scrollTop: scrollTop,
1380
- jump: current.scrollTop - scrollTop,
1381
- changed: true
1382
- };
1383
- } else {
1384
- return {
1385
- scrollHeight: scrollHeight,
1386
- scrollTop: scrollTop,
1387
- jump: 0,
1388
- changed: true
1389
- };
1390
- }
1391
- } else {
1392
- return {
1393
- scrollTop: scrollTop,
1394
- scrollHeight: scrollHeight,
1395
- jump: 0,
1396
- changed: false
1397
- };
1398
- }
1399
- }, {
1400
- scrollHeight: 0,
1401
- jump: 0,
1402
- scrollTop: 0,
1403
- changed: false
1404
- }), u__namespace.filter(function (value) {
1405
- return value.changed;
1406
- }), u__namespace.map(function (value) {
1407
- return value.jump;
1408
- })), 0);
1409
- u__namespace.connect(u__namespace.pipe(atBottomState, u__namespace.map(function (state) {
1410
- return state.atBottom;
1411
- })), isAtBottom);
1412
- u__namespace.subscribe(isAtBottom, function (value) {
1413
- setTimeout(function () {
1414
- return u__namespace.publish(atBottomStateChange, value);
1415
- });
1416
- });
1417
- var scrollDirection = u__namespace.statefulStream(DOWN);
1418
- u__namespace.subscribe(isAtBottom, function (value) {
1419
- setTimeout(function () {
1420
- u__namespace.publish(atBottomStateChange, value);
1421
- });
1422
- });
1423
- u__namespace.connect(u__namespace.pipe(scrollContainerState, u__namespace.map(function (_ref4) {
1424
- var scrollTop = _ref4[0];
1425
- return scrollTop;
1426
- }), u__namespace.distinctUntilChanged(), u__namespace.scan(function (acc, scrollTop) {
1427
- // if things change while compensating for items, ignore,
1428
- // but store the new scrollTop
1429
- if (u__namespace.getValue(isScrollingBy)) {
1430
- return {
1431
- direction: acc.direction,
1432
- prevScrollTop: scrollTop
1433
- };
1434
- }
1435
-
1436
- return {
1437
- direction: scrollTop < acc.prevScrollTop ? UP : DOWN,
1438
- prevScrollTop: scrollTop
1439
- };
1440
- }, {
1441
- direction: DOWN,
1442
- prevScrollTop: 0
1443
- }), u__namespace.map(function (value) {
1444
- return value.direction;
1445
- })), scrollDirection);
1446
- u__namespace.connect(u__namespace.pipe(scrollContainerState, u__namespace.throttleTime(50), u__namespace.mapTo(NONE$1)), scrollDirection);
1447
- u__namespace.connect(isAtBottom, atBottomStateChange);
1448
- var scrollVelocity = u__namespace.statefulStream(0);
1449
- u__namespace.connect(u__namespace.pipe(isScrolling, u__namespace.filter(function (value) {
1450
- return !value;
1451
- }), u__namespace.mapTo(0)), scrollVelocity);
1452
- u__namespace.connect(u__namespace.pipe(scrollTop, u__namespace.throttleTime(100), u__namespace.withLatestFrom(isScrolling), u__namespace.filter(function (_ref5) {
1453
- var isScrolling = _ref5[1];
1454
- return !!isScrolling;
1455
- }), u__namespace.scan(function (_ref6, _ref7) {
1456
- var prev = _ref6[1];
1457
- var next = _ref7[0];
1458
- return [prev, next];
1459
- }, [0, 0]), u__namespace.map(function (_ref8) {
1460
- var prev = _ref8[0],
1461
- next = _ref8[1];
1462
- return next - prev;
1463
- })), scrollVelocity);
1464
- return {
1465
- isScrolling: isScrolling,
1466
- isAtTop: isAtTop,
1467
- isAtBottom: isAtBottom,
1468
- atBottomState: atBottomState,
1469
- atTopStateChange: atTopStateChange,
1470
- atBottomStateChange: atBottomStateChange,
1471
- scrollDirection: scrollDirection,
1472
- atBottomThreshold: atBottomThreshold,
1473
- scrollVelocity: scrollVelocity,
1474
- lastJumpDueToItemResize: lastJumpDueToItemResize
1475
- };
1476
- }, /*#__PURE__*/u__namespace.tup(domIOSystem));
1477
-
1478
- var propsReadySystem = /*#__PURE__*/u__namespace.system(function (_ref) {
1479
- var log = _ref[0].log;
1480
- var propsReady = u__namespace.statefulStream(false);
1481
- var didMount = u__namespace.streamFromEmitter(u__namespace.pipe(propsReady, u__namespace.filter(function (ready) {
1482
- return ready;
1483
- }), u__namespace.distinctUntilChanged()));
1484
- u__namespace.subscribe(propsReady, function (value) {
1485
- value && u.getValue(log)('props updated', {}, exports.LogLevel.DEBUG);
1486
- });
1487
- return {
1488
- propsReady: propsReady,
1489
- didMount: didMount
1490
- };
1491
- }, /*#__PURE__*/u.tup(loggerSystem), {
1492
- singleton: true
1493
- });
1494
-
1495
- var initialTopMostItemIndexSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
1496
- var _ref$ = _ref[0],
1497
- sizes = _ref$.sizes,
1498
- listRefresh = _ref$.listRefresh,
1499
- defaultItemSize = _ref$.defaultItemSize,
1500
- scrollTop = _ref[1].scrollTop,
1501
- scrollToIndex = _ref[2].scrollToIndex,
1502
- didMount = _ref[3].didMount;
1503
- var scrolledToInitialItem = u__namespace.statefulStream(true);
1504
- var initialTopMostItemIndex = u__namespace.statefulStream(0);
1505
- u__namespace.connect(u__namespace.pipe(didMount, u__namespace.withLatestFrom(initialTopMostItemIndex), u__namespace.filter(function (_ref2) {
1506
- var index = _ref2[1];
1507
- return index !== 0;
1508
- }), u__namespace.mapTo(false)), scrolledToInitialItem);
1509
- u__namespace.subscribe(u__namespace.pipe(u__namespace.combineLatest(listRefresh, didMount), u__namespace.withLatestFrom(scrolledToInitialItem, sizes, defaultItemSize), u__namespace.filter(function (_ref3) {
1510
- var _ref3$ = _ref3[0],
1511
- didMount = _ref3$[1],
1512
- scrolledToInitialItem = _ref3[1],
1513
- sizeTree = _ref3[2].sizeTree,
1514
- defaultItemSize = _ref3[3];
1515
- return didMount && (!empty(sizeTree) || defaultItemSize !== undefined) && !scrolledToInitialItem;
1516
- }), u__namespace.withLatestFrom(initialTopMostItemIndex)), function (_ref4) {
1517
- var initialTopMostItemIndex = _ref4[1];
1518
- setTimeout(function () {
1519
- u__namespace.handleNext(scrollTop, function () {
1520
- u__namespace.publish(scrolledToInitialItem, true);
1521
- });
1522
- u__namespace.publish(scrollToIndex, initialTopMostItemIndex);
1523
- });
1524
- });
1525
- return {
1526
- scrolledToInitialItem: scrolledToInitialItem,
1527
- initialTopMostItemIndex: initialTopMostItemIndex
1528
- };
1529
- }, /*#__PURE__*/u__namespace.tup(sizeSystem, domIOSystem, scrollToIndexSystem, propsReadySystem), {
1530
- singleton: true
1531
- });
1532
-
1533
- /* eslint-disable @typescript-eslint/no-unsafe-call */
1534
-
1535
- function normalizeFollowOutput(follow) {
1536
- if (!follow) {
1537
- return false;
1538
- }
1539
-
1540
- return follow === 'smooth' ? 'smooth' : 'auto';
1541
- }
1542
-
1543
- var behaviorFromFollowOutput = function behaviorFromFollowOutput(follow, isAtBottom) {
1544
- if (typeof follow === 'function') {
1545
- return normalizeFollowOutput(follow(isAtBottom));
1546
- }
1547
-
1548
- return isAtBottom && normalizeFollowOutput(follow);
1549
- };
1550
-
1551
- var followOutputSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
1552
- var _ref$ = _ref[0],
1553
- totalCount = _ref$.totalCount,
1554
- listRefresh = _ref$.listRefresh,
1555
- _ref$2 = _ref[1],
1556
- isAtBottom = _ref$2.isAtBottom,
1557
- atBottomState = _ref$2.atBottomState,
1558
- scrollToIndex = _ref[2].scrollToIndex,
1559
- scrolledToInitialItem = _ref[3].scrolledToInitialItem,
1560
- _ref$3 = _ref[4],
1561
- propsReady = _ref$3.propsReady,
1562
- didMount = _ref$3.didMount,
1563
- log = _ref[5].log,
1564
- scrollingInProgress = _ref[6].scrollingInProgress;
1565
- var followOutput = u__namespace.statefulStream(false);
1566
- var pendingScrollHandle = null;
1567
-
1568
- function scrollToBottom(followOutputBehavior) {
1569
- u__namespace.publish(scrollToIndex, {
1570
- index: 'LAST',
1571
- align: 'end',
1572
- behavior: followOutputBehavior
1573
- });
1574
- }
1575
-
1576
- u__namespace.subscribe(u__namespace.pipe(u__namespace.combineLatest(u__namespace.pipe(u__namespace.duc(totalCount), u__namespace.skip(1)), didMount), u__namespace.withLatestFrom(u__namespace.duc(followOutput), isAtBottom, scrolledToInitialItem, scrollingInProgress), u__namespace.map(function (_ref2) {
1577
- var _ref2$ = _ref2[0],
1578
- totalCount = _ref2$[0],
1579
- didMount = _ref2$[1],
1580
- followOutput = _ref2[1],
1581
- isAtBottom = _ref2[2],
1582
- scrolledToInitialItem = _ref2[3],
1583
- scrollingInProgress = _ref2[4];
1584
- var shouldFollow = didMount && scrolledToInitialItem;
1585
- var followOutputBehavior = 'auto';
1586
-
1587
- if (shouldFollow) {
1588
- // if scrolling to index is in progress,
1589
- // assume that a previous followOutput response is going
1590
- followOutputBehavior = behaviorFromFollowOutput(followOutput, isAtBottom || scrollingInProgress);
1591
- shouldFollow = shouldFollow && !!followOutputBehavior;
1592
- }
1593
-
1594
- return {
1595
- totalCount: totalCount,
1596
- shouldFollow: shouldFollow,
1597
- followOutputBehavior: followOutputBehavior
1598
- };
1599
- }), u__namespace.filter(function (_ref3) {
1600
- var shouldFollow = _ref3.shouldFollow;
1601
- return shouldFollow;
1602
- })), function (_ref4) {
1603
- var totalCount = _ref4.totalCount,
1604
- followOutputBehavior = _ref4.followOutputBehavior;
1605
-
1606
- if (pendingScrollHandle) {
1607
- pendingScrollHandle();
1608
- pendingScrollHandle = null;
1609
- }
1610
-
1611
- pendingScrollHandle = u__namespace.handleNext(listRefresh, function () {
1612
- u__namespace.getValue(log)('following output to ', {
1613
- totalCount: totalCount
1614
- }, exports.LogLevel.DEBUG);
1615
- scrollToBottom(followOutputBehavior);
1616
- pendingScrollHandle = null;
1617
- });
1618
- });
1619
- u__namespace.subscribe(u__namespace.pipe(u__namespace.combineLatest(u__namespace.duc(followOutput), totalCount, propsReady), u__namespace.filter(function (_ref5) {
1620
- var follow = _ref5[0],
1621
- ready = _ref5[2];
1622
- return follow && ready;
1623
- }), u__namespace.scan(function (_ref6, _ref7) {
1624
- var value = _ref6.value;
1625
- var next = _ref7[1];
1626
- return {
1627
- refreshed: value === next,
1628
- value: next
1629
- };
1630
- }, {
1631
- refreshed: false,
1632
- value: 0
1633
- }), u__namespace.filter(function (_ref8) {
1634
- var refreshed = _ref8.refreshed;
1635
- return refreshed;
1636
- }), u__namespace.withLatestFrom(followOutput, totalCount)), function (_ref9) {
1637
- var followOutput = _ref9[1];
1638
- var cancel = u__namespace.handleNext(atBottomState, function (state) {
1639
- if (followOutput && !state.atBottom && state.notAtBottomBecause === 'SIZE_INCREASED' && !pendingScrollHandle) {
1640
- u__namespace.getValue(log)('scrolling to bottom due to increased size', {}, exports.LogLevel.DEBUG);
1641
- scrollToBottom('auto');
1642
- }
1643
- });
1644
- setTimeout(cancel, 100);
1645
- });
1646
- u__namespace.subscribe(u__namespace.combineLatest(u__namespace.duc(followOutput), atBottomState), function (_ref10) {
1647
- var followOutput = _ref10[0],
1648
- state = _ref10[1];
1649
-
1650
- if (followOutput && !state.atBottom && state.notAtBottomBecause === 'VIEWPORT_HEIGHT_DECREASING') {
1651
- scrollToBottom('auto');
1652
- }
1653
- });
1654
- return {
1655
- followOutput: followOutput
1656
- };
1657
- }, /*#__PURE__*/u__namespace.tup(sizeSystem, stateFlagsSystem, scrollToIndexSystem, initialTopMostItemIndexSystem, propsReadySystem, loggerSystem, domIOSystem));
1658
-
1659
- function groupCountsToIndicesAndCount(counts) {
1660
- return counts.reduce(function (acc, groupCount) {
1661
- acc.groupIndices.push(acc.totalCount);
1662
- acc.totalCount += groupCount + 1;
1663
- return acc;
1664
- }, {
1665
- totalCount: 0,
1666
- groupIndices: []
1667
- });
1668
- }
1669
- var groupedListSystem = /*#__PURE__*/u.system(function (_ref) {
1670
- var _ref$ = _ref[0],
1671
- totalCount = _ref$.totalCount,
1672
- groupIndices = _ref$.groupIndices,
1673
- sizes = _ref$.sizes,
1674
- _ref$2 = _ref[1],
1675
- scrollTop = _ref$2.scrollTop,
1676
- headerHeight = _ref$2.headerHeight;
1677
- var groupCounts = u.stream();
1678
- var topItemsIndexes = u.stream();
1679
- var groupIndicesAndCount = u.streamFromEmitter(u.pipe(groupCounts, u.map(groupCountsToIndicesAndCount)));
1680
- u.connect(u.pipe(groupIndicesAndCount, u.map(u.prop('totalCount'))), totalCount);
1681
- u.connect(u.pipe(groupIndicesAndCount, u.map(u.prop('groupIndices'))), groupIndices);
1682
- u.connect(u.pipe(u.combineLatest(scrollTop, sizes, headerHeight), u.filter(function (_ref2) {
1683
- var sizes = _ref2[1];
1684
- return hasGroups(sizes);
1685
- }), u.map(function (_ref3) {
1686
- var scrollTop = _ref3[0],
1687
- state = _ref3[1],
1688
- headerHeight = _ref3[2];
1689
- return findMaxKeyValue(state.groupOffsetTree, Math.max(scrollTop - headerHeight, 0), 'v')[0];
1690
- }), u.distinctUntilChanged(), u.map(function (index) {
1691
- return [index];
1692
- })), topItemsIndexes);
1693
- return {
1694
- groupCounts: groupCounts,
1695
- topItemsIndexes: topItemsIndexes
1696
- };
1697
- }, /*#__PURE__*/u.tup(sizeSystem, domIOSystem));
1698
-
1699
- function tupleComparator(prev, current) {
1700
- return !!(prev && prev[0] === current[0] && prev[1] === current[1]);
1701
- }
1702
- function rangeComparator(prev, next) {
1703
- return !!(prev && prev.startIndex === next.startIndex && prev.endIndex === next.endIndex);
1704
- }
1705
-
1706
- var TOP = 'top';
1707
- var BOTTOM = 'bottom';
1708
- var NONE = 'none';
1709
- function getOverscan(overscan, end, direction) {
1710
- if (typeof overscan === 'number') {
1711
- return direction === UP && end === TOP || direction === DOWN && end === BOTTOM ? overscan : 0;
1712
- } else {
1713
- if (direction === UP) {
1714
- return end === TOP ? overscan.main : overscan.reverse;
1715
- } else {
1716
- return end === BOTTOM ? overscan.main : overscan.reverse;
1717
- }
1718
- }
1719
- }
1720
-
1721
- function getViewportIncrease(value, end) {
1722
- return typeof value === 'number' ? value : value[end] || 0;
1723
- }
1724
-
1725
- var sizeRangeSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
1726
- var _ref$ = _ref[0],
1727
- scrollTop = _ref$.scrollTop,
1728
- viewportHeight = _ref$.viewportHeight,
1729
- deviation = _ref$.deviation,
1730
- headerHeight = _ref$.headerHeight;
1731
- var listBoundary = u__namespace.stream();
1732
- var topListHeight = u__namespace.statefulStream(0);
1733
- var fixedHeaderHeight = u__namespace.statefulStream(0);
1734
- var increaseViewportBy = u__namespace.statefulStream(0);
1735
- var overscan = u__namespace.statefulStream(0);
1736
- var visibleRange = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(u__namespace.combineLatest(u__namespace.duc(scrollTop), u__namespace.duc(viewportHeight), u__namespace.duc(headerHeight), u__namespace.duc(listBoundary, tupleComparator), u__namespace.duc(overscan), u__namespace.duc(topListHeight), u__namespace.duc(fixedHeaderHeight), u__namespace.duc(deviation), u__namespace.duc(increaseViewportBy)), u__namespace.map(function (_ref2) {
1737
- var scrollTop = _ref2[0],
1738
- viewportHeight = _ref2[1],
1739
- headerHeight = _ref2[2],
1740
- _ref2$ = _ref2[3],
1741
- listTop = _ref2$[0],
1742
- listBottom = _ref2$[1],
1743
- overscan = _ref2[4],
1744
- topListHeight = _ref2[5],
1745
- fixedHeaderHeight = _ref2[6],
1746
- deviation = _ref2[7],
1747
- increaseViewportBy = _ref2[8];
1748
- var top = scrollTop - deviation;
1749
- var stickyHeaderHeight = topListHeight + fixedHeaderHeight;
1750
- var headerVisible = Math.max(headerHeight - top, 0);
1751
- var direction = NONE;
1752
- var topViewportAddition = getViewportIncrease(increaseViewportBy, TOP);
1753
- var bottomViewportAddition = getViewportIncrease(increaseViewportBy, BOTTOM);
1754
- listTop -= deviation;
1755
- listTop += headerHeight;
1756
- listBottom += headerHeight;
1757
- listBottom -= deviation;
1758
-
1759
- if (listTop > scrollTop + stickyHeaderHeight - topViewportAddition) {
1760
- direction = UP;
1761
- }
1762
-
1763
- if (listBottom < scrollTop - headerVisible + viewportHeight + bottomViewportAddition) {
1764
- direction = DOWN;
1765
- }
1766
-
1767
- if (direction !== NONE) {
1768
- return [Math.max(top - headerHeight - getOverscan(overscan, TOP, direction) - topViewportAddition, 0), top - headerVisible - fixedHeaderHeight + viewportHeight + getOverscan(overscan, BOTTOM, direction) + bottomViewportAddition];
1769
- }
1770
-
1771
- return null;
1772
- }), u__namespace.filter(function (value) {
1773
- return value != null;
1774
- }), u__namespace.distinctUntilChanged(tupleComparator)), [0, 0]);
1775
- return {
1776
- // input
1777
- listBoundary: listBoundary,
1778
- overscan: overscan,
1779
- topListHeight: topListHeight,
1780
- fixedHeaderHeight: fixedHeaderHeight,
1781
- increaseViewportBy: increaseViewportBy,
1782
- // output
1783
- visibleRange: visibleRange
1784
- };
1785
- }, /*#__PURE__*/u__namespace.tup(domIOSystem), {
1786
- singleton: true
1787
- });
1788
-
1789
- function probeItemSet(index, sizes, data) {
1790
- if (hasGroups(sizes)) {
1791
- var itemIndex = originalIndexFromItemIndex(index, sizes);
1792
- var groupIndex = findMaxKeyValue(sizes.groupOffsetTree, itemIndex)[0];
1793
- return [{
1794
- index: groupIndex,
1795
- size: 0,
1796
- offset: 0
1797
- }, {
1798
- index: itemIndex,
1799
- size: 0,
1800
- offset: 0,
1801
- data: data && data[0]
1802
- }];
1803
- }
1804
-
1805
- return [{
1806
- index: index,
1807
- size: 0,
1808
- offset: 0,
1809
- data: data && data[0]
1810
- }];
1811
- }
1812
-
1813
- var EMPTY_LIST_STATE = {
1814
- items: [],
1815
- topItems: [],
1816
- offsetTop: 0,
1817
- offsetBottom: 0,
1818
- top: 0,
1819
- bottom: 0,
1820
- topListHeight: 0,
1821
- totalCount: 0
1822
- };
1823
-
1824
- function transposeItems(items, sizes, firstItemIndex) {
1825
- if (items.length === 0) {
1826
- return [];
1827
- }
1828
-
1829
- if (!hasGroups(sizes)) {
1830
- return items.map(function (item) {
1831
- return _extends({}, item, {
1832
- index: item.index + firstItemIndex,
1833
- originalIndex: item.index
1834
- });
1835
- });
1836
- }
1837
-
1838
- var startIndex = items[0].index;
1839
- var endIndex = items[items.length - 1].index;
1840
- var transposedItems = [];
1841
- var groupRanges = rangesWithin(sizes.groupOffsetTree, startIndex, endIndex);
1842
- var currentRange = undefined;
1843
- var currentGroupIndex = 0;
1844
-
1845
- for (var _iterator = _createForOfIteratorHelperLoose(items), _step; !(_step = _iterator()).done;) {
1846
- var item = _step.value;
1847
-
1848
- if (!currentRange || currentRange.end < item.index) {
1849
- currentRange = groupRanges.shift();
1850
- currentGroupIndex = sizes.groupIndices.indexOf(currentRange.start);
1851
- }
1852
-
1853
- var transposedItem = void 0;
1854
-
1855
- if (item.index === currentRange.start) {
1856
- transposedItem = {
1857
- type: 'group',
1858
- index: currentGroupIndex
1859
- };
1860
- } else {
1861
- transposedItem = {
1862
- index: item.index - (currentGroupIndex + 1) + firstItemIndex,
1863
- groupIndex: currentGroupIndex
1864
- };
1865
- }
1866
-
1867
- transposedItems.push(_extends({}, transposedItem, {
1868
- size: item.size,
1869
- offset: item.offset,
1870
- originalIndex: item.index,
1871
- data: item.data
1872
- }));
1873
- }
1874
-
1875
- return transposedItems;
1876
- }
1877
-
1878
- function buildListState(items, topItems, totalCount, sizes, firstItemIndex) {
1879
- var lastSize = sizes.lastSize,
1880
- lastOffset = sizes.lastOffset,
1881
- lastIndex = sizes.lastIndex;
1882
- var offsetTop = 0;
1883
- var bottom = 0;
1884
-
1885
- if (items.length > 0) {
1886
- offsetTop = items[0].offset;
1887
- var lastItem = items[items.length - 1];
1888
- bottom = lastItem.offset + lastItem.size;
1889
- }
1890
-
1891
- var total = lastOffset + (totalCount - lastIndex) * lastSize;
1892
- var top = offsetTop;
1893
- var offsetBottom = total - bottom;
1894
- return {
1895
- items: transposeItems(items, sizes, firstItemIndex),
1896
- topItems: transposeItems(topItems, sizes, firstItemIndex),
1897
- topListHeight: topItems.reduce(function (height, item) {
1898
- return item.size + height;
1899
- }, 0),
1900
- offsetTop: offsetTop,
1901
- offsetBottom: offsetBottom,
1902
- top: top,
1903
- bottom: bottom,
1904
- totalCount: totalCount
1905
- };
1906
- }
1907
- var listStateSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
1908
- var _ref$ = _ref[0],
1909
- sizes = _ref$.sizes,
1910
- totalCount = _ref$.totalCount,
1911
- data = _ref$.data,
1912
- firstItemIndex = _ref$.firstItemIndex,
1913
- groupedListSystem = _ref[1],
1914
- _ref$2 = _ref[2],
1915
- visibleRange = _ref$2.visibleRange,
1916
- listBoundary = _ref$2.listBoundary,
1917
- rangeTopListHeight = _ref$2.topListHeight,
1918
- _ref$3 = _ref[3],
1919
- scrolledToInitialItem = _ref$3.scrolledToInitialItem,
1920
- initialTopMostItemIndex = _ref$3.initialTopMostItemIndex,
1921
- topListHeight = _ref[4].topListHeight,
1922
- stateFlags = _ref[5],
1923
- didMount = _ref[6].didMount;
1924
- var topItemsIndexes = u__namespace.statefulStream([]);
1925
- var itemsRendered = u__namespace.stream();
1926
- u__namespace.connect(groupedListSystem.topItemsIndexes, topItemsIndexes);
1927
- var listState = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(u__namespace.combineLatest(didMount, u__namespace.duc(visibleRange), u__namespace.duc(totalCount), u__namespace.duc(sizes), u__namespace.duc(initialTopMostItemIndex), scrolledToInitialItem, u__namespace.duc(topItemsIndexes), u__namespace.duc(firstItemIndex), data), u__namespace.filter(function (_ref2) {
1928
- var mount = _ref2[0];
1929
- return mount;
1930
- }), u__namespace.map(function (_ref3) {
1931
- var _ref3$ = _ref3[1],
1932
- startOffset = _ref3$[0],
1933
- endOffset = _ref3$[1],
1934
- totalCount = _ref3[2],
1935
- sizes = _ref3[3],
1936
- initialTopMostItemIndex = _ref3[4],
1937
- scrolledToInitialItem = _ref3[5],
1938
- topItemsIndexes = _ref3[6],
1939
- firstItemIndex = _ref3[7],
1940
- data = _ref3[8];
1941
- var sizesValue = sizes;
1942
- var sizeTree = sizesValue.sizeTree,
1943
- offsetTree = sizesValue.offsetTree;
1944
-
1945
- if (totalCount === 0 || startOffset === 0 && endOffset === 0) {
1946
- return EMPTY_LIST_STATE;
1947
- }
1948
-
1949
- if (empty(sizeTree)) {
1950
- return buildListState(probeItemSet(initialTopMostItemIndex, sizesValue, data), [], totalCount, sizesValue, firstItemIndex);
1951
- }
1952
-
1953
- var topItems = [];
1954
-
1955
- if (topItemsIndexes.length > 0) {
1956
- var startIndex = topItemsIndexes[0];
1957
- var endIndex = topItemsIndexes[topItemsIndexes.length - 1];
1958
- var offset = 0;
1959
-
1960
- for (var _iterator2 = _createForOfIteratorHelperLoose(rangesWithin(sizeTree, startIndex, endIndex)), _step2; !(_step2 = _iterator2()).done;) {
1961
- var range = _step2.value;
1962
- var size = range.value;
1963
- var rangeStartIndex = Math.max(range.start, startIndex);
1964
- var rangeEndIndex = Math.min(range.end, endIndex);
1965
-
1966
- for (var i = rangeStartIndex; i <= rangeEndIndex; i++) {
1967
- topItems.push({
1968
- index: i,
1969
- size: size,
1970
- offset: offset,
1971
- data: data && data[i]
1972
- });
1973
- offset += size;
1974
- }
1975
- }
1976
- } // If the list hasn't scrolled to the initial item because the initial item was set,
1977
- // render empty list.
1978
- //
1979
- // This is a condition to be evaluated past the probe check, do not merge
1980
- // with the totalCount check above
1981
-
1982
-
1983
- if (!scrolledToInitialItem) {
1984
- return buildListState([], topItems, totalCount, sizesValue, firstItemIndex);
1985
- }
1986
-
1987
- var minStartIndex = topItemsIndexes.length > 0 ? topItemsIndexes[topItemsIndexes.length - 1] + 1 : 0;
1988
- var offsetPointRanges = rangesWithinOffsets(offsetTree, startOffset, endOffset, minStartIndex);
1989
-
1990
- if (offsetPointRanges.length === 0) {
1991
- return null;
1992
- }
1993
-
1994
- var maxIndex = totalCount - 1;
1995
- var items = u__namespace.tap([], function (result) {
1996
- for (var _iterator3 = _createForOfIteratorHelperLoose(offsetPointRanges), _step3; !(_step3 = _iterator3()).done;) {
1997
- var _range = _step3.value;
1998
- var point = _range.value;
1999
- var _offset = point.offset;
2000
- var _rangeStartIndex = _range.start;
2001
- var _size = point.size;
2002
-
2003
- if (point.offset < startOffset) {
2004
- _rangeStartIndex += Math.floor((startOffset - point.offset) / _size);
2005
- _offset += (_rangeStartIndex - _range.start) * _size;
2006
- }
2007
-
2008
- if (_rangeStartIndex < minStartIndex) {
2009
- _offset += (minStartIndex - _rangeStartIndex) * _size;
2010
- _rangeStartIndex = minStartIndex;
2011
- }
2012
-
2013
- var _endIndex = Math.min(_range.end, maxIndex);
2014
-
2015
- for (var _i = _rangeStartIndex; _i <= _endIndex; _i++) {
2016
- if (_offset >= endOffset) {
2017
- break;
2018
- }
2019
-
2020
- result.push({
2021
- index: _i,
2022
- size: _size,
2023
- offset: _offset,
2024
- data: data && data[_i]
2025
- });
2026
- _offset += _size;
2027
- }
2028
- }
2029
- });
2030
- return buildListState(items, topItems, totalCount, sizesValue, firstItemIndex);
2031
- }), //@ts-expect-error filter needs to be fixed
2032
- u__namespace.filter(function (value) {
2033
- return value !== null;
2034
- }), u__namespace.distinctUntilChanged()), EMPTY_LIST_STATE);
2035
- u__namespace.connect(u__namespace.pipe(data, u__namespace.filter(function (data) {
2036
- return data !== undefined;
2037
- }), u__namespace.map(function (data) {
2038
- return data.length;
2039
- })), totalCount);
2040
- u__namespace.connect(u__namespace.pipe(listState, u__namespace.map(u__namespace.prop('topListHeight'))), topListHeight);
2041
- u__namespace.connect(topListHeight, rangeTopListHeight);
2042
- u__namespace.connect(u__namespace.pipe(listState, u__namespace.map(function (state) {
2043
- return [state.top, state.bottom];
2044
- })), listBoundary);
2045
- u__namespace.connect(u__namespace.pipe(listState, u__namespace.map(function (state) {
2046
- return state.items;
2047
- })), itemsRendered);
2048
- var endReached = u__namespace.streamFromEmitter(u__namespace.pipe(listState, u__namespace.filter(function (_ref4) {
2049
- var items = _ref4.items;
2050
- return items.length > 0;
2051
- }), u__namespace.withLatestFrom(totalCount, data), u__namespace.filter(function (_ref5) {
2052
- var items = _ref5[0].items,
2053
- totalCount = _ref5[1];
2054
- return items[items.length - 1].originalIndex === totalCount - 1;
2055
- }), u__namespace.map(function (_ref6) {
2056
- var totalCount = _ref6[1],
2057
- data = _ref6[2];
2058
- return [totalCount - 1, data];
2059
- }), u__namespace.distinctUntilChanged(tupleComparator), u__namespace.map(function (_ref7) {
2060
- var count = _ref7[0];
2061
- return count;
2062
- })));
2063
- var startReached = u__namespace.streamFromEmitter(u__namespace.pipe(listState, u__namespace.throttleTime(200), u__namespace.filter(function (_ref8) {
2064
- var items = _ref8.items,
2065
- topItems = _ref8.topItems;
2066
- return items.length > 0 && items[0].originalIndex === topItems.length;
2067
- }), u__namespace.map(function (_ref9) {
2068
- var items = _ref9.items;
2069
- return items[0].index;
2070
- }), u__namespace.distinctUntilChanged()));
2071
- var rangeChanged = u__namespace.streamFromEmitter(u__namespace.pipe(listState, u__namespace.filter(function (_ref10) {
2072
- var items = _ref10.items;
2073
- return items.length > 0;
2074
- }), u__namespace.map(function (_ref11) {
2075
- var items = _ref11.items;
2076
- return {
2077
- startIndex: items[0].index,
2078
- endIndex: items[items.length - 1].index
2079
- };
2080
- }), u__namespace.distinctUntilChanged(rangeComparator)));
2081
- return _extends({
2082
- listState: listState,
2083
- topItemsIndexes: topItemsIndexes,
2084
- endReached: endReached,
2085
- startReached: startReached,
2086
- rangeChanged: rangeChanged,
2087
- itemsRendered: itemsRendered
2088
- }, stateFlags);
2089
- }, /*#__PURE__*/u__namespace.tup(sizeSystem, groupedListSystem, sizeRangeSystem, initialTopMostItemIndexSystem, scrollToIndexSystem, stateFlagsSystem, propsReadySystem), {
2090
- singleton: true
2091
- });
2092
-
2093
- var initialItemCountSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2094
- var _ref$ = _ref[0],
2095
- sizes = _ref$.sizes,
2096
- firstItemIndex = _ref$.firstItemIndex,
2097
- data = _ref$.data,
2098
- listState = _ref[1].listState,
2099
- didMount = _ref[2].didMount;
2100
- var initialItemCount = u__namespace.statefulStream(0);
2101
- u__namespace.connect(u__namespace.pipe(didMount, u__namespace.withLatestFrom(initialItemCount), u__namespace.filter(function (_ref2) {
2102
- var count = _ref2[1];
2103
- return count !== 0;
2104
- }), u__namespace.withLatestFrom(sizes, firstItemIndex, data), u__namespace.map(function (_ref3) {
2105
- var _ref3$ = _ref3[0],
2106
- count = _ref3$[1],
2107
- sizes = _ref3[1],
2108
- firstItemIndex = _ref3[2],
2109
- _ref3$2 = _ref3[3],
2110
- data = _ref3$2 === void 0 ? [] : _ref3$2;
2111
- var includedGroupsCount = 0;
2112
-
2113
- if (sizes.groupIndices.length > 0) {
2114
- for (var _iterator = _createForOfIteratorHelperLoose(sizes.groupIndices), _step; !(_step = _iterator()).done;) {
2115
- var index = _step.value;
2116
-
2117
- if (index - includedGroupsCount >= count) {
2118
- break;
2119
- }
2120
-
2121
- includedGroupsCount++;
2122
- }
2123
- }
2124
-
2125
- var adjustedCount = count + includedGroupsCount;
2126
- var items = Array.from({
2127
- length: adjustedCount
2128
- }).map(function (_, index) {
2129
- return {
2130
- index: index,
2131
- size: 0,
2132
- offset: 0,
2133
- data: data[index]
2134
- };
2135
- });
2136
- return buildListState(items, [], adjustedCount, sizes, firstItemIndex);
2137
- })), listState);
2138
- return {
2139
- initialItemCount: initialItemCount
2140
- };
2141
- }, /*#__PURE__*/u__namespace.tup(sizeSystem, listStateSystem, propsReadySystem), {
2142
- singleton: true
2143
- });
2144
-
2145
- var scrollSeekSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2146
- var scrollVelocity = _ref[0].scrollVelocity;
2147
- var isSeeking = u__namespace.statefulStream(false);
2148
- var rangeChanged = u__namespace.stream();
2149
- var scrollSeekConfiguration = u__namespace.statefulStream(false);
2150
- u__namespace.connect(u__namespace.pipe(scrollVelocity, u__namespace.withLatestFrom(scrollSeekConfiguration, isSeeking, rangeChanged), u__namespace.filter(function (_ref2) {
2151
- var config = _ref2[1];
2152
- return !!config;
2153
- }), u__namespace.map(function (_ref3) {
2154
- var speed = _ref3[0],
2155
- config = _ref3[1],
2156
- isSeeking = _ref3[2],
2157
- range = _ref3[3];
2158
- var exit = config.exit,
2159
- enter = config.enter;
2160
-
2161
- if (isSeeking) {
2162
- if (exit(speed, range)) {
2163
- return false;
2164
- }
2165
- } else {
2166
- if (enter(speed, range)) {
2167
- return true;
2168
- }
2169
- }
2170
-
2171
- return isSeeking;
2172
- }), u__namespace.distinctUntilChanged()), isSeeking);
2173
- u__namespace.subscribe(u__namespace.pipe(u__namespace.combineLatest(isSeeking, scrollVelocity, rangeChanged), u__namespace.withLatestFrom(scrollSeekConfiguration)), function (_ref4) {
2174
- var _ref4$ = _ref4[0],
2175
- isSeeking = _ref4$[0],
2176
- velocity = _ref4$[1],
2177
- range = _ref4$[2],
2178
- config = _ref4[1];
2179
- return isSeeking && config && config.change && config.change(velocity, range);
2180
- });
2181
- return {
2182
- isSeeking: isSeeking,
2183
- scrollSeekConfiguration: scrollSeekConfiguration,
2184
- scrollVelocity: scrollVelocity,
2185
- scrollSeekRangeChanged: rangeChanged
2186
- };
2187
- }, /*#__PURE__*/u__namespace.tup(stateFlagsSystem), {
2188
- singleton: true
2189
- });
2190
-
2191
- var topItemCountSystem = /*#__PURE__*/u.system(function (_ref) {
2192
- var topItemsIndexes = _ref[0].topItemsIndexes;
2193
- var topItemCount = u.statefulStream(0);
2194
- u.connect(u.pipe(topItemCount, u.filter(function (length) {
2195
- return length > 0;
2196
- }), u.map(function (length) {
2197
- return Array.from({
2198
- length: length
2199
- }).map(function (_, index) {
2200
- return index;
2201
- });
2202
- })), topItemsIndexes);
2203
- return {
2204
- topItemCount: topItemCount
2205
- };
2206
- }, /*#__PURE__*/u.tup(listStateSystem));
2207
-
2208
- var totalListHeightSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2209
- var _ref$ = _ref[0],
2210
- footerHeight = _ref$.footerHeight,
2211
- headerHeight = _ref$.headerHeight,
2212
- listState = _ref[1].listState;
2213
- var totalListHeightChanged = u__namespace.stream();
2214
- var totalListHeight = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(u__namespace.combineLatest(footerHeight, headerHeight, listState), u__namespace.map(function (_ref2) {
2215
- var footerHeight = _ref2[0],
2216
- headerHeight = _ref2[1],
2217
- listState = _ref2[2];
2218
- return footerHeight + headerHeight + listState.offsetBottom + listState.bottom;
2219
- })), 0);
2220
- u__namespace.connect(u__namespace.duc(totalListHeight), totalListHeightChanged);
2221
- return {
2222
- totalListHeight: totalListHeight,
2223
- totalListHeightChanged: totalListHeightChanged
2224
- };
2225
- }, /*#__PURE__*/u__namespace.tup(domIOSystem, listStateSystem), {
2226
- singleton: true
2227
- });
2228
-
2229
- /**
2230
- * Fixes upward scrolling by calculating and compensation from changed item heights, using scrollBy.
2231
- */
2232
-
2233
- var upwardScrollFixSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2234
- var _ref$ = _ref[0],
2235
- scrollBy = _ref$.scrollBy,
2236
- scrollTop = _ref$.scrollTop,
2237
- deviation = _ref$.deviation,
2238
- scrollingInProgress = _ref$.scrollingInProgress,
2239
- _ref$2 = _ref[1],
2240
- isScrolling = _ref$2.isScrolling,
2241
- isAtBottom = _ref$2.isAtBottom,
2242
- atBottomState = _ref$2.atBottomState,
2243
- scrollDirection = _ref$2.scrollDirection,
2244
- lastJumpDueToItemResize = _ref$2.lastJumpDueToItemResize,
2245
- listState = _ref[2].listState,
2246
- _ref$3 = _ref[3],
2247
- beforeUnshiftWith = _ref$3.beforeUnshiftWith,
2248
- sizes = _ref$3.sizes,
2249
- log = _ref[4].log;
2250
- var deviationOffset = u__namespace.streamFromEmitter(u__namespace.pipe(listState, u__namespace.withLatestFrom(lastJumpDueToItemResize), u__namespace.scan(function (_ref2, _ref3) {
2251
- var prevItems = _ref2[1],
2252
- prevTotalCount = _ref2[2];
2253
- var _ref3$ = _ref3[0],
2254
- items = _ref3$.items,
2255
- totalCount = _ref3$.totalCount,
2256
- lastJumpDueToItemResize = _ref3[1];
2257
- var newDev = 0;
2258
-
2259
- if (prevTotalCount === totalCount) {
2260
- if (prevItems.length > 0 && items.length > 0) {
2261
- var firstItemIndex = items[0].originalIndex;
2262
- var prevFirstItemIndex = prevItems[0].originalIndex;
2263
- var atStart = firstItemIndex === 0 && prevFirstItemIndex === 0;
2264
- var onlyItem = items.length === 1;
2265
-
2266
- if (!atStart) {
2267
- var _loop = function _loop(index) {
2268
- var item = items[index];
2269
- var prevItem = prevItems.find(function (pItem) {
2270
- return pItem.originalIndex === item.originalIndex;
2271
- });
2272
-
2273
- if (!prevItem) {
2274
- return "continue";
2275
- }
2276
-
2277
- if (item.offset !== prevItem.offset || onlyItem) {
2278
- newDev = item.offset - prevItem.offset + item.size - prevItem.size;
2279
- return "break";
2280
- }
2281
- };
2282
-
2283
- for (var index = items.length - 1; index >= 0; index--) {
2284
- var _ret = _loop(index);
2285
-
2286
- if (_ret === "continue") continue;
2287
- if (_ret === "break") break;
2288
- }
2289
- }
2290
- }
2291
-
2292
- if (newDev !== 0) {
2293
- newDev += lastJumpDueToItemResize;
2294
- }
2295
- }
2296
-
2297
- return [newDev, items, totalCount];
2298
- }, [0, [], 0]), u__namespace.filter(function (_ref4) {
2299
- var amount = _ref4[0];
2300
- return amount !== 0;
2301
- }), u__namespace.withLatestFrom(scrollTop, scrollDirection, scrollingInProgress, log, isAtBottom, atBottomState), u__namespace.filter(function (_ref5) {
2302
- var scrollTop = _ref5[1],
2303
- scrollDirection = _ref5[2],
2304
- scrollingInProgress = _ref5[3];
2305
- // console.log({ amount, scrollTop, scrollDirection, scrollingInProgress, isAtBottom, atBottomState })
2306
- return !scrollingInProgress && scrollTop !== 0 && scrollDirection === UP; // && (isAtBottom ? amount > 0 : true)
2307
- }), u__namespace.map(function (_ref6) {
2308
- var _ref6$ = _ref6[0],
2309
- amount = _ref6$[0],
2310
- log = _ref6[4];
2311
- log('Upward scrolling compensation', {
2312
- amount: amount
2313
- }, exports.LogLevel.DEBUG);
2314
- return amount;
2315
- })));
2316
- u__namespace.connect(u__namespace.pipe(deviationOffset, u__namespace.withLatestFrom(deviation), u__namespace.map(function (_ref7) {
2317
- var amount = _ref7[0],
2318
- deviation = _ref7[1];
2319
- return deviation - amount;
2320
- })), deviation); // when the browser stops scrolling,
2321
- // restore the position and reset the glitching
2322
-
2323
- u__namespace.subscribe(u__namespace.pipe(u__namespace.combineLatest(u__namespace.statefulStreamFromEmitter(isScrolling, false), deviation), u__namespace.filter(function (_ref8) {
2324
- var is = _ref8[0],
2325
- deviation = _ref8[1];
2326
- return !is && deviation !== 0;
2327
- }), u__namespace.map(function (_ref9) {
2328
- var deviation = _ref9[1];
2329
- return deviation;
2330
- }), u__namespace.throttleTime(1)), function (offset) {
2331
- if (offset > 0) {
2332
- u__namespace.publish(scrollBy, {
2333
- top: -offset,
2334
- behavior: 'auto'
2335
- });
2336
- u__namespace.publish(deviation, 0);
2337
- } else {
2338
- u__namespace.publish(deviation, 0);
2339
- u__namespace.publish(scrollBy, {
2340
- top: -offset,
2341
- behavior: 'auto'
2342
- });
2343
- }
2344
- });
2345
- u__namespace.connect(u__namespace.pipe(beforeUnshiftWith, u__namespace.withLatestFrom(sizes), u__namespace.map(function (_ref10) {
2346
- var offset = _ref10[0],
2347
- lastSize = _ref10[1].lastSize;
2348
- return offset * lastSize;
2349
- })), deviationOffset);
2350
- return {
2351
- deviation: deviation
2352
- };
2353
- }, /*#__PURE__*/u__namespace.tup(domIOSystem, stateFlagsSystem, listStateSystem, sizeSystem, loggerSystem));
2354
-
2355
- var initialScrollTopSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2356
- var totalListHeight = _ref[0].totalListHeight,
2357
- didMount = _ref[1].didMount,
2358
- scrollTo = _ref[2].scrollTo;
2359
- var initialScrollTop = u__namespace.statefulStream(0);
2360
- u__namespace.subscribe(u__namespace.pipe(didMount, u__namespace.withLatestFrom(initialScrollTop), u__namespace.filter(function (_ref2) {
2361
- var offset = _ref2[1];
2362
- return offset !== 0;
2363
- }), u__namespace.map(function (_ref3) {
2364
- var offset = _ref3[1];
2365
- return {
2366
- top: offset
2367
- };
2368
- })), function (location) {
2369
- u__namespace.handleNext(u__namespace.pipe(totalListHeight, u__namespace.filter(function (val) {
2370
- return val !== 0;
2371
- })), function () {
2372
- setTimeout(function () {
2373
- u__namespace.publish(scrollTo, location);
2374
- });
2375
- });
2376
- });
2377
- return {
2378
- initialScrollTop: initialScrollTop
2379
- };
2380
- }, /*#__PURE__*/u__namespace.tup(totalListHeightSystem, propsReadySystem, domIOSystem), {
2381
- singleton: true
2382
- });
2383
-
2384
- var alignToBottomSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2385
- var viewportHeight = _ref[0].viewportHeight,
2386
- totalListHeight = _ref[1].totalListHeight;
2387
- var alignToBottom = u__namespace.statefulStream(false);
2388
- var paddingTopAddition = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(u__namespace.combineLatest(alignToBottom, viewportHeight, totalListHeight), u__namespace.filter(function (_ref2) {
2389
- var enabled = _ref2[0];
2390
- return enabled;
2391
- }), u__namespace.map(function (_ref3) {
2392
- var viewportHeight = _ref3[1],
2393
- totalListHeight = _ref3[2];
2394
- return Math.max(0, viewportHeight - totalListHeight);
2395
- }), u__namespace.distinctUntilChanged()), 0);
2396
- return {
2397
- alignToBottom: alignToBottom,
2398
- paddingTopAddition: paddingTopAddition
2399
- };
2400
- }, /*#__PURE__*/u__namespace.tup(domIOSystem, totalListHeightSystem), {
2401
- singleton: true
2402
- });
2403
-
2404
- var windowScrollerSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2405
- var _ref$ = _ref[0],
2406
- scrollTo = _ref$.scrollTo,
2407
- scrollContainerState = _ref$.scrollContainerState;
2408
- var windowScrollContainerState = u__namespace.stream();
2409
- var windowViewportRect = u__namespace.stream();
2410
- var windowScrollTo = u__namespace.stream();
2411
- var useWindowScroll = u__namespace.statefulStream(false);
2412
- var customScrollParent = u__namespace.statefulStream(undefined);
2413
- u__namespace.connect(u__namespace.pipe(u__namespace.combineLatest(windowScrollContainerState, windowViewportRect), u__namespace.map(function (_ref2) {
2414
- var _ref2$ = _ref2[0],
2415
- windowScrollTop = _ref2$[0],
2416
- scrollHeight = _ref2$[1],
2417
- offsetTop = _ref2[1].offsetTop;
2418
- return [Math.max(0, windowScrollTop - offsetTop), scrollHeight];
2419
- })), scrollContainerState);
2420
- u__namespace.connect(u__namespace.pipe(scrollTo, u__namespace.withLatestFrom(windowViewportRect), u__namespace.map(function (_ref3) {
2421
- var scrollTo = _ref3[0],
2422
- offsetTop = _ref3[1].offsetTop;
2423
- return _extends({}, scrollTo, {
2424
- top: scrollTo.top + offsetTop
2425
- });
2426
- })), windowScrollTo);
2427
- return {
2428
- // config
2429
- useWindowScroll: useWindowScroll,
2430
- customScrollParent: customScrollParent,
2431
- // input
2432
- windowScrollContainerState: windowScrollContainerState,
2433
- windowViewportRect: windowViewportRect,
2434
- // signals
2435
- windowScrollTo: windowScrollTo
2436
- };
2437
- }, /*#__PURE__*/u__namespace.tup(domIOSystem));
2438
-
2439
- var scrollIntoViewSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
2440
- var _ref$ = _ref[0],
2441
- sizes = _ref$.sizes,
2442
- totalCount = _ref$.totalCount,
2443
- _ref$2 = _ref[1],
2444
- scrollTop = _ref$2.scrollTop,
2445
- viewportHeight = _ref$2.viewportHeight,
2446
- headerHeight = _ref$2.headerHeight,
2447
- scrollingInProgress = _ref$2.scrollingInProgress,
2448
- scrollToIndex = _ref[2].scrollToIndex;
2449
- var scrollIntoView = u__namespace.stream();
2450
- u__namespace.connect(u__namespace.pipe(scrollIntoView, u__namespace.withLatestFrom(sizes, viewportHeight, totalCount, headerHeight, scrollTop), u__namespace.map(function (_ref2) {
2451
- var _ref2$ = _ref2[0],
2452
- index = _ref2$.index,
2453
- _ref2$$behavior = _ref2$.behavior,
2454
- behavior = _ref2$$behavior === void 0 ? 'auto' : _ref2$$behavior,
2455
- done = _ref2$.done,
2456
- sizes = _ref2[1],
2457
- viewportHeight = _ref2[2],
2458
- totalCount = _ref2[3],
2459
- headerHeight = _ref2[4],
2460
- scrollTop = _ref2[5];
2461
- var lastIndex = totalCount - 1;
2462
- var location = null;
2463
- index = originalIndexFromItemIndex(index, sizes);
2464
- index = Math.max(0, index, Math.min(lastIndex, index));
2465
- var itemTop = offsetOf(index, sizes.offsetTree) + headerHeight;
2466
-
2467
- if (itemTop < scrollTop) {
2468
- location = {
2469
- index: index,
2470
- behavior: behavior,
2471
- align: 'start'
2472
- };
2473
- } else {
2474
- var itemBottom = itemTop + findMaxKeyValue(sizes.sizeTree, index)[1];
2475
-
2476
- if (itemBottom > scrollTop + viewportHeight) {
2477
- location = {
2478
- index: index,
2479
- behavior: behavior,
2480
- align: 'end'
2481
- };
2482
- }
2483
- }
2484
-
2485
- if (location) {
2486
- done && u__namespace.handleNext(u__namespace.pipe(scrollingInProgress, u__namespace.skip(1), u__namespace.filter(function (value) {
2487
- return value === false;
2488
- })), done);
2489
- } else {
2490
- done && done();
2491
- }
2492
-
2493
- return location;
2494
- }), u__namespace.filter(function (value) {
2495
- return value !== null;
2496
- })), scrollToIndex);
2497
- return {
2498
- scrollIntoView: scrollIntoView
2499
- };
2500
- }, /*#__PURE__*/u__namespace.tup(sizeSystem, domIOSystem, scrollToIndexSystem, listStateSystem, loggerSystem), {
2501
- singleton: true
2502
- });
2503
-
2504
- // fix this with 4.1 recursive conditional types
2505
-
2506
- var featureGroup1System = /*#__PURE__*/u__namespace.system(function (_ref) {
2507
- var sizeRange = _ref[0],
2508
- initialItemCount = _ref[1],
2509
- propsReady = _ref[2],
2510
- scrollSeek = _ref[3],
2511
- totalListHeight = _ref[4],
2512
- initialScrollTopSystem = _ref[5],
2513
- alignToBottom = _ref[6],
2514
- windowScroller = _ref[7],
2515
- scrollIntoView = _ref[8];
2516
- return _extends({}, sizeRange, initialItemCount, propsReady, scrollSeek, totalListHeight, initialScrollTopSystem, alignToBottom, windowScroller, scrollIntoView);
2517
- }, /*#__PURE__*/u__namespace.tup(sizeRangeSystem, initialItemCountSystem, propsReadySystem, scrollSeekSystem, totalListHeightSystem, initialScrollTopSystem, alignToBottomSystem, windowScrollerSystem, scrollIntoViewSystem));
2518
- var listSystem = /*#__PURE__*/u__namespace.system(function (_ref2) {
2519
- var _ref2$ = _ref2[0],
2520
- totalCount = _ref2$.totalCount,
2521
- sizeRanges = _ref2$.sizeRanges,
2522
- fixedItemSize = _ref2$.fixedItemSize,
2523
- defaultItemSize = _ref2$.defaultItemSize,
2524
- trackItemSizes = _ref2$.trackItemSizes,
2525
- itemSize = _ref2$.itemSize,
2526
- data = _ref2$.data,
2527
- firstItemIndex = _ref2$.firstItemIndex,
2528
- groupIndices = _ref2$.groupIndices,
2529
- statefulTotalCount = _ref2$.statefulTotalCount,
2530
- _ref2$2 = _ref2[1],
2531
- initialTopMostItemIndex = _ref2$2.initialTopMostItemIndex,
2532
- scrolledToInitialItem = _ref2$2.scrolledToInitialItem,
2533
- domIO = _ref2[2],
2534
- followOutput = _ref2[3],
2535
- _ref2$3 = _ref2[4],
2536
- listState = _ref2$3.listState,
2537
- topItemsIndexes = _ref2$3.topItemsIndexes,
2538
- flags = _objectWithoutPropertiesLoose(_ref2$3, ["listState", "topItemsIndexes"]),
2539
- scrollToIndex = _ref2[5].scrollToIndex,
2540
- topItemCount = _ref2[7].topItemCount,
2541
- groupCounts = _ref2[8].groupCounts,
2542
- featureGroup1 = _ref2[9],
2543
- log = _ref2[10];
2544
-
2545
- u__namespace.connect(flags.rangeChanged, featureGroup1.scrollSeekRangeChanged);
2546
- u__namespace.connect(u__namespace.pipe(featureGroup1.windowViewportRect, u__namespace.map(u__namespace.prop('visibleHeight'))), domIO.viewportHeight);
2547
- return _extends({
2548
- // input
2549
- totalCount: totalCount,
2550
- data: data,
2551
- firstItemIndex: firstItemIndex,
2552
- sizeRanges: sizeRanges,
2553
- initialTopMostItemIndex: initialTopMostItemIndex,
2554
- scrolledToInitialItem: scrolledToInitialItem,
2555
- topItemsIndexes: topItemsIndexes,
2556
- topItemCount: topItemCount,
2557
- groupCounts: groupCounts,
2558
- fixedItemHeight: fixedItemSize,
2559
- defaultItemHeight: defaultItemSize
2560
- }, followOutput, {
2561
- // output
2562
- statefulTotalCount: statefulTotalCount,
2563
- listState: listState,
2564
- scrollToIndex: scrollToIndex,
2565
- trackItemSizes: trackItemSizes,
2566
- itemSize: itemSize,
2567
- groupIndices: groupIndices
2568
- }, flags, featureGroup1, domIO, log);
2569
- }, /*#__PURE__*/u__namespace.tup(sizeSystem, initialTopMostItemIndexSystem, domIOSystem, followOutputSystem, listStateSystem, scrollToIndexSystem, upwardScrollFixSystem, topItemCountSystem, groupedListSystem, featureGroup1System, loggerSystem));
2570
-
2571
- function simpleMemoize(func) {
2572
- var called = false;
2573
- var result;
2574
- return function () {
2575
- if (!called) {
2576
- called = true;
2577
- result = func();
2578
- }
2579
-
2580
- return result;
2581
- };
2582
- }
2583
-
2584
- var WEBKIT_STICKY = '-webkit-sticky';
2585
- var STICKY = 'sticky';
2586
- var positionStickyCssValue = /*#__PURE__*/simpleMemoize(function () {
2587
- if (typeof document === 'undefined') {
2588
- return STICKY;
2589
- }
2590
-
2591
- var node = document.createElement('div');
2592
- node.style.position = WEBKIT_STICKY;
2593
- return node.style.position === WEBKIT_STICKY ? WEBKIT_STICKY : STICKY;
2594
- });
2595
-
2596
- function useWindowViewportRectRef(callback, customScrollParent) {
2597
- var viewportInfo = React.useRef(null);
2598
- var calculateInfo = React.useCallback(function (element) {
2599
- if (element === null) {
2600
- return;
2601
- }
2602
-
2603
- var rect = element.getBoundingClientRect();
2604
- var visibleWidth = rect.width;
2605
- var visibleHeight, offsetTop;
2606
-
2607
- if (customScrollParent) {
2608
- var customScrollParentRect = customScrollParent.getBoundingClientRect();
2609
- var deltaTop = rect.top - customScrollParentRect.top;
2610
- visibleHeight = customScrollParentRect.height - Math.max(0, deltaTop);
2611
- offsetTop = deltaTop + customScrollParent.scrollTop;
2612
- } else {
2613
- visibleHeight = window.innerHeight - Math.max(0, rect.top);
2614
- offsetTop = rect.top + window.pageYOffset;
2615
- }
2616
-
2617
- viewportInfo.current = {
2618
- offsetTop: offsetTop,
2619
- visibleHeight: visibleHeight,
2620
- visibleWidth: visibleWidth
2621
- };
2622
- callback(viewportInfo.current);
2623
- }, [callback, customScrollParent]);
2624
-
2625
- var _useSizeWithElRef = useSizeWithElRef(calculateInfo),
2626
- callbackRef = _useSizeWithElRef.callbackRef,
2627
- ref = _useSizeWithElRef.ref;
2628
-
2629
- var scrollAndResizeEventHandler = React.useCallback(function () {
2630
- calculateInfo(ref.current);
2631
- }, [calculateInfo, ref]);
2632
- React.useEffect(function () {
2633
- if (customScrollParent) {
2634
- customScrollParent.addEventListener('scroll', scrollAndResizeEventHandler);
2635
- var observer = new ResizeObserver(scrollAndResizeEventHandler);
2636
- observer.observe(customScrollParent);
2637
- return function () {
2638
- customScrollParent.removeEventListener('scroll', scrollAndResizeEventHandler);
2639
- observer.unobserve(customScrollParent);
2640
- };
2641
- } else {
2642
- window.addEventListener('scroll', scrollAndResizeEventHandler);
2643
- window.addEventListener('resize', scrollAndResizeEventHandler);
2644
- return function () {
2645
- window.removeEventListener('scroll', scrollAndResizeEventHandler);
2646
- window.removeEventListener('resize', scrollAndResizeEventHandler);
2647
- };
2648
- }
2649
- }, [scrollAndResizeEventHandler, customScrollParent]);
2650
- return callbackRef;
2651
- }
2652
-
2653
- function identity(value) {
2654
- return value;
2655
- }
2656
- var listComponentPropsSystem = /*#__PURE__*/u.system(function () {
2657
- var itemContent = u.statefulStream(function (index) {
2658
- return "Item " + index;
2659
- });
2660
- var context = u.statefulStream(null);
2661
- var groupContent = u.statefulStream(function (index) {
2662
- return "Group " + index;
2663
- });
2664
- var components = u.statefulStream({});
2665
- var computeItemKey = u.statefulStream(identity);
2666
- var headerFooterTag = u.statefulStream('div');
2667
- var scrollerRef = u.statefulStream(u.noop);
2668
-
2669
- var distinctProp = function distinctProp(propName, defaultValue) {
2670
- if (defaultValue === void 0) {
2671
- defaultValue = null;
2672
- }
2673
-
2674
- return u.statefulStreamFromEmitter(u.pipe(components, u.map(function (components) {
2675
- return components[propName];
2676
- }), u.distinctUntilChanged()), defaultValue);
2677
- };
2678
-
2679
- return {
2680
- context: context,
2681
- itemContent: itemContent,
2682
- groupContent: groupContent,
2683
- components: components,
2684
- computeItemKey: computeItemKey,
2685
- headerFooterTag: headerFooterTag,
2686
- scrollerRef: scrollerRef,
2687
- FooterComponent: distinctProp('Footer'),
2688
- HeaderComponent: distinctProp('Header'),
2689
- TopItemListComponent: distinctProp('TopItemList'),
2690
- ListComponent: distinctProp('List', 'div'),
2691
- ItemComponent: distinctProp('Item', 'div'),
2692
- GroupComponent: distinctProp('Group', 'div'),
2693
- ScrollerComponent: distinctProp('Scroller', 'div'),
2694
- EmptyPlaceholder: distinctProp('EmptyPlaceholder'),
2695
- ScrollSeekPlaceholder: distinctProp('ScrollSeekPlaceholder')
2696
- };
2697
- });
2698
- function addDeprecatedAlias(prop, message) {
2699
- var alias = u.stream();
2700
- u.subscribe(alias, function () {
2701
- return console.warn("react-virtuoso: You are using a deprecated property. " + message, 'color: red;', 'color: inherit;', 'color: blue;');
2702
- });
2703
- u.connect(alias, prop);
2704
- return alias;
2705
- }
2706
- var combinedSystem$2 = /*#__PURE__*/u.system(function (_ref) {
2707
- var listSystem = _ref[0],
2708
- propsSystem = _ref[1];
2709
- var deprecatedProps = {
2710
- item: addDeprecatedAlias(propsSystem.itemContent, 'Rename the %citem%c prop to %citemContent.'),
2711
- group: addDeprecatedAlias(propsSystem.groupContent, 'Rename the %cgroup%c prop to %cgroupContent.'),
2712
- topItems: addDeprecatedAlias(listSystem.topItemCount, 'Rename the %ctopItems%c prop to %ctopItemCount.'),
2713
- itemHeight: addDeprecatedAlias(listSystem.fixedItemHeight, 'Rename the %citemHeight%c prop to %cfixedItemHeight.'),
2714
- scrollingStateChange: addDeprecatedAlias(listSystem.isScrolling, 'Rename the %cscrollingStateChange%c prop to %cisScrolling.'),
2715
- adjustForPrependedItems: u.stream(),
2716
- maxHeightCacheSize: u.stream(),
2717
- footer: u.stream(),
2718
- header: u.stream(),
2719
- HeaderContainer: u.stream(),
2720
- FooterContainer: u.stream(),
2721
- ItemContainer: u.stream(),
2722
- ScrollContainer: u.stream(),
2723
- GroupContainer: u.stream(),
2724
- ListContainer: u.stream(),
2725
- emptyComponent: u.stream(),
2726
- scrollSeek: u.stream()
2727
- };
2728
- u.subscribe(deprecatedProps.adjustForPrependedItems, function () {
2729
- console.warn("react-virtuoso: adjustForPrependedItems is no longer supported. Use the firstItemIndex property instead - https://virtuoso.dev/prepend-items.", 'color: red;', 'color: inherit;', 'color: blue;');
2730
- });
2731
- u.subscribe(deprecatedProps.maxHeightCacheSize, function () {
2732
- console.warn("react-virtuoso: maxHeightCacheSize is no longer necessary. Setting it has no effect - remove it from your code.");
2733
- });
2734
- u.subscribe(deprecatedProps.HeaderContainer, function () {
2735
- console.warn("react-virtuoso: HeaderContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the header component and pass components.Header to change its contents.");
2736
- });
2737
- u.subscribe(deprecatedProps.FooterContainer, function () {
2738
- console.warn("react-virtuoso: FooterContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the footer component and pass components.Footer to change its contents.");
2739
- });
2740
-
2741
- function deprecateComponentProp(stream, componentName, propName) {
2742
- u.connect(u.pipe(stream, u.withLatestFrom(propsSystem.components), u.map(function (_ref2) {
2743
- var _extends2;
2744
-
2745
- var comp = _ref2[0],
2746
- components = _ref2[1];
2747
- console.warn("react-virtuoso: " + propName + " property is deprecated. Pass components." + componentName + " instead."); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2748
-
2749
- return _extends({}, components, (_extends2 = {}, _extends2[componentName] = comp, _extends2));
2750
- })), propsSystem.components);
2751
- }
2752
-
2753
- u.subscribe(deprecatedProps.scrollSeek, function (_ref3) {
2754
- var placeholder = _ref3.placeholder,
2755
- config = _objectWithoutPropertiesLoose(_ref3, ["placeholder"]);
2756
-
2757
- console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2758
-
2759
- u.publish(propsSystem.components, _extends({}, u.getValue(propsSystem.components), {
2760
- ScrollSeekPlaceholder: placeholder
2761
- }));
2762
- u.publish(listSystem.scrollSeekConfiguration, config);
2763
- });
2764
- deprecateComponentProp(deprecatedProps.footer, 'Footer', 'footer');
2765
- deprecateComponentProp(deprecatedProps.header, 'Header', 'header');
2766
- deprecateComponentProp(deprecatedProps.ItemContainer, 'Item', 'ItemContainer');
2767
- deprecateComponentProp(deprecatedProps.ListContainer, 'List', 'ListContainer');
2768
- deprecateComponentProp(deprecatedProps.ScrollContainer, 'Scroller', 'ScrollContainer');
2769
- deprecateComponentProp(deprecatedProps.emptyComponent, 'EmptyPlaceholder', 'emptyComponent');
2770
- deprecateComponentProp(deprecatedProps.GroupContainer, 'Group', 'GroupContainer');
2771
- return _extends({}, listSystem, propsSystem, deprecatedProps);
2772
- }, /*#__PURE__*/u.tup(listSystem, listComponentPropsSystem));
2773
-
2774
- var DefaultScrollSeekPlaceholder$1 = function DefaultScrollSeekPlaceholder(_ref4) {
2775
- var height = _ref4.height;
2776
- return React__namespace.createElement("div", {
2777
- style: {
2778
- height: height
2779
- }
2780
- });
2781
- };
2782
-
2783
- var GROUP_STYLE = {
2784
- position: /*#__PURE__*/positionStickyCssValue(),
2785
- zIndex: 1,
2786
- overflowAnchor: 'none'
2787
- };
2788
- var Items$1 = /*#__PURE__*/React__namespace.memo(function VirtuosoItems(_ref5) {
2789
- var _ref5$showTopList = _ref5.showTopList,
2790
- showTopList = _ref5$showTopList === void 0 ? false : _ref5$showTopList;
2791
- var listState = useEmitterValue$2('listState');
2792
- var deviation = useEmitterValue$2('deviation');
2793
- var sizeRanges = usePublisher$2('sizeRanges');
2794
- var useWindowScroll = useEmitterValue$2('useWindowScroll');
2795
- var customScrollParent = useEmitterValue$2('customScrollParent');
2796
- var windowScrollContainerStateCallback = usePublisher$2('windowScrollContainerState');
2797
-
2798
- var _scrollContainerStateCallback = usePublisher$2('scrollContainerState');
2799
-
2800
- var scrollContainerStateCallback = customScrollParent || useWindowScroll ? windowScrollContainerStateCallback : _scrollContainerStateCallback;
2801
- var itemContent = useEmitterValue$2('itemContent');
2802
- var context = useEmitterValue$2('context');
2803
- var groupContent = useEmitterValue$2('groupContent');
2804
- var trackItemSizes = useEmitterValue$2('trackItemSizes');
2805
- var itemSize = useEmitterValue$2('itemSize');
2806
- var log = useEmitterValue$2('log');
2807
- var ref = useChangedListContentsSizes(sizeRanges, itemSize, trackItemSizes, showTopList ? u.noop : scrollContainerStateCallback, log, customScrollParent);
2808
- var EmptyPlaceholder = useEmitterValue$2('EmptyPlaceholder');
2809
- var ScrollSeekPlaceholder = useEmitterValue$2('ScrollSeekPlaceholder') || DefaultScrollSeekPlaceholder$1;
2810
- var ListComponent = useEmitterValue$2('ListComponent');
2811
- var ItemComponent = useEmitterValue$2('ItemComponent');
2812
- var GroupComponent = useEmitterValue$2('GroupComponent');
2813
- var computeItemKey = useEmitterValue$2('computeItemKey');
2814
- var isSeeking = useEmitterValue$2('isSeeking');
2815
- var hasGroups = useEmitterValue$2('groupIndices').length > 0;
2816
- var paddingTopAddition = useEmitterValue$2('paddingTopAddition');
2817
- var firstItemIndex = useEmitterValue$2('firstItemIndex');
2818
- var statefulTotalCount = useEmitterValue$2('statefulTotalCount');
2819
- var containerStyle = showTopList ? {} : {
2820
- boxSizing: 'border-box',
2821
- paddingTop: listState.offsetTop + paddingTopAddition,
2822
- paddingBottom: listState.offsetBottom,
2823
- marginTop: deviation
2824
- };
2825
-
2826
- if (!showTopList && statefulTotalCount === 0 && EmptyPlaceholder) {
2827
- return React.createElement(EmptyPlaceholder, contextPropIfNotDomElement(EmptyPlaceholder, context));
2828
- }
2829
-
2830
- return React.createElement(ListComponent, _extends({}, contextPropIfNotDomElement(ListComponent, context), {
2831
- ref: ref,
2832
- style: containerStyle,
2833
- 'data-test-id': showTopList ? 'virtuoso-top-item-list' : 'virtuoso-item-list'
2834
- }), (showTopList ? listState.topItems : listState.items).map(function (item) {
2835
- var index = item.originalIndex;
2836
- var key = computeItemKey(index + firstItemIndex, item.data, context);
2837
-
2838
- if (isSeeking) {
2839
- return React.createElement(ScrollSeekPlaceholder, _extends({}, contextPropIfNotDomElement(ScrollSeekPlaceholder, context), {
2840
- key: key,
2841
- index: item.index,
2842
- height: item.size,
2843
- type: item.type || 'item'
2844
- }, item.type === 'group' ? {} : {
2845
- groupIndex: item.groupIndex
2846
- }));
2847
- }
2848
-
2849
- if (item.type === 'group') {
2850
- return React.createElement(GroupComponent, _extends({}, contextPropIfNotDomElement(GroupComponent, context), {
2851
- key: key,
2852
- 'data-index': index,
2853
- 'data-known-size': item.size,
2854
- 'data-item-index': item.index,
2855
- style: GROUP_STYLE
2856
- }), groupContent(item.index));
2857
- } else {
2858
- return React.createElement(ItemComponent, _extends({}, contextPropIfNotDomElement(ItemComponent, context), {
2859
- key: key,
2860
- 'data-index': index,
2861
- 'data-known-size': item.size,
2862
- 'data-item-index': item.index,
2863
- 'data-item-group-index': item.groupIndex,
2864
- style: {
2865
- overflowAnchor: 'none'
2866
- }
2867
- }), hasGroups ? itemContent(item.index, item.groupIndex, item.data, context) : itemContent(item.index, item.data, context));
2868
- }
2869
- }));
2870
- });
2871
- var scrollerStyle = {
2872
- height: '100%',
2873
- outline: 'none',
2874
- overflowY: 'auto',
2875
- position: 'relative',
2876
- WebkitOverflowScrolling: 'touch'
2877
- };
2878
- var viewportStyle = {
2879
- width: '100%',
2880
- height: '100%',
2881
- position: 'absolute',
2882
- top: 0
2883
- };
2884
- var topItemListStyle = {
2885
- width: '100%',
2886
- position: /*#__PURE__*/positionStickyCssValue(),
2887
- top: 0
2888
- };
2889
- function contextPropIfNotDomElement(element, context) {
2890
- if (typeof element === 'string') {
2891
- return undefined;
2892
- }
2893
-
2894
- return {
2895
- context: context
2896
- };
2897
- }
2898
- var Header = /*#__PURE__*/React__namespace.memo(function VirtuosoHeader() {
2899
- var Header = useEmitterValue$2('HeaderComponent');
2900
- var headerHeight = usePublisher$2('headerHeight');
2901
- var headerFooterTag = useEmitterValue$2('headerFooterTag');
2902
- var ref = useSize(function (el) {
2903
- return headerHeight(correctItemSize(el, 'height'));
2904
- });
2905
- var context = useEmitterValue$2('context');
2906
- return Header ? React.createElement(headerFooterTag, {
2907
- ref: ref
2908
- }, React.createElement(Header, contextPropIfNotDomElement(Header, context))) : null;
2909
- });
2910
- var Footer = /*#__PURE__*/React__namespace.memo(function VirtuosoFooter() {
2911
- var Footer = useEmitterValue$2('FooterComponent');
2912
- var footerHeight = usePublisher$2('footerHeight');
2913
- var headerFooterTag = useEmitterValue$2('headerFooterTag');
2914
- var ref = useSize(function (el) {
2915
- return footerHeight(correctItemSize(el, 'height'));
2916
- });
2917
- var context = useEmitterValue$2('context');
2918
- return Footer ? React.createElement(headerFooterTag, {
2919
- ref: ref
2920
- }, React.createElement(Footer, contextPropIfNotDomElement(Footer, context))) : null;
2921
- });
2922
- function buildScroller(_ref6) {
2923
- var usePublisher = _ref6.usePublisher,
2924
- useEmitter = _ref6.useEmitter,
2925
- useEmitterValue = _ref6.useEmitterValue;
2926
- var Scroller = React__namespace.memo(function VirtuosoScroller(_ref7) {
2927
- var style = _ref7.style,
2928
- children = _ref7.children,
2929
- props = _objectWithoutPropertiesLoose(_ref7, ["style", "children"]);
2930
-
2931
- var scrollContainerStateCallback = usePublisher('scrollContainerState');
2932
- var ScrollerComponent = useEmitterValue('ScrollerComponent');
2933
- var smoothScrollTargetReached = usePublisher('smoothScrollTargetReached');
2934
- var scrollerRefCallback = useEmitterValue('scrollerRef');
2935
- var context = useEmitterValue('context');
2936
-
2937
- var _useScrollTop = useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, ScrollerComponent, scrollerRefCallback),
2938
- scrollerRef = _useScrollTop.scrollerRef,
2939
- scrollByCallback = _useScrollTop.scrollByCallback,
2940
- scrollToCallback = _useScrollTop.scrollToCallback;
2941
-
2942
- useEmitter('scrollTo', scrollToCallback);
2943
- useEmitter('scrollBy', scrollByCallback);
2944
- return React.createElement(ScrollerComponent, _extends({
2945
- ref: scrollerRef,
2946
- style: _extends({}, scrollerStyle, style),
2947
- 'data-test-id': 'virtuoso-scroller',
2948
- 'data-virtuoso-scroller': true,
2949
- tabIndex: 0
2950
- }, props, contextPropIfNotDomElement(ScrollerComponent, context)), children);
2951
- });
2952
- return Scroller;
2953
- }
2954
- function buildWindowScroller(_ref8) {
2955
- var usePublisher = _ref8.usePublisher,
2956
- useEmitter = _ref8.useEmitter,
2957
- useEmitterValue = _ref8.useEmitterValue;
2958
- var Scroller = React__namespace.memo(function VirtuosoWindowScroller(_ref9) {
2959
- var style = _ref9.style,
2960
- children = _ref9.children,
2961
- props = _objectWithoutPropertiesLoose(_ref9, ["style", "children"]);
2962
-
2963
- var scrollContainerStateCallback = usePublisher('windowScrollContainerState');
2964
- var ScrollerComponent = useEmitterValue('ScrollerComponent');
2965
- var smoothScrollTargetReached = usePublisher('smoothScrollTargetReached');
2966
- var totalListHeight = useEmitterValue('totalListHeight');
2967
- var deviation = useEmitterValue('deviation');
2968
- var customScrollParent = useEmitterValue('customScrollParent');
2969
- var context = useEmitterValue('context');
2970
-
2971
- var _useScrollTop2 = useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, ScrollerComponent, u.noop, customScrollParent),
2972
- scrollerRef = _useScrollTop2.scrollerRef,
2973
- scrollByCallback = _useScrollTop2.scrollByCallback,
2974
- scrollToCallback = _useScrollTop2.scrollToCallback;
2975
-
2976
- useIsomorphicLayoutEffect(function () {
2977
- scrollerRef.current = customScrollParent ? customScrollParent : window;
2978
- return function () {
2979
- scrollerRef.current = null;
2980
- };
2981
- }, [scrollerRef, customScrollParent]);
2982
- useEmitter('windowScrollTo', scrollToCallback);
2983
- useEmitter('scrollBy', scrollByCallback);
2984
- return React.createElement(ScrollerComponent, _extends({
2985
- style: _extends({
2986
- position: 'relative'
2987
- }, style, totalListHeight !== 0 ? {
2988
- height: totalListHeight + deviation
2989
- } : {}),
2990
- 'data-virtuoso-scroller': true
2991
- }, props, contextPropIfNotDomElement(ScrollerComponent, context)), children);
2992
- });
2993
- return Scroller;
2994
- }
2995
-
2996
- var Viewport$2 = function Viewport(_ref10) {
2997
- var children = _ref10.children;
2998
- var viewportHeight = usePublisher$2('viewportHeight');
2999
- var viewportRef = useSize(u.compose(viewportHeight, function (el) {
3000
- return correctItemSize(el, 'height');
3001
- }));
3002
- return React__namespace.createElement("div", {
3003
- style: viewportStyle,
3004
- ref: viewportRef,
3005
- "data-viewport-type": "element"
3006
- }, children);
3007
- };
3008
-
3009
- var WindowViewport$2 = function WindowViewport(_ref11) {
3010
- var children = _ref11.children;
3011
- var windowViewportRect = usePublisher$2('windowViewportRect');
3012
- var customScrollParent = useEmitterValue$2('customScrollParent');
3013
- var viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
3014
- return React__namespace.createElement("div", {
3015
- ref: viewportRef,
3016
- style: viewportStyle,
3017
- "data-viewport-type": "window"
3018
- }, children);
3019
- };
3020
-
3021
- var TopItemListContainer = function TopItemListContainer(_ref12) {
3022
- var children = _ref12.children;
3023
- var TopItemList = useEmitterValue$2('TopItemListComponent');
3024
- var headerHeight = useEmitterValue$2('headerHeight');
3025
-
3026
- var style = _extends({}, topItemListStyle, {
3027
- marginTop: headerHeight + "px"
3028
- });
3029
-
3030
- var context = useEmitterValue$2('context');
3031
- return React.createElement(TopItemList || 'div', {
3032
- style: style,
3033
- context: context
3034
- }, children);
3035
- };
3036
-
3037
- var ListRoot = /*#__PURE__*/React__namespace.memo(function VirtuosoRoot(props) {
3038
- var useWindowScroll = useEmitterValue$2('useWindowScroll');
3039
- var showTopList = useEmitterValue$2('topItemsIndexes').length > 0;
3040
- var customScrollParent = useEmitterValue$2('customScrollParent');
3041
- var TheScroller = customScrollParent || useWindowScroll ? WindowScroller$2 : Scroller$2;
3042
- var TheViewport = customScrollParent || useWindowScroll ? WindowViewport$2 : Viewport$2;
3043
- return React__namespace.createElement(TheScroller, _extends({}, props), React__namespace.createElement(TheViewport, null, React__namespace.createElement(Header, null), React__namespace.createElement(Items$1, null), React__namespace.createElement(Footer, null)), showTopList && React__namespace.createElement(TopItemListContainer, null, React__namespace.createElement(Items$1, {
3044
- showTopList: true
3045
- })));
3046
- });
3047
-
3048
- var _systemToComponent$2 = /*#__PURE__*/reactUrx.systemToComponent(combinedSystem$2, {
3049
- required: {},
3050
- optional: {
3051
- context: 'context',
3052
- followOutput: 'followOutput',
3053
- firstItemIndex: 'firstItemIndex',
3054
- itemContent: 'itemContent',
3055
- groupContent: 'groupContent',
3056
- overscan: 'overscan',
3057
- increaseViewportBy: 'increaseViewportBy',
3058
- totalCount: 'totalCount',
3059
- topItemCount: 'topItemCount',
3060
- initialTopMostItemIndex: 'initialTopMostItemIndex',
3061
- components: 'components',
3062
- groupCounts: 'groupCounts',
3063
- atBottomThreshold: 'atBottomThreshold',
3064
- computeItemKey: 'computeItemKey',
3065
- defaultItemHeight: 'defaultItemHeight',
3066
- fixedItemHeight: 'fixedItemHeight',
3067
- itemSize: 'itemSize',
3068
- scrollSeekConfiguration: 'scrollSeekConfiguration',
3069
- headerFooterTag: 'headerFooterTag',
3070
- data: 'data',
3071
- initialItemCount: 'initialItemCount',
3072
- initialScrollTop: 'initialScrollTop',
3073
- alignToBottom: 'alignToBottom',
3074
- useWindowScroll: 'useWindowScroll',
3075
- customScrollParent: 'customScrollParent',
3076
- scrollerRef: 'scrollerRef',
3077
- logLevel: 'logLevel',
3078
- // deprecated
3079
- item: 'item',
3080
- group: 'group',
3081
- topItems: 'topItems',
3082
- itemHeight: 'itemHeight',
3083
- scrollingStateChange: 'scrollingStateChange',
3084
- maxHeightCacheSize: 'maxHeightCacheSize',
3085
- footer: 'footer',
3086
- header: 'header',
3087
- ItemContainer: 'ItemContainer',
3088
- ScrollContainer: 'ScrollContainer',
3089
- ListContainer: 'ListContainer',
3090
- GroupContainer: 'GroupContainer',
3091
- emptyComponent: 'emptyComponent',
3092
- HeaderContainer: 'HeaderContainer',
3093
- FooterContainer: 'FooterContainer',
3094
- scrollSeek: 'scrollSeek'
3095
- },
3096
- methods: {
3097
- scrollToIndex: 'scrollToIndex',
3098
- scrollIntoView: 'scrollIntoView',
3099
- scrollTo: 'scrollTo',
3100
- scrollBy: 'scrollBy',
3101
- adjustForPrependedItems: 'adjustForPrependedItems'
3102
- },
3103
- events: {
3104
- isScrolling: 'isScrolling',
3105
- endReached: 'endReached',
3106
- startReached: 'startReached',
3107
- rangeChanged: 'rangeChanged',
3108
- atBottomStateChange: 'atBottomStateChange',
3109
- atTopStateChange: 'atTopStateChange',
3110
- totalListHeightChanged: 'totalListHeightChanged',
3111
- itemsRendered: 'itemsRendered',
3112
- groupIndices: 'groupIndices'
3113
- }
3114
- }, ListRoot),
3115
- List = _systemToComponent$2.Component,
3116
- usePublisher$2 = _systemToComponent$2.usePublisher,
3117
- useEmitterValue$2 = _systemToComponent$2.useEmitterValue,
3118
- useEmitter$2 = _systemToComponent$2.useEmitter;
3119
- var Scroller$2 = /*#__PURE__*/buildScroller({
3120
- usePublisher: usePublisher$2,
3121
- useEmitterValue: useEmitterValue$2,
3122
- useEmitter: useEmitter$2
3123
- });
3124
- var WindowScroller$2 = /*#__PURE__*/buildWindowScroller({
3125
- usePublisher: usePublisher$2,
3126
- useEmitterValue: useEmitterValue$2,
3127
- useEmitter: useEmitter$2
3128
- });
3129
-
3130
- var Virtuoso = List;
3131
-
3132
- var GroupedVirtuoso = List;
3133
-
3134
- var tableComponentPropsSystem = /*#__PURE__*/u.system(function () {
3135
- var itemContent = u.statefulStream(function (index) {
3136
- return React__namespace.createElement("td", null, "Item $", index);
3137
- });
3138
- var context = u.statefulStream(null);
3139
- var fixedHeaderContent = u.statefulStream(null);
3140
- var components = u.statefulStream({});
3141
- var computeItemKey = u.statefulStream(identity);
3142
- var scrollerRef = u.statefulStream(u.noop);
3143
-
3144
- var distinctProp = function distinctProp(propName, defaultValue) {
3145
- if (defaultValue === void 0) {
3146
- defaultValue = null;
3147
- }
3148
-
3149
- return u.statefulStreamFromEmitter(u.pipe(components, u.map(function (components) {
3150
- return components[propName];
3151
- }), u.distinctUntilChanged()), defaultValue);
3152
- };
3153
-
3154
- return {
3155
- context: context,
3156
- itemContent: itemContent,
3157
- fixedHeaderContent: fixedHeaderContent,
3158
- components: components,
3159
- computeItemKey: computeItemKey,
3160
- scrollerRef: scrollerRef,
3161
- TableComponent: distinctProp('Table', 'table'),
3162
- TableHeadComponent: distinctProp('TableHead', 'thead'),
3163
- TableBodyComponent: distinctProp('TableBody', 'tbody'),
3164
- TableRowComponent: distinctProp('TableRow', 'tr'),
3165
- ScrollerComponent: distinctProp('Scroller', 'div'),
3166
- EmptyPlaceholder: distinctProp('EmptyPlaceholder'),
3167
- ScrollSeekPlaceholder: distinctProp('ScrollSeekPlaceholder')
3168
- };
3169
- });
3170
- var combinedSystem$1 = /*#__PURE__*/u.system(function (_ref) {
3171
- var listSystem = _ref[0],
3172
- propsSystem = _ref[1];
3173
- return _extends({}, listSystem, propsSystem);
3174
- }, /*#__PURE__*/u.tup(listSystem, tableComponentPropsSystem));
3175
-
3176
- var DefaultScrollSeekPlaceholder = function DefaultScrollSeekPlaceholder(_ref2) {
3177
- var height = _ref2.height;
3178
- return React__namespace.createElement("tr", null, React__namespace.createElement("td", {
3179
- style: {
3180
- height: height
3181
- }
3182
- }));
3183
- };
3184
-
3185
- var FillerRow = function FillerRow(_ref3) {
3186
- var height = _ref3.height;
3187
- return React__namespace.createElement("tr", null, React__namespace.createElement("td", {
3188
- style: {
3189
- height: height,
3190
- padding: 0,
3191
- border: 0
3192
- }
3193
- }));
3194
- };
3195
-
3196
- var Items = /*#__PURE__*/React__namespace.memo(function VirtuosoItems() {
3197
- var listState = useEmitterValue$1('listState');
3198
- var deviation = useEmitterValue$1('deviation');
3199
- var sizeRanges = usePublisher$1('sizeRanges');
3200
- var useWindowScroll = useEmitterValue$1('useWindowScroll');
3201
- var customScrollParent = useEmitterValue$1('customScrollParent');
3202
- var windowScrollContainerStateCallback = usePublisher$1('windowScrollContainerState');
3203
-
3204
- var _scrollContainerStateCallback = usePublisher$1('scrollContainerState');
3205
-
3206
- var scrollContainerStateCallback = customScrollParent || useWindowScroll ? windowScrollContainerStateCallback : _scrollContainerStateCallback;
3207
- var itemContent = useEmitterValue$1('itemContent');
3208
- var trackItemSizes = useEmitterValue$1('trackItemSizes');
3209
- var itemSize = useEmitterValue$1('itemSize');
3210
- var log = useEmitterValue$1('log');
3211
- var ref = useChangedListContentsSizes(sizeRanges, itemSize, trackItemSizes, scrollContainerStateCallback, log, customScrollParent);
3212
- var EmptyPlaceholder = useEmitterValue$1('EmptyPlaceholder');
3213
- var ScrollSeekPlaceholder = useEmitterValue$1('ScrollSeekPlaceholder') || DefaultScrollSeekPlaceholder;
3214
- var TableBodyComponent = useEmitterValue$1('TableBodyComponent');
3215
- var TableRowComponent = useEmitterValue$1('TableRowComponent');
3216
- var computeItemKey = useEmitterValue$1('computeItemKey');
3217
- var isSeeking = useEmitterValue$1('isSeeking');
3218
- var paddingTopAddition = useEmitterValue$1('paddingTopAddition');
3219
- var firstItemIndex = useEmitterValue$1('firstItemIndex');
3220
- var statefulTotalCount = useEmitterValue$1('statefulTotalCount');
3221
- var context = useEmitterValue$1('context');
3222
-
3223
- if (statefulTotalCount === 0 && EmptyPlaceholder) {
3224
- return React.createElement(EmptyPlaceholder, contextPropIfNotDomElement(EmptyPlaceholder, context));
3225
- }
3226
-
3227
- var paddingTop = listState.offsetTop + paddingTopAddition + deviation;
3228
- var paddingBottom = listState.offsetBottom;
3229
- var paddingTopEl = paddingTop > 0 ? React__namespace.createElement(FillerRow, {
3230
- height: paddingTop,
3231
- key: "padding-top"
3232
- }) : null;
3233
- var paddingBottomEl = paddingBottom > 0 ? React__namespace.createElement(FillerRow, {
3234
- height: paddingBottom,
3235
- key: "padding-bottom"
3236
- }) : null;
3237
- var items = listState.items.map(function (item) {
3238
- var index = item.originalIndex;
3239
- var key = computeItemKey(index + firstItemIndex, item.data, context);
3240
-
3241
- if (isSeeking) {
3242
- return React.createElement(ScrollSeekPlaceholder, _extends({}, contextPropIfNotDomElement(ScrollSeekPlaceholder, context), {
3243
- key: key,
3244
- index: item.index,
3245
- height: item.size,
3246
- type: item.type || 'item'
3247
- }));
3248
- }
3249
-
3250
- return React.createElement(TableRowComponent, _extends({}, contextPropIfNotDomElement(TableRowComponent, context), {
3251
- key: key,
3252
- 'data-index': index,
3253
- 'data-known-size': item.size,
3254
- 'data-item-index': item.index,
3255
- style: {
3256
- overflowAnchor: 'none'
3257
- }
3258
- }), itemContent(item.index, item.data, context));
3259
- });
3260
- return React.createElement(TableBodyComponent, _extends({
3261
- ref: ref,
3262
- 'data-test-id': 'virtuoso-item-list'
3263
- }, contextPropIfNotDomElement(TableBodyComponent, context)), [paddingTopEl].concat(items, [paddingBottomEl]));
3264
- });
3265
-
3266
- var Viewport$1 = function Viewport(_ref4) {
3267
- var children = _ref4.children;
3268
- var viewportHeight = usePublisher$1('viewportHeight');
3269
- var viewportRef = useSize(u.compose(viewportHeight, function (el) {
3270
- return correctItemSize(el, 'height');
3271
- }));
3272
- return React__namespace.createElement("div", {
3273
- style: viewportStyle,
3274
- ref: viewportRef,
3275
- "data-viewport-type": "element"
3276
- }, children);
3277
- };
3278
-
3279
- var WindowViewport$1 = function WindowViewport(_ref5) {
3280
- var children = _ref5.children;
3281
- var windowViewportRect = usePublisher$1('windowViewportRect');
3282
- var customScrollParent = useEmitterValue$1('customScrollParent');
3283
- var viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
3284
- return React__namespace.createElement("div", {
3285
- ref: viewportRef,
3286
- style: viewportStyle,
3287
- "data-viewport-type": "window"
3288
- }, children);
3289
- };
3290
-
3291
- var TableRoot = /*#__PURE__*/React__namespace.memo(function TableVirtuosoRoot(props) {
3292
- var useWindowScroll = useEmitterValue$1('useWindowScroll');
3293
- var customScrollParent = useEmitterValue$1('customScrollParent');
3294
- var fixedHeaderHeight = usePublisher$1('fixedHeaderHeight');
3295
- var fixedHeaderContent = useEmitterValue$1('fixedHeaderContent');
3296
- var context = useEmitterValue$1('context');
3297
- var theadRef = useSize(u.compose(fixedHeaderHeight, function (el) {
3298
- return correctItemSize(el, 'height');
3299
- }));
3300
- var TheScroller = customScrollParent || useWindowScroll ? WindowScroller$1 : Scroller$1;
3301
- var TheViewport = customScrollParent || useWindowScroll ? WindowViewport$1 : Viewport$1;
3302
- var TheTable = useEmitterValue$1('TableComponent');
3303
- var TheTHead = useEmitterValue$1('TableHeadComponent');
3304
- var theHead = fixedHeaderContent ? React__namespace.createElement(TheTHead, _extends({
3305
- key: 'TableHead',
3306
- style: {
3307
- zIndex: 1,
3308
- position: 'sticky',
3309
- top: 0
3310
- },
3311
- ref: theadRef
3312
- }, contextPropIfNotDomElement(TheTHead, context)), fixedHeaderContent()) : null;
3313
- return React__namespace.createElement(TheScroller, _extends({}, props), React__namespace.createElement(TheViewport, null, React__namespace.createElement(TheTable, _extends({
3314
- style: {
3315
- borderSpacing: 0
3316
- }
3317
- }, contextPropIfNotDomElement(TheTable, context)), [theHead, React__namespace.createElement(Items, {
3318
- key: "TableBody"
3319
- })])));
3320
- });
3321
-
3322
- var _systemToComponent$1 = /*#__PURE__*/reactUrx.systemToComponent(combinedSystem$1, {
3323
- required: {},
3324
- optional: {
3325
- context: 'context',
3326
- followOutput: 'followOutput',
3327
- firstItemIndex: 'firstItemIndex',
3328
- itemContent: 'itemContent',
3329
- fixedHeaderContent: 'fixedHeaderContent',
3330
- overscan: 'overscan',
3331
- increaseViewportBy: 'increaseViewportBy',
3332
- totalCount: 'totalCount',
3333
- topItemCount: 'topItemCount',
3334
- initialTopMostItemIndex: 'initialTopMostItemIndex',
3335
- components: 'components',
3336
- groupCounts: 'groupCounts',
3337
- atBottomThreshold: 'atBottomThreshold',
3338
- computeItemKey: 'computeItemKey',
3339
- defaultItemHeight: 'defaultItemHeight',
3340
- fixedItemHeight: 'fixedItemHeight',
3341
- itemSize: 'itemSize',
3342
- scrollSeekConfiguration: 'scrollSeekConfiguration',
3343
- data: 'data',
3344
- initialItemCount: 'initialItemCount',
3345
- initialScrollTop: 'initialScrollTop',
3346
- alignToBottom: 'alignToBottom',
3347
- useWindowScroll: 'useWindowScroll',
3348
- customScrollParent: 'customScrollParent',
3349
- scrollerRef: 'scrollerRef',
3350
- logLevel: 'logLevel'
3351
- },
3352
- methods: {
3353
- scrollToIndex: 'scrollToIndex',
3354
- scrollIntoView: 'scrollIntoView',
3355
- scrollTo: 'scrollTo',
3356
- scrollBy: 'scrollBy'
3357
- },
3358
- events: {
3359
- isScrolling: 'isScrolling',
3360
- endReached: 'endReached',
3361
- startReached: 'startReached',
3362
- rangeChanged: 'rangeChanged',
3363
- atBottomStateChange: 'atBottomStateChange',
3364
- atTopStateChange: 'atTopStateChange',
3365
- totalListHeightChanged: 'totalListHeightChanged',
3366
- itemsRendered: 'itemsRendered',
3367
- groupIndices: 'groupIndices'
3368
- }
3369
- }, TableRoot),
3370
- Table = _systemToComponent$1.Component,
3371
- usePublisher$1 = _systemToComponent$1.usePublisher,
3372
- useEmitterValue$1 = _systemToComponent$1.useEmitterValue,
3373
- useEmitter$1 = _systemToComponent$1.useEmitter;
3374
- var Scroller$1 = /*#__PURE__*/buildScroller({
3375
- usePublisher: usePublisher$1,
3376
- useEmitterValue: useEmitterValue$1,
3377
- useEmitter: useEmitter$1
3378
- });
3379
- var WindowScroller$1 = /*#__PURE__*/buildWindowScroller({
3380
- usePublisher: usePublisher$1,
3381
- useEmitterValue: useEmitterValue$1,
3382
- useEmitter: useEmitter$1
3383
- });
3384
-
3385
- var TableVirtuoso = Table;
3386
-
3387
- var INITIAL_GRID_STATE = {
3388
- items: [],
3389
- offsetBottom: 0,
3390
- offsetTop: 0,
3391
- top: 0,
3392
- bottom: 0,
3393
- itemHeight: 0,
3394
- itemWidth: 0
3395
- };
3396
- var PROBE_GRID_STATE = {
3397
- items: [{
3398
- index: 0
3399
- }],
3400
- offsetBottom: 0,
3401
- offsetTop: 0,
3402
- top: 0,
3403
- bottom: 0,
3404
- itemHeight: 0,
3405
- itemWidth: 0
3406
- };
3407
- var ceil = Math.ceil,
3408
- floor = Math.floor,
3409
- min = Math.min,
3410
- max = Math.max;
3411
-
3412
- function buildItems(startIndex, endIndex) {
3413
- return Array.from({
3414
- length: endIndex - startIndex + 1
3415
- }).map(function (_, i) {
3416
- return {
3417
- index: i + startIndex
3418
- };
3419
- });
3420
- }
3421
-
3422
- var gridSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
3423
- var _ref$ = _ref[0],
3424
- overscan = _ref$.overscan,
3425
- visibleRange = _ref$.visibleRange,
3426
- listBoundary = _ref$.listBoundary,
3427
- _ref$2 = _ref[1],
3428
- scrollTop = _ref$2.scrollTop,
3429
- viewportHeight = _ref$2.viewportHeight,
3430
- scrollBy = _ref$2.scrollBy,
3431
- scrollTo = _ref$2.scrollTo,
3432
- smoothScrollTargetReached = _ref$2.smoothScrollTargetReached,
3433
- scrollContainerState = _ref$2.scrollContainerState,
3434
- stateFlags = _ref[2],
3435
- scrollSeek = _ref[3],
3436
- _ref$3 = _ref[4],
3437
- propsReady = _ref$3.propsReady,
3438
- didMount = _ref$3.didMount,
3439
- _ref$4 = _ref[5],
3440
- windowViewportRect = _ref$4.windowViewportRect,
3441
- windowScrollTo = _ref$4.windowScrollTo,
3442
- useWindowScroll = _ref$4.useWindowScroll,
3443
- customScrollParent = _ref$4.customScrollParent,
3444
- windowScrollContainerState = _ref$4.windowScrollContainerState;
3445
- var totalCount = u__namespace.statefulStream(0);
3446
- var initialItemCount = u__namespace.statefulStream(0);
3447
- var gridState = u__namespace.statefulStream(INITIAL_GRID_STATE);
3448
- var viewportDimensions = u__namespace.statefulStream({
3449
- height: 0,
3450
- width: 0
3451
- });
3452
- var itemDimensions = u__namespace.statefulStream({
3453
- height: 0,
3454
- width: 0
3455
- });
3456
- var scrollToIndex = u__namespace.stream();
3457
- var scrollHeight = u__namespace.stream();
3458
- var deviation = u__namespace.statefulStream(0);
3459
- u__namespace.connect(u__namespace.pipe(didMount, u__namespace.withLatestFrom(initialItemCount), u__namespace.filter(function (_ref2) {
3460
- var count = _ref2[1];
3461
- return count !== 0;
3462
- }), u__namespace.map(function (_ref3) {
3463
- var count = _ref3[1];
3464
- return {
3465
- items: buildItems(0, count - 1),
3466
- top: 0,
3467
- bottom: 0,
3468
- offsetBottom: 0,
3469
- offsetTop: 0,
3470
- itemHeight: 0,
3471
- itemWidth: 0
3472
- };
3473
- })), gridState);
3474
- u__namespace.connect(u__namespace.pipe(u__namespace.combineLatest(u__namespace.duc(totalCount), visibleRange, u__namespace.duc(itemDimensions, function (prev, next) {
3475
- return prev && prev.width === next.width && prev.height === next.height;
3476
- })), u__namespace.withLatestFrom(viewportDimensions), u__namespace.map(function (_ref4) {
3477
- var _ref4$ = _ref4[0],
3478
- totalCount = _ref4$[0],
3479
- _ref4$$ = _ref4$[1],
3480
- startOffset = _ref4$$[0],
3481
- endOffset = _ref4$$[1],
3482
- item = _ref4$[2],
3483
- viewport = _ref4[1];
3484
- var itemHeight = item.height,
3485
- itemWidth = item.width;
3486
- var viewportWidth = viewport.width;
3487
-
3488
- if (totalCount === 0 || viewportWidth === 0) {
3489
- return INITIAL_GRID_STATE;
3490
- }
3491
-
3492
- if (itemWidth === 0) {
3493
- return PROBE_GRID_STATE;
3494
- }
3495
-
3496
- var perRow = Math.floor(viewportWidth / itemWidth);
3497
- var startIndex = perRow * floor(startOffset / itemHeight);
3498
- var endIndex = perRow * ceil(endOffset / itemHeight) - 1;
3499
- endIndex = min(totalCount - 1, endIndex);
3500
- startIndex = min(endIndex, max(0, startIndex));
3501
- var items = buildItems(startIndex, endIndex);
3502
-
3503
- var _gridLayout = gridLayout(viewport, item, items),
3504
- top = _gridLayout.top,
3505
- bottom = _gridLayout.bottom;
3506
-
3507
- var totalHeight = ceil(totalCount / perRow) * itemHeight;
3508
- var offsetBottom = totalHeight - bottom;
3509
- return {
3510
- items: items,
3511
- offsetTop: top,
3512
- offsetBottom: offsetBottom,
3513
- top: top,
3514
- bottom: bottom,
3515
- itemHeight: itemHeight,
3516
- itemWidth: itemWidth
3517
- };
3518
- })), gridState);
3519
- u__namespace.connect(u__namespace.pipe(viewportDimensions, u__namespace.map(function (_ref5) {
3520
- var height = _ref5.height;
3521
- return height;
3522
- })), viewportHeight);
3523
- u__namespace.connect(u__namespace.pipe(u__namespace.combineLatest(viewportDimensions, itemDimensions, gridState), u__namespace.map(function (_ref6) {
3524
- var viewportDimensions = _ref6[0],
3525
- item = _ref6[1],
3526
- items = _ref6[2].items;
3527
-
3528
- var _gridLayout2 = gridLayout(viewportDimensions, item, items),
3529
- top = _gridLayout2.top,
3530
- bottom = _gridLayout2.bottom;
3531
-
3532
- return [top, bottom];
3533
- }), u__namespace.distinctUntilChanged(tupleComparator)), listBoundary);
3534
- var endReached = u__namespace.streamFromEmitter(u__namespace.pipe(u__namespace.duc(gridState), u__namespace.filter(function (_ref7) {
3535
- var items = _ref7.items;
3536
- return items.length > 0;
3537
- }), u__namespace.withLatestFrom(totalCount), u__namespace.filter(function (_ref8) {
3538
- var items = _ref8[0].items,
3539
- totalCount = _ref8[1];
3540
- return items[items.length - 1].index === totalCount - 1;
3541
- }), u__namespace.map(function (_ref9) {
3542
- var totalCount = _ref9[1];
3543
- return totalCount - 1;
3544
- }), u__namespace.distinctUntilChanged()));
3545
- var startReached = u__namespace.streamFromEmitter(u__namespace.pipe(u__namespace.duc(gridState), u__namespace.filter(function (_ref10) {
3546
- var items = _ref10.items;
3547
- return items.length > 0 && items[0].index === 0;
3548
- }), u__namespace.mapTo(0), u__namespace.distinctUntilChanged()));
3549
- var rangeChanged = u__namespace.streamFromEmitter(u__namespace.pipe(u__namespace.duc(gridState), u__namespace.filter(function (_ref11) {
3550
- var items = _ref11.items;
3551
- return items.length > 0;
3552
- }), u__namespace.map(function (_ref12) {
3553
- var items = _ref12.items;
3554
- return {
3555
- startIndex: items[0].index,
3556
- endIndex: items[items.length - 1].index
3557
- };
3558
- }), u__namespace.distinctUntilChanged(rangeComparator)));
3559
- u__namespace.connect(rangeChanged, scrollSeek.scrollSeekRangeChanged);
3560
- u__namespace.connect(u__namespace.pipe(scrollToIndex, u__namespace.withLatestFrom(viewportDimensions, itemDimensions, totalCount), u__namespace.map(function (_ref13) {
3561
- var location = _ref13[0],
3562
- viewport = _ref13[1],
3563
- item = _ref13[2],
3564
- totalCount = _ref13[3];
3565
- var normalLocation = normalizeIndexLocation(location);
3566
- var align = normalLocation.align,
3567
- behavior = normalLocation.behavior,
3568
- offset = normalLocation.offset;
3569
- var index = normalLocation.index;
3570
-
3571
- if (index === 'LAST') {
3572
- index = totalCount - 1;
3573
- }
3574
-
3575
- index = Math.max(0, index, Math.min(totalCount - 1, index));
3576
- var top = itemTop(viewport, item, index);
3577
-
3578
- if (align === 'end') {
3579
- top = Math.round(top - viewport.height + item.height);
3580
- } else if (align === 'center') {
3581
- top = Math.round(top - viewport.height / 2 + item.height / 2);
3582
- }
3583
-
3584
- if (offset) {
3585
- top += offset;
3586
- }
3587
-
3588
- return {
3589
- top: top,
3590
- behavior: behavior
3591
- };
3592
- })), scrollTo);
3593
- var totalListHeight = u__namespace.statefulStreamFromEmitter(u__namespace.pipe(gridState, u__namespace.map(function (gridState) {
3594
- return gridState.offsetBottom + gridState.bottom;
3595
- })), 0);
3596
- u__namespace.connect(u__namespace.pipe(windowViewportRect, u__namespace.map(function (viewportInfo) {
3597
- return {
3598
- width: viewportInfo.visibleWidth,
3599
- height: viewportInfo.visibleHeight
3600
- };
3601
- })), viewportDimensions);
3602
- return _extends({
3603
- // input
3604
- totalCount: totalCount,
3605
- viewportDimensions: viewportDimensions,
3606
- itemDimensions: itemDimensions,
3607
- scrollTop: scrollTop,
3608
- scrollHeight: scrollHeight,
3609
- overscan: overscan,
3610
- scrollBy: scrollBy,
3611
- scrollTo: scrollTo,
3612
- scrollToIndex: scrollToIndex,
3613
- smoothScrollTargetReached: smoothScrollTargetReached,
3614
- windowViewportRect: windowViewportRect,
3615
- windowScrollTo: windowScrollTo,
3616
- useWindowScroll: useWindowScroll,
3617
- customScrollParent: customScrollParent,
3618
- windowScrollContainerState: windowScrollContainerState,
3619
- deviation: deviation,
3620
- scrollContainerState: scrollContainerState,
3621
- initialItemCount: initialItemCount
3622
- }, scrollSeek, {
3623
- // output
3624
- gridState: gridState,
3625
- totalListHeight: totalListHeight
3626
- }, stateFlags, {
3627
- startReached: startReached,
3628
- endReached: endReached,
3629
- rangeChanged: rangeChanged,
3630
- propsReady: propsReady
3631
- });
3632
- }, /*#__PURE__*/u__namespace.tup(sizeRangeSystem, domIOSystem, stateFlagsSystem, scrollSeekSystem, propsReadySystem, windowScrollerSystem));
3633
-
3634
- function gridLayout(viewport, item, items) {
3635
- var itemHeight = item.height;
3636
-
3637
- if (itemHeight === undefined || items.length === 0) {
3638
- return {
3639
- top: 0,
3640
- bottom: 0
3641
- };
3642
- }
3643
-
3644
- var top = itemTop(viewport, item, items[0].index);
3645
- var bottom = itemTop(viewport, item, items[items.length - 1].index) + itemHeight;
3646
- return {
3647
- top: top,
3648
- bottom: bottom
3649
- };
3650
- }
3651
-
3652
- function itemTop(viewport, item, index) {
3653
- var perRow = itemsPerRow(viewport.width, item.width);
3654
- return floor(index / perRow) * item.height;
3655
- }
3656
-
3657
- function itemsPerRow(viewportWidth, itemWidth) {
3658
- return Math.floor(viewportWidth / itemWidth);
3659
- }
3660
-
3661
- var gridComponentPropsSystem = /*#__PURE__*/u__namespace.system(function () {
3662
- var itemContent = u__namespace.statefulStream(function (index) {
3663
- return "Item " + index;
3664
- });
3665
- var components = u__namespace.statefulStream({});
3666
- var context = u__namespace.statefulStream(null);
3667
- var itemClassName = u__namespace.statefulStream('virtuoso-grid-item');
3668
- var listClassName = u__namespace.statefulStream('virtuoso-grid-list');
3669
- var computeItemKey = u__namespace.statefulStream(identity);
3670
- var scrollerRef = u__namespace.statefulStream(u__namespace.noop);
3671
-
3672
- var distinctProp = function distinctProp(propName, defaultValue) {
3673
- if (defaultValue === void 0) {
3674
- defaultValue = null;
3675
- }
3676
-
3677
- return u__namespace.statefulStreamFromEmitter(u__namespace.pipe(components, u__namespace.map(function (components) {
3678
- return components[propName];
3679
- }), u__namespace.distinctUntilChanged()), defaultValue);
3680
- };
3681
-
3682
- return {
3683
- context: context,
3684
- itemContent: itemContent,
3685
- components: components,
3686
- computeItemKey: computeItemKey,
3687
- itemClassName: itemClassName,
3688
- listClassName: listClassName,
3689
- scrollerRef: scrollerRef,
3690
- ListComponent: distinctProp('List', 'div'),
3691
- ItemComponent: distinctProp('Item', 'div'),
3692
- ScrollerComponent: distinctProp('Scroller', 'div'),
3693
- ScrollSeekPlaceholder: distinctProp('ScrollSeekPlaceholder', 'div')
3694
- };
3695
- });
3696
- var combinedSystem = /*#__PURE__*/u__namespace.system(function (_ref) {
3697
- var gridSystem = _ref[0],
3698
- gridComponentPropsSystem = _ref[1];
3699
- var deprecatedProps = {
3700
- item: addDeprecatedAlias(gridComponentPropsSystem.itemContent, 'Rename the %citem%c prop to %citemContent.'),
3701
- ItemContainer: u__namespace.stream(),
3702
- ScrollContainer: u__namespace.stream(),
3703
- ListContainer: u__namespace.stream(),
3704
- emptyComponent: u__namespace.stream(),
3705
- scrollSeek: u__namespace.stream()
3706
- };
3707
-
3708
- function deprecateComponentProp(stream, componentName, propName) {
3709
- u__namespace.connect(u__namespace.pipe(stream, u__namespace.withLatestFrom(gridComponentPropsSystem.components), u__namespace.map(function (_ref2) {
3710
- var _extends2;
3711
-
3712
- var comp = _ref2[0],
3713
- components = _ref2[1];
3714
- console.warn("react-virtuoso: " + propName + " property is deprecated. Pass components." + componentName + " instead."); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
3715
-
3716
- return _extends({}, components, (_extends2 = {}, _extends2[componentName] = comp, _extends2));
3717
- })), gridComponentPropsSystem.components);
3718
- }
3719
-
3720
- u__namespace.subscribe(deprecatedProps.scrollSeek, function (_ref3) {
3721
- var placeholder = _ref3.placeholder,
3722
- config = _objectWithoutPropertiesLoose(_ref3, ["placeholder"]);
3723
-
3724
- console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead.");
3725
- u__namespace.publish(gridComponentPropsSystem.components, _extends({}, u__namespace.getValue(gridComponentPropsSystem.components), {
3726
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
3727
- ScrollSeekPlaceholder: placeholder
3728
- }));
3729
- u__namespace.publish(gridSystem.scrollSeekConfiguration, config);
3730
- });
3731
- deprecateComponentProp(deprecatedProps.ItemContainer, 'Item', 'ItemContainer');
3732
- deprecateComponentProp(deprecatedProps.ListContainer, 'List', 'ListContainer');
3733
- deprecateComponentProp(deprecatedProps.ScrollContainer, 'Scroller', 'ScrollContainer');
3734
- return _extends({}, gridSystem, gridComponentPropsSystem, deprecatedProps);
3735
- }, /*#__PURE__*/u__namespace.tup(gridSystem, gridComponentPropsSystem));
3736
- var GridItems = /*#__PURE__*/React__namespace.memo(function GridItems() {
3737
- var gridState = useEmitterValue('gridState');
3738
- var listClassName = useEmitterValue('listClassName');
3739
- var itemClassName = useEmitterValue('itemClassName');
3740
- var itemContent = useEmitterValue('itemContent');
3741
- var computeItemKey = useEmitterValue('computeItemKey');
3742
- var isSeeking = useEmitterValue('isSeeking');
3743
- var scrollHeightCallback = usePublisher('scrollHeight');
3744
- var ItemComponent = useEmitterValue('ItemComponent');
3745
- var ListComponent = useEmitterValue('ListComponent');
3746
- var ScrollSeekPlaceholder = useEmitterValue('ScrollSeekPlaceholder');
3747
- var context = useEmitterValue('context');
3748
- var itemDimensions = usePublisher('itemDimensions');
3749
- var listRef = useSize(function (el) {
3750
- var scrollHeight = el.parentElement.parentElement.scrollHeight;
3751
- scrollHeightCallback(scrollHeight);
3752
- var firstItem = el.firstChild;
3753
-
3754
- if (firstItem) {
3755
- itemDimensions(firstItem.getBoundingClientRect());
3756
- }
3757
- });
3758
- return React.createElement(ListComponent, _extends({
3759
- ref: listRef,
3760
- className: listClassName
3761
- }, contextPropIfNotDomElement(ListComponent, context), {
3762
- style: {
3763
- paddingTop: gridState.offsetTop,
3764
- paddingBottom: gridState.offsetBottom
3765
- }
3766
- }), gridState.items.map(function (item) {
3767
- var key = computeItemKey(item.index);
3768
- return isSeeking ? React.createElement(ScrollSeekPlaceholder, _extends({
3769
- key: key
3770
- }, contextPropIfNotDomElement(ScrollSeekPlaceholder, context), {
3771
- index: item.index,
3772
- height: gridState.itemHeight,
3773
- width: gridState.itemWidth
3774
- })) : React.createElement(ItemComponent, _extends({}, contextPropIfNotDomElement(ItemComponent, context), {
3775
- className: itemClassName,
3776
- 'data-index': item.index,
3777
- key: key
3778
- }), itemContent(item.index, context));
3779
- }));
3780
- });
3781
-
3782
- var Viewport = function Viewport(_ref4) {
3783
- var children = _ref4.children;
3784
- var viewportDimensions = usePublisher('viewportDimensions');
3785
- var viewportRef = useSize(function (el) {
3786
- viewportDimensions(el.getBoundingClientRect());
3787
- });
3788
- return React__namespace.createElement("div", {
3789
- style: viewportStyle,
3790
- ref: viewportRef
3791
- }, children);
3792
- };
3793
-
3794
- var WindowViewport = function WindowViewport(_ref5) {
3795
- var children = _ref5.children;
3796
- var windowViewportRect = usePublisher('windowViewportRect');
3797
- var customScrollParent = useEmitterValue('customScrollParent');
3798
- var viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
3799
- return React__namespace.createElement("div", {
3800
- ref: viewportRef,
3801
- style: viewportStyle
3802
- }, children);
3803
- };
3804
-
3805
- var GridRoot = /*#__PURE__*/React__namespace.memo(function GridRoot(_ref6) {
3806
- var props = _extends({}, _ref6);
3807
-
3808
- var useWindowScroll = useEmitterValue('useWindowScroll');
3809
- var customScrollParent = useEmitterValue('customScrollParent');
3810
- var TheScroller = customScrollParent || useWindowScroll ? WindowScroller : Scroller;
3811
- var TheViewport = customScrollParent || useWindowScroll ? WindowViewport : Viewport;
3812
- return React__namespace.createElement(TheScroller, _extends({}, props), React__namespace.createElement(TheViewport, null, React__namespace.createElement(GridItems, null)));
3813
- });
3814
-
3815
- var _systemToComponent = /*#__PURE__*/reactUrx.systemToComponent(combinedSystem, {
3816
- optional: {
3817
- totalCount: 'totalCount',
3818
- overscan: 'overscan',
3819
- itemContent: 'itemContent',
3820
- components: 'components',
3821
- computeItemKey: 'computeItemKey',
3822
- initialItemCount: 'initialItemCount',
3823
- scrollSeekConfiguration: 'scrollSeekConfiguration',
3824
- listClassName: 'listClassName',
3825
- itemClassName: 'itemClassName',
3826
- useWindowScroll: 'useWindowScroll',
3827
- customScrollParent: 'customScrollParent',
3828
- scrollerRef: 'scrollerRef',
3829
- // deprecated
3830
- item: 'item',
3831
- ItemContainer: 'ItemContainer',
3832
- ScrollContainer: 'ScrollContainer',
3833
- ListContainer: 'ListContainer',
3834
- scrollSeek: 'scrollSeek'
3835
- },
3836
- methods: {
3837
- scrollTo: 'scrollTo',
3838
- scrollBy: 'scrollBy',
3839
- scrollToIndex: 'scrollToIndex'
3840
- },
3841
- events: {
3842
- isScrolling: 'isScrolling',
3843
- endReached: 'endReached',
3844
- startReached: 'startReached',
3845
- rangeChanged: 'rangeChanged',
3846
- atBottomStateChange: 'atBottomStateChange',
3847
- atTopStateChange: 'atTopStateChange'
3848
- }
3849
- }, GridRoot),
3850
- Grid = _systemToComponent.Component,
3851
- usePublisher = _systemToComponent.usePublisher,
3852
- useEmitterValue = _systemToComponent.useEmitterValue,
3853
- useEmitter = _systemToComponent.useEmitter;
3854
- var Scroller = /*#__PURE__*/buildScroller({
3855
- usePublisher: usePublisher,
3856
- useEmitterValue: useEmitterValue,
3857
- useEmitter: useEmitter
3858
- });
3859
- var WindowScroller = /*#__PURE__*/buildWindowScroller({
3860
- usePublisher: usePublisher,
3861
- useEmitterValue: useEmitterValue,
3862
- useEmitter: useEmitter
3863
- });
3864
-
3865
- var VirtuosoGrid = Grid;
3866
-
3867
- exports.GroupedVirtuoso = GroupedVirtuoso;
3868
- exports.TableVirtuoso = TableVirtuoso;
3869
- exports.Virtuoso = Virtuoso;
3870
- exports.VirtuosoGrid = VirtuosoGrid;
3871
- //# sourceMappingURL=react-virtuoso.cjs.development.js.map