@linzjs/step-ag-grid 1.5.4 → 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 +625 -332
- 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 +21 -27
- package/dist/src/components/GridPopoverHook.d.ts +5 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +10 -4
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +5 -5
- package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -4
- package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -3
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +3 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +4 -5
- package/dist/src/contexts/GridContext.d.ts +1 -1
- package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
- package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
- 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 +622 -312
- 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 +3 -8
- package/src/components/GridCell.tsx +62 -79
- package/src/components/GridLoadableCell.tsx +0 -1
- package/src/components/GridPopoverHook.tsx +18 -16
- package/src/components/gridForm/GridFormDropDown.tsx +47 -32
- package/src/components/gridForm/GridFormEditBearing.tsx +14 -14
- package/src/components/gridForm/GridFormMessage.tsx +11 -17
- package/src/components/gridForm/GridFormMultiSelect.tsx +89 -79
- package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
- package/src/components/gridForm/GridFormTextArea.tsx +16 -17
- package/src/components/gridForm/GridFormTextInput.tsx +17 -17
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +20 -15
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +21 -15
- package/src/components/gridPopoverEdit/GridPopoverMenu.scss +4 -4
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +21 -23
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
- package/src/components/gridRender/GridRenderGenericCell.tsx +5 -6
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
- package/src/contexts/GridContext.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +3 -5
- package/src/contexts/GridPopoverContext.tsx +26 -0
- package/src/contexts/GridPopoverContextProvider.tsx +54 -0
- package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
- package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
- 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 +4 -3
- package/src/stories/components/GridPopoutBearing.stories.tsx +30 -26
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +94 -51
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -14
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +78 -62
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +60 -52
- package/src/stories/components/GridReadOnly.stories.tsx +77 -64
- 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/contexts/UpdatingContextProvider.d.ts +0 -7
- package/dist/src/stories/components/FormTest.d.ts +0 -13
- 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
|
@@ -1,61 +1,69 @@
|
|
|
1
1
|
import { GenericMultiEditCellClass } from "../GenericCellClass";
|
|
2
|
-
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
3
2
|
import { bearingCorrectionValueFormatter, bearingValueFormatter } from "@utils/bearing";
|
|
4
|
-
import { GridCell } from "../GridCell";
|
|
3
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
5
4
|
import { GridFormEditBearing, GridFormEditBearingProps } from "../gridForm/GridFormEditBearing";
|
|
6
5
|
import { GridBaseRow } from "../Grid";
|
|
6
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
7
7
|
|
|
8
8
|
export const GridPopoverEditBearingLike = <RowType extends GridBaseRow>(
|
|
9
|
-
colDef: GenericCellColDef<RowType
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
colDef: GenericCellColDef<RowType>,
|
|
10
|
+
props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
|
|
11
|
+
): ColDefT<RowType> => {
|
|
12
|
+
return GridCell(
|
|
13
|
+
{
|
|
14
|
+
initialWidth: 65,
|
|
15
|
+
maxWidth: 150,
|
|
16
|
+
valueFormatter: bearingValueFormatter,
|
|
17
|
+
cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
|
|
18
|
+
...colDef,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
editor: GridFormEditBearing,
|
|
22
|
+
...props,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
};
|
|
24
26
|
|
|
25
27
|
export const GridPopoverEditBearing = <RowType extends GridBaseRow>(
|
|
26
|
-
colDef: GenericCellColDef<RowType
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
-
...
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
colDef: GenericCellColDef<RowType>,
|
|
29
|
+
props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
|
|
30
|
+
): ColDefT<RowType> => {
|
|
31
|
+
return GridPopoverEditBearingLike(
|
|
32
|
+
{ valueFormatter: bearingValueFormatter, ...colDef },
|
|
33
|
+
{
|
|
34
|
+
multiEdit: !!props.multiEdit,
|
|
35
|
+
editorParams: {
|
|
36
|
+
placeHolder: "Enter bearing correction",
|
|
37
|
+
range: (value: number | null) => {
|
|
38
|
+
if (value === null) return "Bearing correction is required";
|
|
39
|
+
if (value >= 360) return "Bearing correction must be less than 360 degrees";
|
|
40
|
+
if (value < 0) return "Bearing correction must not be negative";
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
...props.editorParams,
|
|
38
44
|
},
|
|
39
|
-
...init.cellEditorParams,
|
|
40
45
|
},
|
|
41
|
-
|
|
46
|
+
);
|
|
42
47
|
};
|
|
43
48
|
|
|
44
49
|
export const GridPopoverEditBearingCorrection = <RowType extends GridBaseRow>(
|
|
45
|
-
colDef: GenericCellColDef<RowType
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
...
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
colDef: GenericCellColDef<RowType>,
|
|
51
|
+
props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>,
|
|
52
|
+
): ColDefT<RowType> => {
|
|
53
|
+
return GridPopoverEditBearingLike(
|
|
54
|
+
{ valueFormatter: bearingCorrectionValueFormatter, ...colDef },
|
|
55
|
+
{
|
|
56
|
+
multiEdit: !!props.multiEdit,
|
|
57
|
+
editorParams: {
|
|
58
|
+
placeHolder: "Enter bearing correction",
|
|
59
|
+
range: (value: number | null) => {
|
|
60
|
+
if (value === null) return "Bearing is required";
|
|
61
|
+
if (value >= 360) return "Bearing must be less than 360 degrees";
|
|
62
|
+
if (value <= -180) return "Bearing must be greater then -180 degrees";
|
|
63
|
+
return null;
|
|
64
|
+
},
|
|
65
|
+
...props.editorParams,
|
|
57
66
|
},
|
|
58
|
-
...init.cellEditorParams,
|
|
59
67
|
},
|
|
60
|
-
|
|
68
|
+
);
|
|
61
69
|
};
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { GenericMultiEditCellClass } from "../GenericCellClass";
|
|
2
|
-
import {
|
|
3
|
-
import { GridCell } from "../GridCell";
|
|
2
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
4
3
|
import { GridBaseRow } from "../Grid";
|
|
5
4
|
import { GridFormDropDown, GridFormPopoutDropDownProps } from "../gridForm/GridFormDropDown";
|
|
5
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
6
6
|
|
|
7
7
|
export const GridPopoverEditDropDown = <RowType extends GridBaseRow, ValueType>(
|
|
8
|
-
colDef: GenericCellColDef<RowType
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
colDef: GenericCellColDef<RowType>,
|
|
9
|
+
props: GenericCellEditorProps<GridFormPopoutDropDownProps<RowType, ValueType>>,
|
|
10
|
+
): ColDefT<RowType> =>
|
|
11
|
+
GridCell(
|
|
12
|
+
{
|
|
13
|
+
initialWidth: 65,
|
|
14
|
+
maxWidth: 150,
|
|
15
|
+
cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined,
|
|
16
|
+
...colDef,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
editor: GridFormDropDown,
|
|
20
|
+
...props,
|
|
21
|
+
editorParams: {
|
|
22
|
+
// Defaults to medium size container
|
|
23
|
+
className: "GridPopoverEditDropDown-containerMedium",
|
|
24
|
+
...(props.editorParams as GridFormPopoutDropDownProps<RowType, ValueType>),
|
|
19
25
|
},
|
|
20
|
-
}
|
|
21
|
-
|
|
26
|
+
},
|
|
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,35 +1,33 @@
|
|
|
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
|
-
import { GridCell } from "../GridCell";
|
|
5
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
8
6
|
import { GridFormPopoutMenu, GridFormPopoutMenuProps } from "../gridForm/GridFormPopoutMenu";
|
|
9
7
|
import { GridRenderPopoutMenuCell } from "../gridRender/GridRenderPopoutMenuCell";
|
|
10
|
-
import { GenericCellColDef } from "
|
|
8
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Popout burger menu
|
|
14
12
|
*/
|
|
15
13
|
export const GridPopoverMenu = <RowType extends GridBaseRow>(
|
|
16
|
-
colDef: GenericCellColDef<RowType
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
cellEditorParams: {
|
|
30
|
-
multiEdit: true,
|
|
31
|
-
...colDef.cellEditorParams,
|
|
32
|
-
form: GridFormPopoutMenu,
|
|
14
|
+
colDef: GenericCellColDef<RowType>,
|
|
15
|
+
props: GenericCellEditorProps<GridFormPopoutMenuProps<RowType>>,
|
|
16
|
+
): ColDefT<RowType> =>
|
|
17
|
+
GridCell<RowType, GridFormPopoutMenuProps<RowType>>(
|
|
18
|
+
{
|
|
19
|
+
maxWidth: 64,
|
|
20
|
+
editable: colDef.editable != null ? colDef.editable : true,
|
|
21
|
+
cellRenderer: GridRenderPopoutMenuCell,
|
|
22
|
+
cellClass: colDef?.cellEditorParams?.multiEdit !== false ? GenericMultiEditCellClass : undefined,
|
|
23
|
+
...colDef,
|
|
24
|
+
cellRendererParams: {
|
|
25
|
+
// Menus open on single click, this parameter is picked up in Grid.tsx
|
|
26
|
+
singleClickEdit: true,
|
|
33
27
|
},
|
|
34
|
-
}
|
|
35
|
-
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
editor: GridFormPopoutMenu,
|
|
31
|
+
...props,
|
|
32
|
+
},
|
|
33
|
+
);
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { GridCell } from "../GridCell";
|
|
1
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
2
2
|
import { GridFormMessage, GridFormMessageProps } from "../gridForm/GridFormMessage";
|
|
3
3
|
import { GridBaseRow } from "../Grid";
|
|
4
|
-
import { GenericCellColDef } from "
|
|
4
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverMessage = <RowType extends GridBaseRow>(
|
|
7
|
-
colDef: GenericCellColDef<RowType
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
...colDef.cellEditorParams,
|
|
18
|
-
form: GridFormMessage,
|
|
7
|
+
colDef: GenericCellColDef<RowType>,
|
|
8
|
+
props: GenericCellEditorProps<GridFormMessageProps<RowType>>,
|
|
9
|
+
): ColDefT<RowType> => {
|
|
10
|
+
return GridCell(
|
|
11
|
+
{
|
|
12
|
+
maxWidth: 140,
|
|
13
|
+
...colDef,
|
|
14
|
+
cellRendererParams: {
|
|
15
|
+
singleClickEdit: true,
|
|
16
|
+
...colDef.cellRendererParams,
|
|
19
17
|
},
|
|
20
|
-
}
|
|
21
|
-
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
editor: GridFormMessage,
|
|
21
|
+
...props,
|
|
22
|
+
},
|
|
23
|
+
);
|
|
22
24
|
};
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { GridCell } from "../GridCell";
|
|
1
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
2
2
|
import { GridBaseRow } from "../Grid";
|
|
3
|
-
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
4
3
|
import { GridFormTextArea, GridFormTextAreaProps } from "../gridForm/GridFormTextArea";
|
|
4
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverTextArea = <RowType extends GridBaseRow>(
|
|
7
|
-
colDef: GenericCellColDef<RowType
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
});
|
|
20
|
-
};
|
|
7
|
+
colDef: GenericCellColDef<RowType>,
|
|
8
|
+
params: GenericCellEditorProps<GridFormTextAreaProps<RowType>>,
|
|
9
|
+
): ColDefT<RowType> =>
|
|
10
|
+
GridCell(
|
|
11
|
+
{
|
|
12
|
+
maxWidth: 260,
|
|
13
|
+
...colDef,
|
|
14
|
+
},
|
|
15
|
+
{ editor: GridFormTextArea, ...params },
|
|
16
|
+
);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { GridCell } from "../GridCell";
|
|
1
|
+
import { ColDefT, GenericCellEditorProps, GridCell } from "../GridCell";
|
|
2
2
|
import { GridBaseRow } from "../Grid";
|
|
3
|
-
import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
|
|
4
3
|
import { GridFormTextInput, GridFormTextInputProps } from "../gridForm/GridFormTextInput";
|
|
4
|
+
import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
|
|
5
5
|
|
|
6
6
|
export const GridPopoverTextInput = <RowType extends GridBaseRow>(
|
|
7
|
-
colDef: GenericCellColDef<RowType
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
7
|
+
colDef: GenericCellColDef<RowType>,
|
|
8
|
+
params: GenericCellEditorProps<GridFormTextInputProps<RowType>>,
|
|
9
|
+
): ColDefT<RowType> => {
|
|
10
|
+
return GridCell(
|
|
11
|
+
{
|
|
12
|
+
maxWidth: 140,
|
|
13
|
+
...colDef,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
editor: GridFormTextInput,
|
|
17
|
+
...params,
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
20
|
};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../../styles/GridRenderGenericCell.scss";
|
|
2
2
|
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { GridUpdatingContext } from "@contexts/GridUpdatingContext";
|
|
5
5
|
import { GridLoadableCell } from "../GridLoadableCell";
|
|
6
6
|
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
|
-
import { GenericCellEditorParams } from "../GridCell";
|
|
10
9
|
import { GridBaseRow } from "../Grid";
|
|
10
|
+
import { ColDefT } from "@components/GridCell";
|
|
11
11
|
|
|
12
12
|
export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
|
|
13
13
|
data: RowType;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export interface GenericCellColDef<RowType extends GridBaseRow
|
|
16
|
+
export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<RowType> {
|
|
17
17
|
cellRendererParams?: GenericCellRendererParams<RowType>;
|
|
18
|
-
cellEditorParams?: GenericCellEditorParams<RowType> & FormProps;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
@@ -25,7 +24,7 @@ export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export const GridRendererGenericCell = <RowType extends GridBaseRow>(props: ICellRendererParams): JSX.Element => {
|
|
28
|
-
const { checkUpdating } = useContext(
|
|
27
|
+
const { checkUpdating } = useContext(GridUpdatingContext);
|
|
29
28
|
|
|
30
29
|
const colDef = props.colDef as ColDef;
|
|
31
30
|
const cellRendererParams = colDef.cellRendererParams as GenericCellRendererParams<RowType> | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { ColDef, ICellRendererParams } from "ag-grid-community";
|
|
3
|
-
import {
|
|
3
|
+
import { GridUpdatingContext } from "@contexts/GridUpdatingContext";
|
|
4
4
|
import { GridLoadableCell } from "../GridLoadableCell";
|
|
5
5
|
import { LuiIcon } from "@linzjs/lui";
|
|
6
6
|
import { Column } from "ag-grid-community/dist/lib/entities/column";
|
|
7
7
|
|
|
8
8
|
export const GridRenderPopoutMenuCell = (props: ICellRendererParams) => {
|
|
9
|
-
const { checkUpdating } = useContext(
|
|
9
|
+
const { checkUpdating } = useContext(GridUpdatingContext);
|
|
10
10
|
const isLoading = checkUpdating(props.colDef?.field ?? "", props.data.id);
|
|
11
11
|
const editable = props.colDef?.editable;
|
|
12
12
|
const disabled = !(typeof editable === "function"
|
|
@@ -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>;
|
|
@@ -3,7 +3,7 @@ import { GridApi, RowNode } from "ag-grid-community";
|
|
|
3
3
|
import { GridContext } from "./GridContext";
|
|
4
4
|
import { delay, difference, isEmpty, last, sortBy } from "lodash-es";
|
|
5
5
|
import { isNotEmpty } from "@utils/util";
|
|
6
|
-
import {
|
|
6
|
+
import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
7
7
|
import { GridBaseRow } from "@components/Grid";
|
|
8
8
|
|
|
9
9
|
interface GridContextProps {
|
|
@@ -16,7 +16,7 @@ interface GridContextProps {
|
|
|
16
16
|
* Also, make sure the provider is created in a separate component, otherwise it won't be found.
|
|
17
17
|
*/
|
|
18
18
|
export const GridContextProvider = (props: GridContextProps): ReactElement => {
|
|
19
|
-
const { modifyUpdating } = useContext(
|
|
19
|
+
const { modifyUpdating } = useContext(GridUpdatingContext);
|
|
20
20
|
const gridApiRef = useRef<GridApi>();
|
|
21
21
|
const idsBeforeUpdate = useRef<number[]>([]);
|
|
22
22
|
|
|
@@ -48,9 +48,7 @@ export const GridContextProvider = (props: GridContextProps): ReactElement => {
|
|
|
48
48
|
noApiFn = (() => {}) as () => R;
|
|
49
49
|
}
|
|
50
50
|
const gridApi = gridApiRef.current;
|
|
51
|
-
|
|
52
|
-
console.error("GridApi not ready");
|
|
53
|
-
return noApiFn();
|
|
51
|
+
return gridApi ? hasApiFn(gridApi) : noApiFn();
|
|
54
52
|
};
|
|
55
53
|
|
|
56
54
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createContext, RefObject } from "react";
|
|
2
|
+
import { ICellEditorParams } from "ag-grid-community";
|
|
3
|
+
|
|
4
|
+
export interface PropsType {
|
|
5
|
+
value: any;
|
|
6
|
+
data: any;
|
|
7
|
+
field: string;
|
|
8
|
+
selectedRows: any[];
|
|
9
|
+
updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type GridPopoverContextType = {
|
|
13
|
+
anchorRef: RefObject<Element>;
|
|
14
|
+
saving: boolean;
|
|
15
|
+
setSaving: (saving: boolean) => void;
|
|
16
|
+
setProps: (props: ICellEditorParams, multiEdit: boolean) => void;
|
|
17
|
+
propsRef: RefObject<PropsType>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const GridPopoverContext = createContext<GridPopoverContextType>({
|
|
21
|
+
anchorRef: { current: null },
|
|
22
|
+
saving: false,
|
|
23
|
+
setSaving: () => {},
|
|
24
|
+
setProps: () => {},
|
|
25
|
+
propsRef: { current: null },
|
|
26
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ReactNode, RefObject, useCallback, useContext, useRef, useState } from "react";
|
|
2
|
+
import { GridPopoverContext, PropsType } from "./GridPopoverContext";
|
|
3
|
+
import { ICellEditorParams } from "ag-grid-community";
|
|
4
|
+
import { GridContext } from "@contexts/GridContext";
|
|
5
|
+
import { sortBy } from "lodash-es";
|
|
6
|
+
import { GridBaseRow } from "@components/Grid";
|
|
7
|
+
|
|
8
|
+
interface GridPopoverContextProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const GridPopoverContextProvider = (props: GridPopoverContextProps) => {
|
|
13
|
+
const { getSelectedRows, updatingCells } = useContext(GridContext);
|
|
14
|
+
const anchorRef = useRef<Element>();
|
|
15
|
+
const propsRef = useRef<PropsType>({} as PropsType);
|
|
16
|
+
|
|
17
|
+
const [saving, setSaving] = useState(false);
|
|
18
|
+
|
|
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 ?? "";
|
|
26
|
+
|
|
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
|
+
);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<GridPopoverContext.Provider
|
|
43
|
+
value={{
|
|
44
|
+
anchorRef: anchorRef as any as RefObject<Element>,
|
|
45
|
+
saving,
|
|
46
|
+
setSaving,
|
|
47
|
+
propsRef,
|
|
48
|
+
setProps,
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{props.children}
|
|
52
|
+
</GridPopoverContext.Provider>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type GridUpdatingContextType = {
|
|
4
4
|
checkUpdating: (fields: string | string[], id: number | string) => boolean;
|
|
5
5
|
modifyUpdating: (field: string, ids: (number | string)[], fn: () => void | Promise<void>) => Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const GridUpdatingContext = createContext<GridUpdatingContextType>({
|
|
9
9
|
checkUpdating: () => {
|
|
10
10
|
console.error("Missing UpdatingContext");
|
|
11
11
|
return false;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { ReactNode, useRef } from "react";
|
|
2
2
|
import { castArray, flatten, remove } from "lodash-es";
|
|
3
|
-
import {
|
|
3
|
+
import { GridUpdatingContext } from "./GridUpdatingContext";
|
|
4
4
|
|
|
5
5
|
interface UpdatingContextProviderProps {
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export type
|
|
9
|
+
export type GridUpdatingContextStatus = Record<string, (number | string)[] | undefined>;
|
|
10
10
|
|
|
11
11
|
type FieldName = string;
|
|
12
12
|
type IdList = (number | string)[];
|
|
13
13
|
type UpdatingBlock = Record<FieldName, IdList[]>;
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const GridUpdatingContextProvider = (props: UpdatingContextProviderProps) => {
|
|
16
16
|
const updatingBlocks = useRef<UpdatingBlock>({});
|
|
17
|
-
const updating = useRef<
|
|
17
|
+
const updating = useRef<GridUpdatingContextStatus>({});
|
|
18
18
|
|
|
19
19
|
const resetUpdating = () => {
|
|
20
|
-
const mergedUpdatingBlocks:
|
|
20
|
+
const mergedUpdatingBlocks: GridUpdatingContextStatus = {};
|
|
21
21
|
for (const key in updatingBlocks.current) {
|
|
22
22
|
mergedUpdatingBlocks[key] = flatten(updatingBlocks.current[key]);
|
|
23
23
|
}
|
|
@@ -38,6 +38,8 @@ export const UpdatingContextProvider = (props: UpdatingContextProviderProps) =>
|
|
|
38
38
|
castArray(fields).some((f) => updating.current[f]?.includes(id));
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
|
-
<
|
|
41
|
+
<GridUpdatingContext.Provider value={{ modifyUpdating, checkUpdating }}>
|
|
42
|
+
{props.children}
|
|
43
|
+
</GridUpdatingContext.Provider>
|
|
42
44
|
);
|
|
43
45
|
};
|
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";
|