@douyinfe/semi-ui 2.16.1 → 2.17.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collapse/__test__/collapse.test.js +22 -2
- package/collapse/_story/accordion.stories.js +2 -2
- package/collapse/item.tsx +20 -6
- package/datePicker/__test__/datePicker.test.js +5 -5
- package/datePicker/_story/datePicker.stories.js +138 -22
- package/datePicker/datePicker.tsx +42 -7
- package/datePicker/monthsGrid.tsx +22 -10
- package/datePicker/quickControl.tsx +62 -16
- package/datePicker/yearAndMonth.tsx +31 -5
- package/dist/css/semi.css +289 -32
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +45706 -45192
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/collapse/item.d.ts +8 -0
- package/lib/cjs/collapse/item.js +19 -8
- package/lib/cjs/datePicker/datePicker.d.ts +3 -0
- package/lib/cjs/datePicker/datePicker.js +56 -9
- package/lib/cjs/datePicker/monthsGrid.d.ts +3 -0
- package/lib/cjs/datePicker/monthsGrid.js +14 -3
- package/lib/cjs/datePicker/quickControl.d.ts +6 -0
- package/lib/cjs/datePicker/quickControl.js +61 -14
- package/lib/cjs/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/cjs/datePicker/yearAndMonth.js +15 -3
- package/lib/cjs/popover/index.d.ts +3 -0
- package/lib/cjs/popover/index.js +4 -2
- package/lib/cjs/select/index.d.ts +6 -1
- package/lib/cjs/select/index.js +130 -72
- package/lib/cjs/select/option.js +4 -2
- package/lib/cjs/tag/index.js +6 -4
- package/lib/cjs/tag/interface.d.ts +1 -0
- package/lib/cjs/tagInput/index.d.ts +13 -1
- package/lib/cjs/tagInput/index.js +217 -91
- package/lib/cjs/tooltip/index.d.ts +4 -0
- package/lib/cjs/tooltip/index.js +5 -3
- package/lib/es/collapse/item.d.ts +8 -0
- package/lib/es/collapse/item.js +19 -8
- package/lib/es/datePicker/datePicker.d.ts +3 -0
- package/lib/es/datePicker/datePicker.js +56 -9
- package/lib/es/datePicker/monthsGrid.d.ts +3 -0
- package/lib/es/datePicker/monthsGrid.js +14 -3
- package/lib/es/datePicker/quickControl.d.ts +6 -0
- package/lib/es/datePicker/quickControl.js +61 -15
- package/lib/es/datePicker/yearAndMonth.d.ts +3 -0
- package/lib/es/datePicker/yearAndMonth.js +14 -3
- package/lib/es/popover/index.d.ts +3 -0
- package/lib/es/popover/index.js +4 -2
- package/lib/es/select/index.d.ts +6 -1
- package/lib/es/select/index.js +129 -71
- package/lib/es/select/option.js +4 -2
- package/lib/es/tag/index.js +6 -4
- package/lib/es/tag/interface.d.ts +1 -0
- package/lib/es/tagInput/index.d.ts +13 -1
- package/lib/es/tagInput/index.js +217 -93
- package/lib/es/tooltip/index.d.ts +4 -0
- package/lib/es/tooltip/index.js +5 -3
- package/package.json +7 -7
- package/popover/index.tsx +4 -1
- package/select/__test__/select.test.js +5 -3
- package/select/index.tsx +65 -30
- package/select/option.tsx +2 -0
- package/tag/index.tsx +3 -2
- package/tag/interface.ts +1 -0
- package/tagInput/_story/tagInput.stories.js +18 -0
- package/tagInput/index.tsx +126 -26
- package/tooltip/index.tsx +5 -2
|
@@ -3,11 +3,13 @@ import { BASE_CLASS_PREFIX } from '../../../semi-foundation/base/constants'; //
|
|
|
3
3
|
|
|
4
4
|
import { IconPlus, IconMinus, IconCopy } from '@douyinfe/semi-icons';
|
|
5
5
|
|
|
6
|
-
let getCollapse = collapseProps => {
|
|
6
|
+
let getCollapse = (collapseProps, panel1Props) => {
|
|
7
7
|
let props = collapseProps ? collapseProps : {};
|
|
8
|
+
let panelProps = panel1Props ? panel1Props : {};
|
|
9
|
+
|
|
8
10
|
return (
|
|
9
11
|
<Collapse {...collapseProps}>
|
|
10
|
-
<Collapse.Panel header="This is panel header 1" itemKey="1">
|
|
12
|
+
<Collapse.Panel header="This is panel header 1" itemKey="1" {...panelProps}>
|
|
11
13
|
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
|
|
12
14
|
</Collapse.Panel>
|
|
13
15
|
<Collapse.Panel header="This is panel header 2" itemKey="2">
|
|
@@ -145,4 +147,22 @@ describe('Collapse', () => {
|
|
|
145
147
|
expect(headers.at(1).getDOMNode().getAttribute(expandAttr)).toEqual("false");
|
|
146
148
|
expect(headers.at(2).getDOMNode().getAttribute(expandAttr)).toEqual("true");
|
|
147
149
|
});
|
|
150
|
+
|
|
151
|
+
it('disable Collapse', () => {
|
|
152
|
+
let props = {
|
|
153
|
+
disabled: true,
|
|
154
|
+
};
|
|
155
|
+
const disabledPanel = mount(getCollapse({}, props));
|
|
156
|
+
expect(disabledPanel.exists('.semi-collapse-header-disabled')).toEqual(true);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('hide the panel icon', () => {
|
|
160
|
+
const hidePanelArrow = mount(
|
|
161
|
+
<Collapse >
|
|
162
|
+
<Collapse.Panel header="This is panel header 1" itemKey="1" showArrow={false}>
|
|
163
|
+
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
|
|
164
|
+
</Collapse.Panel>
|
|
165
|
+
</Collapse>);
|
|
166
|
+
expect(hidePanelArrow.exists('.semi-collapse-header-icon')).toEqual(false);
|
|
167
|
+
});
|
|
148
168
|
});
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
export const RegularCollapse = () => (
|
|
18
18
|
<div>
|
|
19
19
|
<Collapse onChange={k => console.log(k)}>
|
|
20
|
-
<Panel header="This is panel header 1" itemKey="1">
|
|
20
|
+
<Panel header="This is panel header 1" itemKey="1" showArrow={false}>
|
|
21
21
|
<p>{text}</p>
|
|
22
22
|
</Panel>
|
|
23
23
|
<Panel header="This is panel header 2" itemKey="2">
|
|
@@ -32,7 +32,7 @@ export const RegularCollapse = () => (
|
|
|
32
32
|
<Panel header="This is panel header 1" itemKey="1">
|
|
33
33
|
<p>{text}</p>
|
|
34
34
|
</Panel>
|
|
35
|
-
<Panel header="This is panel header 2" itemKey="124">
|
|
35
|
+
<Panel header="This is panel header 2" itemKey="124" disabled>
|
|
36
36
|
<p>{text}</p>
|
|
37
37
|
</Panel>
|
|
38
38
|
<Panel header="This is panel header 3" itemKey="3" disabled>
|
package/collapse/item.tsx
CHANGED
|
@@ -15,6 +15,8 @@ export interface CollapsePanelProps {
|
|
|
15
15
|
children?: React.ReactNode;
|
|
16
16
|
reCalcKey?: number | string;
|
|
17
17
|
style?: CSSProperties;
|
|
18
|
+
showArrow?: boolean,
|
|
19
|
+
disabled?: boolean,
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
@@ -32,6 +34,13 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
32
34
|
PropTypes.string,
|
|
33
35
|
PropTypes.number,
|
|
34
36
|
]),
|
|
37
|
+
showArrow: PropTypes.bool,
|
|
38
|
+
disabled: PropTypes.bool,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
static defaultProps = {
|
|
42
|
+
showArrow: true,
|
|
43
|
+
disabled: false,
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
private ariaID = getUuidShort({});
|
|
@@ -40,6 +49,7 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
40
49
|
|
|
41
50
|
renderHeader(active: boolean, expandIconEnable = true) {
|
|
42
51
|
const {
|
|
52
|
+
showArrow,
|
|
43
53
|
header,
|
|
44
54
|
extra,
|
|
45
55
|
} = this.props;
|
|
@@ -65,20 +75,20 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
65
75
|
if (typeof header === 'string') {
|
|
66
76
|
return (
|
|
67
77
|
<>
|
|
68
|
-
{iconPosLeft ? icon : null}
|
|
78
|
+
{showArrow && (iconPosLeft ? icon : null)}
|
|
69
79
|
<span>{header}</span>
|
|
70
80
|
<span className={`${cssClasses.PREFIX}-header-right`}>
|
|
71
81
|
<span>{extra}</span>
|
|
72
|
-
{iconPosLeft ? null : icon}
|
|
82
|
+
{showArrow && (iconPosLeft ? null : icon)}
|
|
73
83
|
</span>
|
|
74
84
|
</>
|
|
75
85
|
);
|
|
76
86
|
}
|
|
77
87
|
return (
|
|
78
88
|
<>
|
|
79
|
-
{iconPosLeft ? icon : null}
|
|
89
|
+
{showArrow && (iconPosLeft ? icon : null)}
|
|
80
90
|
{header}
|
|
81
|
-
{iconPosLeft ? null : icon}
|
|
91
|
+
{showArrow && (iconPosLeft ? null : icon)}
|
|
82
92
|
</>
|
|
83
93
|
);
|
|
84
94
|
}
|
|
@@ -91,6 +101,8 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
91
101
|
reCalcKey,
|
|
92
102
|
header,
|
|
93
103
|
extra,
|
|
104
|
+
showArrow,
|
|
105
|
+
disabled,
|
|
94
106
|
...restProps
|
|
95
107
|
} = this.props;
|
|
96
108
|
const {
|
|
@@ -106,6 +118,7 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
106
118
|
});
|
|
107
119
|
const headerCls = cls({
|
|
108
120
|
[`${cssClasses.PREFIX}-header`]: true,
|
|
121
|
+
[`${cssClasses.PREFIX}-header-disabled`]: disabled,
|
|
109
122
|
[`${cssClasses.PREFIX}-header-iconLeft`]: expandIconPosition === 'left',
|
|
110
123
|
});
|
|
111
124
|
const contentCls = cls({
|
|
@@ -120,11 +133,12 @@ export default class CollapsePanel extends PureComponent<CollapsePanelProps> {
|
|
|
120
133
|
role="button"
|
|
121
134
|
tabIndex={0}
|
|
122
135
|
className={headerCls}
|
|
136
|
+
aria-disabled={disabled}
|
|
123
137
|
aria-expanded={active ? 'true' : 'false'}
|
|
124
138
|
aria-owns={this.ariaID}
|
|
125
|
-
onClick={e => onClick(itemKey, e)}
|
|
139
|
+
onClick={e => !disabled && onClick(itemKey, e)}
|
|
126
140
|
>
|
|
127
|
-
{this.renderHeader(active, children !== undefined)}
|
|
141
|
+
{this.renderHeader(active, children !== undefined && !disabled)}
|
|
128
142
|
</div>
|
|
129
143
|
{
|
|
130
144
|
children && (
|
|
@@ -114,7 +114,7 @@ describe(`DatePicker`, () => {
|
|
|
114
114
|
const demo = mount(<DatePicker presets={presets} motion={motion} open={open} defaultValue={defaultValue} />);
|
|
115
115
|
const elem = demo.find(BaseDatePicker);
|
|
116
116
|
|
|
117
|
-
const btns = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-quick-control
|
|
117
|
+
const btns = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-quick-control button`);
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* click next day
|
|
@@ -560,7 +560,7 @@ describe(`DatePicker`, () => {
|
|
|
560
560
|
};
|
|
561
561
|
const demo = mount(<DatePicker {...props} />);
|
|
562
562
|
const elem = demo.find(BaseDatePicker);
|
|
563
|
-
const btns = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-quick-control
|
|
563
|
+
const btns = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-quick-control button`);
|
|
564
564
|
|
|
565
565
|
// click disabled date
|
|
566
566
|
btns[0].click();
|
|
@@ -675,7 +675,7 @@ describe(`DatePicker`, () => {
|
|
|
675
675
|
const demo = mount(<DatePicker onPresetClick={handlePresetClick} presets={presets} motion={motion} open={open} defaultValue={defaultValue} />);
|
|
676
676
|
const elem = demo.find(BaseDatePicker);
|
|
677
677
|
|
|
678
|
-
const btns = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-quick-control
|
|
678
|
+
const btns = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-datepicker-quick-control button`);
|
|
679
679
|
|
|
680
680
|
btns[0].click();
|
|
681
681
|
btns[1].click();
|
|
@@ -987,7 +987,7 @@ describe(`DatePicker`, () => {
|
|
|
987
987
|
const demo = mount(<DatePicker {...props} onChange={handleChange} />);
|
|
988
988
|
const elem = demo.find(BaseDatePicker);
|
|
989
989
|
|
|
990
|
-
const btns = document.querySelectorAll('.semi-datepicker-quick-control
|
|
990
|
+
const btns = document.querySelectorAll('.semi-datepicker-quick-control button');
|
|
991
991
|
|
|
992
992
|
btns[0].click();
|
|
993
993
|
expect(handleChange.called).toBeTruthy();
|
|
@@ -1016,7 +1016,7 @@ describe(`DatePicker`, () => {
|
|
|
1016
1016
|
const demo = mount(<DatePicker {...props} onChange={handleChange} onConfirm={handleConfirm} />);
|
|
1017
1017
|
const elem = demo.find(BaseDatePicker);
|
|
1018
1018
|
|
|
1019
|
-
const btns = document.querySelectorAll('.semi-datepicker-quick-control
|
|
1019
|
+
const btns = document.querySelectorAll('.semi-datepicker-quick-control button');
|
|
1020
1020
|
|
|
1021
1021
|
// 点击 preset
|
|
1022
1022
|
btns[0].click();
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
startOfWeek,
|
|
11
11
|
endOfWeek,
|
|
12
12
|
} from 'date-fns';
|
|
13
|
-
import { Space, ConfigProvider, InputGroup, InputNumber, Form, withField, Button } from '../../index';
|
|
13
|
+
import { Space, ConfigProvider, InputGroup, InputNumber, Form, withField, Button, RadioGroup, Radio } from '../../index';
|
|
14
14
|
|
|
15
15
|
// stores
|
|
16
16
|
import NeedConfirmDemo from './NeedConfirm';
|
|
@@ -36,6 +36,7 @@ import DatePickerSlot from './DatePickerSlot';
|
|
|
36
36
|
import DatePickerTimeZone from './DatePickerTimeZone';
|
|
37
37
|
import BetterRangePicker from './BetterRangePicker';
|
|
38
38
|
import SyncSwitchMonth from './SyncSwitchMonth';
|
|
39
|
+
import { Checkbox } from '../../checkbox';
|
|
39
40
|
export * from './v2';
|
|
40
41
|
|
|
41
42
|
export default {
|
|
@@ -189,6 +190,11 @@ const presets = [
|
|
|
189
190
|
start: addDays(new Date(), 1),
|
|
190
191
|
end: addDays(new Date(), 1),
|
|
191
192
|
},
|
|
193
|
+
{
|
|
194
|
+
text: 'Today After Tomorrow',
|
|
195
|
+
start: addDays(new Date(), 2),
|
|
196
|
+
end: addDays(new Date(), 2),
|
|
197
|
+
},
|
|
192
198
|
{
|
|
193
199
|
text: 'Next Week',
|
|
194
200
|
start: addWeeks(new Date(), 1),
|
|
@@ -200,24 +206,14 @@ const presets = [
|
|
|
200
206
|
end: endOfMonth(addMonths(new Date(), 1)),
|
|
201
207
|
},
|
|
202
208
|
{
|
|
203
|
-
text: '
|
|
204
|
-
start: new Date(),
|
|
205
|
-
end: new Date(),
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
text: 'Tomorrow',
|
|
209
|
-
start: addDays(new Date(), 1),
|
|
210
|
-
end: addDays(new Date(), 1),
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
text: 'Next Week',
|
|
214
|
-
start: addWeeks(new Date(), 1),
|
|
215
|
-
end: addWeeks(new Date(), 2),
|
|
209
|
+
text: 'Next Bimonthly',
|
|
210
|
+
start: startOfMonth(addMonths(new Date(), 1)),
|
|
211
|
+
end: endOfMonth(addMonths(new Date(), 2)),
|
|
216
212
|
},
|
|
217
213
|
{
|
|
218
|
-
text: 'Next
|
|
219
|
-
start: startOfMonth(addMonths(new Date(),
|
|
220
|
-
end: endOfMonth(addMonths(new Date(),
|
|
214
|
+
text: 'Next Quarter',
|
|
215
|
+
start: startOfMonth(addMonths(new Date(), 3)),
|
|
216
|
+
end: endOfMonth(addMonths(new Date(), 3)),
|
|
221
217
|
},
|
|
222
218
|
];
|
|
223
219
|
|
|
@@ -225,40 +221,160 @@ export const DatePickerWithPresets = () => {
|
|
|
225
221
|
const onPresetClick = (item, e) => {
|
|
226
222
|
console.log('preset click', item, e);
|
|
227
223
|
};
|
|
224
|
+
const [presetPosition, setPresetPosition] = useState('right');
|
|
225
|
+
const [insetInput, setInsetInput] = useState(false);
|
|
226
|
+
const [presetArr, setPresetArr] = useState(presets);
|
|
227
|
+
|
|
228
|
+
const BottomSlot = function(props) {
|
|
229
|
+
const { style } = props;
|
|
230
|
+
return (
|
|
231
|
+
<div style={{ padding: '12px 20px', ...style }}>
|
|
232
|
+
<div strong style={{ color: 'var(--semi-color-text-2)' }}>
|
|
233
|
+
定版前请阅读
|
|
234
|
+
</div>
|
|
235
|
+
<div link={{ href: 'https://semi.design/', target: '_blank' }}>发版须知</div>
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
};
|
|
228
239
|
return (
|
|
229
240
|
<div style={demoDiv}>
|
|
230
241
|
<span>带快捷选择的DatePicker</span>
|
|
242
|
+
<br/>
|
|
243
|
+
<br/>
|
|
244
|
+
<RadioGroup onChange={e=>setPresetPosition(e.target.value)} value={presetPosition} aria-label="选择快捷选择面板位置" name="preset-radio-group">
|
|
245
|
+
<Radio value={'left'}>left</Radio>
|
|
246
|
+
<Radio value={'right'}>right</Radio>
|
|
247
|
+
<Radio value={'top'}>top</Radio>
|
|
248
|
+
<Radio value={'bottom'}>bottom</Radio>
|
|
249
|
+
</RadioGroup>
|
|
250
|
+
<Checkbox value={insetInput} onChange={e=>setInsetInput(e.target.checked)}>insetInput</Checkbox>
|
|
251
|
+
<Checkbox value={presetArr} onChange={e=>setPresetArr(e.target.checked ? [...presets, ...presets, ...presets]:presets)}>more presets</Checkbox>
|
|
252
|
+
<br/>
|
|
253
|
+
<div>type="date"</div>
|
|
231
254
|
<DatePicker
|
|
232
|
-
type="
|
|
233
|
-
presets={
|
|
255
|
+
type="date"
|
|
256
|
+
presets={presetArr}
|
|
257
|
+
insetInput={insetInput}
|
|
258
|
+
presetPosition={presetPosition}
|
|
234
259
|
onPresetClick={onPresetClick}
|
|
235
260
|
onChange={(...args) => console.log(...args)}
|
|
236
261
|
/>
|
|
262
|
+
<br/>
|
|
263
|
+
<br/>
|
|
264
|
+
<div>type="dateTime"</div>
|
|
237
265
|
<DatePicker
|
|
238
266
|
type="dateTime"
|
|
239
|
-
|
|
267
|
+
insetInput={insetInput}
|
|
268
|
+
needConfirm
|
|
269
|
+
bottomSlot={<BottomSlot/>}
|
|
270
|
+
presetPosition={presetPosition}
|
|
271
|
+
presets={presetArr.map(preset => ({
|
|
272
|
+
text: preset.text,
|
|
273
|
+
start: preset.start,
|
|
274
|
+
}))}
|
|
275
|
+
onPresetClick={onPresetClick}
|
|
276
|
+
onChange={(...args) => console.log(...args)}
|
|
277
|
+
/>
|
|
278
|
+
<br/>
|
|
279
|
+
<br/>
|
|
280
|
+
<div>type="dateRange"</div>
|
|
281
|
+
<DatePicker
|
|
282
|
+
type="dateRange"
|
|
283
|
+
presets={presetArr}
|
|
284
|
+
insetInput={insetInput}
|
|
285
|
+
presetPosition={presetPosition}
|
|
286
|
+
onPresetClick={onPresetClick}
|
|
287
|
+
onChange={(...args) => console.log(...args)}
|
|
288
|
+
/>
|
|
289
|
+
<br/>
|
|
290
|
+
<br/>
|
|
291
|
+
<div>type="dateTimeRange"</div>
|
|
292
|
+
<DatePicker
|
|
293
|
+
type="dateTimeRange"
|
|
294
|
+
presets={presetArr}
|
|
295
|
+
insetInput={insetInput}
|
|
296
|
+
presetPosition={presetPosition}
|
|
297
|
+
onPresetClick={onPresetClick}
|
|
298
|
+
onChange={(...args) => console.log(...args)}
|
|
299
|
+
/>
|
|
300
|
+
<br/>
|
|
301
|
+
<br/>
|
|
302
|
+
<div>type="month"</div>
|
|
303
|
+
<DatePicker
|
|
304
|
+
type="month"
|
|
305
|
+
insetInput={insetInput}
|
|
306
|
+
presetPosition={presetPosition}
|
|
307
|
+
presets={presetArr.map(preset => ({
|
|
240
308
|
text: preset.text,
|
|
241
309
|
start: preset.start,
|
|
242
310
|
}))}
|
|
243
311
|
onPresetClick={onPresetClick}
|
|
244
312
|
onChange={(...args) => console.log(...args)}
|
|
245
313
|
/>
|
|
314
|
+
<br/>
|
|
315
|
+
<br/>
|
|
316
|
+
<div>type="date" density="compact"</div>
|
|
317
|
+
<DatePicker
|
|
318
|
+
type="date"
|
|
319
|
+
presets={presetArr}
|
|
320
|
+
insetInput={insetInput}
|
|
321
|
+
density="compact"
|
|
322
|
+
presetPosition={presetPosition}
|
|
323
|
+
onPresetClick={onPresetClick}
|
|
324
|
+
onChange={(...args) => console.log(...args)}
|
|
325
|
+
/>
|
|
326
|
+
<br/>
|
|
327
|
+
<br/>
|
|
328
|
+
<div>type="dateTime" density="compact"</div>
|
|
246
329
|
<DatePicker
|
|
247
330
|
type="dateTime"
|
|
331
|
+
insetInput={insetInput}
|
|
248
332
|
needConfirm
|
|
249
|
-
|
|
333
|
+
density="compact"
|
|
334
|
+
presetPosition={presetPosition}
|
|
335
|
+
presets={presetArr.map(preset => ({
|
|
250
336
|
text: preset.text,
|
|
251
337
|
start: preset.start,
|
|
252
338
|
}))}
|
|
253
339
|
onPresetClick={onPresetClick}
|
|
254
340
|
onChange={(...args) => console.log(...args)}
|
|
255
341
|
/>
|
|
342
|
+
<br/>
|
|
343
|
+
<br/>
|
|
344
|
+
<div>type="dateRange" density="compact"</div>
|
|
345
|
+
<DatePicker
|
|
346
|
+
type="dateRange"
|
|
347
|
+
presets={presetArr}
|
|
348
|
+
density="compact"
|
|
349
|
+
insetInput={insetInput}
|
|
350
|
+
presetPosition={presetPosition}
|
|
351
|
+
onPresetClick={onPresetClick}
|
|
352
|
+
onChange={(...args) => console.log(...args)}
|
|
353
|
+
/>
|
|
354
|
+
<br/>
|
|
355
|
+
<br/>
|
|
356
|
+
<div>type="dateTimeRange" density="compact"</div>
|
|
357
|
+
<DatePicker
|
|
358
|
+
type="dateTimeRange"
|
|
359
|
+
density="compact"
|
|
360
|
+
presets={presetArr}
|
|
361
|
+
insetInput={insetInput}
|
|
362
|
+
presetPosition={presetPosition}
|
|
363
|
+
onPresetClick={onPresetClick}
|
|
364
|
+
onChange={(...args) => console.log(...args)}
|
|
365
|
+
/>
|
|
366
|
+
<br/>
|
|
367
|
+
<br/>
|
|
368
|
+
<div>type="month" density="compact"</div>
|
|
256
369
|
<DatePicker
|
|
257
370
|
type="month"
|
|
258
|
-
|
|
371
|
+
insetInput={insetInput}
|
|
372
|
+
presetPosition={presetPosition}
|
|
373
|
+
presets={presetArr.map(preset => ({
|
|
259
374
|
text: preset.text,
|
|
260
375
|
start: preset.start,
|
|
261
376
|
}))}
|
|
377
|
+
density="compact"
|
|
262
378
|
onPresetClick={onPresetClick}
|
|
263
379
|
onChange={(...args) => console.log(...args)}
|
|
264
380
|
/>
|
|
@@ -76,6 +76,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
76
76
|
max: PropTypes.number, // only work when multiple is true
|
|
77
77
|
placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
78
78
|
presets: PropTypes.array,
|
|
79
|
+
presetPosition: PropTypes.oneOf(strings.PRESET_POSITION_SET),
|
|
79
80
|
onChange: PropTypes.func,
|
|
80
81
|
onChangeWithDateFirst: PropTypes.bool,
|
|
81
82
|
weekStartsOn: PropTypes.number,
|
|
@@ -134,6 +135,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
134
135
|
stopPropagation: true,
|
|
135
136
|
motion: true,
|
|
136
137
|
prefixCls: cssClasses.PREFIX,
|
|
138
|
+
presetPosition: 'bottom',
|
|
137
139
|
// position: 'bottomLeft',
|
|
138
140
|
zIndex: popoverNumbers.DEFAULT_Z_INDEX,
|
|
139
141
|
type: 'date',
|
|
@@ -415,7 +417,8 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
415
417
|
onPanelChange,
|
|
416
418
|
timeZone,
|
|
417
419
|
triggerRender,
|
|
418
|
-
insetInput
|
|
420
|
+
insetInput,
|
|
421
|
+
presetPosition
|
|
419
422
|
} = this.props;
|
|
420
423
|
const { cachedSelectedValue, motionEnd, rangeInputFocus } = this.state;
|
|
421
424
|
|
|
@@ -456,21 +459,49 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
456
459
|
focusRecordsRef={this.focusRecordsRef}
|
|
457
460
|
triggerRender={triggerRender}
|
|
458
461
|
insetInput={insetInput}
|
|
462
|
+
presetPosition={presetPosition}
|
|
463
|
+
renderQuickControls={this.renderQuickControls()}
|
|
464
|
+
renderDateInput={this.renderDateInput()}
|
|
459
465
|
/>
|
|
460
466
|
);
|
|
461
467
|
}
|
|
462
468
|
|
|
463
469
|
renderQuickControls() {
|
|
464
|
-
const { presets, type } = this.props;
|
|
470
|
+
const { presets, type, presetPosition, insetInput } = this.props;
|
|
465
471
|
return (
|
|
466
472
|
<QuickControl
|
|
467
473
|
type={type}
|
|
468
474
|
presets={presets}
|
|
475
|
+
insetInput={insetInput}
|
|
476
|
+
presetPosition={presetPosition}
|
|
469
477
|
onPresetClick={(item, e) => this.foundation.handlePresetClick(item, e)}
|
|
470
478
|
/>
|
|
471
479
|
);
|
|
472
480
|
}
|
|
473
481
|
|
|
482
|
+
renderDateInput() {
|
|
483
|
+
const { insetInput, dateFnsLocale, density, type, format, rangeSeparator, defaultPickerValue } = this.props;
|
|
484
|
+
const { insetInputValue, value } = this.state;
|
|
485
|
+
|
|
486
|
+
const insetInputProps = {
|
|
487
|
+
dateFnsLocale,
|
|
488
|
+
format,
|
|
489
|
+
insetInputValue,
|
|
490
|
+
rangeSeparator,
|
|
491
|
+
type,
|
|
492
|
+
value: value as Date[],
|
|
493
|
+
handleInsetDateFocus: this.handleInsetDateFocus,
|
|
494
|
+
handleInsetTimeFocus: this.handleInsetTimeFocus,
|
|
495
|
+
onInsetInputChange: this.handleInsetInputChange,
|
|
496
|
+
rangeInputStartRef: this.rangeInputStartRef,
|
|
497
|
+
rangeInputEndRef: this.rangeInputEndRef,
|
|
498
|
+
density,
|
|
499
|
+
defaultPickerValue
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
return insetInput ? <DateInput {...insetInputProps} insetInput={true} /> : null;
|
|
503
|
+
}
|
|
504
|
+
|
|
474
505
|
handleOpenPanel = () => this.foundation.openPanel();
|
|
475
506
|
handleInputChange: DatePickerFoundation['handleInputChange'] = (...args) => this.foundation.handleInputChange(...args);
|
|
476
507
|
handleInsetInputChange = (options: InsetInputChangeProps) => this.foundation.handleInsetInputChange(options);
|
|
@@ -626,7 +657,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
626
657
|
};
|
|
627
658
|
|
|
628
659
|
renderPanel = (locale: Locale['DatePicker'], localeCode: string, dateFnsLocale: Locale['dateFnsLocale']) => {
|
|
629
|
-
const { dropdownClassName, dropdownStyle, density, topSlot, bottomSlot, insetInput, type, format, rangeSeparator, defaultPickerValue } = this.props;
|
|
660
|
+
const { dropdownClassName, dropdownStyle, density, topSlot, bottomSlot, insetInput, type, format, rangeSeparator, defaultPickerValue, presetPosition } = this.props;
|
|
630
661
|
const { insetInputValue, value } = this.state;
|
|
631
662
|
const wrapCls = classnames(
|
|
632
663
|
cssClasses.PREFIX,
|
|
@@ -654,17 +685,18 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
654
685
|
};
|
|
655
686
|
|
|
656
687
|
return (
|
|
657
|
-
<div ref={this.panelRef} className={wrapCls} style={dropdownStyle}>
|
|
688
|
+
<div ref={this.panelRef} className={wrapCls} style={dropdownStyle} >
|
|
658
689
|
{topSlot && (
|
|
659
690
|
<div className={`${cssClasses.PREFIX}-topSlot`} x-semi-prop="topSlot">
|
|
660
691
|
{topSlot}
|
|
661
692
|
</div>
|
|
662
693
|
)}
|
|
663
|
-
{
|
|
694
|
+
{presetPosition === "top" && this.renderQuickControls()}
|
|
695
|
+
{/* {insetInput && <DateInput {...insetInputProps} insetInput={true} />} */}
|
|
664
696
|
{this.adapter.typeIsYearOrMonth()
|
|
665
697
|
? this.renderYearMonthPanel(locale, localeCode)
|
|
666
698
|
: this.renderMonthGrid(locale, localeCode, dateFnsLocale)}
|
|
667
|
-
{this.renderQuickControls()}
|
|
699
|
+
{presetPosition === "bottom" && this.renderQuickControls()}
|
|
668
700
|
{bottomSlot && (
|
|
669
701
|
<div className={`${cssClasses.PREFIX}-bottomSlot`} x-semi-prop="bottomSlot">
|
|
670
702
|
{bottomSlot}
|
|
@@ -676,7 +708,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
676
708
|
};
|
|
677
709
|
|
|
678
710
|
renderYearMonthPanel = (locale: Locale['DatePicker'], localeCode: string) => {
|
|
679
|
-
const { density } = this.props;
|
|
711
|
+
const { density, presetPosition } = this.props;
|
|
680
712
|
|
|
681
713
|
const date = this.state.value[0];
|
|
682
714
|
let year = 0;
|
|
@@ -698,6 +730,9 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
698
730
|
currentYear={year}
|
|
699
731
|
currentMonth={month}
|
|
700
732
|
density={density}
|
|
733
|
+
presetPosition={presetPosition}
|
|
734
|
+
renderQuickControls={this.renderQuickControls()}
|
|
735
|
+
renderDateInput={this.renderDateInput()}
|
|
701
736
|
/>
|
|
702
737
|
);
|
|
703
738
|
};
|
|
@@ -76,6 +76,9 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
76
76
|
onPanelChange: PropTypes.func,
|
|
77
77
|
focusRecordsRef: PropTypes.object,
|
|
78
78
|
triggerRender: PropTypes.func,
|
|
79
|
+
presetPosition: PropTypes.oneOf(strings.PRESET_POSITION_SET),
|
|
80
|
+
renderQuickControls: PropTypes.node,
|
|
81
|
+
renderDateInput: PropTypes.node
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
static defaultProps = {
|
|
@@ -600,9 +603,10 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
600
603
|
);
|
|
601
604
|
}
|
|
602
605
|
|
|
606
|
+
|
|
603
607
|
render() {
|
|
604
608
|
const { monthLeft, monthRight } = this.state;
|
|
605
|
-
const { type, insetInput } = this.props;
|
|
609
|
+
const { type, insetInput, presetPosition, renderQuickControls, renderDateInput } = this.props;
|
|
606
610
|
const monthGridCls = classnames({
|
|
607
611
|
[`${prefixCls }-month-grid`]: true,
|
|
608
612
|
});
|
|
@@ -622,15 +626,23 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
622
626
|
const yearOpenType = this.getYAMOpenType();
|
|
623
627
|
|
|
624
628
|
return (
|
|
625
|
-
<div
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
629
|
+
<div style={{ display: 'flex' }}>
|
|
630
|
+
{presetPosition === "left" && renderQuickControls}
|
|
631
|
+
<div>
|
|
632
|
+
{renderDateInput}
|
|
633
|
+
<div
|
|
634
|
+
className={monthGridCls}
|
|
635
|
+
x-type={type}
|
|
636
|
+
x-panel-yearandmonth-open-type={yearOpenType}
|
|
637
|
+
// FIXME:
|
|
638
|
+
x-insetinput={insetInput ? "true" : "false"}
|
|
639
|
+
x-preset-position={renderQuickControls === null ? 'null' : presetPosition}
|
|
640
|
+
ref={current => this.cacheRefCurrent('monthGrid', current)}
|
|
641
|
+
>
|
|
642
|
+
{content}
|
|
643
|
+
</div>
|
|
644
|
+
</div>
|
|
645
|
+
{presetPosition === "right" && renderQuickControls}
|
|
634
646
|
</div>
|
|
635
647
|
);
|
|
636
648
|
}
|