rsuite 5.5.0 → 5.6.1

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 (89) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/Carousel/styles/index.less +1 -0
  3. package/CheckTreePicker/styles/index.less +5 -5
  4. package/Modal/styles/mixin.less +1 -0
  5. package/README.md +4 -2
  6. package/Sidenav/styles/index.less +2 -2
  7. package/cjs/Affix/Affix.js +1 -0
  8. package/cjs/Calendar/TimeDropdown.js +7 -4
  9. package/cjs/Carousel/Carousel.d.ts +5 -1
  10. package/cjs/Carousel/Carousel.js +22 -16
  11. package/cjs/Cascader/Cascader.js +2 -2
  12. package/cjs/Cascader/DropdownMenu.js +1 -1
  13. package/cjs/CheckTreePicker/CheckTreePicker.js +17 -12
  14. package/cjs/CheckTreePicker/utils.d.ts +3 -3
  15. package/cjs/CheckTreePicker/utils.js +2 -2
  16. package/cjs/DOMHelper/index.d.ts +4 -4
  17. package/cjs/DatePicker/DatePicker.d.ts +2 -1
  18. package/cjs/DatePicker/DatePicker.js +19 -12
  19. package/cjs/DateRangePicker/Calendar.js +2 -16
  20. package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -2
  21. package/cjs/DateRangePicker/DateRangePicker.js +5 -4
  22. package/cjs/IconButton/IconButton.d.ts +5 -2
  23. package/cjs/IconButton/IconButton.js +2 -2
  24. package/cjs/IconButton/test/IconButton.test.d.ts +1 -0
  25. package/cjs/IconButton/test/IconButton.test.js +24 -0
  26. package/cjs/InputPicker/InputAutosize.js +3 -1
  27. package/cjs/InputPicker/InputPicker.js +6 -2
  28. package/cjs/List/ListItem.js +13 -11
  29. package/cjs/Menu/MenuItem.js +14 -11
  30. package/cjs/Picker/PickerOverlay.js +4 -1
  31. package/cjs/Picker/index.d.ts +2 -1
  32. package/cjs/Ripple/Ripple.js +17 -9
  33. package/cjs/TreePicker/TreePicker.js +15 -11
  34. package/cjs/Uploader/UploadTrigger.js +3 -1
  35. package/cjs/Uploader/Uploader.js +3 -1
  36. package/cjs/toaster/toaster.d.ts +1 -1
  37. package/cjs/toaster/toaster.js +9 -3
  38. package/cjs/utils/treeUtils.d.ts +3 -3
  39. package/cjs/utils/useElementResize.d.ts +1 -1
  40. package/cjs/utils/useElementResize.js +5 -2
  41. package/cjs/utils/useTimeout.d.ts +2 -2
  42. package/cjs/utils/useTimeout.js +17 -8
  43. package/dist/rsuite-rtl.css +23 -16
  44. package/dist/rsuite-rtl.min.css +1 -1
  45. package/dist/rsuite-rtl.min.css.map +1 -1
  46. package/dist/rsuite.css +23 -16
  47. package/dist/rsuite.js +370 -51
  48. package/dist/rsuite.js.map +1 -1
  49. package/dist/rsuite.min.css +1 -1
  50. package/dist/rsuite.min.css.map +1 -1
  51. package/dist/rsuite.min.js +1 -1
  52. package/dist/rsuite.min.js.map +1 -1
  53. package/esm/Affix/Affix.js +1 -0
  54. package/esm/Calendar/TimeDropdown.js +7 -4
  55. package/esm/Carousel/Carousel.d.ts +5 -1
  56. package/esm/Carousel/Carousel.js +23 -17
  57. package/esm/Cascader/Cascader.js +2 -2
  58. package/esm/Cascader/DropdownMenu.js +1 -1
  59. package/esm/CheckTreePicker/CheckTreePicker.js +17 -12
  60. package/esm/CheckTreePicker/utils.d.ts +3 -3
  61. package/esm/CheckTreePicker/utils.js +2 -2
  62. package/esm/DOMHelper/index.d.ts +4 -4
  63. package/esm/DatePicker/DatePicker.d.ts +2 -1
  64. package/esm/DatePicker/DatePicker.js +19 -12
  65. package/esm/DateRangePicker/Calendar.js +2 -16
  66. package/esm/DateRangePicker/DateRangePicker.d.ts +2 -2
  67. package/esm/DateRangePicker/DateRangePicker.js +5 -4
  68. package/esm/IconButton/IconButton.d.ts +5 -2
  69. package/esm/IconButton/IconButton.js +1 -1
  70. package/esm/IconButton/test/IconButton.test.d.ts +1 -0
  71. package/esm/IconButton/test/IconButton.test.js +18 -0
  72. package/esm/InputPicker/InputAutosize.js +3 -1
  73. package/esm/InputPicker/InputPicker.js +6 -2
  74. package/esm/List/ListItem.js +13 -11
  75. package/esm/Menu/MenuItem.js +14 -11
  76. package/esm/Picker/PickerOverlay.js +4 -1
  77. package/esm/Picker/index.d.ts +2 -1
  78. package/esm/Ripple/Ripple.js +17 -9
  79. package/esm/TreePicker/TreePicker.js +15 -11
  80. package/esm/Uploader/UploadTrigger.js +3 -1
  81. package/esm/Uploader/Uploader.js +3 -1
  82. package/esm/toaster/toaster.d.ts +1 -1
  83. package/esm/toaster/toaster.js +9 -3
  84. package/esm/utils/treeUtils.d.ts +3 -3
  85. package/esm/utils/useElementResize.d.ts +1 -1
  86. package/esm/utils/useElementResize.js +5 -2
  87. package/esm/utils/useTimeout.d.ts +2 -2
  88. package/esm/utils/useTimeout.js +17 -8
  89. package/package.json +3 -3
@@ -14,6 +14,7 @@ function useOffset(mountRef) {
14
14
  setOffset = _useState[1];
15
15
 
16
16
  var updateOffset = useCallback(function () {
17
+ // FIXME upgrade dom-lib
17
18
  setOffset(getOffset(mountRef.current));
18
19
  }, [mountRef]); // Update after the element size changes
19
20
 
@@ -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']),
@@ -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
- 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));
@@ -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
  }
@@ -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),
@@ -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
- var after;
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,
@@ -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,
@@ -61,19 +61,22 @@ function MenuItem(props) {
61
61
  }, [dispatch]);
62
62
  useEffect(function () {
63
63
  var menuitemElement = menuitemRef.current;
64
- dispatch({
65
- type: MenuActionTypes.RegisterItem,
66
- element: menuitemElement,
67
- props: {
68
- disabled: disabled
69
- }
70
- });
71
- return function () {
64
+
65
+ if (menuitemElement) {
72
66
  dispatch({
73
- type: MenuActionTypes.UnregisterItem,
74
- id: menuitemElement.id
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,
@@ -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
- addStyle(overlayRef.current, 'min-width', width + "px");
40
+
41
+ if (overlayRef.current) {
42
+ addStyle(overlayRef.current, 'min-width', width + "px");
43
+ }
41
44
  }
42
45
  }, [autoWidth, target, overlayRef]);
43
46
 
@@ -1,4 +1,5 @@
1
1
  import { pickTriggerPropKeys, omitTriggerPropKeys, OverlayTriggerInstance, PositionChildProps } from './PickerToggleTrigger';
2
+ import { PickerToggleProps } from './PickerToggle';
2
3
  import { PickerInstance, PickerComponent } from './types';
3
4
  export { default as DropdownMenu } from './DropdownMenu';
4
5
  export { default as DropdownMenuCheckItem } from './DropdownMenuCheckItem';
@@ -10,6 +11,6 @@ export { default as PickerToggleTrigger } from './PickerToggleTrigger';
10
11
  export { default as SearchBar } from './SearchBar';
11
12
  export { default as SelectedElement } from './SelectedElement';
12
13
  export { pickTriggerPropKeys, omitTriggerPropKeys };
13
- export type { OverlayTriggerInstance, PositionChildProps, PickerInstance, PickerComponent };
14
+ export type { OverlayTriggerInstance, PositionChildProps, PickerInstance, PickerComponent, PickerToggleProps };
14
15
  export * from './utils';
15
16
  export * from './propTypes';