@mantine/notifications 4.0.9 → 4.1.2
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/cjs/NotificationContainer/NotificationContainer.js +47 -19
- package/cjs/NotificationContainer/NotificationContainer.js.map +1 -1
- package/cjs/NotificationContainer/get-auto-close/get-auto-close.js +4 -4
- package/cjs/NotificationContainer/get-auto-close/get-auto-close.js.map +1 -1
- package/cjs/NotificationsProvider/NotificationsProvider.js +21 -15
- package/cjs/NotificationsProvider/NotificationsProvider.js.map +1 -1
- package/cjs/events.js +60 -0
- package/cjs/events.js.map +1 -0
- package/cjs/index.js +6 -0
- package/cjs/index.js.map +1 -1
- package/cjs/use-notifications/use-notifications.js +1 -1
- package/cjs/use-notifications/use-notifications.js.map +1 -1
- package/esm/NotificationContainer/NotificationContainer.js +47 -19
- package/esm/NotificationContainer/NotificationContainer.js.map +1 -1
- package/esm/NotificationContainer/get-auto-close/get-auto-close.js +4 -4
- package/esm/NotificationContainer/get-auto-close/get-auto-close.js.map +1 -1
- package/esm/NotificationsProvider/NotificationsProvider.js +21 -15
- package/esm/NotificationsProvider/NotificationsProvider.js.map +1 -1
- package/esm/events.js +49 -0
- package/esm/events.js.map +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/use-notifications/use-notifications.js +1 -1
- package/esm/use-notifications/use-notifications.js.map +1 -1
- package/lib/NotificationContainer/NotificationContainer.d.ts +1 -1
- package/lib/NotificationContainer/NotificationContainer.d.ts.map +1 -1
- package/lib/NotificationContainer/get-auto-close/get-auto-close.d.ts +1 -2
- package/lib/NotificationContainer/get-auto-close/get-auto-close.d.ts.map +1 -1
- package/lib/NotificationsProvider/NotificationsProvider.d.ts.map +1 -1
- package/lib/events.d.ts +20 -0
- package/lib/events.d.ts.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/types.d.ts +2 -10
- package/lib/types.d.ts.map +1 -1
- package/lib/use-notifications/use-notifications.d.ts.map +1 -1
- package/package.json +3 -4
|
@@ -10,15 +10,51 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __defProps = Object.defineProperties;
|
|
15
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
16
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
19
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
20
|
+
var __spreadValues = (a, b) => {
|
|
21
|
+
for (var prop in b || (b = {}))
|
|
22
|
+
if (__hasOwnProp.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
if (__getOwnPropSymbols)
|
|
25
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
26
|
+
if (__propIsEnum.call(b, prop))
|
|
27
|
+
__defNormalProp(a, prop, b[prop]);
|
|
28
|
+
}
|
|
29
|
+
return a;
|
|
30
|
+
};
|
|
31
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
32
|
+
var __objRest = (source, exclude) => {
|
|
33
|
+
var target = {};
|
|
34
|
+
for (var prop in source)
|
|
35
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
36
|
+
target[prop] = source[prop];
|
|
37
|
+
if (source != null && __getOwnPropSymbols)
|
|
38
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
39
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
40
|
+
target[prop] = source[prop];
|
|
41
|
+
}
|
|
42
|
+
return target;
|
|
43
|
+
};
|
|
44
|
+
function NotificationContainer(_a) {
|
|
45
|
+
var _b = _a, {
|
|
46
|
+
notification,
|
|
47
|
+
autoClose,
|
|
48
|
+
onHide,
|
|
49
|
+
innerRef
|
|
50
|
+
} = _b, others = __objRest(_b, [
|
|
51
|
+
"notification",
|
|
52
|
+
"autoClose",
|
|
53
|
+
"onHide",
|
|
54
|
+
"innerRef"
|
|
55
|
+
]);
|
|
56
|
+
const _a2 = notification, { autoClose: notificationAutoClose } = _a2, notificationProps = __objRest(_a2, ["autoClose"]);
|
|
57
|
+
const autoCloseTimeout = getAutoClose['default'](autoClose, notificationAutoClose);
|
|
22
58
|
const hideTimeout = React.useRef();
|
|
23
59
|
const handleHide = () => {
|
|
24
60
|
onHide(notification.id);
|
|
@@ -41,20 +77,12 @@ function NotificationContainer({
|
|
|
41
77
|
handleDelayedHide();
|
|
42
78
|
return cancelDelayedHide;
|
|
43
79
|
}, [autoClose, notification.autoClose]);
|
|
44
|
-
return /* @__PURE__ */ React__default.createElement(core.Notification, {
|
|
45
|
-
sx,
|
|
46
|
-
className,
|
|
47
|
-
title: notification.title,
|
|
80
|
+
return /* @__PURE__ */ React__default.createElement(core.Notification, __spreadProps(__spreadValues(__spreadValues({}, notificationProps), others), {
|
|
48
81
|
onClose: handleHide,
|
|
49
|
-
color: notification.color,
|
|
50
|
-
radius: notification.radius,
|
|
51
|
-
icon: notification.icon,
|
|
52
|
-
loading: notification.loading,
|
|
53
|
-
disallowClose: notification.disallowClose,
|
|
54
82
|
onMouseEnter: cancelDelayedHide,
|
|
55
83
|
onMouseLeave: handleDelayedHide,
|
|
56
84
|
ref: innerRef
|
|
57
|
-
}, notification.message);
|
|
85
|
+
}), notification.message);
|
|
58
86
|
}
|
|
59
87
|
NotificationContainer.displayName = "@mantine/notifications/NotificationContainer";
|
|
60
88
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationContainer.js","sources":["../../src/NotificationContainer/NotificationContainer.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { Notification, DefaultProps } from '@mantine/core';\nimport getAutoClose from './get-auto-close/get-auto-close';\nimport { NotificationProps } from '../types';\n\nexport interface NotificationContainerProps extends DefaultProps {\n notification: NotificationProps;\n onHide(id: string): void;\n autoClose: false | number;\n innerRef: React.ForwardedRef<HTMLDivElement>;\n}\n\nexport default function NotificationContainer({\n
|
|
1
|
+
{"version":3,"file":"NotificationContainer.js","sources":["../../src/NotificationContainer/NotificationContainer.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { Notification, DefaultProps } from '@mantine/core';\nimport getAutoClose from './get-auto-close/get-auto-close';\nimport { NotificationProps } from '../types';\n\nexport interface NotificationContainerProps extends DefaultProps {\n notification: NotificationProps;\n onHide(id: string): void;\n autoClose: false | number;\n innerRef: React.ForwardedRef<HTMLDivElement>;\n}\n\nexport default function NotificationContainer({\n notification,\n autoClose,\n onHide,\n innerRef,\n ...others\n}: NotificationContainerProps) {\n const { autoClose: notificationAutoClose, ...notificationProps } = notification;\n const autoCloseTimeout = getAutoClose(autoClose, notificationAutoClose);\n const hideTimeout = useRef<number>();\n\n const handleHide = () => {\n onHide(notification.id);\n window.clearTimeout(hideTimeout.current);\n };\n\n const cancelDelayedHide = () => {\n clearTimeout(hideTimeout.current);\n };\n\n const handleDelayedHide = () => {\n if (typeof autoCloseTimeout === 'number') {\n hideTimeout.current = window.setTimeout(handleHide, autoCloseTimeout);\n }\n };\n\n useEffect(() => {\n if (typeof notification.onOpen === 'function') {\n notification.onOpen(notification);\n }\n }, []);\n\n useEffect(() => {\n handleDelayedHide();\n return cancelDelayedHide;\n }, [autoClose, notification.autoClose]);\n\n return (\n <Notification\n {...notificationProps}\n {...others}\n onClose={handleHide}\n onMouseEnter={cancelDelayedHide}\n onMouseLeave={handleDelayedHide}\n ref={innerRef}\n >\n {notification.message}\n </Notification>\n );\n}\n\nNotificationContainer.displayName = '@mantine/notifications/NotificationContainer';\n"],"names":["getAutoClose","useRef","useEffect","React","Notification"],"mappings":";;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ,eAAe,CAAC,CAAC,EAA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AAC,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC,EAAE;AACxI,IAAI,OAAO,EAAE,UAAU;AACvB,IAAI,YAAY,EAAE,iBAAiB;AACnC,IAAI,YAAY,EAAE,iBAAiB;AACnC,IAAI,GAAG,EAAE,QAAQ;AACjB,GAAG,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC;AACD,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;;;"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function getAutoClose(autoClose,
|
|
6
|
-
if (typeof
|
|
7
|
-
return
|
|
5
|
+
function getAutoClose(autoClose, notificationAutoClose) {
|
|
6
|
+
if (typeof notificationAutoClose === "number") {
|
|
7
|
+
return notificationAutoClose;
|
|
8
8
|
}
|
|
9
|
-
if (
|
|
9
|
+
if (notificationAutoClose === false || autoClose === false) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
return autoClose;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-auto-close.js","sources":["../../../src/NotificationContainer/get-auto-close/get-auto-close.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"get-auto-close.js","sources":["../../../src/NotificationContainer/get-auto-close/get-auto-close.ts"],"sourcesContent":["export default function getAutoClose(\n autoClose: boolean | number,\n notificationAutoClose: boolean | number\n) {\n if (typeof notificationAutoClose === 'number') {\n return notificationAutoClose;\n }\n\n if (notificationAutoClose === false || autoClose === false) {\n return false;\n }\n\n return autoClose;\n}\n"],"names":[],"mappings":";;;;AAAe,SAAS,YAAY,CAAC,SAAS,EAAE,qBAAqB,EAAE;AACvE,EAAE,IAAI,OAAO,qBAAqB,KAAK,QAAQ,EAAE;AACjD,IAAI,OAAO,qBAAqB,CAAC;AACjC,GAAG;AACH,EAAE,IAAI,qBAAqB,KAAK,KAAK,IAAI,SAAS,KAAK,KAAK,EAAE;AAC9D,IAAI,OAAO,KAAK,CAAC;AACjB,GAAG;AACH,EAAE,OAAO,SAAS,CAAC;AACnB;;;;"}
|
|
@@ -7,6 +7,7 @@ var reactTransitionGroup = require('react-transition-group');
|
|
|
7
7
|
var core = require('@mantine/core');
|
|
8
8
|
var hooks = require('@mantine/hooks');
|
|
9
9
|
var Notifications_context = require('../Notifications.context.js');
|
|
10
|
+
var events = require('../events.js');
|
|
10
11
|
var getPositionStyles = require('./get-position-styles/get-position-styles.js');
|
|
11
12
|
var getNotificationStateStyles = require('./get-notification-state-styles/get-notification-state-styles.js');
|
|
12
13
|
var NotificationContainer = require('../NotificationContainer/NotificationContainer.js');
|
|
@@ -93,12 +94,22 @@ function NotificationsProvider(_a) {
|
|
|
93
94
|
const duration = reduceMotion ? 1 : transitionDuration;
|
|
94
95
|
const { classes, cx, theme } = NotificationsProvider_styles['default']();
|
|
95
96
|
const positioning = (POSITIONS.includes(position) ? position : "bottom-right").split("-");
|
|
97
|
+
const ctx = {
|
|
98
|
+
notifications,
|
|
99
|
+
queue,
|
|
100
|
+
showNotification,
|
|
101
|
+
hideNotification,
|
|
102
|
+
updateNotification,
|
|
103
|
+
clean,
|
|
104
|
+
cleanQueue
|
|
105
|
+
};
|
|
96
106
|
hooks.useDidUpdate(() => {
|
|
97
107
|
if (notifications.length > previousLength.current) {
|
|
98
108
|
setTimeout(() => forceUpdate(), 0);
|
|
99
109
|
}
|
|
100
110
|
previousLength.current = notifications.length;
|
|
101
111
|
}, [notifications]);
|
|
112
|
+
events.useNotificationsEvents(ctx);
|
|
102
113
|
const items = notifications.map((notification) => /* @__PURE__ */ React__default.createElement(reactTransitionGroup.Transition, {
|
|
103
114
|
key: notification.id,
|
|
104
115
|
timeout: duration,
|
|
@@ -112,23 +123,18 @@ function NotificationsProvider(_a) {
|
|
|
112
123
|
onHide: hideNotification,
|
|
113
124
|
className: classes.notification,
|
|
114
125
|
autoClose,
|
|
115
|
-
sx:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
sx: [
|
|
127
|
+
__spreadValues({}, getNotificationStateStyles['default']({
|
|
128
|
+
state,
|
|
129
|
+
positioning,
|
|
130
|
+
transitionDuration: duration,
|
|
131
|
+
maxHeight: notificationMaxHeight
|
|
132
|
+
})),
|
|
133
|
+
...Array.isArray(notification.sx) ? notification.sx : [notification.sx]
|
|
134
|
+
]
|
|
121
135
|
})));
|
|
122
136
|
return /* @__PURE__ */ React__default.createElement(Notifications_context.NotificationsContext.Provider, {
|
|
123
|
-
value:
|
|
124
|
-
notifications,
|
|
125
|
-
queue,
|
|
126
|
-
showNotification,
|
|
127
|
-
hideNotification,
|
|
128
|
-
updateNotification,
|
|
129
|
-
clean,
|
|
130
|
-
cleanQueue
|
|
131
|
-
}
|
|
137
|
+
value: ctx
|
|
132
138
|
}, /* @__PURE__ */ React__default.createElement(core.Portal, {
|
|
133
139
|
zIndex
|
|
134
140
|
}, /* @__PURE__ */ React__default.createElement(core.Box, __spreadValues({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/NotificationsProvider/NotificationsProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Transition, TransitionGroup } from 'react-transition-group';\nimport { DefaultProps, Portal, MantineStyleSystemSize, getDefaultZIndex, Box } from '@mantine/core';\nimport { useReducedMotion, useForceUpdate, useDidUpdate } from '@mantine/hooks';\nimport { NotificationsContext } from '../Notifications.context';\nimport { NotificationsProviderPositioning } from '../types';\nimport getPositionStyles from './get-position-styles/get-position-styles';\nimport getNotificationStateStyles from './get-notification-state-styles/get-notification-state-styles';\nimport NotificationContainer from '../NotificationContainer/NotificationContainer';\nimport useStyles from './NotificationsProvider.styles';\nimport useNotificationsState from './use-notifications-state/use-notifications-state';\n\nconst POSITIONS = [\n 'top-left',\n 'top-right',\n 'top-center',\n 'bottom-left',\n 'bottom-right',\n 'bottom-center',\n] as const;\n\nexport interface NotificationProviderProps\n extends Omit<DefaultProps, MantineStyleSystemSize>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Notifications position */\n position?:\n | 'top-left'\n | 'top-right'\n | 'top-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom-center';\n\n /** Auto close timeout for all notifications, false to disable auto close, can be overwritten for individual notifications by showNotification function */\n autoClose?: number | false;\n\n /** Notification transitions duration, 0 to turn transitions off */\n transitionDuration?: number;\n\n /** Notification width in px, cannot exceed 100% */\n containerWidth?: number;\n\n /** Notification max-height in px, used for transitions */\n notificationMaxHeight?: number;\n\n /** Maximum amount of notifications displayed at a time, other new notifications will be added to queue */\n limit?: number;\n\n /** Notifications container z-index */\n zIndex?: number;\n}\n\nexport function NotificationsProvider({\n className,\n position = 'bottom-right',\n autoClose = 4000,\n transitionDuration = 250,\n containerWidth = 440,\n notificationMaxHeight = 200,\n limit = 5,\n zIndex = getDefaultZIndex('overlay'),\n style,\n children,\n ...others\n}: NotificationProviderProps) {\n const forceUpdate = useForceUpdate();\n const refs = useRef<Record<string, HTMLDivElement>>({});\n const previousLength = useRef<number>(0);\n const {\n notifications,\n queue,\n showNotification,\n updateNotification,\n hideNotification,\n clean,\n cleanQueue,\n } = useNotificationsState({ limit });\n const reduceMotion = useReducedMotion();\n const duration = reduceMotion ? 1 : transitionDuration;\n const { classes, cx, theme } = useStyles();\n const positioning = (POSITIONS.includes(position) ? position : 'bottom-right').split(\n '-'\n ) as NotificationsProviderPositioning;\n\n useDidUpdate(() => {\n if (notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = notifications.length;\n }, [notifications]);\n\n const items = notifications.map((notification) => (\n <Transition\n key={notification.id}\n timeout={duration}\n onEnter={() => refs.current[notification.id].offsetHeight}\n nodeRef={{ current: refs.current[notification.id] }}\n >\n {(state) => (\n <NotificationContainer\n innerRef={(node) => {\n refs.current[notification.id] = node;\n }}\n notification={notification}\n onHide={hideNotification}\n className={classes.notification}\n autoClose={autoClose}\n sx={{\n ...getNotificationStateStyles({\n state,\n positioning,\n transitionDuration: duration,\n maxHeight: notificationMaxHeight,\n }),\n }}\n />\n )}\n </Transition>\n ));\n\n return (\n <NotificationsContext.Provider\n value={{\n notifications,\n queue,\n showNotification,\n hideNotification,\n updateNotification,\n clean,\n cleanQueue,\n }}\n >\n <Portal zIndex={zIndex}>\n <Box\n className={cx(classes.notifications, className)}\n style={style}\n sx={{\n maxWidth: containerWidth,\n ...getPositionStyles(positioning, containerWidth, theme.spacing.md),\n }}\n {...others}\n >\n <TransitionGroup>{items}</TransitionGroup>\n </Box>\n </Portal>\n\n {children}\n </NotificationsContext.Provider>\n );\n}\n\nNotificationsProvider.displayName = '@mantine/notifications/NotificationsProvider';\n"],"names":["getDefaultZIndex","useForceUpdate","useRef","useNotificationsState","useReducedMotion","useStyles","useDidUpdate","React","Transition","NotificationContainer","getNotificationStateStyles","NotificationsContext","Portal","Box","getPositionStyles","TransitionGroup"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE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O,CAAC,YAAY;AACnC,IAAI,SAAS;AACb,IAAI,EAAE,EAAE,cAAc,CAAC,EAAE,EAAEC,qCAA0B,CAAC;AACtD,MAAM,KAAK;AACX,MAAM,WAAW;AACjB,MAAM,kBAAkB,EAAE,QAAQ;AAClC,MAAM,SAAS,EAAE,qBAAqB;AACtC,KAAK,CAAC,CAAC;AACP,GAAG,CAAC,CAAC,CAAC,CAAC;AACP,EAAE,uBAAuBH,cAAK,CAAC,aAAa,CAACI,0CAAoB,CAAC,QAAQ,EAAE;AAC5E,IAAI,KAAK,EAAE;AACX,MAAM,aAAa;AACnB,MAAM,KAAK;AACX,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,KAAK;AACX,MAAM,UAAU;AAChB,KAAK;AACL,GAAG,kBAAkBJ,cAAK,CAAC,aAAa,CAACK,WAAM,EAAE;AACjD,IAAI,MAAM;AACV,GAAG,kBAAkBL,cAAK,CAAC,aAAa,CAACM,QAAG,EAAE,cAAc,CAAC;AAC7D,IAAI,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC;AACnD,IAAI,KAAK;AACT,IAAI,EAAE,EAAE,cAAc,CAAC;AACvB,MAAM,QAAQ,EAAE,cAAc;AAC9B,KAAK,EAAEC,4BAAiB,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACxE,GAAG,EAAE,MAAM,CAAC,kBAAkBP,cAAK,CAAC,aAAa,CAACQ,oCAAe,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7F,CAAC;AACD,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;;;"}
|
|
1
|
+
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/NotificationsProvider/NotificationsProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Transition, TransitionGroup } from 'react-transition-group';\nimport { DefaultProps, Portal, MantineStyleSystemSize, getDefaultZIndex, Box } from '@mantine/core';\nimport { useReducedMotion, useForceUpdate, useDidUpdate } from '@mantine/hooks';\nimport { NotificationsContext } from '../Notifications.context';\nimport { NotificationsProviderPositioning } from '../types';\nimport { useNotificationsEvents } from '../events';\nimport getPositionStyles from './get-position-styles/get-position-styles';\nimport getNotificationStateStyles from './get-notification-state-styles/get-notification-state-styles';\nimport NotificationContainer from '../NotificationContainer/NotificationContainer';\nimport useStyles from './NotificationsProvider.styles';\nimport useNotificationsState from './use-notifications-state/use-notifications-state';\n\nconst POSITIONS = [\n 'top-left',\n 'top-right',\n 'top-center',\n 'bottom-left',\n 'bottom-right',\n 'bottom-center',\n] as const;\n\nexport interface NotificationProviderProps\n extends Omit<DefaultProps, MantineStyleSystemSize>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Notifications position */\n position?:\n | 'top-left'\n | 'top-right'\n | 'top-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom-center';\n\n /** Auto close timeout for all notifications, false to disable auto close, can be overwritten for individual notifications by showNotification function */\n autoClose?: number | false;\n\n /** Notification transitions duration, 0 to turn transitions off */\n transitionDuration?: number;\n\n /** Notification width in px, cannot exceed 100% */\n containerWidth?: number;\n\n /** Notification max-height in px, used for transitions */\n notificationMaxHeight?: number;\n\n /** Maximum amount of notifications displayed at a time, other new notifications will be added to queue */\n limit?: number;\n\n /** Notifications container z-index */\n zIndex?: number;\n}\n\nexport function NotificationsProvider({\n className,\n position = 'bottom-right',\n autoClose = 4000,\n transitionDuration = 250,\n containerWidth = 440,\n notificationMaxHeight = 200,\n limit = 5,\n zIndex = getDefaultZIndex('overlay'),\n style,\n children,\n ...others\n}: NotificationProviderProps) {\n const forceUpdate = useForceUpdate();\n const refs = useRef<Record<string, HTMLDivElement>>({});\n const previousLength = useRef<number>(0);\n const {\n notifications,\n queue,\n showNotification,\n updateNotification,\n hideNotification,\n clean,\n cleanQueue,\n } = useNotificationsState({ limit });\n const reduceMotion = useReducedMotion();\n const duration = reduceMotion ? 1 : transitionDuration;\n const { classes, cx, theme } = useStyles();\n const positioning = (POSITIONS.includes(position) ? position : 'bottom-right').split(\n '-'\n ) as NotificationsProviderPositioning;\n\n const ctx = {\n notifications,\n queue,\n showNotification,\n hideNotification,\n updateNotification,\n clean,\n cleanQueue,\n };\n\n useDidUpdate(() => {\n if (notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = notifications.length;\n }, [notifications]);\n\n useNotificationsEvents(ctx);\n\n const items = notifications.map((notification) => (\n <Transition\n key={notification.id}\n timeout={duration}\n onEnter={() => refs.current[notification.id].offsetHeight}\n nodeRef={{ current: refs.current[notification.id] }}\n >\n {(state) => (\n <NotificationContainer\n innerRef={(node) => {\n refs.current[notification.id] = node;\n }}\n notification={notification}\n onHide={hideNotification}\n className={classes.notification}\n autoClose={autoClose}\n sx={[\n {\n ...getNotificationStateStyles({\n state,\n positioning,\n transitionDuration: duration,\n maxHeight: notificationMaxHeight,\n }),\n },\n ...(Array.isArray(notification.sx) ? notification.sx : [notification.sx]),\n ]}\n />\n )}\n </Transition>\n ));\n\n return (\n <NotificationsContext.Provider value={ctx}>\n <Portal zIndex={zIndex}>\n <Box\n className={cx(classes.notifications, className)}\n style={style}\n sx={{\n maxWidth: containerWidth,\n ...getPositionStyles(positioning, containerWidth, theme.spacing.md),\n }}\n {...others}\n >\n <TransitionGroup>{items}</TransitionGroup>\n </Box>\n </Portal>\n\n {children}\n </NotificationsContext.Provider>\n );\n}\n\nNotificationsProvider.displayName = '@mantine/notifications/NotificationsProvider';\n"],"names":["getDefaultZIndex","useForceUpdate","useRef","useNotificationsState","useReducedMotion","useStyles","useDidUpdate","useNotificationsEvents","React","Transition","NotificationContainer","getNotificationStateStyles","NotificationsContext","Portal","Box","getPositionStyles","TransitionGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,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EAAE,GAAG;AACd,GAAG,kBAAkBJ,cAAK,CAAC,aAAa,CAACK,WAAM,EAAE;AACjD,IAAI,MAAM;AACV,GAAG,kBAAkBL,cAAK,CAAC,aAAa,CAACM,QAAG,EAAE,cAAc,CAAC;AAC7D,IAAI,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC;AACnD,IAAI,KAAK;AACT,IAAI,EAAE,EAAE,cAAc,CAAC;AACvB,MAAM,QAAQ,EAAE,cAAc;AAC9B,KAAK,EAAEC,4BAAiB,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACxE,GAAG,EAAE,MAAM,CAAC,kBAAkBP,cAAK,CAAC,aAAa,CAACQ,oCAAe,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7F,CAAC;AACD,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;;;"}
|
package/cjs/events.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const NOTIFICATIONS_EVENTS = {
|
|
8
|
+
show: "mantine:show-notification",
|
|
9
|
+
hide: "mantine:hide-notification",
|
|
10
|
+
update: "mantine:update-notification",
|
|
11
|
+
clean: "mantine:clean-notifications",
|
|
12
|
+
cleanQueue: "mantine:clean-notifications-queue"
|
|
13
|
+
};
|
|
14
|
+
function createEvent(type, detail) {
|
|
15
|
+
return new CustomEvent(type, { detail });
|
|
16
|
+
}
|
|
17
|
+
function showNotification(notification) {
|
|
18
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.show, notification));
|
|
19
|
+
}
|
|
20
|
+
function updateNotification(notification) {
|
|
21
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.update, notification));
|
|
22
|
+
}
|
|
23
|
+
function hideNotification(id) {
|
|
24
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.hide, id));
|
|
25
|
+
}
|
|
26
|
+
function cleanNotifications() {
|
|
27
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.clean));
|
|
28
|
+
}
|
|
29
|
+
function cleanNotificationsQueue() {
|
|
30
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.cleanQueue));
|
|
31
|
+
}
|
|
32
|
+
function useNotificationsEvents(ctx) {
|
|
33
|
+
const events = {
|
|
34
|
+
show: (event) => ctx.showNotification(event.detail),
|
|
35
|
+
hide: (event) => ctx.hideNotification(event.detail),
|
|
36
|
+
update: (event) => ctx.updateNotification(event.detail.id, event.detail),
|
|
37
|
+
clean: ctx.clean,
|
|
38
|
+
cleanQueue: ctx.cleanQueue
|
|
39
|
+
};
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
Object.keys(events).forEach((event) => {
|
|
42
|
+
window.addEventListener(NOTIFICATIONS_EVENTS[event], events[event]);
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
Object.keys(events).forEach((event) => {
|
|
46
|
+
window.removeEventListener(NOTIFICATIONS_EVENTS[event], events[event]);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.NOTIFICATIONS_EVENTS = NOTIFICATIONS_EVENTS;
|
|
53
|
+
exports.cleanNotifications = cleanNotifications;
|
|
54
|
+
exports.cleanNotificationsQueue = cleanNotificationsQueue;
|
|
55
|
+
exports.createEvent = createEvent;
|
|
56
|
+
exports.hideNotification = hideNotification;
|
|
57
|
+
exports.showNotification = showNotification;
|
|
58
|
+
exports.updateNotification = updateNotification;
|
|
59
|
+
exports.useNotificationsEvents = useNotificationsEvents;
|
|
60
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { NotificationProps, NotificationsContextProps } from './types';\n\ntype ValueOf<T> = T[keyof T];\n\nexport const NOTIFICATIONS_EVENTS = {\n show: 'mantine:show-notification',\n hide: 'mantine:hide-notification',\n update: 'mantine:update-notification',\n clean: 'mantine:clean-notifications',\n cleanQueue: 'mantine:clean-notifications-queue',\n} as const;\n\nexport function createEvent(type: ValueOf<typeof NOTIFICATIONS_EVENTS>, detail?: any) {\n return new CustomEvent(type, { detail });\n}\n\nexport function showNotification(notification: NotificationProps) {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.show, notification));\n}\n\nexport function updateNotification(notification: NotificationProps & { id: string }) {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.update, notification));\n}\n\nexport function hideNotification(id: string) {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.hide, id));\n}\n\nexport function cleanNotifications() {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.clean));\n}\n\nexport function cleanNotificationsQueue() {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.cleanQueue));\n}\n\nexport function useNotificationsEvents(ctx: NotificationsContextProps) {\n const events = {\n show: (event: any) => ctx.showNotification(event.detail),\n hide: (event: any) => ctx.hideNotification(event.detail),\n update: (event: any) => ctx.updateNotification(event.detail.id, event.detail),\n clean: ctx.clean,\n cleanQueue: ctx.cleanQueue,\n };\n\n useEffect(() => {\n Object.keys(events).forEach((event) => {\n window.addEventListener(NOTIFICATIONS_EVENTS[event], events[event]);\n });\n\n return () => {\n Object.keys(events).forEach((event) => {\n window.removeEventListener(NOTIFICATIONS_EVENTS[event], events[event]);\n });\n };\n }, []);\n}\n"],"names":["useEffect"],"mappings":";;;;;;AACY,MAAC,oBAAoB,GAAG;AACpC,EAAE,IAAI,EAAE,2BAA2B;AACnC,EAAE,IAAI,EAAE,2BAA2B;AACnC,EAAE,MAAM,EAAE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BAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC;AAC5E,IAAI,KAAK,EAAE,GAAG,CAAC,KAAK;AACpB,IAAI,UAAU,EAAE,GAAG,CAAC,UAAU;AAC9B,GAAG,CAAC;AACJ,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK;AAC3C,MAAM,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1E,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,MAAM;AACjB,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK;AAC7C,QAAQ,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/E,OAAO,CAAC,CAAC;AACT,KAAK,CAAC;AACN,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;;;;;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -4,9 +4,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var useNotifications = require('./use-notifications/use-notifications.js');
|
|
6
6
|
var NotificationsProvider = require('./NotificationsProvider/NotificationsProvider.js');
|
|
7
|
+
var events = require('./events.js');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
exports.useNotifications = useNotifications.useNotifications;
|
|
11
12
|
exports.NotificationsProvider = NotificationsProvider.NotificationsProvider;
|
|
13
|
+
exports.cleanNotifications = events.cleanNotifications;
|
|
14
|
+
exports.cleanNotificationsQueue = events.cleanNotificationsQueue;
|
|
15
|
+
exports.hideNotification = events.hideNotification;
|
|
16
|
+
exports.showNotification = events.showNotification;
|
|
17
|
+
exports.updateNotification = events.updateNotification;
|
|
12
18
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -8,7 +8,7 @@ var Notifications_context = require('../Notifications.context.js');
|
|
|
8
8
|
function useNotifications() {
|
|
9
9
|
const context = React.useContext(Notifications_context.NotificationsContext);
|
|
10
10
|
if (!context) {
|
|
11
|
-
throw new Error("@mantine/notifications:
|
|
11
|
+
throw new Error("@mantine/notifications: use-notifications hook was called outside of NotificationsProvider context");
|
|
12
12
|
}
|
|
13
13
|
return context;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-notifications.js","sources":["../../src/use-notifications/use-notifications.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { NotificationsContext } from '../Notifications.context';\n\nexport function useNotifications() {\n const context = useContext(NotificationsContext);\n\n if (!context) {\n throw new Error('@mantine/notifications:
|
|
1
|
+
{"version":3,"file":"use-notifications.js","sources":["../../src/use-notifications/use-notifications.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { NotificationsContext } from '../Notifications.context';\n\nexport function useNotifications() {\n const context = useContext(NotificationsContext);\n\n if (!context) {\n throw new Error(\n '@mantine/notifications: use-notifications hook was called outside of NotificationsProvider context'\n );\n }\n\n return context;\n}\n"],"names":["useContext","NotificationsContext"],"mappings":";;;;;;;AAEO,SAAS,gBAAgB,GAAG;AACnC,EAAE,MAAM,OAAO,GAAGA,gBAAU,CAACC,0CAAoB,CAAC,CAAC;AACnD,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,MAAM,IAAI,KAAK,CAAC,oGAAoG,CAAC,CAAC;AAC1H,GAAG;AACH,EAAE,OAAO,OAAO,CAAC;AACjB;;;;"}
|
|
@@ -2,15 +2,51 @@ import React, { useRef, useEffect } from 'react';
|
|
|
2
2
|
import { Notification } from '@mantine/core';
|
|
3
3
|
import getAutoClose from './get-auto-close/get-auto-close.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
function NotificationContainer(_a) {
|
|
37
|
+
var _b = _a, {
|
|
38
|
+
notification,
|
|
39
|
+
autoClose,
|
|
40
|
+
onHide,
|
|
41
|
+
innerRef
|
|
42
|
+
} = _b, others = __objRest(_b, [
|
|
43
|
+
"notification",
|
|
44
|
+
"autoClose",
|
|
45
|
+
"onHide",
|
|
46
|
+
"innerRef"
|
|
47
|
+
]);
|
|
48
|
+
const _a2 = notification, { autoClose: notificationAutoClose } = _a2, notificationProps = __objRest(_a2, ["autoClose"]);
|
|
49
|
+
const autoCloseTimeout = getAutoClose(autoClose, notificationAutoClose);
|
|
14
50
|
const hideTimeout = useRef();
|
|
15
51
|
const handleHide = () => {
|
|
16
52
|
onHide(notification.id);
|
|
@@ -33,20 +69,12 @@ function NotificationContainer({
|
|
|
33
69
|
handleDelayedHide();
|
|
34
70
|
return cancelDelayedHide;
|
|
35
71
|
}, [autoClose, notification.autoClose]);
|
|
36
|
-
return /* @__PURE__ */ React.createElement(Notification, {
|
|
37
|
-
sx,
|
|
38
|
-
className,
|
|
39
|
-
title: notification.title,
|
|
72
|
+
return /* @__PURE__ */ React.createElement(Notification, __spreadProps(__spreadValues(__spreadValues({}, notificationProps), others), {
|
|
40
73
|
onClose: handleHide,
|
|
41
|
-
color: notification.color,
|
|
42
|
-
radius: notification.radius,
|
|
43
|
-
icon: notification.icon,
|
|
44
|
-
loading: notification.loading,
|
|
45
|
-
disallowClose: notification.disallowClose,
|
|
46
74
|
onMouseEnter: cancelDelayedHide,
|
|
47
75
|
onMouseLeave: handleDelayedHide,
|
|
48
76
|
ref: innerRef
|
|
49
|
-
}, notification.message);
|
|
77
|
+
}), notification.message);
|
|
50
78
|
}
|
|
51
79
|
NotificationContainer.displayName = "@mantine/notifications/NotificationContainer";
|
|
52
80
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationContainer.js","sources":["../../src/NotificationContainer/NotificationContainer.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { Notification, DefaultProps } from '@mantine/core';\nimport getAutoClose from './get-auto-close/get-auto-close';\nimport { NotificationProps } from '../types';\n\nexport interface NotificationContainerProps extends DefaultProps {\n notification: NotificationProps;\n onHide(id: string): void;\n autoClose: false | number;\n innerRef: React.ForwardedRef<HTMLDivElement>;\n}\n\nexport default function NotificationContainer({\n
|
|
1
|
+
{"version":3,"file":"NotificationContainer.js","sources":["../../src/NotificationContainer/NotificationContainer.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { Notification, DefaultProps } from '@mantine/core';\nimport getAutoClose from './get-auto-close/get-auto-close';\nimport { NotificationProps } from '../types';\n\nexport interface NotificationContainerProps extends DefaultProps {\n notification: NotificationProps;\n onHide(id: string): void;\n autoClose: false | number;\n innerRef: React.ForwardedRef<HTMLDivElement>;\n}\n\nexport default function NotificationContainer({\n notification,\n autoClose,\n onHide,\n innerRef,\n ...others\n}: NotificationContainerProps) {\n const { autoClose: notificationAutoClose, ...notificationProps } = notification;\n const autoCloseTimeout = getAutoClose(autoClose, notificationAutoClose);\n const hideTimeout = useRef<number>();\n\n const handleHide = () => {\n onHide(notification.id);\n window.clearTimeout(hideTimeout.current);\n };\n\n const cancelDelayedHide = () => {\n clearTimeout(hideTimeout.current);\n };\n\n const handleDelayedHide = () => {\n if (typeof autoCloseTimeout === 'number') {\n hideTimeout.current = window.setTimeout(handleHide, autoCloseTimeout);\n }\n };\n\n useEffect(() => {\n if (typeof notification.onOpen === 'function') {\n notification.onOpen(notification);\n }\n }, []);\n\n useEffect(() => {\n handleDelayedHide();\n return cancelDelayedHide;\n }, [autoClose, notification.autoClose]);\n\n return (\n <Notification\n {...notificationProps}\n {...others}\n onClose={handleHide}\n onMouseEnter={cancelDelayedHide}\n onMouseLeave={handleDelayedHide}\n ref={innerRef}\n >\n {notification.message}\n </Notification>\n );\n}\n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AU;AACvB,IAAI,YAAY,EAAE,iBAAiB;AACnC,IAAI,YAAY,EAAE,iBAAiB;AACnC,IAAI,GAAG,EAAE,QAAQ;AACjB,GAAG,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC;AACD,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function getAutoClose(autoClose,
|
|
2
|
-
if (typeof
|
|
3
|
-
return
|
|
1
|
+
function getAutoClose(autoClose, notificationAutoClose) {
|
|
2
|
+
if (typeof notificationAutoClose === "number") {
|
|
3
|
+
return notificationAutoClose;
|
|
4
4
|
}
|
|
5
|
-
if (
|
|
5
|
+
if (notificationAutoClose === false || autoClose === false) {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
return autoClose;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-auto-close.js","sources":["../../../src/NotificationContainer/get-auto-close/get-auto-close.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"get-auto-close.js","sources":["../../../src/NotificationContainer/get-auto-close/get-auto-close.ts"],"sourcesContent":["export default function getAutoClose(\n autoClose: boolean | number,\n notificationAutoClose: boolean | number\n) {\n if (typeof notificationAutoClose === 'number') {\n return notificationAutoClose;\n }\n\n if (notificationAutoClose === false || autoClose === false) {\n return false;\n }\n\n return autoClose;\n}\n"],"names":[],"mappings":"AAAe,SAAS,YAAY,CAAC,SAAS,EAAE,qBAAqB,EAAE;AACvE,EAAE,IAAI,OAAO,qBAAqB,KAAK,QAAQ,EAAE;AACjD,IAAI,OAAO,qBAAqB,CAAC;AACjC,GAAG;AACH,EAAE,IAAI,qBAAqB,KAAK,KAAK,IAAI,SAAS,KAAK,KAAK,EAAE;AAC9D,IAAI,OAAO,KAAK,CAAC;AACjB,GAAG;AACH,EAAE,OAAO,SAAS,CAAC;AACnB;;;;"}
|
|
@@ -3,6 +3,7 @@ import { Transition, TransitionGroup } from 'react-transition-group';
|
|
|
3
3
|
import { getDefaultZIndex, Portal, Box } from '@mantine/core';
|
|
4
4
|
import { useForceUpdate, useReducedMotion, useDidUpdate } from '@mantine/hooks';
|
|
5
5
|
import { NotificationsContext } from '../Notifications.context.js';
|
|
6
|
+
import { useNotificationsEvents } from '../events.js';
|
|
6
7
|
import getPositionStyles from './get-position-styles/get-position-styles.js';
|
|
7
8
|
import getNotificationStateStyles from './get-notification-state-styles/get-notification-state-styles.js';
|
|
8
9
|
import NotificationContainer from '../NotificationContainer/NotificationContainer.js';
|
|
@@ -85,12 +86,22 @@ function NotificationsProvider(_a) {
|
|
|
85
86
|
const duration = reduceMotion ? 1 : transitionDuration;
|
|
86
87
|
const { classes, cx, theme } = useStyles();
|
|
87
88
|
const positioning = (POSITIONS.includes(position) ? position : "bottom-right").split("-");
|
|
89
|
+
const ctx = {
|
|
90
|
+
notifications,
|
|
91
|
+
queue,
|
|
92
|
+
showNotification,
|
|
93
|
+
hideNotification,
|
|
94
|
+
updateNotification,
|
|
95
|
+
clean,
|
|
96
|
+
cleanQueue
|
|
97
|
+
};
|
|
88
98
|
useDidUpdate(() => {
|
|
89
99
|
if (notifications.length > previousLength.current) {
|
|
90
100
|
setTimeout(() => forceUpdate(), 0);
|
|
91
101
|
}
|
|
92
102
|
previousLength.current = notifications.length;
|
|
93
103
|
}, [notifications]);
|
|
104
|
+
useNotificationsEvents(ctx);
|
|
94
105
|
const items = notifications.map((notification) => /* @__PURE__ */ React.createElement(Transition, {
|
|
95
106
|
key: notification.id,
|
|
96
107
|
timeout: duration,
|
|
@@ -104,23 +115,18 @@ function NotificationsProvider(_a) {
|
|
|
104
115
|
onHide: hideNotification,
|
|
105
116
|
className: classes.notification,
|
|
106
117
|
autoClose,
|
|
107
|
-
sx:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
sx: [
|
|
119
|
+
__spreadValues({}, getNotificationStateStyles({
|
|
120
|
+
state,
|
|
121
|
+
positioning,
|
|
122
|
+
transitionDuration: duration,
|
|
123
|
+
maxHeight: notificationMaxHeight
|
|
124
|
+
})),
|
|
125
|
+
...Array.isArray(notification.sx) ? notification.sx : [notification.sx]
|
|
126
|
+
]
|
|
113
127
|
})));
|
|
114
128
|
return /* @__PURE__ */ React.createElement(NotificationsContext.Provider, {
|
|
115
|
-
value:
|
|
116
|
-
notifications,
|
|
117
|
-
queue,
|
|
118
|
-
showNotification,
|
|
119
|
-
hideNotification,
|
|
120
|
-
updateNotification,
|
|
121
|
-
clean,
|
|
122
|
-
cleanQueue
|
|
123
|
-
}
|
|
129
|
+
value: ctx
|
|
124
130
|
}, /* @__PURE__ */ React.createElement(Portal, {
|
|
125
131
|
zIndex
|
|
126
132
|
}, /* @__PURE__ */ React.createElement(Box, __spreadValues({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/NotificationsProvider/NotificationsProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Transition, TransitionGroup } from 'react-transition-group';\nimport { DefaultProps, Portal, MantineStyleSystemSize, getDefaultZIndex, Box } from '@mantine/core';\nimport { useReducedMotion, useForceUpdate, useDidUpdate } from '@mantine/hooks';\nimport { NotificationsContext } from '../Notifications.context';\nimport { NotificationsProviderPositioning } from '../types';\nimport getPositionStyles from './get-position-styles/get-position-styles';\nimport getNotificationStateStyles from './get-notification-state-styles/get-notification-state-styles';\nimport NotificationContainer from '../NotificationContainer/NotificationContainer';\nimport useStyles from './NotificationsProvider.styles';\nimport useNotificationsState from './use-notifications-state/use-notifications-state';\n\nconst POSITIONS = [\n 'top-left',\n 'top-right',\n 'top-center',\n 'bottom-left',\n 'bottom-right',\n 'bottom-center',\n] as const;\n\nexport interface NotificationProviderProps\n extends Omit<DefaultProps, MantineStyleSystemSize>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Notifications position */\n position?:\n | 'top-left'\n | 'top-right'\n | 'top-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom-center';\n\n /** Auto close timeout for all notifications, false to disable auto close, can be overwritten for individual notifications by showNotification function */\n autoClose?: number | false;\n\n /** Notification transitions duration, 0 to turn transitions off */\n transitionDuration?: number;\n\n /** Notification width in px, cannot exceed 100% */\n containerWidth?: number;\n\n /** Notification max-height in px, used for transitions */\n notificationMaxHeight?: number;\n\n /** Maximum amount of notifications displayed at a time, other new notifications will be added to queue */\n limit?: number;\n\n /** Notifications container z-index */\n zIndex?: number;\n}\n\nexport function NotificationsProvider({\n className,\n position = 'bottom-right',\n autoClose = 4000,\n transitionDuration = 250,\n containerWidth = 440,\n notificationMaxHeight = 200,\n limit = 5,\n zIndex = getDefaultZIndex('overlay'),\n style,\n children,\n ...others\n}: NotificationProviderProps) {\n const forceUpdate = useForceUpdate();\n const refs = useRef<Record<string, HTMLDivElement>>({});\n const previousLength = useRef<number>(0);\n const {\n notifications,\n queue,\n showNotification,\n updateNotification,\n hideNotification,\n clean,\n cleanQueue,\n } = useNotificationsState({ limit });\n const reduceMotion = useReducedMotion();\n const duration = reduceMotion ? 1 : transitionDuration;\n const { classes, cx, theme } = useStyles();\n const positioning = (POSITIONS.includes(position) ? position : 'bottom-right').split(\n '-'\n ) as NotificationsProviderPositioning;\n\n useDidUpdate(() => {\n if (notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = notifications.length;\n }, [notifications]);\n\n const items = notifications.map((notification) => (\n <Transition\n key={notification.id}\n timeout={duration}\n onEnter={() => refs.current[notification.id].offsetHeight}\n nodeRef={{ current: refs.current[notification.id] }}\n >\n {(state) => (\n <NotificationContainer\n innerRef={(node) => {\n refs.current[notification.id] = node;\n }}\n notification={notification}\n onHide={hideNotification}\n className={classes.notification}\n autoClose={autoClose}\n sx={{\n
|
|
1
|
+
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/NotificationsProvider/NotificationsProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Transition, TransitionGroup } from 'react-transition-group';\nimport { DefaultProps, Portal, MantineStyleSystemSize, getDefaultZIndex, Box } from '@mantine/core';\nimport { useReducedMotion, useForceUpdate, useDidUpdate } from '@mantine/hooks';\nimport { NotificationsContext } from '../Notifications.context';\nimport { NotificationsProviderPositioning } from '../types';\nimport { useNotificationsEvents } from '../events';\nimport getPositionStyles from './get-position-styles/get-position-styles';\nimport getNotificationStateStyles from './get-notification-state-styles/get-notification-state-styles';\nimport NotificationContainer from '../NotificationContainer/NotificationContainer';\nimport useStyles from './NotificationsProvider.styles';\nimport useNotificationsState from './use-notifications-state/use-notifications-state';\n\nconst POSITIONS = [\n 'top-left',\n 'top-right',\n 'top-center',\n 'bottom-left',\n 'bottom-right',\n 'bottom-center',\n] as const;\n\nexport interface NotificationProviderProps\n extends Omit<DefaultProps, MantineStyleSystemSize>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Notifications position */\n position?:\n | 'top-left'\n | 'top-right'\n | 'top-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom-center';\n\n /** Auto close timeout for all notifications, false to disable auto close, can be overwritten for individual notifications by showNotification function */\n autoClose?: number | false;\n\n /** Notification transitions duration, 0 to turn transitions off */\n transitionDuration?: number;\n\n /** Notification width in px, cannot exceed 100% */\n containerWidth?: number;\n\n /** Notification max-height in px, used for transitions */\n notificationMaxHeight?: number;\n\n /** Maximum amount of notifications displayed at a time, other new notifications will be added to queue */\n limit?: number;\n\n /** Notifications container z-index */\n zIndex?: number;\n}\n\nexport function NotificationsProvider({\n className,\n position = 'bottom-right',\n autoClose = 4000,\n transitionDuration = 250,\n containerWidth = 440,\n notificationMaxHeight = 200,\n limit = 5,\n zIndex = getDefaultZIndex('overlay'),\n style,\n children,\n ...others\n}: NotificationProviderProps) {\n const forceUpdate = useForceUpdate();\n const refs = useRef<Record<string, HTMLDivElement>>({});\n const previousLength = useRef<number>(0);\n const {\n notifications,\n queue,\n showNotification,\n updateNotification,\n hideNotification,\n clean,\n cleanQueue,\n } = useNotificationsState({ limit });\n const reduceMotion = useReducedMotion();\n const duration = reduceMotion ? 1 : transitionDuration;\n const { classes, cx, theme } = useStyles();\n const positioning = (POSITIONS.includes(position) ? position : 'bottom-right').split(\n '-'\n ) as NotificationsProviderPositioning;\n\n const ctx = {\n notifications,\n queue,\n showNotification,\n hideNotification,\n updateNotification,\n clean,\n cleanQueue,\n };\n\n useDidUpdate(() => {\n if (notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = notifications.length;\n }, [notifications]);\n\n useNotificationsEvents(ctx);\n\n const items = notifications.map((notification) => (\n <Transition\n key={notification.id}\n timeout={duration}\n onEnter={() => refs.current[notification.id].offsetHeight}\n nodeRef={{ current: refs.current[notification.id] }}\n >\n {(state) => (\n <NotificationContainer\n innerRef={(node) => {\n refs.current[notification.id] = node;\n }}\n notification={notification}\n onHide={hideNotification}\n className={classes.notification}\n autoClose={autoClose}\n sx={[\n {\n ...getNotificationStateStyles({\n state,\n positioning,\n transitionDuration: duration,\n maxHeight: notificationMaxHeight,\n }),\n },\n ...(Array.isArray(notification.sx) ? notification.sx : [notification.sx]),\n ]}\n />\n )}\n </Transition>\n ));\n\n return (\n <NotificationsContext.Provider value={ctx}>\n <Portal zIndex={zIndex}>\n <Box\n className={cx(classes.notifications, className)}\n style={style}\n sx={{\n maxWidth: containerWidth,\n ...getPositionStyles(positioning, containerWidth, theme.spacing.md),\n }}\n {...others}\n >\n <TransitionGroup>{items}</TransitionGroup>\n </Box>\n </Portal>\n\n {children}\n </NotificationsContext.Provider>\n );\n}\n\nNotificationsProvider.displayName = '@mantine/notifications/NotificationsProvider';\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,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;AAC7D,IAAI,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC;AACnD,IAAI,KAAK;AACT,IAAI,EAAE,EAAE,cAAc,CAAC;AACvB,MAAM,QAAQ,EAAE,cAAc;AAC9B,KAAK,EAAE,iBAAiB,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACxE,GAAG,EAAE,MAAM,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7F,CAAC;AACD,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;;;"}
|
package/esm/events.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const NOTIFICATIONS_EVENTS = {
|
|
4
|
+
show: "mantine:show-notification",
|
|
5
|
+
hide: "mantine:hide-notification",
|
|
6
|
+
update: "mantine:update-notification",
|
|
7
|
+
clean: "mantine:clean-notifications",
|
|
8
|
+
cleanQueue: "mantine:clean-notifications-queue"
|
|
9
|
+
};
|
|
10
|
+
function createEvent(type, detail) {
|
|
11
|
+
return new CustomEvent(type, { detail });
|
|
12
|
+
}
|
|
13
|
+
function showNotification(notification) {
|
|
14
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.show, notification));
|
|
15
|
+
}
|
|
16
|
+
function updateNotification(notification) {
|
|
17
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.update, notification));
|
|
18
|
+
}
|
|
19
|
+
function hideNotification(id) {
|
|
20
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.hide, id));
|
|
21
|
+
}
|
|
22
|
+
function cleanNotifications() {
|
|
23
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.clean));
|
|
24
|
+
}
|
|
25
|
+
function cleanNotificationsQueue() {
|
|
26
|
+
window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.cleanQueue));
|
|
27
|
+
}
|
|
28
|
+
function useNotificationsEvents(ctx) {
|
|
29
|
+
const events = {
|
|
30
|
+
show: (event) => ctx.showNotification(event.detail),
|
|
31
|
+
hide: (event) => ctx.hideNotification(event.detail),
|
|
32
|
+
update: (event) => ctx.updateNotification(event.detail.id, event.detail),
|
|
33
|
+
clean: ctx.clean,
|
|
34
|
+
cleanQueue: ctx.cleanQueue
|
|
35
|
+
};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
Object.keys(events).forEach((event) => {
|
|
38
|
+
window.addEventListener(NOTIFICATIONS_EVENTS[event], events[event]);
|
|
39
|
+
});
|
|
40
|
+
return () => {
|
|
41
|
+
Object.keys(events).forEach((event) => {
|
|
42
|
+
window.removeEventListener(NOTIFICATIONS_EVENTS[event], events[event]);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { NOTIFICATIONS_EVENTS, cleanNotifications, cleanNotificationsQueue, createEvent, hideNotification, showNotification, updateNotification, useNotificationsEvents };
|
|
49
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { NotificationProps, NotificationsContextProps } from './types';\n\ntype ValueOf<T> = T[keyof T];\n\nexport const NOTIFICATIONS_EVENTS = {\n show: 'mantine:show-notification',\n hide: 'mantine:hide-notification',\n update: 'mantine:update-notification',\n clean: 'mantine:clean-notifications',\n cleanQueue: 'mantine:clean-notifications-queue',\n} as const;\n\nexport function createEvent(type: ValueOf<typeof NOTIFICATIONS_EVENTS>, detail?: any) {\n return new CustomEvent(type, { detail });\n}\n\nexport function showNotification(notification: NotificationProps) {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.show, notification));\n}\n\nexport function updateNotification(notification: NotificationProps & { id: string }) {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.update, notification));\n}\n\nexport function hideNotification(id: string) {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.hide, id));\n}\n\nexport function cleanNotifications() {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.clean));\n}\n\nexport function cleanNotificationsQueue() {\n window.dispatchEvent(createEvent(NOTIFICATIONS_EVENTS.cleanQueue));\n}\n\nexport function useNotificationsEvents(ctx: NotificationsContextProps) {\n const events = {\n show: (event: any) => ctx.showNotification(event.detail),\n hide: (event: any) => ctx.hideNotification(event.detail),\n update: (event: any) => ctx.updateNotification(event.detail.id, event.detail),\n clean: ctx.clean,\n cleanQueue: ctx.cleanQueue,\n };\n\n useEffect(() => {\n Object.keys(events).forEach((event) => {\n window.addEventListener(NOTIFICATIONS_EVENTS[event], events[event]);\n });\n\n return () => {\n Object.keys(events).forEach((event) => {\n window.removeEventListener(NOTIFICATIONS_EVENTS[event], events[event]);\n });\n };\n }, []);\n}\n"],"names":[],"mappings":";;AACY,MAAC,oBAAoB,GAAG;AACpC,EAAE,IAAI,EAAE,2BAA2B;AACnC,EAAE,IAAI,EAAE,2BAA2B;AACnC,EAAE,MAAM,EAAE,6BAA6B;AACvC,EAAE,KAAK,EAAE,6BAA6B;AACtC,EAAE,UAAU,EAAE,mCAAmC;AACjD,EAAE;AACK,SAAS,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE;AAC1C,EAAE,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3C,CAAC;AACM,SAAS,gBAAgB,CAAC,YAAY,EAAE;AAC/C,EAAE,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;AAC7E,CAAC;AACM,SAAS,kBAAkB,CAAC,YAAY,EAAE;AACjD,EAAE,MAAM,CAAC,aAAa,CAAC,WAAW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MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK;AAC7C,QAAQ,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/E,OAAO,CAAC,CAAC;AACT,KAAK,CAAC;AACN,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { useNotifications } from './use-notifications/use-notifications.js';
|
|
2
2
|
export { NotificationsProvider } from './NotificationsProvider/NotificationsProvider.js';
|
|
3
|
+
export { cleanNotifications, cleanNotificationsQueue, hideNotification, showNotification, updateNotification } from './events.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -4,7 +4,7 @@ import { NotificationsContext } from '../Notifications.context.js';
|
|
|
4
4
|
function useNotifications() {
|
|
5
5
|
const context = useContext(NotificationsContext);
|
|
6
6
|
if (!context) {
|
|
7
|
-
throw new Error("@mantine/notifications:
|
|
7
|
+
throw new Error("@mantine/notifications: use-notifications hook was called outside of NotificationsProvider context");
|
|
8
8
|
}
|
|
9
9
|
return context;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-notifications.js","sources":["../../src/use-notifications/use-notifications.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { NotificationsContext } from '../Notifications.context';\n\nexport function useNotifications() {\n const context = useContext(NotificationsContext);\n\n if (!context) {\n throw new Error('@mantine/notifications:
|
|
1
|
+
{"version":3,"file":"use-notifications.js","sources":["../../src/use-notifications/use-notifications.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { NotificationsContext } from '../Notifications.context';\n\nexport function useNotifications() {\n const context = useContext(NotificationsContext);\n\n if (!context) {\n throw new Error(\n '@mantine/notifications: use-notifications hook was called outside of NotificationsProvider context'\n );\n }\n\n return context;\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,gBAAgB,GAAG;AACnC,EAAE,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;AACnD,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,MAAM,IAAI,KAAK,CAAC,oGAAoG,CAAC,CAAC;AAC1H,GAAG;AACH,EAAE,OAAO,OAAO,CAAC;AACjB;;;;"}
|
|
@@ -7,7 +7,7 @@ export interface NotificationContainerProps extends DefaultProps {
|
|
|
7
7
|
autoClose: false | number;
|
|
8
8
|
innerRef: React.ForwardedRef<HTMLDivElement>;
|
|
9
9
|
}
|
|
10
|
-
declare function NotificationContainer({
|
|
10
|
+
declare function NotificationContainer({ notification, autoClose, onHide, innerRef, ...others }: NotificationContainerProps): JSX.Element;
|
|
11
11
|
declare namespace NotificationContainer {
|
|
12
12
|
var displayName: string;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationContainer.d.ts","sourceRoot":"","sources":["../../src/NotificationContainer/NotificationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAgB,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,0BAA2B,SAAQ,YAAY;IAC9D,YAAY,EAAE,iBAAiB,CAAC;IAChC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;CAC9C;AAED,iBAAwB,qBAAqB,CAAC,EAC5C,
|
|
1
|
+
{"version":3,"file":"NotificationContainer.d.ts","sourceRoot":"","sources":["../../src/NotificationContainer/NotificationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAgB,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,0BAA2B,SAAQ,YAAY;IAC9D,YAAY,EAAE,iBAAiB,CAAC;IAChC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;CAC9C;AAED,iBAAwB,qBAAqB,CAAC,EAC5C,YAAY,EACZ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,0BAA0B,eA2C5B;kBAjDuB,qBAAqB;;;eAArB,qBAAqB"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default function getAutoClose(autoClose: boolean | number, notification: NotificationProps): number | boolean;
|
|
1
|
+
export default function getAutoClose(autoClose: boolean | number, notificationAutoClose: boolean | number): number | boolean;
|
|
3
2
|
//# sourceMappingURL=get-auto-close.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-auto-close.d.ts","sourceRoot":"","sources":["../../../src/NotificationContainer/get-auto-close/get-auto-close.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"get-auto-close.d.ts","sourceRoot":"","sources":["../../../src/NotificationContainer/get-auto-close/get-auto-close.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,SAAS,EAAE,OAAO,GAAG,MAAM,EAC3B,qBAAqB,EAAE,OAAO,GAAG,MAAM,oBAWxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsProvider.d.ts","sourceRoot":"","sources":["../../src/NotificationsProvider/NotificationsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAU,sBAAsB,EAAyB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"NotificationsProvider.d.ts","sourceRoot":"","sources":["../../src/NotificationsProvider/NotificationsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAU,sBAAsB,EAAyB,MAAM,eAAe,CAAC;AAoBpG,MAAM,WAAW,yBACf,SAAQ,IAAI,CAAC,YAAY,EAAE,sBAAsB,CAAC,EAChD,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC;IACvC,6BAA6B;IAC7B,QAAQ,CAAC,EACL,UAAU,GACV,WAAW,GACX,YAAY,GACZ,aAAa,GACb,cAAc,GACd,eAAe,CAAC;IAEpB,0JAA0J;IAC1J,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE3B,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,0DAA0D;IAC1D,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,0GAA0G;IAC1G,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAyB,EACzB,SAAgB,EAChB,kBAAwB,EACxB,cAAoB,EACpB,qBAA2B,EAC3B,KAAS,EACT,MAAoC,EACpC,KAAK,EACL,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,yBAAyB,eA0F3B;yBAtGe,qBAAqB"}
|
package/lib/events.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NotificationProps, NotificationsContextProps } from './types';
|
|
2
|
+
declare type ValueOf<T> = T[keyof T];
|
|
3
|
+
export declare const NOTIFICATIONS_EVENTS: {
|
|
4
|
+
readonly show: "mantine:show-notification";
|
|
5
|
+
readonly hide: "mantine:hide-notification";
|
|
6
|
+
readonly update: "mantine:update-notification";
|
|
7
|
+
readonly clean: "mantine:clean-notifications";
|
|
8
|
+
readonly cleanQueue: "mantine:clean-notifications-queue";
|
|
9
|
+
};
|
|
10
|
+
export declare function createEvent(type: ValueOf<typeof NOTIFICATIONS_EVENTS>, detail?: any): CustomEvent<any>;
|
|
11
|
+
export declare function showNotification(notification: NotificationProps): void;
|
|
12
|
+
export declare function updateNotification(notification: NotificationProps & {
|
|
13
|
+
id: string;
|
|
14
|
+
}): void;
|
|
15
|
+
export declare function hideNotification(id: string): void;
|
|
16
|
+
export declare function cleanNotifications(): void;
|
|
17
|
+
export declare function cleanNotificationsQueue(): void;
|
|
18
|
+
export declare function useNotificationsEvents(ctx: NotificationsContextProps): void;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAE5E,aAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE7B,eAAO,MAAM,oBAAoB;;;;;;CAMvB,CAAC;AAEX,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,oBAAoB,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,oBAEnF;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,iBAAiB,QAE/D;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,iBAAiB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,QAElF;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,QAE1C;AAED,wBAAgB,kBAAkB,SAEjC;AAED,wBAAgB,uBAAuB,SAEtC;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,yBAAyB,QAoBpE"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { useNotifications } from './use-notifications/use-notifications';
|
|
2
2
|
export { NotificationsProvider } from './NotificationsProvider/NotificationsProvider';
|
|
3
|
+
export { showNotification, updateNotification, hideNotification, cleanNotifications, cleanNotificationsQueue, } from './events';
|
|
3
4
|
export type { NotificationProps } from './types';
|
|
4
5
|
export type { NotificationProviderProps } from './NotificationsProvider/NotificationsProvider';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,YAAY,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,YAAY,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
export interface NotificationProps {
|
|
2
|
+
import type { NotificationProps as NotificationComponentProps } from '@mantine/core';
|
|
3
|
+
export interface NotificationProps extends Omit<NotificationComponentProps, 'onClose'> {
|
|
4
4
|
id?: string;
|
|
5
|
-
color?: MantineColor;
|
|
6
|
-
radius?: MantineNumberSize;
|
|
7
|
-
className?: string;
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
icon?: React.ReactNode;
|
|
10
|
-
title?: React.ReactNode;
|
|
11
|
-
loading?: boolean;
|
|
12
5
|
message: React.ReactNode;
|
|
13
6
|
autoClose?: boolean | number;
|
|
14
|
-
disallowClose?: boolean;
|
|
15
7
|
onClose?(props: NotificationProps): void;
|
|
16
8
|
onOpen?(props: NotificationProps): void;
|
|
17
9
|
}
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,iBAAiB,IAAI,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAErF,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,0BAA0B,EAAE,SAAS,CAAC;IACpF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,OAAO,CAAC,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,MAAM,CAAC,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,iBAAiB,EAAE,CAAC;IACnC,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC;IACnD,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC/D,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,KAAK,IAAI,IAAI,CAAC;IACd,UAAU,IAAI,IAAI,CAAC;CACpB;AAED,oBAAY,gCAAgC,GAAG,CAAC,KAAK,GAAG,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-notifications.d.ts","sourceRoot":"","sources":["../../src/use-notifications/use-notifications.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"use-notifications.d.ts","sourceRoot":"","sources":["../../src/use-notifications/use-notifications.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,iDAU/B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantine/notifications",
|
|
3
3
|
"description": "Notification system based on Mantine components",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.2",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -28,13 +28,12 @@
|
|
|
28
28
|
"notification-system"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@mantine/core": "4.
|
|
32
|
-
"@mantine/hooks": "4.
|
|
31
|
+
"@mantine/core": "4.1.2",
|
|
32
|
+
"@mantine/hooks": "4.1.2",
|
|
33
33
|
"react": ">=16.8.0",
|
|
34
34
|
"react-dom": ">=16.8.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"clsx": "^1.1.1",
|
|
38
37
|
"react-transition-group": "^4.4.2"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {}
|