@linzjs/step-ag-grid 7.8.1 → 7.10.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/index.css +6 -1
- package/dist/index.js +28 -20
- package/dist/index.js.map +1 -1
- package/dist/src/components/Grid.d.ts +1 -0
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +3 -1
- package/dist/step-ag-grid.esm.js +28 -20
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Grid.tsx +14 -11
- package/src/components/GridCell.tsx +8 -2
- package/src/components/gridRender/GridRenderGenericCell.tsx +3 -1
- package/src/stories/grid/GridPopoutBearing.stories.tsx +1 -1
- package/src/stories/grid/GridReadOnly.stories.tsx +10 -2
- package/src/styles/Grid.scss +6 -1
- package/src/utils/bearing.ts +1 -1
|
@@ -20,6 +20,7 @@ export interface GridProps {
|
|
|
20
20
|
postSortRows?: GridOptions["postSortRows"];
|
|
21
21
|
animateRows?: boolean;
|
|
22
22
|
rowClassRules?: GridOptions["rowClassRules"];
|
|
23
|
+
rowSelection?: "single" | "multiple";
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ICellRendererParams } from "ag-grid-community";
|
|
3
3
|
import { GridBaseRow } from "../Grid";
|
|
4
4
|
import { ColDefT } from "../GridCell";
|
|
5
|
+
import { SuppressKeyboardEventParams } from "ag-grid-community/dist/lib/entities/colDef";
|
|
5
6
|
export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
|
|
6
7
|
data: RowType;
|
|
7
8
|
}
|
|
@@ -10,8 +11,9 @@ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<
|
|
|
10
11
|
}
|
|
11
12
|
export interface GenericCellRendererParams<RowType extends GridBaseRow> {
|
|
12
13
|
singleClickEdit?: boolean;
|
|
13
|
-
|
|
14
|
+
rightHoverElement?: JSX.Element | undefined;
|
|
14
15
|
editAction?: (selectedRows: RowType[]) => void;
|
|
16
|
+
shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
|
|
15
17
|
warning?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
|
|
16
18
|
info?: (props: RowICellRendererParams<RowType>) => string | boolean | null | undefined;
|
|
17
19
|
}
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2669,12 +2669,12 @@ var GridHeaderSelect = function (_a) {
|
|
|
2669
2669
|
* Wrapper for AgGrid to add commonly used functionality.
|
|
2670
2670
|
*/
|
|
2671
2671
|
var Grid = function (params) {
|
|
2672
|
-
var _a, _b;
|
|
2673
|
-
var
|
|
2672
|
+
var _a, _b, _c;
|
|
2673
|
+
var _d = useContext(GridContext), gridReady = _d.gridReady, setGridApi = _d.setGridApi, setQuickFilter = _d.setQuickFilter, ensureRowVisible = _d.ensureRowVisible, selectRowsById = _d.selectRowsById, ensureSelectedRowIsVisible = _d.ensureSelectedRowIsVisible, sizeColumnsToFit = _d.sizeColumnsToFit;
|
|
2674
2674
|
var checkUpdating = useContext(GridUpdatingContext).checkUpdating;
|
|
2675
|
-
var
|
|
2675
|
+
var _e = useState(""), internalQuickFilter = _e[0], setInternalQuickFilter = _e[1];
|
|
2676
2676
|
var lastSelectedIds = useRef([]);
|
|
2677
|
-
var
|
|
2677
|
+
var _f = useState(false), staleGrid = _f[0], setStaleGrid = _f[1];
|
|
2678
2678
|
var postSortRows = usePostSortRowsHook({ setStaleGrid: setStaleGrid });
|
|
2679
2679
|
/**
|
|
2680
2680
|
* AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
|
|
@@ -2794,18 +2794,8 @@ var Grid = function (params) {
|
|
|
2794
2794
|
}
|
|
2795
2795
|
}, [checkUpdating]);
|
|
2796
2796
|
var onCellDoubleClick = useCallback(function (event) {
|
|
2797
|
-
|
|
2798
|
-
var editable = fnOrVar((_a = event.colDef) === null || _a === void 0 ? void 0 : _a.editable, event);
|
|
2799
|
-
if (!editable)
|
|
2800
|
-
return;
|
|
2801
|
-
var editAction = (_c = (_b = event.colDef) === null || _b === void 0 ? void 0 : _b.cellRendererParams) === null || _c === void 0 ? void 0 : _c.editAction;
|
|
2802
|
-
if (editAction) {
|
|
2803
|
-
// Clicked row comes first in selected rows
|
|
2804
|
-
editAction(__spreadArray([event.data], event.api.getSelectedRows().filter(function (row) { return row.id !== event.data.id; }), true));
|
|
2805
|
-
}
|
|
2806
|
-
else if (!((_e = (_d = event.colDef) === null || _d === void 0 ? void 0 : _d.cellRendererParams) === null || _e === void 0 ? void 0 : _e.singleClickEdit)) {
|
|
2797
|
+
if (!invokeEditAction(event))
|
|
2807
2798
|
startCellEditing(event);
|
|
2808
|
-
}
|
|
2809
2799
|
}, [startCellEditing]);
|
|
2810
2800
|
var onCellClicked = useCallback(function (event) {
|
|
2811
2801
|
var _a, _b;
|
|
@@ -2813,9 +2803,20 @@ var Grid = function (params) {
|
|
|
2813
2803
|
startCellEditing(event);
|
|
2814
2804
|
}
|
|
2815
2805
|
}, [startCellEditing]);
|
|
2806
|
+
var invokeEditAction = function (e) {
|
|
2807
|
+
var _a, _b, _c;
|
|
2808
|
+
var editAction = (_b = (_a = e.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.editAction;
|
|
2809
|
+
if (!editAction)
|
|
2810
|
+
return false;
|
|
2811
|
+
var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
|
|
2812
|
+
editable && editAction(__spreadArray([e.data], e.api.getSelectedRows().filter(function (row) { return row.id !== e.data.id; }), true));
|
|
2813
|
+
return true;
|
|
2814
|
+
};
|
|
2816
2815
|
var onCellKeyPress = useCallback(function (e) {
|
|
2817
|
-
if (e.event.key === "Enter")
|
|
2818
|
-
|
|
2816
|
+
if (e.event.key === "Enter") {
|
|
2817
|
+
if (!invokeEditAction(e))
|
|
2818
|
+
startCellEditing(e);
|
|
2819
|
+
}
|
|
2819
2820
|
}, [startCellEditing]);
|
|
2820
2821
|
var onCellEditingStopped = useCallback(function (event) {
|
|
2821
2822
|
refreshSelectedRows(event);
|
|
@@ -2831,7 +2832,7 @@ var Grid = function (params) {
|
|
|
2831
2832
|
}, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
|
|
2832
2833
|
return (jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
|
|
2833
2834
|
setInternalQuickFilter(event.target.value);
|
|
2834
|
-
} }) }))), jsx(AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (
|
|
2835
|
+
} }) }))), jsx(AgGridReact, { animateRows: params.animateRows, rowClassRules: params.rowClassRules, defaultColDef: params.defaultColDef, getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: (_b = params.rowSelection) !== null && _b !== void 0 ? _b : "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_c = params.postSortRows) !== null && _c !== void 0 ? _c : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
|
|
2835
2836
|
};
|
|
2836
2837
|
|
|
2837
2838
|
var GridCellMultiSelectClassRules = {
|
|
@@ -2860,7 +2861,7 @@ var GridCellRenderer = function (props) {
|
|
|
2860
2861
|
var warningText = warningFn ? warningFn(props) : undefined;
|
|
2861
2862
|
var infoFn = rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.info;
|
|
2862
2863
|
var infoText = infoFn ? infoFn(props) : undefined;
|
|
2863
|
-
return (jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_b = (_a = colDef.field) !== null && _a !== void 0 ? _a : colDef.colId) !== null && _b !== void 0 ? _b : "", props.data.id) }, { children: jsxs(Fragment$1, { children: [typeof warningText === "string" && jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsx(GridIcon, { icon: "ic_info", title: infoText }), jsx("div", __assign({ style: { display: "flex", flex: 1, overflow: "hidden" } }, { children: ((_c = colDef === null || colDef === void 0 ? void 0 : colDef.cellRendererParams) === null || _c === void 0 ? void 0 : _c.originalCellRenderer) ? (jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))) : (jsx("span", __assign({ title: props.valueFormatted }, { children: props.valueFormatted }))) })), fnOrVar((_d = props.colDef) === null || _d === void 0 ? void 0 : _d.editable, props) && (rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.
|
|
2864
|
+
return (jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_b = (_a = colDef.field) !== null && _a !== void 0 ? _a : colDef.colId) !== null && _b !== void 0 ? _b : "", props.data.id) }, { children: jsxs(Fragment$1, { children: [typeof warningText === "string" && jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsx(GridIcon, { icon: "ic_info", title: infoText }), jsx("div", __assign({ style: { display: "flex", flex: 1, overflow: "hidden" } }, { children: ((_c = colDef === null || colDef === void 0 ? void 0 : colDef.cellRendererParams) === null || _c === void 0 ? void 0 : _c.originalCellRenderer) ? (jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))) : (jsx("span", __assign({ title: props.valueFormatted }, { children: props.valueFormatted }))) })), fnOrVar((_d = props.colDef) === null || _d === void 0 ? void 0 : _d.editable, props) && (rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.rightHoverElement) && (jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.rightHoverElement })))] }) })));
|
|
2864
2865
|
};
|
|
2865
2866
|
/*
|
|
2866
2867
|
* All cells should use this
|
|
@@ -2872,6 +2873,13 @@ var GridCell = function (props, custom) {
|
|
|
2872
2873
|
editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
|
|
2873
2874
|
cellEditor: GenericCellEditorComponentWrapper(custom)
|
|
2874
2875
|
})), { suppressKeyboardEvent: function (e) {
|
|
2876
|
+
var _a, _b, _c, _d;
|
|
2877
|
+
var shortcutKeys = (_b = (_a = e.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.shortcutKeys) !== null && _b !== void 0 ? _b : {};
|
|
2878
|
+
var exec = shortcutKeys[e.event.key];
|
|
2879
|
+
if (!e.editing && !e.event.repeat && e.event.type === "keypress" && exec) {
|
|
2880
|
+
var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
|
|
2881
|
+
return editable ? (_d = exec(e)) !== null && _d !== void 0 ? _d : true : true;
|
|
2882
|
+
}
|
|
2875
2883
|
// It's important that aggrid doesn't trigger edit on enter
|
|
2876
2884
|
// as the incorrect selected rows will be returned
|
|
2877
2885
|
return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " "].includes(e.event.key);
|
|
@@ -3908,7 +3916,7 @@ var bearingCorrectionValueFormatter = function (params) {
|
|
|
3908
3916
|
return "–";
|
|
3909
3917
|
}
|
|
3910
3918
|
if (typeof value === "string") {
|
|
3911
|
-
return convertDDToDMS(bearingNumberParser(value), true,
|
|
3919
|
+
return convertDDToDMS(bearingNumberParser(value), true, false);
|
|
3912
3920
|
}
|
|
3913
3921
|
return convertDDToDMS(value, true, false);
|
|
3914
3922
|
};
|