@linzjs/step-ag-grid 16.0.0 → 17.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/dist/GridTheme.scss +138 -106
- package/dist/index.css +1 -8
- package/dist/node_modules/@linzjs/lui/dist/assets/svg-content.d.ts +7 -0
- package/dist/src/components/ComponentLoadingWrapper.d.ts +3 -4
- package/dist/src/components/Grid.d.ts +2 -2
- package/dist/src/components/GridCell.d.ts +5 -5
- package/dist/src/components/GridCellMultiEditor.d.ts +2 -2
- package/dist/src/components/GridNoRowsOverlay.d.ts +3 -2
- package/dist/src/components/GridPopoverHook.d.ts +3 -3
- package/dist/src/components/GridWrapper.d.ts +2 -3
- package/dist/src/components/PostSortRowsHook.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterButtons.d.ts +2 -2
- package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +2 -2
- package/dist/src/components/gridFilter/GridFilters.d.ts +2 -5
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormMessage.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -2
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +2 -2
- package/dist/src/contexts/GridContext.d.ts +4 -4
- package/dist/src/contexts/GridContextProvider.d.ts +2 -6
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +2 -3
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +2 -6
- package/dist/src/lui/ActionButton.d.ts +2 -2
- package/dist/src/lui/FormError.d.ts +2 -2
- package/dist/src/lui/TextAreaInput.d.ts +3 -3
- package/dist/src/lui/TextInputFormatted.d.ts +3 -3
- package/dist/src/react-menu3/components/FocusableItem.d.ts +2 -2
- package/dist/src/react-menu3/utils/withHovering.d.ts +2 -2
- package/dist/src/utils/textValidator.d.ts +3 -3
- package/dist/step-ag-grid.cjs.js +39 -17
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +39 -17
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +45 -45
- package/src/components/ComponentLoadingWrapper.tsx +9 -6
- package/src/components/Grid.tsx +19 -10
- package/src/components/GridCell.tsx +5 -5
- package/src/components/GridCellMultiEditor.tsx +2 -2
- package/src/components/GridNoRowsOverlay.tsx +4 -2
- package/src/components/GridPopoverHook.tsx +4 -4
- package/src/components/GridWrapper.tsx +2 -3
- package/src/components/PostSortRowsHook.ts +4 -4
- package/src/components/gridFilter/GridFilterButtons.tsx +2 -2
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +2 -2
- package/src/components/gridFilter/GridFilters.tsx +4 -6
- package/src/components/gridForm/GridFormDropDown.tsx +4 -4
- package/src/components/gridForm/GridFormMessage.tsx +3 -3
- package/src/components/gridForm/GridFormMultiSelect.tsx +2 -1
- package/src/components/gridForm/GridFormPopoverMenu.tsx +4 -4
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +2 -2
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +2 -2
- package/src/components/gridForm/GridFormTextArea.tsx +2 -2
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +1 -1
- package/src/components/gridRender/GridRenderGenericCell.tsx +2 -1
- package/src/contexts/GridContext.tsx +4 -4
- package/src/contexts/GridContextProvider.tsx +33 -22
- package/src/contexts/GridPopoverContextProvider.tsx +2 -3
- package/src/contexts/GridUpdatingContextProvider.tsx +2 -6
- package/src/lui/ActionButton.tsx +2 -2
- package/src/lui/FormError.tsx +3 -1
- package/src/lui/TextAreaInput.tsx +3 -3
- package/src/lui/TextInputFormatted.tsx +3 -3
- package/src/lui/reactUtils.test.tsx +3 -3
- package/src/react-menu3/components/FocusableItem.tsx +2 -2
- package/src/react-menu3/utils/utils.ts +1 -1
- package/src/react-menu3/utils/withHovering.tsx +2 -2
- package/src/stories/grid/FormTest.tsx +2 -2
- package/src/stories/grid/GridFilterButtons.stories.tsx +8 -1
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +8 -8
- package/src/stories/grid/GridNonEditableRow.stories.tsx +9 -2
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +8 -1
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +8 -1
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +8 -1
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +7 -0
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +7 -0
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +7 -0
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +8 -0
- package/src/stories/grid/GridReadOnly.stories.tsx +10 -2
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +2 -2
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +7 -2
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +7 -2
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +2 -2
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +4 -3
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +3 -3
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +3 -3
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +2 -2
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +1 -1
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +4 -0
- package/src/styles/ComponentLoadingWrapper.scss +1 -4
- package/src/styles/Grid.scss +0 -4
- package/src/styles/GridTheme.scss +138 -106
- package/src/utils/testUtil.ts +3 -0
- package/src/utils/textValidator.ts +3 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@linzjs/step-ag-grid",
|
|
3
3
|
"repository": "github:linz/step-ag-grid.git",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "17.0.1",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"aggrid",
|
|
8
8
|
"ag-grid",
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=18"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@linzjs/lui": "
|
|
31
|
-
"ag-grid-community": ">=
|
|
32
|
-
"ag-grid-react": ">=
|
|
30
|
+
"@linzjs/lui": "^18",
|
|
31
|
+
"ag-grid-community": ">=28",
|
|
32
|
+
"ag-grid-react": ">=28",
|
|
33
33
|
"lodash-es": ">=4",
|
|
34
34
|
"react": ">=17",
|
|
35
35
|
"react-dom": ">=17"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@linzjs/lui": "
|
|
39
|
-
"ag-grid-community": ">=
|
|
40
|
-
"ag-grid-react": ">=
|
|
38
|
+
"@linzjs/lui": "^18",
|
|
39
|
+
"ag-grid-community": ">=28",
|
|
40
|
+
"ag-grid-react": ">=28",
|
|
41
41
|
"debounce-promise": "^3.1.2",
|
|
42
42
|
"lodash-es": ">=4",
|
|
43
43
|
"matcher": "^5.0.0",
|
|
44
44
|
"react": ">=17",
|
|
45
45
|
"react-dom": ">=17",
|
|
46
|
-
"react-transition-state": "^2.
|
|
46
|
+
"react-transition-state": "^2.1.1",
|
|
47
47
|
"uuid": "^9.0.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
@@ -81,80 +81,80 @@
|
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@
|
|
84
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
85
|
+
"@rollup/plugin-commonjs": "^25.0.4",
|
|
85
86
|
"@rollup/plugin-json": "^6.0.0",
|
|
86
87
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
87
88
|
"@semantic-release/changelog": "^6.0.3",
|
|
88
89
|
"@semantic-release/git": "^10.0.1",
|
|
89
|
-
"@storybook/addon-essentials": "^7.2.
|
|
90
|
-
"@storybook/addon-interactions": "^7.2.
|
|
90
|
+
"@storybook/addon-essentials": "^7.2.3",
|
|
91
|
+
"@storybook/addon-interactions": "^7.2.3",
|
|
91
92
|
"@storybook/addon-postcss": "^2.0.0",
|
|
92
93
|
"@storybook/jest": "^0.1.0",
|
|
93
|
-
"@storybook/preset-create-react-app": "^7.2.
|
|
94
|
-
"@storybook/react": "^7.2.
|
|
95
|
-
"@storybook/react-webpack5": "^7.2.
|
|
94
|
+
"@storybook/preset-create-react-app": "^7.2.3",
|
|
95
|
+
"@storybook/react": "^7.2.3",
|
|
96
|
+
"@storybook/react-webpack5": "^7.2.3",
|
|
96
97
|
"@storybook/test-runner": "^0.13.0",
|
|
97
98
|
"@storybook/testing-library": "^0.2.0",
|
|
98
99
|
"@testing-library/dom": "^9.3.1",
|
|
99
100
|
"@testing-library/jest-dom": "^5.17.0",
|
|
100
101
|
"@testing-library/react": "^14.0.0",
|
|
101
102
|
"@testing-library/user-event": "^14.4.3",
|
|
102
|
-
"@trivago/prettier-plugin-sort-imports": "^4.
|
|
103
|
+
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
|
|
103
104
|
"@types/debounce-promise": "^3.1.6",
|
|
104
|
-
"@types/jest": "^29.5.
|
|
105
|
+
"@types/jest": "^29.5.3",
|
|
105
106
|
"@types/lodash-es": "^4.17.8",
|
|
106
|
-
"@types/node": "^
|
|
107
|
+
"@types/node": "^18.17.5",
|
|
107
108
|
"@types/react": "^18.2.20",
|
|
108
109
|
"@types/react-dom": "^18.2.7",
|
|
109
110
|
"@types/uuid": "^9.0.2",
|
|
110
|
-
"@typescript-eslint/parser": "^5.
|
|
111
|
-
"babel-jest": "^29.
|
|
111
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
112
|
+
"babel-jest": "^29.6.2",
|
|
112
113
|
"babel-preset-react-app": "^10.0.1",
|
|
113
114
|
"chromatic": "^6.21.0",
|
|
114
|
-
"conventional-changelog-conventionalcommits": "^
|
|
115
|
+
"conventional-changelog-conventionalcommits": "^6.1.0",
|
|
115
116
|
"css-loader": "^6.8.1",
|
|
116
|
-
"eslint": "^8.
|
|
117
|
-
"eslint-config-prettier": "^
|
|
117
|
+
"eslint": "^8.47.0",
|
|
118
|
+
"eslint-config-prettier": "^9.0.0",
|
|
118
119
|
"eslint-config-react-app": "^7.0.1",
|
|
119
|
-
"eslint-plugin-deprecation": "^1.
|
|
120
|
-
"eslint-plugin-import": "^2.
|
|
121
|
-
"eslint-plugin-jest": "^27.2.
|
|
120
|
+
"eslint-plugin-deprecation": "^1.5.0",
|
|
121
|
+
"eslint-plugin-import": "^2.28.0",
|
|
122
|
+
"eslint-plugin-jest": "^27.2.3",
|
|
122
123
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
123
124
|
"eslint-plugin-prettier": "^4.2.1",
|
|
124
|
-
"eslint-plugin-react": "^7.
|
|
125
|
+
"eslint-plugin-react": "^7.33.1",
|
|
125
126
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
126
127
|
"eslint-plugin-storybook": "^0.6.13",
|
|
127
|
-
"eslint-plugin-testing-library": "^
|
|
128
|
+
"eslint-plugin-testing-library": "^6.0.0",
|
|
128
129
|
"jest": "^29.6.2",
|
|
129
|
-
"jest-canvas-mock": "^2.5.
|
|
130
|
-
"jest-environment-jsdom": "^29.
|
|
130
|
+
"jest-canvas-mock": "^2.5.2",
|
|
131
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
131
132
|
"jest-expect-message": "^1.1.3",
|
|
132
133
|
"mkdirp": "^3.0.1",
|
|
133
134
|
"npm-run-all": "^4.1.5",
|
|
134
|
-
"postcss": "^8.4.
|
|
135
|
-
"postcss-loader": "^7.3.
|
|
135
|
+
"postcss": "^8.4.27",
|
|
136
|
+
"postcss-loader": "^7.3.3",
|
|
136
137
|
"postcss-scss": "^4.0.6",
|
|
137
138
|
"prettier": "^2.8.8",
|
|
138
139
|
"react-app-polyfill": "^3.0.0",
|
|
139
140
|
"react-scripts": "^5.0.1",
|
|
140
|
-
"rollup": "^3.
|
|
141
|
+
"rollup": "^3.28.0",
|
|
141
142
|
"rollup-plugin-copy": "^3.4.0",
|
|
142
143
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
143
144
|
"rollup-plugin-postcss": "^4.0.2",
|
|
144
|
-
"rollup-plugin-typescript2": "^0.
|
|
145
|
-
"sass": "
|
|
146
|
-
"sass-loader": "^13.3.
|
|
147
|
-
"semantic-release": "^
|
|
148
|
-
"storybook": "^7.2.
|
|
145
|
+
"rollup-plugin-typescript2": "^0.35.0",
|
|
146
|
+
"sass": "1.64.2",
|
|
147
|
+
"sass-loader": "^13.3.2",
|
|
148
|
+
"semantic-release": "^21.0.7",
|
|
149
|
+
"storybook": "^7.2.3",
|
|
149
150
|
"storybook-css-modules-preset": "^1.1.1",
|
|
150
151
|
"style-loader": "^3.3.3",
|
|
151
|
-
"stylelint": "^
|
|
152
|
-
"stylelint-config-
|
|
153
|
-
"stylelint-config-
|
|
154
|
-
"stylelint-
|
|
155
|
-
"stylelint-
|
|
156
|
-
"
|
|
157
|
-
"tsconfig-paths-webpack-plugin": "^4.0.1",
|
|
152
|
+
"stylelint": "^15.10.2",
|
|
153
|
+
"stylelint-config-recommended-scss": "^12.0.0",
|
|
154
|
+
"stylelint-config-standard": "^34.0.0",
|
|
155
|
+
"stylelint-prettier": "^3.0.0",
|
|
156
|
+
"stylelint-scss": "^5.1.0",
|
|
157
|
+
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
158
158
|
"typescript": "^4.9.5"
|
|
159
159
|
},
|
|
160
160
|
"babel": {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactElement } from "react";
|
|
2
|
+
|
|
1
3
|
import { LuiMiniSpinner } from "@linzjs/lui";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* If loading is true this returns a loading spinner, otherwise it returns its children.
|
|
5
7
|
*/
|
|
6
|
-
export const ComponentLoadingWrapper = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
8
|
+
export const ComponentLoadingWrapper = (
|
|
9
|
+
props: PropsWithChildren<{
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
saving?: boolean;
|
|
12
|
+
className: string | undefined;
|
|
13
|
+
}>,
|
|
14
|
+
): ReactElement => {
|
|
12
15
|
return props.loading ? (
|
|
13
16
|
<LuiMiniSpinner size={22} divProps={{ role: "status", ["aria-label"]: "Loading", style: { padding: 16 } }} />
|
|
14
17
|
) : (
|
package/src/components/Grid.tsx
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { CellClickedEvent, ColDef, ColGroupDef, ColumnResizedEvent, ModelUpdatedEvent } from "ag-grid-community";
|
|
2
2
|
import { CellClassParams, EditableCallback, EditableCallbackParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
3
3
|
import { GridOptions } from "ag-grid-community/dist/lib/entities/gridOptions";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AgGridEvent,
|
|
6
|
+
CellEvent,
|
|
7
|
+
CellKeyDownEvent,
|
|
8
|
+
GridReadyEvent,
|
|
9
|
+
SelectionChangedEvent,
|
|
10
|
+
} from "ag-grid-community/dist/lib/events";
|
|
5
11
|
import { AgGridReact } from "ag-grid-react";
|
|
6
12
|
import clsx from "clsx";
|
|
7
13
|
import { defer, difference, isEmpty, last, omit, xorBy } from "lodash-es";
|
|
8
|
-
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
14
|
+
import { ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
9
15
|
|
|
10
16
|
import { GridContext } from "../contexts/GridContext";
|
|
11
17
|
import { GridUpdatingContext } from "../contexts/GridUpdatingContext";
|
|
@@ -87,12 +93,12 @@ export const Grid = ({
|
|
|
87
93
|
"data-testid": dataTestId,
|
|
88
94
|
rowSelection = "multiple",
|
|
89
95
|
suppressColumnVirtualization = true,
|
|
90
|
-
theme = "ag-theme-
|
|
96
|
+
theme = "ag-theme-step-default",
|
|
91
97
|
sizeColumns = "auto",
|
|
92
98
|
selectColumnPinned = null,
|
|
93
99
|
contextMenuSelectRow = false,
|
|
94
100
|
...params
|
|
95
|
-
}: GridProps):
|
|
101
|
+
}: GridProps): ReactElement => {
|
|
96
102
|
const {
|
|
97
103
|
gridReady,
|
|
98
104
|
setApis,
|
|
@@ -114,9 +120,11 @@ export const Grid = ({
|
|
|
114
120
|
const { prePopupOps } = useContext(GridContext);
|
|
115
121
|
|
|
116
122
|
const gridDivRef = useRef<HTMLDivElement>(null);
|
|
117
|
-
|
|
118
123
|
const lastSelectedIds = useRef<number[]>([]);
|
|
124
|
+
|
|
119
125
|
const [staleGrid, setStaleGrid] = useState(false);
|
|
126
|
+
const [autoSized, setAutoSized] = useState(false);
|
|
127
|
+
|
|
120
128
|
const postSortRows = usePostSortRowsHook({ setStaleGrid });
|
|
121
129
|
|
|
122
130
|
/**
|
|
@@ -162,6 +170,7 @@ export const Grid = ({
|
|
|
162
170
|
if (sizeColumns !== "none") {
|
|
163
171
|
sizeColumnsToFit();
|
|
164
172
|
}
|
|
173
|
+
setAutoSized(true);
|
|
165
174
|
needsAutoSize.current = false;
|
|
166
175
|
}, [autoSizeColumns, params, sizeColumns, sizeColumnsToFit]);
|
|
167
176
|
|
|
@@ -471,7 +480,7 @@ export const Grid = ({
|
|
|
471
480
|
* Start editing on pressing Enter
|
|
472
481
|
*/
|
|
473
482
|
const onCellKeyPress = useCallback(
|
|
474
|
-
(e:
|
|
483
|
+
(e: CellKeyDownEvent) => {
|
|
475
484
|
if ((e.event as KeyboardEvent).key === "Enter") {
|
|
476
485
|
if (!invokeEditAction(e)) startCellEditing(e);
|
|
477
486
|
}
|
|
@@ -551,7 +560,7 @@ export const Grid = ({
|
|
|
551
560
|
}, [sizeColumns, sizeColumnsToFit]);
|
|
552
561
|
|
|
553
562
|
/**
|
|
554
|
-
* Set of column
|
|
563
|
+
* Set of column I'd's that are prevented from auto-sizing as they are user set
|
|
555
564
|
*/
|
|
556
565
|
const userSizedColIds = useRef(new Set<string>());
|
|
557
566
|
|
|
@@ -583,7 +592,7 @@ export const Grid = ({
|
|
|
583
592
|
"Grid-container",
|
|
584
593
|
theme,
|
|
585
594
|
staleGrid && "Grid-sortIsStale",
|
|
586
|
-
gridReady && params.rowData && "Grid-ready",
|
|
595
|
+
gridReady && params.rowData && autoSized && "Grid-ready",
|
|
587
596
|
)}
|
|
588
597
|
>
|
|
589
598
|
{gridContextMenu.component}
|
|
@@ -602,8 +611,8 @@ export const Grid = ({
|
|
|
602
611
|
onColumnVisible={() => {
|
|
603
612
|
setInitialContentSize();
|
|
604
613
|
}}
|
|
605
|
-
|
|
606
|
-
|
|
614
|
+
onRowDataUpdated={onRowDataChanged}
|
|
615
|
+
onCellKeyDown={onCellKeyPress}
|
|
607
616
|
onCellClicked={onCellClicked}
|
|
608
617
|
onCellDoubleClicked={onCellDoubleClick}
|
|
609
618
|
onCellEditingStarted={refreshSelectedRows}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ColDef, ICellEditorParams, ICellRendererParams } from "ag-grid-community";
|
|
2
2
|
import { SuppressKeyboardEventParams, ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
3
|
-
import { forwardRef, useContext } from "react";
|
|
3
|
+
import { ReactElement, forwardRef, useContext } from "react";
|
|
4
4
|
|
|
5
5
|
import { GridPopoverContextProvider } from "../contexts/GridPopoverContextProvider";
|
|
6
6
|
import { GridUpdatingContext } from "../contexts/GridUpdatingContext";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
|
|
19
19
|
export interface GenericCellEditorProps<E> {
|
|
20
20
|
multiEdit?: boolean;
|
|
21
|
-
editor?: (editorProps: E) =>
|
|
21
|
+
editor?: (editorProps: E) => ReactElement;
|
|
22
22
|
editorParams?: E;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -59,7 +59,7 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
|
|
|
59
59
|
// This is so that typescript retains the row type to pass to the GridCells
|
|
60
60
|
export interface ColDefT<RowType extends GridBaseRow> extends ColDef {
|
|
61
61
|
_?: RowType;
|
|
62
|
-
editor?: (editorProps: any) =>
|
|
62
|
+
editor?: (editorProps: any) => ReactElement;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export const suppressCellKeyboardEvents = (e: SuppressKeyboardEventParams) => {
|
|
@@ -106,7 +106,7 @@ export const GridCell = <RowType extends GridBaseRow, Props extends CellEditorCo
|
|
|
106
106
|
custom?: {
|
|
107
107
|
multiEdit?: boolean;
|
|
108
108
|
preventAutoEdit?: boolean;
|
|
109
|
-
editor?: (editorProps: Props) =>
|
|
109
|
+
editor?: (editorProps: Props) => ReactElement;
|
|
110
110
|
editorParams?: Props;
|
|
111
111
|
},
|
|
112
112
|
): ColDefT<RowType> => {
|
|
@@ -164,7 +164,7 @@ export interface CellEditorCommon {
|
|
|
164
164
|
className?: string | undefined;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
export const GenericCellEditorComponentWrapper = (editor?: (props: any) =>
|
|
167
|
+
export const GenericCellEditorComponentWrapper = (editor?: (props: any) => ReactElement) => {
|
|
168
168
|
const obj = { editor };
|
|
169
169
|
return forwardRef(function GenericCellEditorComponentFr(cellEditorParams: ICellEditorParams, _) {
|
|
170
170
|
const valueFormatted = cellEditorParams.formatValue
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CellEditorSelectorResult } from "ag-grid-community/dist/lib/entities/colDef";
|
|
2
2
|
import { ICellEditorParams } from "ag-grid-community/dist/lib/interfaces/iCellEditor";
|
|
3
|
-
import { ComponentProps } from "react";
|
|
3
|
+
import { ComponentProps, ReactElement } from "react";
|
|
4
4
|
|
|
5
5
|
import { GridBaseRow } from "./Grid";
|
|
6
6
|
import { ColDefT, GenericCellEditorComponentWrapper, GridCell } from "./GridCell";
|
|
7
7
|
import { GridCellMultiSelectClassRules } from "./GridCellMultiSelectClassRules";
|
|
8
8
|
import { GenericCellColDef } from "./gridRender";
|
|
9
9
|
|
|
10
|
-
export const Editor = <FN extends (param: any) =>
|
|
10
|
+
export const Editor = <FN extends (param: any) => ReactElement>(props: {
|
|
11
11
|
multiEdit: boolean;
|
|
12
12
|
editor: FN;
|
|
13
13
|
editorParams: ComponentProps<FN>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface GridNoRowsOverlayProps {
|
|
2
2
|
rowCount: number | undefined | null;
|
|
3
3
|
filteredRowCount: number;
|
|
4
4
|
noRowsOverlayText: string | undefined;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const GridNoRowsOverlay = (params: GridNoRowsOverlayProps) => {
|
|
6
8
|
if (params.rowCount === 0) return <span>{params.noRowsOverlayText ?? "There are currently no rows"}</span>;
|
|
7
9
|
if (params.filteredRowCount === 0) return <span>All rows have been filtered</span>;
|
|
8
10
|
return <span />;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
1
|
+
import { ReactElement, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { GridContext } from "../contexts/GridContext";
|
|
4
4
|
import { useGridPopoverContext } from "../contexts/GridPopoverContext";
|
|
@@ -10,8 +10,8 @@ import { GridBaseRow } from "./Grid";
|
|
|
10
10
|
export interface GridPopoverHookProps<RowType> {
|
|
11
11
|
className: string | undefined;
|
|
12
12
|
invalid?: () =>
|
|
13
|
-
| Promise<
|
|
14
|
-
|
|
|
13
|
+
| Promise<ReactElement | boolean | string | null | undefined>
|
|
14
|
+
| ReactElement
|
|
15
15
|
| boolean
|
|
16
16
|
| string
|
|
17
17
|
| null
|
|
@@ -59,7 +59,7 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
|
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
const popoverWrapper = useCallback(
|
|
62
|
-
(children:
|
|
62
|
+
(children: ReactElement) => {
|
|
63
63
|
return (
|
|
64
64
|
<>
|
|
65
65
|
{anchorRef.current && (
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
2
|
|
|
3
3
|
export interface GridWrapperProps {
|
|
4
|
-
children: ReactNode;
|
|
5
4
|
maxHeight?: number | string;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
export const GridWrapper = ({ children, maxHeight }: GridWrapperProps) => (
|
|
7
|
+
export const GridWrapper = ({ children, maxHeight }: PropsWithChildren<GridWrapperProps>) => (
|
|
9
8
|
<div className={"Grid-wrapper"} style={{ maxHeight }}>
|
|
10
9
|
{children}
|
|
11
10
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IRowNode } from "ag-grid-community";
|
|
2
2
|
import { ColumnState } from "ag-grid-community/dist/lib/columns/columnModel";
|
|
3
|
-
import { PostSortRowsParams } from "ag-grid-community/dist/lib/
|
|
3
|
+
import { PostSortRowsParams } from "ag-grid-community/dist/lib/interfaces/iCallbackParams";
|
|
4
4
|
import { isEmpty } from "lodash-es";
|
|
5
5
|
import { useCallback, useContext, useRef } from "react";
|
|
6
6
|
|
|
@@ -44,7 +44,7 @@ export const usePostSortRowsHook = ({ setStaleGrid }: PostSortRowsHookProps) =>
|
|
|
44
44
|
|
|
45
45
|
const previousRowSortIndex = previousRowSortIndexRef.current;
|
|
46
46
|
|
|
47
|
-
const hashNode = (node:
|
|
47
|
+
const hashNode = (node: IRowNode | undefined) => {
|
|
48
48
|
return node ? JSON.stringify(node.data) : "";
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -124,7 +124,7 @@ export const usePostSortRowsHook = ({ setStaleGrid }: PostSortRowsHookProps) =>
|
|
|
124
124
|
}
|
|
125
125
|
} else {
|
|
126
126
|
let firstChangedNodeIndex = -1;
|
|
127
|
-
let lastNewNode:
|
|
127
|
+
let lastNewNode: IRowNode | undefined = undefined;
|
|
128
128
|
let changedRowCount = 0;
|
|
129
129
|
let newRowCount = 0;
|
|
130
130
|
let index = 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx, { ClassValue } from "clsx";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
2
|
+
import { ReactElement, useMemo, useState } from "react";
|
|
3
3
|
|
|
4
4
|
import { LuiButton, LuiButtonGroup } from "@linzjs/lui";
|
|
5
5
|
import { LuiButtonProps } from "@linzjs/lui/dist/components/LuiButton/LuiButton";
|
|
@@ -24,7 +24,7 @@ export const GridFilterButtons = <RowType extends GridBaseRow>({
|
|
|
24
24
|
className,
|
|
25
25
|
luiButtonProps,
|
|
26
26
|
options,
|
|
27
|
-
}: GridFilterButtonsProps<RowType>):
|
|
27
|
+
}: GridFilterButtonsProps<RowType>): ReactElement => {
|
|
28
28
|
// Select defaultSelected option, otherwise first option. If no options select none.
|
|
29
29
|
const [selectedOption, setSelectedOption] = useState(options.find((option) => option.defaultSelected) ?? options[0]);
|
|
30
30
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmpty } from "lodash-es";
|
|
2
|
-
import { useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { ReactElement, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
3
3
|
|
|
4
4
|
import { LuiCheckboxInput, LuiIcon } from "@linzjs/lui";
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ export interface GridFilterColumnsToggleProps {
|
|
|
14
14
|
saveState?: boolean;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const GridFilterColumnsToggle = ({ saveState = true }: GridFilterColumnsToggleProps):
|
|
17
|
+
export const GridFilterColumnsToggle = ({ saveState = true }: GridFilterColumnsToggleProps): ReactElement => {
|
|
18
18
|
const [loaded, setLoaded] = useState(false);
|
|
19
19
|
const { getColumns, getColumnIds, invisibleColumnIds, setInvisibleColumnIds } = useContext(GridContext);
|
|
20
20
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
children
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const GridFilters = ({ children }: GridFiltersProps) => <div className="Grid-container-filters">{children}</div>;
|
|
3
|
+
export const GridFilters = ({ children }: PropsWithChildren) => (
|
|
4
|
+
<div className="Grid-container-filters">{children}</div>
|
|
5
|
+
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debounce from "debounce-promise";
|
|
2
2
|
import { isEmpty } from "lodash-es";
|
|
3
|
-
import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Fragment, ReactElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
|
|
5
5
|
import { useGridPopoverContext } from "../../contexts/GridPopoverContext";
|
|
6
6
|
import { GridSubComponentContext } from "../../contexts/GridSubComponentContext";
|
|
@@ -23,7 +23,7 @@ export interface GridPopoutEditDropDownSelectedItem<RowType> {
|
|
|
23
23
|
|
|
24
24
|
interface FinalSelectOption {
|
|
25
25
|
value: any;
|
|
26
|
-
label?:
|
|
26
|
+
label?: ReactElement | string;
|
|
27
27
|
disabled?: boolean | string;
|
|
28
28
|
subComponent?: (props: any, ref: any) => any;
|
|
29
29
|
}
|
|
@@ -189,8 +189,8 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormDro
|
|
|
189
189
|
dontSaveOnExternalClick: true,
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
let lastHeader:
|
|
193
|
-
let showHeader:
|
|
192
|
+
let lastHeader: ReactElement | null = null;
|
|
193
|
+
let showHeader: ReactElement | null = null;
|
|
194
194
|
|
|
195
195
|
return popoverWrapper(
|
|
196
196
|
<>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { ReactElement, useEffect, useState } from "react";
|
|
3
3
|
|
|
4
4
|
import { useGridPopoverContext } from "../../contexts/GridPopoverContext";
|
|
5
5
|
import { ComponentLoadingWrapper } from "../ComponentLoadingWrapper";
|
|
@@ -8,13 +8,13 @@ import { CellEditorCommon } from "../GridCell";
|
|
|
8
8
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
9
9
|
|
|
10
10
|
export interface GridFormMessageProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
11
|
-
message: (selectedRows: RowType[]) => Promise<string |
|
|
11
|
+
message: (selectedRows: RowType[]) => Promise<string | ReactElement> | string | ReactElement;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const GridFormMessage = <RowType extends GridBaseRow>(props: GridFormMessageProps<RowType>) => {
|
|
15
15
|
const { selectedRows } = useGridPopoverContext<RowType>();
|
|
16
16
|
|
|
17
|
-
const [message, setMessage] = useState<string |
|
|
17
|
+
const [message, setMessage] = useState<string | ReactElement | null>(null);
|
|
18
18
|
const { popoverWrapper } = useGridPopoverHook({ className: props.className });
|
|
19
19
|
|
|
20
20
|
useEffect(() => {
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Dispatch,
|
|
4
4
|
Fragment,
|
|
5
5
|
KeyboardEvent,
|
|
6
|
+
ReactElement,
|
|
6
7
|
SetStateAction,
|
|
7
8
|
useCallback,
|
|
8
9
|
useEffect,
|
|
@@ -31,7 +32,7 @@ type HeaderGroupType = Record<string, MultiSelectOption[]> | undefined;
|
|
|
31
32
|
export interface MultiSelectOption {
|
|
32
33
|
value: any;
|
|
33
34
|
label?: string;
|
|
34
|
-
subComponent?: (props: any) =>
|
|
35
|
+
subComponent?: (props: any) => ReactElement;
|
|
35
36
|
subValue?: any;
|
|
36
37
|
filter?: string;
|
|
37
38
|
checked?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmpty } from "lodash-es";
|
|
2
|
-
import { Fragment, useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Fragment, ReactElement, useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
|
|
4
4
|
import { useGridPopoverContext } from "../../contexts/GridPopoverContext";
|
|
5
5
|
import { GridSubComponentContext } from "../../contexts/GridSubComponentContext";
|
|
@@ -28,11 +28,11 @@ export interface SelectedMenuOptionResult<RowType extends GridBaseRow> extends M
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface MenuOption<RowType extends GridBaseRow> {
|
|
31
|
-
label:
|
|
31
|
+
label: ReactElement | string | MenuSeparatorType;
|
|
32
32
|
action?: (props: { selectedRows: RowType[]; menuOption: SelectedMenuOptionResult<RowType> }) => Promise<void>;
|
|
33
33
|
disabled?: string | boolean;
|
|
34
34
|
hidden?: boolean;
|
|
35
|
-
subComponent?: (props: any) =>
|
|
35
|
+
subComponent?: (props: any) => ReactElement;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -141,7 +141,7 @@ export const GridFormPopoverMenu = <RowType extends GridBaseRow>(props: GridForm
|
|
|
141
141
|
disabled={!!item.disabled}
|
|
142
142
|
title={item.disabled && typeof item.disabled !== "boolean" ? item.disabled : ""}
|
|
143
143
|
>
|
|
144
|
-
{item.label as
|
|
144
|
+
{item.label as ReactElement | string}
|
|
145
145
|
</MenuItem>
|
|
146
146
|
{item.subComponent && subComponentSelected === item && (
|
|
147
147
|
<FocusableItem className={"LuiDeprecatedForms"} key={`${item.label}_subcomponent`}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
|
-
import { useCallback, useContext, useEffect } from "react";
|
|
2
|
+
import { ReactElement, useCallback, useContext, useEffect } from "react";
|
|
3
3
|
|
|
4
4
|
import { GridSubComponentContext } from "../../contexts/GridSubComponentContext";
|
|
5
5
|
import { TextAreaInput } from "../../lui/TextAreaInput";
|
|
@@ -19,7 +19,7 @@ export interface GridSubComponentTextAreaProps<RowType extends GridBaseRow>
|
|
|
19
19
|
|
|
20
20
|
export const GridFormSubComponentTextArea = <RowType extends GridBaseRow>(
|
|
21
21
|
props: GridSubComponentTextAreaProps<RowType>,
|
|
22
|
-
):
|
|
22
|
+
): ReactElement => {
|
|
23
23
|
const { value, data, setValue, setValid, context } = useContext(GridSubComponentContext);
|
|
24
24
|
|
|
25
25
|
const helpText = props.helpText ?? "Press tab to save";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useContext, useEffect } from "react";
|
|
1
|
+
import { ReactElement, useCallback, useContext, useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import { GridSubComponentContext } from "../../contexts/GridSubComponentContext";
|
|
4
4
|
import { TextInputFormatted } from "../../lui/TextInputFormatted";
|
|
@@ -17,7 +17,7 @@ export interface GridFormSubComponentTextInputProps<RowType extends GridBaseRow>
|
|
|
17
17
|
|
|
18
18
|
export const GridFormSubComponentTextInput = <RowType extends GridBaseRow>(
|
|
19
19
|
props: GridFormSubComponentTextInputProps<RowType>,
|
|
20
|
-
):
|
|
20
|
+
): ReactElement => {
|
|
21
21
|
const { value, setValue, setValid, data, context } = useContext(GridSubComponentContext);
|
|
22
22
|
|
|
23
23
|
const helpText = props.helpText ?? "Press enter or tab to save";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from "react";
|
|
1
|
+
import { ReactElement, useCallback, useMemo, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { useGridPopoverContext } from "../../contexts/GridPopoverContext";
|
|
4
4
|
import { TextAreaInput } from "../../lui/TextAreaInput";
|
|
@@ -16,7 +16,7 @@ export interface GridFormTextAreaProps<RowType extends GridBaseRow>
|
|
|
16
16
|
helpText?: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormTextAreaProps<RowType>):
|
|
19
|
+
export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormTextAreaProps<RowType>): ReactElement => {
|
|
20
20
|
const { field, value: initialVale, data } = useGridPopoverContext<RowType>();
|
|
21
21
|
|
|
22
22
|
const initValue = useMemo(() => (initialVale == null ? "" : `${initialVale}`), [initialVale]);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ValueFormatterParams,
|
|
6
6
|
ValueGetterParams,
|
|
7
7
|
} from "ag-grid-community/dist/lib/entities/colDef";
|
|
8
|
+
import { ReactElement } from "react";
|
|
8
9
|
|
|
9
10
|
import { GridBaseRow } from "../Grid";
|
|
10
11
|
import { ColDefT } from "../GridCell";
|
|
@@ -40,7 +41,7 @@ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<
|
|
|
40
41
|
|
|
41
42
|
export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
42
43
|
singleClickEdit?: boolean;
|
|
43
|
-
rightHoverElement?:
|
|
44
|
+
rightHoverElement?: ReactElement | undefined;
|
|
44
45
|
editAction?: (selectedRows: RowType[]) => void;
|
|
45
46
|
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
46
47
|
warning?: (props: RowICellRendererParams<RowType>) => string | string[] | boolean | null | undefined;
|