@infinite-table/infinite-react 0.4.13 → 0.5.1

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 (282) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/API.md +0 -0
  3. package/build/buildPackageJson.js +43 -0
  4. package/build/scripts/test.js +37 -0
  5. package/bundler.config.js +25 -0
  6. package/globals.d.ts +7 -0
  7. package/package.json +102 -3
  8. package/rollup.config.js +15 -0
  9. package/run-build-deepmap.js +47 -0
  10. package/run-build.js +45 -0
  11. package/run-dts-concat.js +21 -0
  12. package/src/components/CSSVariableWatch.tsx +82 -0
  13. package/src/components/DataSource/BooleanCollectionState.ts +214 -0
  14. package/src/components/DataSource/BooleanDeepCollectionState.ts +208 -0
  15. package/src/components/DataSource/DataSourceContext.ts +20 -0
  16. package/src/components/DataSource/GroupRowsState.ts +74 -0
  17. package/src/components/DataSource/Indexer.ts +27 -0
  18. package/src/components/DataSource/RowSelectionState.ts +763 -0
  19. package/src/components/DataSource/defaultFilterTypes.ts +64 -0
  20. package/src/components/DataSource/index.tsx +108 -0
  21. package/src/components/DataSource/privateHooks/getChangeDetect.ts +7 -0
  22. package/src/components/DataSource/privateHooks/useLoadData.ts +783 -0
  23. package/src/components/DataSource/publicHooks/useDataSource.ts +19 -0
  24. package/src/components/DataSource/publicHooks/useDataSourceActions.ts +14 -0
  25. package/src/components/DataSource/state/getInitialState.ts +494 -0
  26. package/src/components/DataSource/state/normalizeSortInfo.ts +35 -0
  27. package/src/components/DataSource/state/reducer.ts +466 -0
  28. package/src/components/DataSource/state/rowInfoStatus.ts +27 -0
  29. package/src/components/DataSource/types.ts +548 -0
  30. package/src/components/HeadlessTable/HeadlessTableWithPinnedContainers.tsx +142 -0
  31. package/src/components/HeadlessTable/MappedCells.ts +251 -0
  32. package/src/components/HeadlessTable/RawTable.tsx +98 -0
  33. package/src/components/HeadlessTable/ReactHeadlessTableRenderer.tsx +1516 -0
  34. package/src/components/HeadlessTable/index.tsx +234 -0
  35. package/src/components/InfiniteTable/InfiniteCls.css.ts +164 -0
  36. package/src/components/InfiniteTable/InfiniteTableContext.ts +16 -0
  37. package/src/components/InfiniteTable/api/getImperativeApi.ts +391 -0
  38. package/src/components/InfiniteTable/api/getSelectionApi.ts +364 -0
  39. package/src/components/InfiniteTable/api/type.ts +11 -0
  40. package/src/components/InfiniteTable/components/ActiveCellIndicator.css.ts +51 -0
  41. package/src/components/InfiniteTable/components/ActiveCellIndicator.tsx +116 -0
  42. package/src/components/InfiniteTable/components/ActiveRowIndicator.css.ts +56 -0
  43. package/src/components/InfiniteTable/components/ActiveRowIndicator.tsx +94 -0
  44. package/src/components/InfiniteTable/components/CheckBox.css.ts +13 -0
  45. package/src/components/InfiniteTable/components/CheckBox.tsx +96 -0
  46. package/src/components/InfiniteTable/components/FilterEditors.tsx +52 -0
  47. package/src/components/InfiniteTable/components/InfiniteTableBody/InfiniteTableBody.tsx +27 -0
  48. package/src/components/InfiniteTable/components/InfiniteTableBody/index.tsx +1 -0
  49. package/src/components/InfiniteTable/components/InfiniteTableFooter/InfiniteTableFooter.tsx +31 -0
  50. package/src/components/InfiniteTable/components/InfiniteTableFooter/index.tsx +1 -0
  51. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableColumnHeaderFilter.tsx +102 -0
  52. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx +163 -0
  53. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx +574 -0
  54. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderGroup.tsx +79 -0
  55. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderTypes.tsx +25 -0
  56. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderWrapper.tsx +185 -0
  57. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/GroupResizeHandle.tsx +159 -0
  58. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/ResizeHandle.css.ts +124 -0
  59. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/columnResizer.ts +166 -0
  60. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/index.tsx +146 -0
  61. package/src/components/InfiniteTable/components/InfiniteTableHeader/buildColumnAndGroupTree.ts +240 -0
  62. package/src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts +358 -0
  63. package/src/components/InfiniteTable/components/InfiniteTableHeader/index.tsx +1 -0
  64. package/src/components/InfiniteTable/components/InfiniteTableHeader/useColumnGroupResizeHandle.tsx +114 -0
  65. package/src/components/InfiniteTable/components/InfiniteTableHeader/useColumnResizeHandle.tsx +146 -0
  66. package/src/components/InfiniteTable/components/InfiniteTableLicenseFooter/footer.css.ts +7 -0
  67. package/src/components/InfiniteTable/components/InfiniteTableLicenseFooter/index.tsx +110 -0
  68. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx +120 -0
  69. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCellTypes.ts +74 -0
  70. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableColumnCell.tsx +457 -0
  71. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRow.tsx +107 -0
  72. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowClassName.ts +6 -0
  73. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowTypes.ts +32 -0
  74. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowUnvirtualized.tsx +75 -0
  75. package/src/components/InfiniteTable/components/InfiniteTableRow/columnRendering.tsx +263 -0
  76. package/src/components/InfiniteTable/components/InfiniteTableRow/index.tsx +1 -0
  77. package/src/components/InfiniteTable/components/InfiniteTableRow/row.css.ts +74 -0
  78. package/src/components/InfiniteTable/components/InfiniteTableRow/useRowDOMProps.ts +199 -0
  79. package/src/components/InfiniteTable/components/LoadMask.css.ts +34 -0
  80. package/src/components/InfiniteTable/components/LoadMask.tsx +27 -0
  81. package/src/components/InfiniteTable/components/ScrollbarPlaceholder.tsx +56 -0
  82. package/src/components/InfiniteTable/components/cell.css.ts +192 -0
  83. package/src/components/InfiniteTable/components/icons/ArrowDown.tsx +14 -0
  84. package/src/components/InfiniteTable/components/icons/ArrowUp.tsx +14 -0
  85. package/src/components/InfiniteTable/components/icons/ExpanderIcon.css.ts +31 -0
  86. package/src/components/InfiniteTable/components/icons/ExpanderIcon.tsx +63 -0
  87. package/src/components/InfiniteTable/components/icons/Icon.tsx +18 -0
  88. package/src/components/InfiniteTable/components/icons/InfiniteTableIconClassName.ts +1 -0
  89. package/src/components/InfiniteTable/components/icons/LoadingIcon.css.ts +8 -0
  90. package/src/components/InfiniteTable/components/icons/LoadingIcon.tsx +45 -0
  91. package/src/components/InfiniteTable/components/icons/MenuIcon.tsx +50 -0
  92. package/src/components/InfiniteTable/components/icons/SortIcon.tsx +113 -0
  93. package/src/components/InfiniteTable/eventHandlers/eventHandlerTypes.ts +57 -0
  94. package/src/components/InfiniteTable/eventHandlers/index.ts +95 -0
  95. package/src/components/InfiniteTable/eventHandlers/keyboardNavigation.ts +232 -0
  96. package/src/components/InfiniteTable/eventHandlers/keyboardSelection.ts +110 -0
  97. package/src/components/InfiniteTable/eventHandlers/onCellClick.ts +94 -0
  98. package/src/components/InfiniteTable/eventHandlers/onKeyDown.ts +25 -0
  99. package/src/components/InfiniteTable/hooks/adjustColumnOrderForAllColumns.ts +70 -0
  100. package/src/components/InfiniteTable/hooks/reorderColumnsOnDrag.ts +476 -0
  101. package/src/components/InfiniteTable/hooks/useAutoSizeColumns.ts +206 -0
  102. package/src/components/InfiniteTable/hooks/useCellClassName.ts +80 -0
  103. package/src/components/InfiniteTable/hooks/useCellRendering.tsx +217 -0
  104. package/src/components/InfiniteTable/hooks/useColumnGroups.ts +71 -0
  105. package/src/components/InfiniteTable/hooks/useColumnMenu.ts +72 -0
  106. package/src/components/InfiniteTable/hooks/useColumnPointerEvents.ts +258 -0
  107. package/src/components/InfiniteTable/hooks/useColumnRowspan.ts +43 -0
  108. package/src/components/InfiniteTable/hooks/useColumnSizeFn.ts +24 -0
  109. package/src/components/InfiniteTable/hooks/useColumnsWhen.ts +582 -0
  110. package/src/components/InfiniteTable/hooks/useComputed.ts +186 -0
  111. package/src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts +219 -0
  112. package/src/components/InfiniteTable/hooks/useDOMProps.ts +306 -0
  113. package/src/components/InfiniteTable/hooks/useEffectWithRaf.ts +47 -0
  114. package/src/components/InfiniteTable/hooks/useInfiniteTable.ts +10 -0
  115. package/src/components/InfiniteTable/hooks/useInfiniteTableState.ts +11 -0
  116. package/src/components/InfiniteTable/hooks/useInternalProps.ts +8 -0
  117. package/src/components/InfiniteTable/hooks/useLicense/LicenseDetails.ts +13 -0
  118. package/src/components/InfiniteTable/hooks/useLicense/crc32.ts +56 -0
  119. package/src/components/InfiniteTable/hooks/useLicense/decode.ts +147 -0
  120. package/src/components/InfiniteTable/hooks/useLicense/useLicense.ts +39 -0
  121. package/src/components/InfiniteTable/hooks/useRerenderOnKeyChange.ts +21 -0
  122. package/src/components/InfiniteTable/hooks/useRowHover.ts +18 -0
  123. package/src/components/InfiniteTable/hooks/useScrollToActiveCell.ts +48 -0
  124. package/src/components/InfiniteTable/hooks/useScrollToActiveRow.ts +44 -0
  125. package/src/components/InfiniteTable/hooks/useScrollbars.ts +51 -0
  126. package/src/components/InfiniteTable/hooks/useToggleGroupRow.ts +56 -0
  127. package/src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx +165 -0
  128. package/src/components/InfiniteTable/hooks/useYourBrain.ts +55 -0
  129. package/src/components/InfiniteTable/index.tsx +352 -0
  130. package/src/components/InfiniteTable/internalProps.ts +4 -0
  131. package/src/components/InfiniteTable/state/computeColumnGroupsDepths.ts +29 -0
  132. package/src/components/InfiniteTable/state/getColumnVisibilityForHideEmptyGroupColumns.ts +127 -0
  133. package/src/components/InfiniteTable/state/getInitialState.ts +375 -0
  134. package/src/components/InfiniteTable/theme.css.ts +556 -0
  135. package/src/components/InfiniteTable/types/InfiniteTableAction.ts +6 -0
  136. package/src/components/InfiniteTable/types/InfiniteTableActionType.ts +12 -0
  137. package/src/components/InfiniteTable/types/InfiniteTableColumn.ts +478 -0
  138. package/src/components/InfiniteTable/types/InfiniteTableComputedValues.ts +43 -0
  139. package/src/components/InfiniteTable/types/InfiniteTableContextValue.ts +12 -0
  140. package/src/components/InfiniteTable/types/InfiniteTableInternalProps.ts +3 -0
  141. package/src/components/InfiniteTable/types/InfiniteTableProps.ts +511 -0
  142. package/src/components/InfiniteTable/types/InfiniteTableState.ts +195 -0
  143. package/src/components/InfiniteTable/types/Utility.ts +35 -0
  144. package/src/components/InfiniteTable/types/index.ts +96 -0
  145. package/src/components/InfiniteTable/utilities.css.ts +179 -0
  146. package/src/components/InfiniteTable/utils/MultiRowSelector.ts +111 -0
  147. package/src/components/InfiniteTable/utils/RenderHookComponentForInfinite.tsx +52 -0
  148. package/src/components/InfiniteTable/utils/adjustColumnOrderForPinning.ts +33 -0
  149. package/src/components/InfiniteTable/utils/assignFiltered.ts +29 -0
  150. package/src/components/InfiniteTable/utils/defaultGetColumContextMenuItems.tsx +108 -0
  151. package/src/components/InfiniteTable/utils/getColumnComputedType.ts +33 -0
  152. package/src/components/InfiniteTable/utils/getColumnForGroupBy.tsx +313 -0
  153. package/src/components/InfiniteTable/utils/getComputedVisibleColumns.ts +773 -0
  154. package/src/components/InfiniteTable/utils/getContextMenuForColumn.tsx +72 -0
  155. package/src/components/InfiniteTable/utils/infiniteDOMUtils.ts +189 -0
  156. package/src/components/InfiniteTable/utils/mapToObject.ts +20 -0
  157. package/src/components/InfiniteTable/utils/moveXatY.ts +25 -0
  158. package/src/components/InfiniteTable/utils/objectValuesExcept.ts +9 -0
  159. package/src/components/InfiniteTable/utils/progressiveSpeedScroller.ts +158 -0
  160. package/src/components/InfiniteTable/utils/rafFn.ts +13 -0
  161. package/src/components/InfiniteTable/utils/toCSSVarName.ts +1 -0
  162. package/src/components/InfiniteTable/utils/toMap.ts +24 -0
  163. package/src/components/Menu/Menu.tsx +750 -0
  164. package/src/components/Menu/MenuCls.css.ts +139 -0
  165. package/src/components/Menu/MenuContext.ts +10 -0
  166. package/src/components/Menu/MenuContextValue.ts +15 -0
  167. package/src/components/Menu/MenuProps.ts +98 -0
  168. package/src/components/Menu/MenuState.ts +56 -0
  169. package/src/components/Menu/MenuTriangleContext.ts +352 -0
  170. package/src/components/Menu/childrenToRuntimeItems.tsx +103 -0
  171. package/src/components/Menu/getMenuState.tsx +119 -0
  172. package/src/components/Menu/index.tsx +88 -0
  173. package/src/components/Menu/propToIdentifyMenu.ts +1 -0
  174. package/src/components/RawList/AvoidReactDiff.tsx +48 -0
  175. package/src/components/RawList/MappedItems.ts +143 -0
  176. package/src/components/RawList/ReactVirtualRenderer.tsx +307 -0
  177. package/src/components/RawList/index.tsx +42 -0
  178. package/src/components/RawList/types.ts +23 -0
  179. package/src/components/RawList/useVirtualRenderer.ts +36 -0
  180. package/src/components/RenderHookComponent.tsx +10 -0
  181. package/src/components/ResizeObserver/index.tsx +170 -0
  182. package/src/components/VirtualBrain/MatrixBrain.ts +1621 -0
  183. package/src/components/VirtualBrain/ScrollListener.ts +39 -0
  184. package/src/components/VirtualBrain/index.ts +664 -0
  185. package/src/components/VirtualList/ColumnListWithExternalScrolling.tsx +78 -0
  186. package/src/components/VirtualList/InfiniteListRootClassName.ts +1 -0
  187. package/src/components/VirtualList/RowListWithExternalScrolling.tsx +120 -0
  188. package/src/components/VirtualList/SpacePlaceholder.tsx +32 -0
  189. package/src/components/VirtualList/VirtualList.css.ts +29 -0
  190. package/src/components/VirtualList/VirtualList.tsx +141 -0
  191. package/src/components/VirtualList/VirtualRowList.tsx +34 -0
  192. package/src/components/VirtualList/types.ts +56 -0
  193. package/src/components/VirtualList/useCorrectHeightForRowElements.ts +14 -0
  194. package/src/components/VirtualScrollContainer/VirtualScrollContainer.css.ts +51 -0
  195. package/src/components/VirtualScrollContainer/getScrollableClassName.ts +30 -0
  196. package/src/components/VirtualScrollContainer/index.tsx +63 -0
  197. package/src/components/flexbox/index.ts +562 -0
  198. package/src/components/hooks/useComponentState/index.tsx +562 -0
  199. package/src/components/hooks/useComponentState/types.ts +32 -0
  200. package/src/components/hooks/useEffectOnceWithProperUnmount.ts +33 -0
  201. package/src/components/hooks/useEffectWithChanges.ts +56 -0
  202. package/src/components/hooks/useImmutableRef.ts +7 -0
  203. package/src/components/hooks/useInterceptedMap.ts +71 -0
  204. package/src/components/hooks/useLatest.tsx +8 -0
  205. package/src/components/hooks/useLazyLatest.ts +23 -0
  206. package/src/components/hooks/useMemoShallowObjectMerge.ts +16 -0
  207. package/src/components/hooks/useMounted.ts +18 -0
  208. package/src/components/hooks/useOnMount.ts +21 -0
  209. package/src/components/hooks/useOnScroll.ts +34 -0
  210. package/src/components/hooks/useOnce.ts +10 -0
  211. package/src/components/hooks/useOverlay/index.tsx +418 -0
  212. package/src/components/hooks/usePrevious.ts +8 -0
  213. package/src/components/hooks/usePropertyOld.ts +168 -0
  214. package/src/components/hooks/useRerender.ts +12 -0
  215. package/src/components/hooks/xuseProperty.ts +165 -0
  216. package/src/components/types/CellPosition.ts +4 -0
  217. package/src/components/types/NonUndefined.ts +1 -0
  218. package/src/components/types/RemoveObject.ts +22 -0
  219. package/src/components/types/Renderable.ts +3 -0
  220. package/src/components/types/ScrollPosition.ts +7 -0
  221. package/src/components/types/Setter.ts +2 -0
  222. package/src/components/types/Size.ts +6 -0
  223. package/src/components/types/SubscriptionCallback.ts +10 -0
  224. package/src/components/types/VoidFn.ts +1 -0
  225. package/src/components/utils/buildSubscriptionCallback.tsx +60 -0
  226. package/src/components/utils/clamp.ts +3 -0
  227. package/src/components/utils/debounce.ts +16 -0
  228. package/src/components/utils/decamelize.ts +11 -0
  229. package/src/components/utils/discardCallsWithEqualArg.ts +42 -0
  230. package/src/components/utils/getRenderIndexes.ts +33 -0
  231. package/src/components/utils/getScrollbarWidth.ts +31 -0
  232. package/src/components/utils/getVirtualRenderCount.ts +21 -0
  233. package/src/components/utils/isControlled.ts +12 -0
  234. package/src/components/utils/isControlledValue.ts +5 -0
  235. package/src/index.tsx +34 -0
  236. package/src/test.tsx +18 -0
  237. package/src/utils/DeepMap/index.ts +588 -0
  238. package/src/utils/DeepMap/once.ts +16 -0
  239. package/src/utils/DeepMap/sortAscending.ts +1 -0
  240. package/src/utils/DeepMap/tsconfig.deepmap.json +17 -0
  241. package/src/utils/DeepMap/xpackage.json +26 -0
  242. package/src/utils/debug.ts +40 -0
  243. package/src/utils/deepClone.ts +38 -0
  244. package/src/utils/getGlobal.ts +3 -0
  245. package/src/utils/groupAndPivot/defaultToKey.ts +3 -0
  246. package/src/utils/groupAndPivot/getGroupKeysForDataItem.ts +19 -0
  247. package/src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts +361 -0
  248. package/src/utils/groupAndPivot/index.ts +1229 -0
  249. package/src/utils/groupAndPivot/types.ts +10 -0
  250. package/src/utils/join.ts +4 -0
  251. package/src/utils/mathIntersection.ts +21 -0
  252. package/src/utils/minified.d.ts +2 -0
  253. package/src/utils/minified.js +6 -0
  254. package/src/utils/multisort/index.ts +151 -0
  255. package/src/utils/multisort/sortTypes.ts +25 -0
  256. package/src/utils/notes-status.md +92 -0
  257. package/src/utils/pageGeometry/ConvexPoly.ts +34 -0
  258. package/src/utils/pageGeometry/Point.ts +51 -0
  259. package/src/utils/pageGeometry/PolyWithPoints.ts +52 -0
  260. package/src/utils/pageGeometry/Rectangle.ts +98 -0
  261. package/src/utils/pageGeometry/Triangle.ts +16 -0
  262. package/src/utils/pageGeometry/alignment/index.ts +221 -0
  263. package/src/utils/pageGeometry/polyContainsPoint.ts +182 -0
  264. package/src/utils/pageGeometry/types.ts +3 -0
  265. package/src/utils/proxyFnCall.ts +46 -0
  266. package/src/utils/raf.ts +13 -0
  267. package/src/utils/selectParent.ts +18 -0
  268. package/src/utils/shallowEqualObjects.ts +49 -0
  269. package/src/utils/stripVar.ts +3 -0
  270. package/src/utils/toUpperFirst.ts +5 -0
  271. package/todo.md +2 -0
  272. package/tsconfig.build.json +8 -0
  273. package/tsconfig.dev.json +7 -0
  274. package/tsconfig.json +30 -0
  275. package/tsconfig.typebundler.json +13 -0
  276. package/typedoc.json +4 -0
  277. package/README.md +0 -104
  278. package/index.css +0 -857
  279. package/index.d.ts +0 -2111
  280. package/index.esm.css +0 -857
  281. package/index.esm.js +0 -13695
  282. package/index.js +0 -13565
@@ -0,0 +1,548 @@
1
+ import * as React from 'react';
2
+
3
+ import { DeepMap } from '../../utils/DeepMap';
4
+
5
+ import {
6
+ AggregationReducerResult,
7
+ DeepMapGroupValueType,
8
+ GroupKeyType,
9
+ PivotBy,
10
+ } from '../../utils/groupAndPivot';
11
+ import { GroupBy } from '../../utils/groupAndPivot/types';
12
+ import { MultisortInfo } from '../../utils/multisort';
13
+ import { ComponentStateActions } from '../hooks/useComponentState/types';
14
+ import {
15
+ InfiniteTableColumn,
16
+ InfiniteTableColumnGroup,
17
+ InfiniteTableRowInfo,
18
+ Scrollbars,
19
+ } from '../InfiniteTable/types';
20
+ import {
21
+ DiscriminatedUnion,
22
+ InfiniteTablePivotColumn,
23
+ InfiniteTablePivotFinalColumnVariant,
24
+ } from '../InfiniteTable/types/InfiniteTableColumn';
25
+ import { ScrollStopInfo } from '../InfiniteTable/types/InfiniteTableProps';
26
+ import {
27
+ InfiniteTablePropPivotGrandTotalColumnPosition,
28
+ InfiniteTablePropPivotTotalColumnPosition,
29
+ } from '../InfiniteTable/types/InfiniteTableState';
30
+ import { NonUndefined } from '../types/NonUndefined';
31
+ import { SubscriptionCallback } from '../types/SubscriptionCallback';
32
+ import { RenderRange } from '../VirtualBrain';
33
+
34
+ import { GroupRowsState } from './GroupRowsState';
35
+ import { Indexer } from './Indexer';
36
+ import {
37
+ RowSelectionState,
38
+ RowSelectionStateObject,
39
+ } from './RowSelectionState';
40
+
41
+ export interface DataSourceDataParams<T> {
42
+ originalDataArray: T[];
43
+ sortInfo?: DataSourceSortInfo<T>;
44
+ groupBy?: DataSourcePropGroupBy<T>;
45
+ pivotBy?: DataSourcePropPivotBy<T>;
46
+ filterValue?: DataSourcePropFilterValue<T>;
47
+
48
+ groupRowsState?: DataSourcePropGroupRowsStateObject<any>;
49
+
50
+ lazyLoadBatchSize?: number;
51
+ lazyLoadStartIndex?: number;
52
+ groupKeys?: any[];
53
+
54
+ append?: boolean;
55
+
56
+ aggregationReducers?: DataSourcePropAggregationReducers<T>;
57
+
58
+ livePaginationCursor?: DataSourceLivePaginationCursorValue;
59
+ __cursorId?: DataSourceSetupState<T>['cursorId'];
60
+
61
+ changes?: DataSourceDataParamsChanges<T>;
62
+ }
63
+
64
+ export type DataSourceDataParamsChanges<T> = Partial<
65
+ Record<
66
+ keyof Omit<DataSourceDataParams<T>, 'originalDataArray' | 'changes'>,
67
+ true
68
+ >
69
+ >;
70
+
71
+ export type DataSourceSingleSortInfo<T> = Omit<MultisortInfo<T>, 'field'> & {
72
+ field?: keyof T | (keyof T)[];
73
+ id?: string;
74
+ };
75
+ export type DataSourceGroupBy<T> = GroupBy<T, any>;
76
+ export type DataSourcePivotBy<T> = PivotBy<T, any>;
77
+
78
+ export type DataSourceSortInfo<T> =
79
+ | null
80
+ | DataSourceSingleSortInfo<T>
81
+ | DataSourceSingleSortInfo<T>[];
82
+
83
+ export type DataSourcePropSortInfo<T> = DataSourceSortInfo<T>;
84
+
85
+ export type DataSourceRemoteData<T> = {
86
+ data: T[] | LazyGroupDataItem<T>[];
87
+ mappings?: DataSourceMappings;
88
+ cache?: boolean;
89
+ error?: string;
90
+ totalCount?: number;
91
+ totalCountUnfiltered?: number;
92
+ livePaginationCursor?: DataSourceLivePaginationCursorValue;
93
+ };
94
+
95
+ export type DataSourceData<T> =
96
+ | T[]
97
+ | DataSourceRemoteData<T>
98
+ | Promise<T[] | DataSourceRemoteData<T>>
99
+ | ((
100
+ dataInfo: DataSourceDataParams<T>,
101
+ ) => T[] | Promise<T[] | DataSourceRemoteData<T>>);
102
+
103
+ export type DataSourceGroupRowsList<KeyType> = true | KeyType[][];
104
+
105
+ export type DataSourcePropGroupRowsStateObject<KeyType> = {
106
+ expandedRows: DataSourceGroupRowsList<KeyType>;
107
+ collapsedRows: DataSourceGroupRowsList<KeyType>;
108
+ };
109
+
110
+ export type DataSourcePropGroupBy<T> = DataSourceGroupBy<T>[];
111
+ export type DataSourcePropPivotBy<T> = DataSourcePivotBy<T>[];
112
+
113
+ export interface DataSourceMappedState<T> {
114
+ aggregationReducers?: DataSourceProps<T>['aggregationReducers'];
115
+ livePagination: DataSourceProps<T>['livePagination'];
116
+ isRowSelected: DataSourceProps<T>['isRowSelected'];
117
+
118
+ lazyLoad: DataSourceProps<T>['lazyLoad'];
119
+ useGroupKeysForMultiRowSelection: NonUndefined<
120
+ DataSourceProps<T>['useGroupKeysForMultiRowSelection']
121
+ >;
122
+
123
+ onDataParamsChange: DataSourceProps<T>['onDataParamsChange'];
124
+ data: DataSourceProps<T>['data'];
125
+ sortMode: DataSourceProps<T>['sortMode'];
126
+ filterFunction: DataSourceProps<T>['filterFunction'];
127
+ filterValue: DataSourceProps<T>['filterValue'];
128
+ filterTypes: NonUndefined<DataSourceProps<T>['filterTypes']>;
129
+ primaryKey: DataSourceProps<T>['primaryKey'];
130
+ filterDelay: NonUndefined<DataSourceProps<T>['filterDelay']>;
131
+ groupBy: NonUndefined<DataSourceProps<T>['groupBy']>;
132
+
133
+ pivotBy: DataSourceProps<T>['pivotBy'];
134
+ loading: NonUndefined<DataSourceProps<T>['loading']>;
135
+ sortTypes: NonUndefined<DataSourceProps<T>['sortTypes']>;
136
+ collapseGroupRowsOnDataFunctionChange: NonUndefined<
137
+ DataSourceProps<T>['collapseGroupRowsOnDataFunctionChange']
138
+ >;
139
+ sortInfo: DataSourceSingleSortInfo<T>[] | null;
140
+ }
141
+
142
+ export type DataSourceAggregationReducer<T, AggregationResultType> = {
143
+ name?: string;
144
+ field?: keyof T;
145
+ initialValue?: AggregationResultType;
146
+ getter?: (data: T) => any;
147
+ reducer:
148
+ | string
149
+ | ((
150
+ accumulator: any,
151
+ value: any,
152
+ data: T,
153
+ index: number,
154
+ groupKeys: any[] | undefined,
155
+ ) => AggregationResultType | any);
156
+ done?: (
157
+ accumulatedValue: AggregationResultType | any,
158
+ array: T[],
159
+ ) => AggregationResultType;
160
+ pivotColumn?:
161
+ | ColumnTypeWithInherit<Partial<InfiniteTableColumn<T>>>
162
+ | (({
163
+ column,
164
+ }: {
165
+ column: InfiniteTablePivotFinalColumnVariant<T>;
166
+ }) => ColumnTypeWithInherit<Partial<InfiniteTablePivotColumn<T>>>);
167
+ };
168
+
169
+ export type ColumnTypeWithInherit<COL_TYPE> = COL_TYPE & {
170
+ inheritFromColumn?: string | boolean;
171
+ };
172
+
173
+ export type DataSourceMappings = Record<'totals' | 'values', string>;
174
+
175
+ export type LazyGroupDataItem<DataType> = {
176
+ data: Partial<DataType>;
177
+ keys: any[];
178
+ aggregations?: Record<string, any>;
179
+ dataset?: DataSourceRemoteData<DataType>;
180
+ totalChildrenCount?: number;
181
+ pivot?: {
182
+ values: Record<string, any>;
183
+ totals?: Record<string, any>;
184
+ };
185
+ };
186
+
187
+ export type LazyRowInfoGroup<DataType> = {
188
+ /**
189
+ * Those are direct children of the current lazy group row
190
+ */
191
+ children: LazyGroupDataItem<DataType>[];
192
+ childrenLoading: boolean;
193
+ childrenAvailable: boolean;
194
+ cache: boolean;
195
+ totalCount: number;
196
+ // TODO make sure this is properly implemented
197
+ totalCountUnfiltered: number;
198
+ error?: string;
199
+ };
200
+
201
+ export type LazyGroupDataDeepMap<DataType, KeyType = string> = DeepMap<
202
+ KeyType,
203
+ LazyRowInfoGroup<DataType>
204
+ >;
205
+
206
+ export interface DataSourceSetupState<T> {
207
+ indexer: Indexer<T, any>;
208
+ unfilteredCount: number;
209
+ filteredCount: number;
210
+ lazyLoadCacheOfLoadedBatches: DeepMap<string, true>;
211
+ pivotMappings?: DataSourceMappings;
212
+ propsCache: Map<keyof DataSourceProps<T>, WeakMap<any, any>>;
213
+ showSeparatePivotColumnForSingleAggregation: boolean;
214
+ dataParams?: DataSourceDataParams<T>;
215
+ originalLazyGroupData: LazyGroupDataDeepMap<T>;
216
+ originalLazyGroupDataChangeDetect: number | string;
217
+ scrollStopDelayUpdatedByTable: number;
218
+
219
+ notifyScrollbarsChange: SubscriptionCallback<Scrollbars>;
220
+ notifyScrollStop: SubscriptionCallback<ScrollStopInfo>;
221
+ notifyRenderRangeChange: SubscriptionCallback<RenderRange>;
222
+ originalDataArray: T[];
223
+ lastFilterDataArray?: T[];
224
+ lastSortDataArray?: T[];
225
+ lastGroupDataArray?: InfiniteTableRowInfo<T>[];
226
+ dataArray: InfiniteTableRowInfo<T>[];
227
+ groupDeepMap?: DeepMap<GroupKeyType, DeepMapGroupValueType<T, any>>;
228
+ groupRowsIndexesInDataArray?: number[];
229
+ reducerResults?: Record<string, AggregationReducerResult>;
230
+ allRowsSelected: boolean;
231
+ // selectedRowCount: number;
232
+ someRowsSelected: boolean;
233
+ pivotTotalColumnPosition: InfiniteTablePropPivotTotalColumnPosition;
234
+ pivotGrandTotalColumnPosition: InfiniteTablePropPivotGrandTotalColumnPosition;
235
+ cursorId: number | symbol | DataSourceLivePaginationCursorValue;
236
+
237
+ updatedAt: number;
238
+ reducedAt: number;
239
+ groupedAt: number;
240
+ sortedAt: number;
241
+ filteredAt: number;
242
+ generateGroupRows: boolean;
243
+
244
+ postFilterDataArray?: T[];
245
+ postSortDataArray?: T[];
246
+ postGroupDataArray?: InfiniteTableRowInfo<T>[];
247
+ pivotColumns?: Map<string, InfiniteTableColumn<T>>;
248
+ pivotColumnGroups?: Map<string, InfiniteTableColumnGroup>;
249
+ }
250
+
251
+ export type DataSourcePropAggregationReducers<T> = Record<
252
+ string,
253
+ DataSourceAggregationReducer<T, any>
254
+ >;
255
+ export type DataSourcePropMultiRowSelectionChangeParamType =
256
+ RowSelectionStateObject;
257
+
258
+ export type DataSourcePropRowSelection =
259
+ | DataSourcePropRowSelection_MultiRow
260
+ | DataSourcePropRowSelection_SingleRow;
261
+
262
+ export type DataSourcePropRowSelection_MultiRow = RowSelectionStateObject;
263
+ export type DataSourcePropRowSelection_SingleRow = null | string | number;
264
+
265
+ export type DataSourcePropCellSelection = any;
266
+
267
+ export type DataSourcePropSelectionMode =
268
+ | false
269
+ | 'single-cell'
270
+ | 'single-row'
271
+ | 'multi-cell'
272
+ | 'multi-row';
273
+
274
+ // export type DataSourcePropOnRowSelectionChange_MultiRow = (params: {
275
+ // rowSelection: DataSourcePropRowSelection_MultiRow;
276
+ // rowSelectionState: RowSelectionState;
277
+ // selectionMode: 'multi-row';
278
+ // }) => void;
279
+ // export type DataSourcePropOnRowSelectionChange_SingleRow = (params: {
280
+ // rowSelection: DataSourcePropRowSelection_SingleRow;
281
+ // selectionMode: 'single-row';
282
+ // }) => void;
283
+
284
+ export type DataSourcePropOnRowSelectionChange_MultiRow = (
285
+ rowSelection: DataSourcePropRowSelection_MultiRow,
286
+ selectionMode: 'multi-row',
287
+ ) => void;
288
+ export type DataSourcePropOnRowSelectionChange_SingleRow = (
289
+ rowSelection: DataSourcePropRowSelection_SingleRow,
290
+ selectionMode: 'single-row',
291
+ ) => void;
292
+
293
+ export type DataSourcePropOnRowSelectionChange =
294
+ | DataSourcePropOnRowSelectionChange_SingleRow
295
+ | DataSourcePropOnRowSelectionChange_MultiRow;
296
+ export type DataSourcePropOnCellSelectionChange = (
297
+ cellSelectionParams: any,
298
+ ) => void;
299
+
300
+ export type DataSourcePropIsRowSelected<T> = (
301
+ rowInfo: InfiniteTableRowInfo<T>,
302
+ rowSelectionState: RowSelectionState,
303
+ selectionMode: 'multi-row',
304
+ ) => boolean | null;
305
+
306
+ export type DataSourceProps<T> = {
307
+ children:
308
+ | React.ReactNode
309
+ | ((contextData: DataSourceState<T>) => React.ReactNode);
310
+ primaryKey: keyof T | ((data: T) => string);
311
+ fields?: (keyof T)[];
312
+
313
+ data: DataSourceData<T>;
314
+
315
+ selectionMode?: DataSourcePropSelectionMode;
316
+ useGroupKeysForMultiRowSelection?: boolean;
317
+
318
+ rowSelection?:
319
+ | DataSourcePropRowSelection_MultiRow
320
+ | DataSourcePropRowSelection_SingleRow;
321
+ defaultRowSelection?:
322
+ | DataSourcePropRowSelection_MultiRow
323
+ | DataSourcePropRowSelection_SingleRow;
324
+
325
+ cellSelection?: DataSourcePropCellSelection;
326
+ defaultCellSelection?: DataSourcePropCellSelection;
327
+ onCellSelectionChange?: DataSourcePropOnCellSelectionChange;
328
+
329
+ isRowSelected?: DataSourcePropIsRowSelected<T>;
330
+
331
+ lazyLoad?: boolean | { batchSize?: number };
332
+
333
+ // other properties, each with controlled and uncontrolled variant
334
+ loading?: boolean;
335
+ defaultLoading?: boolean;
336
+ onLoadingChange?: (loading: boolean) => void;
337
+
338
+ pivotBy?: DataSourcePropPivotBy<T>;
339
+ defaultPivotBy?: DataSourcePropPivotBy<T>;
340
+ onPivotByChange?: (pivotBy: DataSourcePropPivotBy<T>) => void;
341
+
342
+ aggregationReducers?: DataSourcePropAggregationReducers<T>;
343
+ defaultAggregationReducers?: DataSourcePropAggregationReducers<T>;
344
+
345
+ groupBy?: DataSourcePropGroupBy<T>;
346
+ defaultGroupBy?: DataSourcePropGroupBy<T>;
347
+ onGroupByChange?: (groupBy: DataSourcePropGroupBy<T>) => void;
348
+
349
+ groupRowsState?: GroupRowsState | DataSourcePropGroupRowsStateObject<any>;
350
+ defaultGroupRowsState?:
351
+ | GroupRowsState
352
+ | DataSourcePropGroupRowsStateObject<keyof T>;
353
+ onGroupRowsStateChange?: (groupRowsState: GroupRowsState) => void;
354
+
355
+ collapseGroupRowsOnDataFunctionChange?: boolean;
356
+
357
+ sortInfo?: DataSourceSortInfo<T>;
358
+ defaultSortInfo?: DataSourceSortInfo<T>;
359
+ onSortInfoChange?:
360
+ | ((sortInfo: DataSourceSingleSortInfo<T> | null) => void)
361
+ | ((sortInfo: DataSourceSingleSortInfo<T>[]) => void);
362
+
363
+ onDataParamsChange?: (dataParamsChange: DataSourceDataParams<T>) => void;
364
+ livePagination?: boolean;
365
+ livePaginationCursor?: DataSourcePropLivePaginationCursor<T>;
366
+ onLivePaginationCursorChange?: (
367
+ livePaginationCursor: DataSourceLivePaginationCursorValue,
368
+ ) => void;
369
+
370
+ filterFunction?: DataSourcePropFilterFunction<T>;
371
+
372
+ sortMode?: 'local' | 'remote';
373
+ filterMode?: 'local' | 'remote';
374
+ filterValue?: DataSourcePropFilterValue<T>;
375
+ defaultFilterValue?: DataSourcePropFilterValue<T>;
376
+ onFilterValueChange?: (filterValue: DataSourcePropFilterValue<T>) => void;
377
+
378
+ filterDelay?: number;
379
+ filterTypes?: DataSourcePropFilterTypes<T>;
380
+
381
+ sortTypes?: DataSourcePropSortTypes;
382
+ } & (
383
+ | {
384
+ selectionMode?: 'multi-row';
385
+ rowSelection?: DataSourcePropRowSelection_MultiRow;
386
+ defaultRowSelection?: DataSourcePropRowSelection_MultiRow;
387
+ onRowSelectionChange?: DataSourcePropOnRowSelectionChange_MultiRow;
388
+ }
389
+ | {
390
+ selectionMode?: 'single-row';
391
+ rowSelection?: DataSourcePropRowSelection_SingleRow;
392
+ defaultRowSelection?: DataSourcePropRowSelection_SingleRow;
393
+ onRowSelectionChange?: DataSourcePropOnRowSelectionChange_SingleRow;
394
+ }
395
+ | {
396
+ selectionMode?: 'single-cell';
397
+ }
398
+ | {
399
+ selectionMode?: 'multi-cell';
400
+ }
401
+ | {
402
+ selectionMode?: false;
403
+ }
404
+ );
405
+
406
+ export type DataSourcePropSortTypes = Record<
407
+ string,
408
+ (first: any, second: any) => number
409
+ >;
410
+
411
+ export type DataSourcePropFilterTypes<T> = Record<
412
+ string,
413
+ DataSourceFilterType<T>
414
+ >;
415
+
416
+ export type DataSourceFilterFunctionParam<T> = {
417
+ data: T;
418
+ index: number;
419
+ dataArray: T[];
420
+ primaryKey: any;
421
+ };
422
+ export type DataSourcePropFilterFunction<T> = (
423
+ filterParam: DataSourceFilterFunctionParam<T>,
424
+ ) => boolean;
425
+
426
+ export type DataSourcePropFilterValue<T> = DataSourceFilterValueItem<T>[];
427
+
428
+ export type DataSourceFilterValueItem<T> = DiscriminatedUnion<
429
+ {
430
+ field: keyof T;
431
+ },
432
+ { id: string }
433
+ > & {
434
+ valueGetter?: DataSourceFilterValueItemValueGetter<T>;
435
+ filterValue: any;
436
+ disabled?: boolean;
437
+ filterType: string;
438
+ operator: string;
439
+ };
440
+
441
+ export type DataSourceFilterValueItemValueGetter<T> = (
442
+ param: DataSourceFilterFunctionParam<T>,
443
+ ) => any;
444
+
445
+ export type DataSourceFilterType<T> = {
446
+ emptyValues: Set<any>;
447
+ label?: string;
448
+ defaultOperator: string;
449
+ operators: DataSourceFilterOperator<T>[];
450
+ };
451
+
452
+ export type DataSourceFilterOperator<T> = {
453
+ name: string;
454
+ label?: string;
455
+ fn: DataSourceFilterOperatorFunction<T>;
456
+ };
457
+
458
+ export type DataSourceFilterOperatorFunction<T> = (
459
+ filterOperatorFunctionParam: DataSourceFilterOperatorFunctionParam<T>,
460
+ ) => boolean;
461
+
462
+ export type DataSourceFilterOperatorFunctionParam<T> = {
463
+ currentValue: any;
464
+ filterValue: any;
465
+ emptyValues: Set<any>;
466
+ } & DataSourceFilterFunctionParam<T>;
467
+
468
+ export type DataSourcePropLivePaginationCursor<T> =
469
+ | DataSourceLivePaginationCursorValue
470
+ | DataSourceLivePaginationCursorFn<T>;
471
+
472
+ export type DataSourceLivePaginationCursorFn<T> = (
473
+ params: DataSourceLivePaginationCursorParams<T>,
474
+ ) => DataSourceLivePaginationCursorValue;
475
+ export type DataSourceLivePaginationCursorParams<T> = {
476
+ array: T[];
477
+ lastItem: T | Partial<T> | null;
478
+ length: number;
479
+ };
480
+ export type DataSourceLivePaginationCursorValue = string | number | null;
481
+
482
+ // export type DataSourceState<T> = DataSourceSetupState<T> &
483
+ // DataSourceDerivedState<T> &
484
+ // DataSourceMappedState<T>;
485
+
486
+ export interface DataSourceState<T>
487
+ extends DataSourceSetupState<T>,
488
+ DataSourceDerivedState<T>,
489
+ DataSourceMappedState<T> {}
490
+
491
+ export type DataSourceDerivedState<T> = {
492
+ // TODO pass as second arg the index
493
+ toPrimaryKey: (data: T) => any;
494
+ operatorsByFilterType: Record<
495
+ string,
496
+ Record<string, DataSourceFilterOperator<T>>
497
+ >;
498
+
499
+ filterMode: NonUndefined<DataSourceProps<T>['filterMode']>;
500
+ groupRowsState: GroupRowsState<T>;
501
+ multiSort: boolean;
502
+ controlledSort: boolean;
503
+ controlledFilter: boolean;
504
+ livePaginationCursor?: DataSourceLivePaginationCursorValue;
505
+ lazyLoadBatchSize?: number;
506
+ rowSelection: RowSelectionState | null | number | string;
507
+ selectionMode: NonUndefined<DataSourceProps<T>['selectionMode']>;
508
+ };
509
+ // & (
510
+ // | {
511
+ // rowSelection: RowSelectionState;
512
+ // selectionMode: 'multi-row';
513
+ // }
514
+ // | {
515
+ // rowSelection: null | number | string;
516
+ // selectionMode: 'single-row';
517
+ // }
518
+ // | {
519
+ // selectionMode: false | 'single-cell' | 'multi-cell';
520
+ // rowSelection: null;
521
+ // }
522
+ // );
523
+
524
+ export type DataSourceComponentActions<T> = ComponentStateActions<
525
+ DataSourceState<T>
526
+ >;
527
+
528
+ export interface DataSourceContextValue<T> {
529
+ getState: () => DataSourceState<T>;
530
+ componentState: DataSourceState<T>;
531
+ componentActions: DataSourceComponentActions<T>;
532
+ }
533
+
534
+ export enum DataSourceActionType {
535
+ INIT = 'INIT',
536
+ }
537
+
538
+ export interface DataSourceAction<T> {
539
+ type: DataSourceActionType;
540
+ payload: T;
541
+ }
542
+
543
+ export interface DataSourceReducer<T> {
544
+ (
545
+ state: DataSourceState<T>,
546
+ action: DataSourceAction<any>,
547
+ ): DataSourceState<T>;
548
+ }
@@ -0,0 +1,142 @@
1
+ //@ts-nocheck
2
+ import * as React from 'react';
3
+ import { RefObject, useCallback, useEffect, useRef, useState } from 'react';
4
+ import { HeadlessTableProps, useMatrixBrain } from '.';
5
+ import { join } from '../../utils/join';
6
+ import {
7
+ boxSizingBorderBox,
8
+ display,
9
+ position,
10
+ transformTranslateZero,
11
+ } from '../InfiniteTable/utilities.css';
12
+ import { useResizeObserver } from '../ResizeObserver';
13
+ import { ScrollPosition } from '../types/ScrollPosition';
14
+ import { Size } from '../types/Size';
15
+ import { getScrollbarWidth } from '../utils/getScrollbarWidth';
16
+ import { MatrixBrain } from '../VirtualBrain/MatrixBrain';
17
+ import { SpacePlaceholder } from '../VirtualList/SpacePlaceholder';
18
+ import { scrollTransformTargetCls } from '../VirtualList/VirtualList.css';
19
+ import { VirtualScrollContainer } from '../VirtualScrollContainer';
20
+ import { RawTable } from './RawTable';
21
+ import { TableRenderCellFnParam } from './ReactHeadlessTableRenderer';
22
+
23
+ export type HeadlessTableWithPinnedContainersProps = {} & HeadlessTableProps;
24
+
25
+ const ONLY_VERTICAL_SCROLL = {
26
+ horizontal: false,
27
+ vertical: true,
28
+ };
29
+
30
+ const measureSizeStyle: React.CSSProperties = {
31
+ position: 'absolute',
32
+ inset: 0, // this is same as top,left,bottom,right:0
33
+ pointerEvents: 'none',
34
+ zIndex: -1_000,
35
+ };
36
+ export function HeadlessTableWithPinnedContainersFn(
37
+ props: HeadlessTableWithPinnedContainersProps,
38
+ ) {
39
+ const { brain } = props;
40
+
41
+ const domRef = useRef<HTMLDivElement>(null);
42
+ const measureSizeRef = useRef<HTMLDivElement>(null);
43
+
44
+ const [measureSize, setMeasureSize] = useState<Size | null>(null);
45
+ const size = measureSize || { width: props.width, height: props.height };
46
+
47
+ useMatrixBrain(
48
+ brain,
49
+ {
50
+ ...props,
51
+ height: size.height,
52
+ width: size.width,
53
+ },
54
+ {
55
+ fixedColsStart: props.fixedColsStart,
56
+ fixedColsEnd: props.fixedColsEnd,
57
+ fixedRowsStart: props.fixedRowsStart,
58
+ fixedRowsEnd: props.fixedRowsEnd,
59
+ },
60
+ );
61
+ useResizeObserver(measureSizeRef, setMeasureSize);
62
+ const onContainerScroll = useCallback(
63
+ (scrollPos: ScrollPosition) => {
64
+ brain.setScrollPosition({
65
+ scrollTop: scrollPos.scrollTop,
66
+ scrollLeft: 0,
67
+ });
68
+ domRef.current!.style.transform = `translate3d(${-scrollPos.scrollLeft}px, ${-scrollPos.scrollTop}px, 0px)`;
69
+ },
70
+ [brain],
71
+ );
72
+
73
+ const [scrollSize, setTotalScrollSize] = useState({
74
+ width: 0,
75
+ height: 0,
76
+ });
77
+
78
+ useEffect(() => {
79
+ const removeOnRenderCount = brain.onRenderCountChange(() => {
80
+ setTotalScrollSize(brain.getTotalSize());
81
+ });
82
+
83
+ setTotalScrollSize(brain.getTotalSize());
84
+
85
+ return () => {
86
+ removeOnRenderCount();
87
+ };
88
+ }, [brain]);
89
+
90
+ // const hasHorizontalScrollbar =
91
+ // computedUnpinnedColumnsWidth >
92
+ // bodySize.width -
93
+ // computedPinnedStartColumnsWidth -
94
+ // computedPinnedEndColumnsWidth;
95
+
96
+ // const reservedContentHeight =
97
+ // brain.getTotalSize().height +
98
+ // (hasHorizontalScrollbar ? getScrollbarWidth() : 0);
99
+ return (
100
+ <div
101
+ className={join(
102
+ transformTranslateZero,
103
+ position.relative,
104
+ boxSizingBorderBox,
105
+ )}
106
+ style={{
107
+ width: props.width,
108
+ height: props.height,
109
+ }}
110
+ >
111
+ <VirtualScrollContainer
112
+ scrollable={ONLY_VERTICAL_SCROLL}
113
+ onContainerScroll={onContainerScroll}
114
+ ref={props.scrollerDOMRef as RefObject<HTMLDivElement>}
115
+ >
116
+ <div className={display.flex}>
117
+ <div
118
+ ref={domRef}
119
+ className={scrollTransformTargetCls}
120
+ data-name="scroll-transform-target"
121
+ >
122
+ <RawTable renderCell={props.renderCell} brain={brain} />
123
+ </div>
124
+ </div>
125
+ <SpacePlaceholder
126
+ count={props.rows}
127
+ width={0}
128
+ height={scrollSize.height}
129
+ />
130
+ {/**
131
+ * we need this size measurer, even though we have props.width and props.height passed down to us
132
+ * because this measurer also accounts for scrollbars showing/hiding which changes the
133
+ * dimensions of the space available for virtualization
134
+ */}
135
+ <div ref={measureSizeRef} style={measureSizeStyle} />
136
+ </VirtualScrollContainer>
137
+ </div>
138
+ );
139
+ }
140
+
141
+ export const HeadlessTableWithPinnedContainers: React.FC<HeadlessTableWithPinnedContainersProps> =
142
+ React.memo(HeadlessTableWithPinnedContainersFn);