39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import { gridDateComparator } from '../hooks/features/sorting/gridSortingUtils';
|
|
import { getGridDateOperators } from './gridDateOperators';
|
|
import { GRID_STRING_COL_DEF } from './gridStringColDef';
|
|
import { renderEditDateCell } from '../components/cell/GridEditDateCell';
|
|
export function gridDateFormatter({
|
|
value
|
|
}) {
|
|
if (value instanceof Date) {
|
|
return value.toLocaleDateString();
|
|
}
|
|
|
|
return value ?? '';
|
|
}
|
|
export function gridDateTimeFormatter({
|
|
value
|
|
}) {
|
|
if (value instanceof Date) {
|
|
return value.toLocaleString();
|
|
}
|
|
|
|
return value ?? '';
|
|
}
|
|
export const GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
type: 'date',
|
|
sortComparator: gridDateComparator,
|
|
valueFormatter: gridDateFormatter,
|
|
filterOperators: getGridDateOperators(),
|
|
renderEditCell: renderEditDateCell,
|
|
getApplyQuickFilterFn: undefined
|
|
});
|
|
export const GRID_DATETIME_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
type: 'dateTime',
|
|
sortComparator: gridDateComparator,
|
|
valueFormatter: gridDateTimeFormatter,
|
|
filterOperators: getGridDateOperators(true),
|
|
renderEditCell: renderEditDateCell,
|
|
getApplyQuickFilterFn: undefined
|
|
}); |