@linzjs/step-ag-grid 28.4.0 → 28.4.2
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 +27 -35
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +27 -36
- 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 +36 -33
- 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
|
|
|
@@ -3343,11 +3343,13 @@ const GridCellRenderer = (props) => {
|
|
|
3343
3343
|
let warningText = props.data !== undefined && warningFn ? warningFn(props) : undefined;
|
|
3344
3344
|
const infoFn = rendererParams?.info;
|
|
3345
3345
|
let infoText = props.data !== undefined && infoFn ? infoFn(props) : undefined;
|
|
3346
|
-
if (Array.isArray(warningText))
|
|
3346
|
+
if (Array.isArray(warningText)) {
|
|
3347
3347
|
warningText = warningText.join('\n');
|
|
3348
|
-
|
|
3348
|
+
}
|
|
3349
|
+
if (Array.isArray(infoText)) {
|
|
3349
3350
|
infoText = infoText.join('\n');
|
|
3350
|
-
|
|
3351
|
+
}
|
|
3352
|
+
return checkUpdating(colDef.field ?? colDef.colId ?? '', props.data.id) ? (jsxRuntime.jsx(GridLoadableCell, {})) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!warningText && (jsxRuntime.jsx(GridIcon, { icon: 'ic_warning_outline', title: typeof warningText === 'string' ? warningText : 'Warning' })), !!infoText && jsxRuntime.jsx(GridIcon, { icon: 'ic_info_outline', title: typeof infoText === 'string' ? infoText : 'Info' }), jsxRuntime.jsx("div", { className: 'GridCell-container', children: colDef.cellRendererParams?.originalCellRenderer ? (jsxRuntime.jsx(colDef.cellRendererParams.originalCellRenderer, { ...props })) : (jsxRuntime.jsx("span", { title: props.valueFormatted ?? undefined, children: props.valueFormatted || '–' })) }), fnOrVar(colDef.editable, props) && rendererParams?.rightHoverElement && (jsxRuntime.jsx("div", { className: 'GridCell-hoverRight', children: rendererParams?.rightHoverElement }))] }));
|
|
3351
3353
|
};
|
|
3352
3354
|
const suppressCellKeyboardEvents = (e) => {
|
|
3353
3355
|
const shortcutKeys = e.colDef.cellRendererParams?.shortcutKeys ?? {};
|
|
@@ -3360,24 +3362,21 @@ const suppressCellKeyboardEvents = (e) => {
|
|
|
3360
3362
|
// as the incorrect selected rows will be returned
|
|
3361
3363
|
return !['ArrowLeft', 'ArrowRight', 'ArrowDown', 'ArrowUp', 'Tab', ' ', 'Home', 'End', 'PageUp', 'PageDown'].includes(e.event.key);
|
|
3362
3364
|
};
|
|
3363
|
-
const generateFilterGetter = (
|
|
3364
|
-
if (filterValueGetter)
|
|
3365
|
-
return filterValueGetter;
|
|
3365
|
+
const generateFilterGetter = (valueFormatter) => {
|
|
3366
3366
|
// aggrid will default to valueGetter
|
|
3367
|
-
if (typeof valueFormatter !== 'function'
|
|
3367
|
+
if (typeof valueFormatter !== 'function') {
|
|
3368
3368
|
return undefined;
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
};
|
|
3369
|
+
}
|
|
3370
|
+
return (params) => valueFormatter(params);
|
|
3371
|
+
};
|
|
3372
|
+
const stringableValueFormatterTypes = ['number', 'boolean', 'string'];
|
|
3373
|
+
const defaultValueFormatter = ({ value }) => {
|
|
3374
|
+
if (value == null) {
|
|
3375
|
+
return '–';
|
|
3376
|
+
}
|
|
3377
|
+
return stringableValueFormatterTypes.includes(typeof value) //
|
|
3378
|
+
? String(value)
|
|
3379
|
+
: JSON.stringify(value);
|
|
3381
3380
|
};
|
|
3382
3381
|
/*
|
|
3383
3382
|
* All cells should use this.
|
|
@@ -3387,16 +3386,17 @@ const GridCell = (props, custom) => {
|
|
|
3387
3386
|
// Generate a default filter value getter which uses the formatted value plus
|
|
3388
3387
|
// the editable value if it's a string and different from the formatted value.
|
|
3389
3388
|
// This is so that e.g. bearings can be searched for by DMS or raw number.
|
|
3390
|
-
const valueFormatter = props.valueFormatter;
|
|
3389
|
+
const valueFormatter = props.valueFormatter ?? defaultValueFormatter;
|
|
3391
3390
|
// FIXME
|
|
3392
|
-
const filterValueGetter =
|
|
3391
|
+
const filterValueGetter = props.filterValueGetter ?? generateFilterGetter(valueFormatter);
|
|
3393
3392
|
const exportable = props.exportable;
|
|
3394
3393
|
// Can't leave this here ag-grid will complain
|
|
3395
3394
|
delete props.exportable;
|
|
3396
3395
|
return {
|
|
3397
|
-
|
|
3396
|
+
// Will be overridden if specified later
|
|
3397
|
+
colId: props.field,
|
|
3398
3398
|
headerTooltip: props.headerName,
|
|
3399
|
-
sortable:
|
|
3399
|
+
sortable: true,
|
|
3400
3400
|
resizable: true,
|
|
3401
3401
|
editable: props.editable ?? false,
|
|
3402
3402
|
...(custom?.editor && {
|
|
@@ -3413,18 +3413,9 @@ const GridCell = (props, custom) => {
|
|
|
3413
3413
|
},
|
|
3414
3414
|
}),
|
|
3415
3415
|
// If there's a valueFormatter and no filterValueGetter then create a filterValueGetter
|
|
3416
|
-
|
|
3417
|
-
filterValueGetter: filterValueGetter,
|
|
3416
|
+
getQuickFilterText: filterValueGetter,
|
|
3418
3417
|
// 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
|
-
},
|
|
3418
|
+
valueFormatter,
|
|
3428
3419
|
...props,
|
|
3429
3420
|
cellRenderer: typeof props.cellRenderer === 'string' ? props.cellRenderer : GridCellRenderer,
|
|
3430
3421
|
cellRendererParams: {
|
|
@@ -5936,6 +5927,7 @@ exports.bearingRangeValidator = bearingRangeValidator;
|
|
|
5936
5927
|
exports.bearingStringValidator = bearingStringValidator;
|
|
5937
5928
|
exports.bearingValueFormatter = bearingValueFormatter;
|
|
5938
5929
|
exports.convertDDToDMS = convertDDToDMS;
|
|
5930
|
+
exports.defaultValueFormatter = defaultValueFormatter;
|
|
5939
5931
|
exports.downloadCsvUseValueFormattersProcessCellCallback = downloadCsvUseValueFormattersProcessCellCallback;
|
|
5940
5932
|
exports.findParentWithClass = findParentWithClass;
|
|
5941
5933
|
exports.fnOrVar = fnOrVar;
|