@linzjs/step-ag-grid 2.0.0 → 2.1.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.
Files changed (119) hide show
  1. package/README.md +117 -2
  2. package/{src/components → dist}/GridTheme.scss +37 -23
  3. package/dist/index.css +351 -0
  4. package/dist/index.js +463 -212
  5. package/dist/index.js.map +1 -1
  6. package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -0
  7. package/dist/src/components/Grid.d.ts +0 -3
  8. package/dist/src/components/GridCell.d.ts +3 -0
  9. package/dist/src/components/GridPopoverHook.d.ts +2 -1
  10. package/dist/src/components/gridForm/GridFormDropDown.d.ts +4 -3
  11. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +3 -2
  12. package/dist/src/components/gridForm/GridFormMessage.d.ts +2 -2
  13. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +4 -2
  14. package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +2 -1
  15. package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -1
  16. package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -1
  17. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +4 -4
  18. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
  19. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -3
  20. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +2 -2
  21. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +2 -2
  22. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +2 -2
  23. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +4 -3
  24. package/dist/src/contexts/GridContext.d.ts +1 -1
  25. package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
  26. package/dist/src/index.d.ts +31 -0
  27. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -21
  28. package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -0
  29. package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -0
  30. package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -0
  31. package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -0
  32. package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -0
  33. package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -0
  34. package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -0
  35. package/dist/src/react-menu3/index.d.ts +0 -1
  36. package/dist/src/react-menu3/utils/constants.d.ts +1 -50
  37. package/dist/step-ag-grid.esm.js +462 -193
  38. package/dist/step-ag-grid.esm.js.map +1 -1
  39. package/package.json +48 -26
  40. package/src/components/ComponentLoadingWrapper.tsx +2 -1
  41. package/src/components/Grid.tsx +2 -9
  42. package/src/components/GridCell.tsx +5 -0
  43. package/src/components/GridLoadableCell.tsx +0 -4
  44. package/src/components/GridPopoverHook.tsx +13 -7
  45. package/src/components/gridForm/GridFormDropDown.tsx +17 -13
  46. package/src/components/gridForm/GridFormEditBearing.tsx +4 -4
  47. package/src/components/gridForm/GridFormMessage.tsx +6 -7
  48. package/src/components/gridForm/GridFormMultiSelect.tsx +73 -63
  49. package/src/components/gridForm/GridFormPopoutMenu.tsx +6 -6
  50. package/src/components/gridForm/GridFormTextArea.tsx +4 -4
  51. package/src/components/gridForm/GridFormTextInput.tsx +3 -3
  52. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +4 -0
  53. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +4 -4
  54. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +7 -2
  55. package/src/components/gridPopoverEdit/GridPopoverMenu.scss +4 -4
  56. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -3
  57. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +2 -2
  58. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +2 -2
  59. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +2 -2
  60. package/src/components/gridRender/GridRenderGenericCell.tsx +3 -2
  61. package/src/contexts/GridContext.tsx +1 -1
  62. package/src/contexts/GridPopoverContext.tsx +1 -7
  63. package/src/contexts/GridPopoverContextProvider.tsx +23 -22
  64. package/src/index.ts +38 -0
  65. package/src/lui/TextInputFormatted.scss +1 -1
  66. package/src/react-menu3/README.md +66 -0
  67. package/src/react-menu3/components/ControlledMenu.tsx +9 -17
  68. package/src/react-menu3/components/FocusableItem.tsx +2 -9
  69. package/src/react-menu3/components/MenuGroup.tsx +2 -1
  70. package/src/react-menu3/components/MenuItem.tsx +3 -12
  71. package/src/react-menu3/components/MenuList.tsx +4 -4
  72. package/src/react-menu3/components/MenuRadioGroup.tsx +3 -22
  73. package/src/react-menu3/components/SubMenu.tsx +4 -4
  74. package/src/react-menu3/contexts/EventHandlersContext.ts +11 -0
  75. package/src/react-menu3/contexts/HoverItemContext.ts +3 -0
  76. package/src/react-menu3/contexts/ItemSettingsContext.ts +6 -0
  77. package/src/react-menu3/contexts/MenuListContext.ts +10 -0
  78. package/src/react-menu3/contexts/MenuListItemContext.ts +16 -0
  79. package/src/react-menu3/contexts/RadioGroupContext.ts +8 -0
  80. package/src/react-menu3/contexts/SettingsContext.ts +20 -0
  81. package/src/react-menu3/hooks/useItemState.ts +3 -1
  82. package/src/react-menu3/index.ts +0 -1
  83. package/src/react-menu3/styles/_var.scss +4 -4
  84. package/src/react-menu3/styles/core.scss +6 -6
  85. package/src/react-menu3/styles/index.scss +10 -7
  86. package/src/react-menu3/styles/theme-dark.scss +4 -2
  87. package/src/react-menu3/styles/transitions/slide.scss +8 -8
  88. package/src/react-menu3/utils/constants.ts +1 -74
  89. package/src/react-menu3/utils/withHovering.tsx +1 -1
  90. package/src/stories/components/FormTest.scss +1 -2
  91. package/src/stories/components/FormTest.tsx +3 -3
  92. package/src/stories/components/GridPopoutBearing.stories.tsx +4 -4
  93. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +6 -5
  94. package/src/stories/components/GridPopoutEditGeneric.stories.tsx +5 -7
  95. package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +4 -4
  96. package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +4 -4
  97. package/src/stories/components/GridReadOnly.stories.tsx +14 -18
  98. package/src/stories/components/ReactMenu.stories.tsx +0 -4
  99. package/src/{components → styles}/Grid.scss +9 -6
  100. package/src/styles/GridFormDropDown.scss +18 -0
  101. package/src/{components/gridForm → styles}/GridFormEditBearing.scss +0 -0
  102. package/src/styles/GridFormMultiSelect.scss +18 -0
  103. package/src/styles/GridRenderGenericCell.scss +15 -0
  104. package/src/styles/GridTheme.scss +108 -0
  105. package/src/styles/index.scss +2 -0
  106. package/src/styles/lui-overrides.scss +49 -0
  107. package/src/styles/react-menu-customisations.scss +135 -0
  108. package/dist/index.d.ts +0 -38
  109. package/dist/src/stories/components/FormTest.d.ts +0 -12
  110. package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +0 -9
  111. package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +0 -9
  112. package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +0 -9
  113. package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +0 -9
  114. package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +0 -9
  115. package/dist/src/stories/components/GridReadOnly.stories.d.ts +0 -9
  116. package/dist/src/stories/components/ReactMenu.stories.d.ts +0 -8
  117. package/src/components/gridRender/GridRenderGenericCell.scss +0 -15
  118. package/src/lui-overrides.scss +0 -163
  119. package/src/react-menu3/style-utils.d.ts +0 -110
@@ -2,9 +2,9 @@ import { useCallback, useState } from "react";
2
2
  import { TextAreaInput } from "../../lui/TextAreaInput";
3
3
  import { useGridPopoverHook } from "../GridPopoverHook";
4
4
  import { GridBaseRow } from "../Grid";
5
- import { CellParams } from "@components/GridCell";
5
+ import { CellEditorCommon, CellParams } from "@components/GridCell";
6
6
 
7
- export interface GridFormTextAreaProps<RowType extends GridBaseRow> {
7
+ export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends CellEditorCommon {
8
8
  placeholder?: string;
9
9
  required?: boolean;
10
10
  maxlength?: number;
@@ -50,9 +50,9 @@ export const GridFormTextArea = <RowType extends GridBaseRow>(_props: GridFormTe
50
50
  },
51
51
  [props, invalid, value],
52
52
  );
53
- const { popoverWrapper } = useGridPopoverHook({ save });
53
+ const { popoverWrapper } = useGridPopoverHook({ className: props.className, save });
54
54
  return popoverWrapper(
55
- <div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }} className={"FormTest"}>
55
+ <div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }}>
56
56
  <TextAreaInput
57
57
  value={value}
58
58
  onChange={(e) => setValue(e.target.value)}
@@ -2,9 +2,9 @@ import { useCallback, useState } from "react";
2
2
  import { TextInputFormatted } from "../../lui/TextInputFormatted";
3
3
  import { useGridPopoverHook } from "../GridPopoverHook";
4
4
  import { GridBaseRow } from "../Grid";
5
- import { CellParams } from "@components/GridCell";
5
+ import { CellEditorCommon, CellParams } from "@components/GridCell";
6
6
 
7
- export interface GridFormTextInputProps<RowType extends GridBaseRow> {
7
+ export interface GridFormTextInputProps<RowType extends GridBaseRow> extends CellEditorCommon {
8
8
  placeholder?: string;
9
9
  units?: string;
10
10
  required?: boolean;
@@ -54,7 +54,7 @@ export const GridFormTextInput = <RowType extends GridBaseRow>(_props: GridFormT
54
54
  },
55
55
  [invalid, value, initValue, props],
56
56
  );
57
- const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
57
+ const { popoverWrapper, triggerSave } = useGridPopoverHook({ className: props.className, save });
58
58
 
59
59
  return popoverWrapper(
60
60
  <div style={{ display: "flex", flexDirection: "row", width: props.width ?? 240 }} className={"FormTest"}>
@@ -18,5 +18,9 @@ export const GridPopoutEditMultiSelect = <RowType extends GridBaseRow, ValueType
18
18
  {
19
19
  editor: GridFormMultiSelect,
20
20
  ...props,
21
+ editorParams: {
22
+ className: "GridMultiSelect-containerMedium",
23
+ ...(props.editorParams as GridFormMultiSelectProps<RowType, ValueType>),
24
+ },
21
25
  },
22
26
  );
@@ -3,10 +3,10 @@ import { bearingCorrectionValueFormatter, bearingValueFormatter } from "@utils/b
3
3
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
4
4
  import { GridFormEditBearing, GridFormEditBearingProps } from "../gridForm/GridFormEditBearing";
5
5
  import { GridBaseRow } from "../Grid";
6
- import { ColDef } from "ag-grid-community";
6
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
7
7
 
8
8
  export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
9
- colDef: ColDef,
9
+ colDef: GenericCellColDef<RowType>,
10
10
  props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
11
11
  ): ColDefT<RowType> => {
12
12
  return GridCell(
@@ -25,7 +25,7 @@ export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
25
25
  };
26
26
 
27
27
  export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
28
- colDef: ColDef,
28
+ colDef: GenericCellColDef<RowType>,
29
29
  props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
30
30
  ): ColDefT<RowType> => {
31
31
  return GridPopoverEditBearingLike(
@@ -47,7 +47,7 @@ export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
47
47
  };
48
48
 
49
49
  export const GridPopoverEditBearingCorrection = <RowType extends GridBaseRow>(
50
- colDef: ColDef,
50
+ colDef: GenericCellColDef<RowType>,
51
51
  props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
52
52
  ): ColDefT<RowType> => {
53
53
  return GridPopoverEditBearingLike(
@@ -2,10 +2,10 @@ import { GenericMultiEditCellClass } from "../GenericCellClass";
2
2
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
3
3
  import { GridBaseRow } from "../Grid";
4
4
  import { GridFormDropDown, GridFormPopoutDropDownProps } from "../gridForm/GridFormDropDown";
5
- import { ColDef } from "ag-grid-community";
5
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
6
6
 
7
7
  export const GridPopoverEditDropDown = <RowType extends GridBaseRow, ValueType>(
8
- colDef: ColDef,
8
+ colDef: GenericCellColDef<RowType>,
9
9
  props: GenericCellEditorProps<GridFormPopoutDropDownProps<RowType, ValueType>>,
10
10
  ): ColDefT<RowType> =>
11
11
  GridCell(
@@ -18,5 +18,10 @@ export const GridPopoverEditDropDown = <RowType extends GridBaseRow, ValueType>(
18
18
  {
19
19
  editor: GridFormDropDown,
20
20
  ...props,
21
+ editorParams: {
22
+ // Defaults to medium size container
23
+ className: "GridPopoverEditDropDown-containerMedium",
24
+ ...(props.editorParams as GridFormPopoutDropDownProps<RowType, ValueType>),
25
+ },
21
26
  },
22
27
  );
@@ -1,13 +1,13 @@
1
- @use 'node_modules/@linzjs/lui/dist/scss/Core' as lui;
1
+ @use "../../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
2
2
 
3
3
  .GridPopoutMenu-burger {
4
4
  cursor: pointer;
5
5
 
6
- & svg {
7
- fill: lui.$sea;
6
+ svg {
7
+ fill: colors.$sea;
8
8
  }
9
9
  }
10
10
 
11
11
  .GridPopoutMenu-burgerDisabled svg {
12
- fill: lui.$disabled-color;
12
+ fill: colors.$disabled-color;
13
13
  }
@@ -1,18 +1,17 @@
1
1
  import "./GridPopoverMenu.scss";
2
- import "../../react-menu3/styles/index.scss";
3
2
 
4
- import { ColDef } from "ag-grid-community";
5
3
  import { GenericMultiEditCellClass } from "../GenericCellClass";
6
4
  import { GridBaseRow } from "../Grid";
7
5
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
8
6
  import { GridFormPopoutMenu, GridFormPopoutMenuProps } from "../gridForm/GridFormPopoutMenu";
9
7
  import { GridRenderPopoutMenuCell } from "../gridRender/GridRenderPopoutMenuCell";
8
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
10
9
 
11
10
  /**
12
11
  * Popout burger menu
13
12
  */
14
13
  export const GridPopoverMenu = <RowType extends GridBaseRow>(
15
- colDef: ColDef,
14
+ colDef: GenericCellColDef<RowType>,
16
15
  props: GenericCellEditorProps<GridFormPopoutMenuProps<RowType>>,
17
16
  ): ColDefT<RowType> =>
18
17
  GridCell<RowType, GridFormPopoutMenuProps<RowType>>(
@@ -1,10 +1,10 @@
1
1
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
2
2
  import { GridFormMessage, GridFormMessageProps } from "../gridForm/GridFormMessage";
3
3
  import { GridBaseRow } from "../Grid";
4
- import { ColDef } from "ag-grid-community";
4
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
5
5
 
6
6
  export const GridPopoverMessage = <RowType extends GridBaseRow>(
7
- colDef: ColDef,
7
+ colDef: GenericCellColDef<RowType>,
8
8
  props: GenericCellEditorProps<GridFormMessageProps<RowType>>,
9
9
  ): ColDefT<RowType> => {
10
10
  return GridCell(
@@ -1,10 +1,10 @@
1
1
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { GridFormTextArea, GridFormTextAreaProps } from "../gridForm/GridFormTextArea";
4
- import { ColDef } from "ag-grid-community";
4
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
5
5
 
6
6
  export const GridPopoverTextArea = <RowType extends GridBaseRow>(
7
- colDef: ColDef,
7
+ colDef: GenericCellColDef<RowType>,
8
8
  params: GenericCellEditorProps<GridFormTextAreaProps<RowType>>,
9
9
  ): ColDefT<RowType> =>
10
10
  GridCell(
@@ -1,10 +1,10 @@
1
1
  import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { GridFormTextInput, GridFormTextInputProps } from "../gridForm/GridFormTextInput";
4
- import { ColDef } from "ag-grid-community";
4
+ import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
5
5
 
6
6
  export const GridPopoverTextInput = <RowType extends GridBaseRow>(
7
- colDef: ColDef,
7
+ colDef: GenericCellColDef<RowType>,
8
8
  params: GenericCellEditorProps<GridFormTextInputProps<RowType>>,
9
9
  ): ColDefT<RowType> => {
10
10
  return GridCell(
@@ -1,4 +1,4 @@
1
- import "./GridRenderGenericCell.scss";
1
+ import "../../styles/GridRenderGenericCell.scss";
2
2
 
3
3
  import { useContext } from "react";
4
4
  import { GridUpdatingContext } from "@contexts/GridUpdatingContext";
@@ -7,12 +7,13 @@ import { GridIcon } from "../GridIcon";
7
7
  import { ColDef, ICellRendererParams } from "ag-grid-community";
8
8
  import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
9
9
  import { GridBaseRow } from "../Grid";
10
+ import { ColDefT } from "@components/GridCell";
10
11
 
11
12
  export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
12
13
  data: RowType;
13
14
  }
14
15
 
15
- export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDef {
16
+ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<RowType> {
16
17
  cellRendererParams?: GenericCellRendererParams<RowType>;
17
18
  }
18
19
 
@@ -7,7 +7,7 @@ export interface GridContextType {
7
7
  setGridApi: (gridApi: GridApi | undefined) => void;
8
8
  setQuickFilter: (quickFilter: string) => void;
9
9
  editingCells: () => boolean;
10
- getSelectedRows: <T extends unknown>() => T[];
10
+ getSelectedRows: <T extends GridBaseRow>() => T[];
11
11
  getSelectedRowIds: () => number[];
12
12
  selectRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
13
13
  selectRowsWithFlashDiff: (updateFn: () => Promise<any>) => Promise<void>;
@@ -6,11 +6,11 @@ export interface PropsType {
6
6
  data: any;
7
7
  field: string;
8
8
  selectedRows: any[];
9
+ updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>;
9
10
  }
10
11
 
11
12
  export type GridPopoverContextType = {
12
13
  anchorRef: RefObject<Element>;
13
- updateValueRef: RefObject<(saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>>;
14
14
  saving: boolean;
15
15
  setSaving: (saving: boolean) => void;
16
16
  setProps: (props: ICellEditorParams, multiEdit: boolean) => void;
@@ -19,12 +19,6 @@ export type GridPopoverContextType = {
19
19
 
20
20
  export const GridPopoverContext = createContext<GridPopoverContextType>({
21
21
  anchorRef: { current: null },
22
- updateValueRef: {
23
- current: async () => {
24
- console.error("Missing GridPopoverContext updateValueRef");
25
- return false;
26
- },
27
- },
28
22
  saving: false,
29
23
  setSaving: () => {},
30
24
  setProps: () => {},
@@ -1,8 +1,9 @@
1
- import { ReactNode, RefObject, useContext, useRef, useState } from "react";
1
+ import { ReactNode, RefObject, useCallback, useContext, useRef, useState } from "react";
2
2
  import { GridPopoverContext, PropsType } from "./GridPopoverContext";
3
3
  import { ICellEditorParams } from "ag-grid-community";
4
- import { GridBaseRow } from "@components/Grid";
5
4
  import { GridContext } from "@contexts/GridContext";
5
+ import { sortBy } from "lodash-es";
6
+ import { GridBaseRow } from "@components/Grid";
6
7
 
7
8
  interface GridPopoverContextProps {
8
9
  children: ReactNode;
@@ -12,29 +13,30 @@ export const GridPopoverContextProvider = (props: GridPopoverContextProps) => {
12
13
  const { getSelectedRows, updatingCells } = useContext(GridContext);
13
14
  const anchorRef = useRef<Element>();
14
15
  const propsRef = useRef<PropsType>({} as PropsType);
15
- const updateValueRef = useRef<(saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>>(async () => {
16
- console.error("updateValueRef.current is not set");
17
- return false;
18
- });
19
16
 
20
17
  const [saving, setSaving] = useState(false);
21
18
 
22
- const setProps = (props: ICellEditorParams, multiEdit: boolean) => {
23
- const selectedRows = multiEdit ? getSelectedRows<GridBaseRow>() : [props.data];
24
- const field = props.colDef?.field ?? "";
19
+ const setProps = useCallback(
20
+ (props: ICellEditorParams, multiEdit: boolean) => {
21
+ // Then item that is clicked on will always be first in the list
22
+ const selectedRows = multiEdit
23
+ ? sortBy(getSelectedRows(), (row) => row.id !== props.data.id)
24
+ : [props.data as GridBaseRow];
25
+ const field = props.colDef?.field ?? "";
25
26
 
26
- anchorRef.current = props.eGridCell;
27
- propsRef.current = {
28
- value: props.value,
29
- data: props.data,
30
- field,
31
- selectedRows,
32
- };
33
-
34
- updateValueRef.current = async (saveFn: (selectedRows: any[]) => Promise<boolean>): Promise<boolean> => {
35
- return !saving && (await updatingCells({ selectedRows, field }, saveFn, setSaving));
36
- };
37
- };
27
+ anchorRef.current = props.eGridCell;
28
+ propsRef.current = {
29
+ value: props.value,
30
+ data: props.data,
31
+ field,
32
+ selectedRows,
33
+ updateValue: async (saveFn: (selectedRows: any[]) => Promise<boolean>): Promise<boolean> => {
34
+ return !saving && (await updatingCells({ selectedRows, field }, saveFn, setSaving));
35
+ },
36
+ };
37
+ },
38
+ [getSelectedRows, saving, updatingCells],
39
+ );
38
40
 
39
41
  return (
40
42
  <GridPopoverContext.Provider
@@ -42,7 +44,6 @@ export const GridPopoverContextProvider = (props: GridPopoverContextProps) => {
42
44
  anchorRef: anchorRef as any as RefObject<Element>,
43
45
  saving,
44
46
  setSaving,
45
- updateValueRef,
46
47
  propsRef,
47
48
  setProps,
48
49
  }}
package/src/index.ts ADDED
@@ -0,0 +1,38 @@
1
+ export * from "@react-menu3";
2
+ export * from "./react-menu3/types";
3
+
4
+ export * from "@contexts/GridUpdatingContext";
5
+ export * from "@contexts/GridUpdatingContextProvider";
6
+ export * from "@contexts/GridContext";
7
+ export * from "@contexts/GridContextProvider";
8
+
9
+ export type { GridBaseRow } from "@components/Grid";
10
+ export { Grid } from "@components/Grid";
11
+ export * from "@components/GridCell";
12
+ export { GridIcon } from "@components/GridIcon";
13
+ export { ComponentLoadingWrapper } from "@components/ComponentLoadingWrapper";
14
+ export { GenericMultiEditCellClass } from "@components/GenericCellClass";
15
+ export { GridLoadableCell } from "@components/GridLoadableCell";
16
+ export { useGridPopoverHook } from "@components/GridPopoverHook";
17
+ export { usePostSortRowsHook } from "@components/PostSortRowsHook";
18
+
19
+ export { GridRendererGenericCell } from "@components/gridRender/GridRenderGenericCell";
20
+ export { GridRenderPopoutMenuCell } from "@components/gridRender/GridRenderPopoutMenuCell";
21
+
22
+ export { GridPopoutEditMultiSelect } from "@components/gridPopoverEdit/GridPopoutEditMultiSelect";
23
+ export { GridPopoverMenu } from "@components/gridPopoverEdit/GridPopoverMenu";
24
+ export { GridPopoverEditBearing } from "@components/gridPopoverEdit/GridPopoverEditBearing";
25
+ export { GridPopoverEditBearingCorrection } from "@components/gridPopoverEdit/GridPopoverEditBearing";
26
+ export { GridPopoverEditDropDown } from "@components/gridPopoverEdit/GridPopoverEditDropDown";
27
+ export { GridPopoverMessage } from "@components/gridPopoverEdit/GridPopoverMessage";
28
+ export { GridPopoverTextArea } from "@components/gridPopoverEdit/GridPopoverTextArea";
29
+ export { GridPopoverTextInput } from "@components/gridPopoverEdit/GridPopoverTextInput";
30
+
31
+ export { GridHeaderSelect } from "@components/gridHeader/GridHeaderSelect";
32
+
33
+ export { TextAreaInput } from "./lui/TextAreaInput";
34
+ export { TextInputFormatted } from "./lui/TextInputFormatted";
35
+ export { GridSubComponentTextArea } from "@components/GridSubComponentTextArea";
36
+
37
+ export * from "@utils/bearing";
38
+ export * from "@utils/util";
@@ -8,4 +8,4 @@
8
8
  top: 0;
9
9
  line-height: 48px;
10
10
  color: #beb9b4;
11
- }
11
+ }
@@ -0,0 +1,66 @@
1
+ # React-Menu
2
+
3
+ > This is a fork of @szhsin/react-menu. v3.2.0
4
+
5
+ > An accessible and keyboard-friendly React menu library.
6
+
7
+ **[Live examples and docs](https://szhsin.github.io/react-menu/)**
8
+
9
+ ## Features
10
+
11
+ - React menu components for easy and fast web development.
12
+ - Unlimited levels of submenu.
13
+ - Supports dropdown or context menu.
14
+ - Supports radio and checkbox menu items.
15
+ - Flexible menu positioning.
16
+ - Comprehensive keyboard interactions.
17
+ - Unstyled components and easy [customisation](https://szhsin.github.io/react-menu/#styling).
18
+ - [Optimal level support](https://github.com/reactwg/react-18/discussions/70) (level 3) of **React 18** concurrent rendering.
19
+ - Works in major browsers without polyfills.
20
+ - [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/menu/) compliant.
21
+
22
+ ## Install
23
+
24
+ with npm
25
+
26
+ ```bash
27
+ npm install @szhsin/react-menu
28
+ ```
29
+
30
+ or with Yarn
31
+
32
+ ```bash
33
+ yarn add @szhsin/react-menu
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ```jsx
39
+ import { Menu, MenuItem, MenuButton, SubMenu } from "@szhsin/react-menu";
40
+
41
+ export default function App() {
42
+ return (
43
+ <Menu menuButton={<MenuButton>Open menu</MenuButton>}>
44
+ <MenuItem>New File</MenuItem>
45
+ <MenuItem>Save</MenuItem>
46
+ <SubMenu label="Edit">
47
+ <MenuItem>Cut</MenuItem>
48
+ <MenuItem>Copy</MenuItem>
49
+ <MenuItem>Paste</MenuItem>
50
+ </SubMenu>
51
+ <MenuItem>Print...</MenuItem>
52
+ </Menu>
53
+ );
54
+ }
55
+ ```
56
+
57
+ **[Edit on CodeSandbox](https://codesandbox.io/s/react-menu-starter-3ez3c)**<br>
58
+ **[Visit more examples and docs](https://szhsin.github.io/react-menu/)**<br><br>
59
+ [Migration from v2 to v3](https://github.com/szhsin/react-menu/wiki/Migration-from-v2-to-v3)<br>
60
+ [Migration from v1 to v2](https://github.com/szhsin/react-menu/wiki/Migration-from-v1-to-v2)
61
+
62
+ _Please note that React-Menu v3 requires React 16.14.0 or higher. If you are not able to upgrade React, you could install v2/v1 which requires React 16.8.0._
63
+
64
+ ## License
65
+
66
+ [MIT](https://github.com/szhsin/react-menu/blob/master/LICENSE) Licensed.
@@ -12,20 +12,12 @@ import {
12
12
  import { createPortal } from "react-dom";
13
13
  import { MenuList } from "./MenuList";
14
14
  import { useBEM } from "../hooks";
15
- import {
16
- menuContainerClass,
17
- mergeProps,
18
- safeCall,
19
- isMenuOpen,
20
- getTransition,
21
- CloseReason,
22
- Keys,
23
- EventHandlersContext,
24
- SettingsContext,
25
- ItemSettingsContext,
26
- } from "../utils";
15
+ import { menuContainerClass, mergeProps, safeCall, isMenuOpen, getTransition, CloseReason, Keys } from "../utils";
27
16
  import { hasParentClass } from "@utils/util";
28
17
  import { ControlledMenuProps, PortalFieldType, RadioChangeEvent } from "../types";
18
+ import { ItemSettingsContext } from "../contexts/ItemSettingsContext";
19
+ import { SettingsContext } from "../contexts/SettingsContext";
20
+ import { EventHandlersContext, EventHandlersContextType } from "../contexts/EventHandlersContext";
29
21
 
30
22
  export const ControlledMenuFr = (
31
23
  {
@@ -128,13 +120,13 @@ export const ControlledMenuFr = (
128
120
  useEffect(() => {
129
121
  if (isMenuOpen(state)) {
130
122
  const thisDocument = anchorRef?.current ? anchorRef?.current.ownerDocument : document;
131
- thisDocument.addEventListener("mousedown", handleScreenEventForCancel, true);
132
- thisDocument.addEventListener("mouseup", handleScreenEventForSave, true);
123
+ thisDocument.addEventListener("mousedown", handleScreenEventForSave, true);
124
+ thisDocument.addEventListener("mouseup", handleScreenEventForCancel, true);
133
125
  thisDocument.addEventListener("click", handleScreenEventForCancel, true);
134
126
  thisDocument.addEventListener("dblclick", handleScreenEventForCancel, true);
135
127
  return () => {
136
- thisDocument.removeEventListener("mousedown", handleScreenEventForCancel, true);
137
- thisDocument.removeEventListener("mouseup", handleScreenEventForSave, true);
128
+ thisDocument.removeEventListener("mousedown", handleScreenEventForSave, true);
129
+ thisDocument.removeEventListener("mouseup", handleScreenEventForCancel, true);
138
130
  thisDocument.removeEventListener("click", handleScreenEventForCancel, true);
139
131
  thisDocument.removeEventListener("dblclick", handleScreenEventForCancel, true);
140
132
  };
@@ -151,7 +143,7 @@ export const ControlledMenuFr = (
151
143
  );
152
144
 
153
145
  const eventHandlers = useMemo(
154
- () => ({
146
+ (): EventHandlersContextType => ({
155
147
  handleClick(event: RadioChangeEvent, isCheckOrRadio: boolean) {
156
148
  if (!event.stopPropagation) safeCall(onItemClick, event);
157
149
 
@@ -1,16 +1,9 @@
1
1
  import { LegacyRef, useContext, useMemo, useRef } from "react";
2
2
  import { useBEM, useCombinedRef, useItemState } from "../hooks";
3
- import {
4
- mergeProps,
5
- commonProps,
6
- safeCall,
7
- menuClass,
8
- menuItemClass,
9
- withHovering,
10
- EventHandlersContext,
11
- } from "../utils";
3
+ import { mergeProps, commonProps, safeCall, menuClass, menuItemClass, withHovering } from "../utils";
12
4
  import { BaseProps } from "../types";
13
5
  import { withHoveringResultProps } from "../utils/withHovering";
6
+ import { EventHandlersContext } from "../contexts/EventHandlersContext";
14
7
 
15
8
  export interface FocusableItemProps extends BaseProps, withHoveringResultProps {
16
9
  disabled?: boolean;
@@ -1,7 +1,8 @@
1
1
  import { ForwardedRef, forwardRef, ReactNode, useContext, useRef, useState } from "react";
2
2
  import { useBEM, useLayoutEffect, useCombinedRef } from "../hooks";
3
- import { menuClass, menuGroupClass, MenuListContext } from "../utils";
3
+ import { menuClass, menuGroupClass } from "../utils";
4
4
  import { BaseProps, MenuOverflow } from "../types";
5
+ import { MenuListContext } from "../contexts/MenuListContext";
5
6
 
6
7
  export interface MenuGroupProps extends BaseProps {
7
8
  children?: ReactNode;
@@ -1,19 +1,10 @@
1
1
  import { Ref, useContext, useMemo } from "react";
2
2
  import { useBEM, useItemState, useCombinedRef } from "../hooks";
3
- import {
4
- mergeProps,
5
- commonProps,
6
- safeCall,
7
- menuClass,
8
- menuItemClass,
9
- withHovering,
10
- EventHandlersContext,
11
- RadioGroupContext,
12
- Keys,
13
- RMEvent,
14
- } from "../utils";
3
+ import { mergeProps, commonProps, safeCall, menuClass, menuItemClass, withHovering, Keys, RMEvent } from "../utils";
15
4
  import { BaseProps, ClickEvent, EventHandler, Hoverable, MenuItemTypeProp, RenderProp } from "../types";
16
5
  import { withHoveringResultProps } from "../utils/withHovering";
6
+ import { EventHandlersContext } from "../contexts/EventHandlersContext";
7
+ import { RadioGroupContext } from "../contexts/RadioGroupContext";
17
8
 
18
9
  //
19
10
  // MenuItem
@@ -17,12 +17,12 @@ import {
17
17
  Keys,
18
18
  FocusPositions,
19
19
  HoverActionTypes,
20
- SettingsContext,
21
- MenuListContext,
22
- MenuListItemContext,
23
- HoverItemContext,
24
20
  } from "../utils";
25
21
  import { ControlledMenuProps, MenuDirection } from "../types";
22
+ import { MenuListItemContext } from "../contexts/MenuListItemContext";
23
+ import { HoverItemContext } from "../contexts/HoverItemContext";
24
+ import { MenuListContext } from "../contexts/MenuListContext";
25
+ import { SettingsContext } from "../contexts/SettingsContext";
26
26
 
27
27
  export const MenuList = ({
28
28
  ariaLabel,
@@ -1,27 +1,8 @@
1
1
  import { ForwardedRef, forwardRef, ReactNode, useMemo } from "react";
2
2
  import { useBEM } from "../hooks";
3
- import { menuClass, radioGroupClass, RadioGroupContext } from "../utils";
4
- import { BaseProps, Event, EventHandler } from "../types";
5
-
6
- export interface RadioChangeEvent extends Event {
7
- /**
8
- * The `name` prop passed to the `MenuRadioGroup` when the menu item is in a radio group.
9
- */
10
- name?: string;
11
- /**
12
- * Set this property on event object to control whether to keep menu open after menu item is activated.
13
- * Leaving it `undefined` will behave in accordance with WAI-ARIA Authoring Practices.
14
- */
15
- keepOpen?: boolean;
16
- /**
17
- * Setting this property on event object to `true` will skip `onItemClick` event on root menu component.
18
- */
19
- stopPropagation?: boolean;
20
- /**
21
- * DOM event object (React synthetic event)
22
- */
23
- syntheticEvent: MouseEvent | KeyboardEvent;
24
- }
3
+ import { menuClass, radioGroupClass } from "../utils";
4
+ import { BaseProps, EventHandler, RadioChangeEvent } from "../types";
5
+ import { RadioGroupContext } from "../contexts/RadioGroupContext";
25
6
 
26
7
  //
27
8
  // MenuRadioGroup
@@ -21,10 +21,6 @@ import {
21
21
  menuItemClass,
22
22
  isMenuOpen,
23
23
  withHovering,
24
- SettingsContext,
25
- ItemSettingsContext,
26
- MenuListContext,
27
- MenuListItemContext,
28
24
  Keys,
29
25
  HoverActionTypes,
30
26
  FocusPositions,
@@ -43,6 +39,10 @@ import {
43
39
  UncontrolledMenuProps,
44
40
  } from "../types";
45
41
  import { withHoveringResultProps } from "../utils/withHovering";
42
+ import { MenuListItemContext } from "../contexts/MenuListItemContext";
43
+ import { MenuListContext } from "../contexts/MenuListContext";
44
+ import { SettingsContext } from "../contexts/SettingsContext";
45
+ import { ItemSettingsContext } from "../contexts/ItemSettingsContext";
46
46
 
47
47
  //
48
48
  // SubMenu
@@ -0,0 +1,11 @@
1
+ import { createContext } from "react";
2
+ import { RMEvent } from "../utils";
3
+
4
+ export interface EventHandlersContextType {
5
+ handleClose?: () => void;
6
+ handleClick: (event: RMEvent, checked: boolean) => void;
7
+ }
8
+
9
+ export const EventHandlersContext = createContext<EventHandlersContextType>({
10
+ handleClick: () => {},
11
+ });
@@ -0,0 +1,3 @@
1
+ import { createContext } from "react";
2
+
3
+ export const HoverItemContext = createContext(undefined);
@@ -0,0 +1,6 @@
1
+ import { createContext } from "react";
2
+
3
+ export const ItemSettingsContext = createContext<{ submenuCloseDelay: number; submenuOpenDelay: number }>({
4
+ submenuOpenDelay: 0,
5
+ submenuCloseDelay: 0,
6
+ });