@ucloud-fe/react-components 1.4.4 → 1.4.5

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.
@@ -250,16 +250,21 @@ var Range = function Range(_ref2) {
250
250
  var rangeDateValidResult = (0, _utils.isRangeDateValid)(newValue, rules, precision);
251
251
  setRangeError(undefined);
252
252
 
253
- if (isClear) {// noop
253
+ if (isClear) {
254
+ var _actionRefS$current, _actionRefE$current;
255
+
256
+ onChange(newValue);
257
+ (_actionRefS$current = actionRefS.current) === null || _actionRefS$current === void 0 ? void 0 : _actionRefS$current.hide();
258
+ (_actionRefE$current = actionRefE.current) === null || _actionRefE$current === void 0 ? void 0 : _actionRefE$current.hide();
254
259
  } else if (rangeDateValidResult !== true) {
255
260
  var _inputRefE$current;
256
261
 
257
262
  (_inputRefE$current = inputRefE.current) === null || _inputRefE$current === void 0 ? void 0 : _inputRefE$current.focus();
258
263
 
259
264
  if (rangeDateValidResult === 'startGreaterThanEnd') {
260
- var _actionRefE$current;
265
+ var _actionRefE$current2;
261
266
 
262
- (_actionRefE$current = actionRefE.current) === null || _actionRefE$current === void 0 ? void 0 : _actionRefE$current.clear();
267
+ (_actionRefE$current2 = actionRefE.current) === null || _actionRefE$current2 === void 0 ? void 0 : _actionRefE$current2.clear();
263
268
  } else {
264
269
  setRangeError(locale[rangeDateValidResult + 'Tip']);
265
270
  }
@@ -285,16 +290,21 @@ var Range = function Range(_ref2) {
285
290
  var rangeDateValidResult = (0, _utils.isRangeDateValid)(newValue, rules, precision);
286
291
  setRangeError(undefined);
287
292
 
288
- if (isClear) {// noop
293
+ if (isClear) {
294
+ var _actionRefS$current2, _actionRefE$current3;
295
+
296
+ onChange(newValue);
297
+ (_actionRefS$current2 = actionRefS.current) === null || _actionRefS$current2 === void 0 ? void 0 : _actionRefS$current2.hide();
298
+ (_actionRefE$current3 = actionRefE.current) === null || _actionRefE$current3 === void 0 ? void 0 : _actionRefE$current3.hide();
289
299
  } else if (rangeDateValidResult !== true) {
290
300
  var _inputRefS$current;
291
301
 
292
302
  (_inputRefS$current = inputRefS.current) === null || _inputRefS$current === void 0 ? void 0 : _inputRefS$current.focus();
293
303
 
294
304
  if (rangeDateValidResult === 'startGreaterThanEnd') {
295
- var _actionRefS$current;
305
+ var _actionRefS$current3;
296
306
 
297
- (_actionRefS$current = actionRefS.current) === null || _actionRefS$current === void 0 ? void 0 : _actionRefS$current.clear();
307
+ (_actionRefS$current3 = actionRefS.current) === null || _actionRefS$current3 === void 0 ? void 0 : _actionRefS$current3.clear();
298
308
  } else {
299
309
  setRangeError(locale[rangeDateValidResult + 'Tip']);
300
310
  }
@@ -259,7 +259,11 @@ var usePicker = function usePicker(props, displayToFormatAndTimeMode, mode, onCl
259
259
  setInputValue('');
260
260
  setCalValue(null);
261
261
  }.bind(this), []);
262
- var handleConfirm = (0, _react.useCallback)(function (v, dontChangeVisible) {
262
+ var hide = (0, _react.useCallback)(function () {
263
+ (0, _newArrowCheck2.default)(this, _this2);
264
+ setVisible(false);
265
+ }.bind(this), []);
266
+ var handleConfirm = (0, _react.useCallback)(function (v) {
263
267
  (0, _newArrowCheck2.default)(this, _this2);
264
268
  var currentValue = v !== undefined ? v : calValue;
265
269
 
@@ -270,17 +274,18 @@ var usePicker = function usePicker(props, displayToFormatAndTimeMode, mode, onCl
270
274
  }
271
275
 
272
276
  onChange && onChange(currentValue ? (0, _moment.default)(+currentValue) : null);
273
-
274
- if (!dontChangeVisible) {
275
- setVisible(false);
276
- }
277
+ setVisible(false);
277
278
  }.bind(this), [calValue, nullable, onChange, rules, value]);
278
279
  var handleInputClear = (0, _react.useCallback)(function () {
279
280
  (0, _newArrowCheck2.default)(this, _this2);
280
281
  clear(); // 不走 onChange,区分两种操作
281
282
 
282
- onClear === null || onClear === void 0 ? void 0 : onClear();
283
- }.bind(this), [clear, onClear]);
283
+ if (onClear) {
284
+ onClear();
285
+ } else {
286
+ handleConfirm(null);
287
+ }
288
+ }.bind(this), [clear, handleConfirm, onClear]);
284
289
  var handleCalendarChange = (0, _react.useCallback)(function (v) {
285
290
  (0, _newArrowCheck2.default)(this, _this2);
286
291
  v = (0, _utils.getValidDate)(v, rules);
@@ -400,7 +405,8 @@ var usePicker = function usePicker(props, displayToFormatAndTimeMode, mode, onCl
400
405
  error: typeof error === 'string' ? error : null,
401
406
  active: visible
402
407
  }, {
403
- clear: clear
408
+ clear: clear,
409
+ hide: hide
404
410
  }];
405
411
  }.bind(void 0);
406
412
 
@@ -2,6 +2,7 @@ import { ReactNode, MutableRefObject } from 'react';
2
2
  import { DatePickerProps } from './DatePicker';
3
3
  export declare type RangeActionRef = {
4
4
  clear: () => void;
5
+ hide: () => void;
5
6
  };
6
7
  export declare type RangePickerRef = {
7
8
  focus: () => void;
@@ -76,9 +76,10 @@ var useRangePicker = function useRangePicker(_ref) {
76
76
  (0, _react.useImperativeHandle)(actionRef, function () {
77
77
  (0, _newArrowCheck2.default)(this, _this2);
78
78
  return {
79
- clear: actions.clear
79
+ clear: actions.clear,
80
+ hide: actions.hide
80
81
  };
81
- }.bind(this), [actions.clear]);
82
+ }.bind(this), [actions.clear, actions.hide]);
82
83
  return [// inputProps
83
84
  _objectSpread(_objectSpread({}, inputProps), {}, {
84
85
  customStyle: inputCustomStyle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucloud-fe/react-components",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "title": "UCloud react components",
5
5
  "description": "UCloud react components",
6
6
  "keywords": [