mirror of
https://github.com/zhigang1992/react.git
synced 2026-01-26 22:27:03 +08:00
* refactor(table): redesign interfaces to improve the experience in TypeScript * docs: upgrade to new type exports * style: fix lint warnings
33 lines
885 B
TypeScript
33 lines
885 B
TypeScript
import React from 'react'
|
|
|
|
export type TableDataItemBase = Record<string, any>
|
|
|
|
export type TableColumnRender<Item extends TableDataItemBase> = (
|
|
value: Item[keyof Item],
|
|
rowData: Item,
|
|
rowIndex: number,
|
|
) => JSX.Element | void
|
|
|
|
export type TableAbstractColumn<TableDataItem> = {
|
|
prop: keyof TableDataItem
|
|
label: React.ReactNode | string
|
|
className: string
|
|
width?: number
|
|
renderHandler: TableColumnRender<TableDataItem>
|
|
}
|
|
|
|
export type TableOnRowClick<TableDataItem> = (
|
|
rowData: TableDataItem,
|
|
rowIndex: number,
|
|
) => void
|
|
export type TableOnCellClick<TableDataItem> = (
|
|
cellValue: TableDataItem[keyof TableDataItem],
|
|
rowIndex: number,
|
|
colunmIndex: number,
|
|
) => void
|
|
export type TableOnChange<TableDataItem> = (data: Array<TableDataItem>) => void
|
|
export type TableRowClassNameHandler<TableDataItem> = (
|
|
rowData: TableDataItem,
|
|
rowIndex: number,
|
|
) => string
|