vuestic-ui
Version:
Vue 3 UI Framework
93 lines (92 loc) • 3.83 kB
TypeScript
export type DataTableAlignOptions = 'left' | 'center' | 'right';
export type DataTableVerticalAlignOptions = 'top' | 'middle' | 'bottom';
export type DataTableColumnClass = unknown | (() => unknown);
export type DataTableColumnStyle = unknown | (() => unknown);
export type DataTableSortingOrder = 'asc' | 'desc' | null;
export type DataTableSortingOptions = DataTableSortingOrder[];
export type DataTableColumn<Key = string> = {
[key: string]: any;
key: Key;
name?: string;
label?: string;
thTitle?: string;
sortable?: boolean;
sortingFn?: (a: any, b: any) => number;
displayFormatFn?: (data: any) => any;
sortingOptions?: DataTableSortingOptions;
thAlign?: DataTableAlignOptions;
thVerticalAlign?: DataTableVerticalAlignOptions;
tdAlign?: DataTableAlignOptions;
tdVerticalAlign?: DataTableVerticalAlignOptions;
width?: string | number;
thClass?: DataTableColumnClass;
tdClass?: DataTableColumnClass;
thStyle?: DataTableColumnStyle;
tdStyle?: DataTableColumnStyle;
/** @deprecated use `thTitle` instead */
headerTitle?: string;
/** @deprecated use `thAlign` instead */
alignHead?: DataTableAlignOptions;
/** @deprecated use `thVerticalAlign` instead */
verticalAlignHead?: DataTableVerticalAlignOptions;
/** @deprecated use `tdAlign` instead */
align?: DataTableAlignOptions;
/** @deprecated use `tdVerticalAlign` instead */
verticalAlign?: DataTableVerticalAlignOptions;
/** @deprecated use `tdClass` instead */
classes?: DataTableColumnClass;
/** @deprecated use `thClass` instead */
headerClasses?: DataTableColumnClass;
/** @deprecated use `tdStyle` instead */
style?: DataTableColumnStyle;
/** @deprecated use `thStyle` instead */
headerStyle?: DataTableColumnStyle;
};
export type DataTableColumnSource<Key extends string = string> = DataTableColumn<Key> | Key;
export interface DataTableColumnInternal {
[key: string]: any;
source: DataTableColumnSource;
initialIndex: number;
key: string;
name: string;
label: string;
thTitle: string;
sortable: boolean;
sortingFn: ((a: any, b: any) => number) | undefined;
displayFormatFn: ((data: any) => any) | undefined;
sortingOptions: DataTableSortingOptions;
thAlign: DataTableAlignOptions;
thVerticalAlign: DataTableVerticalAlignOptions;
tdAlign: DataTableAlignOptions;
tdVerticalAlign: DataTableVerticalAlignOptions;
width?: string | number;
tdClass?: DataTableColumnClass;
thClass?: DataTableColumnClass;
tdStyle?: DataTableColumnStyle;
thStyle?: DataTableColumnStyle;
}
export type DataTableItem<T = Record<string, any>> = T;
export type DataTableItemKey = any;
export type DataTableRowData<Item extends Record<string, any>> = Item;
export interface DataTableCell<Item extends DataTableItem = DataTableItem> {
rowIndex: number;
rowKey: DataTableItemKey;
rowData: DataTableRowData<Item>;
column: DataTableColumnInternal;
source: string;
value: string;
}
export interface DataTableRow<Item extends DataTableItem = DataTableItem> {
initialIndex: number;
itemKey: DataTableItemKey;
source: Item;
cells: DataTableCell<Item>[];
/** Same rowData as in DataTableCell */
rowData: DataTableRowData<Item>;
toggleRowDetails: (show?: boolean) => void;
isExpandableRowVisible: boolean;
}
export type DataTableFilterMethod = (source: any, cell: DataTableCell) => boolean;
export type DataTableSelectMode = 'single' | 'multiple';
export type DataTableRowBind = Record<string, string> | ((item: DataTableItem, index: number) => Record<string, string>);
export type DataTableCellBind = Record<string, string> | ((cell: any, row: DataTableItem, column: DataTableColumnInternal, index: number) => Record<string, string>);