@infinite-table/infinite-react 0.4.13 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +95 -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,773 @@
1
+ import { err } from '../../../utils/debug';
2
+ import type {
3
+ DataSourceFilterValueItem,
4
+ DataSourcePropFilterValue,
5
+ DataSourceSingleSortInfo,
6
+ } from '../../DataSource/types';
7
+ import { computeFlex } from '../../flexbox';
8
+ import type { Size } from '../../types/Size';
9
+ import { getScrollbarWidth } from '../../utils/getScrollbarWidth';
10
+ import type {
11
+ InfiniteTableColumn,
12
+ InfiniteTableComputedColumn,
13
+ InfiniteTableGeneratedGroupColumn,
14
+ RequireAtLeastOne,
15
+ } from '../types/InfiniteTableColumn';
16
+ import type {
17
+ InfiniteTableColumnPinnedValues,
18
+ InfiniteTableColumnSizingOptions,
19
+ InfiniteTablePropColumnOrder,
20
+ InfiniteTablePropColumnOrderNormalized,
21
+ InfiniteTablePropColumnPinning,
22
+ InfiniteTablePropColumnSizing,
23
+ InfiniteTablePropColumnTypes,
24
+ InfiniteTablePropColumnVisibility,
25
+ } from '../types/InfiniteTableProps';
26
+
27
+ import { adjustColumnOrderForPinning } from './adjustColumnOrderForPinning';
28
+ import { assignNonNull } from './assignFiltered';
29
+ import { getColumnComputedType } from './getColumnComputedType';
30
+
31
+ const logError = err('getComputedVisibleColumns');
32
+
33
+ export type SortInfoMap<T> = {
34
+ [key: string]: {
35
+ sortInfo: DataSourceSingleSortInfo<T>;
36
+ index: number;
37
+ };
38
+ };
39
+
40
+ const isColumnVisible = (
41
+ columnVisibility: InfiniteTablePropColumnVisibility,
42
+ _columnVisibilityAssumeVisible: boolean,
43
+
44
+ colId: string,
45
+ ) => {
46
+ // if (_columnVisibilityAssumeVisible) {
47
+ return columnVisibility[colId] !== false;
48
+ // }
49
+
50
+ // return columnVisibility.get(colId) === true;
51
+ };
52
+
53
+ const getComputedPinned = (
54
+ colId: string,
55
+ columnPinning: InfiniteTablePropColumnPinning,
56
+ ): InfiniteTableColumnPinnedValues => {
57
+ if (!columnPinning) {
58
+ return false;
59
+ }
60
+ const pinned = columnPinning[colId];
61
+ const computedPinned: InfiniteTableColumnPinnedValues =
62
+ pinned === 'start' || pinned === true
63
+ ? 'start'
64
+ : pinned === 'end'
65
+ ? 'end'
66
+ : false;
67
+
68
+ return computedPinned;
69
+ };
70
+
71
+ export type GetComputedVisibleColumnsResult<T> = {
72
+ renderSelectionCheckBox: boolean;
73
+ computedRemainingSpace: number;
74
+ computedPinnedStartColumnsWidth: number;
75
+ computedPinnedStartWidth: number;
76
+ computedPinnedEndColumnsWidth: number;
77
+ computedPinnedEndWidth: number;
78
+ computedUnpinnedColumnsWidth: number;
79
+
80
+ computedColumnsMap: Map<string, InfiniteTableComputedColumn<T>>;
81
+ computedColumnsMapInInitialOrder: Map<string, InfiniteTableComputedColumn<T>>;
82
+
83
+ columnMinWidth?: number;
84
+ columnMaxWidth?: number;
85
+ columnDefaultWidth?: number;
86
+
87
+ computedPinnedStartColumns: InfiniteTableComputedColumn<T>[];
88
+ computedPinnedEndColumns: InfiniteTableComputedColumn<T>[];
89
+ computedUnpinnedColumns: InfiniteTableComputedColumn<T>[];
90
+
91
+ computedColumnOrder: InfiniteTablePropColumnOrderNormalized;
92
+
93
+ computedUnpinnedOffset: number;
94
+ computedPinnedEndOffset: number;
95
+
96
+ computedVisibleColumns: InfiniteTableComputedColumn<T>[];
97
+ computedVisibleColumnsMap: Map<string, InfiniteTableComputedColumn<T>>;
98
+ fieldsToColumn: Map<keyof T, InfiniteTableComputedColumn<T>>;
99
+ };
100
+
101
+ type GetComputedVisibleColumnsParam<T> = {
102
+ columns: Map<string, InfiniteTableColumn<T>>;
103
+
104
+ bodySize: Size;
105
+ columnMinWidth?: number;
106
+ columnMaxWidth?: number;
107
+ pinnedStartMaxWidth?: number;
108
+ pinnedEndMaxWidth?: number;
109
+ columnDefaultWidth?: number;
110
+ viewportReservedWidth?: number;
111
+ resizableColumns: boolean | undefined;
112
+
113
+ columnCssEllipsis: boolean;
114
+ columnHeaderCssEllipsis: boolean;
115
+
116
+ scrollbarWidth: number | undefined;
117
+
118
+ filterValue?: DataSourcePropFilterValue<T>;
119
+
120
+ sortable?: boolean;
121
+ multiSort: boolean;
122
+ sortInfo?: DataSourceSingleSortInfo<T>[];
123
+ setSortInfo: (sortInfo: DataSourceSingleSortInfo<T>[]) => void;
124
+
125
+ draggableColumns?: boolean;
126
+ columnOrder: InfiniteTablePropColumnOrder;
127
+ columnPinning: InfiniteTablePropColumnPinning;
128
+ columnSizing: InfiniteTablePropColumnSizing;
129
+ columnTypes: InfiniteTablePropColumnTypes<T>;
130
+ columnVisibility: InfiniteTablePropColumnVisibility;
131
+ columnVisibilityAssumeVisible: boolean;
132
+ };
133
+
134
+ function isGroupColumnSortable<T>(
135
+ column: InfiniteTableComputedColumn<T>,
136
+ columns: Map<string, InfiniteTableComputedColumn<T>>,
137
+ ) {
138
+ let sortableColumnOrType = column.sortable ?? column.colType.sortable;
139
+
140
+ if (sortableColumnOrType != null) {
141
+ return sortableColumnOrType;
142
+ }
143
+
144
+ if (column.computedSortable === false) {
145
+ return false;
146
+ }
147
+
148
+ let groupByField = column.groupByField || [];
149
+ if (groupByField != null && !Array.isArray(groupByField)) {
150
+ groupByField = [groupByField];
151
+ }
152
+ const fields = (groupByField || []).reduce((acc, field: string) => {
153
+ acc[field] = true;
154
+ return acc;
155
+ }, {} as Record<string, boolean>);
156
+
157
+ const groupColumns: InfiniteTableComputedColumn<T>[] = [];
158
+ columns.forEach((col) => {
159
+ if (col.field && fields[col.field as string]) {
160
+ groupColumns.push(col);
161
+ }
162
+ });
163
+
164
+ return groupColumns.reduce((sortable, col) => {
165
+ return sortable && col.computedSortable === true;
166
+ }, true as boolean);
167
+ }
168
+
169
+ export const getComputedVisibleColumns = <T extends unknown>({
170
+ columns,
171
+
172
+ bodySize,
173
+ columnMinWidth,
174
+ columnMaxWidth,
175
+ columnDefaultWidth,
176
+ scrollbarWidth,
177
+ columnCssEllipsis,
178
+ columnHeaderCssEllipsis,
179
+ pinnedStartMaxWidth,
180
+ pinnedEndMaxWidth,
181
+ filterValue,
182
+ sortable,
183
+ sortInfo,
184
+ setSortInfo,
185
+ multiSort,
186
+
187
+ viewportReservedWidth,
188
+ resizableColumns,
189
+
190
+ draggableColumns,
191
+ columnOrder,
192
+ columnPinning,
193
+ columnSizing,
194
+ columnTypes,
195
+ columnVisibility,
196
+ columnVisibilityAssumeVisible,
197
+ }: GetComputedVisibleColumnsParam<T>): GetComputedVisibleColumnsResult<T> => {
198
+ let computedOffset = 0;
199
+
200
+ const filterValueRecord = (filterValue || []).reduce(
201
+ (acc, filterValueItem) => {
202
+ const { id, field } = filterValueItem;
203
+
204
+ if (field) {
205
+ acc[field as string] = filterValueItem;
206
+ }
207
+ if (id) {
208
+ acc[id] = filterValueItem;
209
+ }
210
+ return acc;
211
+ },
212
+ {} as Record<string, DataSourceFilterValueItem<T>>,
213
+ );
214
+
215
+ const normalizedColumnOrder = adjustColumnOrderForPinning(
216
+ columnOrder === true ? [...columns.keys()] : columnOrder,
217
+ columnPinning,
218
+ );
219
+
220
+ const visibleColumnOrder = normalizedColumnOrder.filter((colId) => {
221
+ const col = columns.get(colId);
222
+ if (!col) {
223
+ logError(
224
+ `Column with id "${colId}" specified in columnOrder array cannot be found in the columns map.`,
225
+ );
226
+ return false;
227
+ }
228
+
229
+ const result = isColumnVisible(
230
+ columnVisibility,
231
+ columnVisibilityAssumeVisible,
232
+ colId,
233
+ );
234
+
235
+ return result;
236
+ });
237
+
238
+ const columnIdsToVisibleIndex: Map<string, number> = new Map();
239
+
240
+ const visibleColumnsArray: InfiniteTableColumn<T>[] = visibleColumnOrder.map(
241
+ (columnId, index) => {
242
+ const col = columns.get(columnId)!;
243
+
244
+ columnIdsToVisibleIndex.set(columnId, index);
245
+
246
+ return col;
247
+ },
248
+ );
249
+
250
+ const sortedMap = (sortInfo ?? []).reduce(
251
+ (acc: SortInfoMap<T>, info: DataSourceSingleSortInfo<T>, index) => {
252
+ if (info.id) {
253
+ acc[info.id] = { sortInfo: info, index };
254
+ } else if (info.field) {
255
+ acc[info.field as unknown as keyof SortInfoMap<T>] = {
256
+ sortInfo: info,
257
+ index,
258
+ };
259
+ }
260
+ return acc;
261
+ },
262
+ {} as SortInfoMap<T>,
263
+ );
264
+
265
+ type ColSizeOptions = {
266
+ flex?: number;
267
+ size?: number;
268
+ minSize?: number;
269
+ maxSize?: number;
270
+ };
271
+
272
+ function getColSize(
273
+ colId: string,
274
+ ): RequireAtLeastOne<ColSizeOptions, 'flex' | 'size'> {
275
+ const column = columns.get(colId);
276
+ const colType = getColumnComputedType(column!, columnTypes);
277
+ const colTypeSizing: InfiniteTableColumnSizingOptions = {
278
+ minWidth: colType?.minWidth,
279
+ maxWidth: colType?.maxWidth,
280
+ width: colType?.defaultWidth,
281
+ flex: colType?.defaultFlex,
282
+ };
283
+ let colSizing = assignNonNull(
284
+ {
285
+ width: column?.defaultWidth,
286
+ flex: column?.defaultFlex,
287
+ minWidth: column?.minWidth,
288
+ maxWidth: column?.maxWidth,
289
+ },
290
+ columnSizing[colId],
291
+ );
292
+
293
+ // if colSizing has width
294
+ if (colSizing.width != null) {
295
+ // it should ignore coltype flex
296
+ delete colTypeSizing.flex;
297
+ }
298
+
299
+ // or if it has flex
300
+ if (colSizing.flex != null) {
301
+ // it should ignore coltype width
302
+ delete colTypeSizing.width;
303
+ }
304
+
305
+ colSizing = assignNonNull(colTypeSizing, colSizing);
306
+
307
+ const colFlex: number | undefined = colSizing.flex ?? undefined;
308
+ const colMinWidth =
309
+ colSizing.minWidth ?? column?.minWidth ?? columnMinWidth;
310
+ const colMaxWidth =
311
+ colSizing.maxWidth ?? column?.maxWidth ?? columnMaxWidth;
312
+
313
+ let size =
314
+ colFlex != undefined ? undefined : colSizing.width ?? columnDefaultWidth;
315
+
316
+ if (!size && colFlex == undefined) {
317
+ size = colMinWidth;
318
+ }
319
+
320
+ return {
321
+ size,
322
+ flex: colFlex!,
323
+ minSize: colMinWidth,
324
+ maxSize: colMaxWidth,
325
+ };
326
+ }
327
+
328
+ const flexResult = computeFlex({
329
+ availableSize: Math.max(
330
+ bodySize.width -
331
+ (viewportReservedWidth ?? 0) -
332
+ // see #scrollbarverticaltag
333
+ (scrollbarWidth ?? getScrollbarWidth()),
334
+ 0,
335
+ ),
336
+
337
+ maxSize: columnMaxWidth,
338
+ minSize: columnMinWidth,
339
+ items: visibleColumnOrder.map(getColSize),
340
+ });
341
+
342
+ const { computedSizes, flexSizes, minSizes, maxSizes } = flexResult;
343
+
344
+ const computedPinnedStartColumns: InfiniteTableComputedColumn<T>[] = [];
345
+ const computedPinnedEndColumns: InfiniteTableComputedColumn<T>[] = [];
346
+ const computedUnpinnedColumns: InfiniteTableComputedColumn<T>[] = [];
347
+
348
+ const computedVisibleColumns: InfiniteTableComputedColumn<T>[] = [];
349
+ computedVisibleColumns.length = visibleColumnOrder.length;
350
+
351
+ const computedVisibleColumnsMap: Map<
352
+ string,
353
+ InfiniteTableComputedColumn<T>
354
+ > = new Map();
355
+
356
+ const computedColumnsMap: Map<
357
+ string,
358
+ InfiniteTableComputedColumn<T>
359
+ > = new Map();
360
+
361
+ let computedUnpinnedColumnsWidth = 0;
362
+ let computedPinnedStartColumnsWidth = 0;
363
+ let computedPinnedEndColumnsWidth = 0;
364
+ let prevPinned: InfiniteTableColumnPinnedValues | null = null;
365
+
366
+ const computedPinnedArray: InfiniteTableColumnPinnedValues[] = [];
367
+
368
+ let totalPinnedStartWidth = 0;
369
+ let totalUnpinnedWidth = 0;
370
+ let totalPinnedEndWidth = 0;
371
+
372
+ visibleColumnsArray.forEach((_c, i) => {
373
+ const id = visibleColumnOrder[i];
374
+ const computedWidth = computedSizes[i];
375
+
376
+ const pinned = (computedPinnedArray[i] = getComputedPinned(
377
+ id,
378
+ columnPinning,
379
+ ));
380
+ if (pinned === 'start') {
381
+ totalPinnedStartWidth += computedWidth;
382
+ } else if (pinned === 'end') {
383
+ totalPinnedEndWidth += computedWidth;
384
+ } else {
385
+ totalUnpinnedWidth += computedWidth;
386
+ }
387
+ });
388
+
389
+ const firstPinnedEndAbsoluteOffset = bodySize.width - totalPinnedEndWidth;
390
+
391
+ const groupColumns: InfiniteTableComputedColumn<T>[] = [];
392
+
393
+ const orderedColumns: Map<string, InfiniteTableColumn<T>> = new Map();
394
+ visibleColumnOrder.forEach((id, index) => {
395
+ const c = visibleColumnsArray[index];
396
+ orderedColumns.set(id, c);
397
+ });
398
+
399
+ const columnIdsInitialColumnOrder: string[] = [];
400
+
401
+ columns.forEach((c, key) => {
402
+ columnIdsInitialColumnOrder.push(key);
403
+ if (!orderedColumns.has(key)) {
404
+ orderedColumns.set(key, c);
405
+ }
406
+ });
407
+
408
+ const fieldsToColumn: Map<
409
+ keyof T,
410
+ InfiniteTableComputedColumn<T>
411
+ > = new Map();
412
+
413
+ // we need to loop over this in the visibility order
414
+ // as we calculate computedOffset based on previous item
415
+ // and also have a reference
416
+ orderedColumns.forEach((c, id) => {
417
+ let theComputedVisibleIndex = columnIdsToVisibleIndex.get(id);
418
+
419
+ if (theComputedVisibleIndex == undefined) {
420
+ theComputedVisibleIndex = -1;
421
+ }
422
+ const computedVisible = theComputedVisibleIndex != -1;
423
+
424
+ const nextColumnId = visibleColumnOrder[theComputedVisibleIndex + 1];
425
+ const colType = getColumnComputedType(c, columnTypes);
426
+
427
+ const computedVisibleIndex = theComputedVisibleIndex;
428
+
429
+ const sortingInfo = sortedMap[id as string]
430
+ ? sortedMap[id as string]
431
+ : c.field
432
+ ? sortedMap[c.field as string] ?? null
433
+ : null;
434
+
435
+ const computedSortInfo = sortingInfo?.sortInfo ?? null;
436
+ const computedSorted = !!computedSortInfo;
437
+ const computedSortedAsc = computedSorted && computedSortInfo!.dir === 1;
438
+ const computedSortedDesc = computedSorted && !computedSortedAsc;
439
+ const computedSortIndex = sortingInfo?.index ?? -1;
440
+
441
+ const colSizeForNonVisibleColumn: ColSizeOptions = computedVisible
442
+ ? {}
443
+ : getColSize(id);
444
+
445
+ const computedWidth = computedVisible
446
+ ? computedSizes[theComputedVisibleIndex]
447
+ : colSizeForNonVisibleColumn.size || 0;
448
+ const computedFlex = computedVisible
449
+ ? flexSizes[theComputedVisibleIndex] || null
450
+ : null;
451
+
452
+ const computedMinWidth = computedVisible
453
+ ? minSizes[theComputedVisibleIndex] || 0
454
+ : colSizeForNonVisibleColumn.minSize || 0;
455
+
456
+ const computedMaxWidth = computedVisible
457
+ ? maxSizes[theComputedVisibleIndex] || 10_000
458
+ : colSizeForNonVisibleColumn.maxSize || 10_000;
459
+
460
+ // const computedComp;
461
+
462
+ // const pinned = columnPinning.get(id);
463
+ const computedPinned = computedVisible
464
+ ? getComputedPinned(id, columnPinning)
465
+ : false;
466
+
467
+ const computedLast = computedVisible
468
+ ? theComputedVisibleIndex === visibleColumnOrder.length - 1
469
+ : false;
470
+ let computedVisibleIndexInCategory = computedVisibleIndex;
471
+ const computedPinningOffset = computedVisible
472
+ ? computedPinned === 'start'
473
+ ? computedPinnedStartColumnsWidth
474
+ : computedPinned === 'end'
475
+ ? computedPinnedEndColumnsWidth
476
+ : computedOffset - computedPinnedStartColumnsWidth
477
+ : 0;
478
+
479
+ if (computedPinned == 'start') {
480
+ computedVisibleIndexInCategory = computedVisible
481
+ ? computedVisibleIndex
482
+ : -1;
483
+ } else if (computedPinned === 'end') {
484
+ computedVisibleIndexInCategory = computedVisible
485
+ ? computedVisibleIndex -
486
+ (computedPinnedStartColumns.length + computedUnpinnedColumns.length)
487
+ : -1;
488
+ } else {
489
+ computedVisibleIndexInCategory = computedVisible
490
+ ? computedVisibleIndex - computedPinnedStartColumns.length
491
+ : -1;
492
+ }
493
+
494
+ const computedAbsoluteOffset = computedVisible
495
+ ? computedPinned === 'start' || computedPinned === false
496
+ ? computedOffset
497
+ : firstPinnedEndAbsoluteOffset + computedPinnedEndColumnsWidth
498
+ : -1;
499
+
500
+ const computedFirstInCategory = computedVisible
501
+ ? computedPinned !== prevPinned
502
+ : false;
503
+ const computedLastInCategory = computedVisible
504
+ ? computedLast ||
505
+ computedPinned !== getComputedPinned(nextColumnId, columnPinning)
506
+ : false;
507
+
508
+ const cssEllipsis =
509
+ c.cssEllipsis ?? colType.cssEllipsis ?? columnCssEllipsis;
510
+
511
+ const headerCssEllipsis =
512
+ c.headerCssEllipsis ??
513
+ colType.cssEllipsis ??
514
+ c.cssEllipsis ??
515
+ colType.headerCssEllipsis ??
516
+ columnHeaderCssEllipsis ??
517
+ cssEllipsis;
518
+
519
+ const computedFilterValue = computedVisible
520
+ ? filterValueRecord[id] || c.field
521
+ ? filterValueRecord[c.field as string] || null
522
+ : null
523
+ : null;
524
+
525
+ const computedFiltered = computedFilterValue != null;
526
+ const computedFilterable =
527
+ c.defaultFilterable ?? colType.defaultFilterable ?? true;
528
+
529
+ const computedDataType =
530
+ c.dataType ||
531
+ colType.dataType ||
532
+ (Array.isArray(c.type) ? c.type[0] : c.type) ||
533
+ 'string';
534
+ const computedSortType = c.sortType || colType.sortType || computedDataType;
535
+ const computedFilterType =
536
+ c.filterType || colType.filterType || computedDataType;
537
+
538
+ const field = c.field ?? colType.field;
539
+ const valueGetter = c.valueGetter ?? colType.valueGetter;
540
+
541
+ let sortableColumnOrType = c.sortable ?? colType.sortable;
542
+
543
+ if (
544
+ sortableColumnOrType == null &&
545
+ !(c as InfiniteTableGeneratedGroupColumn<T>).groupByField
546
+ ) {
547
+ //not explicitly set, so if no field or valueGetter defined, we'll make this unsortable
548
+ if (field == null && valueGetter == null) {
549
+ sortableColumnOrType = false;
550
+ }
551
+ }
552
+
553
+ let computedSortable = sortableColumnOrType ?? sortable ?? true;
554
+
555
+ const result: InfiniteTableComputedColumn<T> = {
556
+ colType,
557
+ align: colType.align,
558
+ computedVisible,
559
+ verticalAlign: colType.verticalAlign,
560
+ defaultHiddenWhenGroupedBy: colType.defaultHiddenWhenGroupedBy,
561
+ valueGetter,
562
+ valueFormatter: colType.valueFormatter,
563
+ renderValue: colType.renderValue,
564
+ render: colType.render,
565
+ style: colType.style,
566
+ renderMenuIcon: colType.renderMenuIcon,
567
+ renderSortIcon: colType.renderSortIcon,
568
+ renderSelectionCheckBox: colType.renderSelectionCheckBox,
569
+ renderHeaderSelectionCheckBox: colType.renderHeaderSelectionCheckBox,
570
+ headerStyle: colType.headerStyle,
571
+ headerClassName: colType.headerClassName,
572
+
573
+ columnGroup: colType.columnGroup,
574
+ field,
575
+ ...c,
576
+ components: {
577
+ ...colType.components,
578
+ ...c.components,
579
+ },
580
+ computedResizable:
581
+ c.resizable ?? colType.resizable ?? resizableColumns ?? true,
582
+ computedMinWidth,
583
+ computedMaxWidth,
584
+ computedFlex,
585
+ computedDataType,
586
+ computedSortType,
587
+ computedFilterType,
588
+ cssEllipsis,
589
+ headerCssEllipsis,
590
+ computedFilterValue,
591
+ computedFiltered,
592
+ computedFilterable,
593
+ computedWidth,
594
+ computedAbsoluteOffset,
595
+ computedPinningOffset,
596
+ computedVisibleIndexInCategory,
597
+ computedOffset,
598
+ computedSortable,
599
+ computedSortInfo,
600
+ computedSortIndex,
601
+ computedMultiSort: multiSort,
602
+ computedSorted,
603
+ computedSortedAsc,
604
+ computedSortedDesc,
605
+ computedVisibleIndex,
606
+ computedPinned,
607
+ computedDraggable: c.draggable ?? draggableColumns ?? true,
608
+ computedFirstInCategory,
609
+ computedLastInCategory,
610
+ computedFirst: theComputedVisibleIndex === 0,
611
+ computedLast,
612
+ toggleSort: () => {
613
+ const currentSortInfo = computedSortInfo;
614
+ let newColumnSortInfo: DataSourceSingleSortInfo<T> | null;
615
+
616
+ const field = (result.groupByField ? result.groupByField : c.field) as
617
+ | keyof T
618
+ | (keyof T)[];
619
+ if (!currentSortInfo) {
620
+ newColumnSortInfo = {
621
+ dir: 1,
622
+ id,
623
+ field,
624
+ type: computedSortType,
625
+ } as DataSourceSingleSortInfo<T>;
626
+ } else {
627
+ if (computedSortedDesc) {
628
+ newColumnSortInfo = null;
629
+ } else {
630
+ newColumnSortInfo = {
631
+ ...computedSortInfo,
632
+ dir: -1,
633
+ };
634
+ }
635
+ }
636
+
637
+ if (field && newColumnSortInfo && !newColumnSortInfo.field) {
638
+ newColumnSortInfo.field = field;
639
+ }
640
+ if (
641
+ c.valueGetter &&
642
+ newColumnSortInfo &&
643
+ !newColumnSortInfo.valueGetter
644
+ ) {
645
+ newColumnSortInfo.valueGetter = (data) =>
646
+ c.valueGetter!({ data, field: c.field });
647
+ }
648
+
649
+ let finalSortInfo = sortInfo ? [...sortInfo] : [];
650
+ if (multiSort) {
651
+ if (computedSortIndex === -1) {
652
+ // it should be added to the end
653
+ if (newColumnSortInfo) {
654
+ finalSortInfo.push(newColumnSortInfo);
655
+ }
656
+ } else {
657
+ // it's an existing sort - so should be updated
658
+ finalSortInfo = finalSortInfo
659
+ .map((info, index) => {
660
+ if (index === computedSortIndex) {
661
+ return newColumnSortInfo;
662
+ }
663
+ return info;
664
+ })
665
+ .filter((x) => x != null) as DataSourceSingleSortInfo<T>[];
666
+ }
667
+ } else {
668
+ finalSortInfo = newColumnSortInfo ? [newColumnSortInfo] : [];
669
+ }
670
+
671
+ setSortInfo(finalSortInfo);
672
+ },
673
+ id: id as string,
674
+ header: c.header ?? colType.header ?? c.name ?? c.field,
675
+ };
676
+
677
+ if (computedVisible) {
678
+ computedOffset += computedWidth;
679
+ computedVisibleColumnsMap.set(result.id, result);
680
+ computedVisibleColumns[theComputedVisibleIndex] = result;
681
+
682
+ if (computedPinned === 'start') {
683
+ computedPinnedStartColumns.push(result);
684
+ computedPinnedStartColumnsWidth += result.computedWidth;
685
+ }
686
+ if (computedPinned === 'end') {
687
+ computedPinnedEndColumns.push(result);
688
+ computedPinnedEndColumnsWidth += result.computedWidth;
689
+ }
690
+ if (!computedPinned) {
691
+ computedUnpinnedColumns.push(result);
692
+ computedUnpinnedColumnsWidth += result.computedWidth;
693
+ }
694
+
695
+ prevPinned = computedPinned;
696
+ }
697
+ if (result.groupByField) {
698
+ groupColumns.push(result);
699
+ }
700
+ computedColumnsMap.set(result.id, result);
701
+
702
+ if (
703
+ result.field &&
704
+ // for now, do not include group columns
705
+ !result.groupByField &&
706
+ !fieldsToColumn.has(result.field)
707
+ ) {
708
+ fieldsToColumn.set(result.field, result);
709
+ }
710
+ });
711
+
712
+ groupColumns.forEach((col) => {
713
+ col.computedSortable = isGroupColumnSortable(col, computedColumnsMap);
714
+ });
715
+
716
+ const computedColumnsMapInInitialOrder = new Map<
717
+ string,
718
+ InfiniteTableComputedColumn<T>
719
+ >();
720
+ columnIdsInitialColumnOrder.forEach((id) => {
721
+ const col = computedColumnsMap.get(id);
722
+ if (col) {
723
+ computedColumnsMapInInitialOrder.set(id, col);
724
+ }
725
+ });
726
+
727
+ computedColumnsMap.forEach((col) => {
728
+ if (!computedColumnsMapInInitialOrder.has(col.id)) {
729
+ computedColumnsMapInInitialOrder.set(col.id, col);
730
+ }
731
+ });
732
+
733
+ const computedPinnedStartWidth =
734
+ pinnedStartMaxWidth != null
735
+ ? Math.min(pinnedStartMaxWidth, computedPinnedStartColumnsWidth)
736
+ : computedPinnedStartColumnsWidth;
737
+ const computedPinnedEndWidth =
738
+ pinnedEndMaxWidth != null
739
+ ? Math.min(pinnedEndMaxWidth, computedPinnedEndColumnsWidth)
740
+ : computedPinnedEndColumnsWidth;
741
+
742
+ const result: GetComputedVisibleColumnsResult<T> = {
743
+ computedRemainingSpace:
744
+ bodySize.width -
745
+ (totalPinnedStartWidth + totalPinnedEndWidth + totalUnpinnedWidth),
746
+ computedPinnedStartColumnsWidth,
747
+ computedPinnedEndColumnsWidth,
748
+ computedUnpinnedColumnsWidth,
749
+ computedColumnOrder: normalizedColumnOrder,
750
+ computedPinnedStartColumns,
751
+ computedPinnedEndColumns,
752
+ computedUnpinnedOffset: computedPinnedStartColumnsWidth,
753
+ computedPinnedEndOffset:
754
+ computedPinnedStartColumnsWidth + computedUnpinnedColumnsWidth,
755
+ computedUnpinnedColumns,
756
+ computedVisibleColumns,
757
+
758
+ computedColumnsMap,
759
+ computedColumnsMapInInitialOrder,
760
+ computedVisibleColumnsMap,
761
+ computedPinnedEndWidth,
762
+ computedPinnedStartWidth,
763
+ renderSelectionCheckBox: computedVisibleColumns.reduce(
764
+ (bool: boolean, c: InfiniteTableComputedColumn<T>) => {
765
+ return bool || !!c.renderSelectionCheckBox;
766
+ },
767
+ false,
768
+ ),
769
+ fieldsToColumn,
770
+ };
771
+
772
+ return result;
773
+ };