@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.
- package/README.md +117 -2
- package/{src/components → dist}/GridTheme.scss +37 -23
- package/dist/index.css +351 -0
- package/dist/index.js +463 -212
- package/dist/index.js.map +1 -1
- package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -0
- package/dist/src/components/Grid.d.ts +0 -3
- 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 +462 -193
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +48 -26
- package/src/components/ComponentLoadingWrapper.tsx +2 -1
- package/src/components/Grid.tsx +2 -9
- 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 +4 -4
- package/src/stories/components/GridPopoutEditDropDown.stories.tsx +6 -5
- package/src/stories/components/GridPopoutEditGeneric.stories.tsx +5 -7
- package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +4 -4
- package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +4 -4
- package/src/stories/components/GridReadOnly.stories.tsx +14 -18
- 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
package/package.json
CHANGED
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
"name": "@linzjs/step-ag-grid",
|
|
3
3
|
"repository": "github:linz/step-ag-grid.git",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.1.0",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"aggrid",
|
|
8
|
+
"ag-grid",
|
|
9
|
+
"react-menu",
|
|
10
|
+
"grid",
|
|
11
|
+
"table",
|
|
12
|
+
"react",
|
|
13
|
+
"react-component"
|
|
14
|
+
],
|
|
6
15
|
"main": "dist/index.js",
|
|
7
16
|
"typings": "dist/index.d.ts",
|
|
8
17
|
"module": "dist/step-ag-grid.esm.js",
|
|
@@ -20,27 +29,32 @@
|
|
|
20
29
|
"@linzjs/lui": ">=17",
|
|
21
30
|
"ag-grid-community": ">=27",
|
|
22
31
|
"ag-grid-react": ">=27",
|
|
32
|
+
"lodash-es": ">=4",
|
|
23
33
|
"react": ">=17",
|
|
24
34
|
"react-dom": ">=17"
|
|
25
35
|
},
|
|
26
36
|
"dependencies": {
|
|
27
37
|
"@linzjs/lui": ">=17",
|
|
28
|
-
"ag-grid-community": "
|
|
29
|
-
"ag-grid-react": "
|
|
38
|
+
"ag-grid-community": "^27",
|
|
39
|
+
"ag-grid-react": "^27",
|
|
30
40
|
"debounce-promise": "^3.1.2",
|
|
31
41
|
"lodash-es": "^4.17.21",
|
|
32
|
-
"react": "
|
|
33
|
-
"react-dom": "
|
|
42
|
+
"react": "^17",
|
|
43
|
+
"react-dom": "^17",
|
|
34
44
|
"react-transition-state": "^1.1.5",
|
|
35
45
|
"uuid": "^9.0.0"
|
|
36
46
|
},
|
|
37
47
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"
|
|
48
|
+
"build": "run-s clean stylelint lint css bundle",
|
|
49
|
+
"clean": "rimraf dist && mkdirp ./dist",
|
|
50
|
+
"bundle": "rollup -c",
|
|
51
|
+
"stylelint": "stylelint src/**/*.scss src/**/*.css --fix",
|
|
52
|
+
"css": "sass ./src/styles/index.scss:dist/index.css --no-source-map",
|
|
53
|
+
"test": "react-scripts test",
|
|
40
54
|
"eject": "react-scripts eject",
|
|
41
55
|
"lint": "eslint ./src --ext .js,.ts,.tsx --fix --cache",
|
|
42
|
-
"storybook": "start-storybook -p 6006
|
|
43
|
-
"build-storybook": "build-storybook
|
|
56
|
+
"storybook": "start-storybook -p 6006",
|
|
57
|
+
"build-storybook": "build-storybook",
|
|
44
58
|
"deploy-storybook": "npx --yes -p @storybook/storybook-deployer storybook-to-ghpages",
|
|
45
59
|
"chromatic": "chromatic --exit-zero-on-changes",
|
|
46
60
|
"semantic-release": "semantic-release"
|
|
@@ -78,46 +92,54 @@
|
|
|
78
92
|
"@storybook/test-runner": "^0.9.0",
|
|
79
93
|
"@storybook/testing-library": "^0.0.13",
|
|
80
94
|
"@testing-library/jest-dom": "^5.16.5",
|
|
81
|
-
"@testing-library/react": "^
|
|
95
|
+
"@testing-library/react": "^13.4.0",
|
|
82
96
|
"@testing-library/user-event": "^14.4.3",
|
|
83
97
|
"@types/debounce-promise": "^3.1.5",
|
|
84
|
-
"@types/jest": "^29.2.
|
|
98
|
+
"@types/jest": "^29.2.2",
|
|
85
99
|
"@types/lodash-es": "^4.17.6",
|
|
86
|
-
"@types/node": "^18.11.
|
|
100
|
+
"@types/node": "^18.11.9",
|
|
87
101
|
"@types/react": "^17.0.52",
|
|
88
102
|
"@types/react-dom": "^17.0.18",
|
|
89
103
|
"@types/uuid": "^8.3.4",
|
|
90
|
-
"@typescript-eslint/parser": "^5.
|
|
91
|
-
"babel-jest": "^
|
|
92
|
-
"babel-preset-react-app": "10.0.
|
|
93
|
-
"chromatic": "^6.11.
|
|
94
|
-
"
|
|
95
|
-
"eslint": "8.22.0",
|
|
104
|
+
"@typescript-eslint/parser": "^5.42.0",
|
|
105
|
+
"babel-jest": "^29.2.2",
|
|
106
|
+
"babel-preset-react-app": "^10.0.1",
|
|
107
|
+
"chromatic": "^6.11.4",
|
|
108
|
+
"eslint": "^8.26.0",
|
|
96
109
|
"eslint-config-prettier": "^8.5.0",
|
|
97
110
|
"eslint-config-react-app": "^7.0.1",
|
|
98
111
|
"eslint-plugin-deprecation": "^1.3.2",
|
|
99
112
|
"eslint-plugin-import": "^2.26.0",
|
|
100
|
-
"eslint-plugin-jest": "^27.1.
|
|
113
|
+
"eslint-plugin-jest": "^27.1.4",
|
|
101
114
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
102
115
|
"eslint-plugin-prettier": "^4.2.1",
|
|
103
116
|
"eslint-plugin-react": "^7.31.10",
|
|
104
117
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
105
118
|
"eslint-plugin-testing-library": "^5.9.1",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
119
|
+
"mkdirp": "^1.0.4",
|
|
120
|
+
"npm-run-all": "^4.1.5",
|
|
121
|
+
"postcss": "^8.4.18",
|
|
122
|
+
"postcss-scss": "^4.0.5",
|
|
123
|
+
"postcss-loader": "^7.0.1",
|
|
108
124
|
"prettier": "^2.7.1",
|
|
109
125
|
"react-scripts": "^5.0.1",
|
|
110
|
-
"rollup": "^2.
|
|
126
|
+
"rollup": "^3.2.5",
|
|
111
127
|
"rollup-plugin-copy": "^3.4.0",
|
|
112
128
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
113
129
|
"rollup-plugin-postcss": "^4.0.2",
|
|
114
|
-
"rollup-plugin-typescript2": "^0.
|
|
115
|
-
"sass": "^1.
|
|
116
|
-
"sass-loader": "10.
|
|
130
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
131
|
+
"sass": "^1.56.0",
|
|
132
|
+
"sass-loader": "10.3.1",
|
|
117
133
|
"semantic-release": "^19.0.5",
|
|
118
134
|
"storybook-addon-mock": "^2.4.1",
|
|
119
135
|
"style-loader": "^2.0.0",
|
|
120
|
-
"
|
|
136
|
+
"stylelint": "^14.14.1",
|
|
137
|
+
"stylelint-config-prettier": "^9.0.3",
|
|
138
|
+
"stylelint-config-standard": "^29.0.0",
|
|
139
|
+
"stylelint-config-recommended-scss": "^8.0.0",
|
|
140
|
+
"stylelint-prettier": "^2.0.0",
|
|
141
|
+
"stylelint-scss": "^4.3.0",
|
|
142
|
+
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
121
143
|
"typescript": "^4.8.4"
|
|
122
144
|
},
|
|
123
145
|
"babel": {
|
|
@@ -7,11 +7,12 @@ export const ComponentLoadingWrapper = (props: {
|
|
|
7
7
|
loading?: boolean;
|
|
8
8
|
saving?: boolean;
|
|
9
9
|
children: JSX.Element | undefined;
|
|
10
|
+
className: string | undefined;
|
|
10
11
|
}): JSX.Element => {
|
|
11
12
|
return props.loading ? (
|
|
12
13
|
<LuiMiniSpinner size={22} divProps={{ role: "status", ["aria-label"]: "Loading", style: { padding: 16 } }} />
|
|
13
14
|
) : (
|
|
14
|
-
<div style={{
|
|
15
|
+
<div style={{ pointerEvents: props.saving ? "none" : "inherit" }} className={props.className}>
|
|
15
16
|
{props.saving && (
|
|
16
17
|
<div
|
|
17
18
|
style={{
|
package/src/components/Grid.tsx
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import "./Grid.scss";
|
|
2
|
-
import "./GridTheme.scss";
|
|
3
|
-
|
|
4
1
|
import clsx from "clsx";
|
|
5
2
|
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
6
3
|
import { AgGridReact } from "ag-grid-react";
|
|
@@ -27,7 +24,6 @@ export interface GridProps {
|
|
|
27
24
|
domLayout?: GridOptions["domLayout"];
|
|
28
25
|
externalSelectedItems?: any[];
|
|
29
26
|
setExternalSelectedItems?: (items: any[]) => void;
|
|
30
|
-
onGridReady?: GridOptions["onGridReady"];
|
|
31
27
|
defaultColDef?: GridOptions["defaultColDef"];
|
|
32
28
|
columnDefs: GridOptions["columnDefs"];
|
|
33
29
|
rowData: GridOptions["rowData"];
|
|
@@ -149,17 +145,14 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
149
145
|
const onGridReady = useCallback(
|
|
150
146
|
(event: GridReadyEvent) => {
|
|
151
147
|
setGridApi(event.api);
|
|
152
|
-
params.onGridReady && params.onGridReady(event);
|
|
153
148
|
synchroniseExternallySelectedItemsToGrid();
|
|
154
149
|
updateQuickFilter();
|
|
155
150
|
},
|
|
156
|
-
[
|
|
151
|
+
[setGridApi, synchroniseExternallySelectedItemsToGrid, updateQuickFilter],
|
|
157
152
|
);
|
|
158
153
|
|
|
159
154
|
const noRowsOverlayComponent = useCallback(
|
|
160
|
-
() =>
|
|
161
|
-
<span className="ag-overlay-no-rows-center">{params.noRowsOverlayText ?? "There are currently no rows"}</span>
|
|
162
|
-
),
|
|
155
|
+
() => <span>{params.noRowsOverlayText ?? "There are currently no rows"}</span>,
|
|
163
156
|
[params.noRowsOverlayText],
|
|
164
157
|
);
|
|
165
158
|
|
|
@@ -60,6 +60,7 @@ export const GridCell = <RowType extends GridBaseRow, Props>(
|
|
|
60
60
|
},
|
|
61
61
|
): ColDefT<RowType> => {
|
|
62
62
|
return {
|
|
63
|
+
colId: props.field,
|
|
63
64
|
sortable: !!(props?.field || props?.valueGetter),
|
|
64
65
|
resizable: true,
|
|
65
66
|
...(custom?.editor && {
|
|
@@ -86,6 +87,10 @@ export const GridCell = <RowType extends GridBaseRow, Props>(
|
|
|
86
87
|
};
|
|
87
88
|
};
|
|
88
89
|
|
|
90
|
+
export interface CellEditorCommon {
|
|
91
|
+
className?: string | undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
export interface CellParams<RowType extends GridBaseRow> {
|
|
90
95
|
value: any;
|
|
91
96
|
data: RowType;
|
|
@@ -2,8 +2,6 @@ import "./GridLoadableCell.scss";
|
|
|
2
2
|
|
|
3
3
|
import { LuiMiniSpinner } from "@linzjs/lui";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
-
import { useContext } from "react";
|
|
6
|
-
import { GridPopoverContext } from "@contexts/GridPopoverContext";
|
|
7
5
|
|
|
8
6
|
export const GridLoadableCell = (props: {
|
|
9
7
|
isLoading: boolean;
|
|
@@ -11,8 +9,6 @@ export const GridLoadableCell = (props: {
|
|
|
11
9
|
children: JSX.Element | string;
|
|
12
10
|
className?: string;
|
|
13
11
|
}): JSX.Element => {
|
|
14
|
-
const { saving } = useContext(GridPopoverContext);
|
|
15
|
-
|
|
16
12
|
if (props.isLoading) {
|
|
17
13
|
return (
|
|
18
14
|
<div style={{ display: "flex", alignItems: "center" }}>
|
|
@@ -5,12 +5,13 @@ import { ControlledMenu } from "@react-menu3";
|
|
|
5
5
|
import { GridPopoverContext } from "@contexts/GridPopoverContext";
|
|
6
6
|
|
|
7
7
|
export interface GridPopoverHookProps<RowType> {
|
|
8
|
+
className: string | undefined;
|
|
8
9
|
save?: (selectedRows: RowType[]) => Promise<boolean>;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopoverHookProps<RowType>
|
|
12
|
+
export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopoverHookProps<RowType>) => {
|
|
12
13
|
const { stopEditing } = useContext(GridContext);
|
|
13
|
-
const { anchorRef, saving,
|
|
14
|
+
const { anchorRef, saving, propsRef } = useContext(GridPopoverContext);
|
|
14
15
|
const saveButtonRef = useRef<HTMLButtonElement>(null);
|
|
15
16
|
const [isOpen, setOpen] = useState(false);
|
|
16
17
|
|
|
@@ -20,12 +21,16 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
|
|
|
20
21
|
|
|
21
22
|
const triggerSave = useCallback(
|
|
22
23
|
async (reason?: string) => {
|
|
23
|
-
if (
|
|
24
|
+
if (
|
|
25
|
+
reason == "cancel" ||
|
|
26
|
+
!props.save ||
|
|
27
|
+
(propsRef.current?.updateValue && (await propsRef.current?.updateValue(props.save)))
|
|
28
|
+
) {
|
|
24
29
|
setOpen(false);
|
|
25
30
|
stopEditing();
|
|
26
31
|
}
|
|
27
32
|
},
|
|
28
|
-
[props, stopEditing,
|
|
33
|
+
[props, stopEditing, propsRef],
|
|
29
34
|
);
|
|
30
35
|
|
|
31
36
|
const popoverWrapper = useCallback(
|
|
@@ -39,12 +44,13 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
|
|
|
39
44
|
unmountOnClose={true}
|
|
40
45
|
anchorRef={anchorRef}
|
|
41
46
|
saveButtonRef={saveButtonRef}
|
|
42
|
-
menuClassName={"
|
|
47
|
+
menuClassName={"step-ag-grid-react-menu"}
|
|
43
48
|
onClose={(event: { reason: string }) => triggerSave(event.reason).then()}
|
|
44
49
|
viewScroll={"auto"}
|
|
45
50
|
dontShrinkIfDirectionIsTop={true}
|
|
51
|
+
className={props.className}
|
|
46
52
|
>
|
|
47
|
-
{saving && (
|
|
53
|
+
{saving && ( // This is the overlay that prevents editing when the editor is saving
|
|
48
54
|
<div
|
|
49
55
|
style={{
|
|
50
56
|
position: "absolute",
|
|
@@ -64,7 +70,7 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
|
|
|
64
70
|
</>
|
|
65
71
|
);
|
|
66
72
|
},
|
|
67
|
-
[anchorRef, isOpen, saving, triggerSave],
|
|
73
|
+
[anchorRef, isOpen, props.className, saving, triggerSave],
|
|
68
74
|
);
|
|
69
75
|
|
|
70
76
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../
|
|
1
|
+
import "../../styles/GridFormDropDown.scss";
|
|
2
2
|
|
|
3
3
|
import { MenuItem, MenuDivider, FocusableItem, MenuHeader } from "@react-menu3";
|
|
4
4
|
import { useCallback, useContext, useEffect, useRef, useState, KeyboardEvent } from "react";
|
|
@@ -7,10 +7,11 @@ import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
|
7
7
|
import { GridContext } from "@contexts/GridContext";
|
|
8
8
|
import { delay } from "lodash-es";
|
|
9
9
|
import debounce from "debounce-promise";
|
|
10
|
-
import { CellParams } from "../GridCell";
|
|
10
|
+
import { CellEditorCommon, CellParams } from "../GridCell";
|
|
11
11
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
12
12
|
|
|
13
13
|
export interface GridPopoutEditDropDownSelectedItem<RowType, ValueType> {
|
|
14
|
+
// Note the row that was clicked on will be first
|
|
14
15
|
selectedRows: RowType[];
|
|
15
16
|
value: ValueType;
|
|
16
17
|
}
|
|
@@ -31,7 +32,14 @@ export const MenuHeaderItem = (title: string) => {
|
|
|
31
32
|
|
|
32
33
|
export type SelectOption<ValueType> = ValueType | FinalSelectOption<ValueType>;
|
|
33
34
|
|
|
34
|
-
export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow, ValueType> {
|
|
35
|
+
export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow, ValueType> extends CellEditorCommon {
|
|
36
|
+
// This overrides CellEditorCommon to provide some common class options
|
|
37
|
+
className?:
|
|
38
|
+
| "GridPopoverEditDropDown-containerSmall"
|
|
39
|
+
| "GridPopoverEditDropDown-containerMedium"
|
|
40
|
+
| "GridPopoverEditDropDown-containerLarge"
|
|
41
|
+
| string
|
|
42
|
+
| undefined;
|
|
35
43
|
filtered?: "local" | "reload";
|
|
36
44
|
filterPlaceholder?: string;
|
|
37
45
|
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<RowType, ValueType>) => Promise<void>;
|
|
@@ -40,7 +48,6 @@ export interface GridFormPopoutDropDownProps<RowType extends GridBaseRow, ValueT
|
|
|
40
48
|
| SelectOption<ValueType>[]
|
|
41
49
|
| ((selectedRows: RowType[], filter?: string) => Promise<SelectOption<ValueType>[]> | SelectOption<ValueType>[]);
|
|
42
50
|
optionsRequestCancel?: () => void;
|
|
43
|
-
maxRows?: number;
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(
|
|
@@ -171,14 +178,11 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(
|
|
|
171
178
|
[filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, props],
|
|
172
179
|
);
|
|
173
180
|
|
|
174
|
-
const
|
|
175
|
-
props.maxRows !== undefined ? { maxHeight: 62 + 34 * props.maxRows, overFlowY: "auto" } : undefined;
|
|
176
|
-
|
|
177
|
-
const { popoverWrapper } = useGridPopoverHook();
|
|
181
|
+
const { popoverWrapper } = useGridPopoverHook({ className: props.className });
|
|
178
182
|
return popoverWrapper(
|
|
179
183
|
<>
|
|
180
184
|
{props.filtered && (
|
|
181
|
-
|
|
185
|
+
<div className={"GridFormDropDown-filter"}>
|
|
182
186
|
<FocusableItem className={"filter-item"}>
|
|
183
187
|
{({ ref }: any) => (
|
|
184
188
|
<div style={{ display: "flex", width: "100%" }}>
|
|
@@ -198,10 +202,10 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(
|
|
|
198
202
|
)}
|
|
199
203
|
</FocusableItem>
|
|
200
204
|
<MenuDivider key={`$$divider_filter`} />
|
|
201
|
-
|
|
205
|
+
</div>
|
|
202
206
|
)}
|
|
203
|
-
<ComponentLoadingWrapper loading={!options}>
|
|
204
|
-
|
|
207
|
+
<ComponentLoadingWrapper loading={!options} className={"GridFormDropDown-options"}>
|
|
208
|
+
<>
|
|
205
209
|
{options && options.length == filteredValues?.length && <MenuItem>[Empty]</MenuItem>}
|
|
206
210
|
{options?.map((item, index) =>
|
|
207
211
|
item.value === MenuSeparatorString ? (
|
|
@@ -220,7 +224,7 @@ export const GridFormDropDown = <RowType extends GridBaseRow, ValueType>(
|
|
|
220
224
|
</MenuItem>
|
|
221
225
|
),
|
|
222
226
|
)}
|
|
223
|
-
|
|
227
|
+
</>
|
|
224
228
|
</ComponentLoadingWrapper>
|
|
225
229
|
</>,
|
|
226
230
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "../../styles/GridFormEditBearing.scss";
|
|
2
2
|
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { GridBaseRow } from "../Grid";
|
|
5
5
|
import { TextInputFormatted } from "../../lui/TextInputFormatted";
|
|
6
6
|
import { bearingNumberParser, bearingStringValidator, convertDDToDMS } from "@utils/bearing";
|
|
7
7
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
8
|
-
import { CellParams } from "@components/GridCell";
|
|
8
|
+
import { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
9
9
|
|
|
10
|
-
export interface GridFormEditBearingProps<RowType extends GridBaseRow> {
|
|
10
|
+
export interface GridFormEditBearingProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
11
11
|
placeHolder?: string;
|
|
12
12
|
range?: (value: number | null) => string | null;
|
|
13
13
|
onSave?: (selectedRows: RowType[], value: number | null) => Promise<boolean>;
|
|
@@ -39,7 +39,7 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(_props: GridFor
|
|
|
39
39
|
},
|
|
40
40
|
[props, value],
|
|
41
41
|
);
|
|
42
|
-
const { triggerSave, popoverWrapper } = useGridPopoverHook({ save });
|
|
42
|
+
const { triggerSave, popoverWrapper } = useGridPopoverHook({ className: props.className, save });
|
|
43
43
|
|
|
44
44
|
return popoverWrapper(
|
|
45
45
|
<div className={"GridFormEditBearing-input Grid-popoverContainer"}>
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
1
2
|
import { useEffect, useState } from "react";
|
|
2
3
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
3
4
|
import { GridBaseRow } from "../Grid";
|
|
4
5
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
5
|
-
import { CellParams } from "@components/GridCell";
|
|
6
|
+
import { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
6
7
|
|
|
7
|
-
export interface GridFormMessageProps<RowType extends GridBaseRow> {
|
|
8
|
+
export interface GridFormMessageProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
8
9
|
message: (cellParams: CellParams<RowType>) => Promise<string | JSX.Element> | string | JSX.Element;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export const GridFormMessage = <RowType extends GridBaseRow>(_props: GridFormMessageProps<RowType>) => {
|
|
12
13
|
const props = _props as GridFormMessageProps<RowType> & CellParams<RowType>;
|
|
13
14
|
const [message, setMessage] = useState<string | JSX.Element | null>(null);
|
|
14
|
-
const { popoverWrapper } = useGridPopoverHook();
|
|
15
|
+
const { popoverWrapper } = useGridPopoverHook({ className: props.className });
|
|
15
16
|
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
(async () => {
|
|
@@ -20,10 +21,8 @@ export const GridFormMessage = <RowType extends GridBaseRow>(_props: GridFormMes
|
|
|
20
21
|
}, [props]);
|
|
21
22
|
|
|
22
23
|
return popoverWrapper(
|
|
23
|
-
<ComponentLoadingWrapper loading={message === null}>
|
|
24
|
-
|
|
25
|
-
{message}
|
|
26
|
-
</div>
|
|
24
|
+
<ComponentLoadingWrapper loading={message === null} className={clsx("GridFormMessage-container", props.className)}>
|
|
25
|
+
<>{message}</>
|
|
27
26
|
</ComponentLoadingWrapper>,
|
|
28
27
|
);
|
|
29
28
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import "../../
|
|
1
|
+
import "../../styles/GridFormMultiSelect.scss";
|
|
2
2
|
|
|
3
|
-
import { MenuItem, MenuDivider, FocusableItem
|
|
4
|
-
import {
|
|
3
|
+
import { MenuItem, MenuDivider, FocusableItem } from "@react-menu3";
|
|
4
|
+
import { useCallback, useEffect, useRef, useState, KeyboardEvent } from "react";
|
|
5
5
|
import { GridBaseRow } from "../Grid";
|
|
6
6
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
7
7
|
import { delay, fromPairs } from "lodash-es";
|
|
8
8
|
import { LuiCheckboxInput } from "@linzjs/lui";
|
|
9
9
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
10
10
|
import { MenuSeparatorString } from "@components/gridForm/GridFormDropDown";
|
|
11
|
-
import { CellParams } from "@components/GridCell";
|
|
11
|
+
import { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
12
|
+
import { ClickEvent } from "../../react-menu3/types";
|
|
12
13
|
|
|
13
14
|
interface MultiFinalSelectOption<ValueType> {
|
|
14
15
|
value: ValueType;
|
|
@@ -23,7 +24,14 @@ export interface MultiSelectResult<RowType> {
|
|
|
23
24
|
values: Record<string, any>;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType> {
|
|
27
|
+
export interface GridFormMultiSelectProps<RowType extends GridBaseRow, ValueType> extends CellEditorCommon {
|
|
28
|
+
// This overrides CellEditorCommon to provide some common class options
|
|
29
|
+
className?:
|
|
30
|
+
| "GridMultiSelect-containerSmall"
|
|
31
|
+
| "GridMultiSelect-containerMedium"
|
|
32
|
+
| "GridMultiSelect-containerLarge"
|
|
33
|
+
| string
|
|
34
|
+
| undefined;
|
|
27
35
|
filtered?: boolean;
|
|
28
36
|
filterPlaceholder?: string;
|
|
29
37
|
onSave?: (props: MultiSelectResult<RowType>) => Promise<boolean>;
|
|
@@ -58,7 +66,6 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
|
58
66
|
},
|
|
59
67
|
[props, selectedValues],
|
|
60
68
|
);
|
|
61
|
-
const { popoverWrapper, triggerSave } = useGridPopoverHook({ save });
|
|
62
69
|
|
|
63
70
|
// Load up options list if it's async function
|
|
64
71
|
useEffect(() => {
|
|
@@ -105,14 +112,15 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
|
105
112
|
);
|
|
106
113
|
}, [props.filtered, filter, options]);
|
|
107
114
|
|
|
115
|
+
const { popoverWrapper, triggerSave } = useGridPopoverHook({ className: props.className, save });
|
|
108
116
|
return popoverWrapper(
|
|
109
|
-
<ComponentLoadingWrapper loading={!options}>
|
|
110
|
-
|
|
117
|
+
<ComponentLoadingWrapper loading={!options} className={"GridFormMultiSelect-container"}>
|
|
118
|
+
<>
|
|
111
119
|
{options && props.filtered && (
|
|
112
120
|
<>
|
|
113
121
|
<FocusableItem className={"filter-item"} key={"filter"}>
|
|
114
122
|
{({ ref }: any) => (
|
|
115
|
-
<div style={{ display: "flex", width: "100%" }}>
|
|
123
|
+
<div style={{ display: "flex", width: "100%" }} className={"GridFormMultiSelect-filter"}>
|
|
116
124
|
<input
|
|
117
125
|
autoFocus
|
|
118
126
|
className={"free-text-input"}
|
|
@@ -130,70 +138,72 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow, ValueType>(
|
|
|
130
138
|
<MenuDivider key={`$$divider_filter`} />
|
|
131
139
|
</>
|
|
132
140
|
)}
|
|
133
|
-
{options
|
|
134
|
-
item
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
e
|
|
142
|
-
|
|
143
|
-
setSelectedValues(selectedValues.filter((value) => value != item.value));
|
|
144
|
-
} else {
|
|
145
|
-
setSelectedValues([...selectedValues, item.value]);
|
|
146
|
-
}
|
|
147
|
-
}}
|
|
148
|
-
onKeyDown={async (e: KeyboardEvent) => {
|
|
149
|
-
if (e.key === "Enter") triggerSave().then();
|
|
150
|
-
else if (e.key === " ") {
|
|
141
|
+
<div className={"GridFormMultiSelect-options"}>
|
|
142
|
+
{options?.map((item, index) =>
|
|
143
|
+
item.value === MenuSeparatorString ? (
|
|
144
|
+
<MenuDivider key={`$$divider_${index}`} />
|
|
145
|
+
) : filteredValues.includes(item.value) ? null : (
|
|
146
|
+
<div key={`${index}`}>
|
|
147
|
+
<MenuItem
|
|
148
|
+
key={`${index}`}
|
|
149
|
+
onClick={(e: ClickEvent) => {
|
|
150
|
+
e.keepOpen = true;
|
|
151
151
|
if (selectedValues.includes(item.value)) {
|
|
152
152
|
setSelectedValues(selectedValues.filter((value) => value != item.value));
|
|
153
153
|
} else {
|
|
154
154
|
setSelectedValues([...selectedValues, item.value]);
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
inputProps={{
|
|
166
|
-
onClick: (e) => {
|
|
156
|
+
}}
|
|
157
|
+
onKeyDown={async (e: KeyboardEvent) => {
|
|
158
|
+
if (e.key === "Enter") triggerSave().then();
|
|
159
|
+
else if (e.key === " ") {
|
|
160
|
+
if (selectedValues.includes(item.value)) {
|
|
161
|
+
setSelectedValues(selectedValues.filter((value) => value != item.value));
|
|
162
|
+
} else {
|
|
163
|
+
setSelectedValues([...selectedValues, item.value]);
|
|
164
|
+
}
|
|
167
165
|
e.preventDefault();
|
|
168
166
|
e.stopPropagation();
|
|
169
|
-
|
|
170
|
-
},
|
|
171
|
-
}}
|
|
172
|
-
onChange={() => {
|
|
173
|
-
/*Do nothing, change handled by menuItem*/
|
|
167
|
+
}
|
|
174
168
|
}}
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
>
|
|
170
|
+
<LuiCheckboxInput
|
|
171
|
+
isChecked={selectedValues.includes(item.value)}
|
|
172
|
+
value={`${item.value}`}
|
|
173
|
+
label={item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)}
|
|
174
|
+
inputProps={{
|
|
175
|
+
onClick: (e) => {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
e.stopPropagation();
|
|
178
|
+
return false;
|
|
179
|
+
},
|
|
180
|
+
}}
|
|
181
|
+
onChange={() => {
|
|
182
|
+
/*Do nothing, change handled by menuItem*/
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
</MenuItem>
|
|
177
186
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
{selectedValues.includes(item.value) && item.subComponent && (
|
|
188
|
+
<FocusableItem className={"LuiDeprecatedForms"} key={`${item.value}_subcomponent`}>
|
|
189
|
+
{(ref: any) =>
|
|
190
|
+
item.subComponent &&
|
|
191
|
+
item.subComponent(
|
|
192
|
+
{
|
|
193
|
+
setValue: (value: any) => {
|
|
194
|
+
subSelectedValues.current[item.value as string] = value;
|
|
195
|
+
},
|
|
186
196
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
ref,
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
</FocusableItem>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
),
|
|
204
|
+
)}
|
|
205
|
+
</div>
|
|
206
|
+
</>
|
|
197
207
|
</ComponentLoadingWrapper>,
|
|
198
208
|
);
|
|
199
209
|
};
|
|
@@ -4,9 +4,9 @@ import { GridContext } from "@contexts/GridContext";
|
|
|
4
4
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
5
5
|
import { MenuDivider, MenuItem } from "@react-menu3";
|
|
6
6
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
7
|
-
import { CellParams } from "@components/GridCell";
|
|
7
|
+
import { CellEditorCommon, CellParams } from "@components/GridCell";
|
|
8
8
|
|
|
9
|
-
export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> {
|
|
9
|
+
export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
10
10
|
options: (selectedRows: RowType[]) => Promise<MenuOption<RowType>[]>;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -68,10 +68,10 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(_props: GridForm
|
|
|
68
68
|
return menuOption.label === PopoutMenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
const { popoverWrapper } = useGridPopoverHook();
|
|
71
|
+
const { popoverWrapper } = useGridPopoverHook({ className: props.className });
|
|
72
72
|
return popoverWrapper(
|
|
73
|
-
<ComponentLoadingWrapper loading={!filteredOptions}>
|
|
74
|
-
|
|
73
|
+
<ComponentLoadingWrapper loading={!filteredOptions} className={"GridFormPopupMenu"}>
|
|
74
|
+
<>
|
|
75
75
|
{options?.map((item, index) =>
|
|
76
76
|
item.label === PopoutMenuSeparator ? (
|
|
77
77
|
<MenuDivider key={`$$divider_${index}`} />
|
|
@@ -88,7 +88,7 @@ export const GridFormPopoutMenu = <RowType extends GridBaseRow>(_props: GridForm
|
|
|
88
88
|
)
|
|
89
89
|
),
|
|
90
90
|
)}
|
|
91
|
-
|
|
91
|
+
</>
|
|
92
92
|
</ComponentLoadingWrapper>,
|
|
93
93
|
);
|
|
94
94
|
};
|