@rockshin/tao-ui 0.0.14 → 0.0.15
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/component-manifest.json +645 -147
- package/dist/components/sonner/index.d.ts +1 -0
- package/dist/components/sonner/index.js +1 -0
- package/dist/components/sonner/sonner.css +118 -0
- package/dist/components/sonner/sonner.d.ts +57 -0
- package/dist/components/sonner/sonner.js +249 -0
- package/dist/docs/component-docs.js +2 -0
- package/dist/docs/components/sonner.doc.d.ts +18 -0
- package/dist/docs/components/sonner.doc.js +47 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/llms.txt +14 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Sonner, toast, type SonnerAction, type SonnerPosition, type SonnerPromiseMessages, type SonnerProps, type SonnerSemanticPart, type SonnerToastItem, type SonnerToastOptions, type SonnerType, } from './sonner';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Sonner, toast } from "./sonner.js";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
[data-tao-sonner-viewport] {
|
|
2
|
+
z-index: var(--tao-z-index-popup);
|
|
3
|
+
gap: var(--tao-sonner-gap, 12px);
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
max-width: min(420px, calc(100vw - var(--tao-sonner-offset, 24px) * 2));
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
display: flex;
|
|
8
|
+
position: fixed;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[data-tao-sonner-viewport][data-tao-position^="top"] {
|
|
12
|
+
top: var(--tao-sonner-offset, 24px);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[data-tao-sonner-viewport][data-tao-position^="bottom"] {
|
|
16
|
+
bottom: var(--tao-sonner-offset, 24px);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[data-tao-sonner-viewport][data-tao-position$="left"] {
|
|
20
|
+
left: var(--tao-sonner-offset, 24px);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[data-tao-sonner-viewport][data-tao-position$="right"] {
|
|
24
|
+
right: var(--tao-sonner-offset, 24px);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[data-tao-sonner-viewport][data-tao-position$="center"] {
|
|
28
|
+
left: 50%;
|
|
29
|
+
transform: translateX(-50%);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-tao-sonner-toast] {
|
|
33
|
+
pointer-events: auto;
|
|
34
|
+
border: 1px solid var(--tao-color-border);
|
|
35
|
+
background: var(--tao-color-bg-elevated);
|
|
36
|
+
color: var(--tao-color-text);
|
|
37
|
+
border-radius: var(--tao-radius-lg);
|
|
38
|
+
box-shadow: var(--tao-box-shadow-secondary);
|
|
39
|
+
align-items: flex-start;
|
|
40
|
+
gap: 12px;
|
|
41
|
+
min-width: 320px;
|
|
42
|
+
padding: 14px;
|
|
43
|
+
display: flex;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[data-tao-sonner-toast][data-tao-type="success"] {
|
|
47
|
+
background: var(--tao-success-bg);
|
|
48
|
+
border-color: var(--tao-success-border);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-tao-sonner-toast][data-tao-type="error"] {
|
|
52
|
+
background: var(--tao-error-bg);
|
|
53
|
+
border-color: var(--tao-error-border);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-tao-sonner-toast][data-tao-type="warning"] {
|
|
57
|
+
background: var(--tao-warning-bg);
|
|
58
|
+
border-color: var(--tao-warning-border);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-tao-sonner-toast][data-tao-type="info"] {
|
|
62
|
+
background: color-mix(in oklch, var(--tao-color-primary) 6%, var(--tao-color-bg-base));
|
|
63
|
+
border-color: var(--tao-primary-border);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[data-tao-sonner-content] {
|
|
67
|
+
flex: 1;
|
|
68
|
+
min-width: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[data-tao-sonner-title] {
|
|
72
|
+
font-size: var(--tao-font-size-base);
|
|
73
|
+
font-weight: var(--tao-font-weight-strong);
|
|
74
|
+
line-height: var(--tao-line-height);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[data-tao-sonner-description] {
|
|
78
|
+
font-size: var(--tao-font-size-sm);
|
|
79
|
+
color: var(--tao-color-text-secondary);
|
|
80
|
+
line-height: var(--tao-line-height);
|
|
81
|
+
margin-top: 4px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[data-tao-sonner-actions] {
|
|
85
|
+
flex-shrink: 0;
|
|
86
|
+
align-items: center;
|
|
87
|
+
gap: 8px;
|
|
88
|
+
display: flex;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[data-tao-sonner-close] {
|
|
92
|
+
appearance: none;
|
|
93
|
+
color: var(--tao-color-text-tertiary);
|
|
94
|
+
border-radius: var(--tao-radius-sm);
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
width: 24px;
|
|
97
|
+
height: 24px;
|
|
98
|
+
transition: color var(--tao-motion-duration-fast) var(--tao-motion-ease-out),
|
|
99
|
+
background-color var(--tao-motion-duration-fast) var(--tao-motion-ease-out);
|
|
100
|
+
background: none;
|
|
101
|
+
border: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[data-tao-sonner-close]:hover {
|
|
105
|
+
color: var(--tao-color-text);
|
|
106
|
+
background: var(--tao-color-fill-secondary);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@media (width <= 640px) {
|
|
110
|
+
[data-tao-sonner-viewport] {
|
|
111
|
+
max-width: calc(100vw - var(--tao-sonner-offset, 24px) * 2);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
[data-tao-sonner-toast] {
|
|
115
|
+
min-width: 0;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic';
|
|
2
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
import './sonner.css';
|
|
4
|
+
export type SonnerSemanticPart = 'viewport' | 'toast' | 'content' | 'title' | 'description' | 'actions' | 'action' | 'cancel' | 'close';
|
|
5
|
+
export type SonnerType = 'default' | 'success' | 'error' | 'warning' | 'info' | 'loading' | 'custom';
|
|
6
|
+
export type SonnerPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
7
|
+
export interface SonnerAction {
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
onClick?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface SonnerToastOptions {
|
|
12
|
+
id?: string;
|
|
13
|
+
title?: ReactNode;
|
|
14
|
+
description?: ReactNode;
|
|
15
|
+
action?: SonnerAction;
|
|
16
|
+
cancel?: SonnerAction;
|
|
17
|
+
duration?: number;
|
|
18
|
+
closable?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface SonnerPromiseMessages<T> {
|
|
21
|
+
loading: SonnerToastOptions | ReactNode;
|
|
22
|
+
success?: SonnerToastOptions | ReactNode | ((value: T) => SonnerToastOptions | ReactNode);
|
|
23
|
+
error?: SonnerToastOptions | ReactNode | ((error: unknown) => SonnerToastOptions | ReactNode);
|
|
24
|
+
}
|
|
25
|
+
export interface SonnerToastItem extends SonnerToastOptions {
|
|
26
|
+
id: string;
|
|
27
|
+
type: SonnerType;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
custom?: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
export interface SonnerProps {
|
|
32
|
+
position?: SonnerPosition;
|
|
33
|
+
visibleToasts?: number;
|
|
34
|
+
offset?: number;
|
|
35
|
+
gap?: number;
|
|
36
|
+
expand?: boolean;
|
|
37
|
+
richColors?: boolean;
|
|
38
|
+
closeButton?: boolean;
|
|
39
|
+
duration?: number;
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: CSSProperties;
|
|
42
|
+
classNames?: SemanticClassNames<SonnerSemanticPart>;
|
|
43
|
+
styles?: SemanticStyles<SonnerSemanticPart>;
|
|
44
|
+
}
|
|
45
|
+
declare function dismiss(id?: string): void;
|
|
46
|
+
export declare function Sonner({ position, visibleToasts, offset, gap, expand, richColors, closeButton, duration, className, style, classNames, styles, }: SonnerProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare const toast: ((options: SonnerToastOptions | ReactNode) => string) & {
|
|
48
|
+
success: (options: SonnerToastOptions | ReactNode) => string;
|
|
49
|
+
error: (options: SonnerToastOptions | ReactNode) => string;
|
|
50
|
+
warning: (options: SonnerToastOptions | ReactNode) => string;
|
|
51
|
+
info: (options: SonnerToastOptions | ReactNode) => string;
|
|
52
|
+
loading: (options: SonnerToastOptions | ReactNode) => string;
|
|
53
|
+
custom: (node: ReactNode, options?: Omit<SonnerToastOptions, "title" | "description">) => string;
|
|
54
|
+
promise: <T>(promise: Promise<T>, messages: SonnerPromiseMessages<T>) => Promise<T>;
|
|
55
|
+
dismiss: typeof dismiss;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
3
|
+
import { cx } from "../../utils/semantic.js";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { useEffect, useMemo, useSyncExternalStore } from "react";
|
|
6
|
+
import "./sonner.css";
|
|
7
|
+
const listeners = new Set();
|
|
8
|
+
let state = {
|
|
9
|
+
toasts: []
|
|
10
|
+
};
|
|
11
|
+
let seed = 0;
|
|
12
|
+
const timers = new Map();
|
|
13
|
+
function emit() {
|
|
14
|
+
listeners.forEach((listener)=>listener());
|
|
15
|
+
}
|
|
16
|
+
function subscribe(listener) {
|
|
17
|
+
listeners.add(listener);
|
|
18
|
+
return ()=>listeners.delete(listener);
|
|
19
|
+
}
|
|
20
|
+
function getSnapshot() {
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
23
|
+
function clearTimer(id) {
|
|
24
|
+
const timer = timers.get(id);
|
|
25
|
+
if (timer) {
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
timers.delete(id);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function dismiss(id) {
|
|
31
|
+
if (!id) {
|
|
32
|
+
state.toasts.forEach((toast)=>clearTimer(toast.id));
|
|
33
|
+
state = {
|
|
34
|
+
toasts: []
|
|
35
|
+
};
|
|
36
|
+
emit();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
clearTimer(id);
|
|
40
|
+
state = {
|
|
41
|
+
toasts: state.toasts.filter((toast)=>toast.id !== id)
|
|
42
|
+
};
|
|
43
|
+
emit();
|
|
44
|
+
}
|
|
45
|
+
function scheduleDismiss(id, duration) {
|
|
46
|
+
clearTimer(id);
|
|
47
|
+
if (null == duration || duration <= 0) return;
|
|
48
|
+
timers.set(id, setTimeout(()=>{
|
|
49
|
+
dismiss(id);
|
|
50
|
+
}, duration));
|
|
51
|
+
}
|
|
52
|
+
function isToastOptions(value) {
|
|
53
|
+
return null != value && 'object' == typeof value && !Array.isArray(value) && !('$$typeof' in value);
|
|
54
|
+
}
|
|
55
|
+
function normalizeOptions(options) {
|
|
56
|
+
return isToastOptions(options) ? options : {
|
|
57
|
+
title: options
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function create(type, options, custom) {
|
|
61
|
+
const normalized = normalizeOptions(options);
|
|
62
|
+
const id = normalized.id ?? `toast-${Date.now()}-${seed++}`;
|
|
63
|
+
const next = {
|
|
64
|
+
...normalized,
|
|
65
|
+
id,
|
|
66
|
+
type,
|
|
67
|
+
createdAt: Date.now(),
|
|
68
|
+
custom
|
|
69
|
+
};
|
|
70
|
+
state = {
|
|
71
|
+
toasts: [
|
|
72
|
+
...state.toasts.filter((toast)=>toast.id !== id),
|
|
73
|
+
next
|
|
74
|
+
]
|
|
75
|
+
};
|
|
76
|
+
emit();
|
|
77
|
+
scheduleDismiss(id, normalized.duration);
|
|
78
|
+
return id;
|
|
79
|
+
}
|
|
80
|
+
function resolveDataType(type, richColors) {
|
|
81
|
+
if ('custom' === type) return 'custom';
|
|
82
|
+
if ('loading' === type) return 'loading';
|
|
83
|
+
if (!richColors) return 'default';
|
|
84
|
+
return type;
|
|
85
|
+
}
|
|
86
|
+
function getAriaLabel(type) {
|
|
87
|
+
switch(type){
|
|
88
|
+
case 'success':
|
|
89
|
+
return 'Success notification';
|
|
90
|
+
case 'error':
|
|
91
|
+
return 'Error notification';
|
|
92
|
+
case 'warning':
|
|
93
|
+
return 'Warning notification';
|
|
94
|
+
case 'info':
|
|
95
|
+
return 'Info notification';
|
|
96
|
+
case 'loading':
|
|
97
|
+
return 'Loading notification';
|
|
98
|
+
default:
|
|
99
|
+
return 'Notification';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function renderPromiseState(stateValue, payload) {
|
|
103
|
+
if (!stateValue) return;
|
|
104
|
+
if ('function' == typeof stateValue) return stateValue(payload);
|
|
105
|
+
return stateValue;
|
|
106
|
+
}
|
|
107
|
+
function Sonner({ position = 'bottom-right', visibleToasts = 3, offset = 24, gap = 12, expand = true, richColors = false, closeButton = false, duration = 4000, className, style, classNames, styles }) {
|
|
108
|
+
useTaoConfig();
|
|
109
|
+
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
110
|
+
useEffect(()=>{
|
|
111
|
+
for (const toast of snapshot.toasts)if (!timers.has(toast.id)) scheduleDismiss(toast.id, toast.duration ?? duration);
|
|
112
|
+
}, [
|
|
113
|
+
duration,
|
|
114
|
+
snapshot.toasts
|
|
115
|
+
]);
|
|
116
|
+
const visible = useMemo(()=>{
|
|
117
|
+
const toasts = snapshot.toasts;
|
|
118
|
+
const sliced = expand ? toasts : toasts.slice(-visibleToasts);
|
|
119
|
+
return sliced.slice(-visibleToasts).reverse();
|
|
120
|
+
}, [
|
|
121
|
+
expand,
|
|
122
|
+
snapshot.toasts,
|
|
123
|
+
visibleToasts
|
|
124
|
+
]);
|
|
125
|
+
return /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
126
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
127
|
+
className: cx(classNames?.viewport, className),
|
|
128
|
+
style: {
|
|
129
|
+
...styles?.viewport,
|
|
130
|
+
...style,
|
|
131
|
+
['--tao-sonner-offset']: `${offset}px`,
|
|
132
|
+
['--tao-sonner-gap']: `${gap}px`
|
|
133
|
+
},
|
|
134
|
+
"data-tao-sonner-viewport": "",
|
|
135
|
+
"data-tao-position": position,
|
|
136
|
+
children: visible.map((toast_0)=>{
|
|
137
|
+
const showClose = toast_0.closable ?? closeButton;
|
|
138
|
+
return /*#__PURE__*/ jsx("div", {
|
|
139
|
+
className: cx(classNames?.toast),
|
|
140
|
+
style: styles?.toast,
|
|
141
|
+
role: "status",
|
|
142
|
+
"aria-live": "polite",
|
|
143
|
+
"aria-label": getAriaLabel(toast_0.type),
|
|
144
|
+
"data-tao-sonner-toast": "",
|
|
145
|
+
"data-tao-type": resolveDataType(toast_0.type, richColors),
|
|
146
|
+
children: toast_0.custom ? toast_0.custom : /*#__PURE__*/ jsxs(Fragment, {
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ jsxs("div", {
|
|
149
|
+
className: cx(classNames?.content),
|
|
150
|
+
style: styles?.content,
|
|
151
|
+
"data-tao-sonner-content": "",
|
|
152
|
+
children: [
|
|
153
|
+
toast_0.title ? /*#__PURE__*/ jsx("div", {
|
|
154
|
+
className: cx(classNames?.title),
|
|
155
|
+
style: styles?.title,
|
|
156
|
+
"data-tao-sonner-title": "",
|
|
157
|
+
children: toast_0.title
|
|
158
|
+
}) : null,
|
|
159
|
+
toast_0.description ? /*#__PURE__*/ jsx("div", {
|
|
160
|
+
className: cx(classNames?.description),
|
|
161
|
+
style: styles?.description,
|
|
162
|
+
"data-tao-sonner-description": "",
|
|
163
|
+
children: toast_0.description
|
|
164
|
+
}) : null
|
|
165
|
+
]
|
|
166
|
+
}),
|
|
167
|
+
(toast_0.action || toast_0.cancel || showClose) && /*#__PURE__*/ jsxs("div", {
|
|
168
|
+
className: cx(classNames?.actions),
|
|
169
|
+
style: styles?.actions,
|
|
170
|
+
"data-tao-sonner-actions": "",
|
|
171
|
+
children: [
|
|
172
|
+
toast_0.cancel ? /*#__PURE__*/ jsx(Button, {
|
|
173
|
+
variant: "ghost",
|
|
174
|
+
size: "small",
|
|
175
|
+
className: cx(classNames?.cancel),
|
|
176
|
+
style: styles?.cancel,
|
|
177
|
+
onClick: ()=>{
|
|
178
|
+
toast_0.cancel?.onClick?.();
|
|
179
|
+
dismiss(toast_0.id);
|
|
180
|
+
},
|
|
181
|
+
children: toast_0.cancel.label
|
|
182
|
+
}) : null,
|
|
183
|
+
toast_0.action ? /*#__PURE__*/ jsx(Button, {
|
|
184
|
+
variant: "secondary",
|
|
185
|
+
size: "small",
|
|
186
|
+
className: cx(classNames?.action),
|
|
187
|
+
style: styles?.action,
|
|
188
|
+
onClick: ()=>{
|
|
189
|
+
toast_0.action?.onClick?.();
|
|
190
|
+
dismiss(toast_0.id);
|
|
191
|
+
},
|
|
192
|
+
children: toast_0.action.label
|
|
193
|
+
}) : null,
|
|
194
|
+
showClose ? /*#__PURE__*/ jsx("button", {
|
|
195
|
+
type: "button",
|
|
196
|
+
"aria-label": "Close notification",
|
|
197
|
+
className: cx(classNames?.close),
|
|
198
|
+
style: styles?.close,
|
|
199
|
+
"data-tao-sonner-close": "",
|
|
200
|
+
onClick: ()=>dismiss(toast_0.id),
|
|
201
|
+
children: "\xd7"
|
|
202
|
+
}) : null
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
]
|
|
206
|
+
})
|
|
207
|
+
}, toast_0.id);
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
const baseToast = (options)=>create('default', options);
|
|
213
|
+
const sonner_toast = Object.assign(baseToast, {
|
|
214
|
+
success: (options)=>create('success', options),
|
|
215
|
+
error: (options)=>create('error', options),
|
|
216
|
+
warning: (options)=>create('warning', options),
|
|
217
|
+
info: (options)=>create('info', options),
|
|
218
|
+
loading: (options)=>create('loading', isToastOptions(options) ? {
|
|
219
|
+
...options,
|
|
220
|
+
duration: options.duration ?? 0
|
|
221
|
+
} : {
|
|
222
|
+
title: options,
|
|
223
|
+
duration: 0
|
|
224
|
+
}),
|
|
225
|
+
custom: (node, options = {})=>create('custom', options, node),
|
|
226
|
+
promise: async (promise, messages)=>{
|
|
227
|
+
const id = create('loading', isToastOptions(messages.loading) ? {
|
|
228
|
+
...messages.loading,
|
|
229
|
+
duration: messages.loading.duration ?? 0
|
|
230
|
+
} : {
|
|
231
|
+
title: messages.loading,
|
|
232
|
+
duration: 0
|
|
233
|
+
});
|
|
234
|
+
try {
|
|
235
|
+
const value = await promise;
|
|
236
|
+
dismiss(id);
|
|
237
|
+
const success = renderPromiseState(messages.success, value);
|
|
238
|
+
if (success) create('success', success);
|
|
239
|
+
return value;
|
|
240
|
+
} catch (error) {
|
|
241
|
+
dismiss(id);
|
|
242
|
+
const failure = renderPromiseState(messages.error, error);
|
|
243
|
+
if (failure) create('error', failure);
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
dismiss: dismiss
|
|
248
|
+
});
|
|
249
|
+
export { Sonner, sonner_toast as toast };
|
|
@@ -19,6 +19,7 @@ import { radioDoc } from "./components/radio.doc.js";
|
|
|
19
19
|
import { rangePickerDoc } from "./components/range-picker.doc.js";
|
|
20
20
|
import { scrollAreaDoc } from "./components/scroll-area.doc.js";
|
|
21
21
|
import { selectDoc } from "./components/select.doc.js";
|
|
22
|
+
import { sonnerDoc } from "./components/sonner.doc.js";
|
|
22
23
|
import { spinnerDoc } from "./components/spinner.doc.js";
|
|
23
24
|
import { splitterDoc } from "./components/splitter.doc.js";
|
|
24
25
|
import { stackDoc } from "./components/stack.doc.js";
|
|
@@ -50,6 +51,7 @@ const componentDocs = [
|
|
|
50
51
|
rangePickerDoc,
|
|
51
52
|
scrollAreaDoc,
|
|
52
53
|
selectDoc,
|
|
54
|
+
sonnerDoc,
|
|
53
55
|
spinnerDoc,
|
|
54
56
|
splitterDoc,
|
|
55
57
|
stackDoc,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const sonnerDoc: {
|
|
2
|
+
name: string;
|
|
3
|
+
displayName: string;
|
|
4
|
+
category: "Feedback";
|
|
5
|
+
description: string;
|
|
6
|
+
exports: string[];
|
|
7
|
+
source: string;
|
|
8
|
+
story: string;
|
|
9
|
+
tests: string[];
|
|
10
|
+
semanticParts: string[];
|
|
11
|
+
keywords: string[];
|
|
12
|
+
related: string[];
|
|
13
|
+
usage: {
|
|
14
|
+
description: string;
|
|
15
|
+
bestPractices: string[];
|
|
16
|
+
avoid: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const sonnerDoc = {
|
|
2
|
+
name: 'sonner',
|
|
3
|
+
displayName: 'Sonner',
|
|
4
|
+
category: 'Feedback',
|
|
5
|
+
description: 'Displays temporary toast notifications with optional actions and provider-aware theming.',
|
|
6
|
+
exports: [
|
|
7
|
+
'Sonner',
|
|
8
|
+
'toast'
|
|
9
|
+
],
|
|
10
|
+
source: 'src/components/sonner/sonner.tsx',
|
|
11
|
+
story: 'stories/sonner.stories.tsx',
|
|
12
|
+
tests: [
|
|
13
|
+
'tests/sonner/sonner.test.tsx'
|
|
14
|
+
],
|
|
15
|
+
semanticParts: [
|
|
16
|
+
'viewport',
|
|
17
|
+
'toast',
|
|
18
|
+
'content',
|
|
19
|
+
'title',
|
|
20
|
+
"description",
|
|
21
|
+
'actions',
|
|
22
|
+
'action',
|
|
23
|
+
'cancel',
|
|
24
|
+
'close'
|
|
25
|
+
],
|
|
26
|
+
keywords: [
|
|
27
|
+
'toast',
|
|
28
|
+
'notification',
|
|
29
|
+
'sonner'
|
|
30
|
+
],
|
|
31
|
+
related: [
|
|
32
|
+
'Modal',
|
|
33
|
+
'Drawer',
|
|
34
|
+
'Button'
|
|
35
|
+
],
|
|
36
|
+
usage: {
|
|
37
|
+
description: 'Mount one Sonner near app root, then call toast() imperatively from event handlers. Supports toast.loading(), toast.promise(), and toast.custom() for richer async and custom notification flows.',
|
|
38
|
+
bestPractices: [
|
|
39
|
+
'Prefer short, status-oriented messages with one primary action at most.',
|
|
40
|
+
'Enable richColors when semantic status color should be visible.'
|
|
41
|
+
],
|
|
42
|
+
avoid: [
|
|
43
|
+
'Do not use toast notifications for blocking confirmations.'
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export { sonnerDoc };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { InputNumber, type InputNumberProps, type InputNumberSemanticPart, } fro
|
|
|
17
17
|
export { type ConfirmType, Modal, type ModalFooterRender, type ModalFuncProps, type ModalFuncReturn, type ModalHookApi, type ModalProps, type ModalSemanticPart, } from './components/modal';
|
|
18
18
|
export { Pagination, type PaginationProps, type PaginationSemanticPart, } from './components/pagination/pagination';
|
|
19
19
|
export { Radio, RadioGroup, type RadioGroupProps, type RadioOptionType, type RadioProps, type RadioSemanticPart, } from './components/radio/radio';
|
|
20
|
+
export { Sonner, toast, type SonnerAction, type SonnerPosition, type SonnerProps, type SonnerSemanticPart, type SonnerToastItem, type SonnerToastOptions, type SonnerType, } from './components/sonner';
|
|
20
21
|
export { ScrollArea, type ScrollAreaProps, type ScrollAreaSemanticPart, type ScrollAreaType, } from './components/scroll-area/scroll-area';
|
|
21
22
|
export { ChevronsUpDownIcon, Select, type SelectOption, type SelectPlacement, type SelectProps, type SelectSemanticPart, type TagRenderProps, } from './components/select/select';
|
|
22
23
|
export { Spinner, type SpinnerProps, type SpinnerSemanticPart, } from './components/spinner/spinner';
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { InputNumber } from "./components/input-number/input-number.js";
|
|
|
17
17
|
export { Modal } from "./components/modal/index.js";
|
|
18
18
|
export { Pagination } from "./components/pagination/pagination.js";
|
|
19
19
|
export { Radio, RadioGroup } from "./components/radio/radio.js";
|
|
20
|
+
export { Sonner, toast } from "./components/sonner/index.js";
|
|
20
21
|
export { ScrollArea } from "./components/scroll-area/scroll-area.js";
|
|
21
22
|
export { ChevronsUpDownIcon, Select } from "./components/select/select.js";
|
|
22
23
|
export { Spinner } from "./components/spinner/spinner.js";
|
package/llms.txt
CHANGED
|
@@ -23,7 +23,7 @@ Import from the package root. The package entry imports tao-ui CSS side effects
|
|
|
23
23
|
- Config: TaoProvider
|
|
24
24
|
- Data Display: Collapsible, ScrollArea, Table, Tag
|
|
25
25
|
- Data Entry: Checkbox, DatePicker, FormActions, FormField, FormSection, Input, InputNumber, Radio, RangePicker, Select, Switch, Textarea
|
|
26
|
-
- Feedback: Drawer, Modal, Spinner
|
|
26
|
+
- Feedback: Drawer, Modal, Sonner, Spinner
|
|
27
27
|
- General: Button
|
|
28
28
|
- Headless: HeadlessInputNumber
|
|
29
29
|
- Layout: FormLayout, Splitter, Stack
|
|
@@ -302,6 +302,19 @@ Chooses one value from a compact list of options.
|
|
|
302
302
|
|
|
303
303
|
Use Select when choices are known but too numerous or secondary to show as radios.
|
|
304
304
|
|
|
305
|
+
### Sonner
|
|
306
|
+
|
|
307
|
+
Displays temporary toast notifications with optional actions and provider-aware theming.
|
|
308
|
+
|
|
309
|
+
- Category: Feedback
|
|
310
|
+
- Exports: `Sonner`, `toast`
|
|
311
|
+
- Source: `src/components/sonner/sonner.tsx`
|
|
312
|
+
- Storybook: `stories/sonner.stories.tsx`
|
|
313
|
+
- Tests: `tests/sonner/sonner.test.tsx`
|
|
314
|
+
- Semantic parts: `viewport`, `toast`, `content`, `title`, `description`, `actions`, `action`, `cancel`, `close`
|
|
315
|
+
|
|
316
|
+
Mount one Sonner near app root, then call toast() imperatively from event handlers. Supports toast.loading(), toast.promise(), and toast.custom() for richer async and custom notification flows.
|
|
317
|
+
|
|
305
318
|
### Spinner
|
|
306
319
|
|
|
307
320
|
Indicates indeterminate loading activity.
|