import React, { useState } from 'react';
import { CarryOutOutlined, CheckOutlined, FormOutlined } from '@ant-design/icons';
import { Select, Switch, Tree } from 'antd';
import type { DataNode } from 'antd/es/tree';
const treeData: DataNode[] = [
{
title: 'parent 1',
key: '0-0',
icon: ,
children: [
{
title: 'parent 1-0',
key: '0-0-0',
icon: ,
children: [
{ title: 'leaf', key: '0-0-0-0', icon: },
{
title: (
<>
multiple line title
multiple line title
>
),
key: '0-0-0-1',
icon: ,
},
{ title: 'leaf', key: '0-0-0-2', icon: },
],
},
{
title: 'parent 1-1',
key: '0-0-1',
icon: ,
children: [{ title: 'leaf', key: '0-0-1-0', icon: }],
},
{
title: 'parent 1-2',
key: '0-0-2',
icon: ,
children: [
{ title: 'leaf', key: '0-0-2-0', icon: },
{
title: 'leaf',
key: '0-0-2-1',
icon: ,
switcherIcon: ,
},
],
},
],
},
{
title: 'parent 2',
key: '0-1',
icon: ,
children: [
{
title: 'parent 2-0',
key: '0-1-0',
icon: ,
children: [
{ title: 'leaf', key: '0-1-0-0', icon: },
{ title: 'leaf', key: '0-1-0-1', icon: },
],
},
],
},
];
const App: React.FC = () => {
const [showLine, setShowLine] = useState(true);
const [showIcon, setShowIcon] = useState(false);
const [showLeafIcon, setShowLeafIcon] = useState(true);
const onSelect = (selectedKeys: React.Key[], info: any) => {
console.log('selected', selectedKeys, info);
};
const handleLeafIconChange = (value: 'true' | 'false' | 'custom') => {
if (value === 'custom') {
return setShowLeafIcon();
}
if (value === 'true') {
return setShowLeafIcon(true);
}
return setShowLeafIcon(false);
};
return (
showLine:
showIcon:
showLeafIcon:{' '}
);
};
export default App;