@propellerads/toast 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,156 @@
1
- # Temporary Holding Version
1
+ # Toast
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A short message over the interface that goes away by itself: shadcn's
4
+ [Toast](https://ui.shadcn.com/docs/components/base/toast) on
5
+ [Base UI's Toast](https://base-ui.com/react/components/toast). The stack, the
6
+ fan-out under the pointer and the swipe to dismiss are shadcn's; every colour,
7
+ gap, corner and font comes from [@propellerads/tokens](../Tokens/README.md), and
8
+ the action and the close button are [@propellerads/button](../Button/README.md).
9
+
10
+ ![](https://img.shields.io/npm/v/@propellerads/toast.svg?style=flat-square)
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ bun add @propellerads/toast
16
+ ```
17
+
18
+ The built entry imports its own stylesheet. The tokens are the app's:
19
+
20
+ ```ts
21
+ import '@propellerads/tokens/common.css';
22
+ import '@propellerads/tokens/propellerads.css'; // or monetag / propush / zeydoo
23
+ ```
24
+
25
+ ## Use
26
+
27
+ Put `<Toaster />` once at the root of the app:
28
+
29
+ ```tsx
30
+ import {Toaster} from '@propellerads/toast';
31
+
32
+ <App />
33
+ <Toaster />
34
+ ```
35
+
36
+ Then call `toast` from anywhere — a component, a saga, an axios interceptor, a
37
+ jQuery widget. A call made before `<Toaster />` is on the page, on the app's
38
+ first request say, waits and shows once it is:
39
+
40
+ ```ts
41
+ import {toast} from '@propellerads/toast';
42
+
43
+ toast.error('Could not save the campaign');
44
+ toast.success('Campaign saved', {description: 'Changes go live within five minutes.'});
45
+ toast.add({type: 'warning', title: 'Balance is running low', persistent: true});
46
+ ```
47
+
48
+ `toast.success`, `info`, `warning`, `error` and `loading` take the title and the
49
+ rest of the options, and return the toast's id. A `\n` in the title or the
50
+ description starts a new line, so server errors joined with `'\n'` keep a line
51
+ each. Both take any ReactNode, links included.
52
+
53
+ ## Types
54
+
55
+ `type` picks the icon and its colour; the surface is the same for all of them.
56
+
57
+ | type | icon |
58
+ | --- | --- |
59
+ | none | no icon |
60
+ | `success` | check, `--color-success` |
61
+ | `info` | info, `--color-action` |
62
+ | `warning` | warning, `--color-warning` |
63
+ | `error` | error, `--color-danger` |
64
+ | `loading` | a turning ring; it never closes by itself |
65
+
66
+ The danger type is `error`, not Alert's `danger`: `toast.promise` writes
67
+ `loading`, `success` and `error` itself.
68
+
69
+ ## Options
70
+
71
+ | option | what it does |
72
+ | --- | --- |
73
+ | `title`, `description` | Either may be left out. |
74
+ | `persistent` | Stays until the user closes it or presses its action, and is announced at once. Without it a toast goes away after five seconds; no call picks its own number. A `loading` toast stays until it is updated or closed. |
75
+ | `actionProps` | One button: `{children: 'Undo', onClick}`. |
76
+ | `priority` | `'high'` announces it to a screen reader at once. |
77
+ | `id` | Your own id. An `add` with the id of a toast still on screen updates it instead of stacking a second one — react-toastify's `toastId`. |
78
+ | `onClose`, `onRemove` | Called when it closes, and when it is gone after the animation. |
79
+
80
+ ## The manager
81
+
82
+ ```ts
83
+ toast.isActive('api-network-error'); // still on screen
84
+
85
+ const id = toast.add({type: 'loading', title: 'Uploading…'});
86
+ toast.update(id, {type: 'success', title: 'Uploaded'}); // goes away in five seconds
87
+ toast.close(id); // or close it before that
88
+
89
+ toast.promise(save(), {
90
+ loading: 'Saving…',
91
+ success: 'Saved',
92
+ error: (error) => ({title: 'Could not save', description: error.message}),
93
+ });
94
+
95
+ // Partly done: a stage may name its own type.
96
+ toast.promise(importRates(), {
97
+ loading: 'Importing rates…',
98
+ success: (result) => ({type: 'warning', title: 'Rates imported', description: `${result.skipped} campaigns skipped`}),
99
+ error: 'Could not import rates',
100
+ });
101
+ ```
102
+
103
+ A stage given as text is the title, as in `toast.error(text)`. The result goes
104
+ away in five seconds, or stays with `persistent: true`.
105
+
106
+ `error` may be left out. Then a failure closes the loading toast and shows
107
+ nothing: for a request whose errors the app's own handler already shows, one
108
+ failure stays one toast.
109
+
110
+ ## Toaster
111
+
112
+ | prop | what it does |
113
+ | --- | --- |
114
+ | `limit` | How many toasts stand at once: `1`–`5`, `3` by default. A toast over the limit is not dropped: it waits unseen and comes forward when one in front closes. The stack does not scroll, so it stops at five. |
115
+ | `toastManager` | A manager of your own from `createToastManager()`: a second Toaster with it is a second stack. |
116
+
117
+ The stack always stands in the bottom right — the full width at the bottom on a
118
+ phone — for every toast of every product, cookie consent included. It is at
119
+ `z-index: 3100`, above dialogs and tooltips at 3000; `--toast-layer` on any
120
+ ancestor changes it.
121
+
122
+ ## From react-toastify
123
+
124
+ | react-toastify | here |
125
+ | --- | --- |
126
+ | `<ToastContainer position="top-right" autoClose={5000} />` | `<Toaster />` — the bottom right and five seconds, always |
127
+ | `toast.error(text)`, `toast.success(text)` | the same |
128
+ | `toast.warn(text)`, `toast.info(text)`, `toast(text)` | `toast.warning(text)`, `toast.info(text)`, `toast.add({title: text})` |
129
+ | `{autoClose: false}` | `{persistent: true}`; any other `autoClose` goes |
130
+ | `{toastId}` | `{id}` |
131
+ | `toast.dismiss(id)`, `toast.isActive(id)` | `toast.close(id)`, `toast.isActive(id)` |
132
+
133
+ The progress bar, `draggable`, `closeOnClick`, `newestOnTop` and per-call
134
+ `className` and `position` have no counterpart.
135
+
136
+ ## Writing toasts
137
+
138
+ - One short line. A second, the description, only when it adds something.
139
+ - A list of errors does not belong in a toast: it is gone before it is read.
140
+ The toast says that the save failed; the errors stand by their fields.
141
+ - The button says what to do, so the text does not repeat it.
142
+ - Do not reload or leave the page right after a toast: it goes with the page,
143
+ unread. Reload from the toast's own button, or after it closes (`onClose`).
144
+
145
+ ## Outside the corner
146
+
147
+ `ToastItem` is one toast as the Toaster draws it. Inside a `ToastProvider` of
148
+ its own it shows a toast anywhere — a reference page, a preview. `useToasts()`
149
+ reads the toasts of that provider to draw them; toasts are added with `toast`
150
+ or a manager from `createToastManager()`, never past them.
151
+
152
+ ## Overrides
153
+
154
+ The custom properties at the top of `.toast` are the override API:
155
+ `--toast-bg`, `--toast-contour`, `--toast-shadow`, `--toast-title`,
156
+ `--toast-text`, `--toast-icon`.
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .toast-viewport{z-index:var(--toast-layer,3100);inset-inline:var(--space-16);bottom:var(--space-16);pointer-events:none;outline:none;width:auto;max-width:384px;margin-inline:auto;position:fixed}@media (width>=640px){.toast-viewport{left:auto;right:var(--space-16);width:100%;margin-inline:var(--space-0)}}.toast{--toast-bg:var(--color-light-inversion);--toast-contour:var(--color-formal);--toast-shadow:var(--shadow-big);--toast-title:var(--color-dark-inversion);--toast-text:var(--color-quiet-text);--toast-icon:var(--color-quiet);--gap:var(--space-12);--peek:var(--space-12);--height:var(--toast-frontmost-height,var(--toast-height));--offset-y:calc(var(--toast-offset-y) * -1 + var(--toast-index) * var(--gap) * -1 + var(--toast-swipe-movement-y));--scale:max(0, 1 - var(--toast-index) * .1);--shrink:calc(1 - var(--scale));--toast-move:var(--duration-300) var(--ease-enter);--toast-fade:var(--duration-300);box-sizing:border-box;z-index:calc(1000 - var(--toast-index));width:100%;height:var(--height);border-radius:var(--radius-16);background-color:var(--toast-bg);box-shadow:inset 0 0 0 var(--space-1) var(--toast-contour), var(--toast-shadow);color:var(--toast-text);font:var(--font-paragraph);font-family:var(--font-family);transform-origin:bottom;transform:translateX(var(--toast-swipe-movement-x)) translateY(calc(var(--toast-swipe-movement-y) - var(--toast-index) * var(--peek) - var(--shrink) * var(--height))) scale(var(--scale));transition:transform var(--toast-move), opacity var(--toast-fade) var(--ease-flat), height var(--duration-100) var(--ease-flat);outline:var(--space-2) solid transparent;outline-offset:var(--space-1);pointer-events:auto;-webkit-user-select:none;user-select:none;will-change:transform;position:absolute;bottom:0;right:0}.toast:focus-visible{outline-color:var(--color-action)}.toast:after{content:"";width:100%;height:calc(var(--gap) + 1px);position:absolute;top:100%;left:0}.toast[data-expanded]{height:var(--toast-height);transform:translateX(var(--toast-swipe-movement-x)) translateY(var(--offset-y))}.toast[data-ending-style]{--toast-move:var(--duration-200) var(--ease-exit);--toast-fade:var(--duration-200)}.toast[data-starting-style],.toast[data-ending-style]:not([data-limited]):not([data-swipe-direction]){transform:translateY(150%)}.toast[data-limited]{opacity:0}.toast[data-ending-style][data-swipe-direction=down]{transform:translateY(calc(var(--toast-swipe-movement-y) + 150%))}.toast[data-ending-style][data-swipe-direction=up]{transform:translateY(calc(var(--toast-swipe-movement-y) - 150%))}.toast[data-ending-style][data-swipe-direction=left]{transform:translateX(calc(var(--toast-swipe-movement-x) - 150%)) translateY(var(--offset-y))}.toast[data-ending-style][data-swipe-direction=right]{transform:translateX(calc(var(--toast-swipe-movement-x) + 150%)) translateY(var(--offset-y))}.toast[data-type=success]{--toast-icon:var(--color-success)}.toast[data-type=info]{--toast-icon:var(--color-action)}.toast[data-type=warning]{--toast-icon:var(--color-warning)}.toast[data-type=error]{--toast-icon:var(--color-danger)}.toast__content{--toast-line:36px;--toast-text-line:var(--space-20);box-sizing:border-box;align-items:flex-start;gap:var(--space-12);height:100%;padding:var(--space-16);transition:opacity var(--duration-200) var(--ease-flat);padding-inline-start:calc(var(--space-16) + var(--space-4));display:flex;overflow:hidden}.toast__content[data-behind]{opacity:0}.toast__content[data-expanded]{opacity:1}.toast__icon{width:var(--space-16);height:var(--space-16);color:var(--toast-icon);pointer-events:none;flex-shrink:0;margin-block-start:calc((var(--toast-line) - var(--space-16)) / 2);display:flex}.toast__icon>svg{width:100%;height:100%}.toast__ring{box-sizing:border-box;border:var(--space-2) solid var(--color-rich);border-top-color:var(--color-dark-inversion);border-radius:50%;width:100%;height:100%;animation:.8s linear infinite toast-turn}@keyframes toast-turn{to{transform:rotate(360deg)}}.toast__body{align-items:flex-start;gap:var(--space-4) var(--space-12);flex-wrap:wrap;flex:1;min-width:0;display:flex}.toast__text{gap:var(--space-4);min-width:0;padding-block:calc((var(--toast-line) - var(--toast-text-line)) / 2);flex-direction:column;flex:auto;display:flex}.toast__title{margin:var(--space-0);color:var(--toast-title);font:var(--font-h4);font-family:var(--font-family);line-height:var(--toast-text-line);white-space:pre-line;overflow-wrap:anywhere}.toast__description{margin:var(--space-0);color:var(--toast-text);font:var(--font-paragraph);font-family:var(--font-family);text-wrap:pretty;white-space:pre-line;overflow-wrap:anywhere}.toast__description a{color:inherit;text-underline-offset:var(--space-4);text-decoration:underline}.toast__action,.toast__close{flex-shrink:0}.toast__close>svg{width:var(--space-16);height:var(--space-16)}@media (prefers-reduced-motion:reduce){.toast__ring{animation-duration:2.4s}}
@@ -0,0 +1,163 @@
1
+ import * as _base_ui_components_react_toast from '@base-ui-components/react/toast';
2
+ import { Toast as Toast$1, ToastManager as ToastManager$1, ToastManagerAddOptions } from '@base-ui-components/react/toast';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { ReactNode } from 'react';
5
+
6
+ /**
7
+ * What the toast is about: the icon in front of the title and its colour. These
8
+ * are the types shadcn's renderer recognises. The danger one is `error` rather
9
+ * than the `danger` of Alert and the tokens, because `toast.promise` writes
10
+ * `loading`, `success` and `error` itself, and a toast it settles has to look
11
+ * like one added by hand.
12
+ */
13
+ declare const ToastType: {
14
+ /** No status, no icon: the plain message. */
15
+ readonly Default: "default";
16
+ /** A scenario that worked: the --color-success icon. */
17
+ readonly Success: "success";
18
+ /** Something to know: the --color-action icon. */
19
+ readonly Info: "info";
20
+ /** Nothing is broken yet: the --color-warning icon. */
21
+ readonly Warning: "warning";
22
+ /** Something failed: the --color-danger icon. */
23
+ readonly Error: "error";
24
+ /** A task still running: a turning ring. It stays until it is updated or closed. */
25
+ readonly Loading: "loading";
26
+ };
27
+ type ToastType = (typeof ToastType)[keyof typeof ToastType];
28
+ /**
29
+ * What `toast.add` takes: Base UI's options without `timeout`. A toast either
30
+ * goes away by itself after five seconds, or stays until the user closes it or
31
+ * acts on it — `persistent`. No call site picks its own number of seconds.
32
+ * `data` is anything of your own the toast carries.
33
+ */
34
+ type ToastOptions<Data extends object = {}> = Omit<ToastManagerAddOptions<Data>, 'timeout'> & {
35
+ /**
36
+ * Stays until the user closes it or presses its action: a new build to
37
+ * reload for, a session that expired, cookie consent. It is announced at
38
+ * once, as `priority: 'high'`, unless `priority` says otherwise.
39
+ */
40
+ persistent?: boolean;
41
+ };
42
+ /** What `toast.update` takes: any of the options, the rest stay as they were. */
43
+ type ToastUpdateOptions<Data extends object = {}> = Partial<ToastOptions<Data>>;
44
+ /** What the shortcuts take after the text: everything but the type and the title. */
45
+ type ToastShortcutOptions<Data extends object = {}> = Omit<ToastOptions<Data>, 'type' | 'title'>;
46
+ /** One stage of `toast.promise`: a title, the options, or a function of the result or the error. */
47
+ type ToastPromiseStage<Input, Data extends object> = string | ToastUpdateOptions<Data> | ((input: Input) => string | ToastUpdateOptions<Data>);
48
+ type ToastPromiseOptions<Value, Data extends object = {}> = {
49
+ loading: string | ToastUpdateOptions<Data>;
50
+ success: ToastPromiseStage<Value, Data>;
51
+ /**
52
+ * Left out, a failure closes the loading toast and says nothing: for a
53
+ * request whose errors the app's own handler already shows, so that one
54
+ * failure is one toast.
55
+ */
56
+ error?: ToastPromiseStage<any, Data>;
57
+ };
58
+ /** A shortcut for one type: the text is the title. Returns the toast's id. */
59
+ type Shortcut = <Data extends object>(title: ReactNode, options?: ToastShortcutOptions<Data>) => string;
60
+ /**
61
+ * Base UI's manager with what the cabinets lean on.
62
+ *
63
+ * - `add` with the `id` of a toast still on screen updates that toast instead
64
+ * of stacking a second one, as react-toastify's `toastId` did.
65
+ * - `update` of a loading toast to any other type starts its five seconds,
66
+ * as `toast.promise` does when the promise settles.
67
+ * - `isActive` says whether a toast is still on screen.
68
+ * - One shortcut per type: `toast.error('Could not save')`.
69
+ */
70
+ type ToastManager = Omit<ToastManager$1, 'add' | 'update' | 'promise'> & {
71
+ add: <Data extends object>(options: ToastOptions<Data>) => string;
72
+ update: <Data extends object>(id: string, updates: ToastUpdateOptions<Data>) => void;
73
+ promise: <Value, Data extends object>(promise: Promise<Value>, options: ToastPromiseOptions<Value, Data>) => Promise<Value>;
74
+ isActive: (id: string) => boolean;
75
+ success: Shortcut;
76
+ info: Shortcut;
77
+ warning: Shortcut;
78
+ error: Shortcut;
79
+ loading: Shortcut;
80
+ };
81
+ /**
82
+ * A part's own props, with `className` as a string. Base UI also takes a
83
+ * function of the part's state there; the parts here join the string with
84
+ * their own class names, and a function cannot be joined.
85
+ */
86
+ type WithClassName<Props> = Omit<Props, 'className'> & {
87
+ className?: string;
88
+ };
89
+ /** How many toasts stand in the stack at once: up to five, so a fanned-out stack fits a laptop's screen. */
90
+ type ToastLimit = 1 | 2 | 3 | 4 | 5;
91
+ /** Base UI's provider props without `timeout`: every toast that goes away by itself takes five seconds. */
92
+ type ToasterProps = Omit<Toast$1.Provider.Props, 'timeout' | 'limit'> & {
93
+ /**
94
+ * How many toasts stand at once. One over the limit is not dropped: it waits
95
+ * unseen and comes forward when one in front closes. The stack does not
96
+ * scroll, so it stops at five. @default 3
97
+ */
98
+ limit?: ToastLimit;
99
+ };
100
+ type ToastViewportProps = WithClassName<Toast$1.Viewport.Props>;
101
+ type ToastProps = WithClassName<Toast$1.Root.Props>;
102
+ type ToastContentProps = WithClassName<Toast$1.Content.Props>;
103
+ type ToastTitleProps = WithClassName<Toast$1.Title.Props>;
104
+ type ToastDescriptionProps = WithClassName<Toast$1.Description.Props>;
105
+ type ToastActionProps = WithClassName<Toast$1.Action.Props>;
106
+ type ToastCloseProps = WithClassName<Toast$1.Close.Props>;
107
+ type ToastIconProps = {
108
+ type: string | undefined;
109
+ };
110
+
111
+ /**
112
+ * Base UI's manager, with what the cabinets did through react-toastify. A
113
+ * toast stops being active as it starts to close, so an `add` with its id
114
+ * while it slides out is a new toast rather than an update of a leaving one.
115
+ *
116
+ * A loading toast is Base UI's `promise` with a promise this manager holds:
117
+ * Base UI starts a toast's seconds only when it is added or when its promise
118
+ * settles, never on an update. The `update` that turns it into anything else
119
+ * settles that promise, so the result goes away by itself as one from
120
+ * `toast.promise` does.
121
+ */
122
+ declare const createToastManager: () => ToastManager;
123
+ /**
124
+ * The manager the app calls from anywhere, components or not — an axios
125
+ * interceptor, a saga, a jQuery widget: `toast.error('Could not save')`,
126
+ * `toast.add({type: 'success', title: 'Saved'})`. `<Toaster />` renders what
127
+ * it holds.
128
+ */
129
+ declare const toast: ToastManager;
130
+ declare const ToastProvider: (props: Toast$1.Provider.Props) => react_jsx_runtime.JSX.Element;
131
+ declare const ToastPortal: (props: Toast$1.Portal.Props) => react_jsx_runtime.JSX.Element;
132
+ /** The corner the toasts stack in: the bottom right, and the full width on a phone. */
133
+ declare const ToastViewport: ({ className, ...props }: ToastViewportProps) => react_jsx_runtime.JSX.Element;
134
+ /** One toast in the stack. The stylesheet moves it by the custom properties Base UI writes on it. */
135
+ declare const Toast: ({ className, ...props }: ToastProps) => react_jsx_runtime.JSX.Element;
136
+ /** The row inside: the icon, the text, the action and the close button. It fades out behind the front toast. */
137
+ declare const ToastContent: ({ className, ...props }: ToastContentProps) => react_jsx_runtime.JSX.Element;
138
+ declare const ToastTitle: ({ className, ...props }: ToastTitleProps) => react_jsx_runtime.JSX.Element;
139
+ declare const ToastDescription: ({ className, ...props }: ToastDescriptionProps) => react_jsx_runtime.JSX.Element;
140
+ /** The one button a toast may carry — undo, retry, open. It takes its label and handler from `actionProps`. */
141
+ declare const ToastAction: ({ className, ...props }: ToastActionProps) => react_jsx_runtime.JSX.Element;
142
+ /** The close button at the end of the row, a ghost square with a hit area wider than itself. */
143
+ declare const ToastClose: ({ className, children, ...props }: ToastCloseProps) => react_jsx_runtime.JSX.Element;
144
+ /** The status icon, in the status colour. A toast of no known type has none. The title says what it shows. */
145
+ declare const ToastIcon: ({ type }: ToastIconProps) => react_jsx_runtime.JSX.Element | null;
146
+ /**
147
+ * One toast as the Toaster draws it: the icon, the title and the description,
148
+ * the action, and the cross. A page that shows a toast outside the
149
+ * corner — a reference, a preview — draws it with this too.
150
+ */
151
+ declare const ToastItem: ({ toast: item, ...props }: ToastProps) => react_jsx_runtime.JSX.Element;
152
+ declare const Toaster: ({ children, toastManager, limit, ...props }: ToasterProps) => react_jsx_runtime.JSX.Element;
153
+ /**
154
+ * The toasts of the nearest Toaster or ToastProvider, to draw them — as
155
+ * ToastItem does in a reference page. It reads and does not add: Base UI's own
156
+ * hook would add past this package's manager, without `persistent`, the id
157
+ * check or `isActive`. Toasts are added with `toast` or a manager from
158
+ * `createToastManager`.
159
+ */
160
+ declare const useToasts: () => _base_ui_components_react_toast.ToastObject<any>[];
161
+
162
+ export { Toast, ToastAction, ToastClose, ToastContent, ToastDescription, ToastIcon, ToastItem, ToastPortal, ToastProvider, ToastTitle, ToastType, ToastViewport, Toaster, createToastManager, Toaster as default, toast, useToasts };
163
+ export type { ToastActionProps, ToastCloseProps, ToastContentProps, ToastDescriptionProps, ToastIconProps, ToastLimit, ToastManager, ToastOptions, ToastProps, ToastShortcutOptions, ToastTitleProps, ToastViewportProps, ToasterProps };
package/dist/index.js ADDED
@@ -0,0 +1,196 @@
1
+ import { Toast as e } from "@base-ui-components/react/toast";
2
+ import { buttonVariants as t } from "@propellerads/button";
3
+ import { clsx as n } from "clsx";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import './index.css';//#region src/cn.ts
6
+ var a = (...e) => n(e), o = {
7
+ Default: "default",
8
+ Success: "success",
9
+ Info: "info",
10
+ Warning: "warning",
11
+ Error: "error",
12
+ Loading: "loading"
13
+ }, s = ({ persistent: e, ...t }) => {
14
+ let n = { ...t };
15
+ return delete n.timeout, e === !0 && (n.timeout = 0, n.priority = t.priority ?? "high"), n;
16
+ }, c = () => {
17
+ let t = e.createToastManager(), n = /* @__PURE__ */ new Map(), r = 0, i = 0, a = [], c = (e) => {
18
+ i > 0 ? e() : a.push(e);
19
+ }, l = (e) => {
20
+ let r = t[" subscribe"](e);
21
+ i += 1;
22
+ for (let e of a.splice(0)) e();
23
+ return () => {
24
+ r(), --i;
25
+ let e = new Map(n);
26
+ queueMicrotask(() => {
27
+ if (!(i > 0)) for (let [t, r] of e) n.get(t) === r && n.delete(t);
28
+ });
29
+ };
30
+ }, u = (e) => n.get(e) ?? [...n.values()].find((t) => t.internal === e), d = (e, { onClose: t, onRemove: n }) => {
31
+ e.onClose = t ?? e.onClose, e.onRemove = n ?? e.onRemove;
32
+ }, f = ({ onClose: e, onRemove: t, id: n, ...r }) => s(r), p = (e, t, r) => ({
33
+ ...f(r),
34
+ id: t.internal,
35
+ onClose: () => {
36
+ t.active = !1, t.pending = void 0, t.onClose?.();
37
+ },
38
+ onRemove: () => {
39
+ n.get(e) === t && n.delete(e), t.onRemove?.();
40
+ }
41
+ }), m = (e, n) => {
42
+ let r = u(e);
43
+ if (!r) return;
44
+ d(r, n);
45
+ let i = r.pending;
46
+ if (!i || n.type === void 0 || n.type === o.Loading) {
47
+ c(() => t.update(r.internal, f(n)));
48
+ return;
49
+ }
50
+ r.pending = void 0;
51
+ let { type: a } = n;
52
+ a === o.Error ? i.reject(f(n)) : i.resolve(f(n)), a !== o.Success && a !== o.Error && c(() => queueMicrotask(() => t.update(r.internal, { type: a === o.Default ? void 0 : a })));
53
+ }, h = (e) => {
54
+ if (e.id !== void 0 && n.get(e.id)?.active) return m(e.id, e), e.id;
55
+ r += 1;
56
+ let i = e.id ?? `~toast-${r}`, a = {
57
+ internal: n.has(i) ? `${i}~${r}` : i,
58
+ active: !0
59
+ };
60
+ if (d(a, e), n.set(i, a), e.type !== o.Loading) return c(() => t.add(p(i, a, e))), i;
61
+ let s = new Promise((e, t) => {
62
+ a.pending = {
63
+ resolve: e,
64
+ reject: t
65
+ };
66
+ });
67
+ return c(() => {
68
+ t.promise(s, {
69
+ loading: p(i, a, e),
70
+ success: (e) => e,
71
+ error: (e) => e
72
+ }).catch(() => void 0);
73
+ }), i;
74
+ }, g = (e) => {
75
+ let n = u(e);
76
+ n && (n.pending = void 0, c(() => t.close(n.internal)));
77
+ }, _ = (e, t) => {
78
+ let n = typeof e == "function" ? e(t) : e;
79
+ return typeof n == "string" ? { title: n } : n;
80
+ }, v = (e, t) => {
81
+ let n = h({
82
+ ..._(t.loading),
83
+ type: o.Loading
84
+ });
85
+ return e.then((e) => (m(n, {
86
+ type: o.Success,
87
+ ..._(t.success, e)
88
+ }), e), (e) => {
89
+ throw t.error === void 0 ? g(n) : m(n, {
90
+ type: o.Error,
91
+ ..._(t.error, e)
92
+ }), e;
93
+ });
94
+ }, y = (e) => (t, n) => h({
95
+ ...n,
96
+ type: e,
97
+ title: t
98
+ });
99
+ return {
100
+ ...t,
101
+ " subscribe": l,
102
+ add: h,
103
+ update: m,
104
+ close: g,
105
+ promise: v,
106
+ isActive: (e) => u(e)?.active === !0,
107
+ success: y(o.Success),
108
+ info: y(o.Info),
109
+ warning: y(o.Warning),
110
+ error: y(o.Error),
111
+ loading: y(o.Loading)
112
+ };
113
+ }, l = c(), u = (t) => /* @__PURE__ */ r(e.Provider, { ...t }), d = (t) => /* @__PURE__ */ r(e.Portal, {
114
+ "data-slot": "toast-portal",
115
+ ...t
116
+ }), f = ({ className: t, ...n }) => /* @__PURE__ */ r(e.Viewport, {
117
+ "data-slot": "toast-viewport",
118
+ className: a("toast-viewport", t),
119
+ ...n
120
+ }), p = ({ className: t, ...n }) => /* @__PURE__ */ r(e.Root, {
121
+ "data-slot": "toast",
122
+ className: a("toast", t),
123
+ ...n
124
+ }), m = ({ className: t, ...n }) => /* @__PURE__ */ r(e.Content, {
125
+ "data-slot": "toast-content",
126
+ className: a("toast__content", t),
127
+ ...n
128
+ }), h = ({ className: t, ...n }) => /* @__PURE__ */ r(e.Title, {
129
+ "data-slot": "toast-title",
130
+ className: a("toast__title", t),
131
+ ...n
132
+ }), g = ({ className: t, ...n }) => /* @__PURE__ */ r(e.Description, {
133
+ "data-slot": "toast-description",
134
+ className: a("toast__description", t),
135
+ ...n
136
+ }), _ = ({ className: n, ...i }) => /* @__PURE__ */ r(e.Action, {
137
+ "data-slot": "toast-action",
138
+ className: a(t({ variant: "secondary" }), "toast__action", n),
139
+ ...i
140
+ }), v = ({ children: e }) => /* @__PURE__ */ r("svg", {
141
+ viewBox: "0 0 24 24",
142
+ fill: "currentColor",
143
+ "aria-hidden": "true",
144
+ focusable: "false",
145
+ children: e
146
+ }), y = () => /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r("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" }) }), b = {
147
+ [o.Success]: /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r("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" }) }),
148
+ [o.Info]: /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r("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" }) }),
149
+ [o.Warning]: /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r("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" }) }),
150
+ [o.Error]: /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r("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" }) }),
151
+ [o.Loading]: /* @__PURE__ */ r("span", { className: "toast__ring" })
152
+ }, x = ({ className: n, children: i, ...o }) => /* @__PURE__ */ r(e.Close, {
153
+ "data-slot": "toast-close",
154
+ "aria-label": "Close",
155
+ className: a(t({
156
+ variant: "ghost",
157
+ iconOnly: !0,
158
+ quiet: !0
159
+ }), "toast__close", n),
160
+ ...o,
161
+ children: i ?? /* @__PURE__ */ r(y, {})
162
+ }), S = ({ type: e }) => {
163
+ let t = e === void 0 ? void 0 : b[e];
164
+ return t ? /* @__PURE__ */ r("span", {
165
+ "data-slot": "toast-icon",
166
+ className: "toast__icon",
167
+ "aria-hidden": !0,
168
+ children: t
169
+ }) : null;
170
+ }, C = ({ toast: e, ...t }) => /* @__PURE__ */ r(p, {
171
+ toast: e,
172
+ ...t,
173
+ children: /* @__PURE__ */ i(m, { children: [
174
+ /* @__PURE__ */ r(S, { type: e.type }),
175
+ /* @__PURE__ */ i("div", {
176
+ className: "toast__body",
177
+ children: [/* @__PURE__ */ i("div", {
178
+ className: "toast__text",
179
+ children: [/* @__PURE__ */ r(h, {}), /* @__PURE__ */ r(g, {})]
180
+ }), /* @__PURE__ */ r(_, {})]
181
+ }),
182
+ /* @__PURE__ */ r(x, {})
183
+ ] })
184
+ }), w = () => {
185
+ let { toasts: t } = e.useToastManager();
186
+ return t.map((e) => /* @__PURE__ */ r(C, { toast: e }, e.id));
187
+ }, T = 5, E = ({ children: e, toastManager: t = l, limit: n = 3, ...a }) => /* @__PURE__ */ i(u, {
188
+ toastManager: t,
189
+ limit: Math.min(Math.max(n, 1), T),
190
+ ...a,
191
+ children: [e, /* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(f, { children: /* @__PURE__ */ r(w, {}) }) })]
192
+ }), D = () => e.useToastManager().toasts;
193
+ //#endregion
194
+ export { p as Toast, _ as ToastAction, x as ToastClose, m as ToastContent, g as ToastDescription, S as ToastIcon, C as ToastItem, d as ToastPortal, u as ToastProvider, h as ToastTitle, o as ToastType, f as ToastViewport, E as Toaster, E as default, c as createToastManager, l as toast, D as useToasts };
195
+
196
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 * 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};\nexport type ToastViewportProps = WithClassName<ToastPrimitive.Viewport.Props>;\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 type {ReactNode} 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 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\n/** The corner the toasts stack in: the bottom right, and the full width on a phone. */\nconst ToastViewport = ({className, ...props}: ToastViewportProps) => (\n <ToastPrimitive.Viewport data-slot=\"toast-viewport\" className={cn('toast-viewport', className)} {...props} />\n);\n\n/** One toast in the stack. The stylesheet moves it by the custom properties Base UI writes on it. */\nconst Toast = ({className, ...props}: ToastProps) => (\n <ToastPrimitive.Root data-slot=\"toast\" className={cn('toast', className)} {...props} />\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 = ({children, toastManager = toast, limit = 3, ...props}: ToasterProps) => (\n <ToastProvider toastManager={toastManager} limit={Math.min(Math.max(limit, 1), MAX_LIMIT)} {...props}>\n {children}\n <ToastPortal>\n <ToastViewport>\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 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,ECQK,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,IAAI,IAAI,EAAS;GAC9B,qBAAqB;IACf,UAAY,IAGhB,KAAK,IAAM,CAAC,GAAI,MAAY,GAC1B,AAAI,EAAS,IAAI,EAAG,KAAK,KACvB,EAAS,OAAO,EAAG;KAGvB;;IAQA,KAAQ,MACZ,EAAS,IAAI,EAAG,IAAI,CAAC,GAAG,EAAS,QAAQ,CAAC,CAAC,MAAM,MAAY,EAAQ,aAAa,EAAG,EAGjF,KAAY,GAAkB,EAAC,YAAS,kBAAwC;EAEpF,AADA,EAAQ,UAAU,KAAW,EAAQ,SACrC,EAAQ,WAAW,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e,CAAA,CACX;;EACN,kBAAC,GAAD,EAAc,CAAA;EACD,EAAA,CAAA;CACT,CAAA,EAIJ,UAAkB;CACtB,IAAM,EAAC,cAAU,EAAe,iBAAiB;CAEjD,OAAO,EAAO,KAAK,MAAS,kBAAC,GAAD,EAAyB,OAAO,GAAQ,EAAxB,EAAK,GAAmB,CAAC;GASjE,IAAY,GAEZ,KAAW,EAAC,aAAU,kBAAe,GAAO,WAAQ,GAAG,GAAG,QAC9D,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,EAAA,UACE,kBAAC,GAAD,EAAa,CAAA,EACC,CAAA,EACJ,CAAA,CACA;IAUZ,UAAkB,EAAe,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@propellerads/toast",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "types": "dist/index.d.ts",
6
+ "style": "dist/index.css",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./index.css": "./dist/index.css"
13
+ },
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "repository": "https://github.com/propellerads/ui-components.git",
21
+ "author": "v.bykov@propellerads.net",
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/propellerads/ui-components/issues"
25
+ },
26
+ "scripts": {
27
+ "build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
28
+ },
29
+ "homepage": "https://github.com/propellerads/ui-components#readme",
30
+ "private": false,
31
+ "dependencies": {
32
+ "@base-ui-components/react": "1.0.0-rc.0",
33
+ "@propellerads/button": "^12.1.0",
34
+ "clsx": "^2.1.1"
35
+ },
36
+ "peerDependencies": {
37
+ "@propellerads/tokens": ">=0.3.0",
38
+ "react": "^18.0.0 || ^19.0.0",
39
+ "react-dom": "^18.0.0 || ^19.0.0"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "@propellerads/tokens": {
43
+ "optional": true
44
+ }
45
+ },
46
+ "devDependencies": {
47
+ "@propellerads/tokens": "workspace:^",
48
+ "@types/react": "^19.2.14",
49
+ "@vitejs/plugin-react": "^6.0.1",
50
+ "rollup": "^4.60.3",
51
+ "rollup-plugin-dts": "^6.4.1",
52
+ "typescript": "^6.0.3",
53
+ "vite": "^8.0.11",
54
+ "vite-plugin-lib-inject-css": "^2.2.2"
55
+ }
56
+ }