mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 04:48:02 +08:00
4f1ca4c52b
* docs: Optimization demo * test: update snap * docs: update * docs: update
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import React, { useState } from 'react';
|
|
import type { SelectProps } from 'antd';
|
|
import { Select, Space, Tooltip } from 'antd';
|
|
|
|
interface ItemProps {
|
|
label: string;
|
|
value: string;
|
|
}
|
|
|
|
const options: ItemProps[] = [];
|
|
|
|
for (let i = 10; i < 36; i++) {
|
|
const value = i.toString(36) + i;
|
|
options.push({
|
|
label: `Long Label: ${value}`,
|
|
value,
|
|
});
|
|
}
|
|
|
|
const sharedProps: SelectProps = {
|
|
mode: 'multiple',
|
|
style: { width: '100%' },
|
|
options,
|
|
placeholder: 'Select Item...',
|
|
maxTagCount: 'responsive',
|
|
};
|
|
|
|
const App: React.FC = () => {
|
|
const [value, setValue] = useState(['a10', 'c12', 'h17', 'j19', 'k20']);
|
|
|
|
const selectProps: SelectProps = {
|
|
value,
|
|
onChange: setValue,
|
|
};
|
|
|
|
return (
|
|
<Space direction="vertical" style={{ width: '100%' }}>
|
|
<Select {...sharedProps} {...selectProps} />
|
|
<Select {...sharedProps} disabled />
|
|
<Select
|
|
{...sharedProps}
|
|
{...selectProps}
|
|
maxTagPlaceholder={(omittedValues) => (
|
|
<Tooltip
|
|
overlayStyle={{ pointerEvents: 'none' }}
|
|
title={omittedValues.map(({ label }) => label).join(', ')}
|
|
>
|
|
<span>Hover Me</span>
|
|
</Tooltip>
|
|
)}
|
|
/>
|
|
</Space>
|
|
);
|
|
};
|
|
|
|
export default App;
|