@linzjs/step-ag-grid 28.3.0 → 28.4.1

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
@@ -439,6 +439,11 @@ div.ag-ltr div.ag-header-cell-resize {
439
439
  right: -4px;
440
440
  }
441
441
 
442
+ .step-ag-grid__alert-icon {
443
+ max-width: 34px;
444
+ width: 34px;
445
+ }
446
+
442
447
  .GridCell-container {
443
448
  overflow: hidden;
444
449
  text-overflow: ellipsis;
@@ -1,5 +1,5 @@
1
- import { ColDef, EditableCallback, ICellEditorParams, ICellRendererParams } from 'ag-grid-community';
2
- import { SuppressKeyboardEventParams, ValueFormatterFunc, ValueGetterFunc } from 'ag-grid-community';
1
+ import { ColDef, EditableCallback, GetQuickFilterTextParams, ICellEditorParams, ICellRendererParams } from 'ag-grid-community';
2
+ import { SuppressKeyboardEventParams, ValueFormatterFunc, ValueFormatterParams, ValueGetterFunc } from 'ag-grid-community';
3
3
  import { ReactElement } from 'react';
4
4
  import { GridBaseRow } from './Grid';
5
5
  import { GenericCellColDef } from './gridRender';
@@ -25,7 +25,8 @@ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends Col
25
25
  editor?: (editorProps: any) => ReactElement;
26
26
  }
27
27
  export declare const suppressCellKeyboardEvents: (e: SuppressKeyboardEventParams) => any;
28
- export declare const generateFilterGetter: <TData extends GridBaseRow, ValueType>(field: string | undefined, filterValueGetter: string | ValueGetterFunc<TData, ValueType> | undefined, valueFormatter: string | ValueFormatterFunc<TData, ValueType> | undefined) => string | ValueGetterFunc<TData, ValueType> | undefined;
28
+ export declare const generateFilterGetter: <TData extends GridBaseRow, ValueType>(valueFormatter: string | ValueFormatterFunc<TData, ValueType> | undefined) => string | ((params: GetQuickFilterTextParams<TData, ValueType>) => string) | undefined;
29
+ export declare const defaultValueFormatter: ({ value }: ValueFormatterParams) => string;
29
30
  export declare const GridCell: <TData extends GridBaseRow, TValue = any, Props extends CellEditorCommon = any>(props: GenericCellColDef<TData, TValue>, custom?: {
30
31
  multiEdit?: boolean;
31
32
  preventAutoEdit?: boolean;
@@ -3235,11 +3235,8 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
3235
3235
  event.api.forEachNode(() => rowCount++);
3236
3236
  return (jsxRuntime.jsx(GridNoRowsOverlay, { loading: !rowData || params.loading === true, rowCount: rowCount, headerRowHeight: headerRowCount * rowHeight, filteredRowCount: event.api.getDisplayedRowCount(), noRowsOverlayText: params.noRowsOverlayText, noRowsMatchingOverlayText: params.noRowsMatchingOverlayText }));
3237
3237
  }, quickFilterParser: (filterStr) => {
3238
- filterStr = filterStr.trim();
3239
- const quoted = filterStr.startsWith('"');
3240
- filterStr = filterStr.replace(/^"/, '').replace(/"$/, '');
3241
- // If the user encloses the search term in quotes, treat it as an exact match otherwise split by space
3242
- return quoted ? [filterStr] : filterStr.split(' ');
3238
+ // filter is exact matches exactly groups separated by commas
3239
+ return filterStr.split(',').map((str) => str.trim());
3243
3240
  }, onModelUpdated: onModelUpdated, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: params.onRowDragEnd || !defaultPostSort ? undefined : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection, onColumnMoved: params.onColumnMoved, 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, selectionColumnDef: {
3244
3241
  suppressNavigable: params.hideSelectColumn,
3245
3242
  rowDrag: !!params.onRowDragEnd,
@@ -3334,7 +3331,7 @@ const GridCellMultiSelectClassRules = {
3334
3331
  },
3335
3332
  };
3336
3333
 
3337
- const GridIcon = (props) => (jsxRuntime.jsx(lui.LuiIcon, { name: props.icon, title: props.title, alt: props.title, size: props.size ?? 'md', className: clsx(`AgGridGenericCellRenderer-${props.icon}Icon`, props.className, props.disabled && 'GridIcon-disabled') }));
3334
+ const GridIcon = (props) => (jsxRuntime.jsx(lui.LuiIcon, { name: props.icon, title: props.title, alt: props.title, size: props.size ?? 'md', className: clsx(`step-ag-grid__alert-icon`, `AgGridGenericCellRenderer-${props.icon}Icon`, props.className, props.disabled && 'GridIcon-disabled') }));
3338
3335
 
3339
3336
  const GridLoadableCell = () => (jsxRuntime.jsx(lui.LuiMiniSpinner, { size: 22, divProps: { className: 'GridLoadableCell-container', role: 'status', 'aria-label': 'Loading' } }));
3340
3337
 
@@ -3363,24 +3360,21 @@ const suppressCellKeyboardEvents = (e) => {
3363
3360
  // as the incorrect selected rows will be returned
3364
3361
  return !['ArrowLeft', 'ArrowRight', 'ArrowDown', 'ArrowUp', 'Tab', ' ', 'Home', 'End', 'PageUp', 'PageDown'].includes(e.event.key);
3365
3362
  };
3366
- const generateFilterGetter = (field, filterValueGetter, valueFormatter) => {
3367
- if (filterValueGetter)
3368
- return filterValueGetter;
3363
+ const generateFilterGetter = (valueFormatter) => {
3369
3364
  // aggrid will default to valueGetter
3370
- if (typeof valueFormatter !== 'function' || !field)
3365
+ if (typeof valueFormatter !== 'function') {
3371
3366
  return undefined;
3372
- return (params) => {
3373
- const value = params.getValue(field);
3374
- let formattedValue = valueFormatter({ ...params, value });
3375
- // Search for null values using standard dash
3376
- if (formattedValue === '–')
3377
- formattedValue += ' -';
3378
- // Search by raw value as well as formatted
3379
- const gotValue = ['string', 'number'].includes(typeof value) ? value : undefined;
3380
- return (formattedValue + (gotValue != null && formattedValue != gotValue ? ' ' + gotValue : '')) //
3381
- .replace(/\s+/g, ' ')
3382
- .trim();
3383
- };
3367
+ }
3368
+ return (params) => valueFormatter(params);
3369
+ };
3370
+ const stringableValueFormatterTypes = ['number', 'boolean', 'string'];
3371
+ const defaultValueFormatter = ({ value }) => {
3372
+ if (value == null) {
3373
+ return '–';
3374
+ }
3375
+ return stringableValueFormatterTypes.includes(typeof value) //
3376
+ ? String(value)
3377
+ : JSON.stringify(value);
3384
3378
  };
3385
3379
  /*
3386
3380
  * All cells should use this.
@@ -3390,16 +3384,17 @@ const GridCell = (props, custom) => {
3390
3384
  // Generate a default filter value getter which uses the formatted value plus
3391
3385
  // the editable value if it's a string and different from the formatted value.
3392
3386
  // This is so that e.g. bearings can be searched for by DMS or raw number.
3393
- const valueFormatter = props.valueFormatter;
3387
+ const valueFormatter = props.valueFormatter ?? defaultValueFormatter;
3394
3388
  // FIXME
3395
- const filterValueGetter = generateFilterGetter(props.field, props.filterValueGetter, valueFormatter);
3389
+ const filterValueGetter = props.filterValueGetter ?? generateFilterGetter(valueFormatter);
3396
3390
  const exportable = props.exportable;
3397
3391
  // Can't leave this here ag-grid will complain
3398
3392
  delete props.exportable;
3399
3393
  return {
3400
- colId: props.field ?? props.field,
3394
+ // Will be overridden if specified later
3395
+ colId: props.field,
3401
3396
  headerTooltip: props.headerName,
3402
- sortable: !!(props?.field || props?.valueGetter),
3397
+ sortable: true,
3403
3398
  resizable: true,
3404
3399
  editable: props.editable ?? false,
3405
3400
  ...(custom?.editor && {
@@ -3416,18 +3411,9 @@ const GridCell = (props, custom) => {
3416
3411
  },
3417
3412
  }),
3418
3413
  // If there's a valueFormatter and no filterValueGetter then create a filterValueGetter
3419
- // FIXME
3420
- filterValueGetter: filterValueGetter,
3414
+ getQuickFilterText: filterValueGetter,
3421
3415
  // Default value formatter, otherwise react freaks out on objects
3422
- valueFormatter: (params) => {
3423
- if (params.value == null)
3424
- return '–';
3425
- const types = ['number', 'boolean', 'string'];
3426
- if (types.includes(typeof params.value))
3427
- return `${params.value}`;
3428
- else
3429
- return JSON.stringify(params.value);
3430
- },
3416
+ valueFormatter,
3431
3417
  ...props,
3432
3418
  cellRenderer: typeof props.cellRenderer === 'string' ? props.cellRenderer : GridCellRenderer,
3433
3419
  cellRendererParams: {
@@ -5939,6 +5925,7 @@ exports.bearingRangeValidator = bearingRangeValidator;
5939
5925
  exports.bearingStringValidator = bearingStringValidator;
5940
5926
  exports.bearingValueFormatter = bearingValueFormatter;
5941
5927
  exports.convertDDToDMS = convertDDToDMS;
5928
+ exports.defaultValueFormatter = defaultValueFormatter;
5942
5929
  exports.downloadCsvUseValueFormattersProcessCellCallback = downloadCsvUseValueFormattersProcessCellCallback;
5943
5930
  exports.findParentWithClass = findParentWithClass;
5944
5931
  exports.fnOrVar = fnOrVar;