@linzjs/step-ag-grid 29.0.0 → 29.1.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/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": "29.0.0",
5
+ "version": "29.1.0",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -16,6 +16,8 @@ import {
16
16
  GridReadyEvent,
17
17
  ModelUpdatedEvent,
18
18
  ModuleRegistry,
19
+ RowClickedEvent,
20
+ RowDoubleClickedEvent,
19
21
  RowDragEndEvent,
20
22
  RowDragMoveEvent,
21
23
  SelectionChangedEvent,
@@ -120,6 +122,8 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
120
122
  suppressCellFocus?: boolean;
121
123
  pinnedTopRowData?: GridOptions['pinnedTopRowData'];
122
124
  pinnedBottomRowData?: GridOptions['pinnedBottomRowData'];
125
+ onRowClicked?: (event: RowClickedEvent) => void;
126
+ onRowDoubleClicked?: (event: RowDoubleClickedEvent) => void;
123
127
  }
124
128
 
125
129
  /**
@@ -806,6 +810,8 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
806
810
  suppressCellFocus={params.suppressCellFocus}
807
811
  pinnedTopRowData={params.pinnedTopRowData}
808
812
  pinnedBottomRowData={params.pinnedBottomRowData}
813
+ onRowClicked={params.onRowClicked}
814
+ onRowDoubleClicked={params.onRowDoubleClicked}
809
815
  />
810
816
  </div>
811
817
  </div>
@@ -120,6 +120,11 @@ export const defaultValueFormatter = ({ value }: ValueFormatterParams) => {
120
120
  : JSON.stringify(value);
121
121
  };
122
122
 
123
+ // ag-grid doesn't understand the custom editor, when it stops editing it thinks
124
+ // that _it_ was editing and overwrites the user updated data
125
+ // _but_, it only does this if the initial value of the cell was null!?
126
+ const blockValueSetter = () => true;
127
+
123
128
  /*
124
129
  * All cells should use this.
125
130
  */
@@ -132,12 +137,10 @@ export const GridCell = <TData extends GridBaseRow, TValue = any, Props extends
132
137
  editorParams?: Props;
133
138
  },
134
139
  ): ColDefT<TData, TValue> => {
135
- // props.field = ;
136
140
  // Generate a default filter value getter which uses the formatted value plus
137
141
  // the editable value if it's a string and different from the formatted value.
138
142
  // This is so that e.g. bearings can be searched for by DMS or raw number.
139
143
  const valueFormatter = props.valueFormatter ?? defaultValueFormatter;
140
- // FIXME
141
144
  const filterValueGetter = props.filterValueGetter ?? generateFilterGetter(valueFormatter as any);
142
145
  const exportable = props.exportable;
143
146
  // Can't leave this here ag-grid will complain
@@ -149,6 +152,7 @@ export const GridCell = <TData extends GridBaseRow, TValue = any, Props extends
149
152
  headerTooltip: props.headerName,
150
153
  sortable: true,
151
154
  resizable: true,
155
+ valueSetter: custom?.editor ? blockValueSetter : undefined,
152
156
  editable: props.editable ?? false,
153
157
  ...(custom?.editor && {
154
158
  cellClassRules: GridCellMultiSelectClassRules,
@@ -29,11 +29,15 @@ export const GridFormTextInput = <TData extends GridBaseRow>(props: GridFormText
29
29
 
30
30
  const save = useCallback(
31
31
  async (selectedRows: TData[]): Promise<boolean> => {
32
- if (invalid()) return false;
32
+ if (invalid()) {
33
+ return false;
34
+ }
33
35
 
34
36
  const trimmedValue = value.trim();
35
37
  // No change, so don't save
36
- if (initValue === trimmedValue) return true;
38
+ if (initValue === trimmedValue) {
39
+ return true;
40
+ }
37
41
 
38
42
  if (props.onSave) {
39
43
  return await props.onSave({ selectedRows, value: trimmedValue });
@@ -127,7 +127,7 @@ const GridPopoutContextMenuTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props
127
127
  sizeColumns={'auto'}
128
128
  onBulkEditingComplete={() => {
129
129
  /* eslint-disable-next-line no-console */
130
- console.log('onBulkEditingComplete');
130
+ console.log('onBulkEditingComplete()');
131
131
  }}
132
132
  contextMenu={ContextMenu}
133
133
  />
@@ -219,7 +219,7 @@ const GridPopoutEditGenericTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props
219
219
  sizeColumns={'auto'}
220
220
  onBulkEditingComplete={() => {
221
221
  /* eslint-disable-next-line no-console */
222
- console.log('Cell editing complete');
222
+ console.log('onBulkEditingComplete()');
223
223
  }}
224
224
  />
225
225
  <ActionButton icon={'ic_add'} name={'Add new row'} inProgressName={'Adding...'} onClick={addRowAction} />