@linzjs/step-ag-grid 7.4.0 → 7.5.0
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.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/src/lui/ActionButton.d.ts +2 -3
- package/dist/src/utils/util.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +12 -5
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lui/ActionButton.tsx +3 -8
- package/src/stories/components/ActionButton.stories.tsx +3 -3
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +1 -1
- package/src/utils/util.ts +10 -0
package/package.json
CHANGED
package/src/lui/ActionButton.tsx
CHANGED
|
@@ -18,9 +18,7 @@ export interface ActionButtonProps {
|
|
|
18
18
|
size?: "xs" | "sm" | "md" | "lg" | "xl" | "ns";
|
|
19
19
|
iconPosition?: "left" | "right";
|
|
20
20
|
className?: "ActionButton-fill" | string;
|
|
21
|
-
|
|
22
|
-
// Used for external code to get access to whether action is in progress
|
|
23
|
-
externalSetInProgress?: () => void;
|
|
21
|
+
onClick: () => Promise<void> | void;
|
|
24
22
|
level?: LuiButtonProps["level"];
|
|
25
23
|
style?: React.CSSProperties;
|
|
26
24
|
}
|
|
@@ -36,8 +34,7 @@ export const ActionButton = ({
|
|
|
36
34
|
style,
|
|
37
35
|
className,
|
|
38
36
|
title,
|
|
39
|
-
|
|
40
|
-
externalSetInProgress,
|
|
37
|
+
onClick,
|
|
41
38
|
size = "sm",
|
|
42
39
|
iconPosition = "left",
|
|
43
40
|
level = "tertiary",
|
|
@@ -77,13 +74,11 @@ export const ActionButton = ({
|
|
|
77
74
|
size={"lg"}
|
|
78
75
|
style={{ ...(name == null && { padding: "8px 5px" }), ...style }}
|
|
79
76
|
onClick={async () => {
|
|
80
|
-
const promise =
|
|
77
|
+
const promise = onClick();
|
|
81
78
|
const isPromise = typeof promise !== "undefined";
|
|
82
79
|
if (isPromise) {
|
|
83
80
|
setInProgress(true);
|
|
84
|
-
externalSetInProgress && setInProgress(true);
|
|
85
81
|
if (isPromise) await promise;
|
|
86
|
-
externalSetInProgress && setInProgress(false);
|
|
87
82
|
setInProgress(false);
|
|
88
83
|
}
|
|
89
84
|
}}
|
|
@@ -18,14 +18,14 @@ const ActionButtonTemplate: ComponentStory<typeof ActionButton> = () => {
|
|
|
18
18
|
}, []);
|
|
19
19
|
return (
|
|
20
20
|
<>
|
|
21
|
-
<ActionButton icon={"ic_add"} name={"Add new row"} inProgressName={"Adding..."}
|
|
21
|
+
<ActionButton icon={"ic_add"} name={"Add new row"} inProgressName={"Adding..."} onClick={performAction} />
|
|
22
22
|
<br />
|
|
23
|
-
<ActionButton icon={"ic_add"} aria-label={"Add new row"}
|
|
23
|
+
<ActionButton icon={"ic_add"} aria-label={"Add new row"} onClick={performAction} level={"primary"} />
|
|
24
24
|
<br />
|
|
25
25
|
<ActionButton
|
|
26
26
|
icon={"ic_arrow_back"}
|
|
27
27
|
name={"Continue"}
|
|
28
|
-
|
|
28
|
+
onClick={performAction}
|
|
29
29
|
iconPosition={"right"}
|
|
30
30
|
level={"secondary"}
|
|
31
31
|
className={"ActionButton-fill"}
|
|
@@ -169,7 +169,7 @@ const GridPopoutEditGenericTemplate: ComponentStory<typeof Grid> = (props: GridP
|
|
|
169
169
|
rowData={rowData}
|
|
170
170
|
domLayout={"autoHeight"}
|
|
171
171
|
/>
|
|
172
|
-
<ActionButton icon={"ic_add"} name={"Add new row"} inProgressName={"Adding..."}
|
|
172
|
+
<ActionButton icon={"ic_add"} name={"Add new row"} inProgressName={"Adding..."} onClick={addRowAction} />
|
|
173
173
|
</>
|
|
174
174
|
);
|
|
175
175
|
};
|
package/src/utils/util.ts
CHANGED
|
@@ -12,6 +12,16 @@ export const isFloat = (value: string) => {
|
|
|
12
12
|
return regexp.test(value);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
export const findParentWithClass = function (className: string, child: Node): HTMLElement | null {
|
|
16
|
+
for (let node: Node | null = child; node; node = node.parentNode) {
|
|
17
|
+
// When nodes are in portals they aren't type node anymore hence treating it as any here
|
|
18
|
+
if ((node as any).classList && (node as any).classList.contains(className)) {
|
|
19
|
+
return node as HTMLElement;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
export const hasParentClass = function (className: string, child: Node) {
|
|
16
26
|
for (let node: Node | null = child; node; node = node.parentNode) {
|
|
17
27
|
// When nodes are in portals they aren't type node anymore hence treating it as any here
|