@linzjs/step-ag-grid 1.4.4 → 1.4.6

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 (102) hide show
  1. package/dist/index.js +1631 -3040
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/components/GridLoadableCell.d.ts +2 -0
  4. package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
  5. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
  6. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +1 -1
  7. package/dist/src/react-menu3/components/ControlledMenu.d.ts +2 -0
  8. package/dist/src/react-menu3/components/FocusableItem.d.ts +9 -0
  9. package/dist/src/react-menu3/components/Menu.d.ts +16 -0
  10. package/dist/src/react-menu3/components/MenuButton.d.ts +8 -0
  11. package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -0
  12. package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -0
  13. package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -0
  14. package/dist/src/react-menu3/components/MenuItem.d.ts +59 -0
  15. package/dist/src/react-menu3/components/MenuList.d.ts +57 -0
  16. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +44 -0
  17. package/dist/src/react-menu3/components/SubMenu.d.ts +110 -0
  18. package/dist/src/react-menu3/hooks/index.d.ts +9 -0
  19. package/dist/src/react-menu3/hooks/useBEM.d.ts +10 -0
  20. package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -0
  21. package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +3 -0
  22. package/dist/src/react-menu3/hooks/useItemEffect.d.ts +2 -0
  23. package/dist/src/react-menu3/hooks/useItemState.d.ts +7 -0
  24. package/dist/src/react-menu3/hooks/useItems.d.ts +7 -0
  25. package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -0
  26. package/dist/src/react-menu3/hooks/useMenuState.d.ts +14 -0
  27. package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -0
  28. package/dist/src/react-menu3/index.d.ts +402 -0
  29. package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +11 -0
  30. package/dist/src/react-menu3/positionUtils/index.d.ts +3 -0
  31. package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +8 -0
  32. package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +8 -0
  33. package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +19 -0
  34. package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +19 -0
  35. package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +13 -0
  36. package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +26 -0
  37. package/dist/src/react-menu3/style-utils/index.d.ts +11 -0
  38. package/dist/src/react-menu3/utils/constants.d.ts +92 -0
  39. package/dist/src/react-menu3/utils/index.d.ts +4 -0
  40. package/dist/src/react-menu3/utils/propTypes.d.ts +56 -0
  41. package/dist/src/react-menu3/utils/utils.d.ts +36 -0
  42. package/dist/src/react-menu3/utils/withHovering.d.ts +7 -0
  43. package/dist/src/stories/components/ReactMenu.stories.d.ts +8 -0
  44. package/dist/step-ag-grid.esm.js +1543 -2951
  45. package/dist/step-ag-grid.esm.js.map +1 -1
  46. package/package.json +22 -13
  47. package/src/components/GridLoadableCell.scss +4 -0
  48. package/src/components/GridLoadableCell.tsx +5 -1
  49. package/src/components/GridPopoverHook.tsx +4 -50
  50. package/src/components/gridForm/GridFormDropDown.tsx +3 -3
  51. package/src/components/gridForm/GridFormMultiSelect.tsx +12 -6
  52. package/src/components/gridForm/GridFormPopoutMenu.tsx +1 -1
  53. package/src/components/gridPopoverEdit/GridPopoverMenu.scss +6 -2
  54. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +1 -1
  55. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +7 -9
  56. package/src/react-menu3/components/ControlledMenu.tsx +261 -0
  57. package/src/react-menu3/components/FocusableItem.tsx +75 -0
  58. package/src/react-menu3/components/Menu.tsx +108 -0
  59. package/src/react-menu3/components/MenuButton.tsx +34 -0
  60. package/src/react-menu3/components/MenuDivider.tsx +17 -0
  61. package/src/react-menu3/components/MenuGroup.tsx +47 -0
  62. package/src/react-menu3/components/MenuHeader.tsx +17 -0
  63. package/src/react-menu3/components/MenuItem.tsx +183 -0
  64. package/src/react-menu3/components/MenuList.tsx +502 -0
  65. package/src/react-menu3/components/MenuRadioGroup.tsx +72 -0
  66. package/src/react-menu3/components/SubMenu.tsx +349 -0
  67. package/src/react-menu3/hooks/index.ts +9 -0
  68. package/src/react-menu3/hooks/useBEM.ts +33 -0
  69. package/src/react-menu3/hooks/useCombinedRef.ts +24 -0
  70. package/src/react-menu3/hooks/useIsomorphicLayoutEffect.ts +15 -0
  71. package/src/react-menu3/hooks/useItemEffect.ts +23 -0
  72. package/src/react-menu3/hooks/useItemState.ts +67 -0
  73. package/src/react-menu3/hooks/useItems.ts +111 -0
  74. package/src/react-menu3/hooks/useMenuChange.ts +12 -0
  75. package/src/react-menu3/hooks/useMenuState.ts +42 -0
  76. package/src/react-menu3/hooks/useMenuStateAndFocus.ts +17 -0
  77. package/src/react-menu3/index.d.ts +683 -0
  78. package/src/react-menu3/index.ts +442 -0
  79. package/src/react-menu3/positionUtils/getPositionHelpers.ts +83 -0
  80. package/src/react-menu3/positionUtils/index.ts +3 -0
  81. package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +15 -0
  82. package/src/react-menu3/positionUtils/placeArrowVertical.ts +15 -0
  83. package/src/react-menu3/positionUtils/placeLeftorRight.ts +92 -0
  84. package/src/react-menu3/positionUtils/placeToporBottom.ts +93 -0
  85. package/src/react-menu3/positionUtils/positionContextMenu.ts +61 -0
  86. package/src/react-menu3/positionUtils/positionMenu.ts +80 -0
  87. package/src/react-menu3/style-utils/index.ts +83 -0
  88. package/src/react-menu3/style-utils.d.ts +110 -0
  89. package/src/react-menu3/styles/_mixins.scss +11 -0
  90. package/src/react-menu3/styles/_var.scss +20 -0
  91. package/src/react-menu3/styles/core.scss +80 -0
  92. package/src/react-menu3/styles/index.scss +70 -0
  93. package/src/react-menu3/styles/theme-dark.scss +30 -0
  94. package/src/react-menu3/styles/transitions/slide.scss +47 -0
  95. package/src/react-menu3/utils/constants.ts +116 -0
  96. package/src/react-menu3/utils/index.ts +4 -0
  97. package/src/react-menu3/utils/propTypes.ts +63 -0
  98. package/src/react-menu3/utils/utils.ts +88 -0
  99. package/src/react-menu3/utils/withHovering.tsx +27 -0
  100. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +1 -3
  101. package/src/stories/components/ReactMenu.stories.tsx +37 -0
  102. package/src/utils/util.ts +2 -1
@@ -0,0 +1,116 @@
1
+ import { createContext, MutableRefObject } from "react";
2
+ import { EventHandler, FocusPosition, MenuDirection, MenuOverflow, MenuState } from "../index";
3
+ import { RadioChangeEvent } from "../components/MenuRadioGroup";
4
+ import { ControlledMenuProps } from "../components/MenuList";
5
+
6
+ export const menuContainerClass = "szh-menu-container";
7
+ export const menuClass = "szh-menu";
8
+ export const menuButtonClass = "szh-menu-button";
9
+ export const menuArrowClass = "arrow";
10
+ export const menuItemClass = "item";
11
+ export const menuDividerClass = "divider";
12
+ export const menuHeaderClass = "header";
13
+ export const menuGroupClass = "group";
14
+ export const subMenuClass = "submenu";
15
+ export const radioGroupClass = "radio-group";
16
+
17
+ export const HoverItemContext = createContext(undefined);
18
+
19
+ interface MenuListItemContextType {
20
+ isParentOpen?: boolean;
21
+ isSubmenuOpen?: boolean;
22
+ dispatch: (actionType: number, item: any, nextIndex: FocusPosition) => void;
23
+ updateItems: (item: any, isMounted?: boolean) => void;
24
+ setOpenSubmenuCount: (fn: (count: number) => number) => void;
25
+ }
26
+
27
+ export const MenuListItemContext = createContext<MenuListItemContextType>({
28
+ dispatch: () => {},
29
+ updateItems: () => {},
30
+ setOpenSubmenuCount: () => 0,
31
+ });
32
+
33
+ export const MenuListContext = createContext<{
34
+ overflow?: MenuOverflow;
35
+ overflowAmt?: number;
36
+ parentMenuRef?: MutableRefObject<any>;
37
+ parentDir?: MenuDirection;
38
+ reposSubmenu?: boolean;
39
+ }>({});
40
+
41
+ export interface RMEvent {
42
+ value: any;
43
+ syntheticEvent: any;
44
+ checked?: boolean;
45
+ name?: string;
46
+ key?: string;
47
+ }
48
+
49
+ export const EventHandlersContext = createContext<{
50
+ handleClose?: () => void;
51
+ handleClick: (event: RMEvent, checked: boolean) => void;
52
+ }>({
53
+ handleClick: () => {},
54
+ });
55
+
56
+ export const RadioGroupContext = createContext<{
57
+ value?: any;
58
+ name?: string;
59
+ onRadioChange?: EventHandler<RadioChangeEvent>;
60
+ }>({});
61
+
62
+ interface SettingsContextType extends ControlledMenuProps, MenuListItemContextType {
63
+ rootMenuRef?: MutableRefObject<any>;
64
+ rootAnchorRef?: MutableRefObject<any>;
65
+ scrollNodesRef: MutableRefObject<{ anchors?: Element[]; menu: any }>;
66
+ }
67
+
68
+ // FIXME hacking a default context in here is probably bad
69
+ export const SettingsContext = createContext<SettingsContextType>({} as SettingsContextType);
70
+
71
+ export const ItemSettingsContext = createContext<{ submenuCloseDelay: number; submenuOpenDelay: number }>({
72
+ submenuOpenDelay: 0,
73
+ submenuCloseDelay: 0,
74
+ });
75
+
76
+ export const Keys = Object.freeze({
77
+ ENTER: "Enter",
78
+ ESC: "Escape",
79
+ SPACE: " ",
80
+ HOME: "Home",
81
+ END: "End",
82
+ LEFT: "ArrowLeft",
83
+ RIGHT: "ArrowRight",
84
+ UP: "ArrowUp",
85
+ DOWN: "ArrowDown",
86
+ });
87
+
88
+ export const HoverActionTypes = Object.freeze({
89
+ RESET: 0,
90
+ SET: 1,
91
+ UNSET: 2,
92
+ INCREASE: 3,
93
+ DECREASE: 4,
94
+ FIRST: 5,
95
+ LAST: 6,
96
+ SET_INDEX: 7,
97
+ });
98
+
99
+ export const CloseReason = Object.freeze({
100
+ CLICK: "click",
101
+ CANCEL: "cancel",
102
+ BLUR: "blur",
103
+ SCROLL: "scroll",
104
+ });
105
+
106
+ export const FocusPositions = Object.freeze({
107
+ FIRST: "first",
108
+ LAST: "last",
109
+ });
110
+
111
+ export const MenuStateMap: Record<string, MenuState> = Object.freeze({
112
+ entering: "opening",
113
+ entered: "open",
114
+ exiting: "closing",
115
+ exited: "closed",
116
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./constants";
2
+ export * from "./utils";
3
+ export * from "./propTypes";
4
+ export { withHovering } from "./withHovering";
@@ -0,0 +1,63 @@
1
+ import { string, number, bool, func, object, oneOf, oneOfType, exact } from "prop-types";
2
+
3
+ export const stylePropTypes = (name?: string) => ({
4
+ [name ? `${name}ClassName` : "className"]: oneOfType([string, func]),
5
+ });
6
+
7
+ export const Direction = oneOf(["left", "right", "top", "bottom"]);
8
+
9
+ // Menu, SubMenu and ControlledMenu
10
+ export const menuPropTypes = {
11
+ className: string,
12
+ ...stylePropTypes("menu"),
13
+ ...stylePropTypes("arrow"),
14
+ menuStyle: object,
15
+ arrowStyle: object,
16
+ arrow: bool,
17
+ setDownOverflow: bool,
18
+ offsetX: number,
19
+ offsetY: number,
20
+ align: oneOf(["start", "center", "end"]),
21
+ direction: Direction,
22
+ position: oneOf(["auto", "anchor", "initial"]),
23
+ overflow: oneOf(["auto", "visible", "hidden"]),
24
+ };
25
+
26
+ // Menu and ControlledMenu
27
+ export const rootMenuPropTypes = {
28
+ ...menuPropTypes,
29
+ containerProps: object,
30
+ initialMounted: bool,
31
+ unmountOnClose: bool,
32
+ transition: oneOfType([
33
+ bool,
34
+ exact({
35
+ open: bool,
36
+ close: bool,
37
+ item: bool,
38
+ }),
39
+ ]),
40
+ transitionTimeout: number,
41
+ boundingBoxRef: object,
42
+ boundingBoxPadding: string,
43
+ reposition: oneOf(["auto", "initial"]),
44
+ repositionFlag: oneOfType([string, number]),
45
+ viewScroll: oneOf(["auto", "close", "initial"]),
46
+ submenuOpenDelay: number,
47
+ submenuCloseDelay: number,
48
+ portal: oneOfType([
49
+ bool,
50
+ exact({
51
+ target: object,
52
+ stablePosition: bool,
53
+ }),
54
+ ]),
55
+ theming: string,
56
+ onItemClick: func,
57
+ };
58
+
59
+ // Menu and SubMenu
60
+ export const uncontrolledMenuPropTypes = {
61
+ instanceRef: oneOfType([object, func]),
62
+ onMenuChange: func,
63
+ };
@@ -0,0 +1,88 @@
1
+ import { unstable_batchedUpdates } from "react-dom";
2
+ import { MenuState, MenuStateOptions } from "../index";
3
+ import { MenuButtonProps } from "../components/MenuButton";
4
+ import { findIndex } from "lodash-es";
5
+
6
+ export const isMenuOpen = (state?: MenuState) => !!state && state[0] === "o";
7
+ export const batchedUpdates = unstable_batchedUpdates || ((callback: () => any) => callback());
8
+ export const values = Object.values || ((obj: { [x: string]: any }) => Object.keys(obj).map((key) => obj[key]));
9
+ export const floatEqual = (a: number, b: number, diff = 0.0001) => Math.abs(a - b) < diff;
10
+
11
+ export type TransitionMap = {
12
+ open?: boolean;
13
+ close?: boolean;
14
+ item?: boolean;
15
+ };
16
+ export const getTransition = (transition: MenuStateOptions["transition"], name: keyof TransitionMap) =>
17
+ transition === true || !!(transition && transition[name]);
18
+
19
+ export function safeCall<T, R>(fn: (arg?: T) => R, arg?: T): R;
20
+ export function safeCall<T, R>(fn: T, arg: R): T;
21
+ export function safeCall<T, R>(fn: (arg?: T) => R, arg?: T): T | R {
22
+ return typeof fn === "function" ? fn(arg) : fn;
23
+ }
24
+
25
+ const internalKey = "_szhsinMenu";
26
+ export const getName = (component: Record<string, any | undefined>) => component[internalKey];
27
+ //export const defineName = <T extends any[]>(name: string, component: (...args: T) => JSX.Element) =>
28
+ // Object.defineProperty(component, internalKey, { value: name });
29
+
30
+ export const defineName = (
31
+ name: string,
32
+ component: React.ForwardRefExoticComponent<React.PropsWithoutRef<MenuButtonProps> & React.RefAttributes<unknown>>,
33
+ ) => Object.defineProperty(component, internalKey, { value: name });
34
+
35
+ export const mergeProps = (target: Record<string, any>, source: Record<string, any>) => {
36
+ source &&
37
+ Object.keys(source).forEach((key) => {
38
+ const targetProp = target[key];
39
+ const sourceProp = source[key];
40
+ if (typeof sourceProp === "function" && targetProp) {
41
+ target[key] = (...arg: any[]) => {
42
+ sourceProp(...arg);
43
+ targetProp(...arg);
44
+ };
45
+ } else {
46
+ target[key] = sourceProp;
47
+ }
48
+ });
49
+
50
+ return target;
51
+ };
52
+
53
+ export const parsePadding = (paddingStr: string | undefined) => {
54
+ if (paddingStr == null) return { top: 0, right: 0, bottom: 0, left: 0 };
55
+
56
+ const padding = paddingStr.trim().split(/\s+/, 4).map(parseFloat);
57
+ const top = !isNaN(padding[0]) ? padding[0] : 0;
58
+ const right = !isNaN(padding[1]) ? padding[1] : top;
59
+ return {
60
+ top,
61
+ right,
62
+ bottom: !isNaN(padding[2]) ? padding[2] : top,
63
+ left: !isNaN(padding[3]) ? padding[3] : right,
64
+ };
65
+ };
66
+
67
+ // Adapted from https://github.com/popperjs/popper-core/tree/v2.9.1/src/dom-utils
68
+ export const getScrollAncestor = (node: Node | null): Element | null => {
69
+ const thisWindow = (node?.ownerDocument ?? document).defaultView ?? window;
70
+ while (node) {
71
+ node = node.parentNode;
72
+ if (!node || node === thisWindow?.document?.body) return null;
73
+ if (node instanceof Element) {
74
+ const { overflow, overflowX, overflowY } = thisWindow.getComputedStyle(node);
75
+ if (/auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX)) return node;
76
+ }
77
+ }
78
+ return null;
79
+ };
80
+
81
+ export function commonProps(isDisabled?: boolean, isHovering?: boolean) {
82
+ return {
83
+ "aria-disabled": isDisabled || undefined,
84
+ tabIndex: isHovering ? 0 : -1,
85
+ };
86
+ }
87
+
88
+ export const indexOfNode = (nodeList: NodeListOf<Node>, node: Node) => findIndex(nodeList, node);
@@ -0,0 +1,27 @@
1
+ import { memo, forwardRef, useContext, useRef, MutableRefObject } from "react";
2
+ import { HoverItemContext } from "./constants";
3
+
4
+ export interface withHoveringResultProps {
5
+ isHovering?: boolean;
6
+ externalRef?: MutableRefObject<any>;
7
+ menuItemRef?: MutableRefObject<any>;
8
+ }
9
+
10
+ export const withHovering = (name: string, WrappedComponent: (...args: any) => JSX.Element): any => {
11
+ const Component = memo(WrappedComponent);
12
+ const WithHovering = forwardRef<any>((props: any, ref) => {
13
+ const menuItemRef = useRef<any>(null);
14
+ return (
15
+ <Component
16
+ {...props}
17
+ menuItemRef={menuItemRef}
18
+ externalRef={ref}
19
+ isHovering={useContext(HoverItemContext) === menuItemRef.current}
20
+ />
21
+ );
22
+ });
23
+
24
+ WithHovering.displayName = `WithHovering(${name})`;
25
+
26
+ return WithHovering;
27
+ };
@@ -8,12 +8,10 @@ import { GridContextProvider } from "@contexts/GridContextProvider";
8
8
  import { Grid, GridProps } from "@components/Grid";
9
9
  import { useCallback, useMemo, useState } from "react";
10
10
  import {
11
- FinalSelectOption,
12
11
  GridFormDropDown,
13
12
  GridFormPopoutDropDownProps,
14
13
  MenuSeparator,
15
14
  MenuSeparatorString,
16
- SelectOption,
17
15
  } from "@components/gridForm/GridFormDropDown";
18
16
  import { ColDef } from "ag-grid-community";
19
17
  import { wait } from "@utils/util";
@@ -180,7 +178,7 @@ const GridEditDropDownTemplate: ComponentStory<typeof Grid> = (props: GridProps)
180
178
  },
181
179
  }),
182
180
  ] as ColDef[],
183
- [optionsFn],
181
+ [optionsFn, optionsObjects],
184
182
  );
185
183
 
186
184
  const rowData = useMemo(
@@ -0,0 +1,37 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+ import "../../lui-overrides.scss";
4
+
5
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
6
+ import { Grid } from "@components/Grid";
7
+ import { Menu, MenuItem, MenuButton, MenuDivider, SubMenu } from "@react-menu3";
8
+
9
+ export default {
10
+ title: "Components / React-menu",
11
+ component: Grid,
12
+ args: {
13
+ externalSelectedItems: [],
14
+ setExternalSelectedItems: () => {},
15
+ },
16
+ } as ComponentMeta<typeof Grid>;
17
+
18
+ const ReactMenuTemplate: ComponentStory<typeof Grid> = () => {
19
+ return (
20
+ <>
21
+ <Menu menuButton={<MenuButton>Open menu</MenuButton>}>
22
+ <MenuItem>New File</MenuItem>
23
+ <MenuItem>Save</MenuItem>
24
+ <SubMenu label="Edit">
25
+ <MenuItem>Cut</MenuItem>
26
+ <MenuItem>Copy</MenuItem>
27
+ <MenuItem>Paste</MenuItem>
28
+ </SubMenu>
29
+ <MenuItem>Print...</MenuItem>
30
+ <MenuDivider />
31
+ <MenuItem>Exit</MenuItem>
32
+ </Menu>
33
+ </>
34
+ );
35
+ };
36
+
37
+ export const ReactMenuControlled = ReactMenuTemplate.bind({});
package/src/utils/util.ts CHANGED
@@ -17,7 +17,8 @@ export const isFloat = (value: string) => {
17
17
  export const hasParentClass = function (className: string, child: Node) {
18
18
  let node: Node | null = child;
19
19
  while (node) {
20
- if (node instanceof Node && node instanceof HTMLElement && node.classList.contains(className)) {
20
+ // When nodes are in portals they aren't type node anymore hence treating it as any here
21
+ if ((node as any).classList && (node as any).classList.contains(className)) {
21
22
  return true;
22
23
  }
23
24
  node = node.parentNode;