@aura-react-comp/ui 0.0.0-stage → 0.1.1

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 +163 -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 +107 -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 +175 -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 +247 -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 +258 -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 +118 -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 +182 -0
  62. package/esm/pagination/index.less +230 -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 +155 -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 +104 -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 +471 -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 +179 -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 +160 -0
  96. package/esm/tabs/index.d.ts +45 -0
  97. package/esm/tabs/index.js +170 -0
  98. package/esm/tabs/index.less +228 -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 +226 -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 +107 -0
  118. package/esm/upload/index.d.ts +68 -0
  119. package/esm/upload/index.js +447 -0
  120. package/esm/upload/index.less +376 -0
  121. package/esm/upload/request.d.ts +26 -0
  122. package/esm/upload/request.js +38 -0
  123. package/package.json +56 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Aura Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # @aura-react-comp/ui
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
+ Aura 自研组件库:基于 React 18 的现代化、AI 友好组件库,采用 CSS Variables 主题体系。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @aura-react-comp/ui
9
+ ```
10
+
11
+ `react` / `react-dom` 为 peerDependencies,需由使用方提供(>=18)。
12
+
13
+ ## 使用
14
+
15
+ ```tsx
16
+ import { Button, Space } from '@aura-react-comp/ui';
17
+ import '@aura-react-comp/ui/style.css';
18
+
19
+ const App = () => (
20
+ <Space>
21
+ <Button variant="primary">主要按钮</Button>
22
+ <Button>默认按钮</Button>
23
+ </Space>
24
+ );
25
+ ```
26
+
27
+ > 引入 `@aura-react-comp/ui` 时其入口已自动引入主题令牌,`import '@aura-react-comp/ui/style.css'` 仅在你需要手动控制样式加载顺序时才需显式书写。
28
+ > 请勿使用 `@aura-react-comp/ui/src/...` 这类源码路径 —— 发布包只包含 `esm/` 产物。
29
+
30
+ ## 主题
31
+
32
+ 通过 CSS Variables 控制,支持亮色 / 暗色。令牌定义在 `@aura-react-comp/ui/style.css`,可用 `ThemeProvider` 与 `useTheme` 切换:
33
+
34
+ ```tsx
35
+ import { ThemeProvider, useTheme } from '@aura-react-comp/ui';
36
+ ```
37
+
38
+ 覆盖单个别名即可定制主题:
39
+
40
+ ```css
41
+ :root {
42
+ --aura-primary-700: #7c3aed;
43
+ --aura-radius-sm: 6px;
44
+ }
45
+ ```
46
+
47
+ ## 组件总览(36 个)
48
+
49
+ | 分类 | 组件 |
50
+ | -------- | -------------------------------------------------------- |
51
+ | 通用 | Button、Icon、Typography、Space、Divider |
52
+ | 布局 | Layout、Flex、Scrollbar |
53
+ | 导航 | Menu、Breadcrumb、Pagination、Steps、Dropdown |
54
+ | 表单 | Input、Textarea、Select、Checkbox、Radio、Switch |
55
+ | 表单高级 | Slider、Rate、Upload、Form |
56
+ | 数据展示 | Tag、Badge、Avatar、Tooltip、Card、Collapse、Tabs、Empty |
57
+ | 反馈 | Alert、Spin、Message、Notification、Result、Popconfirm |
58
+
59
+ 完整 API 与在线示例见文档站。
60
+
61
+ ## 说明
62
+
63
+ - 样式与逻辑分离:每个组件为独立的 `index.tsx` + `index.less`。
64
+ - 支持 tree-shaking;`sideEffects` 仅保留 `*.less` / `*.css`,避免样式被误摇除。
65
+
66
+ ## 许可证
67
+
68
+ MIT
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ export interface AlertProps {
3
+ /** 提示类型
4
+ * @default 'default'
5
+ */
6
+ variant?: 'default' | 'success' | 'warning' | 'error' | 'info';
7
+ /** 标题 */
8
+ title?: React.ReactNode;
9
+ /** 是否用作页面顶部通栏(去圆角、居中展示) */
10
+ banner?: boolean;
11
+ /** 是否可关闭 */
12
+ closable?: boolean;
13
+ /** 是否显示图标 */
14
+ showIcon?: boolean;
15
+ /** 自定义图标(需配合 showIcon 使用),覆盖变体默认图标 */
16
+ icon?: React.ReactNode;
17
+ /** 右侧操作区(如「去查看」链接、按钮) */
18
+ action?: React.ReactNode;
19
+ /** 关闭回调 */
20
+ onClose?: () => void;
21
+ /** 自定义类名 */
22
+ className?: string;
23
+ /** 自定义样式 */
24
+ style?: React.CSSProperties;
25
+ /** 描述内容 */
26
+ children?: React.ReactNode;
27
+ }
28
+ export declare const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,76 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import { classNames, prefixCls } from '@aura-react-comp/shared';
3
+ import { CheckCircleFilled, WarningTriangleFilled, CloseCircleFilled, InfoCircleFilled, Close } from '@aura-react-comp/icons';
4
+ import "./index.less";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ /** 不同 variant 对应的图标 */
8
+ const variantIcons = {
9
+ success: /*#__PURE__*/_jsx(CheckCircleFilled, {
10
+ size: 16
11
+ }),
12
+ warning: /*#__PURE__*/_jsx(WarningTriangleFilled, {
13
+ size: 16
14
+ }),
15
+ error: /*#__PURE__*/_jsx(CloseCircleFilled, {
16
+ size: 16
17
+ }),
18
+ info: /*#__PURE__*/_jsx(InfoCircleFilled, {
19
+ size: 16
20
+ }),
21
+ default: /*#__PURE__*/_jsx(InfoCircleFilled, {
22
+ size: 16
23
+ })
24
+ };
25
+ export const Alert = /*#__PURE__*/forwardRef(({
26
+ variant = 'default',
27
+ title,
28
+ banner = false,
29
+ closable = false,
30
+ showIcon = false,
31
+ icon,
32
+ action,
33
+ onClose,
34
+ className,
35
+ style,
36
+ children
37
+ }, ref) => {
38
+ const [visible, setVisible] = useState(true);
39
+ if (!visible) return null;
40
+ const handleClose = () => {
41
+ setVisible(false);
42
+ onClose?.();
43
+ };
44
+ const cls = classNames(prefixCls('alert'), variant !== 'default' && prefixCls(`alert-${variant}`), banner && prefixCls('alert-banner'), showIcon && prefixCls('alert-with-icon'), className);
45
+ return /*#__PURE__*/_jsxs("div", {
46
+ ref: ref,
47
+ className: cls,
48
+ style: style,
49
+ role: "alert",
50
+ children: [showIcon && /*#__PURE__*/_jsx("span", {
51
+ className: prefixCls('alert-icon'),
52
+ children: icon ?? variantIcons[variant]
53
+ }), /*#__PURE__*/_jsxs("span", {
54
+ className: prefixCls('alert-content'),
55
+ children: [title && /*#__PURE__*/_jsx("span", {
56
+ className: prefixCls('alert-title'),
57
+ children: title
58
+ }), children && /*#__PURE__*/_jsx("span", {
59
+ className: prefixCls('alert-description'),
60
+ children: children
61
+ })]
62
+ }), action && /*#__PURE__*/_jsx("span", {
63
+ className: prefixCls('alert-action'),
64
+ children: action
65
+ }), closable && /*#__PURE__*/_jsx("button", {
66
+ type: "button",
67
+ className: prefixCls('alert-close'),
68
+ onClick: handleClose,
69
+ "aria-label": "\u5173\u95ED",
70
+ children: /*#__PURE__*/_jsx(Close, {
71
+ size: 14
72
+ })
73
+ })]
74
+ });
75
+ });
76
+ Alert.displayName = 'Alert';
@@ -0,0 +1,172 @@
1
+ .aura-alert {
2
+ position: relative;
3
+ display: flex;
4
+ align-items: flex-start;
5
+ gap: var(--aura-spacing-2);
6
+ padding: var(--aura-spacing-3) var(--aura-spacing-4);
7
+ border-radius: var(--aura-radius-md);
8
+ font-size: var(--aura-font-size-md);
9
+ line-height: 1.5;
10
+ background: var(--aura-info-light);
11
+ border: 1px solid var(--aura-info);
12
+ color: var(--aura-text);
13
+ animation: aura-slide-down 0.3s cubic-bezier(0.4, 0, 0.2, 1);
14
+ transition:
15
+ opacity 0.3s var(--aura-easing),
16
+ transform 0.3s var(--aura-easing),
17
+ max-height 0.3s var(--aura-easing);
18
+
19
+ // 关闭动画
20
+ &&-closing {
21
+ opacity: 0;
22
+ transform: translateY(-8px);
23
+ max-height: 0;
24
+ padding-top: 0;
25
+ padding-bottom: 0;
26
+ margin-bottom: 0;
27
+ overflow: hidden;
28
+ }
29
+
30
+ // 带图标时
31
+ &-with-icon {
32
+ .aura-alert-icon {
33
+ display: flex;
34
+ align-items: center;
35
+ flex-shrink: 0;
36
+ margin-top: 2px;
37
+ color: var(--aura-info);
38
+ animation: aura-icon-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
39
+ }
40
+ }
41
+
42
+ // 内容区
43
+ &-content {
44
+ display: flex;
45
+ flex-direction: column;
46
+ flex: 1;
47
+ min-width: 0;
48
+ }
49
+
50
+ // 标题
51
+ &-title {
52
+ font-weight: 600;
53
+ color: var(--aura-text);
54
+ }
55
+
56
+ // 描述
57
+ &-description {
58
+ color: var(--aura-text-secondary);
59
+ font-size: var(--aura-font-size-sm);
60
+ margin-top: var(--aura-spacing-1);
61
+ }
62
+
63
+ // 操作区
64
+ &-action {
65
+ flex-shrink: 0;
66
+ display: flex;
67
+ align-items: center;
68
+ margin-top: 1px;
69
+ }
70
+
71
+ // 关闭按钮
72
+ &-close {
73
+ display: inline-flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+ flex-shrink: 0;
77
+ padding: 0;
78
+ border: none;
79
+ background: transparent;
80
+ color: var(--aura-text-tertiary);
81
+ cursor: pointer;
82
+ border-radius: var(--aura-radius-sm);
83
+ transition: all 0.2s var(--aura-easing);
84
+ margin-left: auto;
85
+
86
+ &:hover {
87
+ color: var(--aura-text);
88
+ background: rgba(0, 0, 0, 0.06);
89
+ transform: scale(1.1);
90
+ }
91
+
92
+ &:active {
93
+ transform: scale(0.95);
94
+ }
95
+ }
96
+
97
+ // 成功
98
+ &&-success {
99
+ background: var(--aura-success-light);
100
+ border-color: var(--aura-success);
101
+ .aura-alert-icon {
102
+ color: var(--aura-success);
103
+ }
104
+ }
105
+
106
+ // 警告
107
+ &&-warning {
108
+ background: var(--aura-warning-light);
109
+ border-color: var(--aura-warning);
110
+ .aura-alert-icon {
111
+ color: var(--aura-warning);
112
+ }
113
+ }
114
+
115
+ // 错误
116
+ &&-error {
117
+ background: var(--aura-error-light);
118
+ border-color: var(--aura-error);
119
+ .aura-alert-icon {
120
+ color: var(--aura-error);
121
+ }
122
+ }
123
+
124
+ // 信息
125
+ &&-info {
126
+ background: var(--aura-info-light);
127
+ border-color: var(--aura-info);
128
+ .aura-alert-icon {
129
+ color: var(--aura-info);
130
+ }
131
+ }
132
+ }
133
+
134
+ @keyframes aura-slide-down {
135
+ from {
136
+ opacity: 0;
137
+ transform: translateY(-12px);
138
+ }
139
+ to {
140
+ opacity: 1;
141
+ transform: translateY(0);
142
+ }
143
+ }
144
+
145
+ @keyframes aura-icon-pop {
146
+ from {
147
+ opacity: 0;
148
+ transform: scale(0.5);
149
+ }
150
+ to {
151
+ opacity: 1;
152
+ transform: scale(1);
153
+ }
154
+ }
155
+
156
+ // 暗色模式
157
+ [data-theme='dark'] {
158
+ .aura-alert {
159
+ color: var(--aura-text);
160
+ &-close:hover {
161
+ background: rgba(255, 255, 255, 0.08);
162
+ }
163
+ }
164
+ }
165
+
166
+ /* ===== 通栏模式 ===== */
167
+ .aura-alert-banner {
168
+ border-radius: 0;
169
+ border: none;
170
+ border-bottom: 1px solid var(--aura-border);
171
+ text-align: center;
172
+ }
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ export interface AvatarProps {
3
+ /** 头像尺寸
4
+ * @default 'md'
5
+ */
6
+ size?: 'sm' | 'md' | 'lg' | number;
7
+ /** 头像形状
8
+ * @default 'circle'
9
+ */
10
+ shape?: 'circle' | 'square';
11
+ /** 图片地址 */
12
+ src?: string;
13
+ /** 图片 alt 文本 */
14
+ alt?: string;
15
+ /** 头像变体
16
+ * @default 'default'
17
+ */
18
+ variant?: 'default' | 'primary';
19
+ /** 自定义类名 */
20
+ className?: string;
21
+ /** 自定义样式 */
22
+ style?: React.CSSProperties;
23
+ /** 子元素(图片加载失败或无 src 时显示) */
24
+ children?: React.ReactNode;
25
+ }
26
+ export declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>;
27
+ export interface AvatarGroupProps {
28
+ /** 最大显示数量,超出以 +N 显示 */
29
+ maxCount?: number;
30
+ /** 头像组尺寸 */
31
+ size?: 'sm' | 'md' | 'lg' | number;
32
+ /** 头像组形状 */
33
+ shape?: 'circle' | 'square';
34
+ /** 自定义类名 */
35
+ className?: string;
36
+ /** 自定义样式 */
37
+ style?: React.CSSProperties;
38
+ /** 子元素 */
39
+ children?: React.ReactNode;
40
+ }
41
+ export declare const AvatarGroup: React.FC<AvatarGroupProps>;
@@ -0,0 +1,117 @@
1
+ import React, { forwardRef, useState, useCallback, useRef } from 'react';
2
+ import { classNames, prefixCls } from '@aura-react-comp/shared';
3
+ import "./index.less";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ /** 获取首字母 */
7
+ function getInitial(children) {
8
+ if (typeof children === 'string') {
9
+ return children.charAt(0).toUpperCase();
10
+ }
11
+ if (typeof children === 'number') {
12
+ return String(children).charAt(0);
13
+ }
14
+ return '?';
15
+ }
16
+
17
+ /** 尺寸映射 */
18
+ const sizeMap = {
19
+ sm: 24,
20
+ md: 32,
21
+ lg: 40
22
+ };
23
+ export const Avatar = /*#__PURE__*/forwardRef(({
24
+ size = 'md',
25
+ shape = 'circle',
26
+ src,
27
+ alt,
28
+ variant = 'default',
29
+ className,
30
+ style,
31
+ children
32
+ }, ref) => {
33
+ const [imgFailed, setImgFailed] = useState(false);
34
+ const prevSrcRef = useRef(src);
35
+
36
+ // src 变化时重置失败状态
37
+ if (prevSrcRef.current !== src) {
38
+ setImgFailed(false);
39
+ prevSrcRef.current = src;
40
+ }
41
+ const handleError = useCallback(() => {
42
+ setImgFailed(true);
43
+ }, []);
44
+ const pixelSize = typeof size === 'number' ? size : sizeMap[size] ?? 32;
45
+ const customStyle = {
46
+ width: pixelSize,
47
+ height: pixelSize,
48
+ fontSize: Math.max(Math.round(pixelSize * 0.4), 12),
49
+ lineHeight: `${pixelSize}px`,
50
+ ...style
51
+ };
52
+ const showImage = src && !imgFailed;
53
+ const cls = classNames(prefixCls('avatar'), prefixCls(`avatar-${shape}`), variant !== 'default' && prefixCls(`avatar-${variant}`), imgFailed && prefixCls('avatar-img-failed'), className);
54
+ return /*#__PURE__*/_jsx("span", {
55
+ ref: ref,
56
+ className: cls,
57
+ style: customStyle,
58
+ role: showImage ? 'img' : undefined,
59
+ "aria-label": alt || (typeof children === 'string' ? children : undefined),
60
+ children: showImage ? /*#__PURE__*/_jsx("img", {
61
+ className: prefixCls('avatar-img'),
62
+ src: src,
63
+ alt: alt || '',
64
+ onError: handleError
65
+ }) : /*#__PURE__*/_jsx("span", {
66
+ className: prefixCls('avatar-text'),
67
+ children: children ?? getInitial(children)
68
+ })
69
+ });
70
+ });
71
+ Avatar.displayName = 'Avatar';
72
+
73
+ /* ===== Avatar.Group(头像组) ===== */
74
+
75
+ export const AvatarGroup = ({
76
+ maxCount,
77
+ size,
78
+ shape,
79
+ className,
80
+ style,
81
+ children
82
+ }) => {
83
+ const cls = classNames(prefixCls('avatar-group'), className);
84
+ const childArray = React.Children.toArray(children);
85
+ const displayChildren = maxCount ? childArray.slice(0, maxCount) : childArray;
86
+ const remainingCount = maxCount ? Math.max(childArray.length - maxCount, 0) : 0;
87
+
88
+ /** 尺寸映射(用于溢出指示器的字体大小) */
89
+ const pixelSize = typeof size === 'number' ? size : sizeMap[size ?? 'md'] ?? 32;
90
+ return /*#__PURE__*/_jsxs("div", {
91
+ className: cls,
92
+ style: style,
93
+ children: [displayChildren.map((child, index) => {
94
+ if ( /*#__PURE__*/React.isValidElement(child)) {
95
+ return /*#__PURE__*/React.cloneElement(child, {
96
+ size: child.props.size ?? size,
97
+ shape: child.props.shape ?? shape,
98
+ style: {
99
+ ...child.props.style,
100
+ zIndex: displayChildren.length - index
101
+ }
102
+ });
103
+ }
104
+ return child;
105
+ }), remainingCount > 0 && /*#__PURE__*/_jsxs("span", {
106
+ className: classNames(prefixCls('avatar'), prefixCls('avatar-circle'), prefixCls('avatar-group-overflow')),
107
+ style: {
108
+ width: pixelSize,
109
+ height: pixelSize,
110
+ fontSize: Math.max(Math.round(pixelSize * 0.35), 12),
111
+ lineHeight: `${pixelSize}px`
112
+ },
113
+ children: ["+", remainingCount]
114
+ })]
115
+ });
116
+ };
117
+ AvatarGroup.displayName = 'AvatarGroup';
@@ -0,0 +1,163 @@
1
+ .aura-avatar {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ overflow: hidden;
6
+ white-space: nowrap;
7
+ text-align: center;
8
+ vertical-align: middle;
9
+ background: var(--aura-bg-tertiary);
10
+ color: var(--aura-text-secondary);
11
+ font-weight: 500;
12
+ user-select: none;
13
+ position: relative;
14
+ box-sizing: border-box;
15
+ transition:
16
+ transform var(--aura-duration-normal) cubic-bezier(0.34, 1.56, 0.64, 1),
17
+ box-shadow var(--aura-duration-normal) var(--aura-easing),
18
+ z-index 0s;
19
+
20
+ &:hover {
21
+ transform: translateY(-3px);
22
+ z-index: 10;
23
+ box-shadow: var(--aura-shadow-md);
24
+ }
25
+
26
+ // 图片
27
+ &-img {
28
+ width: 100%;
29
+ height: 100%;
30
+ object-fit: cover;
31
+ display: block;
32
+ }
33
+
34
+ // 文字回退
35
+ &-text {
36
+ display: flex;
37
+ align-items: center;
38
+ justify-content: center;
39
+ width: 100%;
40
+ height: 100%;
41
+ transform: scale(1);
42
+ transition: transform var(--aura-duration-normal)
43
+ cubic-bezier(0.34, 1.56, 0.64, 1);
44
+ }
45
+
46
+ // 加载失败
47
+ &&-img-failed {
48
+ background: var(--aura-error-light);
49
+ color: var(--aura-error);
50
+ }
51
+
52
+ // ===== 形状 =====
53
+ &&-circle {
54
+ border-radius: var(--aura-radius-full);
55
+ }
56
+
57
+ &&-square {
58
+ border-radius: var(--aura-radius-sm);
59
+ }
60
+
61
+ // ===== 变体 =====
62
+ &&-primary {
63
+ background: var(--aura-primary-100);
64
+ color: var(--aura-primary-700);
65
+
66
+ &:hover {
67
+ box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
68
+ }
69
+ }
70
+
71
+ // 默认尺寸由 inline style 控制,此处提供基础样式
72
+ }
73
+
74
+ /* ===== Avatar.Group ===== */
75
+ .aura-avatar-group {
76
+ display: inline-flex;
77
+ align-items: center;
78
+
79
+ .aura-avatar {
80
+ border: 2px solid var(--aura-bg);
81
+ box-sizing: content-box;
82
+ margin-left: -8px;
83
+ transition:
84
+ transform var(--aura-duration-normal) cubic-bezier(0.34, 1.56, 0.64, 1),
85
+ box-shadow var(--aura-duration-normal) var(--aura-easing),
86
+ margin var(--aura-duration-normal) var(--aura-easing);
87
+
88
+ &:first-child {
89
+ margin-left: 0;
90
+ }
91
+
92
+ &:hover {
93
+ transform: translateY(-3px);
94
+ z-index: 10;
95
+ box-shadow: var(--shadow-md, var(--aura-shadow-md));
96
+ margin-left: 0;
97
+ margin-right: 4px;
98
+ }
99
+ }
100
+
101
+ // 溢出指示器
102
+ .aura-avatar-group-overflow {
103
+ background: var(--aura-bg-tertiary);
104
+ color: var(--aura-text-secondary);
105
+ font-weight: 600;
106
+ border: 2px solid var(--aura-bg);
107
+ box-sizing: content-box;
108
+ cursor: default;
109
+
110
+ &:hover {
111
+ transform: translateY(-3px);
112
+ background: var(--aura-gray-200, #e5e7eb);
113
+ }
114
+ }
115
+ }
116
+
117
+ // 入场动画
118
+ @keyframes aura-avatar-enter {
119
+ from {
120
+ opacity: 0;
121
+ transform: scale(0.5);
122
+ }
123
+ to {
124
+ opacity: 1;
125
+ transform: scale(1);
126
+ }
127
+ }
128
+
129
+ // 暗色模式
130
+ [data-theme='dark'] {
131
+ .aura-avatar {
132
+ background: var(--aura-bg-tertiary);
133
+ color: var(--aura-text-secondary);
134
+
135
+ &&-primary {
136
+ background: rgba(124, 58, 237, 0.15);
137
+ color: var(--aura-primary-400);
138
+
139
+ &:hover {
140
+ box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
141
+ }
142
+ }
143
+
144
+ &&-img-failed {
145
+ background: rgba(239, 68, 68, 0.15);
146
+ color: var(--aura-error);
147
+ }
148
+ }
149
+
150
+ .aura-avatar-group {
151
+ .aura-avatar {
152
+ border-color: var(--aura-bg);
153
+ }
154
+
155
+ .aura-avatar-group-overflow {
156
+ border-color: var(--aura-bg);
157
+
158
+ &:hover {
159
+ background: var(--aura-bg-tertiary);
160
+ }
161
+ }
162
+ }
163
+ }