virtual-scroller 1.14.0 → 1.15.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 (216) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +309 -250
  3. package/bundle/index-dom-bypass.html +198 -0
  4. package/bundle/index-dom-grid.html +204 -0
  5. package/bundle/index-dom-scrollableContainer.html +215 -0
  6. package/bundle/index-dom-tbody-scrollableContainer.html +81 -0
  7. package/bundle/index-dom-tbody.html +65 -0
  8. package/bundle/index-dom.html +115 -84
  9. package/bundle/{index-bypass.html → index-react-bypass.html} +83 -78
  10. package/bundle/{index-grid.html → index-react-grid.html} +78 -91
  11. package/bundle/{index-scrollableContainer.html → index-react-scrollableContainer.html} +96 -91
  12. package/bundle/index-react-strictMode.html +199 -0
  13. package/bundle/index-react-tbody-scrollableContainer.html +96 -0
  14. package/bundle/index-react-tbody.html +80 -0
  15. package/bundle/{messages.js → items.js} +1 -1
  16. package/bundle/lib/babel.min.js +25 -0
  17. package/bundle/lib/prop-types.min.js +1 -0
  18. package/bundle/lib/react-dom.development.js +29924 -0
  19. package/bundle/lib/react-dom.production.min.js +267 -0
  20. package/bundle/lib/react.development.js +3343 -0
  21. package/bundle/lib/react.production.min.js +31 -0
  22. package/bundle/style.base.css +33 -0
  23. package/{website/style.css → bundle/style.list.css} +10 -43
  24. package/bundle/style.list.grid.css +23 -0
  25. package/bundle/virtual-scroller-dom.js +1 -1
  26. package/bundle/virtual-scroller-dom.js.map +1 -1
  27. package/bundle/virtual-scroller-react.js +1 -1
  28. package/bundle/virtual-scroller-react.js.map +1 -1
  29. package/bundle/virtual-scroller.js +1 -1
  30. package/bundle/virtual-scroller.js.map +1 -1
  31. package/commonjs/BeforeResize.js +1 -2
  32. package/commonjs/BeforeResize.js.map +1 -1
  33. package/commonjs/DOM/VirtualScroller.js +7 -13
  34. package/commonjs/DOM/VirtualScroller.js.map +1 -1
  35. package/commonjs/DOM/tbody.js +6 -6
  36. package/commonjs/DOM/tbody.js.map +1 -1
  37. package/commonjs/ItemHeights.js +10 -13
  38. package/commonjs/ItemHeights.js.map +1 -1
  39. package/commonjs/Layout.defaults.js +21 -0
  40. package/commonjs/Layout.defaults.js.map +1 -0
  41. package/commonjs/Layout.js +75 -64
  42. package/commonjs/Layout.js.map +1 -1
  43. package/commonjs/Layout.test.js +8 -4
  44. package/commonjs/Layout.test.js.map +1 -1
  45. package/commonjs/VirtualScroller.constructor.js +38 -4
  46. package/commonjs/VirtualScroller.constructor.js.map +1 -1
  47. package/commonjs/VirtualScroller.items.js +50 -4
  48. package/commonjs/VirtualScroller.items.js.map +1 -1
  49. package/commonjs/VirtualScroller.js +23 -14
  50. package/commonjs/VirtualScroller.js.map +1 -1
  51. package/commonjs/VirtualScroller.layout.js +40 -29
  52. package/commonjs/VirtualScroller.layout.js.map +1 -1
  53. package/commonjs/VirtualScroller.onContainerResize.js +1 -2
  54. package/commonjs/VirtualScroller.onContainerResize.js.map +1 -1
  55. package/commonjs/VirtualScroller.state.js +10 -9
  56. package/commonjs/VirtualScroller.state.js.map +1 -1
  57. package/commonjs/VirtualScroller.verticalSpacing.js +39 -6
  58. package/commonjs/VirtualScroller.verticalSpacing.js.map +1 -1
  59. package/commonjs/react/VirtualScroller.js +85 -34
  60. package/commonjs/react/VirtualScroller.js.map +1 -1
  61. package/commonjs/react/useClassName.js +2 -2
  62. package/commonjs/react/useClassName.js.map +1 -1
  63. package/commonjs/react/useForwardedRef.js +50 -0
  64. package/commonjs/react/useForwardedRef.js.map +1 -0
  65. package/commonjs/react/useInstanceMethods.js +4 -4
  66. package/commonjs/react/useInstanceMethods.js.map +1 -1
  67. package/commonjs/react/useItemKeys.js +28 -5
  68. package/commonjs/react/useItemKeys.js.map +1 -1
  69. package/commonjs/react/useOnItemHeightDidChange.js +28 -12
  70. package/commonjs/react/useOnItemHeightDidChange.js.map +1 -1
  71. package/commonjs/react/useSetItemState.js +31 -12
  72. package/commonjs/react/useSetItemState.js.map +1 -1
  73. package/commonjs/react/useState.js +9 -9
  74. package/commonjs/react/useState.js.map +1 -1
  75. package/commonjs/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +3 -3
  76. package/commonjs/react/useStateWithRepeatableRead.js.map +1 -0
  77. package/commonjs/react/useStyle.js +10 -4
  78. package/commonjs/react/useStyle.js.map +1 -1
  79. package/commonjs/react/useValidateTableBodyItemsContainer.js +24 -0
  80. package/commonjs/react/useValidateTableBodyItemsContainer.js.map +1 -0
  81. package/commonjs/react/useVirtualScroller.js +4 -3
  82. package/commonjs/react/useVirtualScroller.js.map +1 -1
  83. package/commonjs/test/ItemsContainer.js +10 -10
  84. package/commonjs/test/ItemsContainer.js.map +1 -1
  85. package/commonjs/test/VirtualScroller.js +25 -10
  86. package/commonjs/test/VirtualScroller.js.map +1 -1
  87. package/dom/index.d.ts +6 -5
  88. package/index.d.ts +19 -8
  89. package/modules/BeforeResize.js +1 -2
  90. package/modules/BeforeResize.js.map +1 -1
  91. package/modules/DOM/VirtualScroller.js +7 -13
  92. package/modules/DOM/VirtualScroller.js.map +1 -1
  93. package/modules/DOM/tbody.js +4 -4
  94. package/modules/DOM/tbody.js.map +1 -1
  95. package/modules/ItemHeights.js +11 -14
  96. package/modules/ItemHeights.js.map +1 -1
  97. package/modules/Layout.defaults.js +11 -0
  98. package/modules/Layout.defaults.js.map +1 -0
  99. package/modules/Layout.js +74 -64
  100. package/modules/Layout.js.map +1 -1
  101. package/modules/Layout.test.js +8 -4
  102. package/modules/Layout.test.js.map +1 -1
  103. package/modules/VirtualScroller.constructor.js +37 -4
  104. package/modules/VirtualScroller.constructor.js.map +1 -1
  105. package/modules/VirtualScroller.items.js +51 -5
  106. package/modules/VirtualScroller.items.js.map +1 -1
  107. package/modules/VirtualScroller.js +23 -14
  108. package/modules/VirtualScroller.js.map +1 -1
  109. package/modules/VirtualScroller.layout.js +40 -29
  110. package/modules/VirtualScroller.layout.js.map +1 -1
  111. package/modules/VirtualScroller.onContainerResize.js +1 -2
  112. package/modules/VirtualScroller.onContainerResize.js.map +1 -1
  113. package/modules/VirtualScroller.state.js +10 -9
  114. package/modules/VirtualScroller.state.js.map +1 -1
  115. package/modules/VirtualScroller.verticalSpacing.js +38 -6
  116. package/modules/VirtualScroller.verticalSpacing.js.map +1 -1
  117. package/modules/react/VirtualScroller.js +84 -35
  118. package/modules/react/VirtualScroller.js.map +1 -1
  119. package/modules/react/useClassName.js +3 -3
  120. package/modules/react/useClassName.js.map +1 -1
  121. package/modules/react/useForwardedRef.js +42 -0
  122. package/modules/react/useForwardedRef.js.map +1 -0
  123. package/modules/react/useInstanceMethods.js +4 -4
  124. package/modules/react/useInstanceMethods.js.map +1 -1
  125. package/modules/react/useItemKeys.js +28 -5
  126. package/modules/react/useItemKeys.js.map +1 -1
  127. package/modules/react/useOnItemHeightDidChange.js +28 -12
  128. package/modules/react/useOnItemHeightDidChange.js.map +1 -1
  129. package/modules/react/useSetItemState.js +31 -12
  130. package/modules/react/useSetItemState.js.map +1 -1
  131. package/modules/react/useState.js +9 -9
  132. package/modules/react/useState.js.map +1 -1
  133. package/modules/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +2 -2
  134. package/modules/react/useStateWithRepeatableRead.js.map +1 -0
  135. package/modules/react/useStyle.js +10 -4
  136. package/modules/react/useStyle.js.map +1 -1
  137. package/modules/react/useValidateTableBodyItemsContainer.js +16 -0
  138. package/modules/react/useValidateTableBodyItemsContainer.js.map +1 -0
  139. package/modules/react/useVirtualScroller.js +4 -3
  140. package/modules/react/useVirtualScroller.js.map +1 -1
  141. package/modules/test/ItemsContainer.js +10 -10
  142. package/modules/test/ItemsContainer.js.map +1 -1
  143. package/modules/test/VirtualScroller.js +25 -10
  144. package/modules/test/VirtualScroller.js.map +1 -1
  145. package/package.json +1 -1
  146. package/react/as.d.ts +42 -0
  147. package/react/index.d.ts +204 -63
  148. package/source/BeforeResize.js +1 -2
  149. package/source/DOM/VirtualScroller.js +7 -13
  150. package/source/DOM/tbody.js +5 -5
  151. package/source/ItemHeights.js +11 -12
  152. package/source/Layout.defaults.js +8 -0
  153. package/source/Layout.js +66 -53
  154. package/source/Layout.test.js +7 -2
  155. package/source/VirtualScroller.constructor.js +27 -4
  156. package/source/VirtualScroller.items.js +47 -2
  157. package/source/VirtualScroller.js +23 -14
  158. package/source/VirtualScroller.layout.js +41 -28
  159. package/source/VirtualScroller.onContainerResize.js +1 -2
  160. package/source/VirtualScroller.state.js +10 -11
  161. package/source/VirtualScroller.verticalSpacing.js +32 -6
  162. package/source/react/VirtualScroller.js +96 -33
  163. package/source/react/useClassName.js +3 -3
  164. package/source/react/useForwardedRef.js +39 -0
  165. package/source/react/useInstanceMethods.js +12 -4
  166. package/source/react/useItemKeys.js +22 -4
  167. package/source/react/useOnItemHeightDidChange.js +29 -10
  168. package/source/react/useSetItemState.js +32 -10
  169. package/source/react/useState.js +6 -6
  170. package/source/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +1 -1
  171. package/source/react/useStyle.js +3 -2
  172. package/source/react/useValidateTableBodyItemsContainer.js +16 -0
  173. package/source/react/useVirtualScroller.js +4 -3
  174. package/source/test/ItemsContainer.js +10 -10
  175. package/source/test/VirtualScroller.js +16 -10
  176. package/website/index-dom-bypass.html +198 -0
  177. package/website/index-dom-grid.html +204 -0
  178. package/website/index-dom-scrollableContainer.html +215 -0
  179. package/website/index-dom-tbody-scrollableContainer.html +81 -0
  180. package/website/index-dom-tbody.html +65 -0
  181. package/website/index-dom.html +117 -84
  182. package/website/index-react-bypass.html +200 -0
  183. package/website/{index-grid.html → index-react-grid.html} +79 -92
  184. package/website/index-react-scrollableContainer.html +213 -0
  185. package/website/index-react-strictMode.html +199 -0
  186. package/website/index-react-tbody-scrollableContainer.html +96 -0
  187. package/website/index-react-tbody.html +80 -0
  188. package/website/{index-bypass.html → index-react.html} +84 -70
  189. package/website/index.html +84 -69
  190. package/website/{messages.js → items.js} +1 -1
  191. package/website/lib/babel.min.js +25 -0
  192. package/website/lib/prop-types.min.js +1 -0
  193. package/website/lib/react-dom.development.js +29924 -0
  194. package/website/lib/react-dom.production.min.js +267 -0
  195. package/website/lib/react.development.js +3343 -0
  196. package/website/lib/react.production.min.js +31 -0
  197. package/website/style.base.css +33 -0
  198. package/website/style.list.css +92 -0
  199. package/website/style.list.grid.css +23 -0
  200. package/bundle/index-tbody-scrollableContainer.html +0 -70
  201. package/bundle/index-tbody.html +0 -57
  202. package/bundle/on-scroll-to-dom.js +0 -2
  203. package/bundle/on-scroll-to-dom.js.map +0 -1
  204. package/bundle/on-scroll-to-react.js +0 -2
  205. package/bundle/on-scroll-to-react.js.map +0 -1
  206. package/bundle/on-scroll-to.js +0 -2
  207. package/bundle/on-scroll-to.js.map +0 -1
  208. package/commonjs/react/useStateNoStaleBug.js.map +0 -1
  209. package/modules/react/useStateNoStaleBug.js.map +0 -1
  210. package/website/index-scrollableContainer.html +0 -208
  211. package/website/index-tbody-scrollableContainer.html +0 -70
  212. package/website/index-tbody.html +0 -57
  213. package/website/lib/on-scroll-to-dom.js +0 -2
  214. package/website/lib/on-scroll-to-dom.js.map +0 -1
  215. package/website/lib/on-scroll-to-react.js +0 -2
  216. package/website/lib/on-scroll-to-react.js.map +0 -1
@@ -1,4 +1,4 @@
1
- var _excluded = ["as", "items", "itemComponent", "itemComponentProps", "estimatedItemHeight", "getEstimatedItemHeight", "getEstimatedVisibleItemRowsCount", "bypass", "tbody", "preserveScrollPosition", "preserveScrollPositionOnPrependItems", "measureItemsBatchSize", "scrollableContainer", "getScrollableContainer", "getColumnsCount", "getItemId", "className", "readyToStart", "onMount", "onItemFirstRender", "onItemInitialRender", "initialScrollPosition", "onScrollPositionChange", "onStateChange", "initialState", "getInitialItemState"];
1
+ var _excluded = ["as", "items", "itemComponent", "itemComponentProps", "itemsContainerComponent", "itemsContainerComponentProps", "itemsContainerRef", "estimatedItemHeight", "getEstimatedItemHeight", "getEstimatedVisibleItemRowsCount", "getEstimatedInterItemVerticalSpacing", "onMount", "tbody", "readyToStart", "className", "bypass", "preserveScrollPosition", "preserveScrollPositionOnPrependItems", "measureItemsBatchSize", "scrollableContainer", "getScrollableContainer", "getColumnsCount", "getItemId", "onItemFirstRender", "onItemInitialRender", "initialScrollPosition", "onScrollPositionChange", "initialState", "getInitialItemState", "onStateChange"];
2
2
 
3
3
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
 
@@ -6,7 +6,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
6
6
 
7
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
8
8
 
9
- import React, { useRef, useMemo, useLayoutEffect } from 'react';
9
+ import React, { useMemo, useLayoutEffect } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import useState from './useState.js';
12
12
  import useVirtualScroller from './useVirtualScroller.js';
@@ -17,6 +17,8 @@ import useSetItemState from './useSetItemState.js';
17
17
  import useOnItemHeightDidChange from './useOnItemHeightDidChange.js';
18
18
  import useSetNewItemsOnItemsPropertyChange from './useSetNewItemsOnItemsPropertyChange.js';
19
19
  import useUpdateItemKeysOnItemsChange from './useUpdateItemKeysOnItemsChange.js';
20
+ import useValidateTableBodyItemsContainer from './useValidateTableBodyItemsContainer.js';
21
+ import useForwardedRef from './useForwardedRef.js';
20
22
  import useClassName from './useClassName.js';
21
23
  import useStyle from './useStyle.js';
22
24
  import { warn } from '../utility/debug.js'; // When `items` property changes:
@@ -31,16 +33,22 @@ import { warn } from '../utility/debug.js'; // When `items` property changes:
31
33
  // * The React component re-renders itself the second time.
32
34
 
33
35
  function VirtualScroller(_ref, ref) {
34
- var _ref$as = _ref.as,
35
- AsComponent = _ref$as === void 0 ? 'div' : _ref$as,
36
+ var as = _ref.as,
36
37
  itemsProperty = _ref.items,
37
- Component = _ref.itemComponent,
38
+ ItemComponent = _ref.itemComponent,
38
39
  itemComponentProps = _ref.itemComponentProps,
40
+ ItemsContainerComponent = _ref.itemsContainerComponent,
41
+ itemsContainerComponentProps = _ref.itemsContainerComponentProps,
42
+ itemsContainerRef = _ref.itemsContainerRef,
39
43
  estimatedItemHeight = _ref.estimatedItemHeight,
40
44
  getEstimatedItemHeight = _ref.getEstimatedItemHeight,
41
45
  getEstimatedVisibleItemRowsCount = _ref.getEstimatedVisibleItemRowsCount,
42
- bypass = _ref.bypass,
46
+ getEstimatedInterItemVerticalSpacing = _ref.getEstimatedInterItemVerticalSpacing,
47
+ onMount = _ref.onMount,
43
48
  tbody = _ref.tbody,
49
+ readyToStart = _ref.readyToStart,
50
+ classNameProperty = _ref.className,
51
+ bypass = _ref.bypass,
44
52
  preserveScrollPosition = _ref.preserveScrollPosition,
45
53
  preserveScrollPositionOnPrependItems = _ref.preserveScrollPositionOnPrependItems,
46
54
  measureItemsBatchSize = _ref.measureItemsBatchSize,
@@ -48,30 +56,46 @@ function VirtualScroller(_ref, ref) {
48
56
  getScrollableContainer = _ref.getScrollableContainer,
49
57
  getColumnsCount = _ref.getColumnsCount,
50
58
  getItemId = _ref.getItemId,
51
- className = _ref.className,
52
- readyToStart = _ref.readyToStart,
53
- onMount = _ref.onMount,
54
59
  onItemFirstRender = _ref.onItemFirstRender,
55
60
  onItemInitialRender = _ref.onItemInitialRender,
56
61
  initialScrollPosition = _ref.initialScrollPosition,
57
62
  onScrollPositionChange = _ref.onScrollPositionChange,
58
- onStateChange = _ref.onStateChange,
59
63
  initialState = _ref.initialState,
60
64
  getInitialItemState = _ref.getInitialItemState,
65
+ onStateChange = _ref.onStateChange,
61
66
  rest = _objectWithoutProperties(_ref, _excluded);
62
67
 
63
- // It turns out that since May 2022, `useVirtualScroller()` hook completely ignored the `tbody` property.
68
+ // Previously, `as` property was being used instead of `itemsContainerComponent`,
69
+ // and the default `as` property value was a generic `<div/>`.
70
+ // Starting from version `1.14.1`, it is recommended to explicitly specify the `itemsContainerComponent`.
71
+ // The default `"div"` fallback value is just a legacy compatibility relic, and so is the `as` property.
72
+ if (!ItemsContainerComponent) {
73
+ ItemsContainerComponent = as || 'div';
74
+ } // It turns out that since May 2022, `useVirtualScroller()` hook completely ignored the `tbody` property.
64
75
  // Instead, it always derived `tbody` property value from `as` property value by comparing it to `"tbody"` string.
65
76
  // As a result, it seemed like the explicit passing of `tbody` property didn't really work as intended.
66
77
  // In the end, it was decided that perhaps `tbody` property value should always be derived from `as` property
67
78
  // without a developer having to manually specify it. So the `tbody` property was deprecated.
68
79
  // It still exists though for backwards compatibility with the older versions of the package.
80
+
81
+
69
82
  if (tbody === undefined) {
70
- tbody = AsComponent === 'tbody';
83
+ // `tbody` should be somehow detected before any DOM Elements have been mounted.
84
+ // This is because during Server-Side Render there's no DOM Elements tree at all.
85
+ // And server-sider render result is required to be exactly the same as client-side render result.
86
+ // This means that `tbody` detection for the purposes of getting the initial
87
+ // `className` or `style` property values must not rely on any DOM Elements at all,
88
+ // and should use some other means such as explicitly passing a `tbody: true` property
89
+ // (as it used to be in the past) or detecting `<tbody/>` tag usage from the
90
+ // `itemsContainerCompoent` property value.
91
+ tbody = ItemsContainerComponent === 'tbody';
71
92
  } // List items "container" DOM Element reference.
72
93
 
73
94
 
74
- var container = useRef(); // Create a `VirtualScroller` instance.
95
+ var _useForwardedRef = useForwardedRef(itemsContainerRef),
96
+ setItemsContainerRef = _useForwardedRef.setRef,
97
+ itemsContainer = _useForwardedRef.internalRef; // Create a `VirtualScroller` instance.
98
+
75
99
 
76
100
  var virtualScroller = useVirtualScroller({
77
101
  items: itemsProperty,
@@ -80,6 +104,7 @@ function VirtualScroller(_ref, ref) {
80
104
  estimatedItemHeight: estimatedItemHeight,
81
105
  getEstimatedItemHeight: getEstimatedItemHeight,
82
106
  getEstimatedVisibleItemRowsCount: getEstimatedVisibleItemRowsCount,
107
+ getEstimatedInterItemVerticalSpacing: getEstimatedInterItemVerticalSpacing,
83
108
  bypass: bypass,
84
109
  // bypassBatchSize,
85
110
  onItemInitialRender: onItemInitialRender,
@@ -94,12 +119,11 @@ function VirtualScroller(_ref, ref) {
94
119
  getScrollableContainer: getScrollableContainer,
95
120
  getColumnsCount: getColumnsCount,
96
121
  getItemId: getItemId,
97
- AsComponent: AsComponent,
98
122
  initialState: initialState,
99
123
  getInitialItemState: getInitialItemState,
100
124
  onStateChange: onStateChange
101
125
  }, {
102
- container: container
126
+ itemsContainer: itemsContainer
103
127
  }); // Only compute the initial state once.
104
128
 
105
129
  var _initialState = useMemo(function () {
@@ -134,19 +158,22 @@ function VirtualScroller(_ref, ref) {
134
158
  getItemId: getItemId
135
159
  }),
136
160
  getItemKey = _useItemKeys.getItemKey,
161
+ onItemKeysReset = _useItemKeys.onItemKeysReset,
137
162
  usesAutogeneratedItemKeys = _useItemKeys.usesAutogeneratedItemKeys,
138
163
  updateItemKeysForNewItems = _useItemKeys.updateItemKeysForNewItems; // Cache per-item `setItemState` functions' "references"
139
164
  // so that item components don't get re-rendered needlessly.
140
165
 
141
166
 
142
167
  var getSetItemState = useSetItemState({
143
- initialItemsCount: itemsProperty.length,
168
+ getItemKey: getItemKey,
169
+ onItemKeysReset: onItemKeysReset,
144
170
  virtualScroller: virtualScroller
145
171
  }); // Cache per-item `onItemHeightDidChange` functions' "references"
146
172
  // so that item components don't get re-rendered needlessly.
147
173
 
148
174
  var getOnItemHeightDidChange = useOnItemHeightDidChange({
149
- initialItemsCount: itemsProperty.length,
175
+ getItemKey: getItemKey,
176
+ onItemKeysReset: onItemKeysReset,
150
177
  virtualScroller: virtualScroller
151
178
  }); // Calls `.setItems()` if `items` property has changed.
152
179
 
@@ -175,7 +202,14 @@ function VirtualScroller(_ref, ref) {
175
202
  warn('`onMount` property is deprecated');
176
203
  onMount();
177
204
  }
178
- }, []); // `willRender()` function is no longer used.
205
+ }, []); // A developer might "forget" to pass `itemsContainerComponent="tbody"` property
206
+ // when using a `<tbody/>` as a container for list items.
207
+ // This hook validates that the developer didn't "forget" to do that in such case.
208
+
209
+ useValidateTableBodyItemsContainer({
210
+ virtualScroller: virtualScroller,
211
+ tbody: tbody
212
+ }); // `willRender()` function is no longer used.
179
213
  //
180
214
  // // `getSnapshotBeforeUpdate()` is called right before `componentDidUpdate()`.
181
215
  // // A hook equivalent/workaround for `getSnapshotBeforeUpdate()`:
@@ -190,10 +224,12 @@ function VirtualScroller(_ref, ref) {
190
224
  // return null
191
225
  // }
192
226
 
193
- className = useClassName(className, {
227
+ var classNamePassThrough = classNameProperty || itemsContainerComponentProps && itemsContainerComponentProps.className;
228
+ var className = useClassName(classNamePassThrough, {
194
229
  tbody: tbody
195
230
  });
196
- var style = useStyle({
231
+ var stylePassThrough = itemsContainerComponentProps && itemsContainerComponentProps.style;
232
+ var style = useStyle(stylePassThrough, {
197
233
  tbody: tbody,
198
234
  state: stateToRender
199
235
  });
@@ -201,32 +237,36 @@ function VirtualScroller(_ref, ref) {
201
237
  itemStates = stateToRender.itemStates,
202
238
  firstShownItemIndex = stateToRender.firstShownItemIndex,
203
239
  lastShownItemIndex = stateToRender.lastShownItemIndex;
204
- return /*#__PURE__*/React.createElement(AsComponent, _extends({}, rest, {
205
- ref: container,
240
+ return /*#__PURE__*/React.createElement(ItemsContainerComponent, _extends({}, itemsContainerComponentProps, rest, {
241
+ ref: setItemsContainerRef,
206
242
  className: className,
207
243
  style: style
208
244
  }), currentItems.map(function (item, i) {
209
245
  if (i >= firstShownItemIndex && i <= lastShownItemIndex) {
210
- // * Passing `item` as `children` property is legacy and is deprecated.
246
+ // * Passing the `item` as `children` property is legacy and is deprecated.
211
247
  // If version `2.x` is published in some hypothetical future,
212
- // the `item` and `itemIndex` properties should be moved below
213
- // `{...itemComponentProps}`.
248
+ // the `item` property should be moved below `{...itemComponentProps}`.
214
249
  //
215
- // * Passing `itemIndex` property is legacy and is deprecated.
216
- // The rationale is that setting new `items` on a React component
217
- // is an asynchronous operation, so when a user obtains `itemIndex`,
218
- // they don't know which `items` list does that index correspond to,
219
- // therefore making it useless, or even buggy if used incorreclty.
250
+ // * Passing `itemIndex` property is legacy and is deprecated
251
+ // and could be removed in some future.
252
+ // The rationale for deprecation is that the `items` property
253
+ // is not constant and could change, in which case the `itemIndex` value
254
+ // would be of no use because the application wouldn't know
255
+ // which exact `items` it corresponds to at any given moment in time.
256
+ // Having just the `itemIndex` and no actual `item` is therefore considered useless.
257
+ // Instead, a developer could simply use `getItemKey(item)` function.
220
258
  //
221
- // * Passing `onStateChange` property for legacy reasons.
259
+ // * `onStateChange` property is passed here for legacy reasons.
222
260
  // The new property name is `setState`.
223
- // The old property name `onStateChange` is deprecated.
261
+ // The old property name `onStateChange` is deprecated
262
+ // and could be removed in some future.
224
263
  //
225
- // * Passing `onHeightChange` property for legacy reasons.
264
+ // * `onHeightChange` property is passed here for legacy reasons.
226
265
  // The new property name is `onHeightDidChange`.
227
- // The old property name `onHeightChange` is deprecated.
266
+ // The old property name `onHeightChange` is deprecated
267
+ // and could be removed in some future.
228
268
  //
229
- return /*#__PURE__*/React.createElement(Component, _extends({
269
+ return /*#__PURE__*/React.createElement(ItemComponent, _extends({
230
270
  item: item,
231
271
  itemIndex: i
232
272
  }, itemComponentProps, {
@@ -249,15 +289,24 @@ export default VirtualScroller; // `PropTypes.elementType` is available in some
249
289
 
250
290
  var elementType = PropTypes.elementType || PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]);
251
291
  VirtualScroller.propTypes = {
292
+ // `as` property is deprecated, use `itemsContainerComponent` property instead.
252
293
  as: elementType,
253
294
  items: PropTypes.arrayOf(PropTypes.any).isRequired,
254
295
  itemComponent: elementType.isRequired,
255
296
  itemComponentProps: PropTypes.object,
297
+ // `itemsContainerComponent` property is not required just for legacy compatibility reasons.
298
+ // Any new applications should explicitly specify it.
299
+ itemsContainerComponent: elementType,
300
+ itemsContainerComponentProps: PropTypes.object,
301
+ itemsContainerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
302
+ current: PropTypes.object
303
+ })]),
256
304
  // `estimatedItemHeight` property name is deprecated,
257
305
  // use `getEstimatedItemHeight` property instead.
258
306
  estimatedItemHeight: PropTypes.number,
259
307
  getEstimatedItemHeight: PropTypes.func,
260
308
  getEstimatedVisibleItemRowsCount: PropTypes.func,
309
+ getEstimatedInterItemVerticalSpacing: PropTypes.func,
261
310
  bypass: PropTypes.bool,
262
311
  // bypassBatchSize: PropTypes.number,
263
312
  // `tbody` property is deprecated.
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualScroller.js","names":["React","useRef","useMemo","useLayoutEffect","PropTypes","useState","useVirtualScroller","useVirtualScrollerStartStop","useInstanceMethods","useItemKeys","useSetItemState","useOnItemHeightDidChange","useSetNewItemsOnItemsPropertyChange","useUpdateItemKeysOnItemsChange","useClassName","useStyle","warn","VirtualScroller","ref","as","AsComponent","itemsProperty","items","Component","itemComponent","itemComponentProps","estimatedItemHeight","getEstimatedItemHeight","getEstimatedVisibleItemRowsCount","bypass","tbody","preserveScrollPosition","preserveScrollPositionOnPrependItems","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","getItemId","className","readyToStart","onMount","onItemFirstRender","onItemInitialRender","initialScrollPosition","onScrollPositionChange","onStateChange","initialState","getInitialItemState","rest","undefined","container","virtualScroller","_initialState","getInitialState","onRender","getState","setState","stateToRender","getItemKey","usesAutogeneratedItemKeys","updateItemKeysForNewItems","getSetItemState","initialItemsCount","length","getOnItemHeightDidChange","style","state","currentItems","itemStates","firstShownItemIndex","lastShownItemIndex","map","item","i","forwardRef","elementType","oneOfType","string","func","object","propTypes","arrayOf","any","isRequired","number","bool","shape","beforeItemsHeight","afterItemsHeight","itemHeights","columnsCount","verticalSpacing"],"sources":["../../source/react/VirtualScroller.js"],"sourcesContent":["import React, { useRef, useMemo, useLayoutEffect } from 'react'\r\nimport PropTypes from 'prop-types'\r\n\r\nimport useState from './useState.js'\r\nimport useVirtualScroller from './useVirtualScroller.js'\r\nimport useVirtualScrollerStartStop from './useVirtualScrollerStartStop.js'\r\nimport useInstanceMethods from './useInstanceMethods.js'\r\nimport useItemKeys from './useItemKeys.js'\r\nimport useSetItemState from './useSetItemState.js'\r\nimport useOnItemHeightDidChange from './useOnItemHeightDidChange.js'\r\nimport useSetNewItemsOnItemsPropertyChange from './useSetNewItemsOnItemsPropertyChange.js'\r\nimport useUpdateItemKeysOnItemsChange from './useUpdateItemKeysOnItemsChange.js'\r\nimport useClassName from './useClassName.js'\r\nimport useStyle from './useStyle.js'\r\n\r\nimport { warn } from '../utility/debug.js'\r\n\r\n// When `items` property changes:\r\n// * A new `items` property is supplied to the React component.\r\n// * The React component re-renders itself.\r\n// * `useSetNewItemsOnItemsPropertyChange()` hook is run.\r\n// * `useSetNewItemsOnItemsPropertyChange()` hook detects that the `items` property\r\n// has changed and calls `VirtualScroller.setItems(items)`.\r\n// * `VirtualScroller.setItems(items)` calls `VirtualScroller.setState()`.\r\n// * `VirtualScroller.setState()` calls the `setState()` function.\r\n// * The `setState()` function calls a setter from a `useState()` hook.\r\n// * The React component re-renders itself the second time.\r\n\r\nfunction VirtualScroller({\r\n\tas: AsComponent = 'div',\r\n\titems: itemsProperty,\r\n\titemComponent: Component,\r\n\titemComponentProps,\r\n\t// `estimatedItemHeight` property name is deprecated,\r\n\t// use `getEstimatedItemHeight` property instead.\r\n\testimatedItemHeight,\r\n\tgetEstimatedItemHeight,\r\n\tgetEstimatedVisibleItemRowsCount,\r\n\tbypass,\r\n\t// `tbody` property is deprecated.\r\n\t// Pass `as: \"tbody\"` property instead.\r\n\ttbody,\r\n\t// `preserveScrollPosition` property name is deprecated,\r\n\t// use `preserveScrollPositionOnPrependItems` property instead.\r\n\tpreserveScrollPosition,\r\n\tpreserveScrollPositionOnPrependItems,\r\n\tmeasureItemsBatchSize,\r\n\t// `scrollableContainer` property is deprecated.\r\n\t// Use `getScrollableContainer()` property instead.\r\n\tscrollableContainer,\r\n\tgetScrollableContainer,\r\n\tgetColumnsCount,\r\n\tgetItemId,\r\n\tclassName,\r\n\treadyToStart,\r\n\tonMount,\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\tonItemFirstRender,\r\n\tonItemInitialRender,\r\n\tinitialScrollPosition,\r\n\tonScrollPositionChange,\r\n\tonStateChange,\r\n\tinitialState,\r\n\tgetInitialItemState,\r\n\t...rest\r\n}, ref) {\r\n\t// It turns out that since May 2022, `useVirtualScroller()` hook completely ignored the `tbody` property.\r\n\t// Instead, it always derived `tbody` property value from `as` property value by comparing it to `\"tbody\"` string.\r\n\t// As a result, it seemed like the explicit passing of `tbody` property didn't really work as intended.\r\n\t// In the end, it was decided that perhaps `tbody` property value should always be derived from `as` property\r\n\t// without a developer having to manually specify it. So the `tbody` property was deprecated.\r\n\t// It still exists though for backwards compatibility with the older versions of the package.\r\n\tif (tbody === undefined) {\r\n\t\ttbody = AsComponent === 'tbody'\r\n\t}\r\n\r\n\t// List items \"container\" DOM Element reference.\r\n\tconst container = useRef()\r\n\r\n\t// Create a `VirtualScroller` instance.\r\n\tconst virtualScroller = useVirtualScroller({\r\n\t\titems: itemsProperty,\r\n\t\t// `estimatedItemHeight` property name is deprecated,\r\n\t\t// use `getEstimatedItemHeight` property instead.\r\n\t\testimatedItemHeight,\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tbypass,\r\n\t\t// bypassBatchSize,\r\n\t\tonItemInitialRender,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tmeasureItemsBatchSize,\r\n\t\t// `scrollableContainer` property is deprecated.\r\n\t\t// Use `getScrollableContainer()` property instead.\r\n\t\tscrollableContainer,\r\n\t\tgetScrollableContainer,\r\n\t\tgetColumnsCount,\r\n\t\tgetItemId,\r\n\t\tAsComponent,\r\n\t\tinitialState,\r\n\t\tgetInitialItemState,\r\n\t\tonStateChange\r\n\t}, {\r\n\t\tcontainer\r\n\t})\r\n\r\n\t// Only compute the initial state once.\r\n\tconst _initialState = useMemo(() => {\r\n\t\treturn virtualScroller.getInitialState()\r\n\t}, [])\r\n\r\n\t// Use React's `useState()` hook for managing `VirtualScroller`'s state lifecycle.\r\n\t// This way, React will re-render the component on every state update.\r\n\tconst {\r\n\t\tgetState,\r\n\t\tsetState,\r\n\t\tstateToRender\r\n\t} = useState({\r\n\t\tinitialState: _initialState,\r\n\t\tonRender: virtualScroller.onRender\r\n\t})\r\n\r\n\t// Use custom (external) state storage in the `VirtualScroller`.\r\n\tuseMemo(() => {\r\n\t\tvirtualScroller.useState({\r\n\t\t\tgetState,\r\n\t\t\tsetState\r\n\t\t})\r\n\t}, [])\r\n\r\n\t// Start `VirtualScroller` on mount.\r\n\t// Stop `VirtualScroller` on unmount.\r\n\tuseVirtualScrollerStartStop(virtualScroller, { readyToStart })\r\n\r\n\t// List items are rendered with `key`s so that React doesn't\r\n\t// \"reuse\" `itemComponent`s in cases when `items` are changed.\r\n\tconst {\r\n\t\tgetItemKey,\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tupdateItemKeysForNewItems\r\n\t} = useItemKeys({\r\n\t\tgetItemId\r\n\t})\r\n\r\n\t// Cache per-item `setItemState` functions' \"references\"\r\n\t// so that item components don't get re-rendered needlessly.\r\n\tconst getSetItemState = useSetItemState({\r\n\t\tinitialItemsCount: itemsProperty.length,\r\n\t\tvirtualScroller\r\n\t})\r\n\r\n\t// Cache per-item `onItemHeightDidChange` functions' \"references\"\r\n\t// so that item components don't get re-rendered needlessly.\r\n\tconst getOnItemHeightDidChange = useOnItemHeightDidChange({\r\n\t\tinitialItemsCount: itemsProperty.length,\r\n\t\tvirtualScroller\r\n\t})\r\n\r\n\t// Calls `.setItems()` if `items` property has changed.\r\n\tuseSetNewItemsOnItemsPropertyChange(itemsProperty, {\r\n\t\tvirtualScroller,\r\n\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t// use `preserveScrollPositionOnPrependItems` property instead.\r\n\t\tpreserveScrollPosition,\r\n\t\tpreserveScrollPositionOnPrependItems\r\n\t})\r\n\r\n\t// Updates `key`s if item indexes have changed.\r\n\tuseUpdateItemKeysOnItemsChange(stateToRender.items, {\r\n\t\tvirtualScroller,\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tupdateItemKeysForNewItems\r\n\t})\r\n\r\n\t// Add instance methods to the React component.\r\n\tuseInstanceMethods(ref, {\r\n\t\tvirtualScroller\r\n\t})\r\n\r\n\tuseLayoutEffect(() => {\r\n\t\t// (deprecated)\r\n\t\t// `onMount()` option is deprecated due to no longer being used.\r\n\t\t// If someone thinks there's a valid use case for it, create an issue.\r\n\t\tif (onMount) {\r\n\t\t\twarn('`onMount` property is deprecated')\r\n\t\t\tonMount()\r\n\t\t}\r\n\t}, [])\r\n\r\n\t// `willRender()` function is no longer used.\r\n\t//\r\n\t// // `getSnapshotBeforeUpdate()` is called right before `componentDidUpdate()`.\r\n\t// // A hook equivalent/workaround for `getSnapshotBeforeUpdate()`:\r\n\t// // https://github.com/facebook/react/issues/15221#issuecomment-583448887\r\n\t// //\r\n\t// getSnapshotBeforeUpdate(prevProps, prevState) {\r\n\t// \tif (this.state !== prevState) {\r\n\t// \t\tthis.willRender(this.state, prevState)\r\n\t// \t}\r\n\t// \t// Returns `null` to avoid React warning:\r\n\t// \t// \"A snapshot value (or null) must be returned. You have returned undefined\".\r\n\t// \treturn null\r\n\t// }\r\n\r\n\tclassName = useClassName(className, {\r\n\t\ttbody\r\n\t})\r\n\r\n\tconst style = useStyle({\r\n\t\ttbody,\r\n\t\tstate: stateToRender\r\n\t})\r\n\r\n\tconst {\r\n\t\titems: currentItems,\r\n\t\titemStates,\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex\r\n\t} = stateToRender\r\n\r\n\treturn (\r\n\t\t<AsComponent\r\n\t\t\t{...rest}\r\n\t\t\tref={container}\r\n\t\t\tclassName={className}\r\n\t\t\tstyle={style}>\r\n\t\t\t{currentItems.map((item, i) => {\r\n\t\t\t\tif (i >= firstShownItemIndex && i <= lastShownItemIndex) {\r\n\t\t\t\t\t// * Passing `item` as `children` property is legacy and is deprecated.\r\n\t\t\t\t\t// If version `2.x` is published in some hypothetical future,\r\n\t\t\t\t\t// the `item` and `itemIndex` properties should be moved below\r\n\t\t\t\t\t// `{...itemComponentProps}`.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// * Passing `itemIndex` property is legacy and is deprecated.\r\n\t\t\t\t\t// The rationale is that setting new `items` on a React component\r\n\t\t\t\t\t// is an asynchronous operation, so when a user obtains `itemIndex`,\r\n\t\t\t\t\t// they don't know which `items` list does that index correspond to,\r\n\t\t\t\t\t// therefore making it useless, or even buggy if used incorreclty.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// * Passing `onStateChange` property for legacy reasons.\r\n\t\t\t\t\t// The new property name is `setState`.\r\n\t\t\t\t\t// The old property name `onStateChange` is deprecated.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// * Passing `onHeightChange` property for legacy reasons.\r\n\t\t\t\t\t// The new property name is `onHeightDidChange`.\r\n\t\t\t\t\t// The old property name `onHeightChange` is deprecated.\r\n\t\t\t\t\t//\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\t<Component\r\n\t\t\t\t\t\t\titem={item}\r\n\t\t\t\t\t\t\titemIndex={i}\r\n\t\t\t\t\t\t\t{...itemComponentProps}\r\n\t\t\t\t\t\t\tkey={getItemKey(item, i)}\r\n\t\t\t\t\t\t\tstate={itemStates && itemStates[i]}\r\n\t\t\t\t\t\t\tsetState={getSetItemState(i)}\r\n\t\t\t\t\t\t\tonStateChange={getSetItemState(i)}\r\n\t\t\t\t\t\t\tonHeightChange={getOnItemHeightDidChange(i)}\r\n\t\t\t\t\t\t\tonHeightDidChange={getOnItemHeightDidChange(i)}>\r\n\t\t\t\t\t\t\t{item}\r\n\t\t\t\t\t\t</Component>\r\n\t\t\t\t\t)\r\n\t\t\t\t}\r\n\t\t\t\treturn null\r\n\t\t\t})}\r\n\t\t</AsComponent>\r\n\t)\r\n}\r\n\r\nVirtualScroller = React.forwardRef(VirtualScroller)\r\n\r\nexport default VirtualScroller\r\n\r\n// `PropTypes.elementType` is available in some version of `prop-types`.\r\n// https://github.com/facebook/prop-types/issues/200\r\nconst elementType = PropTypes.elementType || PropTypes.oneOfType([\r\n\tPropTypes.string,\r\n\tPropTypes.func,\r\n\tPropTypes.object\r\n])\r\n\r\nVirtualScroller.propTypes = {\r\n\tas: elementType,\r\n\titems: PropTypes.arrayOf(PropTypes.any).isRequired,\r\n\titemComponent: elementType.isRequired,\r\n\titemComponentProps: PropTypes.object,\r\n\t// `estimatedItemHeight` property name is deprecated,\r\n\t// use `getEstimatedItemHeight` property instead.\r\n\testimatedItemHeight: PropTypes.number,\r\n\tgetEstimatedItemHeight: PropTypes.func,\r\n\tgetEstimatedVisibleItemRowsCount: PropTypes.func,\r\n\tbypass: PropTypes.bool,\r\n\t// bypassBatchSize: PropTypes.number,\r\n\t// `tbody` property is deprecated.\r\n\t// Pass `as: \"tbody\"` property instead.\r\n\t// tbody: PropTypes.bool,\r\n\tpreserveScrollPositionOnPrependItems: PropTypes.bool,\r\n\t// `preserveScrollPosition` property name is deprecated,\r\n\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\tpreserveScrollPosition: PropTypes.bool,\r\n\tmeasureItemsBatchSize: PropTypes.number,\r\n\t// `scrollableContainer` property is deprecated.\r\n\t// Use `getScrollableContainer()` property instead.\r\n\tscrollableContainer: PropTypes.any,\r\n\tgetScrollableContainer: PropTypes.func,\r\n\tgetColumnsCount: PropTypes.func,\r\n\tgetItemId: PropTypes.func,\r\n\tclassName: PropTypes.string,\r\n\treadyToStart: PropTypes.bool,\r\n\tonMount: PropTypes.func,\r\n\tonItemInitialRender: PropTypes.func,\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\tonItemFirstRender: PropTypes.func,\r\n\tinitialScrollPosition: PropTypes.number,\r\n\tonScrollPositionChange: PropTypes.func,\r\n\tonStateChange: PropTypes.func,\r\n\tinitialState: PropTypes.shape({\r\n\t\titems: PropTypes.arrayOf(PropTypes.object).isRequired,\r\n\t\titemStates: PropTypes.arrayOf(PropTypes.any).isRequired,\r\n\t\tfirstShownItemIndex: PropTypes.number.isRequired,\r\n\t\tlastShownItemIndex: PropTypes.number.isRequired,\r\n\t\tbeforeItemsHeight: PropTypes.number.isRequired,\r\n\t\tafterItemsHeight: PropTypes.number.isRequired,\r\n\t\titemHeights: PropTypes.arrayOf(PropTypes.number).isRequired,\r\n\t\tcolumnsCount: PropTypes.number,\r\n\t\tverticalSpacing: PropTypes.number\r\n\t}),\r\n\tgetInitialItemState: PropTypes.func\r\n}\r\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,OAAxB,EAAiCC,eAAjC,QAAwD,OAAxD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,QAAP,MAAqB,eAArB;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,2BAAP,MAAwC,kCAAxC;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,WAAP,MAAwB,kBAAxB;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,wBAAP,MAAqC,+BAArC;AACA,OAAOC,mCAAP,MAAgD,0CAAhD;AACA,OAAOC,8BAAP,MAA2C,qCAA3C;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AACA,OAAOC,QAAP,MAAqB,eAArB;AAEA,SAASC,IAAT,QAAqB,qBAArB,C,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,eAAT,OAqCGC,GArCH,EAqCQ;EAAA,mBApCPC,EAoCO;EAAA,IApCHC,W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BAAsB,EAAExC,SAAS,CAAC0E,IAjCP;EAkC3BjC,aAAa,EAAEzC,SAAS,CAAC0E,IAlCE;EAmC3BhC,YAAY,EAAE1C,SAAS,CAACkF,KAAV,CAAgB;IAC7BhE,KAAK,EAAElB,SAAS,CAAC6E,OAAV,CAAkB7E,SAAS,CAAC2E,MAA5B,EAAoCI,UADd;IAE7Bf,UAAU,EAAEhE,SAAS,CAAC6E,OAAV,CAAkB7E,SAAS,CAAC8E,GAA5B,EAAiCC,UAFhB;IAG7Bd,mBAAmB,EAAEjE,SAAS,CAACgF,MAAV,CAAiBD,UAHT;IAI7Bb,kBAAkB,EAAElE,SAAS,CAACgF,MAAV,CAAiBD,UAJR;IAK7BI,iBAAiB,EAAEnF,SAAS,CAACgF,MAAV,CAAiBD,UALP;IAM7BK,gBAAgB,EAAEpF,SAAS,CAACgF,MAAV,CAAiBD,UANN;IAO7BM,WAAW,EAAErF,SAAS,CAAC6E,OAAV,CAAkB7E,SAAS,CAACgF,MAA5B,EAAoCD,UAPpB;IAQ7BO,YAAY,EAAEtF,SAAS,CAACgF,MARK;IAS7BO,eAAe,EAAEvF,SAAS,CAACgF;EATE,CAAhB,CAnCa;EA8C3BrC,mBAAmB,EAAE3C,SAAS,CAAC0E;AA9CJ,CAA5B"}
1
+ {"version":3,"file":"VirtualScroller.js","names":["React","useMemo","useLayoutEffect","PropTypes","useState","useVirtualScroller","useVirtualScrollerStartStop","useInstanceMethods","useItemKeys","useSetItemState","useOnItemHeightDidChange","useSetNewItemsOnItemsPropertyChange","useUpdateItemKeysOnItemsChange","useValidateTableBodyItemsContainer","useForwardedRef","useClassName","useStyle","warn","VirtualScroller","ref","as","itemsProperty","items","ItemComponent","itemComponent","itemComponentProps","ItemsContainerComponent","itemsContainerComponent","itemsContainerComponentProps","itemsContainerRef","estimatedItemHeight","getEstimatedItemHeight","getEstimatedVisibleItemRowsCount","getEstimatedInterItemVerticalSpacing","onMount","tbody","readyToStart","classNameProperty","className","bypass","preserveScrollPosition","preserveScrollPositionOnPrependItems","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","getItemId","onItemFirstRender","onItemInitialRender","initialScrollPosition","onScrollPositionChange","initialState","getInitialItemState","onStateChange","rest","undefined","setItemsContainerRef","setRef","itemsContainer","internalRef","virtualScroller","_initialState","getInitialState","onRender","getState","setState","stateToRender","getItemKey","onItemKeysReset","usesAutogeneratedItemKeys","updateItemKeysForNewItems","getSetItemState","getOnItemHeightDidChange","classNamePassThrough","stylePassThrough","style","state","currentItems","itemStates","firstShownItemIndex","lastShownItemIndex","map","item","i","forwardRef","elementType","oneOfType","string","func","object","propTypes","arrayOf","any","isRequired","shape","current","number","bool","beforeItemsHeight","afterItemsHeight","itemHeights","columnsCount","verticalSpacing"],"sources":["../../source/react/VirtualScroller.js"],"sourcesContent":["import React, { useMemo, useLayoutEffect } from 'react'\r\nimport PropTypes from 'prop-types'\r\n\r\nimport useState from './useState.js'\r\nimport useVirtualScroller from './useVirtualScroller.js'\r\nimport useVirtualScrollerStartStop from './useVirtualScrollerStartStop.js'\r\nimport useInstanceMethods from './useInstanceMethods.js'\r\nimport useItemKeys from './useItemKeys.js'\r\nimport useSetItemState from './useSetItemState.js'\r\nimport useOnItemHeightDidChange from './useOnItemHeightDidChange.js'\r\nimport useSetNewItemsOnItemsPropertyChange from './useSetNewItemsOnItemsPropertyChange.js'\r\nimport useUpdateItemKeysOnItemsChange from './useUpdateItemKeysOnItemsChange.js'\r\nimport useValidateTableBodyItemsContainer from './useValidateTableBodyItemsContainer.js'\r\nimport useForwardedRef from './useForwardedRef.js'\r\nimport useClassName from './useClassName.js'\r\nimport useStyle from './useStyle.js'\r\n\r\nimport { warn } from '../utility/debug.js'\r\n\r\n// When `items` property changes:\r\n// * A new `items` property is supplied to the React component.\r\n// * The React component re-renders itself.\r\n// * `useSetNewItemsOnItemsPropertyChange()` hook is run.\r\n// * `useSetNewItemsOnItemsPropertyChange()` hook detects that the `items` property\r\n// has changed and calls `VirtualScroller.setItems(items)`.\r\n// * `VirtualScroller.setItems(items)` calls `VirtualScroller.setState()`.\r\n// * `VirtualScroller.setState()` calls the `setState()` function.\r\n// * The `setState()` function calls a setter from a `useState()` hook.\r\n// * The React component re-renders itself the second time.\r\n\r\nfunction VirtualScroller({\r\n\t// The following are `<VirtualScroller/>` properties.\r\n\t//\r\n\t// `as` property is deprecated, use `itemsContainerComponent` property instead.\r\n\tas,\r\n\titems: itemsProperty,\r\n\titemComponent: ItemComponent,\r\n\titemComponentProps,\r\n\titemsContainerComponent: ItemsContainerComponent,\r\n\titemsContainerComponentProps,\r\n\titemsContainerRef,\r\n\t// `estimatedItemHeight` property name is deprecated,\r\n\t// use `getEstimatedItemHeight` property instead.\r\n\testimatedItemHeight,\r\n\tgetEstimatedItemHeight,\r\n\tgetEstimatedVisibleItemRowsCount,\r\n\tgetEstimatedInterItemVerticalSpacing,\r\n\tonMount,\r\n\t// `tbody` property is deprecated.\r\n\t// Pass `as: \"tbody\"` property instead.\r\n\ttbody,\r\n\treadyToStart,\r\n\tclassName: classNameProperty,\r\n\r\n\t// The following are the \"core\" component options.\r\n\t//\r\n\tbypass,\r\n\t// `preserveScrollPosition` property name is deprecated,\r\n\t// use `preserveScrollPositionOnPrependItems` property instead.\r\n\tpreserveScrollPosition,\r\n\tpreserveScrollPositionOnPrependItems,\r\n\tmeasureItemsBatchSize,\r\n\t// `scrollableContainer` property is deprecated.\r\n\t// Use `getScrollableContainer()` property instead.\r\n\tscrollableContainer,\r\n\tgetScrollableContainer,\r\n\tgetColumnsCount,\r\n\tgetItemId,\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\tonItemFirstRender,\r\n\tonItemInitialRender,\r\n\tinitialScrollPosition,\r\n\tonScrollPositionChange,\r\n\tinitialState,\r\n\tgetInitialItemState,\r\n\tonStateChange,\r\n\r\n\t// \"Rest\" properties that will be passed through to the `itemsContainerComponent`.\r\n\t...rest\r\n}, ref) {\r\n\t// Previously, `as` property was being used instead of `itemsContainerComponent`,\r\n\t// and the default `as` property value was a generic `<div/>`.\r\n\t// Starting from version `1.14.1`, it is recommended to explicitly specify the `itemsContainerComponent`.\r\n\t// The default `\"div\"` fallback value is just a legacy compatibility relic, and so is the `as` property.\r\n\tif (!ItemsContainerComponent) {\r\n\t\tItemsContainerComponent = as || 'div'\r\n\t}\r\n\r\n\t// It turns out that since May 2022, `useVirtualScroller()` hook completely ignored the `tbody` property.\r\n\t// Instead, it always derived `tbody` property value from `as` property value by comparing it to `\"tbody\"` string.\r\n\t// As a result, it seemed like the explicit passing of `tbody` property didn't really work as intended.\r\n\t// In the end, it was decided that perhaps `tbody` property value should always be derived from `as` property\r\n\t// without a developer having to manually specify it. So the `tbody` property was deprecated.\r\n\t// It still exists though for backwards compatibility with the older versions of the package.\r\n\tif (tbody === undefined) {\r\n\t\t// `tbody` should be somehow detected before any DOM Elements have been mounted.\r\n\t\t// This is because during Server-Side Render there's no DOM Elements tree at all.\r\n\t\t// And server-sider render result is required to be exactly the same as client-side render result.\r\n\t\t// This means that `tbody` detection for the purposes of getting the initial\r\n\t\t// `className` or `style` property values must not rely on any DOM Elements at all,\r\n\t\t// and should use some other means such as explicitly passing a `tbody: true` property\r\n\t\t// (as it used to be in the past) or detecting `<tbody/>` tag usage from the\r\n\t\t// `itemsContainerCompoent` property value.\r\n\t\ttbody = ItemsContainerComponent === 'tbody'\r\n\t}\r\n\r\n\t// List items \"container\" DOM Element reference.\r\n\tconst {\r\n\t\tsetRef: setItemsContainerRef,\r\n\t\tinternalRef: itemsContainer\r\n\t} = useForwardedRef(itemsContainerRef)\r\n\r\n\t// Create a `VirtualScroller` instance.\r\n\tconst virtualScroller = useVirtualScroller({\r\n\t\titems: itemsProperty,\r\n\t\t// `estimatedItemHeight` property name is deprecated,\r\n\t\t// use `getEstimatedItemHeight` property instead.\r\n\t\testimatedItemHeight,\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tgetEstimatedInterItemVerticalSpacing,\r\n\t\tbypass,\r\n\t\t// bypassBatchSize,\r\n\t\tonItemInitialRender,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tmeasureItemsBatchSize,\r\n\t\t// `scrollableContainer` property is deprecated.\r\n\t\t// Use `getScrollableContainer()` property instead.\r\n\t\tscrollableContainer,\r\n\t\tgetScrollableContainer,\r\n\t\tgetColumnsCount,\r\n\t\tgetItemId,\r\n\t\tinitialState,\r\n\t\tgetInitialItemState,\r\n\t\tonStateChange\r\n\t}, {\r\n\t\titemsContainer\r\n\t})\r\n\r\n\t// Only compute the initial state once.\r\n\tconst _initialState = useMemo(() => {\r\n\t\treturn virtualScroller.getInitialState()\r\n\t}, [])\r\n\r\n\t// Use React's `useState()` hook for managing `VirtualScroller`'s state lifecycle.\r\n\t// This way, React will re-render the component on every state update.\r\n\tconst {\r\n\t\tgetState,\r\n\t\tsetState,\r\n\t\tstateToRender\r\n\t} = useState({\r\n\t\tinitialState: _initialState,\r\n\t\tonRender: virtualScroller.onRender\r\n\t})\r\n\r\n\t// Use custom (external) state storage in the `VirtualScroller`.\r\n\tuseMemo(() => {\r\n\t\tvirtualScroller.useState({\r\n\t\t\tgetState,\r\n\t\t\tsetState\r\n\t\t})\r\n\t}, [])\r\n\r\n\t// Start `VirtualScroller` on mount.\r\n\t// Stop `VirtualScroller` on unmount.\r\n\tuseVirtualScrollerStartStop(virtualScroller, { readyToStart })\r\n\r\n\t// List items are rendered with `key`s so that React doesn't\r\n\t// \"reuse\" `itemComponent`s in cases when `items` are changed.\r\n\tconst {\r\n\t\tgetItemKey,\r\n\t\tonItemKeysReset,\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tupdateItemKeysForNewItems\r\n\t} = useItemKeys({\r\n\t\tgetItemId\r\n\t})\r\n\r\n\t// Cache per-item `setItemState` functions' \"references\"\r\n\t// so that item components don't get re-rendered needlessly.\r\n\tconst getSetItemState = useSetItemState({\r\n\t\tgetItemKey,\r\n\t\tonItemKeysReset,\r\n\t\tvirtualScroller\r\n\t})\r\n\r\n\t// Cache per-item `onItemHeightDidChange` functions' \"references\"\r\n\t// so that item components don't get re-rendered needlessly.\r\n\tconst getOnItemHeightDidChange = useOnItemHeightDidChange({\r\n\t\tgetItemKey,\r\n\t\tonItemKeysReset,\r\n\t\tvirtualScroller\r\n\t})\r\n\r\n\t// Calls `.setItems()` if `items` property has changed.\r\n\tuseSetNewItemsOnItemsPropertyChange(itemsProperty, {\r\n\t\tvirtualScroller,\r\n\t\t// `preserveScrollPosition` property name is deprecated,\r\n\t\t// use `preserveScrollPositionOnPrependItems` property instead.\r\n\t\tpreserveScrollPosition,\r\n\t\tpreserveScrollPositionOnPrependItems\r\n\t})\r\n\r\n\t// Updates `key`s if item indexes have changed.\r\n\tuseUpdateItemKeysOnItemsChange(stateToRender.items, {\r\n\t\tvirtualScroller,\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tupdateItemKeysForNewItems\r\n\t})\r\n\r\n\t// Add instance methods to the React component.\r\n\tuseInstanceMethods(ref, {\r\n\t\tvirtualScroller\r\n\t})\r\n\r\n\tuseLayoutEffect(() => {\r\n\t\t// (deprecated)\r\n\t\t// `onMount()` option is deprecated due to no longer being used.\r\n\t\t// If someone thinks there's a valid use case for it, create an issue.\r\n\t\tif (onMount) {\r\n\t\t\twarn('`onMount` property is deprecated')\r\n\t\t\tonMount()\r\n\t\t}\r\n\t}, [])\r\n\r\n\t// A developer might \"forget\" to pass `itemsContainerComponent=\"tbody\"` property\r\n\t// when using a `<tbody/>` as a container for list items.\r\n\t// This hook validates that the developer didn't \"forget\" to do that in such case.\r\n\tuseValidateTableBodyItemsContainer({\r\n\t\tvirtualScroller,\r\n\t\ttbody\r\n\t})\r\n\r\n\t// `willRender()` function is no longer used.\r\n\t//\r\n\t// // `getSnapshotBeforeUpdate()` is called right before `componentDidUpdate()`.\r\n\t// // A hook equivalent/workaround for `getSnapshotBeforeUpdate()`:\r\n\t// // https://github.com/facebook/react/issues/15221#issuecomment-583448887\r\n\t// //\r\n\t// getSnapshotBeforeUpdate(prevProps, prevState) {\r\n\t// \tif (this.state !== prevState) {\r\n\t// \t\tthis.willRender(this.state, prevState)\r\n\t// \t}\r\n\t// \t// Returns `null` to avoid React warning:\r\n\t// \t// \"A snapshot value (or null) must be returned. You have returned undefined\".\r\n\t// \treturn null\r\n\t// }\r\n\r\n\tconst classNamePassThrough = classNameProperty || itemsContainerComponentProps && itemsContainerComponentProps.className\r\n\r\n\tconst className = useClassName(classNamePassThrough, {\r\n\t\ttbody\r\n\t})\r\n\r\n\tconst stylePassThrough = itemsContainerComponentProps && itemsContainerComponentProps.style\r\n\r\n\tconst style = useStyle(stylePassThrough, {\r\n\t\ttbody,\r\n\t\tstate: stateToRender\r\n\t})\r\n\r\n\tconst {\r\n\t\titems: currentItems,\r\n\t\titemStates,\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex\r\n\t} = stateToRender\r\n\r\n\treturn (\r\n\t\t<ItemsContainerComponent\r\n\t\t\t{...itemsContainerComponentProps}\r\n\t\t\t{...rest}\r\n\t\t\tref={setItemsContainerRef}\r\n\t\t\tclassName={className}\r\n\t\t\tstyle={style}>\r\n\t\t\t{currentItems.map((item, i) => {\r\n\t\t\t\tif (i >= firstShownItemIndex && i <= lastShownItemIndex) {\r\n\t\t\t\t\t// * Passing the `item` as `children` property is legacy and is deprecated.\r\n\t\t\t\t\t// If version `2.x` is published in some hypothetical future,\r\n\t\t\t\t\t// the `item` property should be moved below `{...itemComponentProps}`.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// * Passing `itemIndex` property is legacy and is deprecated\r\n\t\t\t\t\t// and could be removed in some future.\r\n\t\t\t\t\t// The rationale for deprecation is that the `items` property\r\n\t\t\t\t\t// is not constant and could change, in which case the `itemIndex` value\r\n\t\t\t\t\t// would be of no use because the application wouldn't know\r\n\t\t\t\t\t// which exact `items` it corresponds to at any given moment in time.\r\n\t\t\t\t\t// Having just the `itemIndex` and no actual `item` is therefore considered useless.\r\n\t\t\t\t\t// Instead, a developer could simply use `getItemKey(item)` function.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// * `onStateChange` property is passed here for legacy reasons.\r\n\t\t\t\t\t// The new property name is `setState`.\r\n\t\t\t\t\t// The old property name `onStateChange` is deprecated\r\n\t\t\t\t\t// and could be removed in some future.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// * `onHeightChange` property is passed here for legacy reasons.\r\n\t\t\t\t\t// The new property name is `onHeightDidChange`.\r\n\t\t\t\t\t// The old property name `onHeightChange` is deprecated\r\n\t\t\t\t\t// and could be removed in some future.\r\n\t\t\t\t\t//\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\t<ItemComponent\r\n\t\t\t\t\t\t\titem={item}\r\n\t\t\t\t\t\t\titemIndex={i}\r\n\t\t\t\t\t\t\t{...itemComponentProps}\r\n\t\t\t\t\t\t\tkey={getItemKey(item, i)}\r\n\t\t\t\t\t\t\tstate={itemStates && itemStates[i]}\r\n\t\t\t\t\t\t\tsetState={getSetItemState(i)}\r\n\t\t\t\t\t\t\tonStateChange={getSetItemState(i)}\r\n\t\t\t\t\t\t\tonHeightChange={getOnItemHeightDidChange(i)}\r\n\t\t\t\t\t\t\tonHeightDidChange={getOnItemHeightDidChange(i)}>\r\n\t\t\t\t\t\t\t{item}\r\n\t\t\t\t\t\t</ItemComponent>\r\n\t\t\t\t\t)\r\n\t\t\t\t}\r\n\t\t\t\treturn null\r\n\t\t\t})}\r\n\t\t</ItemsContainerComponent>\r\n\t)\r\n}\r\n\r\nVirtualScroller = React.forwardRef(VirtualScroller)\r\n\r\nexport default VirtualScroller\r\n\r\n// `PropTypes.elementType` is available in some version of `prop-types`.\r\n// https://github.com/facebook/prop-types/issues/200\r\nconst elementType = PropTypes.elementType || PropTypes.oneOfType([\r\n\tPropTypes.string,\r\n\tPropTypes.func,\r\n\tPropTypes.object\r\n])\r\n\r\nVirtualScroller.propTypes = {\r\n\t// `as` property is deprecated, use `itemsContainerComponent` property instead.\r\n\tas: elementType,\r\n\titems: PropTypes.arrayOf(PropTypes.any).isRequired,\r\n\titemComponent: elementType.isRequired,\r\n\titemComponentProps: PropTypes.object,\r\n\t// `itemsContainerComponent` property is not required just for legacy compatibility reasons.\r\n\t// Any new applications should explicitly specify it.\r\n\titemsContainerComponent: elementType,\r\n\titemsContainerComponentProps: PropTypes.object,\r\n\titemsContainerRef: PropTypes.oneOfType([\r\n\t\tPropTypes.func,\r\n\t\tPropTypes.shape({ current: PropTypes.object })\r\n\t]),\r\n\t// `estimatedItemHeight` property name is deprecated,\r\n\t// use `getEstimatedItemHeight` property instead.\r\n\testimatedItemHeight: PropTypes.number,\r\n\tgetEstimatedItemHeight: PropTypes.func,\r\n\tgetEstimatedVisibleItemRowsCount: PropTypes.func,\r\n\tgetEstimatedInterItemVerticalSpacing: PropTypes.func,\r\n\tbypass: PropTypes.bool,\r\n\t// bypassBatchSize: PropTypes.number,\r\n\t// `tbody` property is deprecated.\r\n\t// Pass `as: \"tbody\"` property instead.\r\n\t// tbody: PropTypes.bool,\r\n\tpreserveScrollPositionOnPrependItems: PropTypes.bool,\r\n\t// `preserveScrollPosition` property name is deprecated,\r\n\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\tpreserveScrollPosition: PropTypes.bool,\r\n\tmeasureItemsBatchSize: PropTypes.number,\r\n\t// `scrollableContainer` property is deprecated.\r\n\t// Use `getScrollableContainer()` property instead.\r\n\tscrollableContainer: PropTypes.any,\r\n\tgetScrollableContainer: PropTypes.func,\r\n\tgetColumnsCount: PropTypes.func,\r\n\tgetItemId: PropTypes.func,\r\n\tclassName: PropTypes.string,\r\n\treadyToStart: PropTypes.bool,\r\n\tonMount: PropTypes.func,\r\n\tonItemInitialRender: PropTypes.func,\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\tonItemFirstRender: PropTypes.func,\r\n\tinitialScrollPosition: PropTypes.number,\r\n\tonScrollPositionChange: PropTypes.func,\r\n\tonStateChange: PropTypes.func,\r\n\tinitialState: PropTypes.shape({\r\n\t\titems: PropTypes.arrayOf(PropTypes.object).isRequired,\r\n\t\titemStates: PropTypes.arrayOf(PropTypes.any).isRequired,\r\n\t\tfirstShownItemIndex: PropTypes.number.isRequired,\r\n\t\tlastShownItemIndex: PropTypes.number.isRequired,\r\n\t\tbeforeItemsHeight: PropTypes.number.isRequired,\r\n\t\tafterItemsHeight: PropTypes.number.isRequired,\r\n\t\titemHeights: PropTypes.arrayOf(PropTypes.number).isRequired,\r\n\t\tcolumnsCount: PropTypes.number,\r\n\t\tverticalSpacing: PropTypes.number\r\n\t}),\r\n\tgetInitialItemState: PropTypes.func\r\n}\r\n"],"mappings":";;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,eAAzB,QAAgD,OAAhD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,QAAP,MAAqB,eAArB;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,2BAAP,MAAwC,kCAAxC;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,WAAP,MAAwB,kBAAxB;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,wBAAP,MAAqC,+BAArC;AACA,OAAOC,mCAAP,MAAgD,0CAAhD;AACA,OAAOC,8BAAP,MAA2C,qCAA3C;AACA,OAAOC,kCAAP,MAA+C,yCAA/C;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AACA,OAAOC,QAAP,MAAqB,eAArB;AAEA,SAASC,IAAT,QAAqB,qBAArB,C,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,eAAT,OAiDGC,GAjDH,EAiDQ;EAAA,IA7CPC,EA6CO,QA7C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BxE,KAAK,EAAEnB,SAAS,CAACwF,OAAV,CAAkBxF,SAAS,CAACsF,MAA5B,EAAoCI,UADd;IAE7Bf,UAAU,EAAE3E,SAAS,CAACwF,OAAV,CAAkBxF,SAAS,CAACyF,GAA5B,EAAiCC,UAFhB;IAG7Bd,mBAAmB,EAAE5E,SAAS,CAAC6F,MAAV,CAAiBH,UAHT;IAI7Bb,kBAAkB,EAAE7E,SAAS,CAAC6F,MAAV,CAAiBH,UAJR;IAK7BK,iBAAiB,EAAE/F,SAAS,CAAC6F,MAAV,CAAiBH,UALP;IAM7BM,gBAAgB,EAAEhG,SAAS,CAAC6F,MAAV,CAAiBH,UANN;IAO7BO,WAAW,EAAEjG,SAAS,CAACwF,OAAV,CAAkBxF,SAAS,CAAC6F,MAA5B,EAAoCH,UAPpB;IAQ7BQ,YAAY,EAAElG,SAAS,CAAC6F,MARK;IAS7BM,eAAe,EAAEnG,SAAS,CAAC6F;EATE,CAAhB,CA7Ca;EAwD3B5C,mBAAmB,EAAEjD,SAAS,CAACqF;AAxDJ,CAA5B"}
@@ -1,4 +1,4 @@
1
- import { TBODY_CLASS_NAME } from '../DOM/tbody.js';
1
+ import { CLASS_NAME_FOR_TBODY_WORKAROUND } from '../DOM/tbody.js';
2
2
  export default function useClassName(className, _ref) {
3
3
  var tbody = _ref.tbody;
4
4
 
@@ -7,10 +7,10 @@ export default function useClassName(className, _ref) {
7
7
  // See `addTbodyStyles()` function in `../DOM/tbody.js` for more details.
8
8
  if (tbody) {
9
9
  if (className) {
10
- return className + ' ' + TBODY_CLASS_NAME;
10
+ return className + ' ' + CLASS_NAME_FOR_TBODY_WORKAROUND;
11
11
  }
12
12
 
13
- return TBODY_CLASS_NAME;
13
+ return CLASS_NAME_FOR_TBODY_WORKAROUND;
14
14
  }
15
15
 
16
16
  return className;
@@ -1 +1 @@
1
- {"version":3,"file":"useClassName.js","names":["TBODY_CLASS_NAME","useClassName","className","tbody"],"sources":["../../source/react/useClassName.js"],"sourcesContent":["import { TBODY_CLASS_NAME } from '../DOM/tbody.js'\r\n\r\nexport default function useClassName(className, { tbody }) {\r\n\t// For `<tbody/>`, a workaround is used which uses CSS variables\r\n\t// and a special CSS class name \"VirtualScroller\".\r\n\t// See `addTbodyStyles()` function in `../DOM/tbody.js` for more details.\r\n\tif (tbody) {\r\n\t\tif (className) {\r\n\t\t\treturn className + ' ' + TBODY_CLASS_NAME\r\n\t\t}\r\n\t\treturn TBODY_CLASS_NAME\r\n\t}\r\n\treturn className\r\n}"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,iBAAjC;AAEA,eAAe,SAASC,YAAT,CAAsBC,SAAtB,QAA4C;EAAA,IAATC,KAAS,QAATA,KAAS;;EAC1D;EACA;EACA;EACA,IAAIA,KAAJ,EAAW;IACV,IAAID,SAAJ,EAAe;MACd,OAAOA,SAAS,GAAG,GAAZ,GAAkBF,gBAAzB;IACA;;IACD,OAAOA,gBAAP;EACA;;EACD,OAAOE,SAAP;AACA"}
1
+ {"version":3,"file":"useClassName.js","names":["CLASS_NAME_FOR_TBODY_WORKAROUND","useClassName","className","tbody"],"sources":["../../source/react/useClassName.js"],"sourcesContent":["import { CLASS_NAME_FOR_TBODY_WORKAROUND } from '../DOM/tbody.js'\r\n\r\nexport default function useClassName(className, { tbody }) {\r\n\t// For `<tbody/>`, a workaround is used which uses CSS variables\r\n\t// and a special CSS class name \"VirtualScroller\".\r\n\t// See `addTbodyStyles()` function in `../DOM/tbody.js` for more details.\r\n\tif (tbody) {\r\n\t\tif (className) {\r\n\t\t\treturn className + ' ' + CLASS_NAME_FOR_TBODY_WORKAROUND\r\n\t\t}\r\n\t\treturn CLASS_NAME_FOR_TBODY_WORKAROUND\r\n\t}\r\n\treturn className\r\n}"],"mappings":"AAAA,SAASA,+BAAT,QAAgD,iBAAhD;AAEA,eAAe,SAASC,YAAT,CAAsBC,SAAtB,QAA4C;EAAA,IAATC,KAAS,QAATA,KAAS;;EAC1D;EACA;EACA;EACA,IAAIA,KAAJ,EAAW;IACV,IAAID,SAAJ,EAAe;MACd,OAAOA,SAAS,GAAG,GAAZ,GAAkBF,+BAAzB;IACA;;IACD,OAAOA,+BAAP;EACA;;EACD,OAAOE,SAAP;AACA"}
@@ -0,0 +1,42 @@
1
+ // import type { MutableRefObject } from 'react'
2
+ import { useCallback, useRef } from 'react'; // When a React component receives a `ref` which it is supposed to "forward"
3
+ // and when it would like to also read that `ref` in its internal implementation,
4
+ // this `useForwardedRef()` hook could be used to get read access to such "forwarded" ref
5
+ // inside the component's internal implementation.
6
+ //
7
+ // ```js
8
+ // const FormWithAutoFocus = forwardRef((props, ref) => {
9
+ // const { setRef, internalRef } = useForwardedRef<RefValueType>(ref)
10
+ //
11
+ // useEffect(() => {
12
+ // internalRef.current.focus()
13
+ // }, [])
14
+ //
15
+ // return (
16
+ // <Form ref={setRef} {...props}/>
17
+ // )
18
+ // })
19
+ // ```
20
+ //
21
+ // export default function useForwardedRef<T extends MutableRefObject<any>>(ref) {
22
+
23
+ export default function useForwardedRef(ref) {
24
+ var internalRef = useRef(); // as T
25
+
26
+ var setRef = useCallback(function (instance) {
27
+ internalRef.current = instance;
28
+
29
+ if (ref) {
30
+ if (typeof ref === 'function') {
31
+ ref(instance);
32
+ } else {
33
+ ref.current = instance;
34
+ }
35
+ }
36
+ }, [ref]);
37
+ return {
38
+ setRef: setRef,
39
+ internalRef: internalRef
40
+ };
41
+ }
42
+ //# sourceMappingURL=useForwardedRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForwardedRef.js","names":["useCallback","useRef","useForwardedRef","ref","internalRef","setRef","instance","current"],"sources":["../../source/react/useForwardedRef.js"],"sourcesContent":["// import type { MutableRefObject } from 'react'\r\nimport { useCallback, useRef } from 'react'\r\n\r\n// When a React component receives a `ref` which it is supposed to \"forward\"\r\n// and when it would like to also read that `ref` in its internal implementation,\r\n// this `useForwardedRef()` hook could be used to get read access to such \"forwarded\" ref\r\n// inside the component's internal implementation.\r\n//\r\n// ```js\r\n// const FormWithAutoFocus = forwardRef((props, ref) => {\r\n// const { setRef, internalRef } = useForwardedRef<RefValueType>(ref)\r\n//\r\n// useEffect(() => {\r\n// internalRef.current.focus()\r\n// }, [])\r\n//\r\n// return (\r\n// <Form ref={setRef} {...props}/>\r\n// )\r\n// })\r\n// ```\r\n//\r\n// export default function useForwardedRef<T extends MutableRefObject<any>>(ref) {\r\nexport default function useForwardedRef(ref) {\r\n\tconst internalRef = useRef() // as T\r\n\r\n\tconst setRef = useCallback((instance) => {\r\n\t\tinternalRef.current = instance\r\n\t\tif (ref) {\r\n\t\t\tif (typeof ref === 'function') {\r\n\t\t\t\tref(instance)\r\n\t\t\t} else {\r\n\t\t\t\tref.current = instance\r\n\t\t\t}\r\n\t\t}\r\n\t}, [ref])\r\n\r\n\treturn { setRef, internalRef }\r\n}\r\n"],"mappings":"AAAA;AACA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC,C,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,eAAT,CAAyBC,GAAzB,EAA8B;EAC5C,IAAMC,WAAW,GAAGH,MAAM,EAA1B,CAD4C,CACf;;EAE7B,IAAMI,MAAM,GAAGL,WAAW,CAAC,UAACM,QAAD,EAAc;IACxCF,WAAW,CAACG,OAAZ,GAAsBD,QAAtB;;IACA,IAAIH,GAAJ,EAAS;MACR,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;QAC9BA,GAAG,CAACG,QAAD,CAAH;MACA,CAFD,MAEO;QACNH,GAAG,CAACI,OAAJ,GAAcD,QAAd;MACA;IACD;EACD,CATyB,EASvB,CAACH,GAAD,CATuB,CAA1B;EAWA,OAAO;IAAEE,MAAM,EAANA,MAAF;IAAUD,WAAW,EAAXA;EAAV,CAAP;AACA"}
@@ -7,20 +7,20 @@ export default function useInstanceMethods(ref, _ref) {
7
7
  return {
8
8
  // This is a proxy for `VirtualScroller`'s `.updateLayout` instance method.
9
9
  updateLayout: function updateLayout() {
10
- return virtualScroller.updateLayout();
10
+ virtualScroller.updateLayout();
11
11
  },
12
12
  // (deprecated)
13
13
  // `.layout()` method name is deprecated, use `.updateLayout()` instead.
14
14
  layout: function layout() {
15
- return virtualScroller.updateLayout();
15
+ virtualScroller.updateLayout();
16
16
  },
17
17
  // (deprecated)
18
18
  updateItem: function updateItem(i) {
19
- return reportError("[virtual-scroller] \".updateItem(i)\" method of React <VirtualScroller/> has been removed");
19
+ reportError("[virtual-scroller] \".updateItem(i)\" method of React <VirtualScroller/> has been removed");
20
20
  },
21
21
  // (deprecated)
22
22
  renderItem: function renderItem(i) {
23
- return reportError("[virtual-scroller] \".renderItem(i)\" method of React <VirtualScroller/> has been removed");
23
+ reportError("[virtual-scroller] \".renderItem(i)\" method of React <VirtualScroller/> has been removed");
24
24
  }
25
25
  };
26
26
  }, [virtualScroller]);
@@ -1 +1 @@
1
- {"version":3,"file":"useInstanceMethods.js","names":["useImperativeHandle","reportError","useInstanceMethods","ref","virtualScroller","updateLayout","layout","updateItem","i","renderItem"],"sources":["../../source/react/useInstanceMethods.js"],"sourcesContent":["import { useImperativeHandle } from 'react'\r\n\r\nimport { reportError } from '../utility/debug.js'\r\n\r\n// Adds instance methods to the React component.\r\nexport default function useInstanceMethods(ref, {\r\n\tvirtualScroller\r\n}) {\r\n\tuseImperativeHandle(ref, () => ({\r\n\t\t// This is a proxy for `VirtualScroller`'s `.updateLayout` instance method.\r\n\t\tupdateLayout: () => virtualScroller.updateLayout(),\r\n\r\n\t\t// (deprecated)\r\n\t\t// `.layout()` method name is deprecated, use `.updateLayout()` instead.\r\n layout: () => virtualScroller.updateLayout(),\r\n\r\n\t\t// (deprecated)\r\n\t\tupdateItem: (i) => reportError(`[virtual-scroller] \".updateItem(i)\" method of React <VirtualScroller/> has been removed`),\r\n\r\n\t\t// (deprecated)\r\n\t\trenderItem: (i) => reportError(`[virtual-scroller] \".renderItem(i)\" method of React <VirtualScroller/> has been removed`)\r\n\t}), [\r\n\t\tvirtualScroller\r\n\t])\r\n}"],"mappings":"AAAA,SAASA,mBAAT,QAAoC,OAApC;AAEA,SAASC,WAAT,QAA4B,qBAA5B,C,CAEA;;AACA,eAAe,SAASC,kBAAT,CAA4BC,GAA5B,QAEZ;EAAA,IADFC,eACE,QADFA,eACE;EACFJ,mBAAmB,CAACG,GAAD,EAAM;IAAA,OAAO;MAC/B;MACAE,YAAY,EAAE;QAAA,OAAMD,eAAe,CAACC,YAAhB,EAAN;MAAA,CAFiB;MAI/B;MACA;MACEC,MAAM,EAAE;QAAA,OAAMF,eAAe,CAACC,YAAhB,EAAN;MAAA,CANqB;MAQ/B;MACAE,UAAU,EAAE,oBAACC,CAAD;QAAA,OAAOP,WAAW,6FAAlB;MAAA,CATmB;MAW/B;MACAQ,UAAU,EAAE,oBAACD,CAAD;QAAA,OAAOP,WAAW,6FAAlB;MAAA;IAZmB,CAAP;EAAA,CAAN,EAaf,CACHG,eADG,CAbe,CAAnB;AAgBA"}
1
+ {"version":3,"file":"useInstanceMethods.js","names":["useImperativeHandle","reportError","useInstanceMethods","ref","virtualScroller","updateLayout","layout","updateItem","i","renderItem"],"sources":["../../source/react/useInstanceMethods.js"],"sourcesContent":["import { useImperativeHandle } from 'react'\r\n\r\nimport { reportError } from '../utility/debug.js'\r\n\r\n// Adds instance methods to the React component.\r\nexport default function useInstanceMethods(ref, {\r\n\tvirtualScroller\r\n}) {\r\n\tuseImperativeHandle(ref, () => ({\r\n\t\t// This is a proxy for `VirtualScroller`'s `.updateLayout` instance method.\r\n\t\tupdateLayout: () => {\r\n\t\t\tvirtualScroller.updateLayout()\r\n\t\t},\r\n\r\n\t\t// (deprecated)\r\n\t\t// `.layout()` method name is deprecated, use `.updateLayout()` instead.\r\n layout: () => {\r\n\t\t\tvirtualScroller.updateLayout()\r\n\t\t},\r\n\r\n\t\t// (deprecated)\r\n\t\tupdateItem: (i) => {\r\n\t\t\treportError(`[virtual-scroller] \".updateItem(i)\" method of React <VirtualScroller/> has been removed`)\r\n\t\t},\r\n\r\n\t\t// (deprecated)\r\n\t\trenderItem: (i) => {\r\n\t\t\treportError(`[virtual-scroller] \".renderItem(i)\" method of React <VirtualScroller/> has been removed`)\r\n\t\t}\r\n\t}), [\r\n\t\tvirtualScroller\r\n\t])\r\n}"],"mappings":"AAAA,SAASA,mBAAT,QAAoC,OAApC;AAEA,SAASC,WAAT,QAA4B,qBAA5B,C,CAEA;;AACA,eAAe,SAASC,kBAAT,CAA4BC,GAA5B,QAEZ;EAAA,IADFC,eACE,QADFA,eACE;EACFJ,mBAAmB,CAACG,GAAD,EAAM;IAAA,OAAO;MAC/B;MACAE,YAAY,EAAE,wBAAM;QACnBD,eAAe,CAACC,YAAhB;MACA,CAJ8B;MAM/B;MACA;MACEC,MAAM,EAAE,kBAAM;QACfF,eAAe,CAACC,YAAhB;MACA,CAV8B;MAY/B;MACAE,UAAU,EAAE,oBAACC,CAAD,EAAO;QAClBP,WAAW,6FAAX;MACA,CAf8B;MAiB/B;MACAQ,UAAU,EAAE,oBAACD,CAAD,EAAO;QAClBP,WAAW,6FAAX;MACA;IApB8B,CAAP;EAAA,CAAN,EAqBf,CACHG,eADG,CArBe,CAAnB;AAwBA"}
@@ -1,16 +1,38 @@
1
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2
+
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6
+
1
7
  import log from '../utility/debug.js';
2
8
  import { useRef, useMemo, useCallback } from 'react';
3
9
  export default function useItemKeys(_ref) {
4
10
  var getItemId = _ref.getItemId;
5
- // List items are rendered with `key`s so that React doesn't
11
+ // These "listeners" will be called in case the auto-generated item keys are reset
12
+ // due to the prefix counter number reaching its maximum allowed value.
13
+ var itemKeysResetEventListeners = useMemo(function () {
14
+ return [];
15
+ }, []); // Adds an "on item keys reset" listener.
16
+
17
+ var onItemKeysReset = useCallback(function (listener) {
18
+ itemKeysResetEventListeners.push(listener);
19
+ }, []); // List items are rendered with `key`s so that React doesn't
6
20
  // "reuse" `itemComponent`s in cases when `items` are changed.
7
- var itemKeyPrefix = useRef(); // Generates a unique `key` prefix for list item components.
21
+
22
+ var itemKeyPrefix = useRef(); // When no `getItemId()` function is specified, it creates an item key
23
+ // from an auto-generated unique prefix and the item's index in the `items` array.
24
+ // This way, when the `items` change, their keys are also changed.
8
25
 
9
26
  var generateItemKeyPrefix = useMemo(function () {
10
27
  var counter = 0;
11
28
 
12
29
  function getNextCounter() {
13
30
  if (counter === Number.MAX_SAFE_INTEGER) {
31
+ for (var _iterator = _createForOfIteratorHelperLoose(itemKeysResetEventListeners), _step; !(_step = _iterator()).done;) {
32
+ var listener = _step.value;
33
+ listener();
34
+ }
35
+
14
36
  counter = 0;
15
37
  }
16
38
 
@@ -21,9 +43,9 @@ export default function useItemKeys(_ref) {
21
43
  return function () {
22
44
  itemKeyPrefix.current = String(getNextCounter());
23
45
  };
24
- }, [itemKeyPrefix]);
46
+ }, [itemKeyPrefix, itemKeysResetEventListeners]);
25
47
  useMemo(function () {
26
- // Generate an initial unique `key` prefix for list item components.
48
+ // Generate an initial unique `key` prefix for list items.
27
49
  generateItemKeyPrefix();
28
50
  }, []); // If `getItemId()` function is defined, then item `id`s are gonna be the item element `key`s.
29
51
 
@@ -43,13 +65,14 @@ export default function useItemKeys(_ref) {
43
65
 
44
66
  var getItemKey = useCallback(function (item, i) {
45
67
  if (getItemId) {
46
- return getItemId(item);
68
+ return String(getItemId(item));
47
69
  }
48
70
 
49
71
  return "".concat(itemKeyPrefix.current, ":").concat(i);
50
72
  }, [getItemId, itemKeyPrefix]);
51
73
  return {
52
74
  getItemKey: getItemKey,
75
+ onItemKeysReset: onItemKeysReset,
53
76
  usesAutogeneratedItemKeys: usesAutogeneratedItemKeys,
54
77
  updateItemKeysForNewItems: generateItemKeyPrefixIfNotUsingItemIds
55
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useItemKeys.js","names":["log","useRef","useMemo","useCallback","useItemKeys","getItemId","itemKeyPrefix","generateItemKeyPrefix","counter","getNextCounter","Number","MAX_SAFE_INTEGER","current","String","usesAutogeneratedItemKeys","generateItemKeyPrefixIfNotUsingItemIds","getItemKey","item","i","updateItemKeysForNewItems"],"sources":["../../source/react/useItemKeys.js"],"sourcesContent":["import log from '../utility/debug.js'\r\n\r\nimport { useRef, useMemo, useCallback } from 'react'\r\n\r\nexport default function useItemKeys({ getItemId }) {\r\n\t// List items are rendered with `key`s so that React doesn't\r\n\t// \"reuse\" `itemComponent`s in cases when `items` are changed.\r\n const itemKeyPrefix = useRef()\r\n\r\n\t// Generates a unique `key` prefix for list item components.\r\n\tconst generateItemKeyPrefix = useMemo(() => {\r\n\t\tlet counter = 0\r\n\t\tfunction getNextCounter() {\r\n\t\t\tif (counter === Number.MAX_SAFE_INTEGER) {\r\n\t\t\t\tcounter = 0\r\n\t\t\t}\r\n\t\t\tcounter++\r\n\t\t\treturn counter\r\n\t\t}\r\n\t\treturn () => {\r\n\t\t\titemKeyPrefix.current = String(getNextCounter())\r\n\t\t}\r\n\t}, [\r\n\t\titemKeyPrefix\r\n\t])\r\n\r\n\tuseMemo(() => {\r\n\t\t// Generate an initial unique `key` prefix for list item components.\r\n\t\tgenerateItemKeyPrefix()\r\n\t}, [])\r\n\r\n\t// If `getItemId()` function is defined, then item `id`s are gonna be the item element `key`s.\r\n\tconst usesAutogeneratedItemKeys = !getItemId\r\n\r\n\tconst generateItemKeyPrefixIfNotUsingItemIds = useCallback(() => {\r\n\t\tif (usesAutogeneratedItemKeys) {\r\n\t\t\tgenerateItemKeyPrefix()\r\n\t\t\tlog('React: ~ Item key prefix:', itemKeyPrefix.current)\r\n\t\t}\r\n\t}, [\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tgenerateItemKeyPrefix\r\n\t])\r\n\r\n\t/**\r\n\t * Returns a `key` for an `item`'s element.\r\n\t * @param {object} item — The item.\r\n\t * @param {number} i — Item's index in `items` list.\r\n\t * @return {any}\r\n\t */\r\n\tconst getItemKey = useCallback((item, i) => {\r\n\t\tif (getItemId) {\r\n\t\t\treturn getItemId(item)\r\n\t\t}\r\n\t\treturn `${itemKeyPrefix.current}:${i}`\r\n\t}, [\r\n\t\tgetItemId,\r\n\t\titemKeyPrefix\r\n\t])\r\n\r\n\treturn {\r\n\t\tgetItemKey,\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tupdateItemKeysForNewItems: generateItemKeyPrefixIfNotUsingItemIds\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,qBAAhB;AAEA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,WAA1B,QAA6C,OAA7C;AAEA,eAAe,SAASC,WAAT,OAAoC;EAAA,IAAbC,SAAa,QAAbA,SAAa;EAClD;EACA;EACC,IAAMC,aAAa,GAAGL,MAAM,EAA5B,CAHiD,CAKlD;;EACA,IAAMM,qBAAqB,GAAGL,OAAO,CAAC,YAAM;IAC3C,IAAIM,OAAO,GAAG,CAAd;;IACA,SAASC,cAAT,GAA0B;MACzB,IAAID,OAAO,KAAKE,MAAM,CAACC,gBAAvB,EAAyC;QACxCH,OAAO,GAAG,CAAV;MACA;;MACDA,OAAO;MACP,OAAOA,OAAP;IACA;;IACD,OAAO,YAAM;MACZF,aAAa,CAACM,OAAd,GAAwBC,MAAM,CAACJ,cAAc,EAAf,CAA9B;IACA,CAFD;EAGA,CAZoC,EAYlC,CACFH,aADE,CAZkC,CAArC;EAgBAJ,OAAO,CAAC,YAAM;IACb;IACAK,qBAAqB;EACrB,CAHM,EAGJ,EAHI,CAAP,CAtBkD,CA2BlD;;EACA,IAAMO,yBAAyB,GAAG,CAACT,SAAnC;EAEA,IAAMU,sCAAsC,GAAGZ,WAAW,CAAC,YAAM;IAChE,IAAIW,yBAAJ,EAA+B;MAC9BP,qBAAqB;MACrBP,GAAG,CAAC,2BAAD,EAA8BM,aAAa,CAACM,OAA5C,CAAH;IACA;EACD,CALyD,EAKvD,CACFE,yBADE,EAEFP,qBAFE,CALuD,CAA1D;EAUA;AACD;AACA;AACA;AACA;AACA;;EACC,IAAMS,UAAU,GAAGb,WAAW,CAAC,UAACc,IAAD,EAAOC,CAAP,EAAa;IAC3C,IAAIb,SAAJ,EAAe;MACd,OAAOA,SAAS,CAACY,IAAD,CAAhB;IACA;;IACD,iBAAUX,aAAa,CAACM,OAAxB,cAAmCM,CAAnC;EACA,CAL6B,EAK3B,CACFb,SADE,EAEFC,aAFE,CAL2B,CAA9B;EAUA,OAAO;IACNU,UAAU,EAAVA,UADM;IAENF,yBAAyB,EAAzBA,yBAFM;IAGNK,yBAAyB,EAAEJ;EAHrB,CAAP;AAKA"}
1
+ {"version":3,"file":"useItemKeys.js","names":["log","useRef","useMemo","useCallback","useItemKeys","getItemId","itemKeysResetEventListeners","onItemKeysReset","listener","push","itemKeyPrefix","generateItemKeyPrefix","counter","getNextCounter","Number","MAX_SAFE_INTEGER","current","String","usesAutogeneratedItemKeys","generateItemKeyPrefixIfNotUsingItemIds","getItemKey","item","i","updateItemKeysForNewItems"],"sources":["../../source/react/useItemKeys.js"],"sourcesContent":["import log from '../utility/debug.js'\r\n\r\nimport { useRef, useMemo, useCallback } from 'react'\r\n\r\nexport default function useItemKeys({ getItemId }) {\r\n\t// These \"listeners\" will be called in case the auto-generated item keys are reset\r\n\t// due to the prefix counter number reaching its maximum allowed value.\r\n\tconst itemKeysResetEventListeners = useMemo(() => {\r\n\t\treturn []\r\n\t}, [])\r\n\r\n\t// Adds an \"on item keys reset\" listener.\r\n\tconst onItemKeysReset = useCallback((listener) => {\r\n\t\titemKeysResetEventListeners.push(listener)\r\n\t}, [])\r\n\r\n\t// List items are rendered with `key`s so that React doesn't\r\n\t// \"reuse\" `itemComponent`s in cases when `items` are changed.\r\n const itemKeyPrefix = useRef()\r\n\r\n\t// When no `getItemId()` function is specified, it creates an item key\r\n\t// from an auto-generated unique prefix and the item's index in the `items` array.\r\n\t// This way, when the `items` change, their keys are also changed.\r\n\tconst generateItemKeyPrefix = useMemo(() => {\r\n\t\tlet counter = 0\r\n\t\tfunction getNextCounter() {\r\n\t\t\tif (counter === Number.MAX_SAFE_INTEGER) {\r\n\t\t\t\tfor (const listener of itemKeysResetEventListeners) {\r\n\t\t\t\t\tlistener()\r\n\t\t\t\t}\r\n\t\t\t\tcounter = 0\r\n\t\t\t}\r\n\t\t\tcounter++\r\n\t\t\treturn counter\r\n\t\t}\r\n\t\treturn () => {\r\n\t\t\titemKeyPrefix.current = String(getNextCounter())\r\n\t\t}\r\n\t}, [\r\n\t\titemKeyPrefix,\r\n\t\titemKeysResetEventListeners\r\n\t])\r\n\r\n\tuseMemo(() => {\r\n\t\t// Generate an initial unique `key` prefix for list items.\r\n\t\tgenerateItemKeyPrefix()\r\n\t}, [])\r\n\r\n\t// If `getItemId()` function is defined, then item `id`s are gonna be the item element `key`s.\r\n\tconst usesAutogeneratedItemKeys = !getItemId\r\n\r\n\tconst generateItemKeyPrefixIfNotUsingItemIds = useCallback(() => {\r\n\t\tif (usesAutogeneratedItemKeys) {\r\n\t\t\tgenerateItemKeyPrefix()\r\n\t\t\tlog('React: ~ Item key prefix:', itemKeyPrefix.current)\r\n\t\t}\r\n\t}, [\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tgenerateItemKeyPrefix\r\n\t])\r\n\r\n\t/**\r\n\t * Returns a `key` for an `item`'s element.\r\n\t * @param {object} item — The item.\r\n\t * @param {number} i — Item's index in `items` list.\r\n\t * @return {any}\r\n\t */\r\n\tconst getItemKey = useCallback((item, i) => {\r\n\t\tif (getItemId) {\r\n\t\t\treturn String(getItemId(item))\r\n\t\t}\r\n\t\treturn `${itemKeyPrefix.current}:${i}`\r\n\t}, [\r\n\t\tgetItemId,\r\n\t\titemKeyPrefix\r\n\t])\r\n\r\n\treturn {\r\n\t\tgetItemKey,\r\n\t\tonItemKeysReset,\r\n\t\tusesAutogeneratedItemKeys,\r\n\t\tupdateItemKeysForNewItems: generateItemKeyPrefixIfNotUsingItemIds\r\n\t}\r\n}"],"mappings":";;;;;;AAAA,OAAOA,GAAP,MAAgB,qBAAhB;AAEA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,WAA1B,QAA6C,OAA7C;AAEA,eAAe,SAASC,WAAT,OAAoC;EAAA,IAAbC,SAAa,QAAbA,SAAa;EAClD;EACA;EACA,IAAMC,2BAA2B,GAAGJ,OAAO,CAAC,YAAM;IACjD,OAAO,EAAP;EACA,CAF0C,EAExC,EAFwC,CAA3C,CAHkD,CAOlD;;EACA,IAAMK,eAAe,GAAGJ,WAAW,CAAC,UAACK,QAAD,EAAc;IACjDF,2BAA2B,CAACG,IAA5B,CAAiCD,QAAjC;EACA,CAFkC,EAEhC,EAFgC,CAAnC,CARkD,CAYlD;EACA;;EACC,IAAME,aAAa,GAAGT,MAAM,EAA5B,CAdiD,CAgBlD;EACA;EACA;;EACA,IAAMU,qBAAqB,GAAGT,OAAO,CAAC,YAAM;IAC3C,IAAIU,OAAO,GAAG,CAAd;;IACA,SAASC,cAAT,GAA0B;MACzB,IAAID,OAAO,K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