Skip to content

Commit

Permalink
feat: tree add keys.disabled api
Browse files Browse the repository at this point in the history
  • Loading branch information
PengYYYYY committed Aug 16, 2023
1 parent 6dedd58 commit c041bc1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/tree/tree.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ expanded | Array | [] | Typescript:`Array<TreeNodeValue>` | N
filter | Function | - | Typescript:`(node: TreeNodeModel<T>) => boolean` | N
hover | Boolean | - | \- | N
icon | TNode | true | Typescript:`boolean \| TNode<TreeNodeModel<T>>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
keys | Object | - | Typescript:`TreeKeysType` `interface TreeKeysType { value?: string; label?: string; children?: string }`[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/tree/type.ts) | N
keys | Object | - | alias field name in data。Typescript:`TreeKeysType`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
label | TNode | true | Typescript:`string \| boolean \| TNode<TreeNodeModel<T>>`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
lazy | Boolean | true | \- | N
line | TNode | false | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
Expand Down
2 changes: 1 addition & 1 deletion src/tree/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ expanded | Array | [] | 展开的节点值。TS 类型:`Array<TreeNodeValue>`
filter | Function | - | 节点过滤方法,只呈现返回值为 true 的节点,泛型 `T` 表示树节点 TS 类型。TS 类型:`(node: TreeNodeModel<T>) => boolean` | N
hover | Boolean | - | 节点是否有悬浮状态 | N
icon | TNode | true | 节点图标,可自定义。TS 类型:`boolean \| TNode<TreeNodeModel<T>>`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
keys | Object | - | 用来定义 `value / label / children``data` 数据中对应的字段别名,示例:`{ value: 'key', label 'name', children: 'list' }`。TS 类型:`TreeKeysType` `interface TreeKeysType { value?: string; label?: string; children?: string }`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/tree/type.ts) | N
keys | Object | - | 用来定义 `value / label / disabled / children``data` 数据中对应的字段别名,示例:`{ value: 'key', label 'name', children: 'list' }`其中,disabled 待开发。。TS 类型:`TreeKeysType`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
label | TNode | true | 自定义节点内容,值为 `false` 不显示,值为 `true` 显示默认 label,值为字符串直接输出该字符串。泛型 `T` 表示树节点 TS 类型。<br/>如果期望只有点击复选框才选中,而点击节点不选中,可以使用 `label` 自定义节点,然后加上点击事件 `e.preventDefault()`,通过调整自定义节点的宽度和高度决定禁止点击选中的范围。TS 类型:`string \| boolean \| TNode<TreeNodeModel<T>>`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
lazy | Boolean | true | 延迟加载 children 为 true 的节点的子节点数据,即使 expandAll 被设置为 true,也同样延迟加载 | N
line | TNode | false | 连接线。值为 false 不显示连接线;值为 true 显示默认连接线;值类型为 Function 表示自定义连接线。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N
Expand Down
10 changes: 2 additions & 8 deletions src/tree/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* */

import { CheckboxProps } from '../checkbox';
import { TNode, TreeOptionData, TScroll } from '../common';
import { TNode, TreeOptionData, TreeKeysType, TScroll } from '../common';
import { MouseEvent, WheelEvent, DragEvent } from 'react';

export interface TdTreeProps<T extends TreeOptionData = TreeOptionData> {
Expand Down Expand Up @@ -118,7 +118,7 @@ export interface TdTreeProps<T extends TreeOptionData = TreeOptionData> {
*/
icon?: boolean | TNode<TreeNodeModel<T>>;
/**
* 用来定义 `value / label / children` 在 `data` 数据中对应的字段别名,示例:`{ value: 'key', label 'name', children: 'list' }`
* 用来定义 `value / label / disabled / children` 在 `data` 数据中对应的字段别名,示例:`{ value: 'key', label 'name', children: 'list' }`。其中,disabled 待开发。
*/
keys?: TreeKeysType;
/**
Expand Down Expand Up @@ -438,10 +438,4 @@ export interface TreeNodeModel<T extends TreeOptionData = TreeOptionData> extend
setData: (data: T) => void;
}

export interface TreeKeysType {
value?: string;
label?: string;
children?: string;
}

export type TreeNodeValue = string | number;

0 comments on commit c041bc1

Please sign in to comment.