@linzjs/step-ag-grid 15.1.3 → 17.0.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/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 +6 -6
- package/dist/src/components/GridCellMultiEditor.d.ts +2 -2
- package/dist/src/components/GridIcon.d.ts +2 -2
- package/dist/src/components/GridLoadableCell.d.ts +1 -2
- package/dist/src/components/GridNoRowsOverlay.d.ts +5 -4
- 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/GridFilterDownloadCsvButton.d.ts +1 -2
- package/dist/src/components/gridFilter/GridFilterQuick.d.ts +1 -2
- package/dist/src/components/gridFilter/GridFilters.d.ts +2 -5
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -2
- package/dist/src/components/gridForm/GridFormMessage.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +4 -4
- 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/gridForm/GridFormTextInput.d.ts +1 -2
- package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +1 -2
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +1 -1
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +2 -2
- package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +1 -2
- package/dist/src/contexts/GridContext.d.ts +5 -5
- 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 +3 -3
- package/dist/src/lui/FormError.d.ts +3 -3
- package/dist/src/lui/TextAreaInput.d.ts +4 -4
- package/dist/src/lui/TextInputFormatted.d.ts +3 -3
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +3 -3
- package/dist/src/react-menu3/components/FocusableItem.d.ts +4 -4
- package/dist/src/react-menu3/components/Menu.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuButton.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuDivider.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuHeader.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuItem.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuList.d.ts +1 -2
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/SubMenu.d.ts +2 -2
- package/dist/src/react-menu3/utils/utils.d.ts +1 -1
- 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 +1007 -3909
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +1008 -3910
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +63 -59
- package/src/components/ComponentLoadingWrapper.tsx +9 -6
- package/src/components/Grid.tsx +32 -27
- package/src/components/GridCell.tsx +5 -5
- package/src/components/GridCellMultiEditor.tsx +2 -2
- package/src/components/GridIcon.tsx +2 -1
- package/src/components/GridNoRowsOverlay.tsx +10 -11
- 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 +5 -5
- package/src/contexts/GridContextProvider.tsx +57 -32
- package/src/contexts/GridPopoverContextProvider.tsx +2 -3
- package/src/contexts/GridUpdatingContextProvider.tsx +2 -6
- package/src/lui/ActionButton.tsx +4 -3
- package/src/lui/FormError.tsx +3 -1
- package/src/lui/TextAreaInput.tsx +3 -3
- package/src/lui/TextInputFormatted.tsx +5 -4
- package/src/lui/reactUtils.test.tsx +7 -6
- 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/components/ActionButton.stories.tsx +2 -1
- package/src/stories/grid/FormTest.tsx +4 -3
- package/src/stories/grid/GridFilterButtons.stories.tsx +13 -16
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +14 -11
- package/src/stories/grid/GridNonEditableRow.stories.tsx +13 -5
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +12 -4
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +12 -4
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +13 -5
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +11 -3
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +11 -3
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +11 -3
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +12 -3
- package/src/stories/grid/GridReadOnly.stories.tsx +22 -5
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +15 -12
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +20 -12
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +20 -12
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +13 -10
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +19 -16
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +21 -17
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +13 -10
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +15 -12
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +5 -2
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +5 -2
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +5 -2
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +6 -3
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +4 -1
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +4 -1
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +5 -2
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +5 -2
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +25 -12
- package/src/stories/react-menu/ReactMenu.stories.tsx +6 -4
- 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.0",
|
|
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": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"test": "jest",
|
|
57
57
|
"eject": "react-scripts eject",
|
|
58
58
|
"lint": "eslint ./src --ext .js,.ts,.tsx --fix --cache --ignore-path .gitignore",
|
|
59
|
-
"storybook": "
|
|
60
|
-
"build-storybook": "build
|
|
59
|
+
"storybook": "storybook dev -p 6006",
|
|
60
|
+
"build-storybook": "storybook build",
|
|
61
61
|
"deploy-storybook": "npx --yes -p @storybook/storybook-deployer storybook-to-ghpages",
|
|
62
62
|
"chromatic": "chromatic --exit-zero-on-changes",
|
|
63
63
|
"semantic-release": "semantic-release"
|
|
@@ -81,76 +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": "^
|
|
90
|
-
"@storybook/addon-interactions": "^
|
|
91
|
-
"@storybook/
|
|
92
|
-
"@storybook/jest": "^0.0
|
|
93
|
-
"@storybook/
|
|
94
|
-
"@storybook/
|
|
95
|
-
"@storybook/react": "^
|
|
96
|
-
"@storybook/test-runner": "^0.
|
|
97
|
-
"@storybook/testing-library": "^0.0
|
|
98
|
-
"@testing-library/dom": "^9.3.
|
|
99
|
-
"@testing-library/jest-dom": "^5.
|
|
100
|
-
"@testing-library/react": "^
|
|
90
|
+
"@storybook/addon-essentials": "^7.2.3",
|
|
91
|
+
"@storybook/addon-interactions": "^7.2.3",
|
|
92
|
+
"@storybook/addon-postcss": "^2.0.0",
|
|
93
|
+
"@storybook/jest": "^0.1.0",
|
|
94
|
+
"@storybook/preset-create-react-app": "^7.2.3",
|
|
95
|
+
"@storybook/react": "^7.2.3",
|
|
96
|
+
"@storybook/react-webpack5": "^7.2.3",
|
|
97
|
+
"@storybook/test-runner": "^0.13.0",
|
|
98
|
+
"@storybook/testing-library": "^0.2.0",
|
|
99
|
+
"@testing-library/dom": "^9.3.1",
|
|
100
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
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/lodash-es": "^4.17.
|
|
106
|
-
"@types/node": "^
|
|
107
|
-
"@types/react": "^
|
|
108
|
-
"@types/react-dom": "^
|
|
109
|
-
"@types/uuid": "^9.0.
|
|
110
|
-
"@typescript-eslint/parser": "^5.
|
|
111
|
-
"babel-jest": "^29.
|
|
105
|
+
"@types/jest": "^29.5.3",
|
|
106
|
+
"@types/lodash-es": "^4.17.8",
|
|
107
|
+
"@types/node": "^18.17.5",
|
|
108
|
+
"@types/react": "^18.2.20",
|
|
109
|
+
"@types/react-dom": "^18.2.7",
|
|
110
|
+
"@types/uuid": "^9.0.2",
|
|
111
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
112
|
+
"babel-jest": "^29.6.2",
|
|
112
113
|
"babel-preset-react-app": "^10.0.1",
|
|
113
|
-
"chromatic": "^6.
|
|
114
|
-
"conventional-changelog-conventionalcommits": "^
|
|
115
|
-
"
|
|
116
|
-
"eslint
|
|
114
|
+
"chromatic": "^6.21.0",
|
|
115
|
+
"conventional-changelog-conventionalcommits": "^6.1.0",
|
|
116
|
+
"css-loader": "^6.8.1",
|
|
117
|
+
"eslint": "^8.47.0",
|
|
118
|
+
"eslint-config-prettier": "^9.0.0",
|
|
117
119
|
"eslint-config-react-app": "^7.0.1",
|
|
118
|
-
"eslint-plugin-deprecation": "^1.
|
|
119
|
-
"eslint-plugin-import": "^2.
|
|
120
|
-
"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",
|
|
121
123
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
122
124
|
"eslint-plugin-prettier": "^4.2.1",
|
|
123
|
-
"eslint-plugin-react": "^7.
|
|
125
|
+
"eslint-plugin-react": "^7.33.1",
|
|
124
126
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
125
|
-
"eslint-plugin-
|
|
126
|
-
"
|
|
127
|
-
"jest
|
|
128
|
-
"jest-
|
|
127
|
+
"eslint-plugin-storybook": "^0.6.13",
|
|
128
|
+
"eslint-plugin-testing-library": "^6.0.0",
|
|
129
|
+
"jest": "^29.6.2",
|
|
130
|
+
"jest-canvas-mock": "^2.5.2",
|
|
131
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
129
132
|
"jest-expect-message": "^1.1.3",
|
|
130
133
|
"mkdirp": "^3.0.1",
|
|
131
134
|
"npm-run-all": "^4.1.5",
|
|
132
|
-
"postcss": "^8.4.
|
|
133
|
-
"postcss-loader": "^7.3.
|
|
135
|
+
"postcss": "^8.4.27",
|
|
136
|
+
"postcss-loader": "^7.3.3",
|
|
134
137
|
"postcss-scss": "^4.0.6",
|
|
135
138
|
"prettier": "^2.8.8",
|
|
136
139
|
"react-app-polyfill": "^3.0.0",
|
|
137
140
|
"react-scripts": "^5.0.1",
|
|
138
|
-
"rollup": "^3.
|
|
141
|
+
"rollup": "^3.28.0",
|
|
139
142
|
"rollup-plugin-copy": "^3.4.0",
|
|
140
143
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
141
144
|
"rollup-plugin-postcss": "^4.0.2",
|
|
142
|
-
"rollup-plugin-typescript2": "^0.
|
|
143
|
-
"sass": "
|
|
144
|
-
"sass-loader": "^13.3.
|
|
145
|
-
"semantic-release": "^
|
|
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",
|
|
150
|
+
"storybook-css-modules-preset": "^1.1.1",
|
|
146
151
|
"style-loader": "^3.3.3",
|
|
147
|
-
"stylelint": "^
|
|
148
|
-
"stylelint-config-
|
|
149
|
-
"stylelint-config-
|
|
150
|
-
"stylelint-
|
|
151
|
-
"stylelint-
|
|
152
|
-
"
|
|
153
|
-
"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",
|
|
154
158
|
"typescript": "^4.9.5"
|
|
155
159
|
},
|
|
156
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
|
|
|
@@ -208,7 +217,7 @@ export const Grid = ({
|
|
|
208
217
|
if (params.autoSelectFirstRow) {
|
|
209
218
|
selectRowsById([firstRowId]);
|
|
210
219
|
} else {
|
|
211
|
-
focusByRowById(firstRowId);
|
|
220
|
+
focusByRowById(firstRowId, true);
|
|
212
221
|
}
|
|
213
222
|
}
|
|
214
223
|
}, [
|
|
@@ -357,6 +366,7 @@ export const Grid = ({
|
|
|
357
366
|
const onGridReady = useCallback(
|
|
358
367
|
(event: GridReadyEvent) => {
|
|
359
368
|
setApis(event.api, event.columnApi, dataTestId);
|
|
369
|
+
event.api.showNoRowsOverlay();
|
|
360
370
|
synchroniseExternallySelectedItemsToGrid();
|
|
361
371
|
},
|
|
362
372
|
[dataTestId, setApis, synchroniseExternallySelectedItemsToGrid],
|
|
@@ -389,19 +399,8 @@ export const Grid = ({
|
|
|
389
399
|
/**
|
|
390
400
|
* Show/hide no rows overlay when model changes.
|
|
391
401
|
*/
|
|
392
|
-
const isShowingNoRowsOverlay = useRef(false);
|
|
393
402
|
const onModelUpdated = useCallback((event: ModelUpdatedEvent) => {
|
|
394
|
-
|
|
395
|
-
if (!isShowingNoRowsOverlay.current) {
|
|
396
|
-
event.api.showNoRowsOverlay();
|
|
397
|
-
isShowingNoRowsOverlay.current = true;
|
|
398
|
-
}
|
|
399
|
-
} else {
|
|
400
|
-
if (isShowingNoRowsOverlay.current) {
|
|
401
|
-
event.api.hideOverlay();
|
|
402
|
-
isShowingNoRowsOverlay.current = false;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
403
|
+
event.api.showNoRowsOverlay();
|
|
405
404
|
}, []);
|
|
406
405
|
|
|
407
406
|
/**
|
|
@@ -481,7 +480,7 @@ export const Grid = ({
|
|
|
481
480
|
* Start editing on pressing Enter
|
|
482
481
|
*/
|
|
483
482
|
const onCellKeyPress = useCallback(
|
|
484
|
-
(e:
|
|
483
|
+
(e: CellKeyDownEvent) => {
|
|
485
484
|
if ((e.event as KeyboardEvent).key === "Enter") {
|
|
486
485
|
if (!invokeEditAction(e)) startCellEditing(e);
|
|
487
486
|
}
|
|
@@ -561,7 +560,7 @@ export const Grid = ({
|
|
|
561
560
|
}, [sizeColumns, sizeColumnsToFit]);
|
|
562
561
|
|
|
563
562
|
/**
|
|
564
|
-
* Set of column
|
|
563
|
+
* Set of column I'd's that are prevented from auto-sizing as they are user set
|
|
565
564
|
*/
|
|
566
565
|
const userSizedColIds = useRef(new Set<string>());
|
|
567
566
|
|
|
@@ -593,7 +592,7 @@ export const Grid = ({
|
|
|
593
592
|
"Grid-container",
|
|
594
593
|
theme,
|
|
595
594
|
staleGrid && "Grid-sortIsStale",
|
|
596
|
-
gridReady && params.rowData && "Grid-ready",
|
|
595
|
+
gridReady && params.rowData && autoSized && "Grid-ready",
|
|
597
596
|
)}
|
|
598
597
|
>
|
|
599
598
|
{gridContextMenu.component}
|
|
@@ -612,8 +611,8 @@ export const Grid = ({
|
|
|
612
611
|
onColumnVisible={() => {
|
|
613
612
|
setInitialContentSize();
|
|
614
613
|
}}
|
|
615
|
-
|
|
616
|
-
|
|
614
|
+
onRowDataUpdated={onRowDataChanged}
|
|
615
|
+
onCellKeyDown={onCellKeyPress}
|
|
617
616
|
onCellClicked={onCellClicked}
|
|
618
617
|
onCellDoubleClicked={onCellDoubleClick}
|
|
619
618
|
onCellEditingStarted={refreshSelectedRows}
|
|
@@ -622,10 +621,16 @@ export const Grid = ({
|
|
|
622
621
|
defaultColDef={{ minWidth: 48, ...omit(params.defaultColDef, ["editable"]) }}
|
|
623
622
|
columnDefs={columnDefsAdjusted}
|
|
624
623
|
rowData={params.rowData}
|
|
625
|
-
noRowsOverlayComponent={
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
624
|
+
noRowsOverlayComponent={(event: AgGridEvent) => {
|
|
625
|
+
let rowCount = 0;
|
|
626
|
+
event.api.forEachNode(() => rowCount++);
|
|
627
|
+
return (
|
|
628
|
+
<GridNoRowsOverlay
|
|
629
|
+
rowCount={rowCount}
|
|
630
|
+
filteredRowCount={event.api.getDisplayedRowCount()}
|
|
631
|
+
noRowsOverlayText={params.noRowsOverlayText}
|
|
632
|
+
/>
|
|
633
|
+
);
|
|
629
634
|
}}
|
|
630
635
|
onModelUpdated={onModelUpdated}
|
|
631
636
|
onGridReady={onGridReady}
|
|
@@ -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,4 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
|
+
import { ReactElement } from "react";
|
|
2
3
|
|
|
3
4
|
import { LuiIcon } from "@linzjs/lui";
|
|
4
5
|
import { IconName, IconSize } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
|
|
@@ -9,7 +10,7 @@ export const GridIcon = (props: {
|
|
|
9
10
|
size?: IconSize;
|
|
10
11
|
disabled?: boolean;
|
|
11
12
|
className?: string;
|
|
12
|
-
}):
|
|
13
|
+
}): ReactElement => (
|
|
13
14
|
<LuiIcon
|
|
14
15
|
name={props.icon}
|
|
15
16
|
title={props.title}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
rowData: any[] | null | undefined;
|
|
1
|
+
export interface GridNoRowsOverlayProps {
|
|
2
|
+
rowCount: number | undefined | null;
|
|
3
|
+
filteredRowCount: number;
|
|
5
4
|
noRowsOverlayText: string | undefined;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const GridNoRowsOverlay = (params: GridNoRowsOverlayProps) => {
|
|
8
|
+
if (params.rowCount === 0) return <span>{params.noRowsOverlayText ?? "There are currently no rows"}</span>;
|
|
9
|
+
if (params.filteredRowCount === 0) return <span>All rows have been filtered</span>;
|
|
10
|
+
return <span />;
|
|
11
|
+
};
|
|
@@ -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;
|