@ringcentral/juno 2.4.2 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/components/Buttons/IconButton/IconButton.d.ts +10 -2
  2. package/components/Buttons/IconButton/IconButton.js +10 -8
  3. package/components/Buttons/IconButton/styles/StyledIconButton.js +15 -7
  4. package/components/Buttons/IconButton/utils/IconButtonUtils.d.ts +1 -1
  5. package/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
  6. package/components/Dialer/DialPad/DialPad.d.ts +25 -7
  7. package/components/Dialer/DialPad/DialPad.js +6 -6
  8. package/components/Dialer/DialPad/utils/useDialKeyboard.d.ts +8 -9
  9. package/components/Dialer/DialTextField/DialTextField.d.ts +3 -1
  10. package/components/Dialer/DialTextField/DialTextField.js +7 -6
  11. package/components/Downshift/SuggestionList/SuggestionList.d.ts +74 -2
  12. package/components/Downshift/styles/DownshiftStyle.d.ts +1 -1
  13. package/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.d.ts +1 -1
  14. package/components/Forms/Picker/DatePicker/styles/StyledYear.d.ts +1 -1
  15. package/components/Forms/Picker/TimePicker/styles/StyledSelectionItem.d.ts +1 -1
  16. package/components/Forms/Picker/TimePicker/styles/StyledTimeIconButton.d.ts +1 -1
  17. package/components/Forms/Picker/styles/PickerBaseIconButton.d.ts +1 -1
  18. package/components/Forms/TextField/styles/ClearIconButton.d.ts +2 -2
  19. package/components/Grid/Grid.d.ts +1 -1
  20. package/components/Pagination/Pagination/Pagination.d.ts +1 -1
  21. package/components/Stepper/StepButton/StepButton.d.ts +1 -1
  22. package/components/Stepper/StepLabel/StepLabel.d.ts +1 -1
  23. package/components/Table/TableCell/styles/TableCellStyle.js +3 -1
  24. package/components/Table/types.d.ts +1 -1
  25. package/components/TablePagination/TablePagination.d.ts +1 -1
  26. package/components/VirtualizedMenu/VirtualizedMenu.js +11 -0
  27. package/components/VirtualizedMenu/VirtualizedMenuList.js +6 -2
  28. package/components/Virtuoso/react-virtuoso/AATree.js +15 -15
  29. package/components/Virtuoso/react-virtuoso/Grid.d.ts +193 -106
  30. package/components/Virtuoso/react-virtuoso/Grid.js +19 -24
  31. package/components/Virtuoso/react-virtuoso/List.d.ts +2664 -596
  32. package/components/Virtuoso/react-virtuoso/List.js +83 -70
  33. package/components/Virtuoso/react-virtuoso/Table.d.ts +6253 -0
  34. package/components/Virtuoso/react-virtuoso/Table.js +184 -0
  35. package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +153 -37
  36. package/components/Virtuoso/react-virtuoso/components.d.ts +248 -41
  37. package/components/Virtuoso/react-virtuoso/components.js +2 -0
  38. package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +2 -4
  39. package/components/Virtuoso/react-virtuoso/domIOSystem.js +12 -10
  40. package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +146 -27
  41. package/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
  42. package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +67 -52
  43. package/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
  44. package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +17 -3
  45. package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +2 -1
  46. package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +32 -7
  47. package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +1 -1
  48. package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
  49. package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -2
  50. package/components/Virtuoso/react-virtuoso/hooks/useSize.js +26 -28
  51. package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.d.ts +1 -1
  52. package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
  53. package/components/Virtuoso/react-virtuoso/index.d.ts +1 -0
  54. package/components/Virtuoso/react-virtuoso/index.js +2 -0
  55. package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +165 -35
  56. package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
  57. package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +160 -38
  58. package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +54 -12
  59. package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +26 -10
  60. package/components/Virtuoso/react-virtuoso/interfaces.d.ts +134 -28
  61. package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +141 -32
  62. package/components/Virtuoso/react-virtuoso/listStateSystem.js +1 -2
  63. package/components/Virtuoso/react-virtuoso/listSystem.d.ts +2123 -407
  64. package/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
  65. package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +17 -0
  66. package/components/Virtuoso/react-virtuoso/loggerSystem.js +37 -0
  67. package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +8 -1
  68. package/components/Virtuoso/react-virtuoso/propsReadySystem.js +8 -2
  69. package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +641 -0
  70. package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +42 -0
  71. package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +52 -67
  72. package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
  73. package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +26 -5
  74. package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
  75. package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +11 -4
  76. package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +44 -15
  77. package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +12 -2
  78. package/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
  79. package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +17 -5
  80. package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
  81. package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +145 -33
  82. package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +149 -35
  83. package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +183 -42
  84. package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +37 -26
  85. package/components/Virtuoso/react-virtuoso/utils/correctItemSize.d.ts +1 -0
  86. package/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +6 -0
  87. package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +7 -4
  88. package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
  89. package/es6/components/Buttons/IconButton/IconButton.js +12 -10
  90. package/es6/components/Buttons/IconButton/styles/StyledIconButton.js +16 -8
  91. package/es6/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
  92. package/es6/components/Dialer/DialPad/DialPad.js +6 -6
  93. package/es6/components/Dialer/DialTextField/DialTextField.js +7 -6
  94. package/es6/components/Table/TableCell/TableCell.js +2 -2
  95. package/es6/components/Table/TableCell/styles/TableCellStyle.js +3 -1
  96. package/es6/components/VirtualizedMenu/VirtualizedMenu.js +13 -2
  97. package/es6/components/VirtualizedMenu/VirtualizedMenuList.js +6 -2
  98. package/es6/components/Virtuoso/react-virtuoso/AATree.js +15 -15
  99. package/es6/components/Virtuoso/react-virtuoso/Grid.js +20 -25
  100. package/es6/components/Virtuoso/react-virtuoso/List.js +84 -72
  101. package/es6/components/Virtuoso/react-virtuoso/Table.js +182 -0
  102. package/es6/components/Virtuoso/react-virtuoso/components.js +2 -0
  103. package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +13 -10
  104. package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
  105. package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
  106. package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +31 -6
  107. package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
  108. package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +27 -29
  109. package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
  110. package/es6/components/Virtuoso/react-virtuoso/index.js +1 -0
  111. package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
  112. package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +25 -10
  113. package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +2 -3
  114. package/es6/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
  115. package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +34 -0
  116. package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +9 -2
  117. package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +40 -0
  118. package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
  119. package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
  120. package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +39 -11
  121. package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
  122. package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
  123. package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +39 -28
  124. package/es6/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +3 -0
  125. package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
  126. package/es6/foundation/hooks/useEventListener/useEventListener.js +27 -8
  127. package/es6/foundation/hooks/useGlobalListener/createGlobalListener.js +81 -0
  128. package/es6/foundation/hooks/useGlobalListener/index.js +1 -0
  129. package/es6/foundation/hooks/useGlobalListener/useGlobalListener.js +67 -97
  130. package/es6/foundation/hooks/useLongPress/useLongPress.js +52 -33
  131. package/es6/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +27 -28
  132. package/foundation/hooks/useEventListener/useEventListener.d.ts +12 -16
  133. package/foundation/hooks/useEventListener/useEventListener.js +26 -7
  134. package/foundation/hooks/useGlobalListener/createGlobalListener.d.ts +55 -0
  135. package/foundation/hooks/useGlobalListener/createGlobalListener.js +83 -0
  136. package/foundation/hooks/useGlobalListener/index.d.ts +1 -0
  137. package/foundation/hooks/useGlobalListener/index.js +1 -0
  138. package/foundation/hooks/useGlobalListener/useGlobalListener.d.ts +11 -105
  139. package/foundation/hooks/useGlobalListener/useGlobalListener.js +67 -97
  140. package/foundation/hooks/useLongPress/useLongPress.d.ts +10 -8
  141. package/foundation/hooks/useLongPress/useLongPress.js +50 -31
  142. package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.d.ts +27 -14
  143. package/foundation/hooks/useTouchMouseEvent/useTouchMouseEvent.js +27 -28
  144. package/foundation/typings/deepPartial.d.ts +1 -1
  145. package/package.json +2 -2
@@ -1,37 +1,40 @@
1
+ import { __read } from "tslib";
1
2
  import * as u from '@virtuoso.dev/urx';
2
- export var UP = 'up';
3
- export var DOWN = 'down';
4
3
  export var domIOSystem = u.system(function () {
4
+ var scrollContainerState = u.stream();
5
5
  var scrollTop = u.stream();
6
6
  var deviation = u.statefulStream(0);
7
7
  var smoothScrollTargetReached = u.stream();
8
8
  var statefulScrollTop = u.statefulStream(0);
9
9
  var viewportHeight = u.stream();
10
+ var scrollHeight = u.stream();
10
11
  var headerHeight = u.statefulStream(0);
11
12
  var footerHeight = u.statefulStream(0);
12
13
  var scrollTo = u.stream();
13
14
  var scrollBy = u.stream();
14
15
  var scrollingInProgress = u.statefulStream(false);
16
+ u.connect(u.pipe(scrollContainerState, u.map(function (_a) {
17
+ var _b = __read(_a, 1), scrollTop = _b[0];
18
+ return scrollTop;
19
+ })), scrollTop);
20
+ u.connect(u.pipe(scrollContainerState, u.map(function (_a) {
21
+ var _b = __read(_a, 2), scrollHeight = _b[1];
22
+ return scrollHeight;
23
+ })), scrollHeight);
15
24
  u.connect(scrollTop, statefulScrollTop);
16
- var scrollDirection = u.statefulStream(DOWN);
17
- u.connect(u.pipe(scrollTop, u.scan(function (acc, scrollTop) {
18
- return {
19
- direction: scrollTop < acc.prevScrollTop ? UP : DOWN,
20
- prevScrollTop: scrollTop,
21
- };
22
- }, { direction: DOWN, prevScrollTop: 0 }), u.map(function (value) { return value.direction; })), scrollDirection);
23
25
  return {
24
26
  // input
27
+ scrollContainerState: scrollContainerState,
25
28
  scrollTop: scrollTop,
26
29
  viewportHeight: viewportHeight,
27
30
  headerHeight: headerHeight,
28
31
  footerHeight: footerHeight,
32
+ scrollHeight: scrollHeight,
29
33
  smoothScrollTargetReached: smoothScrollTargetReached,
30
34
  // signals
31
35
  scrollTo: scrollTo,
32
36
  scrollBy: scrollBy,
33
37
  // state
34
- scrollDirection: scrollDirection,
35
38
  statefulScrollTop: statefulScrollTop,
36
39
  deviation: deviation,
37
40
  scrollingInProgress: scrollingInProgress,
@@ -1,6 +1,8 @@
1
1
  import { __read } from "tslib";
2
2
  import * as u from '@virtuoso.dev/urx';
3
+ import { domIOSystem } from './domIOSystem';
3
4
  import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
5
+ import { loggerSystem, LogLevel } from './loggerSystem';
4
6
  import { propsReadySystem } from './propsReadySystem';
5
7
  import { scrollToIndexSystem } from './scrollToIndexSystem';
6
8
  import { sizeSystem } from './sizeSystem';
@@ -18,21 +20,24 @@ var behaviorFromFollowOutput = function (follow, isAtBottom) {
18
20
  return isAtBottom && normalizeFollowOutput(follow);
19
21
  };
20
22
  export var followOutputSystem = u.system(function (_a) {
21
- var _b = __read(_a, 5), _c = _b[0], totalCount = _c.totalCount, listRefresh = _c.listRefresh, _d = _b[1], isAtBottom = _d.isAtBottom, atBottomState = _d.atBottomState, scrollToIndex = _b[2].scrollToIndex, scrolledToInitialItem = _b[3].scrolledToInitialItem, _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount;
23
+ var _b = __read(_a, 7), _c = _b[0], totalCount = _c.totalCount, listRefresh = _c.listRefresh, _d = _b[1], isAtBottom = _d.isAtBottom, atBottomState = _d.atBottomState, scrollToIndex = _b[2].scrollToIndex, scrolledToInitialItem = _b[3].scrolledToInitialItem, _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount, log = _b[5].log, scrollingInProgress = _b[6].scrollingInProgress;
22
24
  var followOutput = u.statefulStream(false);
23
- function scrollToBottom(totalCount, followOutputBehavior) {
25
+ var pendingScrollHandle = null;
26
+ function scrollToBottom(followOutputBehavior) {
24
27
  u.publish(scrollToIndex, {
25
- index: totalCount - 1,
28
+ index: 'LAST',
26
29
  align: 'end',
27
30
  behavior: followOutputBehavior,
28
31
  });
29
32
  }
30
- u.subscribe(u.pipe(u.combineLatest(u.duc(totalCount), didMount), u.withLatestFrom(u.duc(followOutput), isAtBottom, scrolledToInitialItem), u.map(function (_a) {
31
- var _b = __read(_a, 4), _c = __read(_b[0], 2), totalCount = _c[0], didMount = _c[1], followOutput = _b[1], isAtBottom = _b[2], scrolledToInitialItem = _b[3];
33
+ u.subscribe(u.pipe(u.combineLatest(u.pipe(u.duc(totalCount), u.skip(1)), didMount), u.withLatestFrom(u.duc(followOutput), isAtBottom, scrolledToInitialItem, scrollingInProgress), u.map(function (_a) {
34
+ var _b = __read(_a, 5), _c = __read(_b[0], 2), totalCount = _c[0], didMount = _c[1], followOutput = _b[1], isAtBottom = _b[2], scrolledToInitialItem = _b[3], scrollingInProgress = _b[4];
32
35
  var shouldFollow = didMount && scrolledToInitialItem;
33
36
  var followOutputBehavior = 'auto';
34
37
  if (shouldFollow) {
35
- followOutputBehavior = behaviorFromFollowOutput(followOutput, isAtBottom);
38
+ // if scrolling to index is in progress,
39
+ // assume that a previous followOutput response is going
40
+ followOutputBehavior = behaviorFromFollowOutput(followOutput, isAtBottom || scrollingInProgress);
36
41
  shouldFollow = shouldFollow && !!followOutputBehavior;
37
42
  }
38
43
  return { totalCount: totalCount, shouldFollow: shouldFollow, followOutputBehavior: followOutputBehavior };
@@ -41,8 +46,14 @@ export var followOutputSystem = u.system(function (_a) {
41
46
  return shouldFollow;
42
47
  })), function (_a) {
43
48
  var totalCount = _a.totalCount, followOutputBehavior = _a.followOutputBehavior;
44
- u.handleNext(listRefresh, function () {
45
- scrollToBottom(totalCount, followOutputBehavior);
49
+ if (pendingScrollHandle) {
50
+ pendingScrollHandle();
51
+ pendingScrollHandle = null;
52
+ }
53
+ pendingScrollHandle = u.handleNext(listRefresh, function () {
54
+ u.getValue(log)('following output to ', { totalCount: totalCount }, LogLevel.DEBUG);
55
+ scrollToBottom(followOutputBehavior);
56
+ pendingScrollHandle = null;
46
57
  });
47
58
  });
48
59
  u.subscribe(u.pipe(u.combineLatest(u.duc(followOutput), totalCount, propsReady), u.filter(function (_a) {
@@ -56,23 +67,25 @@ export var followOutputSystem = u.system(function (_a) {
56
67
  var refreshed = _a.refreshed;
57
68
  return refreshed;
58
69
  }), u.withLatestFrom(followOutput, totalCount)), function (_a) {
59
- var _b = __read(_a, 3), followOutput = _b[1], totalCount = _b[2];
70
+ var _b = __read(_a, 2), followOutput = _b[1];
60
71
  var cancel = u.handleNext(atBottomState, function (state) {
61
72
  if (followOutput &&
62
73
  !state.atBottom &&
63
- state.notAtBottomBecause === 'SIZE_INCREASED') {
64
- scrollToBottom(totalCount, 'auto');
74
+ state.notAtBottomBecause === 'SIZE_INCREASED' &&
75
+ !pendingScrollHandle) {
76
+ u.getValue(log)('scrolling to bottom due to increased size', {}, LogLevel.DEBUG);
77
+ scrollToBottom('auto');
65
78
  }
66
79
  });
67
80
  setTimeout(cancel, 100);
68
81
  });
69
- u.subscribe(u.pipe(u.combineLatest(u.duc(followOutput), atBottomState), u.withLatestFrom(totalCount)), function (_a) {
70
- var _b = __read(_a, 2), _c = __read(_b[0], 2), followOutput = _c[0], state = _c[1], totalCount = _b[1];
82
+ u.subscribe(u.combineLatest(u.duc(followOutput), atBottomState), function (_a) {
83
+ var _b = __read(_a, 2), followOutput = _b[0], state = _b[1];
71
84
  if (followOutput &&
72
85
  !state.atBottom &&
73
86
  state.notAtBottomBecause === 'VIEWPORT_HEIGHT_DECREASING') {
74
- scrollToBottom(totalCount, 'auto');
87
+ scrollToBottom('auto');
75
88
  }
76
89
  });
77
90
  return { followOutput: followOutput };
78
- }, u.tup(sizeSystem, stateFlagsSystem, scrollToIndexSystem, initialTopMostItemIndexSystem, propsReadySystem));
91
+ }, u.tup(sizeSystem, stateFlagsSystem, scrollToIndexSystem, initialTopMostItemIndexSystem, propsReadySystem, loggerSystem, domIOSystem));
@@ -26,15 +26,12 @@ var PROBE_GRID_STATE = {
26
26
  itemHeight: 0,
27
27
  itemWidth: 0,
28
28
  };
29
- var ceil = Math.ceil, floor = Math.floor, min = Math.min, max = Math.max;
30
- function hackFloor(val) {
31
- return ceil(val) - val < 0.03 ? ceil(val) : floor(val);
32
- }
29
+ var round = Math.round, ceil = Math.ceil, floor = Math.floor, min = Math.min, max = Math.max;
33
30
  function buildItems(startIndex, endIndex) {
34
31
  return Array.from({ length: endIndex - startIndex + 1 }).map(function (_, i) { return ({ index: i + startIndex }); });
35
32
  }
36
33
  export var gridSystem = u.system(function (_a) {
37
- var _b = __read(_a, 6), _c = _b[0], overscan = _c.overscan, visibleRange = _c.visibleRange, listBoundary = _c.listBoundary, _d = _b[1], scrollTop = _d.scrollTop, viewportHeight = _d.viewportHeight, scrollBy = _d.scrollBy, scrollTo = _d.scrollTo, smoothScrollTargetReached = _d.smoothScrollTargetReached, stateFlags = _b[2], scrollSeek = _b[3], _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount, _f = _b[5], windowViewportRect = _f.windowViewportRect, windowScrollTo = _f.windowScrollTo, useWindowScroll = _f.useWindowScroll, windowScrollTop = _f.windowScrollTop;
34
+ var _b = __read(_a, 6), _c = _b[0], overscan = _c.overscan, visibleRange = _c.visibleRange, listBoundary = _c.listBoundary, _d = _b[1], scrollTop = _d.scrollTop, viewportHeight = _d.viewportHeight, scrollBy = _d.scrollBy, scrollTo = _d.scrollTo, smoothScrollTargetReached = _d.smoothScrollTargetReached, scrollContainerState = _d.scrollContainerState, stateFlags = _b[2], scrollSeek = _b[3], _e = _b[4], propsReady = _e.propsReady, didMount = _e.didMount, _f = _b[5], windowViewportRect = _f.windowViewportRect, windowScrollTo = _f.windowScrollTo, useWindowScroll = _f.useWindowScroll, customScrollParent = _f.customScrollParent, windowScrollContainerState = _f.windowScrollContainerState;
38
35
  var totalCount = u.statefulStream(0);
39
36
  var initialItemCount = u.statefulStream(0);
40
37
  var gridState = u.statefulStream(INITIAL_GRID_STATE);
@@ -47,6 +44,8 @@ export var gridSystem = u.system(function (_a) {
47
44
  width: 0,
48
45
  });
49
46
  var scrollToIndex = u.stream();
47
+ var scrollHeight = u.stream();
48
+ var deviation = u.statefulStream(0);
50
49
  u.connect(u.pipe(didMount, u.withLatestFrom(initialItemCount), u.filter(function (_a) {
51
50
  var _b = __read(_a, 2), count = _b[1];
52
51
  return count !== 0;
@@ -74,7 +73,7 @@ export var gridSystem = u.system(function (_a) {
74
73
  if (itemWidth === 0) {
75
74
  return PROBE_GRID_STATE;
76
75
  }
77
- var perRow = hackFloor(viewportWidth / itemWidth);
76
+ var perRow = itemsPerRow(viewportWidth, itemWidth);
78
77
  var startIndex = perRow * floor(startOffset / itemHeight);
79
78
  var endIndex = perRow * ceil(endOffset / itemHeight) - 1;
80
79
  endIndex = min(totalCount - 1, endIndex);
@@ -102,10 +101,6 @@ export var gridSystem = u.system(function (_a) {
102
101
  var _c = gridLayout(viewportDimensions, item, items), top = _c.top, bottom = _c.bottom;
103
102
  return [top, bottom];
104
103
  }), u.distinctUntilChanged(tupleComparator)), listBoundary);
105
- u.connect(u.pipe(listBoundary, u.withLatestFrom(gridState), u.map(function (_a) {
106
- var _b = __read(_a, 2), _c = __read(_b[0], 2), bottom = _c[1], offsetBottom = _b[1].offsetBottom;
107
- return { bottom: bottom, offsetBottom: offsetBottom };
108
- })), stateFlags.listStateListener);
109
104
  var endReached = u.streamFromEmitter(u.pipe(u.duc(gridState), u.filter(function (_a) {
110
105
  var items = _a.items;
111
106
  return items.length > 0;
@@ -136,13 +131,16 @@ export var gridSystem = u.system(function (_a) {
136
131
  var normalLocation = normalizeIndexLocation(location);
137
132
  var align = normalLocation.align, behavior = normalLocation.behavior, offset = normalLocation.offset;
138
133
  var index = normalLocation.index;
139
- index = Math.max(0, index, Math.min(totalCount - 1, index));
134
+ if (index === 'LAST') {
135
+ index = totalCount - 1;
136
+ }
137
+ index = max(0, index, min(totalCount - 1, index));
140
138
  var top = itemTop(viewport, item, index);
141
139
  if (align === 'end') {
142
- top = Math.round(top - viewport.height + item.height);
140
+ top = round(top - viewport.height + item.height);
143
141
  }
144
142
  else if (align === 'center') {
145
- top = Math.round(top - viewport.height / 2 + item.height / 2);
143
+ top = round(top - viewport.height / 2 + item.height / 2);
146
144
  }
147
145
  if (offset) {
148
146
  top += offset;
@@ -162,6 +160,7 @@ export var gridSystem = u.system(function (_a) {
162
160
  viewportDimensions: viewportDimensions,
163
161
  itemDimensions: itemDimensions,
164
162
  scrollTop: scrollTop,
163
+ scrollHeight: scrollHeight,
165
164
  overscan: overscan,
166
165
  scrollBy: scrollBy,
167
166
  scrollTo: scrollTo,
@@ -170,7 +169,10 @@ export var gridSystem = u.system(function (_a) {
170
169
  windowViewportRect: windowViewportRect,
171
170
  windowScrollTo: windowScrollTo,
172
171
  useWindowScroll: useWindowScroll,
173
- windowScrollTop: windowScrollTop,
172
+ customScrollParent: customScrollParent,
173
+ windowScrollContainerState: windowScrollContainerState,
174
+ deviation: deviation,
175
+ scrollContainerState: scrollContainerState,
174
176
  initialItemCount: initialItemCount }, scrollSeek), {
175
177
  // output
176
178
  gridState: gridState,
@@ -193,5 +195,5 @@ function itemTop(viewport, item, index) {
193
195
  return floor(index / perRow) * item.height;
194
196
  }
195
197
  function itemsPerRow(viewportWidth, itemWidth) {
196
- return hackFloor(viewportWidth / itemWidth);
198
+ return max(1, floor(viewportWidth / itemWidth));
197
199
  }
@@ -1,13 +1,37 @@
1
+ /* eslint-disable no-continue */
2
+ import { useRcPortalWindowContext } from '../../../../foundation';
3
+ import { LogLevel } from '../loggerSystem';
1
4
  import useSize from './useSize';
2
- export default function useChangedChildSizes(callback, itemSize, enabled) {
5
+ export default function useChangedListContentsSizes(callback, itemSize, enabled, scrollContainerStateCallback, log, customScrollParent) {
6
+ var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
3
7
  return useSize(function (el) {
4
- var ranges = getChangedChildSizes(el.children, itemSize, 'offsetHeight');
8
+ var ranges = getChangedChildSizes(el.children, itemSize, 'offsetHeight', log);
9
+ var scrollableElement = el.parentElement;
10
+ while (!scrollableElement.dataset['virtuosoScroller']) {
11
+ scrollableElement = scrollableElement.parentElement;
12
+ }
13
+ var scrollTop = customScrollParent
14
+ ? customScrollParent.scrollTop
15
+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
16
+ scrollableElement.firstElementChild.dataset['viewportType'] === 'window'
17
+ ? externalWindow.pageYOffset ||
18
+ externalWindow.document.documentElement.scrollTop
19
+ : scrollableElement.scrollTop;
20
+ customScrollParent
21
+ ? scrollContainerStateCallback([
22
+ Math.max(scrollTop, 0),
23
+ customScrollParent.scrollHeight,
24
+ ])
25
+ : scrollContainerStateCallback([
26
+ Math.max(scrollTop, 0),
27
+ scrollableElement.scrollHeight,
28
+ ]);
5
29
  if (ranges !== null) {
6
30
  callback(ranges);
7
31
  }
8
32
  }, enabled);
9
33
  }
10
- function getChangedChildSizes(children, itemSize, field) {
34
+ function getChangedChildSizes(children, itemSize, field, log) {
11
35
  var length = children.length;
12
36
  if (length === 0) {
13
37
  return null;
@@ -18,11 +42,12 @@ function getChangedChildSizes(children, itemSize, field) {
18
42
  if (!child || child.dataset.index === undefined) {
19
43
  continue;
20
44
  }
21
- var index = parseInt(child.dataset.index, 10);
22
- var knownSize = parseInt(child.dataset.knownSize, 10);
45
+ // eslint-disable-next-line radix
46
+ var index = parseInt(child.dataset.index);
47
+ var knownSize = parseFloat(child.dataset.knownSize);
23
48
  var size = itemSize(child, field);
24
49
  if (size === 0) {
25
- throw new Error('Zero-sized element, this should not happen');
50
+ log('Zero-sized element, this should not happen', { child: child }, LogLevel.ERROR);
26
51
  }
27
52
  if (size === knownSize) {
28
53
  continue;
@@ -1,22 +1,31 @@
1
1
  import { useCallback, useEffect, useRef } from 'react';
2
2
  import * as u from '@virtuoso.dev/urx';
3
- export default function useScrollTop(scrollTopCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback, customWindow) {
3
+ import { correctItemSize } from '../utils/correctItemSize';
4
+ import { useRcPortalWindowContext } from '../../../../foundation';
5
+ function approximatelyEqual(num1, num2) {
6
+ return Math.abs(num1 - num2) < 1.01;
7
+ }
8
+ export default function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback, customScrollParent) {
4
9
  if (scrollerRefCallback === void 0) { scrollerRefCallback = u.noop; }
5
- if (customWindow === void 0) { customWindow = window; }
6
10
  var scrollerRef = useRef(null);
7
11
  var scrollTopTarget = useRef(null);
8
12
  var timeoutRef = useRef(null);
9
- var customDocument = customWindow.document;
13
+ var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
10
14
  var handler = useCallback(function (ev) {
11
15
  var el = ev.target;
12
- var scrollTop = el === customWindow || el === customDocument
13
- ? customWindow.pageYOffset || customDocument.documentElement.scrollTop
16
+ var scrollTop = el === externalWindow ||
17
+ el === externalWindow.document
18
+ ? externalWindow.pageYOffset ||
19
+ externalWindow.document.documentElement.scrollTop
14
20
  : el.scrollTop;
15
- scrollTopCallback(Math.max(scrollTop, 0));
21
+ var scrollHeight = el === externalWindow
22
+ ? externalWindow.document.documentElement.scrollHeight
23
+ : el.scrollHeight;
24
+ scrollContainerStateCallback([Math.max(scrollTop, 0), scrollHeight]);
16
25
  if (scrollTopTarget.current !== null) {
17
26
  if (scrollTop === scrollTopTarget.current ||
18
27
  scrollTop <= 0 ||
19
- scrollTop === el.scrollHeight - el.offsetHeight) {
28
+ scrollTop === el.scrollHeight - correctItemSize(el, 'height')) {
20
29
  scrollTopTarget.current = null;
21
30
  smoothScrollTargetReached(true);
22
31
  if (timeoutRef.current) {
@@ -25,54 +34,59 @@ export default function useScrollTop(scrollTopCallback, smoothScrollTargetReache
25
34
  }
26
35
  }
27
36
  }
28
- }, [
29
- customDocument,
30
- customWindow,
31
- scrollTopCallback,
32
- smoothScrollTargetReached,
33
- ]);
37
+ }, [externalWindow, scrollContainerStateCallback, smoothScrollTargetReached]);
34
38
  useEffect(function () {
35
- var localRef = scrollerRef.current;
36
- scrollerRefCallback(scrollerRef.current);
39
+ var localRef = customScrollParent
40
+ ? customScrollParent
41
+ : scrollerRef.current;
42
+ scrollerRefCallback(customScrollParent ? customScrollParent : scrollerRef.current);
37
43
  handler({ target: localRef });
38
44
  localRef.addEventListener('scroll', handler, { passive: true });
39
45
  return function () {
40
46
  scrollerRefCallback(null);
41
47
  localRef.removeEventListener('scroll', handler);
42
48
  };
43
- }, [scrollerRef, handler, scrollerElement, scrollerRefCallback]);
49
+ }, [
50
+ scrollerRef,
51
+ handler,
52
+ scrollerElement,
53
+ scrollerRefCallback,
54
+ customScrollParent,
55
+ ]);
44
56
  function scrollToCallback(location) {
45
57
  var scrollerElement = scrollerRef.current;
46
- if (!scrollerElement) {
58
+ if (!scrollerElement ||
59
+ ('offsetHeight' in scrollerElement && scrollerElement.offsetHeight === 0)) {
47
60
  return;
48
61
  }
49
62
  var isSmooth = location.behavior === 'smooth';
50
63
  var offsetHeight;
51
64
  var scrollHeight;
52
65
  var scrollTop;
53
- if (scrollerElement === customWindow) {
66
+ if (scrollerElement === externalWindow) {
54
67
  // this is not a mistake
55
- scrollHeight = Math.max(customDocument.documentElement.offsetHeight, customDocument.documentElement.scrollHeight);
56
- offsetHeight = customWindow.innerHeight;
57
- scrollTop = customDocument.documentElement.scrollTop;
68
+ scrollHeight = Math.max(correctItemSize(externalWindow.document.documentElement, 'height'), externalWindow.document.documentElement.scrollHeight);
69
+ offsetHeight = externalWindow.window.innerHeight;
70
+ scrollTop = externalWindow.document.documentElement.scrollTop;
58
71
  }
59
72
  else {
60
73
  scrollHeight = scrollerElement.scrollHeight;
61
- offsetHeight = scrollerElement.offsetHeight;
74
+ offsetHeight = correctItemSize(scrollerElement, 'height');
62
75
  scrollTop = scrollerElement.scrollTop;
63
76
  }
77
+ var maxScrollTop = scrollHeight - offsetHeight;
78
+ location.top = Math.ceil(Math.max(Math.min(maxScrollTop, location.top), 0));
64
79
  // avoid system hanging because the DOM never called back
65
80
  // with the scrollTop
66
81
  // scroller is already at this location
67
- if (offsetHeight === scrollHeight || location.top === scrollTop) {
68
- scrollTopCallback(scrollTop);
82
+ if (approximatelyEqual(offsetHeight, scrollHeight) ||
83
+ location.top === scrollTop) {
84
+ scrollContainerStateCallback([scrollTop, scrollHeight]);
69
85
  if (isSmooth) {
70
86
  smoothScrollTargetReached(true);
71
87
  }
72
88
  return;
73
89
  }
74
- var maxScrollTop = scrollHeight - offsetHeight;
75
- location.top = Math.max(Math.min(maxScrollTop, location.top), 0);
76
90
  if (isSmooth) {
77
91
  scrollTopTarget.current = location.top;
78
92
  if (timeoutRef.current) {
@@ -1,37 +1,35 @@
1
1
  import { useRef } from 'react';
2
- import { getResizeObserver, useRcPortalWindowContext, } from '../../../../foundation';
2
+ import { useRcPortalWindowContext } from '../../../../foundation';
3
3
  export function useSizeWithElRef(callback, enabled) {
4
4
  if (enabled === void 0) { enabled = true; }
5
- var externalWindow = useRcPortalWindowContext().externalWindow;
6
5
  var ref = useRef(null);
7
- var observer = getResizeObserver(function (entries) {
8
- var element = entries[0].target;
9
- // Revert the RAF below - it causes a blink in the upward scrolling fix
10
- // See e2e/chat example
11
- // Avoid Resize loop limit exceeded error
12
- // https://github.com/edunad/react-virtuoso/commit/581d4558f2994adea375291b76fe59605556c08f
13
- // requestAnimationFrame(() => {
14
- //
15
- // if display: none, the element won't have an offsetParent
16
- // measuring it at this mode is not going to work
17
- // https://stackoverflow.com/a/21696585/1009797
18
- if (element.offsetParent !== null) {
19
- callback(element);
20
- }
21
- // })
22
- }, externalWindow);
23
- var callbackRef = function (elRef) {
24
- if (elRef && enabled) {
25
- observer.observe(elRef);
26
- ref.current = elRef;
27
- }
28
- else {
29
- if (ref.current) {
30
- observer.unobserve(ref.current);
31
- }
32
- ref.current = null;
33
- }
6
+ var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+ var callbackRef = function (_el) {
9
+ // eslint-disable-next-line no-void
10
+ void 0;
34
11
  };
12
+ // TODO: fix after upgrade ts
13
+ if (typeof externalWindow['ResizeObserver'] !== 'undefined') {
14
+ var observer_1 = new externalWindow['ResizeObserver'](function (entries) {
15
+ var element = entries[0].target;
16
+ if (element.offsetParent !== null) {
17
+ callback(element);
18
+ }
19
+ });
20
+ callbackRef = function (elRef) {
21
+ if (elRef && enabled) {
22
+ observer_1.observe(elRef);
23
+ ref.current = elRef;
24
+ }
25
+ else {
26
+ if (ref.current) {
27
+ observer_1.unobserve(ref.current);
28
+ }
29
+ ref.current = null;
30
+ }
31
+ };
32
+ }
35
33
  return { ref: ref, callbackRef: callbackRef };
36
34
  }
37
35
  export default function useSize(callback, enabled) {
@@ -1,34 +1,54 @@
1
1
  import { useCallback, useEffect, useRef } from 'react';
2
+ import { useRcPortalWindowContext } from '../../../../foundation';
2
3
  import { useSizeWithElRef } from './useSize';
3
- export default function useWindowViewportRectRef(callback, customWindow) {
4
- if (customWindow === void 0) { customWindow = window; }
4
+ export default function useWindowViewportRectRef(callback, customScrollParent) {
5
5
  var viewportInfo = useRef(null);
6
+ var _a = useRcPortalWindowContext().externalWindow, externalWindow = _a === void 0 ? window : _a;
6
7
  var calculateInfo = useCallback(function (element) {
7
8
  if (element === null) {
8
9
  return;
9
10
  }
10
11
  var rect = element.getBoundingClientRect();
11
- var visibleHeight = customWindow.innerHeight - Math.max(0, rect.top);
12
12
  var visibleWidth = rect.width;
13
- var offsetTop = rect.top + customWindow.pageYOffset;
13
+ var visibleHeight;
14
+ var offsetTop;
15
+ if (customScrollParent) {
16
+ var customScrollParentRect = customScrollParent.getBoundingClientRect();
17
+ var deltaTop = rect.top - customScrollParentRect.top;
18
+ visibleHeight = customScrollParentRect.height - Math.max(0, deltaTop);
19
+ offsetTop = deltaTop + customScrollParent.scrollTop;
20
+ }
21
+ else {
22
+ visibleHeight = externalWindow.innerHeight - Math.max(0, rect.top);
23
+ offsetTop = rect.top + externalWindow.pageYOffset;
24
+ }
14
25
  viewportInfo.current = {
15
26
  offsetTop: offsetTop,
16
27
  visibleHeight: visibleHeight,
17
28
  visibleWidth: visibleWidth,
18
29
  };
19
30
  callback(viewportInfo.current);
20
- }, [callback, customWindow]);
21
- var _a = useSizeWithElRef(calculateInfo), callbackRef = _a.callbackRef, ref = _a.ref;
22
- var windowEH = useCallback(function () {
31
+ }, [callback, customScrollParent, externalWindow]);
32
+ var _b = useSizeWithElRef(calculateInfo), callbackRef = _b.callbackRef, ref = _b.ref;
33
+ var scrollAndResizeEventHandler = useCallback(function () {
23
34
  calculateInfo(ref.current);
24
35
  }, [calculateInfo, ref]);
25
36
  useEffect(function () {
26
- customWindow.addEventListener('scroll', windowEH);
27
- customWindow.addEventListener('resize', windowEH);
37
+ if (customScrollParent) {
38
+ customScrollParent.addEventListener('scroll', scrollAndResizeEventHandler);
39
+ var observer_1 = new externalWindow['ResizeObserver'](scrollAndResizeEventHandler);
40
+ observer_1.observe(customScrollParent);
41
+ return function () {
42
+ customScrollParent.removeEventListener('scroll', scrollAndResizeEventHandler);
43
+ observer_1.unobserve(customScrollParent);
44
+ };
45
+ }
46
+ externalWindow.addEventListener('scroll', scrollAndResizeEventHandler);
47
+ externalWindow.addEventListener('resize', scrollAndResizeEventHandler);
28
48
  return function () {
29
- customWindow.removeEventListener('scroll', windowEH);
30
- customWindow.removeEventListener('resize', windowEH);
49
+ externalWindow.removeEventListener('scroll', scrollAndResizeEventHandler);
50
+ externalWindow.removeEventListener('resize', scrollAndResizeEventHandler);
31
51
  };
32
- }, [customWindow, windowEH]);
52
+ }, [scrollAndResizeEventHandler, customScrollParent, externalWindow]);
33
53
  return callbackRef;
34
54
  }
@@ -1 +1,2 @@
1
1
  export * from './components';
2
+ export { LogLevel } from './loggerSystem';
@@ -32,14 +32,7 @@ export var initialItemCountSystem = u.system(function (_a) {
32
32
  }
33
33
  }
34
34
  var adjustedCount = count + includedGroupsCount;
35
- var items = Array.from({
36
- length: adjustedCount,
37
- }).map(function (_, index) { return ({
38
- index: index,
39
- size: 0,
40
- offset: 0,
41
- data: data[index],
42
- }); });
35
+ var items = Array.from({ length: adjustedCount }).map(function (_, index) { return ({ index: index, size: 0, offset: 0, data: data[index] }); });
43
36
  return buildListState(items, [], adjustedCount, sizes, firstItemIndex);
44
37
  })), listState);
45
38
  return { initialItemCount: initialItemCount };
@@ -5,23 +5,38 @@ import { domIOSystem } from './domIOSystem';
5
5
  import { propsReadySystem } from './propsReadySystem';
6
6
  import { scrollToIndexSystem } from './scrollToIndexSystem';
7
7
  import { sizeSystem } from './sizeSystem';
8
+ export function getInitialTopMostItemIndexNumber(location, totalCount) {
9
+ var lastIndex = totalCount - 1;
10
+ var index = typeof location === 'number'
11
+ ? location
12
+ : location.index === 'LAST'
13
+ ? lastIndex
14
+ : location.index;
15
+ return index;
16
+ }
8
17
  export var initialTopMostItemIndexSystem = u.system(function (_a) {
9
- var _b = __read(_a, 4), _c = _b[0], sizes = _c.sizes, listRefresh = _c.listRefresh, scrollTop = _b[1].scrollTop, scrollToIndex = _b[2].scrollToIndex, didMount = _b[3].didMount;
18
+ var _b = __read(_a, 4), _c = _b[0], sizes = _c.sizes, listRefresh = _c.listRefresh, defaultItemSize = _c.defaultItemSize, scrollTop = _b[1].scrollTop, scrollToIndex = _b[2].scrollToIndex, didMount = _b[3].didMount;
10
19
  var scrolledToInitialItem = u.statefulStream(true);
11
20
  var initialTopMostItemIndex = u.statefulStream(0);
12
- u.connect(u.pipe(didMount, u.withLatestFrom(initialTopMostItemIndex), u.filter(function (_a) {
13
- var _b = __read(_a, 2), index = _b[1];
14
- return index !== 0;
21
+ u.connect(u.pipe(didMount, u.withLatestFrom(initialTopMostItemIndex),
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ u.filter(function (_a) {
24
+ var _b = __read(_a, 2), location = _b[1];
25
+ return !!location;
15
26
  }), u.mapTo(false)), scrolledToInitialItem);
16
- u.subscribe(u.pipe(listRefresh, u.withLatestFrom(scrolledToInitialItem, sizes), u.filter(function (_a) {
17
- var _b = __read(_a, 3), scrolledToInitialItem = _b[1], sizeTree = _b[2].sizeTree;
18
- return !empty(sizeTree) && !scrolledToInitialItem;
27
+ u.subscribe(u.pipe(u.combineLatest(listRefresh, didMount), u.withLatestFrom(scrolledToInitialItem, sizes, defaultItemSize), u.filter(function (_a) {
28
+ var _b = __read(_a, 4), _c = __read(_b[0], 2), didMount = _c[1], scrolledToInitialItem = _b[1], sizeTree = _b[2].sizeTree, defaultItemSize = _b[3];
29
+ return (didMount &&
30
+ (!empty(sizeTree) || defaultItemSize !== undefined) &&
31
+ !scrolledToInitialItem);
19
32
  }), u.withLatestFrom(initialTopMostItemIndex)), function (_a) {
20
33
  var _b = __read(_a, 2), initialTopMostItemIndex = _b[1];
21
- u.handleNext(scrollTop, function () {
22
- u.publish(scrolledToInitialItem, true);
34
+ setTimeout(function () {
35
+ u.handleNext(scrollTop, function () {
36
+ u.publish(scrolledToInitialItem, true);
37
+ });
38
+ u.publish(scrollToIndex, initialTopMostItemIndex);
23
39
  });
24
- u.publish(scrollToIndex, initialTopMostItemIndex);
25
40
  });
26
41
  return {
27
42
  scrolledToInitialItem: scrolledToInitialItem,
@@ -3,7 +3,7 @@ import * as u from '@virtuoso.dev/urx';
3
3
  import { empty, findMaxKeyValue, rangesWithin } from './AATree';
4
4
  import { rangeComparator, tupleComparator } from './comparators';
5
5
  import { groupedListSystem } from './groupedListSystem';
6
- import { initialTopMostItemIndexSystem } from './initialTopMostItemIndexSystem';
6
+ import { getInitialTopMostItemIndexNumber, initialTopMostItemIndexSystem, } from './initialTopMostItemIndexSystem';
7
7
  import { propsReadySystem } from './propsReadySystem';
8
8
  import { scrollToIndexSystem } from './scrollToIndexSystem';
9
9
  import { sizeRangeSystem } from './sizeRangeSystem';
@@ -116,7 +116,7 @@ export var listStateSystem = u.system(function (_a) {
116
116
  return EMPTY_LIST_STATE;
117
117
  }
118
118
  if (empty(sizeTree)) {
119
- return buildListState(probeItemSet(initialTopMostItemIndex, sizesValue, data), [], totalCount, sizesValue, firstItemIndex);
119
+ return buildListState(probeItemSet(getInitialTopMostItemIndexNumber(initialTopMostItemIndex, totalCount), sizesValue, data), [], totalCount, sizesValue, firstItemIndex);
120
120
  }
121
121
  var topItems = [];
122
122
  if (topItemsIndexes.length > 0) {
@@ -209,7 +209,6 @@ export var listStateSystem = u.system(function (_a) {
209
209
  u.connect(u.pipe(data, u.filter(function (data) { return data !== undefined; }), u.map(function (data) { return data.length; })), totalCount);
210
210
  u.connect(u.pipe(listState, u.map(u.prop('topListHeight'))), topListHeight);
211
211
  u.connect(topListHeight, rangeTopListHeight);
212
- u.connect(listState, stateFlags.listStateListener);
213
212
  u.connect(u.pipe(listState, u.map(function (state) { return [state.top, state.bottom]; })), listBoundary);
214
213
  u.connect(u.pipe(listState, u.map(function (state) { return state.items; })), itemsRendered);
215
214
  var endReached = u.streamFromEmitter(u.pipe(listState, u.filter(function (_a) {