@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 CHANGED
@@ -5,7 +5,7 @@
5
5
  ## Features
6
6
 
7
7
  - [ag-grid-community](https://www.npmjs.com/package/ag-grid-community) based grid with custom popover components
8
- implemented using a modified [react-menu](https://www.npmjs.com/package/@szhsin/react-menu).
8
+ implemented using a modified [react-menu](https://www.npmjs.com/package/@szhsin/react-menu).
9
9
  - Default components
10
10
  - Text input
11
11
  - Text area
@@ -15,7 +15,7 @@ implemented using a modified [react-menu](https://www.npmjs.com/package/@szhsin/
15
15
  - Popover message
16
16
  - Custom form
17
17
 
18
- *Please note this requires React >=17, ag-grid-community >=27, and sass.*
18
+ _Please note this requires React >=17, ag-grid-community >=27, and sass._
19
19
 
20
20
  ## Install
21
21
 
@@ -44,7 +44,7 @@ Storybook demo deployed at: https://linz.github.io/step-ag-grid/
44
44
  ```tsx
45
45
  import "@linzjs/lui/dist/scss/base.scss";
46
46
  import "@linzjs/lui/dist/fonts";
47
- import "@linzjs/step-ag-grid/dist/index.css"
47
+ import "@linzjs/step-ag-grid/dist/index.css";
48
48
  // Only required for LINZ themes otherwise import the default theme from ag-grid
49
49
  import "@linzjs/step-ag-grid/dist/GridTheme.scss";
50
50
 
@@ -55,7 +55,7 @@ import {
55
55
  ColDefT,
56
56
  GridCell,
57
57
  GridPopoverMessage,
58
- GridPopoverEditDropDown
58
+ GridPopoverEditDropDown,
59
59
  } from "@linzjs/step-ag-grid";
60
60
 
61
61
  const GridDemo = () => {
@@ -63,9 +63,10 @@ const GridDemo = () => {
63
63
  id: number;
64
64
  name: number;
65
65
  position: string;
66
- };
67
-
68
- const columnDefs: ColDefT<ITestRow>[] = useMemo(() => [
66
+ }
67
+
68
+ const columnDefs: ColDefT<ITestRow>[] = useMemo(
69
+ () => [
69
70
  GridCell({
70
71
  field: "id",
71
72
  headerName: "Id",
@@ -116,8 +117,8 @@ const GridDemo = () => {
116
117
 
117
118
  const rowData: ITestRow[] = useMemo(
118
119
  () => [
119
- { id: 1000, name: "Tom", position: "Tester" },
120
- { id: 1001, name: "Sue", position: "Developer" },
120
+ { id: 1000, name: "Tom", position: "Tester" },
121
+ { id: 1001, name: "Sue", position: "Developer" },
121
122
  ],
122
123
  [],
123
124
  );
@@ -125,13 +126,11 @@ const GridDemo = () => {
125
126
  return (
126
127
  <GridUpdatingContextProvider>
127
128
  <GridContextProvider>
128
- <Grid
129
- selectable={true}
130
- columnDefs={columnDefs}
131
- rowData={rowData}
132
- />
129
+ <Grid selectable={true} columnDefs={columnDefs} rowData={rowData} />
133
130
  </GridContextProvider>
134
131
  </GridUpdatingContextProvider>
135
132
  );
136
133
  };
137
134
  ```
135
+
136
+ Check `src\stories` for more usage examples
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
@@ -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);
@@ -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);
@@ -3931,7 +3939,7 @@ var bearingCorrectionValueFormatter = function (params) {
3931
3939
  if (typeof value === "string") {
3932
3940
  return convertDDToDMS(bearingNumberParser(value), true, true);
3933
3941
  }
3934
- return convertDDToDMS(value, true, true);
3942
+ return convertDDToDMS(value, true, false);
3935
3943
  };
3936
3944
  var bearingNumberParser = function (value) {
3937
3945
  if (value === "")