import { ComponentPublicInstance, CSSProperties } from 'vue'; import { SearchOptions, SizeProp, TextAlignment, VerticalAlignment } from '../../declaration'; import { default as VsTable } from './VsTable.vue'; import { VsSearchInputStyleSet } from '../vs-search-input/types'; import { VsPaginationStyleSet } from '../vs-pagination/types'; import { VsSelectStyleSet } from '../vs-select/types'; declare module 'vue' { interface GlobalComponents { VsTable: typeof VsTable; } } export interface VsTableRef extends ComponentPublicInstance { expand: (index: number) => void; collapse: (index: number) => void; } export interface VsTableStyleSet extends CSSProperties { $toolbar?: CSSProperties; $search?: VsSearchInputStyleSet; $caption?: CSSProperties; $header?: CSSProperties; $stickyHeaderTop?: string; $row?: CSSProperties & { $selected?: CSSProperties; }; $cell?: CSSProperties; $pagination?: VsPaginationStyleSet; $pageSizeSelect?: VsSelectStyleSet; } export type VsTablePageSizeOption = { label: string; value: number; }; export type VsTablePageSizeOptions = VsTablePageSizeOption[]; export interface VsTablePaginationOptions { pageSizeOptions?: VsTablePageSizeOptions; showPageSizeSelect?: boolean; showingLength?: number; edgeButtons?: boolean; showTotal?: boolean; totalItemCount?: number; } type IsAny = 0 extends 1 & T ? true : false; type Join = Prev extends '' ? K : `${Prev}${Sep}${K}`; type JoinField = keyof T extends never ? string : { [K in Extract]: IsAny extends true ? Join : T[K] extends Record ? Join | JoinField> : Join; }[Extract]; type JoinDotField = JoinField; /** * NOTE: If I is `{ user: { name: { first: 'John' } } }`, then `ColumnKey` is `'user' | 'user.name' | 'user.name.first'` */ export type VsTableColumnKey = JoinDotField; export type VsTableItem = any; export type VsTableItemKey = VsTableColumnKey | ((item: I) => string | number); export declare enum VsTableSortType { NONE = 0, ASCEND = 1, DESCEND = 2 } export interface VsTableSort { key: VsTableColumnKey | ''; type: VsTableSortType; } export interface VsTableSearchOptions extends SearchOptions { extraKeys?: VsTableColumnKey[]; } export interface VsTableColumnDef { key: VsTableColumnKey; label: string; headerAlign?: TextAlignment; align?: TextAlignment; verticalAlign?: VerticalAlignment; minWidth?: SizeProp; maxWidth?: SizeProp; width?: SizeProp; sortable?: boolean; sortBy?: VsTableColumnKey; skipSearch?: boolean; transform?: (value: any, item: I) => unknown; } export interface VsTableCell { item: I; value: unknown; colKey: VsTableColumnKey; rowIdx: number; colIdx: number; } export {};