feat: Tree support fieldNames (#31395)

* feat: Tree support fieldNames

* docs: Update desc

* chore: Update snapshot
This commit is contained in:
二货机器人 2021-07-14 14:23:50 +08:00 committed by GitHub
parent 24e416437e
commit 86c5bf6e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 129 additions and 127 deletions

View File

@ -35526,11 +35526,11 @@ exports[`ConfigProvider components Tree configProvider 1`] = `
<div>
<div
class="config-tree config-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -35589,11 +35589,11 @@ exports[`ConfigProvider components Tree configProvider 1`] = `
</div>
<div
class="config-tree config-tree-block-node config-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -35680,11 +35680,11 @@ exports[`ConfigProvider components Tree configProvider componentSize large 1`] =
<div>
<div
class="config-tree config-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -35743,11 +35743,11 @@ exports[`ConfigProvider components Tree configProvider componentSize large 1`] =
</div>
<div
class="config-tree config-tree-block-node config-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -35834,11 +35834,11 @@ exports[`ConfigProvider components Tree configProvider componentSize middle 1`]
<div>
<div
class="config-tree config-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -35897,11 +35897,11 @@ exports[`ConfigProvider components Tree configProvider componentSize middle 1`]
</div>
<div
class="config-tree config-tree-block-node config-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -35988,11 +35988,11 @@ exports[`ConfigProvider components Tree configProvider virtual and dropdownMatch
<div>
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -36051,11 +36051,11 @@ exports[`ConfigProvider components Tree configProvider virtual and dropdownMatch
</div>
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -36142,11 +36142,11 @@ exports[`ConfigProvider components Tree normal 1`] = `
<div>
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -36205,11 +36205,11 @@ exports[`ConfigProvider components Tree normal 1`] = `
</div>
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -36296,11 +36296,11 @@ exports[`ConfigProvider components Tree prefixCls 1`] = `
<div>
<div
class="prefix-Tree prefix-Tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -36359,11 +36359,11 @@ exports[`ConfigProvider components Tree prefixCls 1`] = `
</div>
<div
class="prefix-Tree prefix-Tree-block-node prefix-Tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""

View File

@ -4236,11 +4236,11 @@ exports[`renders ./components/transfer/demo/tree-transfer.md correctly 1`] = `
>
<div
class="ant-tree ant-tree-icon-hide ant-tree-block-node"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""

View File

@ -3,11 +3,11 @@
exports[`renders ./components/tree/demo/basic.md correctly 1`] = `
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -309,11 +309,11 @@ exports[`renders ./components/tree/demo/basic.md correctly 1`] = `
exports[`renders ./components/tree/demo/basic-controlled.md correctly 1`] = `
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -824,11 +824,11 @@ exports[`renders ./components/tree/demo/basic-controlled.md correctly 1`] = `
exports[`renders ./components/tree/demo/customized-icon.md correctly 1`] = `
<div
class="ant-tree"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -1029,11 +1029,11 @@ exports[`renders ./components/tree/demo/customized-icon.md correctly 1`] = `
exports[`renders ./components/tree/demo/directory.md correctly 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -1445,11 +1445,11 @@ Array [
</div>,
<div
class="ant-tree ant-tree-block-node draggable-tree ant-tree-show-line"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -2130,11 +2130,11 @@ Array [
exports[`renders ./components/tree/demo/draggable.md correctly 1`] = `
<div
class="ant-tree ant-tree-icon-hide ant-tree-block-node draggable-tree"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -2495,11 +2495,11 @@ exports[`renders ./components/tree/demo/draggable.md correctly 1`] = `
exports[`renders ./components/tree/demo/dynamic.md correctly 1`] = `
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -2694,11 +2694,11 @@ exports[`renders ./components/tree/demo/line.md correctly 1`] = `
</div>
<div
class="ant-tree ant-tree-icon-hide ant-tree-show-line"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -3165,11 +3165,11 @@ exports[`renders ./components/tree/demo/search.md correctly 1`] = `
</span>
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -3329,11 +3329,11 @@ exports[`renders ./components/tree/demo/search.md correctly 1`] = `
exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = `
<div
class="ant-tree ant-tree-icon-hide ant-tree-show-line"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""

View File

@ -3,11 +3,11 @@
exports[`Directory Tree DirectoryTree should expend all when use treeData and defaultExpandAll is true 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -231,11 +231,11 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
exports[`Directory Tree defaultExpandAll 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -596,11 +596,11 @@ exports[`Directory Tree defaultExpandAll 1`] = `
exports[`Directory Tree defaultExpandParent 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -769,11 +769,11 @@ exports[`Directory Tree defaultExpandParent 1`] = `
exports[`Directory Tree expand click 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -1043,11 +1043,11 @@ exports[`Directory Tree expand click 1`] = `
exports[`Directory Tree expand click 2`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -1317,11 +1317,11 @@ exports[`Directory Tree expand click 2`] = `
exports[`Directory Tree expand double click 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -1591,11 +1591,11 @@ exports[`Directory Tree expand double click 1`] = `
exports[`Directory Tree expand double click 2`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -1865,11 +1865,11 @@ exports[`Directory Tree expand double click 2`] = `
exports[`Directory Tree expand with state control click 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -2022,11 +2022,11 @@ exports[`Directory Tree expand with state control click 1`] = `
exports[`Directory Tree expand with state control doubleClick 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -2179,11 +2179,11 @@ exports[`Directory Tree expand with state control doubleClick 1`] = `
exports[`Directory Tree expandedKeys update 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -2453,11 +2453,11 @@ exports[`Directory Tree expandedKeys update 1`] = `
exports[`Directory Tree group select 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -2818,11 +2818,11 @@ exports[`Directory Tree group select 1`] = `
exports[`Directory Tree group select 2`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -3183,11 +3183,11 @@ exports[`Directory Tree group select 2`] = `
exports[`Directory Tree rtl render component should be rendered correctly in RTL direction 1`] = `
<div
class="ant-tree ant-tree-icon-hide ant-tree-rtl"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -3227,11 +3227,11 @@ exports[`Directory Tree rtl render component should be rendered correctly in RTL
exports[`Directory Tree rtl render component should be rendered correctly in RTL direction 2`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-rtl ant-tree-directory ant-tree-directory-rtl"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width:0;height:0;display:flex;overflow:hidden;opacity:0;border:0;padding:0;margin:0"
tabindex="0"
value=""
@ -3271,11 +3271,11 @@ exports[`Directory Tree rtl render component should be rendered correctly in RTL
exports[`Directory Tree selectedKeys update 1`] = `
<div
class="ant-tree ant-tree-block-node ant-tree-directory"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""

View File

@ -3,11 +3,11 @@
exports[`Tree icon and switcherIcon of Tree with showLine should render correctly 1`] = `
<div
class="ant-tree ant-tree-show-line"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -149,11 +149,11 @@ exports[`Tree icon and switcherIcon of Tree with showLine should render correctl
exports[`Tree showLine is object type should render correctly 1`] = `
<div
class="ant-tree ant-tree-icon-hide ant-tree-show-line"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -478,11 +478,11 @@ exports[`Tree showLine is object type should render correctly 1`] = `
exports[`Tree switcherIcon in Tree could be string 1`] = `
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""
@ -596,11 +596,11 @@ exports[`Tree switcherIcon in Tree could be string 1`] = `
exports[`Tree switcherIcon should be loading icon when loadData 1`] = `
<div
class="ant-tree ant-tree-icon-hide"
role="tree"
>
<div
role="tree"
>
<div>
<input
aria-label="for screen reader"
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
tabindex="0"
value=""

View File

@ -31,6 +31,7 @@ Almost anything can be represented in a tree structure. Examples include directo
| disabled | Whether disabled the tree | boolean | false | |
| draggable | Specifies whether this Tree or the node is draggable (IE > 8) | boolean \| ((node: DataNode) => boolean) | false | |
| expandedKeys | (Controlled) Specifies the keys of the expanded treeNodes | string\[] | \[] | |
| fieldNames | Customize node title, key, children field name | object | { title: `title`, key: `key`, children: `children` } | 4.17.0 |
| filterTreeNode | Defines a function to filter (highlight) treeNodes. When the function returns `true`, the corresponding treeNode will be highlighted | function(node) | - | |
| height | Config virtual scroll height. Will not support horizontal scroll when enable this | number | - | |
| icon | Customize treeNode icon | ReactNode \| (props) => ReactNode | - | |

View File

@ -32,6 +32,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/Xh-oWqg9k/Tree.svg
| disabled | 将树禁用 | boolean | false | |
| draggable | 设置节点可拖拽IE>8 | boolean \| ((node: DataNode) => boolean) | false | |
| expandedKeys | (受控)展开指定的树节点 | string\[] | \[] | |
| fieldNames | 自定义节点 title、key、children 的字段 | object | { title: `title`, key: `key`, children: `children` } | 4.17.0 |
| filterTreeNode | 按需筛选树节点(高亮),返回 true | function(node) | - | |
| height | 设置虚拟滚动容器高度,设置后内部节点不再支持横向滚动 | number | - | |
| icon | 自定义树节点图标。 | ReactNode \| (props) => ReactNode | - | |

View File

@ -143,7 +143,7 @@
"rc-tabs": "~11.9.1",
"rc-textarea": "~0.3.0",
"rc-tooltip": "~5.1.1",
"rc-tree": "~4.2.1",
"rc-tree": "~5.0.0",
"rc-tree-select": "~4.3.0",
"rc-trigger": "^5.2.1",
"rc-upload": "~4.3.0",