UNPKG

hongluan-ui

Version:
339 lines (338 loc) 9.91 kB
import type { ComputedRef, Ref, ExtractPropTypes, InjectionKey, PropType } from 'vue'; import type { Indexable } from 'hongluan-ui/es/utils'; import type { PopperEffect, Placement } from 'hongluan-ui/es/components/popper'; import type SimpleTable from './simple-table.vue'; import type VirtualTable from './virtual-table.vue'; export interface ColumnType { id: string; title: string; prop: string; columnKey?: string; tooltipProps: Indexable<any>; align: 'left' | 'right' | 'center'; width: string; minWidth: string; maxWidth: string; fixed: string | { position: 'left' | 'right'; distance: string; }; slotName: string; headerSlotName: string; filter: { slotName: string; placement: Placement; popperClass: string; effect: PopperEffect; trigger: 'hover' | 'click' | 'all'; }; showTooltip: boolean; expand: { slotName: string; hideLabel: boolean; }; formatter: (row: unknown, column: ColumnType, cellValue: unknown, rowIndex: number, columnIndex: number) => any; sortable: boolean | 'descending' | 'ascending'; $show$?: boolean; level?: number; colSpan?: number; rowSpan?: number; children?: Array<ColumnType>; } export declare type RealCols = { headerRows: Array<ColumnType[]>; realCols: ColumnType[]; }; export declare type RowClassFunction = ({ row, rowIndex }: { row: unknown; rowIndex: number; }) => string; export declare type RowStyleFunction = ({ row, rowIndex }: { row: unknown; rowIndex: number; }) => Indexable<any>; export declare type CellClassFunction = ({ row, column, rowIndex, columnIndex }: { row: unknown; column: ColumnType; rowIndex: number; columnIndex: number; }) => string; export declare type CellStyleFunction = ({ row, column, rowIndex, columnIndex }: { row: unknown; column: ColumnType; rowIndex: number; columnIndex: number; }) => Indexable<any>; export declare type SpanFunction = ({ row, column, rowIndex, columnIndex }: { row: unknown; column: ColumnType; rowIndex: number; columnIndex: number; }) => [number, number] | { rowspan: number; colspan: number; }; export declare type ResizeOption = { min?: number; max?: number; }; export declare type TreeProps = { children: string; hasChildren: string; }; export declare type GetRowKey = (row: unknown) => string; export declare type LoadFunction = (row: unknown, node: { level: number; }, resolve: (children: unknown[]) => void) => Promise<unknown[]>; export declare type ScrollContainer = string | HTMLElement; export declare const simpleTableProps: { fixedHeader: BooleanConstructor; fixedFooter: BooleanConstructor; border: { type: StringConstructor; default: string; }; size: StringConstructor; hover: BooleanConstructor; crossHover: BooleanConstructor; list: BooleanConstructor; autoHeight: BooleanConstructor; tableFixed: BooleanConstructor; stripe: (BooleanConstructor | StringConstructor)[]; padding: StringConstructor; cellPadding: StringConstructor; gap: StringConstructor; gapX: StringConstructor; gapY: StringConstructor; showHeader: { type: BooleanConstructor; default: boolean; }; data: { type: PropType<any[]>; }; cols: { type: PropType<ColumnType[]>; default: () => any[]; }; rowKey: { type: PropType<string | ((row: unknown) => string)>; default: string; }; expandRowKeys: { type: PropType<string[]>; default: () => any[]; }; defaultExpandAll: { type: BooleanConstructor; default: boolean; }; rowClassName: { type: PropType<string | RowClassFunction>; default: string; }; rowStyle: { type: PropType<Indexable<any> | RowStyleFunction>; default: () => {}; }; cellClassName: { type: PropType<string | CellClassFunction>; default: string; }; cellStyle: { type: PropType<Indexable<any> | CellStyleFunction>; default: () => {}; }; headerRowClassName: { type: PropType<string | RowClassFunction>; default: string; }; headerRowStyle: { type: PropType<Indexable<any> | RowStyleFunction>; default: () => {}; }; headerCellClassName: { type: PropType<string | CellClassFunction>; default: string; }; headerCellStyle: { type: PropType<Indexable<any> | CellStyleFunction>; default: () => {}; }; spanMethod: PropType<SpanFunction>; highlightCurrentRow: BooleanConstructor; resize: { type: PropType<boolean | ResizeOption>; default: boolean; }; firstColumnIndex: { type: NumberConstructor; default: number; }; treeProps: { type: PropType<TreeProps>; default: () => { children: string; hasChildren: string; }; }; load: PropType<LoadFunction>; scrollContainer: { type: PropType<ScrollContainer>; }; }; export declare type SimpleTableProps = ExtractPropTypes<typeof simpleTableProps>; export declare type SimpleTableInstance = InstanceType<typeof SimpleTable>; export declare type SimpleTableContext = { rowClassName: Ref<string | RowClassFunction>; rowStyle: Ref<Indexable<any>>; cellClassName: Ref<string | CellClassFunction>; cellStyle: Ref<Indexable<any>>; hoverColIndex: Ref<string | number>; firstColumnIndex: Ref<number>; load: LoadFunction; getSpan: (args: any) => any; currentSelectedRow: Ref<unknown>; slotNames: ComputedRef<string[]>; expandSlotNames: ComputedRef<string[]>; realColsInfo: ComputedRef<RealCols>; getRowKey: GetRowKey; toggleExpandRow: (row: unknown, slotName: string) => void; expandedKeyExisted: (row: unknown, slotName: string) => boolean; isShowTooltipMap: Ref<Indexable<boolean>>; tdMouseover: (e: Event, rowIndex: number, colIndex: number) => void; tdMouseleave: () => void; tableTreeMap: Ref<Indexable<Indexable<any>>>; hasChildren: (row: unknown) => boolean; hasTreeData: ComputedRef<boolean>; toggleExpandTree: (row: unknown) => void; isShowCol: (col: ColumnType) => boolean; getColFixed: (col: ColumnType, columnIndex?: number) => { position: string; distance: string | number; hasShadow: boolean; }; }; export declare const simpleTableContextKey: InjectionKey<SimpleTableContext>; export declare const virtualTableProps: { height: { type: (StringConstructor | NumberConstructor)[]; default: number; }; itemSize: { type: NumberConstructor; default: number; }; total: NumberConstructor; scrollbarAlwaysOn: { type: BooleanConstructor; default: boolean; }; cache: { type: NumberConstructor; default: number; }; fixedHeader: BooleanConstructor; fixedFooter: BooleanConstructor; border: { type: StringConstructor; default: string; }; size: StringConstructor; hover: BooleanConstructor; crossHover: BooleanConstructor; list: BooleanConstructor; autoHeight: BooleanConstructor; tableFixed: BooleanConstructor; stripe: (BooleanConstructor | StringConstructor)[]; padding: StringConstructor; cellPadding: StringConstructor; gap: StringConstructor; gapX: StringConstructor; gapY: StringConstructor; showHeader: { type: BooleanConstructor; default: boolean; }; data: { type: PropType<any[]>; }; cols: { type: PropType<ColumnType[]>; default: () => any[]; }; rowKey: { type: PropType<string | ((row: unknown) => string)>; default: string; }; expandRowKeys: { type: PropType<string[]>; default: () => any[]; }; defaultExpandAll: { type: BooleanConstructor; default: boolean; }; rowClassName: { type: PropType<string | RowClassFunction>; default: string; }; rowStyle: { type: PropType<Indexable<any> | RowStyleFunction>; default: () => {}; }; cellClassName: { type: PropType<string | CellClassFunction>; default: string; }; cellStyle: { type: PropType<Indexable<any> | CellStyleFunction>; default: () => {}; }; headerRowClassName: { type: PropType<string | RowClassFunction>; default: string; }; headerRowStyle: { type: PropType<Indexable<any> | RowStyleFunction>; default: () => {}; }; headerCellClassName: { type: PropType<string | CellClassFunction>; default: string; }; headerCellStyle: { type: PropType<Indexable<any> | CellStyleFunction>; default: () => {}; }; spanMethod: PropType<SpanFunction>; highlightCurrentRow: BooleanConstructor; resize: { type: PropType<boolean | ResizeOption>; default: boolean; }; firstColumnIndex: { type: NumberConstructor; default: number; }; treeProps: { type: PropType<TreeProps>; default: () => { children: string; hasChildren: string; }; }; load: PropType<LoadFunction>; scrollContainer: { type: PropType<ScrollContainer>; }; }; export declare type VirtualTableProps = ExtractPropTypes<typeof virtualTableProps>; export declare type VirtualTableInstance = InstanceType<typeof VirtualTable>; export declare type VirtualTableContext = { isShowCol: (col: ColumnType) => boolean; getColFixed: (col: ColumnType) => { position: string; distance: string | number; }; };