mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-17 23:50:52 +08:00

* feat(auto-complete): popup supports Semantic DOM and retire some api * refactor(auto-complete, select): deprecate `onDropdownVisibleChange` in favor of `onOpenChange` and update related tests * refactor: adjust semantic demo logic * docs: update api description * docs: update doc * docs: add space * docs: update * chore: update semantic demo logic * feat: add CP support * feat: add CP support for tree-select and update doc * docs: update Select and TreeSelect common props in configuration documentation * Update components/config-provider/index.zh-CN.md Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Signed-off-by: Jony J <1844749591@qq.com> * feat: add root support * docs: update doc * chore: bump cascader version --------- Signed-off-by: Jony J <1844749591@qq.com> Co-authored-by: thinkasany <480968828@qq.com> Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
79 lines
1.6 KiB
TypeScript
79 lines
1.6 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: {
|
|
root: '根元素',
|
|
popup: '弹出菜单元素',
|
|
},
|
|
en: {
|
|
root: 'Root element',
|
|
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={{ width: 200, marginBottom: 80, marginTop: -10 }}
|
|
styles={{
|
|
popup: {
|
|
zIndex: 1,
|
|
height: 90,
|
|
},
|
|
}}
|
|
value={value}
|
|
placeholder="Please select"
|
|
treeDefaultExpandAll
|
|
onChange={onChange}
|
|
treeData={treeData}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
const App: React.FC = () => {
|
|
const [locale] = useLocale(locales);
|
|
return (
|
|
<SemanticPreview
|
|
semantics={[
|
|
{ name: 'root', desc: locale.root, version: '5.25.0' },
|
|
{ name: 'popup', desc: locale.popup, version: '5.25.0' },
|
|
]}
|
|
>
|
|
<Block />
|
|
</SemanticPreview>
|
|
);
|
|
};
|
|
|
|
export default App;
|