@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.
- 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 +162 -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 +108 -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 +141 -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 +245 -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 +257 -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 +113 -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 +180 -0
- package/esm/pagination/index.less +238 -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 +119 -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 +103 -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 +427 -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 +170 -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 +135 -0
- package/esm/tabs/index.d.ts +45 -0
- package/esm/tabs/index.js +170 -0
- package/esm/tabs/index.less +226 -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 +224 -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 +106 -0
- package/esm/upload/index.d.ts +68 -0
- package/esm/upload/index.js +447 -0
- package/esm/upload/index.less +371 -0
- package/esm/upload/request.d.ts +26 -0
- package/esm/upload/request.js +38 -0
- package/package.json +56 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* ===== Divider 分割线 ===== */
|
|
2
|
+
.aura-divider {
|
|
3
|
+
margin: 0;
|
|
4
|
+
border: none;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
|
|
7
|
+
/* 水平分割线 */
|
|
8
|
+
&&-horizontal {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
width: 100%;
|
|
12
|
+
margin: 16px 0;
|
|
13
|
+
border-bottom: 1px solid var(--aura-border);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* 垂直分割线 */
|
|
17
|
+
&&-vertical {
|
|
18
|
+
display: inline-block;
|
|
19
|
+
width: 1px;
|
|
20
|
+
height: 0.9em;
|
|
21
|
+
margin: 0 8px;
|
|
22
|
+
border-left: 1px solid var(--aura-border);
|
|
23
|
+
vertical-align: middle;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* 虚线样式 */
|
|
27
|
+
&&-dashed {
|
|
28
|
+
&.aura-divider-horizontal {
|
|
29
|
+
border-bottom-style: dashed;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.aura-divider-vertical {
|
|
33
|
+
border-left-style: dashed;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* 带文字 */
|
|
38
|
+
&&-with-text {
|
|
39
|
+
border-bottom: none;
|
|
40
|
+
|
|
41
|
+
&::before,
|
|
42
|
+
&::after {
|
|
43
|
+
content: '';
|
|
44
|
+
flex: 1;
|
|
45
|
+
border-bottom: 1px solid var(--aura-border);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&::before {
|
|
49
|
+
margin-right: 16px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&::after {
|
|
53
|
+
margin-left: 16px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* 虚线 + 带文字 */
|
|
57
|
+
&.aura-divider-dashed {
|
|
58
|
+
&::before,
|
|
59
|
+
&::after {
|
|
60
|
+
border-bottom-style: dashed;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* 文字位置 - left */
|
|
66
|
+
&&-with-text-left {
|
|
67
|
+
&::before {
|
|
68
|
+
flex: 0 0 5%;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&::after {
|
|
72
|
+
flex: 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* 文字位置 - right */
|
|
77
|
+
&&-with-text-right {
|
|
78
|
+
&::before {
|
|
79
|
+
flex: 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&::after {
|
|
83
|
+
flex: 0 0 5%;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* 文字位置 - center 是默认,不需要额外样式 */
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* 内部文字 */
|
|
91
|
+
.aura-divider-inner-text {
|
|
92
|
+
display: inline-block;
|
|
93
|
+
padding: 0 4px;
|
|
94
|
+
font-size: var(--aura-font-size-md);
|
|
95
|
+
color: var(--aura-text);
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ===== Dark mode ===== */
|
|
100
|
+
[data-theme="dark"] {
|
|
101
|
+
.aura-divider-horizontal {
|
|
102
|
+
border-bottom-color: var(--aura-border);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.aura-divider-vertical {
|
|
106
|
+
border-left-color: var(--aura-border);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.aura-divider-with-text {
|
|
110
|
+
&::before,
|
|
111
|
+
&::after {
|
|
112
|
+
border-bottom-color: var(--aura-border);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DropdownMenuItem {
|
|
3
|
+
/** 菜单项唯一标识 */
|
|
4
|
+
key: string;
|
|
5
|
+
/** 菜单项显示内容 */
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
/** 是否禁用 */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** 是否为危险操作样式 */
|
|
10
|
+
danger?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface DropdownProps {
|
|
13
|
+
/** 菜单项列表 */
|
|
14
|
+
menu: DropdownMenuItem[];
|
|
15
|
+
/** 触发方式
|
|
16
|
+
* @default 'hover'
|
|
17
|
+
*/
|
|
18
|
+
trigger?: 'hover' | 'click';
|
|
19
|
+
/** 弹出方位
|
|
20
|
+
* @default 'bottom'
|
|
21
|
+
*/
|
|
22
|
+
placement?: 'top' | 'bottom' | 'left' | 'right' | 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
|
|
23
|
+
/** 是否显示箭头
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
arrow?: boolean;
|
|
27
|
+
/** 是否禁用下拉菜单 */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** 菜单项点击回调 */
|
|
30
|
+
onMenuClick?: (key: string) => void;
|
|
31
|
+
/** 自定义类名 */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** 自定义样式 */
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
/** 触发元素(仅接受单个 ReactElement) */
|
|
36
|
+
children: React.ReactElement;
|
|
37
|
+
}
|
|
38
|
+
export declare const Dropdown: React.ForwardRefExoticComponent<DropdownProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useRef, useEffect, useCallback } 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 Dropdown = /*#__PURE__*/forwardRef(({
|
|
7
|
+
menu,
|
|
8
|
+
trigger = 'hover',
|
|
9
|
+
placement = 'bottom',
|
|
10
|
+
arrow = false,
|
|
11
|
+
disabled = false,
|
|
12
|
+
onMenuClick,
|
|
13
|
+
className,
|
|
14
|
+
style,
|
|
15
|
+
children
|
|
16
|
+
}, ref) => {
|
|
17
|
+
const [visible, setVisible] = useState(false);
|
|
18
|
+
const [animating, setAnimating] = useState(false);
|
|
19
|
+
const wrapperRef = useRef(null);
|
|
20
|
+
|
|
21
|
+
// 显示菜单
|
|
22
|
+
const show = useCallback(() => {
|
|
23
|
+
if (disabled) return;
|
|
24
|
+
setAnimating(true);
|
|
25
|
+
setVisible(true);
|
|
26
|
+
}, [disabled]);
|
|
27
|
+
|
|
28
|
+
// 隐藏菜单
|
|
29
|
+
const hide = useCallback(() => {
|
|
30
|
+
setAnimating(false);
|
|
31
|
+
setTimeout(() => setVisible(false), 150);
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
// 切换菜单
|
|
35
|
+
const toggle = useCallback(() => {
|
|
36
|
+
if (disabled) return;
|
|
37
|
+
if (visible) {
|
|
38
|
+
hide();
|
|
39
|
+
} else {
|
|
40
|
+
show();
|
|
41
|
+
}
|
|
42
|
+
}, [disabled, visible, show, hide]);
|
|
43
|
+
|
|
44
|
+
// 点击外部关闭
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!visible) return;
|
|
47
|
+
const handleClickOutside = e => {
|
|
48
|
+
if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
|
|
49
|
+
hide();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
53
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
54
|
+
}, [visible, hide]);
|
|
55
|
+
|
|
56
|
+
// 构建子元素的 props
|
|
57
|
+
const childProps = {};
|
|
58
|
+
const childOwnProps = children.props;
|
|
59
|
+
if (trigger === 'hover') {
|
|
60
|
+
childProps.onMouseEnter = e => {
|
|
61
|
+
show();
|
|
62
|
+
childOwnProps.onMouseEnter?.(e);
|
|
63
|
+
};
|
|
64
|
+
childProps.onMouseLeave = e => {
|
|
65
|
+
hide();
|
|
66
|
+
childOwnProps.onMouseLeave?.(e);
|
|
67
|
+
};
|
|
68
|
+
} else if (trigger === 'click') {
|
|
69
|
+
childProps.onClick = e => {
|
|
70
|
+
toggle();
|
|
71
|
+
childOwnProps.onClick?.(e);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 菜单项点击处理
|
|
76
|
+
const handleMenuClick = item => {
|
|
77
|
+
if (item.disabled) return;
|
|
78
|
+
onMenuClick?.(item.key);
|
|
79
|
+
hide();
|
|
80
|
+
};
|
|
81
|
+
const wrapperCls = classNames(prefixCls('dropdown'), className);
|
|
82
|
+
const menuCls = classNames(prefixCls('dropdown-menu'), prefixCls(`dropdown-menu-${placement}`), animating && prefixCls('dropdown-menu-visible'));
|
|
83
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
84
|
+
ref: ref || wrapperRef,
|
|
85
|
+
className: wrapperCls,
|
|
86
|
+
style: style,
|
|
87
|
+
children: [/*#__PURE__*/React.cloneElement(children, childProps), visible && menu.length > 0 && /*#__PURE__*/_jsxs("div", {
|
|
88
|
+
className: menuCls,
|
|
89
|
+
role: "menu",
|
|
90
|
+
"aria-label": "\u4E0B\u62C9\u83DC\u5355",
|
|
91
|
+
onMouseEnter: trigger === 'hover' ? show : undefined,
|
|
92
|
+
onMouseLeave: trigger === 'hover' ? hide : undefined,
|
|
93
|
+
children: [arrow && /*#__PURE__*/_jsx("div", {
|
|
94
|
+
className: prefixCls('dropdown-arrow')
|
|
95
|
+
}), menu.map(item => {
|
|
96
|
+
const itemCls = classNames(prefixCls('dropdown-menu-item'), item.disabled && prefixCls('dropdown-menu-item-disabled'), item.danger && prefixCls('dropdown-menu-item-danger'));
|
|
97
|
+
return /*#__PURE__*/_jsx("div", {
|
|
98
|
+
className: itemCls,
|
|
99
|
+
role: "menuitem",
|
|
100
|
+
"aria-disabled": item.disabled,
|
|
101
|
+
onClick: () => handleMenuClick(item),
|
|
102
|
+
children: item.label
|
|
103
|
+
}, item.key);
|
|
104
|
+
})]
|
|
105
|
+
})]
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
Dropdown.displayName = 'Dropdown';
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/* ===== Dropdown 组件样式 ===== */
|
|
2
|
+
|
|
3
|
+
.aura-dropdown {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.aura-dropdown-menu {
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: 1070;
|
|
11
|
+
width: max-content;
|
|
12
|
+
min-width: 160px;
|
|
13
|
+
padding: var(--aura-spacing-1) 0;
|
|
14
|
+
margin: 0;
|
|
15
|
+
border-radius: var(--aura-radius-md);
|
|
16
|
+
background: var(--aura-bg);
|
|
17
|
+
border: 1px solid var(--aura-border);
|
|
18
|
+
box-shadow: var(--aura-shadow-lg);
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transform: scaleY(0.8);
|
|
21
|
+
transform-origin: top center;
|
|
22
|
+
transition:
|
|
23
|
+
opacity var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1),
|
|
24
|
+
transform var(--aura-duration-normal) cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
25
|
+
|
|
26
|
+
// ===== 出现状态 =====
|
|
27
|
+
&&-visible {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
transform: scaleY(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ===== 方位定位 =====
|
|
33
|
+
&&-bottom {
|
|
34
|
+
top: calc(100% + 12px);
|
|
35
|
+
left: 50%;
|
|
36
|
+
transform-origin: top center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&&-bottomLeft {
|
|
40
|
+
top: calc(100% + 12px);
|
|
41
|
+
left: 0;
|
|
42
|
+
transform-origin: top left;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&&-bottomRight {
|
|
46
|
+
top: calc(100% + 12px);
|
|
47
|
+
right: 0;
|
|
48
|
+
transform-origin: top right;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&&-top {
|
|
52
|
+
bottom: calc(100% + 12px);
|
|
53
|
+
left: 50%;
|
|
54
|
+
transform-origin: bottom center;
|
|
55
|
+
transform: scaleY(0.8);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&&-topLeft {
|
|
59
|
+
bottom: calc(100% + 12px);
|
|
60
|
+
left: 0;
|
|
61
|
+
transform-origin: bottom left;
|
|
62
|
+
transform: scaleY(0.8);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&&-topRight {
|
|
66
|
+
bottom: calc(100% + 12px);
|
|
67
|
+
right: 0;
|
|
68
|
+
transform-origin: bottom right;
|
|
69
|
+
transform: scaleY(0.8);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&&-left {
|
|
73
|
+
right: calc(100% + 12px);
|
|
74
|
+
top: 50%;
|
|
75
|
+
transform: translateY(-50%) scaleX(0.8);
|
|
76
|
+
transform-origin: right center;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&&-right {
|
|
80
|
+
left: calc(100% + 12px);
|
|
81
|
+
top: 50%;
|
|
82
|
+
transform: translateY(-50%) scaleX(0.8);
|
|
83
|
+
transform-origin: left center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 修正 visible 状态的 transform
|
|
87
|
+
&&-visible&&-top,
|
|
88
|
+
&&-visible&&-topLeft,
|
|
89
|
+
&&-visible&&-topRight {
|
|
90
|
+
transform: scaleY(1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&&-visible&&-bottom {
|
|
94
|
+
transform: translateX(-50%) scaleY(1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&&-visible&&-left {
|
|
98
|
+
transform: translateY(-50%) scaleX(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&&-visible&&-right {
|
|
102
|
+
transform: translateY(-50%) scaleX(1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ===== 箭头 =====
|
|
107
|
+
.aura-dropdown-arrow {
|
|
108
|
+
position: absolute;
|
|
109
|
+
width: 10px;
|
|
110
|
+
height: 10px;
|
|
111
|
+
background: var(--aura-bg);
|
|
112
|
+
border: 1px solid var(--aura-border);
|
|
113
|
+
transform: rotate(45deg);
|
|
114
|
+
z-index: 0;
|
|
115
|
+
|
|
116
|
+
// 下方弹出 → 箭头在顶部,隐藏下侧和右侧边框
|
|
117
|
+
.aura-dropdown-menu-bottom &,
|
|
118
|
+
.aura-dropdown-menu-bottomLeft &,
|
|
119
|
+
.aura-dropdown-menu-bottomRight & {
|
|
120
|
+
top: -6px;
|
|
121
|
+
border-bottom: none;
|
|
122
|
+
border-right: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.aura-dropdown-menu-bottom & {
|
|
126
|
+
left: 50%;
|
|
127
|
+
margin-left: -5px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.aura-dropdown-menu-bottomLeft & {
|
|
131
|
+
left: 16px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.aura-dropdown-menu-bottomRight & {
|
|
135
|
+
right: 16px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 上方弹出 → 箭头在底部,隐藏上侧和左侧边框
|
|
139
|
+
.aura-dropdown-menu-top &,
|
|
140
|
+
.aura-dropdown-menu-topLeft &,
|
|
141
|
+
.aura-dropdown-menu-topRight & {
|
|
142
|
+
bottom: -6px;
|
|
143
|
+
border-top: none;
|
|
144
|
+
border-left: none;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.aura-dropdown-menu-top & {
|
|
148
|
+
left: 50%;
|
|
149
|
+
margin-left: -5px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.aura-dropdown-menu-topLeft & {
|
|
153
|
+
left: 16px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.aura-dropdown-menu-topRight & {
|
|
157
|
+
right: 16px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 左侧弹出 → 箭头在右侧
|
|
161
|
+
.aura-dropdown-menu-left & {
|
|
162
|
+
right: -6px;
|
|
163
|
+
top: 50%;
|
|
164
|
+
margin-top: -5px;
|
|
165
|
+
border-top: none;
|
|
166
|
+
border-right: none;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 右侧弹出 → 箭头在左侧
|
|
170
|
+
.aura-dropdown-menu-right & {
|
|
171
|
+
left: -6px;
|
|
172
|
+
top: 50%;
|
|
173
|
+
margin-top: -5px;
|
|
174
|
+
border-bottom: none;
|
|
175
|
+
border-left: none;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ===== 菜单项 =====
|
|
180
|
+
.aura-dropdown-menu-item {
|
|
181
|
+
position: relative;
|
|
182
|
+
z-index: 1;
|
|
183
|
+
display: flex;
|
|
184
|
+
align-items: center;
|
|
185
|
+
padding: var(--aura-spacing-2) var(--aura-spacing-3);
|
|
186
|
+
font-size: var(--aura-font-size-md);
|
|
187
|
+
color: var(--aura-text);
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
transition: background var(--aura-duration-fast) var(--aura-easing);
|
|
190
|
+
white-space: nowrap;
|
|
191
|
+
|
|
192
|
+
&:hover {
|
|
193
|
+
background: var(--aura-bg-secondary);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 禁用状态
|
|
197
|
+
&&-disabled {
|
|
198
|
+
color: var(--aura-text-tertiary);
|
|
199
|
+
cursor: not-allowed;
|
|
200
|
+
opacity: 0.5;
|
|
201
|
+
|
|
202
|
+
&:hover {
|
|
203
|
+
background: transparent;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 危险操作
|
|
208
|
+
&&-danger {
|
|
209
|
+
color: var(--aura-error);
|
|
210
|
+
|
|
211
|
+
&:hover {
|
|
212
|
+
background: rgba(239, 68, 68, 0.08);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ===== 暗色模式 =====
|
|
218
|
+
[data-theme="dark"] {
|
|
219
|
+
.aura-dropdown-menu {
|
|
220
|
+
background: var(--aura-gray-800);
|
|
221
|
+
border-color: var(--aura-gray-700);
|
|
222
|
+
box-shadow: var(--aura-shadow-lg), 0 0 20px rgba(124, 58, 237, 0.1);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.aura-dropdown-arrow {
|
|
226
|
+
background: var(--aura-gray-800);
|
|
227
|
+
border-color: var(--aura-gray-700);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.aura-dropdown-menu-item {
|
|
231
|
+
color: var(--aura-gray-100);
|
|
232
|
+
|
|
233
|
+
&:hover {
|
|
234
|
+
background: var(--aura-gray-700);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
&&-danger {
|
|
238
|
+
color: #f87171;
|
|
239
|
+
|
|
240
|
+
&:hover {
|
|
241
|
+
background: rgba(239, 68, 68, 0.15);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface EmptyProps {
|
|
3
|
+
/** 描述文字
|
|
4
|
+
* @default '暂无数据'
|
|
5
|
+
*/
|
|
6
|
+
description?: React.ReactNode;
|
|
7
|
+
/** 自定义图片,传 null 则不显示 */
|
|
8
|
+
image?: React.ReactNode;
|
|
9
|
+
/** 图片样式 */
|
|
10
|
+
imageStyle?: React.CSSProperties;
|
|
11
|
+
/** 自定义类名 */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** 自定义样式 */
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
/** 附加内容(如操作按钮) */
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export interface EmptyPresetProps {
|
|
19
|
+
/** 预置类型 */
|
|
20
|
+
type: 'noData' | 'noResult' | '404';
|
|
21
|
+
/** 自定义类名 */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** 自定义样式 */
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
/** 附加内容 */
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/** 预置空状态组件 */
|
|
29
|
+
declare const EmptyPreset: React.FC<EmptyPresetProps>;
|
|
30
|
+
interface EmptyComponent extends React.ForwardRefExoticComponent<EmptyProps & React.RefAttributes<HTMLDivElement>> {
|
|
31
|
+
Preset: typeof EmptyPreset;
|
|
32
|
+
}
|
|
33
|
+
declare const Empty: EmptyComponent;
|
|
34
|
+
export { Empty };
|
|
35
|
+
export default Empty;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { classNames, prefixCls } from '@aura-react-comp/shared';
|
|
3
|
+
import { EmptyDefault, Empty404 } 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
|
+
/** 默认空状态图标 */
|
|
8
|
+
const DefaultEmptyImage = ({
|
|
9
|
+
style
|
|
10
|
+
}) => /*#__PURE__*/_jsx(EmptyDefault, {
|
|
11
|
+
size: 200,
|
|
12
|
+
className: prefixCls('empty-image-default'),
|
|
13
|
+
style: style
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/* ===== 预置空状态 ===== */
|
|
17
|
+
|
|
18
|
+
const presetConfig = {
|
|
19
|
+
noData: {
|
|
20
|
+
description: '暂无数据',
|
|
21
|
+
image: undefined // 使用默认
|
|
22
|
+
},
|
|
23
|
+
noResult: {
|
|
24
|
+
description: '未找到匹配结果',
|
|
25
|
+
image: undefined
|
|
26
|
+
},
|
|
27
|
+
404: {
|
|
28
|
+
description: '抱歉,您访问的页面不存在',
|
|
29
|
+
image: /*#__PURE__*/_jsx(Empty404, {
|
|
30
|
+
size: 200
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** 预置空状态组件 */
|
|
36
|
+
const EmptyPreset = ({
|
|
37
|
+
type,
|
|
38
|
+
className,
|
|
39
|
+
style,
|
|
40
|
+
children
|
|
41
|
+
}) => {
|
|
42
|
+
const config = presetConfig[type] ?? presetConfig.noData;
|
|
43
|
+
return /*#__PURE__*/_jsx(EmptyBase, {
|
|
44
|
+
description: config.description,
|
|
45
|
+
image: config.image,
|
|
46
|
+
className: className,
|
|
47
|
+
style: style,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
EmptyPreset.displayName = 'EmptyPreset';
|
|
52
|
+
|
|
53
|
+
/* ===== Empty 主组件 ===== */
|
|
54
|
+
const EmptyBase = /*#__PURE__*/forwardRef(({
|
|
55
|
+
description = '暂无数据',
|
|
56
|
+
image,
|
|
57
|
+
imageStyle,
|
|
58
|
+
className,
|
|
59
|
+
style,
|
|
60
|
+
children
|
|
61
|
+
}, ref) => {
|
|
62
|
+
const cls = classNames(prefixCls('empty'), className);
|
|
63
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
64
|
+
ref: ref,
|
|
65
|
+
className: cls,
|
|
66
|
+
style: style,
|
|
67
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
68
|
+
className: prefixCls('empty-image'),
|
|
69
|
+
style: imageStyle,
|
|
70
|
+
children: image !== undefined ? image : /*#__PURE__*/_jsx(DefaultEmptyImage, {})
|
|
71
|
+
}), description && /*#__PURE__*/_jsx("div", {
|
|
72
|
+
className: prefixCls('empty-description'),
|
|
73
|
+
children: description
|
|
74
|
+
}), children && /*#__PURE__*/_jsx("div", {
|
|
75
|
+
className: prefixCls('empty-footer'),
|
|
76
|
+
children: children
|
|
77
|
+
})]
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
EmptyBase.displayName = 'Empty';
|
|
81
|
+
|
|
82
|
+
// 子组件挂载
|
|
83
|
+
|
|
84
|
+
const Empty = EmptyBase;
|
|
85
|
+
Empty.Preset = EmptyPreset;
|
|
86
|
+
export { Empty };
|
|
87
|
+
export default Empty;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
.aura-empty {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
padding: var(--aura-spacing-8) var(--aura-spacing-4);
|
|
7
|
+
text-align: center;
|
|
8
|
+
animation: aura-empty-fade-in var(--aura-duration-slow) var(--aura-easing);
|
|
9
|
+
|
|
10
|
+
/* ===== 图片区域 ===== */
|
|
11
|
+
&-image {
|
|
12
|
+
margin-bottom: var(--aura-spacing-4);
|
|
13
|
+
|
|
14
|
+
&-default {
|
|
15
|
+
opacity: 0.7;
|
|
16
|
+
transition: opacity var(--aura-duration-normal) var(--aura-easing);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* 允许外部传入图片自适应 */
|
|
20
|
+
img,
|
|
21
|
+
svg {
|
|
22
|
+
max-width: 200px;
|
|
23
|
+
height: auto;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:hover &-image-default {
|
|
28
|
+
opacity: 0.9;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ===== 描述文字 ===== */
|
|
32
|
+
&-description {
|
|
33
|
+
font-size: var(--aura-font-size-md);
|
|
34
|
+
color: var(--aura-text-secondary);
|
|
35
|
+
line-height: 1.6;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ===== 附加内容(如操作按钮) ===== */
|
|
39
|
+
&-footer {
|
|
40
|
+
margin-top: var(--aura-spacing-3);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ===== 动画关键帧 ===== */
|
|
45
|
+
@keyframes aura-empty-fade-in {
|
|
46
|
+
from {
|
|
47
|
+
opacity: 0;
|
|
48
|
+
transform: translateY(8px);
|
|
49
|
+
}
|
|
50
|
+
to {
|
|
51
|
+
opacity: 1;
|
|
52
|
+
transform: translateY(0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* ===== 暗色模式 ===== */
|
|
57
|
+
[data-theme="dark"] {
|
|
58
|
+
.aura-empty {
|
|
59
|
+
&-image-default {
|
|
60
|
+
opacity: 0.5;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:hover &-image-default {
|
|
64
|
+
opacity: 0.7;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|