@mantine/notifications 7.1.3 → 7.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationContainer.js","sources":["../src/NotificationContainer.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useEffect } from 'react';\nimport { Notification, NotificationProps } from '@mantine/core';\nimport { NotificationData } from './notifications.store';\nimport { getAutoClose } from './get-auto-close/get-auto-close';\n\ninterface NotificationContainerProps extends NotificationProps {\n data: NotificationData;\n onHide(id: string): void;\n autoClose: number | false;\n}\n\nexport const NotificationContainer = forwardRef<HTMLDivElement, NotificationContainerProps>(\n ({ data, onHide, autoClose, ...others }, ref) => {\n const { autoClose: _autoClose, message, ...notificationProps } = data;\n const autoCloseDuration = getAutoClose(autoClose, data.autoClose);\n const autoCloseTimeout = useRef<number>();\n\n const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);\n\n const handleHide = () => {\n onHide(data.id!);\n cancelAutoClose();\n };\n\n const handleAutoClose = () => {\n if (typeof autoCloseDuration === 'number') {\n autoCloseTimeout.current = window.setTimeout(handleHide, autoCloseDuration);\n }\n };\n\n useEffect(() => {\n data.onOpen?.(data);\n }, []);\n\n useEffect(() => {\n handleAutoClose();\n return cancelAutoClose;\n }, [autoCloseDuration]);\n\n return (\n <Notification\n {...others}\n {...notificationProps}\n onClose={handleHide}\n ref={ref}\n onMouseEnter={cancelAutoClose}\n onMouseLeave={handleAutoClose}\n >\n {message}\n </Notification>\n );\n }\n);\n\nNotificationContainer.displayName = '@mantine/notifications/NotificationContainer';\n"],"names":["forwardRef","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,IAA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.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useEffect } from 'react';\nimport { Notification, NotificationProps } from '@mantine/core';\nimport { NotificationData } from './notifications.store';\nimport { getAutoClose } from './get-auto-close/get-auto-close';\n\ninterface NotificationContainerProps extends NotificationProps {\n data: NotificationData;\n onHide: (id: string) => void;\n autoClose: number | false;\n}\n\nexport const NotificationContainer = forwardRef<HTMLDivElement, NotificationContainerProps>(\n ({ data, onHide, autoClose, ...others }, ref) => {\n const { autoClose: _autoClose, message, ...notificationProps } = data;\n const autoCloseDuration = getAutoClose(autoClose, data.autoClose);\n const autoCloseTimeout = useRef<number>();\n\n const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);\n\n const handleHide = () => {\n onHide(data.id!);\n cancelAutoClose();\n };\n\n const handleAutoClose = () => {\n if (typeof autoCloseDuration === 'number') {\n autoCloseTimeout.current = window.setTimeout(handleHide, autoCloseDuration);\n }\n };\n\n useEffect(() => {\n data.onOpen?.(data);\n }, []);\n\n useEffect(() => {\n handleAutoClose();\n return cancelAutoClose;\n }, [autoCloseDuration]);\n\n return (\n <Notification\n {...others}\n {...notificationProps}\n onClose={handleHide}\n ref={ref}\n onMouseEnter={cancelAutoClose}\n onMouseLeave={handleAutoClose}\n >\n {message}\n </Notification>\n );\n }\n);\n\nNotificationContainer.displayName = '@mantine/notifications/NotificationContainer';\n"],"names":["forwardRef","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;A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AM,eAAe,EAAE,CAAC;AACxB,KAAK,CAAC;AACN,IAAI,MAAM,eAAe,GAAG,MAAM;AAClC,MAAM,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;AACjD,QAAQ,gBAAgB,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AACpF,OAAO;AACP,KAAK,CAAC;AACN,IAAIC,eAAS,CAAC,MAAM;AACpB,MAAM,IAAI,GAAG,CAAC;AACd,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAClE,KAAK,EAAE,EAAE,CAAC,CAAC;AACX,IAAIA,eAAS,CAAC,MAAM;AACpB,MAAM,eAAe,EAAE,CAAC;AACxB,MAAM,OAAO,eAAe,CAAC;AAC7B,KAAK,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC5B,IAAI,uBAAuBC,cAAK,CAAC,aAAa;AAC9C,MAAMC,iBAAY;AAClB,MAAM,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,iBAAiB,CAAC,EAAE;AACnF,QAAQ,OAAO,EAAE,UAAU;AAC3B,QAAQ,GAAG;AACX,QAAQ,YAAY,EAAE,eAAe;AACrC,QAAQ,YAAY,EAAE,eAAe;AACrC,OAAO,CAAC;AACR,MAAM,OAAO;AACb,KAAK,CAAC;AACN,GAAG;AACH,EAAE;AACF,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;"}
@@ -1 +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":["createStore","store","useStore","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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C,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;;;;;;;;;;;"}
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":["createStore","store","useStore","randomId"],"mappings":";;;;;;;;AAAA,IAAI,SAA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AkB,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;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationContainer.mjs","sources":["../src/NotificationContainer.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useEffect } from 'react';\nimport { Notification, NotificationProps } from '@mantine/core';\nimport { NotificationData } from './notifications.store';\nimport { getAutoClose } from './get-auto-close/get-auto-close';\n\ninterface NotificationContainerProps extends NotificationProps {\n data: NotificationData;\n onHide(id: string): void;\n autoClose: number | false;\n}\n\nexport const NotificationContainer = forwardRef<HTMLDivElement, NotificationContainerProps>(\n ({ data, onHide, autoClose, ...others }, ref) => {\n const { autoClose: _autoClose, message, ...notificationProps } = data;\n const autoCloseDuration = getAutoClose(autoClose, data.autoClose);\n const autoCloseTimeout = useRef<number>();\n\n const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);\n\n const handleHide = () => {\n onHide(data.id!);\n cancelAutoClose();\n };\n\n const handleAutoClose = () => {\n if (typeof autoCloseDuration === 'number') {\n autoCloseTimeout.current = window.setTimeout(handleHide, autoCloseDuration);\n }\n };\n\n useEffect(() => {\n data.onOpen?.(data);\n }, []);\n\n useEffect(() => {\n handleAutoClose();\n return cancelAutoClose;\n }, [autoCloseDuration]);\n\n return (\n <Notification\n {...others}\n {...notificationProps}\n onClose={handleHide}\n ref={ref}\n onMouseEnter={cancelAutoClose}\n onMouseLeave={handleAutoClose}\n >\n {message}\n </Notification>\n );\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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a;AAC9C,MAAM,YAAY;AAClB,MAAM,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,iBAAiB,CAAC,EAAE;AACnF,QAAQ,OAAO,EAAE,UAAU;AAC3B,QAAQ,GAAG;AACX,QAAQ,YAAY,EAAE,eAAe;AACrC,QAAQ,YAAY,EAAE,eAAe;AACrC,OAAO,CAAC;AACR,MAAM,OAAO;AACb,KAAK,CAAC;AACN,GAAG;AACH,EAAE;AACF,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;"}
1
+ {"version":3,"file":"NotificationContainer.mjs","sources":["../src/NotificationContainer.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useEffect } from 'react';\nimport { Notification, NotificationProps } from '@mantine/core';\nimport { NotificationData } from './notifications.store';\nimport { getAutoClose } from './get-auto-close/get-auto-close';\n\ninterface NotificationContainerProps extends NotificationProps {\n data: NotificationData;\n onHide: (id: string) => void;\n autoClose: number | false;\n}\n\nexport const NotificationContainer = forwardRef<HTMLDivElement, NotificationContainerProps>(\n ({ data, onHide, autoClose, ...others }, ref) => {\n const { autoClose: _autoClose, message, ...notificationProps } = data;\n const autoCloseDuration = getAutoClose(autoClose, data.autoClose);\n const autoCloseTimeout = useRef<number>();\n\n const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);\n\n const handleHide = () => {\n onHide(data.id!);\n cancelAutoClose();\n };\n\n const handleAutoClose = () => {\n if (typeof autoCloseDuration === 'number') {\n autoCloseTimeout.current = window.setTimeout(handleHide, autoCloseDuration);\n }\n };\n\n useEffect(() => {\n data.onOpen?.(data);\n }, []);\n\n useEffect(() => {\n handleAutoClose();\n return cancelAutoClose;\n }, [autoCloseDuration]);\n\n return (\n <Notification\n {...others}\n {...notificationProps}\n onClose={handleHide}\n ref={ref}\n onMouseEnter={cancelAutoClose}\n onMouseLeave={handleAutoClose}\n >\n {message}\n </Notification>\n );\n }\n);\n\nNotificationContainer.displayName = '@mantine/notifications/Notification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,EAAE,eAAe;AACrC,OAAO,CAAC;AACR,MAAM,OAAO;AACb,KAAK,CAAC;AACN,GAAG;AACH,EAAE;AACF,qBAAqB,CAAC,WAAW,GAAG,8CAA8C;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.store.mjs","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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,CAAC;AACJ,EAAE,OAAO,EAAE,CAAC;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;;"}
1
+ {"version":3,"file":"notifications.store.mjs","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;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,CAA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AAY,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;;"}
@@ -3,7 +3,7 @@ import { NotificationProps } from '@mantine/core';
3
3
  import { NotificationData } from './notifications.store';
4
4
  interface NotificationContainerProps extends NotificationProps {
5
5
  data: NotificationData;
6
- onHide(id: string): void;
6
+ onHide: (id: string) => void;
7
7
  autoClose: number | false;
8
8
  }
9
9
  export declare const NotificationContainer: React.ForwardRefExoticComponent<NotificationContainerProps & React.RefAttributes<HTMLDivElement>>;
@@ -1 +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"}
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,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC;CAC3B;AAED,eAAO,MAAM,qBAAqB,mGAyCjC,CAAC"}
@@ -11,9 +11,9 @@ export interface NotificationData extends Omit<NotificationProps, 'onClose'> {
11
11
  * */
12
12
  autoClose?: boolean | number;
13
13
  /** Called when notification closes */
14
- onClose?(props: NotificationData): void;
14
+ onClose?: (props: NotificationData) => void;
15
15
  /** Called when notification opens */
16
- onOpen?(props: NotificationData): void;
16
+ onOpen?: (props: NotificationData) => void;
17
17
  }
18
18
  export interface NotificationsState {
19
19
  notifications: NotificationData[];
@@ -1 +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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uC,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,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/notifications",
3
- "version": "7.1.3",
3
+ "version": "7.1.4",
4
4
  "main": "./cjs/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "module": "./esm/index.mjs",
@@ -43,13 +43,13 @@
43
43
  "notification-system"
44
44
  ],
45
45
  "peerDependencies": {
46
- "@mantine/core": "7.1.3",
47
- "@mantine/hooks": "7.1.3",
46
+ "@mantine/core": "7.1.4",
47
+ "@mantine/hooks": "7.1.4",
48
48
  "react": "^18.2.0",
49
49
  "react-dom": "^18.2.0"
50
50
  },
51
51
  "dependencies": {
52
- "@mantine/store": "7.1.3",
52
+ "@mantine/store": "7.1.4",
53
53
  "react-transition-group": "4.4.5"
54
54
  },
55
55
  "devDependencies": {}