virtual-scroller 1.13.1 → 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 (231) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +825 -578
  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 +116 -83
  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 +67 -44
  34. package/commonjs/DOM/VirtualScroller.js.map +1 -1
  35. package/commonjs/DOM/tbody.js +15 -15
  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 +78 -67
  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/Scroll.js +3 -3
  46. package/commonjs/Scroll.js.map +1 -1
  47. package/commonjs/ScrollableContainerResizeHandler.js +4 -5
  48. package/commonjs/ScrollableContainerResizeHandler.js.map +1 -1
  49. package/commonjs/VirtualScroller.constructor.js +53 -31
  50. package/commonjs/VirtualScroller.constructor.js.map +1 -1
  51. package/commonjs/VirtualScroller.items.js +50 -4
  52. package/commonjs/VirtualScroller.items.js.map +1 -1
  53. package/commonjs/VirtualScroller.js +44 -28
  54. package/commonjs/VirtualScroller.js.map +1 -1
  55. package/commonjs/VirtualScroller.layout.js +42 -31
  56. package/commonjs/VirtualScroller.layout.js.map +1 -1
  57. package/commonjs/VirtualScroller.onContainerResize.js +1 -2
  58. package/commonjs/VirtualScroller.onContainerResize.js.map +1 -1
  59. package/commonjs/VirtualScroller.onRender.js +1 -1
  60. package/commonjs/VirtualScroller.onRender.js.map +1 -1
  61. package/commonjs/VirtualScroller.state.js +18 -9
  62. package/commonjs/VirtualScroller.state.js.map +1 -1
  63. package/commonjs/VirtualScroller.verticalSpacing.js +39 -6
  64. package/commonjs/VirtualScroller.verticalSpacing.js.map +1 -1
  65. package/commonjs/react/VirtualScroller.js +98 -37
  66. package/commonjs/react/VirtualScroller.js.map +1 -1
  67. package/commonjs/react/useClassName.js +2 -2
  68. package/commonjs/react/useClassName.js.map +1 -1
  69. package/commonjs/react/useForwardedRef.js +50 -0
  70. package/commonjs/react/useForwardedRef.js.map +1 -0
  71. package/commonjs/react/useInstanceMethods.js +4 -4
  72. package/commonjs/react/useInstanceMethods.js.map +1 -1
  73. package/commonjs/react/useItemKeys.js +28 -5
  74. package/commonjs/react/useItemKeys.js.map +1 -1
  75. package/commonjs/react/useOnItemHeightDidChange.js +28 -12
  76. package/commonjs/react/useOnItemHeightDidChange.js.map +1 -1
  77. package/commonjs/react/useSetItemState.js +31 -12
  78. package/commonjs/react/useSetItemState.js.map +1 -1
  79. package/commonjs/react/useState.js +10 -11
  80. package/commonjs/react/useState.js.map +1 -1
  81. package/commonjs/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +3 -3
  82. package/commonjs/react/useStateWithRepeatableRead.js.map +1 -0
  83. package/commonjs/react/useStyle.js +10 -4
  84. package/commonjs/react/useStyle.js.map +1 -1
  85. package/commonjs/react/useValidateTableBodyItemsContainer.js +24 -0
  86. package/commonjs/react/useValidateTableBodyItemsContainer.js.map +1 -0
  87. package/commonjs/react/useVirtualScroller.js +12 -14
  88. package/commonjs/react/useVirtualScroller.js.map +1 -1
  89. package/commonjs/test/ItemsContainer.js +10 -10
  90. package/commonjs/test/ItemsContainer.js.map +1 -1
  91. package/commonjs/test/VirtualScroller.js +25 -10
  92. package/commonjs/test/VirtualScroller.js.map +1 -1
  93. package/dom/index.d.ts +11 -9
  94. package/index.d.ts +19 -9
  95. package/modules/BeforeResize.js +1 -2
  96. package/modules/BeforeResize.js.map +1 -1
  97. package/modules/DOM/VirtualScroller.js +67 -44
  98. package/modules/DOM/VirtualScroller.js.map +1 -1
  99. package/modules/DOM/tbody.js +14 -13
  100. package/modules/DOM/tbody.js.map +1 -1
  101. package/modules/ItemHeights.js +11 -14
  102. package/modules/ItemHeights.js.map +1 -1
  103. package/modules/Layout.defaults.js +11 -0
  104. package/modules/Layout.defaults.js.map +1 -0
  105. package/modules/Layout.js +77 -67
  106. package/modules/Layout.js.map +1 -1
  107. package/modules/Layout.test.js +8 -4
  108. package/modules/Layout.test.js.map +1 -1
  109. package/modules/Scroll.js +3 -3
  110. package/modules/Scroll.js.map +1 -1
  111. package/modules/ScrollableContainerResizeHandler.js +4 -5
  112. package/modules/ScrollableContainerResizeHandler.js.map +1 -1
  113. package/modules/VirtualScroller.constructor.js +53 -31
  114. package/modules/VirtualScroller.constructor.js.map +1 -1
  115. package/modules/VirtualScroller.items.js +51 -5
  116. package/modules/VirtualScroller.items.js.map +1 -1
  117. package/modules/VirtualScroller.js +44 -28
  118. package/modules/VirtualScroller.js.map +1 -1
  119. package/modules/VirtualScroller.layout.js +42 -31
  120. package/modules/VirtualScroller.layout.js.map +1 -1
  121. package/modules/VirtualScroller.onContainerResize.js +1 -2
  122. package/modules/VirtualScroller.onContainerResize.js.map +1 -1
  123. package/modules/VirtualScroller.onRender.js +1 -1
  124. package/modules/VirtualScroller.onRender.js.map +1 -1
  125. package/modules/VirtualScroller.state.js +18 -9
  126. package/modules/VirtualScroller.state.js.map +1 -1
  127. package/modules/VirtualScroller.verticalSpacing.js +38 -6
  128. package/modules/VirtualScroller.verticalSpacing.js.map +1 -1
  129. package/modules/react/VirtualScroller.js +97 -38
  130. package/modules/react/VirtualScroller.js.map +1 -1
  131. package/modules/react/useClassName.js +3 -3
  132. package/modules/react/useClassName.js.map +1 -1
  133. package/modules/react/useForwardedRef.js +42 -0
  134. package/modules/react/useForwardedRef.js.map +1 -0
  135. package/modules/react/useInstanceMethods.js +4 -4
  136. package/modules/react/useInstanceMethods.js.map +1 -1
  137. package/modules/react/useItemKeys.js +28 -5
  138. package/modules/react/useItemKeys.js.map +1 -1
  139. package/modules/react/useOnItemHeightDidChange.js +28 -12
  140. package/modules/react/useOnItemHeightDidChange.js.map +1 -1
  141. package/modules/react/useSetItemState.js +31 -12
  142. package/modules/react/useSetItemState.js.map +1 -1
  143. package/modules/react/useState.js +10 -11
  144. package/modules/react/useState.js.map +1 -1
  145. package/modules/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +2 -2
  146. package/modules/react/useStateWithRepeatableRead.js.map +1 -0
  147. package/modules/react/useStyle.js +10 -4
  148. package/modules/react/useStyle.js.map +1 -1
  149. package/modules/react/useValidateTableBodyItemsContainer.js +16 -0
  150. package/modules/react/useValidateTableBodyItemsContainer.js.map +1 -0
  151. package/modules/react/useVirtualScroller.js +10 -12
  152. package/modules/react/useVirtualScroller.js.map +1 -1
  153. package/modules/test/ItemsContainer.js +10 -10
  154. package/modules/test/ItemsContainer.js.map +1 -1
  155. package/modules/test/VirtualScroller.js +25 -10
  156. package/modules/test/VirtualScroller.js.map +1 -1
  157. package/package.json +1 -1
  158. package/react/as.d.ts +42 -0
  159. package/react/index.d.ts +204 -63
  160. package/source/BeforeResize.js +1 -2
  161. package/source/DOM/VirtualScroller.js +65 -40
  162. package/source/DOM/tbody.js +15 -14
  163. package/source/ItemHeights.js +11 -12
  164. package/source/Layout.defaults.js +8 -0
  165. package/source/Layout.js +69 -56
  166. package/source/Layout.test.js +7 -2
  167. package/source/Scroll.js +3 -3
  168. package/source/ScrollableContainerResizeHandler.js +4 -4
  169. package/source/VirtualScroller.constructor.js +40 -31
  170. package/source/VirtualScroller.items.js +47 -2
  171. package/source/VirtualScroller.js +49 -27
  172. package/source/VirtualScroller.layout.js +43 -30
  173. package/source/VirtualScroller.onContainerResize.js +1 -2
  174. package/source/VirtualScroller.onRender.js +1 -1
  175. package/source/VirtualScroller.state.js +18 -11
  176. package/source/VirtualScroller.verticalSpacing.js +32 -6
  177. package/source/react/VirtualScroller.js +111 -36
  178. package/source/react/useClassName.js +3 -3
  179. package/source/react/useForwardedRef.js +39 -0
  180. package/source/react/useInstanceMethods.js +12 -4
  181. package/source/react/useItemKeys.js +22 -4
  182. package/source/react/useOnItemHeightDidChange.js +29 -10
  183. package/source/react/useSetItemState.js +32 -10
  184. package/source/react/useState.js +7 -8
  185. package/source/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +1 -1
  186. package/source/react/useStyle.js +3 -2
  187. package/source/react/useValidateTableBodyItemsContainer.js +16 -0
  188. package/source/react/useVirtualScroller.js +4 -6
  189. package/source/test/ItemsContainer.js +10 -10
  190. package/source/test/VirtualScroller.js +16 -10
  191. package/website/index-dom-bypass.html +198 -0
  192. package/website/index-dom-grid.html +204 -0
  193. package/website/index-dom-scrollableContainer.html +215 -0
  194. package/website/index-dom-tbody-scrollableContainer.html +81 -0
  195. package/website/index-dom-tbody.html +65 -0
  196. package/website/index-dom.html +117 -84
  197. package/website/index-react-bypass.html +200 -0
  198. package/website/{index-grid.html → index-react-grid.html} +79 -92
  199. package/website/index-react-scrollableContainer.html +213 -0
  200. package/website/index-react-strictMode.html +199 -0
  201. package/website/index-react-tbody-scrollableContainer.html +96 -0
  202. package/website/index-react-tbody.html +80 -0
  203. package/website/{index-bypass.html → index-react.html} +84 -70
  204. package/website/index.html +84 -69
  205. package/website/{messages.js → items.js} +1 -1
  206. package/website/lib/babel.min.js +25 -0
  207. package/website/lib/prop-types.min.js +1 -0
  208. package/website/lib/react-dom.development.js +29924 -0
  209. package/website/lib/react-dom.production.min.js +267 -0
  210. package/website/lib/react.development.js +3343 -0
  211. package/website/lib/react.production.min.js +31 -0
  212. package/website/style.base.css +33 -0
  213. package/website/style.list.css +92 -0
  214. package/website/style.list.grid.css +23 -0
  215. package/bundle/index-tbody-scrollableContainer.html +0 -70
  216. package/bundle/index-tbody.html +0 -57
  217. package/bundle/on-scroll-to-dom.js +0 -2
  218. package/bundle/on-scroll-to-dom.js.map +0 -1
  219. package/bundle/on-scroll-to-react.js +0 -2
  220. package/bundle/on-scroll-to-react.js.map +0 -1
  221. package/bundle/on-scroll-to.js +0 -2
  222. package/bundle/on-scroll-to.js.map +0 -1
  223. package/commonjs/react/useStateNoStaleBug.js.map +0 -1
  224. package/modules/react/useStateNoStaleBug.js.map +0 -1
  225. package/website/index-scrollableContainer.html +0 -208
  226. package/website/index-tbody-scrollableContainer.html +0 -70
  227. package/website/index-tbody.html +0 -57
  228. package/website/lib/on-scroll-to-dom.js +0 -2
  229. package/website/lib/on-scroll-to-dom.js.map +0 -1
  230. package/website/lib/on-scroll-to-react.js +0 -2
  231. package/website/lib/on-scroll-to-react.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualScroller.state.js","names":["fillArray","log","warn","isDebug","reportError","cleanUpBeforeResizeState","getStateSnapshot","createStateHelpers","initialState","state","getInitialItemState","onStateChange","render","initialItems","items","_render","_setItemState","i","newItemState","JSON","stringify","getState","itemStates","newItemsWillBeRendered","itemStatesThatChangedWhileNewItemsWereBeingRendered","String","_getState","updateState","stateUpdate","_isSettingNewItems","undefined","waitingForRender","previousState","mostRecentSetStateValue","_setState","getInitialState","getRestoredState","call","getInitialStateFromScratch","useState","setState","_isActive","Error","_usesCustomStateStorage","newState","useDefaultStateStorage","defaultGetState","bind","defaultSetState","setInitialState","defaultSetInitialState","onRender","getInitialLayoutState","beforeStart","Array","length","firstShownItemIndex","lastShownItemIndex","verticalSpacing","isStateColumnsCountMismatch","columnsCount","getActualColumnsCount","itemsCount","getColumnsCount","layout","getInitialLayoutValueWithFallback","getInitialLayoutValues","beforeItemsHeight","afterItemsHeight","itemHeights","onBeforeShowItems","getActualColumnsCountForState","stateColumnsCount","Math","floor"],"sources":["../source/VirtualScroller.state.js"],"sourcesContent":["import fillArray from './utility/fillArray.js'\r\nimport log, { warn, isDebug, reportError } from './utility/debug.js'\r\nimport { cleanUpBeforeResizeState } from './BeforeResize.js'\r\nimport getStateSnapshot from './utility/getStateSnapshot.js'\r\n\r\n// There're three main places where state is updated:\r\n//\r\n// * On scroll.\r\n// * On window resize.\r\n// * On set new items.\r\n//\r\n// State updates may be \"asynchronous\" (like in React), in which case the\r\n// corresponding operation is \"pending\" until the state update is applied.\r\n//\r\n// If there's a \"pending\" window resize or a \"pending\" update of the set of items,\r\n// then \"on scroll\" updates aren't dispatched.\r\n//\r\n// If there's a \"pending\" on scroll update and the window is resize or a new set\r\n// of items is set, then that \"pending\" on scroll update gets overwritten.\r\n//\r\n// If there's a \"pending\" update of the set of items, then window resize handler\r\n// sees that \"pending\" update and dispatches its own state update so that the\r\n// \"pending\" state update originating from `setItems()` is not lost.\r\n//\r\n// If there's a \"pending\" window resize, and a new set of items is set,\r\n// then the state update of the window resize handler gets overwritten.\r\n\r\nexport default function createStateHelpers({\r\n\tstate: initialState,\r\n\tgetInitialItemState,\r\n\tonStateChange,\r\n\trender,\r\n\titems: initialItems\r\n}) {\r\n\tthis.onStateChange = onStateChange\r\n\tthis._render = render\r\n\r\n\tthis.getInitialItemState = getInitialItemState\r\n\r\n\tthis._setItemState = (i, newItemState) => {\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('~ Item state changed ~')\r\n\t\t\tlog('Item index', i)\r\n\t\t\t// Uses `JSON.stringify()` here instead of just outputting the JSON objects as is\r\n\t\t\t// because outputting JSON objects as is would show different results later when\r\n\t\t\t// the developer inspects those in the web browser console if those state objects\r\n\t\t\t// get modified in between they've been output to the console and the developer\r\n\t\t\t// decided to inspect them.\r\n\t\t\tlog('Previous state' + '\\n' + JSON.stringify(this.getState().itemStates[i], null, 2))\r\n\t\t\tlog('New state' + '\\n' + JSON.stringify(newItemState, null, 2))\r\n\t\t}\r\n\r\n\t\tthis.getState().itemStates[i] = newItemState\r\n\r\n\t\t// If there was a request for `setState()` with new `items`, then the changes\r\n\t\t// to `currentState.itemStates[]` made above would be overwritten when that\r\n\t\t// pending `setState()` call gets applied.\r\n\t\t// To fix that, the updates to current `itemStates[]` are noted in\r\n\t\t// `this.itemStatesThatChangedWhileNewItemsWereBeingRendered` variable.\r\n\t\t// That variable is then checked when the `setState()` call with the new `items`\r\n\t\t// has been updated.\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tif (!this.itemStatesThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered = {}\r\n\t\t\t}\r\n\t\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered[String(i)] = newItemState\r\n\t\t}\r\n\t}\r\n\r\n\tthis.getState = () => this._getState()\r\n\r\n\tthis.updateState = (stateUpdate) => {\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('~ Set state ~')\r\n\t\t\tlog(getStateSnapshot(stateUpdate))\r\n\t\t}\r\n\r\n\t\t// Ensure that a non-initial `stateUpdate` can only contain an `items`\r\n\t\t// property when it comes from a `setItems()` call.\r\n\t\tif (stateUpdate.items) {\r\n\t\t\tif (!this._isSettingNewItems) {\r\n\t\t\t\treportError('A `stateUpdate` can only contain `items` property as a result of calling `.setItems()`')\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._isSettingNewItems = undefined\r\n\r\n\t\tthis.waitingForRender = true\r\n\r\n\t\t// Store previous `state`.\r\n\t\tthis.previousState = this.getState()\r\n\r\n\t\t// If it's the first call to `this.updateState()` then initialize\r\n\t\t// the most recent `setState()` value to be the current state.\r\n\t\tif (!this.mostRecentSetStateValue) {\r\n\t\t\tthis.mostRecentSetStateValue = this.getState()\r\n\t\t}\r\n\r\n\t\t// Accumulates all \"pending\" state updates until they have been applied.\r\n\t\tthis.mostRecentSetStateValue = {\r\n\t\t\t...this.mostRecentSetStateValue,\r\n\t\t\t...stateUpdate\r\n\t\t}\r\n\r\n\t\t// Update `state`.\r\n\t\tthis._setState(this.mostRecentSetStateValue, stateUpdate)\r\n\t}\r\n\r\n\tthis.getInitialState = () => {\r\n\t\tif (initialState) {\r\n\t\t\treturn getRestoredState.call(this, initialState)\r\n\t\t}\r\n\t\treturn getInitialStateFromScratch.call(this, { getInitialItemState })\r\n\t}\r\n\r\n\tthis.useState = ({\r\n\t\tgetState,\r\n\t\tsetState,\r\n\t\tupdateState\r\n\t}) => {\r\n\t\tif (this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] `VirtualScroller` has already been started')\r\n\t\t}\r\n\r\n\t\tif (this._getState) {\r\n\t\t\tthrow new Error('[virtual-scroller] Custom state storage has already been configured')\r\n\t\t}\r\n\r\n\t\tif (render) {\r\n\t\t\tthrow new Error('[virtual-scroller] Creating a `VirtualScroller` class instance with a `render()` parameter implies using the default (internal) state storage')\r\n\t\t}\r\n\r\n\t\tif (setState && updateState) {\r\n\t\t\tthrow new Error('[virtual-scroller] When using a custom state storage, one must supply either `setState()` or `updateState()` function but not both')\r\n\t\t}\r\n\r\n\t\tif (!getState || !(setState || updateState)) {\r\n\t\t\tthrow new Error('[virtual-scroller] When using a custom state storage, one must supply both `getState()` and `setState()`/`updateState()` functions')\r\n\t\t}\r\n\r\n\t\tthis._usesCustomStateStorage = true\r\n\r\n\t\tthis._getState = getState\r\n\r\n\t\tthis._setState = (newState, stateUpdate) => {\r\n\t\t\tif (setState) {\r\n\t\t\t\tsetState(newState)\r\n\t\t\t} else {\r\n\t\t\t\tupdateState(stateUpdate)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.useDefaultStateStorage = () => {\r\n\t\tif (!render) {\r\n\t\t\tthrow new Error('[virtual-scroller] When using the default (internal) state management, one must supply a `render(state, prevState)` function parameter')\r\n\t\t}\r\n\r\n\t\t// Create default `getState()`/`setState()` functions.\r\n\t\tthis._getState = defaultGetState.bind(this)\r\n\t\tthis._setState = defaultSetState.bind(this)\r\n\r\n\t\t// When `state` is stored externally, a developer is responsible for\r\n\t\t// initializing it with the initial value.\r\n\t\t// Otherwise, if default state management is used, set the initial state now.\r\n\t\tconst setInitialState = defaultSetInitialState.bind(this)\r\n\t\tsetInitialState(this.getInitialState())\r\n\t}\r\n\r\n\tfunction defaultGetState() {\r\n\t\treturn this.state\r\n\t}\r\n\r\n\tfunction defaultSetInitialState(newState) {\r\n\t\tthis.state = newState\r\n\t}\r\n\r\n\tfunction defaultSetState(newState, stateUpdate) {\r\n\t\t// // Because the default state updates are \"synchronous\" (immediate),\r\n\t\t// // the `...stateUpdate` could be applied over `...this.state`,\r\n\t\t// // and no state updates would be lost.\r\n\t\t// // But if it was \"asynchronous\" (not immediate), then `...this.state`\r\n\t\t// // wouldn't work in all cases, because it could be stale in cases\r\n\t\t// // when more than a single `setState()` call is made before\r\n\t\t// // the state actually updates, making some properties of `this.state` stale.\r\n\t\t// this.state = {\r\n\t\t// \t...this.state,\r\n\t\t// \t...stateUpdate\r\n\t\t// }\r\n\r\n\t\tthis.state = newState\r\n\r\n\t\trender(this.state, this.previousState)\r\n\r\n\t\tthis.onRender()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the initial state of the `VirtualScroller` \"from scratch\".\r\n\t * (i.e. not from a previously saved one).\r\n\t * @param {function} [options.getInitialItemState] — Gets initial item state.\r\n\t * @return {object}\r\n\t */\r\n\tfunction getInitialStateFromScratch({ getInitialItemState }) {\r\n\t\tconst items = initialItems\r\n\r\n\t\tconst state = {\r\n\t\t\t...getInitialLayoutState.call(this, items, { beforeStart: true }),\r\n\t\t\titems,\r\n\t\t\titemStates: fillArray(new Array(items.length), (i) => getInitialItemState(items[i]))\r\n\t\t}\r\n\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('Initial state (autogenerated)', getStateSnapshot(state))\r\n\t\t}\r\n\t\tlog('First shown item index', state.firstShownItemIndex)\r\n\t\tlog('Last shown item index', state.lastShownItemIndex)\r\n\r\n\t\treturn state\r\n\t}\r\n\r\n\tfunction getRestoredState(state) {\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('Restore state', getStateSnapshot(state))\r\n\t\t}\r\n\r\n\t\t// Possibly clean up \"before resize\" property in state.\r\n\t\t// \"Before resize\" state property is cleaned up when all \"before resize\" item heights\r\n\t\t// have been re-measured in an asynchronous `this.updateState({ beforeResize: undefined })` call.\r\n\t\t// If `VirtualScroller` state was snapshotted externally before that `this.updateState()` call\r\n\t\t// has been applied, then \"before resize\" property might have not been cleaned up properly.\r\n\t\tstate = cleanUpBeforeResizeState(state)\r\n\r\n\t\t// Reset `verticalSpacing` so that it re-measures it after the list\r\n\t\t// has been rendered initially. The rationale is that a previously captured\r\n\t\t// inter-item vertical spacing can't be \"trusted\" in a sense that the user\r\n\t\t// might have resized the window after the previous `state` has been snapshotted.\r\n\t\t// If the user has resized the window, then changing window width might have\r\n\t\t// activated different CSS `@media()` \"queries\" resulting in a potentially different\r\n\t\t// vertical spacing when the `VirtualScroller` is re-created with such previously\r\n\t\t// snapshotted state.\r\n\t\tstate = {\r\n\t\t\t...state,\r\n\t\t\tverticalSpacing: undefined\r\n\t\t}\r\n\r\n\t\t// `this.verticalSpacing` acts as a \"true\" source for vertical spacing value.\r\n\t\t// Vertical spacing is also stored in `state` but `state` updates could be\r\n\t\t// \"asynchronous\" (not applied immediately) and `this.onUpdateShownItemIndexes()`\r\n\t\t// requires vertical spacing to be correct at any time, without any delays.\r\n\t\t// So, vertical spacing is also duplicated in `state`, but the \"true\" source\r\n\t\t// is still `this.verticalSpacing`.\r\n\t\t//\r\n\t\t// `this.verticalSpacing` must be initialized before calling `this.getInitialStateFromScratch()`\r\n\t\t// because `this.getInitialStateFromScratch()` uses `this.verticalSpacing` in its calculations.\r\n\t\t//\r\n\t\t// With the code above, `state.verticalSpacing` is always gonna be `undefined`,\r\n\t\t// so commented out this code. It's safer to just re-measure vertical spacing\r\n\t\t// from scratch when `VirtualScroller` is mounted.\r\n\t\t//\r\n\t\t// this.verticalSpacing = state ? state.verticalSpacing : undefined\r\n\r\n\t\t// Check if the actual `columnsCount` on the screen matches the one from state.\r\n\t\tif (isStateColumnsCountMismatch(state, {\r\n\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t})) {\r\n\t\t\twarn('Reset Layout')\r\n\t\t\tstate = {\r\n\t\t\t\t...state,\r\n\t\t\t\t...getInitialLayoutState.call(this, state.items, { beforeStart: false })\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn state\r\n\t}\r\n\r\n\tfunction getInitialLayoutState(items, { beforeStart }) {\r\n\t\tconst itemsCount = items.length\r\n\r\n\t\tconst getColumnsCount = () => this.getActualColumnsCount()\r\n\r\n\t\tconst columnsCount = beforeStart\r\n\t\t\t? this.layout.getInitialLayoutValueWithFallback(\r\n\t\t\t\t'columnsCount',\r\n\t\t\t\tgetColumnsCount,\r\n\t\t\t\t1\r\n\t\t\t)\r\n\t\t\t: getColumnsCount()\r\n\r\n\t\tconst {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t} = this.layout.getInitialLayoutValues({\r\n\t\t\titemsCount,\r\n\t\t\tcolumnsCount: this.getActualColumnsCount(),\r\n\t\t\tbeforeStart\r\n\t\t})\r\n\r\n\t\tconst itemHeights = new Array(itemsCount)\r\n\r\n\t\t// Optionally preload items to be rendered.\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\titems,\r\n\t\t\titemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\titemHeights,\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\t\t\tverticalSpacing: this.verticalSpacing,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t}\r\n\t}\r\n\r\n\t// Checks if the actual `columnsCount` on the screen matches the one from state.\r\n\t//\r\n\t// For example, a developer might snapshot `VirtualScroller` state\r\n\t// when the user navigates from the page containing the list\r\n\t// in order to later restore the list's state when the user goes \"Back\".\r\n\t// But, the user might have also resized the window while being on that\r\n\t// \"other\" page, and when they come \"Back\", their snapshotted state\r\n\t// no longer qualifies. Well, it does qualify, but only partially.\r\n\t// For example, `itemStates` are still valid, but first and last shown\r\n\t// item indexes aren't.\r\n\t//\r\n\tfunction isStateColumnsCountMismatch(state, { columnsCount }) {\r\n\t\tconst stateColumnsCount = state.columnsCount || 1\r\n\t\tif (stateColumnsCount !== columnsCount) {\r\n\t\t\twarn('~ Columns Count changed from', stateColumnsCount, 'to', columnsCount, '~')\r\n\t\t\treturn true\r\n\t\t}\r\n\t\tconst firstShownItemIndex = Math.floor(state.firstShownItemIndex / columnsCount) * columnsCount\r\n\t\tif (firstShownItemIndex !== state.firstShownItemIndex) {\r\n\t\t\twarn('~ First Shown Item Index', state.firstShownItemIndex, 'is not divisible by Columns Count', columnsCount, '~')\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;AAAA,OAAOA,SAAP,MAAsB,wBAAtB;AACA,OAAOC,GAAP,IAAcC,IAAd,EAAoBC,OAApB,EAA6BC,WAA7B,QAAgD,oBAAhD;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,OAAOC,gBAAP,MAA6B,+BAA7B,C,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,kBAAT,OAMZ;EAAA;;EAAA,IALKC,YAKL,QALFC,KAKE;EAAA,IAJFC,mBAIE,QAJFA,mBAIE;EAAA,IAHFC,aAGE,QAHFA,aAGE;EAAA,IAFFC,MAEE,QAFFA,MAEE;EAAA,IADKC,YACL,QADFC,KACE;EACF,KAAKH,aAAL,GAAqBA,aAArB;EACA,KAAKI,OAAL,GAAeH,MAAf;EAEA,KAAKF,mBAAL,GAA2BA,mBAA3B;;EAEA,KAAKM,aAAL,GAAqB,UAACC,CAAD,EAAIC,YAAJ,EAAqB;IACzC,IAAIf,OAAO,EAAX,EAAe;MACdF,GAAG,CAAC,wBAAD,CAAH;MACAA,GAAG,CAAC,YAAD,EAAegB,CAAf,CAAH,CAFc,CAGd;MACA;MACA;MACA;MACA;;MACAhB,GAAG,CAAC,mBAAmB,IAAnB,GAA0BkB,IAAI,CAACC,SAAL,CAAe,KAAI,CAACC,QAAL,GAAgBC,UAAhB,CAA2BL,CAA3B,CAAf,EAA8C,IAA9C,EAAoD,CAApD,CAA3B,CAAH;MACAhB,GAAG,CAAC,cAAc,IAAd,GAAqBkB,IAAI,CAACC,SAAL,CAAeF,YAAf,EAA6B,IAA7B,EAAmC,CAAnC,CAAtB,CAAH;IACA;;IAED,KAAI,CAACG,QAAL,GAAgBC,UAAh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AAlC,EAAuD;MACtDtD,IAAI,CAAC,0BAAD,EAA6BO,KAAK,CAAC+C,mBAAnC,EAAwD,mCAAxD,EAA6FI,YAA7F,EAA2G,GAA3G,CAAJ;MACA,OAAO,IAAP;IACA;EACD;AACD"}
1
+ {"version":3,"file":"VirtualScroller.state.js","names":["fillArray","log","warn","isDebug","reportError","cleanUpBeforeResizeState","getStateSnapshot","createStateHelpers","initialState","state","getInitialItemState","onStateChange","render","initialItems","items","_render","_setItemState","itemOrIndex","newItemState","i","_getItemIndexByItemOrIndex","undefined","JSON","stringify","getState","itemStates","newItemsWillBeRendered","itemStatesThatChangedWhileNewItemsWereBeingRendered","String","_getState","updateState","stateUpdate","_isSettingNewItems","waitingForRender","previousState","mostRecentSetStateValue","_setState","getInitialState","getRestoredState","call","getInitialStateFromScratch","useState","setState","_isActive","Error","_usesCustomStateStorage","newState","useDefaultStateStorage","defaultGetState","bind","defaultSetState","setInitialState","defaultSetInitialState","setUpState","onRender","getInitialLayoutState","beforeStart","Array","length","firstShownItemIndex","lastShownItemIndex","verticalSpacing","isStateColumnsCountMismatch","columnsCount","getActualColumnsCount","itemsCount","layout","getInitialLayoutValues","beforeItemsHeight","afterItemsHeight","itemHeights","onBeforeShowItems","getActualColumnsCountForState","stateColumnsCount","Math","floor"],"sources":["../source/VirtualScroller.state.js"],"sourcesContent":["import fillArray from './utility/fillArray.js'\r\nimport log, { warn, isDebug, reportError } from './utility/debug.js'\r\nimport { cleanUpBeforeResizeState } from './BeforeResize.js'\r\nimport getStateSnapshot from './utility/getStateSnapshot.js'\r\n\r\n// There're three main places where state is updated:\r\n//\r\n// * On scroll.\r\n// * On window resize.\r\n// * On set new items.\r\n//\r\n// State updates may be \"asynchronous\" (like in React), in which case the\r\n// corresponding operation is \"pending\" until the state update is applied.\r\n//\r\n// If there's a \"pending\" window resize or a \"pending\" update of the set of items,\r\n// then \"on scroll\" updates aren't dispatched.\r\n//\r\n// If there's a \"pending\" on scroll update and the window is resize or a new set\r\n// of items is set, then that \"pending\" on scroll update gets overwritten.\r\n//\r\n// If there's a \"pending\" update of the set of items, then window resize handler\r\n// sees that \"pending\" update and dispatches its own state update so that the\r\n// \"pending\" state update originating from `setItems()` is not lost.\r\n//\r\n// If there's a \"pending\" window resize, and a new set of items is set,\r\n// then the state update of the window resize handler gets overwritten.\r\n\r\nexport default function createStateHelpers({\r\n\tstate: initialState,\r\n\tgetInitialItemState,\r\n\tonStateChange,\r\n\trender,\r\n\titems: initialItems\r\n}) {\r\n\tthis.onStateChange = onStateChange\r\n\tthis._render = render\r\n\r\n\tthis.getInitialItemState = getInitialItemState\r\n\r\n\tthis._setItemState = (itemOrIndex, newItemState) => {\r\n\t\t// Item index.\r\n\t\tconst i = this._getItemIndexByItemOrIndex(itemOrIndex)\r\n\r\n\t\t// If the item wasn't found, the error was already reported,\r\n\t\t// so just return some \"sensible\" default value.\r\n\t\tif (i === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('~ Item state changed ~')\r\n\t\t\tlog('Item index', i)\r\n\t\t\t// Uses `JSON.stringify()` here instead of just outputting the JSON objects as is\r\n\t\t\t// because outputting JSON objects as is would show different results later when\r\n\t\t\t// the developer inspects those in the web browser console if those state objects\r\n\t\t\t// get modified in between they've been output to the console and the developer\r\n\t\t\t// decided to inspect them.\r\n\t\t\tlog('Previous state' + '\\n' + JSON.stringify(this.getState().itemStates[i], null, 2))\r\n\t\t\tlog('New state' + '\\n' + JSON.stringify(newItemState, null, 2))\r\n\t\t}\r\n\r\n\t\tthis.getState().itemStates[i] = newItemState\r\n\r\n\t\t// If there was a request for `setState()` with new `items`, then the changes\r\n\t\t// to `currentState.itemStates[]` made above would be overwritten when that\r\n\t\t// pending `setState()` call gets applied.\r\n\t\t// To fix that, the updates to current `itemStates[]` are noted in\r\n\t\t// `this.itemStatesThatChangedWhileNewItemsWereBeingRendered` variable.\r\n\t\t// That variable is then checked when the `setState()` call with the new `items`\r\n\t\t// has been updated.\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tif (!this.itemStatesThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered = {}\r\n\t\t\t}\r\n\t\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered[String(i)] = newItemState\r\n\t\t}\r\n\t}\r\n\r\n\tthis.getState = () => this._getState()\r\n\r\n\tthis.updateState = (stateUpdate) => {\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('~ Set state ~')\r\n\t\t\tlog(getStateSnapshot(stateUpdate))\r\n\t\t}\r\n\r\n\t\t// Ensure that a non-initial `stateUpdate` can only contain an `items`\r\n\t\t// property when it comes from a `setItems()` call.\r\n\t\tif (stateUpdate.items) {\r\n\t\t\tif (!this._isSettingNewItems) {\r\n\t\t\t\treportError('A `stateUpdate` can only contain `items` property as a result of calling `.setItems()`')\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._isSettingNewItems = undefined\r\n\r\n\t\tthis.waitingForRender = true\r\n\r\n\t\t// Store previous `state`.\r\n\t\tthis.previousState = this.getState()\r\n\r\n\t\t// If it's the first call to `this.updateState()` then initialize\r\n\t\t// the most recent `setState()` value to be the current state.\r\n\t\tif (!this.mostRecentSetStateValue) {\r\n\t\t\tthis.mostRecentSetStateValue = this.getState()\r\n\t\t}\r\n\r\n\t\t// Accumulates all \"pending\" state updates until they have been applied.\r\n\t\tthis.mostRecentSetStateValue = {\r\n\t\t\t...this.mostRecentSetStateValue,\r\n\t\t\t...stateUpdate\r\n\t\t}\r\n\r\n\t\t// Update `state`.\r\n\t\tthis._setState(this.mostRecentSetStateValue, stateUpdate)\r\n\t}\r\n\r\n\tthis.getInitialState = () => {\r\n\t\tif (initialState) {\r\n\t\t\treturn getRestoredState.call(this, initialState)\r\n\t\t}\r\n\t\treturn getInitialStateFromScratch.call(this, { getInitialItemState })\r\n\t}\r\n\r\n\tthis.useState = ({\r\n\t\tgetState,\r\n\t\tsetState,\r\n\t\tupdateState\r\n\t}) => {\r\n\t\tif (this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] `VirtualScroller` has already been started')\r\n\t\t}\r\n\r\n\t\tif (this._getState) {\r\n\t\t\tthrow new Error('[virtual-scroller] Custom state storage has already been configured')\r\n\t\t}\r\n\r\n\t\tif (render) {\r\n\t\t\tthrow new Error('[virtual-scroller] Creating a `VirtualScroller` class instance with a `render()` parameter implies using the default (internal) state storage')\r\n\t\t}\r\n\r\n\t\tif (setState && updateState) {\r\n\t\t\tthrow new Error('[virtual-scroller] When using a custom state storage, one must supply either `setState()` or `updateState()` function but not both')\r\n\t\t}\r\n\r\n\t\tif (!getState || !(setState || updateState)) {\r\n\t\t\tthrow new Error('[virtual-scroller] When using a custom state storage, one must supply both `getState()` and `setState()`/`updateState()` functions')\r\n\t\t}\r\n\r\n\t\tthis._usesCustomStateStorage = true\r\n\r\n\t\tthis._getState = getState\r\n\r\n\t\tthis._setState = (newState, stateUpdate) => {\r\n\t\t\tif (setState) {\r\n\t\t\t\tsetState(newState)\r\n\t\t\t} else {\r\n\t\t\t\tupdateState(stateUpdate)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.useDefaultStateStorage = () => {\r\n\t\tif (!render) {\r\n\t\t\tthrow new Error('[virtual-scroller] When using the default (internal) state management, one must supply a `render(state, prevState)` function parameter')\r\n\t\t}\r\n\r\n\t\t// Create default `getState()`/`setState()` functions.\r\n\t\tthis._getState = defaultGetState.bind(this)\r\n\t\tthis._setState = defaultSetState.bind(this)\r\n\r\n\t\t// When `state` is stored externally, a developer is responsible for\r\n\t\t// initializing it with the initial value.\r\n\t\t// Otherwise, if default state management is used, set the initial state now.\r\n\t\tconst setInitialState = defaultSetInitialState.bind(this)\r\n\t\tsetInitialState(this.getInitialState())\r\n\t}\r\n\r\n\tthis.setUpState = () => {\r\n\t\t// If no custom state storage has been configured, use the default one.\r\n\t\t// Also sets the initial state.\r\n\t\tif (!this._usesCustomStateStorage) {\r\n\t\t\tthis.useDefaultStateStorage()\r\n\t\t}\r\n\t}\r\n\r\n\tfunction defaultGetState() {\r\n\t\treturn this.state\r\n\t}\r\n\r\n\tfunction defaultSetInitialState(newState) {\r\n\t\tthis.state = newState\r\n\t}\r\n\r\n\tfunction defaultSetState(newState, stateUpdate) {\r\n\t\t// // Because the default state updates are \"synchronous\" (immediate),\r\n\t\t// // the `...stateUpdate` could be applied over `...this.state`,\r\n\t\t// // and no state updates would be lost.\r\n\t\t// // But if it was \"asynchronous\" (not immediate), then `...this.state`\r\n\t\t// // wouldn't work in all cases, because it could be stale in cases\r\n\t\t// // when more than a single `setState()` call is made before\r\n\t\t// // the state actually updates, making some properties of `this.state` stale.\r\n\t\t// this.state = {\r\n\t\t// \t...this.state,\r\n\t\t// \t...stateUpdate\r\n\t\t// }\r\n\r\n\t\tthis.state = newState\r\n\r\n\t\trender(this.state, this.previousState)\r\n\r\n\t\tthis.onRender()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the initial state of the `VirtualScroller` \"from scratch\".\r\n\t * (i.e. not from a previously saved one).\r\n\t * @param {function} [options.getInitialItemState] — Gets initial item state.\r\n\t * @return {object}\r\n\t */\r\n\tfunction getInitialStateFromScratch({ getInitialItemState }) {\r\n\t\tconst items = initialItems\r\n\r\n\t\tconst state = {\r\n\t\t\t...getInitialLayoutState.call(this, items, { beforeStart: true }),\r\n\t\t\titems,\r\n\t\t\titemStates: fillArray(new Array(items.length), (i) => getInitialItemState(items[i]))\r\n\t\t}\r\n\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('Initial state (autogenerated)', getStateSnapshot(state))\r\n\t\t}\r\n\t\tlog('First shown item index', state.firstShownItemIndex)\r\n\t\tlog('Last shown item index', state.lastShownItemIndex)\r\n\r\n\t\treturn state\r\n\t}\r\n\r\n\tfunction getRestoredState(state) {\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('Restore state', getStateSnapshot(state))\r\n\t\t}\r\n\r\n\t\t// Possibly clean up \"before resize\" property in state.\r\n\t\t// \"Before resize\" state property is cleaned up when all \"before resize\" item heights\r\n\t\t// have been re-measured in an asynchronous `this.updateState({ beforeResize: undefined })` call.\r\n\t\t// If `VirtualScroller` state was snapshotted externally before that `this.updateState()` call\r\n\t\t// has been applied, then \"before resize\" property might have not been cleaned up properly.\r\n\t\tstate = cleanUpBeforeResizeState(state)\r\n\r\n\t\t// Reset `verticalSpacing` so that it re-measures it after the list\r\n\t\t// has been rendered initially. The rationale is that a previously captured\r\n\t\t// inter-item vertical spacing can't be \"trusted\" in a sense that the user\r\n\t\t// might have resized the window after the previous `state` has been snapshotted.\r\n\t\t// If the user has resized the window, then changing window width might have\r\n\t\t// activated different CSS `@media()` \"queries\" resulting in a potentially different\r\n\t\t// vertical spacing when the `VirtualScroller` is re-created with such previously\r\n\t\t// snapshotted state.\r\n\t\tstate = {\r\n\t\t\t...state,\r\n\t\t\tverticalSpacing: undefined\r\n\t\t}\r\n\r\n\t\t// `this.verticalSpacing` acts as a \"true\" source for vertical spacing value.\r\n\t\t// Vertical spacing is also stored in `state` but `state` updates could be\r\n\t\t// \"asynchronous\" (not applied immediately) and `this.onUpdateShownItemIndexes()`\r\n\t\t// requires vertical spacing to be correct at any time, without any delays.\r\n\t\t// So, vertical spacing is also duplicated in `state`, but the \"true\" source\r\n\t\t// is still `this.verticalSpacing`.\r\n\t\t//\r\n\t\t// `this.verticalSpacing` must be initialized before calling `this.getInitialStateFromScratch()`\r\n\t\t// because `this.getInitialStateFromScratch()` uses `this.verticalSpacing` in its calculations.\r\n\t\t//\r\n\t\t// With the code above, `state.verticalSpacing` is always gonna be `undefined`,\r\n\t\t// so commented out this code. It's safer to just re-measure vertical spacing\r\n\t\t// from scratch when `VirtualScroller` is mounted.\r\n\t\t//\r\n\t\t// this.verticalSpacing = state ? state.verticalSpacing : undefined\r\n\r\n\t\t// Check if the actual `columnsCount` on the screen matches the one from state.\r\n\t\tif (isStateColumnsCountMismatch(state, {\r\n\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t})) {\r\n\t\t\twarn('Reset Layout')\r\n\t\t\tstate = {\r\n\t\t\t\t...state,\r\n\t\t\t\t...getInitialLayoutState.call(this, state.items, { beforeStart: false })\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn state\r\n\t}\r\n\r\n\tfunction getInitialLayoutState(items, { beforeStart }) {\r\n\t\tconst itemsCount = items.length\r\n\r\n\t\tconst {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t} = this.layout.getInitialLayoutValues({\r\n\t\t\titemsCount,\r\n\t\t\tcolumnsCount: this.getActualColumnsCount(),\r\n\t\t\tbeforeStart\r\n\t\t})\r\n\r\n\t\tconst itemHeights = new Array(itemsCount)\r\n\r\n\t\t// Optionally preload items to be rendered.\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\titems,\r\n\t\t\titemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\titemHeights,\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\t\t\tverticalSpacing: this.verticalSpacing,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t}\r\n\t}\r\n\r\n\t// Checks if the actual `columnsCount` on the screen matches the one from state.\r\n\t//\r\n\t// For example, a developer might snapshot `VirtualScroller` state\r\n\t// when the user navigates from the page containing the list\r\n\t// in order to later restore the list's state when the user goes \"Back\".\r\n\t// But, the user might have also resized the window while being on that\r\n\t// \"other\" page, and when they come \"Back\", their snapshotted state\r\n\t// no longer qualifies. Well, it does qualify, but only partially.\r\n\t// For example, `itemStates` are still valid, but first and last shown\r\n\t// item indexes aren't.\r\n\t//\r\n\tfunction isStateColumnsCountMismatch(state, { columnsCount }) {\r\n\t\tconst stateColumnsCount = state.columnsCount || 1\r\n\t\tif (stateColumnsCount !== columnsCount) {\r\n\t\t\twarn('~ Columns Count changed from', stateColumnsCount, 'to', columnsCount, '~')\r\n\t\t\treturn true\r\n\t\t}\r\n\t\tconst firstShownItemIndex = Math.floor(state.firstShownItemIndex / columnsCount) * columnsCount\r\n\t\tif (firstShownItemIndex !== state.firstShownItemIndex) {\r\n\t\t\twarn('~ First Shown Item Index', state.firstShownItemIndex, 'is not divisible by Columns Count', columnsCount, '~')\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;AAAA,OAAOA,SAAP,MAAsB,wBAAtB;AACA,OAAOC,GAAP,IAAcC,IAAd,EAAoBC,OAApB,EAA6BC,WAA7B,QAAgD,oBAAhD;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,OAAOC,gBAAP,MAA6B,+BAA7B,C,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,kBAAT,OAMZ;EAAA;;EAAA,IALKC,YAKL,QALFC,KAKE;EAAA,IAJFC,mBAIE,QAJFA,mBAIE;EAAA,IAHFC,aAGE,QAHFA,aAGE;EAAA,IAFFC,MAEE,QAFFA,MAEE;EAAA,IADKC,YACL,QADFC,KACE;EACF,KAAKH,aAAL,GAAqBA,aAArB;EACA,KAAKI,OAAL,GAAeH,MAAf;EAEA,KAAKF,mBAAL,GAA2BA,mBAA3B;;EAEA,KAAKM,aAAL,GAAqB,UAACC,WAAD,EAAcC,YAAd,EAA+B;IACnD;IACA,IAAMC,CAAC,GAAG,KAAI,CAACC,0BAAL,CAAgCH,WAAhC,CAAV,CAFmD,CAInD;IACA;;;IACA,IAAIE,CAAC,KAAKE,SAAV,EAAqB;MACpB;IACA;;IAED,IAAIlB,OAAO,EAAX,EAAe;MACdF,GAAG,CAAC,wBAAD,C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,iBAAiB,KAAKV,YAA1B,EAAwC;MACvC7D,IAAI,CAAC,8BAAD,EAAiCuE,iBAAjC,EAAoD,IAApD,EAA0DV,YAA1D,EAAwE,GAAxE,CAAJ;MACA,OAAO,IAAP;IACA;;IACD,IAAMJ,mBAAmB,GAAGe,IAAI,CAACC,KAAL,CAAWlE,KAAK,CAACkD,mBAAN,GAA4BI,YAAvC,IAAuDA,YAAnF;;IACA,IAAIJ,mBAAmB,KAAKlD,KAAK,CAACkD,mBAAlC,EAAuD;MACtDzD,IAAI,CAAC,0BAAD,EAA6BO,KAAK,CAACkD,mBAAnC,EAAwD,mCAAxD,EAA6FI,YAA7F,EAA2G,GAA3G,CAAJ;MACA,OAAO,IAAP;IACA;EACD;AACD"}
@@ -1,23 +1,55 @@
1
1
  import log from './utility/debug.js';
2
2
  import getVerticalSpacing from './getVerticalSpacing.js';
3
- export default function createVerticalSpacingHelpers() {
3
+ import { DEFAULT_INTER_ITEM_VERTICAL_SPACING } from './Layout.defaults.js';
4
+ export default function createVerticalSpacingHelpers(_ref) {
4
5
  var _this = this;
5
6
 
7
+ var getEstimatedInterItemVerticalSpacing = _ref.getEstimatedInterItemVerticalSpacing;
8
+
6
9
  // Bind to `this` in order to prevent bugs when this function is passed by reference
7
10
  // and then called with its `this` being unintentionally `window` resulting in
8
11
  // the `if` condition being "falsy".
9
12
  this.getVerticalSpacing = function () {
10
- return _this.verticalSpacing || 0;
13
+ var verticalSpacing = _this.verticalSpacing;
14
+
15
+ if (typeof verticalSpacing === 'number') {
16
+ return verticalSpacing;
17
+ }
18
+
19
+ return _this.getEstimatedInterItemVerticalSpacing();
11
20
  };
12
21
 
13
22
  this.getVerticalSpacingBeforeResize = function () {
14
- // `beforeResize.verticalSpacing` can be `undefined`.
15
- // For example, if `this.updateState({ verticalSpacing })` call hasn't been applied
16
- // before the resize happened (in case of an "asynchronous" state update).
17
23
  var _this$getState = _this.getState(),
18
24
  beforeResize = _this$getState.beforeResize;
19
25
 
20
- return beforeResize && beforeResize.verticalSpacing || 0;
26
+ if (beforeResize) {
27
+ var verticalSpacing = beforeResize.verticalSpacing; // `beforeResize.verticalSpacing` can be `undefined`.
28
+ // For example, if `this.updateState({ verticalSpacing })` call hasn't been applied
29
+ // before the resize happened (in case of an "asynchronous" state update).
30
+
31
+ if (typeof verticalSpacing === 'number') {
32
+ return verticalSpacing;
33
+ }
34
+
35
+ return _this.getEstimatedInterItemVerticalSpacing();
36
+ }
37
+ };
38
+
39
+ this.getEstimatedInterItemVerticalSpacing = function () {
40
+ if (getEstimatedInterItemVerticalSpacing) {
41
+ var estimatedVerticalSpacing = getEstimatedInterItemVerticalSpacing();
42
+
43
+ if (typeof estimatedVerticalSpacing === 'number') {
44
+ return estimatedVerticalSpacing;
45
+ }
46
+
47
+ throw new Error('[virtual-scroller] `getEstimatedInterItemVerticalSpacing()` must return a number');
48
+ } // `DEFAULT_INTER_ITEM_VERTICAL_SPACING` will be used in server-side render
49
+ // unless `getEstimatedInterItemVerticalSpacing()` parameter is specified.
50
+
51
+
52
+ return DEFAULT_INTER_ITEM_VERTICAL_SPACING;
21
53
  };
22
54
  /**
23
55
  * Measures item vertical spacing, if not measured.
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualScroller.verticalSpacing.js","names":["log","getVerticalSpacing","createVerticalSpacingHelpers","verticalSpacing","getVerticalSpacingBeforeResize","getState","beforeResize","measureVerticalSpacingIfNotMeasured","undefined","measureVerticalSpacing","call","firstShownItemIndex","lastShownItemIndex","itemsContainer","renderedItemsCount"],"sources":["../source/VirtualScroller.verticalSpacing.js"],"sourcesContent":["import log from './utility/debug.js'\r\nimport getVerticalSpacing from './getVerticalSpacing.js'\r\n\r\nexport default function createVerticalSpacingHelpers() {\r\n\t// Bind to `this` in order to prevent bugs when this function is passed by reference\r\n\t// and then called with its `this` being unintentionally `window` resulting in\r\n\t// the `if` condition being \"falsy\".\r\n\tthis.getVerticalSpacing = () => {\r\n\t\treturn this.verticalSpacing || 0\r\n\t}\r\n\r\n\tthis.getVerticalSpacingBeforeResize = () => {\r\n\t\t// `beforeResize.verticalSpacing` can be `undefined`.\r\n\t\t// For example, if `this.updateState({ verticalSpacing })` call hasn't been applied\r\n\t\t// before the resize happened (in case of an \"asynchronous\" state update).\r\n\t\tconst { beforeResize } = this.getState()\r\n\t\treturn beforeResize && beforeResize.verticalSpacing || 0\r\n\t}\r\n\r\n\t/**\r\n\t * Measures item vertical spacing, if not measured.\r\n\t * @return {object} [stateUpdate]\r\n\t */\r\n\tthis.measureVerticalSpacingIfNotMeasured = () => {\r\n\t\tif (this.verticalSpacing === undefined) {\r\n\t\t\tthis.verticalSpacing = measureVerticalSpacing.call(this)\r\n\t\t\treturn this.verticalSpacing\r\n\t\t}\r\n\t}\r\n\r\n\tfunction measureVerticalSpacing() {\r\n\t\tconst {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t} = this.getState()\r\n\r\n\t\tlog('~ Measure item vertical spacing ~')\r\n\r\n\t\tconst verticalSpacing = getVerticalSpacing({\r\n\t\t\titemsContainer: this.itemsContainer,\r\n\t\t\trenderedItemsCount: lastShownItemIndex - firstShownItemIndex + 1\r\n\t\t})\r\n\r\n\t\tif (verticalSpacing === undefined) {\r\n\t\t\tlog('Not enough items rendered to measure vertical spacing')\r\n\t\t} else {\r\n\t\t\tlog('Item vertical spacing', verticalSpacing)\r\n\t\t\treturn verticalSpacing\r\n\t\t}\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,oBAAhB;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,eAAe,SAASC,4BAAT,GAAwC;EAAA;;EACtD;EACA;EACA;EACA,KAAKD,kBAAL,GAA0B,YAAM;IAC/B,OAAO,KAAI,CAACE,eAAL,IAAwB,CAA/B;EACA,CAFD;;EAIA,KAAKC,8BAAL,GAAsC,YAAM;IAC3C;IACA;IACA;IACA,qBAAyB,KAAI,CAACC,QAAL,EAAzB;IAAA,IAAQC,YAAR,kBAAQA,YAAR;;IACA,OAAOA,YAAY,IAAIA,YAAY,CAACH,eAA7B,IAAgD,CAAvD;EACA,CAND;EAQA;AACD;AACA;AACA;;;EACC,KAAKI,mCAAL,GAA2C,YAAM;IAChD,IAAI,KAAI,CAACJ,eAAL,KAAyBK,SAA7B,EAAwC;MACvC,KAAI,CAACL,eAAL,GAAuBM,sBAAsB,CAACC,IAAvB,CAA4B,KAA5B,CAAvB;MACA,OAAO,KAAI,CAACP,eAAZ;IACA;EACD,CALD;;EAOA,SAASM,sBAAT,GAAkC;IACjC,sBAGI,KAAKJ,QAAL,EAHJ;IAAA,IACCM,mBADD,mBACCA,mBADD;IAAA,IAECC,kBAFD,mBAECA,kBAFD;;IAKAZ,GAAG,CAAC,mCAAD,CAAH;IAEA,IAAMG,eAAe,GAAGF,kBAAkB,CAAC;MAC1CY,cAAc,EAAE,KAAKA,cADqB;MAE1CC,kBAAkB,EAAEF,kBAAkB,GAAGD,mBAArB,GAA2C;IAFrB,CAAD,CAA1C;;IAKA,IAAIR,eAAe,KAAKK,SAAxB,EAAmC;MAClCR,GAAG,CAAC,uDAAD,CAAH;IACA,CAFD,MAEO;MACNA,GAAG,CAAC,uBAAD,EAA0BG,eAA1B,CAAH;MACA,OAAOA,eAAP;IACA;EACD;AACD"}
1
+ {"version":3,"file":"VirtualScroller.verticalSpacing.js","names":["log","getVerticalSpacing","DEFAULT_INTER_ITEM_VERTICAL_SPACING","createVerticalSpacingHelpers","getEstimatedInterItemVerticalSpacing","verticalSpacing","getVerticalSpacingBeforeResize","getState","beforeResize","estimatedVerticalSpacing","Error","measureVerticalSpacingIfNotMeasured","undefined","measureVerticalSpacing","call","firstShownItemIndex","lastShownItemIndex","itemsContainer","renderedItemsCount"],"sources":["../source/VirtualScroller.verticalSpacing.js"],"sourcesContent":["import log from './utility/debug.js'\r\nimport getVerticalSpacing from './getVerticalSpacing.js'\r\nimport { DEFAULT_INTER_ITEM_VERTICAL_SPACING } from './Layout.defaults.js'\r\n\r\nexport default function createVerticalSpacingHelpers({\r\n\tgetEstimatedInterItemVerticalSpacing\r\n}) {\r\n\t// Bind to `this` in order to prevent bugs when this function is passed by reference\r\n\t// and then called with its `this` being unintentionally `window` resulting in\r\n\t// the `if` condition being \"falsy\".\r\n\tthis.getVerticalSpacing = () => {\r\n\t\tconst { verticalSpacing } = this\r\n\t\tif (typeof verticalSpacing === 'number') {\r\n\t\t\treturn verticalSpacing\r\n\t\t}\r\n\t\treturn this.getEstimatedInterItemVerticalSpacing()\r\n\t}\r\n\r\n\tthis.getVerticalSpacingBeforeResize = () => {\r\n\t\tconst { beforeResize } = this.getState()\r\n\t\tif (beforeResize) {\r\n\t\t\tconst { verticalSpacing } = beforeResize\r\n\t\t\t// `beforeResize.verticalSpacing` can be `undefined`.\r\n\t\t\t// For example, if `this.updateState({ verticalSpacing })` call hasn't been applied\r\n\t\t\t// before the resize happened (in case of an \"asynchronous\" state update).\r\n\t\t\tif (typeof verticalSpacing === 'number') {\r\n\t\t\t\treturn verticalSpacing\r\n\t\t\t}\r\n\t\t\treturn this.getEstimatedInterItemVerticalSpacing()\r\n\t\t}\r\n\t}\r\n\r\n\tthis.getEstimatedInterItemVerticalSpacing = () => {\r\n\t\tif (getEstimatedInterItemVerticalSpacing) {\r\n\t\t\tconst estimatedVerticalSpacing = getEstimatedInterItemVerticalSpacing()\r\n\t\t\tif (typeof estimatedVerticalSpacing === 'number') {\r\n\t\t\t\treturn estimatedVerticalSpacing\r\n\t\t\t}\r\n\t\t\tthrow new Error('[virtual-scroller] `getEstimatedInterItemVerticalSpacing()` must return a number')\r\n\t\t}\r\n\t\t// `DEFAULT_INTER_ITEM_VERTICAL_SPACING` will be used in server-side render\r\n\t\t// unless `getEstimatedInterItemVerticalSpacing()` parameter is specified.\r\n\t\treturn DEFAULT_INTER_ITEM_VERTICAL_SPACING\r\n\t}\r\n\r\n\t/**\r\n\t * Measures item vertical spacing, if not measured.\r\n\t * @return {object} [stateUpdate]\r\n\t */\r\n\tthis.measureVerticalSpacingIfNotMeasured = () => {\r\n\t\tif (this.verticalSpacing === undefined) {\r\n\t\t\tthis.verticalSpacing = measureVerticalSpacing.call(this)\r\n\t\t\treturn this.verticalSpacing\r\n\t\t}\r\n\t}\r\n\r\n\tfunction measureVerticalSpacing() {\r\n\t\tconst {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t} = this.getState()\r\n\r\n\t\tlog('~ Measure item vertical spacing ~')\r\n\r\n\t\tconst verticalSpacing = getVerticalSpacing({\r\n\t\t\titemsContainer: this.itemsContainer,\r\n\t\t\trenderedItemsCount: lastShownItemIndex - firstShownItemIndex + 1\r\n\t\t})\r\n\r\n\t\tif (verticalSpacing === undefined) {\r\n\t\t\tlog('Not enough items rendered to measure vertical spacing')\r\n\t\t} else {\r\n\t\t\tlog('Item vertical spacing', verticalSpacing)\r\n\t\t\treturn verticalSpacing\r\n\t\t}\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,oBAAhB;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,SAASC,mCAAT,QAAoD,sBAApD;AAEA,eAAe,SAASC,4BAAT,OAEZ;EAAA;;EAAA,IADFC,oCACE,QADFA,oCACE;;EACF;EACA;EACA;EACA,KAAKH,kBAAL,GAA0B,YAAM;IAC/B,IAAQI,eAAR,GAA4B,KAA5B,CAAQA,eAAR;;IACA,IAAI,OAAOA,eAAP,KAA2B,QAA/B,EAAyC;MACxC,OAAOA,eAAP;IACA;;IACD,OAAO,KAAI,CAACD,oCAAL,EAAP;EACA,CAND;;EAQA,KAAKE,8BAAL,GAAsC,YAAM;IAC3C,qBAAyB,KAAI,CAACC,QAAL,EAAzB;IAAA,IAAQC,YAAR,kBAAQA,YAAR;;IACA,IAAIA,YAAJ,EAAkB;MACjB,IAAQH,eAAR,GAA4BG,YAA5B,CAAQH,eAAR,CADiB,CAEjB;MACA;MACA;;MACA,IAAI,OAAOA,eAAP,KAA2B,QAA/B,EAAyC;QACxC,OAAOA,eAAP;MACA;;MACD,OAAO,KAAI,CAACD,oCAAL,EAAP;IACA;EACD,CAZD;;EAcA,KAAKA,oCAAL,GAA4C,YAAM;IACjD,IAAIA,oCAAJ,EAA0C;MACzC,IAAMK,wBAAwB,GAAGL,oCAAoC,EAArE;;MACA,IAAI,OAAOK,wBAAP,KAAoC,QAAxC,EAAkD;QACjD,OAAOA,wBAAP;MACA;;MACD,MAAM,IAAIC,KAAJ,CAAU,kFAAV,CAAN;IACA,CAPgD,CAQjD;IACA;;;IACA,OAAOR,mCAAP;EACA,CAXD;EAaA;AACD;AACA;AACA;;;EACC,KAAKS,mCAAL,GAA2C,YAAM;IAChD,IAAI,KAAI,CAACN,eAAL,KAAyBO,SAA7B,EAAwC;MACvC,KAAI,CAACP,eAAL,GAAuBQ,sBAAsB,CAACC,IAAvB,CAA4B,KAA5B,CAAvB;MACA,OAAO,KAAI,CAACT,eAAZ;IACA;EACD,CALD;;EAOA,SAASQ,sBAAT,GAAkC;IACjC,sBAGI,KAAKN,QAAL,EAHJ;IAAA,IACCQ,mBADD,mBACCA,mBADD;IAAA,IAECC,kBAFD,mBAECA,kBAFD;;IAKAhB,GAAG,CAAC,mCAAD,CAAH;IAEA,IAAMK,eAAe,GAAGJ,kBAAkB,CAAC;MAC1CgB,cAAc,EAAE,KAAKA,cADqB;MAE1CC,kBAAkB,EAAEF,kBAAkB,GAAGD,mBAArB,GAA2C;IAFrB,CAAD,CAA1C;;IAKA,IAAIV,eAAe,KAAKO,SAAxB,EAAmC;MAClCZ,GAAG,CAAC,uDAAD,CAAH;IACA,CAFD,MAEO;MACNA,GAAG,CAAC,uBAAD,EAA0BK,eAA1B,CAAH;MACA,OAAOA,eAAP;IACA;EACD;AACD"}
@@ -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,20 +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
- // List items "container" DOM Element reference.
64
- var container = useRef(); // Create a `VirtualScroller` instance.
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.
75
+ // Instead, it always derived `tbody` property value from `as` property value by comparing it to `"tbody"` string.
76
+ // As a result, it seemed like the explicit passing of `tbody` property didn't really work as intended.
77
+ // In the end, it was decided that perhaps `tbody` property value should always be derived from `as` property
78
+ // without a developer having to manually specify it. So the `tbody` property was deprecated.
79
+ // It still exists though for backwards compatibility with the older versions of the package.
80
+
81
+
82
+ if (tbody === undefined) {
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';
92
+ } // List items "container" DOM Element reference.
93
+
94
+
95
+ var _useForwardedRef = useForwardedRef(itemsContainerRef),
96
+ setItemsContainerRef = _useForwardedRef.setRef,
97
+ itemsContainer = _useForwardedRef.internalRef; // Create a `VirtualScroller` instance.
98
+
65
99
 
66
100
  var virtualScroller = useVirtualScroller({
67
101
  items: itemsProperty,
@@ -70,9 +104,9 @@ function VirtualScroller(_ref, ref) {
70
104
  estimatedItemHeight: estimatedItemHeight,
71
105
  getEstimatedItemHeight: getEstimatedItemHeight,
72
106
  getEstimatedVisibleItemRowsCount: getEstimatedVisibleItemRowsCount,
107
+ getEstimatedInterItemVerticalSpacing: getEstimatedInterItemVerticalSpacing,
73
108
  bypass: bypass,
74
109
  // bypassBatchSize,
75
- tbody: tbody,
76
110
  onItemInitialRender: onItemInitialRender,
77
111
  // `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.
78
112
  onItemFirstRender: onItemFirstRender,
@@ -85,12 +119,11 @@ function VirtualScroller(_ref, ref) {
85
119
  getScrollableContainer: getScrollableContainer,
86
120
  getColumnsCount: getColumnsCount,
87
121
  getItemId: getItemId,
88
- AsComponent: AsComponent,
89
122
  initialState: initialState,
90
123
  getInitialItemState: getInitialItemState,
91
124
  onStateChange: onStateChange
92
125
  }, {
93
- container: container
126
+ itemsContainer: itemsContainer
94
127
  }); // Only compute the initial state once.
95
128
 
96
129
  var _initialState = useMemo(function () {
@@ -101,8 +134,7 @@ function VirtualScroller(_ref, ref) {
101
134
 
102
135
  var _useState = useState({
103
136
  initialState: _initialState,
104
- onRender: virtualScroller.onRender,
105
- itemsProperty: itemsProperty
137
+ onRender: virtualScroller.onRender
106
138
  }),
107
139
  getState = _useState.getState,
108
140
  setState = _useState.setState,
@@ -126,19 +158,22 @@ function VirtualScroller(_ref, ref) {
126
158
  getItemId: getItemId
127
159
  }),
128
160
  getItemKey = _useItemKeys.getItemKey,
161
+ onItemKeysReset = _useItemKeys.onItemKeysReset,
129
162
  usesAutogeneratedItemKeys = _useItemKeys.usesAutogeneratedItemKeys,
130
163
  updateItemKeysForNewItems = _useItemKeys.updateItemKeysForNewItems; // Cache per-item `setItemState` functions' "references"
131
164
  // so that item components don't get re-rendered needlessly.
132
165
 
133
166
 
134
167
  var getSetItemState = useSetItemState({
135
- initialItemsCount: itemsProperty.length,
168
+ getItemKey: getItemKey,
169
+ onItemKeysReset: onItemKeysReset,
136
170
  virtualScroller: virtualScroller
137
171
  }); // Cache per-item `onItemHeightDidChange` functions' "references"
138
172
  // so that item components don't get re-rendered needlessly.
139
173
 
140
174
  var getOnItemHeightDidChange = useOnItemHeightDidChange({
141
- initialItemsCount: itemsProperty.length,
175
+ getItemKey: getItemKey,
176
+ onItemKeysReset: onItemKeysReset,
142
177
  virtualScroller: virtualScroller
143
178
  }); // Calls `.setItems()` if `items` property has changed.
144
179
 
@@ -167,7 +202,14 @@ function VirtualScroller(_ref, ref) {
167
202
  warn('`onMount` property is deprecated');
168
203
  onMount();
169
204
  }
170
- }, []); // `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.
171
213
  //
172
214
  // // `getSnapshotBeforeUpdate()` is called right before `componentDidUpdate()`.
173
215
  // // A hook equivalent/workaround for `getSnapshotBeforeUpdate()`:
@@ -182,10 +224,12 @@ function VirtualScroller(_ref, ref) {
182
224
  // return null
183
225
  // }
184
226
 
185
- className = useClassName(className, {
227
+ var classNamePassThrough = classNameProperty || itemsContainerComponentProps && itemsContainerComponentProps.className;
228
+ var className = useClassName(classNamePassThrough, {
186
229
  tbody: tbody
187
230
  });
188
- var style = useStyle({
231
+ var stylePassThrough = itemsContainerComponentProps && itemsContainerComponentProps.style;
232
+ var style = useStyle(stylePassThrough, {
189
233
  tbody: tbody,
190
234
  state: stateToRender
191
235
  });
@@ -193,32 +237,36 @@ function VirtualScroller(_ref, ref) {
193
237
  itemStates = stateToRender.itemStates,
194
238
  firstShownItemIndex = stateToRender.firstShownItemIndex,
195
239
  lastShownItemIndex = stateToRender.lastShownItemIndex;
196
- return /*#__PURE__*/React.createElement(AsComponent, _extends({}, rest, {
197
- ref: container,
240
+ return /*#__PURE__*/React.createElement(ItemsContainerComponent, _extends({}, itemsContainerComponentProps, rest, {
241
+ ref: setItemsContainerRef,
198
242
  className: className,
199
243
  style: style
200
244
  }), currentItems.map(function (item, i) {
201
245
  if (i >= firstShownItemIndex && i <= lastShownItemIndex) {
202
- // * Passing `item` as `children` property is legacy and is deprecated.
246
+ // * Passing the `item` as `children` property is legacy and is deprecated.
203
247
  // If version `2.x` is published in some hypothetical future,
204
- // the `item` and `itemIndex` properties should be moved below
205
- // `{...itemComponentProps}`.
248
+ // the `item` property should be moved below `{...itemComponentProps}`.
206
249
  //
207
- // * Passing `itemIndex` property is legacy and is deprecated.
208
- // The rationale is that setting new `items` on a React component
209
- // is an asynchronous operation, so when a user obtains `itemIndex`,
210
- // they don't know which `items` list does that index correspond to,
211
- // 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.
212
258
  //
213
- // * Passing `onStateChange` property for legacy reasons.
259
+ // * `onStateChange` property is passed here for legacy reasons.
214
260
  // The new property name is `setState`.
215
- // The old property name `onStateChange` is deprecated.
261
+ // The old property name `onStateChange` is deprecated
262
+ // and could be removed in some future.
216
263
  //
217
- // * Passing `onHeightChange` property for legacy reasons.
264
+ // * `onHeightChange` property is passed here for legacy reasons.
218
265
  // The new property name is `onHeightDidChange`.
219
- // The old property name `onHeightChange` is deprecated.
266
+ // The old property name `onHeightChange` is deprecated
267
+ // and could be removed in some future.
220
268
  //
221
- return /*#__PURE__*/React.createElement(Component, _extends({
269
+ return /*#__PURE__*/React.createElement(ItemComponent, _extends({
222
270
  item: item,
223
271
  itemIndex: i
224
272
  }, itemComponentProps, {
@@ -241,18 +289,29 @@ export default VirtualScroller; // `PropTypes.elementType` is available in some
241
289
 
242
290
  var elementType = PropTypes.elementType || PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]);
243
291
  VirtualScroller.propTypes = {
292
+ // `as` property is deprecated, use `itemsContainerComponent` property instead.
244
293
  as: elementType,
245
294
  items: PropTypes.arrayOf(PropTypes.any).isRequired,
246
295
  itemComponent: elementType.isRequired,
247
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
+ })]),
248
304
  // `estimatedItemHeight` property name is deprecated,
249
305
  // use `getEstimatedItemHeight` property instead.
250
306
  estimatedItemHeight: PropTypes.number,
251
307
  getEstimatedItemHeight: PropTypes.func,
252
308
  getEstimatedVisibleItemRowsCount: PropTypes.func,
309
+ getEstimatedInterItemVerticalSpacing: PropTypes.func,
253
310
  bypass: PropTypes.bool,
254
311
  // bypassBatchSize: PropTypes.number,
255
- tbody: PropTypes.bool,
312
+ // `tbody` property is deprecated.
313
+ // Pass `as: "tbody"` property instead.
314
+ // tbody: PropTypes.bool,
256
315
  preserveScrollPositionOnPrependItems: PropTypes.bool,
257
316
  // `preserveScrollPosition` property name is deprecated,
258
317
  // use `preserveScrollPositionOnPrependItems` instead.
@@ -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","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\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// 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\ttbody,\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\titemsProperty\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\ttbody: 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,MA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;EAyB3BrC,YAAY,EAAEnC,SAAS,CAACgF,IAzBG;EA0B3B5C,OAAO,EAAEpC,SAAS,CAACyE,IA1BQ;EA2B3BnC,mBAAmB,EAAEtC,SAAS,CAACyE,IA3BJ;EA4B3B;EACApC,iBAAiB,EAAErC,SAAS,CAACyE,IA7BF;EA8B3BlC,qBAAqB,EAAEvC,SAAS,CAAC+E,MA9BN;EA+B3BvC,sBAAsB,EAAExC,SAAS,CAACyE,IA/BP;EAgC3BhC,aAAa,EAAEzC,SAAS,CAACyE,IAhCE;EAiC3B/B,YAAY,EAAE1C,SAAS,CAACiF,KAAV,CAAgB;IAC7B/D,KAAK,EAAElB,SAAS,CAAC4E,OAAV,CAAkB5E,SAAS,CAAC0E,MAA5B,EAAoCI,UADd;IAE7Bf,UAAU,EAAE/D,SAAS,CAAC4E,OAAV,CAAkB5E,SAAS,CAAC6E,GAA5B,EAAiCC,UAFhB;IAG7Bd,mBAAmB,EAAEhE,SAAS,CAAC+E,MAAV,CAAiBD,UAHT;IAI7Bb,kBAAkB,EAAEjE,SAAS,CAAC+E,MAAV,CAAiBD,UAJR;IAK7BI,iBAAiB,EAAElF,SAAS,CAAC+E,MAAV,CAAiBD,UALP;IAM7BK,gBAAgB,EAAEnF,SAAS,CAAC+E,MAAV,CAAiBD,UANN;IAO7BM,WAAW,EAAEpF,SAAS,CAAC4E,OAAV,CAAkB5E,SAAS,CAAC+E,MAA5B,EAAoCD,UAPpB;IAQ7BO,YAAY,EAAErF,SAAS,CAAC+E,MARK;IAS7BO,eAAe,EAAEtF,SAAS,CAAC+E;EATE,CAAhB,CAjCa;EA4C3BpC,mBAAmB,EAAE3C,SAAS,CAACyE;AA5CJ,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,y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AvCJ;EAwC3B;EACAzC,iBAAiB,EAAE5C,SAAS,CAACqF,IAzCF;EA0C3BvC,qBAAqB,EAAE9C,SAAS,CAAC6F,MA1CN;EA2C3B9C,sBAAsB,EAAE/C,SAAS,CAACqF,IA3CP;EA4C3BnC,aAAa,EAAElD,SAAS,CAACqF,IA5CE;EA6C3BrC,YAAY,EAAEhD,SAAS,CAAC2F,KAAV,CAAgB;IAC7BxE,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;