@linzjs/step-ag-grid 1.4.4 → 1.4.5

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 (100) hide show
  1. package/dist/index.js +1602 -3043
  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 +1 -0
  9. package/dist/src/react-menu3/components/Menu.d.ts +2 -0
  10. package/dist/src/react-menu3/components/MenuButton.d.ts +1 -0
  11. package/dist/src/react-menu3/components/MenuDivider.d.ts +2 -0
  12. package/dist/src/react-menu3/components/MenuGroup.d.ts +2 -0
  13. package/dist/src/react-menu3/components/MenuHeader.d.ts +2 -0
  14. package/dist/src/react-menu3/components/MenuItem.d.ts +1 -0
  15. package/dist/src/react-menu3/components/MenuList.d.ts +30 -0
  16. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -0
  17. package/dist/src/react-menu3/components/SubMenu.d.ts +1 -0
  18. package/dist/src/react-menu3/hooks/index.d.ts +9 -0
  19. package/dist/src/react-menu3/hooks/useBEM.d.ts +9 -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 +6 -0
  24. package/dist/src/react-menu3/hooks/useItems.d.ts +5 -0
  25. package/dist/src/react-menu3/hooks/useMenuChange.d.ts +1 -0
  26. package/dist/src/react-menu3/hooks/useMenuState.d.ts +11 -0
  27. package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +10 -0
  28. package/dist/src/react-menu3/index.d.ts +11 -0
  29. package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +10 -0
  30. package/dist/src/react-menu3/positionUtils/index.d.ts +3 -0
  31. package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +7 -0
  32. package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +7 -0
  33. package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +21 -0
  34. package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +21 -0
  35. package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +8 -0
  36. package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +21 -0
  37. package/dist/src/react-menu3/style-utils/index.d.ts +11 -0
  38. package/dist/src/react-menu3/utils/constants.d.ts +50 -0
  39. package/dist/src/react-menu3/utils/index.d.ts +4 -0
  40. package/dist/src/react-menu3/utils/propTypes.d.ts +55 -0
  41. package/dist/src/react-menu3/utils/utils.d.ts +27 -0
  42. package/dist/src/react-menu3/utils/withHovering.d.ts +1 -0
  43. package/dist/step-ag-grid.esm.js +1513 -2953
  44. package/dist/step-ag-grid.esm.js.map +1 -1
  45. package/package.json +18 -9
  46. package/src/components/GridLoadableCell.scss +4 -0
  47. package/src/components/GridLoadableCell.tsx +5 -1
  48. package/src/components/GridPopoverHook.tsx +4 -50
  49. package/src/components/gridForm/GridFormDropDown.tsx +2 -2
  50. package/src/components/gridForm/GridFormMultiSelect.tsx +4 -4
  51. package/src/components/gridForm/GridFormPopoutMenu.tsx +1 -1
  52. package/src/components/gridPopoverEdit/GridPopoverMenu.scss +6 -2
  53. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +1 -1
  54. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +7 -9
  55. package/src/react-menu3/components/ControlledMenu.tsx +260 -0
  56. package/src/react-menu3/components/FocusableItem.tsx +70 -0
  57. package/src/react-menu3/components/Menu.tsx +96 -0
  58. package/src/react-menu3/components/MenuButton.tsx +33 -0
  59. package/src/react-menu3/components/MenuDivider.tsx +21 -0
  60. package/src/react-menu3/components/MenuGroup.tsx +38 -0
  61. package/src/react-menu3/components/MenuHeader.tsx +21 -0
  62. package/src/react-menu3/components/MenuItem.tsx +130 -0
  63. package/src/react-menu3/components/MenuList.tsx +434 -0
  64. package/src/react-menu3/components/MenuRadioGroup.tsx +33 -0
  65. package/src/react-menu3/components/SubMenu.tsx +243 -0
  66. package/src/react-menu3/hooks/index.ts +9 -0
  67. package/src/react-menu3/hooks/useBEM.ts +32 -0
  68. package/src/react-menu3/hooks/useCombinedRef.ts +30 -0
  69. package/src/react-menu3/hooks/useIsomorphicLayoutEffect.ts +15 -0
  70. package/src/react-menu3/hooks/useItemEffect.ts +22 -0
  71. package/src/react-menu3/hooks/useItemState.ts +63 -0
  72. package/src/react-menu3/hooks/useItems.ts +110 -0
  73. package/src/react-menu3/hooks/useMenuChange.ts +12 -0
  74. package/src/react-menu3/hooks/useMenuState.ts +24 -0
  75. package/src/react-menu3/hooks/useMenuStateAndFocus.ts +15 -0
  76. package/src/react-menu3/index.d.ts +682 -0
  77. package/src/react-menu3/index.ts +11 -0
  78. package/src/react-menu3/positionUtils/getPositionHelpers.ts +76 -0
  79. package/src/react-menu3/positionUtils/index.ts +3 -0
  80. package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +8 -0
  81. package/src/react-menu3/positionUtils/placeArrowVertical.ts +8 -0
  82. package/src/react-menu3/positionUtils/placeLeftorRight.ts +76 -0
  83. package/src/react-menu3/positionUtils/placeToporBottom.ts +77 -0
  84. package/src/react-menu3/positionUtils/positionContextMenu.ts +49 -0
  85. package/src/react-menu3/positionUtils/positionMenu.ts +73 -0
  86. package/src/react-menu3/style-utils/index.ts +80 -0
  87. package/src/react-menu3/style-utils.d.ts +110 -0
  88. package/src/react-menu3/styles/_mixins.scss +11 -0
  89. package/src/react-menu3/styles/_var.scss +20 -0
  90. package/src/react-menu3/styles/core.scss +80 -0
  91. package/src/react-menu3/styles/index.scss +70 -0
  92. package/src/react-menu3/styles/theme-dark.scss +30 -0
  93. package/src/react-menu3/styles/transitions/slide.scss +47 -0
  94. package/src/react-menu3/utils/constants.ts +63 -0
  95. package/src/react-menu3/utils/index.ts +4 -0
  96. package/src/react-menu3/utils/propTypes.ts +61 -0
  97. package/src/react-menu3/utils/utils.ts +71 -0
  98. package/src/react-menu3/utils/withHovering.tsx +22 -0
  99. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +1 -3
  100. package/src/utils/util.ts +2 -1
@@ -0,0 +1,9 @@
1
+ export { useBEM } from "./useBEM";
2
+ export { useCombinedRef } from "./useCombinedRef";
3
+ export { useLayoutEffect } from "./useIsomorphicLayoutEffect";
4
+ export { useItems } from "./useItems";
5
+ export { useItemEffect } from "./useItemEffect";
6
+ export { useItemState } from "./useItemState";
7
+ export { useMenuChange } from "./useMenuChange";
8
+ export { useMenuState } from "./useMenuState";
9
+ export { useMenuStateAndFocus } from "./useMenuStateAndFocus";
@@ -0,0 +1,32 @@
1
+ import { useMemo } from "react";
2
+
3
+ type useBemModifiers = Record<string, boolean | string | undefined>;
4
+
5
+ interface useBemProps {
6
+ block: string;
7
+ element: string;
8
+ modifiers: useBemModifiers;
9
+ className: string | ((modifiers: useBemModifiers) => string | undefined);
10
+ }
11
+
12
+ // Generate className following BEM methodology: http://getbem.com/naming/
13
+ // Modifier value can be one of the following types: boolean, string, undefined
14
+ export const useBEM = ({ block, element, modifiers, className }: useBemProps) =>
15
+ useMemo(() => {
16
+ const blockElement = element ? `${block}__${element}` : block;
17
+
18
+ let classString = blockElement;
19
+ modifiers &&
20
+ Object.keys(modifiers).forEach((name) => {
21
+ const value = modifiers[name];
22
+ if (value) classString += ` ${blockElement}--${value === true ? name : `${name}-${value}`}`;
23
+ });
24
+
25
+ let expandedClassName = typeof className === "function" ? className(modifiers) : className;
26
+ if (typeof expandedClassName === "string") {
27
+ expandedClassName = expandedClassName.trim();
28
+ if (expandedClassName) classString += ` ${expandedClassName}`;
29
+ }
30
+
31
+ return classString;
32
+ }, [block, element, modifiers, className]);
@@ -0,0 +1,30 @@
1
+ import { Ref, MutableRefObject, useMemo } from "react";
2
+
3
+ // Adapted from material-ui
4
+ // https://github.com/mui-org/material-ui/blob/f996027d00e7e4bff3fc040786c1706f9c6c3f82/packages/material-ui-utils/src/useForkRef.ts
5
+
6
+ const setRef = <T>(
7
+ ref: MutableRefObject<T | null> | ((instance: T | null) => void) | null | undefined,
8
+ instance: T | null,
9
+ ) => {
10
+ if (typeof ref === "function") {
11
+ ref(instance);
12
+ } else if (ref) {
13
+ ref.current = instance;
14
+ }
15
+ };
16
+
17
+ export const useCombinedRef = <Instance>(
18
+ refA: Ref<Instance> | null | undefined,
19
+ refB: Ref<Instance> | null | undefined,
20
+ ): Ref<Instance> | null | undefined => {
21
+ return useMemo(() => {
22
+ if (!refA) return refB;
23
+ if (!refB) return refA;
24
+
25
+ return (instance) => {
26
+ setRef(refA, instance);
27
+ setRef(refB, instance);
28
+ };
29
+ }, [refA, refB]);
30
+ };
@@ -0,0 +1,15 @@
1
+ import { useEffect, useLayoutEffect } from "react";
2
+
3
+ // Get around a warning when using useLayoutEffect on the server.
4
+ // https://github.com/reduxjs/react-redux/blob/b48d087d76f666e1c6c5a9713bbec112a1631841/src/utils/useIsomorphicLayoutEffect.js#L12
5
+ // https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
6
+ // https://github.com/facebook/react/issues/14927#issuecomment-549457471
7
+
8
+ const useIsomorphicLayoutEffect =
9
+ typeof window !== "undefined" &&
10
+ typeof window.document !== "undefined" &&
11
+ typeof window.document.createElement !== "undefined"
12
+ ? useLayoutEffect
13
+ : useEffect;
14
+
15
+ export { useIsomorphicLayoutEffect as useLayoutEffect };
@@ -0,0 +1,22 @@
1
+ import { MutableRefObject } from "react";
2
+ import { useLayoutEffect } from "./useIsomorphicLayoutEffect";
3
+
4
+ export const useItemEffect = (
5
+ isDisabled: boolean,
6
+ itemRef: MutableRefObject<any>,
7
+ updateItems: (item: any, isMounted?: boolean) => void,
8
+ ) => {
9
+ useLayoutEffect(() => {
10
+ if (process.env.NODE_ENV !== "production" && !updateItems) {
11
+ throw new Error(
12
+ `[React-Menu] This menu item or submenu should be rendered under a menu: ${itemRef.current.outerHTML}`,
13
+ );
14
+ }
15
+ if (isDisabled) return;
16
+ const item = itemRef.current;
17
+ updateItems(item, true);
18
+ return () => {
19
+ updateItems(item);
20
+ };
21
+ }, [isDisabled, itemRef, updateItems]);
22
+ };
@@ -0,0 +1,63 @@
1
+ // @ts-nocheck
2
+ import { useRef, useContext, useEffect } from "react";
3
+ import { ItemSettingsContext, MenuListItemContext, HoverActionTypes } from "../utils";
4
+ import { useItemEffect } from "./useItemEffect";
5
+
6
+ // This hook includes some common stateful logic in MenuItem and FocusableItem
7
+ export const useItemState = (itemRef, focusRef, isHovering, isDisabled) => {
8
+ const { submenuCloseDelay } = useContext(ItemSettingsContext);
9
+ const { isParentOpen, isSubmenuOpen, dispatch, updateItems } = useContext(MenuListItemContext);
10
+ const timeoutId = useRef(0);
11
+
12
+ const setHover = () => {
13
+ !isHovering && !isDisabled && dispatch(HoverActionTypes.SET, itemRef.current);
14
+ };
15
+
16
+ const unsetHover = () => {
17
+ !isDisabled && dispatch(HoverActionTypes.UNSET, itemRef.current);
18
+ };
19
+
20
+ const onBlur = (e) => {
21
+ // Focus has moved out of the entire item
22
+ // It handles situation such as clicking on a sibling disabled menu item
23
+ if (isHovering && !e.currentTarget.contains(e.relatedTarget)) unsetHover();
24
+ };
25
+
26
+ const onPointerMove = () => {
27
+ if (isSubmenuOpen) {
28
+ if (!timeoutId.current)
29
+ timeoutId.current = setTimeout(() => {
30
+ timeoutId.current = 0;
31
+ setHover();
32
+ }, submenuCloseDelay);
33
+ } else {
34
+ setHover();
35
+ }
36
+ };
37
+
38
+ const onPointerLeave = (_, keepHover) => {
39
+ if (timeoutId.current) {
40
+ clearTimeout(timeoutId.current);
41
+ timeoutId.current = 0;
42
+ }
43
+
44
+ !keepHover && unsetHover();
45
+ };
46
+
47
+ useItemEffect(isDisabled, itemRef, updateItems);
48
+ useEffect(() => () => clearTimeout(timeoutId.current), []);
49
+ useEffect(() => {
50
+ // Don't set focus when parent menu is closed, otherwise focus will be lost
51
+ // and onBlur event will be fired with relatedTarget setting as null.
52
+ if (isHovering && isParentOpen) {
53
+ focusRef.current && focusRef.current.focus();
54
+ }
55
+ }, [focusRef, isHovering, isParentOpen]);
56
+
57
+ return {
58
+ setHover,
59
+ onBlur,
60
+ onPointerMove,
61
+ onPointerLeave,
62
+ };
63
+ };
@@ -0,0 +1,110 @@
1
+ // @ts-nocheck
2
+ import { useState, useCallback, useRef } from "react";
3
+ import { HoverActionTypes, indexOfNode } from "../utils";
4
+
5
+ export const useItems = (menuRef, focusRef) => {
6
+ const [hoverItem, setHoverItem] = useState();
7
+ const stateRef = useRef({
8
+ items: [],
9
+ hoverIndex: -1,
10
+ sorted: false,
11
+ });
12
+ const mutableState = stateRef.current;
13
+
14
+ const updateItems = useCallback(
15
+ (item, isMounted) => {
16
+ const { items } = mutableState;
17
+ if (!item) {
18
+ mutableState.items = [];
19
+ } else if (isMounted) {
20
+ items.push(item);
21
+ } else {
22
+ const index = items.indexOf(item);
23
+ if (index > -1) {
24
+ items.splice(index, 1);
25
+ if (item.contains(document.activeElement)) {
26
+ focusRef.current.focus();
27
+ setHoverItem();
28
+ }
29
+ }
30
+ }
31
+ mutableState.hoverIndex = -1;
32
+ mutableState.sorted = false;
33
+ },
34
+ [mutableState, focusRef],
35
+ );
36
+
37
+ const dispatch = useCallback(
38
+ (actionType, item, nextIndex) => {
39
+ const { items, hoverIndex } = mutableState;
40
+ const sortItems = () => {
41
+ if (mutableState.sorted) return;
42
+ const orderedNodes = menuRef.current.querySelectorAll(".szh-menu__item");
43
+ items.sort((a, b) => indexOfNode(orderedNodes, a) - indexOfNode(orderedNodes, b));
44
+ mutableState.sorted = true;
45
+ };
46
+
47
+ let index = -1,
48
+ newItem = undefined;
49
+ switch (actionType) {
50
+ case HoverActionTypes.RESET:
51
+ break;
52
+
53
+ case HoverActionTypes.SET:
54
+ newItem = item;
55
+ break;
56
+
57
+ case HoverActionTypes.UNSET:
58
+ newItem = (prevItem) => (prevItem === item ? undefined : prevItem);
59
+ break;
60
+
61
+ case HoverActionTypes.FIRST:
62
+ sortItems();
63
+ index = 0;
64
+ newItem = items[index];
65
+ break;
66
+
67
+ case HoverActionTypes.LAST:
68
+ sortItems();
69
+ index = items.length - 1;
70
+ newItem = items[index];
71
+ break;
72
+
73
+ case HoverActionTypes.SET_INDEX:
74
+ sortItems();
75
+ index = nextIndex;
76
+ newItem = items[index];
77
+ break;
78
+
79
+ case HoverActionTypes.INCREASE:
80
+ sortItems();
81
+ index = hoverIndex;
82
+ if (index < 0) index = items.indexOf(item);
83
+ index++;
84
+ if (index >= items.length) index = 0;
85
+ newItem = items[index];
86
+ break;
87
+
88
+ case HoverActionTypes.DECREASE:
89
+ sortItems();
90
+ index = hoverIndex;
91
+ if (index < 0) index = items.indexOf(item);
92
+ index--;
93
+ if (index < 0) index = items.length - 1;
94
+ newItem = items[index];
95
+ break;
96
+
97
+ default:
98
+ if (process.env.NODE_ENV !== "production")
99
+ throw new Error(`[React-Menu] Unknown hover action type: ${actionType}`);
100
+ }
101
+
102
+ if (!newItem) index = -1;
103
+ setHoverItem(newItem);
104
+ mutableState.hoverIndex = index;
105
+ },
106
+ [menuRef, mutableState],
107
+ );
108
+
109
+ return { hoverItem, dispatch, updateItems };
110
+ };
@@ -0,0 +1,12 @@
1
+ // @ts-nocheck
2
+ import { useRef, useEffect } from "react";
3
+ import { safeCall } from "../utils";
4
+
5
+ export const useMenuChange = (onMenuChange, isOpen) => {
6
+ const prevOpen = useRef(isOpen);
7
+
8
+ useEffect(() => {
9
+ if (prevOpen.current !== isOpen) safeCall(onMenuChange, { open: isOpen });
10
+ prevOpen.current = isOpen;
11
+ }, [onMenuChange, isOpen]);
12
+ };
@@ -0,0 +1,24 @@
1
+ import { useTransition } from "react-transition-state";
2
+ import { MenuStateMap, getTransition } from "../utils";
3
+
4
+ interface useMenuStateProps {
5
+ initialMounted?: boolean;
6
+ unmountOnClose?: boolean;
7
+ transition: boolean | Record<string, string>;
8
+ transitionTimeout?: number;
9
+ }
10
+
11
+ export const useMenuState = (props?: useMenuStateProps) => {
12
+ const { initialMounted, unmountOnClose, transition, transitionTimeout } = props ?? {
13
+ transition: false,
14
+ };
15
+ const [state, toggleMenu, endTransition] = useTransition({
16
+ mountOnEnter: !initialMounted,
17
+ unmountOnExit: unmountOnClose,
18
+ timeout: transitionTimeout ?? 500,
19
+ enter: getTransition(transition, "open"),
20
+ exit: getTransition(transition, "close"),
21
+ });
22
+
23
+ return [{ state: MenuStateMap[state], endTransition }, toggleMenu];
24
+ };
@@ -0,0 +1,15 @@
1
+ // @ts-nocheck
2
+ import { useState } from "react";
3
+ import { useMenuState } from "./useMenuState";
4
+
5
+ export const useMenuStateAndFocus = (options) => {
6
+ const [menuProps, toggleMenu] = useMenuState(options);
7
+ const [menuItemFocus, setMenuItemFocus] = useState();
8
+
9
+ const openMenu = (position, alwaysUpdate) => {
10
+ setMenuItemFocus({ position, alwaysUpdate });
11
+ toggleMenu(true);
12
+ };
13
+
14
+ return [{ menuItemFocus, ...menuProps }, toggleMenu, openMenu];
15
+ };