2021-02-16 10:29:08 +00:00
|
|
|
import {
|
|
|
|
|
ColumnProperties,
|
|
|
|
|
CompactMode,
|
|
|
|
|
ReactTableFilter,
|
|
|
|
|
TableStyles,
|
2021-08-25 13:20:06 +00:00
|
|
|
SortOrderTypes,
|
2021-09-09 15:10:22 +00:00
|
|
|
} from "./component/Constants";
|
2021-02-16 10:29:08 +00:00
|
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
|
|
|
|
import { WithMeta } from "widgets/MetaHOC";
|
|
|
|
|
|
|
|
|
|
export interface TableWidgetProps extends WidgetProps, WithMeta, TableStyles {
|
|
|
|
|
nextPageKey?: string;
|
|
|
|
|
prevPageKey?: string;
|
|
|
|
|
label: string;
|
|
|
|
|
searchText: string;
|
|
|
|
|
defaultSearchText: string;
|
2021-08-30 06:58:45 +00:00
|
|
|
defaultSelectedRow?: number | number[] | string;
|
2021-02-16 10:29:08 +00:00
|
|
|
tableData: Array<Record<string, unknown>>;
|
|
|
|
|
onPageChange?: string;
|
|
|
|
|
pageSize: number;
|
|
|
|
|
onRowSelected?: string;
|
|
|
|
|
onSearchTextChanged: string;
|
2021-08-25 13:20:06 +00:00
|
|
|
onSort: string;
|
2021-02-16 10:29:08 +00:00
|
|
|
selectedRowIndex?: number;
|
|
|
|
|
selectedRowIndices: number[];
|
|
|
|
|
serverSidePaginationEnabled?: boolean;
|
|
|
|
|
multiRowSelection?: boolean;
|
|
|
|
|
hiddenColumns?: string[];
|
|
|
|
|
columnOrder?: string[];
|
|
|
|
|
columnNameMap?: { [key: string]: string };
|
|
|
|
|
columnTypeMap?: {
|
|
|
|
|
[key: string]: { type: string; format: string; inputFormat?: string };
|
|
|
|
|
};
|
|
|
|
|
columnSizeMap?: { [key: string]: number };
|
|
|
|
|
filters?: ReactTableFilter[];
|
|
|
|
|
compactMode?: CompactMode;
|
|
|
|
|
primaryColumns: Record<string, ColumnProperties>;
|
|
|
|
|
derivedColumns: Record<string, ColumnProperties>;
|
2021-08-25 13:20:06 +00:00
|
|
|
sortOrder: {
|
2021-02-16 10:29:08 +00:00
|
|
|
column: string;
|
2021-08-25 13:20:06 +00:00
|
|
|
order: SortOrderTypes | null;
|
2021-02-16 10:29:08 +00:00
|
|
|
};
|
2021-08-30 09:24:59 +00:00
|
|
|
totalRecordsCount?: number;
|
2021-02-16 10:29:08 +00:00
|
|
|
}
|
2021-07-22 08:43:58 +00:00
|
|
|
|
|
|
|
|
export const getCurrentRowBinding = (
|
|
|
|
|
entityName: string,
|
|
|
|
|
userInput: string,
|
|
|
|
|
withBinding = true,
|
|
|
|
|
) => {
|
|
|
|
|
let rowBinding = `${entityName}.sanatizedTableData.map((currentRow) => ( ${userInput}))`;
|
|
|
|
|
if (withBinding) rowBinding = `{{${rowBinding}}}`;
|
|
|
|
|
return rowBinding;
|
|
|
|
|
};
|