@ucloud-fe/react-components 1.4.2 → 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.
- package/CHANGELOG.md +18 -0
- package/dist/main.min.js +2 -2
- package/lib/components/DatePicker/Range.js +56 -12
- package/lib/components/DatePicker/style/index.d.ts +6 -6
- package/lib/components/DatePicker/style/index.js +18 -33
- package/lib/components/DatePicker/usePicker.d.ts +1 -1
- package/lib/components/DatePicker/usePicker.js +21 -16
- package/lib/components/DatePicker/useRangePicker.d.ts +3 -1
- package/lib/components/DatePicker/useRangePicker.js +6 -4
- package/lib/components/Input/Input.d.ts +4 -1
- package/lib/components/Input/Input.js +11 -5
- package/lib/components/Input/style/index.js +7 -3
- package/package.json +1 -1
|
@@ -214,6 +214,13 @@ var Range = function Range(_ref2) {
|
|
|
214
214
|
shortcutsS = _ref6[0],
|
|
215
215
|
shortcutsE = _ref6[1];
|
|
216
216
|
|
|
217
|
+
var startRangeInputRef = (0, _react.useRef)(null);
|
|
218
|
+
|
|
219
|
+
var _useState7 = (0, _react.useState)(200),
|
|
220
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
221
|
+
startRangeInputWidth = _useState8[0],
|
|
222
|
+
setStartRangeInputWidth = _useState8[1];
|
|
223
|
+
|
|
217
224
|
(0, _useDidMount.default)(function () {
|
|
218
225
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
219
226
|
|
|
@@ -233,7 +240,7 @@ var Range = function Range(_ref2) {
|
|
|
233
240
|
onInitialChange && onInitialChange(initialValue);
|
|
234
241
|
updateValueWithoutCallOnChange(initialValue);
|
|
235
242
|
}.bind(this));
|
|
236
|
-
var handleStartChange = (0, _react.useCallback)(function (value) {
|
|
243
|
+
var handleStartChange = (0, _react.useCallback)(function (value, isClear) {
|
|
237
244
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
238
245
|
|
|
239
246
|
var _cacheValue = (0, _slicedToArray2.default)(cacheValue, 2),
|
|
@@ -243,15 +250,21 @@ var Range = function Range(_ref2) {
|
|
|
243
250
|
var rangeDateValidResult = (0, _utils.isRangeDateValid)(newValue, rules, precision);
|
|
244
251
|
setRangeError(undefined);
|
|
245
252
|
|
|
246
|
-
if (
|
|
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();
|
|
259
|
+
} else if (rangeDateValidResult !== true) {
|
|
247
260
|
var _inputRefE$current;
|
|
248
261
|
|
|
249
262
|
(_inputRefE$current = inputRefE.current) === null || _inputRefE$current === void 0 ? void 0 : _inputRefE$current.focus();
|
|
250
263
|
|
|
251
264
|
if (rangeDateValidResult === 'startGreaterThanEnd') {
|
|
252
|
-
var _actionRefE$
|
|
265
|
+
var _actionRefE$current2;
|
|
253
266
|
|
|
254
|
-
(_actionRefE$
|
|
267
|
+
(_actionRefE$current2 = actionRefE.current) === null || _actionRefE$current2 === void 0 ? void 0 : _actionRefE$current2.clear();
|
|
255
268
|
} else {
|
|
256
269
|
setRangeError(locale[rangeDateValidResult + 'Tip']);
|
|
257
270
|
}
|
|
@@ -267,7 +280,7 @@ var Range = function Range(_ref2) {
|
|
|
267
280
|
|
|
268
281
|
setCacheValue(newValue);
|
|
269
282
|
}.bind(this), [cacheValue, rules, precision, isFirstEditing, locale, onChange]);
|
|
270
|
-
var handleEndChange = (0, _react.useCallback)(function (value) {
|
|
283
|
+
var handleEndChange = (0, _react.useCallback)(function (value, isClear) {
|
|
271
284
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
272
285
|
|
|
273
286
|
var _cacheValue2 = (0, _slicedToArray2.default)(cacheValue, 1),
|
|
@@ -277,15 +290,21 @@ var Range = function Range(_ref2) {
|
|
|
277
290
|
var rangeDateValidResult = (0, _utils.isRangeDateValid)(newValue, rules, precision);
|
|
278
291
|
setRangeError(undefined);
|
|
279
292
|
|
|
280
|
-
if (
|
|
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();
|
|
299
|
+
} else if (rangeDateValidResult !== true) {
|
|
281
300
|
var _inputRefS$current;
|
|
282
301
|
|
|
283
302
|
(_inputRefS$current = inputRefS.current) === null || _inputRefS$current === void 0 ? void 0 : _inputRefS$current.focus();
|
|
284
303
|
|
|
285
304
|
if (rangeDateValidResult === 'startGreaterThanEnd') {
|
|
286
|
-
var _actionRefS$
|
|
305
|
+
var _actionRefS$current3;
|
|
287
306
|
|
|
288
|
-
(_actionRefS$
|
|
307
|
+
(_actionRefS$current3 = actionRefS.current) === null || _actionRefS$current3 === void 0 ? void 0 : _actionRefS$current3.clear();
|
|
289
308
|
} else {
|
|
290
309
|
setRangeError(locale[rangeDateValidResult + 'Tip']);
|
|
291
310
|
}
|
|
@@ -301,6 +320,14 @@ var Range = function Range(_ref2) {
|
|
|
301
320
|
|
|
302
321
|
setCacheValue(newValue);
|
|
303
322
|
}.bind(this), [cacheValue, rules, precision, isFirstEditing, locale, onChange]);
|
|
323
|
+
var onClearS = (0, _react.useCallback)(function () {
|
|
324
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
325
|
+
handleStartChange(null, true);
|
|
326
|
+
}.bind(this), [handleStartChange]);
|
|
327
|
+
var onClearE = (0, _react.useCallback)(function () {
|
|
328
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
329
|
+
handleEndChange(null, true);
|
|
330
|
+
}.bind(this), [handleEndChange]);
|
|
304
331
|
var handleOptionChange = (0, _react.useCallback)(function (value) {
|
|
305
332
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
306
333
|
if (value !== 'custom') onChange(getValueFromOption(options, value));
|
|
@@ -339,7 +366,8 @@ var Range = function Range(_ref2) {
|
|
|
339
366
|
nullable: nullableS,
|
|
340
367
|
placeholder: placeholderS,
|
|
341
368
|
shortcuts: shortcutsS,
|
|
342
|
-
actionRef: actionRefS
|
|
369
|
+
actionRef: actionRefS,
|
|
370
|
+
onClear: onClearS
|
|
343
371
|
}, sharedPickerProps), {}, {
|
|
344
372
|
rules: isFirstEditing === 2 ? _objectSpread(_objectSpread({}, rules), {}, {
|
|
345
373
|
range: [(_rules$range = rules.range) === null || _rules$range === void 0 ? void 0 : _rules$range[0], cacheValue[1]]
|
|
@@ -367,7 +395,8 @@ var Range = function Range(_ref2) {
|
|
|
367
395
|
nullable: nullableE,
|
|
368
396
|
placeholder: placeholderE,
|
|
369
397
|
shortcuts: shortcutsE,
|
|
370
|
-
actionRef: actionRefE
|
|
398
|
+
actionRef: actionRefE,
|
|
399
|
+
onClear: onClearE
|
|
371
400
|
}, sharedPickerProps), {}, {
|
|
372
401
|
rules: isFirstEditing === 2 ? _objectSpread(_objectSpread({}, rules), {}, {
|
|
373
402
|
range: [cacheValue[0], (_rules$range2 = rules.range) === null || _rules$range2 === void 0 ? void 0 : _rules$range2[1]]
|
|
@@ -401,6 +430,15 @@ var Range = function Range(_ref2) {
|
|
|
401
430
|
}.bind(this));
|
|
402
431
|
}
|
|
403
432
|
}.bind(this), [activeE, activeS]);
|
|
433
|
+
(0, _react.useEffect)(function () {
|
|
434
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
435
|
+
|
|
436
|
+
if (activeE) {
|
|
437
|
+
var _startRangeInputRef$c;
|
|
438
|
+
|
|
439
|
+
setStartRangeInputWidth(((_startRangeInputRef$c = startRangeInputRef.current) === null || _startRangeInputRef$c === void 0 ? void 0 : _startRangeInputRef$c.offsetWidth) || 200);
|
|
440
|
+
}
|
|
441
|
+
}.bind(this), [activeE]);
|
|
404
442
|
var CalendarComp = isMonth ? _Calendar.default.Month : hasTime ? _Calendar.default : _Calendar.TwoSide;
|
|
405
443
|
return /*#__PURE__*/_react.default.createElement(_style.RangeContainer, (0, _extends2.default)({}, rest, {
|
|
406
444
|
disabled: disabled
|
|
@@ -417,7 +455,11 @@ var Range = function Range(_ref2) {
|
|
|
417
455
|
visible: activeS || activeE,
|
|
418
456
|
popup: /*#__PURE__*/_react.default.createElement(_style.SPopup, (0, _extends2.default)({}, popupProps, {
|
|
419
457
|
endInputHighlight: activeE
|
|
420
|
-
}
|
|
458
|
+
}), /*#__PURE__*/_react.default.createElement(_style.Arrow, {
|
|
459
|
+
style: {
|
|
460
|
+
left: activeE ? startRangeInputWidth + 'px' : '20px'
|
|
461
|
+
}
|
|
462
|
+
}), /*#__PURE__*/_react.default.createElement(_style.RangeCalendarWrap, {
|
|
421
463
|
visible: activeS
|
|
422
464
|
}, /*#__PURE__*/_react.default.createElement(CalendarComp, (0, _extends2.default)({}, calendarPropsS, {
|
|
423
465
|
rangeValue: [calendarPropsS.value, cacheValue === null || cacheValue === void 0 ? void 0 : cacheValue[1]],
|
|
@@ -443,7 +485,9 @@ var Range = function Range(_ref2) {
|
|
|
443
485
|
status: status || contextStatus
|
|
444
486
|
}, readonly ? /*#__PURE__*/_react.default.createElement("span", {
|
|
445
487
|
className: _style.readonlyInputCls
|
|
446
|
-
}, inputPropsS.value) : /*#__PURE__*/_react.default.createElement(_style.RangeInputWrap,
|
|
488
|
+
}, inputPropsS.value) : /*#__PURE__*/_react.default.createElement(_style.RangeInputWrap, (0, _extends2.default)({}, inputWrapPropsS, {
|
|
489
|
+
ref: startRangeInputRef
|
|
490
|
+
}), /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({}, inputPropsS, {
|
|
447
491
|
ref: inputRefS
|
|
448
492
|
}))), readonly ? /*#__PURE__*/_react.default.createElement("span", {
|
|
449
493
|
className: _style.readonlyInputCls
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InputProps } from '../../../components/Input';
|
|
3
|
-
import {
|
|
3
|
+
import { Size } from '../../../style';
|
|
4
4
|
export declare const prefixCls: string;
|
|
5
5
|
export declare const dateSeparatorCls: string;
|
|
6
6
|
export declare const shortcutCls: string;
|
|
@@ -17,7 +17,7 @@ export declare const PickerContainer: import("react").ForwardRefExoticComponent<
|
|
|
17
17
|
hasTime?: boolean | undefined;
|
|
18
18
|
status?: InputProps['status'];
|
|
19
19
|
} & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
20
|
-
theme?: Theme | undefined;
|
|
20
|
+
theme?: import("../../../style").Theme | undefined;
|
|
21
21
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
22
|
export declare const SPopup: import("react").ForwardRefExoticComponent<{
|
|
23
23
|
endInputHighlight: boolean;
|
|
@@ -27,7 +27,7 @@ export declare const SPopup: import("react").ForwardRefExoticComponent<{
|
|
|
27
27
|
hasSuffix?: boolean | undefined;
|
|
28
28
|
clearable?: boolean | undefined;
|
|
29
29
|
} & import("react").HTMLAttributes<HTMLElement> & {
|
|
30
|
-
theme?: Theme | undefined;
|
|
30
|
+
theme?: import("../../../style").Theme | undefined;
|
|
31
31
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
32
32
|
export declare const SRangeInputWrap: import("react").ForwardRefExoticComponent<{
|
|
33
33
|
size: Size;
|
|
@@ -36,12 +36,12 @@ export declare const SRangeInputWrap: import("react").ForwardRefExoticComponent<
|
|
|
36
36
|
readonly?: boolean | undefined;
|
|
37
37
|
status?: string | undefined;
|
|
38
38
|
} & import("react").HTMLAttributes<HTMLElement> & {
|
|
39
|
-
theme?: Theme | undefined;
|
|
39
|
+
theme?: import("../../../style").Theme | undefined;
|
|
40
40
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
41
41
|
export declare const RangeContainer: import("react").ForwardRefExoticComponent<{
|
|
42
42
|
disabled?: boolean | undefined;
|
|
43
43
|
} & import("react").HTMLAttributes<HTMLElement> & {
|
|
44
|
-
theme?: Theme | undefined;
|
|
44
|
+
theme?: import("../../../style").Theme | undefined;
|
|
45
45
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
46
46
|
export declare const RangeInputWrap: import("react").ForwardRefExoticComponent<{
|
|
47
47
|
isMonth?: boolean | undefined;
|
|
@@ -53,7 +53,7 @@ export declare const RangeInputWrap: import("react").ForwardRefExoticComponent<{
|
|
|
53
53
|
status?: InputProps['status'];
|
|
54
54
|
isEnd?: boolean | undefined;
|
|
55
55
|
} & import("react").HTMLAttributes<HTMLElement> & {
|
|
56
|
-
theme?: Theme | undefined;
|
|
56
|
+
theme?: import("../../../style").Theme | undefined;
|
|
57
57
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
58
58
|
export declare const RangeSelect: import("@emotion/styled-base").StyledComponent<import("../../Select/Select").SelectProps & Omit<import("react").HTMLAttributes<HTMLDivElement>, keyof import("../../Select/Select").SelectProps>, Pick<import("../../Select/Select").SelectProps & Omit<import("react").HTMLAttributes<HTMLDivElement>, keyof import("../../Select/Select").SelectProps>, "className" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | keyof import("../../Select/Select").SelectProps>, object>;
|
|
59
59
|
export declare const Arrow: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, Pick<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>, keyof import("react").HTMLAttributes<HTMLSpanElement>>, object>;
|