@douyinfe/semi-foundation 2.2.1 → 2.2.2

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.
@@ -745,7 +745,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
745
745
  let inputValue;
746
746
  if (!this._someDateDisabled(changedDates)) {
747
747
  inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
748
- const isRangeTypeAndInputIncomplete = this._isRangeType() && (isNullOrUndefined(dates[0]) || isNullOrUndefined(dates[1]));
748
+ const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
749
749
  /**
750
750
  * If the input is incomplete when under control, the notifyChange is not triggered because
751
751
  * You need to update the value of the input box, otherwise there will be a problem that a date is selected but the input box does not show the date #1357
@@ -1024,11 +1024,9 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
1024
1024
  };
1025
1025
 
1026
1026
  _isRangeValueComplete = (value: Date[] | Date) => {
1027
- let result = true;
1027
+ let result = false;
1028
1028
  if (Array.isArray(value)) {
1029
1029
  result = !value.some(date => isNullOrUndefined(date));
1030
- } else {
1031
- result = false;
1032
1030
  }
1033
1031
  return result;
1034
1032
  };
@@ -16,7 +16,7 @@ import {
16
16
  import { isBefore, isValidDate, getDefaultFormatToken, getFullDateOffset } from './_utils/index';
17
17
  import { formatFullDate, WeekStartNumber } from './_utils/getMonthTable';
18
18
  import { compatiableParse } from './_utils/parser';
19
- import { includes, isSet, isEqual } from 'lodash';
19
+ import { includes, isSet, isEqual, isFunction } from 'lodash';
20
20
  import { zonedTimeToUtc } from '../utils/date-fns-extra';
21
21
  import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
22
22
  import isNullOrUndefined from '../utils/isNullOrUndefined';
@@ -85,6 +85,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
85
85
  setRangeInputFocus?: (rangeInputFocus: 'rangeStart' | 'rangeEnd') => void;
86
86
  isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
87
87
  focusRecordsRef?: any;
88
+ triggerRender?: (props: Record<string, any>) => any;
88
89
  }
89
90
 
90
91
  export interface MonthInfo {
@@ -636,7 +637,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
636
637
 
637
638
  handleRangeSelected(day: MonthDayInfo) {
638
639
  let { rangeStart, rangeEnd } = this.getStates();
639
- const { startDateOffset, endDateOffset, type, dateFnsLocale, rangeInputFocus } = this.getProps();
640
+ const { startDateOffset, endDateOffset, type, dateFnsLocale, rangeInputFocus, triggerRender } = this._adapter.getProps();
640
641
  const { fullDate } = day;
641
642
  let rangeStartReset = false;
642
643
  let rangeEndReset = false;
@@ -712,7 +713,13 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
712
713
  date = [start, end];
713
714
  }
714
715
  }
715
- this._adapter.notifySelectedChange(date, { needCheckFocusRecord: !(type === 'dateRange' && isDateRangeAndHasOffset) });
716
+ /**
717
+ * no need to check focus then
718
+ * - dateRange and isDateRangeAndHasOffset
719
+ * - dateRange and triggerRender
720
+ */
721
+ const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || isFunction(triggerRender)));
722
+ this._adapter.notifySelectedChange(date, { needCheckFocusRecord });
716
723
  }
717
724
  }
718
725
 
@@ -126,6 +126,7 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
126
126
  }
127
127
  this._adapter.recordCursorPosition();
128
128
  this._adapter.setFocusing(true, null);
129
+ this._adapter.setClickUpOrDown(false);
129
130
  this._adapter.notifyFocus(e);
130
131
  }
131
132
 
@@ -425,11 +426,11 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
425
426
 
426
427
  /**
427
428
  * format number to string
428
- * @param {number} value
429
+ * @param {string|number} value
429
430
  * @param {boolean} needAdjustPrec
430
431
  * @returns {string}
431
432
  */
432
- doFormat(value = 0, needAdjustPrec = true): string {
433
+ doFormat(value: string | number = 0, needAdjustPrec = true): string {
433
434
  // if (typeof value === 'string') {
434
435
  // return value;
435
436
  // }
@@ -96,12 +96,10 @@ class DatePickerFoundation extends _foundation.default {
96
96
  };
97
97
 
98
98
  this._isRangeValueComplete = value => {
99
- let result = true;
99
+ let result = false;
100
100
 
101
101
  if ((0, _isArray.default)(value)) {
102
102
  result = !(0, _some.default)(value).call(value, date => (0, _isNullOrUndefined.default)(date));
103
- } else {
104
- result = false;
105
103
  }
106
104
 
107
105
  return result;
@@ -755,7 +753,7 @@ class DatePickerFoundation extends _foundation.default {
755
753
 
756
754
  if (!this._someDateDisabled(changedDates)) {
757
755
  inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
758
- const isRangeTypeAndInputIncomplete = this._isRangeType() && ((0, _isNullOrUndefined.default)(dates[0]) || (0, _isNullOrUndefined.default)(dates[1]));
756
+ const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
759
757
  /**
760
758
  * If the input is incomplete when under control, the notifyChange is not triggered because
761
759
  * You need to update the value of the input box, otherwise there will be a problem that a date is selected but the input box does not show the date #1357
@@ -53,6 +53,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
53
53
  setRangeInputFocus?: (rangeInputFocus: 'rangeStart' | 'rangeEnd') => void;
54
54
  isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
55
55
  focusRecordsRef?: any;
56
+ triggerRender?: (props: Record<string, any>) => any;
56
57
  }
57
58
  export interface MonthInfo {
58
59
  pickerDate: Date;
@@ -28,6 +28,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
28
28
 
29
29
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
30
30
 
31
+ var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
32
+
31
33
  var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
32
34
 
33
35
  var _isSet2 = _interopRequireDefault(require("lodash/isSet"));
@@ -731,13 +733,16 @@ class MonthsGridFoundation extends _foundation.default {
731
733
  rangeStart,
732
734
  rangeEnd
733
735
  } = this.getStates();
736
+
734
737
  const {
735
738
  startDateOffset,
736
739
  endDateOffset,
737
740
  type,
738
741
  dateFnsLocale,
739
- rangeInputFocus
740
- } = this.getProps();
742
+ rangeInputFocus,
743
+ triggerRender
744
+ } = this._adapter.getProps();
745
+
741
746
  const {
742
747
  fullDate
743
748
  } = day;
@@ -818,9 +823,17 @@ class MonthsGridFoundation extends _foundation.default {
818
823
  date = [start, end];
819
824
  }
820
825
  }
826
+ /**
827
+ * no need to check focus then
828
+ * - dateRange and isDateRangeAndHasOffset
829
+ * - dateRange and triggerRender
830
+ */
831
+
832
+
833
+ const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || (0, _isFunction2.default)(triggerRender)));
821
834
 
822
835
  this._adapter.notifySelectedChange(date, {
823
- needCheckFocusRecord: !(type === 'dateRange' && isDateRangeAndHasOffset)
836
+ needCheckFocusRecord
824
837
  });
825
838
  }
826
839
  }
@@ -63,11 +63,11 @@ declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
63
63
  _adjustPrec(num: string | number): string;
64
64
  /**
65
65
  * format number to string
66
- * @param {number} value
66
+ * @param {string|number} value
67
67
  * @param {boolean} needAdjustPrec
68
68
  * @returns {string}
69
69
  */
70
- doFormat(value?: number, needAdjustPrec?: boolean): string;
70
+ doFormat(value?: string | number, needAdjustPrec?: boolean): string;
71
71
  /**
72
72
  *
73
73
  * @param {number} current
@@ -140,6 +140,8 @@ class InputNumberFoundation extends _foundation.default {
140
140
 
141
141
  this._adapter.setFocusing(true, null);
142
142
 
143
+ this._adapter.setClickUpOrDown(false);
144
+
143
145
  this._adapter.notifyFocus(e);
144
146
  }
145
147
  /**
@@ -476,7 +478,7 @@ class InputNumberFoundation extends _foundation.default {
476
478
  }
477
479
  /**
478
480
  * format number to string
479
- * @param {number} value
481
+ * @param {string|number} value
480
482
  * @param {boolean} needAdjustPrec
481
483
  * @returns {string}
482
484
  */
@@ -58,12 +58,10 @@ export default class DatePickerFoundation extends BaseFoundation {
58
58
  };
59
59
 
60
60
  this._isRangeValueComplete = value => {
61
- let result = true;
61
+ let result = false;
62
62
 
63
63
  if (_Array$isArray(value)) {
64
64
  result = !_someInstanceProperty(value).call(value, date => isNullOrUndefined(date));
65
- } else {
66
- result = false;
67
65
  }
68
66
 
69
67
  return result;
@@ -721,7 +719,7 @@ export default class DatePickerFoundation extends BaseFoundation {
721
719
 
722
720
  if (!this._someDateDisabled(changedDates)) {
723
721
  inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
724
- const isRangeTypeAndInputIncomplete = this._isRangeType() && (isNullOrUndefined(dates[0]) || isNullOrUndefined(dates[1]));
722
+ const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
725
723
  /**
726
724
  * If the input is incomplete when under control, the notifyChange is not triggered because
727
725
  * You need to update the value of the input box, otherwise there will be a problem that a date is selected but the input box does not show the date #1357
@@ -53,6 +53,7 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
53
53
  setRangeInputFocus?: (rangeInputFocus: 'rangeStart' | 'rangeEnd') => void;
54
54
  isAnotherPanelHasOpened?: (currentRangeInput: 'rangeStart' | 'rangeEnd') => boolean;
55
55
  focusRecordsRef?: any;
56
+ triggerRender?: (props: Record<string, any>) => any;
56
57
  }
57
58
  export interface MonthInfo {
58
59
  pickerDate: Date;
@@ -1,3 +1,4 @@
1
+ import _isFunction from "lodash/isFunction";
1
2
  import _isEqual from "lodash/isEqual";
2
3
  import _isSet from "lodash/isSet";
3
4
  import _includes from "lodash/includes";
@@ -704,13 +705,16 @@ export default class MonthsGridFoundation extends BaseFoundation {
704
705
  rangeStart,
705
706
  rangeEnd
706
707
  } = this.getStates();
708
+
707
709
  const {
708
710
  startDateOffset,
709
711
  endDateOffset,
710
712
  type,
711
713
  dateFnsLocale,
712
- rangeInputFocus
713
- } = this.getProps();
714
+ rangeInputFocus,
715
+ triggerRender
716
+ } = this._adapter.getProps();
717
+
714
718
  const {
715
719
  fullDate
716
720
  } = day;
@@ -791,9 +795,17 @@ export default class MonthsGridFoundation extends BaseFoundation {
791
795
  date = [start, end];
792
796
  }
793
797
  }
798
+ /**
799
+ * no need to check focus then
800
+ * - dateRange and isDateRangeAndHasOffset
801
+ * - dateRange and triggerRender
802
+ */
803
+
804
+
805
+ const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || _isFunction(triggerRender)));
794
806
 
795
807
  this._adapter.notifySelectedChange(date, {
796
- needCheckFocusRecord: !(type === 'dateRange' && isDateRangeAndHasOffset)
808
+ needCheckFocusRecord
797
809
  });
798
810
  }
799
811
  }
@@ -63,11 +63,11 @@ declare class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
63
63
  _adjustPrec(num: string | number): string;
64
64
  /**
65
65
  * format number to string
66
- * @param {number} value
66
+ * @param {string|number} value
67
67
  * @param {boolean} needAdjustPrec
68
68
  * @returns {string}
69
69
  */
70
- doFormat(value?: number, needAdjustPrec?: boolean): string;
70
+ doFormat(value?: string | number, needAdjustPrec?: boolean): string;
71
71
  /**
72
72
  *
73
73
  * @param {number} current
@@ -116,6 +116,8 @@ class InputNumberFoundation extends BaseFoundation {
116
116
 
117
117
  this._adapter.setFocusing(true, null);
118
118
 
119
+ this._adapter.setClickUpOrDown(false);
120
+
119
121
  this._adapter.notifyFocus(e);
120
122
  }
121
123
  /**
@@ -454,7 +456,7 @@ class InputNumberFoundation extends BaseFoundation {
454
456
  }
455
457
  /**
456
458
  * format number to string
457
- * @param {number} value
459
+ * @param {string|number} value
458
460
  * @param {boolean} needAdjustPrec
459
461
  * @returns {string}
460
462
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@babel/runtime-corejs3": "^7.15.4",
11
- "@douyinfe/semi-animation": "2.2.1",
11
+ "@douyinfe/semi-animation": "2.2.2",
12
12
  "async-validator": "^3.5.0",
13
13
  "classnames": "^2.2.6",
14
14
  "date-fns": "^2.9.0",
@@ -24,7 +24,7 @@
24
24
  "*.scss",
25
25
  "*.css"
26
26
  ],
27
- "gitHead": "6d8bb9dd22bf199225fa2a0dda4f8524a4b97f6f",
27
+ "gitHead": "de84e4f81bb443c457c075e808c4bd1fcf9441d7",
28
28
  "devDependencies": {
29
29
  "@babel/plugin-proposal-decorators": "^7.15.8",
30
30
  "@babel/plugin-transform-runtime": "^7.15.8",