@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
package/dist/umd/semi-ui.js
CHANGED
|
@@ -52505,12 +52505,10 @@ class foundation_DatePickerFoundation extends foundation {
|
|
|
52505
52505
|
* 2. set cachedSelectedValue using given dates(in needConfirm mode)
|
|
52506
52506
|
* - directly closePanel without click confirm will set cachedSelectedValue to state value
|
|
52507
52507
|
* - select one date(which means that the selection value is incomplete) and click confirm also set cachedSelectedValue to state value
|
|
52508
|
-
* @param {String} inputValue
|
|
52509
|
-
* @param {Date[]} dates
|
|
52510
52508
|
*/
|
|
52511
52509
|
|
|
52512
52510
|
|
|
52513
|
-
rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
52511
|
+
rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates) {
|
|
52514
52512
|
if (this._isRangeType()) {
|
|
52515
52513
|
this._adapter.setRangeInputFocus(false);
|
|
52516
52514
|
/**
|
|
@@ -52520,17 +52518,36 @@ class foundation_DatePickerFoundation extends foundation {
|
|
|
52520
52518
|
|
|
52521
52519
|
|
|
52522
52520
|
this.handleInputBlur(inputValue);
|
|
52521
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
52522
|
+
}
|
|
52523
|
+
}
|
|
52524
|
+
/**
|
|
52525
|
+
* clear input value when selected date is not confirmed
|
|
52526
|
+
*/
|
|
52523
52527
|
|
|
52524
|
-
const {
|
|
52525
|
-
value,
|
|
52526
|
-
cachedSelectedValue
|
|
52527
|
-
} = this._adapter.getStates();
|
|
52528
52528
|
|
|
52529
|
-
|
|
52529
|
+
needConfirmSideEffectsWhenClosePanel(willUpdateDates) {
|
|
52530
|
+
if (this._adapter.needConfirm() && !this._isRangeType()) {
|
|
52531
|
+
/**
|
|
52532
|
+
* if `null` input element will show `cachedSelectedValue` formatted value(format in DateInput render)
|
|
52533
|
+
* if `` input element will show `` directly
|
|
52534
|
+
*/
|
|
52535
|
+
this._adapter.updateInputValue(null);
|
|
52530
52536
|
|
|
52531
|
-
|
|
52532
|
-
|
|
52533
|
-
|
|
52537
|
+
this.resetCachedSelectedValue(willUpdateDates);
|
|
52538
|
+
}
|
|
52539
|
+
}
|
|
52540
|
+
|
|
52541
|
+
resetCachedSelectedValue(willUpdateDates) {
|
|
52542
|
+
const {
|
|
52543
|
+
value,
|
|
52544
|
+
cachedSelectedValue
|
|
52545
|
+
} = this._adapter.getStates();
|
|
52546
|
+
|
|
52547
|
+
const newCachedSelectedValue = is_array_default()(willUpdateDates) ? willUpdateDates : value;
|
|
52548
|
+
|
|
52549
|
+
if (!isEqual_default()(newCachedSelectedValue, cachedSelectedValue)) {
|
|
52550
|
+
this._adapter.updateCachedSelectedValue(newCachedSelectedValue);
|
|
52534
52551
|
}
|
|
52535
52552
|
}
|
|
52536
52553
|
/**
|
|
@@ -52549,7 +52566,14 @@ class foundation_DatePickerFoundation extends foundation {
|
|
|
52549
52566
|
|
|
52550
52567
|
closePanel(e) {
|
|
52551
52568
|
let inputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
52552
|
-
let dates = arguments.length > 2
|
|
52569
|
+
let dates = arguments.length > 2 ? arguments[2] : undefined;
|
|
52570
|
+
|
|
52571
|
+
const {
|
|
52572
|
+
value,
|
|
52573
|
+
cachedSelectedValue
|
|
52574
|
+
} = this._adapter.getStates();
|
|
52575
|
+
|
|
52576
|
+
const willUpdateDates = isNullOrUndefined(dates) ? this._adapter.needConfirm() ? value : cachedSelectedValue : dates;
|
|
52553
52577
|
|
|
52554
52578
|
if (!this._isControlledComponent('open')) {
|
|
52555
52579
|
this._adapter.togglePanel(false);
|
|
@@ -52558,7 +52582,8 @@ class foundation_DatePickerFoundation extends foundation {
|
|
|
52558
52582
|
} // range type picker, closing panel requires the following side effects
|
|
52559
52583
|
|
|
52560
52584
|
|
|
52561
|
-
this.rangeTypeSideEffectsWhenClosePanel(inputValue,
|
|
52585
|
+
this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates);
|
|
52586
|
+
this.needConfirmSideEffectsWhenClosePanel(willUpdateDates);
|
|
52562
52587
|
|
|
52563
52588
|
this._adapter.notifyOpenChange(false);
|
|
52564
52589
|
|
|
@@ -52620,7 +52645,8 @@ class foundation_DatePickerFoundation extends foundation {
|
|
|
52620
52645
|
if (parsedResult && parsedResult.length) {
|
|
52621
52646
|
this._updateValueAndInput(parsedResult, input === '');
|
|
52622
52647
|
} else if (input === '') {
|
|
52623
|
-
|
|
52648
|
+
// if clear input, set input to `''`
|
|
52649
|
+
this._updateValueAndInput('', true, '');
|
|
52624
52650
|
} else {
|
|
52625
52651
|
this._updateValueAndInput(stateValue);
|
|
52626
52652
|
}
|
|
@@ -53527,6 +53553,9 @@ class inputFoundation_InputFoundation extends foundation {
|
|
|
53527
53553
|
}
|
|
53528
53554
|
|
|
53529
53555
|
handleRangeInputClear(e) {
|
|
53556
|
+
// prevent trigger click outside
|
|
53557
|
+
this.stopPropagation(e);
|
|
53558
|
+
|
|
53530
53559
|
this._adapter.notifyRangeInputClear(e);
|
|
53531
53560
|
}
|
|
53532
53561
|
|
|
@@ -59224,6 +59253,10 @@ class datePicker_DatePicker extends baseComponent_BaseComponent {
|
|
|
59224
59253
|
}
|
|
59225
59254
|
|
|
59226
59255
|
this.clickOutSideHandler = e => {
|
|
59256
|
+
if (this.adapter.needConfirm()) {
|
|
59257
|
+
return;
|
|
59258
|
+
}
|
|
59259
|
+
|
|
59227
59260
|
const triggerEl = this.triggerElRef && this.triggerElRef.current;
|
|
59228
59261
|
const panelEl = this.panelRef && this.panelRef.current;
|
|
59229
59262
|
const isInTrigger = triggerEl && triggerEl.contains(e.target);
|