@mantine/notifications 9.5.1 → 9.6.0
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.cjs +142 -11
- package/cjs/NotificationContainer.cjs.map +1 -1
- package/cjs/Notifications.cjs +208 -41
- package/cjs/Notifications.cjs.map +1 -1
- package/cjs/Notifications.module.cjs.map +1 -1
- package/cjs/notifications.store.cjs.map +1 -1
- package/esm/NotificationContainer.mjs +143 -12
- package/esm/NotificationContainer.mjs.map +1 -1
- package/esm/Notifications.mjs +208 -41
- package/esm/Notifications.mjs.map +1 -1
- package/esm/Notifications.module.mjs.map +1 -1
- package/esm/notifications.store.mjs.map +1 -1
- package/lib/NotificationContainer.d.ts +10 -1
- package/lib/Notifications.d.ts +5 -1
- package/lib/notifications.store.d.ts +5 -0
- package/package.json +6 -6
- package/styles.css +8 -0
- package/styles.layer.css +8 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notifications.cjs","names":["_Transition","notificationsStore","useNotifications","getGroupedNotifications","positions","NotificationContainer","hideNotification","getNotificationStateStyles","OptionalPortal","Box","TransitionGroup","RemoveScroll","classes","notifications"],"sources":["../src/Notifications.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport {\n Transition as _Transition,\n TransitionGroup,\n TransitionStatus,\n} from 'react-transition-group';\nimport {\n BasePortalProps,\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getDefaultZIndex,\n OptionalPortal,\n rem,\n RemoveScroll,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { useDidUpdate, useForceUpdate, useReducedMotion } from '@mantine/hooks';\nimport {\n getGroupedNotifications,\n positions,\n} from './get-grouped-notifications/get-grouped-notifications';\nimport { getNotificationStateStyles } from './get-notification-state-styles';\nimport { NotificationContainer } from './NotificationContainer';\nimport {\n hideNotification,\n NotificationPosition,\n notifications,\n NotificationsStore,\n notificationsStore,\n useNotifications,\n} from './notifications.store';\nimport classes from './Notifications.module.css';\n\nconst Transition: any = _Transition;\n\nexport type NotificationsStylesNames = 'root' | 'notification';\nexport type NotificationsCssVariables = {\n root: '--notifications-z-index' | '--notifications-container-width';\n};\n\nexport interface NotificationsProps\n extends BoxProps, StylesApiProps<NotificationsFactory>, ElementProps<'div'> {\n /** Notifications default position @default 'bottom-right' */\n position?: NotificationPosition;\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 @default 4000 */\n autoClose?: number | false;\n\n /** Notification transition duration in ms @default 250 */\n transitionDuration?: number;\n\n /** Determines whether notifications can be dismissed by dragging left or right @default true */\n allowDragDismiss?: boolean;\n\n /** Determines whether notifications can be dismissed with horizontal scroll gesture while hovered @default true */\n allowScrollDismiss?: boolean;\n\n /** Notification width, cannot exceed 100% @default 440 */\n containerWidth?: number | string;\n\n /** Notification `max-height`, used for transitions @default 200 */\n notificationMaxHeight?: number | string;\n\n /** Maximum number of notifications displayed at a time, other new notifications will be added to queue @default 5 */\n limit?: number;\n\n /** Notifications container z-index @default 400 */\n zIndex?: string | number;\n\n /** Props passed down to the `Portal` component */\n portalProps?: BasePortalProps;\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` @default true */\n withinPortal?: boolean;\n\n /** Determines which notifications should pause auto close on hover, `'all'` – pauses auto close for all notifications when any notification is hovered, `'notification'` – pauses auto close only for the hovered notification @default 'all' */\n pauseResetOnHover?: 'all' | 'notification';\n}\n\nexport type NotificationsFactory = Factory<{\n props: NotificationsProps;\n ref: HTMLDivElement;\n stylesNames: NotificationsStylesNames;\n vars: NotificationsCssVariables;\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 = {\n position: 'bottom-right',\n autoClose: 4000,\n transitionDuration: 250,\n allowDragDismiss: true,\n allowScrollDismiss: true,\n containerWidth: 440,\n notificationMaxHeight: 200,\n limit: 5,\n zIndex: getDefaultZIndex('overlay'),\n store: notificationsStore,\n withinPortal: true,\n pauseResetOnHover: 'all',\n} satisfies Partial<NotificationsProps>;\n\nconst varsResolver = createVarsResolver<NotificationsFactory>((_, { zIndex, containerWidth }) => ({\n root: {\n '--notifications-z-index': zIndex?.toString(),\n '--notifications-container-width': rem(containerWidth),\n },\n}));\n\nexport const Notifications = factory<NotificationsFactory>((_props) => {\n const props = useProps('Notifications', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n attributes,\n position,\n autoClose,\n transitionDuration,\n allowDragDismiss,\n allowScrollDismiss,\n containerWidth,\n notificationMaxHeight,\n limit,\n zIndex,\n store,\n portalProps,\n withinPortal,\n pauseResetOnHover,\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 const [hoveredCount, setHoveredCount] = useState(0);\n\n const handleHoverStart = useCallback(() => setHoveredCount((c) => c + 1), []);\n const handleHoverEnd = useCallback(() => setHoveredCount((c) => Math.max(0, c - 1)), []);\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 attributes,\n vars,\n varsResolver,\n });\n\n useEffect(() => {\n store?.updateState((current) => ({\n ...current,\n limit: limit || 5,\n defaultPosition: position,\n }));\n }, [limit, position]);\n\n useDidUpdate(() => {\n if (data.notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = data.notifications.length;\n }, [data.notifications]);\n\n const grouped = getGroupedNotifications(data.notifications, position);\n const groupedComponents = positions.reduce(\n (acc, pos) => {\n acc[pos] = grouped[pos].map(({ style: notificationStyle, ...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 ref={(node) => {\n if (node) {\n refs.current[notification.id!] = node;\n } else {\n delete refs.current[notification.id!];\n }\n }}\n data={notification}\n onHide={(id) => hideNotification(id, store)}\n autoClose={autoClose}\n transitionDuration={duration}\n allowDragDismiss={allowDragDismiss}\n allowScrollDismiss={allowScrollDismiss}\n paused={pauseResetOnHover === 'all' ? hoveredCount > 0 : false}\n onHoverStart={handleHoverStart}\n onHoverEnd={handleHoverEnd}\n {...getStyles('notification', {\n style: {\n ...getNotificationStateStyles({\n state,\n position: pos,\n transitionDuration: duration,\n maxHeight: notificationMaxHeight,\n }),\n ...notificationStyle,\n },\n })}\n />\n )}\n </Transition>\n ));\n\n return acc;\n },\n {} as Record<NotificationPosition, React.ReactNode>\n );\n\n return (\n <OptionalPortal withinPortal={withinPortal} {...portalProps}>\n <Box {...getStyles('root')} data-position=\"top-center\" {...others}>\n <TransitionGroup>{groupedComponents['top-center']}</TransitionGroup>\n </Box>\n\n <Box {...getStyles('root')} data-position=\"top-left\" {...others}>\n <TransitionGroup>{groupedComponents['top-left']}</TransitionGroup>\n </Box>\n\n <Box\n {...getStyles('root', { className: RemoveScroll.classNames.fullWidth })}\n data-position=\"top-right\"\n {...others}\n >\n <TransitionGroup>{groupedComponents['top-right']}</TransitionGroup>\n </Box>\n\n <Box\n {...getStyles('root', { className: RemoveScroll.classNames.fullWidth })}\n data-position=\"bottom-right\"\n {...others}\n >\n <TransitionGroup>{groupedComponents['bottom-right']}</TransitionGroup>\n </Box>\n\n <Box {...getStyles('root')} data-position=\"bottom-left\" {...others}>\n <TransitionGroup>{groupedComponents['bottom-left']}</TransitionGroup>\n </Box>\n\n <Box {...getStyles('root')} data-position=\"bottom-center\" {...others}>\n <TransitionGroup>{groupedComponents['bottom-center']}</TransitionGroup>\n </Box>\n </OptionalPortal>\n );\n});\n\nNotifications.classes = classes;\nNotifications.varsResolver = varsResolver;\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"],"mappings":";;;;;;;;;;;;AAwCA,MAAM,aAAkBA,uBAAAA;AAgExB,MAAM,eAAe;CACnB,UAAU;CACV,WAAW;CACX,oBAAoB;CACpB,kBAAkB;CAClB,oBAAoB;CACpB,gBAAgB;CAChB,uBAAuB;CACvB,OAAO;CACP,SAAA,GAAA,cAAA,iBAAA,CAAyB,SAAS;CAClC,OAAOC,4BAAAA;CACP,cAAc;CACd,mBAAmB;AACrB;AAEA,MAAM,gBAAA,GAAA,cAAA,mBAAA,EAAyD,GAAG,EAAE,QAAQ,sBAAsB,EAChG,MAAM;CACJ,2BAA2B,QAAQ,SAAS;CAC5C,oCAAA,GAAA,cAAA,IAAA,CAAuC,cAAc;AACvD,EACF,EAAE;AAEF,MAAa,iBAAA,GAAA,cAAA,QAAA,EAA+C,WAAW;CACrE,MAAM,SAAA,GAAA,cAAA,SAAA,CAAiB,iBAAiB,cAAc,MAAM;CAC5D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,YACA,UACA,WACA,oBACA,kBACA,oBACA,gBACA,uBACA,OACA,QACA,OACA,aACA,cACA,mBACA,GAAG,WACD;CAEJ,MAAM,SAAA,GAAA,cAAA,gBAAA,CAAwB;CAC9B,MAAM,OAAOC,4BAAAA,iBAAiB,KAAK;CACnC,MAAM,eAAA,GAAA,eAAA,eAAA,CAA6B;CACnC,MAAM,sBAAA,GAAA,eAAA,iBAAA,CAAsC;CAC5C,MAAM,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CAAA;GAEL,iBAAA,GAAA,kBAAA,IAAA,CAACD,cAAAA,KAAD;IACE,GAAI,UAAU,QAAQ,EAAE,WAAWE,cAAAA,aAAa,WAAW,UAAU,CAAC;IACtE,iBAAc;IACd,GAAI;cAEJ,iBAAA,GAAA,kBAAA,IAAA,CAACD,uBAAAA,iBAAD,EAAA,UAAkB,kBAAkB,gBAAiC,CAAA;GAClE,CAAA;GAEL,iBAAA,GAAA,kBAAA,IAAA,CAACD,cAAAA,KAAD;IAAK,GAAI,UAAU,MAAM;IAAG,iBAAc;IAAc,GAAI;cAC1D,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,iBAAD,EAAA,UAAkB,kBAAkB,eAAgC,CAAA;GACjE,CAAA;GAEL,iBAAA,GAAA,kBAAA,IAAA,CAACD,cAAAA,KAAD;IAAK,GAAI,UAAU,MAAM;IAAG,iBAAc;IAAgB,GAAI;cAC5D,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,iBAAD,EAAA,UAAkB,kBAAkB,iBAAkC,CAAA;GACnE,CAAA;EACS;;AAEpB,CAAC;AAED,cAAc,UAAUE,6BAAAA;AACxB,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,OAAOC,4BAAAA,cAAc;AACnC,cAAc,OAAOA,4BAAAA,cAAc;AACnC,cAAc,SAASA,4BAAAA,cAAc;AACrC,cAAc,QAAQA,4BAAAA,cAAc;AACpC,cAAc,aAAaA,4BAAAA,cAAc;AACzC,cAAc,cAAcA,4BAAAA,cAAc"}
|
|
1
|
+
{"version":3,"file":"Notifications.cjs","names":["_Transition","getDefaultZIndex","notificationsStore","createVarsResolver","rem","factory","useProps","useMantineTheme","useNotifications","useForceUpdate","useReducedMotion","useRef","useState","useCallback","positions","getGroupedNotifications","useStyles","NotificationContainer","hideNotification","getNotificationStateStyles","OptionalPortal","Box","TransitionGroup","RemoveScroll","classes","notifications"],"sources":["../src/Notifications.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport {\n Transition as _Transition,\n TransitionGroup,\n TransitionStatus,\n} from 'react-transition-group';\nimport {\n BasePortalProps,\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getDefaultZIndex,\n OptionalPortal,\n rem,\n RemoveScroll,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { useDidUpdate, useForceUpdate, useReducedMotion } from '@mantine/hooks';\nimport {\n getGroupedNotifications,\n positions,\n} from './get-grouped-notifications/get-grouped-notifications';\nimport { getNotificationStateStyles } from './get-notification-state-styles';\nimport { NotificationContainer } from './NotificationContainer';\nimport {\n hideNotification,\n NotificationData,\n NotificationPosition,\n notifications,\n NotificationsStore,\n notificationsStore,\n SequencedNotificationData,\n useNotifications,\n} from './notifications.store';\nimport classes from './Notifications.module.css';\n\nconst Transition: any = _Transition;\n\n/** Vertical gap between notifications of an expanded stack, in px */\nconst STACK_EXPANDED_GAP = 16;\n\n/** Offset step used for a notification that has not been measured yet, in px */\nconst FALLBACK_NOTIFICATION_HEIGHT = 80;\n\nexport type NotificationsStylesNames = 'root' | 'notification';\nexport type NotificationsCssVariables = {\n root: '--notifications-z-index' | '--notifications-container-width';\n};\n\nexport interface NotificationsProps\n extends BoxProps, StylesApiProps<NotificationsFactory>, ElementProps<'div'> {\n /** Notifications default position @default 'bottom-right' */\n position?: NotificationPosition;\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 @default 4000 */\n autoClose?: number | false;\n\n /** Notification transition duration in ms @default 250 */\n transitionDuration?: number;\n\n /** Determines whether notifications can be dismissed by dragging left or right @default true */\n allowDragDismiss?: boolean;\n\n /** Determines whether notifications can be dismissed with horizontal scroll gesture while hovered @default true */\n allowScrollDismiss?: boolean;\n\n /** Notification width, cannot exceed 100% @default 440 */\n containerWidth?: number | string;\n\n /** Notification `max-height`, used for transitions @default 200 */\n notificationMaxHeight?: number | string;\n\n /** Maximum number of notifications displayed at a time, other new notifications will be added to queue @default 5 */\n limit?: number;\n\n /** Notifications container z-index @default 400 */\n zIndex?: string | number;\n\n /** Props passed down to the `Portal` component */\n portalProps?: BasePortalProps;\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` @default true */\n withinPortal?: boolean;\n\n /** Determines which notifications should pause auto close on hover, `'all'` – pauses auto close for all notifications when any notification is hovered, `'notification'` – pauses auto close only for the hovered notification @default 'all' */\n pauseResetOnHover?: 'all' | 'notification';\n\n /** Custom render function that replaces the default notification, can be overridden per notification */\n renderNotification?: (notification: NotificationData) => React.ReactNode;\n\n /** Controls how notifications are positioned in the stack, `'default'` – standard vertical list, `'stacked'` – only first notification is fully visible, rest are stacked behind @default 'default' */\n layout?: 'default' | 'stacked';\n}\n\nexport type NotificationsFactory = Factory<{\n props: NotificationsProps;\n ref: HTMLDivElement;\n stylesNames: NotificationsStylesNames;\n vars: NotificationsCssVariables;\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 = {\n position: 'bottom-right',\n autoClose: 4000,\n transitionDuration: 250,\n allowDragDismiss: true,\n allowScrollDismiss: true,\n containerWidth: 440,\n notificationMaxHeight: 200,\n limit: 5,\n zIndex: getDefaultZIndex('overlay'),\n store: notificationsStore,\n withinPortal: true,\n pauseResetOnHover: 'all',\n layout: 'default',\n} satisfies Partial<NotificationsProps>;\n\nconst varsResolver = createVarsResolver<NotificationsFactory>((_, { zIndex, containerWidth }) => ({\n root: {\n '--notifications-z-index': zIndex?.toString(),\n '--notifications-container-width': rem(containerWidth),\n },\n}));\n\nexport const Notifications = factory<NotificationsFactory>((_props) => {\n const props = useProps('Notifications', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n attributes,\n position,\n autoClose,\n transitionDuration,\n allowDragDismiss,\n allowScrollDismiss,\n containerWidth,\n notificationMaxHeight,\n limit,\n zIndex,\n store,\n portalProps,\n withinPortal,\n pauseResetOnHover,\n renderNotification,\n layout,\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 // Every position renders its own stack, so hover, expansion and pinning are tracked per\n // position – a single shared flag made hovering one corner expand all six of them.\n const [hoveredCounts, setHoveredCounts] = useState<Partial<Record<NotificationPosition, number>>>(\n {}\n );\n const [expandedPositions, setExpandedPositions] = useState<\n Partial<Record<NotificationPosition, boolean>>\n >({});\n const [hoveredGroups, setHoveredGroups] = useState<\n Partial<Record<NotificationPosition, boolean>>\n >({});\n const [pinnedPosition, setPinnedPosition] = useState<NotificationPosition | null>(null);\n const collapseTimeouts = useRef<Partial<Record<NotificationPosition, number>>>({});\n\n // `pauseResetOnHover=\"all\"` is documented as pausing every notification when any one of\n // them is hovered, so this stays global while the stack state above does not.\n const hoveredCount =\n Object.values(hoveredCounts).reduce((acc, count) => acc + (count ?? 0), 0) +\n Object.values(hoveredGroups).filter(Boolean).length;\n\n const handleHoverStart = useCallback(\n (pos: NotificationPosition) =>\n setHoveredCounts((current) => ({ ...current, [pos]: (current[pos] ?? 0) + 1 })),\n []\n );\n\n const handleHoverEnd = useCallback(\n (pos: NotificationPosition) =>\n setHoveredCounts((current) => ({ ...current, [pos]: Math.max(0, (current[pos] ?? 0) - 1) })),\n []\n );\n\n // Stacked hover is also tracked on the group element that wraps a stack, not only on the\n // individual notifications. When the hovered notification unmounts, React does not deliver\n // `onMouseEnter` to the one that slides under a stationary pointer: the browser dispatches\n // only a `mouseover` for the new target (no `mouseout`, the old node is gone), and the\n // enter/leave plugin drops it because its `relatedTarget` still resolves to a React\n // instance. The group is hovered throughout, so its state needs no event to stay correct\n // and the stack stays open until the pointer really leaves.\n // Kept apart from the notification counter above so that it can be released on its own –\n // the group has no unmount hook to fall back on the way a notification does.\n const getGroupHoverProps = useCallback(\n (pos: NotificationPosition) =>\n layout === 'stacked'\n ? {\n onMouseEnter: () => setHoveredGroups((current) => ({ ...current, [pos]: true })),\n onMouseLeave: () => setHoveredGroups((current) => ({ ...current, [pos]: false })),\n }\n : {},\n [layout]\n );\n\n // Touch devices have no hover, so tapping the stack pins it open until the next tap\n // outside of it. Without this the notifications behind the first one are unreachable.\n const handleExpandRequest = useCallback(\n (pos: NotificationPosition) => setPinnedPosition(pos),\n []\n );\n\n useEffect(() => {\n if (layout !== 'stacked') {\n return undefined;\n }\n\n const timeouts = collapseTimeouts.current;\n\n positions.forEach((pos) => {\n if ((hoveredCounts[pos] ?? 0) > 0 || hoveredGroups[pos] || pinnedPosition === pos) {\n window.clearTimeout(timeouts[pos]);\n setExpandedPositions((current) => (current[pos] ? current : { ...current, [pos]: true }));\n } else {\n timeouts[pos] = window.setTimeout(() => {\n setExpandedPositions((current) =>\n current[pos] ? { ...current, [pos]: false } : current\n );\n }, 200);\n }\n });\n\n return () => positions.forEach((pos) => window.clearTimeout(timeouts[pos]));\n }, [hoveredCounts, hoveredGroups, pinnedPosition, layout]);\n\n useEffect(() => {\n if (!pinnedPosition) {\n return undefined;\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node | null;\n const insideStack =\n target !== null && Object.values(refs.current).some((element) => element?.contains(target));\n\n if (!insideStack) {\n setPinnedPosition(null);\n }\n };\n\n document.addEventListener('pointerdown', handlePointerDown);\n return () => document.removeEventListener('pointerdown', handlePointerDown);\n }, [pinnedPosition]);\n\n const grouped = getGroupedNotifications(data.notifications, position);\n const pinnedCount = pinnedPosition ? grouped[pinnedPosition].length : 0;\n\n useEffect(() => {\n if (layout !== 'stacked' || (pinnedPosition !== null && pinnedCount === 0)) {\n setPinnedPosition(null);\n }\n }, [pinnedCount, pinnedPosition, layout]);\n\n // Leaving the stacked layout takes the handlers below out of the tree, so nothing can ever\n // deliver the `mouseleave` that would release the group and a stale flag would keep auto\n // close paused forever. Emptying a stack needs no such handling – the browser drops the\n // hover on its own once the last notification is removed, and releasing it here instead\n // would fire while the dismissed notification is still exiting under the pointer.\n useEffect(() => {\n if (layout !== 'stacked') {\n setHoveredGroups((current) => (Object.values(current).some(Boolean) ? {} : current));\n }\n }, [layout]);\n\n // Expanded stack offsets need the height of every notification. Measuring during render\n // would force a layout pass on every hover, focus and store update, so heights are cached\n // here and refreshed from the ResizeObserver – which also covers a notification that grows\n // after mount (image loads, async content, viewport reflow) and would otherwise leave the\n // ones after it overlapping or gapped until something else triggered a render.\n const resizeObserver = useRef<ResizeObserver | null>(null);\n const measuredHeights = useRef<Record<string, number>>({});\n const observedIds = useRef(new WeakMap<Element, string>());\n\n const measureNotification = useCallback((id: string, element: HTMLElement) => {\n const height = element.offsetHeight;\n\n if (measuredHeights.current[id] === height) {\n return false;\n }\n\n measuredHeights.current[id] = height;\n return true;\n }, []);\n\n useEffect(() => {\n if (layout !== 'stacked' || typeof ResizeObserver === 'undefined') {\n return undefined;\n }\n\n const observer = new ResizeObserver((entries) => {\n let changed = false;\n\n entries.forEach((entry) => {\n const id = observedIds.current.get(entry.target);\n\n if (id && measureNotification(id, entry.target as HTMLElement)) {\n changed = true;\n }\n });\n\n if (changed) {\n forceUpdate();\n }\n });\n\n resizeObserver.current = observer;\n Object.values(refs.current).forEach((element) => element && observer.observe(element));\n\n return () => {\n observer.disconnect();\n resizeObserver.current = null;\n };\n }, [layout, forceUpdate, measureNotification]);\n\n const refCallbacks = useRef<Record<string, (node: HTMLDivElement | null) => void>>({});\n\n const getNotificationRef = useCallback(\n (id: string) => {\n if (!refCallbacks.current[id]) {\n refCallbacks.current[id] = (node: HTMLDivElement | null) => {\n const previous = refs.current[id];\n\n if (previous && previous !== node) {\n resizeObserver.current?.unobserve(previous);\n observedIds.current.delete(previous);\n }\n\n if (node) {\n refs.current[id] = node;\n observedIds.current.set(node, id);\n // Measured here rather than during render – the commit phase is where a layout\n // read is already paid for, and the ResizeObserver keeps the value fresh after.\n measureNotification(id, node);\n resizeObserver.current?.observe(node);\n } else {\n delete refs.current[id];\n delete refCallbacks.current[id];\n delete measuredHeights.current[id];\n }\n };\n }\n\n return refCallbacks.current[id];\n },\n [measureNotification]\n );\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 attributes,\n vars,\n varsResolver,\n });\n\n useEffect(() => {\n store?.updateState((current) => ({\n ...current,\n limit: limit || 5,\n defaultPosition: position,\n }));\n }, [limit, position]);\n\n useDidUpdate(() => {\n if (data.notifications.length > previousLength.current) {\n setTimeout(() => forceUpdate(), 0);\n }\n previousLength.current = data.notifications.length;\n }, [data.notifications]);\n\n const groupedComponents = positions.reduce(\n (acc, pos) => {\n const groupLength = grouped[pos].length;\n const expandedOffsets: number[] = new Array(groupLength).fill(0);\n const stackExpanded = layout === 'stacked' && !!expandedPositions[pos];\n\n // `grouped[pos]` is sorted by priority descending, with equal priorities in insertion\n // order. A stack is rendered front to back, so `stackOrder[0]` is the notification in\n // front: the most urgent one, and the newest among equal priorities – only the\n // tie-break is reversed here. Taking the front from the end of the priority-sorted\n // array instead would put the *lowest* priority notification in front and leave an\n // urgent one inert behind it.\n // Rendering front first also keeps DOM order matching the visual stack – otherwise a\n // forward Tab from the front notification (the only focusable one while collapsed)\n // skips past the ones it just un-inerted and leaves the region. Placement is\n // unaffected: stacked notifications share one grid cell and are positioned by\n // transform and an explicit z-index.\n const stackOrder =\n layout === 'stacked'\n ? [...(grouped[pos] as SequencedNotificationData[])].sort(\n (a, b) =>\n (b.priority ?? 0) - (a.priority ?? 0) || (b.__sequence ?? 0) - (a.__sequence ?? 0)\n )\n : grouped[pos];\n\n if (stackExpanded && groupLength > 0) {\n const direction = pos.startsWith('top') ? 1 : -1;\n let cumOffset = 0;\n\n for (let i = 0; i < groupLength; i += 1) {\n expandedOffsets[i] = cumOffset * direction;\n cumOffset +=\n (measuredHeights.current[stackOrder[i].id!] || FALLBACK_NOTIFICATION_HEIGHT) +\n STACK_EXPANDED_GAP;\n }\n }\n\n acc[pos] = stackOrder.map((item, stackIndex) => {\n const { style: notificationStyle, ...notification } = item;\n\n return (\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 ref={getNotificationRef(notification.id!)}\n data={notification}\n onHide={(id) => hideNotification(id, store)}\n autoClose={autoClose}\n transitionDuration={duration}\n allowDragDismiss={allowDragDismiss}\n allowScrollDismiss={allowScrollDismiss}\n paused={\n (pauseResetOnHover === 'all' ? hoveredCount > 0 : false) ||\n (layout === 'stacked' && !stackExpanded && stackIndex > 0)\n }\n onHoverStart={() => handleHoverStart(pos)}\n onHoverEnd={() => handleHoverEnd(pos)}\n onExpandRequest={() => handleExpandRequest(pos)}\n renderNotification={\n 'renderNotification' in notification\n ? notification.renderNotification\n : renderNotification\n }\n layout={layout}\n stackIndex={stackIndex}\n stackSize={groupLength}\n stackPosition={pos}\n stackExpanded={stackExpanded}\n stackExpandedOffset={expandedOffsets[stackIndex]}\n transitionState={state}\n {...getStyles('notification', {\n style: {\n ...getNotificationStateStyles({\n state,\n position: pos,\n transitionDuration: duration,\n maxHeight: notificationMaxHeight,\n }),\n ...notificationStyle,\n },\n })}\n />\n )}\n </Transition>\n );\n });\n\n return acc;\n },\n {} as Record<NotificationPosition, React.ReactNode>\n );\n\n return (\n <OptionalPortal withinPortal={withinPortal} {...portalProps}>\n <Box {...getStyles('root')} data-position=\"top-center\" data-layout={layout} {...others}>\n <TransitionGroup {...getGroupHoverProps('top-center')}>\n {groupedComponents['top-center']}\n </TransitionGroup>\n </Box>\n\n <Box {...getStyles('root')} data-position=\"top-left\" data-layout={layout} {...others}>\n <TransitionGroup {...getGroupHoverProps('top-left')}>\n {groupedComponents['top-left']}\n </TransitionGroup>\n </Box>\n\n <Box\n {...getStyles('root', { className: RemoveScroll.classNames.fullWidth })}\n data-position=\"top-right\"\n data-layout={layout}\n {...others}\n >\n <TransitionGroup {...getGroupHoverProps('top-right')}>\n {groupedComponents['top-right']}\n </TransitionGroup>\n </Box>\n\n <Box\n {...getStyles('root', { className: RemoveScroll.classNames.fullWidth })}\n data-position=\"bottom-right\"\n data-layout={layout}\n {...others}\n >\n <TransitionGroup {...getGroupHoverProps('bottom-right')}>\n {groupedComponents['bottom-right']}\n </TransitionGroup>\n </Box>\n\n <Box {...getStyles('root')} data-position=\"bottom-left\" data-layout={layout} {...others}>\n <TransitionGroup {...getGroupHoverProps('bottom-left')}>\n {groupedComponents['bottom-left']}\n </TransitionGroup>\n </Box>\n\n <Box {...getStyles('root')} data-position=\"bottom-center\" data-layout={layout} {...others}>\n <TransitionGroup {...getGroupHoverProps('bottom-center')}>\n {groupedComponents['bottom-center']}\n </TransitionGroup>\n </Box>\n </OptionalPortal>\n );\n});\n\nNotifications.classes = classes;\nNotifications.varsResolver = varsResolver;\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"],"mappings":";;;;;;;;;;;;AA0CA,MAAM,aAAkBA,uBAAAA;;AAGxB,MAAM,qBAAqB;;AAG3B,MAAM,+BAA+B;AAsErC,MAAM,eAAe;CACnB,UAAU;CACV,WAAW;CACX,oBAAoB;CACpB,kBAAkB;CAClB,oBAAoB;CACpB,gBAAgB;CAChB,uBAAuB;CACvB,OAAO;CACP,SAAA,GAAQC,cAAAA,iBAAAA,CAAiB,SAAS;CAClC,OAAOC,4BAAAA;CACP,cAAc;CACd,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cAAc,OAAOA,4BAAAA,cAAc;AACnC,cAAc,SAASA,4BAAAA,cAAc;AACrC,cAAc,QAAQA,4BAAAA,cAAc;AACpC,cAAc,aAAaA,4BAAAA,cAAc;AACzC,cAAc,cAAcA,4BAAAA,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notifications.module.cjs","names":[],"sources":["../src/Notifications.module.css"],"sourcesContent":[".root {\n width: calc(100% - var(--mantine-spacing-md) * 2);\n position: fixed;\n z-index: var(--notifications-z-index);\n max-width: var(--notifications-container-width);\n\n &:where([data-position='top-center']) {\n top: var(--mantine-spacing-md);\n left: 50%;\n transform: translateX(-50%);\n }\n\n &:where([data-position='top-left']) {\n top: var(--mantine-spacing-md);\n left: var(--mantine-spacing-md);\n }\n\n &:where([data-position='top-right']) {\n top: var(--mantine-spacing-md);\n right: var(--mantine-spacing-md);\n }\n\n &:where([data-position='bottom-center']) {\n bottom: var(--mantine-spacing-md);\n left: 50%;\n transform: translateX(-50%);\n }\n\n &:where([data-position='bottom-left']) {\n bottom: var(--mantine-spacing-md);\n left: var(--mantine-spacing-md);\n }\n\n &:where([data-position='bottom-right']) {\n bottom: var(--mantine-spacing-md);\n right: var(--mantine-spacing-md);\n }\n}\n\n.notification {\n & + & {\n margin-top: var(--mantine-spacing-md);\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Notifications.module.cjs","names":[],"sources":["../src/Notifications.module.css"],"sourcesContent":[".root {\n width: calc(100% - var(--mantine-spacing-md) * 2);\n position: fixed;\n z-index: var(--notifications-z-index);\n max-width: var(--notifications-container-width);\n\n &:where([data-position='top-center']) {\n top: var(--mantine-spacing-md);\n left: 50%;\n transform: translateX(-50%);\n }\n\n &:where([data-position='top-left']) {\n top: var(--mantine-spacing-md);\n left: var(--mantine-spacing-md);\n }\n\n &:where([data-position='top-right']) {\n top: var(--mantine-spacing-md);\n right: var(--mantine-spacing-md);\n }\n\n &:where([data-position='bottom-center']) {\n bottom: var(--mantine-spacing-md);\n left: 50%;\n transform: translateX(-50%);\n }\n\n &:where([data-position='bottom-left']) {\n bottom: var(--mantine-spacing-md);\n left: var(--mantine-spacing-md);\n }\n\n &:where([data-position='bottom-right']) {\n bottom: var(--mantine-spacing-md);\n right: var(--mantine-spacing-md);\n }\n}\n\n.notification {\n & + & {\n margin-top: var(--mantine-spacing-md);\n }\n\n :where([data-layout='stacked']) & {\n margin-top: 0;\n }\n}\n\n.root:where([data-layout='stacked']) {\n & > * {\n display: grid;\n }\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.store.cjs","names":[],"sources":["../src/notifications.store.ts"],"sourcesContent":["import { NotificationProps } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport { createStore, MantineStore, useStore } from '@mantine/store';\n\nexport type NotificationPosition =\n | 'top-left'\n | 'top-right'\n | 'top-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom-center';\n\nexport interface NotificationData\n extends Omit<NotificationProps, 'onClose'>, Record<`data-${string}`, any> {\n /** Notification id, can be used to close or update notification */\n id?: string;\n\n /** Position of the notification, if not set, the position is determined based on `position` prop on Notifications component */\n position?: NotificationPosition;\n\n /** Notification message, required for all notifications */\n message: React.ReactNode;\n\n /** Display priority. Higher numbers are shown before lower ones when the number of\n * active notifications exceeds `limit`. Notifications with equal priority keep insertion\n * order (FIFO). @default 0 */\n priority?: number;\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 /** Determines whether notification can be closed with close button, drag or horizontal scroll swipe, `true` by default */\n allowClose?: boolean;\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 defaultPosition: NotificationPosition;\n limit: number;\n}\n\nexport type NotificationsStore = MantineStore<NotificationsState>;\n\
|
|
1
|
+
{"version":3,"file":"notifications.store.cjs","names":["createStore","useStore","randomId"],"sources":["../src/notifications.store.ts"],"sourcesContent":["import { NotificationProps } from '@mantine/core';\nimport { randomId } from '@mantine/hooks';\nimport { createStore, MantineStore, useStore } from '@mantine/store';\n\nexport type NotificationPosition =\n | 'top-left'\n | 'top-right'\n | 'top-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'bottom-center';\n\nexport interface NotificationData\n extends Omit<NotificationProps, 'onClose'>, Record<`data-${string}`, any> {\n /** Notification id, can be used to close or update notification */\n id?: string;\n\n /** Position of the notification, if not set, the position is determined based on `position` prop on Notifications component */\n position?: NotificationPosition;\n\n /** Notification message, required for all notifications */\n message: React.ReactNode;\n\n /** Display priority. Higher numbers are shown before lower ones when the number of\n * active notifications exceeds `limit`. Notifications with equal priority keep insertion\n * order (FIFO). @default 0 */\n priority?: number;\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 /** Determines whether notification can be closed with close button, drag or horizontal scroll swipe, `true` by default */\n allowClose?: boolean;\n\n /** Called when notification closes */\n onClose?: (props: NotificationData) => void;\n\n /** Called when notification opens */\n onOpen?: (props: NotificationData) => void;\n\n /** Custom render function that replaces the default notification, overrides `renderNotification` from `Notifications`. Set to `null` to use default rendering when a global `renderNotification` is set. */\n renderNotification?: ((notification: NotificationData) => React.ReactNode) | null;\n}\n\nexport interface NotificationsState {\n notifications: NotificationData[];\n queue: NotificationData[];\n defaultPosition: NotificationPosition;\n limit: number;\n}\n\nexport type NotificationsStore = MantineStore<NotificationsState>;\n\nexport interface SequencedNotificationData extends NotificationData {\n __sequence?: number;\n}\n\nlet notificationSequence = 0;\n\nfunction getDistributedNotifications(\n data: SequencedNotificationData[],\n defaultPosition: NotificationPosition,\n limit: number\n) {\n const queue: NotificationData[] = [];\n const notifications: NotificationData[] = [];\n const groups = new Map<string, SequencedNotificationData[]>();\n\n for (const item of data) {\n const position = item.position || defaultPosition;\n const group = groups.get(position);\n if (group) {\n group.push(item);\n } else {\n groups.set(position, [item]);\n }\n }\n\n for (const group of groups.values()) {\n group.sort(\n (a, b) => (b.priority ?? 0) - (a.priority ?? 0) || (a.__sequence ?? 0) - (b.__sequence ?? 0)\n );\n group.forEach((item, index) => {\n if (index < limit) {\n notifications.push(item);\n } else {\n queue.push(item);\n }\n });\n }\n\n return { notifications, queue };\n}\n\nexport const createNotificationsStore = () =>\n createStore<NotificationsState>({\n notifications: [],\n queue: [],\n defaultPosition: 'bottom-right',\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 for (const item of notifications as SequencedNotificationData[]) {\n if (item.__sequence === undefined) {\n item.__sequence = notificationSequence;\n notificationSequence += 1;\n }\n }\n\n const updated = getDistributedNotifications(notifications, state.defaultPosition, state.limit);\n\n store.setState({\n notifications: updated.notifications,\n queue: updated.queue,\n limit: state.limit,\n defaultPosition: state.defaultPosition,\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 const { defaultPosition, limit } = store.getState();\n updateNotificationsState(\n store,\n (notifications) =>\n getDistributedNotifications(notifications, defaultPosition, limit).notifications\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"],"mappings":";;;;AA2DA,IAAI,uBAAuB;AAE3B,SAAS,4BACP,MACA,iBACA,OACA;CACA,MAAM,QAA4B,CAAC;CACnC,MAAM,gBAAoC,CAAC;CAC3C,MAAM,yBAAS,IAAI,IAAyC;CAE5D,KAAK,MAAM,QAAQ,MAAM;EACvB,MAAM,WAAW,KAAK,YAAY;EAClC,MAAM,QAAQ,OAAO,IAAI,QAAQ;EACjC,IAAI,OACF,MAAM,KAAK,IAAI;OAEf,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC;CAE/B;CAEA,KAAK,MAAM,SAAS,OAAO,OAAO,GAAG;EACnC,MAAM,MACH,GAAG,OAAO,EAAE,YAAY,MAAM,EAAE,YAAY,OAAO,EAAE,cAAc,MAAM,EAAE,cAAc,EAC5F;EACA,MAAM,SAAS,MAAM,UAAU;GAC7B,IAAI,QAAQ,OACV,cAAc,KAAK,IAAI;QAEvB,MAAM,KAAK,IAAI;EAEnB,CAAC;CACH;CAEA,OAAO;EAAE;EAAe;CAAM;AAChC;AAEA,MAAa,kCAAA,GACXA,eAAAA,YAAAA,CAAgC;CAC9B,eAAe,CAAC;CAChB,OAAO,CAAC;CACR,iBAAiB;CACjB,OAAO;AACT,CAAC;AAEH,MAAa,qBAAqB,yBAAyB;AAC3D,MAAa,oBAAoB,QAA4B,wBAAA,GAAuBC,eAAAA,SAAAA,CAAS,KAAK;AAElG,SAAgB,yBACd,OACA,QACA;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AiB,UAAU,MAAM,SAAS;CAClD,yBACE,QACC,kBACC,4BAA4B,eAAe,iBAAiB,KAAK,CAAC,CAAC,aACvE;AACF;AAEA,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,QAAQ;CACR,OAAO;CACP,YAAY;CACZ,aAAa;AACf"}
|
|
@@ -2,25 +2,77 @@
|
|
|
2
2
|
import { getAutoClose } from "./get-auto-close/get-auto-close.mjs";
|
|
3
3
|
import { useDrag, useMergedRef } from "@mantine/hooks";
|
|
4
4
|
import { useEffect, useEffectEvent, useRef, useState } from "react";
|
|
5
|
-
import { Notification, getStyleObject, useMantineTheme } from "@mantine/core";
|
|
5
|
+
import { Notification, extractStyleProps, getStyleObject, useMantineTheme } from "@mantine/core";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region packages/@mantine/notifications/src/NotificationContainer.tsx
|
|
8
8
|
const SCROLL_DISMISS_RESET_TIMEOUT = 120;
|
|
9
|
-
|
|
9
|
+
const MAX_VISIBLE_STACK_DEPTH = 4;
|
|
10
|
+
/**
|
|
11
|
+
* Props that belong to the default `Notification` rendering or to the Styles API and must
|
|
12
|
+
* not reach the plain `div` used for custom rendering. Everything else is a valid div prop
|
|
13
|
+
* and is forwarded – an allow list would silently drop supported props like `onClick`,
|
|
14
|
+
* `dir`, `lang` or `hidden`.
|
|
15
|
+
*/
|
|
16
|
+
const NON_DOM_PROPS = /* @__PURE__ */ new Set([
|
|
17
|
+
"classNames",
|
|
18
|
+
"styles",
|
|
19
|
+
"unstyled",
|
|
20
|
+
"vars",
|
|
21
|
+
"attributes",
|
|
22
|
+
"variant",
|
|
23
|
+
"color",
|
|
24
|
+
"radius",
|
|
25
|
+
"icon",
|
|
26
|
+
"title",
|
|
27
|
+
"loading",
|
|
28
|
+
"withBorder",
|
|
29
|
+
"withCloseButton",
|
|
30
|
+
"closeButtonProps",
|
|
31
|
+
"className",
|
|
32
|
+
"style",
|
|
33
|
+
"role",
|
|
34
|
+
"ref",
|
|
35
|
+
"children",
|
|
36
|
+
"mod"
|
|
37
|
+
]);
|
|
38
|
+
function pickDomProps(props) {
|
|
39
|
+
const { rest } = extractStyleProps(props);
|
|
40
|
+
return Object.fromEntries(Object.entries(rest).filter(([key, value]) => !NON_DOM_PROPS.has(key) && value !== void 0));
|
|
41
|
+
}
|
|
42
|
+
function NotificationContainer({ data, onHide, autoClose, transitionDuration, allowDragDismiss, allowScrollDismiss, paused, onHoverStart, onHoverEnd, onExpandRequest, ref, style, renderNotification, layout, stackIndex, stackSize, stackPosition, stackExpanded, stackExpandedOffset, transitionState, ...others }) {
|
|
10
43
|
const [offset, setOffset] = useState(0);
|
|
11
44
|
const [dismissed, setDismissed] = useState(false);
|
|
12
45
|
const [dismissDirection, setDismissDirection] = useState(1);
|
|
13
46
|
const [scrollDismissActive, setScrollDismissActive] = useState(false);
|
|
14
47
|
const theme = useMantineTheme();
|
|
15
|
-
const { autoClose: _autoClose, message, allowClose, position: _position, style: dataStyle, withCloseButton, onOpen: _onOpen, priority: _priority, __sequence: _sequence, ...notificationProps } = data;
|
|
48
|
+
const { autoClose: _autoClose, message, allowClose, position: _position, style: dataStyle, withCloseButton, renderNotification: _renderNotification, onOpen: _onOpen, priority: _priority, __sequence: _sequence, ...notificationProps } = data;
|
|
16
49
|
const autoCloseDuration = getAutoClose(autoClose, data.autoClose);
|
|
17
50
|
const autoCloseTimeout = useRef(-1);
|
|
18
51
|
const hideTimeout = useRef(-1);
|
|
19
52
|
const scrollDismissTimeout = useRef(-1);
|
|
20
53
|
const notificationRef = useRef(null);
|
|
21
54
|
const hoveredRef = useRef(false);
|
|
55
|
+
const focusedRef = useRef(false);
|
|
56
|
+
const contributedActiveRef = useRef(false);
|
|
22
57
|
const offsetRef = useRef(0);
|
|
23
58
|
const isCloseDisabled = allowClose === false;
|
|
59
|
+
const syncActive = () => {
|
|
60
|
+
const shouldContribute = hoveredRef.current || focusedRef.current;
|
|
61
|
+
if (shouldContribute && !contributedActiveRef.current) {
|
|
62
|
+
contributedActiveRef.current = true;
|
|
63
|
+
onHoverStart?.();
|
|
64
|
+
} else if (!shouldContribute && contributedActiveRef.current) {
|
|
65
|
+
contributedActiveRef.current = false;
|
|
66
|
+
onHoverEnd?.();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const releaseActive = useEffectEvent(() => {
|
|
70
|
+
if (contributedActiveRef.current) {
|
|
71
|
+
contributedActiveRef.current = false;
|
|
72
|
+
onHoverEnd?.();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
useEffect(() => () => releaseActive(), []);
|
|
24
76
|
const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);
|
|
25
77
|
const cancelHide = () => window.clearTimeout(hideTimeout.current);
|
|
26
78
|
const cancelScrollDismissReset = () => window.clearTimeout(scrollDismissTimeout.current);
|
|
@@ -34,8 +86,12 @@ function NotificationContainer({ data, onHide, autoClose, transitionDuration, al
|
|
|
34
86
|
cancelHide();
|
|
35
87
|
cancelScrollDismissReset();
|
|
36
88
|
};
|
|
89
|
+
const pausedRef = useRef(paused);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
pausedRef.current = paused;
|
|
92
|
+
});
|
|
37
93
|
const handleAutoClose = () => {
|
|
38
|
-
if (dismissed || active ||
|
|
94
|
+
if (dismissed || active || hoveredRef.current || focusedRef.current || pausedRef.current || typeof autoCloseDuration !== "number") return;
|
|
39
95
|
cancelAutoClose();
|
|
40
96
|
autoCloseTimeout.current = window.setTimeout(handleHide, autoCloseDuration);
|
|
41
97
|
};
|
|
@@ -102,22 +158,47 @@ function NotificationContainer({ data, onHide, autoClose, transitionDuration, al
|
|
|
102
158
|
const baseOpacity = typeof baseStyle.opacity === "number" ? baseStyle.opacity : 1;
|
|
103
159
|
const swipeOpacity = dismissed ? 0 : 1 - Math.min(Math.abs(offset) / 200, 1) * .6;
|
|
104
160
|
const resolvedTransitionDuration = baseStyle.transitionDuration ?? `${transitionDuration}ms, ${transitionDuration}ms, ${transitionDuration}ms`;
|
|
161
|
+
const isStackedLayout = layout === "stacked";
|
|
162
|
+
const isStacked = isStackedLayout && stackIndex !== void 0 && stackIndex > 0;
|
|
163
|
+
const isCollapsed = isStacked && !stackExpanded;
|
|
164
|
+
const isExiting = transitionState === "exiting" || transitionState === "exited";
|
|
165
|
+
const stackDirection = stackPosition?.startsWith("top") ? 1 : -1;
|
|
166
|
+
const stackDepth = Math.min(stackIndex ?? 0, MAX_VISIBLE_STACK_DEPTH);
|
|
167
|
+
const collapsedOffset = isCollapsed ? stackDepth * 10 * stackDirection : 0;
|
|
168
|
+
const staggerDelay = isStackedLayout ? (stackIndex || 0) * 30 : 0;
|
|
169
|
+
const isDragging = active || scrollDismissActive;
|
|
170
|
+
const getStackedTransform = () => {
|
|
171
|
+
if (!isStackedLayout) return "var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)";
|
|
172
|
+
if (isExiting) return `translateY(${stackExpanded ? stackExpandedOffset || 0 : collapsedOffset}px) var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)`;
|
|
173
|
+
if (stackExpanded) return `translateY(${stackExpandedOffset || 0}px) translate3d(var(--notifications-swipe-offset), 0, 0)`;
|
|
174
|
+
if (isStacked) return `scale(${1 - stackDepth * .03}) translateY(${collapsedOffset}px)`;
|
|
175
|
+
return "var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)";
|
|
176
|
+
};
|
|
105
177
|
const notificationStyle = {
|
|
106
178
|
...baseStyle,
|
|
179
|
+
...isStackedLayout ? { maxHeight: void 0 } : {},
|
|
107
180
|
["--notifications-state-transform"]: typeof baseStyle.transform === "string" ? baseStyle.transform : "translateX(0)",
|
|
108
181
|
["--notifications-state-opacity"]: String(baseOpacity),
|
|
109
182
|
["--notifications-swipe-offset"]: `${offset}px`,
|
|
110
183
|
["--notifications-swipe-opacity"]: String(swipeOpacity),
|
|
111
|
-
transform:
|
|
184
|
+
transform: getStackedTransform(),
|
|
112
185
|
opacity: "calc(var(--notifications-state-opacity) * var(--notifications-swipe-opacity))",
|
|
113
|
-
transitionDuration:
|
|
186
|
+
transitionDuration: isDragging ? "0ms, 0ms, 0ms" : resolvedTransitionDuration,
|
|
114
187
|
cursor: "default",
|
|
115
|
-
touchAction: "pan-y"
|
|
188
|
+
touchAction: "pan-y",
|
|
189
|
+
...isStackedLayout ? {
|
|
190
|
+
gridArea: "1 / 1",
|
|
191
|
+
zIndex: (stackSize || 5) - (stackIndex ?? 0),
|
|
192
|
+
pointerEvents: isCollapsed ? "none" : void 0,
|
|
193
|
+
alignSelf: stackDirection === 1 ? "start" : "end",
|
|
194
|
+
transition: isDragging ? "none" : `transform ${transitionDuration}ms cubic-bezier(.51,.3,0,1.21), opacity ${transitionDuration}ms ease`,
|
|
195
|
+
transitionDelay: isDragging || isExiting ? "0ms" : `${staggerDelay}ms`
|
|
196
|
+
} : {}
|
|
116
197
|
};
|
|
117
198
|
const handleMouseEnter = () => {
|
|
118
199
|
hoveredRef.current = true;
|
|
119
200
|
cancelAutoClose();
|
|
120
|
-
|
|
201
|
+
syncActive();
|
|
121
202
|
};
|
|
122
203
|
const handleMouseLeave = () => {
|
|
123
204
|
hoveredRef.current = false;
|
|
@@ -125,7 +206,20 @@ function NotificationContainer({ data, onHide, autoClose, transitionDuration, al
|
|
|
125
206
|
resetSwipe();
|
|
126
207
|
handleAutoClose();
|
|
127
208
|
}
|
|
128
|
-
|
|
209
|
+
syncActive();
|
|
210
|
+
};
|
|
211
|
+
const handleFocusCapture = isStackedLayout ? () => {
|
|
212
|
+
focusedRef.current = true;
|
|
213
|
+
cancelAutoClose();
|
|
214
|
+
syncActive();
|
|
215
|
+
} : void 0;
|
|
216
|
+
const handleBlurCapture = isStackedLayout ? () => {
|
|
217
|
+
focusedRef.current = false;
|
|
218
|
+
if (!scrollDismissActive) handleAutoClose();
|
|
219
|
+
syncActive();
|
|
220
|
+
} : void 0;
|
|
221
|
+
const handlePointerDownCapture = (event) => {
|
|
222
|
+
if (isStackedLayout && (event.pointerType === "touch" || event.pointerType === "pen")) onExpandRequest?.();
|
|
129
223
|
};
|
|
130
224
|
const handleWheel = useEffectEvent((event) => {
|
|
131
225
|
if (dismissed || active) return;
|
|
@@ -189,15 +283,52 @@ function NotificationContainer({ data, onHide, autoClose, transitionDuration, al
|
|
|
189
283
|
else handleAutoClose();
|
|
190
284
|
return cancelAutoClose;
|
|
191
285
|
}, [paused]);
|
|
286
|
+
const consumerProps = {
|
|
287
|
+
...others,
|
|
288
|
+
...notificationProps
|
|
289
|
+
};
|
|
290
|
+
const interactionProps = {
|
|
291
|
+
style: notificationStyle,
|
|
292
|
+
inert: isCollapsed,
|
|
293
|
+
onMouseEnter: (event) => {
|
|
294
|
+
consumerProps.onMouseEnter?.(event);
|
|
295
|
+
handleMouseEnter();
|
|
296
|
+
},
|
|
297
|
+
onMouseLeave: (event) => {
|
|
298
|
+
consumerProps.onMouseLeave?.(event);
|
|
299
|
+
handleMouseLeave();
|
|
300
|
+
},
|
|
301
|
+
onFocusCapture: (event) => {
|
|
302
|
+
consumerProps.onFocusCapture?.(event);
|
|
303
|
+
handleFocusCapture?.();
|
|
304
|
+
},
|
|
305
|
+
onBlurCapture: (event) => {
|
|
306
|
+
consumerProps.onBlurCapture?.(event);
|
|
307
|
+
handleBlurCapture?.();
|
|
308
|
+
},
|
|
309
|
+
onPointerDownCapture: (event) => {
|
|
310
|
+
consumerProps.onPointerDownCapture?.(event);
|
|
311
|
+
handlePointerDownCapture(event);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
if (renderNotification) {
|
|
315
|
+
const classNames = [others.className, notificationProps.className].filter(Boolean).join(" ");
|
|
316
|
+
return /* @__PURE__ */ jsx("div", {
|
|
317
|
+
ref: mergedRef,
|
|
318
|
+
role: notificationProps.role || others.role || "alert",
|
|
319
|
+
...pickDomProps(consumerProps),
|
|
320
|
+
className: classNames || void 0,
|
|
321
|
+
...interactionProps,
|
|
322
|
+
children: renderNotification(data)
|
|
323
|
+
});
|
|
324
|
+
}
|
|
192
325
|
return /* @__PURE__ */ jsx(Notification, {
|
|
193
326
|
ref: mergedRef,
|
|
194
327
|
...others,
|
|
195
|
-
style: notificationStyle,
|
|
196
328
|
...notificationProps,
|
|
329
|
+
...interactionProps,
|
|
197
330
|
withCloseButton: isCloseDisabled ? false : withCloseButton,
|
|
198
331
|
onClose: handleHide,
|
|
199
|
-
onMouseEnter: handleMouseEnter,
|
|
200
|
-
onMouseLeave: handleMouseLeave,
|
|
201
332
|
children: message
|
|
202
333
|
});
|
|
203
334
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationContainer.mjs","names":[],"sources":["../src/NotificationContainer.tsx"],"sourcesContent":["import { useEffect, useEffectEvent, useRef, useState } from 'react';\nimport { getStyleObject, Notification, NotificationProps, useMantineTheme } from '@mantine/core';\nimport { useDrag, useMergedRef } from '@mantine/hooks';\nimport { getAutoClose } from './get-auto-close/get-auto-close';\nimport { NotificationData } from './notifications.store';\n\nconst SCROLL_DISMISS_RESET_TIMEOUT = 120;\n\ninterface NotificationContainerProps extends NotificationProps {\n data: NotificationData;\n onHide: (id: string) => void;\n autoClose: number | false;\n transitionDuration: number;\n allowDragDismiss: boolean;\n allowScrollDismiss: boolean;\n paused: boolean;\n onHoverStart?: () => void;\n onHoverEnd?: () => void;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport function NotificationContainer({\n data,\n onHide,\n autoClose,\n transitionDuration,\n allowDragDismiss,\n allowScrollDismiss,\n paused,\n onHoverStart,\n onHoverEnd,\n ref,\n style,\n ...others\n}: NotificationContainerProps) {\n const [offset, setOffset] = useState(0);\n const [dismissed, setDismissed] = useState(false);\n const [dismissDirection, setDismissDirection] = useState<-1 | 1>(1);\n const [scrollDismissActive, setScrollDismissActive] = useState(false);\n const theme = useMantineTheme();\n const {\n autoClose: _autoClose,\n message,\n allowClose,\n position: _position,\n style: dataStyle,\n withCloseButton,\n onOpen: _onOpen,\n priority: _priority,\n __sequence: _sequence,\n ...notificationProps\n } = data as NotificationData & { __sequence?: number };\n const autoCloseDuration = getAutoClose(autoClose, data.autoClose);\n const autoCloseTimeout = useRef<number>(-1);\n const hideTimeout = useRef<number>(-1);\n const scrollDismissTimeout = useRef<number>(-1);\n const notificationRef = useRef<HTMLDivElement>(null);\n const hoveredRef = useRef(false);\n const offsetRef = useRef(0);\n const isCloseDisabled = allowClose === false;\n\n const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);\n const cancelHide = () => window.clearTimeout(hideTimeout.current);\n const cancelScrollDismissReset = () => window.clearTimeout(scrollDismissTimeout.current);\n\n const setSwipeOffset = (value: number) => {\n offsetRef.current = value;\n setOffset(value);\n };\n\n const handleHide = () => {\n onHide(data.id!);\n cancelAutoClose();\n cancelHide();\n cancelScrollDismissReset();\n };\n\n const handleAutoClose = () => {\n if (\n dismissed ||\n active ||\n paused ||\n hoveredRef.current ||\n typeof autoCloseDuration !== 'number'\n ) {\n return;\n }\n\n cancelAutoClose();\n autoCloseTimeout.current = window.setTimeout(handleHide, autoCloseDuration);\n };\n\n const getExitOffset = (direction: -1 | 1) => {\n const width = notificationRef.current?.offsetWidth ?? 440;\n return direction * (width + 40);\n };\n\n const shouldDismiss = (movement: number, velocity: number) => {\n const width = notificationRef.current?.offsetWidth ?? 440;\n return Math.abs(movement) > width * 0.35 || velocity > 0.5;\n };\n\n const resetSwipe = () => {\n cancelScrollDismissReset();\n setScrollDismissActive(false);\n setSwipeOffset(0);\n };\n\n const dismissNotification = (direction: -1 | 1) => {\n setDismissDirection(direction);\n setDismissed(true);\n setScrollDismissActive(false);\n setSwipeOffset(getExitOffset(direction));\n cancelAutoClose();\n cancelHide();\n cancelScrollDismissReset();\n hideTimeout.current = window.setTimeout(handleHide, transitionDuration);\n };\n\n const scheduleScrollDismissReset = () => {\n cancelScrollDismissReset();\n scrollDismissTimeout.current = window.setTimeout(() => {\n setScrollDismissActive(false);\n setSwipeOffset(0);\n handleAutoClose();\n }, SCROLL_DISMISS_RESET_TIMEOUT);\n };\n\n const { ref: dragRef, active } = useDrag<HTMLDivElement>(\n (state) => {\n if (dismissed) {\n return;\n }\n\n if (state.first) {\n cancelAutoClose();\n }\n\n if (state.last) {\n if (state.tap || state.canceled) {\n setSwipeOffset(0);\n handleAutoClose();\n return;\n }\n\n const movement = state.movement[0];\n const direction =\n movement === 0 ? (state.direction[0] === -1 ? -1 : 1) : movement > 0 ? 1 : -1;\n\n if (shouldDismiss(movement, state.velocity[0])) {\n dismissNotification(direction);\n } else {\n setSwipeOffset(0);\n handleAutoClose();\n }\n } else {\n setSwipeOffset(state.movement[0]);\n }\n },\n {\n axis: 'x',\n threshold: 5,\n filterTaps: true,\n enabled: allowDragDismiss && !isCloseDisabled && !dismissed,\n }\n );\n\n const mergedRef = useMergedRef(ref, notificationRef, dragRef);\n const resolvedStyle = getStyleObject(style, theme);\n const resolvedDataStyle = getStyleObject(dataStyle, theme);\n const baseStyle = { ...resolvedStyle, ...resolvedDataStyle };\n const baseOpacity = typeof baseStyle.opacity === 'number' ? baseStyle.opacity : 1;\n const swipeOpacity = dismissed ? 0 : 1 - Math.min(Math.abs(offset) / 200, 1) * 0.6;\n const resolvedTransitionDuration =\n baseStyle.transitionDuration ??\n `${transitionDuration}ms, ${transitionDuration}ms, ${transitionDuration}ms`;\n const notificationStyle = {\n ...baseStyle,\n ['--notifications-state-transform' as string]:\n typeof baseStyle.transform === 'string' ? baseStyle.transform : 'translateX(0)',\n ['--notifications-state-opacity' as string]: String(baseOpacity),\n ['--notifications-swipe-offset' as string]: `${offset}px`,\n ['--notifications-swipe-opacity' as string]: String(swipeOpacity),\n transform:\n 'var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)',\n opacity: 'calc(var(--notifications-state-opacity) * var(--notifications-swipe-opacity))',\n transitionDuration:\n active || scrollDismissActive ? '0ms, 0ms, 0ms' : resolvedTransitionDuration,\n cursor: 'default',\n touchAction: 'pan-y',\n } as React.CSSProperties;\n\n const handleMouseEnter = () => {\n hoveredRef.current = true;\n cancelAutoClose();\n onHoverStart?.();\n };\n\n const handleMouseLeave = () => {\n hoveredRef.current = false;\n if (!scrollDismissActive) {\n resetSwipe();\n handleAutoClose();\n }\n onHoverEnd?.();\n };\n\n const handleWheel = useEffectEvent((event: WheelEvent) => {\n if (dismissed || active) {\n return;\n }\n\n const isDocumentEvent = event.currentTarget === document;\n if (!isDocumentEvent && !hoveredRef.current) {\n return;\n }\n\n const { deltaX, deltaY } = event;\n if (Math.abs(deltaX) <= Math.abs(deltaY) || deltaX === 0) {\n return;\n }\n\n if (!allowScrollDismiss || isCloseDisabled) {\n return;\n }\n\n if (!isDocumentEvent) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n cancelAutoClose();\n setScrollDismissActive(true);\n\n const nextOffset = offsetRef.current - deltaX;\n const direction = nextOffset > 0 ? 1 : -1;\n\n if (shouldDismiss(nextOffset, 0)) {\n dismissNotification(direction);\n return;\n }\n\n setSwipeOffset(nextOffset);\n scheduleScrollDismissReset();\n });\n\n useEffect(() => {\n if (!scrollDismissActive) {\n return undefined;\n }\n\n document.addEventListener('wheel', handleWheel, { passive: false });\n return () => document.removeEventListener('wheel', handleWheel, { passive: false } as any);\n }, [scrollDismissActive]);\n\n useEffect(() => {\n const handleResize = () => {\n if (dismissed) {\n setSwipeOffset(getExitOffset(dismissDirection));\n }\n };\n\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, [dismissDirection, dismissed]);\n\n useEffect(() => {\n const node = notificationRef.current;\n if (!node) {\n return undefined;\n }\n\n node.addEventListener('wheel', handleWheel, { passive: false });\n return () => node.removeEventListener('wheel', handleWheel, { passive: false } as any);\n }, []);\n\n useEffect(() => {\n return () => {\n cancelHide();\n cancelScrollDismissReset();\n };\n }, []);\n\n useEffect(() => {\n data.onOpen?.(data);\n }, []);\n\n useEffect(() => {\n handleAutoClose();\n return cancelAutoClose;\n }, [autoCloseDuration, active, dismissed]);\n\n useEffect(() => {\n if (paused) {\n cancelAutoClose();\n } else {\n handleAutoClose();\n }\n\n return cancelAutoClose;\n }, [paused]);\n\n return (\n <Notification\n ref={mergedRef}\n {...others}\n style={notificationStyle}\n {...notificationProps}\n withCloseButton={isCloseDisabled ? false : withCloseButton}\n onClose={handleHide}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {message}\n </Notification>\n );\n}\n\nNotificationContainer.displayName = '@mantine/notifications/NotificationContainer';\n"],"mappings":";;;;;;;AAMA,MAAM,+BAA+B;AAerC,SAAgB,sBAAsB,EACpC,MACA,QACA,WACA,oBACA,kBACA,oBACA,QACA,cACA,YACA,KACA,OACA,GAAG,UAC0B;CAC7B,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CACtC,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,kBAAkB,uBAAuB,SAAiB,CAAC;CAClE,MAAM,CAAC,qBAAqB,0BAA0B,SAAS,KAAK;CACpE,MAAM,QAAQ,gBAAgB;CAC9B,MAAM,EACJ,WAAW,YACX,SACA,YACA,UAAU,WACV,OAAO,WACP,iBACA,QAAQ,SACR,UAAU,WACV,YAAY,WACZ,GAAG,sBACD;CACJ,MAAM,oBAAoB,aAAa,WAAW,KAAK,SAAS;CAChE,MAAM,mBAAmB,OAAe,EAAE;CAC1C,MAAM,cAAc,OAAe,EAAE;CACrC,MAAM,uBAAuB,OAAe,EAAE;CAC9C,MAAM,kBAAkB,OAAuB,IAAI;CACnD,MAAM,aAAa,OAAO,KAAK;CAC/B,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,kBAAkB,eAAe;CAEvC,MAAM,wBAAwB,OAAO,aAAa,iBAAiB,OAAO;CAC1E,MAAM,mBAAmB,OAAO,aAAa,YAAY,OAAO;CAChE,MAAM,iCAAiC,OAAO,aAAa,qBAAqB,OAAO;CAEvF,MAAM,kBAAkB,UAAkB;EACxC,UAAU,UAAU;EACpB,UAAU,KAAK;CACjB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B;OAEhB,gBAAgB;EAGlB,OAAO;CACT,GAAG,CAAC,MAAM,CAAC;CAEX,OACE,oBAAC,cAAD;EACE,KAAK;EACL,GAAI;EACJ,OAAO;EACP,GAAI;EACJ,iBAAiB,kBAAkB,QAAQ;EAC3C,SAAS;EACT,cAAc;EACd,cAAc;YAEb;CACW,CAAA;AAElB;AAEA,sBAAsB,cAAc"}
|
|
1
|
+
{"version":3,"file":"NotificationContainer.mjs","names":[],"sources":["../src/NotificationContainer.tsx"],"sourcesContent":["import { useEffect, useEffectEvent, useRef, useState } from 'react';\nimport {\n extractStyleProps,\n getStyleObject,\n Notification,\n NotificationProps,\n useMantineTheme,\n} from '@mantine/core';\nimport { useDrag, useMergedRef } from '@mantine/hooks';\nimport { getAutoClose } from './get-auto-close/get-auto-close';\nimport { NotificationData } from './notifications.store';\n\nconst SCROLL_DISMISS_RESET_TIMEOUT = 120;\n\ninterface NotificationContainerProps extends NotificationProps {\n data: NotificationData;\n onHide: (id: string) => void;\n autoClose: number | false;\n transitionDuration: number;\n allowDragDismiss: boolean;\n allowScrollDismiss: boolean;\n paused: boolean;\n onHoverStart?: () => void;\n onHoverEnd?: () => void;\n onExpandRequest?: () => void;\n ref?: React.Ref<HTMLDivElement>;\n renderNotification?: ((notification: NotificationData) => React.ReactNode) | null;\n layout?: 'default' | 'stacked';\n stackIndex?: number;\n stackSize?: number;\n stackPosition?: string;\n stackExpanded?: boolean;\n stackExpandedOffset?: number;\n transitionState?: string;\n}\n\nconst MAX_VISIBLE_STACK_DEPTH = 4;\n\n/**\n * Props that belong to the default `Notification` rendering or to the Styles API and must\n * not reach the plain `div` used for custom rendering. Everything else is a valid div prop\n * and is forwarded – an allow list would silently drop supported props like `onClick`,\n * `dir`, `lang` or `hidden`.\n */\nconst NON_DOM_PROPS = new Set([\n 'classNames',\n 'styles',\n 'unstyled',\n 'vars',\n 'attributes',\n 'variant',\n 'color',\n 'radius',\n 'icon',\n 'title',\n 'loading',\n 'withBorder',\n 'withCloseButton',\n 'closeButtonProps',\n 'className',\n 'style',\n 'role',\n 'ref',\n 'children',\n 'mod',\n]);\n\nfunction pickDomProps(props: Record<string, any>) {\n // Mantine style props (`mt`, `bg`, `w`, …) are valid `NotificationProps` but are not DOM\n // attributes, so they are separated out rather than leaked onto the element.\n const { rest } = extractStyleProps(props);\n\n return Object.fromEntries(\n Object.entries(rest).filter(([key, value]) => !NON_DOM_PROPS.has(key) && value !== undefined)\n );\n}\n\nexport function NotificationContainer({\n data,\n onHide,\n autoClose,\n transitionDuration,\n allowDragDismiss,\n allowScrollDismiss,\n paused,\n onHoverStart,\n onHoverEnd,\n onExpandRequest,\n ref,\n style,\n renderNotification,\n layout,\n stackIndex,\n stackSize,\n stackPosition,\n stackExpanded,\n stackExpandedOffset,\n transitionState,\n ...others\n}: NotificationContainerProps) {\n const [offset, setOffset] = useState(0);\n const [dismissed, setDismissed] = useState(false);\n const [dismissDirection, setDismissDirection] = useState<-1 | 1>(1);\n const [scrollDismissActive, setScrollDismissActive] = useState(false);\n const theme = useMantineTheme();\n const {\n autoClose: _autoClose,\n message,\n allowClose,\n position: _position,\n style: dataStyle,\n withCloseButton,\n renderNotification: _renderNotification,\n onOpen: _onOpen,\n priority: _priority,\n __sequence: _sequence,\n ...notificationProps\n } = data as NotificationData & { __sequence?: number };\n const autoCloseDuration = getAutoClose(autoClose, data.autoClose);\n const autoCloseTimeout = useRef<number>(-1);\n const hideTimeout = useRef<number>(-1);\n const scrollDismissTimeout = useRef<number>(-1);\n const notificationRef = useRef<HTMLDivElement>(null);\n const hoveredRef = useRef(false);\n const focusedRef = useRef(false);\n\n // Hover and focus both keep the notification \"active\". The contribution to the parent\n // counter is tracked so it can be released on unmount – a notification dismissed while\n // hovered or focused never fires `mouseleave` or `blur`, which would otherwise leave the\n // stack expanded and auto close paused forever.\n const contributedActiveRef = useRef(false);\n const offsetRef = useRef(0);\n const isCloseDisabled = allowClose === false;\n\n const syncActive = () => {\n const shouldContribute = hoveredRef.current || focusedRef.current;\n\n if (shouldContribute && !contributedActiveRef.current) {\n contributedActiveRef.current = true;\n onHoverStart?.();\n } else if (!shouldContribute && contributedActiveRef.current) {\n contributedActiveRef.current = false;\n onHoverEnd?.();\n }\n };\n\n const releaseActive = useEffectEvent(() => {\n if (contributedActiveRef.current) {\n contributedActiveRef.current = false;\n onHoverEnd?.();\n }\n });\n\n useEffect(() => () => releaseActive(), []);\n\n const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout.current);\n const cancelHide = () => window.clearTimeout(hideTimeout.current);\n const cancelScrollDismissReset = () => window.clearTimeout(scrollDismissTimeout.current);\n\n const setSwipeOffset = (value: number) => {\n offsetRef.current = value;\n setOffset(value);\n };\n\n const handleHide = () => {\n onHide(data.id!);\n cancelAutoClose();\n cancelHide();\n cancelScrollDismissReset();\n };\n\n // `handleAutoClose` is also called from timeouts scheduled in earlier renders, so the\n // latest `paused` is read through a ref. Written in an effect rather than during render –\n // this effect is declared before every effect that calls `handleAutoClose`, so it is\n // always up to date by the time they run.\n const pausedRef = useRef(paused);\n\n useEffect(() => {\n pausedRef.current = paused;\n });\n\n const handleAutoClose = () => {\n if (\n dismissed ||\n active ||\n hoveredRef.current ||\n focusedRef.current ||\n pausedRef.current ||\n typeof autoCloseDuration !== 'number'\n ) {\n return;\n }\n\n cancelAutoClose();\n autoCloseTimeout.current = window.setTimeout(handleHide, autoCloseDuration);\n };\n\n const getExitOffset = (direction: -1 | 1) => {\n const width = notificationRef.current?.offsetWidth ?? 440;\n return direction * (width + 40);\n };\n\n const shouldDismiss = (movement: number, velocity: number) => {\n const width = notificationRef.current?.offsetWidth ?? 440;\n return Math.abs(movement) > width * 0.35 || velocity > 0.5;\n };\n\n const resetSwipe = () => {\n cancelScrollDismissReset();\n setScrollDismissActive(false);\n setSwipeOffset(0);\n };\n\n const dismissNotification = (direction: -1 | 1) => {\n setDismissDirection(direction);\n setDismissed(true);\n setScrollDismissActive(false);\n setSwipeOffset(getExitOffset(direction));\n cancelAutoClose();\n cancelHide();\n cancelScrollDismissReset();\n hideTimeout.current = window.setTimeout(handleHide, transitionDuration);\n };\n\n const scheduleScrollDismissReset = () => {\n cancelScrollDismissReset();\n scrollDismissTimeout.current = window.setTimeout(() => {\n setScrollDismissActive(false);\n setSwipeOffset(0);\n handleAutoClose();\n }, SCROLL_DISMISS_RESET_TIMEOUT);\n };\n\n const { ref: dragRef, active } = useDrag<HTMLDivElement>(\n (state) => {\n if (dismissed) {\n return;\n }\n\n if (state.first) {\n cancelAutoClose();\n }\n\n if (state.last) {\n if (state.tap || state.canceled) {\n setSwipeOffset(0);\n handleAutoClose();\n return;\n }\n\n const movement = state.movement[0];\n const direction =\n movement === 0 ? (state.direction[0] === -1 ? -1 : 1) : movement > 0 ? 1 : -1;\n\n if (shouldDismiss(movement, state.velocity[0])) {\n dismissNotification(direction);\n } else {\n setSwipeOffset(0);\n handleAutoClose();\n }\n } else {\n setSwipeOffset(state.movement[0]);\n }\n },\n {\n axis: 'x',\n threshold: 5,\n filterTaps: true,\n enabled: allowDragDismiss && !isCloseDisabled && !dismissed,\n }\n );\n\n const mergedRef = useMergedRef(ref, notificationRef, dragRef);\n const resolvedStyle = getStyleObject(style, theme);\n const resolvedDataStyle = getStyleObject(dataStyle, theme);\n const baseStyle = { ...resolvedStyle, ...resolvedDataStyle };\n const baseOpacity = typeof baseStyle.opacity === 'number' ? baseStyle.opacity : 1;\n const swipeOpacity = dismissed ? 0 : 1 - Math.min(Math.abs(offset) / 200, 1) * 0.6;\n const resolvedTransitionDuration =\n baseStyle.transitionDuration ??\n `${transitionDuration}ms, ${transitionDuration}ms, ${transitionDuration}ms`;\n\n const isStackedLayout = layout === 'stacked';\n const isStacked = isStackedLayout && stackIndex !== undefined && stackIndex > 0;\n const isCollapsed = isStacked && !stackExpanded;\n const isExiting = transitionState === 'exiting' || transitionState === 'exited';\n const stackDirection = stackPosition?.startsWith('top') ? 1 : -1;\n\n // Only a few layers are visible behind the front notification – without a cap the scale\n // below reaches 0 at 34 stacked notifications and inverts beyond that, which `limit` can\n // easily exceed.\n const stackDepth = Math.min(stackIndex ?? 0, MAX_VISIBLE_STACK_DEPTH);\n const collapsedOffset = isCollapsed ? stackDepth * 10 * stackDirection : 0;\n const staggerDelay = isStackedLayout ? (stackIndex || 0) * 30 : 0;\n const isDragging = active || scrollDismissActive;\n\n const getStackedTransform = () => {\n if (!isStackedLayout) {\n return 'var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)';\n }\n\n if (isExiting) {\n const exitOffset = stackExpanded ? stackExpandedOffset || 0 : collapsedOffset;\n return `translateY(${exitOffset}px) var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)`;\n }\n\n if (stackExpanded) {\n return `translateY(${stackExpandedOffset || 0}px) translate3d(var(--notifications-swipe-offset), 0, 0)`;\n }\n\n if (isStacked) {\n return `scale(${1 - stackDepth * 0.03}) translateY(${collapsedOffset}px)`;\n }\n\n return 'var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)';\n };\n\n const notificationStyle = {\n ...baseStyle,\n ...(isStackedLayout ? { maxHeight: undefined } : {}),\n ['--notifications-state-transform' as string]:\n typeof baseStyle.transform === 'string' ? baseStyle.transform : 'translateX(0)',\n ['--notifications-state-opacity' as string]: String(baseOpacity),\n ['--notifications-swipe-offset' as string]: `${offset}px`,\n ['--notifications-swipe-opacity' as string]: String(swipeOpacity),\n transform: getStackedTransform(),\n opacity: 'calc(var(--notifications-state-opacity) * var(--notifications-swipe-opacity))',\n transitionDuration: isDragging ? '0ms, 0ms, 0ms' : resolvedTransitionDuration,\n cursor: 'default',\n touchAction: 'pan-y',\n ...(isStackedLayout\n ? {\n gridArea: '1 / 1' as const,\n // `z-index` is not animatable, so it must not depend on `stackExpanded` – flipping\n // the stack to a single layer on hover repaints every notification in front of the\n // first one a frame before the reveal transform has moved anything.\n zIndex: (stackSize || 5) - (stackIndex ?? 0),\n pointerEvents: isCollapsed ? ('none' as const) : undefined,\n alignSelf: stackDirection === 1 ? ('start' as const) : ('end' as const),\n transition: isDragging\n ? 'none'\n : `transform ${transitionDuration}ms cubic-bezier(.51,.3,0,1.21), opacity ${transitionDuration}ms ease`,\n transitionDelay: isDragging || isExiting ? '0ms' : `${staggerDelay}ms`,\n }\n : {}),\n } as React.CSSProperties;\n\n const handleMouseEnter = () => {\n hoveredRef.current = true;\n cancelAutoClose();\n syncActive();\n };\n\n const handleMouseLeave = () => {\n hoveredRef.current = false;\n if (!scrollDismissActive) {\n resetSwipe();\n handleAutoClose();\n }\n syncActive();\n };\n\n // Keyboard users never trigger the hover handlers, and touch devices have no hover at\n // all – both need a way to expand a collapsed stack. Scoped to the stacked layout: its\n // only purpose is keeping the stack expanded, and applying it everywhere would silently\n // change the default layout, where a notification that merely contains the focused\n // element (an action button the user just clicked) would stop auto closing.\n const handleFocusCapture = isStackedLayout\n ? () => {\n focusedRef.current = true;\n cancelAutoClose();\n syncActive();\n }\n : undefined;\n\n const handleBlurCapture = isStackedLayout\n ? () => {\n focusedRef.current = false;\n if (!scrollDismissActive) {\n handleAutoClose();\n }\n syncActive();\n }\n : undefined;\n\n const handlePointerDownCapture = (event: React.PointerEvent) => {\n // Explicitly opt in for touch and pen: hover already covers the mouse, and an unknown\n // pointer type should not pin the stack open.\n if (isStackedLayout && (event.pointerType === 'touch' || event.pointerType === 'pen')) {\n onExpandRequest?.();\n }\n };\n\n const handleWheel = useEffectEvent((event: WheelEvent) => {\n if (dismissed || active) {\n return;\n }\n\n const isDocumentEvent = event.currentTarget === document;\n if (!isDocumentEvent && !hoveredRef.current) {\n return;\n }\n\n const { deltaX, deltaY } = event;\n if (Math.abs(deltaX) <= Math.abs(deltaY) || deltaX === 0) {\n return;\n }\n\n if (!allowScrollDismiss || isCloseDisabled) {\n return;\n }\n\n if (!isDocumentEvent) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n cancelAutoClose();\n setScrollDismissActive(true);\n\n const nextOffset = offsetRef.current - deltaX;\n const direction = nextOffset > 0 ? 1 : -1;\n\n if (shouldDismiss(nextOffset, 0)) {\n dismissNotification(direction);\n return;\n }\n\n setSwipeOffset(nextOffset);\n scheduleScrollDismissReset();\n });\n\n useEffect(() => {\n if (!scrollDismissActive) {\n return undefined;\n }\n\n document.addEventListener('wheel', handleWheel, { passive: false });\n return () => document.removeEventListener('wheel', handleWheel, { passive: false } as any);\n }, [scrollDismissActive]);\n\n useEffect(() => {\n const handleResize = () => {\n if (dismissed) {\n setSwipeOffset(getExitOffset(dismissDirection));\n }\n };\n\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, [dismissDirection, dismissed]);\n\n useEffect(() => {\n const node = notificationRef.current;\n if (!node) {\n return undefined;\n }\n\n node.addEventListener('wheel', handleWheel, { passive: false });\n return () => node.removeEventListener('wheel', handleWheel, { passive: false } as any);\n }, []);\n\n useEffect(() => {\n return () => {\n cancelHide();\n cancelScrollDismissReset();\n };\n }, []);\n\n useEffect(() => {\n data.onOpen?.(data);\n }, []);\n\n useEffect(() => {\n handleAutoClose();\n return cancelAutoClose;\n }, [autoCloseDuration, active, dismissed]);\n\n useEffect(() => {\n if (paused) {\n cancelAutoClose();\n } else {\n handleAutoClose();\n }\n\n return cancelAutoClose;\n }, [paused]);\n\n const consumerProps: Record<string, any> = { ...others, ...notificationProps };\n\n // The interaction handlers below are internal, but the same events are part of the public\n // props of both `Notifications` and every notification – they are composed with whatever\n // the consumer passed instead of replacing it.\n const interactionProps = {\n style: notificationStyle,\n // A collapsed notification is hidden behind the one in front of it – `pointer-events`\n // alone does not take its controls out of the tab order or hide them from a screen\n // reader, so it is fully inert until the stack is expanded.\n inert: isCollapsed,\n onMouseEnter: (event: React.MouseEvent<HTMLDivElement>) => {\n consumerProps.onMouseEnter?.(event);\n handleMouseEnter();\n },\n onMouseLeave: (event: React.MouseEvent<HTMLDivElement>) => {\n consumerProps.onMouseLeave?.(event);\n handleMouseLeave();\n },\n onFocusCapture: (event: React.FocusEvent<HTMLDivElement>) => {\n consumerProps.onFocusCapture?.(event);\n handleFocusCapture?.();\n },\n onBlurCapture: (event: React.FocusEvent<HTMLDivElement>) => {\n consumerProps.onBlurCapture?.(event);\n handleBlurCapture?.();\n },\n onPointerDownCapture: (event: React.PointerEvent<HTMLDivElement>) => {\n consumerProps.onPointerDownCapture?.(event);\n handlePointerDownCapture(event);\n },\n };\n\n if (renderNotification) {\n const classNames = [others.className, notificationProps.className].filter(Boolean).join(' ');\n\n return (\n <div\n ref={mergedRef}\n role={notificationProps.role || others.role || 'alert'}\n {...pickDomProps(consumerProps)}\n className={classNames || undefined}\n {...interactionProps}\n >\n {renderNotification(data)}\n </div>\n );\n }\n\n return (\n <Notification\n ref={mergedRef}\n {...others}\n {...notificationProps}\n {...interactionProps}\n withCloseButton={isCloseDisabled ? false : withCloseButton}\n onClose={handleHide}\n >\n {message}\n </Notification>\n );\n}\n\nNotificationContainer.displayName = '@mantine/notifications/NotificationContainer';\n"],"mappings":";;;;;;;AAYA,MAAM,+BAA+B;AAwBrC,MAAM,0BAA0B;;;;;;;AAQhC,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,aAAa,OAA4B;CAGhD,MAAM,EAAE,SAAS,kBAAkB,KAAK;CAExC,OAAO,OAAO,YACZ,OAAO,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,WAAW,CAAC,cAAc,IAAI,GAAG,KAAK,UAAU,KAAA,CAAS,CAC9F;AACF;AAEA,SAAgB,sBAAsB,EACpC,MACA,QACA,WACA,oBACA,kBACA,oBACA,QACA,cACA,YACA,iBACA,KACA,OACA,oBACA,QACA,YACA,WACA,eACA,eACA,qBACA,iBACA,GAAG,UAC0B;CAC7B,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CACtC,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,M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