UNPKG

hongluan-ui

Version:
1 lines 9.81 kB
{"version":3,"file":"simple-table2.mjs","sources":["../../../../../../packages/components/simple-table/src/simple-table.ts"],"sourcesContent":["\nimport type { ComputedRef, Ref, ExtractPropTypes, InjectionKey, PropType } from 'vue'\nimport type { Indexable } from '@hongluan-ui/utils'\nimport type { PopperEffect, Placement } from '@hongluan-ui/components/popper'\nimport type SimpleTable from './simple-table.vue'\nimport type VirtualTable from './virtual-table.vue'\n\nexport interface ColumnType {\n id: string\n title: string\n prop: string\n columnKey?: string\n tooltipProps: Indexable<any>\n align: 'left' | 'right' | 'center'\n width: string\n minWidth: string\n maxWidth: string\n fixed: string | { position: 'left' | 'right'; distance: string; }\n slotName: string\n headerSlotName: string\n filter: {\n slotName: string\n placement: Placement\n popperClass: string\n effect: PopperEffect\n trigger: 'hover' | 'click' | 'all'\n }\n showTooltip: boolean\n expand: {\n slotName: string\n hideLabel: boolean\n }\n formatter: (row: unknown, column: ColumnType, cellValue: unknown, rowIndex: number, columnIndex: number) => any\n sortable: boolean | 'descending' | 'ascending'\n $show$?: boolean // 配合列选择工具,参考业务组件\n level?: number\n colSpan?: number\n rowSpan?: number\n children?: Array<ColumnType>\n}\nexport type RealCols = { headerRows: Array<ColumnType[]>; realCols: ColumnType[]; }\n\nexport type RowClassFunction = ({ row, rowIndex }: { row: unknown; rowIndex: number; }) => string\nexport type RowStyleFunction = ({ row, rowIndex }: { row: unknown; rowIndex: number; }) => Indexable<any>\nexport type CellClassFunction = ({ row, column, rowIndex, columnIndex }: { row: unknown; column: ColumnType; rowIndex: number; columnIndex: number; }) => string\nexport type CellStyleFunction = ({ row, column, rowIndex, columnIndex }: { row: unknown; column: ColumnType; rowIndex: number; columnIndex: number; }) => Indexable<any>\nexport type SpanFunction = ({ row, column, rowIndex, columnIndex }: { row: unknown; column: ColumnType; rowIndex: number; columnIndex: number; }) => [number, number] | { rowspan: number; colspan: number; }\nexport type ResizeOption = { min?: number; max?: number; }\nexport type TreeProps = { children: string; hasChildren: string; }\nexport type GetRowKey = (row: unknown) => string\nexport type LoadFunction = (row: unknown, node: { level: number; }, resolve: (children: unknown[]) => void) => Promise<unknown[]>\nexport type ScrollContainer = string | HTMLElement\n\nexport const simpleTableProps = {\n fixedHeader: Boolean,\n fixedFooter: Boolean,\n border: {\n type: String,\n default: '',\n },\n size: String,\n hover: Boolean,\n crossHover: Boolean,\n list: Boolean,\n autoHeight: Boolean,\n tableFixed: Boolean,\n stripe: [Boolean, String],\n padding: String,\n cellPadding: String,\n gap: String,\n gapX: String,\n gapY: String,\n showHeader: {\n type: Boolean,\n default: true,\n },\n data: {\n type: Array as PropType<any[]>,\n },\n cols: {\n type: Array as PropType<ColumnType[]>,\n default: () => [],\n },\n rowKey: {\n type: [String, Function] as PropType<string | ((row: unknown) => string)>,\n default: 'id',\n },\n expandRowKeys: {\n type: Array as PropType<string[]>,\n default: () => [],\n },\n defaultExpandAll: {\n type: Boolean,\n default: false,\n },\n rowClassName: {\n type: [String, Function] as PropType<string | RowClassFunction>,\n default: '',\n },\n rowStyle: {\n type: [Object, Function] as PropType<Indexable<any> | RowStyleFunction>,\n default: () => ({}),\n },\n cellClassName: {\n type: [String, Function] as PropType<string | CellClassFunction>,\n default: '',\n },\n cellStyle: {\n type: [Object, Function] as PropType<Indexable<any> | CellStyleFunction>,\n default: () => ({}),\n },\n headerRowClassName: {\n type: [String, Function] as PropType<string | RowClassFunction>,\n default: '',\n },\n headerRowStyle: {\n type: [Object, Function] as PropType<Indexable<any> | RowStyleFunction>,\n default: () => ({}),\n },\n headerCellClassName: {\n type: [String, Function] as PropType<string | CellClassFunction>,\n default: '',\n },\n headerCellStyle: {\n type: [Object, Function] as PropType<Indexable<any> | CellStyleFunction>,\n default: () => ({}),\n },\n spanMethod: Function as PropType<SpanFunction>,\n highlightCurrentRow: Boolean,\n resize: {\n type: [Boolean, Object] as PropType<boolean | ResizeOption>,\n default: false,\n },\n firstColumnIndex: {\n type: Number,\n default: 0,\n },\n treeProps: {\n type: Object as PropType<TreeProps>,\n default: () => ({ children: 'children', hasChildren: 'hasChildren' }),\n },\n load: Function as PropType<LoadFunction>,\n scrollContainer: {\n type: [String, Object] as PropType<ScrollContainer>,\n },\n}\n\nexport type SimpleTableProps = ExtractPropTypes<typeof simpleTableProps>\nexport type SimpleTableInstance = InstanceType<typeof SimpleTable>\n\nexport type SimpleTableContext = {\n rowClassName: Ref<string | RowClassFunction>\n rowStyle: Ref<Indexable<any>>\n cellClassName: Ref<string | CellClassFunction>\n cellStyle: Ref<Indexable<any>>\n hoverColIndex: Ref<string | number>\n firstColumnIndex: Ref<number>\n load: LoadFunction\n getSpan: (args: any) => any\n currentSelectedRow: Ref<unknown>\n slotNames: ComputedRef<string[]>\n expandSlotNames: ComputedRef<string[]>\n realColsInfo: ComputedRef<RealCols>\n getRowKey: GetRowKey\n toggleExpandRow: (row: unknown, slotName: string) => void\n expandedKeyExisted: (row: unknown, slotName: string) => boolean\n isShowTooltipMap: Ref<Indexable<boolean>>\n tdMouseover: (e: Event, rowIndex: number, colIndex: number) => void\n tdMouseleave: () => void\n tableTreeMap: Ref<Indexable<Indexable<any>>>\n hasChildren: (row: unknown) => boolean\n hasTreeData: ComputedRef<boolean>\n toggleExpandTree: (row: unknown) => void\n isShowCol: (col: ColumnType) => boolean\n getColFixed: (col: ColumnType, columnIndex?: number) => { position: string; distance: string | number; hasShadow: boolean; }\n}\nexport const simpleTableContextKey: InjectionKey<SimpleTableContext> = Symbol('simpleTableContextKey')\n\nexport const virtualTableProps = {\n ...simpleTableProps,\n height: {\n type: [Number, String],\n default: 300,\n },\n itemSize: {\n type: Number,\n default: 48,\n },\n total: Number,\n scrollbarAlwaysOn: {\n type: Boolean,\n default: false,\n },\n cache: {\n type: Number,\n default: 2,\n },\n}\nexport type VirtualTableProps = ExtractPropTypes<typeof virtualTableProps>\nexport type VirtualTableInstance = InstanceType<typeof VirtualTable>\n\nexport type VirtualTableContext = {\n isShowCol: (col: ColumnType) => boolean\n getColFixed: (col: Colum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