-
-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathpanelRender.tsx
More file actions
71 lines (68 loc) · 2.08 KB
/
panelRender.tsx
File metadata and controls
71 lines (68 loc) · 2.08 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
60
61
62
63
64
65
66
67
68
69
70
71
import type { Moment } from 'moment';
import moment from 'moment';
import React from 'react';
import '../../assets/index.less';
import Picker, { RangePicker } from '../../src';
import momentGenerateConfig from '../../src/generate/moment';
import zhCN from '../../src/locale/zh_CN';
import './common.less';
const defaultStartValue = moment('2019-09-03 05:02:03');
const defaultEndValue = moment('2019-11-28 01:02:03');
const defaultValue: [Moment, Moment] = [defaultStartValue, defaultEndValue];
export default () => {
const [customizeNode, setCustomizeNode] = React.useState(false);
return (
<>
{String(customizeNode)}
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
<div>
<h3>Picker</h3>
<Picker<Moment>
generateConfig={momentGenerateConfig}
locale={zhCN}
allowClear
defaultValue={defaultStartValue}
panelRender={(node, { components: { Panel } }) => (
<>
<button
type="button"
style={{ display: 'block' }}
onClick={() => {
setCustomizeNode(!customizeNode);
}}
>
Change
</button>
<Panel picker="time" />
{customizeNode ? <span>My Panel</span> : node}
</>
)}
/>
</div>
<div>
<h3>RangePicker</h3>
<RangePicker<Moment>
generateConfig={momentGenerateConfig}
locale={zhCN}
allowClear
defaultValue={defaultValue}
panelRender={(node) => (
<>
<button
type="button"
style={{ display: 'block' }}
onClick={() => {
setCustomizeNode(!customizeNode);
}}
>
Change
</button>
{customizeNode ? <span>My Panel</span> : node}
</>
)}
/>
</div>
</div>
</>
);
};