UNPKG

@cookbookdev/sonner

Version:

An opinionated toast component for React.

1 lines 60.9 kB
{"version":3,"sources":["../src/index.tsx","../src/assets.tsx","../src/hooks.tsx","../src/state.ts","../src/types.ts"],"sourcesContent":["'use client';\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { getAsset, Loader } from './assets';\nimport { useIsDocumentHidden } from './hooks';\nimport { toast, ToastState } from './state';\nimport {\n isAction,\n type ExternalToast,\n type HeightT,\n type ToasterProps,\n type ToastProps,\n type ToastT,\n type ToastToDismiss,\n} from './types';\n\n// Visible toasts amount\nconst VISIBLE_TOASTS_AMOUNT = 3;\n\n// Viewport padding\nconst VIEWPORT_OFFSET = '32px';\n\n// Default lifetime of a toasts (in ms)\nconst TOAST_LIFETIME = 4000;\n\n// Default toast width\nconst TOAST_WIDTH = 356;\n\n// Default gap between toasts\nconst GAP = 14;\n\n// Threshold to dismiss a toast\nconst SWIPE_THRESHOLD = 20;\n\n// Equal to exit animation duration\nconst TIME_BEFORE_UNMOUNT = 200;\n\nfunction _cn(...classes: (string | undefined)[]) {\n return classes.filter(Boolean).join(' ');\n}\n\nconst Toast = (props: ToastProps) => {\n const {\n invert: ToasterInvert,\n toast,\n unstyled,\n interacting,\n setHeights,\n visibleToasts,\n heights,\n index,\n toasts,\n expanded,\n removeToast,\n defaultRichColors,\n closeButton: closeButtonFromToaster,\n style,\n cancelButtonStyle,\n actionButtonStyle,\n className = '',\n descriptionClassName = '',\n duration: durationFromToaster,\n position,\n gap,\n loadingIcon: loadingIconProp,\n expandByDefault,\n classNames,\n icons,\n closeButtonAriaLabel = 'Close toast',\n pauseWhenPageIsHidden,\n cn,\n } = props;\n const [mounted, setMounted] = React.useState(false);\n const [removed, setRemoved] = React.useState(false);\n const [swiping, setSwiping] = React.useState(false);\n const [swipeOut, setSwipeOut] = React.useState(false);\n const [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);\n const [initialHeight, setInitialHeight] = React.useState(0);\n const dragStartTime = React.useRef<Date | null>(null);\n const toastRef = React.useRef<HTMLLIElement>(null);\n const isFront = index === 0;\n const isVisible = index + 1 <= visibleToasts;\n const toastType = toast.type;\n const dismissible = toast.dismissible !== false;\n const toastClassname = toast.className || '';\n const toastDescriptionClassname = toast.descriptionClassName || '';\n // Height index is used to calculate the offset as it gets updated before the toast array, which means we can calculate the new layout faster.\n const heightIndex = React.useMemo(\n () => heights.findIndex((height) => height.toastId === toast.id) || 0,\n [heights, toast.id],\n );\n const closeButton = React.useMemo(\n () => toast.closeButton ?? closeButtonFromToaster,\n [toast.closeButton, closeButtonFromToaster],\n );\n const duration = React.useMemo(\n () => toast.duration || durationFromToaster || TOAST_LIFETIME,\n [toast.duration, durationFromToaster],\n );\n const closeTimerStartTimeRef = React.useRef(0);\n const offset = React.useRef(0);\n const lastCloseTimerStartTimeRef = React.useRef(0);\n const pointerStartRef = React.useRef<{ x: number; y: number } | null>(null);\n const [y, x] = position.split('-');\n const toastsHeightBefore = React.useMemo(() => {\n return heights.reduce((prev, curr, reducerIndex) => {\n // Calculate offset up until current toast\n if (reducerIndex >= heightIndex) {\n return prev;\n }\n\n return prev + curr.height;\n }, 0);\n }, [heights, heightIndex]);\n const isDocumentHidden = useIsDocumentHidden();\n\n const invert = toast.invert || ToasterInvert;\n const disabled = toastType === 'loading';\n\n offset.current = React.useMemo(() => heightIndex * gap + toastsHeightBefore, [heightIndex, toastsHeightBefore]);\n\n React.useEffect(() => {\n // Trigger enter animation without using CSS animation\n setMounted(true);\n }, []);\n\n React.useLayoutEffect(() => {\n if (!mounted) return;\n const toastNode = toastRef.current;\n const originalHeight = toastNode.style.height;\n toastNode.style.height = 'auto';\n const newHeight = toastNode.getBoundingClientRect().height;\n toastNode.style.height = originalHeight;\n\n setInitialHeight(newHeight);\n\n setHeights((heights) => {\n const alreadyExists = heights.find((height) => height.toastId === toast.id);\n if (!alreadyExists) {\n return [{ toastId: toast.id, height: newHeight, position: toast.position }, ...heights];\n } else {\n return heights.map((height) => (height.toastId === toast.id ? { ...height, height: newHeight } : height));\n }\n });\n }, [mounted, toast.title, toast.description, setHeights, toast.id]);\n\n const deleteToast = React.useCallback(() => {\n // Save the offset for the exit swipe animation\n setRemoved(true);\n setOffsetBeforeRemove(offset.current);\n setHeights((h) => h.filter((height) => height.toastId !== toast.id));\n\n setTimeout(() => {\n removeToast(toast);\n }, TIME_BEFORE_UNMOUNT);\n }, [toast, removeToast, setHeights, offset]);\n\n React.useEffect(() => {\n if ((toast.promise && toastType === 'loading') || toast.duration === Infinity || toast.type === 'loading') return;\n let timeoutId: NodeJS.Timeout;\n let remainingTime = duration;\n\n // Pause the timer on each hover\n const pauseTimer = () => {\n if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {\n // Get the elapsed time since the timer started\n const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;\n\n remainingTime = remainingTime - elapsedTime;\n }\n\n lastCloseTimerStartTimeRef.current = new Date().getTime();\n };\n\n const startTimer = () => {\n // setTimeout(, Infinity) behaves as if the delay is 0.\n // As a result, the toast would be closed immediately, giving the appearance that it was never rendered.\n // See: https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#an-infinite-timeout\n if (remainingTime === Infinity) return;\n\n closeTimerStartTimeRef.current = new Date().getTime();\n\n // Let the toast know it has started\n timeoutId = setTimeout(() => {\n toast.onAutoClose?.(toast);\n deleteToast();\n }, remainingTime);\n };\n\n if (expanded || interacting || (pauseWhenPageIsHidden && isDocumentHidden)) {\n pauseTimer();\n } else {\n startTimer();\n }\n\n return () => clearTimeout(timeoutId);\n }, [\n expanded,\n interacting,\n expandByDefault,\n toast,\n duration,\n deleteToast,\n toast.promise,\n toastType,\n pauseWhenPageIsHidden,\n isDocumentHidden,\n ]);\n\n React.useEffect(() => {\n const toastNode = toastRef.current;\n\n if (toastNode) {\n const height = toastNode.getBoundingClientRect().height;\n\n // Add toast height tot heights array after the toast is mounted\n setInitialHeight(height);\n setHeights((h) => [{ toastId: toast.id, height, position: toast.position }, ...h]);\n\n return () => setHeights((h) => h.filter((height) => height.toastId !== toast.id));\n }\n }, [setHeights, toast.id]);\n\n React.useEffect(() => {\n if (toast.delete) {\n deleteToast();\n }\n }, [deleteToast, toast.delete]);\n\n function getLoadingIcon() {\n if (icons?.loading) {\n return (\n <div className=\"sonner-loader\" data-visible={toastType === 'loading'}>\n {icons.loading}\n </div>\n );\n }\n\n if (loadingIconProp) {\n return (\n <div className=\"sonner-loader\" data-visible={toastType === 'loading'}>\n {loadingIconProp}\n </div>\n );\n }\n return <Loader visible={toastType === 'loading'} />;\n }\n\n return (\n <li\n aria-live={toast.important ? 'assertive' : 'polite'}\n aria-atomic=\"true\"\n role=\"status\"\n tabIndex={0}\n ref={toastRef}\n className={cn(\n className,\n toastClassname,\n classNames?.toast,\n toast?.classNames?.toast,\n classNames?.default,\n classNames?.[toastType],\n toast?.classNames?.[toastType],\n )}\n data-sonner-toast=\"\"\n data-rich-colors={toast.richColors ?? defaultRichColors}\n data-styled={!Boolean(toast.jsx || toast.unstyled || unstyled)}\n data-mounted={mounted}\n data-promise={Boolean(toast.promise)}\n data-removed={removed}\n data-visible={isVisible}\n data-y-position={y}\n data-x-position={x}\n data-index={index}\n data-front={isFront}\n data-swiping={swiping}\n data-dismissible={dismissible}\n data-type={toastType}\n data-invert={invert}\n data-swipe-out={swipeOut}\n data-expanded={Boolean(expanded || (expandByDefault && mounted))}\n style={\n {\n '--index': index,\n '--toasts-before': index,\n '--z-index': toasts.length - index,\n '--offset': `${removed ? offsetBeforeRemove : offset.current}px`,\n '--initial-height': expandByDefault ? 'auto' : `${initialHeight}px`,\n ...style,\n ...toast.style,\n } as React.CSSProperties\n }\n onPointerDown={(event) => {\n if (disabled || !dismissible) return;\n dragStartTime.current = new Date();\n setOffsetBeforeRemove(offset.current);\n // Ensure we maintain correct pointer capture even when going outside of the toast (e.g. when swiping)\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if ((event.target as HTMLElement).tagName === 'BUTTON') return;\n setSwiping(true);\n pointerStartRef.current = { x: event.clientX, y: event.clientY };\n }}\n onPointerUp={() => {\n if (swipeOut || !dismissible) return;\n\n pointerStartRef.current = null;\n const swipeAmount = Number(toastRef.current?.style.getPropertyValue('--swipe-amount').replace('px', '') || 0);\n const timeTaken = new Date().getTime() - dragStartTime.current?.getTime();\n const velocity = Math.abs(swipeAmount) / timeTaken;\n\n // Remove only if threshold is met\n if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {\n setOffsetBeforeRemove(offset.current);\n toast.onDismiss?.(toast);\n deleteToast();\n setSwipeOut(true);\n return;\n }\n\n toastRef.current?.style.setProperty('--swipe-amount', '0px');\n setSwiping(false);\n }}\n onPointerMove={(event) => {\n if (!pointerStartRef.current || !dismissible) return;\n\n const yPosition = event.clientY - pointerStartRef.current.y;\n const xPosition = event.clientX - pointerStartRef.current.x;\n\n const clamp = y === 'top' ? Math.min : Math.max;\n const clampedY = clamp(0, yPosition);\n const swipeStartThreshold = event.pointerType === 'touch' ? 10 : 2;\n const isAllowedToSwipe = Math.abs(clampedY) > swipeStartThreshold;\n\n if (isAllowedToSwipe) {\n toastRef.current?.style.setProperty('--swipe-amount', `${yPosition}px`);\n } else if (Math.abs(xPosition) > swipeStartThreshold) {\n // User is swiping in wrong direction so we disable swipe gesture\n // for the current pointer down interaction\n pointerStartRef.current = null;\n }\n }}\n >\n {closeButton && !toast.jsx ? (\n <button\n aria-label={closeButtonAriaLabel}\n data-disabled={disabled}\n data-close-button\n onClick={\n disabled || !dismissible\n ? () => { }\n : () => {\n deleteToast();\n toast.onDismiss?.(toast);\n }\n }\n className={cn(classNames?.closeButton, toast?.classNames?.closeButton)}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n </button>\n ) : null}\n {toast.jsx || React.isValidElement(toast.title) ? (\n toast.jsx || toast.title\n ) : (\n <>\n {toastType || toast.icon || toast.promise ? (\n <div data-icon=\"\" className={cn(classNames?.icon, toast?.classNames?.icon)}>\n {toast.promise || (toast.type === 'loading' && !toast.icon) ? toast.icon || getLoadingIcon() : null}\n {toast.type !== 'loading' ? toast.icon || icons?.[toastType] || getAsset(toastType) : null}\n </div>\n ) : null}\n\n <div data-content=\"\" className={cn(classNames?.content, toast?.classNames?.content)}>\n <div data-title=\"\" className={cn(classNames?.title, toast?.classNames?.title)}>\n {toast.title}\n </div>\n {toast.description ? (\n <div\n data-description=\"\"\n className={cn(\n descriptionClassName,\n toastDescriptionClassname,\n classNames?.description,\n toast?.classNames?.description,\n )}\n >\n {toast.description}\n </div>\n ) : null}\n </div>\n {React.isValidElement(toast.cancel) ? (\n toast.cancel\n ) : toast.cancel && isAction(toast.cancel) ? (\n <button\n data-button\n data-cancel\n style={toast.cancelButtonStyle || cancelButtonStyle}\n onClick={(event) => {\n // We need to check twice because typescript\n if (!isAction(toast.cancel)) return;\n if (!dismissible) return;\n toast.cancel.onClick?.(event);\n deleteToast();\n }}\n className={cn(classNames?.cancelButton, toast?.classNames?.cancelButton)}\n >\n {toast.cancel.label}\n </button>\n ) : null}\n {React.isValidElement(toast.action) ? (\n toast.action\n ) : toast.action && isAction(toast.action) ? (\n <button\n data-button\n data-action\n style={toast.actionButtonStyle || actionButtonStyle}\n onClick={(event) => {\n // We need to check twice because typescript\n if (!isAction(toast.action)) return;\n if (event.defaultPrevented) return;\n toast.action.onClick?.(event);\n deleteToast();\n }}\n className={cn(classNames?.actionButton, toast?.classNames?.actionButton)}\n >\n {toast.action.label}\n </button>\n ) : null}\n </>\n )}\n </li>\n );\n};\n\nfunction getDocumentDirection(): ToasterProps['dir'] {\n if (typeof window === 'undefined') return 'ltr';\n if (typeof document === 'undefined') return 'ltr'; // For Fresh purpose\n\n const dirAttribute = document.documentElement.getAttribute('dir');\n\n if (dirAttribute === 'auto' || !dirAttribute) {\n return window.getComputedStyle(document.documentElement).direction as ToasterProps['dir'];\n }\n\n return dirAttribute as ToasterProps['dir'];\n}\n\nfunction useSonner() {\n const [activeToasts, setActiveToasts] = React.useState<ToastT[]>([]);\n\n React.useEffect(() => {\n return ToastState.subscribe((toast) => {\n setActiveToasts((currentToasts) => {\n if ('dismiss' in toast && toast.dismiss) {\n return currentToasts.filter((t) => t.id !== toast.id);\n }\n\n const existingToastIndex = currentToasts.findIndex((t) => t.id === toast.id);\n if (existingToastIndex !== -1) {\n const updatedToasts = [...currentToasts];\n updatedToasts[existingToastIndex] = { ...updatedToasts[existingToastIndex], ...toast };\n return updatedToasts;\n } else {\n return [toast, ...currentToasts];\n }\n });\n });\n }, []);\n\n return {\n toasts: activeToasts,\n };\n}\n\nconst Toaster = (props: ToasterProps) => {\n const {\n invert,\n position = 'bottom-right',\n hotkey = ['altKey', 'KeyT'],\n expand,\n closeButton,\n className,\n offset,\n theme = 'light',\n richColors,\n duration,\n style,\n visibleToasts = VISIBLE_TOASTS_AMOUNT,\n toastOptions,\n dir = getDocumentDirection(),\n gap = GAP,\n loadingIcon,\n icons,\n containerAriaLabel = 'Notifications',\n pauseWhenPageIsHidden,\n cn = _cn,\n } = props;\n const [toasts, setToasts] = React.useState<ToastT[]>([]);\n const possiblePositions = React.useMemo(() => {\n return Array.from(\n new Set([position].concat(toasts.filter((toast) => toast.position).map((toast) => toast.position))),\n );\n }, [toasts, position]);\n const [heights, setHeights] = React.useState<HeightT[]>([]);\n const [expanded, setExpanded] = React.useState(false);\n const [interacting, setInteracting] = React.useState(false);\n const [actualTheme, setActualTheme] = React.useState(\n theme !== 'system'\n ? theme\n : typeof window !== 'undefined'\n ? window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light'\n : 'light',\n );\n\n const listRef = React.useRef<HTMLOListElement>(null);\n const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');\n const lastFocusedElementRef = React.useRef<HTMLElement>(null);\n const isFocusWithinRef = React.useRef(false);\n\n const removeToast = React.useCallback((toastToRemove: ToastT) => {\n setToasts((toasts) => {\n if (!toasts.find((toast) => toast.id === toastToRemove.id)?.delete) {\n ToastState.dismiss(toastToRemove.id);\n }\n\n return toasts.filter(({ id }) => id !== toastToRemove.id);\n });\n }, []);\n\n React.useEffect(() => {\n return ToastState.subscribe((toast) => {\n if ((toast as ToastToDismiss).dismiss) {\n setToasts((toasts) => toasts.map((t) => (t.id === toast.id ? { ...t, delete: true } : t)));\n return;\n }\n\n // Prevent batching, temp solution.\n setTimeout(() => {\n ReactDOM.flushSync(() => {\n setToasts((toasts) => {\n const indexOfExistingToast = toasts.findIndex((t) => t.id === toast.id);\n\n // Update the toast if it already exists\n if (indexOfExistingToast !== -1) {\n return [\n ...toasts.slice(0, indexOfExistingToast),\n { ...toasts[indexOfExistingToast], ...toast },\n ...toasts.slice(indexOfExistingToast + 1),\n ];\n }\n\n return [toast, ...toasts];\n });\n });\n });\n });\n }, []);\n\n React.useEffect(() => {\n if (theme !== 'system') {\n setActualTheme(theme);\n return;\n }\n\n if (theme === 'system') {\n // check if current preference is dark\n if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {\n // it's currently dark\n setActualTheme('dark');\n } else {\n // it's not dark\n setActualTheme('light');\n }\n }\n\n if (typeof window === 'undefined') return;\n\n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', ({ matches }) => {\n if (matches) {\n setActualTheme('dark');\n } else {\n setActualTheme('light');\n }\n });\n }, [theme]);\n\n React.useEffect(() => {\n // Ensure expanded is always false when no toasts are present / only one left\n if (toasts.length <= 1) {\n setExpanded(false);\n }\n }, [toasts]);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const isHotkeyPressed = hotkey.every((key) => (event as any)[key] || event.code === key);\n\n if (isHotkeyPressed) {\n setExpanded(true);\n listRef.current?.focus();\n }\n\n if (\n event.code === 'Escape' &&\n (document.activeElement === listRef.current || listRef.current?.contains(document.activeElement))\n ) {\n setExpanded(false);\n }\n };\n document.addEventListener('keydown', handleKeyDown);\n\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [hotkey]);\n\n React.useEffect(() => {\n if (listRef.current) {\n return () => {\n if (lastFocusedElementRef.current) {\n lastFocusedElementRef.current.focus({ preventScroll: true });\n lastFocusedElementRef.current = null;\n isFocusWithinRef.current = false;\n }\n };\n }\n }, [listRef.current]);\n\n if (!toasts.length) return null;\n\n return (\n // Remove item from normal navigation flow, only available via hotkey\n <section aria-label={`${containerAriaLabel} ${hotkeyLabel}`} tabIndex={-1}>\n {possiblePositions.map((position, index) => {\n const [y, x] = position.split('-');\n return (\n <ol\n key={position}\n dir={dir === 'auto' ? getDocumentDirection() : dir}\n tabIndex={-1}\n ref={listRef}\n className={className}\n data-sonner-toaster\n data-theme={actualTheme}\n data-y-position={y}\n data-x-position={x}\n style={\n {\n '--front-toast-height': `${heights[0]?.height || 0}px`,\n '--offset': typeof offset === 'number' ? `${offset}px` : offset || VIEWPORT_OFFSET,\n '--width': `${TOAST_WIDTH}px`,\n '--gap': `${gap}px`,\n ...style,\n } as React.CSSProperties\n }\n onBlur={(event) => {\n if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {\n isFocusWithinRef.current = false;\n if (lastFocusedElementRef.current) {\n lastFocusedElementRef.current.focus({ preventScroll: true });\n lastFocusedElementRef.current = null;\n }\n }\n }}\n onFocus={(event) => {\n const isNotDismissible =\n event.target instanceof HTMLElement && event.target.dataset.dismissible === 'false';\n\n if (isNotDismissible) return;\n\n if (!isFocusWithinRef.current) {\n isFocusWithinRef.current = true;\n lastFocusedElementRef.current = event.relatedTarget as HTMLElement;\n }\n }}\n onMouseEnter={() => setExpanded(true)}\n onMouseMove={() => setExpanded(true)}\n onMouseLeave={() => {\n // Avoid setting expanded to false when interacting with a toast, e.g. swiping\n if (!interacting) {\n setExpanded(false);\n }\n }}\n onPointerDown={(event) => {\n const isNotDismissible =\n event.target instanceof HTMLElement && event.target.dataset.dismissible === 'false';\n\n if (isNotDismissible) return;\n setInteracting(true);\n }}\n onPointerUp={() => setInteracting(false)}\n >\n {toasts\n .filter((toast) => (!toast.position && index === 0) || toast.position === position)\n .map((toast, index) => (\n <Toast\n key={toast.id}\n icons={icons}\n index={index}\n toast={toast}\n defaultRichColors={richColors}\n duration={toastOptions?.duration ?? duration}\n className={toastOptions?.className}\n descriptionClassName={toastOptions?.descriptionClassName}\n invert={invert}\n visibleToasts={visibleToasts}\n closeButton={toastOptions?.closeButton ?? closeButton}\n interacting={interacting}\n position={position}\n style={toastOptions?.style}\n unstyled={toastOptions?.unstyled}\n classNames={toastOptions?.classNames}\n cancelButtonStyle={toastOptions?.cancelButtonStyle}\n actionButtonStyle={toastOptions?.actionButtonStyle}\n removeToast={removeToast}\n toasts={toasts.filter((t) => t.position == toast.position)}\n heights={heights.filter((h) => h.position == toast.position)}\n setHeights={setHeights}\n expandByDefault={expand}\n gap={gap}\n loadingIcon={loadingIcon}\n expanded={expanded}\n pauseWhenPageIsHidden={pauseWhenPageIsHidden}\n cn={cn}\n />\n ))}\n </ol>\n );\n })}\n </section>\n );\n};\nexport { toast, Toaster, type ExternalToast, type ToastT, type ToasterProps, useSonner };\nexport { type ToastClassnames, type ToastToDismiss, type Action } from './types';\n","'use client';\nimport React from 'react';\nimport type { ToastTypes } from './types';\n\nexport const getAsset = (type: ToastTypes): JSX.Element | null => {\n switch (type) {\n case 'success':\n return SuccessIcon;\n\n case 'info':\n return InfoIcon;\n\n case 'warning':\n return WarningIcon;\n\n case 'error':\n return ErrorIcon;\n\n default:\n return null;\n }\n};\n\nconst bars = Array(12).fill(0);\n\nexport const Loader = ({ visible }: { visible: boolean }) => {\n return (\n <div className=\"sonner-loading-wrapper\" data-visible={visible}>\n <div className=\"sonner-spinner\">\n {bars.map((_, i) => (\n <div className=\"sonner-loading-bar\" key={`spinner-bar-${i}`} />\n ))}\n </div>\n </div>\n );\n};\n\nconst SuccessIcon = (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path\n fillRule=\"evenodd\"\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\"\n clipRule=\"evenodd\"\n />\n </svg>\n);\n\nconst WarningIcon = (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path\n fillRule=\"evenodd\"\n d=\"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z\"\n clipRule=\"evenodd\"\n />\n </svg>\n);\n\nconst InfoIcon = (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path\n fillRule=\"evenodd\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z\"\n clipRule=\"evenodd\"\n />\n </svg>\n);\n\nconst ErrorIcon = (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" height=\"20\" width=\"20\">\n <path\n fillRule=\"evenodd\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\"\n clipRule=\"evenodd\"\n />\n </svg>\n);\n","import React from 'react';\n\nexport const useIsDocumentHidden = () => {\n const [isDocumentHidden, setIsDocumentHidden] = React.useState(document.hidden);\n\n React.useEffect(() => {\n const callback = () => {\n setIsDocumentHidden(document.hidden);\n };\n document.addEventListener('visibilitychange', callback);\n return () => window.removeEventListener('visibilitychange', callback);\n }, []);\n\n return isDocumentHidden;\n};\n","import type { ExternalToast, PromiseData, PromiseT, ToastT, ToastToDismiss, ToastTypes } from './types';\n\nimport React from 'react';\n\nlet toastsCounter = 1;\n\nclass Observer {\n subscribers: Array<(toast: ExternalToast | ToastToDismiss) => void>;\n toasts: Array<ToastT | ToastToDismiss>;\n\n constructor() {\n this.subscribers = [];\n this.toasts = [];\n }\n\n // We use arrow functions to maintain the correct `this` reference\n subscribe = (subscriber: (toast: ToastT | ToastToDismiss) => void) => {\n this.subscribers.push(subscriber);\n\n return () => {\n const index = this.subscribers.indexOf(subscriber);\n this.subscribers.splice(index, 1);\n };\n };\n\n publish = (data: ToastT) => {\n this.subscribers.forEach((subscriber) => subscriber(data));\n };\n\n addToast = (data: ToastT) => {\n this.publish(data);\n this.toasts = [...this.toasts, data];\n };\n\n create = (\n data: ExternalToast & {\n message?: string | React.ReactNode;\n type?: ToastTypes;\n promise?: PromiseT;\n jsx?: React.ReactElement;\n },\n ) => {\n const { message, ...rest } = data;\n const id = typeof data?.id === 'number' || data.id?.length > 0 ? data.id : toastsCounter++;\n const alreadyExists = this.toasts.find((toast) => {\n return toast.id === id;\n });\n const dismissible = data.dismissible === undefined ? true : data.dismissible;\n\n if (alreadyExists) {\n this.toasts = this.toasts.map((toast) => {\n if (toast.id === id) {\n this.publish({ ...toast, ...data, id, title: message });\n return {\n ...toast,\n ...data,\n id,\n dismissible,\n title: message,\n };\n }\n\n return toast;\n });\n } else {\n this.addToast({ title: message, ...rest, dismissible, id });\n }\n\n return id;\n };\n\n dismiss = (id?: number | string) => {\n if (!id) {\n this.toasts.forEach((toast) => {\n this.subscribers.forEach((subscriber) => subscriber({ id: toast.id, dismiss: true }));\n });\n }\n\n this.subscribers.forEach((subscriber) => subscriber({ id, dismiss: true }));\n return id;\n };\n\n message = (message: string | React.ReactNode, data?: ExternalToast) => {\n return this.create({ ...data, message });\n };\n\n error = (message: string | React.ReactNode, data?: ExternalToast) => {\n return this.create({ ...data, message, type: 'error' });\n };\n\n success = (message: string | React.ReactNode, data?: ExternalToast) => {\n return this.create({ ...data, type: 'success', message });\n };\n\n info = (message: string | React.ReactNode, data?: ExternalToast) => {\n return this.create({ ...data, type: 'info', message });\n };\n\n warning = (message: string | React.ReactNode, data?: ExternalToast) => {\n return this.create({ ...data, type: 'warning', message });\n };\n\n loading = (message: string | React.ReactNode, data?: ExternalToast) => {\n return this.create({ ...data, type: 'loading', message });\n };\n\n promise = <ToastData>(promise: PromiseT<ToastData>, data?: PromiseData<ToastData>) => {\n if (!data) {\n // Nothing to show\n return;\n }\n\n let id: string | number | undefined = undefined;\n if (data.loading !== undefined) {\n id = this.create({\n ...data,\n promise,\n type: 'loading',\n message: data.loading,\n description: typeof data.description !== 'function' ? data.description : undefined,\n });\n }\n\n const p = promise instanceof Promise ? promise : promise();\n\n let shouldDismiss = id !== undefined;\n\n p.then(async (response) => {\n if (isHttpResponse(response) && !response.ok) {\n shouldDismiss = false;\n const message =\n typeof data.error === 'function' ? await data.error(`HTTP error! status: ${response.status}`) : data.error;\n const description =\n typeof data.description === 'function'\n ? await data.description(`HTTP error! status: ${response.status}`)\n : data.description;\n this.create({ id, type: 'error', message, description });\n } else if (data.success !== undefined) {\n shouldDismiss = false;\n const message = typeof data.success === 'function' ? await data.success(response) : data.success;\n const description =\n typeof data.description === 'function' ? await data.description(response) : data.description;\n this.create({ id, type: 'success', message, description });\n }\n })\n .catch(async (error) => {\n if (data.error !== undefined) {\n shouldDismiss = false;\n const message = typeof data.error === 'function' ? await data.error(error) : data.error;\n const description = typeof data.description === 'function' ? await data.description(error) : data.description;\n this.create({ id, type: 'error', message, description });\n }\n })\n .finally(() => {\n if (shouldDismiss) {\n // Toast is still in load state (and will be indefinitely — dismiss it)\n this.dismiss(id);\n id = undefined;\n }\n\n data.finally?.();\n });\n\n return id;\n };\n\n custom = (jsx: (id: number | string) => React.ReactElement, data?: ExternalToast) => {\n const id = data?.id || toastsCounter++;\n this.create({ jsx: jsx(id), id, ...data });\n return id;\n };\n}\n\nexport const ToastState = new Observer();\n\n// bind this to the toast function\nconst toastFunction = (message: string | React.ReactNode, data?: ExternalToast) => {\n const id = data?.id || toastsCounter++;\n\n ToastState.addToast({\n title: message,\n ...data,\n id,\n });\n return id;\n};\n\nconst isHttpResponse = (data: any): data is Response => {\n return (\n data &&\n typeof data === 'object' &&\n 'ok' in data &&\n typeof data.ok === 'boolean' &&\n 'status' in data &&\n typeof data.status === 'number'\n );\n};\n\nconst basicToast = toastFunction;\n\nconst getHistory = () => ToastState.toasts;\n\n// We use `Object.assign` to maintain the correct types as we would lose them otherwise\nexport const toast = Object.assign(\n basicToast,\n {\n success: ToastState.success,\n info: ToastState.info,\n warning: ToastState.warning,\n error: ToastState.error,\n custom: ToastState.custom,\n message: ToastState.message,\n promise: ToastState.promise,\n dismiss: ToastState.dismiss,\n loading: ToastState.loading,\n },\n { getHistory },\n);\n","import React from 'react';\n\nexport type ToastTypes = 'normal' | 'action' | 'success' | 'info' | 'warning' | 'error' | 'loading' | 'default';\n\nexport type PromiseT<Data = any> = Promise<Data> | (() => Promise<Data>);\n\nexport type PromiseTResult<Data = any> =\n | string\n | React.ReactNode\n | ((data: Data) => React.ReactNode | string | Promise<React.ReactNode | string>);\n\nexport type PromiseExternalToast = Omit<ExternalToast, 'description'>;\n\nexport type PromiseData<ToastData = any> = PromiseExternalToast & {\n loading?: string | React.ReactNode;\n success?: PromiseTResult<ToastData>;\n error?: PromiseTResult;\n description?: PromiseTResult;\n finally?: () => void | Promise<void>;\n};\n\nexport interface ToastClassnames {\n toast?: string;\n title?: string;\n description?: string;\n loader?: string;\n closeButton?: string;\n cancelButton?: string;\n actionButton?: string;\n success?: string;\n error?: string;\n info?: string;\n warning?: string;\n loading?: string;\n default?: string;\n content?: string;\n icon?: string;\n}\n\nexport interface ToastIcons {\n success?: React.ReactNode;\n info?: React.ReactNode;\n warning?: React.ReactNode;\n error?: React.ReactNode;\n loading?: React.ReactNode;\n}\n\nexport interface Action {\n label: React.ReactNode;\n onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n actionButtonStyle?: React.CSSProperties;\n}\n\nexport interface ToastT {\n id: number | string;\n title?: string | React.ReactNode;\n type?: ToastTypes;\n icon?: React.ReactNode;\n jsx?: React.ReactNode;\n richColors?: boolean;\n invert?: boolean;\n closeButton?: boolean;\n dismissible?: boolean;\n description?: React.ReactNode;\n duration?: number;\n delete?: boolean;\n important?: boolean;\n action?: Action | React.ReactNode;\n cancel?: Action | React.ReactNode;\n onDismiss?: (toast: ToastT) => void;\n onAutoClose?: (toast: ToastT) => void;\n promise?: PromiseT;\n cancelButtonStyle?: React.CSSProperties;\n actionButtonStyle?: React.CSSProperties;\n style?: React.CSSProperties;\n unstyled?: boolean;\n className?: string;\n classNames?: ToastClassnames;\n descriptionClassName?: string;\n position?: Position;\n}\n\nexport function isAction(action: Action | React.ReactNode): action is Action {\n return (action as Action).label !== undefined;\n}\n\nexport type Position = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center';\nexport interface HeightT {\n height: number;\n toastId: number | string;\n position: Position;\n}\n\ninterface ToastOptions {\n className?: string;\n closeButton?: boolean;\n descriptionClassName?: string;\n style?: React.CSSProperties;\n cancelButtonStyle?: React.CSSProperties;\n actionButtonStyle?: React.CSSProperties;\n duration?: number;\n unstyled?: boolean;\n classNames?: ToastClassnames;\n}\n\ntype CnFunction = (...classes: Array<string | undefined>) => string;\n\nexport interface ToasterProps {\n invert?: boolean;\n theme?: 'light' | 'dark' | 'system';\n position?: Position;\n hotkey?: string[];\n richColors?: boolean;\n expand?: boolean;\n duration?: number;\n gap?: number;\n visibleToasts?: number;\n closeButton?: boolean;\n toastOptions?: ToastOptions;\n className?: string;\n style?: React.CSSProperties;\n offset?: string | number;\n dir?: 'rtl' | 'ltr' | 'auto';\n /**\n * @deprecated Please use the `icons` prop instead:\n * ```jsx\n * <Toaster\n * icons={{ loading: <LoadingIcon /> }}\n * />\n * ```\n */\n loadingIcon?: React.ReactNode;\n icons?: ToastIcons;\n containerAriaLabel?: string;\n pauseWhenPageIsHidden?: boolean;\n cn?: CnFunction;\n}\n\nexport interface ToastProps {\n toast: ToastT;\n toasts: ToastT[];\n index: number;\n expanded: boolean;\n invert: boolean;\n heights: HeightT[];\n setHeights: React.Dispatch<React.SetStateAction<HeightT[]>>;\n removeToast: (toast: ToastT) => void;\n gap?: number;\n position: Position;\n visibleToasts: number;\n expandByDefault: boolean;\n closeButton: boolean;\n interacting: boolean;\n style?: React.CSSProperties;\n cancelButtonStyle?: React.CSSProperties;\n actionButtonStyle?: React.CSSProperties;\n duration?: number;\n className?: string;\n unstyled?: boolean;\n descriptionClassName?: string;\n loadingIcon?: React.ReactNode;\n classNames?: ToastClassnames;\n icons?: ToastIcons;\n closeButtonAriaLabel?: string;\n pauseWhenPageIsHidden: boolean;\n cn: CnFunction;\n defaultRichColors?: boolean;\n}\n\nexport enum SwipeStateTypes {\n SwipedOut = 'SwipedOut',\n SwipedBack = 'SwipedBack',\n NotSwiped = 'NotSwiped',\n}\n\nexport type Theme = 'light' | 'dark';\n\nexport interface ToastToDismiss {\n id: number | string;\n dismiss: boolean;\n}\n\nexport type ExternalToast = Omit<ToastT, 'id' | 'type' | 'title' | 'jsx' | 'delete' | 'promise'> & {\n id?: number | string;\n};\n"],"mappings":"aAEA,OAAOA,MAAW,QACl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