@ringcentral/juno 2.4.1 → 2.5.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 +6 -2
  2. package/components/Buttons/IconButton/IconButton.js +9 -7
  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/SuggestionList/SuggestionList.js +4 -1
  13. package/components/Downshift/styles/DownshiftStyle.d.ts +1 -1
  14. package/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.d.ts +1 -1
  15. package/components/Forms/Picker/DatePicker/styles/StyledYear.d.ts +1 -1
  16. package/components/Forms/Picker/TimePicker/styles/StyledSelectionItem.d.ts +1 -1
  17. package/components/Forms/Picker/TimePicker/styles/StyledTimeIconButton.d.ts +1 -1
  18. package/components/Forms/Picker/styles/PickerBaseIconButton.d.ts +1 -1
  19. package/components/Forms/TextField/styles/ClearIconButton.d.ts +2 -2
  20. package/components/Grid/Grid.d.ts +1 -1
  21. package/components/Pagination/Pagination/Pagination.d.ts +1 -1
  22. package/components/Stepper/StepButton/StepButton.d.ts +1 -1
  23. package/components/Stepper/StepLabel/StepLabel.d.ts +1 -1
  24. package/components/Table/TableCell/styles/TableCellStyle.js +3 -1
  25. package/components/Table/types.d.ts +1 -1
  26. package/components/TablePagination/TablePagination.d.ts +1 -1
  27. package/components/VirtualizedMenu/VirtualizedMenu.js +11 -0
  28. package/components/VirtualizedMenu/VirtualizedMenuList.js +7 -14
  29. package/components/Virtuoso/react-virtuoso/AATree.js +15 -15
  30. package/components/Virtuoso/react-virtuoso/Grid.d.ts +193 -106
  31. package/components/Virtuoso/react-virtuoso/Grid.js +19 -24
  32. package/components/Virtuoso/react-virtuoso/List.d.ts +2664 -596
  33. package/components/Virtuoso/react-virtuoso/List.js +83 -70
  34. package/components/Virtuoso/react-virtuoso/Table.d.ts +6253 -0
  35. package/components/Virtuoso/react-virtuoso/Table.js +184 -0
  36. package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +153 -37
  37. package/components/Virtuoso/react-virtuoso/components.d.ts +248 -41
  38. package/components/Virtuoso/react-virtuoso/components.js +2 -0
  39. package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +2 -4
  40. package/components/Virtuoso/react-virtuoso/domIOSystem.js +12 -10
  41. package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +146 -27
  42. package/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
  43. package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +67 -52
  44. package/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
  45. package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +17 -3
  46. package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +2 -1
  47. package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +32 -7
  48. package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +1 -1
  49. package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
  50. package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -2
  51. package/components/Virtuoso/react-virtuoso/hooks/useSize.js +26 -28
  52. package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.d.ts +1 -1
  53. package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
  54. package/components/Virtuoso/react-virtuoso/index.d.ts +1 -0
  55. package/components/Virtuoso/react-virtuoso/index.js +2 -0
  56. package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +165 -35
  57. package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
  58. package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +160 -38
  59. package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +54 -12
  60. package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +26 -10
  61. package/components/Virtuoso/react-virtuoso/interfaces.d.ts +134 -28
  62. package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +141 -32
  63. package/components/Virtuoso/react-virtuoso/listStateSystem.js +1 -2
  64. package/components/Virtuoso/react-virtuoso/listSystem.d.ts +2123 -407
  65. package/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
  66. package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +17 -0
  67. package/components/Virtuoso/react-virtuoso/loggerSystem.js +37 -0
  68. package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +8 -1
  69. package/components/Virtuoso/react-virtuoso/propsReadySystem.js +8 -2
  70. package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +641 -0
  71. package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +42 -0
  72. package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +52 -67
  73. package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
  74. package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +26 -5
  75. package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
  76. package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +11 -4
  77. package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +44 -15
  78. package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +12 -2
  79. package/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
  80. package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +17 -5
  81. package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
  82. package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +145 -33
  83. package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +149 -35
  84. package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +183 -42
  85. package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +37 -26
  86. package/components/Virtuoso/react-virtuoso/utils/correctItemSize.d.ts +1 -0
  87. package/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +6 -0
  88. package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +7 -4
  89. package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
  90. package/components/Virtuoso/utils/useHighlightScroll.d.ts +4 -0
  91. package/components/Virtuoso/utils/useHighlightScroll.js +17 -0
  92. package/es6/components/Buttons/IconButton/IconButton.js +11 -9
  93. package/es6/components/Buttons/IconButton/styles/StyledIconButton.js +16 -8
  94. package/es6/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
  95. package/es6/components/Dialer/DialPad/DialPad.js +6 -6
  96. package/es6/components/Dialer/DialTextField/DialTextField.js +7 -6
  97. package/es6/components/Downshift/SuggestionList/SuggestionList.js +5 -2
  98. package/es6/components/Table/TableCell/TableCell.js +2 -2
  99. package/es6/components/Table/TableCell/styles/TableCellStyle.js +3 -1
  100. package/es6/components/VirtualizedMenu/VirtualizedMenu.js +13 -2
  101. package/es6/components/VirtualizedMenu/VirtualizedMenuList.js +9 -16
  102. package/es6/components/Virtuoso/react-virtuoso/AATree.js +15 -15
  103. package/es6/components/Virtuoso/react-virtuoso/Grid.js +20 -25
  104. package/es6/components/Virtuoso/react-virtuoso/List.js +84 -72
  105. package/es6/components/Virtuoso/react-virtuoso/Table.js +182 -0
  106. package/es6/components/Virtuoso/react-virtuoso/components.js +2 -0
  107. package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +13 -10
  108. package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
  109. package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
  110. package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +31 -6
  111. package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
  112. package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +27 -29
  113. package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
  114. package/es6/components/Virtuoso/react-virtuoso/index.js +1 -0
  115. package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
  116. package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +25 -10
  117. package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +2 -3
  118. package/es6/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
  119. package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +34 -0
  120. package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +9 -2
  121. package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +40 -0
  122. package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
  123. package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
  124. package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +39 -11
  125. package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
  126. package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
  127. package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +39 -28
  128. package/es6/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +3 -0
  129. package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
  130. package/es6/components/Virtuoso/utils/useHighlightScroll.js +16 -0
  131. package/es6/foundation/hooks/useLongPress/useLongPress.js +7 -7
  132. package/es6/foundation/index.js +1 -1
  133. package/es6/foundation/isWebKit154.js +57 -0
  134. package/es6/foundation/theme/ThemeProvider.js +4 -4
  135. package/foundation/hooks/useLongPress/useLongPress.d.ts +3 -1
  136. package/foundation/hooks/useLongPress/useLongPress.js +7 -7
  137. package/foundation/index.d.ts +1 -1
  138. package/foundation/index.js +1 -1
  139. package/foundation/isWebKit154.d.ts +20 -0
  140. package/foundation/{isSafari154.js → isWebKit154.js} +22 -17
  141. package/foundation/theme/ThemeProvider.d.ts +1 -1
  142. package/foundation/theme/ThemeProvider.js +4 -4
  143. package/package.json +2 -2
  144. package/es6/foundation/isSafari154.js +0 -52
  145. package/foundation/isSafari154.d.ts +0 -15
@@ -1,9 +1,9 @@
1
1
  import { __assign, __makeTemplateObject, __rest } from "tslib";
2
2
  import React, { forwardRef, useImperativeHandle, useMemo, useRef, } from 'react';
3
3
  import { isFragment } from 'react-is';
4
- import { combineProps, fixSafariTransitionStyle, getScrollbarSize, isRcElement, logInDev, styled, useDebounce, useEventCallback, useForkRef, useHiddenTabindex, useKeyboardMoveFocus, useMountState, useOnlyOneFocusable, useRcPortalWindowContext, useTheme, useThemeProps, } from '../../foundation';
4
+ import { combineProps, getScrollbarSize, isRcElement, logInDev, styled, useDebounce, useEventCallback, useForkRef, useHiddenTabindex, useKeyboardMoveFocus, useMountState, useOnlyOneFocusable, useRcPortalWindowContext, useTheme, useThemeProps, } from '../../foundation';
5
5
  import { RcList } from '../List/List/List';
6
- import { isOutOfRange, useDynamicHeight, useHighlightScroll, Virtuoso, } from '../Virtuoso';
6
+ import { isOutOfRange, modifyVlScrollerStyle, useDynamicHeight, useHighlightScroll, Virtuoso, } from '../Virtuoso';
7
7
  import { RcVisuallyHidden } from '../VisuallyHidden';
8
8
  import { StyledMenuListPadding } from './styles';
9
9
  var _RcVirtualizedMenuList = forwardRef(function (inProps, ref) {
@@ -161,8 +161,12 @@ var _RcVirtualizedMenuList = forwardRef(function (inProps, ref) {
161
161
  },
162
162
  }); });
163
163
  var components = useMemo(function () { return ({
164
- Header: disablePadding ? undefined : StyledMenuListPadding,
165
- Footer: disablePadding ? undefined : StyledMenuListPadding,
164
+ Header: disablePadding
165
+ ? undefined
166
+ : StyledMenuListPadding,
167
+ Footer: disablePadding
168
+ ? undefined
169
+ : StyledMenuListPadding,
166
170
  List: React.forwardRef(function (_a, listRef) {
167
171
  var children = _a.children, listRest = __rest(_a, ["children"]);
168
172
  var toRef = useForkRef(handleRef, listRef);
@@ -178,18 +182,7 @@ var _RcVirtualizedMenuList = forwardRef(function (inProps, ref) {
178
182
  []);
179
183
  var combine = combineProps(__assign({ tabIndex: -1, scrollerRef: function (scrollElm) {
180
184
  scrollerRefFn(scrollElm);
181
- if (scrollElm) {
182
- // * Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/100.0.4896.77 Mobile/15E148 Safari/604.1
183
- // * set that to make safari vl render correctly
184
- scrollElm.style.transition = fixSafariTransitionStyle;
185
- if (position) {
186
- var viewPortElm = scrollElm.firstChild;
187
- if (viewPortElm) {
188
- viewPortElm.style.position = position;
189
- }
190
- }
191
- }
192
- // resetViewPortStyle
185
+ modifyVlScrollerStyle(scrollElm, position);
193
186
  // * when not have scrollerRef mean that is first render
194
187
  if (!isMountedRef.current) {
195
188
  onMounted();
@@ -132,22 +132,22 @@ function adjust(node) {
132
132
  }
133
133
  throw new Error('Unexpected empty nodes');
134
134
  }
135
+ else if (isSingle(node)) {
136
+ return split(clone(node, { lvl: lvl - 1 }));
137
+ }
138
+ else if (!empty(r) && !empty(r.l)) {
139
+ var rl = r.l;
140
+ var rlvl = isSingle(rl) ? r.lvl - 1 : r.lvl;
141
+ return clone(rl, {
142
+ l: clone(node, {
143
+ r: rl.l,
144
+ lvl: lvl - 1,
145
+ }),
146
+ r: split(clone(r, { l: rl.r, lvl: rlvl })),
147
+ lvl: rl.lvl + 1,
148
+ });
149
+ }
135
150
  else {
136
- if (isSingle(node)) {
137
- return split(clone(node, { lvl: lvl - 1 }));
138
- }
139
- if (!empty(r) && !empty(r.l)) {
140
- var rl = r.l;
141
- var rlvl = isSingle(rl) ? r.lvl - 1 : r.lvl;
142
- return clone(rl, {
143
- l: clone(node, {
144
- r: rl.l,
145
- lvl: lvl - 1,
146
- }),
147
- r: split(clone(r, { l: rl.r, lvl: rlvl })),
148
- lvl: rl.lvl + 1,
149
- });
150
- }
151
151
  throw new Error('Unexpected empty nodes');
152
152
  }
153
153
  }
@@ -1,4 +1,5 @@
1
1
  import { __assign, __read, __rest } from "tslib";
2
+ /* eslint-disable no-console */
2
3
  import * as React from 'react';
3
4
  import { createElement } from 'react';
4
5
  import { systemToComponent } from '@virtuoso.dev/react-urx';
@@ -6,10 +7,11 @@ import * as u from '@virtuoso.dev/urx';
6
7
  import { gridSystem } from './gridSystem';
7
8
  import useSize from './hooks/useSize';
8
9
  import useWindowViewportRectRef from './hooks/useWindowViewportRect';
9
- import { addDeprecatedAlias, buildScroller, buildWindowScroller, identity, viewportStyle, } from './List';
10
+ import { addDeprecatedAlias, buildScroller, buildWindowScroller, contextPropIfNotDomElement, identity, viewportStyle, } from './List';
10
11
  var gridComponentPropsSystem = u.system(function () {
11
12
  var itemContent = u.statefulStream(function (index) { return "Item " + index; });
12
13
  var components = u.statefulStream({});
14
+ var context = u.statefulStream(null);
13
15
  var itemClassName = u.statefulStream('virtuoso-grid-item');
14
16
  var listClassName = u.statefulStream('virtuoso-grid-list');
15
17
  var computeItemKey = u.statefulStream(identity);
@@ -19,6 +21,7 @@ var gridComponentPropsSystem = u.system(function () {
19
21
  return u.statefulStreamFromEmitter(u.pipe(components, u.map(function (components) { return components[propName]; }), u.distinctUntilChanged()), defaultValue);
20
22
  };
21
23
  return {
24
+ context: context,
22
25
  itemContent: itemContent,
23
26
  components: components,
24
27
  computeItemKey: computeItemKey,
@@ -45,7 +48,6 @@ var combinedSystem = u.system(function (_a) {
45
48
  u.connect(u.pipe(stream, u.withLatestFrom(gridComponentPropsSystem.components), u.map(function (_a) {
46
49
  var _b;
47
50
  var _c = __read(_a, 2), comp = _c[0], components = _c[1];
48
- // eslint-disable-next-line no-console
49
51
  console.warn("react-virtuoso: " + propName + " property is deprecated. Pass components." + componentName + " instead.");
50
52
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
51
53
  return __assign(__assign({}, components), (_b = {}, _b[componentName] = comp, _b));
@@ -53,7 +55,6 @@ var combinedSystem = u.system(function (_a) {
53
55
  }
54
56
  u.subscribe(deprecatedProps.scrollSeek, function (_a) {
55
57
  var placeholder = _a.placeholder, config = __rest(_a, ["placeholder"]);
56
- // eslint-disable-next-line no-console
57
58
  console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead.");
58
59
  u.publish(gridComponentPropsSystem.components, __assign(__assign({}, u.getValue(gridComponentPropsSystem.components)), {
59
60
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
@@ -72,58 +73,51 @@ var GridItems = React.memo(function GridItems() {
72
73
  var itemContent = useEmitterValue('itemContent');
73
74
  var computeItemKey = useEmitterValue('computeItemKey');
74
75
  var isSeeking = useEmitterValue('isSeeking');
76
+ var scrollHeightCallback = usePublisher('scrollHeight');
75
77
  var ItemComponent = useEmitterValue('ItemComponent');
76
78
  var ListComponent = useEmitterValue('ListComponent');
77
79
  var ScrollSeekPlaceholder = useEmitterValue('ScrollSeekPlaceholder');
80
+ var context = useEmitterValue('context');
78
81
  var itemDimensions = usePublisher('itemDimensions');
79
82
  var listRef = useSize(function (el) {
83
+ var scrollHeight = el.parentElement.parentElement.scrollHeight;
84
+ scrollHeightCallback(scrollHeight);
80
85
  var firstItem = el.firstChild;
81
86
  if (firstItem) {
82
- itemDimensions({
83
- width: firstItem.offsetWidth,
84
- height: firstItem.offsetHeight,
85
- });
87
+ itemDimensions(firstItem.getBoundingClientRect());
86
88
  }
87
89
  });
88
- return createElement(ListComponent, {
89
- ref: listRef,
90
- className: listClassName,
91
- style: {
90
+ return createElement(ListComponent, __assign(__assign({ ref: listRef, className: listClassName }, contextPropIfNotDomElement(ListComponent, context)), { style: {
92
91
  paddingTop: gridState.offsetTop,
93
92
  paddingBottom: gridState.offsetBottom,
94
- },
95
- }, gridState.items.map(function (item) {
93
+ } }), gridState.items.map(function (item) {
96
94
  var key = computeItemKey(item.index);
97
95
  return isSeeking
98
- ? createElement(ScrollSeekPlaceholder, {
99
- key: key,
100
- style: { height: gridState.itemHeight, width: gridState.itemWidth },
101
- })
102
- : createElement(ItemComponent, { className: itemClassName, 'data-index': item.index, key: key }, itemContent(item.index));
96
+ ? createElement(ScrollSeekPlaceholder, __assign(__assign({ key: key }, contextPropIfNotDomElement(ScrollSeekPlaceholder, context)), { index: item.index, height: gridState.itemHeight, width: gridState.itemWidth }))
97
+ : createElement(ItemComponent, __assign(__assign({}, contextPropIfNotDomElement(ItemComponent, context)), { className: itemClassName, 'data-index': item.index, key: key }), itemContent(item.index, context));
103
98
  }));
104
99
  });
105
100
  var Viewport = function (_a) {
106
101
  var children = _a.children;
107
102
  var viewportDimensions = usePublisher('viewportDimensions');
108
103
  var viewportRef = useSize(function (el) {
109
- viewportDimensions({
110
- width: el.offsetWidth,
111
- height: el.offsetHeight,
112
- });
104
+ viewportDimensions(el.getBoundingClientRect());
113
105
  });
114
106
  return (React.createElement("div", { style: viewportStyle, ref: viewportRef }, children));
115
107
  };
116
108
  var WindowViewport = function (_a) {
117
109
  var children = _a.children;
118
110
  var windowViewportRect = usePublisher('windowViewportRect');
119
- var viewportRef = useWindowViewportRectRef(windowViewportRect);
111
+ var customScrollParent = useEmitterValue('customScrollParent');
112
+ var viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
120
113
  return (React.createElement("div", { ref: viewportRef, style: viewportStyle }, children));
121
114
  };
122
115
  var GridRoot = React.memo(function GridRoot(_a) {
123
116
  var props = __rest(_a, []);
124
117
  var useWindowScroll = useEmitterValue('useWindowScroll');
125
- var TheScroller = useWindowScroll ? WindowScroller : Scroller;
126
- var TheViewport = useWindowScroll ? WindowViewport : Viewport;
118
+ var customScrollParent = useEmitterValue('customScrollParent');
119
+ var TheScroller = customScrollParent || useWindowScroll ? WindowScroller : Scroller;
120
+ var TheViewport = customScrollParent || useWindowScroll ? WindowViewport : Viewport;
127
121
  return (React.createElement(TheScroller, __assign({}, props),
128
122
  React.createElement(TheViewport, null,
129
123
  React.createElement(GridItems, null))));
@@ -140,6 +134,7 @@ var _a = systemToComponent(combinedSystem, {
140
134
  listClassName: 'listClassName',
141
135
  itemClassName: 'itemClassName',
142
136
  useWindowScroll: 'useWindowScroll',
137
+ customScrollParent: 'customScrollParent',
143
138
  scrollerRef: 'scrollerRef',
144
139
  // deprecated
145
140
  item: 'item',
@@ -1,23 +1,24 @@
1
1
  var _a;
2
2
  import { __assign, __read, __rest } from "tslib";
3
+ /* eslint-disable no-console */
3
4
  import * as React from 'react';
4
5
  import { createElement } from 'react';
5
- /* eslint-disable no-console */
6
6
  import { systemToComponent } from '@virtuoso.dev/react-urx';
7
- import { compose, connect, distinctUntilChanged, getValue, map, noop, pipe, prop, publish, statefulStream, statefulStreamFromEmitter, stream, subscribe, system, tup, withLatestFrom, } from '@virtuoso.dev/urx';
8
- import { useRcPortalWindowContext } from '../../../foundation';
9
- import useChangedChildSizes from './hooks/useChangedChildSizes';
7
+ import { compose, connect, distinctUntilChanged, getValue, map, noop, pipe, publish, statefulStream, statefulStreamFromEmitter, stream, subscribe, system, tup, withLatestFrom, } from '@virtuoso.dev/urx';
8
+ import useChangedListContentsSizes from './hooks/useChangedChildSizes';
10
9
  import useIsomorphicLayoutEffect from './hooks/useIsomorphicLayoutEffect';
11
10
  import useScrollTop from './hooks/useScrollTop';
12
11
  import useSize from './hooks/useSize';
13
12
  import useWindowViewportRectRef from './hooks/useWindowViewportRect';
14
13
  import { listSystem } from './listSystem';
14
+ import { correctItemSize } from './utils/correctItemSize';
15
15
  import { positionStickyCssValue } from './utils/positionStickyCssValue';
16
16
  export function identity(value) {
17
17
  return value;
18
18
  }
19
19
  var listComponentPropsSystem = system(function () {
20
20
  var itemContent = statefulStream(function (index) { return "Item " + index; });
21
+ var context = statefulStream(null);
21
22
  var groupContent = statefulStream(function (index) { return "Group " + index; });
22
23
  var components = statefulStream({});
23
24
  var computeItemKey = statefulStream(identity);
@@ -28,6 +29,7 @@ var listComponentPropsSystem = system(function () {
28
29
  return statefulStreamFromEmitter(pipe(components, map(function (components) { return components[propName]; }), distinctUntilChanged()), defaultValue);
29
30
  };
30
31
  return {
32
+ context: context,
31
33
  itemContent: itemContent,
32
34
  groupContent: groupContent,
33
35
  components: components,
@@ -115,17 +117,30 @@ var DefaultScrollSeekPlaceholder = function (_a) {
115
117
  var height = _a.height;
116
118
  return (React.createElement("div", { style: { height: height } }));
117
119
  };
118
- var GROUP_STYLE = { position: positionStickyCssValue(), zIndex: 1 };
120
+ var GROUP_STYLE = {
121
+ position: positionStickyCssValue(),
122
+ zIndex: 1,
123
+ overflowAnchor: 'none',
124
+ };
119
125
  export var Items = React.memo(function VirtuosoItems(_a) {
120
126
  var _b = _a.showTopList, showTopList = _b === void 0 ? false : _b;
121
127
  var listState = useEmitterValue('listState');
122
128
  var deviation = useEmitterValue('deviation');
123
129
  var sizeRanges = usePublisher('sizeRanges');
130
+ var useWindowScroll = useEmitterValue('useWindowScroll');
131
+ var customScrollParent = useEmitterValue('customScrollParent');
132
+ var windowScrollContainerStateCallback = usePublisher('windowScrollContainerState');
133
+ var _scrollContainerStateCallback = usePublisher('scrollContainerState');
134
+ var scrollContainerStateCallback = customScrollParent || useWindowScroll
135
+ ? windowScrollContainerStateCallback
136
+ : _scrollContainerStateCallback;
124
137
  var itemContent = useEmitterValue('itemContent');
138
+ var context = useEmitterValue('context');
125
139
  var groupContent = useEmitterValue('groupContent');
126
140
  var trackItemSizes = useEmitterValue('trackItemSizes');
127
141
  var itemSize = useEmitterValue('itemSize');
128
- var ref = useChangedChildSizes(sizeRanges, itemSize, trackItemSizes);
142
+ var log = useEmitterValue('log');
143
+ var ref = useChangedListContentsSizes(sizeRanges, itemSize, trackItemSizes, showTopList ? noop : scrollContainerStateCallback, log, customScrollParent);
129
144
  var EmptyPlaceholder = useEmitterValue('EmptyPlaceholder');
130
145
  var ScrollSeekPlaceholder = useEmitterValue('ScrollSeekPlaceholder') || DefaultScrollSeekPlaceholder;
131
146
  var ListComponent = useEmitterValue('ListComponent');
@@ -135,8 +150,8 @@ export var Items = React.memo(function VirtuosoItems(_a) {
135
150
  var isSeeking = useEmitterValue('isSeeking');
136
151
  var hasGroups = useEmitterValue('groupIndices').length > 0;
137
152
  var paddingTopAddition = useEmitterValue('paddingTopAddition');
138
- var scrolledToInitialItem = useEmitterValue('scrolledToInitialItem');
139
- // const calculatedHeight = listState.offsetBottom + listState.bottom
153
+ var firstItemIndex = useEmitterValue('firstItemIndex');
154
+ var statefulTotalCount = useEmitterValue('statefulTotalCount');
140
155
  var containerStyle = showTopList
141
156
  ? {}
142
157
  : {
@@ -145,40 +160,23 @@ export var Items = React.memo(function VirtuosoItems(_a) {
145
160
  paddingBottom: listState.offsetBottom,
146
161
  marginTop: deviation,
147
162
  };
148
- if (!showTopList &&
149
- listState.items.length === 0 &&
150
- EmptyPlaceholder &&
151
- scrolledToInitialItem) {
152
- return createElement(EmptyPlaceholder);
163
+ if (!showTopList && statefulTotalCount === 0 && EmptyPlaceholder) {
164
+ return createElement(EmptyPlaceholder, contextPropIfNotDomElement(EmptyPlaceholder, context));
153
165
  }
154
- return createElement(ListComponent, { ref: ref, style: containerStyle }, (showTopList ? listState.topItems : listState.items).map(function (item) {
166
+ return createElement(ListComponent, __assign(__assign({}, contextPropIfNotDomElement(ListComponent, context)), { ref: ref, style: containerStyle, 'data-test-id': showTopList
167
+ ? 'virtuoso-top-item-list'
168
+ : 'virtuoso-item-list' }), (showTopList ? listState.topItems : listState.items).map(function (item) {
155
169
  var index = item.originalIndex;
156
- var key = computeItemKey(index);
170
+ var key = computeItemKey(index + firstItemIndex, item.data, context);
157
171
  if (isSeeking) {
158
- return createElement(ScrollSeekPlaceholder, {
159
- key: key,
160
- index: item.index,
161
- height: item.size,
162
- });
172
+ return createElement(ScrollSeekPlaceholder, __assign(__assign(__assign({}, contextPropIfNotDomElement(ScrollSeekPlaceholder, context)), { key: key, index: item.index, height: item.size, type: item.type || 'item' }), (item.type === 'group' ? {} : { groupIndex: item.groupIndex })));
163
173
  }
164
174
  if (item.type === 'group') {
165
- return createElement(GroupComponent, {
166
- key: key,
167
- 'data-index': index,
168
- 'data-known-size': item.size,
169
- 'data-item-index': item.index,
170
- style: GROUP_STYLE,
171
- }, groupContent(item.index));
175
+ return createElement(GroupComponent, __assign(__assign({}, contextPropIfNotDomElement(GroupComponent, context)), { key: key, 'data-index': index, 'data-known-size': item.size, 'data-item-index': item.index, style: GROUP_STYLE }), groupContent(item.index));
172
176
  }
173
- return createElement(ItemComponent, {
174
- key: key,
175
- 'data-index': index,
176
- 'data-known-size': item.size,
177
- 'data-item-index': item.index,
178
- 'data-item-group-index': item.groupIndex,
179
- }, hasGroups
180
- ? itemContent(item.index, item.groupIndex, item.data)
181
- : itemContent(item.index, item.data));
177
+ return createElement(ItemComponent, __assign(__assign({}, contextPropIfNotDomElement(ItemComponent, context)), { key: key, 'data-index': index, 'data-known-size': item.size, 'data-item-index': item.index, 'data-item-group-index': item.groupIndex, style: { overflowAnchor: 'none' } }), hasGroups
178
+ ? itemContent(item.index, item.groupIndex, item.data, context)
179
+ : itemContent(item.index, item.data, context));
182
180
  }));
183
181
  });
184
182
  export var scrollerStyle = {
@@ -199,88 +197,101 @@ var topItemListStyle = {
199
197
  position: positionStickyCssValue(),
200
198
  top: 0,
201
199
  };
200
+ export function contextPropIfNotDomElement(element, context) {
201
+ if (typeof element === 'string') {
202
+ return undefined;
203
+ }
204
+ return { context: context };
205
+ }
202
206
  var Header = React.memo(function VirtuosoHeader() {
203
207
  var Header = useEmitterValue('HeaderComponent');
204
208
  var headerHeight = usePublisher('headerHeight');
205
209
  var headerFooterTag = useEmitterValue('headerFooterTag');
206
- var ref = useSize(function (el) { return headerHeight(el.offsetHeight); });
210
+ var ref = useSize(function (el) { return headerHeight(correctItemSize(el, 'height')); });
211
+ var context = useEmitterValue('context');
207
212
  return Header
208
- ? createElement(headerFooterTag, { ref: ref }, createElement(Header))
213
+ ? createElement(headerFooterTag, { ref: ref }, createElement(Header, contextPropIfNotDomElement(Header, context)))
209
214
  : null;
210
215
  });
211
216
  var Footer = React.memo(function VirtuosoFooter() {
212
217
  var Footer = useEmitterValue('FooterComponent');
213
218
  var footerHeight = usePublisher('footerHeight');
214
219
  var headerFooterTag = useEmitterValue('headerFooterTag');
215
- var ref = useSize(function (el) { return footerHeight(el.offsetHeight); });
220
+ var ref = useSize(function (el) { return footerHeight(correctItemSize(el, 'height')); });
221
+ var context = useEmitterValue('context');
216
222
  return Footer
217
- ? createElement(headerFooterTag, { ref: ref }, createElement(Footer))
223
+ ? createElement(headerFooterTag, { ref: ref }, createElement(Footer, contextPropIfNotDomElement(Footer, context)))
218
224
  : null;
219
225
  });
220
226
  export function buildScroller(_a) {
221
- var usePublisher = _a.usePublisher, useEmitter = _a.useEmitter, useEmitterValue = _a.useEmitterValue, customWindow = _a.window;
227
+ var usePublisher = _a.usePublisher, useEmitter = _a.useEmitter, useEmitterValue = _a.useEmitterValue;
222
228
  var Scroller = React.memo(function VirtuosoScroller(_a) {
223
229
  var style = _a.style, children = _a.children, props = __rest(_a, ["style", "children"]);
224
- var scrollTopCallback = usePublisher('scrollTop');
230
+ var scrollContainerStateCallback = usePublisher('scrollContainerState');
225
231
  var ScrollerComponent = useEmitterValue('ScrollerComponent');
226
232
  var smoothScrollTargetReached = usePublisher('smoothScrollTargetReached');
227
233
  var scrollerRefCallback = useEmitterValue('scrollerRef');
228
- var _b = useScrollTop(scrollTopCallback, smoothScrollTargetReached, ScrollerComponent, scrollerRefCallback, customWindow), scrollerRef = _b.scrollerRef, scrollByCallback = _b.scrollByCallback, scrollToCallback = _b.scrollToCallback;
234
+ var context = useEmitterValue('context');
235
+ var _b = useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, ScrollerComponent, scrollerRefCallback), scrollerRef = _b.scrollerRef, scrollByCallback = _b.scrollByCallback, scrollToCallback = _b.scrollToCallback;
229
236
  useEmitter('scrollTo', scrollToCallback);
230
237
  useEmitter('scrollBy', scrollByCallback);
231
- return createElement(ScrollerComponent, __assign({ ref: scrollerRef, style: __assign(__assign({}, scrollerStyle), style), tabIndex: 0 }, props), children);
238
+ return createElement(ScrollerComponent, __assign(__assign({ ref: scrollerRef, style: __assign(__assign({}, scrollerStyle), style), 'data-test-id': 'virtuoso-scroller', 'data-virtuoso-scroller': true, tabIndex: 0 }, props), contextPropIfNotDomElement(ScrollerComponent, context)), children);
232
239
  });
233
240
  return Scroller;
234
241
  }
235
242
  export function buildWindowScroller(_a) {
236
- var usePublisher = _a.usePublisher, useEmitter = _a.useEmitter, useEmitterValue = _a.useEmitterValue, customWindow = _a.window;
243
+ var usePublisher = _a.usePublisher, useEmitter = _a.useEmitter, useEmitterValue = _a.useEmitterValue;
237
244
  var Scroller = React.memo(function VirtuosoWindowScroller(_a) {
238
245
  var style = _a.style, children = _a.children, props = __rest(_a, ["style", "children"]);
239
- var scrollTopCallback = usePublisher('windowScrollTop');
246
+ var scrollContainerStateCallback = usePublisher('windowScrollContainerState');
240
247
  var ScrollerComponent = useEmitterValue('ScrollerComponent');
241
248
  var smoothScrollTargetReached = usePublisher('smoothScrollTargetReached');
242
249
  var totalListHeight = useEmitterValue('totalListHeight');
243
- var _b = useScrollTop(scrollTopCallback, smoothScrollTargetReached, ScrollerComponent, undefined, customWindow), scrollerRef = _b.scrollerRef, scrollByCallback = _b.scrollByCallback, scrollToCallback = _b.scrollToCallback;
250
+ var deviation = useEmitterValue('deviation');
251
+ var customScrollParent = useEmitterValue('customScrollParent');
252
+ var context = useEmitterValue('context');
253
+ var _b = useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, ScrollerComponent, noop, customScrollParent), scrollerRef = _b.scrollerRef, scrollByCallback = _b.scrollByCallback, scrollToCallback = _b.scrollToCallback;
244
254
  useIsomorphicLayoutEffect(function () {
245
- scrollerRef.current = window;
255
+ scrollerRef.current = customScrollParent ? customScrollParent : window;
246
256
  return function () {
247
257
  scrollerRef.current = null;
248
258
  };
249
- }, [scrollerRef]);
259
+ }, [scrollerRef, customScrollParent]);
250
260
  useEmitter('windowScrollTo', scrollToCallback);
251
261
  useEmitter('scrollBy', scrollByCallback);
252
- return createElement(ScrollerComponent, __assign({ style: __assign(__assign({ position: 'relative' }, style), (totalListHeight !== 0 ? { height: totalListHeight } : {})) }, props), children);
262
+ return createElement(ScrollerComponent, __assign(__assign({ style: __assign(__assign({ position: 'relative' }, style), (totalListHeight !== 0
263
+ ? { height: totalListHeight + deviation }
264
+ : {})), 'data-virtuoso-scroller': true }, props), contextPropIfNotDomElement(ScrollerComponent, context)), children);
253
265
  });
254
266
  return Scroller;
255
267
  }
256
268
  var Viewport = function (_a) {
257
269
  var children = _a.children;
258
270
  var viewportHeight = usePublisher('viewportHeight');
259
- var viewportRef = useSize(compose(viewportHeight, prop('offsetHeight')));
260
- return (React.createElement("div", { style: viewportStyle, ref: viewportRef }, children));
271
+ var viewportRef = useSize(compose(viewportHeight, function (el) { return correctItemSize(el, 'height'); }));
272
+ return (React.createElement("div", { style: viewportStyle, ref: viewportRef, "data-viewport-type": "element" }, children));
261
273
  };
262
274
  var WindowViewport = function (_a) {
263
275
  var children = _a.children;
264
276
  var windowViewportRect = usePublisher('windowViewportRect');
265
- var externalWindow = useRcPortalWindowContext().externalWindow;
266
- var viewportRef = useWindowViewportRectRef(windowViewportRect, externalWindow);
267
- return (React.createElement("div", { ref: viewportRef, style: viewportStyle }, children));
277
+ var customScrollParent = useEmitterValue('customScrollParent');
278
+ var viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
279
+ return (React.createElement("div", { ref: viewportRef, style: viewportStyle, "data-viewport-type": "window" }, children));
268
280
  };
269
281
  var TopItemListContainer = function (_a) {
270
282
  var children = _a.children;
271
283
  var TopItemList = useEmitterValue('TopItemListComponent');
272
284
  var headerHeight = useEmitterValue('headerHeight');
273
285
  var style = __assign(__assign({}, topItemListStyle), { marginTop: headerHeight + "px" });
274
- return createElement(TopItemList || 'div', { style: style }, children);
286
+ var context = useEmitterValue('context');
287
+ return createElement(TopItemList || 'div', { style: style, context: context }, children);
275
288
  };
276
289
  var ListRoot = React.memo(function VirtuosoRoot(props) {
277
290
  var useWindowScroll = useEmitterValue('useWindowScroll');
278
291
  var showTopList = useEmitterValue('topItemsIndexes').length > 0;
279
- var externalWindow = useRcPortalWindowContext().externalWindow;
280
- var TheScroller = React.useMemo(function () {
281
- return (useWindowScroll ? createWindowScroller : createScroller)(externalWindow || window);
282
- }, [externalWindow, useWindowScroll]);
283
- var TheViewport = useWindowScroll ? WindowViewport : Viewport;
292
+ var customScrollParent = useEmitterValue('customScrollParent');
293
+ var TheScroller = customScrollParent || useWindowScroll ? WindowScroller : Scroller;
294
+ var TheViewport = customScrollParent || useWindowScroll ? WindowViewport : Viewport;
284
295
  return (React.createElement(TheScroller, __assign({}, props),
285
296
  React.createElement(TheViewport, null,
286
297
  React.createElement(Header, null),
@@ -292,16 +303,19 @@ var ListRoot = React.memo(function VirtuosoRoot(props) {
292
303
  export var List = (_a = systemToComponent(combinedSystem, {
293
304
  required: {},
294
305
  optional: {
306
+ context: 'context',
295
307
  followOutput: 'followOutput',
296
308
  firstItemIndex: 'firstItemIndex',
297
309
  itemContent: 'itemContent',
298
310
  groupContent: 'groupContent',
299
311
  overscan: 'overscan',
312
+ increaseViewportBy: 'increaseViewportBy',
300
313
  totalCount: 'totalCount',
301
314
  topItemCount: 'topItemCount',
302
315
  initialTopMostItemIndex: 'initialTopMostItemIndex',
303
316
  components: 'components',
304
317
  groupCounts: 'groupCounts',
318
+ atBottomThreshold: 'atBottomThreshold',
305
319
  computeItemKey: 'computeItemKey',
306
320
  defaultItemHeight: 'defaultItemHeight',
307
321
  fixedItemHeight: 'fixedItemHeight',
@@ -313,7 +327,9 @@ export var List = (_a = systemToComponent(combinedSystem, {
313
327
  initialScrollTop: 'initialScrollTop',
314
328
  alignToBottom: 'alignToBottom',
315
329
  useWindowScroll: 'useWindowScroll',
330
+ customScrollParent: 'customScrollParent',
316
331
  scrollerRef: 'scrollerRef',
332
+ logLevel: 'logLevel',
317
333
  // deprecated
318
334
  item: 'item',
319
335
  group: 'group',
@@ -334,6 +350,7 @@ export var List = (_a = systemToComponent(combinedSystem, {
334
350
  },
335
351
  methods: {
336
352
  scrollToIndex: 'scrollToIndex',
353
+ scrollIntoView: 'scrollIntoView',
337
354
  scrollTo: 'scrollTo',
338
355
  scrollBy: 'scrollBy',
339
356
  adjustForPrependedItems: 'adjustForPrependedItems',
@@ -350,14 +367,9 @@ export var List = (_a = systemToComponent(combinedSystem, {
350
367
  groupIndices: 'groupIndices',
351
368
  },
352
369
  }, ListRoot), _a.Component), usePublisher = _a.usePublisher, useEmitterValue = _a.useEmitterValue, useEmitter = _a.useEmitter;
353
- var createScroller = function (window) {
354
- return buildScroller({ usePublisher: usePublisher, useEmitterValue: useEmitterValue, useEmitter: useEmitter, window: window });
355
- };
356
- var createWindowScroller = function (window) {
357
- return buildWindowScroller({
358
- usePublisher: usePublisher,
359
- useEmitterValue: useEmitterValue,
360
- useEmitter: useEmitter,
361
- window: window,
362
- });
363
- };
370
+ var Scroller = buildScroller({ usePublisher: usePublisher, useEmitterValue: useEmitterValue, useEmitter: useEmitter });
371
+ var WindowScroller = buildWindowScroller({
372
+ usePublisher: usePublisher,
373
+ useEmitterValue: useEmitterValue,
374
+ useEmitter: useEmitter,
375
+ });