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.
- package/CHANGELOG.md +18 -0
- package/Image/package.json +7 -0
- package/Image/styles/index.css +33 -0
- package/Image/styles/index.less +34 -0
- package/cjs/Carousel/Carousel.js +1 -0
- package/cjs/CustomProvider/CustomProvider.d.ts +13 -15
- package/cjs/CustomProvider/CustomProvider.js +6 -4
- package/cjs/CustomProvider/types.d.ts +2 -0
- package/cjs/Image/Image.d.ts +42 -0
- package/cjs/Image/Image.js +102 -0
- package/cjs/Image/ImageWrapper.d.ts +1 -0
- package/cjs/Image/ImageWrapper.js +10 -0
- package/cjs/Image/hooks/useImage.d.ts +14 -0
- package/cjs/Image/hooks/useImage.js +68 -0
- package/cjs/Image/index.d.ts +3 -0
- package/cjs/Image/index.js +8 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +4 -2
- package/cjs/internals/utils/getDOMNode.js +2 -1
- package/cjs/internals/utils/index.d.ts +0 -1
- package/cjs/internals/utils/index.js +1 -4
- package/cjs/toaster/ToastContainer.d.ts +6 -6
- package/cjs/toaster/ToastContainer.js +48 -38
- package/cjs/toaster/render.d.ts +3 -0
- package/cjs/toaster/render.js +43 -0
- package/cjs/toaster/toaster.js +33 -20
- package/cjs/useToaster/useToaster.js +10 -5
- package/dist/rsuite-no-reset-rtl.css +34 -0
- package/dist/rsuite-no-reset-rtl.min.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
- package/dist/rsuite-no-reset.css +34 -0
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +34 -0
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +34 -0
- package/dist/rsuite.js +63 -19
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Carousel/Carousel.js +1 -0
- package/esm/CustomProvider/CustomProvider.d.ts +13 -15
- package/esm/CustomProvider/CustomProvider.js +7 -5
- package/esm/CustomProvider/types.d.ts +2 -0
- package/esm/Image/Image.d.ts +42 -0
- package/esm/Image/Image.js +97 -0
- package/esm/Image/ImageWrapper.d.ts +1 -0
- package/esm/Image/ImageWrapper.js +6 -0
- package/esm/Image/hooks/useImage.d.ts +14 -0
- package/esm/Image/hooks/useImage.js +63 -0
- package/esm/Image/index.d.ts +3 -0
- package/esm/Image/index.js +3 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/internals/utils/getDOMNode.js +2 -1
- package/esm/internals/utils/index.d.ts +0 -1
- package/esm/internals/utils/index.js +0 -1
- package/esm/toaster/ToastContainer.d.ts +6 -6
- package/esm/toaster/ToastContainer.js +49 -39
- package/esm/toaster/render.d.ts +3 -0
- package/esm/toaster/render.js +35 -0
- package/esm/toaster/toaster.js +31 -20
- package/esm/useToaster/useToaster.js +10 -5
- package/package.json +1 -1
- package/styles/index.less +1 -0
package/esm/toaster/toaster.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
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(
|
|
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
|
-
|
|
35
|
+
containerId = _yield$ToastContainer[1];
|
|
36
|
+
containers.set(containerId + "_" + placement, container);
|
|
34
37
|
return _context.abrupt("return", container);
|
|
35
|
-
case
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
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
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';
|