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.
Files changed (105) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +4 -2
  3. package/cjs/@types/common.d.ts +4 -4
  4. package/cjs/Affix/Affix.js +0 -1
  5. package/cjs/Animation/Transition.d.ts +1 -1
  6. package/cjs/Animation/Transition.js +10 -4
  7. package/cjs/Calendar/TimeDropdown.js +7 -4
  8. package/cjs/Carousel/Carousel.d.ts +5 -1
  9. package/cjs/Carousel/Carousel.js +22 -16
  10. package/cjs/Cascader/DropdownMenu.js +1 -1
  11. package/cjs/CheckTreePicker/CheckTreePicker.js +29 -17
  12. package/cjs/CheckTreePicker/utils.d.ts +3 -3
  13. package/cjs/CheckTreePicker/utils.js +3 -3
  14. package/cjs/DOMHelper/index.d.ts +4 -4
  15. package/cjs/DatePicker/DatePicker.d.ts +2 -1
  16. package/cjs/DatePicker/DatePicker.js +19 -12
  17. package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -2
  18. package/cjs/DateRangePicker/DateRangePicker.js +5 -4
  19. package/cjs/IconButton/IconButton.d.ts +5 -2
  20. package/cjs/IconButton/IconButton.js +2 -2
  21. package/cjs/IconButton/test/IconButton.test.d.ts +1 -0
  22. package/cjs/IconButton/test/IconButton.test.js +24 -0
  23. package/cjs/InputPicker/InputAutosize.js +3 -1
  24. package/cjs/InputPicker/InputPicker.js +6 -2
  25. package/cjs/List/ListItem.js +13 -11
  26. package/cjs/List/helper/AutoScroller.d.ts +2 -3
  27. package/cjs/List/helper/useManager.d.ts +2 -2
  28. package/cjs/List/helper/useSortHelper.js +23 -9
  29. package/cjs/List/helper/utils.d.ts +4 -3
  30. package/cjs/List/helper/utils.js +2 -2
  31. package/cjs/MaskedInput/conformToMask.js +1 -0
  32. package/cjs/Menu/MenuItem.js +14 -11
  33. package/cjs/MultiCascader/DropdownMenu.js +2 -1
  34. package/cjs/MultiCascader/utils.js +7 -7
  35. package/cjs/Overlay/Position.js +1 -2
  36. package/cjs/Pagination/PaginationGroup.js +3 -3
  37. package/cjs/Picker/PickerOverlay.js +4 -1
  38. package/cjs/Picker/SelectedElement.js +1 -1
  39. package/cjs/Picker/index.d.ts +2 -1
  40. package/cjs/Ripple/Ripple.js +17 -9
  41. package/cjs/TreePicker/TreePicker.js +16 -12
  42. package/cjs/Uploader/UploadTrigger.js +3 -1
  43. package/cjs/Uploader/Uploader.js +8 -2
  44. package/cjs/toaster/toaster.d.ts +1 -1
  45. package/cjs/toaster/toaster.js +9 -3
  46. package/cjs/utils/treeUtils.d.ts +3 -3
  47. package/cjs/utils/treeUtils.js +6 -4
  48. package/cjs/utils/useElementResize.d.ts +1 -1
  49. package/cjs/utils/useElementResize.js +5 -2
  50. package/cjs/utils/useTimeout.d.ts +2 -2
  51. package/cjs/utils/useTimeout.js +17 -8
  52. package/dist/rsuite.js +381 -62
  53. package/dist/rsuite.js.map +1 -1
  54. package/dist/rsuite.min.js +1 -1
  55. package/dist/rsuite.min.js.map +1 -1
  56. package/esm/@types/common.d.ts +4 -4
  57. package/esm/Affix/Affix.js +0 -1
  58. package/esm/Animation/Transition.d.ts +1 -1
  59. package/esm/Animation/Transition.js +10 -4
  60. package/esm/Calendar/TimeDropdown.js +7 -4
  61. package/esm/Carousel/Carousel.d.ts +5 -1
  62. package/esm/Carousel/Carousel.js +23 -17
  63. package/esm/Cascader/DropdownMenu.js +1 -1
  64. package/esm/CheckTreePicker/CheckTreePicker.js +29 -17
  65. package/esm/CheckTreePicker/utils.d.ts +3 -3
  66. package/esm/CheckTreePicker/utils.js +3 -3
  67. package/esm/DOMHelper/index.d.ts +4 -4
  68. package/esm/DatePicker/DatePicker.d.ts +2 -1
  69. package/esm/DatePicker/DatePicker.js +19 -12
  70. package/esm/DateRangePicker/DateRangePicker.d.ts +2 -2
  71. package/esm/DateRangePicker/DateRangePicker.js +5 -4
  72. package/esm/IconButton/IconButton.d.ts +5 -2
  73. package/esm/IconButton/IconButton.js +1 -1
  74. package/esm/IconButton/test/IconButton.test.d.ts +1 -0
  75. package/esm/IconButton/test/IconButton.test.js +18 -0
  76. package/esm/InputPicker/InputAutosize.js +3 -1
  77. package/esm/InputPicker/InputPicker.js +6 -2
  78. package/esm/List/ListItem.js +13 -11
  79. package/esm/List/helper/AutoScroller.d.ts +2 -3
  80. package/esm/List/helper/useManager.d.ts +2 -2
  81. package/esm/List/helper/useSortHelper.js +23 -9
  82. package/esm/List/helper/utils.d.ts +4 -3
  83. package/esm/List/helper/utils.js +2 -2
  84. package/esm/MaskedInput/conformToMask.js +1 -0
  85. package/esm/Menu/MenuItem.js +14 -11
  86. package/esm/MultiCascader/DropdownMenu.js +2 -1
  87. package/esm/MultiCascader/utils.js +7 -7
  88. package/esm/Overlay/Position.js +1 -2
  89. package/esm/Pagination/PaginationGroup.js +3 -3
  90. package/esm/Picker/PickerOverlay.js +4 -1
  91. package/esm/Picker/SelectedElement.js +1 -1
  92. package/esm/Picker/index.d.ts +2 -1
  93. package/esm/Ripple/Ripple.js +17 -9
  94. package/esm/TreePicker/TreePicker.js +16 -12
  95. package/esm/Uploader/UploadTrigger.js +3 -1
  96. package/esm/Uploader/Uploader.js +8 -2
  97. package/esm/toaster/toaster.d.ts +1 -1
  98. package/esm/toaster/toaster.js +9 -3
  99. package/esm/utils/treeUtils.d.ts +3 -3
  100. package/esm/utils/treeUtils.js +6 -4
  101. package/esm/utils/useElementResize.d.ts +1 -1
  102. package/esm/utils/useElementResize.js +5 -2
  103. package/esm/utils/useTimeout.d.ts +2 -2
  104. package/esm/utils/useTimeout.js +17 -8
  105. package/package.json +3 -3
@@ -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?: number;
147
- left?: number;
148
- width?: number;
149
- height?: number;
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 {};
@@ -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.cancel = function () {
176
- active = false;
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 _ref2 = getPosition(node, container),
82
- top = _ref2.top;
81
+ var position = getPosition(node, container);
83
82
 
84
- scrollTopAnimation(container, top, scrollTop(container) !== 0);
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 && scrollTo(time, rowRef.current);
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
- /** Callback fired when the active item changes */
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;
@@ -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
- activeIndex = _useState[0],
43
- setActiveIndex = _useState[1];
49
+ lastIndex = _useState[0],
50
+ setLastIndex = _useState[1];
44
51
 
45
- var _useState2 = useState(0),
46
- lastIndex = _useState2[0],
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 rootRef = useRef(null);
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 handleSlide(nextActiveIndex, event) {
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]); // Set a timer for automatic playback.
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
- defaultExpandAll = props.defaultExpandAll,
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
- defaultExpandItemValues = props.defaultExpandItemValues,
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
- focusToActiveTreeNode({
247
- list: listRef.current,
248
- valueKey: valueKey,
249
- selector: "." + checkTreePrefix('node-active'),
250
- activeNode: activeNode,
251
- virtualized: virtualized,
252
- container: treeViewRef.current,
253
- formattedNodes: getFormattedNodes()
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
- if (!node) {
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, !flattenNodes[node.refKey].check);
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: Partial<CheckTreePickerProps>): boolean;
40
- export declare function getFormattedTree(data: any[], nodes: TreeNodesType, props: Partial<CheckTreePickerProps>): any[];
41
- export declare function getDisabledState(nodes: TreeNodesType, node: TreeNodeType, props: Partial<CheckTreePickerProps>): boolean;
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) {
@@ -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, value?: string | number | undefined) => void;
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
- caretAs: IconCalendar,
610
- disabled: disabled
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: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<unknown>>;
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
- copyStyles(inputStyles, sizerRef.current);
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
- handleSelect(focusItemValue, focusItem, event);
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]);
@@ -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
- var _register = register({
33
- node: listItemRef.current,
34
- edgeOffset: null,
35
- info: {
36
- collection: collection,
37
- disabled: disabled,
38
- index: index
39
- }
40
- }),
41
- unregister = _register.unregister;
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
- return unregister;
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 { Offset } from '../../@types/common';
2
- import { Axis } from './utils';
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;