mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-07 09:09:30 +08:00
* feat: add update to Table's actions. add test and doc fix(table): fix comments * feat(table): improve type for table actions chore: update docs chore: remove unused types chore(table): improve docs Co-authored-by: William Castandet <williamcastandet@williams-air.home> Co-authored-by: unix <unix.bio@gmail.com>
23 lines
559 B
TypeScript
23 lines
559 B
TypeScript
import React from 'react'
|
|
|
|
export type TableColumnItem = {
|
|
value: string
|
|
label: React.ReactNode | string
|
|
width?: number
|
|
}
|
|
|
|
export interface TableConfig {
|
|
columns: Array<TableColumnItem>
|
|
updateColumn?: (column: TableColumnItem) => void
|
|
removeRow?: (rowIndex: number) => void
|
|
updateRow?: (rowIndex: number, newData: any) => void
|
|
}
|
|
|
|
const defaultContext = {
|
|
columns: [],
|
|
}
|
|
|
|
export const TableContext = React.createContext<TableConfig>(defaultContext)
|
|
|
|
export const useTableContext = (): TableConfig => React.useContext<TableConfig>(TableContext)
|