@linzjs/step-ag-grid 22.0.1 → 22.1.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/index.css +39 -0
- package/dist/src/components/Grid.d.ts +1 -2
- package/dist/src/components/GridCell.d.ts +1 -1
- package/dist/src/components/clickInputWhenContainingCellClicked.d.ts +6 -0
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
- package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +11 -0
- package/dist/src/components/gridPopoverEdit/index.d.ts +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/step-ag-grid.cjs.js +99 -17
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +98 -18
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +31 -31
- package/src/components/Grid.tsx +18 -23
- package/src/components/GridCell.tsx +4 -2
- package/src/components/clickInputWhenContainingCellClicked.tsx +40 -0
- package/src/components/gridForm/GridFormDropDown.tsx +1 -0
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +1 -1
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +79 -0
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +8 -1
- package/src/components/gridPopoverEdit/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/contexts/GridContextProvider.tsx +1 -0
- package/src/stories/grid/FormTest.tsx +1 -0
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +74 -0
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +1 -0
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +1 -0
- package/src/styles/Grid.scss +34 -0
- package/src/styles/GridFormDropDown.scss +5 -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": "22.
|
|
5
|
+
"version": "22.1.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.
|
|
32
|
-
"ag-grid-react": "^32.
|
|
31
|
+
"ag-grid-community": "^32.2.0",
|
|
32
|
+
"ag-grid-react": "^32.2.0",
|
|
33
33
|
"lodash-es": ">=4",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-dom": ">=18"
|
|
@@ -77,51 +77,51 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
80
|
-
"@chromatic-com/storybook": "^
|
|
81
|
-
"@linzjs/lui": "^21.
|
|
80
|
+
"@chromatic-com/storybook": "^2.0.2",
|
|
81
|
+
"@linzjs/lui": "^21.46.0",
|
|
82
82
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
83
83
|
"@rollup/plugin-json": "^6.1.0",
|
|
84
|
-
"@rollup/plugin-node-resolve": "^15.2.
|
|
84
|
+
"@rollup/plugin-node-resolve": "^15.2.4",
|
|
85
85
|
"@semantic-release/changelog": "^6.0.3",
|
|
86
86
|
"@semantic-release/git": "^10.0.1",
|
|
87
|
-
"@storybook/addon-essentials": "^8.2
|
|
88
|
-
"@storybook/addon-interactions": "^8.2
|
|
89
|
-
"@storybook/addon-links": "^8.2
|
|
90
|
-
"@storybook/react": "^8.2
|
|
91
|
-
"@storybook/react-vite": "^8.2
|
|
92
|
-
"@storybook/test": "^8.2
|
|
87
|
+
"@storybook/addon-essentials": "^8.3.2",
|
|
88
|
+
"@storybook/addon-interactions": "^8.3.2",
|
|
89
|
+
"@storybook/addon-links": "^8.3.2",
|
|
90
|
+
"@storybook/react": "^8.3.2",
|
|
91
|
+
"@storybook/react-vite": "^8.3.2",
|
|
92
|
+
"@storybook/test": "^8.3.2",
|
|
93
93
|
"@storybook/test-runner": "^0.19.1",
|
|
94
94
|
"@testing-library/dom": "^10.4.0",
|
|
95
95
|
"@testing-library/jest-dom": "^6.5.0",
|
|
96
|
-
"@testing-library/react": "^
|
|
96
|
+
"@testing-library/react": "^16.0.1",
|
|
97
97
|
"@testing-library/user-event": "^14.5.2",
|
|
98
98
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
99
99
|
"@types/debounce-promise": "^3.1.9",
|
|
100
|
-
"@types/jest": "^29.5.
|
|
100
|
+
"@types/jest": "^29.5.13",
|
|
101
101
|
"@types/lodash-es": "^4.17.12",
|
|
102
|
-
"@types/node": "^
|
|
103
|
-
"@types/react": "^18.3.
|
|
102
|
+
"@types/node": "^22.5.5",
|
|
103
|
+
"@types/react": "^18.3.8",
|
|
104
104
|
"@types/react-dom": "^18.3.0",
|
|
105
105
|
"@types/uuid": "^10.0.0",
|
|
106
106
|
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
107
107
|
"@typescript-eslint/parser": "^7.15.0",
|
|
108
108
|
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
109
|
-
"ag-grid-community": "^32.
|
|
110
|
-
"ag-grid-react": "^32.
|
|
109
|
+
"ag-grid-community": "^32.2.0",
|
|
110
|
+
"ag-grid-react": "^32.2.0",
|
|
111
111
|
"babel-jest": "^29.7.0",
|
|
112
112
|
"babel-preset-react-app": "^10.0.1",
|
|
113
|
-
"chromatic": "^11.
|
|
113
|
+
"chromatic": "^11.10.2",
|
|
114
114
|
"css-loader": "^7.1.2",
|
|
115
|
-
"esbuild": "^0.
|
|
115
|
+
"esbuild": "^0.24.0",
|
|
116
116
|
"eslint": "^8.57.0",
|
|
117
117
|
"eslint-config-prettier": "^9.1.0",
|
|
118
118
|
"eslint-config-react-app": "^7.0.1",
|
|
119
119
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
120
|
-
"eslint-plugin-import": "^2.
|
|
121
|
-
"eslint-plugin-jest": "^28.8.
|
|
122
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
120
|
+
"eslint-plugin-import": "^2.30.0",
|
|
121
|
+
"eslint-plugin-jest": "^28.8.3",
|
|
122
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
123
123
|
"eslint-plugin-prettier": "^5.2.1",
|
|
124
|
-
"eslint-plugin-react": "^7.
|
|
124
|
+
"eslint-plugin-react": "^7.36.1",
|
|
125
125
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
126
126
|
"eslint-plugin-storybook": "^0.8.0",
|
|
127
127
|
"eslint-plugin-testing-library": "^6.3.0",
|
|
@@ -131,22 +131,22 @@
|
|
|
131
131
|
"jest-expect-message": "^1.1.3",
|
|
132
132
|
"mkdirp": "^3.0.1",
|
|
133
133
|
"npm-run-all": "^4.1.5",
|
|
134
|
-
"postcss": "^8.4.
|
|
134
|
+
"postcss": "^8.4.47",
|
|
135
135
|
"postcss-loader": "^7.3.4",
|
|
136
136
|
"postcss-scss": "^4.0.9",
|
|
137
137
|
"prettier": "^3.3.3",
|
|
138
138
|
"react": ">=18",
|
|
139
139
|
"react-app-polyfill": "^3.0.0",
|
|
140
140
|
"react-dom": "^18.3.1",
|
|
141
|
-
"rollup": "^4.
|
|
141
|
+
"rollup": "^4.22.4",
|
|
142
142
|
"rollup-plugin-copy": "^3.5.0",
|
|
143
143
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
144
144
|
"rollup-plugin-postcss": "^4.0.2",
|
|
145
145
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
146
|
-
"sass": "^1.
|
|
146
|
+
"sass": "^1.79.3",
|
|
147
147
|
"sass-loader": "^14.2.1",
|
|
148
148
|
"semantic-release": "^22.0.12",
|
|
149
|
-
"storybook": "^8.2
|
|
149
|
+
"storybook": "^8.3.2",
|
|
150
150
|
"storybook-css-modules-preset": "^1.1.1",
|
|
151
151
|
"style-loader": "^4.0.0",
|
|
152
152
|
"stylelint": "^15.11.0",
|
|
@@ -154,10 +154,10 @@
|
|
|
154
154
|
"stylelint-config-standard": "^34.0.0",
|
|
155
155
|
"stylelint-prettier": "^4.1.0",
|
|
156
156
|
"stylelint-scss": "^5.3.2",
|
|
157
|
-
"typescript": "^5.
|
|
158
|
-
"vite": "^5.4.
|
|
157
|
+
"typescript": "^5.6.2",
|
|
158
|
+
"vite": "^5.4.7",
|
|
159
159
|
"vite-plugin-html": "^3.2.2",
|
|
160
|
-
"vite-tsconfig-paths": "^
|
|
160
|
+
"vite-tsconfig-paths": "^5.0.1"
|
|
161
161
|
},
|
|
162
162
|
"babel": {
|
|
163
163
|
"presets": [
|
package/src/components/Grid.tsx
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AgGridEvent,
|
|
3
|
+
CellClassParams,
|
|
2
4
|
CellClickedEvent,
|
|
3
5
|
CellDoubleClickedEvent,
|
|
4
6
|
CellEditingStartedEvent,
|
|
7
|
+
CellKeyDownEvent,
|
|
5
8
|
ColDef,
|
|
6
9
|
ColGroupDef,
|
|
7
10
|
ColumnResizedEvent,
|
|
11
|
+
EditableCallback,
|
|
12
|
+
EditableCallbackParams,
|
|
13
|
+
GridOptions,
|
|
14
|
+
GridReadyEvent,
|
|
8
15
|
IClientSideRowModel,
|
|
9
16
|
ModelUpdatedEvent,
|
|
17
|
+
RowDragEndEvent,
|
|
10
18
|
RowDragLeaveEvent,
|
|
19
|
+
RowDragMoveEvent,
|
|
11
20
|
RowHighlightPosition,
|
|
12
21
|
RowNode,
|
|
13
|
-
} from "ag-grid-community";
|
|
14
|
-
import { CellClassParams, EditableCallback, EditableCallbackParams } from "ag-grid-community";
|
|
15
|
-
import { GridOptions } from "ag-grid-community";
|
|
16
|
-
import {
|
|
17
|
-
AgGridEvent,
|
|
18
|
-
CellKeyDownEvent,
|
|
19
|
-
GridReadyEvent,
|
|
20
|
-
RowDragEndEvent,
|
|
21
|
-
RowDragMoveEvent,
|
|
22
22
|
SelectionChangedEvent,
|
|
23
23
|
} from "ag-grid-community";
|
|
24
24
|
import { AgGridReact } from "ag-grid-react";
|
|
@@ -34,6 +34,7 @@ import { GridNoRowsOverlay } from "./GridNoRowsOverlay";
|
|
|
34
34
|
import { usePostSortRowsHook } from "./PostSortRowsHook";
|
|
35
35
|
import { GridHeaderSelect } from "./gridHeader";
|
|
36
36
|
import { GridContextMenuComponent, useGridContextMenu } from "./gridHook";
|
|
37
|
+
import { clickInputWhenContainingCellClicked } from "./clickInputWhenContainingCellClicked";
|
|
37
38
|
|
|
38
39
|
export interface GridBaseRow {
|
|
39
40
|
id: string | number;
|
|
@@ -266,16 +267,6 @@ export const Grid = ({
|
|
|
266
267
|
getFirstRowId,
|
|
267
268
|
]);
|
|
268
269
|
|
|
269
|
-
/**
|
|
270
|
-
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
271
|
-
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
272
|
-
*/
|
|
273
|
-
const clickSelectorCheckboxWhenContainingCellClicked = useCallback(({ event }: CellClickedEvent) => {
|
|
274
|
-
if (!event) return;
|
|
275
|
-
const input = (event.target as Element).querySelector("input");
|
|
276
|
-
input?.dispatchEvent(event);
|
|
277
|
-
}, []);
|
|
278
|
-
|
|
279
270
|
/**
|
|
280
271
|
* Ensure external selected items list is in sync with panel.
|
|
281
272
|
*/
|
|
@@ -388,7 +379,7 @@ export const Grid = ({
|
|
|
388
379
|
}
|
|
389
380
|
return false;
|
|
390
381
|
},
|
|
391
|
-
onCellClicked:
|
|
382
|
+
onCellClicked: clickInputWhenContainingCellClicked,
|
|
392
383
|
},
|
|
393
384
|
...adjustColDefs,
|
|
394
385
|
]
|
|
@@ -402,7 +393,6 @@ export const Grid = ({
|
|
|
402
393
|
params.defaultColDef?.editable,
|
|
403
394
|
selectColumnPinned,
|
|
404
395
|
rowSelection,
|
|
405
|
-
clickSelectorCheckboxWhenContainingCellClicked,
|
|
406
396
|
]);
|
|
407
397
|
|
|
408
398
|
/**
|
|
@@ -528,11 +518,16 @@ export const Grid = ({
|
|
|
528
518
|
*/
|
|
529
519
|
const onCellKeyPress = useCallback(
|
|
530
520
|
(e: CellKeyDownEvent) => {
|
|
531
|
-
|
|
521
|
+
const kbe = e.event as KeyboardEvent;
|
|
522
|
+
if (kbe.key === "Enter") {
|
|
532
523
|
if (!invokeEditAction(e)) startCellEditing(e);
|
|
533
524
|
}
|
|
525
|
+
if (kbe.key === "Tab") {
|
|
526
|
+
// eslint-disable-next-line
|
|
527
|
+
prePopupOps();
|
|
528
|
+
}
|
|
534
529
|
},
|
|
535
|
-
[startCellEditing],
|
|
530
|
+
[prePopupOps, startCellEditing],
|
|
536
531
|
);
|
|
537
532
|
|
|
538
533
|
/**
|
|
@@ -98,7 +98,9 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
|
|
|
98
98
|
editable?: boolean | SAEditableCallback<TData, ValueType>;
|
|
99
99
|
valueGetter?: string | SAValueGetterFunc<TData, ValueType>;
|
|
100
100
|
valueFormatter?: string | SAValueFormatterFunc<TData, ValueType>;
|
|
101
|
-
cellRenderer?:
|
|
101
|
+
cellRenderer?:
|
|
102
|
+
| ((props: SAICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined)
|
|
103
|
+
| string;
|
|
102
104
|
cellRendererParams?: {
|
|
103
105
|
singleClickEdit?: boolean;
|
|
104
106
|
rightHoverElement?: ReactElement;
|
|
@@ -200,7 +202,7 @@ export const GridCell = <TData extends GridBaseRow, TValue = any, Props extends
|
|
|
200
202
|
else return JSON.stringify(params.value);
|
|
201
203
|
},
|
|
202
204
|
...props,
|
|
203
|
-
cellRenderer: GridCellRenderer,
|
|
205
|
+
cellRenderer: typeof props.cellRenderer === "string" ? props.cellRenderer : GridCellRenderer,
|
|
204
206
|
cellRendererParams: {
|
|
205
207
|
originalCellRenderer: props.cellRenderer,
|
|
206
208
|
...props.cellRendererParams,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CellClickedEvent } from "ag-grid-community";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
5
|
+
* This passes the event to the checkbox when you click anywhere in the cell.
|
|
6
|
+
*/
|
|
7
|
+
export const clickInputWhenContainingCellClicked = ({ data, event, colDef }: CellClickedEvent) => {
|
|
8
|
+
if (!data || !event) return;
|
|
9
|
+
|
|
10
|
+
const element = event.target as Element;
|
|
11
|
+
// Already handled
|
|
12
|
+
if (["BUTTON", "INPUT"].includes(element?.tagName) && element.closest(".ag-cell-inline-editing")) return;
|
|
13
|
+
|
|
14
|
+
const row = element.closest("[row-id]");
|
|
15
|
+
if (!row) return;
|
|
16
|
+
|
|
17
|
+
const colId = colDef.colId;
|
|
18
|
+
if (!colId) return;
|
|
19
|
+
|
|
20
|
+
const clickInput = (cnt: number) => {
|
|
21
|
+
const cell = row.querySelector(`[col-id='${colId}']`);
|
|
22
|
+
if (!cell) return;
|
|
23
|
+
|
|
24
|
+
const input = cell.querySelector("input, button");
|
|
25
|
+
if (!input) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// When clicking on a cell that is not editing, the cell changes to editing and the input/button ref becomes invalid
|
|
29
|
+
// So wait until the cell is in edit mode before sending the click
|
|
30
|
+
if (!input.ownerDocument.contains(input)) {
|
|
31
|
+
if (cnt !== 0) {
|
|
32
|
+
setTimeout(() => clickInput(cnt - 1));
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
input?.dispatchEvent(event);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
setTimeout(() => clickInput(20), 10);
|
|
40
|
+
};
|
|
@@ -45,6 +45,7 @@ export interface GridFormDropDownProps<TData extends GridBaseRow> extends CellEd
|
|
|
45
45
|
| "GridPopoverEditDropDown-containerMedium"
|
|
46
46
|
| "GridPopoverEditDropDown-containerLarge"
|
|
47
47
|
| "GridPopoverEditDropDown-containerUnlimited"
|
|
48
|
+
| "GridPopoverEditDropDown-containerAutoWidth"
|
|
48
49
|
| string
|
|
49
50
|
| undefined;
|
|
50
51
|
// local means the use the local filter, otherwise it's expected options will be passed a function that takes a filter
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { CellFocusedEvent } from "ag-grid-community";
|
|
2
|
+
import { CellEditorCommon, ColDefT, GridCell } from "../GridCell";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { fnOrVar } from "../../utils/util";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { GenericCellColDef } from "../gridRender";
|
|
7
|
+
import { GridBaseRow } from "../Grid";
|
|
8
|
+
import { CustomCellEditorProps } from "ag-grid-react";
|
|
9
|
+
import { clickInputWhenContainingCellClicked } from "../clickInputWhenContainingCellClicked";
|
|
10
|
+
|
|
11
|
+
const BooleanCellRenderer = (props: CustomCellEditorProps) => {
|
|
12
|
+
const { onValueChange, value, api, node, column, colDef, data } = props;
|
|
13
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const checkFocus = (event: CellFocusedEvent) => {
|
|
17
|
+
if (event.rowIndex === node.rowIndex && event.column === column) {
|
|
18
|
+
inputRef.current?.focus();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
api.addEventListener("cellFocused", checkFocus);
|
|
22
|
+
return () => {
|
|
23
|
+
api.removeEventListener("cellFocused", checkFocus);
|
|
24
|
+
};
|
|
25
|
+
}, [api, column, node.rowIndex]);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className={clsx("ag-wrapper ag-input-wrapper ag-checkbox-input-wrapper", { "ag-checked": props.value })}>
|
|
29
|
+
<input
|
|
30
|
+
type="checkbox"
|
|
31
|
+
className="ag-input-field-input ag-checkbox-input"
|
|
32
|
+
disabled={!fnOrVar(colDef?.editable, props)}
|
|
33
|
+
ref={inputRef}
|
|
34
|
+
checked={value}
|
|
35
|
+
onChange={() => {}}
|
|
36
|
+
onClick={(e) => {
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
// cell has to be in edit mode
|
|
39
|
+
// if in non-edit mode clickInputWhenContainingCellClicked will click to put it in edit mode
|
|
40
|
+
if (!onValueChange) return;
|
|
41
|
+
const params = props?.colDef?.cellEditorParams as GridEditBooleanEditorProps<any> | undefined;
|
|
42
|
+
if (!params) return;
|
|
43
|
+
const selectedRows = [data];
|
|
44
|
+
const checked = !value;
|
|
45
|
+
onValueChange(checked);
|
|
46
|
+
params.onClick({ selectedRows, selectedRowIds: selectedRows.map((r) => r.id), checked }).then();
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export interface GridEditBooleanEditorProps<TData> extends CellEditorCommon {
|
|
54
|
+
onClick: (props: {
|
|
55
|
+
selectedRows: TData[];
|
|
56
|
+
selectedRowIds: (string | number)[];
|
|
57
|
+
checked: boolean;
|
|
58
|
+
}) => Promise<boolean>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const GridEditBoolean = <TData extends GridBaseRow>(
|
|
62
|
+
colDef: GenericCellColDef<TData, boolean>,
|
|
63
|
+
editorProps: GridEditBooleanEditorProps<TData>,
|
|
64
|
+
): ColDefT<TData> => {
|
|
65
|
+
return GridCell({
|
|
66
|
+
minWidth: 64,
|
|
67
|
+
maxWidth: 64,
|
|
68
|
+
cellRenderer: BooleanCellRenderer as any,
|
|
69
|
+
cellEditor: BooleanCellRenderer,
|
|
70
|
+
cellEditorParams: editorProps,
|
|
71
|
+
onCellClicked: clickInputWhenContainingCellClicked,
|
|
72
|
+
singleClickEdit: true,
|
|
73
|
+
resizable: false,
|
|
74
|
+
editable: true,
|
|
75
|
+
cellClass: "GridCellAlignCenter",
|
|
76
|
+
headerClass: "GridHeaderAlignCenter",
|
|
77
|
+
...colDef,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
@@ -13,6 +13,13 @@ export const GridPopoverEditDropDown = <TData extends GridBaseRow, TValue = any>
|
|
|
13
13
|
...props,
|
|
14
14
|
editorParams: {
|
|
15
15
|
...(props.editorParams as GridFormDropDownProps<TData>),
|
|
16
|
-
className: clsx(
|
|
16
|
+
className: clsx(
|
|
17
|
+
{
|
|
18
|
+
"GridPopoverEditDropDown-containerLarge": !props.editorParams?.className?.includes(
|
|
19
|
+
"GridPopoverEditDropDown-container",
|
|
20
|
+
),
|
|
21
|
+
},
|
|
22
|
+
props.editorParams?.className,
|
|
23
|
+
),
|
|
17
24
|
},
|
|
18
25
|
});
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "../../styles/GridTheme.scss";
|
|
2
|
+
import "../../styles/index.scss";
|
|
3
|
+
import "@linzjs/lui/dist/scss/base.scss";
|
|
4
|
+
|
|
5
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
7
|
+
|
|
8
|
+
import "@linzjs/lui/dist/fonts";
|
|
9
|
+
|
|
10
|
+
import { ColDefT, Grid, GridCell, GridContextProvider, GridEditBoolean, GridUpdatingContextProvider } from "../..";
|
|
11
|
+
import { waitForGridReady } from "../../utils/storybookTestUtil";
|
|
12
|
+
import { IFormTestRow } from "./FormTest";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: "Components / Grids",
|
|
16
|
+
component: Grid,
|
|
17
|
+
decorators: [
|
|
18
|
+
(Story) => (
|
|
19
|
+
<div style={{ width: 1024, height: 400 }}>
|
|
20
|
+
<GridUpdatingContextProvider>
|
|
21
|
+
<GridContextProvider>
|
|
22
|
+
<Story />
|
|
23
|
+
</GridContextProvider>
|
|
24
|
+
</GridUpdatingContextProvider>
|
|
25
|
+
</div>
|
|
26
|
+
),
|
|
27
|
+
],
|
|
28
|
+
} as Meta<typeof Grid>;
|
|
29
|
+
|
|
30
|
+
const GridPopoutEditBooleanTemplate: StoryFn<typeof Grid> = () => {
|
|
31
|
+
const [rowData, setRowData] = useState([
|
|
32
|
+
{ id: 1000, name: "IS IS DP12345", nameType: "IS", numba: "IX", plan: "DP 12345", bold: true },
|
|
33
|
+
{ id: 1001, name: "PEG V SD523", nameType: "PEG", numba: "V", plan: "SD 523", bold: false },
|
|
34
|
+
] as IFormTestRow[]);
|
|
35
|
+
|
|
36
|
+
const columnDefs: ColDefT<IFormTestRow>[] = useMemo(
|
|
37
|
+
() => [
|
|
38
|
+
GridCell({
|
|
39
|
+
field: "id",
|
|
40
|
+
headerName: "Id",
|
|
41
|
+
}),
|
|
42
|
+
GridEditBoolean(
|
|
43
|
+
{
|
|
44
|
+
field: "bold",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
onClick: async ({ selectedRowIds, checked }) => {
|
|
48
|
+
setRowData((rowData) => {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log("onchange", selectedRowIds, checked);
|
|
51
|
+
return rowData.map((row) => (selectedRowIds.includes(row.id) ? { ...row, bold: checked } : row));
|
|
52
|
+
});
|
|
53
|
+
return true;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
),
|
|
57
|
+
],
|
|
58
|
+
[],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Grid
|
|
63
|
+
columnDefs={columnDefs}
|
|
64
|
+
rowData={rowData}
|
|
65
|
+
selectable={false}
|
|
66
|
+
singleClickEdit={true}
|
|
67
|
+
rowSelection="single"
|
|
68
|
+
domLayout={"autoHeight"}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const _EditBoolean = GridPopoutEditBooleanTemplate.bind({});
|
|
74
|
+
_EditBoolean.play = waitForGridReady;
|
package/src/styles/Grid.scss
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
@use "./react-menu-customisations";
|
|
3
3
|
@use "../../node_modules/@linzjs/lui/dist/scss/Foundation/Variables/ColorVars" as colors;
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
.LabelPreferencesPanelGridCellAlignCenter .ag-wrapper {
|
|
7
|
+
margin-left: auto;
|
|
8
|
+
margin-right: auto;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.LabelPreferencesPanelGridCellAlignCenter .ag-cell-wrapper, .LabelPreferencesPanelGridCellAlignCenter .GridCell-container {
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
5
17
|
.Grid-container {
|
|
6
18
|
flex: 1;
|
|
7
19
|
width: 100%;
|
|
@@ -106,4 +118,26 @@
|
|
|
106
118
|
background-color: colors.$hint;
|
|
107
119
|
}
|
|
108
120
|
|
|
121
|
+
.GridHeaderAlignCenter .ag-header-cell-text {
|
|
122
|
+
margin-left: auto;
|
|
123
|
+
margin-right: auto;
|
|
124
|
+
}
|
|
109
125
|
|
|
126
|
+
.GridCellAlignCenter .GridCell-container {
|
|
127
|
+
display: flex;
|
|
128
|
+
justify-content: center;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.GridCellAlignCenter .ag-wrapper {
|
|
132
|
+
margin-left: auto;
|
|
133
|
+
margin-right: auto;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.GridCellAlignCenter .ag-cell-wrapper, .LabelPreferencesPanelGridCellAlignCenter .GridCell-container {
|
|
137
|
+
display: flex;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
div.ag-ltr div.ag-header-cell-resize {
|
|
142
|
+
right: -4px;
|
|
143
|
+
}
|