@linzjs/step-ag-grid 28.4.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 +5 -0
- package/dist/src/components/GridCell.d.ts +4 -3
- package/dist/step-ag-grid.cjs +22 -32
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +22 -33
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +8 -6
- package/src/components/GridCell.test.tsx +27 -25
- package/src/components/GridCell.tsx +29 -29
- package/src/components/GridIcon.tsx +1 -0
- package/src/styles/Grid.scss +5 -0
package/dist/index.css
CHANGED
|
@@ -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>(
|
|
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;
|
package/dist/step-ag-grid.cjs
CHANGED
|
@@ -3331,7 +3331,7 @@ const GridCellMultiSelectClassRules = {
|
|
|
3331
3331
|
},
|
|
3332
3332
|
};
|
|
3333
3333
|
|
|
3334
|
-
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') }));
|
|
3335
3335
|
|
|
3336
3336
|
const GridLoadableCell = () => (jsxRuntime.jsx(lui.LuiMiniSpinner, { size: 22, divProps: { className: 'GridLoadableCell-container', role: 'status', 'aria-label': 'Loading' } }));
|
|
3337
3337
|
|
|
@@ -3360,24 +3360,21 @@ const suppressCellKeyboardEvents = (e) => {
|
|
|
3360
3360
|
// as the incorrect selected rows will be returned
|
|
3361
3361
|
return !['ArrowLeft', 'ArrowRight', 'ArrowDown', 'ArrowUp', 'Tab', ' ', 'Home', 'End', 'PageUp', 'PageDown'].includes(e.event.key);
|
|
3362
3362
|
};
|
|
3363
|
-
const generateFilterGetter = (
|
|
3364
|
-
if (filterValueGetter)
|
|
3365
|
-
return filterValueGetter;
|
|
3363
|
+
const generateFilterGetter = (valueFormatter) => {
|
|
3366
3364
|
// aggrid will default to valueGetter
|
|
3367
|
-
if (typeof valueFormatter !== 'function'
|
|
3365
|
+
if (typeof valueFormatter !== 'function') {
|
|
3368
3366
|
return undefined;
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
};
|
|
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);
|
|
3381
3378
|
};
|
|
3382
3379
|
/*
|
|
3383
3380
|
* All cells should use this.
|
|
@@ -3387,16 +3384,17 @@ const GridCell = (props, custom) => {
|
|
|
3387
3384
|
// Generate a default filter value getter which uses the formatted value plus
|
|
3388
3385
|
// the editable value if it's a string and different from the formatted value.
|
|
3389
3386
|
// This is so that e.g. bearings can be searched for by DMS or raw number.
|
|
3390
|
-
const valueFormatter = props.valueFormatter;
|
|
3387
|
+
const valueFormatter = props.valueFormatter ?? defaultValueFormatter;
|
|
3391
3388
|
// FIXME
|
|
3392
|
-
const filterValueGetter =
|
|
3389
|
+
const filterValueGetter = props.filterValueGetter ?? generateFilterGetter(valueFormatter);
|
|
3393
3390
|
const exportable = props.exportable;
|
|
3394
3391
|
// Can't leave this here ag-grid will complain
|
|
3395
3392
|
delete props.exportable;
|
|
3396
3393
|
return {
|
|
3397
|
-
|
|
3394
|
+
// Will be overridden if specified later
|
|
3395
|
+
colId: props.field,
|
|
3398
3396
|
headerTooltip: props.headerName,
|
|
3399
|
-
sortable:
|
|
3397
|
+
sortable: true,
|
|
3400
3398
|
resizable: true,
|
|
3401
3399
|
editable: props.editable ?? false,
|
|
3402
3400
|
...(custom?.editor && {
|
|
@@ -3413,18 +3411,9 @@ const GridCell = (props, custom) => {
|
|
|
3413
3411
|
},
|
|
3414
3412
|
}),
|
|
3415
3413
|
// If there's a valueFormatter and no filterValueGetter then create a filterValueGetter
|
|
3416
|
-
|
|
3417
|
-
filterValueGetter: filterValueGetter,
|
|
3414
|
+
getQuickFilterText: filterValueGetter,
|
|
3418
3415
|
// Default value formatter, otherwise react freaks out on objects
|
|
3419
|
-
valueFormatter
|
|
3420
|
-
if (params.value == null)
|
|
3421
|
-
return '–';
|
|
3422
|
-
const types = ['number', 'boolean', 'string'];
|
|
3423
|
-
if (types.includes(typeof params.value))
|
|
3424
|
-
return `${params.value}`;
|
|
3425
|
-
else
|
|
3426
|
-
return JSON.stringify(params.value);
|
|
3427
|
-
},
|
|
3416
|
+
valueFormatter,
|
|
3428
3417
|
...props,
|
|
3429
3418
|
cellRenderer: typeof props.cellRenderer === 'string' ? props.cellRenderer : GridCellRenderer,
|
|
3430
3419
|
cellRendererParams: {
|
|
@@ -5936,6 +5925,7 @@ exports.bearingRangeValidator = bearingRangeValidator;
|
|
|
5936
5925
|
exports.bearingStringValidator = bearingStringValidator;
|
|
5937
5926
|
exports.bearingValueFormatter = bearingValueFormatter;
|
|
5938
5927
|
exports.convertDDToDMS = convertDDToDMS;
|
|
5928
|
+
exports.defaultValueFormatter = defaultValueFormatter;
|
|
5939
5929
|
exports.downloadCsvUseValueFormattersProcessCellCallback = downloadCsvUseValueFormattersProcessCellCallback;
|
|
5940
5930
|
exports.findParentWithClass = findParentWithClass;
|
|
5941
5931
|
exports.fnOrVar = fnOrVar;
|