@linzjs/step-ag-grid 21.2.1 → 22.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 +4 -0
- package/dist/src/components/Grid.d.ts +2 -1
- package/dist/src/react-menu3/components/FocusableItem.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuItem.d.ts +1 -1
- package/dist/src/react-menu3/components/SubMenu.d.ts +1 -1
- package/dist/src/react-menu3/utils/withHovering.d.ts +1 -1
- package/dist/step-ag-grid.cjs.js +8 -7
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +28 -27
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +31 -31
- package/src/components/Grid.tsx +13 -9
- package/src/components/GridCell.tsx +1 -1
- package/src/components/PostSortRowsHook.ts +2 -2
- package/src/react-menu3/utils/withHovering.tsx +15 -8
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +18 -15
- package/src/styles/GridTheme.scss +4 -0
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": "22.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": "^32.1.0",
|
|
32
|
+
"ag-grid-react": "^32.1.0",
|
|
33
33
|
"lodash-es": ">=4",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-dom": ">=18"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"debounce-promise": "^3.1.2",
|
|
40
40
|
"lodash-es": ">=4",
|
|
41
41
|
"matcher": "^5.0.0",
|
|
42
|
-
"react-transition-state": "^2.1.
|
|
42
|
+
"react-transition-state": "^2.1.2",
|
|
43
43
|
"usehooks-ts": "^3.1.0",
|
|
44
44
|
"uuid": "^10.0.0"
|
|
45
45
|
},
|
|
@@ -78,22 +78,22 @@
|
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
81
|
-
"@chromatic-com/storybook": "^1.
|
|
82
|
-
"@linzjs/lui": "^21.
|
|
81
|
+
"@chromatic-com/storybook": "^1.8.0",
|
|
82
|
+
"@linzjs/lui": "^21.44.4",
|
|
83
83
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
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.
|
|
89
|
-
"@storybook/addon-interactions": "^8.
|
|
90
|
-
"@storybook/addon-links": "^8.
|
|
91
|
-
"@storybook/react": "^8.
|
|
92
|
-
"@storybook/react-vite": "^8.
|
|
93
|
-
"@storybook/test": "^8.
|
|
94
|
-
"@storybook/test-runner": "^0.19.
|
|
95
|
-
"@testing-library/dom": "^10.
|
|
96
|
-
"@testing-library/jest-dom": "^6.
|
|
88
|
+
"@storybook/addon-essentials": "^8.2.9",
|
|
89
|
+
"@storybook/addon-interactions": "^8.2.9",
|
|
90
|
+
"@storybook/addon-links": "^8.2.9",
|
|
91
|
+
"@storybook/react": "^8.2.9",
|
|
92
|
+
"@storybook/react-vite": "^8.2.9",
|
|
93
|
+
"@storybook/test": "^8.2.9",
|
|
94
|
+
"@storybook/test-runner": "^0.19.1",
|
|
95
|
+
"@testing-library/dom": "^10.4.0",
|
|
96
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
97
97
|
"@testing-library/react": "^15.0.7",
|
|
98
98
|
"@testing-library/user-event": "^14.5.2",
|
|
99
99
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
@@ -101,53 +101,53 @@
|
|
|
101
101
|
"@types/jest": "^29.5.12",
|
|
102
102
|
"@types/lodash-es": "^4.17.12",
|
|
103
103
|
"@types/node": "^18.19.39",
|
|
104
|
-
"@types/react": "^18.3.
|
|
104
|
+
"@types/react": "^18.3.5",
|
|
105
105
|
"@types/react-dom": "^18.3.0",
|
|
106
106
|
"@types/uuid": "^10.0.0",
|
|
107
107
|
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
108
108
|
"@typescript-eslint/parser": "^7.15.0",
|
|
109
109
|
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
110
|
-
"ag-grid-community": "^
|
|
111
|
-
"ag-grid-react": "^
|
|
110
|
+
"ag-grid-community": "^32.1.0",
|
|
111
|
+
"ag-grid-react": "^32.1.0",
|
|
112
112
|
"babel-jest": "^29.7.0",
|
|
113
113
|
"babel-preset-react-app": "^10.0.1",
|
|
114
|
-
"chromatic": "^11.
|
|
114
|
+
"chromatic": "^11.7.1",
|
|
115
115
|
"css-loader": "^7.1.2",
|
|
116
|
-
"esbuild": "^0.
|
|
116
|
+
"esbuild": "^0.23.1",
|
|
117
117
|
"eslint": "^8.57.0",
|
|
118
118
|
"eslint-config-prettier": "^9.1.0",
|
|
119
119
|
"eslint-config-react-app": "^7.0.1",
|
|
120
120
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
121
121
|
"eslint-plugin-import": "^2.29.1",
|
|
122
|
-
"eslint-plugin-jest": "^28.
|
|
122
|
+
"eslint-plugin-jest": "^28.8.1",
|
|
123
123
|
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
124
|
-
"eslint-plugin-prettier": "^5.1
|
|
125
|
-
"eslint-plugin-react": "^7.
|
|
124
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
125
|
+
"eslint-plugin-react": "^7.35.0",
|
|
126
126
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
127
127
|
"eslint-plugin-storybook": "^0.8.0",
|
|
128
|
-
"eslint-plugin-testing-library": "^6.
|
|
128
|
+
"eslint-plugin-testing-library": "^6.3.0",
|
|
129
129
|
"jest": "^29.7.0",
|
|
130
130
|
"jest-canvas-mock": "^2.5.2",
|
|
131
131
|
"jest-environment-jsdom": "^29.7.0",
|
|
132
132
|
"jest-expect-message": "^1.1.3",
|
|
133
133
|
"mkdirp": "^3.0.1",
|
|
134
134
|
"npm-run-all": "^4.1.5",
|
|
135
|
-
"postcss": "^8.4.
|
|
135
|
+
"postcss": "^8.4.43",
|
|
136
136
|
"postcss-loader": "^7.3.4",
|
|
137
137
|
"postcss-scss": "^4.0.9",
|
|
138
|
-
"prettier": "^3.3.
|
|
138
|
+
"prettier": "^3.3.3",
|
|
139
139
|
"react": ">=18",
|
|
140
140
|
"react-app-polyfill": "^3.0.0",
|
|
141
141
|
"react-dom": "^18.3.1",
|
|
142
|
-
"rollup": "^4.
|
|
142
|
+
"rollup": "^4.21.2",
|
|
143
143
|
"rollup-plugin-copy": "^3.5.0",
|
|
144
144
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
145
145
|
"rollup-plugin-postcss": "^4.0.2",
|
|
146
146
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
147
|
-
"sass": "^1.77.
|
|
147
|
+
"sass": "^1.77.8",
|
|
148
148
|
"sass-loader": "^14.2.1",
|
|
149
149
|
"semantic-release": "^22.0.12",
|
|
150
|
-
"storybook": "^8.
|
|
150
|
+
"storybook": "^8.2.9",
|
|
151
151
|
"storybook-css-modules-preset": "^1.1.1",
|
|
152
152
|
"style-loader": "^4.0.0",
|
|
153
153
|
"stylelint": "^15.11.0",
|
|
@@ -155,8 +155,8 @@
|
|
|
155
155
|
"stylelint-config-standard": "^34.0.0",
|
|
156
156
|
"stylelint-prettier": "^4.1.0",
|
|
157
157
|
"stylelint-scss": "^5.3.2",
|
|
158
|
-
"typescript": "^5.5.
|
|
159
|
-
"vite": "^5.
|
|
158
|
+
"typescript": "^5.5.4",
|
|
159
|
+
"vite": "^5.4.2",
|
|
160
160
|
"vite-plugin-html": "^3.2.2",
|
|
161
161
|
"vite-tsconfig-paths": "^4.3.2"
|
|
162
162
|
},
|
package/src/components/Grid.tsx
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CellClickedEvent,
|
|
3
|
+
CellDoubleClickedEvent,
|
|
4
|
+
CellEditingStartedEvent,
|
|
3
5
|
ColDef,
|
|
4
6
|
ColGroupDef,
|
|
5
7
|
ColumnResizedEvent,
|
|
6
8
|
IClientSideRowModel,
|
|
7
9
|
ModelUpdatedEvent,
|
|
10
|
+
RowDragLeaveEvent,
|
|
8
11
|
RowHighlightPosition,
|
|
9
12
|
RowNode,
|
|
10
13
|
} from "ag-grid-community";
|
|
@@ -12,7 +15,6 @@ import { CellClassParams, EditableCallback, EditableCallbackParams } from "ag-gr
|
|
|
12
15
|
import { GridOptions } from "ag-grid-community";
|
|
13
16
|
import {
|
|
14
17
|
AgGridEvent,
|
|
15
|
-
CellEvent,
|
|
16
18
|
CellKeyDownEvent,
|
|
17
19
|
GridReadyEvent,
|
|
18
20
|
RowDragEndEvent,
|
|
@@ -39,6 +41,7 @@ export interface GridBaseRow {
|
|
|
39
41
|
|
|
40
42
|
export interface GridProps {
|
|
41
43
|
readOnly?: boolean; // set all editables to false when read only, make all styles black, otherwise style is gray for not editable
|
|
44
|
+
defaultPostSort?: boolean; // Retain sort order after edit, Defaults to true.
|
|
42
45
|
selectable?: boolean;
|
|
43
46
|
theme?: string; // should have prefix ag-theme-
|
|
44
47
|
["data-testid"]?: string;
|
|
@@ -114,6 +117,7 @@ export interface GridProps {
|
|
|
114
117
|
*/
|
|
115
118
|
export const Grid = ({
|
|
116
119
|
"data-testid": dataTestId,
|
|
120
|
+
defaultPostSort = true,
|
|
117
121
|
rowSelection = "multiple",
|
|
118
122
|
suppressColumnVirtualization = true,
|
|
119
123
|
theme = "ag-theme-step-default",
|
|
@@ -370,6 +374,7 @@ export const Grid = ({
|
|
|
370
374
|
exportable: false,
|
|
371
375
|
},
|
|
372
376
|
checkboxSelection: params.selectable,
|
|
377
|
+
headerClass: params.onRowDragEnd ? "ag-header-select-draggable" : undefined,
|
|
373
378
|
headerComponent: rowSelection === "multiple" ? GridHeaderSelect : null,
|
|
374
379
|
suppressHeaderKeyboardEvent: (e) => {
|
|
375
380
|
if (!params.selectable) return false;
|
|
@@ -448,7 +453,7 @@ export const Grid = ({
|
|
|
448
453
|
/**
|
|
449
454
|
* Force-refresh all selected rows to re-run class function, to update selection highlighting
|
|
450
455
|
*/
|
|
451
|
-
const refreshSelectedRows = useCallback((event:
|
|
456
|
+
const refreshSelectedRows = useCallback((event: CellEditingStartedEvent): void => {
|
|
452
457
|
event.api.refreshCells({
|
|
453
458
|
force: true,
|
|
454
459
|
rowNodes: event.api.getSelectedNodes(),
|
|
@@ -459,7 +464,7 @@ export const Grid = ({
|
|
|
459
464
|
* Make sure node is selected for editing and start edit
|
|
460
465
|
*/
|
|
461
466
|
const startCellEditing = useCallback(
|
|
462
|
-
(event:
|
|
467
|
+
(event: CellKeyDownEvent | CellClickedEvent | CellDoubleClickedEvent) => {
|
|
463
468
|
prePopupOps();
|
|
464
469
|
if (!event.node.isSelected()) {
|
|
465
470
|
event.node.setSelected(true, true);
|
|
@@ -483,7 +488,7 @@ export const Grid = ({
|
|
|
483
488
|
* Handle double click edit
|
|
484
489
|
*/
|
|
485
490
|
const onCellDoubleClick = useCallback(
|
|
486
|
-
(event:
|
|
491
|
+
(event: CellDoubleClickedEvent) => {
|
|
487
492
|
if (!invokeEditAction(event)) startCellEditing(event);
|
|
488
493
|
},
|
|
489
494
|
[startCellEditing],
|
|
@@ -493,7 +498,7 @@ export const Grid = ({
|
|
|
493
498
|
* Handle single click edits
|
|
494
499
|
*/
|
|
495
500
|
const onCellClicked = useCallback(
|
|
496
|
-
(event:
|
|
501
|
+
(event: CellClickedEvent) => {
|
|
497
502
|
if (event.colDef?.cellRendererParams?.singleClickEdit ?? singleClickEdit) {
|
|
498
503
|
startCellEditing(event);
|
|
499
504
|
}
|
|
@@ -504,7 +509,7 @@ export const Grid = ({
|
|
|
504
509
|
/**
|
|
505
510
|
* If cell has an edit action invoke it (if editable)
|
|
506
511
|
*/
|
|
507
|
-
const invokeEditAction = (e:
|
|
512
|
+
const invokeEditAction = (e: CellDoubleClickedEvent | CellKeyDownEvent): boolean => {
|
|
508
513
|
const editAction = e.colDef?.cellRendererParams?.editAction;
|
|
509
514
|
if (!editAction) return false;
|
|
510
515
|
|
|
@@ -636,7 +641,7 @@ export const Grid = ({
|
|
|
636
641
|
|
|
637
642
|
const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
|
|
638
643
|
|
|
639
|
-
const onRowDragLeave = useCallback((event:
|
|
644
|
+
const onRowDragLeave = useCallback((event: RowDragLeaveEvent) => {
|
|
640
645
|
const clientSideRowModel = event.api.getModel() as IClientSideRowModel;
|
|
641
646
|
clientSideRowModel.highlightRowAtPixel(null);
|
|
642
647
|
}, []);
|
|
@@ -701,7 +706,6 @@ export const Grid = ({
|
|
|
701
706
|
{gridContextMenu.component}
|
|
702
707
|
<div style={{ flex: 1 }} ref={gridDivRef}>
|
|
703
708
|
<AgGridReact
|
|
704
|
-
reactiveCustomComponents={true}
|
|
705
709
|
rowHeight={rowHeight}
|
|
706
710
|
animateRows={params.animateRows ?? false}
|
|
707
711
|
rowClassRules={params.rowClassRules}
|
|
@@ -742,7 +746,7 @@ export const Grid = ({
|
|
|
742
746
|
onModelUpdated={onModelUpdated}
|
|
743
747
|
onGridReady={onGridReady}
|
|
744
748
|
onSortChanged={ensureSelectedRowIsVisible}
|
|
745
|
-
postSortRows={params.onRowDragEnd ? undefined : postSortRows}
|
|
749
|
+
postSortRows={params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows}
|
|
746
750
|
onSelectionChanged={synchroniseExternalStateToGridSelection}
|
|
747
751
|
onColumnMoved={params.onColumnMoved}
|
|
748
752
|
alwaysShowVerticalScroll={params.alwaysShowVerticalScroll}
|
|
@@ -116,7 +116,7 @@ export const suppressCellKeyboardEvents = (e: SuppressKeyboardEventParams) => {
|
|
|
116
116
|
const exec = shortcutKeys[e.event.key];
|
|
117
117
|
if (exec && !e.editing && !e.event.repeat && e.event.type === "keydown") {
|
|
118
118
|
const editable = fnOrVar(e.colDef?.editable, e);
|
|
119
|
-
return editable ? exec(e) ?? true : true;
|
|
119
|
+
return editable ? (exec(e) ?? true) : true;
|
|
120
120
|
}
|
|
121
121
|
// It's important that aggrid doesn't trigger edit on enter
|
|
122
122
|
// as the incorrect selected rows will be returned
|
|
@@ -81,9 +81,9 @@ export const usePostSortRowsHook = ({ setStaleGrid }: PostSortRowsHookProps) =>
|
|
|
81
81
|
const newSortOrder = JSON.stringify(copyCurrentSortSettings());
|
|
82
82
|
let sortOrderChanged = newSortOrder != lastSortOrderHash.current;
|
|
83
83
|
|
|
84
|
-
const quickFilter = (
|
|
84
|
+
const quickFilter = api.getQuickFilter();
|
|
85
85
|
if (previousQuickFilter.current != quickFilter) {
|
|
86
|
-
previousQuickFilter.current = quickFilter;
|
|
86
|
+
previousQuickFilter.current = quickFilter ?? "";
|
|
87
87
|
sortOrderChanged = true;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -8,17 +8,24 @@ export interface withHoveringResultProps {
|
|
|
8
8
|
menuItemRef?: MutableRefObject<HTMLLIElement>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const withHovering = <
|
|
11
|
+
export const withHovering = <X extends Record<string, any>, T extends PropsWithRef<X>>(
|
|
12
|
+
name: string,
|
|
13
|
+
WrappedComponent: (props: T) => ReactElement,
|
|
14
|
+
) => {
|
|
12
15
|
const Component = memo(WrappedComponent);
|
|
13
|
-
const WithHovering = forwardRef((props
|
|
16
|
+
const WithHovering = forwardRef<any, T>((props, ref) => {
|
|
14
17
|
const menuItemRef = useRef<any>(null);
|
|
18
|
+
|
|
15
19
|
return (
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
<>
|
|
21
|
+
{/* @ts-ignore Can't work out what the ref issue is here */}
|
|
22
|
+
<Component
|
|
23
|
+
{...props}
|
|
24
|
+
menuItemRef={menuItemRef}
|
|
25
|
+
externalRef={ref}
|
|
26
|
+
isHovering={useContext(HoverItemContext) === menuItemRef.current}
|
|
27
|
+
/>
|
|
28
|
+
</>
|
|
22
29
|
);
|
|
23
30
|
});
|
|
24
31
|
|
|
@@ -84,21 +84,24 @@ const GridEditMultiSelectTemplate: StoryFn<typeof Grid> = (props: GridProps) =>
|
|
|
84
84
|
filterPlaceholder: "Filter position",
|
|
85
85
|
className: "GridMultiSelect-containerUnlimited",
|
|
86
86
|
headers: [{ header: "Header item" }],
|
|
87
|
-
options:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
options: (selectedRows) => {
|
|
88
|
+
const firstRow = selectedRows[0];
|
|
89
|
+
return [
|
|
90
|
+
{ value: "lot1", label: "Lot 1" },
|
|
91
|
+
{ value: "lot2", label: "Lot 2" },
|
|
92
|
+
{ value: "lot3", label: "Lot 3" },
|
|
93
|
+
{ value: "lot11", label: "Lot 11" },
|
|
94
|
+
{ value: "lot4", label: "Lot A 482392" },
|
|
95
|
+
{ value: "appA", label: "A" },
|
|
96
|
+
{ value: "appB", label: "B" },
|
|
97
|
+
MenuSeparator,
|
|
98
|
+
{
|
|
99
|
+
value: "other",
|
|
100
|
+
label: "Other",
|
|
101
|
+
subComponent: () => <GridFormSubComponentTextArea required={true} maxLength={5} defaultValue={""} />,
|
|
102
|
+
},
|
|
103
|
+
].map((r) => ({ ...r, checked: firstRow.position?.includes(r.value) }));
|
|
104
|
+
},
|
|
102
105
|
onSave: async ({ selectedRows, selectedOptions }) => {
|
|
103
106
|
// eslint-disable-next-line no-console
|
|
104
107
|
console.log("multiSelect result", { selectedRows, selectedOptions });
|
|
@@ -67,6 +67,10 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
|
|
|
67
67
|
}
|
|
68
68
|
// fix alignment of cell content when grabber is present
|
|
69
69
|
.ag-header-cell-comp-wrapper {
|
|
70
|
+
justify-content: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ag-header-select-draggable .ag-header-cell-comp-wrapper {
|
|
70
74
|
justify-content: end;
|
|
71
75
|
}
|
|
72
76
|
|