@linzjs/step-ag-grid 7.8.0 → 7.9.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/README.md +13 -14
- package/dist/index.css +6 -1
- package/dist/index.js +23 -15
- package/dist/index.js.map +1 -1
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +3 -1
- package/dist/step-ag-grid.esm.js +23 -15
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +12 -10
- package/src/components/GridCell.tsx +8 -2
- package/src/components/gridRender/GridRenderGenericCell.tsx +3 -1
- package/src/stories/grid/GridPopoutBearing.stories.tsx +1 -0
- package/src/stories/grid/GridReadOnly.stories.tsx +8 -1
- package/src/styles/Grid.scss +6 -1
- package/src/utils/bearing.ts +1 -1
package/package.json
CHANGED
package/src/components/Grid.tsx
CHANGED
|
@@ -200,15 +200,7 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
200
200
|
|
|
201
201
|
const onCellDoubleClick = useCallback(
|
|
202
202
|
(event: CellEvent) => {
|
|
203
|
-
|
|
204
|
-
if (!editable) return;
|
|
205
|
-
const editAction = event.colDef?.cellRendererParams?.editAction;
|
|
206
|
-
if (editAction) {
|
|
207
|
-
// Clicked row comes first in selected rows
|
|
208
|
-
editAction([event.data, ...event.api.getSelectedRows().filter((row) => row.id !== event.data.id)]);
|
|
209
|
-
} else if (!event.colDef?.cellRendererParams?.singleClickEdit) {
|
|
210
|
-
startCellEditing(event);
|
|
211
|
-
}
|
|
203
|
+
if (!invokeEditAction(event)) startCellEditing(event);
|
|
212
204
|
},
|
|
213
205
|
[startCellEditing],
|
|
214
206
|
);
|
|
@@ -222,9 +214,19 @@ export const Grid = (params: GridProps): JSX.Element => {
|
|
|
222
214
|
[startCellEditing],
|
|
223
215
|
);
|
|
224
216
|
|
|
217
|
+
const invokeEditAction = (e: CellEvent): boolean => {
|
|
218
|
+
const editAction = e.colDef?.cellRendererParams?.editAction;
|
|
219
|
+
if (!editAction) return false;
|
|
220
|
+
const editable = fnOrVar(e.colDef?.editable, e);
|
|
221
|
+
editable && editAction([e.data, ...e.api.getSelectedRows().filter((row) => row.id !== e.data.id)]);
|
|
222
|
+
return true;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
225
|
const onCellKeyPress = useCallback(
|
|
226
226
|
(e: CellEvent) => {
|
|
227
|
-
if ((e.event as KeyboardEvent).key === "Enter")
|
|
227
|
+
if ((e.event as KeyboardEvent).key === "Enter") {
|
|
228
|
+
if (!invokeEditAction(e)) startCellEditing(e);
|
|
229
|
+
}
|
|
228
230
|
},
|
|
229
231
|
[startCellEditing],
|
|
230
232
|
);
|
|
@@ -38,8 +38,8 @@ export const GridCellRenderer = (props: ICellRendererParams) => {
|
|
|
38
38
|
<span title={props.valueFormatted}>{props.valueFormatted}</span>
|
|
39
39
|
)}
|
|
40
40
|
</div>
|
|
41
|
-
{fnOrVar(props.colDef?.editable, props) && rendererParams?.
|
|
42
|
-
<div style={{ display: "flex", alignItems: "center" }}>{rendererParams?.
|
|
41
|
+
{fnOrVar(props.colDef?.editable, props) && rendererParams?.rightHoverElement && (
|
|
42
|
+
<div style={{ display: "flex", alignItems: "center" }}>{rendererParams?.rightHoverElement}</div>
|
|
43
43
|
)}
|
|
44
44
|
</>
|
|
45
45
|
</GridLoadableCell>
|
|
@@ -73,6 +73,12 @@ export const GridCell = <RowType extends GridBaseRow, Props extends CellEditorCo
|
|
|
73
73
|
cellEditor: GenericCellEditorComponentWrapper(custom),
|
|
74
74
|
}),
|
|
75
75
|
suppressKeyboardEvent: (e) => {
|
|
76
|
+
const shortcutKeys = e.colDef.cellRendererParams?.shortcutKeys ?? {};
|
|
77
|
+
const exec = shortcutKeys[e.event.key];
|
|
78
|
+
if (!e.editing && !e.event.repeat && e.event.type === "keypress" && exec) {
|
|
79
|
+
const editable = fnOrVar(e.colDef?.editable, e);
|
|
80
|
+
return editable ? exec(e) ?? true : true;
|
|
81
|
+
}
|
|
76
82
|
// It's important that aggrid doesn't trigger edit on enter
|
|
77
83
|
// as the incorrect selected rows will be returned
|
|
78
84
|
return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " "].includes(e.event.key);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ICellRendererParams } from "ag-grid-community";
|
|
2
2
|
import { GridBaseRow } from "../Grid";
|
|
3
3
|
import { ColDefT } from "../GridCell";
|
|
4
|
+
import { SuppressKeyboardEventParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
4
5
|
|
|
5
6
|
export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
|
|
6
7
|
data: RowType;
|
|
@@ -12,8 +13,9 @@ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<
|
|
|
12
13
|
|
|
13
14
|
export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
14
15
|
singleClickEdit?: boolean;
|
|
15
|
-
|
|
16
|
+
rightHoverElement?: JSX.Element | undefined;
|
|
16
17
|
editAction?: (selectedRows: RowType[]) => void;
|
|
18
|
+
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
17
19
|
warning?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
|
|
18
20
|
info?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
|
|
19
21
|
}
|
|
@@ -88,6 +88,7 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
88
88
|
{ id: 1001, bearing: "0E-12", bearingCorrection: 240 },
|
|
89
89
|
{ id: 1002, bearing: null, bearingCorrection: 355.1 },
|
|
90
90
|
{ id: 1003, bearing: null, bearingCorrection: 0 },
|
|
91
|
+
{ id: 1004, bearing: 5.0, bearingCorrection: 50.0 },
|
|
91
92
|
] as ITestRow[]);
|
|
92
93
|
|
|
93
94
|
return (
|
|
@@ -101,10 +101,17 @@ const GridReadOnlyTemplate: ComponentStory<typeof Grid> = (props: GridProps) =>
|
|
|
101
101
|
editable: true,
|
|
102
102
|
valueFormatter: () => "Double click me!",
|
|
103
103
|
cellRendererParams: {
|
|
104
|
-
|
|
104
|
+
rightHoverElement: (
|
|
105
|
+
<GridIcon icon={"ic_launch_modal"} title={"Title text"} className={"GridCell-editableIcon"} />
|
|
106
|
+
),
|
|
105
107
|
editAction: (selectedRows) => {
|
|
106
108
|
alert(`Custom edit ${selectedRows.length} row(s) selected`);
|
|
107
109
|
},
|
|
110
|
+
shortcutKeys: {
|
|
111
|
+
e: () => {
|
|
112
|
+
alert("Hi");
|
|
113
|
+
},
|
|
114
|
+
},
|
|
108
115
|
},
|
|
109
116
|
}),
|
|
110
117
|
GridPopoverMenu(
|
package/src/styles/Grid.scss
CHANGED
|
@@ -35,8 +35,13 @@
|
|
|
35
35
|
padding: 4px 8px;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.GridCell-editableIcon {
|
|
38
|
+
.ag-cell .GridCell-editableIcon {
|
|
39
39
|
fill: colors.$silver;
|
|
40
|
+
visibility: hidden;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.ag-cell:hover .GridCell-editableIcon, .ag-cell.ag-cell-focus .GridCell-editableIcon {
|
|
44
|
+
visibility: visible;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
.GridFormMessage-container {
|
package/src/utils/bearing.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const bearingCorrectionValueFormatter = (params: ValueFormatterParams): s
|
|
|
16
16
|
if (typeof value === "string") {
|
|
17
17
|
return convertDDToDMS(bearingNumberParser(value), true, true);
|
|
18
18
|
}
|
|
19
|
-
return convertDDToDMS(value, true,
|
|
19
|
+
return convertDDToDMS(value, true, false);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const bearingNumberParser = (value: string): number | null => {
|