@mantine/notifications 6.0.13 → 7.0.0-alpha.13
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 → NotificationContainer.js} +37 -44
- package/cjs/NotificationContainer.js.map +1 -0
- package/cjs/Notifications.js +179 -0
- package/cjs/Notifications.js.map +1 -0
- package/cjs/Notifications.module.css.js +8 -0
- package/cjs/Notifications.module.css.js.map +1 -0
- package/cjs/{NotificationContainer/get-auto-close → get-auto-close}/get-auto-close.js +1 -1
- package/cjs/get-auto-close/get-auto-close.js.map +1 -0
- package/cjs/{Notifications/get-notification-state-styles/get-notification-state-styles.js → get-notification-state-styles.js} +3 -3
- package/cjs/get-notification-state-styles.js.map +1 -0
- package/cjs/index.css +15 -0
- package/cjs/index.js +13 -8
- package/cjs/index.js.map +1 -1
- package/cjs/notifications.store.js +107 -0
- package/cjs/notifications.store.js.map +1 -0
- package/esm/NotificationContainer.js +75 -0
- package/esm/NotificationContainer.js.map +1 -0
- package/esm/Notifications.js +171 -0
- package/esm/Notifications.js.map +1 -0
- package/esm/Notifications.module.css.js +4 -0
- package/esm/Notifications.module.css.js.map +1 -0
- package/esm/{NotificationContainer/get-auto-close → get-auto-close}/get-auto-close.js +1 -1
- package/esm/get-auto-close/get-auto-close.js.map +1 -0
- package/esm/{Notifications/get-notification-state-styles/get-notification-state-styles.js → get-notification-state-styles.js} +3 -3
- package/esm/get-notification-state-styles.js.map +1 -0
- package/esm/index.css +15 -0
- package/esm/index.js +3 -2
- package/esm/index.js.map +1 -1
- package/esm/notifications.store.js +94 -0
- package/esm/notifications.store.js.map +1 -0
- package/lib/NotificationContainer.d.ts +11 -0
- package/lib/NotificationContainer.d.ts.map +1 -0
- package/lib/Notifications.d.ts +61 -0
- package/lib/Notifications.d.ts.map +1 -0
- package/lib/get-auto-close/get-auto-close.d.ts +2 -0
- package/lib/get-auto-close/get-auto-close.d.ts.map +1 -0
- package/lib/get-notification-state-styles.d.ts +12 -0
- package/lib/get-notification-state-styles.d.ts.map +1 -0
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/notifications.store.d.ts +41 -0
- package/lib/notifications.store.d.ts.map +1 -0
- package/package.json +16 -10
- package/cjs/NotificationContainer/NotificationContainer.js.map +0 -1
- package/cjs/NotificationContainer/get-auto-close/get-auto-close.js.map +0 -1
- package/cjs/Notifications/Notifications.js +0 -152
- package/cjs/Notifications/Notifications.js.map +0 -1
- package/cjs/Notifications/Notifications.styles.js +0 -22
- package/cjs/Notifications/Notifications.styles.js.map +0 -1
- package/cjs/Notifications/get-notification-state-styles/get-notification-state-styles.js.map +0 -1
- package/cjs/Notifications/get-position-styles/get-position-styles.js +0 -16
- package/cjs/Notifications/get-position-styles/get-position-styles.js.map +0 -1
- package/cjs/Notifications/use-notifications-state/use-notifications-state.js +0 -70
- package/cjs/Notifications/use-notifications-state/use-notifications-state.js.map +0 -1
- package/cjs/events.js +0 -29
- package/cjs/events.js.map +0 -1
- package/esm/NotificationContainer/NotificationContainer.js +0 -82
- package/esm/NotificationContainer/NotificationContainer.js.map +0 -1
- package/esm/NotificationContainer/get-auto-close/get-auto-close.js.map +0 -1
- package/esm/Notifications/Notifications.js +0 -144
- package/esm/Notifications/Notifications.js.map +0 -1
- package/esm/Notifications/Notifications.styles.js +0 -18
- package/esm/Notifications/Notifications.styles.js.map +0 -1
- package/esm/Notifications/get-notification-state-styles/get-notification-state-styles.js.map +0 -1
- package/esm/Notifications/get-position-styles/get-position-styles.js +0 -12
- package/esm/Notifications/get-position-styles/get-position-styles.js.map +0 -1
- package/esm/Notifications/use-notifications-state/use-notifications-state.js +0 -66
- package/esm/Notifications/use-notifications-state/use-notifications-state.js.map +0 -1
- package/esm/events.js +0 -18
- package/esm/events.js.map +0 -1
- package/lib/NotificationContainer/NotificationContainer.d.ts +0 -15
- package/lib/NotificationContainer/NotificationContainer.d.ts.map +0 -1
- package/lib/NotificationContainer/get-auto-close/get-auto-close.d.ts +0 -2
- package/lib/NotificationContainer/get-auto-close/get-auto-close.d.ts.map +0 -1
- package/lib/Notifications/Notifications.d.ts +0 -25
- package/lib/Notifications/Notifications.d.ts.map +0 -1
- package/lib/Notifications/Notifications.styles.d.ts +0 -14
- package/lib/Notifications/Notifications.styles.d.ts.map +0 -1
- package/lib/Notifications/get-notification-state-styles/get-notification-state-styles.d.ts +0 -12
- package/lib/Notifications/get-notification-state-styles/get-notification-state-styles.d.ts.map +0 -1
- package/lib/Notifications/get-position-styles/get-position-styles.d.ts +0 -4
- package/lib/Notifications/get-position-styles/get-position-styles.d.ts.map +0 -1
- package/lib/Notifications/use-notifications-state/use-notifications-state.d.ts +0 -13
- package/lib/Notifications/use-notifications-state/use-notifications-state.d.ts.map +0 -1
- package/lib/events.d.ts +0 -20
- package/lib/events.d.ts.map +0 -1
- package/lib/types.d.ts +0 -15
- package/lib/types.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
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, message, ...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 {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,IA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,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,iBAAiB,EAAE,CAAC;AACxB,IAAI,OAAO,iBAAiB,CAAC;AAC7B,GAAG,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AAC1C,EAAE,uBAAuBC,cAAK,CAAC,aAAa,CAACC,iBAAY,EAAE,aAAa,CAAC,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,OAAO,CAAC,CAAC;AACf,CAAC;AACD,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;"}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var reactTransitionGroup = require('react-transition-group');
|
|
7
|
-
var core = require('@mantine/core');
|
|
8
|
-
var hooks = require('@mantine/hooks');
|
|
9
|
-
var events = require('../events.js');
|
|
10
|
-
var getPositionStyles = require('./get-position-styles/get-position-styles.js');
|
|
11
|
-
var getNotificationStateStyles = require('./get-notification-state-styles/get-notification-state-styles.js');
|
|
12
|
-
var NotificationContainer = require('../NotificationContainer/NotificationContainer.js');
|
|
13
|
-
var Notifications_styles = require('./Notifications.styles.js');
|
|
14
|
-
var useNotificationsState = require('./use-notifications-state/use-notifications-state.js');
|
|
15
|
-
|
|
16
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
17
|
-
|
|
18
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
|
-
|
|
20
|
-
var __defProp = Object.defineProperty;
|
|
21
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
22
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
23
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
24
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
25
|
-
var __spreadValues = (a, b) => {
|
|
26
|
-
for (var prop in b || (b = {}))
|
|
27
|
-
if (__hasOwnProp.call(b, prop))
|
|
28
|
-
__defNormalProp(a, prop, b[prop]);
|
|
29
|
-
if (__getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
31
|
-
if (__propIsEnum.call(b, prop))
|
|
32
|
-
__defNormalProp(a, prop, b[prop]);
|
|
33
|
-
}
|
|
34
|
-
return a;
|
|
35
|
-
};
|
|
36
|
-
var __objRest = (source, exclude) => {
|
|
37
|
-
var target = {};
|
|
38
|
-
for (var prop in source)
|
|
39
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
40
|
-
target[prop] = source[prop];
|
|
41
|
-
if (source != null && __getOwnPropSymbols)
|
|
42
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
43
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
44
|
-
target[prop] = source[prop];
|
|
45
|
-
}
|
|
46
|
-
return target;
|
|
47
|
-
};
|
|
48
|
-
const POSITIONS = [
|
|
49
|
-
"top-left",
|
|
50
|
-
"top-right",
|
|
51
|
-
"top-center",
|
|
52
|
-
"bottom-left",
|
|
53
|
-
"bottom-right",
|
|
54
|
-
"bottom-center"
|
|
55
|
-
];
|
|
56
|
-
const Notifications = (_a) => {
|
|
57
|
-
var _b = _a, {
|
|
58
|
-
className,
|
|
59
|
-
position = "bottom-right",
|
|
60
|
-
autoClose = 4e3,
|
|
61
|
-
transitionDuration = 250,
|
|
62
|
-
containerWidth = core.rem(440),
|
|
63
|
-
notificationMaxHeight = core.rem(200),
|
|
64
|
-
limit = 5,
|
|
65
|
-
zIndex = core.getDefaultZIndex("overlay"),
|
|
66
|
-
style,
|
|
67
|
-
children,
|
|
68
|
-
target
|
|
69
|
-
} = _b, others = __objRest(_b, [
|
|
70
|
-
"className",
|
|
71
|
-
"position",
|
|
72
|
-
"autoClose",
|
|
73
|
-
"transitionDuration",
|
|
74
|
-
"containerWidth",
|
|
75
|
-
"notificationMaxHeight",
|
|
76
|
-
"limit",
|
|
77
|
-
"zIndex",
|
|
78
|
-
"style",
|
|
79
|
-
"children",
|
|
80
|
-
"target"
|
|
81
|
-
]);
|
|
82
|
-
const forceUpdate = hooks.useForceUpdate();
|
|
83
|
-
const refs = React.useRef({});
|
|
84
|
-
const previousLength = React.useRef(0);
|
|
85
|
-
const {
|
|
86
|
-
notifications,
|
|
87
|
-
showNotification,
|
|
88
|
-
updateNotification,
|
|
89
|
-
hideNotification,
|
|
90
|
-
clean,
|
|
91
|
-
cleanQueue
|
|
92
|
-
} = useNotificationsState['default']({ limit });
|
|
93
|
-
const { classes, cx, theme } = Notifications_styles['default']({ zIndex });
|
|
94
|
-
const shouldReduceMotion = hooks.useReducedMotion();
|
|
95
|
-
const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
|
|
96
|
-
const duration = reduceMotion ? 1 : transitionDuration;
|
|
97
|
-
const positioning = (POSITIONS.includes(position) ? position : "bottom-right").split("-");
|
|
98
|
-
hooks.useDidUpdate(() => {
|
|
99
|
-
if (notifications.length > previousLength.current) {
|
|
100
|
-
setTimeout(() => forceUpdate(), 0);
|
|
101
|
-
}
|
|
102
|
-
previousLength.current = notifications.length;
|
|
103
|
-
}, [notifications]);
|
|
104
|
-
events.useNotificationsEvents({
|
|
105
|
-
show: showNotification,
|
|
106
|
-
hide: hideNotification,
|
|
107
|
-
update: updateNotification,
|
|
108
|
-
clean,
|
|
109
|
-
cleanQueue
|
|
110
|
-
});
|
|
111
|
-
const items = notifications.map((notification) => /* @__PURE__ */ React__default.createElement(reactTransitionGroup.Transition, {
|
|
112
|
-
key: notification.id,
|
|
113
|
-
timeout: duration,
|
|
114
|
-
onEnter: () => refs.current[notification.id].offsetHeight,
|
|
115
|
-
nodeRef: { current: refs.current[notification.id] }
|
|
116
|
-
}, (state) => /* @__PURE__ */ React__default.createElement(NotificationContainer['default'], {
|
|
117
|
-
innerRef: (node) => {
|
|
118
|
-
refs.current[notification.id] = node;
|
|
119
|
-
},
|
|
120
|
-
notification,
|
|
121
|
-
onHide: hideNotification,
|
|
122
|
-
className: classes.notification,
|
|
123
|
-
autoClose,
|
|
124
|
-
sx: [
|
|
125
|
-
__spreadValues({}, getNotificationStateStyles['default']({
|
|
126
|
-
state,
|
|
127
|
-
positioning,
|
|
128
|
-
transitionDuration: duration,
|
|
129
|
-
maxHeight: notificationMaxHeight
|
|
130
|
-
})),
|
|
131
|
-
...Array.isArray(notification.sx) ? notification.sx : [notification.sx]
|
|
132
|
-
]
|
|
133
|
-
})));
|
|
134
|
-
return /* @__PURE__ */ React__default.createElement(core.Portal, {
|
|
135
|
-
target
|
|
136
|
-
}, /* @__PURE__ */ React__default.createElement(core.Box, __spreadValues({
|
|
137
|
-
className: cx(classes.notifications, className),
|
|
138
|
-
style,
|
|
139
|
-
sx: __spreadValues({
|
|
140
|
-
maxWidth: containerWidth
|
|
141
|
-
}, getPositionStyles['default'](positioning, theme.spacing.md))
|
|
142
|
-
}, others), /* @__PURE__ */ React__default.createElement(reactTransitionGroup.TransitionGroup, null, items)));
|
|
143
|
-
};
|
|
144
|
-
Notifications.displayName = "@mantine/notifications/Notifications";
|
|
145
|
-
Notifications.show = events.notifications.show;
|
|
146
|
-
Notifications.hide = events.notifications.hide;
|
|
147
|
-
Notifications.update = events.notifications.update;
|
|
148
|
-
Notifications.clean = events.notifications.clean;
|
|
149
|
-
Notifications.cleanQueue = events.notifications.cleanQueue;
|
|
150
|
-
|
|
151
|
-
exports.Notifications = Notifications;
|
|
152
|
-
//# sourceMappingURL=Notifications.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Notifications.js","sources":["../../src/Notifications/Notifications.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Transition, TransitionGroup } from 'react-transition-group';\nimport { DefaultProps, Portal, getDefaultZIndex, Box, PortalProps, rem } from '@mantine/core';\nimport { useReducedMotion, useForceUpdate, useDidUpdate } from '@mantine/hooks';\nimport { NotificationsPositioning } from '../types';\nimport {\n notifications as GlobalNotifications,\n NotificationsEvents,\n useNotificationsEvents,\n} 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 './Notifications.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\ntype NotificationsStaticMethods = NotificationsEvents;\n\nexport interface NotificationsProps\n extends Omit<DefaultProps, 'style'>,\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 notifications.show function */\n autoClose?: number | false;\n\n /** Notification transitions duration, 0 to turn transitions off */\n transitionDuration?: number;\n\n /** Notification width, cannot exceed 100% */\n containerWidth?: number | string;\n\n /** Notification max-height, used for transitions */\n notificationMaxHeight?: number | string;\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?: React.CSSProperties['zIndex'];\n\n /** Target element of Portal component */\n target?: PortalProps['target'];\n}\n\nexport const Notifications: React.FC<NotificationsProps> & NotificationsStaticMethods = ({\n className,\n position = 'bottom-right',\n autoClose = 4000,\n transitionDuration = 250,\n containerWidth = rem(440),\n notificationMaxHeight = rem(200),\n limit = 5,\n zIndex = getDefaultZIndex('overlay'),\n style,\n children,\n target,\n ...others\n}) => {\n const forceUpdate = useForceUpdate();\n const refs = useRef<Record<string, HTMLDivElement>>({});\n const previousLength = useRef<number>(0);\n const {\n notifications,\n showNotification,\n updateNotification,\n hideNotification,\n clean,\n cleanQueue,\n } = useNotificationsState({ limit });\n\n const { classes, cx, theme } = useStyles({ zIndex });\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const duration = reduceMotion ? 1 : transitionDuration;\n const positioning = (POSITIONS.includes(position) ? position : 'bottom-right').split(\n '-'\n ) as NotificationsPositioning;\n\n useDidUpdate(() => {\n if (notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = notifications.length;\n }, [notifications]);\n\n useNotificationsEvents({\n show: showNotification,\n hide: hideNotification,\n update: updateNotification,\n clean,\n cleanQueue,\n });\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 <Portal target={target}>\n <Box\n className={cx(classes.notifications, className)}\n style={style}\n sx={{\n maxWidth: containerWidth,\n ...getPositionStyles(positioning, theme.spacing.md),\n }}\n {...others}\n >\n <TransitionGroup>{items}</TransitionGroup>\n </Box>\n </Portal>\n );\n};\n\nNotifications.displayName = '@mantine/notifications/Notifications';\nNotifications.show = GlobalNotifications.show;\nNotifications.hide = GlobalNotifications.hide;\nNotifications.update = GlobalNotifications.update;\nNotifications.clean = GlobalNotifications.clean;\nNotifications.cleanQueue = GlobalNotifications.cleanQueue;\n"],"names":["rem","getDefaultZIndex","useForceUpdate","useRef","useNotificationsState","useStyles","useReducedMotion","useDidUpdate","useNotificationsEvents","React","Transition","NotificationContainer","getNotificationStateStyles","Portal","Box","getPositionStyles","TransitionGroup","GlobalNotifications"],"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,CAA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AAK;AACT,IAAI,EAAE,EAAE,cAAc,CAAC;AACvB,MAAM,QAAQ,EAAE,cAAc;AAC9B,KAAK,EAAEC,4BAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACxD,GAAG,EAAE,MAAM,CAAC,kBAAkBN,cAAK,CAAC,aAAa,CAACO,oCAAe,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAClF,EAAE;AACF,aAAa,CAAC,WAAW,GAAG,sCAAsC,CAAC;AACnE,aAAa,CAAC,IAAI,GAAGC,oBAAmB,CAAC,IAAI,CAAC;AAC9C,aAAa,CAAC,IAAI,GAAGA,oBAAmB,CAAC,IAAI,CAAC;AAC9C,aAAa,CAAC,MAAM,GAAGA,oBAAmB,CAAC,MAAM,CAAC;AAClD,aAAa,CAAC,KAAK,GAAGA,oBAAmB,CAAC,KAAK,CAAC;AAChD,aAAa,CAAC,UAAU,GAAGA,oBAAmB,CAAC,UAAU;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@mantine/core');
|
|
6
|
-
|
|
7
|
-
var useStyles = core.createStyles((theme, { zIndex }) => ({
|
|
8
|
-
notifications: {
|
|
9
|
-
width: `calc(100% - ${theme.spacing.md} * 2)`,
|
|
10
|
-
boxSizing: "border-box",
|
|
11
|
-
position: "fixed",
|
|
12
|
-
zIndex
|
|
13
|
-
},
|
|
14
|
-
notification: {
|
|
15
|
-
"&:not(:first-of-type)": {
|
|
16
|
-
marginTop: theme.spacing.sm
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
exports.default = useStyles;
|
|
22
|
-
//# sourceMappingURL=Notifications.styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Notifications.styles.js","sources":["../../src/Notifications/Notifications.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/core';\n\ninterface NotificationsStylesParams {\n zIndex: React.CSSProperties['zIndex'];\n}\n\nexport default createStyles((theme, { zIndex }: NotificationsStylesParams) => ({\n notifications: {\n width: `calc(100% - ${theme.spacing.md} * 2)`,\n boxSizing: 'border-box',\n position: 'fixed',\n zIndex,\n },\n\n notification: {\n '&:not(:first-of-type)': {\n marginTop: theme.spacing.sm,\n },\n },\n}));\n"],"names":["createStyles"],"mappings":";;;;;;AACA,gBAAeA,iBAAY,CAAC,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM;AACpD,EAAE,aAAa,EAAE;AACjB,IAAI,KAAK,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC;AACjD,IAAI,SAAS,EAAE,YAAY;AAC3B,IAAI,QAAQ,EAAE,OAAO;AACrB,IAAI,MAAM;AACV,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,uBAAuB,EAAE;AAC7B,MAAM,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;AACjC,KAAK;AACL,GAAG;AACH,CAAC,CAAC,CAAC;;;;"}
|
package/cjs/Notifications/get-notification-state-styles/get-notification-state-styles.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-notification-state-styles.js","sources":["../../../src/Notifications/get-notification-state-styles/get-notification-state-styles.ts"],"sourcesContent":["import { TransitionStatus } from 'react-transition-group';\nimport { CSSObject } from '@mantine/core';\nimport { NotificationsPositioning } from '../../types';\n\ninterface NotificationStateStylesProps {\n state: TransitionStatus;\n maxHeight: number | string;\n positioning: NotificationsPositioning;\n transitionDuration: number;\n}\n\nconst transforms = {\n left: 'translateX(-100%)',\n right: 'translateX(100%)',\n 'top-center': 'translateY(-100%)',\n 'bottom-center': 'translateY(100%)',\n};\n\nconst noTransform = {\n left: 'translateX(0)',\n right: 'translateX(0)',\n 'top-center': 'translateY(0)',\n 'bottom-center': 'translateY(0)',\n};\n\nexport default function getNotificationStateStyles({\n state,\n maxHeight,\n positioning,\n transitionDuration,\n}: NotificationStateStylesProps): CSSObject {\n const [vertical, horizontal] = positioning;\n const property = horizontal === 'center' ? `${vertical}-center` : horizontal;\n\n const commonStyles: CSSObject = {\n opacity: 0,\n maxHeight,\n transform: transforms[property],\n transitionDuration: `${transitionDuration}ms, ${transitionDuration}ms, ${transitionDuration}ms`,\n transitionTimingFunction: 'cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear',\n transitionProperty: 'opacity, transform, max-height',\n };\n\n const inState: CSSObject = {\n opacity: 1,\n transform: noTransform[property],\n };\n\n const outState: CSSObject = {\n opacity: 0,\n maxHeight: 0,\n transform: transforms[property],\n };\n\n const transitionStyles = {\n entering: inState,\n entered: inState,\n exiting: outState,\n exited: outState,\n };\n\n return { ...commonStyles, ...transitionStyles[state] };\n}\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,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,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BAAkB,EAAE,CAAC,EAAE,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,CAAC,EAAE,CAAC;AACnG,IAAI,wBAAwB,EAAE,kEAAkE;AAChG,IAAI,kBAAkB,EAAE,gCAAgC;AACxD,GAAG,CAAC;AACJ,EAAE,MAAM,OAAO,GAAG;AAClB,IAAI,OAAO,EAAE,CAAC;AACd,IAAI,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC;AACpC,GAAG,CAAC;AACJ,EAAE,MAAM,QAAQ,GAAG;AACnB,IAAI,OAAO,EAAE,CAAC;AACd,IAAI,SAAS,EAAE,CAAC;AAChB,IAAI,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC;AACnC,GAAG,CAAC;AACJ,EAAE,MAAM,gBAAgB,GAAG;AAC3B,IAAI,QAAQ,EAAE,OAAO;AACrB,IAAI,OAAO,EAAE,OAAO;AACpB,IAAI,OAAO,EAAE,QAAQ;AACrB,IAAI,MAAM,EAAE,QAAQ;AACpB,GAAG,CAAC;AACJ,EAAE,OAAO,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;AACnF;;;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function getPositionStyles([vertical, horizontal], spacing) {
|
|
6
|
-
const styles = {};
|
|
7
|
-
vertical === "top" && (styles.top = spacing);
|
|
8
|
-
vertical === "bottom" && (styles.bottom = spacing);
|
|
9
|
-
horizontal === "left" && (styles.left = spacing);
|
|
10
|
-
horizontal === "right" && (styles.right = spacing);
|
|
11
|
-
horizontal === "center" && (styles.left = "50%", styles.transform = "translateX(-50%)");
|
|
12
|
-
return styles;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.default = getPositionStyles;
|
|
16
|
-
//# sourceMappingURL=get-position-styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-position-styles.js","sources":["../../../src/Notifications/get-position-styles/get-position-styles.ts"],"sourcesContent":["import { CSSObject } from '@mantine/core';\nimport { NotificationsPositioning } from '../../types';\n\nexport default function getPositionStyles(\n [vertical, horizontal]: NotificationsPositioning,\n spacing: number | string\n) {\n const styles: CSSObject = {};\n\n vertical === 'top' && (styles.top = spacing);\n vertical === 'bottom' && (styles.bottom = spacing);\n\n horizontal === 'left' && (styles.left = spacing);\n horizontal === 'right' && (styles.right = spacing);\n horizontal === 'center' && ((styles.left = '50%'), (styles.transform = 'translateX(-50%)'));\n\n return styles;\n}\n"],"names":[],"mappings":";;;;AAAe,SAAS,iBAAiB,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE;AAC3E,EAAE,MAAM,MAAM,GAAG,EAAE,CAAC;AACpB,EAAE,QAAQ,KAAK,KAAK,KAAK,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC;AAC/C,EAAE,QAAQ,KAAK,QAAQ,KAAK,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;AACrD,EAAE,UAAU,KAAK,MAAM,KAAK,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;AACnD,EAAE,UAAU,KAAK,OAAO,KAAK,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC;AACrD,EAAE,UAAU,KAAK,QAAQ,KAAK,MAAM,CAAC,IAAI,GAAG,KAAK,EAAE,MAAM,CAAC,SAAS,GAAG,kBAAkB,CAAC,CAAC;AAC1F,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var hooks = require('@mantine/hooks');
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __defProps = Object.defineProperties;
|
|
9
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
-
var __spreadValues = (a, b) => {
|
|
15
|
-
for (var prop in b || (b = {}))
|
|
16
|
-
if (__hasOwnProp.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
if (__getOwnPropSymbols)
|
|
19
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
-
if (__propIsEnum.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
}
|
|
23
|
-
return a;
|
|
24
|
-
};
|
|
25
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
-
function useNotificationsState({ limit }) {
|
|
27
|
-
const { state, queue, update, cleanQueue } = hooks.useQueue({
|
|
28
|
-
initialValues: [],
|
|
29
|
-
limit
|
|
30
|
-
});
|
|
31
|
-
const showNotification = (notification) => {
|
|
32
|
-
const id = notification.id || hooks.randomId();
|
|
33
|
-
update((notifications) => {
|
|
34
|
-
if (notification.id && notifications.some((n) => n.id === notification.id)) {
|
|
35
|
-
return notifications;
|
|
36
|
-
}
|
|
37
|
-
return [...notifications, __spreadProps(__spreadValues({}, notification), { id })];
|
|
38
|
-
});
|
|
39
|
-
return id;
|
|
40
|
-
};
|
|
41
|
-
const updateNotification = (notification) => update((notifications) => {
|
|
42
|
-
const index = notifications.findIndex((n) => n.id === notification.id);
|
|
43
|
-
if (index === -1) {
|
|
44
|
-
return notifications;
|
|
45
|
-
}
|
|
46
|
-
const newNotifications = [...notifications];
|
|
47
|
-
newNotifications[index] = notification;
|
|
48
|
-
return newNotifications;
|
|
49
|
-
});
|
|
50
|
-
const hideNotification = (id) => update((notifications) => notifications.filter((notification) => {
|
|
51
|
-
if (notification.id === id) {
|
|
52
|
-
typeof notification.onClose === "function" && notification.onClose(notification);
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}));
|
|
57
|
-
const clean = () => update(() => []);
|
|
58
|
-
return {
|
|
59
|
-
notifications: state,
|
|
60
|
-
queue,
|
|
61
|
-
showNotification,
|
|
62
|
-
updateNotification,
|
|
63
|
-
hideNotification,
|
|
64
|
-
cleanQueue,
|
|
65
|
-
clean
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
exports.default = useNotificationsState;
|
|
70
|
-
//# sourceMappingURL=use-notifications-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-notifications-state.js","sources":["../../../src/Notifications/use-notifications-state/use-notifications-state.ts"],"sourcesContent":["import { useQueue, randomId } from '@mantine/hooks';\nimport { NotificationProps } from '../../types';\n\nexport default function useNotificationsState({ limit }: { limit: number }) {\n const { state, queue, update, cleanQueue } = useQueue<NotificationProps>({\n initialValues: [],\n limit,\n });\n\n const showNotification = (notification: NotificationProps) => {\n const id = notification.id || randomId();\n\n update((notifications) => {\n if (notification.id && notifications.some((n) => n.id === notification.id)) {\n return notifications;\n }\n\n return [...notifications, { ...notification, id }];\n });\n\n return id;\n };\n\n const updateNotification = (notification: NotificationProps) =>\n update((notifications) => {\n const index = notifications.findIndex((n) => n.id === notification.id);\n\n if (index === -1) {\n return notifications;\n }\n\n const newNotifications = [...notifications];\n newNotifications[index] = notification;\n\n return newNotifications;\n });\n\n const hideNotification = (id: string) =>\n update((notifications) =>\n notifications.filter((notification) => {\n if (notification.id === id) {\n typeof notification.onClose === 'function' && notification.onClose(notification);\n return false;\n }\n\n return true;\n })\n );\n\n const clean = () => update(() => []);\n\n return {\n notifications: state,\n queue,\n showNotification,\n updateNotification,\n hideNotification,\n cleanQueue,\n clean,\n };\n}\n"],"names":["useQueue","randomId"],"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,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,C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a,CAAC;AAC3B,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;AAChD,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC;AAC3C,IAAI,OAAO,gBAAgB,CAAC;AAC5B,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,gBAAgB,GAAG,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,KAAK;AACpG,IAAI,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE;AAChC,MAAM,OAAO,YAAY,CAAC,OAAO,KAAK,UAAU,IAAI,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACvF,MAAM,OAAO,KAAK,CAAC;AACnB,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG,CAAC,CAAC,CAAC;AACN,EAAE,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,EAAE,OAAO;AACT,IAAI,aAAa,EAAE,KAAK;AACxB,IAAI,KAAK;AACT,IAAI,gBAAgB;AACpB,IAAI,kBAAkB;AACtB,IAAI,gBAAgB;AACpB,IAAI,UAAU;AACd,IAAI,KAAK;AACT,GAAG,CAAC;AACJ;;;;"}
|
package/cjs/events.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var utils = require('@mantine/utils');
|
|
6
|
-
|
|
7
|
-
const [useNotificationsEvents, createEvent] = utils.createUseExternalEvents("mantine-notifications");
|
|
8
|
-
const showNotification = createEvent("show");
|
|
9
|
-
const hideNotification = createEvent("hide");
|
|
10
|
-
const cleanNotifications = createEvent("clean");
|
|
11
|
-
const cleanNotificationsQueue = createEvent("cleanQueue");
|
|
12
|
-
const updateNotification = createEvent("update");
|
|
13
|
-
const notifications = {
|
|
14
|
-
show: showNotification,
|
|
15
|
-
hide: hideNotification,
|
|
16
|
-
clean: cleanNotifications,
|
|
17
|
-
cleanQueue: cleanNotificationsQueue,
|
|
18
|
-
update: updateNotification
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.cleanNotifications = cleanNotifications;
|
|
22
|
-
exports.cleanNotificationsQueue = cleanNotificationsQueue;
|
|
23
|
-
exports.createEvent = createEvent;
|
|
24
|
-
exports.hideNotification = hideNotification;
|
|
25
|
-
exports.notifications = notifications;
|
|
26
|
-
exports.showNotification = showNotification;
|
|
27
|
-
exports.updateNotification = updateNotification;
|
|
28
|
-
exports.useNotificationsEvents = useNotificationsEvents;
|
|
29
|
-
//# sourceMappingURL=events.js.map
|
package/cjs/events.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/utils';\nimport type { NotificationProps } from './types';\n\nexport type NotificationsEvents = {\n show(notification: NotificationProps): void;\n hide(id: string): void;\n update(notification: NotificationProps & { id: string }): void;\n clean(): void;\n cleanQueue(): void;\n};\n\nexport const [useNotificationsEvents, createEvent] =\n createUseExternalEvents<NotificationsEvents>('mantine-notifications');\n\nexport const showNotification = createEvent('show');\nexport const hideNotification = createEvent('hide');\nexport const cleanNotifications = createEvent('clean');\nexport const cleanNotificationsQueue = createEvent('cleanQueue');\nexport const updateNotification = createEvent('update');\n\nexport const notifications: NotificationsEvents = {\n show: showNotification,\n hide: hideNotification,\n clean: cleanNotifications,\n cleanQueue: cleanNotificationsQueue,\n update: updateNotification,\n};\n"],"names":["createUseExternalEvents"],"mappings":";;;;;;AACY,MAAC,CAAC,sBAAsB,EAAE,WAAW,CAAC,GAAGA,6BAAuB,CAAC,uBAAuB,EAAE;AAC1F,MAAC,gBAAgB,GAAG,WAAW,CAAC,MAAM,EAAE;AACxC,MAAC,gBAAgB,GAAG,WAAW,CAAC,MAAM,EAAE;AACxC,MAAC,kBAAkB,GAAG,WAAW,CAAC,OAAO,EAAE;AAC3C,MAAC,uBAAuB,GAAG,WAAW,CAAC,YAAY,EAAE;AACrD,MAAC,kBAAkB,GAAG,WAAW,CAAC,QAAQ,EAAE;AAC5C,MAAC,aAAa,GAAG;AAC7B,EAAE,IAAI,EAAE,gBAAgB;AACxB,EAAE,IAAI,EAAE,gBAAgB;AACxB,EAAE,KAAK,EAAE,kBAAkB;AAC3B,EAAE,UAAU,EAAE,uBAAuB;AACrC,EAAE,MAAM,EAAE,kBAAkB;AAC5B;;;;;;;;;;;"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from 'react';
|
|
2
|
-
import { Notification } from '@mantine/core';
|
|
3
|
-
import getAutoClose from './get-auto-close/get-auto-close.js';
|
|
4
|
-
|
|
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, message } = _a2, notificationProps = __objRest(_a2, ["autoClose", "message"]);
|
|
49
|
-
const autoCloseTimeout = getAutoClose(autoClose, notificationAutoClose);
|
|
50
|
-
const hideTimeout = useRef();
|
|
51
|
-
const handleHide = () => {
|
|
52
|
-
onHide(notification.id);
|
|
53
|
-
window.clearTimeout(hideTimeout.current);
|
|
54
|
-
};
|
|
55
|
-
const cancelDelayedHide = () => {
|
|
56
|
-
clearTimeout(hideTimeout.current);
|
|
57
|
-
};
|
|
58
|
-
const handleDelayedHide = () => {
|
|
59
|
-
if (typeof autoCloseTimeout === "number") {
|
|
60
|
-
hideTimeout.current = window.setTimeout(handleHide, autoCloseTimeout);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (typeof notification.onOpen === "function") {
|
|
65
|
-
notification.onOpen(notification);
|
|
66
|
-
}
|
|
67
|
-
}, []);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
handleDelayedHide();
|
|
70
|
-
return cancelDelayedHide;
|
|
71
|
-
}, [autoClose, notification.autoClose]);
|
|
72
|
-
return /* @__PURE__ */ React.createElement(Notification, __spreadProps(__spreadValues(__spreadValues({}, notificationProps), others), {
|
|
73
|
-
onClose: handleHide,
|
|
74
|
-
onMouseEnter: cancelDelayedHide,
|
|
75
|
-
onMouseLeave: handleDelayedHide,
|
|
76
|
-
ref: innerRef
|
|
77
|
-
}), message);
|
|
78
|
-
}
|
|
79
|
-
NotificationContainer.displayName = "@mantine/notifications/NotificationContainer";
|
|
80
|
-
|
|
81
|
-
export default NotificationContainer;
|
|
82
|
-
//# sourceMappingURL=NotificationContainer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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, message, ...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 {message}\n </Notification>\n );\n}\n\nNotificationContainer.displayName = '@mantine/notifications/NotificationContainer';\n"],"names":[],"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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AAC,CAAC,CAAC;AAC1C,EAAE,uBAAuB,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC,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,OAAO,CAAC,CAAC;AACf,CAAC;AACD,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { Transition, TransitionGroup } from 'react-transition-group';
|
|
3
|
-
import { rem, getDefaultZIndex, Portal, Box } from '@mantine/core';
|
|
4
|
-
import { useForceUpdate, useReducedMotion, useDidUpdate } from '@mantine/hooks';
|
|
5
|
-
import { useNotificationsEvents, notifications } from '../events.js';
|
|
6
|
-
import getPositionStyles from './get-position-styles/get-position-styles.js';
|
|
7
|
-
import getNotificationStateStyles from './get-notification-state-styles/get-notification-state-styles.js';
|
|
8
|
-
import NotificationContainer from '../NotificationContainer/NotificationContainer.js';
|
|
9
|
-
import useStyles from './Notifications.styles.js';
|
|
10
|
-
import useNotificationsState from './use-notifications-state/use-notifications-state.js';
|
|
11
|
-
|
|
12
|
-
var __defProp = Object.defineProperty;
|
|
13
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
14
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
16
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
-
var __spreadValues = (a, b) => {
|
|
18
|
-
for (var prop in b || (b = {}))
|
|
19
|
-
if (__hasOwnProp.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
if (__getOwnPropSymbols)
|
|
22
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
23
|
-
if (__propIsEnum.call(b, prop))
|
|
24
|
-
__defNormalProp(a, prop, b[prop]);
|
|
25
|
-
}
|
|
26
|
-
return a;
|
|
27
|
-
};
|
|
28
|
-
var __objRest = (source, exclude) => {
|
|
29
|
-
var target = {};
|
|
30
|
-
for (var prop in source)
|
|
31
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
if (source != null && __getOwnPropSymbols)
|
|
34
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
35
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
36
|
-
target[prop] = source[prop];
|
|
37
|
-
}
|
|
38
|
-
return target;
|
|
39
|
-
};
|
|
40
|
-
const POSITIONS = [
|
|
41
|
-
"top-left",
|
|
42
|
-
"top-right",
|
|
43
|
-
"top-center",
|
|
44
|
-
"bottom-left",
|
|
45
|
-
"bottom-right",
|
|
46
|
-
"bottom-center"
|
|
47
|
-
];
|
|
48
|
-
const Notifications = (_a) => {
|
|
49
|
-
var _b = _a, {
|
|
50
|
-
className,
|
|
51
|
-
position = "bottom-right",
|
|
52
|
-
autoClose = 4e3,
|
|
53
|
-
transitionDuration = 250,
|
|
54
|
-
containerWidth = rem(440),
|
|
55
|
-
notificationMaxHeight = rem(200),
|
|
56
|
-
limit = 5,
|
|
57
|
-
zIndex = getDefaultZIndex("overlay"),
|
|
58
|
-
style,
|
|
59
|
-
children,
|
|
60
|
-
target
|
|
61
|
-
} = _b, others = __objRest(_b, [
|
|
62
|
-
"className",
|
|
63
|
-
"position",
|
|
64
|
-
"autoClose",
|
|
65
|
-
"transitionDuration",
|
|
66
|
-
"containerWidth",
|
|
67
|
-
"notificationMaxHeight",
|
|
68
|
-
"limit",
|
|
69
|
-
"zIndex",
|
|
70
|
-
"style",
|
|
71
|
-
"children",
|
|
72
|
-
"target"
|
|
73
|
-
]);
|
|
74
|
-
const forceUpdate = useForceUpdate();
|
|
75
|
-
const refs = useRef({});
|
|
76
|
-
const previousLength = useRef(0);
|
|
77
|
-
const {
|
|
78
|
-
notifications,
|
|
79
|
-
showNotification,
|
|
80
|
-
updateNotification,
|
|
81
|
-
hideNotification,
|
|
82
|
-
clean,
|
|
83
|
-
cleanQueue
|
|
84
|
-
} = useNotificationsState({ limit });
|
|
85
|
-
const { classes, cx, theme } = useStyles({ zIndex });
|
|
86
|
-
const shouldReduceMotion = useReducedMotion();
|
|
87
|
-
const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
|
|
88
|
-
const duration = reduceMotion ? 1 : transitionDuration;
|
|
89
|
-
const positioning = (POSITIONS.includes(position) ? position : "bottom-right").split("-");
|
|
90
|
-
useDidUpdate(() => {
|
|
91
|
-
if (notifications.length > previousLength.current) {
|
|
92
|
-
setTimeout(() => forceUpdate(), 0);
|
|
93
|
-
}
|
|
94
|
-
previousLength.current = notifications.length;
|
|
95
|
-
}, [notifications]);
|
|
96
|
-
useNotificationsEvents({
|
|
97
|
-
show: showNotification,
|
|
98
|
-
hide: hideNotification,
|
|
99
|
-
update: updateNotification,
|
|
100
|
-
clean,
|
|
101
|
-
cleanQueue
|
|
102
|
-
});
|
|
103
|
-
const items = notifications.map((notification) => /* @__PURE__ */ React.createElement(Transition, {
|
|
104
|
-
key: notification.id,
|
|
105
|
-
timeout: duration,
|
|
106
|
-
onEnter: () => refs.current[notification.id].offsetHeight,
|
|
107
|
-
nodeRef: { current: refs.current[notification.id] }
|
|
108
|
-
}, (state) => /* @__PURE__ */ React.createElement(NotificationContainer, {
|
|
109
|
-
innerRef: (node) => {
|
|
110
|
-
refs.current[notification.id] = node;
|
|
111
|
-
},
|
|
112
|
-
notification,
|
|
113
|
-
onHide: hideNotification,
|
|
114
|
-
className: classes.notification,
|
|
115
|
-
autoClose,
|
|
116
|
-
sx: [
|
|
117
|
-
__spreadValues({}, getNotificationStateStyles({
|
|
118
|
-
state,
|
|
119
|
-
positioning,
|
|
120
|
-
transitionDuration: duration,
|
|
121
|
-
maxHeight: notificationMaxHeight
|
|
122
|
-
})),
|
|
123
|
-
...Array.isArray(notification.sx) ? notification.sx : [notification.sx]
|
|
124
|
-
]
|
|
125
|
-
})));
|
|
126
|
-
return /* @__PURE__ */ React.createElement(Portal, {
|
|
127
|
-
target
|
|
128
|
-
}, /* @__PURE__ */ React.createElement(Box, __spreadValues({
|
|
129
|
-
className: cx(classes.notifications, className),
|
|
130
|
-
style,
|
|
131
|
-
sx: __spreadValues({
|
|
132
|
-
maxWidth: containerWidth
|
|
133
|
-
}, getPositionStyles(positioning, theme.spacing.md))
|
|
134
|
-
}, others), /* @__PURE__ */ React.createElement(TransitionGroup, null, items)));
|
|
135
|
-
};
|
|
136
|
-
Notifications.displayName = "@mantine/notifications/Notifications";
|
|
137
|
-
Notifications.show = notifications.show;
|
|
138
|
-
Notifications.hide = notifications.hide;
|
|
139
|
-
Notifications.update = notifications.update;
|
|
140
|
-
Notifications.clean = notifications.clean;
|
|
141
|
-
Notifications.cleanQueue = notifications.cleanQueue;
|
|
142
|
-
|
|
143
|
-
export { Notifications };
|
|
144
|
-
//# sourceMappingURL=Notifications.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Notifications.js","sources":["../../src/Notifications/Notifications.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Transition, TransitionGroup } from 'react-transition-group';\nimport { DefaultProps, Portal, getDefaultZIndex, Box, PortalProps, rem } from '@mantine/core';\nimport { useReducedMotion, useForceUpdate, useDidUpdate } from '@mantine/hooks';\nimport { NotificationsPositioning } from '../types';\nimport {\n notifications as GlobalNotifications,\n NotificationsEvents,\n useNotificationsEvents,\n} 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 './Notifications.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\ntype NotificationsStaticMethods = NotificationsEvents;\n\nexport interface NotificationsProps\n extends Omit<DefaultProps, 'style'>,\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 notifications.show function */\n autoClose?: number | false;\n\n /** Notification transitions duration, 0 to turn transitions off */\n transitionDuration?: number;\n\n /** Notification width, cannot exceed 100% */\n containerWidth?: number | string;\n\n /** Notification max-height, used for transitions */\n notificationMaxHeight?: number | string;\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?: React.CSSProperties['zIndex'];\n\n /** Target element of Portal component */\n target?: PortalProps['target'];\n}\n\nexport const Notifications: React.FC<NotificationsProps> & NotificationsStaticMethods = ({\n className,\n position = 'bottom-right',\n autoClose = 4000,\n transitionDuration = 250,\n containerWidth = rem(440),\n notificationMaxHeight = rem(200),\n limit = 5,\n zIndex = getDefaultZIndex('overlay'),\n style,\n children,\n target,\n ...others\n}) => {\n const forceUpdate = useForceUpdate();\n const refs = useRef<Record<string, HTMLDivElement>>({});\n const previousLength = useRef<number>(0);\n const {\n notifications,\n showNotification,\n updateNotification,\n hideNotification,\n clean,\n cleanQueue,\n } = useNotificationsState({ limit });\n\n const { classes, cx, theme } = useStyles({ zIndex });\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const duration = reduceMotion ? 1 : transitionDuration;\n const positioning = (POSITIONS.includes(position) ? position : 'bottom-right').split(\n '-'\n ) as NotificationsPositioning;\n\n useDidUpdate(() => {\n if (notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = notifications.length;\n }, [notifications]);\n\n useNotificationsEvents({\n show: showNotification,\n hide: hideNotification,\n update: updateNotification,\n clean,\n cleanQueue,\n });\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 <Portal target={target}>\n <Box\n className={cx(classes.notifications, className)}\n style={style}\n sx={{\n maxWidth: containerWidth,\n ...getPositionStyles(positioning, theme.spacing.md),\n }}\n {...others}\n >\n <TransitionGroup>{items}</TransitionGroup>\n </Box>\n </Portal>\n );\n};\n\nNotifications.displayName = '@mantine/notifications/Notifications';\nNotifications.show = GlobalNotifications.show;\nNotifications.hide = GlobalNotifications.hide;\nNotifications.update = GlobalNotifications.update;\nNotifications.clean = GlobalNotifications.clean;\nNotifications.cleanQueue = GlobalNotifications.cleanQueue;\n"],"names":["GlobalNotifications"],"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,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,C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