@aura-react-comp/ui 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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -2
  3. package/esm/alert/index.d.ts +28 -0
  4. package/esm/alert/index.js +76 -0
  5. package/esm/alert/index.less +172 -0
  6. package/esm/avatar/index.d.ts +41 -0
  7. package/esm/avatar/index.js +117 -0
  8. package/esm/avatar/index.less +162 -0
  9. package/esm/badge/index.d.ts +29 -0
  10. package/esm/badge/index.js +84 -0
  11. package/esm/badge/index.less +215 -0
  12. package/esm/breadcrumb/index.d.ts +31 -0
  13. package/esm/breadcrumb/index.js +91 -0
  14. package/esm/breadcrumb/index.less +108 -0
  15. package/esm/button/index.d.ts +28 -0
  16. package/esm/button/index.js +59 -0
  17. package/esm/button/index.less +191 -0
  18. package/esm/card/index.d.ts +67 -0
  19. package/esm/card/index.js +156 -0
  20. package/esm/card/index.less +231 -0
  21. package/esm/checkbox/index.d.ts +35 -0
  22. package/esm/checkbox/index.js +118 -0
  23. package/esm/checkbox/index.less +141 -0
  24. package/esm/collapse/index.d.ts +45 -0
  25. package/esm/collapse/index.js +157 -0
  26. package/esm/collapse/index.less +144 -0
  27. package/esm/divider/index.d.ts +16 -0
  28. package/esm/divider/index.js +37 -0
  29. package/esm/divider/index.less +115 -0
  30. package/esm/dropdown/index.d.ts +38 -0
  31. package/esm/dropdown/index.js +108 -0
  32. package/esm/dropdown/index.less +245 -0
  33. package/esm/empty/index.d.ts +35 -0
  34. package/esm/empty/index.js +87 -0
  35. package/esm/empty/index.less +67 -0
  36. package/esm/flex/index.d.ts +24 -0
  37. package/esm/flex/index.js +64 -0
  38. package/esm/flex/index.less +9 -0
  39. package/esm/form/index.d.ts +121 -0
  40. package/esm/form/index.js +443 -0
  41. package/esm/form/index.less +257 -0
  42. package/esm/global.d.ts +6 -0
  43. package/esm/index.d.ts +78 -0
  44. package/esm/index.js +41 -0
  45. package/esm/input/index.d.ts +51 -0
  46. package/esm/input/index.js +217 -0
  47. package/esm/input/index.less +369 -0
  48. package/esm/layout/index.d.ts +46 -0
  49. package/esm/layout/index.js +135 -0
  50. package/esm/layout/index.less +132 -0
  51. package/esm/menu/index.d.ts +91 -0
  52. package/esm/menu/index.js +294 -0
  53. package/esm/menu/index.less +340 -0
  54. package/esm/message/index.d.ts +33 -0
  55. package/esm/message/index.js +199 -0
  56. package/esm/message/index.less +113 -0
  57. package/esm/notification/index.d.ts +33 -0
  58. package/esm/notification/index.js +229 -0
  59. package/esm/notification/index.less +175 -0
  60. package/esm/pagination/index.d.ts +38 -0
  61. package/esm/pagination/index.js +180 -0
  62. package/esm/pagination/index.less +238 -0
  63. package/esm/popconfirm/index.d.ts +37 -0
  64. package/esm/popconfirm/index.js +115 -0
  65. package/esm/popconfirm/index.less +229 -0
  66. package/esm/radio/index.d.ts +33 -0
  67. package/esm/radio/index.js +122 -0
  68. package/esm/radio/index.less +119 -0
  69. package/esm/rate/index.d.ts +30 -0
  70. package/esm/rate/index.js +143 -0
  71. package/esm/rate/index.less +87 -0
  72. package/esm/result/index.d.ts +19 -0
  73. package/esm/result/index.js +69 -0
  74. package/esm/result/index.less +103 -0
  75. package/esm/scrollbar/index.d.ts +18 -0
  76. package/esm/scrollbar/index.js +35 -0
  77. package/esm/scrollbar/index.less +67 -0
  78. package/esm/select/index.d.ts +63 -0
  79. package/esm/select/index.js +358 -0
  80. package/esm/select/index.less +427 -0
  81. package/esm/slider/index.d.ts +36 -0
  82. package/esm/slider/index.js +255 -0
  83. package/esm/slider/index.less +154 -0
  84. package/esm/space/index.d.ts +16 -0
  85. package/esm/space/index.js +34 -0
  86. package/esm/space/index.less +34 -0
  87. package/esm/spin/index.d.ts +44 -0
  88. package/esm/spin/index.js +152 -0
  89. package/esm/spin/index.less +170 -0
  90. package/esm/steps/index.d.ts +55 -0
  91. package/esm/steps/index.js +165 -0
  92. package/esm/steps/index.less +394 -0
  93. package/esm/switch/index.d.ts +30 -0
  94. package/esm/switch/index.js +56 -0
  95. package/esm/switch/index.less +135 -0
  96. package/esm/tabs/index.d.ts +45 -0
  97. package/esm/tabs/index.js +170 -0
  98. package/esm/tabs/index.less +226 -0
  99. package/esm/tag/index.d.ts +52 -0
  100. package/esm/tag/index.js +120 -0
  101. package/esm/tag/index.less +227 -0
  102. package/esm/textarea/index.d.ts +27 -0
  103. package/esm/textarea/index.js +84 -0
  104. package/esm/textarea/index.less +224 -0
  105. package/esm/theme/ThemeProvider.d.ts +15 -0
  106. package/esm/theme/ThemeProvider.js +32 -0
  107. package/esm/theme/index.d.ts +2 -0
  108. package/esm/theme/index.js +1 -0
  109. package/esm/theme/tokens.css +183 -0
  110. package/esm/theme/useTheme.d.ts +1 -0
  111. package/esm/theme/useTheme.js +1 -0
  112. package/esm/tooltip/index.d.ts +38 -0
  113. package/esm/tooltip/index.js +149 -0
  114. package/esm/tooltip/index.less +244 -0
  115. package/esm/typography/index.d.ts +26 -0
  116. package/esm/typography/index.js +92 -0
  117. package/esm/typography/index.less +106 -0
  118. package/esm/upload/index.d.ts +68 -0
  119. package/esm/upload/index.js +447 -0
  120. package/esm/upload/index.less +371 -0
  121. package/esm/upload/request.d.ts +26 -0
  122. package/esm/upload/request.js +38 -0
  123. package/package.json +56 -3
@@ -0,0 +1,340 @@
1
+ /* ===== Menu 组件样式 ===== */
2
+
3
+ .aura-menu {
4
+ display: flex;
5
+ flex-direction: column;
6
+ padding: var(--aura-spacing-1) 0;
7
+ background: var(--aura-bg);
8
+ border-radius: var(--aura-radius-md);
9
+ list-style: none;
10
+ margin: 0;
11
+
12
+ /* ===== 折叠开关(collapsible 时渲染) ===== */
13
+ &-collapse-trigger {
14
+ display: inline-flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ width: calc(100% - var(--aura-spacing-2));
18
+ margin: 0 var(--aura-spacing-1) var(--aura-spacing-1);
19
+ padding: 6px 0;
20
+ border: none;
21
+ background: transparent;
22
+ color: var(--aura-text-tertiary);
23
+ cursor: pointer;
24
+ border-radius: var(--aura-radius-sm);
25
+ transition:
26
+ color var(--aura-duration-fast) var(--aura-easing),
27
+ background var(--aura-duration-fast) var(--aura-easing);
28
+
29
+ &:hover {
30
+ color: var(--aura-primary-700);
31
+ background: var(--aura-primary-50);
32
+ }
33
+
34
+ &:focus-visible {
35
+ outline: 2px solid var(--aura-primary-500);
36
+ outline-offset: -2px;
37
+ }
38
+ }
39
+
40
+ /* ===== 折叠态:仅展示图标 ===== */
41
+ &&-collapsed {
42
+ width: 56px;
43
+
44
+ .aura-menu-item-text,
45
+ .aura-menu-submenu-arrow,
46
+ .aura-menu-group-title {
47
+ display: none;
48
+ }
49
+
50
+ .aura-menu-item,
51
+ .aura-menu-submenu-title {
52
+ justify-content: center;
53
+ padding-left: 0;
54
+ padding-right: 0;
55
+ }
56
+
57
+ .aura-menu-item-icon {
58
+ margin-right: 0;
59
+ }
60
+ }
61
+
62
+ /* ===== Mode: vertical ===== */
63
+ &&-vertical {
64
+ width: fit-content;
65
+ border: 1px solid var(--aura-border);
66
+ }
67
+
68
+ /* ===== Mode: horizontal ===== */
69
+ &&-horizontal {
70
+ flex-direction: row;
71
+ align-items: center;
72
+ border-bottom: 1px solid var(--aura-border);
73
+ border-radius: 0;
74
+ padding: 0;
75
+
76
+ .aura-menu-item {
77
+ padding: 10px 20px;
78
+ border-bottom: 2px solid transparent;
79
+ transition: all var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
80
+
81
+ &:hover {
82
+ border-bottom-color: var(--aura-primary-200);
83
+ }
84
+
85
+ &-selected {
86
+ border-bottom-color: var(--aura-primary-600);
87
+ color: var(--aura-primary-700);
88
+ }
89
+ }
90
+
91
+ .aura-menu-submenu {
92
+ position: relative;
93
+ z-index: 1;
94
+
95
+ .aura-menu-submenu-content {
96
+ position: absolute;
97
+ top: calc(100% + 4px);
98
+ left: 0;
99
+ min-width: 200px;
100
+ background: var(--aura-bg);
101
+ border-radius: var(--aura-radius-md);
102
+ overflow: hidden;
103
+ z-index: 100;
104
+ border: 1px solid transparent;
105
+ box-shadow: none;
106
+ transition:
107
+ grid-template-rows var(--aura-duration-slow)
108
+ cubic-bezier(0.4, 0, 0.2, 1),
109
+ border-color 0.15s ease 0.05s,
110
+ box-shadow 0.15s ease 0.05s;
111
+
112
+ &-open {
113
+ grid-template-rows: 1fr;
114
+ border-color: var(--aura-border);
115
+ box-shadow: var(--aura-shadow-md);
116
+ }
117
+ }
118
+ }
119
+ }
120
+
121
+ /* ===== Mode: inline ===== */
122
+ &&-inline {
123
+ width: fit-content;
124
+ border: 1px solid var(--aura-border);
125
+ }
126
+ }
127
+
128
+ /* ===== Menu.Item ===== */
129
+ .aura-menu-item {
130
+ display: flex;
131
+ align-items: center;
132
+ padding: 8px var(--aura-spacing-4);
133
+ margin: 0 var(--aura-spacing-1);
134
+ font-size: var(--aura-font-size-md);
135
+ line-height: 1.5;
136
+ color: var(--aura-text);
137
+ border-radius: var(--aura-radius-sm);
138
+ cursor: pointer;
139
+ user-select: none;
140
+ transition:
141
+ background var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1),
142
+ color var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
143
+
144
+ &:hover {
145
+ background: var(--aura-primary-50);
146
+ color: var(--aura-primary-700);
147
+ }
148
+
149
+ &:focus-visible {
150
+ outline: 2px solid var(--aura-primary-500);
151
+ outline-offset: -2px;
152
+ }
153
+
154
+ &-selected {
155
+ background: var(--aura-primary-50);
156
+ color: var(--aura-primary-700);
157
+ font-weight: 600;
158
+ }
159
+
160
+ &-disabled {
161
+ color: var(--aura-text-tertiary);
162
+ cursor: not-allowed;
163
+ opacity: 0.6;
164
+
165
+ &:hover {
166
+ background: transparent;
167
+ color: var(--aura-text-tertiary);
168
+ }
169
+ }
170
+ }
171
+
172
+ .aura-menu-item-icon {
173
+ display: inline-flex;
174
+ align-items: center;
175
+ justify-content: center;
176
+ margin-right: var(--aura-spacing-2);
177
+ font-size: var(--aura-font-size-md);
178
+ }
179
+
180
+ .aura-menu-item-text {
181
+ flex: 1;
182
+ }
183
+
184
+ /* ===== Menu.SubMenu ===== */
185
+ .aura-menu-submenu {
186
+ display: flex;
187
+ flex-direction: column;
188
+ }
189
+
190
+ .aura-menu-submenu-title {
191
+ display: flex;
192
+ align-items: center;
193
+ padding: 8px var(--aura-spacing-4);
194
+ margin: 0 var(--aura-spacing-1);
195
+ font-size: var(--aura-font-size-md);
196
+ line-height: 1.5;
197
+ color: var(--aura-text);
198
+ border-radius: var(--aura-radius-sm);
199
+ cursor: pointer;
200
+ user-select: none;
201
+ transition:
202
+ background var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1),
203
+ color var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
204
+
205
+ &:hover {
206
+ background: var(--aura-bg-secondary);
207
+ color: var(--aura-primary-700);
208
+ }
209
+
210
+ &:focus-visible {
211
+ outline: 2px solid var(--aura-primary-500);
212
+ outline-offset: -2px;
213
+ }
214
+ }
215
+
216
+ .aura-menu-submenu-arrow {
217
+ display: inline-flex;
218
+ align-items: center;
219
+ justify-content: center;
220
+ margin-left: auto;
221
+ color: var(--aura-text-tertiary);
222
+ transition: transform var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
223
+
224
+ &-open {
225
+ transform: rotate(180deg);
226
+ }
227
+ }
228
+
229
+ .aura-menu-submenu-content {
230
+ display: grid;
231
+ grid-template-rows: 0fr;
232
+ transition: grid-template-rows var(--aura-duration-slow)
233
+ cubic-bezier(0.4, 0, 0.2, 1);
234
+
235
+ &-open {
236
+ grid-template-rows: 1fr;
237
+ }
238
+ }
239
+
240
+ .aura-menu-submenu-inner {
241
+ overflow: hidden;
242
+ min-height: 0;
243
+ padding: var(--aura-spacing-1) 0;
244
+
245
+ .aura-menu-item,
246
+ .aura-menu-submenu-title {
247
+ padding-left: var(--aura-spacing-8);
248
+ }
249
+ }
250
+
251
+ .aura-menu-submenu-title-selected {
252
+ color: var(--aura-primary-700);
253
+ }
254
+
255
+ /* ===== Menu.Group ===== */
256
+ .aura-menu-group {
257
+ display: flex;
258
+ flex-direction: column;
259
+ }
260
+
261
+ .aura-menu-group-title {
262
+ padding: var(--aura-spacing-2) var(--aura-spacing-4);
263
+ font-size: var(--aura-font-size-xs);
264
+ font-weight: 600;
265
+ color: var(--aura-text-tertiary);
266
+ text-transform: uppercase;
267
+ letter-spacing: 0.05em;
268
+ user-select: none;
269
+ }
270
+
271
+ /* ===== 暗色模式 ===== */
272
+ [data-theme='dark'] {
273
+ .aura-menu {
274
+ background: var(--aura-bg);
275
+ }
276
+
277
+ .aura-menu-item {
278
+ color: var(--aura-text);
279
+
280
+ &:hover {
281
+ background: var(--aura-bg-tertiary);
282
+ color: var(--aura-primary-400);
283
+ }
284
+
285
+ &-selected {
286
+ background: rgba(124, 58, 237, 0.15);
287
+ color: var(--aura-primary-400);
288
+ }
289
+
290
+ &-disabled {
291
+ color: var(--aura-text-tertiary);
292
+
293
+ &:hover {
294
+ background: transparent;
295
+ color: var(--aura-text-tertiary);
296
+ }
297
+ }
298
+ }
299
+
300
+ .aura-menu-submenu-title {
301
+ color: var(--aura-text);
302
+
303
+ &:hover {
304
+ background: var(--aura-bg-tertiary);
305
+ color: var(--aura-primary-400);
306
+ }
307
+
308
+ &-selected {
309
+ color: var(--aura-primary-400);
310
+ }
311
+ }
312
+
313
+ .aura-menu-horizontal {
314
+ .aura-menu-item-selected {
315
+ border-bottom-color: var(--aura-primary-400);
316
+ color: var(--aura-primary-400);
317
+ }
318
+ }
319
+
320
+ .aura-menu-group-title {
321
+ color: var(--aura-text-tertiary);
322
+ }
323
+ }
324
+
325
+ /* ===== 危险操作项 ===== */
326
+ .aura-menu-item-danger {
327
+ color: var(--aura-error);
328
+
329
+ &:hover {
330
+ background: var(--aura-error-light);
331
+ }
332
+ }
333
+
334
+ /* ===== 分隔线 ===== */
335
+ .aura-menu-divider {
336
+ height: 1px;
337
+ margin: var(--aura-spacing-1) 0;
338
+ background: var(--aura-border);
339
+ overflow: hidden;
340
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ type MessageVariant = 'success' | 'error' | 'warning' | 'info' | 'loading';
3
+ export interface MessageArgs {
4
+ /** 消息内容,支持任意 ReactNode(链接、按钮等) */
5
+ content: React.ReactNode;
6
+ /** 唯一标识;重复调用同 key 会原位更新内容与变体(loading → success 场景),不重新播放入场动画 */
7
+ key?: string;
8
+ /** 自动关闭延时(毫秒);0 表示不自动关闭 */
9
+ duration?: number;
10
+ /** 自定义图标,覆盖变体默认图标 */
11
+ icon?: React.ReactNode;
12
+ /** 消息关闭(自动关闭 / destroy)后的回调 */
13
+ onClose?: () => void;
14
+ }
15
+ export declare function _resetMessageState(): void;
16
+ /** 首参:纯内容或完整参数对象 */
17
+ export type MessageContent = React.ReactNode | MessageArgs;
18
+ export interface MessageApi {
19
+ success(content: MessageContent, duration?: number): void;
20
+ error(content: MessageContent, duration?: number): void;
21
+ warning(content: MessageContent, duration?: number): void;
22
+ info(content: MessageContent, duration?: number): void;
23
+ loading(content: MessageContent, duration?: number): void;
24
+ /** 完整参数打开消息,变体由 variant 指定(缺省 info) */
25
+ open(args: Omit<MessageArgs, 'key'> & {
26
+ key?: string;
27
+ variant?: MessageVariant;
28
+ }): void;
29
+ /** 关闭指定消息;不传 key 关闭全部 */
30
+ destroy(key?: string): void;
31
+ }
32
+ export declare const message: MessageApi;
33
+ export default message;
@@ -0,0 +1,199 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { flushSync } from 'react-dom';
4
+ import { classNames, prefixCls } from '@aura-react-comp/shared';
5
+ import { CheckCircleFilled, CloseCircleFilled, WarningTriangleFilled, InfoCircleFilled, Loading } from '@aura-react-comp/icons';
6
+ import "./index.less";
7
+
8
+ /* ===== 类型定义 ===== */
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ /* ===== 图标 ===== */
13
+ const variantIcons = {
14
+ success: /*#__PURE__*/_jsx(CheckCircleFilled, {
15
+ size: 16
16
+ }),
17
+ error: /*#__PURE__*/_jsx(CloseCircleFilled, {
18
+ size: 16
19
+ }),
20
+ warning: /*#__PURE__*/_jsx(WarningTriangleFilled, {
21
+ size: 16
22
+ }),
23
+ info: /*#__PURE__*/_jsx(InfoCircleFilled, {
24
+ size: 16
25
+ }),
26
+ loading: /*#__PURE__*/_jsx(Loading, {
27
+ size: 16,
28
+ className: prefixCls('message-loading-icon')
29
+ })
30
+ };
31
+
32
+ /* ===== 容器管理 ===== */
33
+ let containerEl = null;
34
+ let rootInstance = null;
35
+ let messageList = [];
36
+ let messageKeyCounter = 0;
37
+ function getContainer() {
38
+ if (!containerEl) {
39
+ containerEl = document.createElement('div');
40
+ containerEl.className = prefixCls('message-container');
41
+ document.body.appendChild(containerEl);
42
+ rootInstance = createRoot(containerEl);
43
+ }
44
+ return containerEl;
45
+ }
46
+ function renderMessages() {
47
+ getContainer();
48
+ if (rootInstance) {
49
+ const root = rootInstance;
50
+ flushSync(() => {
51
+ root.render( /*#__PURE__*/_jsx(MessageList, {
52
+ items: messageList
53
+ }));
54
+ });
55
+ }
56
+ // 无消息时卸载容器
57
+ if (messageList.length === 0 && rootInstance) {
58
+ setTimeout(() => {
59
+ if (messageList.length === 0 && containerEl && rootInstance) {
60
+ rootInstance.unmount();
61
+ document.body.removeChild(containerEl);
62
+ containerEl = null;
63
+ rootInstance = null;
64
+ }
65
+ }, 300);
66
+ }
67
+ }
68
+
69
+ /** 解析调用参数:首参可以是纯内容(string / number / ReactElement),也可以是完整 MessageArgs */
70
+ function resolveArgs(args, duration) {
71
+ if (args !== null && typeof args === 'object' && ! /*#__PURE__*/React.isValidElement(args) && 'content' in args) {
72
+ const config = args;
73
+ return {
74
+ ...config,
75
+ duration: config.duration ?? duration
76
+ };
77
+ }
78
+ return {
79
+ content: args,
80
+ duration
81
+ };
82
+ }
83
+ function addMessage(variant, args, duration) {
84
+ const resolved = resolveArgs(args, duration);
85
+ // 显式传 0 / 负数视为不自动关闭;loading 默认不自动关闭
86
+ const effectiveDuration = resolved.duration !== undefined ? resolved.duration > 0 ? resolved.duration : null : variant === 'loading' ? null : 3000;
87
+ const existingIndex = resolved.key ? messageList.findIndex(item => item.key === resolved.key) : -1;
88
+ const item = {
89
+ ...resolved,
90
+ key: resolved.key ?? `aura-msg-${++messageKeyCounter}`,
91
+ variant,
92
+ duration: effectiveDuration,
93
+ version: existingIndex >= 0 ? messageList[existingIndex].version + 1 : 0
94
+ };
95
+ if (existingIndex >= 0) {
96
+ // 同 key 原位更新:保持消息在列表中的位置,不重新播放入场动画
97
+ messageList = messageList.map((existing, i) => i === existingIndex ? item : existing);
98
+ } else {
99
+ messageList = [...messageList, item];
100
+ }
101
+ renderMessages();
102
+ }
103
+ function removeMessage(key) {
104
+ const item = messageList.find(m => m.key === key);
105
+ messageList = messageList.filter(m => m.key !== key);
106
+ renderMessages();
107
+ if (item?.onClose) item.onClose();
108
+ }
109
+
110
+ /* ===== MessageList 组件 ===== */
111
+ const MessageList = ({
112
+ items
113
+ }) => {
114
+ return /*#__PURE__*/_jsx(_Fragment, {
115
+ children: items.map(item => /*#__PURE__*/_jsx(MessageItemComponent, {
116
+ item: item,
117
+ onClose: () => removeMessage(item.key)
118
+ }, item.key))
119
+ });
120
+ };
121
+
122
+ /* ===== 单条消息组件 ===== */
123
+ const MessageItemComponent = ({
124
+ item,
125
+ onClose
126
+ }) => {
127
+ const [visible, setVisible] = useState(false);
128
+ const [leaving, setLeaving] = useState(false);
129
+ const timerRef = useRef(null);
130
+ useEffect(() => {
131
+ // 入场动画:下一帧设置 visible
132
+ const raf = requestAnimationFrame(() => setVisible(true));
133
+ return () => cancelAnimationFrame(raf);
134
+ }, []);
135
+ useEffect(() => {
136
+ if (item.duration !== null && item.duration > 0) {
137
+ timerRef.current = setTimeout(() => {
138
+ handleClose();
139
+ }, item.duration);
140
+ }
141
+ return () => {
142
+ if (timerRef.current) clearTimeout(timerRef.current);
143
+ };
144
+ // eslint-disable-next-line react-hooks/exhaustive-deps
145
+ }, [item.duration, item.version]);
146
+ const handleClose = () => {
147
+ setLeaving(true);
148
+ setTimeout(() => {
149
+ setVisible(false);
150
+ onClose();
151
+ }, 300);
152
+ };
153
+ const cls = classNames(prefixCls('message'), prefixCls(`message-${item.variant}`), visible && !leaving && prefixCls('message-visible'), leaving && prefixCls('message-leaving'));
154
+ return /*#__PURE__*/_jsxs("div", {
155
+ className: cls,
156
+ role: "status",
157
+ children: [/*#__PURE__*/_jsx("span", {
158
+ className: prefixCls('message-icon'),
159
+ children: item.icon ?? variantIcons[item.variant]
160
+ }), /*#__PURE__*/_jsx("span", {
161
+ className: prefixCls('message-content'),
162
+ children: item.content
163
+ })]
164
+ });
165
+ };
166
+
167
+ /* ===== 重置内部状态(供测试使用) ===== */
168
+ export function _resetMessageState() {
169
+ messageList = [];
170
+ if (rootInstance) {
171
+ rootInstance.unmount();
172
+ }
173
+ if (containerEl && containerEl.parentNode) {
174
+ containerEl.parentNode.removeChild(containerEl);
175
+ }
176
+ containerEl = null;
177
+ rootInstance = null;
178
+ }
179
+
180
+ /* ===== 对外导出 ===== */
181
+ /** 首参:纯内容或完整参数对象 */
182
+
183
+ export const message = {
184
+ success: (content, duration) => addMessage('success', content, duration),
185
+ error: (content, duration) => addMessage('error', content, duration),
186
+ warning: (content, duration) => addMessage('warning', content, duration),
187
+ info: (content, duration) => addMessage('info', content, duration),
188
+ loading: (content, duration) => addMessage('loading', content, duration),
189
+ open: args => addMessage(args.variant ?? 'info', args),
190
+ destroy: key => {
191
+ if (key === undefined) {
192
+ const keys = messageList.map(item => item.key);
193
+ keys.forEach(removeMessage);
194
+ return;
195
+ }
196
+ removeMessage(key);
197
+ }
198
+ };
199
+ export default message;
@@ -0,0 +1,113 @@
1
+ .aura-message-container {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ width: 100%;
6
+ z-index: 9999;
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ padding-top: var(--aura-spacing-4);
11
+ pointer-events: none;
12
+ }
13
+
14
+ .aura-message {
15
+ display: inline-flex;
16
+ align-items: center;
17
+ gap: var(--aura-spacing-2);
18
+ padding: var(--aura-spacing-2) var(--aura-spacing-4);
19
+ margin-bottom: var(--aura-spacing-2);
20
+ background: var(--aura-bg);
21
+ border-radius: var(--aura-radius-md);
22
+ box-shadow: var(--aura-shadow-md);
23
+ font-size: var(--aura-font-size-md);
24
+ color: var(--aura-text);
25
+ pointer-events: auto;
26
+ opacity: 0;
27
+ transform: translateY(-100%);
28
+ transition: opacity var(--aura-duration-normal) var(--aura-easing),
29
+ transform var(--aura-duration-normal) var(--aura-easing);
30
+
31
+ /* ===== 图标 ===== */
32
+ &-icon {
33
+ display: flex;
34
+ align-items: center;
35
+ flex-shrink: 0;
36
+ }
37
+
38
+ /* ===== 内容 ===== */
39
+ &-content {
40
+ line-height: 1.5;
41
+ }
42
+
43
+ /* ===== 入场状态 ===== */
44
+ &-visible {
45
+ opacity: 1;
46
+ transform: translateY(0);
47
+ }
48
+
49
+ /* ===== 退场状态 ===== */
50
+ &-leaving {
51
+ opacity: 0;
52
+ transform: translateY(-100%);
53
+ }
54
+
55
+ /* ===== Variant 颜色 ===== */
56
+ &-success {
57
+ border-left: 3px solid var(--aura-success);
58
+
59
+ .aura-message-icon {
60
+ color: var(--aura-success);
61
+ }
62
+ }
63
+
64
+ &-error {
65
+ border-left: 3px solid var(--aura-error);
66
+
67
+ .aura-message-icon {
68
+ color: var(--aura-error);
69
+ }
70
+ }
71
+
72
+ &-warning {
73
+ border-left: 3px solid var(--aura-warning);
74
+
75
+ .aura-message-icon {
76
+ color: var(--aura-warning);
77
+ }
78
+ }
79
+
80
+ &-info {
81
+ border-left: 3px solid var(--aura-info);
82
+
83
+ .aura-message-icon {
84
+ color: var(--aura-info);
85
+ }
86
+ }
87
+
88
+ &-loading {
89
+ border-left: 3px solid var(--aura-primary-500);
90
+
91
+ .aura-message-icon {
92
+ color: var(--aura-primary-500);
93
+ }
94
+ }
95
+
96
+ /* ===== Loading 旋转动画 ===== */
97
+ &-loading-icon {
98
+ animation: aura-message-spin 0.8s linear infinite;
99
+ }
100
+ }
101
+
102
+ @keyframes aura-message-spin {
103
+ from { transform: rotate(0deg); }
104
+ to { transform: rotate(360deg); }
105
+ }
106
+
107
+ /* ===== 暗色模式 ===== */
108
+ [data-theme="dark"] {
109
+ .aura-message {
110
+ background: var(--aura-bg-secondary);
111
+ box-shadow: var(--aura-shadow-lg);
112
+ }
113
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ type NotificationVariant = 'default' | 'success' | 'warning' | 'error' | 'info';
3
+ type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
4
+ export interface NotificationOptions {
5
+ /** 通知标题,支持任意 ReactNode */
6
+ title?: React.ReactNode;
7
+ /** 通知内容(必填),支持任意 ReactNode */
8
+ content: React.ReactNode;
9
+ /** 唯一标识;重复调用同 key 会原位更新(不重新弹出新通知),并重置自动关闭计时 */
10
+ key?: string;
11
+ /** 自动关闭延时(毫秒);0 表示不自动关闭 */
12
+ duration?: number;
13
+ /** 通知类型 */
14
+ variant?: NotificationVariant;
15
+ /** 弹出位置 */
16
+ placement?: NotificationPlacement;
17
+ /** 底部操作区(按钮组等) */
18
+ actions?: React.ReactNode;
19
+ /** 关闭回调(自动关闭 / 手动关闭 / destroy 均触发) */
20
+ onClose?: () => void;
21
+ }
22
+ export declare function _resetNotificationState(): void;
23
+ export interface NotificationApi {
24
+ open(options: NotificationOptions): void;
25
+ success(options: Omit<NotificationOptions, 'variant'>): void;
26
+ error(options: Omit<NotificationOptions, 'variant'>): void;
27
+ warning(options: Omit<NotificationOptions, 'variant'>): void;
28
+ info(options: Omit<NotificationOptions, 'variant'>): void;
29
+ /** 关闭指定通知;不传 key 关闭全部 */
30
+ destroy(key?: string): void;
31
+ }
32
+ export declare const notification: NotificationApi;
33
+ export default notification;