@ucloud-fe/react-components 1.4.1 → 1.4.4
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/Calendar/style/index.js +5 -5
- package/lib/components/DatePicker/Range.js +42 -8
- 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 +16 -17
- package/lib/components/DatePicker/useRangePicker.d.ts +2 -1
- package/lib/components/DatePicker/useRangePicker.js +3 -2
- 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,7 +250,8 @@ 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) {// noop
|
|
254
|
+
} else if (rangeDateValidResult !== true) {
|
|
247
255
|
var _inputRefE$current;
|
|
248
256
|
|
|
249
257
|
(_inputRefE$current = inputRefE.current) === null || _inputRefE$current === void 0 ? void 0 : _inputRefE$current.focus();
|
|
@@ -267,7 +275,7 @@ var Range = function Range(_ref2) {
|
|
|
267
275
|
|
|
268
276
|
setCacheValue(newValue);
|
|
269
277
|
}.bind(this), [cacheValue, rules, precision, isFirstEditing, locale, onChange]);
|
|
270
|
-
var handleEndChange = (0, _react.useCallback)(function (value) {
|
|
278
|
+
var handleEndChange = (0, _react.useCallback)(function (value, isClear) {
|
|
271
279
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
272
280
|
|
|
273
281
|
var _cacheValue2 = (0, _slicedToArray2.default)(cacheValue, 1),
|
|
@@ -277,7 +285,8 @@ var Range = function Range(_ref2) {
|
|
|
277
285
|
var rangeDateValidResult = (0, _utils.isRangeDateValid)(newValue, rules, precision);
|
|
278
286
|
setRangeError(undefined);
|
|
279
287
|
|
|
280
|
-
if (
|
|
288
|
+
if (isClear) {// noop
|
|
289
|
+
} else if (rangeDateValidResult !== true) {
|
|
281
290
|
var _inputRefS$current;
|
|
282
291
|
|
|
283
292
|
(_inputRefS$current = inputRefS.current) === null || _inputRefS$current === void 0 ? void 0 : _inputRefS$current.focus();
|
|
@@ -301,6 +310,14 @@ var Range = function Range(_ref2) {
|
|
|
301
310
|
|
|
302
311
|
setCacheValue(newValue);
|
|
303
312
|
}.bind(this), [cacheValue, rules, precision, isFirstEditing, locale, onChange]);
|
|
313
|
+
var onClearS = (0, _react.useCallback)(function () {
|
|
314
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
315
|
+
handleStartChange(null, true);
|
|
316
|
+
}.bind(this), [handleStartChange]);
|
|
317
|
+
var onClearE = (0, _react.useCallback)(function () {
|
|
318
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
319
|
+
handleEndChange(null, true);
|
|
320
|
+
}.bind(this), [handleEndChange]);
|
|
304
321
|
var handleOptionChange = (0, _react.useCallback)(function (value) {
|
|
305
322
|
(0, _newArrowCheck2.default)(this, _this3);
|
|
306
323
|
if (value !== 'custom') onChange(getValueFromOption(options, value));
|
|
@@ -339,7 +356,8 @@ var Range = function Range(_ref2) {
|
|
|
339
356
|
nullable: nullableS,
|
|
340
357
|
placeholder: placeholderS,
|
|
341
358
|
shortcuts: shortcutsS,
|
|
342
|
-
actionRef: actionRefS
|
|
359
|
+
actionRef: actionRefS,
|
|
360
|
+
onClear: onClearS
|
|
343
361
|
}, sharedPickerProps), {}, {
|
|
344
362
|
rules: isFirstEditing === 2 ? _objectSpread(_objectSpread({}, rules), {}, {
|
|
345
363
|
range: [(_rules$range = rules.range) === null || _rules$range === void 0 ? void 0 : _rules$range[0], cacheValue[1]]
|
|
@@ -367,7 +385,8 @@ var Range = function Range(_ref2) {
|
|
|
367
385
|
nullable: nullableE,
|
|
368
386
|
placeholder: placeholderE,
|
|
369
387
|
shortcuts: shortcutsE,
|
|
370
|
-
actionRef: actionRefE
|
|
388
|
+
actionRef: actionRefE,
|
|
389
|
+
onClear: onClearE
|
|
371
390
|
}, sharedPickerProps), {}, {
|
|
372
391
|
rules: isFirstEditing === 2 ? _objectSpread(_objectSpread({}, rules), {}, {
|
|
373
392
|
range: [cacheValue[0], (_rules$range2 = rules.range) === null || _rules$range2 === void 0 ? void 0 : _rules$range2[1]]
|
|
@@ -401,6 +420,15 @@ var Range = function Range(_ref2) {
|
|
|
401
420
|
}.bind(this));
|
|
402
421
|
}
|
|
403
422
|
}.bind(this), [activeE, activeS]);
|
|
423
|
+
(0, _react.useEffect)(function () {
|
|
424
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
425
|
+
|
|
426
|
+
if (activeE) {
|
|
427
|
+
var _startRangeInputRef$c;
|
|
428
|
+
|
|
429
|
+
setStartRangeInputWidth(((_startRangeInputRef$c = startRangeInputRef.current) === null || _startRangeInputRef$c === void 0 ? void 0 : _startRangeInputRef$c.offsetWidth) || 200);
|
|
430
|
+
}
|
|
431
|
+
}.bind(this), [activeE]);
|
|
404
432
|
var CalendarComp = isMonth ? _Calendar.default.Month : hasTime ? _Calendar.default : _Calendar.TwoSide;
|
|
405
433
|
return /*#__PURE__*/_react.default.createElement(_style.RangeContainer, (0, _extends2.default)({}, rest, {
|
|
406
434
|
disabled: disabled
|
|
@@ -417,7 +445,11 @@ var Range = function Range(_ref2) {
|
|
|
417
445
|
visible: activeS || activeE,
|
|
418
446
|
popup: /*#__PURE__*/_react.default.createElement(_style.SPopup, (0, _extends2.default)({}, popupProps, {
|
|
419
447
|
endInputHighlight: activeE
|
|
420
|
-
}
|
|
448
|
+
}), /*#__PURE__*/_react.default.createElement(_style.Arrow, {
|
|
449
|
+
style: {
|
|
450
|
+
left: activeE ? startRangeInputWidth + 'px' : '20px'
|
|
451
|
+
}
|
|
452
|
+
}), /*#__PURE__*/_react.default.createElement(_style.RangeCalendarWrap, {
|
|
421
453
|
visible: activeS
|
|
422
454
|
}, /*#__PURE__*/_react.default.createElement(CalendarComp, (0, _extends2.default)({}, calendarPropsS, {
|
|
423
455
|
rangeValue: [calendarPropsS.value, cacheValue === null || cacheValue === void 0 ? void 0 : cacheValue[1]],
|
|
@@ -443,7 +475,9 @@ var Range = function Range(_ref2) {
|
|
|
443
475
|
status: status || contextStatus
|
|
444
476
|
}, readonly ? /*#__PURE__*/_react.default.createElement("span", {
|
|
445
477
|
className: _style.readonlyInputCls
|
|
446
|
-
}, inputPropsS.value) : /*#__PURE__*/_react.default.createElement(_style.RangeInputWrap,
|
|
478
|
+
}, inputPropsS.value) : /*#__PURE__*/_react.default.createElement(_style.RangeInputWrap, (0, _extends2.default)({}, inputWrapPropsS, {
|
|
479
|
+
ref: startRangeInputRef
|
|
480
|
+
}), /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({}, inputPropsS, {
|
|
447
481
|
ref: inputRefS
|
|
448
482
|
}))), readonly ? /*#__PURE__*/_react.default.createElement("span", {
|
|
449
483
|
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>;
|