@linzjs/step-ag-grid 2.0.0 → 2.0.1
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/README.md +117 -2
- package/{src/components → dist}/GridTheme.scss +37 -23
- package/dist/index.css +351 -0
- package/dist/index.js +462 -210
- package/dist/index.js.map +1 -1
- package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -0
- package/dist/src/components/Grid.d.ts +0 -2
- package/dist/src/components/GridCell.d.ts +3 -0
- package/dist/src/components/GridPopoverHook.d.ts +2 -1
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +4 -3
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +3 -2
- package/dist/src/components/gridForm/GridFormMessage.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +4 -2
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +2 -1
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -1
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -1
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -3
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +2 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +2 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +4 -3
- package/dist/src/contexts/GridContext.d.ts +1 -1
- package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
- package/dist/src/index.d.ts +31 -0
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -21
- package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -0
- package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -0
- package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -0
- package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -0
- package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -0
- package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -0
- package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -0
- package/dist/src/react-menu3/index.d.ts +0 -1
- package/dist/src/react-menu3/utils/constants.d.ts +1 -50
- package/dist/step-ag-grid.esm.js +461 -191
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +39 -26
- package/src/components/ComponentLoadingWrapper.tsx +2 -1
- package/src/components/Grid.tsx +1 -6
- package/src/components/GridCell.tsx +5 -0
- package/src/components/GridLoadableCell.tsx +0 -4
- package/src/components/GridPopoverHook.tsx +13 -7
- package/src/components/gridForm/GridFormDropDown.tsx +17 -13
- package/src/components/gridForm/GridFormEditBearing.tsx +4 -4
- package/src/components/gridForm/GridFormMessage.tsx +6 -7
- package/src/components/gridForm/GridFormMultiSelect.tsx +73 -63
- package/src/components/gridForm/GridFormPopoutMenu.tsx +6 -6
- package/src/components/gridForm/GridFormTextArea.tsx +4 -4
- package/src/components/gridForm/GridFormTextInput.tsx +3 -3
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +4 -0
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +4 -4
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +7 -2
- package/src/components/gridPopoverEdit/GridPopoverMenu.scss +4 -4
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -3
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +2 -2
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +2 -2
- package/src/components/gridRender/GridRenderGenericCell.tsx +3 -2
- package/src/contexts/GridContext.tsx +1 -1
- package/src/contexts/GridPopoverContext.tsx +1 -7
- package/src/contexts/GridPopoverContextProvider.tsx +23 -22
- package/src/index.ts +38 -0
- package/src/lui/TextInputFormatted.scss +1 -1
- package/src/react-menu3/README.md +66 -0
- package/src/react-menu3/components/ControlledMenu.tsx +9 -17
- package/src/react-menu3/components/FocusableItem.tsx +2 -9
- package/src/react-menu3/components/MenuGroup.tsx +2 -1
- package/src/react-menu3/components/MenuItem.tsx +3 -12
- package/src/react-menu3/components/MenuList.tsx +4 -4
- package/src/react-menu3/components/MenuRadioGroup.tsx +3 -22
- package/src/react-menu3/components/SubMenu.tsx +4 -4
- package/src/react-menu3/contexts/EventHandlersContext.ts +11 -0
- package/src/react-menu3/contexts/HoverItemContext.ts +3 -0
- package/src/react-menu3/contexts/ItemSettingsContext.ts +6 -0
- package/src/react-menu3/contexts/MenuListContext.ts +10 -0
- package/src/react-menu3/contexts/MenuListItemContext.ts +16 -0
- package/src/react-menu3/contexts/RadioGroupContext.ts +8 -0
- package/src/react-menu3/contexts/SettingsContext.ts +20 -0
- package/src/react-menu3/hooks/useItemState.ts +3 -1
- package/src/react-menu3/index.ts +0 -1
- package/src/react-menu3/styles/_var.scss +4 -4
- package/src/react-menu3/styles/core.scss +6 -6
- package/src/react-menu3/styles/index.scss +10 -7
- package/src/react-menu3/styles/theme-dark.scss +4 -2
- package/src/react-menu3/styles/transitions/slide.scss +8 -8
- package/src/react-menu3/utils/constants.ts +1 -74
- package/src/react-menu3/utils/withHovering.tsx +1 -1
- package/src/stories/components/FormTest.scss +1 -2
- package/src/stories/components/FormTest.tsx +3 -3
- package/src/stories/components/GridPopoutBearing.stories.tsx +2 -1
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +4 -2
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +3 -4
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +2 -1
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +2 -1
- package/src/stories/components/GridReadOnly.stories.tsx +10 -13
- package/src/stories/components/ReactMenu.stories.tsx +0 -4
- package/src/{components → styles}/Grid.scss +9 -6
- package/src/styles/GridFormDropDown.scss +18 -0
- package/src/{components/gridForm → styles}/GridFormEditBearing.scss +0 -0
- package/src/styles/GridFormMultiSelect.scss +18 -0
- package/src/styles/GridRenderGenericCell.scss +15 -0
- package/src/styles/GridTheme.scss +108 -0
- package/src/styles/index.scss +2 -0
- package/src/styles/lui-overrides.scss +49 -0
- package/src/styles/react-menu-customisations.scss +135 -0
- package/dist/index.d.ts +0 -38
- package/dist/src/stories/components/FormTest.d.ts +0 -12
- package/dist/src/stories/components/GridPopoutBearing.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditDropDown.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditGeneric.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditGenericTextArea.stories.d.ts +0 -9
- package/dist/src/stories/components/GridPopoutEditMultiSelect.stories.d.ts +0 -9
- package/dist/src/stories/components/GridReadOnly.stories.d.ts +0 -9
- package/dist/src/stories/components/ReactMenu.stories.d.ts +0 -8
- package/src/components/gridRender/GridRenderGenericCell.scss +0 -15
- package/src/lui-overrides.scss +0 -163
- package/src/react-menu3/style-utils.d.ts +0 -110
|
@@ -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 {
|
|
6
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
7
7
|
|
|
8
8
|
export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
|
|
9
|
-
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:
|
|
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:
|
|
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 {
|
|
5
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
6
6
|
|
|
7
7
|
export const GridPopoverEditDropDown = <RowType extends GridBaseRow, ValueType>(
|
|
8
|
-
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
|
|
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
|
-
|
|
7
|
-
fill:
|
|
6
|
+
svg {
|
|
7
|
+
fill: colors.$sea;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.GridPopoutMenu-burgerDisabled svg {
|
|
12
|
-
fill:
|
|
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:
|
|
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 {
|
|
4
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverMessage = <RowType extends GridBaseRow>(
|
|
7
|
-
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 {
|
|
4
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverTextArea = <RowType extends GridBaseRow>(
|
|
7
|
-
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 {
|
|
4
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverTextInput = <RowType extends GridBaseRow>(
|
|
7
|
-
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 "
|
|
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
|
|
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
|
|
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 = (
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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";
|
|
@@ -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",
|
|
132
|
-
thisDocument.addEventListener("mouseup",
|
|
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",
|
|
137
|
-
thisDocument.removeEventListener("mouseup",
|
|
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
|
|
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
|
|
4
|
-
import { BaseProps,
|
|
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,10 @@
|
|
|
1
|
+
import { createContext, MutableRefObject } from "react";
|
|
2
|
+
import { MenuDirection, MenuOverflow } from "../types";
|
|
3
|
+
|
|
4
|
+
export const MenuListContext = createContext<{
|
|
5
|
+
overflow?: MenuOverflow;
|
|
6
|
+
overflowAmt?: number;
|
|
7
|
+
parentMenuRef?: MutableRefObject<any>;
|
|
8
|
+
parentDir?: MenuDirection;
|
|
9
|
+
reposSubmenu?: boolean;
|
|
10
|
+
}>({});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FocusPosition } from "../types";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
|
|
4
|
+
interface MenuListItemContextType {
|
|
5
|
+
isParentOpen?: boolean;
|
|
6
|
+
isSubmenuOpen?: boolean;
|
|
7
|
+
dispatch: (actionType: number, item: any, nextIndex: FocusPosition) => void;
|
|
8
|
+
updateItems: (item: any, isMounted?: boolean) => void;
|
|
9
|
+
setOpenSubmenuCount: (fn: (count: number) => number) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MenuListItemContext = createContext<MenuListItemContextType>({
|
|
13
|
+
dispatch: () => {},
|
|
14
|
+
updateItems: () => {},
|
|
15
|
+
setOpenSubmenuCount: () => 0,
|
|
16
|
+
});
|