-
-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathmultiple.tsx
More file actions
59 lines (51 loc) · 1.48 KB
/
multiple.tsx
File metadata and controls
59 lines (51 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import * as React from 'react';
import '../../assets/index.less';
import type { PickerRef } from '../../src/interface';
import SinglePicker from '../../src/PickerInput/SinglePicker';
import dayjs from 'dayjs';
import 'dayjs/locale/ar';
import 'dayjs/locale/zh-cn';
import LocalizedFormat from 'dayjs/plugin/localizedFormat';
import dayjsGenerateConfig from '../../src/generate/dayjs';
import zhCN from '../../src/locale/zh_CN';
dayjs.locale('zh-cn');
dayjs.extend(LocalizedFormat);
console.clear();
(window as any).dayjs = dayjs;
const sharedLocale = {
locale: zhCN,
generateConfig: dayjsGenerateConfig,
style: { width: 300 },
};
const maxTagPlaceholder = (value) => {
return (
<ul>
{value?.map((item, index) => {
return <li key={index}>{item?.format('YYYY-MM-DD')}</li>;
})}
</ul>
);
};
export default () => {
const singleRef = React.useRef<PickerRef>(null);
return (
<div>
<SinglePicker {...sharedLocale} multiple ref={singleRef} onOpenChange={console.error} />
<SinglePicker {...sharedLocale} multiple ref={singleRef} needConfirm />
<SinglePicker
{...sharedLocale}
multiple
picker="week"
defaultValue={[dayjs('2021-01-01'), dayjs('2021-01-08')]}
/>
<SinglePicker
maxTagCount={10}
{...sharedLocale}
multiple
ref={singleRef}
maxTagPlaceholder={maxTagPlaceholder}
defaultValue={[dayjs('2021-01-01'), dayjs('2021-01-08')]}
/>
</div>
);
};