@mantine/notifications 9.6.3 → 9.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { notifications, showNotification, hideNotification, cleanNotifications, cleanNotificationsQueue, updateNotification, updateNotificationsState, createNotificationsStore, notificationsStore, useNotifications, } from './notifications.store.js';
1
+ export { notifications, showNotification, hideNotification, cleanNotifications, cleanNotificationsQueue, updateNotification, promiseNotification, updateNotificationsState, createNotificationsStore, notificationsStore, useNotifications, } from './notifications.store.js';
2
2
  export { Notifications } from './Notifications.js';
3
- export type { NotificationData, NotificationsState, NotificationsStore, } from './notifications.store';
3
+ export type { NotificationData, NotificationsState, NotificationsStore, PromiseNotificationData, PromiseNotificationOptions, } from './notifications.store';
4
4
  export type { NotificationsCssVariables, NotificationsFactory, NotificationsProps, NotificationsStylesNames, } from './Notifications';
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { notifications, showNotification, hideNotification, cleanNotifications, cleanNotificationsQueue, updateNotification, updateNotificationsState, createNotificationsStore, notificationsStore, useNotifications, } from './notifications.store.js';
1
+ export { notifications, showNotification, hideNotification, cleanNotifications, cleanNotificationsQueue, updateNotification, promiseNotification, updateNotificationsState, createNotificationsStore, notificationsStore, useNotifications, } from './notifications.store.js';
2
2
  export { Notifications } from './Notifications.js';
3
- export type { NotificationData, NotificationsState, NotificationsStore, } from './notifications.store';
3
+ export type { NotificationData, NotificationsState, NotificationsStore, PromiseNotificationData, PromiseNotificationOptions, } from './notifications.store';
4
4
  export type { NotificationsCssVariables, NotificationsFactory, NotificationsProps, NotificationsStylesNames, } from './Notifications';
@@ -18,6 +18,8 @@ export interface NotificationData extends Omit<NotificationProps, 'onClose'>, Re
18
18
  autoClose?: boolean | number;
19
19
  /** Determines whether notification can be closed with close button, drag or horizontal scroll swipe, `true` by default */
20
20
  allowClose?: boolean;
21
+ /** Determines whether a progress line that fills up until the notification auto closes is displayed at the bottom of the notification, overrides `withAutoCloseProgress` from `Notifications` */
22
+ withAutoCloseProgress?: boolean;
21
23
  /** Called when notification closes */
22
24
  onClose?: (props: NotificationData) => void;
23
25
  /** Called when notification opens */
@@ -42,12 +44,25 @@ export declare function updateNotificationsState(store: NotificationsStore, upda
42
44
  export declare function showNotification(notification: NotificationData, store?: NotificationsStore): string;
43
45
  export declare function hideNotification(id: string, store?: NotificationsStore): string;
44
46
  export declare function updateNotification(notification: NotificationData, store?: NotificationsStore): string | undefined;
47
+ export type PromiseNotificationData = Omit<NotificationData, 'id'>;
48
+ export interface PromiseNotificationOptions<T> {
49
+ /** Notification id, used for all three states, by default `id` is randomly generated */
50
+ id?: string;
51
+ /** Notification displayed while the promise is pending, `loading: true` and `autoClose: false` are applied by default */
52
+ loading: PromiseNotificationData;
53
+ /** Notification displayed when the promise resolves, `color: 'teal'` is applied by default. Function receives the resolved value. */
54
+ success: PromiseNotificationData | ((value: T) => PromiseNotificationData);
55
+ /** Notification displayed when the promise rejects, `color: 'red'` is applied by default. Function receives the rejection reason. */
56
+ error: PromiseNotificationData | ((error: unknown) => PromiseNotificationData);
57
+ }
58
+ export declare function promiseNotification<T>(promise: Promise<T>, options: PromiseNotificationOptions<T>, store?: NotificationsStore): Promise<T>;
45
59
  export declare function cleanNotifications(store?: NotificationsStore): void;
46
60
  export declare function cleanNotificationsQueue(store?: NotificationsStore): void;
47
61
  export declare const notifications: {
48
62
  readonly show: typeof showNotification;
49
63
  readonly hide: typeof hideNotification;
50
64
  readonly update: typeof updateNotification;
65
+ readonly promise: typeof promiseNotification;
51
66
  readonly clean: typeof cleanNotifications;
52
67
  readonly cleanQueue: typeof cleanNotificationsQueue;
53
68
  readonly updateState: typeof updateNotificationsState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/notifications",
3
- "version": "9.6.3",
3
+ "version": "9.7.1",
4
4
  "description": "Mantine notifications system",
5
5
  "homepage": "https://mantine.dev",
6
6
  "license": "MIT",
@@ -44,20 +44,20 @@
44
44
  "directory": "packages/@mantine/notifications"
45
45
  },
46
46
  "peerDependencies": {
47
- "@mantine/core": "9.6.3",
48
- "@mantine/hooks": "9.6.3",
47
+ "@mantine/core": "9.7.1",
48
+ "@mantine/hooks": "9.7.1",
49
49
  "react": "^19.2.0",
50
50
  "react-dom": "^19.2.0"
51
51
  },
52
52
  "dependencies": {
53
- "@mantine/store": "9.6.3",
53
+ "@mantine/store": "9.7.1",
54
54
  "react-transition-group": "4.4.5"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@mantine-tests/core": "workspace:*",
58
58
  "@mantine/core": "workspace:*",
59
59
  "@mantine/hooks": "workspace:*",
60
- "react": "19.2.8",
61
- "react-dom": "19.2.8"
60
+ "react": "19.3.0",
61
+ "react-dom": "19.3.0"
62
62
  }
63
63
  }
package/styles.css CHANGED
@@ -48,3 +48,43 @@
48
48
  .m_b37d9ac7:where([data-layout='stacked']) > * {
49
49
  display: grid;
50
50
  }
51
+
52
+ .m_836192 {
53
+ position: absolute;
54
+ bottom: 0;
55
+ inset-inline-start: 0;
56
+ width: 100%;
57
+ height: calc(0.1875rem * var(--mantine-scale));
58
+ background-color: var(--notification-color);
59
+ transform: scaleX(0);
60
+ transform-origin: left center;
61
+ transition: opacity 200ms ease;
62
+ animation:
63
+ m_5f780017 var(--notifications-progress-duration) linear forwards,
64
+ m_bb245a60 200ms ease;
65
+ }
66
+
67
+ [dir="rtl"] .m_836192 {
68
+ transform-origin: right center;
69
+ }
70
+
71
+ .m_836192:where([data-paused]) {
72
+ opacity: 0;
73
+ animation-play-state: paused, running;
74
+ }
75
+
76
+ @keyframes m_5f780017 {
77
+ from {
78
+ transform: scaleX(0);
79
+ }
80
+
81
+ to {
82
+ transform: scaleX(1);
83
+ }
84
+ }
85
+
86
+ @keyframes m_bb245a60 {
87
+ from {
88
+ opacity: 0;
89
+ }
90
+ }
package/styles.layer.css CHANGED
@@ -48,4 +48,44 @@
48
48
  .m_b37d9ac7:where([data-layout='stacked']) > * {
49
49
  display: grid;
50
50
  }
51
+
52
+ .m_836192 {
53
+ position: absolute;
54
+ bottom: 0;
55
+ inset-inline-start: 0;
56
+ width: 100%;
57
+ height: calc(0.1875rem * var(--mantine-scale));
58
+ background-color: var(--notification-color);
59
+ transform: scaleX(0);
60
+ transform-origin: left center;
61
+ transition: opacity 200ms ease;
62
+ animation:
63
+ m_5f780017 var(--notifications-progress-duration) linear forwards,
64
+ m_bb245a60 200ms ease;
65
+ }
66
+
67
+ [dir="rtl"] .m_836192 {
68
+ transform-origin: right center;
69
+ }
70
+
71
+ .m_836192:where([data-paused]) {
72
+ opacity: 0;
73
+ animation-play-state: paused, running;
74
+ }
75
+
76
+ @keyframes m_5f780017 {
77
+ from {
78
+ transform: scaleX(0);
79
+ }
80
+
81
+ to {
82
+ transform: scaleX(1);
83
+ }
84
+ }
85
+
86
+ @keyframes m_bb245a60 {
87
+ from {
88
+ opacity: 0;
89
+ }
90
+ }
51
91
  }