@linzjs/step-ag-grid 2.2.0 → 2.2.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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "2.2.0",
5
+ "version": "2.2.2",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -3,6 +3,7 @@ import { GridContext } from "../contexts/GridContext";
3
3
  import { GridBaseRow } from "./Grid";
4
4
  import { ControlledMenu } from "../react-menu3";
5
5
  import { GridPopoverContext } from "../contexts/GridPopoverContext";
6
+ import { MenuCloseEvent } from "../react-menu3/types";
6
7
 
7
8
  export interface GridPopoverHookProps<RowType> {
8
9
  className: string | undefined;
@@ -45,10 +46,14 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
45
46
  anchorRef={anchorRef}
46
47
  saveButtonRef={saveButtonRef}
47
48
  menuClassName={"step-ag-grid-react-menu"}
48
- onClose={(event: { reason: string }) => triggerSave(event.reason).then()}
49
+ onClose={(event: MenuCloseEvent) => {
50
+ if (event.reason === "blur") return;
51
+ triggerSave(event.reason).then();
52
+ }}
49
53
  viewScroll={"auto"}
50
54
  dontShrinkIfDirectionIsTop={true}
51
55
  className={props.className}
56
+ closeMenuExclusionClassName={"ReactModal__Content"}
52
57
  >
53
58
  {saving && ( // This is the overlay that prevents editing when the editor is saving
54
59
  <div
package/src/index.ts CHANGED
@@ -27,6 +27,9 @@ export { GridPopoverEditDropDown } from "./components/gridPopoverEdit/GridPopove
27
27
  export { GridPopoverMessage } from "./components/gridPopoverEdit/GridPopoverMessage";
28
28
  export { GridPopoverTextArea } from "./components/gridPopoverEdit/GridPopoverTextArea";
29
29
  export { GridPopoverTextInput } from "./components/gridPopoverEdit/GridPopoverTextInput";
30
+ export * from "./components/gridForm/GridFormDropDown";
31
+ export * from "./components/gridForm/GridFormMultiSelect";
32
+ export * from "./components/gridForm/GridFormPopoutMenu";
30
33
 
31
34
  export { GridHeaderSelect } from "./components/gridHeader/GridHeaderSelect";
32
35
 
@@ -40,6 +40,7 @@ export const ControlledMenuFr = (
40
40
  onItemClick,
41
41
  onClose,
42
42
  saveButtonRef,
43
+ closeMenuExclusionClassName,
43
44
  ...restProps
44
45
  }: ControlledMenuProps & { saveButtonRef?: MutableRefObject<HTMLButtonElement | null> },
45
46
  externalRef: ForwardedRef<HTMLUListElement>,
@@ -75,14 +76,16 @@ export const ControlledMenuFr = (
75
76
  ],
76
77
  );
77
78
 
78
- const clickIsWithinMenu = useCallback((ev: MouseEvent) => {
79
- return hasParentClass("szh-menu--state-open", ev.target as Node);
80
- }, []);
79
+ const clickIsWithinMenu = useCallback(
80
+ (ev: MouseEvent) =>
81
+ hasParentClass("szh-menu--state-open", ev.target as Node) ||
82
+ (closeMenuExclusionClassName && hasParentClass(closeMenuExclusionClassName, ev.target as Node)),
83
+ [closeMenuExclusionClassName],
84
+ );
81
85
 
82
86
  const handleScreenEventForSave = useCallback(
83
87
  (ev: MouseEvent) => {
84
88
  if (!clickIsWithinMenu(ev)) {
85
- //!ev.currentTarget.contains(ev.relatedTarget || document.activeElement)) {
86
89
  ev.preventDefault();
87
90
  ev.stopPropagation();
88
91
  // FIXME There's an issue in React17
@@ -439,4 +439,9 @@ export interface ControlledMenuProps extends RootMenuProps, ExtraMenuProps {
439
439
  * Event fired when menu is about to close.
440
440
  */
441
441
  onClose?: EventHandler<MenuCloseEvent>;
442
+
443
+ /**
444
+ * When clicking outside the menu to close, anything with this class will not cause a close.
445
+ */
446
+ closeMenuExclusionClassName?: string;
442
447
  }
@@ -1,7 +1,7 @@
1
1
  import "./FormTest.scss";
2
2
 
3
3
  import { useCallback, useState } from "react";
4
- import { LuiTextInput } from "@linzjs/lui";
4
+ import { LuiAlertModal, LuiAlertModalButtons, LuiButton, LuiTextInput } from "@linzjs/lui";
5
5
  import { wait } from "../../utils/util";
6
6
  import { CellEditorCommon, CellParams } from "../../components/GridCell";
7
7
  import { useGridPopoverHook } from "../../components/GridPopoverHook";
@@ -35,19 +35,59 @@ export const FormTest = <RowType extends GridBaseRow>(_props: CellEditorCommon):
35
35
  // Close form
36
36
  return true;
37
37
  }, [nameType, numba, plan, props.selectedRows]);
38
+
39
+ const [showModal, setShowModal] = useState<boolean>(false);
40
+
38
41
  const { popoverWrapper } = useGridPopoverHook({ className: _props.className, save });
39
42
 
40
43
  return popoverWrapper(
41
- <div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
42
- <div className={"FormTest-textInput"}>
43
- <LuiTextInput label={"Name type"} value={nameType} onChange={(e) => setNameType(e.target.value)} />
44
- </div>
45
- <div className={"FormTest-textInput"}>
46
- <LuiTextInput label={"Number"} value={numba} onChange={(e) => setNumba(e.target.value)} />
47
- </div>
48
- <div className={"FormTest-textInput"}>
49
- <LuiTextInput label={"Plan"} value={plan} onChange={(e) => setPlan(e.target.value)} />
44
+ <>
45
+ {showModal && (
46
+ <LuiAlertModal
47
+ data-testid="WarningAlertWithButtons-modal"
48
+ level="warning"
49
+ // If panel is popped out, append modal to poppped out window DOM, otherwise use default
50
+ //appendToElement={() => (poppedOut && popoutElement) || document.body}
51
+ >
52
+ <h2>Header</h2>
53
+ <p className="WarningAlertWithButtons-new-line">
54
+ This modal was added to help fix a bug where the onBlur for the context menu was prematurely closing the
55
+ editor and therefore this modal.
56
+ </p>
57
+ <LuiAlertModalButtons>
58
+ <LuiButton
59
+ level="secondary"
60
+ onClick={() => {
61
+ setShowModal(false);
62
+ }}
63
+ data-testid="WarningAlertWithButtons-cancel"
64
+ >
65
+ Cancel
66
+ </LuiButton>
67
+
68
+ <LuiButton
69
+ level="primary"
70
+ onClick={() => {
71
+ setShowModal(false);
72
+ }}
73
+ data-testid="WarningAlertWithButtons-ok"
74
+ >
75
+ OK
76
+ </LuiButton>
77
+ </LuiAlertModalButtons>
78
+ </LuiAlertModal>
79
+ )}
80
+ <div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
81
+ <div className={"FormTest-textInput"}>
82
+ <LuiTextInput label={"Name type"} value={nameType} onChange={(e) => setNameType(e.target.value)} />
83
+ </div>
84
+ <div className={"FormTest-textInput"}>
85
+ <LuiTextInput label={"Number"} value={numba} onChange={(e) => setNumba(e.target.value)} />
86
+ </div>
87
+ <div className={"FormTest-textInput"}>
88
+ <LuiButton onClick={() => setShowModal(true)}>Show Modal</LuiButton>
89
+ </div>
50
90
  </div>
51
- </div>,
91
+ </>,
52
92
  );
53
93
  };