@douyinfe/semi-ui 2.2.0 → 2.2.1
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/datePicker/__test__/datePicker.test.js +15 -0
- package/datePicker/_story/datePicker.stories.js +62 -1
- package/datePicker/datePicker.tsx +3 -0
- package/dist/css/semi.css +26 -4
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +47 -14
- 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/datePicker/datePicker.js +4 -0
- package/lib/es/datePicker/datePicker.js +4 -0
- package/package.json +8 -8
|
@@ -191,12 +191,27 @@ describe(`DatePicker`, () => {
|
|
|
191
191
|
btns[0].click();
|
|
192
192
|
await sleep();
|
|
193
193
|
expect(_.first(elem.state('value')).getDate() === currentValue.getDate()).toBeTruthy();
|
|
194
|
+
expect(_.isEqual(elem.state('cachedSelectedValue'), [currentValue])).toBe(true);
|
|
194
195
|
|
|
195
196
|
/**
|
|
196
197
|
* click ensure button
|
|
197
198
|
*/
|
|
198
199
|
btns[1].click();
|
|
199
200
|
await sleep();
|
|
201
|
+
expect(_.first(elem.state('value')).getDate() === currentValue.getDate()).toBe(true);
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* re click next day
|
|
205
|
+
*/
|
|
206
|
+
nextOffsetDayElem.click();
|
|
207
|
+
await sleep();
|
|
208
|
+
expect(_.first(elem.state('value')).getDate() === currentValue.getDate()).toBeTruthy();
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* re click ensure button
|
|
212
|
+
*/
|
|
213
|
+
btns[1].click();
|
|
214
|
+
await sleep();
|
|
200
215
|
expect(_.first(elem.state('value')).getDate() - currentValue.getDate()).toBe(dayOffset);
|
|
201
216
|
|
|
202
217
|
demo.unmount();
|
|
@@ -661,4 +661,65 @@ export const FixParseISOBug = () => (
|
|
|
661
661
|
FixParseISOBug.storyName = '修复 parseISO bug';
|
|
662
662
|
FixParseISOBug.parameters = {
|
|
663
663
|
chromatic: { disableSnapshot: false },
|
|
664
|
-
};
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
export const FixNeedConfirm = () => {
|
|
667
|
+
const defaultDate = '2021-12-27 10:37:13';
|
|
668
|
+
const defaultDateRange = ['2021-12-27 10:37:13', '2022-01-28 10:37:13' ];
|
|
669
|
+
const props = {
|
|
670
|
+
needConfirm: true,
|
|
671
|
+
onConfirm: (...args) => {
|
|
672
|
+
console.log('Confirmed: ', ...args);
|
|
673
|
+
},
|
|
674
|
+
onChange: (...args) => {
|
|
675
|
+
console.log('Changed: ', ...args);
|
|
676
|
+
},
|
|
677
|
+
onCancel: (...args) => {
|
|
678
|
+
console.log('Canceled: ', ...args);
|
|
679
|
+
},
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
return (
|
|
683
|
+
<div>
|
|
684
|
+
<div data-cy="1">
|
|
685
|
+
<span>dateTime + needConfirm + defaultValue</span>
|
|
686
|
+
<div>
|
|
687
|
+
<DatePicker
|
|
688
|
+
type="dateTime"
|
|
689
|
+
defaultValue={defaultDate}
|
|
690
|
+
{...props}
|
|
691
|
+
/>
|
|
692
|
+
</div>
|
|
693
|
+
</div>
|
|
694
|
+
<div data-cy="2">
|
|
695
|
+
<span>dateTime + needConfirm</span>
|
|
696
|
+
<div>
|
|
697
|
+
<DatePicker
|
|
698
|
+
type="dateTime"
|
|
699
|
+
{...props}
|
|
700
|
+
/>
|
|
701
|
+
</div>
|
|
702
|
+
</div>
|
|
703
|
+
<div data-cy="3">
|
|
704
|
+
<span>dateTimeRange + needConfirm + defaultValue</span>
|
|
705
|
+
<div>
|
|
706
|
+
<DatePicker
|
|
707
|
+
type="dateTimeRange"
|
|
708
|
+
defaultValue={defaultDateRange}
|
|
709
|
+
{...props}
|
|
710
|
+
/>
|
|
711
|
+
</div>
|
|
712
|
+
</div>
|
|
713
|
+
<div data-cy="4">
|
|
714
|
+
<span>dateTimeRange + needConfirm</span>
|
|
715
|
+
<div>
|
|
716
|
+
<DatePicker
|
|
717
|
+
type="dateTimeRange"
|
|
718
|
+
{...props}
|
|
719
|
+
/>
|
|
720
|
+
</div>
|
|
721
|
+
</div>
|
|
722
|
+
</div>
|
|
723
|
+
)
|
|
724
|
+
}
|
|
725
|
+
FixNeedConfirm.storyName = '修复 needConfirm 取消后输入框显示错误';
|
|
@@ -206,6 +206,9 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
206
206
|
this.clickOutSideHandler = null;
|
|
207
207
|
}
|
|
208
208
|
this.clickOutSideHandler = e => {
|
|
209
|
+
if (this.adapter.needConfirm()) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
209
212
|
const triggerEl = this.triggerElRef && this.triggerElRef.current;
|
|
210
213
|
const panelEl = this.panelRef && this.panelRef.current;
|
|
211
214
|
const isInTrigger = triggerEl && triggerEl.contains(e.target as Node);
|
package/dist/css/semi.css
CHANGED
|
@@ -3524,6 +3524,12 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
3524
3524
|
text-align: right;
|
|
3525
3525
|
background-color: var(--semi-color-fill-0);
|
|
3526
3526
|
}
|
|
3527
|
+
.semi-datepicker-footer .semi-button:first-of-type {
|
|
3528
|
+
margin-right: 12px;
|
|
3529
|
+
}
|
|
3530
|
+
.semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
3531
|
+
margin-right: 8px;
|
|
3532
|
+
}
|
|
3527
3533
|
.semi-datepicker-yam {
|
|
3528
3534
|
position: absolute;
|
|
3529
3535
|
top: 0;
|
|
@@ -4131,6 +4137,16 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
4131
4137
|
padding-left: 8px;
|
|
4132
4138
|
text-align: left;
|
|
4133
4139
|
}
|
|
4140
|
+
.semi-rtl .semi-datepicker-footer .semi-button:first-of-type,
|
|
4141
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:first-of-type {
|
|
4142
|
+
margin-left: 0;
|
|
4143
|
+
margin-right: 0;
|
|
4144
|
+
}
|
|
4145
|
+
.semi-rtl .semi-datepicker-footer .semi-button:nth-of-type(2),
|
|
4146
|
+
.semi-portal-rtl .semi-datepicker-footer .semi-button:nth-of-type(2) {
|
|
4147
|
+
margin-right: 12px;
|
|
4148
|
+
margin-left: 0;
|
|
4149
|
+
}
|
|
4134
4150
|
.semi-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main,
|
|
4135
4151
|
.semi-portal-rtl .semi-datepicker-day-offsetrange-start .semi-datepicker-day-main {
|
|
4136
4152
|
border-radius: 0 var(--semi-border-radius-small) var(--semi-border-radius-small) 0;
|
|
@@ -4166,12 +4182,20 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
4166
4182
|
margin-right: 8px;
|
|
4167
4183
|
}
|
|
4168
4184
|
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
4169
|
-
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
4185
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
4186
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
4187
|
+
.semi-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right, .semi-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
4170
4188
|
.semi-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
4189
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
4190
|
+
.semi-rtl .semi-datepicker-yam .semi-icon-double_chevron_right,
|
|
4171
4191
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_left,
|
|
4172
4192
|
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-chevron_right,
|
|
4193
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_left,
|
|
4194
|
+
.semi-portal-rtl .semi-datepicker-navigation .semi-icon-double_chevron_right,
|
|
4173
4195
|
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_left,
|
|
4174
|
-
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right
|
|
4196
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-chevron_right,
|
|
4197
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_left,
|
|
4198
|
+
.semi-portal-rtl .semi-datepicker-yam .semi-icon-double_chevron_right {
|
|
4175
4199
|
transform: scaleX(-1);
|
|
4176
4200
|
}
|
|
4177
4201
|
.semi-rtl .semi-datepicker-range-input-prefix,
|
|
@@ -16104,12 +16128,10 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
16104
16128
|
color: var(--semi-color-text-0);
|
|
16105
16129
|
width: 100%;
|
|
16106
16130
|
}
|
|
16107
|
-
.semi-table-middle .semi-table-thead > .semi-table-row > .semi-table-row-head,
|
|
16108
16131
|
.semi-table-middle .semi-table-tbody > .semi-table-row > .semi-table-row-cell {
|
|
16109
16132
|
padding-top: 12px;
|
|
16110
16133
|
padding-bottom: 12px;
|
|
16111
16134
|
}
|
|
16112
|
-
.semi-table-small .semi-table-thead > .semi-table-row > .semi-table-row-head,
|
|
16113
16135
|
.semi-table-small .semi-table-tbody > .semi-table-row > .semi-table-row-cell {
|
|
16114
16136
|
padding-top: 8px;
|
|
16115
16137
|
padding-bottom: 8px;
|