@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
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { TransitionGroup, Transition as Transition$1 } from 'react-transition-group';
|
|
3
|
+
import { useForceUpdate, useReducedMotion, useDidUpdate } from '@mantine/hooks';
|
|
4
|
+
import { getDefaultZIndex, createVarsResolver, rem, factory, useProps, useMantineTheme, useStyles, OptionalPortal, Box } from '@mantine/core';
|
|
5
|
+
import { notificationsStore, useNotifications, notifications, hideNotification } from './notifications.store.js';
|
|
6
|
+
import { NotificationContainer } from './NotificationContainer.js';
|
|
7
|
+
import { getNotificationStateStyles } from './get-notification-state-styles.js';
|
|
8
|
+
import classes from './Notifications.module.css.js';
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __defProps = Object.defineProperties;
|
|
12
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
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 __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
29
|
+
var __objRest = (source, exclude) => {
|
|
30
|
+
var target = {};
|
|
31
|
+
for (var prop in source)
|
|
32
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
if (source != null && __getOwnPropSymbols)
|
|
35
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
36
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
37
|
+
target[prop] = source[prop];
|
|
38
|
+
}
|
|
39
|
+
return target;
|
|
40
|
+
};
|
|
41
|
+
const Transition = Transition$1;
|
|
42
|
+
const defaultProps = {
|
|
43
|
+
position: "bottom-right",
|
|
44
|
+
autoClose: 4e3,
|
|
45
|
+
transitionDuration: 250,
|
|
46
|
+
containerWidth: 440,
|
|
47
|
+
notificationMaxHeight: 200,
|
|
48
|
+
limit: 5,
|
|
49
|
+
zIndex: getDefaultZIndex("overlay"),
|
|
50
|
+
store: notificationsStore,
|
|
51
|
+
withinPortal: true
|
|
52
|
+
};
|
|
53
|
+
const varsResolver = createVarsResolver(
|
|
54
|
+
(_, { zIndex, position, containerWidth }) => {
|
|
55
|
+
const [vertical, horizontal] = position.split("-");
|
|
56
|
+
return {
|
|
57
|
+
root: {
|
|
58
|
+
"--notifications-z-index": zIndex == null ? void 0 : zIndex.toString(),
|
|
59
|
+
"--notifications-top": vertical === "top" ? "var(--mantine-spacing-md)" : void 0,
|
|
60
|
+
"--notifications-bottom": vertical === "bottom" ? "var(--mantine-spacing-md)" : void 0,
|
|
61
|
+
"--notifications-left": horizontal === "left" ? "var(--mantine-spacing-md)" : horizontal === "center" ? "50%" : void 0,
|
|
62
|
+
"--notifications-right": horizontal === "right" ? "var(--mantine-spacing-md)" : void 0,
|
|
63
|
+
"--notifications-transform": horizontal === "center" ? "translateX(-50%)" : void 0,
|
|
64
|
+
"--notifications-container-width": rem(containerWidth)
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
const Notifications = factory((_props, ref) => {
|
|
70
|
+
const props = useProps("Notifications", defaultProps, _props);
|
|
71
|
+
const _a = props, {
|
|
72
|
+
classNames,
|
|
73
|
+
className,
|
|
74
|
+
style,
|
|
75
|
+
styles,
|
|
76
|
+
unstyled,
|
|
77
|
+
vars,
|
|
78
|
+
position,
|
|
79
|
+
autoClose,
|
|
80
|
+
transitionDuration,
|
|
81
|
+
containerWidth,
|
|
82
|
+
notificationMaxHeight,
|
|
83
|
+
limit,
|
|
84
|
+
zIndex,
|
|
85
|
+
store,
|
|
86
|
+
portalProps,
|
|
87
|
+
withinPortal
|
|
88
|
+
} = _a, others = __objRest(_a, [
|
|
89
|
+
"classNames",
|
|
90
|
+
"className",
|
|
91
|
+
"style",
|
|
92
|
+
"styles",
|
|
93
|
+
"unstyled",
|
|
94
|
+
"vars",
|
|
95
|
+
"position",
|
|
96
|
+
"autoClose",
|
|
97
|
+
"transitionDuration",
|
|
98
|
+
"containerWidth",
|
|
99
|
+
"notificationMaxHeight",
|
|
100
|
+
"limit",
|
|
101
|
+
"zIndex",
|
|
102
|
+
"store",
|
|
103
|
+
"portalProps",
|
|
104
|
+
"withinPortal"
|
|
105
|
+
]);
|
|
106
|
+
const theme = useMantineTheme();
|
|
107
|
+
const data = useNotifications(store);
|
|
108
|
+
const forceUpdate = useForceUpdate();
|
|
109
|
+
const shouldReduceMotion = useReducedMotion();
|
|
110
|
+
const refs = useRef({});
|
|
111
|
+
const previousLength = useRef(0);
|
|
112
|
+
const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
|
|
113
|
+
const duration = reduceMotion ? 1 : transitionDuration;
|
|
114
|
+
const getStyles = useStyles({
|
|
115
|
+
name: "Notifications",
|
|
116
|
+
classes,
|
|
117
|
+
props,
|
|
118
|
+
className,
|
|
119
|
+
style,
|
|
120
|
+
classNames,
|
|
121
|
+
styles,
|
|
122
|
+
unstyled,
|
|
123
|
+
vars,
|
|
124
|
+
varsResolver
|
|
125
|
+
});
|
|
126
|
+
useDidUpdate(() => {
|
|
127
|
+
if (data.notifications.length > previousLength.current) {
|
|
128
|
+
setTimeout(() => forceUpdate(), 0);
|
|
129
|
+
}
|
|
130
|
+
previousLength.current = data.notifications.length;
|
|
131
|
+
}, [notifications]);
|
|
132
|
+
const items = data.notifications.map((notification) => /* @__PURE__ */ React.createElement(
|
|
133
|
+
Transition,
|
|
134
|
+
{
|
|
135
|
+
key: notification.id,
|
|
136
|
+
timeout: duration,
|
|
137
|
+
onEnter: () => refs.current[notification.id].offsetHeight,
|
|
138
|
+
nodeRef: { current: refs.current[notification.id] }
|
|
139
|
+
},
|
|
140
|
+
(state) => /* @__PURE__ */ React.createElement(
|
|
141
|
+
NotificationContainer,
|
|
142
|
+
__spreadProps(__spreadValues({}, getStyles("notification", {
|
|
143
|
+
style: getNotificationStateStyles({
|
|
144
|
+
state,
|
|
145
|
+
position,
|
|
146
|
+
transitionDuration: duration,
|
|
147
|
+
maxHeight: notificationMaxHeight
|
|
148
|
+
})
|
|
149
|
+
})), {
|
|
150
|
+
ref: (node) => {
|
|
151
|
+
refs.current[notification.id] = node;
|
|
152
|
+
},
|
|
153
|
+
data: notification,
|
|
154
|
+
onHide: (id) => hideNotification(id, store),
|
|
155
|
+
autoClose
|
|
156
|
+
})
|
|
157
|
+
)
|
|
158
|
+
));
|
|
159
|
+
return /* @__PURE__ */ React.createElement(OptionalPortal, __spreadValues({ withinPortal }, portalProps), /* @__PURE__ */ React.createElement(Box, __spreadValues(__spreadProps(__spreadValues({}, getStyles("root")), { ref }), others), /* @__PURE__ */ React.createElement(TransitionGroup, null, items)));
|
|
160
|
+
});
|
|
161
|
+
Notifications.classes = classes;
|
|
162
|
+
Notifications.displayName = "@mantine/notifications/Notifications";
|
|
163
|
+
Notifications.show = notifications.show;
|
|
164
|
+
Notifications.hide = notifications.hide;
|
|
165
|
+
Notifications.update = notifications.update;
|
|
166
|
+
Notifications.clean = notifications.clean;
|
|
167
|
+
Notifications.cleanQueue = notifications.cleanQueue;
|
|
168
|
+
Notifications.updateState = notifications.updateState;
|
|
169
|
+
|
|
170
|
+
export { Notifications };
|
|
171
|
+
//# sourceMappingURL=Notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifications.js","sources":["../src/Notifications.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport {\n Transition as _Transition,\n TransitionGroup,\n TransitionStatus,\n} from 'react-transition-group';\nimport { useForceUpdate, useDidUpdate, useReducedMotion } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n StylesApiProps,\n factory,\n ElementProps,\n useProps,\n useStyles,\n createVarsResolver,\n Factory,\n PortalProps,\n getDefaultZIndex,\n useMantineTheme,\n OptionalPortal,\n rem,\n} from '@mantine/core';\nimport {\n useNotifications,\n NotificationsStore,\n notificationsStore,\n hideNotification,\n notifications,\n} from './notifications.store';\nimport { NotificationContainer } from './NotificationContainer';\nimport { getNotificationStateStyles } from './get-notification-state-styles';\nimport classes from './Notifications.module.css';\n\nconst Transition: any = _Transition;\n\nexport type NotificationsStylesNames = 'root' | 'notification';\nexport type NotificationsVariant = string;\nexport type NotificationsCssVariables = {\n root:\n | '--notifications-z-index'\n | '--notifications-top'\n | '--notifications-right'\n | '--notifications-left'\n | '--notifications-left'\n | '--notifications-transform'\n | '--notifications-container-width';\n};\n\nexport interface NotificationsProps\n extends BoxProps,\n StylesApiProps<NotificationsFactory>,\n ElementProps<'div'> {\n /** Notifications position, `'bottom-right'` by default */\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 in ms, `false` to disable auto close, can be overwritten for individual notifications in `notifications.show` function, `4000` by defualt */\n autoClose?: number | false;\n\n /** Notification transition duration in ms, `250` by default */\n transitionDuration?: number;\n\n /** Notification width, cannot exceed 100%, `440` by default */\n containerWidth?: number | string;\n\n /** Notification `max-height`, used for transitions, `200` by default */\n notificationMaxHeight?: number | string;\n\n /** Maximum number of notifications displayed at a time, other new notifications will be added to queue, `5` by default */\n limit?: number;\n\n /** Notifications container z-index, `400` by default */\n zIndex?: React.CSSProperties['zIndex'];\n\n /** Props passed down to the `Portal` component */\n portalProps?: Omit<PortalProps, 'children'>;\n\n /** Store for notifications state, can be used to create multiple instances of notifications system in your application */\n store?: NotificationsStore;\n\n /** Determines whether notifications container should be rendered inside `Portal`, `true` by default */\n withinPortal?: boolean;\n}\n\nexport type NotificationsFactory = Factory<{\n props: NotificationsProps;\n ref: HTMLDivElement;\n stylesNames: NotificationsStylesNames;\n vars: NotificationsCssVariables;\n variant: NotificationsVariant;\n staticComponents: {\n show: typeof notifications.show;\n hide: typeof notifications.hide;\n update: typeof notifications.update;\n clean: typeof notifications.clean;\n cleanQueue: typeof notifications.cleanQueue;\n updateState: typeof notifications.updateState;\n };\n}>;\n\nconst defaultProps: Partial<NotificationsProps> = {\n position: 'bottom-right',\n autoClose: 4000,\n transitionDuration: 250,\n containerWidth: 440,\n notificationMaxHeight: 200,\n limit: 5,\n zIndex: getDefaultZIndex('overlay'),\n store: notificationsStore,\n withinPortal: true,\n};\n\nconst varsResolver = createVarsResolver<NotificationsFactory>(\n (_, { zIndex, position, containerWidth }) => {\n const [vertical, horizontal] = position!.split('-');\n\n return {\n root: {\n '--notifications-z-index': zIndex?.toString(),\n '--notifications-top': vertical === 'top' ? 'var(--mantine-spacing-md)' : undefined,\n '--notifications-bottom': vertical === 'bottom' ? 'var(--mantine-spacing-md)' : undefined,\n '--notifications-left':\n horizontal === 'left'\n ? 'var(--mantine-spacing-md)'\n : horizontal === 'center'\n ? '50%'\n : undefined,\n '--notifications-right': horizontal === 'right' ? 'var(--mantine-spacing-md)' : undefined,\n '--notifications-transform': horizontal === 'center' ? 'translateX(-50%)' : undefined,\n '--notifications-container-width': rem(containerWidth),\n },\n };\n }\n);\n\nexport const Notifications = factory<NotificationsFactory>((_props, ref) => {\n const props = useProps('Notifications', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n position,\n autoClose,\n transitionDuration,\n containerWidth,\n notificationMaxHeight,\n limit,\n zIndex,\n store,\n portalProps,\n withinPortal,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n const data = useNotifications(store);\n const forceUpdate = useForceUpdate();\n const shouldReduceMotion = useReducedMotion();\n const refs = useRef<Record<string, HTMLDivElement>>({});\n const previousLength = useRef<number>(0);\n\n const reduceMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const duration = reduceMotion ? 1 : transitionDuration;\n\n const getStyles = useStyles<NotificationsFactory>({\n name: 'Notifications',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n vars,\n varsResolver,\n });\n\n useDidUpdate(() => {\n if (data.notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = data.notifications.length;\n }, [notifications]);\n\n const items = data.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: TransitionStatus) => (\n <NotificationContainer\n {...getStyles('notification', {\n style: getNotificationStateStyles({\n state,\n position,\n transitionDuration: duration!,\n maxHeight: notificationMaxHeight!,\n }),\n })}\n ref={(node) => {\n refs.current[notification.id!] = node!;\n }}\n data={notification}\n onHide={(id) => hideNotification(id, store)}\n autoClose={autoClose!}\n />\n )}\n </Transition>\n ));\n\n return (\n <OptionalPortal withinPortal={withinPortal} {...portalProps}>\n <Box {...getStyles('root')} ref={ref} {...others}>\n <TransitionGroup>{items}</TransitionGroup>\n </Box>\n </OptionalPortal>\n );\n});\n\nNotifications.classes = classes;\nNotifications.displayName = '@mantine/notifications/Notifications';\nNotifications.show = notifications.show;\nNotifications.hide = notifications.hide;\nNotifications.update = notifications.update;\nNotifications.clean = notifications.clean;\nNotifications.cleanQueue = notifications.cleanQueue;\nNotifications.updateState = notifications.updateState;\n"],"names":["_Transition"],"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,GA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AAC5C,aAAa,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;AAC1C,aAAa,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;AACpD,aAAa,CAAC,WAAW,GAAG,aAAa,CAAC,WAAW;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifications.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-auto-close.js","sources":["../../src/get-auto-close/get-auto-close.ts"],"sourcesContent":["export function getAutoClose(\n autoClose: boolean | number | undefined,\n notificationAutoClose: boolean | number | undefined\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":"AAAO,SAAS,YAAY,CAAC,SAAS,EAAE,qBAAqB,EAAE;AAC/D,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;;;;"}
|
|
@@ -29,10 +29,10 @@ const noTransform = {
|
|
|
29
29
|
function getNotificationStateStyles({
|
|
30
30
|
state,
|
|
31
31
|
maxHeight,
|
|
32
|
-
|
|
32
|
+
position,
|
|
33
33
|
transitionDuration
|
|
34
34
|
}) {
|
|
35
|
-
const [vertical, horizontal] =
|
|
35
|
+
const [vertical, horizontal] = position.split("-");
|
|
36
36
|
const property = horizontal === "center" ? `${vertical}-center` : horizontal;
|
|
37
37
|
const commonStyles = {
|
|
38
38
|
opacity: 0,
|
|
@@ -60,5 +60,5 @@ function getNotificationStateStyles({
|
|
|
60
60
|
return __spreadValues(__spreadValues({}, commonStyles), transitionStyles[state]);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export
|
|
63
|
+
export { getNotificationStateStyles };
|
|
64
64
|
//# sourceMappingURL=get-notification-state-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-notification-state-styles.js","sources":["../src/get-notification-state-styles.ts"],"sourcesContent":["import { TransitionStatus } from 'react-transition-group';\nimport type { NotificationsProps } from './Notifications';\n\ninterface NotificationStateStylesProps {\n state: TransitionStatus;\n maxHeight: number | string;\n position: NotificationsProps['position'];\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 function getNotificationStateStyles({\n state,\n maxHeight,\n position,\n transitionDuration,\n}: NotificationStateStylesProps): React.CSSProperties {\n const [vertical, horizontal] = position!.split('-');\n const property = (\n horizontal === 'center' ? `${vertical}-center` : horizontal\n ) as keyof typeof transforms;\n\n const commonStyles: React.CSSProperties = {\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: React.CSSProperties = {\n opacity: 1,\n transform: noTransform[property],\n };\n\n const outState: React.CSSProperties = {\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 as keyof typeof transitionStyles] };\n}\n"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;A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;AACpB,GAAG,CAAC;AACJ,EAAE,OAAO,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;AACnF;;;;"}
|
package/esm/index.css
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.mantine-AvnBpXo {
|
|
2
|
+
width: calc(100% - var(--mantine-spacing-md) * 2);
|
|
3
|
+
position: fixed;
|
|
4
|
+
z-index: var(--notifications-z-index);
|
|
5
|
+
top: var(--notifications-top);
|
|
6
|
+
left: var(--notifications-left);
|
|
7
|
+
right: var(--notifications-right);
|
|
8
|
+
bottom: var(--notifications-bottom);
|
|
9
|
+
transform: var(--notifications-transform);
|
|
10
|
+
max-width: var(--notifications-container-width);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.mantine-V8o1rqk + .mantine-V8o1rqk {
|
|
14
|
+
margin-top: var(--mantine-spacing-md);
|
|
15
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { cleanNotifications, cleanNotificationsQueue, hideNotification, notifications, showNotification, updateNotification } from './
|
|
1
|
+
'use client';
|
|
2
|
+
export { cleanNotifications, cleanNotificationsQueue, createNotificationsStore, hideNotification, notifications, notificationsStore, showNotification, updateNotification, updateNotificationsState, useNotifications } from './notifications.store.js';
|
|
3
|
+
export { Notifications } from './Notifications.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":";;"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { randomId } from '@mantine/hooks';
|
|
2
|
+
import { createStore, useStore } from '@mantine/store';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
const createNotificationsStore = () => createStore({
|
|
24
|
+
notifications: [],
|
|
25
|
+
queue: [],
|
|
26
|
+
limit: 5
|
|
27
|
+
});
|
|
28
|
+
const notificationsStore = createNotificationsStore();
|
|
29
|
+
const useNotifications = (store = notificationsStore) => useStore(store);
|
|
30
|
+
function updateNotificationsState(store, update) {
|
|
31
|
+
const state = store.getState();
|
|
32
|
+
const notifications2 = update([...state.notifications, ...state.queue]);
|
|
33
|
+
store.setState({
|
|
34
|
+
notifications: notifications2.slice(0, state.limit),
|
|
35
|
+
queue: notifications2.slice(state.limit),
|
|
36
|
+
limit: state.limit
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function showNotification(notification, store = notificationsStore) {
|
|
40
|
+
const id = notification.id || randomId();
|
|
41
|
+
updateNotificationsState(store, (notifications2) => {
|
|
42
|
+
if (notification.id && notifications2.some((n) => n.id === notification.id)) {
|
|
43
|
+
return notifications2;
|
|
44
|
+
}
|
|
45
|
+
return [...notifications2, __spreadProps(__spreadValues({}, notification), { id })];
|
|
46
|
+
});
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
49
|
+
function hideNotification(id, store = notificationsStore) {
|
|
50
|
+
updateNotificationsState(
|
|
51
|
+
store,
|
|
52
|
+
(notifications2) => notifications2.filter((notification) => {
|
|
53
|
+
var _a;
|
|
54
|
+
if (notification.id === id) {
|
|
55
|
+
(_a = notification.onClose) == null ? void 0 : _a.call(notification, notification);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
return id;
|
|
62
|
+
}
|
|
63
|
+
function updateNotification(notification, store = notificationsStore) {
|
|
64
|
+
updateNotificationsState(
|
|
65
|
+
store,
|
|
66
|
+
(notifications2) => notifications2.map((item) => {
|
|
67
|
+
if (item.id === notification.id) {
|
|
68
|
+
return __spreadValues(__spreadValues({}, item), notification);
|
|
69
|
+
}
|
|
70
|
+
return item;
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
return notification.id;
|
|
74
|
+
}
|
|
75
|
+
function cleanNotifications(store = notificationsStore) {
|
|
76
|
+
updateNotificationsState(store, () => []);
|
|
77
|
+
}
|
|
78
|
+
function cleanNotificationsQueue(store = notificationsStore) {
|
|
79
|
+
updateNotificationsState(
|
|
80
|
+
store,
|
|
81
|
+
(notifications2) => notifications2.slice(0, store.getState().limit)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const notifications = {
|
|
85
|
+
show: showNotification,
|
|
86
|
+
hide: hideNotification,
|
|
87
|
+
update: updateNotification,
|
|
88
|
+
clean: cleanNotifications,
|
|
89
|
+
cleanQueue: cleanNotificationsQueue,
|
|
90
|
+
updateState: updateNotificationsState
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { cleanNotifications, cleanNotificationsQueue, createNotificationsStore, hideNotification, notifications, notificationsStore, showNotification, updateNotification, updateNotificationsState, useNotifications };
|
|
94
|
+
//# sourceMappingURL=notifications.store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.store.js","sources":["../src/notifications.store.ts"],"sourcesContent":["import { NotificationProps } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport { createStore, useStore, MantineStore } from '@mantine/store';\n\nexport interface NotificationData extends Omit<NotificationProps, 'onClose'> {\n /** Notification id, can be used to close or update notification */\n id?: string;\n\n /** Notification message, required for all notifications */\n message: React.ReactNode;\n\n /** Determines whether notification should be closed automatically,\n * number is auto close timeout in ms, overrides `autoClose` from `Notifications`\n * */\n autoClose?: boolean | number;\n\n /** Called when notification closes */\n onClose?(props: NotificationData): void;\n\n /** Called when notification opens */\n onOpen?(props: NotificationData): void;\n}\n\nexport interface NotificationsState {\n notifications: NotificationData[];\n queue: NotificationData[];\n limit: number;\n}\n\nexport type NotificationsStore = MantineStore<NotificationsState>;\n\nexport const createNotificationsStore = () =>\n createStore<NotificationsState>({\n notifications: [],\n queue: [],\n limit: 5,\n });\n\nexport const notificationsStore = createNotificationsStore();\nexport const useNotifications = (store: NotificationsStore = notificationsStore) => useStore(store);\n\nexport function updateNotificationsState(\n store: NotificationsStore,\n update: (notifications: NotificationData[]) => NotificationData[]\n) {\n const state = store.getState();\n const notifications = update([...state.notifications, ...state.queue]);\n\n store.setState({\n notifications: notifications.slice(0, state.limit),\n queue: notifications.slice(state.limit),\n limit: state.limit,\n });\n}\n\nexport function showNotification(\n notification: NotificationData,\n store: NotificationsStore = notificationsStore\n) {\n const id = notification.id || randomId();\n\n updateNotificationsState(store, (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\nexport function hideNotification(id: string, store: NotificationsStore = notificationsStore) {\n updateNotificationsState(store, (notifications) =>\n notifications.filter((notification) => {\n if (notification.id === id) {\n notification.onClose?.(notification);\n return false;\n }\n\n return true;\n })\n );\n\n return id;\n}\n\nexport function updateNotification(\n notification: NotificationData,\n store: NotificationsStore = notificationsStore\n) {\n updateNotificationsState(store, (notifications) =>\n notifications.map((item) => {\n if (item.id === notification.id) {\n return { ...item, ...notification };\n }\n\n return item;\n })\n );\n\n return notification.id;\n}\n\nexport function cleanNotifications(store: NotificationsStore = notificationsStore) {\n updateNotificationsState(store, () => []);\n}\n\nexport function cleanNotificationsQueue(store: NotificationsStore = notificationsStore) {\n updateNotificationsState(store, (notifications) =>\n notifications.slice(0, store.getState().limit)\n );\n}\n\nexport const notifications = {\n show: showNotification,\n hide: hideNotification,\n update: updateNotification,\n clean: cleanNotifications,\n cleanQueue: cleanNotificationsQueue,\n updateState: updateNotificationsState,\n} as const;\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;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AACZ,CAAC;AACM,SAAS,kBAAkB,CAAC,YAAY,EAAE,KAAK,GAAG,kBAAkB,EAAE;AAC7E,EAAE,wBAAwB;AAC1B,IAAI,KAAK;AACT,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK;AACrD,MAAM,IAAI,IAAI,CAAC,EAAE,KAAK,YAAY,CAAC,EAAE,EAAE;AACvC,QAAQ,OAAO,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;AACtE,OAAO;AACP,MAAM,OAAO,IAAI,CAAC;AAClB,KAAK,CAAC;AACN,GAAG,CAAC;AACJ,EAAE,OAAO,YAAY,CAAC,EAAE,CAAC;AACzB,CAAC;AACM,SAAS,kBAAkB,CAAC,KAAK,GAAG,kBAAkB,EAAE;AAC/D,EAAE,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAC5C,CAAC;AACM,SAAS,uBAAuB,CAAC,KAAK,GAAG,kBAAkB,EAAE;AACpE,EAAE,wBAAwB;AAC1B,IAAI,KAAK;AACT,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC;AACvE,GAAG,CAAC;AACJ,CAAC;AACW,MAAC,aAAa,GAAG;AAC7B,EAAE,IAAI,EAAE,gBAAgB;AACxB,EAAE,IAAI,EAAE,gBAAgB;AACxB,EAAE,MAAM,EAAE,kBAAkB;AAC5B,EAAE,KAAK,EAAE,kBAAkB;AAC3B,EAAE,UAAU,EAAE,uBAAuB;AACrC,EAAE,WAAW,EAAE,wBAAwB;AACvC;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NotificationProps } from '@mantine/core';
|
|
3
|
+
import { NotificationData } from './notifications.store';
|
|
4
|
+
interface NotificationContainerProps extends NotificationProps {
|
|
5
|
+
data: NotificationData;
|
|
6
|
+
onHide(id: string): void;
|
|
7
|
+
autoClose: number | false;
|
|
8
|
+
}
|
|
9
|
+
export declare const NotificationContainer: React.ForwardRefExoticComponent<NotificationContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=NotificationContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationContainer.d.ts","sourceRoot":"","sources":["../src/NotificationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAgB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,UAAU,0BAA2B,SAAQ,iBAAiB;IAC5D,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;CAC3B;AAED,eAAO,MAAM,qBAAqB,mGAyCjC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BoxProps, StylesApiProps, ElementProps, Factory, PortalProps } from '@mantine/core';
|
|
3
|
+
import { NotificationsStore, notifications } from './notifications.store';
|
|
4
|
+
export type NotificationsStylesNames = 'root' | 'notification';
|
|
5
|
+
export type NotificationsVariant = string;
|
|
6
|
+
export type NotificationsCssVariables = {
|
|
7
|
+
root: '--notifications-z-index' | '--notifications-top' | '--notifications-right' | '--notifications-left' | '--notifications-left' | '--notifications-transform' | '--notifications-container-width';
|
|
8
|
+
};
|
|
9
|
+
export interface NotificationsProps extends BoxProps, StylesApiProps<NotificationsFactory>, ElementProps<'div'> {
|
|
10
|
+
/** Notifications position, `'bottom-right'` by default */
|
|
11
|
+
position?: 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center';
|
|
12
|
+
/** Auto close timeout for all notifications in ms, `false` to disable auto close, can be overwritten for individual notifications in `notifications.show` function, `4000` by defualt */
|
|
13
|
+
autoClose?: number | false;
|
|
14
|
+
/** Notification transition duration in ms, `250` by default */
|
|
15
|
+
transitionDuration?: number;
|
|
16
|
+
/** Notification width, cannot exceed 100%, `440` by default */
|
|
17
|
+
containerWidth?: number | string;
|
|
18
|
+
/** Notification `max-height`, used for transitions, `200` by default */
|
|
19
|
+
notificationMaxHeight?: number | string;
|
|
20
|
+
/** Maximum number of notifications displayed at a time, other new notifications will be added to queue, `5` by default */
|
|
21
|
+
limit?: number;
|
|
22
|
+
/** Notifications container z-index, `400` by default */
|
|
23
|
+
zIndex?: React.CSSProperties['zIndex'];
|
|
24
|
+
/** Props passed down to the `Portal` component */
|
|
25
|
+
portalProps?: Omit<PortalProps, 'children'>;
|
|
26
|
+
/** Store for notifications state, can be used to create multiple instances of notifications system in your application */
|
|
27
|
+
store?: NotificationsStore;
|
|
28
|
+
/** Determines whether notifications container should be rendered inside `Portal`, `true` by default */
|
|
29
|
+
withinPortal?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type NotificationsFactory = Factory<{
|
|
32
|
+
props: NotificationsProps;
|
|
33
|
+
ref: HTMLDivElement;
|
|
34
|
+
stylesNames: NotificationsStylesNames;
|
|
35
|
+
vars: NotificationsCssVariables;
|
|
36
|
+
variant: NotificationsVariant;
|
|
37
|
+
staticComponents: {
|
|
38
|
+
show: typeof notifications.show;
|
|
39
|
+
hide: typeof notifications.hide;
|
|
40
|
+
update: typeof notifications.update;
|
|
41
|
+
clean: typeof notifications.clean;
|
|
42
|
+
cleanQueue: typeof notifications.cleanQueue;
|
|
43
|
+
updateState: typeof notifications.updateState;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
export declare const Notifications: import("@mantine/core").MantineComponent<{
|
|
47
|
+
props: NotificationsProps;
|
|
48
|
+
ref: HTMLDivElement;
|
|
49
|
+
stylesNames: NotificationsStylesNames;
|
|
50
|
+
vars: NotificationsCssVariables;
|
|
51
|
+
variant: NotificationsVariant;
|
|
52
|
+
staticComponents: {
|
|
53
|
+
show: typeof notifications.show;
|
|
54
|
+
hide: typeof notifications.hide;
|
|
55
|
+
update: typeof notifications.update;
|
|
56
|
+
clean: typeof notifications.clean;
|
|
57
|
+
cleanQueue: typeof notifications.cleanQueue;
|
|
58
|
+
updateState: typeof notifications.updateState;
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
//# sourceMappingURL=Notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifications.d.ts","sourceRoot":"","sources":["../src/Notifications.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAOtC,OAAO,EAEL,QAAQ,EACR,cAAc,EAEd,YAAY,EAIZ,OAAO,EACP,WAAW,EAKZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,kBAAkB,EAGlB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAO/B,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,cAAc,CAAC;AAC/D,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAC1C,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EACA,yBAAyB,GACzB,qBAAqB,GACrB,uBAAuB,GACvB,sBAAsB,GACtB,sBAAsB,GACtB,2BAA2B,GAC3B,iCAAiC,CAAC;CACvC,CAAC;AAEF,MAAM,WAAW,kBACf,SAAQ,QAAQ,EACd,cAAc,CAAC,oBAAoB,CAAC,EACpC,YAAY,CAAC,KAAK,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,EACL,UAAU,GACV,WAAW,GACX,YAAY,GACZ,aAAa,GACb,cAAc,GACd,eAAe,CAAC;IAEpB,yLAAyL;IACzL,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE3B,+DAA+D;IAC/D,kBAAkB,CAAC,EAAE,MAAM,C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AM,CAAC;QACpC,KAAK,EAAE,OAAO,cAAc,KAAK,CAAC;QAClC,UAAU,EAAE,OAAO,cAAc,UAAU,CAAC;QAC5C,WAAW,EAAE,OAAO,cAAc,WAAW,CAAC;KAC/C;EA6HD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-auto-close.d.ts","sourceRoot":"","sources":["../../src/get-auto-close/get-auto-close.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAC1B,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,EACvC,qBAAqB,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,gCAWpD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TransitionStatus } from 'react-transition-group';
|
|
3
|
+
import type { NotificationsProps } from './Notifications';
|
|
4
|
+
interface NotificationStateStylesProps {
|
|
5
|
+
state: TransitionStatus;
|
|
6
|
+
maxHeight: number | string;
|
|
7
|
+
position: NotificationsProps['position'];
|
|
8
|
+
transitionDuration: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function getNotificationStateStyles({ state, maxHeight, position, transitionDuration, }: NotificationStateStylesProps): React.CSSProperties;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=get-notification-state-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-notification-state-styles.d.ts","sourceRoot":"","sources":["../src/get-notification-state-styles.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,UAAU,4BAA4B;IACpC,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACzC,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAgBD,wBAAgB,0BAA0B,CAAC,EACzC,KAAK,EACL,SAAS,EACT,QAAQ,EACR,kBAAkB,GACnB,EAAE,4BAA4B,GAAG,KAAK,CAAC,aAAa,CAkCpD"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export type {
|
|
4
|
-
export type { NotificationsProps } from './Notifications
|
|
1
|
+
export { notifications, showNotification, hideNotification, cleanNotifications, cleanNotificationsQueue, updateNotification, updateNotificationsState, createNotificationsStore, notificationsStore, useNotifications, } from './notifications.store';
|
|
2
|
+
export { Notifications } from './Notifications';
|
|
3
|
+
export type { NotificationData, NotificationsState, NotificationsStore, } from './notifications.store';
|
|
4
|
+
export type { NotificationsCssVariables, NotificationsFactory, NotificationsProps, NotificationsStylesNames, NotificationsVariant, } from './Notifications';
|
|
5
5
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { NotificationProps } from '@mantine/core';
|
|
3
|
+
import { MantineStore } from '@mantine/store';
|
|
4
|
+
export interface NotificationData extends Omit<NotificationProps, 'onClose'> {
|
|
5
|
+
/** Notification id, can be used to close or update notification */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Notification message, required for all notifications */
|
|
8
|
+
message: React.ReactNode;
|
|
9
|
+
/** Determines whether notification should be closed automatically,
|
|
10
|
+
* number is auto close timeout in ms, overrides `autoClose` from `Notifications`
|
|
11
|
+
* */
|
|
12
|
+
autoClose?: boolean | number;
|
|
13
|
+
/** Called when notification closes */
|
|
14
|
+
onClose?(props: NotificationData): void;
|
|
15
|
+
/** Called when notification opens */
|
|
16
|
+
onOpen?(props: NotificationData): void;
|
|
17
|
+
}
|
|
18
|
+
export interface NotificationsState {
|
|
19
|
+
notifications: NotificationData[];
|
|
20
|
+
queue: NotificationData[];
|
|
21
|
+
limit: number;
|
|
22
|
+
}
|
|
23
|
+
export type NotificationsStore = MantineStore<NotificationsState>;
|
|
24
|
+
export declare const createNotificationsStore: () => MantineStore<NotificationsState>;
|
|
25
|
+
export declare const notificationsStore: MantineStore<NotificationsState>;
|
|
26
|
+
export declare const useNotifications: (store?: NotificationsStore) => NotificationsState;
|
|
27
|
+
export declare function updateNotificationsState(store: NotificationsStore, update: (notifications: NotificationData[]) => NotificationData[]): void;
|
|
28
|
+
export declare function showNotification(notification: NotificationData, store?: NotificationsStore): string;
|
|
29
|
+
export declare function hideNotification(id: string, store?: NotificationsStore): string;
|
|
30
|
+
export declare function updateNotification(notification: NotificationData, store?: NotificationsStore): string | undefined;
|
|
31
|
+
export declare function cleanNotifications(store?: NotificationsStore): void;
|
|
32
|
+
export declare function cleanNotificationsQueue(store?: NotificationsStore): void;
|
|
33
|
+
export declare const notifications: {
|
|
34
|
+
readonly show: typeof showNotification;
|
|
35
|
+
readonly hide: typeof hideNotification;
|
|
36
|
+
readonly update: typeof updateNotification;
|
|
37
|
+
readonly clean: typeof cleanNotifications;
|
|
38
|
+
readonly cleanQueue: typeof cleanNotificationsQueue;
|
|
39
|
+
readonly updateState: typeof updateNotificationsState;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=notifications.store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.store.d.ts","sourceRoot":"","sources":["../src/notifications.store.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAyB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAErE,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC;IAC1E,mEAAmE;IACnE,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,2DAA2D;IAC3D,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IAEzB;;SAEK;IACL,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE7B,sCAAsC;IACtC,OAAO,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAExC,qCAAqC;IACrC,MAAM,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAClC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAElE,eAAO,MAAM,wBAAwB,wCAKjC,CAAC;AAEL,eAAO,MAAM,kBAAkB,kCAA6B,CAAC;AAC7D,eAAO,MAAM,gBAAgB,oDAAsE,CAAC;AAEpG,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,CAAC,aAAa,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,QAUlE;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,gBAAgB,EAC9B,KAAK,GAAE,kBAAuC,UAa/C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,kBAAuC,UAa1F;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,gBAAgB,EAC9B,KAAK,GAAE,kBAAuC,sBAa/C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,GAAE,kBAAuC,QAEhF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,GAAE,kBAAuC,QAIrF;AAED,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantine/notifications",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "7.0.0-alpha.13",
|
|
4
|
+
"types": "./lib/index.d.ts",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": "./esm/index.js",
|
|
8
|
+
"require": "./cjs/index.js",
|
|
9
|
+
"types": "./lib/index.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"./styles.css": "./esm/index.css"
|
|
12
|
+
},
|
|
8
13
|
"license": "MIT",
|
|
9
14
|
"author": "Vitaly Rtishchev <rtivital@gmail.com>",
|
|
10
15
|
"sideEffects": false,
|
|
11
|
-
"homepage": "https://mantine.dev
|
|
16
|
+
"homepage": "https://mantine.dev",
|
|
12
17
|
"repository": {
|
|
13
18
|
"url": "https://github.com/mantinedev/mantine.git",
|
|
14
19
|
"type": "git",
|
|
15
|
-
"directory": "src/mantine-
|
|
20
|
+
"directory": "src/mantine-store"
|
|
16
21
|
},
|
|
17
22
|
"keywords": [
|
|
18
23
|
"react",
|
|
@@ -28,14 +33,15 @@
|
|
|
28
33
|
"notification-system"
|
|
29
34
|
],
|
|
30
35
|
"peerDependencies": {
|
|
31
|
-
"@mantine/core": "
|
|
32
|
-
"@mantine/hooks": "
|
|
36
|
+
"@mantine/core": "7.0.0-alpha.13",
|
|
37
|
+
"@mantine/hooks": "7.0.0-alpha.13",
|
|
33
38
|
"react": ">=16.8.0",
|
|
34
39
|
"react-dom": ">=16.8.0"
|
|
35
40
|
},
|
|
36
41
|
"dependencies": {
|
|
42
|
+
"@mantine/store": "7.0.0-alpha.13",
|
|
37
43
|
"react-transition-group": "4.4.2",
|
|
38
|
-
"
|
|
44
|
+
"tslib": "^2.5.2"
|
|
39
45
|
},
|
|
40
46
|
"devDependencies": {}
|
|
41
47
|
}
|