ant-design/components/tree-select/demo/_semantic.tsx
Jony J c073d2cb6c
feat(tree-select): popup support semantic dom and deprecated some api (#53285)
* feat(tree-select): popup support semantic dom and deprecated some api

* chore: update demo

* chore: update demo

* fix(compact): update dropdownStyle to styles for better semantic structure

* docs: add space
2025-03-25 20:34:26 +08:00

75 lines
1.5 KiB
TypeScript

import React from 'react';
import { TreeSelect } from 'antd';
import SemanticPreview from '../../../.dumi/components/SemanticPreview';
import useLocale from '../../../.dumi/hooks/useLocale';
const locales = {
cn: {
popup: '弹出菜单元素',
},
en: {
popup: 'Popup element',
},
};
const treeData = [
{
value: 'contributors',
title: 'contributors',
children: [
{
value: 'thinkasany',
title: 'thinkasany',
},
{
value: 'aojunhao123',
title: 'aojunhao123',
},
],
},
];
const Block = (props: any) => {
const divRef = React.useRef<HTMLDivElement>(null);
const [value, setValue] = React.useState<string>();
const onChange = (newValue: string) => {
setValue(newValue);
};
return (
<div ref={divRef}>
<TreeSelect
{...props}
getPopupContainer={() => divRef.current}
showSearch
placement="bottomLeft"
open
style={{ marginBottom: 100, width: 200 }}
styles={{
popup: {
zIndex: 1,
},
}}
value={value}
placeholder="Please select"
treeDefaultExpandAll
onChange={onChange}
treeData={treeData}
/>
</div>
);
};
const App: React.FC = () => {
const [locale] = useLocale(locales);
return (
<SemanticPreview
semantics={[{ name: 'popup', desc: locale.popup, version: '5.25.0' }]}
height={200}
>
<Block />
</SemanticPreview>
);
};
export default App;