@mezzanine-ui/react 0.10.3 → 0.10.4
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/Message/Message.js
CHANGED
|
@@ -38,7 +38,7 @@ const { add, config, destroy, remove, } = createNotifier({
|
|
|
38
38
|
duration: 3000,
|
|
39
39
|
render: (message) => jsx(Message, { ...message }),
|
|
40
40
|
setRoot: (root) => {
|
|
41
|
-
root.setAttribute('class', messageClasses.root);
|
|
41
|
+
root === null || root === void 0 ? void 0 : root.setAttribute('class', messageClasses.root);
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
Message.add = add;
|
|
@@ -50,5 +50,5 @@ export interface Notification extends FC<NotificationData>, Notifier<Notificatio
|
|
|
50
50
|
* Use the API from the Notification instance such as `Notification.success` and `Notification.error`
|
|
51
51
|
* to display a notification globally.
|
|
52
52
|
*/
|
|
53
|
-
declare const
|
|
54
|
-
export default
|
|
53
|
+
declare const NotificationElement: Notification;
|
|
54
|
+
export default NotificationElement;
|
|
@@ -16,7 +16,7 @@ import { createNotifier } from '../Notifier/createNotifier.js';
|
|
|
16
16
|
* to display a notification globally.
|
|
17
17
|
*/
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
19
|
-
const
|
|
19
|
+
const NotificationElement = ((props) => {
|
|
20
20
|
const { cancelText, children, confirmText, direction = 'left', duration, onCancel: onCancelProp, onClose: onCloseProp, onConfirm: onConfirmProp, onExited: onExitedProp, reference, severity, title, ...restTransitionProps } = props;
|
|
21
21
|
const targetIcon = severity ? notificationIcons[severity] : severity;
|
|
22
22
|
const [open, setOpen] = useState(true);
|
|
@@ -48,27 +48,27 @@ const Notification = ((props) => {
|
|
|
48
48
|
if (onExitedProp) {
|
|
49
49
|
onExitedProp(node);
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
NotificationElement.remove(reference);
|
|
52
52
|
};
|
|
53
53
|
return (jsx(SlideFade, { in: open, appear: true, onExited: onExited, direction: direction, ...restTransitionProps, children: jsxs("div", { className: cx(notificationClasses.host, severity ? notificationClasses.severity(severity) : undefined), children: [targetIcon ? (jsx("div", { className: notificationClasses.iconContainer, children: jsx(Icon, { icon: targetIcon, className: notificationClasses.severityIcon }) })) : null, jsxs("div", { className: notificationClasses.body, children: [jsx("h4", { className: notificationClasses.title, children: title }), jsx("div", { className: notificationClasses.content, children: children }), onConfirm && !severity ? (jsxs(ButtonGroup, { className: notificationClasses.action, children: [jsx(Button, { variant: "contained", onClick: onConfirm, children: confirmText }), jsx(Button, { variant: "outlined", onClick: onCancel || onClose, children: cancelText })] })) : null] }), jsx(Icon, { icon: TimesIcon, className: notificationClasses.closeIcon, onClick: onClose })] }) }));
|
|
54
54
|
});
|
|
55
55
|
const { add, config, destroy, remove, } = createNotifier({
|
|
56
56
|
duration: false,
|
|
57
|
-
render: (notif) => jsx(
|
|
57
|
+
render: (notif) => jsx(NotificationElement, { ...notif }),
|
|
58
58
|
setRoot: (root) => {
|
|
59
|
-
root.setAttribute('class', notificationClasses.root);
|
|
59
|
+
root === null || root === void 0 ? void 0 : root.setAttribute('class', notificationClasses.root);
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
NotificationElement.add = add;
|
|
63
|
+
NotificationElement.config = config;
|
|
64
|
+
NotificationElement.destroy = destroy;
|
|
65
|
+
NotificationElement.remove = remove;
|
|
66
66
|
['success', 'warning', 'error', 'info'].forEach((severity) => {
|
|
67
|
-
|
|
67
|
+
NotificationElement[severity] = (props) => NotificationElement.add({
|
|
68
68
|
...props,
|
|
69
69
|
severity,
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
-
var
|
|
72
|
+
var NotificationElement$1 = NotificationElement;
|
|
73
73
|
|
|
74
|
-
export {
|
|
74
|
+
export { NotificationElement$1 as default };
|
|
@@ -10,19 +10,21 @@ import NotifierManager from './NotifierManager.js';
|
|
|
10
10
|
*/
|
|
11
11
|
function createNotifier(props) {
|
|
12
12
|
const { config: configProp, render: renderNotifier, setRoot, duration, maxCount, ...restNotifierProps } = props;
|
|
13
|
-
const root = document.createElement('div');
|
|
13
|
+
const root = typeof document === 'undefined' ? null : document.createElement('div');
|
|
14
14
|
const controllerRef = createRef();
|
|
15
15
|
let currentConfig = {
|
|
16
16
|
duration,
|
|
17
17
|
maxCount,
|
|
18
18
|
...configProp,
|
|
19
19
|
};
|
|
20
|
-
if (setRoot) {
|
|
20
|
+
if (setRoot && root) {
|
|
21
21
|
setRoot(root);
|
|
22
22
|
}
|
|
23
23
|
return {
|
|
24
24
|
add(notifier) {
|
|
25
25
|
var _a, _b;
|
|
26
|
+
if (root === null)
|
|
27
|
+
return 'NOT_SET';
|
|
26
28
|
document.body.appendChild(root);
|
|
27
29
|
const key = (_a = notifier.key) !== null && _a !== void 0 ? _a : Date.now();
|
|
28
30
|
const resolvedNotifier = {
|
|
@@ -47,6 +49,8 @@ function createNotifier(props) {
|
|
|
47
49
|
}
|
|
48
50
|
},
|
|
49
51
|
destroy() {
|
|
52
|
+
if (root === null)
|
|
53
|
+
return;
|
|
50
54
|
unmountComponentAtNode(root);
|
|
51
55
|
if (root.parentNode) {
|
|
52
56
|
root.parentNode.removeChild(root);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mezzanine-ui/react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "React components for mezzanine-ui",
|
|
5
5
|
"author": "Mezzanine",
|
|
6
6
|
"repository": {
|
|
@@ -31,12 +31,13 @@
|
|
|
31
31
|
"react-dom": "^17.0.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mezzanine-ui/core": "^0.10.
|
|
34
|
+
"@mezzanine-ui/core": "^0.10.4",
|
|
35
35
|
"@mezzanine-ui/icons": "^0.10.2",
|
|
36
36
|
"@mezzanine-ui/system": "^0.7.0",
|
|
37
37
|
"@popperjs/core": "^2.9.2",
|
|
38
38
|
"@types/react-transition-group": "4.4.1",
|
|
39
39
|
"clsx": "^1.1.1",
|
|
40
|
+
"lodash": "^4.17.21",
|
|
40
41
|
"react-popper": "^2.2.5",
|
|
41
42
|
"react-transition-group": "4.4.1",
|
|
42
43
|
"tslib": "^2.1.0"
|
|
@@ -47,9 +48,9 @@
|
|
|
47
48
|
"@testing-library/react-hooks": "^5.1.0",
|
|
48
49
|
"@types/lodash": "^4.14.168",
|
|
49
50
|
"@types/moment": "^2.13.0",
|
|
50
|
-
"@types/react": "
|
|
51
|
-
"@types/react-dom": "
|
|
52
|
-
"@types/react-test-renderer": "
|
|
51
|
+
"@types/react": "17.0.43",
|
|
52
|
+
"@types/react-dom": "17.0.14",
|
|
53
|
+
"@types/react-test-renderer": "17.0.1",
|
|
53
54
|
"chromatic": "^5.10.1",
|
|
54
55
|
"dayjs": "^1.10.7",
|
|
55
56
|
"lodash": "^4.17.21",
|