@douyinfe/semi-foundation 2.15.0-beta.0 → 2.15.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.
@@ -101,15 +101,6 @@ $module: #{$prefix}-checkbox;
101
101
  font-size: 16px;
102
102
  }
103
103
  }
104
-
105
- &-pureCardType {
106
- // Reasons to use opacity:0 & width: 0 instead of display: none
107
- // The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
108
- // input focus/blur cannot take effect when display: none
109
- opacity: 0;
110
- width: 0;
111
- margin-right: 0 !important;
112
- }
113
104
  }
114
105
 
115
106
  &-inner-checked {
@@ -196,6 +187,15 @@ $module: #{$prefix}-checkbox;
196
187
  flex-shrink: 0;
197
188
  }
198
189
 
190
+ .#{$module}-inner-pureCardType {
191
+ // Reasons to use opacity:0 & width: 0 instead of display: none
192
+ // The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
193
+ // input focus/blur cannot take effect when display: none
194
+ opacity: 0;
195
+ width: 0;
196
+ margin-right: 0;
197
+ }
198
+
199
199
  .#{$module}-addon {
200
200
  font-weight: $font-checkbox_cardType_addon-fontWeight;
201
201
  font-size: $font-checkbox_cardType_addon-size;
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-nested-ternary */
2
2
  /* eslint-disable max-len, max-depth, */
3
3
  import { format, isValid, isSameSecond, isEqual as isDateEqual, isDate } from 'date-fns';
4
- import { get, isObject, isString, isEqual } from 'lodash';
4
+ import { get, isObject, isString, isEqual, isFunction } from 'lodash';
5
5
 
6
6
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
7
7
  import { isValidDate, isTimestamp } from './_utils/index';
@@ -246,6 +246,23 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
246
246
  this._adapter.updateInputValue(null);
247
247
  this._adapter.updateValue(result);
248
248
  this.resetCachedSelectedValue(result);
249
+ this.initRangeInputFocus(result);
250
+
251
+ if (this._adapter.needConfirm()) {
252
+ this._adapter.updateCachedSelectedValue(result);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * 如果用户传了一个空的 value,需要把 range input focus 设置为 rangeStart,这样用户可以清除完之后继续从开始选择
258
+ *
259
+ * If the user passes an empty value, you need to set the range input focus to rangeStart, so that the user can continue to select from the beginning after clearing
260
+ */
261
+ initRangeInputFocus(result: Date[]) {
262
+ const { triggerRender } = this.getProps();
263
+ if (this._isRangeType() && isFunction(triggerRender) && result.length === 0) {
264
+ this._adapter.setRangeInputFocus('rangeStart');
265
+ }
249
266
  }
250
267
 
251
268
  parseWithTimezone(value: ValueType, timeZone: string | number, prevTimeZone: string | number) {
@@ -1286,7 +1303,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
1286
1303
  * @returns
1287
1304
  */
1288
1305
  handleTriggerWrapperClick(e: any) {
1289
- const { disabled } = this._adapter.getProps();
1306
+ const { disabled, triggerRender } = this._adapter.getProps();
1290
1307
  const { rangeInputFocus } = this._adapter.getStates();
1291
1308
  if (disabled) {
1292
1309
  return;
@@ -1298,12 +1315,18 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
1298
1315
  * - When type is not range type, Input component will automatically focus in the same case
1299
1316
  * - isEventTarget is used to judge whether the event is a bubbling event
1300
1317
  */
1301
- if (this._isRangeType() && !rangeInputFocus && this._adapter.isEventTarget(e)) {
1302
- setTimeout(() => {
1303
- // using setTimeout get correct state value 'rangeInputFocus'
1304
- this.handleInputFocus(e, 'rangeStart');
1305
- this.openPanel();
1306
- }, 0);
1318
+ if (this._isRangeType() && !rangeInputFocus) {
1319
+ if (this._adapter.isEventTarget(e)) {
1320
+ setTimeout(() => {
1321
+ // using setTimeout get correct state value 'rangeInputFocus'
1322
+ this.handleInputFocus(e, 'rangeStart');
1323
+ }, 0);
1324
+ } else if (isFunction(triggerRender)) {
1325
+ // 如果是 triggerRender 场景,因为没有 input,因此打开面板时默认 focus 在 rangeStart
1326
+ // If it is a triggerRender scene, because there is no input, the default focus is rangeStart when the panel is opened
1327
+ this._adapter.setRangeInputFocus('rangeStart');
1328
+ }
1329
+ this.openPanel();
1307
1330
  } else {
1308
1331
  this.openPanel();
1309
1332
  }
@@ -724,9 +724,8 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
724
724
  /**
725
725
  * no need to check focus then
726
726
  * - dateRange and isDateRangeAndHasOffset
727
- * - dateRange and triggerRender
728
727
  */
729
- const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || isFunction(triggerRender)));
728
+ const needCheckFocusRecord = !(type === 'dateRange' && isDateRangeAndHasOffset);
730
729
  this._adapter.notifySelectedChange(date, { needCheckFocusRecord });
731
730
  }
732
731
  }
@@ -75,11 +75,6 @@
75
75
  .semi-checkbox-inner-display .semi-icon {
76
76
  font-size: 16px;
77
77
  }
78
- .semi-checkbox-inner-pureCardType {
79
- opacity: 0;
80
- width: 0;
81
- margin-right: 0 !important;
82
- }
83
78
  .semi-checkbox-inner-checked .semi-checkbox-inner-display {
84
79
  background: var(--semi-color-primary);
85
80
  color: var(--semi-color-white);
@@ -138,6 +133,11 @@
138
133
  .semi-checkbox-cardType .semi-checkbox-inner-display {
139
134
  background: var(--semi-color-white);
140
135
  }
136
+ .semi-checkbox-cardType .semi-checkbox-inner-pureCardType {
137
+ opacity: 0;
138
+ width: 0;
139
+ margin-right: 0;
140
+ }
141
141
  .semi-checkbox-cardType .semi-checkbox-addon {
142
142
  font-weight: 600;
143
143
  font-size: 14px;
@@ -101,15 +101,6 @@ $module: #{$prefix}-checkbox;
101
101
  font-size: 16px;
102
102
  }
103
103
  }
104
-
105
- &-pureCardType {
106
- // Reasons to use opacity:0 & width: 0 instead of display: none
107
- // The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
108
- // input focus/blur cannot take effect when display: none
109
- opacity: 0;
110
- width: 0;
111
- margin-right: 0 !important;
112
- }
113
104
  }
114
105
 
115
106
  &-inner-checked {
@@ -196,6 +187,15 @@ $module: #{$prefix}-checkbox;
196
187
  flex-shrink: 0;
197
188
  }
198
189
 
190
+ .#{$module}-inner-pureCardType {
191
+ // Reasons to use opacity:0 & width: 0 instead of display: none
192
+ // The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
193
+ // input focus/blur cannot take effect when display: none
194
+ opacity: 0;
195
+ width: 0;
196
+ margin-right: 0;
197
+ }
198
+
199
199
  .#{$module}-addon {
200
200
  font-weight: $font-checkbox_cardType_addon-fontWeight;
201
201
  font-size: $font-checkbox_cardType_addon-size;
@@ -185,6 +185,12 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
185
185
  initFromProps({ value, timeZone, prevTimeZone }: Pick<DatePickerFoundationProps, 'value' | 'timeZone'> & {
186
186
  prevTimeZone?: string | number;
187
187
  }): void;
188
+ /**
189
+ * 如果用户传了一个空的 value,需要把 range input focus 设置为 rangeStart,这样用户可以清除完之后继续从开始选择
190
+ *
191
+ * If the user passes an empty value, you need to set the range input focus to rangeStart, so that the user can continue to select from the beginning after clearing
192
+ */
193
+ initRangeInputFocus(result: Date[]): void;
188
194
  parseWithTimezone(value: ValueType, timeZone: string | number, prevTimeZone: string | number): Date[];
189
195
  _isMultiple(): boolean;
190
196
  /**
@@ -40,6 +40,8 @@ var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable
40
40
 
41
41
  var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
42
42
 
43
+ var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
44
+
43
45
  var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
44
46
 
45
47
  var _isString2 = _interopRequireDefault(require("lodash/isString"));
@@ -176,6 +178,27 @@ class DatePickerFoundation extends _foundation.default {
176
178
  this._adapter.updateValue(result);
177
179
 
178
180
  this.resetCachedSelectedValue(result);
181
+ this.initRangeInputFocus(result);
182
+
183
+ if (this._adapter.needConfirm()) {
184
+ this._adapter.updateCachedSelectedValue(result);
185
+ }
186
+ }
187
+ /**
188
+ * 如果用户传了一个空的 value,需要把 range input focus 设置为 rangeStart,这样用户可以清除完之后继续从开始选择
189
+ *
190
+ * If the user passes an empty value, you need to set the range input focus to rangeStart, so that the user can continue to select from the beginning after clearing
191
+ */
192
+
193
+
194
+ initRangeInputFocus(result) {
195
+ const {
196
+ triggerRender
197
+ } = this.getProps();
198
+
199
+ if (this._isRangeType() && (0, _isFunction2.default)(triggerRender) && result.length === 0) {
200
+ this._adapter.setRangeInputFocus('rangeStart');
201
+ }
179
202
  }
180
203
 
181
204
  parseWithTimezone(value, timeZone, prevTimeZone) {
@@ -1424,7 +1447,8 @@ class DatePickerFoundation extends _foundation.default {
1424
1447
 
1425
1448
  handleTriggerWrapperClick(e) {
1426
1449
  const {
1427
- disabled
1450
+ disabled,
1451
+ triggerRender
1428
1452
  } = this._adapter.getProps();
1429
1453
 
1430
1454
  const {
@@ -1443,12 +1467,19 @@ class DatePickerFoundation extends _foundation.default {
1443
1467
  */
1444
1468
 
1445
1469
 
1446
- if (this._isRangeType() && !rangeInputFocus && this._adapter.isEventTarget(e)) {
1447
- (0, _setTimeout2.default)(() => {
1448
- // using setTimeout get correct state value 'rangeInputFocus'
1449
- this.handleInputFocus(e, 'rangeStart');
1450
- this.openPanel();
1451
- }, 0);
1470
+ if (this._isRangeType() && !rangeInputFocus) {
1471
+ if (this._adapter.isEventTarget(e)) {
1472
+ (0, _setTimeout2.default)(() => {
1473
+ // using setTimeout get correct state value 'rangeInputFocus'
1474
+ this.handleInputFocus(e, 'rangeStart');
1475
+ }, 0);
1476
+ } else if ((0, _isFunction2.default)(triggerRender)) {
1477
+ // 如果是 triggerRender 场景,因为没有 input,因此打开面板时默认 focus 在 rangeStart
1478
+ // If it is a triggerRender scene, because there is no input, the default focus is rangeStart when the panel is opened
1479
+ this._adapter.setRangeInputFocus('rangeStart');
1480
+ }
1481
+
1482
+ this.openPanel();
1452
1483
  } else {
1453
1484
  this.openPanel();
1454
1485
  }
@@ -28,8 +28,6 @@ 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
-
33
31
  var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
34
32
 
35
33
  var _isSet2 = _interopRequireDefault(require("lodash/isSet"));
@@ -828,11 +826,10 @@ class MonthsGridFoundation extends _foundation.default {
828
826
  /**
829
827
  * no need to check focus then
830
828
  * - dateRange and isDateRangeAndHasOffset
831
- * - dateRange and triggerRender
832
829
  */
833
830
 
834
831
 
835
- const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || (0, _isFunction2.default)(triggerRender)));
832
+ const needCheckFocusRecord = !(type === 'dateRange' && isDateRangeAndHasOffset);
836
833
 
837
834
  this._adapter.notifySelectedChange(date, {
838
835
  needCheckFocusRecord
@@ -75,11 +75,6 @@
75
75
  .semi-checkbox-inner-display .semi-icon {
76
76
  font-size: 16px;
77
77
  }
78
- .semi-checkbox-inner-pureCardType {
79
- opacity: 0;
80
- width: 0;
81
- margin-right: 0 !important;
82
- }
83
78
  .semi-checkbox-inner-checked .semi-checkbox-inner-display {
84
79
  background: var(--semi-color-primary);
85
80
  color: var(--semi-color-white);
@@ -138,6 +133,11 @@
138
133
  .semi-checkbox-cardType .semi-checkbox-inner-display {
139
134
  background: var(--semi-color-white);
140
135
  }
136
+ .semi-checkbox-cardType .semi-checkbox-inner-pureCardType {
137
+ opacity: 0;
138
+ width: 0;
139
+ margin-right: 0;
140
+ }
141
141
  .semi-checkbox-cardType .semi-checkbox-addon {
142
142
  font-weight: 600;
143
143
  font-size: 14px;
@@ -101,15 +101,6 @@ $module: #{$prefix}-checkbox;
101
101
  font-size: 16px;
102
102
  }
103
103
  }
104
-
105
- &-pureCardType {
106
- // Reasons to use opacity:0 & width: 0 instead of display: none
107
- // The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
108
- // input focus/blur cannot take effect when display: none
109
- opacity: 0;
110
- width: 0;
111
- margin-right: 0 !important;
112
- }
113
104
  }
114
105
 
115
106
  &-inner-checked {
@@ -196,6 +187,15 @@ $module: #{$prefix}-checkbox;
196
187
  flex-shrink: 0;
197
188
  }
198
189
 
190
+ .#{$module}-inner-pureCardType {
191
+ // Reasons to use opacity:0 & width: 0 instead of display: none
192
+ // The a11y keyboard focus event of the checkbox depends on the implementation of the input focus/blur event
193
+ // input focus/blur cannot take effect when display: none
194
+ opacity: 0;
195
+ width: 0;
196
+ margin-right: 0;
197
+ }
198
+
199
199
  .#{$module}-addon {
200
200
  font-weight: $font-checkbox_cardType_addon-fontWeight;
201
201
  font-size: $font-checkbox_cardType_addon-size;
@@ -185,6 +185,12 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
185
185
  initFromProps({ value, timeZone, prevTimeZone }: Pick<DatePickerFoundationProps, 'value' | 'timeZone'> & {
186
186
  prevTimeZone?: string | number;
187
187
  }): void;
188
+ /**
189
+ * 如果用户传了一个空的 value,需要把 range input focus 设置为 rangeStart,这样用户可以清除完之后继续从开始选择
190
+ *
191
+ * If the user passes an empty value, you need to set the range input focus to rangeStart, so that the user can continue to select from the beginning after clearing
192
+ */
193
+ initRangeInputFocus(result: Date[]): void;
188
194
  parseWithTimezone(value: ValueType, timeZone: string | number, prevTimeZone: string | number): Date[];
189
195
  _isMultiple(): boolean;
190
196
  /**
@@ -1,3 +1,4 @@
1
+ import _isFunction from "lodash/isFunction";
1
2
  import _isEqual from "lodash/isEqual";
2
3
  import _isString from "lodash/isString";
3
4
  import _isObject from "lodash/isObject";
@@ -135,6 +136,27 @@ export default class DatePickerFoundation extends BaseFoundation {
135
136
  this._adapter.updateValue(result);
136
137
 
137
138
  this.resetCachedSelectedValue(result);
139
+ this.initRangeInputFocus(result);
140
+
141
+ if (this._adapter.needConfirm()) {
142
+ this._adapter.updateCachedSelectedValue(result);
143
+ }
144
+ }
145
+ /**
146
+ * 如果用户传了一个空的 value,需要把 range input focus 设置为 rangeStart,这样用户可以清除完之后继续从开始选择
147
+ *
148
+ * If the user passes an empty value, you need to set the range input focus to rangeStart, so that the user can continue to select from the beginning after clearing
149
+ */
150
+
151
+
152
+ initRangeInputFocus(result) {
153
+ const {
154
+ triggerRender
155
+ } = this.getProps();
156
+
157
+ if (this._isRangeType() && _isFunction(triggerRender) && result.length === 0) {
158
+ this._adapter.setRangeInputFocus('rangeStart');
159
+ }
138
160
  }
139
161
 
140
162
  parseWithTimezone(value, timeZone, prevTimeZone) {
@@ -1392,7 +1414,8 @@ export default class DatePickerFoundation extends BaseFoundation {
1392
1414
 
1393
1415
  handleTriggerWrapperClick(e) {
1394
1416
  const {
1395
- disabled
1417
+ disabled,
1418
+ triggerRender
1396
1419
  } = this._adapter.getProps();
1397
1420
 
1398
1421
  const {
@@ -1411,12 +1434,19 @@ export default class DatePickerFoundation extends BaseFoundation {
1411
1434
  */
1412
1435
 
1413
1436
 
1414
- if (this._isRangeType() && !rangeInputFocus && this._adapter.isEventTarget(e)) {
1415
- _setTimeout(() => {
1416
- // using setTimeout get correct state value 'rangeInputFocus'
1417
- this.handleInputFocus(e, 'rangeStart');
1418
- this.openPanel();
1419
- }, 0);
1437
+ if (this._isRangeType() && !rangeInputFocus) {
1438
+ if (this._adapter.isEventTarget(e)) {
1439
+ _setTimeout(() => {
1440
+ // using setTimeout get correct state value 'rangeInputFocus'
1441
+ this.handleInputFocus(e, 'rangeStart');
1442
+ }, 0);
1443
+ } else if (_isFunction(triggerRender)) {
1444
+ // 如果是 triggerRender 场景,因为没有 input,因此打开面板时默认 focus 在 rangeStart
1445
+ // If it is a triggerRender scene, because there is no input, the default focus is rangeStart when the panel is opened
1446
+ this._adapter.setRangeInputFocus('rangeStart');
1447
+ }
1448
+
1449
+ this.openPanel();
1420
1450
  } else {
1421
1451
  this.openPanel();
1422
1452
  }
@@ -1,4 +1,3 @@
1
- import _isFunction from "lodash/isFunction";
2
1
  import _isEqual from "lodash/isEqual";
3
2
  import _isSet from "lodash/isSet";
4
3
  import _includes from "lodash/includes";
@@ -800,11 +799,10 @@ export default class MonthsGridFoundation extends BaseFoundation {
800
799
  /**
801
800
  * no need to check focus then
802
801
  * - dateRange and isDateRangeAndHasOffset
803
- * - dateRange and triggerRender
804
802
  */
805
803
 
806
804
 
807
- const needCheckFocusRecord = !(type === 'dateRange' && (isDateRangeAndHasOffset || _isFunction(triggerRender)));
805
+ const needCheckFocusRecord = !(type === 'dateRange' && isDateRangeAndHasOffset);
808
806
 
809
807
  this._adapter.notifySelectedChange(date, {
810
808
  needCheckFocusRecord
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.15.0-beta.0",
3
+ "version": "2.15.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -24,7 +24,7 @@
24
24
  "*.scss",
25
25
  "*.css"
26
26
  ],
27
- "gitHead": "09fa8ba9a3765537c9de842dbcc2f97d515b54d9",
27
+ "gitHead": "236be8e52864297171e3b08da20475139dadd633",
28
28
  "devDependencies": {
29
29
  "@babel/plugin-proposal-decorators": "^7.15.8",
30
30
  "@babel/plugin-transform-runtime": "^7.15.8",