@linzjs/step-ag-grid 21.3.0 → 22.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/GridTheme.scss +4 -0
- package/dist/src/lui/TextAreaInput.d.ts +0 -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 -64
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +29 -84
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +32 -33
- package/src/components/Grid.tsx +10 -8
- package/src/components/GridCell.tsx +1 -1
- package/src/components/PostSortRowsHook.ts +2 -2
- package/src/lui/TextAreaInput.tsx +3 -8
- 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.1",
|
|
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,9 +39,8 @@
|
|
|
39
39
|
"debounce-promise": "^3.1.2",
|
|
40
40
|
"lodash-es": ">=4",
|
|
41
41
|
"matcher": "^5.0.0",
|
|
42
|
-
"react-transition-state": "^2.1.
|
|
43
|
-
"usehooks-ts": "^3.1.0"
|
|
44
|
-
"uuid": "^10.0.0"
|
|
42
|
+
"react-transition-state": "^2.1.2",
|
|
43
|
+
"usehooks-ts": "^3.1.0"
|
|
45
44
|
},
|
|
46
45
|
"scripts": {
|
|
47
46
|
"build": "run-s clean stylelint lint css bundle",
|
|
@@ -78,22 +77,22 @@
|
|
|
78
77
|
},
|
|
79
78
|
"devDependencies": {
|
|
80
79
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
81
|
-
"@chromatic-com/storybook": "^1.
|
|
82
|
-
"@linzjs/lui": "^21.
|
|
80
|
+
"@chromatic-com/storybook": "^1.8.0",
|
|
81
|
+
"@linzjs/lui": "^21.44.4",
|
|
83
82
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
84
83
|
"@rollup/plugin-json": "^6.1.0",
|
|
85
84
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
86
85
|
"@semantic-release/changelog": "^6.0.3",
|
|
87
86
|
"@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.
|
|
87
|
+
"@storybook/addon-essentials": "^8.2.9",
|
|
88
|
+
"@storybook/addon-interactions": "^8.2.9",
|
|
89
|
+
"@storybook/addon-links": "^8.2.9",
|
|
90
|
+
"@storybook/react": "^8.2.9",
|
|
91
|
+
"@storybook/react-vite": "^8.2.9",
|
|
92
|
+
"@storybook/test": "^8.2.9",
|
|
93
|
+
"@storybook/test-runner": "^0.19.1",
|
|
94
|
+
"@testing-library/dom": "^10.4.0",
|
|
95
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
97
96
|
"@testing-library/react": "^15.0.7",
|
|
98
97
|
"@testing-library/user-event": "^14.5.2",
|
|
99
98
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
@@ -101,53 +100,53 @@
|
|
|
101
100
|
"@types/jest": "^29.5.12",
|
|
102
101
|
"@types/lodash-es": "^4.17.12",
|
|
103
102
|
"@types/node": "^18.19.39",
|
|
104
|
-
"@types/react": "^18.3.
|
|
103
|
+
"@types/react": "^18.3.5",
|
|
105
104
|
"@types/react-dom": "^18.3.0",
|
|
106
105
|
"@types/uuid": "^10.0.0",
|
|
107
106
|
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
108
107
|
"@typescript-eslint/parser": "^7.15.0",
|
|
109
108
|
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
110
|
-
"ag-grid-community": "^
|
|
111
|
-
"ag-grid-react": "^
|
|
109
|
+
"ag-grid-community": "^32.1.0",
|
|
110
|
+
"ag-grid-react": "^32.1.0",
|
|
112
111
|
"babel-jest": "^29.7.0",
|
|
113
112
|
"babel-preset-react-app": "^10.0.1",
|
|
114
|
-
"chromatic": "^11.
|
|
113
|
+
"chromatic": "^11.7.1",
|
|
115
114
|
"css-loader": "^7.1.2",
|
|
116
|
-
"esbuild": "^0.
|
|
115
|
+
"esbuild": "^0.23.1",
|
|
117
116
|
"eslint": "^8.57.0",
|
|
118
117
|
"eslint-config-prettier": "^9.1.0",
|
|
119
118
|
"eslint-config-react-app": "^7.0.1",
|
|
120
119
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
121
120
|
"eslint-plugin-import": "^2.29.1",
|
|
122
|
-
"eslint-plugin-jest": "^28.
|
|
121
|
+
"eslint-plugin-jest": "^28.8.1",
|
|
123
122
|
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
124
|
-
"eslint-plugin-prettier": "^5.1
|
|
125
|
-
"eslint-plugin-react": "^7.
|
|
123
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
124
|
+
"eslint-plugin-react": "^7.35.0",
|
|
126
125
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
127
126
|
"eslint-plugin-storybook": "^0.8.0",
|
|
128
|
-
"eslint-plugin-testing-library": "^6.
|
|
127
|
+
"eslint-plugin-testing-library": "^6.3.0",
|
|
129
128
|
"jest": "^29.7.0",
|
|
130
129
|
"jest-canvas-mock": "^2.5.2",
|
|
131
130
|
"jest-environment-jsdom": "^29.7.0",
|
|
132
131
|
"jest-expect-message": "^1.1.3",
|
|
133
132
|
"mkdirp": "^3.0.1",
|
|
134
133
|
"npm-run-all": "^4.1.5",
|
|
135
|
-
"postcss": "^8.4.
|
|
134
|
+
"postcss": "^8.4.43",
|
|
136
135
|
"postcss-loader": "^7.3.4",
|
|
137
136
|
"postcss-scss": "^4.0.9",
|
|
138
|
-
"prettier": "^3.3.
|
|
137
|
+
"prettier": "^3.3.3",
|
|
139
138
|
"react": ">=18",
|
|
140
139
|
"react-app-polyfill": "^3.0.0",
|
|
141
140
|
"react-dom": "^18.3.1",
|
|
142
|
-
"rollup": "^4.
|
|
141
|
+
"rollup": "^4.21.2",
|
|
143
142
|
"rollup-plugin-copy": "^3.5.0",
|
|
144
143
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
145
144
|
"rollup-plugin-postcss": "^4.0.2",
|
|
146
145
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
147
|
-
"sass": "^1.77.
|
|
146
|
+
"sass": "^1.77.8",
|
|
148
147
|
"sass-loader": "^14.2.1",
|
|
149
148
|
"semantic-release": "^22.0.12",
|
|
150
|
-
"storybook": "^8.
|
|
149
|
+
"storybook": "^8.2.9",
|
|
151
150
|
"storybook-css-modules-preset": "^1.1.1",
|
|
152
151
|
"style-loader": "^4.0.0",
|
|
153
152
|
"stylelint": "^15.11.0",
|
|
@@ -155,8 +154,8 @@
|
|
|
155
154
|
"stylelint-config-standard": "^34.0.0",
|
|
156
155
|
"stylelint-prettier": "^4.1.0",
|
|
157
156
|
"stylelint-scss": "^5.3.2",
|
|
158
|
-
"typescript": "^5.5.
|
|
159
|
-
"vite": "^5.
|
|
157
|
+
"typescript": "^5.5.4",
|
|
158
|
+
"vite": "^5.4.2",
|
|
160
159
|
"vite-plugin-html": "^3.2.2",
|
|
161
160
|
"vite-tsconfig-paths": "^4.3.2"
|
|
162
161
|
},
|
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
|
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
2
|
import { omit } from "lodash-es";
|
|
3
|
-
import { InputHTMLAttributes, ReactElement,
|
|
4
|
-
import { v4 as uuidVersion4 } from "uuid";
|
|
3
|
+
import { InputHTMLAttributes, ReactElement, useId } from "react";
|
|
5
4
|
|
|
6
5
|
import { FormError } from "./FormError";
|
|
7
6
|
|
|
8
|
-
export const useGenerateOrDefaultId = (idFromProps?: string) => {
|
|
9
|
-
const [id] = useState(idFromProps ? idFromProps : uuidVersion4());
|
|
10
|
-
return id;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
7
|
export interface LuiTextAreaInputProps extends InputHTMLAttributes<HTMLTextAreaElement> {
|
|
14
8
|
// overrides value in base class to be string type only
|
|
15
9
|
value: string;
|
|
@@ -23,7 +17,8 @@ export interface LuiTextAreaInputProps extends InputHTMLAttributes<HTMLTextAreaE
|
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
export const TextAreaInput = (props: LuiTextAreaInputProps) => {
|
|
26
|
-
const
|
|
20
|
+
const reactId = useId();
|
|
21
|
+
const id = props?.id ?? reactId;
|
|
27
22
|
|
|
28
23
|
return (
|
|
29
24
|
<div
|
|
@@ -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
|
|