@linzjs/step-ag-grid 1.4.5 → 1.4.7
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +284 -232
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridCell.d.ts +4 -3
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +8 -5
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -2
- package/dist/src/react-menu3/components/FocusableItem.d.ts +8 -0
- package/dist/src/react-menu3/components/Menu.d.ts +16 -2
- package/dist/src/react-menu3/components/MenuButton.d.ts +8 -1
- package/dist/src/react-menu3/components/MenuDivider.d.ts +2 -1
- package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -2
- package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -2
- package/dist/src/react-menu3/components/MenuItem.d.ts +56 -0
- package/dist/src/react-menu3/components/MenuList.d.ts +2 -29
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +44 -2
- package/dist/src/react-menu3/components/SubMenu.d.ts +109 -0
- package/dist/src/react-menu3/hooks/useBEM.d.ts +4 -3
- package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useItemEffect.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItemState.d.ts +4 -3
- package/dist/src/react-menu3/hooks/useItems.d.ts +6 -4
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -1
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +13 -10
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -10
- package/dist/src/react-menu3/index.d.ts +1 -0
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +10 -9
- package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +7 -6
- package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +7 -6
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +17 -19
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +18 -20
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +11 -6
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +23 -18
- package/dist/src/react-menu3/types.d.ts +389 -0
- package/dist/src/react-menu3/utils/constants.d.ts +58 -9
- package/dist/src/react-menu3/utils/index.d.ts +0 -1
- package/dist/src/react-menu3/utils/{propTypes.d.ts → propTypes2.d.ts} +1 -0
- package/dist/src/react-menu3/utils/utils.d.ts +20 -11
- package/dist/src/react-menu3/utils/withHovering.d.ts +7 -1
- package/dist/src/stories/components/ReactMenu.stories.d.ts +8 -0
- package/dist/step-ag-grid.esm.js +276 -235
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +11 -11
- package/src/components/GridCell.tsx +6 -3
- package/src/components/GridPopoverHook.tsx +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +1 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +36 -17
- package/src/components/gridRender/GridRenderGenericCell.tsx +11 -7
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +14 -2
- package/src/contexts/GridContextProvider.tsx +3 -2
- package/src/react-menu3/components/ControlledMenu.tsx +40 -45
- package/src/react-menu3/components/FocusableItem.tsx +58 -53
- package/src/react-menu3/components/Menu.tsx +40 -28
- package/src/react-menu3/components/MenuButton.tsx +30 -29
- package/src/react-menu3/components/MenuDivider.tsx +14 -18
- package/src/react-menu3/components/MenuGroup.tsx +25 -16
- package/src/react-menu3/components/MenuHeader.tsx +14 -18
- package/src/react-menu3/components/MenuItem.tsx +158 -106
- package/src/react-menu3/components/MenuList.tsx +61 -36
- package/src/react-menu3/components/MenuRadioGroup.tsx +54 -15
- package/src/react-menu3/components/SubMenu.tsx +317 -202
- package/src/react-menu3/hooks/useBEM.ts +4 -3
- package/src/react-menu3/hooks/useCombinedRef.ts +6 -12
- package/src/react-menu3/hooks/useItemEffect.ts +6 -5
- package/src/react-menu3/hooks/useItemState.ts +16 -12
- package/src/react-menu3/hooks/useItems.ts +11 -10
- package/src/react-menu3/hooks/useMenuChange.ts +3 -3
- package/src/react-menu3/hooks/useMenuState.ts +25 -7
- package/src/react-menu3/hooks/useMenuStateAndFocus.ts +6 -4
- package/src/react-menu3/index.ts +1 -0
- package/src/react-menu3/positionUtils/getPositionHelpers.ts +19 -12
- package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +12 -5
- package/src/react-menu3/positionUtils/placeArrowVertical.ts +12 -5
- package/src/react-menu3/positionUtils/placeLeftorRight.ts +33 -17
- package/src/react-menu3/positionUtils/placeToporBottom.ts +34 -18
- package/src/react-menu3/positionUtils/positionContextMenu.ts +15 -3
- package/src/react-menu3/positionUtils/positionMenu.ts +21 -14
- package/src/react-menu3/style-utils/index.ts +10 -7
- package/src/react-menu3/{index.d.ts → types.ts} +106 -358
- package/src/react-menu3/utils/constants.ts +82 -10
- package/src/react-menu3/utils/index.ts +1 -1
- package/src/react-menu3/utils/{propTypes.ts → propTypes2.ts} +3 -1
- package/src/react-menu3/utils/utils.ts +41 -24
- package/src/react-menu3/utils/withHovering.tsx +11 -6
- package/src/stories/components/GridReadOnly.stories.tsx +3 -4
- package/src/stories/components/ReactMenu.stories.tsx +37 -0
|
@@ -1,25 +1,44 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { unstable_batchedUpdates } from "react-dom";
|
|
2
|
+
import { MenuState, MenuStateOptions } from "../types";
|
|
3
|
+
import { MenuButtonProps } from "../components/MenuButton";
|
|
4
|
+
import { findIndex } from "lodash-es";
|
|
3
5
|
|
|
4
|
-
export const isMenuOpen = (state) => !!state && state[0] === "o";
|
|
5
|
-
export const batchedUpdates = unstable_batchedUpdates || ((callback) => callback());
|
|
6
|
-
export const values = Object.values || ((obj) => Object.keys(obj).map((key) => obj[key]));
|
|
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]));
|
|
7
9
|
export const floatEqual = (a: number, b: number, diff = 0.0001) => Math.abs(a - b) < diff;
|
|
8
|
-
|
|
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) =>
|
|
9
17
|
transition === true || !!(transition && transition[name]);
|
|
10
|
-
|
|
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
|
+
}
|
|
11
24
|
|
|
12
25
|
const internalKey = "_szhsinMenu";
|
|
13
|
-
export const getName = (component) => component[internalKey];
|
|
14
|
-
export const defineName = (name, component) =>
|
|
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 });
|
|
15
29
|
|
|
16
|
-
export const
|
|
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: any, source: any) => {
|
|
17
36
|
source &&
|
|
18
37
|
Object.keys(source).forEach((key) => {
|
|
19
38
|
const targetProp = target[key];
|
|
20
39
|
const sourceProp = source[key];
|
|
21
40
|
if (typeof sourceProp === "function" && targetProp) {
|
|
22
|
-
target[key] = (...arg) => {
|
|
41
|
+
target[key] = (...arg: any[]) => {
|
|
23
42
|
sourceProp(...arg);
|
|
24
43
|
targetProp(...arg);
|
|
25
44
|
};
|
|
@@ -31,8 +50,8 @@ export const mergeProps = (target: Record<string, any>, source: Record<string, a
|
|
|
31
50
|
return target;
|
|
32
51
|
};
|
|
33
52
|
|
|
34
|
-
export const parsePadding = (paddingStr) => {
|
|
35
|
-
if (
|
|
53
|
+
export const parsePadding = (paddingStr: string | undefined) => {
|
|
54
|
+
if (paddingStr == null) return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
36
55
|
|
|
37
56
|
const padding = paddingStr.trim().split(/\s+/, 4).map(parseFloat);
|
|
38
57
|
const top = !isNaN(padding[0]) ? padding[0] : 0;
|
|
@@ -46,26 +65,24 @@ export const parsePadding = (paddingStr) => {
|
|
|
46
65
|
};
|
|
47
66
|
|
|
48
67
|
// Adapted from https://github.com/popperjs/popper-core/tree/v2.9.1/src/dom-utils
|
|
49
|
-
export const getScrollAncestor = (node) => {
|
|
50
|
-
const thisWindow = node
|
|
68
|
+
export const getScrollAncestor = (node: Node | null): Element | null => {
|
|
69
|
+
const thisWindow = (node?.ownerDocument ?? document).defaultView ?? window;
|
|
51
70
|
while (node) {
|
|
52
71
|
node = node.parentNode;
|
|
53
|
-
if (!node || node === thisWindow
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
}
|
|
56
77
|
}
|
|
78
|
+
return null;
|
|
57
79
|
};
|
|
58
80
|
|
|
59
|
-
export function commonProps(isDisabled, isHovering) {
|
|
81
|
+
export function commonProps(isDisabled?: boolean, isHovering?: boolean) {
|
|
60
82
|
return {
|
|
61
83
|
"aria-disabled": isDisabled || undefined,
|
|
62
84
|
tabIndex: isHovering ? 0 : -1,
|
|
63
85
|
};
|
|
64
86
|
}
|
|
65
87
|
|
|
66
|
-
export
|
|
67
|
-
for (let i = 0; i < nodeList.length; i++) {
|
|
68
|
-
if (nodeList[i] === node) return i;
|
|
69
|
-
}
|
|
70
|
-
return -1;
|
|
71
|
-
}
|
|
88
|
+
export const indexOfNode = (nodeList: NodeListOf<Node>, node: Node) => findIndex(nodeList, node);
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import { memo, forwardRef, useContext, useRef } from "react";
|
|
1
|
+
import { memo, forwardRef, useContext, useRef, MutableRefObject } from "react";
|
|
3
2
|
import { HoverItemContext } from "./constants";
|
|
4
3
|
|
|
5
|
-
export
|
|
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 => {
|
|
6
11
|
const Component = memo(WrappedComponent);
|
|
7
12
|
const WithHovering = forwardRef<any>((props: any, ref) => {
|
|
8
|
-
const
|
|
13
|
+
const menuItemRef = useRef<any>(null);
|
|
9
14
|
return (
|
|
10
15
|
<Component
|
|
11
16
|
{...props}
|
|
12
|
-
|
|
17
|
+
menuItemRef={menuItemRef}
|
|
13
18
|
externalRef={ref}
|
|
14
|
-
isHovering={useContext(HoverItemContext) ===
|
|
19
|
+
isHovering={useContext(HoverItemContext) === menuItemRef.current}
|
|
15
20
|
/>
|
|
16
21
|
);
|
|
17
22
|
});
|
|
@@ -8,7 +8,6 @@ import { GridContextProvider } from "@contexts/GridContextProvider";
|
|
|
8
8
|
import { Grid, GridProps } from "@components/Grid";
|
|
9
9
|
import { useMemo, useState } from "react";
|
|
10
10
|
import { wait } from "@utils/util";
|
|
11
|
-
import { ICellRendererParams } from "ag-grid-community";
|
|
12
11
|
import { GridPopoverMenu } from "@components/gridPopoverEdit/GridPopoverMenu";
|
|
13
12
|
import { GridPopoverMessage } from "@components/gridPopoverEdit/GridPopoverMessage";
|
|
14
13
|
import { GridCell } from "@components/GridCell";
|
|
@@ -51,14 +50,14 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
51
50
|
initialWidth: 65,
|
|
52
51
|
maxWidth: 85,
|
|
53
52
|
}),
|
|
54
|
-
GridCell({
|
|
53
|
+
GridCell<ITestRow, any>({
|
|
55
54
|
field: "position",
|
|
56
55
|
headerName: "Position",
|
|
57
56
|
initialWidth: 65,
|
|
58
57
|
maxWidth: 150,
|
|
59
58
|
cellRendererParams: {
|
|
60
|
-
warning: (props
|
|
61
|
-
info: (props
|
|
59
|
+
warning: (props) => props.value === "Tester" && "Testers are testing",
|
|
60
|
+
info: (props) => props.value === "Developer" && "Developers are awesome",
|
|
62
61
|
},
|
|
63
62
|
}),
|
|
64
63
|
GridCell({
|
|
@@ -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({});
|