Skip to content

Commit 976c38b

Browse files
committed
feat(Table): update mobile-react table props
1 parent 2ba7de8 commit 976c38b

10 files changed

Lines changed: 1049 additions & 135 deletions

File tree

db/TDesign.db

0 Bytes
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
:: BASE_DOC ::
2+
3+
## API
4+
5+
### BaseTable Props
6+
7+
name | type | default | description | required
8+
-- | -- | -- | -- | --
9+
className | String | - | className of component | N
10+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
11+
bordered | Boolean | false | show table bordered | N
12+
cellEmptyContent | TNode | - | Typescript: `string \| TNode<BaseTableCellParams<T>>`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
13+
columns | Array | [] | table column configs。Typescript: `Array<BaseTableCol<T>>` | N
14+
data | Array | [] | table data。Typescript: `Array<T>` | N
15+
empty | TNode | '' | empty text or empty element。Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
16+
fixedRows | Array | - | `0.16.0`。Typescript: `Array<number>` | N
17+
footerSummary | TNode | - | footer summary content。Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
18+
height | String / Number | - | table height | N
19+
loading | TNode | undefined | loading state table。Typescript: `boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
20+
loadingProps | Object | - | Typescript: `Partial<LoadingProps>`[Loading API Documents](./loading?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
21+
maxHeight | String / Number | - | table max height | N
22+
rowAttributes | Object / Array / Function | - | `0.17.0``tr` attributes。Typescript: `TableRowAttributes<T>` `type TableRowAttributes<T> = HTMLElementAttributes \| ((params: { row: T; rowIndex: number; type: 'body' \| 'foot' }) => HTMLElementAttributes) \| Array<TableRowAttributes<T>>`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
23+
rowClassName | String / Object / Array / Function | - | `0.17.0`。table `th` classname。Typescript: `ClassName \| ((params: RowClassNameParams<T>) => ClassName)` `interface RowClassNameParams<T> { row: T; rowIndex: number; rowKey?: string; type?: 'body' \| 'foot' }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
24+
rowKey | String | 'id' | required。unique key for each row data | Y
25+
rowspanAndColspan | Function | - | rowspan and colspan。Typescript: `TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T extends TableRowData = TableRowData> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
26+
showHeader | Boolean | true | show table header | N
27+
stripe | Boolean | false | show stripe style | N
28+
tableContentWidth | String | - | \- | N
29+
tableLayout | String | fixed | table-layout css properties, [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout). set value to be `fixed` on `resizable=true` please。options: auto/fixed | N
30+
verticalAlign | String | middle | vertical align。options: top/middle/bottom | N
31+
onCellClick | Function | | Typescript: `(context: BaseTableCellEventContext<T>) => void`<br/>trigger on cell clicked。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface BaseTableCellEventContext<T extends TableRowData = TableRowData> { row: T; col: BaseTableCol<T>; rowIndex: number; colIndex: number; e: MouseEvent }`<br/> | N
32+
onRowClick | Function | | Typescript: `(context: RowEventContext<T>) => void`<br/>trigger on row click。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface RowEventContext<T extends TableRowData = TableRowData> { row: T; index: number; e: MouseEvent }`<br/> | N
33+
onScroll | Function | | Typescript: `(params: { e: UIEvent }) => void`<br/>trigger on table content scroll | N
34+
35+
### BaseTableInstanceFunctions 组件实例方法
36+
37+
name | params | return | description
38+
-- | -- | -- | --
39+
className | String | - | className of component | N
40+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
41+
refreshTable | \- | \- | required
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
:: BASE_DOC ::
2+
3+
## API
4+
5+
### BaseTable Props
6+
7+
名称 | 类型 | 默认值 | 描述 | 必传
8+
-- | -- | -- | -- | --
9+
className | String | - | 类名 | N
10+
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
11+
bordered | Boolean | false | 是否显示表格边框 | N
12+
cellEmptyContent | TNode | - | 单元格数据为空时呈现的内容。TS 类型:`string \| TNode<BaseTableCellParams<T>>`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
13+
columns | Array | [] | 列配置,泛型 T 指表格数据类型。TS 类型:`Array<BaseTableCol<T>>` | N
14+
data | Array | [] | 数据源,泛型 T 指表格数据类型。TS 类型:`Array<T>` | N
15+
empty | TNode | '' | 空表格呈现样式,支持全局配置 `GlobalConfigProvider`。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
16+
fixedRows | Array | - | `0.16.0`。固定行(冻结行),示例:[M, N],表示冻结表头 M 行和表尾 N 行。M 和 N 值为 0 时,表示不冻结行。TS 类型:`Array<number>` | N
17+
footerSummary | TNode | - | 表尾总结行。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
18+
height | String / Number | - | 表格高度,超出后会出现滚动条。示例:100, '30%', '300'。值为数字类型,会自动加上单位 px。如果不是绝对固定表格高度,建议使用 `maxHeight` | N
19+
loading | TNode | undefined | 加载中状态。值为 `true` 会显示默认加载中样式,可以通过 Function 和 插槽 自定义加载状态呈现内容和样式。值为 `false` 则会取消加载状态。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
20+
loadingProps | Object | - | 透传加载组件全部属性。TS 类型:`Partial<LoadingProps>`[Loading API Documents](./loading?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
21+
maxHeight | String / Number | - | 表格最大高度,超出后会出现滚动条。示例:100, '30%', '300'。值为数字类型,会自动加上单位 px | N
22+
rowAttributes | Object / Array / Function | - | `0.17.0`。HTML 标签 `tr` 的属性。类型为 Function 时,参数说明:`params.row` 表示行数据;`params.rowIndex` 表示行下标;`params.type=body` 表示属性作用于 `tbody` 中的元素;`params.type=foot` 表示属性作用于 `tfoot` 中的元素。<br />示例一:{ draggable: true },<br />示例二:[{ draggable: true }, { title: '超出省略显示' }]。<br /> 示例三:() => [{ draggable: true }]。TS 类型:`TableRowAttributes<T>` `type TableRowAttributes<T> = HTMLElementAttributes \| ((params: { row: T; rowIndex: number; type: 'body' \| 'foot' }) => HTMLElementAttributes) \| Array<TableRowAttributes<T>>`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
23+
rowClassName | String / Object / Array / Function | - | `0.17.0`。行类名,泛型 T 指表格数据类型。`params.row` 表示行数据;`params.rowIndex` 表示行下标;`params.type=body` 表示类名作用于 `tbody` 中的元素;`params.type= tfoot` 表示类名作用于 `tfoot` 中的元素。TS 类型:`ClassName \| ((params: RowClassNameParams<T>) => ClassName)` `interface RowClassNameParams<T> { row: T; rowIndex: number; rowKey?: string; type?: 'body' \| 'foot' }`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
24+
rowKey | String | 'id' | 必需。唯一标识一行数据的字段名,来源于 `data` 中的字段。如果是字段嵌套多层,可以设置形如 `item.a.id` 的方法 | Y
25+
rowspanAndColspan | Function | - | 用于自定义合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }`。TS 类型:`TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T extends TableRowData = TableRowData> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
26+
showHeader | Boolean | true | 是否显示表头 | N
27+
stripe | Boolean | false | 是否显示斑马纹 | N
28+
tableContentWidth | String | - | 表格内容的总宽度,注意不是表格可见宽度。主要应用于 `table-layout: auto` 模式下的固定列显示。`tableContentWidth` 内容宽度的值必须大于表格可见宽度 | N
29+
tableLayout | String | fixed | 表格布局方式。可选项:auto/fixed | N
30+
verticalAlign | String | middle | 行内容上下方向对齐。可选项:top/middle/bottom | N
31+
onCellClick | Function | | TS 类型:`(context: BaseTableCellEventContext<T>) => void`<br/>单元格点击时触发。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface BaseTableCellEventContext<T extends TableRowData = TableRowData> { row: T; col: BaseTableCol<T>; rowIndex: number; colIndex: number; e: MouseEvent }`<br/> | N
32+
onRowClick | Function | | TS 类型:`(context: RowEventContext<T>) => void`<br/>行点击时触发,泛型 T 指表格数据类型。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface RowEventContext<T extends TableRowData = TableRowData> { row: T; index: number; e: MouseEvent }`<br/> | N
33+
onScroll | Function | | TS 类型:`(params: { e: UIEvent }) => void`<br/>表格内容滚动时触发 | N
34+
35+
### BaseTableInstanceFunctions 组件实例方法
36+
37+
名称 | 参数 | 返回值 | 描述
38+
-- | -- | -- | --
39+
className | String | - | 类名 | N
40+
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
41+
refreshTable | \- | \- | 必需。全部重新渲染表格
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
:: BASE_DOC ::
2+
3+
## API
4+
5+
### PrimaryTable Props
6+
7+
name | type | default | description | required
8+
-- | -- | -- | -- | --
9+
className | String | - | className of component | N
10+
style | Object | - | CSS(Cascading Style Sheets),Typescript: `React.CSSProperties` | N
11+
columns | Array | [] | table column configs。Typescript: `Array<PrimaryTableCol<T>>` | N
12+
displayColumns | Array | - | Typescript: `CheckboxGroupValue` | N
13+
defaultDisplayColumns | Array | - | uncontrolled property。Typescript: `CheckboxGroupValue` | N
14+
dragSort | String | - | dag sort。options: row/row-handler/col/row-handler-col/drag-col | N
15+
dragSortOptions | Object | - | drag sort params。Typescript: `SortableOptions` | N
16+
expandIcon | TNode | true | to show expand icon. expand icon is set in first column。Typescript: `boolean \| TNode<ExpandArrowRenderParams<T>>` `interface ExpandArrowRenderParams<T> { row: T; index: number }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
17+
expandOnRowClick | Boolean | - | expand row on click | N
18+
expandedRow | TNode | - | table expanded row, to show more detail information。Typescript: `TNode<TableExpandedRowParams<T>>` `interface TableExpandedRowParams<T> { row: T; index: number; columns: PrimaryTableCol<T>[] \| BaseTableCol<T>[] }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
19+
expandedRowKeys | Array | [] | expanded row keys, row key value is from data[rowKey]。Typescript: `Array<string \| number>` | N
20+
defaultExpandedRowKeys | Array | [] | expanded row keys, row key value is from data[rowKey]。uncontrolled property。Typescript: `Array<string \| number>` | N
21+
filterIcon | TElement | - | filter icon。Typescript: `TNode<{ col: PrimaryTableCol<T>; colIndex: number }>`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
22+
filterRow | TNode | - | filter value。Typescript: `string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
23+
filterValue | Object | - | filter value。Typescript: `FilterValue` `type FilterValue = { [key: string]: any }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
24+
defaultFilterValue | Object | - | filter value。uncontrolled property。Typescript: `FilterValue` `type FilterValue = { [key: string]: any }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
25+
hideSortTips | Boolean | - | hide sort tips | N
26+
indeterminateSelectedRowKeys | Array | - | indeterminate selected row keys, row key is from data[rowKey]。Typescript: `Array<string \| number>` | N
27+
loadingMode | String | pull-refresh | Data Loading Mode。options: pull-refresh/pagination | N
28+
multipleSort | Boolean | false | support multiple column fields sort | N
29+
reserveSelectedRowOnPaginate | Boolean | true | Controls whether selected rows are retained across pagination. When enabled, selections persist across all pages, allowing batch operations on multi-page data. If set to `false`, selections are confined to the current page and do not extend to other pages. | N
30+
selectOnRowClick | Boolean | - | select row data on row click | N
31+
selectedRowKeys | Array | [] | selected row keys, row key is from data[rowKey]。Typescript: `Array<string \| number>` | N
32+
defaultSelectedRowKeys | Array | [] | selected row keys, row key is from data[rowKey]。uncontrolled property。Typescript: `Array<string \| number>` | N
33+
showSortColumnBgColor | Boolean | false | column shows sort bg color | N
34+
sort | Object / Array | - | sort configs。Typescript: `TableSort` `type TableSort = SortInfo \| Array<SortInfo>` `interface SortInfo { sortBy: string; descending: boolean }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
35+
defaultSort | Object / Array | - | sort configs。uncontrolled property。Typescript: `TableSort` `type TableSort = SortInfo \| Array<SortInfo>` `interface SortInfo { sortBy: string; descending: boolean }`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts) | N
36+
sortIcon | TElement | - | sort icon。Typescript: `TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
37+
onCellClick | Function | | Typescript: `(context: PrimaryTableCellEventContext<T>) => void`<br/>trigger on cell clicked。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface PrimaryTableCellEventContext<T> { row: T; col: PrimaryTableCol; rowIndex: number; colIndex: number; e: MouseEvent }`<br/> | N
38+
onChange | Function | | Typescript: `(data: TableChangeData, context: TableChangeContext<T>) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface TableChangeData { sorter?: TableSort; filter?: FilterValue; pagination?: PaginationProps }`<br/><br/>`interface TableChangeContext<T> { trigger: TableChangeTrigger; currentData?: T[] }`<br/><br/>`type TableChangeTrigger = 'filter' \| 'sorter' \| 'pagination'`<br/> | N
39+
onColumnChange | Function | | Typescript: `(context: PrimaryTableColumnChange<T>) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface PrimaryTableColumnChange<T> { columns?: CheckboxGroupValue; currentColumn?: PrimaryTableCol<T>; type?: 'check' \| 'uncheck'; e?: ChangeEvent }`<br/> | N
40+
onDataChange | Function | | Typescript: `(data: Array<T>, context: TableDataChangeContext) => void`<br/>trigger on data changing。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface TableDataChangeContext { trigger: 'sort' }`<br/> | N
41+
onDisplayColumnsChange | Function | | Typescript: `(value: CheckboxGroupValue) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`import { CheckboxGroupValue } from '@Checkbox'`<br/> | N
42+
onDragSort | Function | | Typescript: `(context: DragSortContext<T>) => void`<br/>trigger on drag sort。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface DragSortContext<T> { currentIndex: number; current: T; targetIndex: number; target: T; data: T[]; newData: T[]; currentData?: T[]; e: SortableEvent; sort: 'row' \| 'col' }`<br/><br/>`import { SortableEvent, SortableOptions } from 'sortablejs'`<br/> | N
43+
onExpandChange | Function | | Typescript: `(expandedRowKeys: Array<string \| number>, options: ExpandOptions<T>) => void`<br/>trigger on expand row keys changing。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface ExpandOptions<T> { expandedRowData: Array<T>; currentRowData: T }`<br/> | N
44+
onFilterChange | Function | | Typescript: `(filterValue: FilterValue, context: TableFilterChangeContext<T>) => void`<br/>trigger on filter value changing。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface TableFilterChangeContext<T> { col?: PrimaryTableCol<T>; trigger: 'filter-change' \| 'confirm' \| 'reset' \| 'clear' }`<br/> | N
45+
onSelectChange | Function | | Typescript: `(selectedRowKeys: Array<string \| number>, options: SelectOptions<T>) => void`<br/>trigger on select changing。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface SelectOptions<T> { selectedRowData: Array<T>; type: 'uncheck' \| 'check'; currentRowKey?: string; currentRowData?: T }`<br/> | N
46+
onSortChange | Function | | Typescript: `(sort: TableSort, options: SortOptions<T>) => void`<br/>trigger on sort changing。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/table/type.ts)。<br/>`interface SortOptions<T> { currentDataSource?: Array<T>; col: PrimaryTableCol }`<br/> | N

0 commit comments

Comments
 (0)