rsuite 5.75.0 → 5.76.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 (68) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/Image/package.json +7 -0
  3. package/Image/styles/index.css +33 -0
  4. package/Image/styles/index.less +34 -0
  5. package/cjs/Carousel/Carousel.js +1 -0
  6. package/cjs/CustomProvider/CustomProvider.d.ts +13 -15
  7. package/cjs/CustomProvider/CustomProvider.js +6 -4
  8. package/cjs/CustomProvider/types.d.ts +2 -0
  9. package/cjs/Image/Image.d.ts +42 -0
  10. package/cjs/Image/Image.js +102 -0
  11. package/cjs/Image/ImageWrapper.d.ts +1 -0
  12. package/cjs/Image/ImageWrapper.js +10 -0
  13. package/cjs/Image/hooks/useImage.d.ts +14 -0
  14. package/cjs/Image/hooks/useImage.js +68 -0
  15. package/cjs/Image/index.d.ts +3 -0
  16. package/cjs/Image/index.js +8 -0
  17. package/cjs/index.d.ts +2 -0
  18. package/cjs/index.js +4 -2
  19. package/cjs/internals/utils/getDOMNode.js +2 -1
  20. package/cjs/internals/utils/index.d.ts +0 -1
  21. package/cjs/internals/utils/index.js +1 -4
  22. package/cjs/toaster/ToastContainer.d.ts +6 -6
  23. package/cjs/toaster/ToastContainer.js +48 -38
  24. package/cjs/toaster/render.d.ts +3 -0
  25. package/cjs/toaster/render.js +43 -0
  26. package/cjs/toaster/toaster.js +33 -20
  27. package/cjs/useToaster/useToaster.js +10 -5
  28. package/dist/rsuite-no-reset-rtl.css +34 -0
  29. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  30. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  31. package/dist/rsuite-no-reset.css +34 -0
  32. package/dist/rsuite-no-reset.min.css +1 -1
  33. package/dist/rsuite-no-reset.min.css.map +1 -1
  34. package/dist/rsuite-rtl.css +34 -0
  35. package/dist/rsuite-rtl.min.css +1 -1
  36. package/dist/rsuite-rtl.min.css.map +1 -1
  37. package/dist/rsuite.css +34 -0
  38. package/dist/rsuite.js +63 -19
  39. package/dist/rsuite.js.map +1 -1
  40. package/dist/rsuite.min.css +1 -1
  41. package/dist/rsuite.min.css.map +1 -1
  42. package/dist/rsuite.min.js +1 -1
  43. package/dist/rsuite.min.js.map +1 -1
  44. package/esm/Carousel/Carousel.js +1 -0
  45. package/esm/CustomProvider/CustomProvider.d.ts +13 -15
  46. package/esm/CustomProvider/CustomProvider.js +7 -5
  47. package/esm/CustomProvider/types.d.ts +2 -0
  48. package/esm/Image/Image.d.ts +42 -0
  49. package/esm/Image/Image.js +97 -0
  50. package/esm/Image/ImageWrapper.d.ts +1 -0
  51. package/esm/Image/ImageWrapper.js +6 -0
  52. package/esm/Image/hooks/useImage.d.ts +14 -0
  53. package/esm/Image/hooks/useImage.js +63 -0
  54. package/esm/Image/index.d.ts +3 -0
  55. package/esm/Image/index.js +3 -0
  56. package/esm/index.d.ts +2 -0
  57. package/esm/index.js +1 -0
  58. package/esm/internals/utils/getDOMNode.js +2 -1
  59. package/esm/internals/utils/index.d.ts +0 -1
  60. package/esm/internals/utils/index.js +0 -1
  61. package/esm/toaster/ToastContainer.d.ts +6 -6
  62. package/esm/toaster/ToastContainer.js +49 -39
  63. package/esm/toaster/render.d.ts +3 -0
  64. package/esm/toaster/render.js +35 -0
  65. package/esm/toaster/toaster.js +31 -20
  66. package/esm/useToaster/useToaster.js +10 -5
  67. package/package.json +1 -1
  68. package/styles/index.less +1 -0
@@ -1,16 +1,17 @@
1
1
  'use client';
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
- var _excluded = ["placement"];
5
+ var _excluded = ["placement", "container"];
5
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
- import ToastContainer from "./ToastContainer.js";
7
- var defaultContainerId = 'default';
7
+ import ToastContainer, { defaultToasterContainer } from "./ToastContainer.js";
8
+ import { toasterKeyOfContainerElement } from "./render.js";
8
9
  var containers = new Map();
9
10
 
10
11
  /**
11
- * Create a container by Id.
12
- * @param containerId
13
- * @param options
12
+ * Create a container instance.
13
+ * @param placement
14
+ * @param props
14
15
  */
15
16
  function createContainer(_x, _x2) {
16
17
  return _createContainer.apply(this, arguments);
@@ -18,10 +19,11 @@ function createContainer(_x, _x2) {
18
19
  /**
19
20
  * Get the container by ID. Use default ID when ID is not available.
20
21
  * @param containerId
22
+ * @param placement
21
23
  */
22
24
  function _createContainer() {
23
- _createContainer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(containerId, props) {
24
- var _yield$ToastContainer, container;
25
+ _createContainer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(placement, props) {
26
+ var _yield$ToastContainer, container, containerId;
25
27
  return _regeneratorRuntime.wrap(function _callee$(_context) {
26
28
  while (1) switch (_context.prev = _context.next) {
27
29
  case 0:
@@ -30,9 +32,10 @@ function _createContainer() {
30
32
  case 2:
31
33
  _yield$ToastContainer = _context.sent;
32
34
  container = _yield$ToastContainer[0];
33
- containers.set(containerId || defaultContainerId, container);
35
+ containerId = _yield$ToastContainer[1];
36
+ containers.set(containerId + "_" + placement, container);
34
37
  return _context.abrupt("return", container);
35
- case 6:
38
+ case 7:
36
39
  case "end":
37
40
  return _context.stop();
38
41
  }
@@ -40,11 +43,8 @@ function _createContainer() {
40
43
  }));
41
44
  return _createContainer.apply(this, arguments);
42
45
  }
43
- function getContainer(containerId) {
44
- if (containers.size == 0) {
45
- return null;
46
- }
47
- return containers.get(containerId || defaultContainerId);
46
+ function getContainer(containerId, placement) {
47
+ return containers.get(containerId + "_" + placement);
48
48
  }
49
49
  var _toaster = function toaster(message) {
50
50
  return _toaster.push(message);
@@ -54,13 +54,24 @@ _toaster.push = function (message, options) {
54
54
  options = {};
55
55
  }
56
56
  var _options = options,
57
- containerId = _options.placement,
57
+ _options$placement = _options.placement,
58
+ placement = _options$placement === void 0 ? 'topCenter' : _options$placement,
59
+ container = _options.container,
58
60
  restOptions = _objectWithoutPropertiesLoose(_options, _excluded);
59
- var container = getContainer(containerId);
60
- if (container !== null && container !== void 0 && container.current) {
61
- return container.current.push(message, restOptions);
61
+ var containerElement = (typeof container === 'function' ? container() : container) || defaultToasterContainer;
62
+ var containerElementId = containerElement[toasterKeyOfContainerElement];
63
+ if (containerElementId) {
64
+ var existedContainer = getContainer(containerElementId, placement);
65
+ if (existedContainer) {
66
+ var _existedContainer$cur;
67
+ return (_existedContainer$cur = existedContainer.current) === null || _existedContainer$cur === void 0 ? void 0 : _existedContainer$cur.push(message, restOptions);
68
+ }
62
69
  }
63
- return createContainer(containerId !== null && containerId !== void 0 ? containerId : '', options).then(function (ref) {
70
+ var newOptions = _extends({}, options, {
71
+ container: containerElement,
72
+ placement: placement
73
+ });
74
+ return createContainer(placement, newOptions).then(function (ref) {
64
75
  var _ref$current;
65
76
  return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.push(message, restOptions);
66
77
  });
@@ -13,7 +13,8 @@ import { CustomContext } from "../CustomProvider/CustomProvider.js";
13
13
  */
14
14
  var useToaster = function useToaster() {
15
15
  var _useContext = useContext(CustomContext),
16
- toasters = _useContext.toasters;
16
+ toasters = _useContext.toasters,
17
+ toastContainer = _useContext.toastContainer;
17
18
  return useMemo(function () {
18
19
  return {
19
20
  /**
@@ -25,9 +26,13 @@ var useToaster = function useToaster() {
25
26
  * @returns The key of the toast message.
26
27
  */
27
28
  push: function push(message, options) {
28
- var _toasters$current;
29
- var customToaster = toasters === null || toasters === void 0 || (_toasters$current = toasters.current) === null || _toasters$current === void 0 ? void 0 : _toasters$current.get((options === null || options === void 0 ? void 0 : options.placement) || 'topCenter');
30
- return customToaster ? customToaster.push(message, options) : toaster.push(message, options);
29
+ var container = (typeof (options === null || options === void 0 ? void 0 : options.container) === 'function' ? options === null || options === void 0 ? void 0 : options.container() : options === null || options === void 0 ? void 0 : options.container) || toastContainer;
30
+ if (container === toastContainer) {
31
+ var _toasters$current;
32
+ return toasters === null || toasters === void 0 || (_toasters$current = toasters.current) === null || _toasters$current === void 0 || (_toasters$current = _toasters$current.get((options === null || options === void 0 ? void 0 : options.placement) || 'topCenter')) === null || _toasters$current === void 0 ? void 0 : _toasters$current.push(message, options);
33
+ } else {
34
+ return toaster.push(message, options);
35
+ }
31
36
  },
32
37
  /**
33
38
  * Remove a toast message.
@@ -49,6 +54,6 @@ var useToaster = function useToaster() {
49
54
  }) : toaster.clear();
50
55
  }
51
56
  };
52
- }, [toasters]);
57
+ }, [toastContainer, toasters]);
53
58
  };
54
59
  export default useToaster;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.75.0",
3
+ "version": "5.76.1",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
package/styles/index.less CHANGED
@@ -40,6 +40,7 @@
40
40
  @import '../Header/styles/index';
41
41
  @import '../FormHelpText/styles/index';
42
42
  @import '../IconButton/styles/index';
43
+ @import '../Image/styles/index';
43
44
  @import '../Input/styles/index';
44
45
  @import '../InputGroup/styles/index';
45
46
  @import '../InputNumber/styles/index';