@linzjs/step-ag-grid 21.3.0 → 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/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 +6 -5
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +26 -25
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +31 -31
- package/src/components/Grid.tsx +10 -8
- 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,
|
|
@@ -372,6 +374,7 @@ export const Grid = ({
|
|
|
372
374
|
exportable: false,
|
|
373
375
|
},
|
|
374
376
|
checkboxSelection: params.selectable,
|
|
377
|
+
headerClass: params.onRowDragEnd ? "ag-header-select-draggable" : undefined,
|
|
375
378
|
headerComponent: rowSelection === "multiple" ? GridHeaderSelect : null,
|
|
376
379
|
suppressHeaderKeyboardEvent: (e) => {
|
|
377
380
|
if (!params.selectable) return false;
|
|
@@ -450,7 +453,7 @@ export const Grid = ({
|
|
|
450
453
|
/**
|
|
451
454
|
* Force-refresh all selected rows to re-run class function, to update selection highlighting
|
|
452
455
|
*/
|
|
453
|
-
const refreshSelectedRows = useCallback((event:
|
|
456
|
+
const refreshSelectedRows = useCallback((event: CellEditingStartedEvent): void => {
|
|
454
457
|
event.api.refreshCells({
|
|
455
458
|
force: true,
|
|
456
459
|
rowNodes: event.api.getSelectedNodes(),
|
|
@@ -461,7 +464,7 @@ export const Grid = ({
|
|
|
461
464
|
* Make sure node is selected for editing and start edit
|
|
462
465
|
*/
|
|
463
466
|
const startCellEditing = useCallback(
|
|
464
|
-
(event:
|
|
467
|
+
(event: CellKeyDownEvent | CellClickedEvent | CellDoubleClickedEvent) => {
|
|
465
468
|
prePopupOps();
|
|
466
469
|
if (!event.node.isSelected()) {
|
|
467
470
|
event.node.setSelected(true, true);
|
|
@@ -485,7 +488,7 @@ export const Grid = ({
|
|
|
485
488
|
* Handle double click edit
|
|
486
489
|
*/
|
|
487
490
|
const onCellDoubleClick = useCallback(
|
|
488
|
-
(event:
|
|
491
|
+
(event: CellDoubleClickedEvent) => {
|
|
489
492
|
if (!invokeEditAction(event)) startCellEditing(event);
|
|
490
493
|
},
|
|
491
494
|
[startCellEditing],
|
|
@@ -495,7 +498,7 @@ export const Grid = ({
|
|
|
495
498
|
* Handle single click edits
|
|
496
499
|
*/
|
|
497
500
|
const onCellClicked = useCallback(
|
|
498
|
-
(event:
|
|
501
|
+
(event: CellClickedEvent) => {
|
|
499
502
|
if (event.colDef?.cellRendererParams?.singleClickEdit ?? singleClickEdit) {
|
|
500
503
|
startCellEditing(event);
|
|
501
504
|
}
|
|
@@ -506,7 +509,7 @@ export const Grid = ({
|
|
|
506
509
|
/**
|
|
507
510
|
* If cell has an edit action invoke it (if editable)
|
|
508
511
|
*/
|
|
509
|
-
const invokeEditAction = (e:
|
|
512
|
+
const invokeEditAction = (e: CellDoubleClickedEvent | CellKeyDownEvent): boolean => {
|
|
510
513
|
const editAction = e.colDef?.cellRendererParams?.editAction;
|
|
511
514
|
if (!editAction) return false;
|
|
512
515
|
|
|
@@ -638,7 +641,7 @@ export const Grid = ({
|
|
|
638
641
|
|
|
639
642
|
const gridContextMenu = useGridContextMenu({ contextMenu: params.contextMenu, contextMenuSelectRow });
|
|
640
643
|
|
|
641
|
-
const onRowDragLeave = useCallback((event:
|
|
644
|
+
const onRowDragLeave = useCallback((event: RowDragLeaveEvent) => {
|
|
642
645
|
const clientSideRowModel = event.api.getModel() as IClientSideRowModel;
|
|
643
646
|
clientSideRowModel.highlightRowAtPixel(null);
|
|
644
647
|
}, []);
|
|
@@ -703,7 +706,6 @@ export const Grid = ({
|
|
|
703
706
|
{gridContextMenu.component}
|
|
704
707
|
<div style={{ flex: 1 }} ref={gridDivRef}>
|
|
705
708
|
<AgGridReact
|
|
706
|
-
reactiveCustomComponents={true}
|
|
707
709
|
rowHeight={rowHeight}
|
|
708
710
|
animateRows={params.animateRows ?? false}
|
|
709
711
|
rowClassRules={params.rowClassRules}
|
|
@@ -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
|
|