@linzjs/step-ag-grid 20.0.0 → 21.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/src/components/ComponentLoadingWrapper.d.ts +9 -9
- package/dist/src/components/Grid.d.ts +80 -80
- package/dist/src/components/GridCell.d.ts +63 -27
- package/dist/src/components/GridCell.test.d.ts +1 -1
- package/dist/src/components/GridCellFiller.d.ts +5 -4
- package/dist/src/components/GridCellMultiEditor.d.ts +18 -18
- package/dist/src/components/GridCellMultiSelectClassRules.d.ts +2 -2
- package/dist/src/components/GridIcon.d.ts +9 -9
- package/dist/src/components/GridLoadableCell.d.ts +1 -1
- package/dist/src/components/GridNoRowsOverlay.d.ts +9 -9
- package/dist/src/components/GridPopoverHook.d.ts +12 -12
- package/dist/src/components/GridWrapper.d.ts +5 -5
- package/dist/src/components/PostSortRowsHook.d.ts +11 -11
- package/dist/src/components/gridFilter/GridFilterButtons.d.ts +16 -16
- package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +5 -5
- package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +2 -2
- package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +11 -11
- package/dist/src/components/gridFilter/GridFilterQuick.d.ts +5 -5
- package/dist/src/components/gridFilter/GridFilters.d.ts +2 -2
- package/dist/src/components/gridFilter/index.d.ts +7 -7
- package/dist/src/components/gridFilter/useGridFilter.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +37 -37
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +12 -12
- package/dist/src/components/gridForm/GridFormMessage.d.ts +7 -7
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +36 -36
- package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +24 -24
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +36 -36
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +12 -12
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +11 -11
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +14 -14
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +14 -14
- package/dist/src/components/gridForm/index.d.ts +10 -10
- package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +7 -7
- package/dist/src/components/gridHeader/index.d.ts +1 -1
- package/dist/src/components/gridHook/index.d.ts +1 -1
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +19 -19
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +16 -16
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +8 -8
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/index.d.ts +9 -9
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +16 -37
- package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +2 -2
- package/dist/src/components/gridRender/index.d.ts +2 -2
- package/dist/src/components/gridUtil.d.ts +3 -3
- package/dist/src/components/index.d.ts +18 -18
- package/dist/src/contexts/GridContext.d.ts +67 -67
- package/dist/src/contexts/GridContextProvider.d.ts +15 -15
- package/dist/src/contexts/GridContextProvider.test.d.ts +1 -1
- package/dist/src/contexts/GridPopoverContext.d.ts +15 -15
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +7 -7
- package/dist/src/contexts/GridSubComponentContext.d.ts +10 -10
- package/dist/src/contexts/GridUpdatingContext.d.ts +8 -8
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +3 -3
- package/dist/src/index.d.ts +17 -17
- package/dist/src/lui/ActionButton.d.ts +20 -20
- package/dist/src/lui/FormError.d.ts +7 -7
- package/dist/src/lui/TextAreaInput.d.ts +11 -11
- package/dist/src/lui/TextInputFormatted.d.ts +10 -10
- package/dist/src/lui/reactUtils.d.ts +6 -6
- package/dist/src/lui/reactUtils.test.d.ts +1 -1
- package/dist/src/lui/stateDeferredHook.d.ts +4 -4
- package/dist/src/lui/timeoutHook.d.ts +14 -14
- package/dist/src/lui/timeoutHook.test.d.ts +1 -1
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -8
- package/dist/src/react-menu3/components/FocusableItem.d.ts +9 -9
- package/dist/src/react-menu3/components/Menu.d.ts +16 -16
- package/dist/src/react-menu3/components/MenuButton.d.ts +8 -8
- package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -12
- package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -4
- package/dist/src/react-menu3/components/MenuItem.d.ts +59 -59
- package/dist/src/react-menu3/components/MenuList.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +25 -25
- package/dist/src/react-menu3/components/SubMenu.d.ts +110 -110
- package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -7
- package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -2
- package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -5
- package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -9
- package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -11
- package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -7
- package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -20
- package/dist/src/react-menu3/hooks/index.d.ts +9 -9
- package/dist/src/react-menu3/hooks/useBEM.d.ts +10 -10
- package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +3 -3
- package/dist/src/react-menu3/hooks/useItemEffect.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useItemState.d.ts +7 -7
- package/dist/src/react-menu3/hooks/useItems.d.ts +7 -7
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +23 -14
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -2
- package/dist/src/react-menu3/index.d.ts +11 -11
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +11 -11
- package/dist/src/react-menu3/positionUtils/index.d.ts +3 -3
- package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +8 -8
- package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +8 -8
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +19 -19
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +19 -19
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +13 -13
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +26 -26
- package/dist/src/react-menu3/style-utils/index.d.ts +11 -11
- package/dist/src/react-menu3/types.d.ts +401 -401
- package/dist/src/react-menu3/utils/constants.d.ts +54 -54
- package/dist/src/react-menu3/utils/index.d.ts +3 -3
- package/dist/src/react-menu3/utils/propTypes2.d.ts +56 -56
- package/dist/src/react-menu3/utils/utils.d.ts +37 -37
- package/dist/src/react-menu3/utils/withHovering.d.ts +7 -7
- package/dist/src/utils/bearing.d.ts +19 -19
- package/dist/src/utils/bearing.test.d.ts +1 -1
- package/dist/src/utils/deferredPromise.d.ts +5 -5
- package/dist/src/utils/storybookTestUtil.d.ts +3 -3
- package/dist/src/utils/testQuick.d.ts +62 -62
- package/dist/src/utils/testUtil.d.ts +46 -45
- package/dist/src/utils/textMatcher.d.ts +13 -13
- package/dist/src/utils/textMatcher.test.d.ts +1 -1
- package/dist/src/utils/textValidator.d.ts +18 -18
- package/dist/src/utils/textValidator.test.d.ts +1 -1
- package/dist/src/utils/util.d.ts +8 -8
- package/dist/src/utils/util.test.d.ts +1 -1
- package/dist/step-ag-grid.cjs.js +4652 -4651
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +4652 -4651
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/dist/vite.config.d.ts +2 -0
- package/package.json +21 -20
- package/src/components/Grid.tsx +4 -4
- package/src/components/GridCell.test.tsx +2 -3
- package/src/components/GridCell.tsx +75 -23
- package/src/components/GridCellFiller.tsx +2 -1
- package/src/components/GridCellMultiEditor.tsx +9 -9
- package/src/components/GridCellMultiSelectClassRules.tsx +4 -4
- package/src/components/GridPopoverHook.tsx +4 -4
- package/src/components/PostSortRowsHook.ts +2 -2
- package/src/components/gridFilter/GridFilterButtons.tsx +6 -6
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +2 -5
- package/src/components/gridFilter/GridFilterDownloadCsvButton.tsx +1 -1
- package/src/components/gridFilter/useGridFilter.ts +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +9 -9
- package/src/components/gridForm/GridFormEditBearing.tsx +5 -5
- package/src/components/gridForm/GridFormMessage.tsx +4 -4
- package/src/components/gridForm/GridFormMultiSelect.tsx +9 -9
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +11 -11
- package/src/components/gridForm/GridFormPopoverMenu.tsx +13 -13
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +4 -4
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +4 -4
- package/src/components/gridForm/GridFormTextArea.tsx +6 -6
- package/src/components/gridForm/GridFormTextInput.tsx +7 -7
- package/src/components/gridHook/useGridContextMenu.tsx +8 -8
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +6 -6
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +6 -6
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +16 -16
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +6 -6
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +5 -5
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +5 -5
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +5 -4
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +5 -5
- package/src/components/gridRender/GridRenderGenericCell.tsx +6 -36
- package/src/contexts/GridContext.tsx +7 -7
- package/src/contexts/GridContextProvider.test.tsx +1 -1
- package/src/contexts/GridContextProvider.tsx +10 -10
- package/src/contexts/GridPopoverContext.tsx +6 -6
- package/src/stories/grid/GridDragRow.stories.tsx +4 -4
- package/src/stories/grid/GridNonEditableRow.stories.tsx +2 -3
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +2 -2
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +1 -1
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +2 -2
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +3 -3
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +2 -2
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +2 -2
- package/src/stories/grid/GridReadOnly.stories.tsx +6 -6
- package/src/stories/grid/GridViewList.stories.tsx +5 -7
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +3 -3
- package/src/utils/testUtil.ts +49 -7
- package/src/utils/textValidator.ts +5 -5
- package/src/utils/util.ts +1 -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": "21.0.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"aggrid",
|
|
8
8
|
"ag-grid",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@linzjs/lui": ">=21",
|
|
31
|
-
"ag-grid-community": "^
|
|
32
|
-
"ag-grid-react": "^
|
|
31
|
+
"ag-grid-community": "^31",
|
|
32
|
+
"ag-grid-react": "^31",
|
|
33
33
|
"lodash-es": ">=4",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-dom": ">=18"
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"stylelint": "stylelint src/**/*.scss src/**/*.css --fix",
|
|
52
52
|
"css": "sass ./src/styles/index.scss:dist/index.css --no-source-map",
|
|
53
53
|
"test": "jest",
|
|
54
|
-
"eject": "react-scripts eject",
|
|
55
54
|
"lint": "eslint ./src --ext .js,.ts,.tsx --fix --cache --ignore-path .gitignore",
|
|
56
55
|
"storybook": "storybook dev -p 6006",
|
|
57
56
|
"build-storybook": "storybook build",
|
|
@@ -80,18 +79,19 @@
|
|
|
80
79
|
"devDependencies": {
|
|
81
80
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
82
81
|
"@chromatic-com/storybook": "^1.3.5",
|
|
82
|
+
"@linzjs/lui": ">=21",
|
|
83
83
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
84
84
|
"@rollup/plugin-json": "^6.1.0",
|
|
85
85
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
86
86
|
"@semantic-release/changelog": "^6.0.3",
|
|
87
87
|
"@semantic-release/git": "^10.0.1",
|
|
88
|
-
"@storybook/addon-essentials": "^8.1.
|
|
89
|
-
"@storybook/addon-interactions": "^8.1.
|
|
90
|
-
"@storybook/
|
|
91
|
-
"@storybook/react": "^8.1.
|
|
92
|
-
"@storybook/react-
|
|
93
|
-
"@storybook/test": "^8.1.
|
|
94
|
-
"@storybook/test-runner": "^0.18.
|
|
88
|
+
"@storybook/addon-essentials": "^8.1.1",
|
|
89
|
+
"@storybook/addon-interactions": "^8.1.1",
|
|
90
|
+
"@storybook/addon-links": "^8.1.1",
|
|
91
|
+
"@storybook/react": "^8.1.1",
|
|
92
|
+
"@storybook/react-vite": "^8.1.1",
|
|
93
|
+
"@storybook/test": "^8.1.1",
|
|
94
|
+
"@storybook/test-runner": "^0.18.1",
|
|
95
95
|
"@testing-library/dom": "^10.1.0",
|
|
96
96
|
"@testing-library/jest-dom": "^6.4.5",
|
|
97
97
|
"@testing-library/react": "^15.0.7",
|
|
@@ -106,6 +106,9 @@
|
|
|
106
106
|
"@types/uuid": "^9.0.8",
|
|
107
107
|
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
|
108
108
|
"@typescript-eslint/parser": "^7.9.0",
|
|
109
|
+
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
110
|
+
"ag-grid-community": "^31",
|
|
111
|
+
"ag-grid-react": "^31",
|
|
109
112
|
"babel-jest": "^29.7.0",
|
|
110
113
|
"babel-preset-react-app": "^10.0.1",
|
|
111
114
|
"chromatic": "^11.3.2",
|
|
@@ -133,8 +136,9 @@
|
|
|
133
136
|
"postcss-loader": "^7.3.4",
|
|
134
137
|
"postcss-scss": "^4.0.9",
|
|
135
138
|
"prettier": "^3.2.5",
|
|
139
|
+
"react": ">=18",
|
|
136
140
|
"react-app-polyfill": "^3.0.0",
|
|
137
|
-
"react-
|
|
141
|
+
"react-dom": ">=18",
|
|
138
142
|
"rollup": "^4.17.2",
|
|
139
143
|
"rollup-plugin-copy": "^3.5.0",
|
|
140
144
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
@@ -143,7 +147,7 @@
|
|
|
143
147
|
"sass": "1.77.1",
|
|
144
148
|
"sass-loader": "^14.2.1",
|
|
145
149
|
"semantic-release": "^22.0.12",
|
|
146
|
-
"storybook": "^8.1.
|
|
150
|
+
"storybook": "^8.1.1",
|
|
147
151
|
"storybook-css-modules-preset": "^1.1.1",
|
|
148
152
|
"style-loader": "^4.0.0",
|
|
149
153
|
"stylelint": "15.11.0",
|
|
@@ -151,13 +155,10 @@
|
|
|
151
155
|
"stylelint-config-standard": "^34.0.0",
|
|
152
156
|
"stylelint-prettier": "^4.1.0",
|
|
153
157
|
"stylelint-scss": "^5.3.2",
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
"ag-grid-react": "^30",
|
|
159
|
-
"react": ">=18",
|
|
160
|
-
"react-dom": ">=18"
|
|
158
|
+
"typescript": "^5.4.5",
|
|
159
|
+
"vite": "^5.2.11",
|
|
160
|
+
"vite-plugin-html": "^3.2.2",
|
|
161
|
+
"vite-tsconfig-paths": "^4.3.2"
|
|
161
162
|
},
|
|
162
163
|
"babel": {
|
|
163
164
|
"presets": [
|
package/src/components/Grid.tsx
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
RowHighlightPosition,
|
|
9
9
|
RowNode,
|
|
10
10
|
} from "ag-grid-community";
|
|
11
|
-
import { CellClassParams, EditableCallback, EditableCallbackParams } from "ag-grid-community
|
|
12
|
-
import { GridOptions } from "ag-grid-community
|
|
11
|
+
import { CellClassParams, EditableCallback, EditableCallbackParams } from "ag-grid-community";
|
|
12
|
+
import { GridOptions } from "ag-grid-community";
|
|
13
13
|
import {
|
|
14
14
|
AgGridEvent,
|
|
15
15
|
CellEvent,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
RowDragEndEvent,
|
|
19
19
|
RowDragMoveEvent,
|
|
20
20
|
SelectionChangedEvent,
|
|
21
|
-
} from "ag-grid-community
|
|
21
|
+
} from "ag-grid-community";
|
|
22
22
|
import { AgGridReact } from "ag-grid-react";
|
|
23
23
|
import clsx from "clsx";
|
|
24
24
|
import { defer, difference, isEmpty, last, omit, xorBy } from "lodash-es";
|
|
@@ -687,7 +687,7 @@ export const Grid = ({
|
|
|
687
687
|
<div style={{ flex: 1 }} ref={gridDivRef}>
|
|
688
688
|
<AgGridReact
|
|
689
689
|
rowHeight={rowHeight}
|
|
690
|
-
animateRows={params.animateRows}
|
|
690
|
+
animateRows={params.animateRows ?? false}
|
|
691
691
|
rowClassRules={params.rowClassRules}
|
|
692
692
|
getRowId={(params) => `${params.data.id}`}
|
|
693
693
|
suppressRowClickSelection={true}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GridBaseRow } from "./Grid";
|
|
2
|
-
import { generateFilterGetter } from "./GridCell";
|
|
3
|
-
import { RowValueGetterParams } from "./gridRender/GridRenderGenericCell";
|
|
2
|
+
import { generateFilterGetter, SAValueGetterParams } from "./GridCell";
|
|
4
3
|
|
|
5
4
|
describe("GridCell", () => {
|
|
6
5
|
test("generateFilterGetter returns passed filterValueGetter", () => {
|
|
@@ -25,7 +24,7 @@ describe("GridCell", () => {
|
|
|
25
24
|
const filterGetter = generateFilterGetter(field, undefined, valueFormatter);
|
|
26
25
|
expect(typeof filterGetter).toBe("function");
|
|
27
26
|
if (typeof filterGetter !== "function") return;
|
|
28
|
-
expect(filterGetter({ getValue: () => test.value } as any as
|
|
27
|
+
expect(filterGetter({ getValue: () => test.value } as any as SAValueGetterParams<GridBaseRow>)).toBe(
|
|
29
28
|
test.expected,
|
|
30
29
|
);
|
|
31
30
|
});
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { ColDef, ICellEditorParams, ICellRendererParams } from "ag-grid-community";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
SuppressKeyboardEventParams,
|
|
4
|
+
ValueFormatterFunc,
|
|
5
|
+
ValueFormatterParams,
|
|
6
|
+
ValueGetterFunc,
|
|
7
|
+
ValueGetterParams,
|
|
8
|
+
EditableCallbackParams,
|
|
9
|
+
} from "ag-grid-community";
|
|
10
|
+
import { forwardRef, ReactElement, useContext } from "react";
|
|
4
11
|
|
|
5
12
|
import { GridPopoverContextProvider } from "../contexts/GridPopoverContextProvider";
|
|
6
13
|
import { GridUpdatingContext } from "../contexts/GridUpdatingContext";
|
|
@@ -9,12 +16,7 @@ import { GridBaseRow } from "./Grid";
|
|
|
9
16
|
import { GridCellMultiSelectClassRules } from "./GridCellMultiSelectClassRules";
|
|
10
17
|
import { GridIcon } from "./GridIcon";
|
|
11
18
|
import { GridLoadableCell } from "./GridLoadableCell";
|
|
12
|
-
import {
|
|
13
|
-
GenericCellColDef,
|
|
14
|
-
GenericCellRendererParams,
|
|
15
|
-
RowValueFormatterParams,
|
|
16
|
-
RowValueGetterParams,
|
|
17
|
-
} from "./gridRender";
|
|
19
|
+
import { GenericCellColDef, GenericCellRendererParams } from "./gridRender";
|
|
18
20
|
|
|
19
21
|
export interface GenericCellEditorProps<E> {
|
|
20
22
|
multiEdit?: boolean;
|
|
@@ -22,15 +24,20 @@ export interface GenericCellEditorProps<E> {
|
|
|
22
24
|
editorParams?: E;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
export interface SAICellRendererParams<TData = any, TValue = any, TContext = any>
|
|
28
|
+
extends Omit<ICellRendererParams<TData, TValue, TContext>, "data"> {
|
|
29
|
+
data: TData;
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
export const GridCellRenderer = (props: ICellRendererParams) => {
|
|
26
33
|
const { checkUpdating } = useContext(GridUpdatingContext);
|
|
27
34
|
const colDef = props.colDef as ColDef;
|
|
28
35
|
|
|
29
36
|
const rendererParams = colDef.cellRendererParams as GenericCellRendererParams<any> | undefined;
|
|
30
37
|
const warningFn = rendererParams?.warning;
|
|
31
|
-
let warningText = warningFn ? warningFn(props) : undefined;
|
|
38
|
+
let warningText = props.data !== undefined && warningFn ? warningFn(props) : undefined;
|
|
32
39
|
const infoFn = rendererParams?.info;
|
|
33
|
-
let infoText = infoFn ? infoFn(props) : undefined;
|
|
40
|
+
let infoText = props.data !== undefined && infoFn ? infoFn(props) : undefined;
|
|
34
41
|
if (Array.isArray(warningText)) warningText = warningText.join("\n");
|
|
35
42
|
if (Array.isArray(infoText)) infoText = infoText.join("\n");
|
|
36
43
|
|
|
@@ -56,9 +63,51 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
|
|
|
56
63
|
);
|
|
57
64
|
};
|
|
58
65
|
|
|
66
|
+
export interface SAValueGetterParams<TData = any, TValue = any> extends Omit<ValueGetterParams<TData, TValue>, "data"> {
|
|
67
|
+
data: TData;
|
|
68
|
+
getValue: (field: string) => any;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface SAValueGetterFunc<TData = any, TValue = any> {
|
|
72
|
+
(params: SAValueGetterParams<TData, TValue>): TValue | null | undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface SAEditableCallbackParams<TData = any, TValue = any>
|
|
76
|
+
extends Omit<EditableCallbackParams<TData, TValue>, "data"> {
|
|
77
|
+
data: TData;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface SAEditableCallback<TData = any, TValue = any> {
|
|
81
|
+
(params: SAEditableCallbackParams<TData, TValue>): boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SAValueFormatterParams<TData = any, TValue = any>
|
|
85
|
+
extends Omit<ValueFormatterParams<TData, TValue>, "data" | "value"> {
|
|
86
|
+
data: TData;
|
|
87
|
+
value: TValue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface SAValueFormatterFunc<TData = any, TValue = any> {
|
|
91
|
+
(params: SAValueFormatterParams<TData, TValue>): string;
|
|
92
|
+
}
|
|
93
|
+
|
|
59
94
|
// This is so that typescript retains the row type to pass to the GridCells
|
|
60
|
-
|
|
61
|
-
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends ColDef<TData, ValueType> {
|
|
97
|
+
_?: TData;
|
|
98
|
+
editable?: boolean | SAEditableCallback<TData, ValueType>;
|
|
99
|
+
valueGetter?: string | SAValueGetterFunc<TData, ValueType>;
|
|
100
|
+
valueFormatter?: string | SAValueFormatterFunc<TData, ValueType>;
|
|
101
|
+
cellRenderer?: (props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
102
|
+
cellRendererParams?: {
|
|
103
|
+
singleClickEdit?: boolean;
|
|
104
|
+
rightHoverElement?: ReactElement;
|
|
105
|
+
originalCellRenderer?: any;
|
|
106
|
+
editAction?: (selectedRows: TData[]) => void;
|
|
107
|
+
shortcutKeys?: Record<string, () => void>;
|
|
108
|
+
warning?: (props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
109
|
+
info?: (props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
|
|
110
|
+
};
|
|
62
111
|
editor?: (editorProps: any) => ReactElement;
|
|
63
112
|
}
|
|
64
113
|
|
|
@@ -76,16 +125,16 @@ export const suppressCellKeyboardEvents = (e: SuppressKeyboardEventParams) => {
|
|
|
76
125
|
);
|
|
77
126
|
};
|
|
78
127
|
|
|
79
|
-
export const generateFilterGetter = <
|
|
128
|
+
export const generateFilterGetter = <TData extends GridBaseRow, ValueType>(
|
|
80
129
|
field: string | undefined,
|
|
81
|
-
filterValueGetter: string |
|
|
82
|
-
valueFormatter: string |
|
|
83
|
-
) => {
|
|
130
|
+
filterValueGetter: string | ValueGetterFunc<TData, ValueType> | undefined,
|
|
131
|
+
valueFormatter: string | ValueFormatterFunc<TData, ValueType> | undefined,
|
|
132
|
+
): string | SAValueGetterFunc<TData, ValueType> | undefined => {
|
|
84
133
|
if (filterValueGetter) return filterValueGetter;
|
|
85
134
|
// aggrid will default to valueGetter
|
|
86
135
|
if (typeof valueFormatter !== "function" || !field) return undefined;
|
|
87
136
|
|
|
88
|
-
return (params:
|
|
137
|
+
return (params: ValueGetterParams<TData, ValueType>): any => {
|
|
89
138
|
const value = params.getValue(field);
|
|
90
139
|
let formattedValue = valueFormatter({ ...params, value });
|
|
91
140
|
// Search for null values using standard dash
|
|
@@ -93,7 +142,7 @@ export const generateFilterGetter = <RowType extends GridBaseRow>(
|
|
|
93
142
|
// Search by raw value as well as formatted
|
|
94
143
|
const gotValue = ["string", "number"].includes(typeof value) ? value : undefined;
|
|
95
144
|
return (formattedValue + (gotValue != null && formattedValue != gotValue ? " " + gotValue : "")) //
|
|
96
|
-
.
|
|
145
|
+
.replace(/\s+/g, " ")
|
|
97
146
|
.trim();
|
|
98
147
|
};
|
|
99
148
|
};
|
|
@@ -101,20 +150,22 @@ export const generateFilterGetter = <RowType extends GridBaseRow>(
|
|
|
101
150
|
/*
|
|
102
151
|
* All cells should use this.
|
|
103
152
|
*/
|
|
104
|
-
export const GridCell = <
|
|
105
|
-
props: GenericCellColDef<
|
|
153
|
+
export const GridCell = <TData extends GridBaseRow, TValue = any, Props extends CellEditorCommon = any>(
|
|
154
|
+
props: GenericCellColDef<TData, TValue>,
|
|
106
155
|
custom?: {
|
|
107
156
|
multiEdit?: boolean;
|
|
108
157
|
preventAutoEdit?: boolean;
|
|
109
158
|
editor?: (editorProps: Props) => ReactElement;
|
|
110
159
|
editorParams?: Props;
|
|
111
160
|
},
|
|
112
|
-
): ColDefT<
|
|
161
|
+
): ColDefT<TData, TValue> => {
|
|
162
|
+
// props.field = ;
|
|
113
163
|
// Generate a default filter value getter which uses the formatted value plus
|
|
114
164
|
// the editable value if it's a string and different from the formatted value.
|
|
115
165
|
// This is so that e.g. bearings can be searched for by DMS or raw number.
|
|
116
166
|
const valueFormatter = props.valueFormatter;
|
|
117
|
-
|
|
167
|
+
// FIXME
|
|
168
|
+
const filterValueGetter = generateFilterGetter(props.field, props.filterValueGetter as any, valueFormatter as any);
|
|
118
169
|
const exportable = props.exportable;
|
|
119
170
|
// Can't leave this here ag-grid will complain
|
|
120
171
|
delete props.exportable;
|
|
@@ -139,7 +190,8 @@ export const GridCell = <RowType extends GridBaseRow, Props extends CellEditorCo
|
|
|
139
190
|
},
|
|
140
191
|
}),
|
|
141
192
|
// If there's a valueFormatter and no filterValueGetter then create a filterValueGetter
|
|
142
|
-
|
|
193
|
+
// FIXME
|
|
194
|
+
filterValueGetter: filterValueGetter as any,
|
|
143
195
|
// Default value formatter, otherwise react freaks out on objects
|
|
144
196
|
valueFormatter: (params: ValueFormatterParams) => {
|
|
145
197
|
if (params.value == null) return "–";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ColDef } from "ag-grid-community";
|
|
2
|
+
import { GridBaseRow } from "./Grid";
|
|
2
3
|
|
|
3
4
|
export const GridCellFillerColId = "gridCellFiller";
|
|
4
5
|
|
|
5
6
|
export const isGridCellFiller = (col: ColDef) => col.colId === GridCellFillerColId;
|
|
6
7
|
|
|
7
|
-
export const GridCellFiller = (): ColDef => ({
|
|
8
|
+
export const GridCellFiller = <TData extends GridBaseRow>(): ColDef<TData, any> => ({
|
|
8
9
|
colId: GridCellFillerColId,
|
|
9
10
|
headerName: "",
|
|
10
11
|
flex: 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CellEditorSelectorResult } from "ag-grid-community
|
|
2
|
-
import { ICellEditorParams } from "ag-grid-community
|
|
1
|
+
import { CellEditorSelectorResult } from "ag-grid-community";
|
|
2
|
+
import { ICellEditorParams } from "ag-grid-community";
|
|
3
3
|
import { ComponentProps, ReactElement } from "react";
|
|
4
4
|
|
|
5
5
|
import { GridBaseRow } from "./Grid";
|
|
@@ -16,18 +16,18 @@ export const Editor = <FN extends (param: any) => ReactElement>(props: {
|
|
|
16
16
|
params: { ...props.editorParams, multiEdit: props.multiEdit },
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
export interface RowCellEditorParams<
|
|
20
|
-
data:
|
|
19
|
+
export interface RowCellEditorParams<TData extends GridBaseRow> extends ICellEditorParams {
|
|
20
|
+
data: TData;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Used to choose between cell editors based in data.
|
|
25
25
|
*/
|
|
26
|
-
export const GridCellMultiEditor = <
|
|
27
|
-
props: GenericCellColDef<
|
|
28
|
-
cellEditorSelector: (params: RowCellEditorParams<
|
|
29
|
-
): ColDefT<
|
|
30
|
-
GridCell({
|
|
26
|
+
export const GridCellMultiEditor = <TData extends GridBaseRow, TValue = any>(
|
|
27
|
+
props: GenericCellColDef<TData, TValue>,
|
|
28
|
+
cellEditorSelector: (params: RowCellEditorParams<TData>) => CellEditorSelectorResult,
|
|
29
|
+
): ColDefT<TData, TValue> =>
|
|
30
|
+
GridCell<TData, TValue>({
|
|
31
31
|
cellClassRules: GridCellMultiSelectClassRules,
|
|
32
32
|
cellEditorSelector,
|
|
33
33
|
editable: props.editable ?? true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CellClassParams, CellClassRules } from "ag-grid-community
|
|
2
|
-
import { ICellEditorParams } from "ag-grid-community
|
|
1
|
+
import { CellClassParams, CellClassRules } from "ag-grid-community";
|
|
2
|
+
import { ICellEditorParams } from "ag-grid-community";
|
|
3
3
|
|
|
4
4
|
export const GridCellMultiSelectClassRules: CellClassRules = {
|
|
5
5
|
"ag-selected-for-edit": (params: CellClassParams) => {
|
|
@@ -12,8 +12,8 @@ export const GridCellMultiSelectClassRules: CellClassRules = {
|
|
|
12
12
|
cep?.multiEdit &&
|
|
13
13
|
api
|
|
14
14
|
.getSelectedNodes()
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
?.map((row) => row.id)
|
|
16
|
+
?.includes(node.id) &&
|
|
17
17
|
api.getEditingCells().some((cell) => cell.column.getColDef() === colDef)
|
|
18
18
|
);
|
|
19
19
|
},
|
|
@@ -7,7 +7,7 @@ import { MenuCloseEvent } from "../react-menu3/types";
|
|
|
7
7
|
import { CloseReason } from "../react-menu3/utils";
|
|
8
8
|
import { GridBaseRow } from "./Grid";
|
|
9
9
|
|
|
10
|
-
export interface GridPopoverHookProps<
|
|
10
|
+
export interface GridPopoverHookProps<TData> {
|
|
11
11
|
className: string | undefined;
|
|
12
12
|
invalid?: () =>
|
|
13
13
|
| Promise<ReactElement | boolean | string | null | undefined>
|
|
@@ -16,13 +16,13 @@ export interface GridPopoverHookProps<RowType> {
|
|
|
16
16
|
| string
|
|
17
17
|
| null
|
|
18
18
|
| undefined;
|
|
19
|
-
save?: (selectedRows:
|
|
19
|
+
save?: (selectedRows: TData[]) => Promise<boolean>;
|
|
20
20
|
dontSaveOnExternalClick?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const useGridPopoverHook = <
|
|
23
|
+
export const useGridPopoverHook = <TData extends GridBaseRow>(props: GridPopoverHookProps<TData>) => {
|
|
24
24
|
const { stopEditing, cancelEdit } = useContext(GridContext);
|
|
25
|
-
const { anchorRef, saving, updateValue } = useGridPopoverContext<
|
|
25
|
+
const { anchorRef, saving, updateValue } = useGridPopoverContext<TData>();
|
|
26
26
|
const saveButtonRef = useRef<HTMLButtonElement>(null);
|
|
27
27
|
const [isOpen, setOpen] = useState(false);
|
|
28
28
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IRowNode } from "ag-grid-community";
|
|
2
|
-
import { ColumnState } from "ag-grid-community
|
|
3
|
-
import { PostSortRowsParams } from "ag-grid-community
|
|
2
|
+
import { ColumnState } from "ag-grid-community";
|
|
3
|
+
import { PostSortRowsParams } from "ag-grid-community";
|
|
4
4
|
import { isEmpty } from "lodash-es";
|
|
5
5
|
import { useCallback, useContext, useRef } from "react";
|
|
6
6
|
|
|
@@ -8,23 +8,23 @@ import { GridFilterExternal } from "../../contexts/GridContext";
|
|
|
8
8
|
import { GridBaseRow } from "../Grid";
|
|
9
9
|
import { useGridFilter } from "./useGridFilter";
|
|
10
10
|
|
|
11
|
-
export interface GridFilterButtonsOption<
|
|
11
|
+
export interface GridFilterButtonsOption<TData extends GridBaseRow> {
|
|
12
12
|
defaultSelected?: boolean;
|
|
13
|
-
filter?: GridFilterExternal<
|
|
13
|
+
filter?: GridFilterExternal<TData>;
|
|
14
14
|
label: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export type GridFilterButtonsProps<
|
|
17
|
+
export type GridFilterButtonsProps<TData extends GridBaseRow> = {
|
|
18
18
|
className?: ClassValue;
|
|
19
19
|
luiButtonProps?: Partial<LuiButtonProps>;
|
|
20
|
-
options: GridFilterButtonsOption<
|
|
20
|
+
options: GridFilterButtonsOption<TData>[];
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export const GridFilterButtons = <
|
|
23
|
+
export const GridFilterButtons = <TData extends GridBaseRow>({
|
|
24
24
|
className,
|
|
25
25
|
luiButtonProps,
|
|
26
26
|
options,
|
|
27
|
-
}: GridFilterButtonsProps<
|
|
27
|
+
}: GridFilterButtonsProps<TData>): 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
|
|
|
@@ -6,9 +6,8 @@ import { LuiCheckboxInput, LuiIcon } from "@linzjs/lui";
|
|
|
6
6
|
import { GridContext } from "../../contexts/GridContext";
|
|
7
7
|
import { Menu, MenuDivider, MenuItem } from "../../react-menu3";
|
|
8
8
|
import { ClickEvent } from "../../react-menu3/types";
|
|
9
|
-
import { GridBaseRow } from "../Grid";
|
|
10
|
-
import { ColDefT } from "../GridCell";
|
|
11
9
|
import { GridFilterHeaderIconButton } from "./GridFilterHeaderIconButton";
|
|
10
|
+
import { ColDef } from "ag-grid-community";
|
|
12
11
|
|
|
13
12
|
export interface GridFilterColumnsToggleProps {
|
|
14
13
|
saveState?: boolean;
|
|
@@ -78,9 +77,7 @@ export const GridFilterColumnsToggle = ({ saveState = true }: GridFilterColumnsT
|
|
|
78
77
|
);
|
|
79
78
|
|
|
80
79
|
const numericRegExp = /^\d+$/;
|
|
81
|
-
const isNonManageableColumn = (col:
|
|
82
|
-
return col.lockVisible || col.colId == null || numericRegExp.test(col.colId);
|
|
83
|
-
};
|
|
80
|
+
const isNonManageableColumn = (col: ColDef) => col.lockVisible || col.colId == null || numericRegExp.test(col.colId);
|
|
84
81
|
|
|
85
82
|
return (
|
|
86
83
|
<Menu
|
|
@@ -3,7 +3,7 @@ import { useContext, useEffect } from "react";
|
|
|
3
3
|
import { GridContext, GridFilterExternal } from "../../contexts/GridContext";
|
|
4
4
|
import { GridBaseRow } from "../Grid";
|
|
5
5
|
|
|
6
|
-
export const useGridFilter = <
|
|
6
|
+
export const useGridFilter = <TData extends GridBaseRow>(filter: GridFilterExternal<TData> | undefined) => {
|
|
7
7
|
const { addExternalFilter, removeExternalFilter } = useContext(GridContext);
|
|
8
8
|
|
|
9
9
|
useEffect(() => {
|
|
@@ -14,9 +14,9 @@ import { GridBaseRow } from "../Grid";
|
|
|
14
14
|
import { CellEditorCommon } from "../GridCell";
|
|
15
15
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
16
16
|
|
|
17
|
-
export interface GridPopoutEditDropDownSelectedItem<
|
|
17
|
+
export interface GridPopoutEditDropDownSelectedItem<TData> {
|
|
18
18
|
// Note the row that was clicked on will be first
|
|
19
|
-
selectedRows:
|
|
19
|
+
selectedRows: TData[];
|
|
20
20
|
value: any;
|
|
21
21
|
subComponentValue?: any;
|
|
22
22
|
}
|
|
@@ -38,7 +38,7 @@ export const MenuHeaderItem = (title: string) => {
|
|
|
38
38
|
|
|
39
39
|
export type SelectOption = null | string | FinalSelectOption;
|
|
40
40
|
|
|
41
|
-
export interface GridFormDropDownProps<
|
|
41
|
+
export interface GridFormDropDownProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
42
42
|
// This overrides CellEditorCommon to provide some common class options
|
|
43
43
|
className?:
|
|
44
44
|
| "GridPopoverEditDropDown-containerSmall"
|
|
@@ -53,11 +53,11 @@ export interface GridFormDropDownProps<RowType extends GridBaseRow> extends Cell
|
|
|
53
53
|
filterPlaceholder?: string;
|
|
54
54
|
filterHelpText?: string;
|
|
55
55
|
noOptionsMessage?: string;
|
|
56
|
-
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<
|
|
57
|
-
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<
|
|
56
|
+
onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem<TData>) => Promise<void>;
|
|
57
|
+
onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem<TData>) => Promise<void>;
|
|
58
58
|
options:
|
|
59
59
|
| SelectOption[]
|
|
60
|
-
| ((selectedRows:
|
|
60
|
+
| ((selectedRows: TData[], filter?: string) => Promise<SelectOption[] | undefined> | SelectOption[] | undefined)
|
|
61
61
|
| undefined;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -65,8 +65,8 @@ const fieldToString = (field: any) => {
|
|
|
65
65
|
return typeof field == "symbol" ? field.toString() : `${field}`;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
export const GridFormDropDown = <
|
|
69
|
-
const { selectedRows, field, data } = useGridPopoverContext<
|
|
68
|
+
export const GridFormDropDown = <TData extends GridBaseRow>(props: GridFormDropDownProps<TData>) => {
|
|
69
|
+
const { selectedRows, field, data } = useGridPopoverContext<TData>();
|
|
70
70
|
|
|
71
71
|
// Save triggers during async action processing which triggers another selectItem(), this ref blocks that
|
|
72
72
|
const [filter, setFilter] = useState(props.filterDefaultValue ?? "");
|
|
@@ -81,7 +81,7 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormDro
|
|
|
81
81
|
const selectItemHandler = useCallback(
|
|
82
82
|
async (value: any, subComponentValue?: any): Promise<boolean> => {
|
|
83
83
|
const hasChanged =
|
|
84
|
-
selectedRows.some((row) => row[field as keyof
|
|
84
|
+
selectedRows.some((row) => row[field as keyof TData] !== value) ||
|
|
85
85
|
(subComponentValue !== undefined && subComponentInitialValue.current !== JSON.stringify(subComponentValue));
|
|
86
86
|
if (hasChanged) {
|
|
87
87
|
if (props.onSelectedItem) {
|
|
@@ -7,15 +7,15 @@ import { GridBaseRow } from "../Grid";
|
|
|
7
7
|
import { CellEditorCommon } from "../GridCell";
|
|
8
8
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
9
9
|
|
|
10
|
-
export interface GridFormEditBearingProps<
|
|
10
|
+
export interface GridFormEditBearingProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
11
11
|
formatValue?: (value: any) => string;
|
|
12
12
|
placeHolder?: string;
|
|
13
13
|
range?: (value: number | null) => string | null;
|
|
14
|
-
onSave?: (props: { selectedRows:
|
|
14
|
+
onSave?: (props: { selectedRows: TData[]; value: number | null }) => Promise<boolean>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const GridFormEditBearing = <
|
|
18
|
-
const { field, value: initialValue } = useGridPopoverContext<
|
|
17
|
+
export const GridFormEditBearing = <TData extends GridBaseRow>(props: GridFormEditBearingProps<TData>) => {
|
|
18
|
+
const { field, value: initialValue } = useGridPopoverContext<TData>();
|
|
19
19
|
|
|
20
20
|
// This clears out any scientific precision
|
|
21
21
|
const defaultValue = useMemo(
|
|
@@ -28,7 +28,7 @@ export const GridFormEditBearing = <RowType extends GridBaseRow>(props: GridForm
|
|
|
28
28
|
const invalid = useCallback(() => bearingStringValidator(value, props.range), [props.range, value]);
|
|
29
29
|
|
|
30
30
|
const save = useCallback(
|
|
31
|
-
async (selectedRows:
|
|
31
|
+
async (selectedRows: TData[]): Promise<boolean> => {
|
|
32
32
|
const parsedValue = bearingNumberParser(value);
|
|
33
33
|
// Value didn't change so don't save just cancel
|
|
34
34
|
if (parsedValue === bearingNumberParser(defaultValue)) {
|
|
@@ -7,12 +7,12 @@ import { GridBaseRow } from "../Grid";
|
|
|
7
7
|
import { CellEditorCommon } from "../GridCell";
|
|
8
8
|
import { useGridPopoverHook } from "../GridPopoverHook";
|
|
9
9
|
|
|
10
|
-
export interface GridFormMessageProps<
|
|
11
|
-
message: (selectedRows:
|
|
10
|
+
export interface GridFormMessageProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
11
|
+
message: (selectedRows: TData[]) => Promise<string | ReactElement> | string | ReactElement;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const GridFormMessage = <
|
|
15
|
-
const { selectedRows } = useGridPopoverContext<
|
|
14
|
+
export const GridFormMessage = <TData extends GridBaseRow>(props: GridFormMessageProps<TData>): ReactElement => {
|
|
15
|
+
const { selectedRows } = useGridPopoverContext<TData>();
|
|
16
16
|
|
|
17
17
|
const [message, setMessage] = useState<string | ReactElement | null>(null);
|
|
18
18
|
const { popoverWrapper } = useGridPopoverHook({ className: props.className });
|