-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,79 @@ | ||
import type { Component, Slot, Slots, VNode } from 'vue' | ||
import type { Component, Slot, Slots, VNode, RendererNode, RendererElement } from 'vue' | ||
|
||
export type { TableProps } from './props' | ||
|
||
/** 表格居中方式类型 */ | ||
export type TableAlign = 'left' | 'center' | 'right' | ||
|
||
/** 表格数据类型 */ | ||
export type TableData = Record<string, unknown>[] | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type TableData = Record<string, any>[] | ||
|
||
/** | ||
* @see h() https://cn.vuejs.org/api/render-function.html | ||
*/ | ||
type Children = string | number | boolean | VNode | null | Children[] | ||
|
||
export type TableRenderH = ( | ||
/** 自定义模板函数渲染返回值类型 */ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type RenderReturn = VNode<RendererNode, RendererElement, Record<string, any>> | ||
|
||
/** | ||
* 自定义模板函数渲染类型 | ||
* | ||
* 详情参考 | ||
* | ||
* @see h() https://cn.vuejs.org/api/render-function.html | ||
* | ||
* @param { string | Object } type 类型 | ||
* @param { Object } props props 传参数 | ||
* @param { Object } children 子节点 | ||
*/ | ||
export type TableRender = ( | ||
type: string | Component, | ||
props?: object | null, | ||
children?: Children | Slot | Slots | Record<string, () => unknown> | ||
) => VNode | ||
) => RenderReturn | VNode | ||
|
||
export type TableRender = ( | ||
h: TableRenderH, | ||
dataItem: Record<string, unknown>, | ||
index: number, | ||
headerItem: TableColumns | ||
) => VNode | ||
|
||
export type TableHeaderRender = ( | ||
h: TableRenderH, | ||
headerItem: TableColumns, | ||
/** | ||
* 渲染内容自定义模板方法类型 | ||
* | ||
* @param { Function } h 渲染函数 | ||
* @param { Object } row 行的每一项 | ||
* @param { Object } column 列的每一项 | ||
* @param { number } index 当前行的索引 | ||
*/ | ||
export type TableRenderData = ( | ||
h: TableRender, | ||
row: Record<string, any>, | ||
column: TableColumns, | ||
index: number | ||
) => RenderReturn | ||
|
||
/** | ||
* 渲染标题自定义模板方法类型 | ||
* | ||
* @param { Function } h 渲染函数 | ||
* @param { Object } item 每一项 | ||
* @param { number } index 当前行的索引 | ||
*/ | ||
export type TableRenderHeader = ( | ||
h: TableRender, | ||
item: TableColumns, | ||
index: number | ||
) => VNode | ||
) => RenderReturn | ||
|
||
/** 表格表头每一项配置类型 */ | ||
/** | ||
* 表格表头每一项配置类型 | ||
* | ||
* @param { string | Function } 标题 | ||
* @param { string } [key] 唯一值 | ||
* @param { number | string } [width] 宽度 | ||
* @param { Function } [render] 自定义渲染方法 | ||
*/ | ||
export interface TableColumns { | ||
title: string | TableHeaderRender | ||
title: string | TableRenderHeader | ||
key?: string | ||
width?: number | string | undefined | ||
render?: TableRender | ||
render?: TableRenderData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters