ant-design/components/select/demo/_semantic.tsx
Jony J 33fa456979
feat(select): popup supports Semantic DOM and retire some api (#53243)
* feat(select):popup support Semantic DOM and retire some api

* chore: adjust logic

* chore: adjust semantic preview demo

* style: set popup zIndex for better visibility
2025-03-21 22:01:18 +08:00

52 lines
1.1 KiB
TypeScript

import React from 'react';
import { Select } from 'antd';
import SemanticPreview from '../../../.dumi/components/SemanticPreview';
import useLocale from '../../../.dumi/hooks/useLocale';
const locales = {
cn: {
popup: '弹出菜单元素',
},
en: {
popup: 'Popup element',
},
};
const Block = (prop: any) => {
const divRef = React.useRef<HTMLDivElement>(null);
return (
<div ref={divRef} style={{ position: 'absolute', marginBottom: 80 }}>
<Select
{...prop}
open
placement="bottomLeft"
defaultValue="aojunhao123"
getPopupContainer={() => divRef.current}
options={[
{ value: 'aojunhao123', label: 'aojunhao123' },
{ value: 'thinkasany', label: 'thinkasany' },
]}
styles={{
popup: { zIndex: 1 },
}}
/>
</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;