Skip to content

Commit

Permalink
feat(table): rowclassnameparams type extend (#433)
Browse files Browse the repository at this point in the history
* feat(table): rowclassnameparams type extend

* chore: revert deprecated change
  • Loading branch information
uyarn authored Sep 22, 2024
1 parent b3a58ce commit bd07901
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 7 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/products/tdesign-react/src/table/table.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pagination | Object | - | you can use all props of pagination component with pag
paginationAffixedBottom | Boolean / Object | - | affix props。Typescript:`boolean \| Partial<AffixProps>` | N
resizable | Boolean | false | allow to resize column width, set `tableLayout=fixed` would be better | N
rowAttributes | Object / Array / Function | - | `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-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | table `th` classname。Typescript:`ClassName \| ((params: RowClassNameParams<T>) => ClassName)` `interface RowClassNameParams<T> { row: T; rowIndex: number; type?: 'body' \| 'foot' }`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 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-react/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowKey | String | 'id' | required。unique key for each row data | Y
rowspanAndColspan | Function | - | rowspan and colspan。Typescript:`TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowspanAndColspanInFooter | Function | - | rowspan and colspan for footer。Typescript:`TableRowspanAndColspanFunc<T>` | N
Expand Down
2 changes: 1 addition & 1 deletion packages/products/tdesign-react/src/table/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pagination | Object | - | 分页配置,值为空则不显示。具体 API 参
paginationAffixedBottom | Boolean / Object | - | 分页吸底。基于 Affix 组件开发,透传全部 Affix 组件属性。TS 类型:`boolean \| Partial<AffixProps>` | N
resizable | Boolean | false | 是否允许调整列宽,设置 `tableLayout=fixed` 效果更友好,此时不允许通过 CSS 设置 `table`元素宽度,也不允许设置 `tableContentWidth`。一般不建议在列宽调整场景使用 `tableLayout: auto`。如果想要配置宽度可调整的最小值和最大值,请使用 `column.resize`,示例:`columns: [{ resize: { minWidth: 120, maxWidth: 300 } }]`。<br/> 默认规则:因列宽超出存在横向滚动条时,列宽调整仅影响当前列宽和总列宽;表格列较少没有横向滚动条时,列宽调整表现为自身宽度和相邻宽度变化 | N
rowAttributes | Object / Array / Function | - | 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-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 行类名,泛型 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; type?: 'body' \| 'foot' }`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 行类名,泛型 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-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowKey | String | 'id' | 必需。唯一标识一行数据的字段名,来源于 `data` 中的字段。如果是字段嵌套多层,可以设置形如 `item.a.id` 的方法 | Y
rowspanAndColspan | Function | - | 用于自定义合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }`。TS 类型:`TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/table/type.ts) | N
rowspanAndColspanInFooter | Function | - | 用于自定义表尾的合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }`。TS 类型:`TableRowspanAndColspanFunc<T>` | N
Expand Down
1 change: 1 addition & 0 deletions packages/products/tdesign-react/src/table/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ export type TableRowAttributes<T> =
export interface RowClassNameParams<T> {
row: T;
rowIndex: number;
rowKey?: string;
type?: 'body' | 'foot';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pagination | Object | - | you can use all props of pagination component with pag
paginationAffixedBottom | Boolean / Object | - | affix props。Typescript:`boolean \| Partial<AffixProps>` | N
resizable | Boolean | false | allow to resize column width, set `tableLayout=fixed` would be better | N
rowAttributes | Object / Array / Function | - | `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-vue-next/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | table `th` classname。Typescript:`ClassName \| ((params: RowClassNameParams<T>) => ClassName)` `interface RowClassNameParams<T> { row: T; rowIndex: number; type?: 'body' \| 'foot' }`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 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-vue-next/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowKey | String | 'id' | required。unique key for each row data | Y
rowspanAndColspan | Function | - | rowspan and colspan。Typescript:`TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowspanAndColspanInFooter | Function | - | rowspan and colspan for footer。Typescript:`TableRowspanAndColspanFunc<T>` | N
Expand Down
2 changes: 1 addition & 1 deletion packages/products/tdesign-vue-next/src/table/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pagination | Object | - | 分页配置,值为空则不显示。具体 API 参
paginationAffixedBottom | Boolean / Object | - | 分页吸底。基于 Affix 组件开发,透传全部 Affix 组件属性。TS 类型:`boolean \| Partial<AffixProps>` | N
resizable | Boolean | false | 是否允许调整列宽,设置 `tableLayout=fixed` 效果更友好,此时不允许通过 CSS 设置 `table`元素宽度,也不允许设置 `tableContentWidth`。一般不建议在列宽调整场景使用 `tableLayout: auto`。如果想要配置宽度可调整的最小值和最大值,请使用 `column.resize`,示例:`columns: [{ resize: { minWidth: 120, maxWidth: 300 } }]`。<br/> 默认规则:因列宽超出存在横向滚动条时,列宽调整仅影响当前列宽和总列宽;表格列较少没有横向滚动条时,列宽调整表现为自身宽度和相邻宽度变化 | N
rowAttributes | Object / Array / Function | - | 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-vue-next/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 行类名,泛型 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; type?: 'body' \| 'foot' }`[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 行类名,泛型 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-vue-next/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowKey | String | 'id' | 必需。唯一标识一行数据的字段名,来源于 `data` 中的字段。如果是字段嵌套多层,可以设置形如 `item.a.id` 的方法 | Y
rowspanAndColspan | Function | - | 用于自定义合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }`。TS 类型:`TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/table/type.ts) | N
rowspanAndColspanInFooter | Function | - | 用于自定义表尾的合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }`。TS 类型:`TableRowspanAndColspanFunc<T>` | N
Expand Down
1 change: 1 addition & 0 deletions packages/products/tdesign-vue-next/src/table/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ export type TableRowAttributes<T> =
export interface RowClassNameParams<T> {
row: T;
rowIndex: number;
rowKey?: string;
type?: 'body' | 'foot';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/products/tdesign-vue/src/table/table.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pagination | Object | - | you can use all props of pagination component with pag
paginationAffixedBottom | Boolean / Object | - | affix props。Typescript:`boolean \| Partial<AffixProps>` | N
resizable | Boolean | false | allow to resize column width, set `tableLayout=fixed` would be better | N
rowAttributes | Object / Array / Function | - | `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-vue/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | table `th` classname。Typescript:`ClassName \| ((params: RowClassNameParams<T>) => ClassName)` `interface RowClassNameParams<T> { row: T; rowIndex: number; type?: 'body' \| 'foot' }`[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 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-vue/blob/develop/src/common.ts)[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowKey | String | 'id' | required。unique key for each row data | Y
rowspanAndColspan | Function | - | rowspan and colspan。Typescript:`TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowspanAndColspanInFooter | Function | - | rowspan and colspan for footer。Typescript:`TableRowspanAndColspanFunc<T>` | N
Expand Down
2 changes: 1 addition & 1 deletion packages/products/tdesign-vue/src/table/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pagination | Object | - | 分页配置,值为空则不显示。具体 API 参
paginationAffixedBottom | Boolean / Object | - | 分页吸底。基于 Affix 组件开发,透传全部 Affix 组件属性。TS 类型:`boolean \| Partial<AffixProps>` | N
resizable | Boolean | false | 是否允许调整列宽,设置 `tableLayout=fixed` 效果更友好,此时不允许通过 CSS 设置 `table`元素宽度,也不允许设置 `tableContentWidth`。一般不建议在列宽调整场景使用 `tableLayout: auto`。如果想要配置宽度可调整的最小值和最大值,请使用 `column.resize`,示例:`columns: [{ resize: { minWidth: 120, maxWidth: 300 } }]`。<br/> 默认规则:因列宽超出存在横向滚动条时,列宽调整仅影响当前列宽和总列宽;表格列较少没有横向滚动条时,列宽调整表现为自身宽度和相邻宽度变化 | N
rowAttributes | Object / Array / Function | - | 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-vue/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 行类名,泛型 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; type?: 'body' \| 'foot' }`[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowClassName | String / Object / Array / Function | - | 行类名,泛型 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-vue/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowKey | String | 'id' | 必需。唯一标识一行数据的字段名,来源于 `data` 中的字段。如果是字段嵌套多层,可以设置形如 `item.a.id` 的方法 | Y
rowspanAndColspan | Function | - | 用于自定义合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }`。TS 类型:`TableRowspanAndColspanFunc<T>` `type TableRowspanAndColspanFunc<T> = (params: BaseTableCellParams<T>) => RowspanColspan` `interface RowspanColspan { colspan?: number; rowspan?: number }`[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/table/type.ts) | N
rowspanAndColspanInFooter | Function | - | 用于自定义表尾的合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }`。TS 类型:`TableRowspanAndColspanFunc<T>` | N
Expand Down
1 change: 1 addition & 0 deletions packages/products/tdesign-vue/src/table/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ export type TableRowAttributes<T> =
export interface RowClassNameParams<T> {
row: T;
rowIndex: number;
rowKey?: string;
type?: 'body' | 'foot';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -10605,7 +10605,7 @@
"create_time": "2020-12-18 03:26:16",
"update_time": "2022-03-04 14:57:28",
"event_output": null,
"custom_field_type": "ClassName | ((params: RowClassNameParams<T>) => ClassName)【interface RowClassNameParams<T> { row: T; rowIndex: number; type?: 'body' | 'foot' }】",
"custom_field_type": "ClassName | ((params: RowClassNameParams<T>) => ClassName)【interface RowClassNameParams<T> { row: T; rowIndex: number; rowKey?: string; type?: 'body' | 'foot' }】",
"syntactic_sugar": null,
"readonly": 1,
"html_attribute": 0,
Expand Down

0 comments on commit bd07901

Please sign in to comment.