@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 CHANGED
@@ -343,8 +343,13 @@
343
343
  padding: 4px 8px;
344
344
  }
345
345
 
346
- .GridCell-editableIcon {
346
+ .ag-cell .GridCell-editableIcon {
347
347
  fill: #beb9b4;
348
+ visibility: hidden;
349
+ }
350
+
351
+ .ag-cell:hover .GridCell-editableIcon, .ag-cell.ag-cell-focus .GridCell-editableIcon {
352
+ visibility: visible;
348
353
  }
349
354
 
350
355
  .GridFormMessage-container {
package/dist/index.js CHANGED
@@ -2690,12 +2690,12 @@ var GridHeaderSelect = function (_a) {
2690
2690
  * Wrapper for AgGrid to add commonly used functionality.
2691
2691
  */
2692
2692
  var Grid = function (params) {
2693
- var _a, _b;
2694
- var _c = React.useContext(GridContext), gridReady = _c.gridReady, setGridApi = _c.setGridApi, setQuickFilter = _c.setQuickFilter, ensureRowVisible = _c.ensureRowVisible, selectRowsById = _c.selectRowsById, ensureSelectedRowIsVisible = _c.ensureSelectedRowIsVisible, sizeColumnsToFit = _c.sizeColumnsToFit;
2693
+ var _a, _b, _c;
2694
+ var _d = React.useContext(GridContext), gridReady = _d.gridReady, setGridApi = _d.setGridApi, setQuickFilter = _d.setQuickFilter, ensureRowVisible = _d.ensureRowVisible, selectRowsById = _d.selectRowsById, ensureSelectedRowIsVisible = _d.ensureSelectedRowIsVisible, sizeColumnsToFit = _d.sizeColumnsToFit;
2695
2695
  var checkUpdating = React.useContext(GridUpdatingContext).checkUpdating;
2696
- var _d = React.useState(""), internalQuickFilter = _d[0], setInternalQuickFilter = _d[1];
2696
+ var _e = React.useState(""), internalQuickFilter = _e[0], setInternalQuickFilter = _e[1];
2697
2697
  var lastSelectedIds = React.useRef([]);
2698
- var _e = React.useState(false), staleGrid = _e[0], setStaleGrid = _e[1];
2698
+ var _f = React.useState(false), staleGrid = _f[0], setStaleGrid = _f[1];
2699
2699
  var postSortRows = usePostSortRowsHook({ setStaleGrid: setStaleGrid });
2700
2700
  /**
2701
2701
  * AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
@@ -2815,18 +2815,8 @@ var Grid = function (params) {
2815
2815
  }
2816
2816
  }, [checkUpdating]);
2817
2817
  var onCellDoubleClick = React.useCallback(function (event) {
2818
- var _a, _b, _c, _d, _e;
2819
- var editable = fnOrVar((_a = event.colDef) === null || _a === void 0 ? void 0 : _a.editable, event);
2820
- if (!editable)
2821
- return;
2822
- var editAction = (_c = (_b = event.colDef) === null || _b === void 0 ? void 0 : _b.cellRendererParams) === null || _c === void 0 ? void 0 : _c.editAction;
2823
- if (editAction) {
2824
- // Clicked row comes first in selected rows
2825
- editAction(__spreadArray([event.data], event.api.getSelectedRows().filter(function (row) { return row.id !== event.data.id; }), true));
2826
- }
2827
- else if (!((_e = (_d = event.colDef) === null || _d === void 0 ? void 0 : _d.cellRendererParams) === null || _e === void 0 ? void 0 : _e.singleClickEdit)) {
2818
+ if (!invokeEditAction(event))
2828
2819
  startCellEditing(event);
2829
- }
2830
2820
  }, [startCellEditing]);
2831
2821
  var onCellClicked = React.useCallback(function (event) {
2832
2822
  var _a, _b;
@@ -2834,9 +2824,20 @@ var Grid = function (params) {
2834
2824
  startCellEditing(event);
2835
2825
  }
2836
2826
  }, [startCellEditing]);
2827
+ var invokeEditAction = function (e) {
2828
+ var _a, _b, _c;
2829
+ var editAction = (_b = (_a = e.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.editAction;
2830
+ if (!editAction)
2831
+ return false;
2832
+ var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
2833
+ editable && editAction(__spreadArray([e.data], e.api.getSelectedRows().filter(function (row) { return row.id !== e.data.id; }), true));
2834
+ return true;
2835
+ };
2837
2836
  var onCellKeyPress = React.useCallback(function (e) {
2838
- if (e.event.key === "Enter")
2839
- startCellEditing(e);
2837
+ if (e.event.key === "Enter") {
2838
+ if (!invokeEditAction(e))
2839
+ startCellEditing(e);
2840
+ }
2840
2841
  }, [startCellEditing]);
2841
2842
  var onCellEditingStopped = React.useCallback(function (event) {
2842
2843
  refreshSelectedRows(event);
@@ -2852,7 +2853,7 @@ var Grid = function (params) {
2852
2853
  }, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
2853
2854
  return (jsxRuntime.jsxs("div", __assign({ "data-testid": params["data-testid"], className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.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) {
2854
2855
  setInternalQuickFilter(event.target.value);
2855
- } }) }))), jsxRuntime.jsx(agGridReact.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: (_b = params.postSortRows) !== null && _b !== void 0 ? _b : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
2856
+ } }) }))), jsxRuntime.jsx(agGridReact.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 })] })));
2856
2857
  };
2857
2858
 
2858
2859
  var GridCellMultiSelectClassRules = {
@@ -2881,7 +2882,7 @@ var GridCellRenderer = function (props) {
2881
2882
  var warningText = warningFn ? warningFn(props) : undefined;
2882
2883
  var infoFn = rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.info;
2883
2884
  var infoText = infoFn ? infoFn(props) : undefined;
2884
- return (jsxRuntime.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: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [typeof warningText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_info", title: infoText }), jsxRuntime.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) ? (jsxRuntime.jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))) : (jsxRuntime.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.editableIcon) && (jsxRuntime.jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.editableIcon })))] }) })));
2885
+ return (jsxRuntime.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: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [typeof warningText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_info", title: infoText }), jsxRuntime.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) ? (jsxRuntime.jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))) : (jsxRuntime.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) && (jsxRuntime.jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.rightHoverElement })))] }) })));
2885
2886
  };
2886
2887
  /*
2887
2888
  * All cells should use this
@@ -2893,6 +2894,13 @@ var GridCell = function (props, custom) {
2893
2894
  editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
2894
2895
  cellEditor: GenericCellEditorComponentWrapper(custom)
2895
2896
  })), { suppressKeyboardEvent: function (e) {
2897
+ var _a, _b, _c, _d;
2898
+ var shortcutKeys = (_b = (_a = e.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.shortcutKeys) !== null && _b !== void 0 ? _b : {};
2899
+ var exec = shortcutKeys[e.event.key];
2900
+ if (!e.editing && !e.event.repeat && e.event.type === "keypress" && exec) {
2901
+ var editable = fnOrVar((_c = e.colDef) === null || _c === void 0 ? void 0 : _c.editable, e);
2902
+ return editable ? (_d = exec(e)) !== null && _d !== void 0 ? _d : true : true;
2903
+ }
2896
2904
  // It's important that aggrid doesn't trigger edit on enter
2897
2905
  // as the incorrect selected rows will be returned
2898
2906
  return !["ArrowLeft", "ArrowRight", "ArrowDown", "ArrowUp", "Tab", " "].includes(e.event.key);
@@ -3929,7 +3937,7 @@ var bearingCorrectionValueFormatter = function (params) {
3929
3937
  return "–";
3930
3938
  }
3931
3939
  if (typeof value === "string") {
3932
- return convertDDToDMS(bearingNumberParser(value), true, true);
3940
+ return convertDDToDMS(bearingNumberParser(value), true, false);
3933
3941
  }
3934
3942
  return convertDDToDMS(value, true, false);
3935
3943
  };