@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,35 @@
1
+ export type ArrayElement<ArrayType extends readonly unknown[]> =
2
+ ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
3
+
4
+ export type MapOrRecord<K extends string, V> = Map<K, V> | Record<K, V>;
5
+
6
+ export type RequireOnlyOneProperty<T, Keys extends keyof T> = Pick<
7
+ T,
8
+ Exclude<keyof T, Keys>
9
+ > &
10
+ {
11
+ [K in Keys]-?: Required<Pick<T, K>> &
12
+ Partial<Record<Exclude<Keys, K>, undefined>>;
13
+ }[Keys];
14
+
15
+ export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
16
+ T,
17
+ Exclude<keyof T, Keys>
18
+ > &
19
+ {
20
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
21
+ }[Keys];
22
+
23
+ export type DiscriminatedUnion<A, B> =
24
+ | (A & {
25
+ [K in keyof B]?: undefined;
26
+ })
27
+ | (B & {
28
+ [K in keyof A]?: undefined;
29
+ });
30
+
31
+ export type AllPropertiesOrNone<DATA_TYPE> =
32
+ | DATA_TYPE
33
+ | { [KEY in keyof DATA_TYPE]?: never };
34
+
35
+ export type KeyOfNoSymbol<T> = Exclude<keyof T, Symbol>;
@@ -0,0 +1,96 @@
1
+ import type { InfiniteTableRowInfo } from '../../../utils/groupAndPivot';
2
+
3
+ import type { InfiniteTableAction } from './InfiniteTableAction';
4
+ import type { InfiniteTableActionType } from './InfiniteTableActionType';
5
+ import type {
6
+ InfiniteTableColumn,
7
+ InfiniteTableColumnComparer,
8
+ InfiniteTableComputedColumn,
9
+ InfiniteTableColumnRenderParam,
10
+ InfiniteTableColumnRenderValueParam,
11
+ InfiniteTableColumnRowspanParam,
12
+ InfiniteTablePivotColumn,
13
+ InfiniteTableColumnRenderFunctionForGroupRows,
14
+ InfiniteTableColumnRenderFunctionForNormalRows,
15
+ } from './InfiniteTableColumn';
16
+ import type { InfiniteTableComputedValues } from './InfiniteTableComputedValues';
17
+ import type { InfiniteTableContextValue } from './InfiniteTableContextValue';
18
+ import type {
19
+ InfiniteTableProps,
20
+ InfiniteTableApi,
21
+ InfiniteTablePropColumnOrder,
22
+ InfiniteTablePropColumnVisibility,
23
+ InfiniteTablePropColumnPinning,
24
+ InfiniteTableColumnAggregator,
25
+ InfiniteTableColumnGroup,
26
+ InfiniteTablePropGroupRenderStrategy,
27
+ InfiniteTablePropColumnGroups,
28
+ InfiniteTablePropRowStyle,
29
+ InfiniteTableRowStyleFn,
30
+ InfiniteTableRowClassNameFn,
31
+ InfiniteTableFilterEditorProps,
32
+ InfiniteTablePropFilterEditors,
33
+ InfiniteTablePropRowClassName,
34
+ InfiniteTablePropColumns,
35
+ InfiniteTableColumnsMap,
36
+ InfiniteTablePropComponents,
37
+ InfiniteTableGroupColumnFunction,
38
+ InfiniteTableGroupColumnGetterOptions,
39
+ InfiniteTablePropColumnSizing,
40
+ InfiniteTablePropColumnTypes,
41
+ InfiniteTableColumnSizingOptions,
42
+ Scrollbars,
43
+ InfiniteTableGroupColumnBase,
44
+ InfiniteTablePropGroupColumn,
45
+ InfiniteTablePropAutoSizeColumnsKey,
46
+ InfiniteTablePropHeaderOptions,
47
+ InfiniteTablePropKeyboardNavigation,
48
+ } from './InfiniteTableProps';
49
+ import type { InfiniteTableState } from './InfiniteTableState';
50
+
51
+ export type {
52
+ Scrollbars,
53
+ InfiniteTablePropHeaderOptions,
54
+ InfiniteTablePropAutoSizeColumnsKey,
55
+ InfiniteTableColumnAggregator,
56
+ InfiniteTableComputedValues,
57
+ InfiniteTableColumnRowspanParam,
58
+ InfiniteTablePivotColumn,
59
+ InfiniteTablePropColumns,
60
+ InfiniteTablePropGroupColumn,
61
+ InfiniteTableColumnsMap,
62
+ InfiniteTableRowInfo,
63
+ InfiniteTableGroupColumnFunction,
64
+ InfiniteTableGroupColumnBase,
65
+ InfiniteTablePropColumnOrder,
66
+ InfiniteTablePropComponents,
67
+ InfiniteTablePropColumnVisibility,
68
+ InfiniteTablePropColumnPinning,
69
+ InfiniteTableColumnGroup,
70
+ InfiniteTableColumn,
71
+ InfiniteTableColumnComparer,
72
+ InfiniteTableComputedColumn,
73
+ InfiniteTableColumnRenderParam,
74
+ InfiniteTableColumnRenderFunctionForGroupRows,
75
+ InfiniteTableColumnRenderFunctionForNormalRows,
76
+ InfiniteTableColumnRenderValueParam,
77
+ InfiniteTableContextValue,
78
+ InfiniteTablePropGroupRenderStrategy,
79
+ InfiniteTablePropColumnGroups,
80
+ InfiniteTablePropColumnSizing,
81
+ InfiniteTableColumnSizingOptions,
82
+ InfiniteTableState,
83
+ InfiniteTableAction,
84
+ InfiniteTableProps,
85
+ InfiniteTablePropKeyboardNavigation,
86
+ InfiniteTablePropColumnTypes,
87
+ InfiniteTableApi,
88
+ InfiniteTableActionType,
89
+ InfiniteTablePropRowStyle,
90
+ InfiniteTablePropRowClassName,
91
+ InfiniteTableRowStyleFn,
92
+ InfiniteTableRowClassNameFn,
93
+ InfiniteTableGroupColumnGetterOptions,
94
+ InfiniteTableFilterEditorProps,
95
+ InfiniteTablePropFilterEditors,
96
+ };
@@ -0,0 +1,179 @@
1
+ import {
2
+ CSSProperties,
3
+ globalStyle,
4
+ style,
5
+ styleVariants,
6
+ } from '@vanilla-extract/css';
7
+
8
+ import { ThemeVars } from './theme.css';
9
+
10
+ const borderBox: CSSProperties = {
11
+ boxSizing: 'border-box',
12
+ };
13
+ export const boxSizingBorderBox = style(borderBox);
14
+
15
+ globalStyle(`${boxSizingBorderBox}:before`, borderBox);
16
+ globalStyle(`${boxSizingBorderBox}:after`, borderBox);
17
+ globalStyle(`${boxSizingBorderBox} *`, borderBox);
18
+ globalStyle(`${boxSizingBorderBox} *:before`, borderBox);
19
+ globalStyle(`${boxSizingBorderBox} *:after`, borderBox);
20
+
21
+ export const position = styleVariants({
22
+ relative: { position: 'relative' },
23
+ absolute: { position: 'absolute' },
24
+ sticky: { position: 'sticky' },
25
+ fixed: { position: 'fixed' },
26
+ });
27
+
28
+ export const fill = styleVariants({
29
+ currentColor: { fill: 'currentColor' },
30
+ accentColor: { fill: ThemeVars.color.accent },
31
+ });
32
+
33
+ export const margin = styleVariants({
34
+ none: { margin: 0 },
35
+ });
36
+
37
+ export const stroke = styleVariants({
38
+ currentColor: { stroke: 'currentColor' },
39
+ accentColor: { stroke: ThemeVars.color.accent },
40
+ });
41
+
42
+ export const background = styleVariants({
43
+ inherit: { background: 'inherit' },
44
+ });
45
+
46
+ export const transformTranslateZero = style({
47
+ transform: 'translate3d(0,0,0)',
48
+ });
49
+
50
+ export const transform = styleVariants({
51
+ translateZero: { transform: 'translate3d(0,0,0)' },
52
+ rotate90: { transform: 'rotate(90deg)' },
53
+ rotate180: { transform: 'rotate(180deg)' },
54
+ });
55
+
56
+ export const cursor = styleVariants({
57
+ pointer: { cursor: 'pointer' },
58
+ default: { cursor: 'default' },
59
+ colResize: { cursor: 'col-resize' },
60
+ });
61
+
62
+ export const pointerEvents = styleVariants({
63
+ none: { pointerEvents: 'none' },
64
+ });
65
+
66
+ export const flex = styleVariants({
67
+ 1: { flex: 1 },
68
+ none: { flex: 'none' },
69
+ });
70
+ export const zIndex = styleVariants({
71
+ 1: { zIndex: 1 },
72
+ 10: { zIndex: 10 },
73
+ 100: { zIndex: 100 },
74
+ 1000: { zIndex: 1000 },
75
+ '1k': { zIndex: 1000 },
76
+ 10_000: { zIndex: 10_000 },
77
+ '10k': { zIndex: 10_000 },
78
+ 100_000: { zIndex: 100_000 },
79
+ '100k': { zIndex: 100_000 },
80
+ 1_000_000: { zIndex: 1_000_000 },
81
+ 10_000_000: { zIndex: 10_000_000 },
82
+ });
83
+
84
+ export const display = styleVariants({
85
+ flex: { display: 'flex' },
86
+ contents: { display: 'contents' },
87
+ none: { display: 'none' },
88
+ block: { display: 'block' },
89
+ grid: { display: 'grid' },
90
+ inlineBlock: { display: 'inline-block' },
91
+ inlineFlex: { display: 'inline-flex' },
92
+ inlineGrid: { display: 'inline-grid' },
93
+ });
94
+ export const userSelect = styleVariants({
95
+ none: { userSelect: 'none' },
96
+ });
97
+
98
+ export const height = styleVariants({
99
+ '100%': { height: '100%' },
100
+ '0': { height: '0' },
101
+ });
102
+ export const width = styleVariants({
103
+ '100%': { width: '100%' },
104
+ '0': { width: '0' },
105
+ });
106
+ export const top = styleVariants({
107
+ '100%': { top: '100%' },
108
+ '0': { top: '0' },
109
+ });
110
+
111
+ export const left = styleVariants({
112
+ '100%': { left: '100%' },
113
+ '0': { left: '0' },
114
+ auto: { left: 'auto' },
115
+ });
116
+ export const bottom = styleVariants({
117
+ '100%': { bottom: '100%' },
118
+ '0': { bottom: '0' },
119
+ });
120
+ export const right = styleVariants({
121
+ '100%': { right: '100%' },
122
+ '0': { right: '0' },
123
+ auto: { right: 'auto' },
124
+ });
125
+ export const flexFlow = styleVariants({
126
+ column: { flexFlow: 'column' },
127
+ columnReverse: { flexFlow: 'column-reverse' },
128
+ row: { flexFlow: 'row' },
129
+ rowReverse: { flexFlow: 'row-reverse' },
130
+ });
131
+
132
+ export const alignItems = styleVariants({
133
+ center: { alignItems: 'center' },
134
+ stretch: { alignItems: 'stretch' },
135
+ });
136
+
137
+ export const justifyContent = styleVariants({
138
+ center: { justifyContent: 'center' },
139
+ spaceBetween: { justifyContent: 'space-between' },
140
+ spaceAround: { justifyContent: 'space-around' },
141
+ start: { justifyContent: 'flex-start' },
142
+ end: { justifyContent: 'flex-end' },
143
+ });
144
+
145
+ export const overflow = styleVariants({
146
+ hidden: { overflow: 'hidden' },
147
+ auto: { overflow: 'auto' },
148
+ visible: { overflow: 'visible' },
149
+ });
150
+
151
+ export const visibility = styleVariants({
152
+ visible: { visibility: 'visible' },
153
+ hidden: { visibility: 'hidden' },
154
+ });
155
+
156
+ export const willChange = styleVariants({
157
+ transform: { willChange: 'transform' },
158
+ });
159
+
160
+ export const whiteSpace = styleVariants({
161
+ nowrap: { whiteSpace: 'nowrap' },
162
+ });
163
+ export const textOverflow = styleVariants({
164
+ ellipsis: { textOverflow: 'ellipsis' },
165
+ });
166
+
167
+ export const cssEllipsisClassName = style([
168
+ whiteSpace.nowrap,
169
+ textOverflow.ellipsis,
170
+ overflow.hidden,
171
+ ]);
172
+
173
+ export const absoluteCover = style([
174
+ position.absolute,
175
+ top[0],
176
+ left[0],
177
+ right[0],
178
+ bottom[0],
179
+ ]);
@@ -0,0 +1,111 @@
1
+ import { RowSelectionState } from '../../DataSource/RowSelectionState';
2
+
3
+ export type MultiRowSelectorOptions = {
4
+ getIdForIndex: (index: number) => string | number;
5
+ };
6
+
7
+ function ensureMinMax(start: number, end: number) {
8
+ return start < end ? [start, end] : [end, start];
9
+ }
10
+
11
+ export class MultiRowSelector {
12
+ getIdForIndex: MultiRowSelectorOptions['getIdForIndex'];
13
+
14
+ multiSelectStartIndex: number = 0;
15
+ multiSelectEndIndex?: number;
16
+
17
+ _rowSelectionState!: RowSelectionState;
18
+
19
+ constructor(options: MultiRowSelectorOptions) {
20
+ this.getIdForIndex = options.getIdForIndex;
21
+ }
22
+
23
+ set rowSelectionState(rowSelectionState: RowSelectionState) {
24
+ this._rowSelectionState = rowSelectionState;
25
+ }
26
+
27
+ get rowSelectionState() {
28
+ return this._rowSelectionState;
29
+ }
30
+
31
+ private selectRange(startIndex: number, endIndex: number) {
32
+ const [start, end] = ensureMinMax(startIndex, endIndex);
33
+
34
+ const rowSelectionState = this.rowSelectionState;
35
+
36
+ for (let i = start; i <= end; i++) {
37
+ const id = this.getIdForIndex(i);
38
+
39
+ rowSelectionState.selectRow(id);
40
+ }
41
+ }
42
+ private deselectRange(startIndex: number, endIndex: number) {
43
+ const [start, end] = ensureMinMax(startIndex, endIndex);
44
+
45
+ const rowSelectionState = this.rowSelectionState;
46
+
47
+ for (let i = start; i <= end; i++) {
48
+ const id = this.getIdForIndex(i);
49
+
50
+ rowSelectionState.deselectRow(id);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * This is the single click, without any modifier
56
+ */
57
+ resetClick(index: number) {
58
+ this.rowSelectionState.deselectAll();
59
+ const id = this.getIdForIndex(index);
60
+
61
+ this.rowSelectionState.selectRow(id);
62
+
63
+ this.multiSelectStartIndex = index;
64
+ this.multiSelectEndIndex = undefined;
65
+ }
66
+
67
+ /**
68
+ * This is the click with ctrl/cmd key pressed
69
+ * @param index
70
+ */
71
+ singleAddClick(index: number) {
72
+ const id = this.getIdForIndex(index);
73
+
74
+ if (this.rowSelectionState.isRowSelected(id)) {
75
+ this.rowSelectionState.deselectRow(id);
76
+ if (this.rowSelectionState.isRowSelected(this.getIdForIndex(index + 1))) {
77
+ this.multiSelectStartIndex = index + 1;
78
+ } else {
79
+ // this.lastResetClickIndex = index;
80
+ }
81
+ // this.lastMultiAddClickIndex = undefined;
82
+ } else {
83
+ this.rowSelectionState.selectRow(id);
84
+ this.multiSelectStartIndex = index;
85
+
86
+ let multiSelectEndIndex = undefined;
87
+
88
+ // we have to go to previous rows and find the last row that we meet that is selected
89
+ // without going over any deselected rows and that's the selection end
90
+ for (let i = index - 1; i >= 0; i--) {
91
+ const id = this.getIdForIndex(i);
92
+ if (this.rowSelectionState.isRowSelected(id)) {
93
+ multiSelectEndIndex = i;
94
+ } else {
95
+ break;
96
+ }
97
+ }
98
+ this.multiSelectEndIndex = multiSelectEndIndex;
99
+ }
100
+ }
101
+
102
+ multiSelectClick(index: number) {
103
+ if (this.multiSelectEndIndex != null) {
104
+ this.deselectRange(this.multiSelectStartIndex, this.multiSelectEndIndex);
105
+ }
106
+
107
+ this.selectRange(this.multiSelectStartIndex, index);
108
+
109
+ this.multiSelectEndIndex = index;
110
+ }
111
+ }
@@ -0,0 +1,52 @@
1
+ import * as React from 'react';
2
+ import { InfiniteTableHeaderCellContext } from '../components/InfiniteTableHeader/InfiniteTableHeaderCell';
3
+
4
+ import { InfiniteTableColumnCellContext } from '../components/InfiniteTableRow/InfiniteTableColumnCell';
5
+ import {
6
+ InfiniteTableColumnCellContextType,
7
+ InfiniteTableHeaderCellContextType,
8
+ } from '../types/InfiniteTableColumn';
9
+ import {
10
+ RenderHookComponent,
11
+ RenderHookComponentProps,
12
+ } from '../../RenderHookComponent';
13
+
14
+ export function RenderCellHookComponent<T, RENDER_FN extends Function>(
15
+ props: RenderHookComponentProps<
16
+ RENDER_FN,
17
+ InfiniteTableColumnCellContextType<T>
18
+ >,
19
+ ) {
20
+ const ContextProvider =
21
+ InfiniteTableColumnCellContext.Provider as React.Provider<
22
+ InfiniteTableColumnCellContextType<T>
23
+ >;
24
+ return (
25
+ <ContextProvider value={props.renderParam}>
26
+ <RenderHookComponent
27
+ render={props.render}
28
+ renderParam={props.renderParam}
29
+ />
30
+ </ContextProvider>
31
+ );
32
+ }
33
+
34
+ export function RenderHeaderCellHookComponent<T, RENDER_FN extends Function>(
35
+ props: RenderHookComponentProps<
36
+ RENDER_FN,
37
+ InfiniteTableHeaderCellContextType<T>
38
+ >,
39
+ ) {
40
+ const ContextProvider =
41
+ InfiniteTableHeaderCellContext.Provider as React.Provider<
42
+ InfiniteTableHeaderCellContextType<T>
43
+ >;
44
+ return (
45
+ <ContextProvider value={props.renderParam}>
46
+ <RenderHookComponent
47
+ render={props.render}
48
+ renderParam={props.renderParam}
49
+ />
50
+ </ContextProvider>
51
+ );
52
+ }
@@ -0,0 +1,33 @@
1
+ import {
2
+ InfiniteTablePropColumnOrderNormalized,
3
+ InfiniteTablePropColumnPinning,
4
+ } from '../types/InfiniteTableProps';
5
+
6
+ const order = ['start', undefined, 'end'];
7
+ export const adjustColumnOrderForPinning = (
8
+ columnOrder: InfiniteTablePropColumnOrderNormalized,
9
+ columnPinning: InfiniteTablePropColumnPinning,
10
+ ) => {
11
+ if (columnPinning && Object.keys(columnPinning).length > 0) {
12
+ // make sure pinned columns are coming first
13
+ columnOrder.sort((colId1: string, colId2: string) => {
14
+ let p1 = columnPinning[colId1];
15
+ let p2 = columnPinning[colId2];
16
+
17
+ if (p1 === true) {
18
+ p1 = 'start';
19
+ }
20
+
21
+ if (p2 === true) {
22
+ p2 = 'start';
23
+ }
24
+
25
+ if (p1 == p2) {
26
+ return 0;
27
+ }
28
+
29
+ return order.indexOf(p1) - order.indexOf(p2);
30
+ });
31
+ }
32
+ return columnOrder;
33
+ };
@@ -0,0 +1,29 @@
1
+ export function assignFiltered(
2
+ filterFn: (value: any, key: string) => boolean,
3
+ target: any,
4
+ ...rest: any[]
5
+ ) {
6
+ const result = target;
7
+
8
+ rest.forEach((obj) => {
9
+ for (const key in obj) {
10
+ if (obj.hasOwnProperty(key) && filterFn(obj[key], key)) {
11
+ result[key] = obj[key];
12
+ }
13
+ }
14
+ });
15
+
16
+ return result;
17
+ }
18
+
19
+ export function assignNonNull(target: any, ...rest: any[]) {
20
+ return assignFiltered((value) => value != null, target, ...rest);
21
+ }
22
+
23
+ export function assignExcept(
24
+ exceptKeys: Record<string, boolean>,
25
+ target: any,
26
+ ...rest: any[]
27
+ ) {
28
+ return assignFiltered((_value, key) => !(key in exceptKeys), target, ...rest);
29
+ }
@@ -0,0 +1,108 @@
1
+ import * as React from 'react';
2
+ import { MenuItemObject, MenuProps } from '../../Menu/MenuProps';
3
+ import { InfiniteCheckBox } from '../components/CheckBox';
4
+ import {
5
+ InfiniteTableApi,
6
+ InfiniteTableComputedColumn,
7
+ InfiniteTableComputedValues,
8
+ InfiniteTableState,
9
+ } from '../types';
10
+ import { InfiniteTableActions } from '../types/InfiniteTableState';
11
+
12
+ export function defaultGetColumContextMenuItems<T>(params: {
13
+ column: InfiniteTableComputedColumn<T>;
14
+ api: InfiniteTableApi<T>;
15
+ getState: () => InfiniteTableState<T>;
16
+ getComputed: () => InfiniteTableComputedValues<T>;
17
+ actions: InfiniteTableActions<T>;
18
+ }): MenuProps['items'] {
19
+ const { column, getComputed, api } = params;
20
+
21
+ return [
22
+ {
23
+ key: 'sort-asc',
24
+ label: 'Sort Ascending',
25
+ disabled: column.computedSortedAsc,
26
+ onAction: () => {
27
+ api.setSortingForColumn(column.id, 1);
28
+ },
29
+ },
30
+ {
31
+ key: 'sort-desc',
32
+ label: 'Sort Descending',
33
+ disabled: column.computedSortedDesc,
34
+ onAction: () => {
35
+ api.setSortingForColumn(column.id, -1);
36
+ },
37
+ },
38
+ {
39
+ key: 'sort-none',
40
+ label: 'Unsort',
41
+ disabled: !column.computedSorted,
42
+ onAction: () => {
43
+ api.setSortingForColumn(column.id, null);
44
+ },
45
+ },
46
+ '-',
47
+ {
48
+ key: 'pin-start',
49
+ label: 'Pin to start',
50
+ disabled: column.computedPinned === 'start',
51
+ onAction: () => {
52
+ api.setPinningForColumn(column.id, 'start');
53
+ },
54
+ },
55
+ // {
56
+ // key: 'pin-end',
57
+ // label: 'Pin to end',
58
+ // disabled: column.computedPinned === 'end',
59
+ // onAction: () => {},
60
+ // },
61
+ {
62
+ key: 'unpin',
63
+ label: 'Unpin',
64
+ disabled: !column.computedPinned,
65
+ onAction: () => {
66
+ api.setPinningForColumn(column.id, false);
67
+ },
68
+ },
69
+ '-',
70
+ {
71
+ key: 'columns',
72
+ label: 'Columns',
73
+ menu: () => {
74
+ const colItems: MenuItemObject[] = [];
75
+
76
+ getComputed().computedColumnsMapInInitialOrder.forEach((col, id) => {
77
+ colItems.push({
78
+ key: id,
79
+ label: col.name || id || '',
80
+
81
+ check: (
82
+ <InfiniteCheckBox
83
+ key={col.id}
84
+ disabled={
85
+ col.computedVisible && api.getVisibleColumnsCount() === 1
86
+ }
87
+ checked={col.computedVisible}
88
+ onChange={(checked) => {
89
+ api.setVisibilityForColumn(col.id, !!checked);
90
+ }}
91
+ ></InfiniteCheckBox>
92
+ ),
93
+ });
94
+ });
95
+
96
+ return {
97
+ columns: [
98
+ {
99
+ name: 'check',
100
+ },
101
+ { name: 'label' },
102
+ ],
103
+ items: colItems,
104
+ };
105
+ },
106
+ },
107
+ ];
108
+ }
@@ -0,0 +1,33 @@
1
+ import type { InfiniteTableColumn } from '../types';
2
+ import type {
3
+ InfiniteTableColumnType,
4
+ InfiniteTablePropColumnTypes,
5
+ } from '../types/InfiniteTableProps';
6
+
7
+ const emptyType: InfiniteTableColumnType<any> = Object.freeze({
8
+ filterType: 'string',
9
+ });
10
+
11
+ export function getColumnComputedType<T>(
12
+ column: InfiniteTableColumn<T>,
13
+ columnTypes: InfiniteTablePropColumnTypes<T>,
14
+ ): InfiniteTableColumnType<T> {
15
+ const defaultType: InfiniteTableColumnType<T> =
16
+ columnTypes['default'] || emptyType;
17
+
18
+ if (column.type === undefined) {
19
+ return defaultType;
20
+ }
21
+ if (column.type === null) {
22
+ return emptyType;
23
+ }
24
+ if (typeof column.type === 'string') {
25
+ const type = columnTypes[column.type] || emptyType;
26
+
27
+ return type;
28
+ }
29
+ return column.type.reduce(
30
+ (acc, columnType) => Object.assign(acc, columnTypes[columnType]),
31
+ {} as InfiniteTableColumnType<T>,
32
+ );
33
+ }