@infinite-table/infinite-react 0.5.0 → 0.5.2

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/README.md +104 -0
  2. package/index.css +896 -0
  3. package/index.d.ts +2264 -0
  4. package/index.esm.css +896 -0
  5. package/index.esm.js +15404 -0
  6. package/index.js +15240 -0
  7. package/package.json +9 -94
  8. package/.vscode/settings.json +0 -3
  9. package/API.md +0 -0
  10. package/build/buildPackageJson.js +0 -43
  11. package/build/scripts/test.js +0 -37
  12. package/bundler.config.js +0 -25
  13. package/globals.d.ts +0 -7
  14. package/rollup.config.js +0 -15
  15. package/run-build-deepmap.js +0 -47
  16. package/run-build.js +0 -45
  17. package/run-dts-concat.js +0 -21
  18. package/src/components/CSSVariableWatch.tsx +0 -82
  19. package/src/components/DataSource/BooleanCollectionState.ts +0 -214
  20. package/src/components/DataSource/BooleanDeepCollectionState.ts +0 -208
  21. package/src/components/DataSource/DataSourceContext.ts +0 -20
  22. package/src/components/DataSource/GroupRowsState.ts +0 -74
  23. package/src/components/DataSource/Indexer.ts +0 -27
  24. package/src/components/DataSource/RowSelectionState.ts +0 -763
  25. package/src/components/DataSource/defaultFilterTypes.ts +0 -64
  26. package/src/components/DataSource/index.tsx +0 -108
  27. package/src/components/DataSource/privateHooks/getChangeDetect.ts +0 -7
  28. package/src/components/DataSource/privateHooks/useLoadData.ts +0 -783
  29. package/src/components/DataSource/publicHooks/useDataSource.ts +0 -19
  30. package/src/components/DataSource/publicHooks/useDataSourceActions.ts +0 -14
  31. package/src/components/DataSource/state/getInitialState.ts +0 -494
  32. package/src/components/DataSource/state/normalizeSortInfo.ts +0 -35
  33. package/src/components/DataSource/state/reducer.ts +0 -466
  34. package/src/components/DataSource/state/rowInfoStatus.ts +0 -27
  35. package/src/components/DataSource/types.ts +0 -548
  36. package/src/components/HeadlessTable/HeadlessTableWithPinnedContainers.tsx +0 -142
  37. package/src/components/HeadlessTable/MappedCells.ts +0 -251
  38. package/src/components/HeadlessTable/RawTable.tsx +0 -98
  39. package/src/components/HeadlessTable/ReactHeadlessTableRenderer.tsx +0 -1516
  40. package/src/components/HeadlessTable/index.tsx +0 -234
  41. package/src/components/InfiniteTable/InfiniteCls.css.ts +0 -164
  42. package/src/components/InfiniteTable/InfiniteTableContext.ts +0 -16
  43. package/src/components/InfiniteTable/api/getImperativeApi.ts +0 -391
  44. package/src/components/InfiniteTable/api/getSelectionApi.ts +0 -364
  45. package/src/components/InfiniteTable/api/type.ts +0 -11
  46. package/src/components/InfiniteTable/components/ActiveCellIndicator.css.ts +0 -51
  47. package/src/components/InfiniteTable/components/ActiveCellIndicator.tsx +0 -116
  48. package/src/components/InfiniteTable/components/ActiveRowIndicator.css.ts +0 -56
  49. package/src/components/InfiniteTable/components/ActiveRowIndicator.tsx +0 -94
  50. package/src/components/InfiniteTable/components/CheckBox.css.ts +0 -13
  51. package/src/components/InfiniteTable/components/CheckBox.tsx +0 -96
  52. package/src/components/InfiniteTable/components/FilterEditors.tsx +0 -52
  53. package/src/components/InfiniteTable/components/InfiniteTableBody/InfiniteTableBody.tsx +0 -27
  54. package/src/components/InfiniteTable/components/InfiniteTableBody/index.tsx +0 -1
  55. package/src/components/InfiniteTable/components/InfiniteTableFooter/InfiniteTableFooter.tsx +0 -31
  56. package/src/components/InfiniteTable/components/InfiniteTableFooter/index.tsx +0 -1
  57. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableColumnHeaderFilter.tsx +0 -102
  58. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeader.tsx +0 -163
  59. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderCell.tsx +0 -574
  60. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderGroup.tsx +0 -79
  61. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderTypes.tsx +0 -25
  62. package/src/components/InfiniteTable/components/InfiniteTableHeader/InfiniteTableHeaderWrapper.tsx +0 -185
  63. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/GroupResizeHandle.tsx +0 -159
  64. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/ResizeHandle.css.ts +0 -124
  65. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/columnResizer.ts +0 -166
  66. package/src/components/InfiniteTable/components/InfiniteTableHeader/ResizeHandle/index.tsx +0 -146
  67. package/src/components/InfiniteTable/components/InfiniteTableHeader/buildColumnAndGroupTree.ts +0 -240
  68. package/src/components/InfiniteTable/components/InfiniteTableHeader/header.css.ts +0 -358
  69. package/src/components/InfiniteTable/components/InfiniteTableHeader/index.tsx +0 -1
  70. package/src/components/InfiniteTable/components/InfiniteTableHeader/useColumnGroupResizeHandle.tsx +0 -114
  71. package/src/components/InfiniteTable/components/InfiniteTableHeader/useColumnResizeHandle.tsx +0 -146
  72. package/src/components/InfiniteTable/components/InfiniteTableLicenseFooter/footer.css.ts +0 -7
  73. package/src/components/InfiniteTable/components/InfiniteTableLicenseFooter/index.tsx +0 -110
  74. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCell.tsx +0 -120
  75. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableCellTypes.ts +0 -74
  76. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableColumnCell.tsx +0 -457
  77. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRow.tsx +0 -107
  78. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowClassName.ts +0 -6
  79. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowTypes.ts +0 -32
  80. package/src/components/InfiniteTable/components/InfiniteTableRow/InfiniteTableRowUnvirtualized.tsx +0 -75
  81. package/src/components/InfiniteTable/components/InfiniteTableRow/columnRendering.tsx +0 -263
  82. package/src/components/InfiniteTable/components/InfiniteTableRow/index.tsx +0 -1
  83. package/src/components/InfiniteTable/components/InfiniteTableRow/row.css.ts +0 -74
  84. package/src/components/InfiniteTable/components/InfiniteTableRow/useRowDOMProps.ts +0 -199
  85. package/src/components/InfiniteTable/components/LoadMask.css.ts +0 -34
  86. package/src/components/InfiniteTable/components/LoadMask.tsx +0 -27
  87. package/src/components/InfiniteTable/components/ScrollbarPlaceholder.tsx +0 -56
  88. package/src/components/InfiniteTable/components/cell.css.ts +0 -192
  89. package/src/components/InfiniteTable/components/icons/ArrowDown.tsx +0 -14
  90. package/src/components/InfiniteTable/components/icons/ArrowUp.tsx +0 -14
  91. package/src/components/InfiniteTable/components/icons/ExpanderIcon.css.ts +0 -31
  92. package/src/components/InfiniteTable/components/icons/ExpanderIcon.tsx +0 -63
  93. package/src/components/InfiniteTable/components/icons/Icon.tsx +0 -18
  94. package/src/components/InfiniteTable/components/icons/InfiniteTableIconClassName.ts +0 -1
  95. package/src/components/InfiniteTable/components/icons/LoadingIcon.css.ts +0 -8
  96. package/src/components/InfiniteTable/components/icons/LoadingIcon.tsx +0 -45
  97. package/src/components/InfiniteTable/components/icons/MenuIcon.tsx +0 -50
  98. package/src/components/InfiniteTable/components/icons/SortIcon.tsx +0 -113
  99. package/src/components/InfiniteTable/eventHandlers/eventHandlerTypes.ts +0 -57
  100. package/src/components/InfiniteTable/eventHandlers/index.ts +0 -95
  101. package/src/components/InfiniteTable/eventHandlers/keyboardNavigation.ts +0 -232
  102. package/src/components/InfiniteTable/eventHandlers/keyboardSelection.ts +0 -110
  103. package/src/components/InfiniteTable/eventHandlers/onCellClick.ts +0 -94
  104. package/src/components/InfiniteTable/eventHandlers/onKeyDown.ts +0 -25
  105. package/src/components/InfiniteTable/hooks/adjustColumnOrderForAllColumns.ts +0 -70
  106. package/src/components/InfiniteTable/hooks/reorderColumnsOnDrag.ts +0 -476
  107. package/src/components/InfiniteTable/hooks/useAutoSizeColumns.ts +0 -206
  108. package/src/components/InfiniteTable/hooks/useCellClassName.ts +0 -80
  109. package/src/components/InfiniteTable/hooks/useCellRendering.tsx +0 -217
  110. package/src/components/InfiniteTable/hooks/useColumnGroups.ts +0 -71
  111. package/src/components/InfiniteTable/hooks/useColumnMenu.ts +0 -72
  112. package/src/components/InfiniteTable/hooks/useColumnPointerEvents.ts +0 -258
  113. package/src/components/InfiniteTable/hooks/useColumnRowspan.ts +0 -43
  114. package/src/components/InfiniteTable/hooks/useColumnSizeFn.ts +0 -24
  115. package/src/components/InfiniteTable/hooks/useColumnsWhen.ts +0 -582
  116. package/src/components/InfiniteTable/hooks/useComputed.ts +0 -186
  117. package/src/components/InfiniteTable/hooks/useComputedVisibleColumns.ts +0 -219
  118. package/src/components/InfiniteTable/hooks/useDOMProps.ts +0 -306
  119. package/src/components/InfiniteTable/hooks/useEffectWithRaf.ts +0 -47
  120. package/src/components/InfiniteTable/hooks/useInfiniteTable.ts +0 -10
  121. package/src/components/InfiniteTable/hooks/useInfiniteTableState.ts +0 -11
  122. package/src/components/InfiniteTable/hooks/useInternalProps.ts +0 -8
  123. package/src/components/InfiniteTable/hooks/useLicense/LicenseDetails.ts +0 -13
  124. package/src/components/InfiniteTable/hooks/useLicense/crc32.ts +0 -56
  125. package/src/components/InfiniteTable/hooks/useLicense/decode.ts +0 -147
  126. package/src/components/InfiniteTable/hooks/useLicense/useLicense.ts +0 -39
  127. package/src/components/InfiniteTable/hooks/useRerenderOnKeyChange.ts +0 -21
  128. package/src/components/InfiniteTable/hooks/useRowHover.ts +0 -18
  129. package/src/components/InfiniteTable/hooks/useScrollToActiveCell.ts +0 -48
  130. package/src/components/InfiniteTable/hooks/useScrollToActiveRow.ts +0 -44
  131. package/src/components/InfiniteTable/hooks/useScrollbars.ts +0 -51
  132. package/src/components/InfiniteTable/hooks/useToggleGroupRow.ts +0 -56
  133. package/src/components/InfiniteTable/hooks/useUnpinnedRendering.tsx +0 -165
  134. package/src/components/InfiniteTable/hooks/useYourBrain.ts +0 -55
  135. package/src/components/InfiniteTable/index.tsx +0 -352
  136. package/src/components/InfiniteTable/internalProps.ts +0 -4
  137. package/src/components/InfiniteTable/state/computeColumnGroupsDepths.ts +0 -29
  138. package/src/components/InfiniteTable/state/getColumnVisibilityForHideEmptyGroupColumns.ts +0 -127
  139. package/src/components/InfiniteTable/state/getInitialState.ts +0 -375
  140. package/src/components/InfiniteTable/theme.css.ts +0 -556
  141. package/src/components/InfiniteTable/types/InfiniteTableAction.ts +0 -6
  142. package/src/components/InfiniteTable/types/InfiniteTableActionType.ts +0 -12
  143. package/src/components/InfiniteTable/types/InfiniteTableColumn.ts +0 -478
  144. package/src/components/InfiniteTable/types/InfiniteTableComputedValues.ts +0 -43
  145. package/src/components/InfiniteTable/types/InfiniteTableContextValue.ts +0 -12
  146. package/src/components/InfiniteTable/types/InfiniteTableInternalProps.ts +0 -3
  147. package/src/components/InfiniteTable/types/InfiniteTableProps.ts +0 -511
  148. package/src/components/InfiniteTable/types/InfiniteTableState.ts +0 -195
  149. package/src/components/InfiniteTable/types/Utility.ts +0 -35
  150. package/src/components/InfiniteTable/types/index.ts +0 -96
  151. package/src/components/InfiniteTable/utilities.css.ts +0 -179
  152. package/src/components/InfiniteTable/utils/MultiRowSelector.ts +0 -111
  153. package/src/components/InfiniteTable/utils/RenderHookComponentForInfinite.tsx +0 -52
  154. package/src/components/InfiniteTable/utils/adjustColumnOrderForPinning.ts +0 -33
  155. package/src/components/InfiniteTable/utils/assignFiltered.ts +0 -29
  156. package/src/components/InfiniteTable/utils/defaultGetColumContextMenuItems.tsx +0 -108
  157. package/src/components/InfiniteTable/utils/getColumnComputedType.ts +0 -33
  158. package/src/components/InfiniteTable/utils/getColumnForGroupBy.tsx +0 -313
  159. package/src/components/InfiniteTable/utils/getComputedVisibleColumns.ts +0 -773
  160. package/src/components/InfiniteTable/utils/getContextMenuForColumn.tsx +0 -72
  161. package/src/components/InfiniteTable/utils/infiniteDOMUtils.ts +0 -189
  162. package/src/components/InfiniteTable/utils/mapToObject.ts +0 -20
  163. package/src/components/InfiniteTable/utils/moveXatY.ts +0 -25
  164. package/src/components/InfiniteTable/utils/objectValuesExcept.ts +0 -9
  165. package/src/components/InfiniteTable/utils/progressiveSpeedScroller.ts +0 -158
  166. package/src/components/InfiniteTable/utils/rafFn.ts +0 -13
  167. package/src/components/InfiniteTable/utils/toCSSVarName.ts +0 -1
  168. package/src/components/InfiniteTable/utils/toMap.ts +0 -24
  169. package/src/components/Menu/Menu.tsx +0 -750
  170. package/src/components/Menu/MenuCls.css.ts +0 -139
  171. package/src/components/Menu/MenuContext.ts +0 -10
  172. package/src/components/Menu/MenuContextValue.ts +0 -15
  173. package/src/components/Menu/MenuProps.ts +0 -98
  174. package/src/components/Menu/MenuState.ts +0 -56
  175. package/src/components/Menu/MenuTriangleContext.ts +0 -352
  176. package/src/components/Menu/childrenToRuntimeItems.tsx +0 -103
  177. package/src/components/Menu/getMenuState.tsx +0 -119
  178. package/src/components/Menu/index.tsx +0 -88
  179. package/src/components/Menu/propToIdentifyMenu.ts +0 -1
  180. package/src/components/RawList/AvoidReactDiff.tsx +0 -48
  181. package/src/components/RawList/MappedItems.ts +0 -143
  182. package/src/components/RawList/ReactVirtualRenderer.tsx +0 -307
  183. package/src/components/RawList/index.tsx +0 -42
  184. package/src/components/RawList/types.ts +0 -23
  185. package/src/components/RawList/useVirtualRenderer.ts +0 -36
  186. package/src/components/RenderHookComponent.tsx +0 -10
  187. package/src/components/ResizeObserver/index.tsx +0 -170
  188. package/src/components/VirtualBrain/MatrixBrain.ts +0 -1621
  189. package/src/components/VirtualBrain/ScrollListener.ts +0 -39
  190. package/src/components/VirtualBrain/index.ts +0 -664
  191. package/src/components/VirtualList/ColumnListWithExternalScrolling.tsx +0 -78
  192. package/src/components/VirtualList/InfiniteListRootClassName.ts +0 -1
  193. package/src/components/VirtualList/RowListWithExternalScrolling.tsx +0 -120
  194. package/src/components/VirtualList/SpacePlaceholder.tsx +0 -32
  195. package/src/components/VirtualList/VirtualList.css.ts +0 -29
  196. package/src/components/VirtualList/VirtualList.tsx +0 -141
  197. package/src/components/VirtualList/VirtualRowList.tsx +0 -34
  198. package/src/components/VirtualList/types.ts +0 -56
  199. package/src/components/VirtualList/useCorrectHeightForRowElements.ts +0 -14
  200. package/src/components/VirtualScrollContainer/VirtualScrollContainer.css.ts +0 -51
  201. package/src/components/VirtualScrollContainer/getScrollableClassName.ts +0 -30
  202. package/src/components/VirtualScrollContainer/index.tsx +0 -63
  203. package/src/components/flexbox/index.ts +0 -562
  204. package/src/components/hooks/useComponentState/index.tsx +0 -562
  205. package/src/components/hooks/useComponentState/types.ts +0 -32
  206. package/src/components/hooks/useEffectOnceWithProperUnmount.ts +0 -33
  207. package/src/components/hooks/useEffectWithChanges.ts +0 -56
  208. package/src/components/hooks/useImmutableRef.ts +0 -7
  209. package/src/components/hooks/useInterceptedMap.ts +0 -71
  210. package/src/components/hooks/useLatest.tsx +0 -8
  211. package/src/components/hooks/useLazyLatest.ts +0 -23
  212. package/src/components/hooks/useMemoShallowObjectMerge.ts +0 -16
  213. package/src/components/hooks/useMounted.ts +0 -18
  214. package/src/components/hooks/useOnMount.ts +0 -21
  215. package/src/components/hooks/useOnScroll.ts +0 -34
  216. package/src/components/hooks/useOnce.ts +0 -10
  217. package/src/components/hooks/useOverlay/index.tsx +0 -418
  218. package/src/components/hooks/usePrevious.ts +0 -8
  219. package/src/components/hooks/usePropertyOld.ts +0 -168
  220. package/src/components/hooks/useRerender.ts +0 -12
  221. package/src/components/hooks/xuseProperty.ts +0 -165
  222. package/src/components/types/CellPosition.ts +0 -4
  223. package/src/components/types/NonUndefined.ts +0 -1
  224. package/src/components/types/RemoveObject.ts +0 -22
  225. package/src/components/types/Renderable.ts +0 -3
  226. package/src/components/types/ScrollPosition.ts +0 -7
  227. package/src/components/types/Setter.ts +0 -2
  228. package/src/components/types/Size.ts +0 -6
  229. package/src/components/types/SubscriptionCallback.ts +0 -10
  230. package/src/components/types/VoidFn.ts +0 -1
  231. package/src/components/utils/buildSubscriptionCallback.tsx +0 -60
  232. package/src/components/utils/clamp.ts +0 -3
  233. package/src/components/utils/debounce.ts +0 -16
  234. package/src/components/utils/decamelize.ts +0 -11
  235. package/src/components/utils/discardCallsWithEqualArg.ts +0 -42
  236. package/src/components/utils/getRenderIndexes.ts +0 -33
  237. package/src/components/utils/getScrollbarWidth.ts +0 -31
  238. package/src/components/utils/getVirtualRenderCount.ts +0 -21
  239. package/src/components/utils/isControlled.ts +0 -12
  240. package/src/components/utils/isControlledValue.ts +0 -5
  241. package/src/index.tsx +0 -34
  242. package/src/test.tsx +0 -18
  243. package/src/utils/DeepMap/index.ts +0 -588
  244. package/src/utils/DeepMap/once.ts +0 -16
  245. package/src/utils/DeepMap/sortAscending.ts +0 -1
  246. package/src/utils/DeepMap/tsconfig.deepmap.json +0 -17
  247. package/src/utils/DeepMap/xpackage.json +0 -26
  248. package/src/utils/debug.ts +0 -40
  249. package/src/utils/deepClone.ts +0 -38
  250. package/src/utils/getGlobal.ts +0 -3
  251. package/src/utils/groupAndPivot/defaultToKey.ts +0 -3
  252. package/src/utils/groupAndPivot/getGroupKeysForDataItem.ts +0 -19
  253. package/src/utils/groupAndPivot/getPivotColumnsAndColumnGroups.ts +0 -361
  254. package/src/utils/groupAndPivot/index.ts +0 -1229
  255. package/src/utils/groupAndPivot/types.ts +0 -10
  256. package/src/utils/join.ts +0 -4
  257. package/src/utils/mathIntersection.ts +0 -21
  258. package/src/utils/minified.d.ts +0 -2
  259. package/src/utils/minified.js +0 -6
  260. package/src/utils/multisort/index.ts +0 -151
  261. package/src/utils/multisort/sortTypes.ts +0 -25
  262. package/src/utils/notes-status.md +0 -92
  263. package/src/utils/pageGeometry/ConvexPoly.ts +0 -34
  264. package/src/utils/pageGeometry/Point.ts +0 -51
  265. package/src/utils/pageGeometry/PolyWithPoints.ts +0 -52
  266. package/src/utils/pageGeometry/Rectangle.ts +0 -98
  267. package/src/utils/pageGeometry/Triangle.ts +0 -16
  268. package/src/utils/pageGeometry/alignment/index.ts +0 -221
  269. package/src/utils/pageGeometry/polyContainsPoint.ts +0 -182
  270. package/src/utils/pageGeometry/types.ts +0 -3
  271. package/src/utils/proxyFnCall.ts +0 -46
  272. package/src/utils/raf.ts +0 -13
  273. package/src/utils/selectParent.ts +0 -18
  274. package/src/utils/shallowEqualObjects.ts +0 -49
  275. package/src/utils/stripVar.ts +0 -3
  276. package/src/utils/toUpperFirst.ts +0 -5
  277. package/todo.md +0 -2
  278. package/tsconfig.build.json +0 -8
  279. package/tsconfig.dev.json +0 -7
  280. package/tsconfig.json +0 -30
  281. package/tsconfig.typebundler.json +0 -13
  282. package/typedoc.json +0 -4
@@ -1,139 +0,0 @@
1
- import { fallbackVar, style } from '@vanilla-extract/css';
2
- import { recipe } from '@vanilla-extract/recipes';
3
- import { ThemeVars } from '../InfiniteTable/theme.css';
4
- import {
5
- alignItems,
6
- boxSizingBorderBox,
7
- cursor,
8
- display,
9
- flexFlow,
10
- margin,
11
- position,
12
- userSelect,
13
- } from '../InfiniteTable/utilities.css';
14
-
15
- export const MenuCls = style([
16
- boxSizingBorderBox,
17
- position.relative,
18
- display.inlineGrid,
19
- flexFlow.column,
20
- margin.none,
21
- {
22
- padding: ThemeVars.components.Menu.padding,
23
- color: ThemeVars.components.Menu.color,
24
- background: ThemeVars.components.Menu.background,
25
- borderRadius: ThemeVars.components.Menu.borderRadius,
26
- outline: 'none',
27
- boxShadow: `0 6px 12px -2px ${ThemeVars.components.Menu.shadowColor},0 3px 7px -3px ${ThemeVars.components.Menu.background}`,
28
- },
29
- ]);
30
-
31
- export const MenuRowCls = style({
32
- display: 'contents',
33
- });
34
-
35
- const keyboardActiveItemBorder = fallbackVar(
36
- ThemeVars.components.Row.activeBorder,
37
- `${fallbackVar(
38
- ThemeVars.components.Row.activeBorderWidth,
39
- ThemeVars.components.Cell.activeBorderWidth,
40
- )} ${fallbackVar(
41
- ThemeVars.components.Row.activeBorderStyle,
42
- ThemeVars.components.Cell.activeBorderStyle,
43
- )} ${fallbackVar(
44
- ThemeVars.components.Row.activeBorderColor,
45
- `rgb(${ThemeVars.components.Cell.activeBorderColor_R} ${ThemeVars.components.Cell.activeBorderColor_G} ${ThemeVars.components.Cell.activeBorderColor_B})`,
46
- )}`,
47
- );
48
- export const MenuItemCls = recipe({
49
- base: [
50
- {
51
- paddingBlock: ThemeVars.components.Menu.cellPaddingVertical,
52
- paddingInline: ThemeVars.components.Menu.cellPaddingHorizontal,
53
- marginBlock: ThemeVars.components.Menu.cellMarginVertical,
54
- border: keyboardActiveItemBorder,
55
- borderColor: 'transparent',
56
- },
57
- display.flex,
58
- alignItems.center,
59
- userSelect.none,
60
- ],
61
- variants: {
62
- disabled: {
63
- true: [
64
- {
65
- opacity: ThemeVars.components.Menu.itemDisabledOpacity,
66
- background: ThemeVars.components.Menu.itemDisabledBackground,
67
- },
68
- cursor.default,
69
- userSelect.none,
70
- ],
71
- false: [cursor.pointer],
72
- },
73
- active: {
74
- true: {},
75
- false: {},
76
- },
77
- pressed: {
78
- false: {},
79
- true: {},
80
- },
81
- keyboardActive: {
82
- true: {
83
- selectors: {
84
- [`${MenuCls}:focus-within > ${MenuRowCls} > &`]: {
85
- border: keyboardActiveItemBorder,
86
- },
87
- [`${MenuCls}:focus-within > ${MenuRowCls} > &:first-child:last-child`]:
88
- {
89
- border: keyboardActiveItemBorder,
90
- },
91
- [`${MenuCls}:focus-within > ${MenuRowCls} > &:first-child`]: {
92
- borderRightColor: 'transparent',
93
- },
94
- [`${MenuCls}:focus-within > ${MenuRowCls} > &:last-child`]: {
95
- borderLeftColor: 'transparent',
96
- },
97
- [`${MenuCls}:focus-within > ${MenuRowCls} > &:not(:first-child):not(:last-child)`]:
98
- {
99
- borderLeftColor: 'transparent',
100
- borderRightColor: 'transparent',
101
- },
102
- },
103
- },
104
- false: {},
105
- },
106
- },
107
- compoundVariants: [
108
- {
109
- variants: {
110
- active: true,
111
- disabled: false,
112
- },
113
- style: {
114
- background: ThemeVars.components.Menu.itemActiveBackground,
115
- opacity: ThemeVars.components.Menu.itemActiveOpacity,
116
- },
117
- },
118
- {
119
- variants: {
120
- pressed: true,
121
- active: true,
122
- disabled: false,
123
- },
124
- style: {
125
- background: ThemeVars.components.Menu.itemPressedBackground,
126
- opacity: ThemeVars.components.Menu.itemPressedOpacity,
127
- },
128
- },
129
- ],
130
- });
131
-
132
- export const MenuSeparatorCls = style([
133
- {
134
- borderTop: '1px solid currentColor',
135
- borderBottom: 0,
136
- marginTop: `calc(${ThemeVars.components.Menu.cellPaddingVertical} / 2)`,
137
- marginBottom: `calc(${ThemeVars.components.Menu.cellPaddingVertical} / 2)`,
138
- },
139
- ]);
@@ -1,10 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
- import { MenuContextValue } from './MenuContextValue';
3
-
4
- export const MenuContext = createContext<MenuContextValue | null>(null);
5
-
6
- export function useMenuContext(): MenuContextValue {
7
- const contextValue = useContext(MenuContext);
8
-
9
- return contextValue!;
10
- }
@@ -1,15 +0,0 @@
1
- import {
2
- MenuActions,
3
- // MenuApi,
4
- // MenuComputedValues,
5
- MenuState,
6
- } from './MenuState';
7
-
8
- export interface MenuContextValue {
9
- // imperativeApi: MenuApi;
10
- componentState: MenuState;
11
- componentActions: MenuActions;
12
- // computed: MenuComputedValues;
13
- // getComputed: () => MenuComputedValues;
14
- getState: () => MenuState;
15
- }
@@ -1,98 +0,0 @@
1
- import { CSSProperties, HTMLProps } from 'react';
2
- import { ElementContainerGetter, OverlayShowParams } from '../hooks/useOverlay';
3
- import { NonUndefined } from '../types/NonUndefined';
4
- import { RemoveObject } from '../types/RemoveObject';
5
- import { Renderable } from '../types/Renderable';
6
- import { MenuApi, MenuState } from './MenuState';
7
-
8
- export type MenuRenderable = string | number | RemoveObject<Renderable>;
9
-
10
- export type MenuRuntimeItemSelectable = {
11
- type: 'item';
12
- key: string;
13
- parentMenuId: string;
14
- active: boolean;
15
- keyboardActive: boolean;
16
- value: MenuItemObject;
17
- style?: CSSProperties;
18
- className?: string;
19
- disabled: boolean;
20
- span: number;
21
- menu: MenuProps | (() => MenuProps) | null;
22
- originalMenuItem: MenuItemObject;
23
- };
24
- export type MenuRuntimeItem =
25
- | MenuRuntimeItemSelectable
26
- | {
27
- type: 'decoration';
28
- value: MenuDecoration;
29
- style: CSSProperties;
30
- span: number;
31
- };
32
-
33
- export type MenuChildrenFnParam = {
34
- item: MenuRuntimeItem;
35
- column: MenuColumn;
36
- columns: MenuColumn[];
37
- };
38
-
39
- export type MenuProps = {
40
- id?: string;
41
- portalContainer?: ElementContainerGetter | false | null;
42
- items?: MenuItemDefinition[];
43
- constrainTo?: OverlayShowParams['constrainTo'];
44
- columns?: MenuColumn[];
45
- children?: MenuRenderable;
46
- wrapLabels?: boolean;
47
- onShow?: (state: MenuState, api: MenuApi) => void;
48
- onHide?: (state: MenuState) => void;
49
- onHideIntent?: (state: MenuState) => void;
50
- bubbleActionsFromSubmenus?: boolean;
51
- addSubmenuColumnIfNeeded?: boolean;
52
- onAction?: (key: string, item: MenuItemObject) => void;
53
- parentMenuId?: string;
54
- parentMenuItemKey?: string;
55
- autoFocus?: boolean;
56
- };
57
-
58
- export type MenuSeparator = '-';
59
- export type MenuItemDefinition =
60
- | MenuItemObject
61
- | MenuDecoration
62
- | MenuSeparator;
63
-
64
- type MenuItemSubMenu = Omit<MenuProps, 'children' | 'items'> & {
65
- items: (MenuItemObject | MenuSeparator)[];
66
- };
67
-
68
- export type MenuItemObject = {
69
- key: string;
70
- label: NonUndefined<MenuRenderable>;
71
- span?: number;
72
- description?: MenuRenderable;
73
- disabled?: boolean;
74
- menu?: MenuItemSubMenu | (() => MenuItemSubMenu);
75
- style?: CSSProperties;
76
- className?: string;
77
- onClick?: (event: React.MouseEvent) => void;
78
- onAction?: (key: string, item: MenuItemObject) => void;
79
- [k: string]: any;
80
- };
81
-
82
- export type MenuDecoration = MenuRenderable;
83
-
84
- export type MenuColumn = {
85
- flex?: number;
86
- width?: string | number;
87
- style?: CSSProperties;
88
- name: string;
89
- field?: string;
90
- render?: (param: MenuColumnRenderParam) => MenuRenderable;
91
- };
92
-
93
- export type MenuColumnRenderParam = {
94
- item: MenuItemObject;
95
- column: MenuColumn;
96
- value: MenuRenderable;
97
- domProps: HTMLProps<HTMLDivElement>;
98
- };
@@ -1,56 +0,0 @@
1
- import { MutableRefObject } from 'react';
2
- import { ComponentStateActions } from '../hooks/useComponentState/types';
3
- import {
4
- MenuColumn,
5
- MenuProps,
6
- MenuRuntimeItem,
7
- MenuRuntimeItemSelectable,
8
- } from './MenuProps';
9
-
10
- export type MenuSetupState = {
11
- domRef: MutableRefObject<HTMLDivElement | null>;
12
- keyboardActiveItemKey: string | null;
13
- activeItemKey: string | null;
14
- generatedId: string;
15
- focused: boolean;
16
- destroyed: boolean;
17
- };
18
-
19
- export type MenuDerivedState = {
20
- runtimeItems: MenuRuntimeItem[];
21
- runtimeSelectableItems: MenuRuntimeItemSelectable[];
22
- columns: MenuColumn[];
23
- menuId: string;
24
- };
25
-
26
- export type MenuMappedState = {
27
- parentMenuId: MenuProps['parentMenuId'];
28
- parentMenuItemKey: MenuProps['parentMenuItemKey'];
29
- constrainTo: MenuProps['constrainTo'];
30
- autoFocus: MenuProps['autoFocus'];
31
- onHideIntent: MenuProps['onHideIntent'];
32
- onAction: MenuProps['onAction'];
33
- onShow: MenuProps['onShow'];
34
- onHide: MenuProps['onHide'];
35
- wrapLabels: MenuProps['wrapLabels'];
36
- };
37
-
38
- export interface MenuState
39
- extends MenuMappedState,
40
- MenuDerivedState,
41
- MenuSetupState {}
42
-
43
- export type MenuActions = ComponentStateActions<MenuState>;
44
-
45
- export type MenuApi = {
46
- focus: VoidFunction;
47
- getMenuId: () => string;
48
- getParentMenuId: () => string | undefined;
49
- };
50
- export type MenuComputedValues = {};
51
- export type MenuRuntimeItemContext = {
52
- columns: MenuColumn[];
53
- keyboardActiveItemKey: string | null;
54
- activeItemKey: string | null;
55
- menuId: string;
56
- };
@@ -1,352 +0,0 @@
1
- import { getGlobal } from '../../utils/getGlobal';
2
- import { Point } from '../../utils/pageGeometry/Point';
3
- import { Rectangle } from '../../utils/pageGeometry/Rectangle';
4
- import { Triangle } from '../../utils/pageGeometry/Triangle';
5
- import { raf } from '../../utils/raf';
6
-
7
- const ACTIVE_OTHER_MENU_ITEM_TIMEOUT = 250;
8
-
9
- export function waitForValueOnRaf<ReturnType>(
10
- getter: () => ReturnType,
11
- timeout: number = 100,
12
- ): Promise<ReturnType | undefined> {
13
- const start = Date.now();
14
- return new Promise((resolve) => {
15
- let value;
16
-
17
- const fn = () => {
18
- value = getter();
19
- if (value !== undefined) {
20
- resolve(value);
21
- return;
22
- }
23
- if (Date.now() - start > timeout) {
24
- resolve(undefined);
25
- return;
26
- }
27
-
28
- raf(fn);
29
- };
30
-
31
- // it's important to start it on next tick
32
- raf(() => {
33
- fn();
34
- });
35
- });
36
- }
37
-
38
- const globalObject = getGlobal();
39
-
40
- type MenuTriangleParams = {
41
- timeout?: number;
42
- /**
43
- * NOTE: #IAC-false
44
- * onItemActivateChange will only be called
45
- * with `itemKey: null` when the user has an active item that has no submenu and
46
- * leaves the menu hovering off that item directly outside the menu (not over another item).
47
- *
48
- * In this case, we want to mark that menu item as inactive, as it doesn't have any submenus.
49
- *
50
- * If the user hovers away from the menu when an item (that has submenu) is active,
51
- * we keep that as active even when the mouse is away, so we don't call onItemActivateChange with `itemKey: null`.
52
- */
53
- onItemActivate: (itemKey: string | null, target: HTMLElement | null) => void;
54
- itemHasSubMenu: (itemKey: string) => boolean;
55
- getMenuRectFor: (itemKey: string) => Rectangle | undefined;
56
- parentMenuId?: string;
57
- };
58
- /**
59
- * Here's the logic of menu and the menu triangle solution:
60
- *
61
- * - use hovers a menu item
62
- * - user then diagonally goes down and to the right to access the submenu
63
- * and even though along the way other menu items are hovered, the submenu
64
- * is not closed (and submenus for hovered items are not displayed along the way) - unless the move is slow (take more than say 200ms). When
65
- * an item has the submenu visible, we call it "active".
66
- * - if the move reverses, the submenu is closed and the last hovered item is activated
67
- *
68
- * Even items with no submenus can be active.
69
- *
70
- */
71
-
72
- export class MenuTriangleContext {
73
- private activeItem: string | null = null;
74
- private currentHoveredItem: string | null = null;
75
-
76
- // private activeItemTimestamp: number = 0;
77
- private activeItemLeavePoint: Point | null = null;
78
-
79
- private menuLeaveTimeoutId: any = null;
80
-
81
- // private activeItemEventTarget: HTMLElement | null = null;
82
- private activeItemMenuRect: Rectangle | null = null;
83
-
84
- private lastPointerMoveTimestamp: number = 0;
85
- private mouseMoveTimeoutId: number = 0;
86
- private params: MenuTriangleParams;
87
-
88
- private lastHorizontalDiff: number = 0;
89
-
90
- constructor(params: MenuTriangleParams) {
91
- this.params = params;
92
- }
93
-
94
- private getTimeout = () => {
95
- return this.params.timeout || ACTIVE_OTHER_MENU_ITEM_TIMEOUT;
96
- };
97
-
98
- private getPointerMoveTarget = () => {
99
- return document.documentElement || globalObject;
100
- };
101
-
102
- private removePointerMoveListener = () => {
103
- this.getPointerMoveTarget().removeEventListener(
104
- 'pointermove',
105
- this.onPointerMoveWhileActiveItem,
106
- );
107
- };
108
-
109
- /**
110
- * The whole point of this method is to change the active item when the mouse moves,
111
- * if the user is moving slowly or outside the menu triangle.
112
- *
113
- * This is called while having a currently active item.
114
- */
115
- private onPointerMoveWhileActiveItem = (pointerMoveEvent?: PointerEvent) => {
116
- clearTimeout(this.mouseMoveTimeoutId);
117
-
118
- if (!pointerMoveEvent) {
119
- // we called it ourselves
120
- // in order to update the timestamp of the last move
121
- this.lastPointerMoveTimestamp = Date.now();
122
- // and we exit early
123
- return;
124
- }
125
-
126
- // if there is no hovered item, or the hovered item is the active one, we can return
127
- // because we don't need tp update the active item
128
- if (
129
- !this.currentHoveredItem ||
130
- this.currentHoveredItem === this.activeItem
131
- ) {
132
- return;
133
- }
134
-
135
- const now = Date.now();
136
-
137
- if (!this.lastPointerMoveTimestamp) {
138
- this.lastPointerMoveTimestamp = now;
139
- }
140
-
141
- const timeElapsed = now - this.lastPointerMoveTimestamp;
142
- const timeoutGone = timeElapsed > this.getTimeout();
143
-
144
- // update the value of the last move timestamp
145
- this.lastPointerMoveTimestamp = now;
146
-
147
- const activateHoveredItem = () => {
148
- this.setActiveItem(null, null);
149
- // so we trigger onItemChange for the last hovered item again
150
- // because the move was slow or out of triangle
151
-
152
- this.onItemChange(true, this.currentHoveredItem!, pointerMoveEvent);
153
- };
154
-
155
- if (timeoutGone) {
156
- // the last mouse move was too long ago
157
- // so we trigger onItemChange for the last hovered item
158
- activateHoveredItem();
159
- return;
160
- }
161
-
162
- let hoveredItem = this.currentHoveredItem;
163
- this.mouseMoveTimeoutId = setTimeout(() => {
164
- if (hoveredItem !== this.currentHoveredItem) {
165
- // the hover item has changed, so we're out of sync
166
- return;
167
- }
168
-
169
- const now = Date.now();
170
- const elapsedTime = now - this.lastPointerMoveTimestamp;
171
- const timeoutGone = elapsedTime > this.getTimeout();
172
-
173
- if (timeoutGone) {
174
- activateHoveredItem();
175
- }
176
- }, this.getTimeout()) as any as number;
177
-
178
- const currentPoint = new Point({
179
- left: pointerMoveEvent.clientX,
180
- top: pointerMoveEvent.clientY,
181
- });
182
-
183
- // for checking the triangle logic, we have to have those, otherwise we can't continue
184
- if (!this.activeItemMenuRect || !this.activeItemLeavePoint) {
185
- return;
186
- }
187
-
188
- // we need to check if the user is moving the mouse back from the submenu to the menu again
189
- // this is a reverse movement, so we should activate the last hovered item
190
-
191
- const submenuToTheRight =
192
- this.activeItemLeavePoint.left < this.activeItemMenuRect.left;
193
-
194
- const horizontalDirectionSign = submenuToTheRight ? 1 : -1;
195
- const horizontalDiff =
196
- horizontalDirectionSign *
197
- (currentPoint.left - this.activeItemLeavePoint.left);
198
-
199
- if (horizontalDiff - this.lastHorizontalDiff < 0) {
200
- this.lastHorizontalDiff = 0;
201
- activateHoveredItem();
202
- return;
203
- }
204
- this.lastHorizontalDiff = horizontalDiff;
205
-
206
- // we need to check if the user is moving diagonally down and to the right/left (depending on the submenu position)
207
- const triangle = submenuToTheRight
208
- ? new Triangle([
209
- this.activeItemLeavePoint,
210
- this.activeItemMenuRect.getTopLeft(),
211
- this.activeItemMenuRect.getBottomLeft(),
212
- ])
213
- : new Triangle([
214
- // in this case, the menu is placed to the left, so adjust the triangle
215
- this.activeItemLeavePoint,
216
- this.activeItemMenuRect.getTopRight(),
217
- this.activeItemMenuRect.getBottomRight(),
218
- ]);
219
-
220
- if (!triangle.containsPoint(currentPoint)) {
221
- this.setActiveItem(null, null);
222
- this.onItemChange(true, this.currentHoveredItem!, pointerMoveEvent);
223
- }
224
- };
225
-
226
- /**
227
- * See #IAC-false note above
228
- */
229
- private setupMenuLeaveTracking = () => {
230
- this.menuLeaveTimeoutId = setTimeout(() => {
231
- if (this.activeItem && this.params.itemHasSubMenu(this.activeItem)) {
232
- // as per the note #IAC-false
233
- // we don't continue clearing the active item if it has submenus
234
- return;
235
- }
236
- this.setActiveItem(null, null);
237
- }, this.getTimeout());
238
- };
239
-
240
- /**
241
- * This function should call onItemActivate to notify whoever's listening
242
- */
243
- private setActiveItem = (
244
- itemKey: string | null,
245
- target: HTMLElement | null,
246
- ) => {
247
- if (itemKey === this.activeItem) {
248
- return;
249
- }
250
-
251
- if (itemKey == null) {
252
- this.removePointerMoveListener();
253
- this.params.onItemActivate(null, null);
254
-
255
- this.activeItem = null;
256
- // this.activeItemTimestamp = 0;
257
- // this.activeItemEventTarget = null;
258
- this.activeItemMenuRect = null;
259
-
260
- return;
261
- }
262
-
263
- this.activeItem = itemKey;
264
- // this.activeItemTimestamp = Date.now();
265
- // this.activeItemEventTarget = target as HTMLElement;
266
-
267
- this.params.onItemActivate(itemKey, target);
268
-
269
- this.activeItemMenuRect = null;
270
- // wait for the active item to be rendered
271
- // so we can retrieve the rect
272
-
273
- waitForValueOnRaf(() => {
274
- if (this.activeItem != itemKey) {
275
- return false;
276
- }
277
- return this.params.getMenuRectFor(itemKey);
278
- }).then((rect: Rectangle | false | undefined) => {
279
- if (this.activeItem != itemKey) {
280
- return;
281
- }
282
- if (rect) {
283
- this.activeItemMenuRect = rect;
284
- }
285
- });
286
- };
287
-
288
- /**
289
- * This function is called when an item receives mouse enter or mouse leave.
290
- */
291
- private onItemChange = (
292
- hovered: boolean,
293
- itemKey: string,
294
- event: PointerEvent,
295
- ) => {
296
- clearTimeout(this.menuLeaveTimeoutId);
297
- clearTimeout(this.mouseMoveTimeoutId);
298
-
299
- if (!hovered) {
300
- this.removePointerMoveListener();
301
-
302
- if (itemKey === this.activeItem) {
303
- // we're leaving the currently opened item
304
- // so make sure we save the leave coords as we might need them
305
- // later in the triangle logic
306
- this.activeItemLeavePoint = new Point({
307
- left: event.clientX,
308
- top: event.clientY,
309
- });
310
- }
311
-
312
- // we might be leaving the menu for good and stop moving the mouse for a while
313
- // so we need to make sure we start the timeout
314
- this.setupMenuLeaveTracking();
315
- return;
316
- }
317
-
318
- // if by some accident this gets called twice one after the other, we can simply ignore this
319
- // if (this.currentHoveredItem === itemKey) {
320
- // return;
321
- // }
322
-
323
- this.currentHoveredItem = itemKey;
324
- if (!this.activeItem || !this.params.itemHasSubMenu(this.activeItem)) {
325
- // no item is currently activated or the currently activated item does not have a submenu
326
- // so we can safely activate the hovered item immediately
327
- this.setActiveItem(itemKey, event.target as HTMLElement);
328
- return;
329
- }
330
-
331
- // there is an active item already, and the active item does have a submenu
332
- // and the active item is different from the currently hovered item
333
- // so we listen to mouse moves
334
-
335
- this.onPointerMoveWhileActiveItem(); // we need to call this in order to initialize the timestamp of the last "move" (to the value of Date.now())
336
- this.getPointerMoveTarget().addEventListener(
337
- 'pointermove',
338
- this.onPointerMoveWhileActiveItem,
339
- );
340
- };
341
-
342
- getHandlers = () => {
343
- return {
344
- onItemEnter: (itemKey: string, event: PointerEvent) => {
345
- this.onItemChange(true, itemKey, event);
346
- },
347
- onItemLeave: (itemKey: string, event: PointerEvent) => {
348
- this.onItemChange(false, itemKey, event);
349
- },
350
- };
351
- };
352
- }