rsuite 5.6.0 → 5.6.3

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 (73) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -1
  3. package/cjs/@types/common.d.ts +4 -4
  4. package/cjs/Affix/Affix.js +0 -2
  5. package/cjs/Animation/Transition.d.ts +1 -1
  6. package/cjs/Animation/Transition.js +10 -4
  7. package/cjs/CheckTreePicker/CheckTreePicker.js +12 -5
  8. package/cjs/CheckTreePicker/utils.js +1 -1
  9. package/cjs/DatePicker/DatePicker.d.ts +2 -1
  10. package/cjs/DatePicker/DatePicker.js +4 -3
  11. package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -2
  12. package/cjs/DateRangePicker/DateRangePicker.js +4 -3
  13. package/cjs/IconButton/IconButton.d.ts +5 -2
  14. package/cjs/IconButton/IconButton.js +2 -2
  15. package/cjs/IconButton/test/IconButton.test.d.ts +1 -0
  16. package/cjs/IconButton/test/IconButton.test.js +24 -0
  17. package/cjs/List/helper/AutoScroller.d.ts +2 -3
  18. package/cjs/List/helper/useManager.d.ts +2 -2
  19. package/cjs/List/helper/useSortHelper.js +23 -9
  20. package/cjs/List/helper/utils.d.ts +4 -3
  21. package/cjs/List/helper/utils.js +2 -2
  22. package/cjs/MaskedInput/conformToMask.js +1 -0
  23. package/cjs/MultiCascader/DropdownMenu.js +2 -1
  24. package/cjs/MultiCascader/utils.js +7 -7
  25. package/cjs/Overlay/Position.js +1 -2
  26. package/cjs/Pagination/PaginationGroup.js +3 -3
  27. package/cjs/Picker/SelectedElement.js +1 -1
  28. package/cjs/Picker/index.d.ts +2 -1
  29. package/cjs/TreePicker/TreePicker.js +1 -1
  30. package/cjs/Uploader/Uploader.js +5 -1
  31. package/cjs/toaster/toaster.d.ts +1 -1
  32. package/cjs/toaster/toaster.js +9 -3
  33. package/cjs/utils/treeUtils.js +6 -4
  34. package/cjs/utils/useTimeout.d.ts +2 -2
  35. package/cjs/utils/useTimeout.js +17 -8
  36. package/dist/rsuite.js +38 -357
  37. package/dist/rsuite.js.map +1 -1
  38. package/dist/rsuite.min.js +1 -1
  39. package/dist/rsuite.min.js.map +1 -1
  40. package/esm/@types/common.d.ts +4 -4
  41. package/esm/Affix/Affix.js +0 -2
  42. package/esm/Animation/Transition.d.ts +1 -1
  43. package/esm/Animation/Transition.js +10 -4
  44. package/esm/CheckTreePicker/CheckTreePicker.js +12 -5
  45. package/esm/CheckTreePicker/utils.js +1 -1
  46. package/esm/DatePicker/DatePicker.d.ts +2 -1
  47. package/esm/DatePicker/DatePicker.js +4 -3
  48. package/esm/DateRangePicker/DateRangePicker.d.ts +2 -2
  49. package/esm/DateRangePicker/DateRangePicker.js +4 -3
  50. package/esm/IconButton/IconButton.d.ts +5 -2
  51. package/esm/IconButton/IconButton.js +1 -1
  52. package/esm/IconButton/test/IconButton.test.d.ts +1 -0
  53. package/esm/IconButton/test/IconButton.test.js +18 -0
  54. package/esm/List/helper/AutoScroller.d.ts +2 -3
  55. package/esm/List/helper/useManager.d.ts +2 -2
  56. package/esm/List/helper/useSortHelper.js +23 -9
  57. package/esm/List/helper/utils.d.ts +4 -3
  58. package/esm/List/helper/utils.js +2 -2
  59. package/esm/MaskedInput/conformToMask.js +1 -0
  60. package/esm/MultiCascader/DropdownMenu.js +2 -1
  61. package/esm/MultiCascader/utils.js +7 -7
  62. package/esm/Overlay/Position.js +1 -2
  63. package/esm/Pagination/PaginationGroup.js +3 -3
  64. package/esm/Picker/SelectedElement.js +1 -1
  65. package/esm/Picker/index.d.ts +2 -1
  66. package/esm/TreePicker/TreePicker.js +1 -1
  67. package/esm/Uploader/Uploader.js +5 -1
  68. package/esm/toaster/toaster.d.ts +1 -1
  69. package/esm/toaster/toaster.js +9 -3
  70. package/esm/utils/treeUtils.js +6 -4
  71. package/esm/utils/useTimeout.d.ts +2 -2
  72. package/esm/utils/useTimeout.js +17 -8
  73. package/package.json +2 -2
@@ -41,6 +41,8 @@ var toaster = function toaster(message) {
41
41
  };
42
42
 
43
43
  toaster.push = function (message, options) {
44
+ var _container$current;
45
+
44
46
  if (options === void 0) {
45
47
  options = {};
46
48
  }
@@ -53,18 +55,22 @@ toaster.push = function (message, options) {
53
55
  container = createContainer((_options$placement = options.placement) !== null && _options$placement !== void 0 ? _options$placement : '', options);
54
56
  }
55
57
 
56
- return container.current.push(message);
58
+ return (_container$current = container.current) === null || _container$current === void 0 ? void 0 : _container$current.push(message);
57
59
  };
58
60
 
59
61
  toaster.remove = function (key) {
60
62
  containers.forEach(function (c) {
61
- return c.current.remove(key);
63
+ var _c$current;
64
+
65
+ return (_c$current = c.current) === null || _c$current === void 0 ? void 0 : _c$current.remove(key);
62
66
  });
63
67
  };
64
68
 
65
69
  toaster.clear = function () {
66
70
  containers.forEach(function (c) {
67
- return c.current.clear();
71
+ var _c$current2;
72
+
73
+ return (_c$current2 = c.current) === null || _c$current2 === void 0 ? void 0 : _c$current2.clear();
68
74
  });
69
75
  };
70
76
 
@@ -165,11 +165,13 @@ function getNodeParentKeys(nodes, node, valueKey) {
165
165
  var parentKeys = [];
166
166
 
167
167
  var traverse = function traverse(node) {
168
- if (node !== null && node !== void 0 && node.parent) {
169
- var _node$parent;
168
+ var _node$parent;
169
+
170
+ if (node !== null && node !== void 0 && (_node$parent = node.parent) !== null && _node$parent !== void 0 && _node$parent.refKey) {
171
+ var _node$parent2;
170
172
 
171
173
  traverse(nodes[node.parent.refKey]);
172
- parentKeys.push(node === null || node === void 0 ? void 0 : (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent[valueKey]);
174
+ parentKeys.push(node === null || node === void 0 ? void 0 : (_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2[valueKey]);
173
175
  }
174
176
  };
175
177
 
@@ -718,7 +720,7 @@ function getChildrenByFlattenNodes(nodes, parent) {
718
720
  return Object.values(nodes).filter(function (item) {
719
721
  var _item$parent;
720
722
 
721
- return (item === null || item === void 0 ? void 0 : (_item$parent = item.parent) === null || _item$parent === void 0 ? void 0 : _item$parent.refKey) === parent.refKey && !nodes[item.refKey].uncheckable;
723
+ return (item === null || item === void 0 ? void 0 : (_item$parent = item.parent) === null || _item$parent === void 0 ? void 0 : _item$parent.refKey) === parent.refKey && item.refKey && !nodes[item.refKey].uncheckable;
722
724
  });
723
725
  }
724
726
 
@@ -6,7 +6,7 @@ export interface UseTimeoutFnReturn {
6
6
  * A timer hook
7
7
  * @param fn Timer callback function
8
8
  * @param ms Milliseconds of the timer
9
- * @param open Whether to open the timer
9
+ * @param enabled Whether to open the timer
10
10
  */
11
- declare function useTimeout(fn: (() => void) | undefined, ms?: number, open?: boolean): UseTimeoutFnReturn;
11
+ declare function useTimeout(fn: (() => void) | undefined, ms?: number, enabled?: boolean): UseTimeoutFnReturn;
12
12
  export default useTimeout;
@@ -9,32 +9,41 @@ var _react = require("react");
9
9
  * A timer hook
10
10
  * @param fn Timer callback function
11
11
  * @param ms Milliseconds of the timer
12
- * @param open Whether to open the timer
12
+ * @param enabled Whether to open the timer
13
13
  */
14
- function useTimeout(fn, ms, open) {
14
+ function useTimeout(fn, ms, enabled) {
15
15
  if (ms === void 0) {
16
16
  ms = 0;
17
17
  }
18
18
 
19
- if (open === void 0) {
20
- open = true;
19
+ if (enabled === void 0) {
20
+ enabled = true;
21
21
  }
22
22
 
23
23
  var timeout = (0, _react.useRef)();
24
+ var callback = (0, _react.useRef)(fn);
24
25
  var clear = (0, _react.useCallback)(function () {
25
26
  timeout.current && clearTimeout(timeout.current);
26
27
  }, []);
27
28
  var set = (0, _react.useCallback)(function () {
28
- if (open) {
29
+ timeout.current && clearTimeout(timeout.current);
30
+
31
+ if (enabled) {
29
32
  timeout.current = setTimeout(function () {
30
- return fn === null || fn === void 0 ? void 0 : fn();
33
+ var _callback$current;
34
+
35
+ (_callback$current = callback.current) === null || _callback$current === void 0 ? void 0 : _callback$current.call(callback);
31
36
  }, ms);
32
37
  }
33
- }, [ms, fn, open]);
38
+ }, [ms, enabled]); // update ref when function changes
39
+
40
+ (0, _react.useEffect)(function () {
41
+ callback.current = fn;
42
+ }, [fn]);
34
43
  (0, _react.useEffect)(function () {
35
44
  set();
36
45
  return clear;
37
- }, [fn, ms, open, clear, set]);
46
+ }, [ms, enabled, set, clear]);
38
47
  return {
39
48
  clear: clear,
40
49
  reset: set