rsuite 5.5.2 → 5.6.2
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 +27 -0
- package/README.md +4 -2
- package/cjs/@types/common.d.ts +4 -4
- package/cjs/Affix/Affix.js +0 -1
- package/cjs/Animation/Transition.d.ts +1 -1
- package/cjs/Animation/Transition.js +10 -4
- 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/DropdownMenu.js +1 -1
- package/cjs/CheckTreePicker/CheckTreePicker.js +29 -17
- package/cjs/CheckTreePicker/utils.d.ts +3 -3
- package/cjs/CheckTreePicker/utils.js +3 -3
- package/cjs/DOMHelper/index.d.ts +4 -4
- package/cjs/DatePicker/DatePicker.d.ts +2 -1
- package/cjs/DatePicker/DatePicker.js +19 -12
- package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/cjs/DateRangePicker/DateRangePicker.js +5 -4
- package/cjs/IconButton/IconButton.d.ts +5 -2
- package/cjs/IconButton/IconButton.js +2 -2
- package/cjs/IconButton/test/IconButton.test.d.ts +1 -0
- package/cjs/IconButton/test/IconButton.test.js +24 -0
- package/cjs/InputPicker/InputAutosize.js +3 -1
- package/cjs/InputPicker/InputPicker.js +6 -2
- package/cjs/List/ListItem.js +13 -11
- package/cjs/List/helper/AutoScroller.d.ts +2 -3
- package/cjs/List/helper/useManager.d.ts +2 -2
- package/cjs/List/helper/useSortHelper.js +23 -9
- package/cjs/List/helper/utils.d.ts +4 -3
- package/cjs/List/helper/utils.js +2 -2
- package/cjs/MaskedInput/conformToMask.js +1 -0
- package/cjs/Menu/MenuItem.js +14 -11
- package/cjs/MultiCascader/DropdownMenu.js +2 -1
- package/cjs/MultiCascader/utils.js +7 -7
- package/cjs/Overlay/Position.js +1 -2
- package/cjs/Pagination/PaginationGroup.js +3 -3
- package/cjs/Picker/PickerOverlay.js +4 -1
- package/cjs/Picker/SelectedElement.js +1 -1
- package/cjs/Picker/index.d.ts +2 -1
- package/cjs/Ripple/Ripple.js +17 -9
- package/cjs/TreePicker/TreePicker.js +16 -12
- package/cjs/Uploader/UploadTrigger.js +3 -1
- package/cjs/Uploader/Uploader.js +8 -2
- package/cjs/toaster/toaster.d.ts +1 -1
- package/cjs/toaster/toaster.js +9 -3
- package/cjs/utils/treeUtils.d.ts +3 -3
- package/cjs/utils/treeUtils.js +6 -4
- package/cjs/utils/useElementResize.d.ts +1 -1
- package/cjs/utils/useElementResize.js +5 -2
- package/cjs/utils/useTimeout.d.ts +2 -2
- package/cjs/utils/useTimeout.js +17 -8
- package/dist/rsuite.js +381 -62
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/@types/common.d.ts +4 -4
- package/esm/Affix/Affix.js +0 -1
- package/esm/Animation/Transition.d.ts +1 -1
- package/esm/Animation/Transition.js +10 -4
- 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/DropdownMenu.js +1 -1
- package/esm/CheckTreePicker/CheckTreePicker.js +29 -17
- package/esm/CheckTreePicker/utils.d.ts +3 -3
- package/esm/CheckTreePicker/utils.js +3 -3
- package/esm/DOMHelper/index.d.ts +4 -4
- package/esm/DatePicker/DatePicker.d.ts +2 -1
- package/esm/DatePicker/DatePicker.js +19 -12
- package/esm/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/esm/DateRangePicker/DateRangePicker.js +5 -4
- package/esm/IconButton/IconButton.d.ts +5 -2
- package/esm/IconButton/IconButton.js +1 -1
- package/esm/IconButton/test/IconButton.test.d.ts +1 -0
- package/esm/IconButton/test/IconButton.test.js +18 -0
- package/esm/InputPicker/InputAutosize.js +3 -1
- package/esm/InputPicker/InputPicker.js +6 -2
- package/esm/List/ListItem.js +13 -11
- package/esm/List/helper/AutoScroller.d.ts +2 -3
- package/esm/List/helper/useManager.d.ts +2 -2
- package/esm/List/helper/useSortHelper.js +23 -9
- package/esm/List/helper/utils.d.ts +4 -3
- package/esm/List/helper/utils.js +2 -2
- package/esm/MaskedInput/conformToMask.js +1 -0
- package/esm/Menu/MenuItem.js +14 -11
- package/esm/MultiCascader/DropdownMenu.js +2 -1
- package/esm/MultiCascader/utils.js +7 -7
- package/esm/Overlay/Position.js +1 -2
- package/esm/Pagination/PaginationGroup.js +3 -3
- package/esm/Picker/PickerOverlay.js +4 -1
- package/esm/Picker/SelectedElement.js +1 -1
- package/esm/Picker/index.d.ts +2 -1
- package/esm/Ripple/Ripple.js +17 -9
- package/esm/TreePicker/TreePicker.js +16 -12
- package/esm/Uploader/UploadTrigger.js +3 -1
- package/esm/Uploader/Uploader.js +8 -2
- package/esm/toaster/toaster.d.ts +1 -1
- package/esm/toaster/toaster.js +9 -3
- package/esm/utils/treeUtils.d.ts +3 -3
- package/esm/utils/treeUtils.js +6 -4
- package/esm/utils/useElementResize.d.ts +1 -1
- package/esm/utils/useElementResize.js +5 -2
- package/esm/utils/useTimeout.d.ts +2 -2
- package/esm/utils/useTimeout.js +17 -8
- package/package.json +3 -3
package/esm/@types/common.d.ts
CHANGED
|
@@ -143,10 +143,10 @@ export interface ItemDataType<T = number | string> extends Record<string, any> {
|
|
|
143
143
|
loading?: boolean;
|
|
144
144
|
}
|
|
145
145
|
export interface Offset {
|
|
146
|
-
top
|
|
147
|
-
left
|
|
148
|
-
width
|
|
149
|
-
height
|
|
146
|
+
top: number;
|
|
147
|
+
left: number;
|
|
148
|
+
width: number;
|
|
149
|
+
height: number;
|
|
150
150
|
}
|
|
151
151
|
export declare type OnChangeCallback<T, E = React.SyntheticEvent> = (value: T, event: E) => void;
|
|
152
152
|
export {};
|
package/esm/Affix/Affix.js
CHANGED
|
@@ -118,7 +118,6 @@ var Affix = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
118
118
|
var fixedStyles = {
|
|
119
119
|
position: 'fixed',
|
|
120
120
|
top: top,
|
|
121
|
-
left: offset === null || offset === void 0 ? void 0 : offset.left,
|
|
122
121
|
width: offset === null || offset === void 0 ? void 0 : offset.width,
|
|
123
122
|
zIndex: 10
|
|
124
123
|
};
|
|
@@ -100,7 +100,7 @@ declare class Transition extends React.Component<TransitionProps, TransitionStat
|
|
|
100
100
|
setNextCallback(callback: (event?: React.AnimationEvent) => void): {
|
|
101
101
|
(event?: React.AnimationEvent<Element> | undefined): void;
|
|
102
102
|
cancel: () => any;
|
|
103
|
-
};
|
|
103
|
+
} | null;
|
|
104
104
|
getChildElement(): HTMLElement;
|
|
105
105
|
performEnter(props: TransitionProps): void;
|
|
106
106
|
performExit(props: TransitionProps): void;
|
|
@@ -133,6 +133,10 @@ var Transition = /*#__PURE__*/function (_React$Component) {
|
|
|
133
133
|
this.setNextCallback(handler);
|
|
134
134
|
(_this$animationEventL = this.animationEventListener) === null || _this$animationEventL === void 0 ? void 0 : _this$animationEventL.off();
|
|
135
135
|
|
|
136
|
+
if (!this.nextCallback) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
136
140
|
if (node) {
|
|
137
141
|
var _this$props = this.props,
|
|
138
142
|
timeout = _this$props.timeout,
|
|
@@ -172,9 +176,11 @@ var Transition = /*#__PURE__*/function (_React$Component) {
|
|
|
172
176
|
_this2.nextCallback = null;
|
|
173
177
|
};
|
|
174
178
|
|
|
175
|
-
this.nextCallback
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
if (this.nextCallback) {
|
|
180
|
+
this.nextCallback.cancel = function () {
|
|
181
|
+
active = false;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
178
184
|
|
|
179
185
|
return this.nextCallback;
|
|
180
186
|
};
|
|
@@ -252,7 +258,7 @@ var Transition = /*#__PURE__*/function (_React$Component) {
|
|
|
252
258
|
if (this.instanceElement) {
|
|
253
259
|
var nextCallback = this.setNextCallback(callback);
|
|
254
260
|
this.setState(nextState, function () {
|
|
255
|
-
return nextCallback();
|
|
261
|
+
return nextCallback === null || nextCallback === void 0 ? void 0 : nextCallback();
|
|
256
262
|
});
|
|
257
263
|
}
|
|
258
264
|
};
|
|
@@ -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']),
|
|
@@ -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));
|
|
@@ -283,9 +288,9 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
283
288
|
forceUpdate();
|
|
284
289
|
}, [cascade, value, uncheckableItemValues, unSerializeList, flattenNodes, forceUpdate]);
|
|
285
290
|
var toggleUpChecked = useCallback(function (nodes, node, checked) {
|
|
286
|
-
var currentNode = nodes[node.refKey];
|
|
291
|
+
var currentNode = node.refKey ? nodes[node.refKey] : null;
|
|
287
292
|
|
|
288
|
-
if (cascade) {
|
|
293
|
+
if (cascade && currentNode) {
|
|
289
294
|
if (!checked) {
|
|
290
295
|
currentNode.check = checked;
|
|
291
296
|
currentNode.checkAll = checked;
|
|
@@ -305,7 +310,12 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
305
310
|
}
|
|
306
311
|
}, [cascade]);
|
|
307
312
|
var toggleDownChecked = useCallback(function (nodes, node, isChecked) {
|
|
308
|
-
var currentNode = nodes[node.refKey];
|
|
313
|
+
var currentNode = node.refKey ? nodes[node.refKey] : null;
|
|
314
|
+
|
|
315
|
+
if (!currentNode) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
309
319
|
currentNode.check = isChecked;
|
|
310
320
|
|
|
311
321
|
if (!currentNode[childrenKey] || !currentNode[childrenKey].length || !cascade) {
|
|
@@ -329,11 +339,13 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
329
339
|
});
|
|
330
340
|
}, [flattenNodes, uncheckableItemValues, serializeListOnlyParent, toggleDownChecked, toggleUpChecked]);
|
|
331
341
|
var handleSelect = useCallback(function (node, event) {
|
|
332
|
-
|
|
342
|
+
var currentNode = node.refKey ? flattenNodes[node.refKey] : null;
|
|
343
|
+
|
|
344
|
+
if (!node || !currentNode) {
|
|
333
345
|
return;
|
|
334
346
|
}
|
|
335
347
|
|
|
336
|
-
var selectedValues = toggleChecked(node, !
|
|
348
|
+
var selectedValues = toggleChecked(node, !currentNode.check);
|
|
337
349
|
|
|
338
350
|
if (!isControlled) {
|
|
339
351
|
unSerializeList({
|
|
@@ -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
|
}
|
|
@@ -141,7 +141,7 @@ export function getDisabledState(nodes, node, props) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
return disabledItemValues.some(function (value) {
|
|
144
|
-
return shallowEqual(nodes[node.refKey][valueKey], value);
|
|
144
|
+
return node.refKey && shallowEqual(nodes[node.refKey][valueKey], value);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
export function getCheckTreePickerDefaultValue(value, uncheckableItemValues) {
|
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;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RangeType } from './Toolbar';
|
|
3
3
|
import { DatePickerLocale } from '../locales';
|
|
4
|
+
import { PickerToggleProps } from '../Picker';
|
|
4
5
|
import { FormControlBaseProps, PickerBaseProps, RsRefForwardingComponent } from '../@types/common';
|
|
5
6
|
export type { RangeType } from './Toolbar';
|
|
6
|
-
export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, FormControlBaseProps<Date | null> {
|
|
7
|
+
export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, FormControlBaseProps<Date | null>, Pick<PickerToggleProps, 'caretAs' | 'readOnly' | 'plaintext'> {
|
|
7
8
|
/** Configure shortcut options */
|
|
8
9
|
ranges?: RangeType<Date>[];
|
|
9
10
|
/** Calendar panel default presentation date and time */
|
|
@@ -44,6 +44,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
44
44
|
showWeekNumbers = props.showWeekNumbers,
|
|
45
45
|
style = props.style,
|
|
46
46
|
toggleAs = props.toggleAs,
|
|
47
|
+
caretAsProp = props.caretAs,
|
|
47
48
|
disabledDateProp = props.disabledDate,
|
|
48
49
|
renderValue = props.renderValue,
|
|
49
50
|
onChange = props.onChange,
|
|
@@ -59,7 +60,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
59
60
|
onSelect = props.onSelect,
|
|
60
61
|
onToggleMonthDropdown = props.onToggleMonthDropdown,
|
|
61
62
|
onToggleTimeDropdown = props.onToggleTimeDropdown,
|
|
62
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "calendarDefaultDate", "cleanable", "defaultValue", "disabled", "format", "isoWeek", "limitEndYear", "locale", "menuClassName", "appearance", "placement", "oneTap", "placeholder", "ranges", "value", "showMeridian", "showWeekNumbers", "style", "toggleAs", "disabledDate", "renderValue", "onChange", "onChangeCalendarDate", "onClean", "onClose", "onEntered", "onExited", "onNextMonth", "onOk", "onOpen", "onPrevMonth", "onSelect", "onToggleMonthDropdown", "onToggleTimeDropdown"]);
|
|
63
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "calendarDefaultDate", "cleanable", "defaultValue", "disabled", "format", "isoWeek", "limitEndYear", "locale", "menuClassName", "appearance", "placement", "oneTap", "placeholder", "ranges", "value", "showMeridian", "showWeekNumbers", "style", "toggleAs", "caretAs", "disabledDate", "renderValue", "onChange", "onChangeCalendarDate", "onClean", "onClose", "onEntered", "onExited", "onNextMonth", "onOk", "onOpen", "onPrevMonth", "onSelect", "onToggleMonthDropdown", "onToggleTimeDropdown"]);
|
|
63
64
|
|
|
64
65
|
var _useCustom = useCustom('DatePicker', overrideLocale),
|
|
65
66
|
locale = _useCustom.locale,
|
|
@@ -128,15 +129,6 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
128
129
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(nextValue, event);
|
|
129
130
|
onChangeCalendarDate === null || onChangeCalendarDate === void 0 ? void 0 : onChangeCalendarDate(nextValue, event);
|
|
130
131
|
}, [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
132
|
/**
|
|
141
133
|
* A callback triggered when the time on the calendar changes.
|
|
142
134
|
*/
|
|
@@ -261,6 +253,21 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
261
253
|
updateValue(event, nextValue);
|
|
262
254
|
}
|
|
263
255
|
}, [formatStr, handleDateChange, oneTap, calendarDate, setCalendarDate, updateValue]);
|
|
256
|
+
/**
|
|
257
|
+
* A callback triggered when the date on the calendar changes.
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
var handleChangePageDate = useCallback(function (nextPageDate, event) {
|
|
261
|
+
setCalendarDate(nextPageDate);
|
|
262
|
+
reset();
|
|
263
|
+
handleDateChange(nextPageDate); // Show only the calendar month panel. formatStr = 'yyyy-MM'
|
|
264
|
+
|
|
265
|
+
var onlyShowMonth = DateUtils.shouldMonth(formatStr) && !DateUtils.shouldDate(formatStr);
|
|
266
|
+
|
|
267
|
+
if (oneTap && onlyShowMonth) {
|
|
268
|
+
updateValue(event, nextPageDate);
|
|
269
|
+
}
|
|
270
|
+
}, [formatStr, handleDateChange, oneTap, reset, setCalendarDate, updateValue]);
|
|
264
271
|
var disabledDate = useCallback(function (date) {
|
|
265
272
|
var _disabledDateProp;
|
|
266
273
|
|
|
@@ -409,8 +416,8 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
409
416
|
return (_renderValue = renderValue === null || renderValue === void 0 ? void 0 : renderValue(value, formatStr)) !== null && _renderValue !== void 0 ? _renderValue : formatDate(value, formatStr);
|
|
410
417
|
}, [formatStr, formatDate, placeholder, renderValue, value]);
|
|
411
418
|
var caretAs = useMemo(function () {
|
|
412
|
-
return DateUtils.shouldOnlyTime(formatStr) ? IconClockO : IconCalendar;
|
|
413
|
-
}, [formatStr]);
|
|
419
|
+
return caretAsProp || (DateUtils.shouldOnlyTime(formatStr) ? IconClockO : IconCalendar);
|
|
420
|
+
}, [caretAsProp, formatStr]);
|
|
414
421
|
return /*#__PURE__*/React.createElement(PickerToggleTrigger, {
|
|
415
422
|
trigger: "active",
|
|
416
423
|
pickerProps: pick(props, pickTriggerPropKeys),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormControlBaseProps, PickerBaseProps } from '../@types/common';
|
|
3
|
-
import { PickerComponent } from '../Picker';
|
|
3
|
+
import { PickerComponent, PickerToggleProps } from '../Picker';
|
|
4
4
|
import { DisabledDateFunction, RangeType, DateRange } from './types';
|
|
5
|
-
export interface DateRangePickerProps extends PickerBaseProps, FormControlBaseProps<DateRange | null> {
|
|
5
|
+
export interface DateRangePickerProps extends PickerBaseProps, FormControlBaseProps<DateRange | null>, Pick<PickerToggleProps, 'caretAs' | 'readOnly' | 'plaintext'> {
|
|
6
6
|
/** Configure shortcut options */
|
|
7
7
|
ranges?: RangeType[];
|
|
8
8
|
/** Format date */
|
|
@@ -56,6 +56,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
56
56
|
showMeridian = props.showMeridian,
|
|
57
57
|
style = props.style,
|
|
58
58
|
toggleAs = props.toggleAs,
|
|
59
|
+
caretAs = props.caretAs,
|
|
59
60
|
valueProp = props.value,
|
|
60
61
|
onChange = props.onChange,
|
|
61
62
|
onClean = props.onClean,
|
|
@@ -66,7 +67,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
66
67
|
onOk = props.onOk,
|
|
67
68
|
onOpen = props.onOpen,
|
|
68
69
|
onSelect = props.onSelect,
|
|
69
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "appearance", "cleanable", "character", "defaultCalendarValue", "defaultValue", "disabled", "disabledDate", "format", "hoverRange", "isoWeek", "limitEndYear", "locale", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "renderValue", "showOneCalendar", "showWeekNumbers", "showMeridian", "style", "toggleAs", "value", "onChange", "onClean", "onClose", "onEnter", "onEntered", "onExited", "onOk", "onOpen", "onSelect"]);
|
|
70
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "appearance", "cleanable", "character", "defaultCalendarValue", "defaultValue", "disabled", "disabledDate", "format", "hoverRange", "isoWeek", "limitEndYear", "locale", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "renderValue", "showOneCalendar", "showWeekNumbers", "showMeridian", "style", "toggleAs", "caretAs", "value", "onChange", "onClean", "onClose", "onEnter", "onEntered", "onExited", "onOk", "onOpen", "onSelect"]);
|
|
70
71
|
|
|
71
72
|
var _useClassNames = useClassNames(classPrefix),
|
|
72
73
|
merge = _useClassNames.merge,
|
|
@@ -250,7 +251,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
250
251
|
|
|
251
252
|
if (!hasDoneSelect.current) {
|
|
252
253
|
// If `hoverRange` is set, you need to change the value of hoverDateRange according to the rules
|
|
253
|
-
if (!isNil(nextHoverDateRange)) {
|
|
254
|
+
if (!isNil(nextHoverDateRange) && !isNil(selectRangeValueRef.current)) {
|
|
254
255
|
var nextSelectedDates = [selectRangeValueRef.current[0], nextHoverDateRange[1]];
|
|
255
256
|
|
|
256
257
|
if (DateUtils.isBefore(nextHoverDateRange[0], selectRangeValueRef.current[0])) {
|
|
@@ -606,8 +607,8 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
606
607
|
hasValue: hasValue,
|
|
607
608
|
active: isPickerToggleActive,
|
|
608
609
|
placement: placement,
|
|
609
|
-
|
|
610
|
-
|
|
610
|
+
disabled: disabled,
|
|
611
|
+
caretAs: caretAs || IconCalendar
|
|
611
612
|
}), getDisplayString(value))));
|
|
612
613
|
});
|
|
613
614
|
DateRangePicker.after = disabledDateUtils.after;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ButtonProps } from '../Button';
|
|
3
2
|
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
3
|
+
import { RsRefForwardingComponent } from '../@types/common';
|
|
4
|
+
import Button, { ButtonProps } from '../Button';
|
|
4
5
|
export interface IconButtonProps extends ButtonProps {
|
|
5
6
|
/** Set the icon */
|
|
6
7
|
icon?: React.ReactElement<IconProps>;
|
|
@@ -9,5 +10,7 @@ export interface IconButtonProps extends ButtonProps {
|
|
|
9
10
|
/** The placement of icon */
|
|
10
11
|
placement?: 'left' | 'right';
|
|
11
12
|
}
|
|
12
|
-
declare const IconButton:
|
|
13
|
+
declare const IconButton: RsRefForwardingComponent<typeof Button, IconButtonProps & {
|
|
14
|
+
ref?: React.Ref<HTMLElement>;
|
|
15
|
+
}>;
|
|
13
16
|
export default IconButton;
|
|
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import Button from '../Button';
|
|
6
5
|
import { useClassNames } from '../utils';
|
|
6
|
+
import Button from '../Button';
|
|
7
7
|
var IconButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
8
8
|
var icon = props.icon,
|
|
9
9
|
_props$placement = props.placement,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import IconButton from '../IconButton';
|
|
3
|
+
|
|
4
|
+
var Link = function Link(_ref) {
|
|
5
|
+
var to = _ref.to;
|
|
6
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
7
|
+
href: to
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
var ref = /*#__PURE__*/React.createRef(); // Infer `as` component props
|
|
12
|
+
|
|
13
|
+
/*#__PURE__*/
|
|
14
|
+
React.createElement(IconButton, {
|
|
15
|
+
ref: ref,
|
|
16
|
+
as: Link,
|
|
17
|
+
to: "/home"
|
|
18
|
+
});
|
|
@@ -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,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare type OffsetCallback = (offset: Offset) => void;
|
|
1
|
+
import { Axis, EdgeOffset } from './utils';
|
|
2
|
+
declare type OffsetCallback = (offset: EdgeOffset) => void;
|
|
4
3
|
export interface AutoScrollerUpdatePayload {
|
|
5
4
|
translate: Axis;
|
|
6
5
|
minTranslate: Axis;
|