Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {
AggregateFunctions,
ColumnDataType,
ColumnModel,
ColumnSortDirection
} from 'tubular-common';
const regularOrderIdCol = new ColumnModel('OrderID', {
DataType: ColumnDataType.NUMERIC,
Filterable: true,
IsKey: true,
SortDirection: ColumnSortDirection.ASCENDING,
SortOrder: 1,
Sortable: true
});
// Column samples
const validColumnsSample = [
regularOrderIdCol,
new ColumnModel('CustomerName', {
Aggregate: AggregateFunctions.COUNT,
Filterable: true,
Searchable: true
}),
new ColumnModel('ShippedDate', {
DataType: ColumnDataType.DATE_TIME,
Filterable: true
}),
setActiveColumn: jest.fn().mockReturnValue('CustomerName'),
setInitialData: jest.fn(),
sortColumn: jest.fn().mockReturnValue('OrderID'),
updatePage: jest.fn(),
updateSearchText: jest.fn().mockReturnValue('search'),
},
state: {
activeColumn: null,
aggregate: null as any,
columns: [
new ColumnModel('OrderID', {
DataType: ColumnDataType.NUMERIC,
Filterable: true,
IsKey: true,
Label: 'Order ID',
SortDirection: ColumnSortDirection.ASCENDING,
SortOrder: 1,
Sortable: true,
}),
new ColumnModel('CustomerName', {
Aggregate: AggregateFunctions.COUNT,
Filterable: true,
Searchable: true,
}),
new ColumnModel('ShippedDate', {
DataType: ColumnDataType.DATE_TIME,
Filterable: true,
}),
new ColumnModel('ShipperCity'),
new ColumnModel('Amount', { DataType: ColumnDataType.NUMERIC }),
],
data: [
export const GridHeaderCell: React.FunctionComponent = ({
column,
sortColumn,
setActiveColumn,
}: IGridHeaderCellProps) => {
const sort = () => sortColumn(column.Name);
const handleClick = (e: any) => setActiveColumn(column, e);
const direction =
column.SortDirection === ColumnSortDirection.ASCENDING || column.SortDirection === ColumnSortDirection.NONE
? 'asc'
: 'desc';
const render = column.Sortable ? (
{column.Label}
import {
AggregateFunctions,
ColumnDataType,
ColumnModel,
ColumnSortDirection,
} from 'tubular-common';
const columns = [
new ColumnModel('OrderID', {
DataType: ColumnDataType.NUMERIC,
Filterable: true,
IsKey: true,
Label: 'Id',
SortDirection: ColumnSortDirection.ASCENDING,
SortOrder: 1,
Sortable: true,
}),
new ColumnModel('CustomerName', {
Aggregate: AggregateFunctions.COUNT,
Filterable: true,
Searchable: true,
Sortable: true,
}),
new ColumnModel('ShippedDate', {
DataType: ColumnDataType.DATE_TIME,
Filterable: true,
Sortable: true,
}),
new ColumnModel('ShipperCity'),
new ColumnModel('Amount', {