mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
feat: Tree support showLeafIcon in showLine (#25271)
closes #23261 Co-authored-by: zoomdong <1344492820@qq.com>
This commit is contained in:
parent
88f7de7090
commit
ab56668d40
@ -36299,7 +36299,7 @@ exports[`ConfigProvider components Tree configProvider 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close"
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close config-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="config-tree-switcher config-tree-switcher-noop"
|
||||
@ -36340,7 +36340,7 @@ exports[`ConfigProvider components Tree configProvider 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close"
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close config-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="config-tree-switcher config-tree-switcher-noop"
|
||||
@ -36410,7 +36410,7 @@ exports[`ConfigProvider components Tree configProvider componentSize large 1`] =
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close"
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close config-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="config-tree-switcher config-tree-switcher-noop"
|
||||
@ -36451,7 +36451,7 @@ exports[`ConfigProvider components Tree configProvider componentSize large 1`] =
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close"
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close config-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="config-tree-switcher config-tree-switcher-noop"
|
||||
@ -36521,7 +36521,7 @@ exports[`ConfigProvider components Tree configProvider componentSize middle 1`]
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close"
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close config-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="config-tree-switcher config-tree-switcher-noop"
|
||||
@ -36562,7 +36562,7 @@ exports[`ConfigProvider components Tree configProvider componentSize middle 1`]
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close"
|
||||
class="config-tree-treenode config-tree-treenode-switcher-close config-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="config-tree-switcher config-tree-switcher-noop"
|
||||
@ -36632,7 +36632,7 @@ exports[`ConfigProvider components Tree configProvider virtual and dropdownMatch
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -36673,7 +36673,7 @@ exports[`ConfigProvider components Tree configProvider virtual and dropdownMatch
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -36743,7 +36743,7 @@ exports[`ConfigProvider components Tree normal 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -36784,7 +36784,7 @@ exports[`ConfigProvider components Tree normal 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -36854,7 +36854,7 @@ exports[`ConfigProvider components Tree prefixCls 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="prefix-Tree-treenode prefix-Tree-treenode-switcher-close"
|
||||
class="prefix-Tree-treenode prefix-Tree-treenode-switcher-close prefix-Tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="prefix-Tree-switcher prefix-Tree-switcher-noop"
|
||||
@ -36895,7 +36895,7 @@ exports[`ConfigProvider components Tree prefixCls 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="prefix-Tree-treenode prefix-Tree-treenode-switcher-close"
|
||||
class="prefix-Tree-treenode prefix-Tree-treenode-switcher-close prefix-Tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="prefix-Tree-switcher prefix-Tree-switcher-noop"
|
||||
|
@ -4446,7 +4446,7 @@ exports[`renders ./components/transfer/demo/tree-transfer.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -4478,7 +4478,7 @@ exports[`renders ./components/transfer/demo/tree-transfer.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
|
@ -91,8 +91,8 @@ export interface AntTreeNodeDropEvent {
|
||||
// [Legacy] Compatible for v3
|
||||
export type TreeNodeNormal = DataNode;
|
||||
|
||||
export interface TreeProps extends Omit<RcTreeProps, 'prefixCls'> {
|
||||
showLine?: boolean;
|
||||
export interface TreeProps extends Omit<RcTreeProps, 'prefixCls' | 'showLine'> {
|
||||
showLine?: boolean | { showLeafIcon: boolean };
|
||||
className?: string;
|
||||
/** 是否支持多选 */
|
||||
multiple?: boolean;
|
||||
@ -153,13 +153,17 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {
|
||||
children,
|
||||
checkable,
|
||||
} = props;
|
||||
const newProps = {
|
||||
...props,
|
||||
showLine: Boolean(showLine),
|
||||
};
|
||||
const prefixCls = getPrefixCls('tree', customizePrefixCls);
|
||||
return (
|
||||
<RcTree
|
||||
itemHeight={20}
|
||||
ref={ref}
|
||||
virtual={virtual}
|
||||
{...props}
|
||||
{...newProps}
|
||||
prefixCls={prefixCls}
|
||||
className={classNames(className, {
|
||||
[`${prefixCls}-icon-hide`]: !showIcon,
|
||||
|
@ -22,7 +22,7 @@ exports[`renders ./components/tree/demo/basic.md correctly 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -155,7 +155,7 @@ exports[`renders ./components/tree/demo/basic.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -190,7 +190,7 @@ exports[`renders ./components/tree/demo/basic.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -243,7 +243,7 @@ exports[`renders ./components/tree/demo/basic.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-checkbox-checked"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -477,7 +477,7 @@ exports[`renders ./components/tree/demo/basic-controlled.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-checkbox-checked"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -635,7 +635,7 @@ exports[`renders ./components/tree/demo/basic-controlled.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -670,7 +670,7 @@ exports[`renders ./components/tree/demo/basic-controlled.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -747,7 +747,7 @@ exports[`renders ./components/tree/demo/basic-controlled.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -798,7 +798,7 @@ exports[`renders ./components/tree/demo/customized-icon.md correctly 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -909,7 +909,7 @@ exports[`renders ./components/tree/demo/customized-icon.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1096,7 +1096,7 @@ exports[`renders ./components/tree/demo/directory.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode"
|
||||
class="ant-tree-treenode ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1145,7 +1145,7 @@ exports[`renders ./components/tree/demo/directory.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -1256,7 +1256,7 @@ exports[`renders ./components/tree/demo/directory.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode"
|
||||
class="ant-tree-treenode ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1480,7 +1480,7 @@ exports[`renders ./components/tree/demo/draggable.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1558,7 +1558,7 @@ exports[`renders ./components/tree/demo/draggable.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1625,7 +1625,7 @@ exports[`renders ./components/tree/demo/draggable.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -1747,7 +1747,7 @@ exports[`renders ./components/tree/demo/dynamic.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode"
|
||||
class="ant-tree-treenode ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -1804,6 +1804,22 @@ exports[`renders ./components/tree/demo/line.md correctly 1`] = `
|
||||
class="ant-switch-inner"
|
||||
/>
|
||||
</button>
|
||||
<br />
|
||||
<br />
|
||||
showLeafIcon:
|
||||
<button
|
||||
aria-checked="true"
|
||||
class="ant-switch ant-switch-checked"
|
||||
role="switch"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="ant-switch-handle"
|
||||
/>
|
||||
<span
|
||||
class="ant-switch-inner"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree ant-tree-icon-hide ant-tree-show-line"
|
||||
@ -1826,7 +1842,7 @@ exports[`renders ./components/tree/demo/line.md correctly 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -2014,7 +2030,7 @@ exports[`renders ./components/tree/demo/line.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2112,7 +2128,7 @@ exports[`renders ./components/tree/demo/line.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2312,7 +2328,7 @@ exports[`renders ./components/tree/demo/search.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
@ -2362,7 +2378,7 @@ exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = `
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -2544,7 +2560,7 @@ exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2639,7 +2655,7 @@ exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
|
@ -22,7 +22,7 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
|
||||
style="display:flex;flex-direction:column"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -84,7 +84,7 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -154,7 +154,7 @@ exports[`Directory Tree DirectoryTree should expend all when use treeData and de
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode"
|
||||
class="ant-tree-treenode ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -344,7 +344,7 @@ exports[`Directory Tree defaultExpandAll 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -393,7 +393,7 @@ exports[`Directory Tree defaultExpandAll 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -504,7 +504,7 @@ exports[`Directory Tree defaultExpandAll 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -642,7 +642,7 @@ exports[`Directory Tree defaultExpandParent 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
@ -846,7 +846,7 @@ exports[`Directory Tree expand click 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -896,7 +896,7 @@ exports[`Directory Tree expand click 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
@ -1048,7 +1048,7 @@ exports[`Directory Tree expand click 2`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
@ -1252,7 +1252,7 @@ exports[`Directory Tree expand double click 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1302,7 +1302,7 @@ exports[`Directory Tree expand double click 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
@ -1454,7 +1454,7 @@ exports[`Directory Tree expand double click 2`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
@ -1544,7 +1544,7 @@ exports[`Directory Tree expand with state control click 1`] = `
|
||||
style="display: flex; flex-direction: column;"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-selected"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-selected ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -1609,7 +1609,7 @@ exports[`Directory Tree expand with state control click 1`] = `
|
||||
class="ant-tree-treenode-motion"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1687,7 +1687,7 @@ exports[`Directory Tree expand with state control doubleClick 1`] = `
|
||||
style="display: flex; flex-direction: column;"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -1752,7 +1752,7 @@ exports[`Directory Tree expand with state control doubleClick 1`] = `
|
||||
class="ant-tree-treenode-motion"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -1892,7 +1892,7 @@ exports[`Directory Tree expandedKeys update 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -2006,7 +2006,7 @@ exports[`Directory Tree expandedKeys update 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2194,7 +2194,7 @@ exports[`Directory Tree group select 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2243,7 +2243,7 @@ exports[`Directory Tree group select 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -2354,7 +2354,7 @@ exports[`Directory Tree group select 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2541,7 +2541,7 @@ exports[`Directory Tree group select 2`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-selected"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-selected ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2590,7 +2590,7 @@ exports[`Directory Tree group select 2`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-selected"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-selected ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -2701,7 +2701,7 @@ exports[`Directory Tree group select 2`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2940,7 +2940,7 @@ exports[`Directory Tree selectedKeys update 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -2989,7 +2989,7 @@ exports[`Directory Tree selectedKeys update 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -3100,7 +3100,7 @@ exports[`Directory Tree selectedKeys update 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
|
@ -68,7 +68,7 @@ exports[`Tree icon and switcherIcon of Tree with showLine should render correctl
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
@ -117,6 +117,317 @@ exports[`Tree icon and switcherIcon of Tree with showLine should render correctl
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Tree showLine is object type should render correctly 1`] = `
|
||||
<div
|
||||
class="ant-tree ant-tree-icon-hide ant-tree-show-line"
|
||||
>
|
||||
<div
|
||||
role="tree"
|
||||
>
|
||||
<input
|
||||
style="width: 0px; height: 0px; display: flex; overflow: hidden; opacity: 0; border: 0px; padding: 0px; margin: 0px;"
|
||||
tabindex="0"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-list"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
class="ant-tree-list-holder-inner"
|
||||
style="display: flex; flex-direction: column;"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
>
|
||||
<span
|
||||
aria-label="minus-square"
|
||||
class="anticon anticon-minus-square ant-tree-switcher-line-icon"
|
||||
role="img"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class=""
|
||||
data-icon="minus-square"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"
|
||||
/>
|
||||
<path
|
||||
d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open"
|
||||
title="parent 1"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-title"
|
||||
>
|
||||
parent 1
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="ant-tree-indent"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-indent-unit ant-tree-indent-unit-start"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
>
|
||||
<span
|
||||
aria-label="minus-square"
|
||||
class="anticon anticon-minus-square ant-tree-switcher-line-icon"
|
||||
role="img"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class=""
|
||||
data-icon="minus-square"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"
|
||||
/>
|
||||
<path
|
||||
d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open"
|
||||
title="parent 1-0"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-title"
|
||||
>
|
||||
parent 1-0
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="ant-tree-indent"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-indent-unit ant-tree-indent-unit-start"
|
||||
/>
|
||||
<span
|
||||
class="ant-tree-indent-unit ant-tree-indent-unit-start"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher-leaf-line"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
|
||||
title="leaf"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-title"
|
||||
>
|
||||
leaf
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="ant-tree-indent"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-indent-unit ant-tree-indent-unit-start"
|
||||
/>
|
||||
<span
|
||||
class="ant-tree-indent-unit"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher-leaf-line"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
|
||||
title="leaf"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-title"
|
||||
>
|
||||
leaf
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="ant-tree-indent"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-indent-unit ant-tree-indent-unit-start"
|
||||
/>
|
||||
<span
|
||||
class="ant-tree-indent-unit ant-tree-indent-unit-end"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher-noop"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher-leaf-line"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-normal"
|
||||
title="leaf"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-title"
|
||||
>
|
||||
leaf
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="ant-tree-indent"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-indent-unit"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
>
|
||||
<span
|
||||
aria-label="plus-square"
|
||||
class="anticon anticon-plus-square ant-tree-switcher-line-icon"
|
||||
role="img"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class=""
|
||||
data-icon="plus-square"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"
|
||||
/>
|
||||
<path
|
||||
d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-close"
|
||||
title="parent 1-1"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-title"
|
||||
>
|
||||
parent 1-1
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-close ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="ant-tree-indent"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-indent-unit ant-tree-indent-unit-end"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_close"
|
||||
>
|
||||
<span
|
||||
aria-label="plus-square"
|
||||
class="anticon anticon-plus-square ant-tree-switcher-line-icon"
|
||||
role="img"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class=""
|
||||
data-icon="plus-square"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"
|
||||
/>
|
||||
<path
|
||||
d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-close"
|
||||
title="parent 1-2"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-title"
|
||||
>
|
||||
parent 1-2
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Tree switcherIcon in Tree could be string 1`] = `
|
||||
<div
|
||||
class="ant-tree ant-tree-icon-hide"
|
||||
@ -139,7 +450,7 @@ exports[`Tree switcherIcon in Tree could be string 1`] = `
|
||||
style="display: flex; flex-direction: column;"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -183,7 +494,7 @@ exports[`Tree switcherIcon in Tree could be string 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
@ -235,7 +546,7 @@ exports[`Tree switcherIcon should be loading icon when loadData 1`] = `
|
||||
style="display: flex; flex-direction: column;"
|
||||
>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
class="ant-tree-switcher ant-tree-switcher_open"
|
||||
@ -303,7 +614,7 @@ exports[`Tree switcherIcon should be loading icon when loadData 1`] = `
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-loading"
|
||||
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-loading ant-tree-treenode-leaf-last"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
|
@ -73,4 +73,27 @@ describe('Tree', () => {
|
||||
);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/23261
|
||||
it('showLine is object type should render correctly', () => {
|
||||
const wrapper = mount(
|
||||
<Tree showLine={{ showLeafIcon: false }} defaultExpandedKeys={['0-0-0']}>
|
||||
<TreeNode title="parent 1" key="0-0">
|
||||
<TreeNode title="parent 1-0" key="0-0-0">
|
||||
<TreeNode title="leaf" key="0-0-0-0" />
|
||||
<TreeNode title="leaf" key="0-0-0-1" />
|
||||
<TreeNode title="leaf" key="0-0-0-2" />
|
||||
</TreeNode>
|
||||
<TreeNode title="parent 1-1" key="0-0-1">
|
||||
<TreeNode title="leaf" key="0-0-1-0" />
|
||||
</TreeNode>
|
||||
<TreeNode title="parent 1-2" key="0-0-2">
|
||||
<TreeNode title="leaf" key="0-0-2-0" />
|
||||
<TreeNode title="leaf" key="0-0-2-1" />
|
||||
</TreeNode>
|
||||
</TreeNode>
|
||||
</Tree>,
|
||||
);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@ -61,18 +61,35 @@ const treeData = [
|
||||
const Demo: React.FC<{}> = () => {
|
||||
const [showLine, setShowLine] = useState(true);
|
||||
const [showIcon, setShowIcon] = useState(false);
|
||||
const [showLeafIcon, setShowLeafIcon] = useState(true);
|
||||
|
||||
const onSelect = (selectedKeys, info) => {
|
||||
console.log('selected', selectedKeys, info);
|
||||
};
|
||||
|
||||
const onSetLeafIcon = checked => {
|
||||
setShowLeafIcon(checked);
|
||||
setShowLine({ showLeafIcon: checked });
|
||||
};
|
||||
|
||||
const onSetShowLine = checked => {
|
||||
if (checked) {
|
||||
showLeafIcon ? setShowLine(checked) : setShowLine({ showLeafIcon });
|
||||
} else {
|
||||
setShowLine(checked);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
showLine: <Switch checked={showLine} onChange={setShowLine} />
|
||||
showLine: <Switch checked={showLine} onChange={onSetShowLine} />
|
||||
<br />
|
||||
<br />
|
||||
showIcon: <Switch checked={showIcon} onChange={setShowIcon} />
|
||||
<br />
|
||||
<br />
|
||||
showLeafIcon: <Switch checked={showLeafIcon} onChange={onSetLeafIcon} />
|
||||
</div>
|
||||
<Tree
|
||||
showLine={showLine}
|
||||
|
@ -38,7 +38,7 @@ Almost anything can be represented in a tree structure. Examples include directo
|
||||
| selectedKeys | (Controlled) Specifies the keys of the selected treeNodes | string\[] | - | |
|
||||
| showIcon | Shows the icon before a TreeNode's title. There is no default style; you must set a custom style for it if set to `true` | boolean | false | |
|
||||
| switcherIcon | customize collapse/expand icon of tree node | ReactNode | - | |
|
||||
| showLine | Shows a connecting line | boolean | false | |
|
||||
| showLine | Shows a connecting line | booleanboolean\|{showLeafIcon: boolean} | false | |
|
||||
| treeData | treeNodes data Array, if set it then you need not to construct children TreeNode. (key should be unique across the whole array) | array\<{ key, title, children, \[disabled, selectable] }> | - | |
|
||||
| virtual | Disable virtual scroll when set to `false` | boolean | true | 4.1.0 |
|
||||
| onCheck | Callback function for when the onCheck event occurs | function(checkedKeys, e:{checked: bool, checkedNodes, node, event, halfCheckedKeys}) | - | |
|
||||
|
@ -39,7 +39,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/Xh-oWqg9k/Tree.svg
|
||||
| selectedKeys | (受控)设置选中的树节点 | string\[] | - | |
|
||||
| showIcon | 是否展示 TreeNode title 前的图标,没有默认样式,如设置为 true,需要自行定义图标相关样式 | boolean | false | |
|
||||
| switcherIcon | 自定义树节点的展开/折叠图标 | ReactNode | - |
|
||||
| showLine | 是否展示连接线 | boolean | false | |
|
||||
| showLine | 是否展示连接线 | boolean\|{showLeafIcon: boolean} | false | |
|
||||
| treeData | treeNodes 数据,如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一) | array\<{key, title, children, \[disabled, selectable]}> | - | |
|
||||
| virtual | 设置 `false` 时关闭虚拟滚动 | boolean | true | 4.1.0 |
|
||||
| onCheck | 点击复选框触发 | function(checkedKeys, e:{checked: bool, checkedNodes, node, event, halfCheckedKeys}) | - | |
|
||||
|
@ -1,6 +1,7 @@
|
||||
@import '../../style/mixins/index';
|
||||
|
||||
@tree-prefix-cls: ~'@{ant-prefix}-tree';
|
||||
@tree-node-prefix-cls: ~'@{tree-prefix-cls}-treenode';
|
||||
@select-tree-prefix-cls: ~'@{ant-prefix}-select-tree';
|
||||
@tree-motion: ~'@{ant-prefix}-motion-collapse';
|
||||
|
||||
@ -119,6 +120,28 @@
|
||||
&-loading-icon {
|
||||
color: @primary-color;
|
||||
}
|
||||
|
||||
&-leaf-line {
|
||||
z-index: 1;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
&::before {
|
||||
position: absolute;
|
||||
height: @tree-title-height;
|
||||
margin-left: -1px;
|
||||
border-left: 1px solid @normal-color;
|
||||
content: ' ';
|
||||
}
|
||||
&::after {
|
||||
position: absolute;
|
||||
width: @tree-title-height - 14px;
|
||||
height: @tree-title-height - 10px;
|
||||
margin-left: -1px;
|
||||
border-bottom: 1px solid @normal-color;
|
||||
content: ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// >>> Checkbox
|
||||
@ -229,3 +252,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.@{tree-node-prefix-cls}-leaf-last {
|
||||
.@{tree-prefix-cls}-switcher {
|
||||
&-leaf-line {
|
||||
&::before {
|
||||
height: @tree-title-height - 10px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,24 @@ import { isValidElement, cloneElement } from '../../_util/reactNode';
|
||||
export default function renderSwitcherIcon(
|
||||
prefixCls: string,
|
||||
switcherIcon: React.ReactNode | null | undefined,
|
||||
showLine: boolean | undefined,
|
||||
showLine: boolean | { showLeafIcon: boolean } | undefined,
|
||||
{ isLeaf, expanded, loading }: AntTreeNodeProps,
|
||||
) {
|
||||
if (loading) {
|
||||
return <LoadingOutlined className={`${prefixCls}-switcher-loading-icon`} />;
|
||||
}
|
||||
let showLeafIcon;
|
||||
if (showLine && typeof showLine === 'object') {
|
||||
showLeafIcon = showLine.showLeafIcon;
|
||||
}
|
||||
if (isLeaf) {
|
||||
return showLine ? <FileOutlined className={`${prefixCls}-switcher-line-icon`} /> : null;
|
||||
if (showLine) {
|
||||
if (typeof showLine === 'object' && !showLeafIcon) {
|
||||
return <span className={`${prefixCls}-switcher-leaf-line`} />;
|
||||
}
|
||||
return <FileOutlined className={`${prefixCls}-switcher-line-icon`} />;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const switcherCls = `${prefixCls}-switcher-icon`;
|
||||
if (isValidElement(switcherIcon)) {
|
||||
|
@ -139,8 +139,8 @@
|
||||
"rc-tabs": "~11.5.0",
|
||||
"rc-textarea": "~0.2.2",
|
||||
"rc-tooltip": "~4.2.0",
|
||||
"rc-tree": "~3.5.0",
|
||||
"rc-tree-select": "~4.0.0",
|
||||
"rc-tree": "~3.6.0",
|
||||
"rc-tree-select": "~4.0.2",
|
||||
"rc-trigger": "~4.3.0",
|
||||
"rc-upload": "~3.2.0",
|
||||
"rc-util": "^5.0.1",
|
||||
|
Loading…
Reference in New Issue
Block a user