@teamix-evo/ui 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +19 -19
  2. package/src/components/alert/index.tsx +1 -1
  3. package/src/components/alert-dialog/index.tsx +17 -24
  4. package/src/components/alert-dialog/meta.md +102 -8
  5. package/src/components/alert-dialog/stories.tsx +117 -7
  6. package/src/components/avatar/index.tsx +1 -1
  7. package/src/components/badge/index.tsx +1 -1
  8. package/src/components/button/index.tsx +1 -29
  9. package/src/components/button/meta.md +24 -13
  10. package/src/components/button/stories.tsx +21 -12
  11. package/src/components/button-group/meta.md +6 -9
  12. package/src/components/button-group/stories.tsx +2 -6
  13. package/src/components/calendar/index.tsx +12 -7
  14. package/src/components/cascader-select/index.tsx +1 -1
  15. package/src/components/checkbox/index.tsx +1 -1
  16. package/src/components/combobox/index.tsx +54 -10
  17. package/src/components/combobox/meta.md +3 -5
  18. package/src/components/combobox/stories.tsx +104 -25
  19. package/src/components/data-table/stories.tsx +4 -1
  20. package/src/components/date-picker/index.tsx +25 -2
  21. package/src/components/field/index.tsx +1 -1
  22. package/src/components/filter-bar/index.tsx +1 -1
  23. package/src/components/float-button/meta.md +3 -15
  24. package/src/components/icon/index.tsx +3 -4
  25. package/src/components/icon/meta.md +1 -2
  26. package/src/components/input/index.tsx +10 -2
  27. package/src/components/input-group/index.tsx +3 -3
  28. package/src/components/input-group/meta.md +15 -0
  29. package/src/components/input-group/stories.tsx +14 -0
  30. package/src/components/input-ip/index.tsx +1 -1
  31. package/src/components/input-number/index.tsx +5 -5
  32. package/src/components/item/meta.md +11 -11
  33. package/src/components/radio-group/index.tsx +1 -1
  34. package/src/components/rate/index.tsx +3 -3
  35. package/src/components/select/index.tsx +2 -2
  36. package/src/components/skeleton/index.tsx +1 -1
  37. package/src/components/skeleton/meta.md +6 -6
  38. package/src/components/skeleton/stories.tsx +8 -8
  39. package/src/components/slider/index.tsx +27 -1
  40. package/src/components/sonner/index.tsx +43 -40
  41. package/src/components/sonner/meta.md +84 -68
  42. package/src/components/sonner/stories.tsx +122 -83
  43. package/src/components/spinner/index.tsx +170 -0
  44. package/src/components/spinner/meta.md +27 -1
  45. package/src/components/spinner/stories.tsx +23 -0
  46. package/src/components/steps/index.tsx +5 -1
  47. package/src/components/switch/index.tsx +1 -1
  48. package/src/components/tag/index.tsx +14 -0
  49. package/src/components/tag/meta.md +1 -0
  50. package/src/components/tag/stories.tsx +13 -0
  51. package/src/components/textarea/index.tsx +1 -1
  52. package/src/components/textarea/stories.tsx +1 -1
  53. package/src/components/time-picker/index.tsx +3 -1
  54. package/src/components/toggle/index.tsx +1 -1
  55. package/src/components/tooltip/index.tsx +5 -1
  56. package/src/components/tooltip/meta.md +13 -28
  57. package/src/components/tooltip/stories.tsx +11 -28
  58. package/src/components/tree-select/index.tsx +1 -1
  59. package/LICENSE +0 -21
@@ -21,16 +21,18 @@ import {
21
21
  toast,
22
22
  type ToasterProps as SonnerToasterProps,
23
23
  } from 'sonner';
24
- import {
25
- CircleCheckIcon,
26
- CircleHelpIcon,
27
- InfoIcon,
28
- Loader2Icon,
29
- OctagonXIcon,
30
- TriangleAlertIcon,
31
- } from 'lucide-react';
24
+ import { Loader2Icon } from 'lucide-react';
32
25
 
33
26
  import { cn } from '@/lib/utils';
27
+ import {
28
+ ErrorFilledIcon,
29
+ HelpFilledIcon,
30
+ InfoFilledIcon,
31
+ SuccessFilledIcon,
32
+ WarningFilledIcon,
33
+ } from '@/components/icon';
34
+
35
+ /* ─── Types ────────────────────────────────────────────────────────────────── */
34
36
 
35
37
  /**
36
38
  * 容器级摆放位置 — cloud-design Notification.config({ placement }) 的 6 档形态。
@@ -52,17 +54,13 @@ export interface ToasterProps
52
54
  maxToasts?: number;
53
55
  }
54
56
 
55
- /* ────────────────────────────────────────────────────────────────────────── */
56
- /* 内置状态图标(占位) */
57
- /* */
58
- /* TODO(icon): 项目自研 Icon 组件就绪后,统一替换以下 STATE_ICONS 即可, */
59
- /* 不影响 Toaster / toast 的 API。 */
60
- /* ────────────────────────────────────────────────────────────────────────── */
57
+ /* ─── 内置语义图标(对齐 Alert 面性图标体系) ──────────────────────────────── */
58
+
61
59
  const STATE_ICONS = {
62
- success: <CircleCheckIcon className="size-4 shrink-0 text-success" />,
63
- info: <InfoIcon className="size-4 shrink-0 text-info" />,
64
- warning: <TriangleAlertIcon className="size-4 shrink-0 text-warning" />,
65
- error: <OctagonXIcon className="size-4 shrink-0 text-destructive" />,
60
+ success: <SuccessFilledIcon className="size-4 shrink-0 text-success" />,
61
+ info: <InfoFilledIcon className="size-4 shrink-0 text-info" />,
62
+ warning: <WarningFilledIcon className="size-4 shrink-0 text-warning" />,
63
+ error: <ErrorFilledIcon className="size-4 shrink-0 text-destructive" />,
66
64
  loading: (
67
65
  <Loader2Icon className="size-4 shrink-0 animate-spin text-muted-foreground" />
68
66
  ),
@@ -70,12 +68,14 @@ const STATE_ICONS = {
70
68
 
71
69
  /**
72
70
  * `help` 状态在 sonner 原生类型中不存在,作为业界常见第六档语义保留。
73
- * 业务侧通过 `toast(msg, { icon: HelpToastIcon })` 触发,或参考 stories 演示。
71
+ * 业务侧通过 `toast(msg, { icon: HelpToastIcon })` 触发。
74
72
  */
75
73
  export const HelpToastIcon = (
76
- <CircleHelpIcon className="size-4 shrink-0 text-help" />
74
+ <HelpFilledIcon className="size-4 shrink-0 text-help" />
77
75
  );
78
76
 
77
+ /* ─── Toaster 容器 ─────────────────────────────────────────────────────────── */
78
+
79
79
  function Toaster({
80
80
  theme,
81
81
  placement = 'top-right',
@@ -104,32 +104,35 @@ function Toaster({
104
104
  className={cn('toaster group', className)}
105
105
  style={
106
106
  {
107
- // 容器与文字基础变量沿用主题语义 token,dark 自动跟随
108
- '--normal-bg': 'var(--popover)',
109
- '--normal-text': 'var(--popover-foreground)',
110
- '--normal-border': 'var(--border)',
107
+ // 基础外观桥接 Tailwind v4 主题 token 到 sonner CSS 变量
108
+ '--normal-bg': 'var(--color-popover)',
109
+ '--normal-text': 'var(--color-popover-foreground)',
110
+ '--normal-border': 'var(--color-border)',
111
111
  '--border-radius': 'var(--radius)',
112
- // 状态变量桥接开启 richColors 时由 sonner 消费
113
- '--success-bg': 'var(--success-bg)',
114
- '--success-text': 'var(--success)',
115
- '--success-border': 'var(--success-border)',
116
- '--info-bg': 'var(--info-bg)',
117
- '--info-text': 'var(--info)',
118
- '--info-border': 'var(--info-border)',
119
- '--warning-bg': 'var(--warning-bg)',
120
- '--warning-text': 'var(--warning)',
121
- '--warning-border': 'var(--warning-border)',
122
- '--error-bg': 'var(--destructive-bg)',
123
- '--error-text': 'var(--destructive)',
124
- '--error-border': 'var(--destructive-border)',
112
+ // 关闭按钮定位右上角内部
113
+ '--toast-close-button-start': 'unset',
114
+ '--toast-close-button-end': '8px',
115
+ '--toast-close-button-transform': 'translate(0, 8px)',
116
+ // richColors 状态变量桥接
117
+ '--success-bg': 'var(--color-success-bg)',
118
+ '--success-text': 'var(--color-success)',
119
+ '--success-border': 'var(--color-success-border)',
120
+ '--info-bg': 'var(--color-info-bg)',
121
+ '--info-text': 'var(--color-info)',
122
+ '--info-border': 'var(--color-info-border)',
123
+ '--warning-bg': 'var(--color-warning-bg)',
124
+ '--warning-text': 'var(--color-warning)',
125
+ '--warning-border': 'var(--color-warning-border)',
126
+ '--error-bg': 'var(--color-destructive-bg)',
127
+ '--error-text': 'var(--color-destructive)',
128
+ '--error-border': 'var(--color-destructive-border)',
125
129
  ...style,
126
130
  } as React.CSSProperties
127
131
  }
128
132
  toastOptions={{
129
133
  ...toastOptions,
130
134
  classNames: {
131
- toast:
132
- 'group toast group-[.toaster]:bg-popover group-[.toaster]:text-popover-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
135
+ toast: 'group toast shadow-none',
133
136
  title: 'text-sm font-medium leading-5 text-foreground',
134
137
  description: 'text-xs leading-5 text-muted-foreground',
135
138
  actionButton:
@@ -137,7 +140,7 @@ function Toaster({
137
140
  cancelButton:
138
141
  'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground group-[.toast]:rounded-sm group-[.toast]:text-xs group-[.toast]:px-2 group-[.toast]:py-1 group-[.toast]:cursor-pointer hover:group-[.toast]:bg-muted/80',
139
142
  closeButton:
140
- 'group-[.toast]:bg-transparent group-[.toast]:text-muted-foreground group-[.toast]:border-border hover:group-[.toast]:text-foreground',
143
+ '!size-5 !border-0 !rounded-sm !bg-transparent !text-muted-foreground hover:!text-foreground hover:!bg-transparent [&>svg]:!size-4',
141
144
  ...toastOptions?.classNames,
142
145
  },
143
146
  }}
@@ -30,15 +30,18 @@
30
30
  标题 + 描述 — 对应 cloud-design `Notification.open({ title, content })`。
31
31
 
32
32
  ```tsx
33
- <Button
34
- onClick={() =>
35
- toast('文件已保存', {
36
- description: '你的修改已自动同步到云端,可在历史版本中找回。',
37
- })
38
- }
39
- >
40
- 触发
41
- </Button>
33
+ <>
34
+ <Button
35
+ onClick={() =>
36
+ toast('文件已保存', {
37
+ description: '你的修改已自动同步到云端,可在历史版本中找回。',
38
+ })
39
+ }
40
+ >
41
+ 触发
42
+ </Button>
43
+ <Toaster />
44
+ </>
42
45
  ```
43
46
 
44
47
  ### WithAction
@@ -46,19 +49,22 @@
46
49
  操作按钮 — 业内主流 `action` props,单击执行下一步行动并关闭。
47
50
 
48
51
  ```tsx
49
- <Button
50
- onClick={() =>
51
- toast('已删除项目「示例」', {
52
- description: '删除后 7 天内可在回收站恢复。',
53
- action: {
54
- label: '撤销',
55
- onClick: () => toast.success('已撤销删除'),
56
- },
57
- })
58
- }
59
- >
60
- 触发
61
- </Button>
52
+ <>
53
+ <Button
54
+ onClick={() =>
55
+ toast('已删除项目「示例」', {
56
+ description: '删除后 7 天内可在回收站恢复。',
57
+ action: {
58
+ label: '撤销',
59
+ onClick: () => toast.success('已撤销删除'),
60
+ },
61
+ })
62
+ }
63
+ >
64
+ 触发
65
+ </Button>
66
+ <Toaster />
67
+ </>
62
68
  ```
63
69
 
64
70
  ### WithCancel
@@ -66,17 +72,20 @@
66
72
  取消按钮 — 与 action 并存的次级行动点,可阻断默认行为。
67
73
 
68
74
  ```tsx
69
- <Button
70
- onClick={() =>
71
- toast('确认离开当前页面?', {
72
- description: '未保存的修改将丢失。',
73
- action: { label: '继续', onClick: () => toast.info('已继续') },
74
- cancel: { label: '取消', onClick: () => toast('已取消') },
75
- })
76
- }
77
- >
78
- 触发
79
- </Button>
75
+ <>
76
+ <Button
77
+ onClick={() =>
78
+ toast('确认离开当前页面?', {
79
+ description: '未保存的修改将丢失。',
80
+ action: { label: '继续', onClick: () => toast.info('已继续') },
81
+ cancel: { label: '取消', onClick: () => toast('已取消') },
82
+ })
83
+ }
84
+ >
85
+ 触发
86
+ </Button>
87
+ <Toaster />
88
+ </>
80
89
  ```
81
90
 
82
91
  ### LoadingThenResolve
@@ -84,19 +93,22 @@
84
93
  按 id 链式更新 — 等价 cloud-design `Message.loading + Message.success({ key })`。
85
94
 
86
95
  ```tsx
87
- <Button
88
- onClick={() => {
89
- const id = toast.loading('正在上传...');
90
- setTimeout(() => {
91
- toast.success('上传完成', {
92
- id,
93
- description: '文件已发布到生产环境。',
94
- });
95
- }, 1500);
96
- }}
97
- >
98
- 触发
99
- </Button>
96
+ <>
97
+ <Button
98
+ onClick={() => {
99
+ const id = toast.loading('正在上传...');
100
+ setTimeout(() => {
101
+ toast.success('上传完成', {
102
+ id,
103
+ description: '文件已发布到生产环境。',
104
+ });
105
+ }, 1500);
106
+ }}
107
+ >
108
+ 触发
109
+ </Button>
110
+ <Toaster />
111
+ </>
100
112
  ```
101
113
 
102
114
  ### Duration
@@ -121,6 +133,7 @@
121
133
  >
122
134
  持久 (Infinity)
123
135
  </Button>
136
+ <Toaster />
124
137
  </div>
125
138
  ```
126
139
 
@@ -129,28 +142,31 @@
129
142
  自定义渲染 — `toast.custom` 完全接管节点,用于嵌入富内容卡片。
130
143
 
131
144
  ```tsx
132
- <Button
133
- onClick={() =>
134
- toast.custom((id) => (
135
- <div className="flex w-80 items-start gap-3 rounded-md border border-border bg-popover p-3 text-popover-foreground shadow-lg">
136
- <CircleHelpIcon className="mt-0.5 size-4 shrink-0 text-help" />
137
- <div className="flex-1">
138
- <div className="text-sm font-medium">自定义卡片</div>
139
- <div className="mt-1 text-xs text-muted-foreground">
140
- 你可以在此渲染任意 JSX:表单、富文本、进度条等。
145
+ <>
146
+ <Button
147
+ onClick={() =>
148
+ toast.custom((id) => (
149
+ <div className="flex w-80 items-start gap-3 rounded-md border border-border bg-popover p-3 text-popover-foreground">
150
+ <HelpFilledIcon className="mt-0.5 size-4 shrink-0 text-help" />
151
+ <div className="flex-1">
152
+ <div className="text-sm font-medium">自定义卡片</div>
153
+ <div className="mt-1 text-xs text-muted-foreground">
154
+ 你可以在此渲染任意 JSX:表单、富文本、进度条等。
155
+ </div>
141
156
  </div>
157
+ <button
158
+ type="button"
159
+ className="cursor-pointer text-xs text-muted-foreground hover:text-foreground"
160
+ onClick={() => toast.dismiss(id)}
161
+ >
162
+ 关闭
163
+ </button>
142
164
  </div>
143
- <button
144
- type="button"
145
- className="cursor-pointer text-xs text-muted-foreground hover:text-foreground"
146
- onClick={() => toast.dismiss(id)}
147
- >
148
- 关闭
149
- </button>
150
- </div>
151
- ))
152
- }
153
- >
154
- 触发
155
- </Button>
165
+ ))
166
+ }
167
+ >
168
+ 触发
169
+ </Button>
170
+ <Toaster />
171
+ </>
156
172
  ```
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import * as React from 'react';
3
- import { CircleHelpIcon } from 'lucide-react';
3
+ import { HelpFilledIcon } from '@/components/icon';
4
4
  import { Button } from '@/components/button';
5
5
  import { HelpToastIcon, Toaster, toast } from './index';
6
6
 
@@ -13,9 +13,8 @@ const meta: Meta<typeof Toaster> = {
13
13
  },
14
14
  decorators: [
15
15
  (Story) => (
16
- <div>
16
+ <div style={{ minHeight: 280 }}>
17
17
  <Story />
18
- <Toaster />
19
18
  </div>
20
19
  ),
21
20
  ],
@@ -26,6 +25,25 @@ type Story = StoryObj<typeof Toaster>;
26
25
 
27
26
  /** 五档语义状态 — 等价 cloud-design `Message.success / .error / .warning / .notice / .help / .loading`。 */
28
27
  export const Default: Story = {
28
+ parameters: {
29
+ docs: {
30
+ source: {
31
+ code: `import { Toaster, toast } from '@/components/sonner';
32
+
33
+ // 全局挂载一次 Toaster 容器
34
+ <Toaster />
35
+
36
+ // 通过 toast() 函数式触发
37
+ toast('默认通知');
38
+ toast.success('保存成功');
39
+ toast.info('已收到 3 条新消息');
40
+ toast.warning('请检查网络连接');
41
+ toast.error('操作失败,请重试');
42
+ toast.loading('正在加载...');
43
+ toast('需要帮助?', { icon: HelpToastIcon });`,
44
+ },
45
+ },
46
+ },
29
47
  render: () => (
30
48
  <div className="flex flex-wrap gap-2">
31
49
  <Button onClick={() => toast('默认通知')}>默认</Button>
@@ -44,6 +62,7 @@ export const Default: Story = {
44
62
  help
45
63
  </Button>
46
64
  <Button onClick={() => toast.loading('正在加载...')}>loading</Button>
65
+ <Toaster />
47
66
  </div>
48
67
  ),
49
68
  };
@@ -51,70 +70,82 @@ export const Default: Story = {
51
70
  /** 标题 + 描述 — 对应 cloud-design `Notification.open({ title, content })`。 */
52
71
  export const WithTitleAndDescription: Story = {
53
72
  render: () => (
54
- <Button
55
- onClick={() =>
56
- toast('文件已保存', {
57
- description: '你的修改已自动同步到云端,可在历史版本中找回。',
58
- })
59
- }
60
- >
61
- 触发
62
- </Button>
73
+ <>
74
+ <Button
75
+ onClick={() =>
76
+ toast('文件已保存', {
77
+ description: '你的修改已自动同步到云端,可在历史版本中找回。',
78
+ })
79
+ }
80
+ >
81
+ 触发
82
+ </Button>
83
+ <Toaster />
84
+ </>
63
85
  ),
64
86
  };
65
87
 
66
88
  /** 操作按钮 — 业内主流 `action` props,单击执行下一步行动并关闭。 */
67
89
  export const WithAction: Story = {
68
90
  render: () => (
69
- <Button
70
- onClick={() =>
71
- toast('已删除项目「示例」', {
72
- description: '删除后 7 天内可在回收站恢复。',
73
- action: {
74
- label: '撤销',
75
- onClick: () => toast.success('已撤销删除'),
76
- },
77
- })
78
- }
79
- >
80
- 触发
81
- </Button>
91
+ <>
92
+ <Button
93
+ onClick={() =>
94
+ toast('已删除项目「示例」', {
95
+ description: '删除后 7 天内可在回收站恢复。',
96
+ action: {
97
+ label: '撤销',
98
+ onClick: () => toast.success('已撤销删除'),
99
+ },
100
+ })
101
+ }
102
+ >
103
+ 触发
104
+ </Button>
105
+ <Toaster />
106
+ </>
82
107
  ),
83
108
  };
84
109
 
85
110
  /** 取消按钮 — 与 action 并存的次级行动点,可阻断默认行为。 */
86
111
  export const WithCancel: Story = {
87
112
  render: () => (
88
- <Button
89
- onClick={() =>
90
- toast('确认离开当前页面?', {
91
- description: '未保存的修改将丢失。',
92
- action: { label: '继续', onClick: () => toast.info('已继续') },
93
- cancel: { label: '取消', onClick: () => toast('已取消') },
94
- })
95
- }
96
- >
97
- 触发
98
- </Button>
113
+ <>
114
+ <Button
115
+ onClick={() =>
116
+ toast('确认离开当前页面?', {
117
+ description: '未保存的修改将丢失。',
118
+ action: { label: '继续', onClick: () => toast.info('已继续') },
119
+ cancel: { label: '取消', onClick: () => toast('已取消') },
120
+ })
121
+ }
122
+ >
123
+ 触发
124
+ </Button>
125
+ <Toaster />
126
+ </>
99
127
  ),
100
128
  };
101
129
 
102
130
  /** 按 id 链式更新 — 等价 cloud-design `Message.loading + Message.success({ key })`。 */
103
131
  export const LoadingThenResolve: Story = {
104
132
  render: () => (
105
- <Button
106
- onClick={() => {
107
- const id = toast.loading('正在上传...');
108
- setTimeout(() => {
109
- toast.success('上传完成', {
110
- id,
111
- description: '文件已发布到生产环境。',
112
- });
113
- }, 1500);
114
- }}
115
- >
116
- 触发
117
- </Button>
133
+ <>
134
+ <Button
135
+ onClick={() => {
136
+ const id = toast.loading('正在上传...');
137
+ setTimeout(() => {
138
+ toast.success('上传完成', {
139
+ id,
140
+ description: '文件已发布到生产环境。',
141
+ });
142
+ }, 1500);
143
+ }}
144
+ >
145
+ 触发
146
+ </Button>
147
+ <Toaster />
148
+ </>
118
149
  ),
119
150
  };
120
151
 
@@ -130,17 +161,20 @@ export const PromiseToast: Story = {
130
161
  });
131
162
 
132
163
  return (
133
- <Button
134
- onClick={() =>
135
- toast.promise(mockRequest(), {
136
- loading: '正在提交订单...',
137
- success: (data) => `${data.name} 已提交`,
138
- error: (err: Error) => `提交失败:${err.message}`,
139
- })
140
- }
141
- >
142
- 触发
143
- </Button>
164
+ <>
165
+ <Button
166
+ onClick={() =>
167
+ toast.promise(mockRequest(), {
168
+ loading: '正在提交订单...',
169
+ success: (data) => `${data.name} 已提交`,
170
+ error: (err: Error) => `提交失败:${err.message}`,
171
+ })
172
+ }
173
+ >
174
+ 触发
175
+ </Button>
176
+ <Toaster />
177
+ </>
144
178
  );
145
179
  },
146
180
  };
@@ -165,6 +199,7 @@ export const Duration: Story = {
165
199
  >
166
200
  持久 (Infinity)
167
201
  </Button>
202
+ <Toaster />
168
203
  </div>
169
204
  ),
170
205
  };
@@ -215,30 +250,33 @@ export const Placement: Story = {
215
250
  /** 自定义渲染 — `toast.custom` 完全接管节点,用于嵌入富内容卡片。 */
216
251
  export const Custom: Story = {
217
252
  render: () => (
218
- <Button
219
- onClick={() =>
220
- toast.custom((id) => (
221
- <div className="flex w-80 items-start gap-3 rounded-md border border-border bg-popover p-3 text-popover-foreground shadow-lg">
222
- <CircleHelpIcon className="mt-0.5 size-4 shrink-0 text-help" />
223
- <div className="flex-1">
224
- <div className="text-sm font-medium">自定义卡片</div>
225
- <div className="mt-1 text-xs text-muted-foreground">
226
- 你可以在此渲染任意 JSX:表单、富文本、进度条等。
253
+ <>
254
+ <Button
255
+ onClick={() =>
256
+ toast.custom((id) => (
257
+ <div className="flex w-80 items-start gap-3 rounded-md border border-border bg-popover p-3 text-popover-foreground">
258
+ <HelpFilledIcon className="mt-0.5 size-4 shrink-0 text-help" />
259
+ <div className="flex-1">
260
+ <div className="text-sm font-medium">自定义卡片</div>
261
+ <div className="mt-1 text-xs text-muted-foreground">
262
+ 你可以在此渲染任意 JSX:表单、富文本、进度条等。
263
+ </div>
227
264
  </div>
265
+ <button
266
+ type="button"
267
+ className="cursor-pointer text-xs text-muted-foreground hover:text-foreground"
268
+ onClick={() => toast.dismiss(id)}
269
+ >
270
+ 关闭
271
+ </button>
228
272
  </div>
229
- <button
230
- type="button"
231
- className="cursor-pointer text-xs text-muted-foreground hover:text-foreground"
232
- onClick={() => toast.dismiss(id)}
233
- >
234
- 关闭
235
- </button>
236
- </div>
237
- ))
238
- }
239
- >
240
- 触发
241
- </Button>
273
+ ))
274
+ }
275
+ >
276
+ 触发
277
+ </Button>
278
+ <Toaster />
279
+ </>
242
280
  ),
243
281
  };
244
282
 
@@ -251,7 +289,7 @@ export const DismissProgrammatic: Story = {
251
289
  <Button
252
290
  onClick={() => {
253
291
  idRef.current = toast('一条可被定向关闭的通知', {
254
- description: '保留这条 id,再点"关闭它"按钮。',
292
+ description: '保留这条 id,再点“关闭它”按钮。',
255
293
  duration: Infinity,
256
294
  });
257
295
  }}
@@ -279,6 +317,7 @@ export const DismissProgrammatic: Story = {
279
317
  <Button variant="destructive" onClick={() => toast.dismiss()}>
280
318
  全部关闭
281
319
  </Button>
320
+ <Toaster />
282
321
  </div>
283
322
  );
284
323
  },