@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.
@@ -3254,7 +3254,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3254
3254
  enableClickSelection: params.enableClickSelection ?? false,
3255
3255
  mode: rowSelection == 'single' ? 'singleRow' : 'multiRow',
3256
3256
  }
3257
- : undefined, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated: onRowDataChanged, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, selectionColumnDef: selectionColumnDef, rowData: rowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, quickFilterParser: quickFilterParser, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, noRowsOverlayComponent: noRowsOverlayComponent, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragCancel: clearHighlightRowClasses, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData }) })] }));
3257
+ : undefined, rowHeight: rowHeight, animateRows: params.animateRows ?? false, rowClassRules: params.rowClassRules, getRowId: getRowId, onGridSizeChanged: onGridSizeChanged, suppressColumnVirtualisation: suppressColumnVirtualization, suppressClickEdit: true, onColumnVisible: setInitialContentSize, onRowDataUpdated: onRowDataChanged, onCellFocused: onCellFocused, onCellKeyDown: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, domLayout: params.domLayout, onColumnResized: onColumnResized, defaultColDef: defaultColDef, columnDefs: columnDefsAdjusted, selectionColumnDef: selectionColumnDef, rowData: rowData, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, quickFilterParser: quickFilterParser, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, noRowsOverlayComponent: noRowsOverlayComponent, alwaysShowVerticalScroll: params.alwaysShowVerticalScroll, isExternalFilterPresent: isExternalFilterPresent, doesExternalFilterPass: doesExternalFilterPass, maintainColumnOrder: true, preventDefaultOnContextMenu: true, onCellContextMenu: gridContextMenu.cellContextMenu, rowDragText: params.rowDragText, onRowDragCancel: clearHighlightRowClasses, onRowDragMove: onRowDragMove, onRowDragEnd: onRowDragEnd, suppressCellFocus: params.suppressCellFocus, pinnedTopRowData: params.pinnedTopRowData, pinnedBottomRowData: params.pinnedBottomRowData, onRowClicked: params.onRowClicked, onRowDoubleClicked: params.onRowDoubleClicked }) })] }));
3258
3258
  };
3259
3259
  const quickFilterParser = (filterStr) => {
3260
3260
  // filter is exact matches exactly groups separated by commas
@@ -3375,16 +3375,18 @@ const defaultValueFormatter = ({ value }) => {
3375
3375
  ? String(value)
3376
3376
  : JSON.stringify(value);
3377
3377
  };
3378
+ // ag-grid doesn't understand the custom editor, when it stops editing it thinks
3379
+ // that _it_ was editing and overwrites the user updated data
3380
+ // _but_, it only does this if the initial value of the cell was null!?
3381
+ const blockValueSetter = () => true;
3378
3382
  /*
3379
3383
  * All cells should use this.
3380
3384
  */
3381
3385
  const GridCell = (props, custom) => {
3382
- // props.field = ;
3383
3386
  // Generate a default filter value getter which uses the formatted value plus
3384
3387
  // the editable value if it's a string and different from the formatted value.
3385
3388
  // This is so that e.g. bearings can be searched for by DMS or raw number.
3386
3389
  const valueFormatter = props.valueFormatter ?? defaultValueFormatter;
3387
- // FIXME
3388
3390
  const filterValueGetter = props.filterValueGetter ?? generateFilterGetter(valueFormatter);
3389
3391
  const exportable = props.exportable;
3390
3392
  // Can't leave this here ag-grid will complain
@@ -3395,6 +3397,7 @@ const GridCell = (props, custom) => {
3395
3397
  headerTooltip: props.headerName,
3396
3398
  sortable: true,
3397
3399
  resizable: true,
3400
+ valueSetter: custom?.editor ? blockValueSetter : undefined,
3398
3401
  editable: props.editable ?? false,
3399
3402
  ...(custom?.editor && {
3400
3403
  cellClassRules: GridCellMultiSelectClassRules,
@@ -4834,12 +4837,14 @@ const GridFormTextInput = (props) => {
4834
4837
  const [value, setValue] = useState(initValue);
4835
4838
  const invalid = useCallback(() => TextInputValidator(props, value, data, {}), [data, props, value]);
4836
4839
  const save = useCallback(async (selectedRows) => {
4837
- if (invalid())
4840
+ if (invalid()) {
4838
4841
  return false;
4842
+ }
4839
4843
  const trimmedValue = value.trim();
4840
4844
  // No change, so don't save
4841
- if (initValue === trimmedValue)
4845
+ if (initValue === trimmedValue) {
4842
4846
  return true;
4847
+ }
4843
4848
  if (props.onSave) {
4844
4849
  return await props.onSave({ selectedRows, value: trimmedValue });
4845
4850
  }