@propellerads/toast 2.0.0 → 3.0.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/dist/index.d.ts +13 -13
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _base_ui_components_react_toast from '@base-ui-components/react/toast';
|
|
2
2
|
import { Toast as Toast$1, ToastManager as ToastManager$1, ToastManagerAddOptions } from '@base-ui-components/react/toast';
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -149,29 +149,29 @@ declare const createToastManager: () => ToastManager;
|
|
|
149
149
|
* it holds.
|
|
150
150
|
*/
|
|
151
151
|
declare const toast: ToastManager;
|
|
152
|
-
declare const ToastProvider: (props: Toast$1.Provider.Props) =>
|
|
153
|
-
declare const ToastPortal: (props: Toast$1.Portal.Props) =>
|
|
152
|
+
declare const ToastProvider: (props: Toast$1.Provider.Props) => react.JSX.Element;
|
|
153
|
+
declare const ToastPortal: (props: Toast$1.Portal.Props) => react.JSX.Element;
|
|
154
154
|
/** The corner the toasts stack in; the full width at its edge on a phone. */
|
|
155
|
-
declare const ToastViewport: ({ className, position, ...props }: ToastViewportProps) =>
|
|
155
|
+
declare const ToastViewport: ({ className, position, ...props }: ToastViewportProps) => react.JSX.Element;
|
|
156
156
|
/** One toast in the stack. The stylesheet moves it by the custom properties Base UI writes on it. */
|
|
157
|
-
declare const Toast: ({ className, swipeDirection, ...props }: ToastProps) =>
|
|
157
|
+
declare const Toast: ({ className, swipeDirection, ...props }: ToastProps) => react.JSX.Element;
|
|
158
158
|
/** The row inside: the icon, the text, the action and the close button. It fades out behind the front toast. */
|
|
159
|
-
declare const ToastContent: ({ className, ...props }: ToastContentProps) =>
|
|
160
|
-
declare const ToastTitle: ({ className, ...props }: ToastTitleProps) =>
|
|
161
|
-
declare const ToastDescription: ({ className, ...props }: ToastDescriptionProps) =>
|
|
159
|
+
declare const ToastContent: ({ className, ...props }: ToastContentProps) => react.JSX.Element;
|
|
160
|
+
declare const ToastTitle: ({ className, ...props }: ToastTitleProps) => react.JSX.Element;
|
|
161
|
+
declare const ToastDescription: ({ className, ...props }: ToastDescriptionProps) => react.JSX.Element;
|
|
162
162
|
/** The one button a toast may carry — undo, retry, open. It takes its label and handler from `actionProps`. */
|
|
163
|
-
declare const ToastAction: ({ className, ...props }: ToastActionProps) =>
|
|
163
|
+
declare const ToastAction: ({ className, ...props }: ToastActionProps) => react.JSX.Element;
|
|
164
164
|
/** The close button at the end of the row, a ghost square with a hit area wider than itself. */
|
|
165
|
-
declare const ToastClose: ({ className, children, ...props }: ToastCloseProps) =>
|
|
165
|
+
declare const ToastClose: ({ className, children, ...props }: ToastCloseProps) => react.JSX.Element;
|
|
166
166
|
/** The status icon, in the status colour. A toast of no known type has none. The title says what it shows. */
|
|
167
|
-
declare const ToastIcon: ({ type }: ToastIconProps) =>
|
|
167
|
+
declare const ToastIcon: ({ type }: ToastIconProps) => react.JSX.Element | null;
|
|
168
168
|
/**
|
|
169
169
|
* One toast as the Toaster draws it: the icon, the title and the description,
|
|
170
170
|
* the action, and the cross. A page that shows a toast outside the
|
|
171
171
|
* corner — a reference, a preview — draws it with this too.
|
|
172
172
|
*/
|
|
173
|
-
declare const ToastItem: ({ toast: item, ...props }: ToastProps) =>
|
|
174
|
-
declare const Toaster: ({ children, toastManager, limit, position, ...props }: ToasterProps) =>
|
|
173
|
+
declare const ToastItem: ({ toast: item, ...props }: ToastProps) => react.JSX.Element;
|
|
174
|
+
declare const Toaster: ({ children, toastManager, limit, position, ...props }: ToasterProps) => react.JSX.Element;
|
|
175
175
|
/**
|
|
176
176
|
* The toasts of the nearest Toaster or ToastProvider, to draw them — as
|
|
177
177
|
* ToastItem does in a reference page. It reads and does not add: Base UI's own
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { buttonVariants as t } from "@propellerads/button";
|
|
|
3
3
|
import { createContext as n, useContext as r } from "react";
|
|
4
4
|
import { clsx as i } from "clsx";
|
|
5
5
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
-
import './index.css'
|
|
6
|
+
import './index.css';// src/cn.ts
|
|
7
7
|
var s = (...e) => i(e), c = {
|
|
8
8
|
Default: "default",
|
|
9
9
|
Success: "success",
|
|
@@ -222,7 +222,6 @@ var s = (...e) => i(e), c = {
|
|
|
222
222
|
children: /* @__PURE__ */ a(j, {})
|
|
223
223
|
}) })]
|
|
224
224
|
}), P = () => e.useToastManager().toasts;
|
|
225
|
-
//#endregion
|
|
226
225
|
export { b as Toast, w as ToastAction, O as ToastClose, x as ToastContent, C as ToastDescription, k as ToastIcon, A as ToastItem, m as ToastPortal, l as ToastPosition, p as ToastProvider, S as ToastTitle, c as ToastType, y as ToastViewport, N as Toaster, N as default, d as createToastManager, f as toast, P as useToasts };
|
|
227
226
|
|
|
228
227
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/cn.ts","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the toast\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import type {\n ToastManagerAddOptions,\n Toast as ToastPrimitive,\n ToastManager as ToastPrimitiveManager,\n} from '@base-ui-components/react/toast';\nimport type {ReactNode} from 'react';\n\n/**\n * What the toast is about: the icon in front of the title and its colour. These\n * are the types shadcn's renderer recognises. The danger one is `error` rather\n * than the `danger` of Alert and the tokens, because `toast.promise` writes\n * `loading`, `success` and `error` itself, and a toast it settles has to look\n * like one added by hand.\n */\nexport const ToastType = {\n /** No status, no icon: the plain message. */\n Default: 'default',\n /** A scenario that worked: the --color-success icon. */\n Success: 'success',\n /** Something to know: the --color-action icon. */\n Info: 'info',\n /** Nothing is broken yet: the --color-warning icon. */\n Warning: 'warning',\n /** Something failed: the --color-danger icon. */\n Error: 'error',\n /** A task still running: a turning ring. It stays until it is updated or closed. */\n Loading: 'loading',\n} as const;\nexport type ToastType = (typeof ToastType)[keyof typeof ToastType];\n\n/**\n * The corner the stack stands in, the top right by default. On a phone the\n * stack takes the full width at the top or the bottom.\n */\nexport const ToastPosition = {\n TopLeft: 'top-left',\n TopCenter: 'top-center',\n TopRight: 'top-right',\n BottomLeft: 'bottom-left',\n BottomCenter: 'bottom-center',\n BottomRight: 'bottom-right',\n} as const;\nexport type ToastPosition = (typeof ToastPosition)[keyof typeof ToastPosition];\n\n/**\n * What `toast.add` takes: Base UI's options without `timeout`. A toast either\n * goes away by itself after five seconds, or stays until the user closes it or\n * acts on it — `persistent`. No call site picks its own number of seconds.\n * `data` is anything of your own the toast carries.\n */\nexport type ToastOptions<Data extends object = {}> = Omit<ToastManagerAddOptions<Data>, 'timeout'> & {\n /**\n * Stays until the user closes it or presses its action: a new build to\n * reload for, a session that expired, cookie consent. It is announced at\n * once, as `priority: 'high'`, unless `priority` says otherwise.\n */\n persistent?: boolean;\n};\n\n/** What `toast.update` takes: any of the options, the rest stay as they were. */\nexport type ToastUpdateOptions<Data extends object = {}> = Partial<ToastOptions<Data>>;\n\n/** What the shortcuts take after the text: everything but the type and the title. */\nexport type ToastShortcutOptions<Data extends object = {}> = Omit<ToastOptions<Data>, 'type' | 'title'>;\n\n/** One stage of `toast.promise`: a title, the options, or a function of the result or the error. */\ntype ToastPromiseStage<Input, Data extends object> =\n | string\n | ToastUpdateOptions<Data>\n | ((input: Input) => string | ToastUpdateOptions<Data>);\n\nexport type ToastPromiseOptions<Value, Data extends object = {}> = {\n loading: string | ToastUpdateOptions<Data>;\n success: ToastPromiseStage<Value, Data>;\n /**\n * Left out, a failure closes the loading toast and says nothing: for a\n * request whose errors the app's own handler already shows, so that one\n * failure is one toast.\n */\n error?: ToastPromiseStage<any, Data>;\n};\n\n/** A shortcut for one type: the text is the title. Returns the toast's id. */\ntype Shortcut = <Data extends object>(title: ReactNode, options?: ToastShortcutOptions<Data>) => string;\n\n/**\n * Base UI's manager with what the cabinets lean on.\n *\n * - `add` with the `id` of a toast still on screen updates that toast instead\n * of stacking a second one, as react-toastify's `toastId` did.\n * - `update` of a loading toast to any other type starts its five seconds,\n * as `toast.promise` does when the promise settles.\n * - `isActive` says whether a toast is still on screen.\n * - One shortcut per type: `toast.error('Could not save')`.\n */\nexport type ToastManager = Omit<ToastPrimitiveManager, 'add' | 'update' | 'promise'> & {\n add: <Data extends object>(options: ToastOptions<Data>) => string;\n update: <Data extends object>(id: string, updates: ToastUpdateOptions<Data>) => void;\n promise: <Value, Data extends object>(\n promise: Promise<Value>,\n options: ToastPromiseOptions<Value, Data>,\n ) => Promise<Value>;\n isActive: (id: string) => boolean;\n success: Shortcut;\n info: Shortcut;\n warning: Shortcut;\n error: Shortcut;\n loading: Shortcut;\n};\n\n/**\n * A part's own props, with `className` as a string. Base UI also takes a\n * function of the part's state there; the parts here join the string with\n * their own class names, and a function cannot be joined.\n */\ntype WithClassName<Props> = Omit<Props, 'className'> & {className?: string};\n\n/** How many toasts stand in the stack at once: up to five, so a fanned-out stack fits a laptop's screen. */\nexport type ToastLimit = 1 | 2 | 3 | 4 | 5;\n\n/** Base UI's provider props without `timeout`: every toast that goes away by itself takes five seconds. */\nexport type ToasterProps = Omit<ToastPrimitive.Provider.Props, 'timeout' | 'limit'> & {\n /**\n * How many toasts stand at once. One over the limit is not dropped: it waits\n * unseen and comes forward when one in front closes. The stack does not\n * scroll, so it stops at five. @default 3\n */\n limit?: ToastLimit;\n /**\n * The corner the stack stands in. Its distance from the edges is the\n * `--toast-offset-top`, `-right`, `-bottom` and `-left` custom properties,\n * 16px each by default. @default 'top-right'\n */\n position?: ToastPosition;\n};\nexport type ToastViewportProps = WithClassName<ToastPrimitive.Viewport.Props> & {\n /** The corner the stack stands in. @default 'top-right' */\n position?: ToastPosition;\n};\nexport type ToastProps = WithClassName<ToastPrimitive.Root.Props>;\nexport type ToastContentProps = WithClassName<ToastPrimitive.Content.Props>;\nexport type ToastTitleProps = WithClassName<ToastPrimitive.Title.Props>;\nexport type ToastDescriptionProps = WithClassName<ToastPrimitive.Description.Props>;\nexport type ToastActionProps = WithClassName<ToastPrimitive.Action.Props>;\nexport type ToastCloseProps = WithClassName<ToastPrimitive.Close.Props>;\nexport type ToastIconProps = {type: string | undefined};\n","import {type ToastManagerAddOptions, Toast as ToastPrimitive} from '@base-ui-components/react/toast';\nimport {buttonVariants} from '@propellerads/button';\nimport {createContext, type ReactNode, useContext} from 'react';\nimport './toast.css';\nimport {cn} from './cn';\nimport {\n type ToastActionProps,\n type ToastCloseProps,\n type ToastContentProps,\n type ToastDescriptionProps,\n type ToasterProps,\n type ToastIconProps,\n type ToastManager,\n type ToastOptions,\n ToastPosition,\n type ToastPromiseOptions,\n type ToastProps,\n type ToastShortcutOptions,\n type ToastTitleProps,\n ToastType,\n type ToastUpdateOptions,\n type ToastViewportProps,\n} from './types';\n\n/*\n * shadcn's Toast on Base UI, part for part: the same manager, the same stack\n * that fans out under the pointer, the same swipe to dismiss. The utility\n * classes are a stylesheet on @propellerads/tokens instead, the action and\n * the close button wear @propellerads/button, and the status icons are the\n * product's own from @propellerads/icon.\n */\n\n/* Base UI's own options, as the provider takes them. */\ntype PrimitiveOptions = ToastManagerAddOptions<object>;\n\n/** `persistent` in Base UI's words: no timeout, and announced at once. */\nconst toPrimitive = <Data extends object>({persistent, ...options}: ToastUpdateOptions<Data>) => {\n const primitive = {...options} as ToastUpdateOptions<Data> & {timeout?: number};\n // A call written against Base UI's own API keeps no number of seconds either.\n delete primitive.timeout;\n if (persistent === true) {\n primitive.timeout = 0;\n primitive.priority = options.priority ?? 'high';\n }\n return primitive as PrimitiveOptions;\n};\n\n/** A loading toast's promise, settled by the `update` that ends the loading. */\ntype Pending = {resolve: (options: PrimitiveOptions) => void; reject: (options: PrimitiveOptions) => void};\n\n/**\n * Base UI's manager, with what the cabinets did through react-toastify. A\n * toast stops being active as it starts to close, so an `add` with its id\n * while it slides out is a new toast rather than an update of a leaving one.\n *\n * A loading toast is Base UI's `promise` with a promise this manager holds:\n * Base UI starts a toast's seconds only when it is added or when its promise\n * settles, never on an update. The `update` that turns it into anything else\n * settles that promise, so the result goes away by itself as one from\n * `toast.promise` does.\n */\nconst createToastManager = (): ToastManager => {\n const manager = ToastPrimitive.createToastManager();\n\n /* One showing of a toast. The id the caller knows can be shown again while\n the last showing still slides out, and Base UI tells toasts apart by id\n alone — removing the one that left would take the new one with it. So\n each showing has an id of its own for Base UI, and keeps its own\n callbacks: an update merges into the toast, and one that names no\n callback must not take away those it was added with. */\n type Showing = {\n internal: string;\n active: boolean;\n pending?: Pending;\n onClose?: () => void;\n onRemove?: () => void;\n };\n\n /** The latest showing of each id the caller knows. */\n const showings = new Map<string, Showing>();\n let count = 0;\n\n /* Base UI hands an event only to a provider already listening, and the\n Toaster listens from its first effect on. A toast called before that — an\n interceptor on the app's first request — would be lost, and its id would\n stay active with nothing on screen. So until a provider listens, the calls\n wait here and play when it does. */\n let listeners = 0;\n const waiting: Array<() => void> = [];\n const send = (call: () => void): void => {\n if (listeners > 0) {\n call();\n } else {\n waiting.push(call);\n }\n };\n const subscribe: ToastManager[' subscribe'] = (listener) => {\n const unsubscribe = manager[' subscribe'](listener);\n listeners += 1;\n for (const call of waiting.splice(0)) {\n call();\n }\n return () => {\n unsubscribe();\n listeners -= 1;\n // The last Toaster gone takes its toasts with it: they will neither close\n // nor be removed, so their ids are forgotten and the next add shows anew.\n // Checked a step later — React in development unsubscribes and subscribes\n // straight back, and the toasts of that one Toaster stay on screen. Only\n // the showings it had are forgotten: one added in between is waiting for\n // the next Toaster and keeps its id.\n const gone = new Map(showings);\n queueMicrotask(() => {\n if (listeners > 0) {\n return;\n }\n for (const [id, showing] of gone) {\n if (showings.get(id) === showing) {\n showings.delete(id);\n }\n }\n });\n };\n };\n\n /**\n * The showing an id names: the id the caller knows, or the one Base UI has —\n * which `useToasts` hands out, so a toast drawn by hand can be closed by it.\n */\n const find = (id: string): Showing | undefined =>\n showings.get(id) ?? [...showings.values()].find((showing) => showing.internal === id);\n\n /** Keeps the callbacks an add or an update names, and those it leaves out. */\n const remember = (showing: Showing, {onClose, onRemove}: ToastUpdateOptions): void => {\n showing.onClose = onClose ?? showing.onClose;\n showing.onRemove = onRemove ?? showing.onRemove;\n };\n\n /** The options in Base UI's words, without the caller's callbacks: those live on the showing. */\n const bare = <Data extends object>({onClose, onRemove, id, ...options}: ToastUpdateOptions<Data>): PrimitiveOptions =>\n toPrimitive(options);\n\n /* The showing's own callbacks, set once as it is added: they mark it gone\n and call whatever the caller has kept on it by then. The id the caller\n knows forgets the showing only if no newer one has taken it. */\n const tracked = <Data extends object>(id: string, showing: Showing, options: ToastUpdateOptions<Data>) => ({\n ...bare(options),\n id: showing.internal,\n onClose: () => {\n showing.active = false;\n showing.pending = undefined;\n showing.onClose?.();\n },\n onRemove: () => {\n if (showings.get(id) === showing) {\n showings.delete(id);\n }\n showing.onRemove?.();\n },\n });\n\n const update = <Data extends object>(id: string, updates: ToastUpdateOptions<Data>): void => {\n const showing = find(id);\n if (!showing) {\n return;\n }\n remember(showing, updates);\n const loading = showing.pending;\n if (!loading || updates.type === undefined || updates.type === ToastType.Loading) {\n send(() => manager.update(showing.internal, bare(updates)));\n return;\n }\n\n showing.pending = undefined;\n // Base UI writes `success` on a resolve and `error` on a reject; any other\n // type is written back right after it.\n const {type} = updates;\n if (type === ToastType.Error) {\n loading.reject(bare(updates));\n } else {\n loading.resolve(bare(updates));\n }\n if (type !== ToastType.Success && type !== ToastType.Error) {\n send(() =>\n queueMicrotask(() => manager.update(showing.internal, {type: type === ToastType.Default ? undefined : type})),\n );\n }\n };\n\n const add = <Data extends object>(options: ToastOptions<Data>): string => {\n if (options.id !== undefined && showings.get(options.id)?.active) {\n update(options.id, options);\n return options.id;\n }\n\n count += 1;\n // A tilde no caller writes keeps these apart from the ids the caller picks.\n const id = options.id ?? `~toast-${count}`;\n // An id still sliding out under its last showing takes a fresh one for Base UI.\n const internal = showings.has(id) ? `${id}~${count}` : id;\n const showing: Showing = {internal, active: true};\n remember(showing, options);\n showings.set(id, showing);\n\n if (options.type !== ToastType.Loading) {\n send(() => manager.add(tracked(id, showing, options)));\n return id;\n }\n\n const settled = new Promise<PrimitiveOptions>((resolve, reject) => {\n showing.pending = {resolve, reject};\n });\n send(() => {\n manager\n .promise(settled, {\n loading: tracked(id, showing, options),\n success: (result: PrimitiveOptions) => result,\n error: (result: PrimitiveOptions) => result,\n })\n // The rejection is how a loading toast turns into an error; nobody awaits it.\n .catch(() => undefined);\n });\n return id;\n };\n\n const close = (id: string): void => {\n const showing = find(id);\n if (!showing) {\n return;\n }\n showing.pending = undefined;\n send(() => manager.close(showing.internal));\n };\n\n /* A stage of `toast.promise` as options: text alone is the title, as in the shortcuts. */\n const stage = <Input, Data extends object>(\n value: string | ToastUpdateOptions<Data> | ((input: Input) => string | ToastUpdateOptions<Data>),\n input?: Input,\n ): ToastUpdateOptions<Data> => {\n const resolved = typeof value === 'function' ? value(input as Input) : value;\n return typeof resolved === 'string' ? {title: resolved} : resolved;\n };\n\n /**\n * A loading toast that the promise ends. It is this manager's loading and\n * update rather than Base UI's own `promise`, which writes `success` over\n * whatever the stage says: here a stage may end in a warning — partly done —\n * or in any other type it names.\n */\n const promise = <Value, Data extends object>(\n work: Promise<Value>,\n options: ToastPromiseOptions<Value, Data>,\n ): Promise<Value> => {\n const id = add({...stage(options.loading), type: ToastType.Loading});\n return work.then(\n (result) => {\n update(id, {type: ToastType.Success, ...stage(options.success, result)});\n return result;\n },\n (error: unknown) => {\n if (options.error === undefined) {\n close(id);\n } else {\n update(id, {type: ToastType.Error, ...stage(options.error, error)});\n }\n throw error;\n },\n );\n };\n\n const shortcut =\n (type: ToastType) =>\n <Data extends object>(title: ReactNode, options?: ToastShortcutOptions<Data>) =>\n add({...options, type, title});\n\n return {\n ...manager,\n ' subscribe': subscribe,\n add,\n update,\n close,\n promise,\n isActive: (id) => find(id)?.active === true,\n success: shortcut(ToastType.Success),\n info: shortcut(ToastType.Info),\n warning: shortcut(ToastType.Warning),\n error: shortcut(ToastType.Error),\n loading: shortcut(ToastType.Loading),\n };\n};\n\n/**\n * The manager the app calls from anywhere, components or not — an axios\n * interceptor, a saga, a jQuery widget: `toast.error('Could not save')`,\n * `toast.add({type: 'success', title: 'Saved'})`. `<Toaster />` renders what\n * it holds.\n */\nconst toast = createToastManager();\n\nconst ToastProvider = (props: ToastPrimitive.Provider.Props) => <ToastPrimitive.Provider {...props} />;\n\nconst ToastPortal = (props: ToastPrimitive.Portal.Props) => (\n <ToastPrimitive.Portal data-slot=\"toast-portal\" {...props} />\n);\n\nconst POSITIONS: readonly string[] = Object.values(ToastPosition);\n\n/** A value from plain JS that names no corner falls back to the top right. */\nconst splitPosition = (position: ToastPosition) => {\n const known = POSITIONS.includes(position) ? position : ToastPosition.TopRight;\n const [y, x] = known.split('-') as ['top' | 'bottom', 'left' | 'center' | 'right'];\n return {x, y};\n};\n\nconst swipeDirectionOf = (position: ToastPosition): ToastProps['swipeDirection'] => {\n const {x, y} = splitPosition(position);\n const vertical = y === 'top' ? 'up' : 'down';\n return x === 'center' ? [vertical] : [vertical, x];\n};\n\n/* Lets a Toast composed by hand swipe towards the corner of its viewport. */\nconst ToastPositionContext = createContext<ToastPosition>(ToastPosition.TopRight);\n\n/** The corner the toasts stack in; the full width at its edge on a phone. */\nconst ToastViewport = ({className, position = ToastPosition.TopRight, ...props}: ToastViewportProps) => {\n const {x, y} = splitPosition(position);\n\n return (\n <ToastPositionContext.Provider value={position}>\n <ToastPrimitive.Viewport\n data-slot=\"toast-viewport\"\n data-x-position={x}\n data-y-position={y}\n className={cn('toast-viewport', className)}\n {...props}\n />\n </ToastPositionContext.Provider>\n );\n};\n\n/** One toast in the stack. The stylesheet moves it by the custom properties Base UI writes on it. */\nconst Toast = ({className, swipeDirection, ...props}: ToastProps) => {\n const position = useContext(ToastPositionContext);\n\n return (\n <ToastPrimitive.Root\n data-slot=\"toast\"\n className={cn('toast', className)}\n swipeDirection={swipeDirection ?? swipeDirectionOf(position)}\n {...props}\n />\n );\n};\n\n/** The row inside: the icon, the text, the action and the close button. It fades out behind the front toast. */\nconst ToastContent = ({className, ...props}: ToastContentProps) => (\n <ToastPrimitive.Content data-slot=\"toast-content\" className={cn('toast__content', className)} {...props} />\n);\n\nconst ToastTitle = ({className, ...props}: ToastTitleProps) => (\n <ToastPrimitive.Title data-slot=\"toast-title\" className={cn('toast__title', className)} {...props} />\n);\n\nconst ToastDescription = ({className, ...props}: ToastDescriptionProps) => (\n <ToastPrimitive.Description\n data-slot=\"toast-description\"\n className={cn('toast__description', className)}\n {...props}\n />\n);\n\n/** The one button a toast may carry — undo, retry, open. It takes its label and handler from `actionProps`. */\nconst ToastAction = ({className, ...props}: ToastActionProps) => (\n <ToastPrimitive.Action\n data-slot=\"toast-action\"\n className={cn(buttonVariants({variant: 'secondary'}), 'toast__action', className)}\n {...props}\n />\n);\n\n/* The icons are the paths of @propellerads/icon. That package draws through\n styled-components; a toast has no other use for it, so it carries the\n paths themselves. */\nconst Svg = ({children}: {children: ReactNode}) => (\n <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" focusable=\"false\">\n {children}\n </svg>\n);\n\n/* Close */\nconst CloseIcon = () => (\n <Svg>\n <path d=\"M18.3 5.71c-.39-.39-1.02-.39-1.41 0L12 10.59 7.11 5.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z\" />\n </Svg>\n);\n\n/* CheckCircle, InfoOutline, WarningOutline and Error, as Alert's stories pair them with the statuses. */\nconst STATUS_ICONS: Partial<Record<string, ReactNode>> = {\n [ToastType.Success]: (\n <Svg>\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z\" />\n </Svg>\n ),\n [ToastType.Info]: (\n <Svg>\n <path d=\"M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z\" />\n </Svg>\n ),\n [ToastType.Warning]: (\n <Svg>\n <path d=\"M12 5.98999L19.53 19H4.47L12 5.98999ZM2.74 18C1.97 19.33 2.93 21 4.47 21H19.53C21.07 21 22.03 19.33 21.26 18L13.73 4.98999C12.96 3.65999 11.04 3.65999 10.27 4.98999L2.74 18ZM11 11V13C11 13.55 11.45 14 12 14C12.55 14 13 13.55 13 13V11C13 10.45 12.55 9.99999 12 9.99999C11.45 9.99999 11 10.45 11 11ZM11 16H13V18H11V16Z\" />\n </Svg>\n ),\n [ToastType.Error]: (\n <Svg>\n <path d=\"M12 7c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1zm-.01-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm1-3h-2v-2h2v2z\" />\n </Svg>\n ),\n // The ring is drawn by the stylesheet, the way the Spinner draws its own.\n [ToastType.Loading]: <span className=\"toast__ring\" />,\n};\n\n/** The close button at the end of the row, a ghost square with a hit area wider than itself. */\nconst ToastClose = ({className, children, ...props}: ToastCloseProps) => (\n <ToastPrimitive.Close\n data-slot=\"toast-close\"\n aria-label=\"Close\"\n className={cn(buttonVariants({variant: 'ghost', iconOnly: true, quiet: true}), 'toast__close', className)}\n {...props}\n >\n {children ?? <CloseIcon />}\n </ToastPrimitive.Close>\n);\n\n/** The status icon, in the status colour. A toast of no known type has none. The title says what it shows. */\nconst ToastIcon = ({type}: ToastIconProps) => {\n const icon = type === undefined ? undefined : STATUS_ICONS[type];\n\n return icon ? (\n <span data-slot=\"toast-icon\" className=\"toast__icon\" aria-hidden>\n {icon}\n </span>\n ) : null;\n};\n\n/**\n * One toast as the Toaster draws it: the icon, the title and the description,\n * the action, and the cross. A page that shows a toast outside the\n * corner — a reference, a preview — draws it with this too.\n */\nconst ToastItem = ({toast: item, ...props}: ToastProps) => (\n <Toast toast={item} {...props}>\n <ToastContent>\n <ToastIcon type={item.type} />\n <div className=\"toast__body\">\n <div className=\"toast__text\">\n <ToastTitle />\n <ToastDescription />\n </div>\n <ToastAction />\n </div>\n <ToastClose />\n </ToastContent>\n </Toast>\n);\n\n/** Every toast the manager holds, drawn the one way. */\nconst ToastList = () => {\n const {toasts} = ToastPrimitive.useToastManager();\n\n return toasts.map((item) => <ToastItem key={item.id} toast={item} />);\n};\n\n/**\n * Put once at the root of the app, around it or beside it. It renders the\n * toasts of `toast`, or of the manager passed in — a second Toaster with a\n * manager of its own is a second stack.\n */\n/** The most toasts a stack holds, whatever a call from plain JS asks for. */\nconst MAX_LIMIT = 5;\n\nconst Toaster = ({\n children,\n toastManager = toast,\n limit = 3,\n position = ToastPosition.TopRight,\n ...props\n}: ToasterProps) => (\n <ToastProvider toastManager={toastManager} limit={Math.min(Math.max(limit, 1), MAX_LIMIT)} {...props}>\n {children}\n <ToastPortal>\n <ToastViewport position={position}>\n <ToastList />\n </ToastViewport>\n </ToastPortal>\n </ToastProvider>\n);\n\n/**\n * The toasts of the nearest Toaster or ToastProvider, to draw them — as\n * ToastItem does in a reference page. It reads and does not add: Base UI's own\n * hook would add past this package's manager, without `persistent`, the id\n * check or `isActive`. Toasts are added with `toast` or a manager from\n * `createToastManager`.\n */\nconst useToasts = () => ToastPrimitive.useToastManager().toasts;\n\nexport default Toaster;\n\nexport type {\n ToastActionProps,\n ToastCloseProps,\n ToastContentProps,\n ToastDescriptionProps,\n ToasterProps,\n ToastIconProps,\n ToastLimit,\n ToastManager,\n ToastOptions,\n ToastProps,\n ToastShortcutOptions,\n ToastTitleProps,\n ToastViewportProps,\n} from './types';\nexport {\n createToastManager,\n Toast,\n ToastAction,\n ToastClose,\n ToastContent,\n ToastDescription,\n Toaster,\n ToastIcon,\n ToastItem,\n ToastPortal,\n ToastPosition,\n ToastProvider,\n ToastTitle,\n ToastType,\n ToastViewport,\n toast,\n useToasts,\n};\n"],"mappings":";;;;;;AAOA,IAAM,KAAM,GAAG,MAAiC,EAAK,EAAO,ECO/C,IAAY;CAEvB,SAAS;CAET,SAAS;CAET,MAAM;CAEN,SAAS;CAET,OAAO;CAEP,SAAS;CACV,EAOY,IAAgB;CAC3B,SAAS;CACT,WAAW;CACX,UAAU;CACV,YAAY;CACZ,cAAc;CACd,aAAa;CACd,ECLK,KAAoC,EAAC,eAAY,GAAG,QAAuC;CAC/F,IAAM,IAAY,EAAC,GAAG,GAAQ;CAO9B,OALA,OAAO,EAAU,SACb,MAAe,OACjB,EAAU,UAAU,GACpB,EAAU,WAAW,EAAQ,YAAY,SAEpC;GAiBH,UAAyC;CAC7C,IAAM,IAAU,EAAe,oBAAoB,EAiB7C,oBAAW,IAAI,KAAsB,EACvC,IAAQ,GAOR,IAAY,GACV,IAA6B,EAAE,EAC/B,KAAQ,MAA2B;EACvC,AAAI,IAAY,IACd,GAAM,GAEN,EAAQ,KAAK,EAAK;IAGhB,KAAyC,MAAa;EAC1D,IAAM,IAAc,EAAQ,cAAc,EAAS;EACnD,KAAa;EACb,KAAK,IAAM,KAAQ,EAAQ,OAAO,EAAE,EAClC,GAAM;EAER,aAAa;GAEX,AADA,GAAa,EACb;GAOA,IAAM,IAAO,I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AW,EAAc,UACzB,GAAG,QAEH,kBAAC,GAAD;CAA6B;CAAc,OAAO,KAAK,IAAI,KAAK,IAAI,GAAO,EAAE,EAAE,EAAU;CAAE,GAAI;WAA/F,CACG,GACD,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAAyB;YACvB,kBAAC,GAAD,EAAa,CAAA;EACC,CAAA,EACJ,CAAA,CACA;IAUZ,UAAkB,EAAe,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ToastPrimitive","Toast$1","cn","inputs","clsx","ToastType","ToastPosition","toPrimitive","options","primitive","persistent","createToastManager","manager","showings","count","listeners","waiting","send","call","subscribe","unsubscribe","listener","gone","id","showing","find","remember","onClose","onRemove","bare","tracked","update","updates","loading","type","add","settled","result","close","stage","resolved","value","input","promise","work","error","shortcut","toast","ToastProvider","props","ToastPortal","POSITIONS","splitPosition","y","x","position","swipeDirectionOf","vertical","ToastPositionContext","createContext","ToastViewport","className","Toast","useContext","swipeDirection","ToastContent","ToastTitle","ToastDescription","ToastAction","buttonVariants","Svg","CloseIcon","STATUS_ICONS","ToastClose","children","ToastIcon","icon","ToastItem","item","ToastList","toasts","MAX_LIMIT","Toaster","limit","useToasts"],"sources":["../src/cn.ts","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the toast\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import type {\n ToastManagerAddOptions,\n Toast as ToastPrimitive,\n ToastManager as ToastPrimitiveManager,\n} from '@base-ui-components/react/toast';\nimport type {ReactNode} from 'react';\n\n/**\n * What the toast is about: the icon in front of the title and its colour. These\n * are the types shadcn's renderer recognises. The danger one is `error` rather\n * than the `danger` of Alert and the tokens, because `toast.promise` writes\n * `loading`, `success` and `error` itself, and a toast it settles has to look\n * like one added by hand.\n */\nexport const ToastType = {\n /** No status, no icon: the plain message. */\n Default: 'default',\n /** A scenario that worked: the --color-success icon. */\n Success: 'success',\n /** Something to know: the --color-action icon. */\n Info: 'info',\n /** Nothing is broken yet: the --color-warning icon. */\n Warning: 'warning',\n /** Something failed: the --color-danger icon. */\n Error: 'error',\n /** A task still running: a turning ring. It stays until it is updated or closed. */\n Loading: 'loading',\n} as const;\nexport type ToastType = (typeof ToastType)[keyof typeof ToastType];\n\n/**\n * The corner the stack stands in, the top right by default. On a phone the\n * stack takes the full width at the top or the bottom.\n */\nexport const ToastPosition = {\n TopLeft: 'top-left',\n TopCenter: 'top-center',\n TopRight: 'top-right',\n BottomLeft: 'bottom-left',\n BottomCenter: 'bottom-center',\n BottomRight: 'bottom-right',\n} as const;\nexport type ToastPosition = (typeof ToastPosition)[keyof typeof ToastPosition];\n\n/**\n * What `toast.add` takes: Base UI's options without `timeout`. A toast either\n * goes away by itself after five seconds, or stays until the user closes it or\n * acts on it — `persistent`. No call site picks its own number of seconds.\n * `data` is anything of your own the toast carries.\n */\nexport type ToastOptions<Data extends object = {}> = Omit<ToastManagerAddOptions<Data>, 'timeout'> & {\n /**\n * Stays until the user closes it or presses its action: a new build to\n * reload for, a session that expired, cookie consent. It is announced at\n * once, as `priority: 'high'`, unless `priority` says otherwise.\n */\n persistent?: boolean;\n};\n\n/** What `toast.update` takes: any of the options, the rest stay as they were. */\nexport type ToastUpdateOptions<Data extends object = {}> = Partial<ToastOptions<Data>>;\n\n/** What the shortcuts take after the text: everything but the type and the title. */\nexport type ToastShortcutOptions<Data extends object = {}> = Omit<ToastOptions<Data>, 'type' | 'title'>;\n\n/** One stage of `toast.promise`: a title, the options, or a function of the result or the error. */\ntype ToastPromiseStage<Input, Data extends object> =\n | string\n | ToastUpdateOptions<Data>\n | ((input: Input) => string | ToastUpdateOptions<Data>);\n\nexport type ToastPromiseOptions<Value, Data extends object = {}> = {\n loading: string | ToastUpdateOptions<Data>;\n success: ToastPromiseStage<Value, Data>;\n /**\n * Left out, a failure closes the loading toast and says nothing: for a\n * request whose errors the app's own handler already shows, so that one\n * failure is one toast.\n */\n error?: ToastPromiseStage<any, Data>;\n};\n\n/** A shortcut for one type: the text is the title. Returns the toast's id. */\ntype Shortcut = <Data extends object>(title: ReactNode, options?: ToastShortcutOptions<Data>) => string;\n\n/**\n * Base UI's manager with what the cabinets lean on.\n *\n * - `add` with the `id` of a toast still on screen updates that toast instead\n * of stacking a second one, as react-toastify's `toastId` did.\n * - `update` of a loading toast to any other type starts its five seconds,\n * as `toast.promise` does when the promise settles.\n * - `isActive` says whether a toast is still on screen.\n * - One shortcut per type: `toast.error('Could not save')`.\n */\nexport type ToastManager = Omit<ToastPrimitiveManager, 'add' | 'update' | 'promise'> & {\n add: <Data extends object>(options: ToastOptions<Data>) => string;\n update: <Data extends object>(id: string, updates: ToastUpdateOptions<Data>) => void;\n promise: <Value, Data extends object>(\n promise: Promise<Value>,\n options: ToastPromiseOptions<Value, Data>,\n ) => Promise<Value>;\n isActive: (id: string) => boolean;\n success: Shortcut;\n info: Shortcut;\n warning: Shortcut;\n error: Shortcut;\n loading: Shortcut;\n};\n\n/**\n * A part's own props, with `className` as a string. Base UI also takes a\n * function of the part's state there; the parts here join the string with\n * their own class names, and a function cannot be joined.\n */\ntype WithClassName<Props> = Omit<Props, 'className'> & {className?: string};\n\n/** How many toasts stand in the stack at once: up to five, so a fanned-out stack fits a laptop's screen. */\nexport type ToastLimit = 1 | 2 | 3 | 4 | 5;\n\n/** Base UI's provider props without `timeout`: every toast that goes away by itself takes five seconds. */\nexport type ToasterProps = Omit<ToastPrimitive.Provider.Props, 'timeout' | 'limit'> & {\n /**\n * How many toasts stand at once. One over the limit is not dropped: it waits\n * unseen and comes forward when one in front closes. The stack does not\n * scroll, so it stops at five. @default 3\n */\n limit?: ToastLimit;\n /**\n * The corner the stack stands in. Its distance from the edges is the\n * `--toast-offset-top`, `-right`, `-bottom` and `-left` custom properties,\n * 16px each by default. @default 'top-right'\n */\n position?: ToastPosition;\n};\nexport type ToastViewportProps = WithClassName<ToastPrimitive.Viewport.Props> & {\n /** The corner the stack stands in. @default 'top-right' */\n position?: ToastPosition;\n};\nexport type ToastProps = WithClassName<ToastPrimitive.Root.Props>;\nexport type ToastContentProps = WithClassName<ToastPrimitive.Content.Props>;\nexport type ToastTitleProps = WithClassName<ToastPrimitive.Title.Props>;\nexport type ToastDescriptionProps = WithClassName<ToastPrimitive.Description.Props>;\nexport type ToastActionProps = WithClassName<ToastPrimitive.Action.Props>;\nexport type ToastCloseProps = WithClassName<ToastPrimitive.Close.Props>;\nexport type ToastIconProps = {type: string | undefined};\n","import {type ToastManagerAddOptions, Toast as ToastPrimitive} from '@base-ui-components/react/toast';\nimport {buttonVariants} from '@propellerads/button';\nimport {createContext, type ReactNode, useContext} from 'react';\nimport './toast.css';\nimport {cn} from './cn';\nimport {\n type ToastActionProps,\n type ToastCloseProps,\n type ToastContentProps,\n type ToastDescriptionProps,\n type ToasterProps,\n type ToastIconProps,\n type ToastManager,\n type ToastOptions,\n ToastPosition,\n type ToastPromiseOptions,\n type ToastProps,\n type ToastShortcutOptions,\n type ToastTitleProps,\n ToastType,\n type ToastUpdateOptions,\n type ToastViewportProps,\n} from './types';\n\n/*\n * shadcn's Toast on Base UI, part for part: the same manager, the same stack\n * that fans out under the pointer, the same swipe to dismiss. The utility\n * classes are a stylesheet on @propellerads/tokens instead, the action and\n * the close button wear @propellerads/button, and the status icons are the\n * product's own from @propellerads/icon.\n */\n\n/* Base UI's own options, as the provider takes them. */\ntype PrimitiveOptions = ToastManagerAddOptions<object>;\n\n/** `persistent` in Base UI's words: no timeout, and announced at once. */\nconst toPrimitive = <Data extends object>({persistent, ...options}: ToastUpdateOptions<Data>) => {\n const primitive = {...options} as ToastUpdateOptions<Data> & {timeout?: number};\n // A call written against Base UI's own API keeps no number of seconds either.\n delete primitive.timeout;\n if (persistent === true) {\n primitive.timeout = 0;\n primitive.priority = options.priority ?? 'high';\n }\n return primitive as PrimitiveOptions;\n};\n\n/** A loading toast's promise, settled by the `update` that ends the loading. */\ntype Pending = {resolve: (options: PrimitiveOptions) => void; reject: (options: PrimitiveOptions) => void};\n\n/**\n * Base UI's manager, with what the cabinets did through react-toastify. A\n * toast stops being active as it starts to close, so an `add` with its id\n * while it slides out is a new toast rather than an update of a leaving one.\n *\n * A loading toast is Base UI's `promise` with a promise this manager holds:\n * Base UI starts a toast's seconds only when it is added or when its promise\n * settles, never on an update. The `update` that turns it into anything else\n * settles that promise, so the result goes away by itself as one from\n * `toast.promise` does.\n */\nconst createToastManager = (): ToastManager => {\n const manager = ToastPrimitive.createToastManager();\n\n /* One showing of a toast. The id the caller knows can be shown again while\n the last showing still slides out, and Base UI tells toasts apart by id\n alone — removing the one that left would take the new one with it. So\n each showing has an id of its own for Base UI, and keeps its own\n callbacks: an update merges into the toast, and one that names no\n callback must not take away those it was added with. */\n type Showing = {\n internal: string;\n active: boolean;\n pending?: Pending;\n onClose?: () => void;\n onRemove?: () => void;\n };\n\n /** The latest showing of each id the caller knows. */\n const showings = new Map<string, Showing>();\n let count = 0;\n\n /* Base UI hands an event only to a provider already listening, and the\n Toaster listens from its first effect on. A toast called before that — an\n interceptor on the app's first request — would be lost, and its id would\n stay active with nothing on screen. So until a provider listens, the calls\n wait here and play when it does. */\n let listeners = 0;\n const waiting: Array<() => void> = [];\n const send = (call: () => void): void => {\n if (listeners > 0) {\n call();\n } else {\n waiting.push(call);\n }\n };\n const subscribe: ToastManager[' subscribe'] = (listener) => {\n const unsubscribe = manager[' subscribe'](listener);\n listeners += 1;\n for (const call of waiting.splice(0)) {\n call();\n }\n return () => {\n unsubscribe();\n listeners -= 1;\n // The last Toaster gone takes its toasts with it: they will neither close\n // nor be removed, so their ids are forgotten and the next add shows anew.\n // Checked a step later — React in development unsubscribes and subscribes\n // straight back, and the toasts of that one Toaster stay on screen. Only\n // the showings it had are forgotten: one added in between is waiting for\n // the next Toaster and keeps its id.\n const gone = new Map(showings);\n queueMicrotask(() => {\n if (listeners > 0) {\n return;\n }\n for (const [id, showing] of gone) {\n if (showings.get(id) === showing) {\n showings.delete(id);\n }\n }\n });\n };\n };\n\n /**\n * The showing an id names: the id the caller knows, or the one Base UI has —\n * which `useToasts` hands out, so a toast drawn by hand can be closed by it.\n */\n const find = (id: string): Showing | undefined =>\n showings.get(id) ?? [...showings.values()].find((showing) => showing.internal === id);\n\n /** Keeps the callbacks an add or an update names, and those it leaves out. */\n const remember = (showing: Showing, {onClose, onRemove}: ToastUpdateOptions): void => {\n showing.onClose = onClose ?? showing.onClose;\n showing.onRemove = onRemove ?? showing.onRemove;\n };\n\n /** The options in Base UI's words, without the caller's callbacks: those live on the showing. */\n const bare = <Data extends object>({onClose, onRemove, id, ...options}: ToastUpdateOptions<Data>): PrimitiveOptions =>\n toPrimitive(options);\n\n /* The showing's own callbacks, set once as it is added: they mark it gone\n and call whatever the caller has kept on it by then. The id the caller\n knows forgets the showing only if no newer one has taken it. */\n const tracked = <Data extends object>(id: string, showing: Showing, options: ToastUpdateOptions<Data>) => ({\n ...bare(options),\n id: showing.internal,\n onClose: () => {\n showing.active = false;\n showing.pending = undefined;\n showing.onClose?.();\n },\n onRemove: () => {\n if (showings.get(id) === showing) {\n showings.delete(id);\n }\n showing.onRemove?.();\n },\n });\n\n const update = <Data extends object>(id: string, updates: ToastUpdateOptions<Data>): void => {\n const showing = find(id);\n if (!showing) {\n return;\n }\n remember(showing, updates);\n const loading = showing.pending;\n if (!loading || updates.type === undefined || updates.type === ToastType.Loading) {\n send(() => manager.update(showing.internal, bare(updates)));\n return;\n }\n\n showing.pending = undefined;\n // Base UI writes `success` on a resolve and `error` on a reject; any other\n // type is written back right after it.\n const {type} = updates;\n if (type === ToastType.Error) {\n loading.reject(bare(updates));\n } else {\n loading.resolve(bare(updates));\n }\n if (type !== ToastType.Success && type !== ToastType.Error) {\n send(() =>\n queueMicrotask(() => manager.update(showing.internal, {type: type === ToastType.Default ? undefined : type})),\n );\n }\n };\n\n const add = <Data extends object>(options: ToastOptions<Data>): string => {\n if (options.id !== undefined && showings.get(options.id)?.active) {\n update(options.id, options);\n return options.id;\n }\n\n count += 1;\n // A tilde no caller writes keeps these apart from the ids the caller picks.\n const id = options.id ?? `~toast-${count}`;\n // An id still sliding out under its last showing takes a fresh one for Base UI.\n const internal = showings.has(id) ? `${id}~${count}` : id;\n const showing: Showing = {internal, active: true};\n remember(showing, options);\n showings.set(id, showing);\n\n if (options.type !== ToastType.Loading) {\n send(() => manager.add(tracked(id, showing, options)));\n return id;\n }\n\n const settled = new Promise<PrimitiveOptions>((resolve, reject) => {\n showing.pending = {resolve, reject};\n });\n send(() => {\n manager\n .promise(settled, {\n loading: tracked(id, showing, options),\n success: (result: PrimitiveOptions) => result,\n error: (result: PrimitiveOptions) => result,\n })\n // The rejection is how a loading toast turns into an error; nobody awaits it.\n .catch(() => undefined);\n });\n return id;\n };\n\n const close = (id: string): void => {\n const showing = find(id);\n if (!showing) {\n return;\n }\n showing.pending = undefined;\n send(() => manager.close(showing.internal));\n };\n\n /* A stage of `toast.promise` as options: text alone is the title, as in the shortcuts. */\n const stage = <Input, Data extends object>(\n value: string | ToastUpdateOptions<Data> | ((input: Input) => string | ToastUpdateOptions<Data>),\n input?: Input,\n ): ToastUpdateOptions<Data> => {\n const resolved = typeof value === 'function' ? value(input as Input) : value;\n return typeof resolved === 'string' ? {title: resolved} : resolved;\n };\n\n /**\n * A loading toast that the promise ends. It is this manager's loading and\n * update rather than Base UI's own `promise`, which writes `success` over\n * whatever the stage says: here a stage may end in a warning — partly done —\n * or in any other type it names.\n */\n const promise = <Value, Data extends object>(\n work: Promise<Value>,\n options: ToastPromiseOptions<Value, Data>,\n ): Promise<Value> => {\n const id = add({...stage(options.loading), type: ToastType.Loading});\n return work.then(\n (result) => {\n update(id, {type: ToastType.Success, ...stage(options.success, result)});\n return result;\n },\n (error: unknown) => {\n if (options.error === undefined) {\n close(id);\n } else {\n update(id, {type: ToastType.Error, ...stage(options.error, error)});\n }\n throw error;\n },\n );\n };\n\n const shortcut =\n (type: ToastType) =>\n <Data extends object>(title: ReactNode, options?: ToastShortcutOptions<Data>) =>\n add({...options, type, title});\n\n return {\n ...manager,\n ' subscribe': subscribe,\n add,\n update,\n close,\n promise,\n isActive: (id) => find(id)?.active === true,\n success: shortcut(ToastType.Success),\n info: shortcut(ToastType.Info),\n warning: shortcut(ToastType.Warning),\n error: shortcut(ToastType.Error),\n loading: shortcut(ToastType.Loading),\n };\n};\n\n/**\n * The manager the app calls from anywhere, components or not — an axios\n * interceptor, a saga, a jQuery widget: `toast.error('Could not save')`,\n * `toast.add({type: 'success', title: 'Saved'})`. `<Toaster />` renders what\n * it holds.\n */\nconst toast = createToastManager();\n\nconst ToastProvider = (props: ToastPrimitive.Provider.Props) => <ToastPrimitive.Provider {...props} />;\n\nconst ToastPortal = (props: ToastPrimitive.Portal.Props) => (\n <ToastPrimitive.Portal data-slot=\"toast-portal\" {...props} />\n);\n\nconst POSITIONS: readonly string[] = Object.values(ToastPosition);\n\n/** A value from plain JS that names no corner falls back to the top right. */\nconst splitPosition = (position: ToastPosition) => {\n const known = POSITIONS.includes(position) ? position : ToastPosition.TopRight;\n const [y, x] = known.split('-') as ['top' | 'bottom', 'left' | 'center' | 'right'];\n return {x, y};\n};\n\nconst swipeDirectionOf = (position: ToastPosition): ToastProps['swipeDirection'] => {\n const {x, y} = splitPosition(position);\n const vertical = y === 'top' ? 'up' : 'down';\n return x === 'center' ? [vertical] : [vertical, x];\n};\n\n/* Lets a Toast composed by hand swipe towards the corner of its viewport. */\nconst ToastPositionContext = createContext<ToastPosition>(ToastPosition.TopRight);\n\n/** The corner the toasts stack in; the full width at its edge on a phone. */\nconst ToastViewport = ({className, position = ToastPosition.TopRight, ...props}: ToastViewportProps) => {\n const {x, y} = splitPosition(position);\n\n return (\n <ToastPositionContext.Provider value={position}>\n <ToastPrimitive.Viewport\n data-slot=\"toast-viewport\"\n data-x-position={x}\n data-y-position={y}\n className={cn('toast-viewport', className)}\n {...props}\n />\n </ToastPositionContext.Provider>\n );\n};\n\n/** One toast in the stack. The stylesheet moves it by the custom properties Base UI writes on it. */\nconst Toast = ({className, swipeDirection, ...props}: ToastProps) => {\n const position = useContext(ToastPositionContext);\n\n return (\n <ToastPrimitive.Root\n data-slot=\"toast\"\n className={cn('toast', className)}\n swipeDirection={swipeDirection ?? swipeDirectionOf(position)}\n {...props}\n />\n );\n};\n\n/** The row inside: the icon, the text, the action and the close button. It fades out behind the front toast. */\nconst ToastContent = ({className, ...props}: ToastContentProps) => (\n <ToastPrimitive.Content data-slot=\"toast-content\" className={cn('toast__content', className)} {...props} />\n);\n\nconst ToastTitle = ({className, ...props}: ToastTitleProps) => (\n <ToastPrimitive.Title data-slot=\"toast-title\" className={cn('toast__title', className)} {...props} />\n);\n\nconst ToastDescription = ({className, ...props}: ToastDescriptionProps) => (\n <ToastPrimitive.Description\n data-slot=\"toast-description\"\n className={cn('toast__description', className)}\n {...props}\n />\n);\n\n/** The one button a toast may carry — undo, retry, open. It takes its label and handler from `actionProps`. */\nconst ToastAction = ({className, ...props}: ToastActionProps) => (\n <ToastPrimitive.Action\n data-slot=\"toast-action\"\n className={cn(buttonVariants({variant: 'secondary'}), 'toast__action', className)}\n {...props}\n />\n);\n\n/* The icons are the paths of @propellerads/icon. That package draws through\n styled-components; a toast has no other use for it, so it carries the\n paths themselves. */\nconst Svg = ({children}: {children: ReactNode}) => (\n <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" focusable=\"false\">\n {children}\n </svg>\n);\n\n/* Close */\nconst CloseIcon = () => (\n <Svg>\n <path d=\"M18.3 5.71c-.39-.39-1.02-.39-1.41 0L12 10.59 7.11 5.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z\" />\n </Svg>\n);\n\n/* CheckCircle, InfoOutline, WarningOutline and Error, as Alert's stories pair them with the statuses. */\nconst STATUS_ICONS: Partial<Record<string, ReactNode>> = {\n [ToastType.Success]: (\n <Svg>\n <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z\" />\n </Svg>\n ),\n [ToastType.Info]: (\n <Svg>\n <path d=\"M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z\" />\n </Svg>\n ),\n [ToastType.Warning]: (\n <Svg>\n <path d=\"M12 5.98999L19.53 19H4.47L12 5.98999ZM2.74 18C1.97 19.33 2.93 21 4.47 21H19.53C21.07 21 22.03 19.33 21.26 18L13.73 4.98999C12.96 3.65999 11.04 3.65999 10.27 4.98999L2.74 18ZM11 11V13C11 13.55 11.45 14 12 14C12.55 14 13 13.55 13 13V11C13 10.45 12.55 9.99999 12 9.99999C11.45 9.99999 11 10.45 11 11ZM11 16H13V18H11V16Z\" />\n </Svg>\n ),\n [ToastType.Error]: (\n <Svg>\n <path d=\"M12 7c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1zm-.01-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm1-3h-2v-2h2v2z\" />\n </Svg>\n ),\n // The ring is drawn by the stylesheet, the way the Spinner draws its own.\n [ToastType.Loading]: <span className=\"toast__ring\" />,\n};\n\n/** The close button at the end of the row, a ghost square with a hit area wider than itself. */\nconst ToastClose = ({className, children, ...props}: ToastCloseProps) => (\n <ToastPrimitive.Close\n data-slot=\"toast-close\"\n aria-label=\"Close\"\n className={cn(buttonVariants({variant: 'ghost', iconOnly: true, quiet: true}), 'toast__close', className)}\n {...props}\n >\n {children ?? <CloseIcon />}\n </ToastPrimitive.Close>\n);\n\n/** The status icon, in the status colour. A toast of no known type has none. The title says what it shows. */\nconst ToastIcon = ({type}: ToastIconProps) => {\n const icon = type === undefined ? undefined : STATUS_ICONS[type];\n\n return icon ? (\n <span data-slot=\"toast-icon\" className=\"toast__icon\" aria-hidden>\n {icon}\n </span>\n ) : null;\n};\n\n/**\n * One toast as the Toaster draws it: the icon, the title and the description,\n * the action, and the cross. A page that shows a toast outside the\n * corner — a reference, a preview — draws it with this too.\n */\nconst ToastItem = ({toast: item, ...props}: ToastProps) => (\n <Toast toast={item} {...props}>\n <ToastContent>\n <ToastIcon type={item.type} />\n <div className=\"toast__body\">\n <div className=\"toast__text\">\n <ToastTitle />\n <ToastDescription />\n </div>\n <ToastAction />\n </div>\n <ToastClose />\n </ToastContent>\n </Toast>\n);\n\n/** Every toast the manager holds, drawn the one way. */\nconst ToastList = () => {\n const {toasts} = ToastPrimitive.useToastManager();\n\n return toasts.map((item) => <ToastItem key={item.id} toast={item} />);\n};\n\n/**\n * Put once at the root of the app, around it or beside it. It renders the\n * toasts of `toast`, or of the manager passed in — a second Toaster with a\n * manager of its own is a second stack.\n */\n/** The most toasts a stack holds, whatever a call from plain JS asks for. */\nconst MAX_LIMIT = 5;\n\nconst Toaster = ({\n children,\n toastManager = toast,\n limit = 3,\n position = ToastPosition.TopRight,\n ...props\n}: ToasterProps) => (\n <ToastProvider toastManager={toastManager} limit={Math.min(Math.max(limit, 1), MAX_LIMIT)} {...props}>\n {children}\n <ToastPortal>\n <ToastViewport position={position}>\n <ToastList />\n </ToastViewport>\n </ToastPortal>\n </ToastProvider>\n);\n\n/**\n * The toasts of the nearest Toaster or ToastProvider, to draw them — as\n * ToastItem does in a reference page. It reads and does not add: Base UI's own\n * hook would add past this package's manager, without `persistent`, the id\n * check or `isActive`. Toasts are added with `toast` or a manager from\n * `createToastManager`.\n */\nconst useToasts = () => ToastPrimitive.useToastManager().toasts;\n\nexport default Toaster;\n\nexport type {\n ToastActionProps,\n ToastCloseProps,\n ToastContentProps,\n ToastDescriptionProps,\n ToasterProps,\n ToastIconProps,\n ToastLimit,\n ToastManager,\n ToastOptions,\n ToastProps,\n ToastShortcutOptions,\n ToastTitleProps,\n ToastViewportProps,\n} from './types';\nexport {\n createToastManager,\n Toast,\n ToastAction,\n ToastClose,\n ToastContent,\n ToastDescription,\n Toaster,\n ToastIcon,\n ToastItem,\n ToastPortal,\n ToastPosition,\n ToastProvider,\n ToastTitle,\n ToastType,\n ToastViewport,\n toast,\n useToasts,\n};\n"],"mappings":";;;;;;AAOA,IAAME,KAAM,GAAGC,MAAiCC,EAAKD,CAAM,GCO9CE,IAAY;CAEvB,SAAS;CAET,SAAS;CAET,MAAM;CAEN,SAAS;CAET,OAAO;CAEP,SAAS;AACX,GAOaC,IAAgB;CAC3B,SAAS;CACT,WAAW;CACX,UAAU;CACV,YAAY;CACZ,cAAc;CACd,aAAa;AACf,GCLMC,KAAoC,EAAC,eAAY,GAAGC,QAAuC;CAC/F,IAAMC,IAAY,EAAC,GAAGD,EAAO;CAO7B,OALA,OAAOC,EAAU,SACbC,MAAe,OACjB,EAAU,UAAU,GACpB,EAAU,WAAWF,EAAQ,YAAY,SAEpCC;AACT,GAgBME,UAAyC;CAC7C,IAAMC,IAAUZ,EAAe,mBAAmB,GAiB5Ca,oBAAW,IAAI,IAAqB,GACtCC,IAAQ,GAORC,IAAY,GACVC,IAA6B,CAAC,GAC9BC,KAAQ,MAA2B;EACvC,AAAIF,IAAY,IACdG,EAAK,IAELF,EAAQ,KAAKE,CAAI;CAErB,GACMC,KAAyC,MAAa;EAC1D,IAAMC,IAAcR,EAAQ,aAAa,CAACS,CAAQ;EAClD,KAAa;EACb,KAAK,IAAMH,KAAQF,EAAQ,OAAO,CAAC,GACjC,EAAK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;EAClD,UAAAA;CACG,CAAA,IACJ;AACN,GAOMC,KAAa,EAAC,OAAOC,GAAM,GAAG7B,QAClC,kBAACa,GAAD;CAAO,OAAOgB;CAAM,GAAI7B;CACtB,UAAA,kBAACgB,GAAD,EAAA,UAAA;EACE,kBAACU,GAAD,EAAW,MAAMG,EAAK,KAAO,CAAA;EAC7B,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACZ,GAAD,CAAa,CAAA,GACb,kBAACC,GAAD,CAAmB,CAAA,CAChB;GACL,CAAA,GAAA,kBAACC,GAAD,CAAc,CAAA,CACX;;EACL,kBAACK,GAAD,CAAa,CAAA;CACD,EAAA,CAAA;AACT,CAAA,GAIHM,UAAkB;CACtB,IAAM,EAAC,cAAU/E,EAAe,gBAAgB;CAEhD,OAAOgF,EAAO,KAAK,MAAS,kBAACH,GAAD,EAAyB,OAAOC,EAAO,GAAvBA,EAAK,EAAkB,CAAC;AACtE,GAQMG,IAAY,GAEZC,KAAW,EACf,aACA,kBAAenC,GACf,WAAQ,GACR,cAAWzC,EAAc,UACzB,GAAG2C,QAEH,kBAACD,GAAD;CAA6B;CAAc,OAAO,KAAK,IAAI,KAAK,IAAImC,GAAO,CAAC,GAAGF,CAAS;CAAG,GAAIhC;CAA/F,UAAA,CACGyB,GACD,kBAACxB,GAAD,EAAA,UACE,kBAACU,GAAD;EAAyB;EACvB,UAAA,kBAACmB,GAAD,CAAY,CAAA;CACC,CAAA,EACJ,CAAA,CACA;A,IAUXK,UAAkBpF,EAAe,gBAAgB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/toast",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/index.css",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc && vite build &&
|
|
27
|
+
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
30
30
|
"private": false,
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@base-ui-components/react": "1.0.0-rc.0",
|
|
33
|
-
"@propellerads/button": "^
|
|
33
|
+
"@propellerads/button": "^14.0.0",
|
|
34
34
|
"clsx": "^2.1.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@propellerads/tokens": ">=0.
|
|
37
|
+
"@propellerads/tokens": ">=0.5.0",
|
|
38
38
|
"react": "^18.0.0 || ^19.0.0",
|
|
39
39
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
40
40
|
},
|