rsuite 5.4.4 → 5.6.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.
- package/CHANGELOG.md +48 -0
- package/Carousel/styles/index.less +1 -0
- package/CheckTreePicker/styles/index.less +51 -50
- package/Modal/styles/mixin.less +1 -0
- package/Picker/styles/mixin.less +3 -2
- package/README.md +1 -1
- package/Sidenav/styles/index.less +54 -59
- package/TreePicker/styles/index.less +3 -3
- package/cjs/Affix/Affix.js +1 -0
- package/cjs/Calendar/TimeDropdown.js +7 -4
- package/cjs/Carousel/Carousel.d.ts +5 -1
- package/cjs/Carousel/Carousel.js +22 -16
- package/cjs/Cascader/Cascader.js +2 -2
- package/cjs/Cascader/DropdownMenu.js +1 -1
- package/cjs/CheckTreePicker/CheckTreePicker.js +17 -12
- package/cjs/CheckTreePicker/utils.d.ts +3 -3
- package/cjs/CheckTreePicker/utils.js +2 -2
- package/cjs/DOMHelper/index.d.ts +4 -4
- package/cjs/DatePicker/DatePicker.js +15 -9
- package/cjs/DateRangePicker/Calendar.js +2 -16
- package/cjs/DateRangePicker/DateRangePicker.js +1 -1
- package/cjs/Dropdown/Dropdown.d.ts +5 -0
- package/cjs/Dropdown/test/Dropdown.test.d.ts +1 -0
- package/cjs/Dropdown/test/Dropdown.test.js +30 -0
- package/cjs/InputNumber/InputNumber.d.ts +1 -1
- package/cjs/InputNumber/InputNumber.js +36 -6
- package/cjs/InputNumber/test/InputNumber.test.d.ts +1 -0
- package/cjs/InputNumber/test/InputNumber.test.js +14 -0
- package/cjs/InputPicker/InputAutosize.js +3 -1
- package/cjs/InputPicker/InputPicker.js +6 -2
- package/cjs/List/ListItem.js +13 -11
- package/cjs/Menu/MenuItem.js +14 -11
- package/cjs/MultiCascader/MultiCascader.js +1 -0
- package/cjs/Picker/PickerOverlay.js +4 -1
- package/cjs/RangeSlider/RangeSlider.d.ts +12 -2
- package/cjs/RangeSlider/RangeSlider.js +35 -12
- package/cjs/Ripple/Ripple.js +17 -9
- package/cjs/TreePicker/TreePicker.js +15 -11
- package/cjs/Uploader/UploadTrigger.js +3 -1
- package/cjs/Uploader/Uploader.js +3 -1
- package/cjs/utils/treeUtils.d.ts +3 -3
- package/cjs/utils/treeUtils.js +4 -3
- package/cjs/utils/useElementResize.d.ts +1 -1
- package/cjs/utils/useElementResize.js +5 -2
- package/dist/rsuite-rtl.css +114 -123
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +114 -123
- package/dist/rsuite.js +372 -53
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Affix/Affix.js +1 -0
- package/esm/Calendar/TimeDropdown.js +7 -4
- package/esm/Carousel/Carousel.d.ts +5 -1
- package/esm/Carousel/Carousel.js +23 -17
- package/esm/Cascader/Cascader.js +2 -2
- package/esm/Cascader/DropdownMenu.js +1 -1
- package/esm/CheckTreePicker/CheckTreePicker.js +17 -12
- package/esm/CheckTreePicker/utils.d.ts +3 -3
- package/esm/CheckTreePicker/utils.js +2 -2
- package/esm/DOMHelper/index.d.ts +4 -4
- package/esm/DatePicker/DatePicker.js +15 -9
- package/esm/DateRangePicker/Calendar.js +2 -16
- package/esm/DateRangePicker/DateRangePicker.js +1 -1
- package/esm/Dropdown/Dropdown.d.ts +5 -0
- package/esm/Dropdown/test/Dropdown.test.d.ts +1 -0
- package/esm/Dropdown/test/Dropdown.test.js +22 -0
- package/esm/InputNumber/InputNumber.d.ts +1 -1
- package/esm/InputNumber/InputNumber.js +38 -7
- package/esm/InputNumber/test/InputNumber.test.d.ts +1 -0
- package/esm/InputNumber/test/InputNumber.test.js +7 -0
- package/esm/InputPicker/InputAutosize.js +3 -1
- package/esm/InputPicker/InputPicker.js +6 -2
- package/esm/List/ListItem.js +13 -11
- package/esm/Menu/MenuItem.js +14 -11
- package/esm/MultiCascader/MultiCascader.js +1 -0
- package/esm/Picker/PickerOverlay.js +4 -1
- package/esm/RangeSlider/RangeSlider.d.ts +12 -2
- package/esm/RangeSlider/RangeSlider.js +35 -12
- package/esm/Ripple/Ripple.js +17 -9
- package/esm/TreePicker/TreePicker.js +15 -11
- package/esm/Uploader/UploadTrigger.js +3 -1
- package/esm/Uploader/Uploader.js +3 -1
- package/esm/utils/treeUtils.d.ts +3 -3
- package/esm/utils/treeUtils.js +6 -3
- package/esm/utils/useElementResize.d.ts +1 -1
- package/esm/utils/useElementResize.js +5 -2
- package/package.json +3 -3
package/esm/Affix/Affix.js
CHANGED
|
@@ -78,10 +78,11 @@ var scrollTo = function scrollTo(time, row) {
|
|
|
78
78
|
var node = container === null || container === void 0 ? void 0 : container.querySelector("[data-key=\"" + type + "-" + value + "\"]");
|
|
79
79
|
|
|
80
80
|
if (node && container) {
|
|
81
|
-
var
|
|
82
|
-
top = _ref2.top;
|
|
81
|
+
var position = getPosition(node, container);
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
if (position) {
|
|
84
|
+
scrollTopAnimation(container, position.top, scrollTop(container) !== 0);
|
|
85
|
+
}
|
|
85
86
|
}
|
|
86
87
|
});
|
|
87
88
|
};
|
|
@@ -111,7 +112,9 @@ var TimeDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
111
112
|
showMeridian: showMeridian
|
|
112
113
|
}); // The currently selected time scrolls to the visible range.
|
|
113
114
|
|
|
114
|
-
show &&
|
|
115
|
+
if (show && rowRef.current) {
|
|
116
|
+
scrollTo(time, rowRef.current);
|
|
117
|
+
}
|
|
115
118
|
}, [date, format, show, showMeridian]);
|
|
116
119
|
|
|
117
120
|
var handleClick = function handleClick(type, d, event) {
|
|
@@ -9,7 +9,11 @@ export interface CarouselProps extends WithAsProps {
|
|
|
9
9
|
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
10
10
|
/** Button shape */
|
|
11
11
|
shape?: 'dot' | 'bar';
|
|
12
|
-
/**
|
|
12
|
+
/** Active element index */
|
|
13
|
+
activeIndex?: number;
|
|
14
|
+
/** Defaul initial index */
|
|
15
|
+
defaultActiveIndex?: number;
|
|
16
|
+
/** Callback fired when the active item manually changes */
|
|
13
17
|
onSelect?: (index: number, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
14
18
|
/** Callback fired when a slide transition starts */
|
|
15
19
|
onSlideStart?: (index: number, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
package/esm/Carousel/Carousel.js
CHANGED
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
import React, { useState, useMemo, useCallback, useRef } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { useClassNames, useCustom, guid, ReactChildren, useTimeout, mergeRefs } from '../utils';
|
|
6
|
+
import { useClassNames, useCustom, guid, ReactChildren, useTimeout, mergeRefs, useControlled } from '../utils';
|
|
7
7
|
var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
8
8
|
var _sliderStyles, _ref;
|
|
9
9
|
|
|
@@ -20,10 +20,13 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
20
20
|
autoplay = props.autoplay,
|
|
21
21
|
_props$autoplayInterv = props.autoplayInterval,
|
|
22
22
|
autoplayInterval = _props$autoplayInterv === void 0 ? 4000 : _props$autoplayInterv,
|
|
23
|
+
activeIndexProp = props.activeIndex,
|
|
24
|
+
_props$defaultActiveI = props.defaultActiveIndex,
|
|
25
|
+
defaultActiveIndex = _props$defaultActiveI === void 0 ? 0 : _props$defaultActiveI,
|
|
23
26
|
onSelect = props.onSelect,
|
|
24
27
|
onSlideStart = props.onSlideStart,
|
|
25
28
|
onSlideEnd = props.onSlideEnd,
|
|
26
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "children", "classPrefix", "className", "placement", "shape", "autoplay", "autoplayInterval", "onSelect", "onSlideStart", "onSlideEnd"]);
|
|
29
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "children", "classPrefix", "className", "placement", "shape", "autoplay", "autoplayInterval", "activeIndex", "defaultActiveIndex", "onSelect", "onSlideStart", "onSlideEnd"]);
|
|
27
30
|
|
|
28
31
|
var _useCustom = useCustom('Carousel'),
|
|
29
32
|
rtl = _useCustom.rtl;
|
|
@@ -38,17 +41,24 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
38
41
|
var vertical = placement === 'left' || placement === 'right';
|
|
39
42
|
var lengthKey = vertical ? 'height' : 'width';
|
|
40
43
|
|
|
44
|
+
var _useControlled = useControlled(activeIndexProp, defaultActiveIndex),
|
|
45
|
+
activeIndex = _useControlled[0],
|
|
46
|
+
setActiveIndex = _useControlled[1];
|
|
47
|
+
|
|
41
48
|
var _useState = useState(0),
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
lastIndex = _useState[0],
|
|
50
|
+
setLastIndex = _useState[1];
|
|
44
51
|
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
setLastIndex = _useState2[1];
|
|
52
|
+
var rootRef = useRef(null); // Set a timer for automatic playback.
|
|
53
|
+
// `autoplay` needs to be cast to boolean type to avoid undefined parameters.
|
|
48
54
|
|
|
49
|
-
var
|
|
55
|
+
var _useTimeout = useTimeout(function () {
|
|
56
|
+
return handleSlide();
|
|
57
|
+
}, autoplayInterval, !!autoplay && count > 1),
|
|
58
|
+
clear = _useTimeout.clear,
|
|
59
|
+
reset = _useTimeout.reset;
|
|
50
60
|
|
|
51
|
-
var handleSlide = function
|
|
61
|
+
var handleSlide = useCallback(function (nextActiveIndex, event) {
|
|
52
62
|
if (!rootRef.current) {
|
|
53
63
|
return;
|
|
54
64
|
}
|
|
@@ -61,7 +71,7 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
61
71
|
onSlideStart === null || onSlideStart === void 0 ? void 0 : onSlideStart(nextIndex, event);
|
|
62
72
|
setLastIndex(nextActiveIndex == null ? activeIndex : nextIndex);
|
|
63
73
|
reset();
|
|
64
|
-
};
|
|
74
|
+
}, [activeIndex, count, setActiveIndex, clear, onSlideStart, reset]);
|
|
65
75
|
|
|
66
76
|
var handleChange = function handleChange(event) {
|
|
67
77
|
var activeIndex = +event.target.value;
|
|
@@ -71,13 +81,7 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
71
81
|
|
|
72
82
|
var handleTransitionEnd = useCallback(function (event) {
|
|
73
83
|
onSlideEnd === null || onSlideEnd === void 0 ? void 0 : onSlideEnd(activeIndex, event);
|
|
74
|
-
}, [activeIndex, onSlideEnd]);
|
|
75
|
-
// `autoplay` needs to be cast to boolean type to avoid undefined parameters.
|
|
76
|
-
|
|
77
|
-
var _useTimeout = useTimeout(handleSlide, autoplayInterval, !!autoplay && count > 1),
|
|
78
|
-
clear = _useTimeout.clear,
|
|
79
|
-
reset = _useTimeout.reset;
|
|
80
|
-
|
|
84
|
+
}, [activeIndex, onSlideEnd]);
|
|
81
85
|
var uniqueId = useMemo(function () {
|
|
82
86
|
return guid();
|
|
83
87
|
}, []);
|
|
@@ -146,6 +150,8 @@ Carousel.propTypes = {
|
|
|
146
150
|
as: PropTypes.elementType,
|
|
147
151
|
className: PropTypes.string,
|
|
148
152
|
classPrefix: PropTypes.string,
|
|
153
|
+
activeIndex: PropTypes.number,
|
|
154
|
+
defaultActiveIndex: PropTypes.number,
|
|
149
155
|
autoplay: PropTypes.bool,
|
|
150
156
|
autoplayInterval: PropTypes.number,
|
|
151
157
|
placement: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
package/esm/Cascader/Cascader.js
CHANGED
|
@@ -140,7 +140,7 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
140
140
|
var getSearchResult = useCallback(function (keyword) {
|
|
141
141
|
var items = [];
|
|
142
142
|
var result = flattenData.filter(function (item) {
|
|
143
|
-
if (item[childrenKey]) {
|
|
143
|
+
if (!parentSelectable && item[childrenKey]) {
|
|
144
144
|
return false;
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -156,7 +156,7 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
return items;
|
|
159
|
-
}, [childrenKey, flattenData, someKeyword]); // Used to hover the focuse item when trigger `onKeydown`
|
|
159
|
+
}, [childrenKey, flattenData, someKeyword, parentSelectable]); // Used to hover the focuse item when trigger `onKeydown`
|
|
160
160
|
|
|
161
161
|
var _useFocusItemValue = useFocusItemValue(value, {
|
|
162
162
|
rtl: rtl,
|
|
@@ -64,7 +64,7 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
64
64
|
if (activeItem) {
|
|
65
65
|
var position = getPosition(activeItem, column); // Let the active option scroll into view.
|
|
66
66
|
|
|
67
|
-
scrollTop(column, position.top);
|
|
67
|
+
scrollTop(column, position === null || position === void 0 ? void 0 : position.top);
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}, [prefix]);
|
|
@@ -51,17 +51,20 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
51
51
|
controlledValue = props.value,
|
|
52
52
|
_props$defaultValue = props.defaultValue,
|
|
53
53
|
defaultValue = _props$defaultValue === void 0 ? emptyArray : _props$defaultValue,
|
|
54
|
-
|
|
54
|
+
_props$defaultExpandA = props.defaultExpandAll,
|
|
55
|
+
defaultExpandAll = _props$defaultExpandA === void 0 ? false : _props$defaultExpandA,
|
|
55
56
|
_props$disabledItemVa = props.disabledItemValues,
|
|
56
57
|
disabledItemValues = _props$disabledItemVa === void 0 ? emptyArray : _props$disabledItemVa,
|
|
57
58
|
controlledExpandItemValues = props.expandItemValues,
|
|
58
|
-
|
|
59
|
+
_props$defaultExpandI = props.defaultExpandItemValues,
|
|
60
|
+
defaultExpandItemValues = _props$defaultExpandI === void 0 ? emptyArray : _props$defaultExpandI,
|
|
59
61
|
_props$height = props.height,
|
|
60
62
|
height = _props$height === void 0 ? 360 : _props$height,
|
|
61
63
|
menuStyle = props.menuStyle,
|
|
62
64
|
_props$searchable = props.searchable,
|
|
63
65
|
searchable = _props$searchable === void 0 ? true : _props$searchable,
|
|
64
|
-
virtualized = props.virtualized,
|
|
66
|
+
_props$virtualized = props.virtualized,
|
|
67
|
+
virtualized = _props$virtualized === void 0 ? false : _props$virtualized,
|
|
65
68
|
className = props.className,
|
|
66
69
|
_props$classPrefix = props.classPrefix,
|
|
67
70
|
classPrefix = _props$classPrefix === void 0 ? 'picker' : _props$classPrefix,
|
|
@@ -243,15 +246,17 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
243
246
|
};
|
|
244
247
|
|
|
245
248
|
var focusActiveNode = useCallback(function () {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
if (listRef.current) {
|
|
250
|
+
focusToActiveTreeNode({
|
|
251
|
+
list: listRef.current,
|
|
252
|
+
valueKey: valueKey,
|
|
253
|
+
selector: "." + checkTreePrefix('node-active'),
|
|
254
|
+
activeNode: activeNode,
|
|
255
|
+
virtualized: virtualized,
|
|
256
|
+
container: treeViewRef.current,
|
|
257
|
+
formattedNodes: getFormattedNodes()
|
|
258
|
+
});
|
|
259
|
+
}
|
|
255
260
|
}, [checkTreePrefix, activeNode, getFormattedNodes, valueKey, virtualized]);
|
|
256
261
|
useEffect(function () {
|
|
257
262
|
setValue(getCheckTreePickerDefaultValue(value, uncheckableItemValues));
|
|
@@ -36,9 +36,9 @@ export declare function isEveryFirstLevelNodeUncheckable(nodes: TreeNodesType, u
|
|
|
36
36
|
* get node uncheckable state
|
|
37
37
|
* @param {*} node
|
|
38
38
|
*/
|
|
39
|
-
export declare function isNodeUncheckable(node: any, props:
|
|
40
|
-
export declare function getFormattedTree(data: any[], nodes: TreeNodesType, props:
|
|
41
|
-
export declare function getDisabledState(nodes: TreeNodesType, node: TreeNodeType, props:
|
|
39
|
+
export declare function isNodeUncheckable(node: any, props: Required<Pick<CheckTreePickerProps, 'uncheckableItemValues' | 'valueKey'>>): boolean;
|
|
40
|
+
export declare function getFormattedTree(data: any[], nodes: TreeNodesType, props: Required<Pick<CheckTreePickerProps, 'childrenKey' | 'cascade'>>): any[];
|
|
41
|
+
export declare function getDisabledState(nodes: TreeNodesType, node: TreeNodeType, props: Required<Pick<CheckTreePickerProps, 'disabledItemValues' | 'valueKey'>>): boolean;
|
|
42
42
|
export declare function getCheckTreePickerDefaultValue(value: any[], uncheckableItemValues: any[]): any[];
|
|
43
43
|
export declare function getSelectedItems(nodes: TreeNodesType, value: (string | number)[], valueKey: string): TreeNodeType[];
|
|
44
44
|
export declare function getNodeCheckState({ nodes, node, cascade, childrenKey }: any): CheckStateType;
|
|
@@ -109,7 +109,7 @@ export function getFormattedTree(data, nodes, props) {
|
|
|
109
109
|
var curNode = nodes[node.refKey];
|
|
110
110
|
|
|
111
111
|
if (curNode) {
|
|
112
|
-
var _node;
|
|
112
|
+
var _node$childrenKey;
|
|
113
113
|
|
|
114
114
|
var checkState = !_isUndefined(cascade) ? getNodeCheckState({
|
|
115
115
|
node: curNode,
|
|
@@ -123,7 +123,7 @@ export function getFormattedTree(data, nodes, props) {
|
|
|
123
123
|
formatted.parent = curNode.parent;
|
|
124
124
|
formatted.checkState = checkState;
|
|
125
125
|
|
|
126
|
-
if (((_node = node[childrenKey]) === null || _node === void 0 ? void 0 : _node.length) > 0) {
|
|
126
|
+
if (((_node$childrenKey = node[childrenKey]) === null || _node$childrenKey === void 0 ? void 0 : _node$childrenKey.length) > 0) {
|
|
127
127
|
formatted[childrenKey] = getFormattedTree(formatted[childrenKey], nodes, props);
|
|
128
128
|
}
|
|
129
129
|
}
|
package/esm/DOMHelper/index.d.ts
CHANGED
|
@@ -13,15 +13,15 @@ declare const DOMHelper: {
|
|
|
13
13
|
cancelAnimationFramePolyfill: typeof clearTimeout;
|
|
14
14
|
requestAnimationFramePolyfill: typeof requestAnimationFrame;
|
|
15
15
|
getAnimationEnd: typeof helpers.getAnimationEnd;
|
|
16
|
-
ownerDocument: (node: Element) => Document;
|
|
16
|
+
ownerDocument: (node: Element | null) => Document;
|
|
17
17
|
ownerWindow: (componentOrElement: Element) => Window;
|
|
18
18
|
getWindow: (node: any) => Window;
|
|
19
|
-
getContainer: (container: Element | (() => Element), defaultContainer?: Element | undefined) => Element;
|
|
19
|
+
getContainer: (container: Element | (() => Element | null) | null, defaultContainer?: Element | undefined) => Element;
|
|
20
20
|
canUseDOM: boolean;
|
|
21
21
|
contains: (context: Element, node: Node & ParentNode) => boolean;
|
|
22
22
|
scrollTop: (node: Element, val?: number | undefined) => number;
|
|
23
23
|
scrollLeft: (node: Element, val?: number | undefined) => number;
|
|
24
|
-
getOffset: (node: Element) => {
|
|
24
|
+
getOffset: (node: Element | null) => {
|
|
25
25
|
top: number;
|
|
26
26
|
left: number;
|
|
27
27
|
height: number;
|
|
@@ -42,7 +42,7 @@ declare const DOMHelper: {
|
|
|
42
42
|
isFocusable: typeof helpers.isFocusable;
|
|
43
43
|
getStyle: (node: Element, property?: string | undefined) => string | CSSStyleDeclaration;
|
|
44
44
|
removeStyle: (node: Element, keys: string | string[]) => void;
|
|
45
|
-
addStyle: (node: Element, property: string | import("dom-lib/esm/addStyle").CSSProperty
|
|
45
|
+
addStyle: (node: Element, property: string | Partial<import("dom-lib/esm/addStyle").CSSProperty>, value?: string | number | undefined) => void;
|
|
46
46
|
translateDOMPositionXY: (style: CSSStyleDeclaration, x?: number | undefined, y?: number | undefined) => CSSStyleDeclaration;
|
|
47
47
|
};
|
|
48
48
|
export default DOMHelper;
|
|
@@ -128,15 +128,6 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
128
128
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(nextValue, event);
|
|
129
129
|
onChangeCalendarDate === null || onChangeCalendarDate === void 0 ? void 0 : onChangeCalendarDate(nextValue, event);
|
|
130
130
|
}, [onChangeCalendarDate, onSelect]);
|
|
131
|
-
/**
|
|
132
|
-
* A callback triggered when the date on the calendar changes.
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
var handleChangePageDate = useCallback(function (nextPageDate) {
|
|
136
|
-
setCalendarDate(nextPageDate);
|
|
137
|
-
reset();
|
|
138
|
-
handleDateChange(nextPageDate);
|
|
139
|
-
}, [handleDateChange, reset, setCalendarDate]);
|
|
140
131
|
/**
|
|
141
132
|
* A callback triggered when the time on the calendar changes.
|
|
142
133
|
*/
|
|
@@ -261,6 +252,21 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
261
252
|
updateValue(event, nextValue);
|
|
262
253
|
}
|
|
263
254
|
}, [formatStr, handleDateChange, oneTap, calendarDate, setCalendarDate, updateValue]);
|
|
255
|
+
/**
|
|
256
|
+
* A callback triggered when the date on the calendar changes.
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
var handleChangePageDate = useCallback(function (nextPageDate, event) {
|
|
260
|
+
setCalendarDate(nextPageDate);
|
|
261
|
+
reset();
|
|
262
|
+
handleDateChange(nextPageDate); // Show only the calendar month panel. formatStr = 'yyyy-MM'
|
|
263
|
+
|
|
264
|
+
var onlyShowMonth = DateUtils.shouldMonth(formatStr) && !DateUtils.shouldDate(formatStr);
|
|
265
|
+
|
|
266
|
+
if (oneTap && onlyShowMonth) {
|
|
267
|
+
updateValue(event, nextPageDate);
|
|
268
|
+
}
|
|
269
|
+
}, [formatStr, handleDateChange, oneTap, reset, setCalendarDate, updateValue]);
|
|
264
270
|
var disabledDate = useCallback(function (date) {
|
|
265
271
|
var _disabledDateProp;
|
|
266
272
|
|
|
@@ -99,22 +99,8 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
99
99
|
return !after;
|
|
100
100
|
}, [calendarDate, index, showOneCalendar]);
|
|
101
101
|
var disabledMonth = useCallback(function (date) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (disabledDate !== null && disabledDate !== void 0 && disabledDate(date, value, DATERANGE_DISABLED_TARGET.CALENDAR)) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (showOneCalendar) return false;
|
|
109
|
-
|
|
110
|
-
if (index === 1) {
|
|
111
|
-
after = isAfter(date, calendarDate[0]);
|
|
112
|
-
return !after;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
after = isAfter(calendarDate[1], date);
|
|
116
|
-
return !after;
|
|
117
|
-
}, [calendarDate, disabledDate, index, showOneCalendar, value]);
|
|
102
|
+
return disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date, value, DATERANGE_DISABLED_TARGET.CALENDAR);
|
|
103
|
+
}, [disabledDate, value]);
|
|
118
104
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
119
105
|
format: format,
|
|
120
106
|
calendarState: calendarState,
|
|
@@ -250,7 +250,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
250
250
|
|
|
251
251
|
if (!hasDoneSelect.current) {
|
|
252
252
|
// If `hoverRange` is set, you need to change the value of hoverDateRange according to the rules
|
|
253
|
-
if (!isNil(nextHoverDateRange)) {
|
|
253
|
+
if (!isNil(nextHoverDateRange) && !isNil(selectRangeValueRef.current)) {
|
|
254
254
|
var nextSelectedDates = [selectRangeValueRef.current[0], nextHoverDateRange[1]];
|
|
255
255
|
|
|
256
256
|
if (DateUtils.isBefore(nextHoverDateRange[0], selectRangeValueRef.current[0])) {
|
|
@@ -3,6 +3,7 @@ import DropdownMenu from './DropdownMenu';
|
|
|
3
3
|
import { TypeAttributes, WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
4
4
|
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
5
5
|
import DropdownItem from './DropdownItem';
|
|
6
|
+
import Button from '../Button';
|
|
6
7
|
export declare type DropdownTrigger = 'click' | 'hover' | 'contextMenu';
|
|
7
8
|
export interface DropdownProps<T = any> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'title'> {
|
|
8
9
|
/** Define the title as a submenu */
|
|
@@ -48,6 +49,10 @@ export interface DropdownProps<T = any> extends WithAsProps, Omit<React.HTMLAttr
|
|
|
48
49
|
onSelect?: (eventKey: T | undefined, event: React.SyntheticEvent) => void;
|
|
49
50
|
}
|
|
50
51
|
export interface DropdownComponent extends RsRefForwardingComponent<'div', DropdownProps> {
|
|
52
|
+
<ToggleAs extends React.ElementType = typeof Button>(props: DropdownProps & {
|
|
53
|
+
ref?: React.Ref<any>;
|
|
54
|
+
toggleAs?: ToggleAs;
|
|
55
|
+
} & React.ComponentProps<ToggleAs>, context: any): JSX.Element | null;
|
|
51
56
|
Item: typeof DropdownItem;
|
|
52
57
|
Menu: typeof DropdownMenu;
|
|
53
58
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Dropdown from '../Dropdown';
|
|
3
|
+
var ref = /*#__PURE__*/React.createRef(); // Infer `toggleAs` props (defaults to Button)
|
|
4
|
+
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
React.createElement(Dropdown, {
|
|
7
|
+
ref: ref,
|
|
8
|
+
appearance: "subtle",
|
|
9
|
+
size: "sm"
|
|
10
|
+
});
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
12
|
+
|
|
13
|
+
var CustomToggle = function CustomToggle(_props) {
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/*#__PURE__*/
|
|
18
|
+
React.createElement(Dropdown, {
|
|
19
|
+
ref: ref,
|
|
20
|
+
toggleAs: CustomToggle,
|
|
21
|
+
myProp: "myValue"
|
|
22
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, TypeAttributes, FormControlBaseProps } from '../@types/common';
|
|
3
|
-
export interface InputNumberProps<T = number | string> extends WithAsProps, FormControlBaseProps<T> {
|
|
3
|
+
export interface InputNumberProps<T = number | string> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'size' | 'prefix'>, WithAsProps, FormControlBaseProps<T> {
|
|
4
4
|
/** Button can have different appearances */
|
|
5
5
|
buttonAppearance?: TypeAttributes.Appearance;
|
|
6
6
|
/** An input can show that it is disabled */
|
|
@@ -10,7 +10,7 @@ import InputGroup from '../InputGroup/InputGroup';
|
|
|
10
10
|
import InputGroupAddon from '../InputGroup/InputGroupAddon';
|
|
11
11
|
import Input from '../Input';
|
|
12
12
|
import Button from '../Button';
|
|
13
|
-
import { partitionHTMLProps, createChainedFunction, useClassNames, useControlled } from '../utils';
|
|
13
|
+
import { partitionHTMLProps, createChainedFunction, useClassNames, useControlled, KEY_VALUES } from '../utils';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Check if the value is a number.
|
|
@@ -93,16 +93,17 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
93
93
|
step = _props$step === void 0 ? 1 : _props$step,
|
|
94
94
|
_props$buttonAppearan = props.buttonAppearance,
|
|
95
95
|
buttonAppearance = _props$buttonAppearan === void 0 ? 'subtle' : _props$buttonAppearan,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_props$max = props.max,
|
|
99
|
-
max = _props$max === void 0 ? Infinity : _props$max,
|
|
96
|
+
minProp = props.min,
|
|
97
|
+
maxProp = props.max,
|
|
100
98
|
_props$scrollable = props.scrollable,
|
|
101
99
|
scrollable = _props$scrollable === void 0 ? true : _props$scrollable,
|
|
102
100
|
onChange = props.onChange,
|
|
103
101
|
onWheel = props.onWheel,
|
|
104
102
|
restProps = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "disabled", "readOnly", "plaintext", "value", "defaultValue", "size", "prefix", "postfix", "step", "buttonAppearance", "min", "max", "scrollable", "onChange", "onWheel"]);
|
|
105
103
|
|
|
104
|
+
var min = minProp !== null && minProp !== void 0 ? minProp : -Infinity;
|
|
105
|
+
var max = maxProp !== null && maxProp !== void 0 ? maxProp : Infinity;
|
|
106
|
+
|
|
106
107
|
var _useControlled = useControlled(valueProp, defaultValue),
|
|
107
108
|
value = _useControlled[0],
|
|
108
109
|
setValue = _useControlled[1];
|
|
@@ -166,6 +167,35 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
166
167
|
var bit = decimals(val, step);
|
|
167
168
|
handleChangeValue(getSafeValue((val - step).toFixed(bit)), event);
|
|
168
169
|
}, [getSafeValue, handleChangeValue, step, value]);
|
|
170
|
+
var handleKeyDown = useCallback(function (event) {
|
|
171
|
+
switch (event.key) {
|
|
172
|
+
case KEY_VALUES.UP:
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
handlePlus(event);
|
|
175
|
+
break;
|
|
176
|
+
|
|
177
|
+
case KEY_VALUES.DOWN:
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
handleMinus(event);
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
case KEY_VALUES.HOME:
|
|
183
|
+
if (typeof minProp !== 'undefined') {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
handleChangeValue(getSafeValue(minProp), event);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
break;
|
|
189
|
+
|
|
190
|
+
case KEY_VALUES.END:
|
|
191
|
+
if (typeof maxProp !== 'undefined') {
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
handleChangeValue(getSafeValue(maxProp), event);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}, [handlePlus, handleMinus, minProp, maxProp, handleChangeValue, getSafeValue]);
|
|
169
199
|
var handleWheel = useCallback(function (event) {
|
|
170
200
|
if (!disabled && !readOnly && event.target === document.activeElement) {
|
|
171
201
|
event.preventDefault();
|
|
@@ -211,7 +241,7 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
211
241
|
};
|
|
212
242
|
}, [handleWheel, scrollable]);
|
|
213
243
|
var input = /*#__PURE__*/React.createElement(Input, _extends({}, htmlInputProps, {
|
|
214
|
-
type: "
|
|
244
|
+
type: "number",
|
|
215
245
|
autoComplete: "off",
|
|
216
246
|
step: step,
|
|
217
247
|
inputRef: inputRef,
|
|
@@ -221,7 +251,8 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
221
251
|
disabled: disabled,
|
|
222
252
|
readOnly: readOnly,
|
|
223
253
|
plaintext: plaintext,
|
|
224
|
-
ref: plaintext ? ref : undefined
|
|
254
|
+
ref: plaintext ? ref : undefined,
|
|
255
|
+
onKeyDown: handleKeyDown
|
|
225
256
|
}));
|
|
226
257
|
|
|
227
258
|
if (plaintext) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -118,7 +118,9 @@ var InputAutosize = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
if (sizerRef.current) {
|
|
122
|
+
copyStyles(inputStyles, sizerRef.current);
|
|
123
|
+
}
|
|
122
124
|
|
|
123
125
|
if (placeholderRef.current) {
|
|
124
126
|
copyStyles(inputStyles, placeholderRef.current);
|
|
@@ -384,7 +384,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
384
384
|
var allData = getAllData();
|
|
385
385
|
var focusItem = allData.find(function (item) {
|
|
386
386
|
return shallowEqual(item[valueKey], focusItemValue);
|
|
387
|
-
});
|
|
387
|
+
}); // FIXME Bad state flow
|
|
388
388
|
|
|
389
389
|
if (!focusItem && focusItemValue === searchKeyword) {
|
|
390
390
|
focusItem = createOption(searchKeyword);
|
|
@@ -392,7 +392,11 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
392
392
|
|
|
393
393
|
setValue(focusItemValue);
|
|
394
394
|
setSearchKeyword('');
|
|
395
|
-
|
|
395
|
+
|
|
396
|
+
if (focusItem) {
|
|
397
|
+
handleSelect(focusItemValue, focusItem, event);
|
|
398
|
+
}
|
|
399
|
+
|
|
396
400
|
handleChange(focusItemValue, event);
|
|
397
401
|
handleClose();
|
|
398
402
|
}, [setValue, disabledItemValues, controlledData, focusItemValue, valueKey, searchKeyword, handleClose, setSearchKeyword, createOption, getAllData, handleChange, handleSelect]);
|
package/esm/List/ListItem.js
CHANGED
|
@@ -29,18 +29,20 @@ var ListItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
29
29
|
|
|
30
30
|
var listItemRef = useRef(null);
|
|
31
31
|
useEffect(function () {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
if (listItemRef.current) {
|
|
33
|
+
var _register = register({
|
|
34
|
+
node: listItemRef.current,
|
|
35
|
+
edgeOffset: null,
|
|
36
|
+
info: {
|
|
37
|
+
collection: collection,
|
|
38
|
+
disabled: disabled,
|
|
39
|
+
index: index
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
unregister = _register.unregister;
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
return unregister;
|
|
45
|
+
}
|
|
44
46
|
}, [collection, disabled, index, register]);
|
|
45
47
|
var classes = merge(className, withClassPrefix(size, {
|
|
46
48
|
disabled: disabled,
|
package/esm/Menu/MenuItem.js
CHANGED
|
@@ -61,19 +61,22 @@ function MenuItem(props) {
|
|
|
61
61
|
}, [dispatch]);
|
|
62
62
|
useEffect(function () {
|
|
63
63
|
var menuitemElement = menuitemRef.current;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
element: menuitemElement,
|
|
67
|
-
props: {
|
|
68
|
-
disabled: disabled
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return function () {
|
|
64
|
+
|
|
65
|
+
if (menuitemElement) {
|
|
72
66
|
dispatch({
|
|
73
|
-
type: MenuActionTypes.
|
|
74
|
-
|
|
67
|
+
type: MenuActionTypes.RegisterItem,
|
|
68
|
+
element: menuitemElement,
|
|
69
|
+
props: {
|
|
70
|
+
disabled: disabled
|
|
71
|
+
}
|
|
75
72
|
});
|
|
76
|
-
|
|
73
|
+
return function () {
|
|
74
|
+
dispatch({
|
|
75
|
+
type: MenuActionTypes.UnregisterItem,
|
|
76
|
+
id: menuitemElement.id
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
77
80
|
}, [menuitemRef, disabled, dispatch]);
|
|
78
81
|
var menuitemProps = {
|
|
79
82
|
id: menuitemId,
|
|
@@ -459,6 +459,7 @@ var MultiCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
459
459
|
var _usePickerClassName = usePickerClassName(_extends({}, props, {
|
|
460
460
|
classPrefix: classPrefix,
|
|
461
461
|
hasValue: hasValue,
|
|
462
|
+
countable: countable,
|
|
462
463
|
name: 'cascader',
|
|
463
464
|
appearance: appearance,
|
|
464
465
|
cleanable: cleanable
|
|
@@ -37,7 +37,10 @@ var PickerOverlay = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
37
37
|
// Get the width value of the button,
|
|
38
38
|
// and then set it to the menu to make their width consistent.
|
|
39
39
|
var width = getWidth(getDOMNode(toggle.root));
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
if (overlayRef.current) {
|
|
42
|
+
addStyle(overlayRef.current, 'min-width', width + "px");
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
}, [autoWidth, target, overlayRef]);
|
|
43
46
|
|