@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.
- package/LICENSE +21 -0
- package/README.md +67 -2
- package/esm/alert/index.d.ts +28 -0
- package/esm/alert/index.js +76 -0
- package/esm/alert/index.less +172 -0
- package/esm/avatar/index.d.ts +41 -0
- package/esm/avatar/index.js +117 -0
- package/esm/avatar/index.less +163 -0
- package/esm/badge/index.d.ts +29 -0
- package/esm/badge/index.js +84 -0
- package/esm/badge/index.less +215 -0
- package/esm/breadcrumb/index.d.ts +31 -0
- package/esm/breadcrumb/index.js +91 -0
- package/esm/breadcrumb/index.less +107 -0
- package/esm/button/index.d.ts +28 -0
- package/esm/button/index.js +59 -0
- package/esm/button/index.less +191 -0
- package/esm/card/index.d.ts +67 -0
- package/esm/card/index.js +156 -0
- package/esm/card/index.less +231 -0
- package/esm/checkbox/index.d.ts +35 -0
- package/esm/checkbox/index.js +118 -0
- package/esm/checkbox/index.less +175 -0
- package/esm/collapse/index.d.ts +45 -0
- package/esm/collapse/index.js +157 -0
- package/esm/collapse/index.less +144 -0
- package/esm/divider/index.d.ts +16 -0
- package/esm/divider/index.js +37 -0
- package/esm/divider/index.less +115 -0
- package/esm/dropdown/index.d.ts +38 -0
- package/esm/dropdown/index.js +108 -0
- package/esm/dropdown/index.less +247 -0
- package/esm/empty/index.d.ts +35 -0
- package/esm/empty/index.js +87 -0
- package/esm/empty/index.less +67 -0
- package/esm/flex/index.d.ts +24 -0
- package/esm/flex/index.js +64 -0
- package/esm/flex/index.less +9 -0
- package/esm/form/index.d.ts +121 -0
- package/esm/form/index.js +443 -0
- package/esm/form/index.less +258 -0
- package/esm/global.d.ts +6 -0
- package/esm/index.d.ts +78 -0
- package/esm/index.js +41 -0
- package/esm/input/index.d.ts +51 -0
- package/esm/input/index.js +217 -0
- package/esm/input/index.less +369 -0
- package/esm/layout/index.d.ts +46 -0
- package/esm/layout/index.js +135 -0
- package/esm/layout/index.less +132 -0
- package/esm/menu/index.d.ts +91 -0
- package/esm/menu/index.js +294 -0
- package/esm/menu/index.less +340 -0
- package/esm/message/index.d.ts +33 -0
- package/esm/message/index.js +199 -0
- package/esm/message/index.less +118 -0
- package/esm/notification/index.d.ts +33 -0
- package/esm/notification/index.js +229 -0
- package/esm/notification/index.less +175 -0
- package/esm/pagination/index.d.ts +38 -0
- package/esm/pagination/index.js +182 -0
- package/esm/pagination/index.less +230 -0
- package/esm/popconfirm/index.d.ts +37 -0
- package/esm/popconfirm/index.js +115 -0
- package/esm/popconfirm/index.less +229 -0
- package/esm/radio/index.d.ts +33 -0
- package/esm/radio/index.js +122 -0
- package/esm/radio/index.less +155 -0
- package/esm/rate/index.d.ts +30 -0
- package/esm/rate/index.js +143 -0
- package/esm/rate/index.less +87 -0
- package/esm/result/index.d.ts +19 -0
- package/esm/result/index.js +69 -0
- package/esm/result/index.less +104 -0
- package/esm/scrollbar/index.d.ts +18 -0
- package/esm/scrollbar/index.js +35 -0
- package/esm/scrollbar/index.less +67 -0
- package/esm/select/index.d.ts +63 -0
- package/esm/select/index.js +358 -0
- package/esm/select/index.less +471 -0
- package/esm/slider/index.d.ts +36 -0
- package/esm/slider/index.js +255 -0
- package/esm/slider/index.less +154 -0
- package/esm/space/index.d.ts +16 -0
- package/esm/space/index.js +34 -0
- package/esm/space/index.less +34 -0
- package/esm/spin/index.d.ts +44 -0
- package/esm/spin/index.js +152 -0
- package/esm/spin/index.less +179 -0
- package/esm/steps/index.d.ts +55 -0
- package/esm/steps/index.js +165 -0
- package/esm/steps/index.less +394 -0
- package/esm/switch/index.d.ts +30 -0
- package/esm/switch/index.js +56 -0
- package/esm/switch/index.less +160 -0
- package/esm/tabs/index.d.ts +45 -0
- package/esm/tabs/index.js +170 -0
- package/esm/tabs/index.less +228 -0
- package/esm/tag/index.d.ts +52 -0
- package/esm/tag/index.js +120 -0
- package/esm/tag/index.less +227 -0
- package/esm/textarea/index.d.ts +27 -0
- package/esm/textarea/index.js +84 -0
- package/esm/textarea/index.less +226 -0
- package/esm/theme/ThemeProvider.d.ts +15 -0
- package/esm/theme/ThemeProvider.js +32 -0
- package/esm/theme/index.d.ts +2 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/tokens.css +183 -0
- package/esm/theme/useTheme.d.ts +1 -0
- package/esm/theme/useTheme.js +1 -0
- package/esm/tooltip/index.d.ts +38 -0
- package/esm/tooltip/index.js +149 -0
- package/esm/tooltip/index.less +244 -0
- package/esm/typography/index.d.ts +26 -0
- package/esm/typography/index.js +92 -0
- package/esm/typography/index.less +107 -0
- package/esm/upload/index.d.ts +68 -0
- package/esm/upload/index.js +447 -0
- package/esm/upload/index.less +376 -0
- package/esm/upload/request.d.ts +26 -0
- package/esm/upload/request.js +38 -0
- package/package.json +56 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface BadgeProps {
|
|
3
|
+
/** 状态点模式(不计数):success / processing(带光环)/ error / warning / default,
|
|
4
|
+
* 配合 `text` 展示状态说明;设置后 count / dot 等属性不生效 */
|
|
5
|
+
status?: 'success' | 'processing' | 'error' | 'warning' | 'default';
|
|
6
|
+
/** 状态点模式的说明文本 */
|
|
7
|
+
text?: React.ReactNode;
|
|
8
|
+
/** 徽标数字,0 时默认隐藏 */
|
|
9
|
+
count?: number;
|
|
10
|
+
/** 是否只显示小圆点 */
|
|
11
|
+
dot?: boolean;
|
|
12
|
+
/** 徽标变体颜色
|
|
13
|
+
* @default 'error'
|
|
14
|
+
*/
|
|
15
|
+
variant?: 'default' | 'success' | 'warning' | 'error' | 'info';
|
|
16
|
+
/** 溢出计数阈值
|
|
17
|
+
* @default 99
|
|
18
|
+
*/
|
|
19
|
+
overflowCount?: number;
|
|
20
|
+
/** 是否在 count 为 0 时显示 */
|
|
21
|
+
showZero?: boolean;
|
|
22
|
+
/** 自定义类名 */
|
|
23
|
+
className?: string;
|
|
24
|
+
/** 自定义样式 */
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
/** 包裹的子元素,有则徽标定位在右上角 */
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect, useState, 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
|
+
export const Badge = /*#__PURE__*/forwardRef(({
|
|
7
|
+
status,
|
|
8
|
+
text,
|
|
9
|
+
count = 0,
|
|
10
|
+
dot = false,
|
|
11
|
+
variant = 'error',
|
|
12
|
+
overflowCount = 99,
|
|
13
|
+
showZero = false,
|
|
14
|
+
className,
|
|
15
|
+
style,
|
|
16
|
+
children
|
|
17
|
+
}, ref) => {
|
|
18
|
+
// 用于数字变化时的缩放动画(status 模式不使用,但 hooks 不能条件调用)
|
|
19
|
+
const [animating, setAnimating] = useState(false);
|
|
20
|
+
const prevCountRef = useRef(count);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (prevCountRef.current !== count) {
|
|
23
|
+
setAnimating(true);
|
|
24
|
+
prevCountRef.current = count;
|
|
25
|
+
const timer = setTimeout(() => setAnimating(false), 400);
|
|
26
|
+
return () => clearTimeout(timer);
|
|
27
|
+
}
|
|
28
|
+
}, [count]);
|
|
29
|
+
|
|
30
|
+
// 状态点模式:不计数,仅状态圆点 + 文本
|
|
31
|
+
if (status) {
|
|
32
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
33
|
+
ref: ref,
|
|
34
|
+
className: classNames(prefixCls('badge-status'), className),
|
|
35
|
+
style: style,
|
|
36
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
37
|
+
className: classNames(prefixCls('badge-status-dot'), prefixCls(`badge-status-${status}`))
|
|
38
|
+
}), text != null && /*#__PURE__*/_jsx("span", {
|
|
39
|
+
className: prefixCls('badge-status-text'),
|
|
40
|
+
children: text
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const displayCount = count > overflowCount ? `${overflowCount}+` : String(count);
|
|
45
|
+
const showBadge = count !== 0 || showZero;
|
|
46
|
+
const badgeCls = classNames(prefixCls('badge-dot'), variant !== 'default' && prefixCls(`badge-dot-${variant}`), dot && prefixCls('badge-dot-small'), animating && prefixCls('badge-dot-animate'));
|
|
47
|
+
|
|
48
|
+
// 无子元素:独立显示
|
|
49
|
+
if (children === undefined) {
|
|
50
|
+
const wrapperCls = classNames(prefixCls('badge-standalone'), className);
|
|
51
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
52
|
+
ref: ref,
|
|
53
|
+
className: wrapperCls,
|
|
54
|
+
style: style,
|
|
55
|
+
children: [dot && showBadge && /*#__PURE__*/_jsx("span", {
|
|
56
|
+
className: badgeCls
|
|
57
|
+
}), !dot && showBadge && /*#__PURE__*/_jsx("span", {
|
|
58
|
+
className: badgeCls,
|
|
59
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
60
|
+
className: prefixCls('badge-text'),
|
|
61
|
+
children: displayCount
|
|
62
|
+
})
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 有子元素:徽标定位在右上角
|
|
68
|
+
const wrapperCls = classNames(prefixCls('badge'), className);
|
|
69
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
70
|
+
ref: ref,
|
|
71
|
+
className: wrapperCls,
|
|
72
|
+
style: style,
|
|
73
|
+
children: [children, dot && showBadge && /*#__PURE__*/_jsx("sup", {
|
|
74
|
+
className: badgeCls
|
|
75
|
+
}), !dot && showBadge && /*#__PURE__*/_jsx("sup", {
|
|
76
|
+
className: badgeCls,
|
|
77
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
78
|
+
className: prefixCls('badge-text'),
|
|
79
|
+
children: displayCount
|
|
80
|
+
})
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
Badge.displayName = 'Badge';
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
.aura-badge {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
vertical-align: middle;
|
|
5
|
+
line-height: 1;
|
|
6
|
+
|
|
7
|
+
sup&-dot {
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 0;
|
|
10
|
+
right: 0;
|
|
11
|
+
transform: translate(50%, -50%);
|
|
12
|
+
z-index: 1;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
min-width: 20px;
|
|
15
|
+
height: 20px;
|
|
16
|
+
padding: 0 6px;
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
font-size: var(--aura-font-size-xs);
|
|
21
|
+
font-family: inherit;
|
|
22
|
+
font-weight: 600;
|
|
23
|
+
line-height: 1;
|
|
24
|
+
color: var(--aura-text-inverse);
|
|
25
|
+
background: var(--aura-error);
|
|
26
|
+
border-radius: var(--aura-radius-full);
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
animation: aura-badge-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
|
|
29
|
+
box-shadow: 0 0 0 2px var(--aura-bg);
|
|
30
|
+
transition:
|
|
31
|
+
transform var(--aura-duration-normal) cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
32
|
+
background var(--aura-duration-normal) var(--aura-easing);
|
|
33
|
+
|
|
34
|
+
// 文字
|
|
35
|
+
.aura-badge-text {
|
|
36
|
+
display: inline-block;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 小圆点模式
|
|
41
|
+
sup&-dot-small {
|
|
42
|
+
min-width: unset;
|
|
43
|
+
width: 6px;
|
|
44
|
+
height: 6px;
|
|
45
|
+
padding: 0;
|
|
46
|
+
border-radius: 50%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 数字变化动画
|
|
50
|
+
sup&-dot-animate {
|
|
51
|
+
animation: aura-badge-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ===== 变体颜色 =====
|
|
55
|
+
sup&-dot-default {
|
|
56
|
+
background: var(--aura-gray-400);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
sup&-dot-success {
|
|
60
|
+
background: var(--aura-success);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
sup&-dot-warning {
|
|
64
|
+
background: var(--aura-warning);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
sup&-dot-error {
|
|
68
|
+
background: var(--aura-error);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
sup&-dot-info {
|
|
72
|
+
background: var(--aura-info);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* ===== 独立模式(无子元素) ===== */
|
|
77
|
+
.aura-badge-standalone {
|
|
78
|
+
display: inline-flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
vertical-align: middle;
|
|
81
|
+
|
|
82
|
+
.aura-badge-dot {
|
|
83
|
+
position: relative;
|
|
84
|
+
top: auto;
|
|
85
|
+
right: auto;
|
|
86
|
+
transform: none;
|
|
87
|
+
animation: aura-badge-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
|
|
88
|
+
transition:
|
|
89
|
+
transform var(--aura-duration-normal) cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
90
|
+
background var(--aura-duration-normal) var(--aura-easing);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.aura-badge-dot-small {
|
|
94
|
+
min-width: unset;
|
|
95
|
+
width: 6px;
|
|
96
|
+
height: 6px;
|
|
97
|
+
padding: 0;
|
|
98
|
+
border-radius: 50%;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.aura-badge-dot-animate {
|
|
102
|
+
animation: aura-badge-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.aura-badge-dot-default {
|
|
106
|
+
background: var(--aura-gray-400);
|
|
107
|
+
}
|
|
108
|
+
.aura-badge-dot-success {
|
|
109
|
+
background: var(--aura-success);
|
|
110
|
+
}
|
|
111
|
+
.aura-badge-dot-warning {
|
|
112
|
+
background: var(--aura-warning);
|
|
113
|
+
}
|
|
114
|
+
.aura-badge-dot-error {
|
|
115
|
+
background: var(--aura-error);
|
|
116
|
+
}
|
|
117
|
+
.aura-badge-dot-info {
|
|
118
|
+
background: var(--aura-info);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 入场动画
|
|
123
|
+
@keyframes aura-badge-enter {
|
|
124
|
+
from {
|
|
125
|
+
opacity: 0;
|
|
126
|
+
transform: translate(50%, -50%) scale(0);
|
|
127
|
+
}
|
|
128
|
+
to {
|
|
129
|
+
opacity: 1;
|
|
130
|
+
transform: translate(50%, -50%) scale(1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 数字变化缩放动画
|
|
135
|
+
@keyframes aura-badge-scale {
|
|
136
|
+
0% {
|
|
137
|
+
transform: translate(50%, -50%) scale(0.6);
|
|
138
|
+
}
|
|
139
|
+
50% {
|
|
140
|
+
transform: translate(50%, -50%) scale(1.15);
|
|
141
|
+
}
|
|
142
|
+
100% {
|
|
143
|
+
transform: translate(50%, -50%) scale(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 暗色模式
|
|
148
|
+
[data-theme='dark'] {
|
|
149
|
+
.aura-badge-dot,
|
|
150
|
+
.aura-badge-standalone .aura-badge-dot {
|
|
151
|
+
box-shadow: 0 0 0 2px var(--aura-bg);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* ===== 状态点模式 ===== */
|
|
156
|
+
.aura-badge-status {
|
|
157
|
+
display: inline-flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
gap: var(--aura-spacing-2);
|
|
160
|
+
|
|
161
|
+
&-dot {
|
|
162
|
+
position: relative;
|
|
163
|
+
width: 6px;
|
|
164
|
+
height: 6px;
|
|
165
|
+
border-radius: 50%;
|
|
166
|
+
background: var(--aura-gray-400);
|
|
167
|
+
flex-shrink: 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&-success {
|
|
171
|
+
background: var(--aura-success);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 处理中:光环扩散动画(只动 opacity / transform)
|
|
175
|
+
&-processing {
|
|
176
|
+
background: var(--aura-primary-600);
|
|
177
|
+
|
|
178
|
+
&::after {
|
|
179
|
+
content: '';
|
|
180
|
+
position: absolute;
|
|
181
|
+
inset: 0;
|
|
182
|
+
border-radius: 50%;
|
|
183
|
+
background: var(--aura-primary-600);
|
|
184
|
+
animation: aura-badge-status-pulse 1.6s var(--aura-easing) infinite;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&-error {
|
|
189
|
+
background: var(--aura-error);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&-warning {
|
|
193
|
+
background: var(--aura-warning);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&-text {
|
|
197
|
+
color: var(--aura-text);
|
|
198
|
+
font-size: var(--aura-font-size-sm);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@keyframes aura-badge-status-pulse {
|
|
203
|
+
0% {
|
|
204
|
+
opacity: 0.6;
|
|
205
|
+
transform: scale(1);
|
|
206
|
+
}
|
|
207
|
+
70% {
|
|
208
|
+
opacity: 0;
|
|
209
|
+
transform: scale(2.4);
|
|
210
|
+
}
|
|
211
|
+
100% {
|
|
212
|
+
opacity: 0;
|
|
213
|
+
transform: scale(2.4);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface BreadcrumbItemProps {
|
|
3
|
+
/** 链接地址 */
|
|
4
|
+
href?: string;
|
|
5
|
+
/** 点击回调 */
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
/** 自定义类名 */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** 自定义样式 */
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
/** 子元素 */
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
declare const BreadcrumbItem: React.ForwardRefExoticComponent<BreadcrumbItemProps & React.RefAttributes<HTMLSpanElement>>;
|
|
15
|
+
export interface BreadcrumbProps {
|
|
16
|
+
/** 分隔符
|
|
17
|
+
* @default '/'
|
|
18
|
+
*/
|
|
19
|
+
separator?: React.ReactNode;
|
|
20
|
+
/** 自定义类名 */
|
|
21
|
+
className?: string;
|
|
22
|
+
/** 自定义样式 */
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
/** 子元素 */
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
interface BreadcrumbComponent extends React.ForwardRefExoticComponent<BreadcrumbProps & React.RefAttributes<HTMLElement>> {
|
|
28
|
+
Item: typeof BreadcrumbItem;
|
|
29
|
+
}
|
|
30
|
+
declare const Breadcrumb: BreadcrumbComponent;
|
|
31
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { forwardRef, createContext } from 'react';
|
|
2
|
+
import { classNames, prefixCls } from '@aura-react-comp/shared';
|
|
3
|
+
import "./index.less";
|
|
4
|
+
|
|
5
|
+
/* ===== Context ===== */
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const BreadcrumbContext = /*#__PURE__*/createContext(null);
|
|
9
|
+
|
|
10
|
+
/* ===== Breadcrumb.Item ===== */
|
|
11
|
+
|
|
12
|
+
const BreadcrumbItem = /*#__PURE__*/forwardRef(({
|
|
13
|
+
href,
|
|
14
|
+
onClick,
|
|
15
|
+
className,
|
|
16
|
+
style,
|
|
17
|
+
children
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const itemCls = classNames(prefixCls('breadcrumb-item'), className);
|
|
20
|
+
return /*#__PURE__*/_jsx("li", {
|
|
21
|
+
ref: ref,
|
|
22
|
+
className: prefixCls('breadcrumb-item-wrapper'),
|
|
23
|
+
children: href ? /*#__PURE__*/_jsx("a", {
|
|
24
|
+
href: href,
|
|
25
|
+
className: itemCls,
|
|
26
|
+
style: style,
|
|
27
|
+
onClick: onClick,
|
|
28
|
+
role: "link",
|
|
29
|
+
children: children
|
|
30
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
31
|
+
className: itemCls,
|
|
32
|
+
style: style,
|
|
33
|
+
onClick: onClick,
|
|
34
|
+
role: onClick ? 'button' : undefined,
|
|
35
|
+
tabIndex: onClick ? 0 : undefined,
|
|
36
|
+
children: children
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
BreadcrumbItem.displayName = 'Breadcrumb.Item';
|
|
41
|
+
|
|
42
|
+
/* ===== Breadcrumb(主组件) ===== */
|
|
43
|
+
|
|
44
|
+
const BreadcrumbBase = /*#__PURE__*/forwardRef(({
|
|
45
|
+
separator = '/',
|
|
46
|
+
className,
|
|
47
|
+
style,
|
|
48
|
+
children
|
|
49
|
+
}, ref) => {
|
|
50
|
+
const childArray = React.Children.toArray(children);
|
|
51
|
+
const total = childArray.length;
|
|
52
|
+
const ctxValue = {
|
|
53
|
+
isLast: index => index === total - 1,
|
|
54
|
+
total,
|
|
55
|
+
separator
|
|
56
|
+
};
|
|
57
|
+
const wrapperCls = classNames(prefixCls('breadcrumb'), className);
|
|
58
|
+
return /*#__PURE__*/_jsx(BreadcrumbContext.Provider, {
|
|
59
|
+
value: ctxValue,
|
|
60
|
+
children: /*#__PURE__*/_jsx("nav", {
|
|
61
|
+
ref: ref,
|
|
62
|
+
className: wrapperCls,
|
|
63
|
+
style: style,
|
|
64
|
+
"aria-label": "\u9762\u5305\u5C51\u5BFC\u822A",
|
|
65
|
+
role: "navigation",
|
|
66
|
+
children: /*#__PURE__*/_jsx("ol", {
|
|
67
|
+
className: prefixCls('breadcrumb-list'),
|
|
68
|
+
children: childArray.map((child, index) => {
|
|
69
|
+
const isLast = index === total - 1;
|
|
70
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
71
|
+
children: [/*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
|
|
72
|
+
...child.props,
|
|
73
|
+
className: classNames(child.props.className, isLast && prefixCls('breadcrumb-item-last'))
|
|
74
|
+
}) : child, !isLast && /*#__PURE__*/_jsx("li", {
|
|
75
|
+
className: prefixCls('breadcrumb-separator'),
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
children: separator
|
|
78
|
+
})]
|
|
79
|
+
}, index);
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
BreadcrumbBase.displayName = 'Breadcrumb';
|
|
86
|
+
|
|
87
|
+
/* ===== 复合组件导出 ===== */
|
|
88
|
+
|
|
89
|
+
const Breadcrumb = BreadcrumbBase;
|
|
90
|
+
Breadcrumb.Item = BreadcrumbItem;
|
|
91
|
+
export { Breadcrumb };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/* ===== Breadcrumb 组件样式 ===== */
|
|
2
|
+
|
|
3
|
+
.aura-breadcrumb {
|
|
4
|
+
font-size: var(--aura-font-size-md);
|
|
5
|
+
color: var(--aura-text-secondary);
|
|
6
|
+
|
|
7
|
+
&-list {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
list-style: none;
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
gap: 0;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.aura-breadcrumb-item-wrapper {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.aura-breadcrumb-item {
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
color: var(--aura-text-secondary);
|
|
27
|
+
text-decoration: none;
|
|
28
|
+
padding: var(--aura-spacing-1) 0;
|
|
29
|
+
font-size: var(--aura-font-size-md);
|
|
30
|
+
cursor: default;
|
|
31
|
+
transition: color var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
color: var(--aura-primary-700);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* 链接样式 */
|
|
38
|
+
a& {
|
|
39
|
+
color: var(--aura-text-secondary);
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
color: var(--aura-primary-700);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:active {
|
|
48
|
+
color: var(--aura-primary-800);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* 可点击的 span */
|
|
53
|
+
span&[role='button'] {
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
|
|
56
|
+
&:hover {
|
|
57
|
+
color: var(--aura-primary-700);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* 最后一项加粗 */
|
|
62
|
+
&-last {
|
|
63
|
+
font-weight: 600;
|
|
64
|
+
color: var(--aura-text);
|
|
65
|
+
cursor: default;
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
color: var(--aura-text);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.aura-breadcrumb-separator {
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
margin: 0 var(--aura-spacing-2);
|
|
77
|
+
color: var(--aura-text-tertiary);
|
|
78
|
+
user-select: none;
|
|
79
|
+
font-size: var(--aura-font-size-md);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ===== 暗色模式 ===== */
|
|
83
|
+
[data-theme='dark'] {
|
|
84
|
+
.aura-breadcrumb-item {
|
|
85
|
+
color: var(--aura-text-secondary);
|
|
86
|
+
|
|
87
|
+
&:hover {
|
|
88
|
+
color: var(--aura-primary-400);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
a&:hover {
|
|
92
|
+
color: var(--aura-primary-400);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&-last {
|
|
96
|
+
color: var(--aura-text);
|
|
97
|
+
|
|
98
|
+
&:hover {
|
|
99
|
+
color: var(--aura-text);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.aura-breadcrumb-separator {
|
|
105
|
+
color: var(--aura-text-tertiary);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { ButtonHTMLAttributes, AnchorHTMLAttributes } from 'react';
|
|
2
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
/** 按钮变体样式
|
|
4
|
+
* @default 'default'
|
|
5
|
+
*/
|
|
6
|
+
variant?: 'default' | 'primary' | 'dashed' | 'text' | 'link';
|
|
7
|
+
/** 按钮尺寸
|
|
8
|
+
* @default 'md'
|
|
9
|
+
*/
|
|
10
|
+
size?: 'sm' | 'md' | 'lg';
|
|
11
|
+
/** 是否禁用 */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** 是否加载中,显示旋转图标 */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/** 按钮图标,置于内容左侧;loading 时自动替换为旋转图标 */
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
/** 是否撑满容器宽度
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
block?: boolean;
|
|
21
|
+
/** 传入后渲染为 `<a>` 链接按钮(配合 target 使用) */
|
|
22
|
+
href?: string;
|
|
23
|
+
/** 链接按钮的打开方式,仅在设置 href 时生效 */
|
|
24
|
+
target?: AnchorHTMLAttributes<HTMLAnchorElement>['target'];
|
|
25
|
+
}
|
|
26
|
+
type ButtonElement = HTMLButtonElement | HTMLAnchorElement;
|
|
27
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<ButtonElement>>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { forwardRef } 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
|
+
export const Button = /*#__PURE__*/forwardRef(({
|
|
7
|
+
variant = 'default',
|
|
8
|
+
size = 'md',
|
|
9
|
+
disabled = false,
|
|
10
|
+
loading = false,
|
|
11
|
+
icon,
|
|
12
|
+
block = false,
|
|
13
|
+
href,
|
|
14
|
+
target,
|
|
15
|
+
className,
|
|
16
|
+
children,
|
|
17
|
+
onClick,
|
|
18
|
+
type,
|
|
19
|
+
...rest
|
|
20
|
+
}, ref) => {
|
|
21
|
+
const blocked = disabled || loading;
|
|
22
|
+
const cls = classNames(prefixCls('btn'), variant !== 'default' && prefixCls(`btn-${variant}`), prefixCls(`btn-${size}`), loading && prefixCls('btn-loading'), blocked && href !== undefined && prefixCls('btn-disabled'), block && prefixCls('btn-block'), className);
|
|
23
|
+
const handleClick = e => {
|
|
24
|
+
if (blocked) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
onClick?.(e);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// 图标区:loading 时旋转图标替换自定义图标(同 antd 行为)
|
|
32
|
+
const iconNode = loading ? /*#__PURE__*/_jsx("span", {
|
|
33
|
+
className: prefixCls('btn-loading-icon')
|
|
34
|
+
}) : icon;
|
|
35
|
+
|
|
36
|
+
// 链接按钮:渲染 <a>,禁用时不输出 href 且阻止点击
|
|
37
|
+
if (href !== undefined) {
|
|
38
|
+
return /*#__PURE__*/_jsxs("a", {
|
|
39
|
+
ref: ref,
|
|
40
|
+
className: cls,
|
|
41
|
+
href: blocked ? undefined : href,
|
|
42
|
+
target: target,
|
|
43
|
+
onClick: handleClick,
|
|
44
|
+
"aria-disabled": blocked || undefined,
|
|
45
|
+
...rest,
|
|
46
|
+
children: [iconNode, children]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/_jsxs("button", {
|
|
50
|
+
ref: ref,
|
|
51
|
+
className: cls,
|
|
52
|
+
type: type ?? 'button',
|
|
53
|
+
disabled: blocked,
|
|
54
|
+
onClick: handleClick,
|
|
55
|
+
...rest,
|
|
56
|
+
children: [iconNode, children]
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
Button.displayName = 'Button';
|