@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,122 @@
1
+ import React, { forwardRef, createContext, useContext, useState } from 'react';
2
+ import { classNames, prefixCls } from '@aura-react-comp/shared';
3
+ import "./index.less";
4
+
5
+ /* ===== Radio Context(用于 Radio.Group) ===== */
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ const RadioGroupContext = /*#__PURE__*/createContext(null);
9
+
10
+ /* ===== Radio ===== */
11
+
12
+ export const Radio = /*#__PURE__*/forwardRef(({
13
+ size,
14
+ disabled,
15
+ checked: controlledChecked,
16
+ onChange: controlledOnChange,
17
+ className,
18
+ children,
19
+ value,
20
+ ...rest
21
+ }, ref) => {
22
+ // 尝试从 Group context 获取
23
+ const groupCtx = useContext(RadioGroupContext);
24
+ const isDisabled = disabled ?? groupCtx?.disabled;
25
+ const resolvedSize = size ?? groupCtx?.size ?? 'md';
26
+
27
+ // 受控:group > 单独 controlled > 非受控
28
+ let isChecked;
29
+ let handleChange;
30
+ if (groupCtx) {
31
+ // Group 模式
32
+ const val = value;
33
+ isChecked = groupCtx.value === val;
34
+ handleChange = () => {
35
+ groupCtx.onChange(val);
36
+ };
37
+ } else {
38
+ // 单独 Radio 模式
39
+ isChecked = !!controlledChecked;
40
+ handleChange = controlledOnChange;
41
+ }
42
+ const cls = classNames(prefixCls('radio'), prefixCls(`radio-${resolvedSize}`), isChecked && prefixCls('radio-checked'), isDisabled && prefixCls('radio-disabled'), className);
43
+
44
+ // 在 Group 模式下,通过 label onClick 确保点击已选中项也能触发回调
45
+ // 因为 React 受控 radio 在 checked=true 时不会触发 input 的 onChange
46
+ const handleLabelClick = groupCtx ? () => {
47
+ if (!isDisabled) {
48
+ groupCtx.onChange(value);
49
+ }
50
+ } : undefined;
51
+ return /*#__PURE__*/_jsxs("label", {
52
+ className: cls,
53
+ onClick: handleLabelClick,
54
+ children: [/*#__PURE__*/_jsxs("span", {
55
+ className: prefixCls('radio-input-wrapper'),
56
+ children: [/*#__PURE__*/_jsx("input", {
57
+ ref: ref,
58
+ type: "radio",
59
+ className: prefixCls('radio-input'),
60
+ checked: isChecked,
61
+ disabled: isDisabled,
62
+ onChange: handleChange,
63
+ value: value,
64
+ onClick: e => {
65
+ // 阻止 input 的默认 click 事件冒泡到 label 的 onClick,
66
+ // 避免 Group 模式下重复触发
67
+ if (groupCtx) {
68
+ e.stopPropagation();
69
+ }
70
+ },
71
+ ...rest
72
+ }), /*#__PURE__*/_jsx("span", {
73
+ className: prefixCls('radio-inner')
74
+ })]
75
+ }), children !== undefined && /*#__PURE__*/_jsx("span", {
76
+ className: prefixCls('radio-label'),
77
+ children: children
78
+ })]
79
+ });
80
+ });
81
+ Radio.displayName = 'Radio';
82
+
83
+ /* ===== Radio.Group ===== */
84
+
85
+ export const RadioGroup = ({
86
+ value: controlledValue,
87
+ defaultValue,
88
+ options,
89
+ onChange,
90
+ direction = 'horizontal',
91
+ disabled = false,
92
+ size,
93
+ className
94
+ }) => {
95
+ const [internalValue, setInternalValue] = useState(defaultValue ?? '');
96
+ const currentValue = controlledValue ?? internalValue;
97
+ const handleChange = nextValue => {
98
+ if (controlledValue === undefined) {
99
+ setInternalValue(nextValue);
100
+ }
101
+ onChange?.(nextValue);
102
+ };
103
+ const ctx = {
104
+ value: currentValue,
105
+ onChange: handleChange,
106
+ disabled,
107
+ size
108
+ };
109
+ const cls = classNames(prefixCls('radio-group'), prefixCls(`radio-group-${direction}`), className);
110
+ return /*#__PURE__*/_jsx(RadioGroupContext.Provider, {
111
+ value: ctx,
112
+ children: /*#__PURE__*/_jsx("div", {
113
+ className: cls,
114
+ children: options.map(opt => /*#__PURE__*/_jsx(Radio, {
115
+ value: opt.value,
116
+ disabled: opt.disabled,
117
+ children: opt.label
118
+ }, opt.value))
119
+ })
120
+ });
121
+ };
122
+ RadioGroup.displayName = 'RadioGroup';
@@ -0,0 +1,119 @@
1
+ .aura-radio {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: var(--aura-spacing-2);
5
+ cursor: pointer;
6
+ user-select: none;
7
+ font-size: var(--aura-font-size-md);
8
+ color: var(--aura-text);
9
+ line-height: 1.5;
10
+
11
+ // 隐藏原生 input
12
+ &-input {
13
+ position: absolute;
14
+ width: 0;
15
+ height: 0;
16
+ opacity: 0;
17
+ margin: 0;
18
+ padding: 0;
19
+ }
20
+
21
+ &-input-wrapper {
22
+ position: relative;
23
+ display: inline-flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ }
27
+
28
+ // 自定义 radio 外观
29
+ &-inner {
30
+ display: inline-block;
31
+ width: 16px;
32
+ height: 16px;
33
+ border: 1.5px solid var(--aura-border);
34
+ border-radius: var(--aura-radius-full);
35
+ background: var(--aura-bg);
36
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
37
+ position: relative;
38
+ flex-shrink: 0;
39
+
40
+ // 选中状态的紫色圆点
41
+ &::after {
42
+ content: '';
43
+ position: absolute;
44
+ display: block;
45
+ top: 50%;
46
+ left: 50%;
47
+ width: 8px;
48
+ height: 8px;
49
+ background: var(--aura-primary-700);
50
+ border-radius: var(--aura-radius-full);
51
+ transform: translate(-50%, -50%) scale(0);
52
+ transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
53
+ opacity: 0;
54
+ }
55
+ }
56
+
57
+ // 选中状态
58
+ &&-checked {
59
+ .aura-radio-inner {
60
+ border-color: var(--aura-primary-700);
61
+
62
+ &::after {
63
+ transform: translate(-50%, -50%) scale(1);
64
+ opacity: 1;
65
+ }
66
+ }
67
+ }
68
+
69
+ // hover
70
+ &:hover .aura-radio-inner {
71
+ border-color: var(--aura-primary-700);
72
+ box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
73
+ }
74
+
75
+ // focus
76
+ &-input:focus-visible + .aura-radio-inner {
77
+ box-shadow: 0 0 0 2px var(--aura-primary-200);
78
+ }
79
+
80
+ // 禁用状态
81
+ &&-disabled {
82
+ opacity: 0.5;
83
+ cursor: not-allowed;
84
+ &:hover .aura-radio-inner { border-color: var(--aura-border); box-shadow: none; }
85
+ &.aura-radio-checked .aura-radio-inner { border-color: var(--aura-border); }
86
+ .aura-radio-inner::after { background: var(--aura-text-tertiary); }
87
+ }
88
+
89
+ // 标签文本
90
+ &-label { font-size: inherit; line-height: inherit; }
91
+
92
+ // 尺寸
93
+ &&-sm {
94
+ font-size: var(--aura-font-size-sm);
95
+ .aura-radio-inner { width: 14px; height: 14px; &::after { width: 6px; height: 6px; } }
96
+ }
97
+
98
+ &&-lg {
99
+ font-size: var(--aura-font-size-lg);
100
+ .aura-radio-inner { width: 18px; height: 18px; &::after { width: 10px; height: 10px; } }
101
+ }
102
+ }
103
+
104
+ /* ===== Radio.Group ===== */
105
+ .aura-radio-group {
106
+ display: flex;
107
+ gap: var(--aura-spacing-3);
108
+ &&-horizontal { flex-direction: row; flex-wrap: wrap; align-items: center; }
109
+ &&-vertical { flex-direction: column; }
110
+ }
111
+
112
+ // 暗色模式
113
+ [data-theme="dark"] {
114
+ .aura-radio {
115
+ &-inner { border-color: rgba(139, 92, 246, 0.3); }
116
+ &:hover .aura-radio-inner { border-color: var(--aura-primary-600); }
117
+ &-input:focus-visible + .aura-radio-inner { box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2); }
118
+ }
119
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ export interface RateProps {
3
+ /** 星星数量
4
+ * @default 5
5
+ */
6
+ count?: number;
7
+ /** 当前值(受控) */
8
+ value?: number;
9
+ /** 默认值(非受控)
10
+ * @default 0
11
+ */
12
+ defaultValue?: number;
13
+ /** 是否允许半星 */
14
+ allowHalf?: boolean;
15
+ /** 是否允许清除(再次点击当前值清零) */
16
+ allowClear?: boolean;
17
+ /** 是否禁用 */
18
+ disabled?: boolean;
19
+ /** 星星大小
20
+ * @default 'md'
21
+ */
22
+ size?: 'sm' | 'md' | 'lg';
23
+ /** 值变化回调 */
24
+ onChange?: (value: number) => void;
25
+ /** 自定义类名 */
26
+ className?: string;
27
+ /** 自定义样式 */
28
+ style?: React.CSSProperties;
29
+ }
30
+ export declare const Rate: React.ForwardRefExoticComponent<RateProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,143 @@
1
+ import React, { forwardRef, useState, useCallback, useRef } from 'react';
2
+ import { classNames, prefixCls } from '@aura-react-comp/shared';
3
+ import { StarFilled, StarEmpty, StarHalf } from '@aura-react-comp/icons';
4
+ import "./index.less";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ /** 星星图标组件 */
7
+ const StarIcon = ({
8
+ filled,
9
+ half
10
+ }) => {
11
+ if (filled && !half) return /*#__PURE__*/_jsx(StarFilled, {
12
+ size: 24
13
+ });
14
+ if (half) return /*#__PURE__*/_jsx(StarHalf, {
15
+ size: 24,
16
+ half: half
17
+ });
18
+ return /*#__PURE__*/_jsx(StarEmpty, {
19
+ size: 24
20
+ });
21
+ };
22
+ export const Rate = /*#__PURE__*/forwardRef(({
23
+ count = 5,
24
+ value: controlledValue,
25
+ defaultValue = 0,
26
+ allowHalf = false,
27
+ allowClear = false,
28
+ disabled = false,
29
+ size = 'md',
30
+ onChange,
31
+ className,
32
+ style
33
+ }, ref) => {
34
+ // 内部维护的值(非受控模式)
35
+ const [internalValue, setInternalValue] = useState(defaultValue);
36
+ // hover 预览值
37
+ const [hoverValue, setHoverValue] = useState(null);
38
+
39
+ // 当前生效的值
40
+ const currentValue = controlledValue ?? internalValue;
41
+ // 显示值(优先 hover)
42
+ const displayValue = hoverValue ?? currentValue;
43
+
44
+ // 单个星星容器引用,用于判断半星区域
45
+ const starRefs = useRef([]);
46
+
47
+ // 根据鼠标位置计算星级值
48
+ const getValueFromEvent = useCallback((e, index) => {
49
+ if (!allowHalf || !starRefs.current[index]) {
50
+ return index + 1;
51
+ }
52
+ const rect = starRefs.current[index].getBoundingClientRect();
53
+ const isLeftHalf = e.clientX - rect.left < rect.width / 2;
54
+ return isLeftHalf ? index + 0.5 : index + 1;
55
+ }, [allowHalf]);
56
+
57
+ // 鼠标移入
58
+ const handleMouseMove = useCallback((e, index) => {
59
+ if (disabled) return;
60
+ setHoverValue(getValueFromEvent(e, index));
61
+ }, [disabled, getValueFromEvent]);
62
+
63
+ // 鼠标移出
64
+ const handleMouseLeave = useCallback(() => {
65
+ if (disabled) return;
66
+ setHoverValue(null);
67
+ }, [disabled]);
68
+
69
+ // 点击选择
70
+ const handleClick = useCallback((e, index) => {
71
+ if (disabled) return;
72
+ const newValue = getValueFromEvent(e, index);
73
+
74
+ // allowClear: 再次点击当前值清零
75
+ if (allowClear && newValue === currentValue) {
76
+ if (controlledValue === undefined) {
77
+ setInternalValue(0);
78
+ }
79
+ onChange?.(0);
80
+ return;
81
+ }
82
+ if (controlledValue === undefined) {
83
+ setInternalValue(newValue);
84
+ }
85
+ onChange?.(newValue);
86
+ }, [disabled, getValueFromEvent, allowClear, currentValue, controlledValue, onChange]);
87
+ const cls = classNames(prefixCls('rate'), prefixCls(`rate-${size}`), disabled && prefixCls('rate-disabled'), className);
88
+
89
+ // 渲染单个星星
90
+ const renderStar = index => {
91
+ const starValue = index + 1;
92
+ const isFilled = displayValue >= starValue;
93
+ const isHalfLeft = allowHalf && !isFilled && displayValue >= starValue - 0.5 && displayValue < starValue;
94
+ // 当使用半星预览时,如果 displayValue 是半星(如 2.5),当前星是第3颗
95
+ // 第2颗星完全填充,第3颗星的左半填充
96
+ const isHalfFilledLeft = allowHalf && isFilled === false && Math.ceil(displayValue) === starValue && displayValue % 1 !== 0;
97
+ let filled = isFilled;
98
+ let half;
99
+ if (isHalfFilledLeft) {
100
+ filled = true;
101
+ half = 'left';
102
+ } else if (isHalfLeft) {
103
+ filled = false;
104
+ half = 'left';
105
+ }
106
+ const starCls = classNames(prefixCls('rate-star'), filled && prefixCls('rate-star-filled'), half && prefixCls('rate-star-half'));
107
+ return /*#__PURE__*/_jsx("span", {
108
+ ref: el => {
109
+ starRefs.current[index] = el;
110
+ },
111
+ className: starCls,
112
+ onMouseMove: e => handleMouseMove(e, index),
113
+ onClick: e => handleClick(e, index),
114
+ role: "radio",
115
+ "aria-checked": filled,
116
+ "aria-label": `${starValue} 星`,
117
+ tabIndex: disabled ? -1 : 0,
118
+ onKeyDown: e => {
119
+ if (disabled) return;
120
+ if (e.key === 'Enter' || e.key === ' ') {
121
+ e.preventDefault();
122
+ handleClick(e, index);
123
+ }
124
+ },
125
+ children: /*#__PURE__*/_jsx(StarIcon, {
126
+ filled: filled,
127
+ half: half
128
+ })
129
+ }, index);
130
+ };
131
+ return /*#__PURE__*/_jsx("div", {
132
+ ref: ref,
133
+ className: cls,
134
+ style: style,
135
+ role: "radiogroup",
136
+ "aria-label": "\u8BC4\u5206",
137
+ onMouseLeave: handleMouseLeave,
138
+ children: Array.from({
139
+ length: count
140
+ }, (_, i) => renderStar(i))
141
+ });
142
+ });
143
+ Rate.displayName = 'Rate';
@@ -0,0 +1,87 @@
1
+ /* ===== Rate 组件样式 ===== */
2
+
3
+ .aura-rate {
4
+ display: inline-flex;
5
+ align-items: center;
6
+ gap: var(--aura-spacing-1);
7
+
8
+ // 禁用状态
9
+ &&-disabled {
10
+ opacity: 0.5;
11
+ cursor: not-allowed;
12
+ pointer-events: none;
13
+ }
14
+ }
15
+
16
+ // ===== 星星尺寸 =====
17
+ .aura-rate-sm {
18
+ .aura-rate-star {
19
+ width: 16px;
20
+ height: 16px;
21
+ font-size: 16px;
22
+ }
23
+ }
24
+
25
+ .aura-rate-md {
26
+ .aura-rate-star {
27
+ width: 20px;
28
+ height: 20px;
29
+ font-size: 20px;
30
+ }
31
+ }
32
+
33
+ .aura-rate-lg {
34
+ .aura-rate-star {
35
+ width: 28px;
36
+ height: 28px;
37
+ font-size: 28px;
38
+ }
39
+ }
40
+
41
+ // ===== 单个星星 =====
42
+ .aura-rate-star {
43
+ display: inline-flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ cursor: pointer;
47
+ color: var(--aura-gray-300);
48
+ transition:
49
+ transform var(--aura-duration-normal) cubic-bezier(0.34, 1.56, 0.64, 1),
50
+ color var(--aura-duration-fast) var(--aura-easing);
51
+ position: relative;
52
+
53
+ &:hover {
54
+ transform: scale(1.15);
55
+ }
56
+
57
+ &:focus-visible {
58
+ outline: none;
59
+ box-shadow: 0 0 0 2px var(--aura-primary-200);
60
+ border-radius: 2px;
61
+ }
62
+
63
+ // 填充状态
64
+ &&-filled {
65
+ color: var(--aura-warning);
66
+ }
67
+
68
+ // 半星状态
69
+ &&-half {
70
+ color: var(--aura-warning);
71
+ }
72
+ }
73
+
74
+ // ===== 暗色模式 =====
75
+ [data-theme="dark"] {
76
+ .aura-rate-star {
77
+ color: var(--aura-gray-600);
78
+
79
+ &&-filled {
80
+ color: var(--aura-warning);
81
+ }
82
+
83
+ &&-half {
84
+ color: var(--aura-warning);
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ export interface ResultProps {
3
+ /** 结果类型 */
4
+ variant?: 'success' | 'error' | 'warning' | 'info' | '404' | '403' | '500';
5
+ /** 标题 */
6
+ title: React.ReactNode;
7
+ /** 副标题 */
8
+ subtitle?: React.ReactNode;
9
+ /** 自定义图标(覆盖默认) */
10
+ icon?: React.ReactNode;
11
+ /** 附加内容(如操作按钮) */
12
+ extra?: React.ReactNode;
13
+ /** 自定义类名 */
14
+ className?: string;
15
+ /** 自定义样式 */
16
+ style?: React.CSSProperties;
17
+ }
18
+ export declare const Result: React.ForwardRefExoticComponent<ResultProps & React.RefAttributes<HTMLDivElement>>;
19
+ export default Result;
@@ -0,0 +1,69 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { classNames, prefixCls } from '@aura-react-comp/shared';
3
+ import { ResultSuccess, ResultError, ResultWarning, ResultInfo, NotFound, Forbidden, ServerError } from '@aura-react-comp/icons';
4
+ import "./index.less";
5
+
6
+ /* ===== 类型定义 ===== */
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ /* ===== 默认图标映射 ===== */
10
+
11
+ const defaultIcons = {
12
+ success: /*#__PURE__*/_jsx(ResultSuccess, {
13
+ size: 72
14
+ }),
15
+ error: /*#__PURE__*/_jsx(ResultError, {
16
+ size: 72
17
+ }),
18
+ warning: /*#__PURE__*/_jsx(ResultWarning, {
19
+ size: 72
20
+ }),
21
+ info: /*#__PURE__*/_jsx(ResultInfo, {
22
+ size: 72
23
+ }),
24
+ '404': /*#__PURE__*/_jsx(NotFound, {
25
+ size: 200
26
+ }),
27
+ '403': /*#__PURE__*/_jsx(Forbidden, {
28
+ size: 200
29
+ }),
30
+ '500': /*#__PURE__*/_jsx(ServerError, {
31
+ size: 200
32
+ })
33
+ };
34
+
35
+ /* ===== Result 主组件 ===== */
36
+
37
+ export const Result = /*#__PURE__*/forwardRef(({
38
+ variant = 'info',
39
+ title,
40
+ subtitle,
41
+ icon,
42
+ extra,
43
+ className,
44
+ style
45
+ }, ref) => {
46
+ const wrapperCls = classNames(prefixCls('result'), prefixCls(`result-${variant}`), className);
47
+ const displayIcon = icon !== undefined ? icon : defaultIcons[variant] ?? defaultIcons.info;
48
+ return /*#__PURE__*/_jsxs("div", {
49
+ ref: ref,
50
+ className: wrapperCls,
51
+ style: style,
52
+ role: "status",
53
+ children: [/*#__PURE__*/_jsx("div", {
54
+ className: prefixCls('result-icon'),
55
+ children: displayIcon
56
+ }), /*#__PURE__*/_jsx("div", {
57
+ className: prefixCls('result-title'),
58
+ children: title
59
+ }), subtitle && /*#__PURE__*/_jsx("div", {
60
+ className: prefixCls('result-subtitle'),
61
+ children: subtitle
62
+ }), extra && /*#__PURE__*/_jsx("div", {
63
+ className: prefixCls('result-extra'),
64
+ children: extra
65
+ })]
66
+ });
67
+ });
68
+ Result.displayName = 'Result';
69
+ export default Result;
@@ -0,0 +1,103 @@
1
+ .aura-result {
2
+ display: flex;
3
+ flex-direction: column;
4
+ align-items: center;
5
+ justify-content: center;
6
+ text-align: center;
7
+ padding: var(--aura-spacing-8) var(--aura-spacing-4);
8
+ min-height: 300px;
9
+
10
+ /* ===== 图标区域 ===== */
11
+ &-icon {
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ margin-bottom: var(--aura-spacing-4);
16
+ animation: aura-result-icon-in var(--aura-duration-slow) cubic-bezier(0.34, 1.56, 0.64, 1);
17
+ }
18
+
19
+ /* ===== 标题 ===== */
20
+ &-title {
21
+ font-size: var(--aura-font-size-xl);
22
+ font-weight: 600;
23
+ color: var(--aura-text);
24
+ line-height: 1.5;
25
+ margin-bottom: var(--aura-spacing-2);
26
+ }
27
+
28
+ /* ===== 副标题 ===== */
29
+ &-subtitle {
30
+ font-size: var(--aura-font-size-md);
31
+ color: var(--aura-text-secondary);
32
+ line-height: 1.6;
33
+ margin-bottom: var(--aura-spacing-4);
34
+ max-width: 480px;
35
+ }
36
+
37
+ /* ===== 附加内容 ===== */
38
+ &-extra {
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ gap: var(--aura-spacing-3);
43
+ margin-top: var(--aura-spacing-2);
44
+ }
45
+
46
+ /* ===== 变体颜色 ===== */
47
+ &&-success {
48
+ .aura-result-icon {
49
+ color: var(--aura-success);
50
+ }
51
+ }
52
+
53
+ &&-error {
54
+ .aura-result-icon {
55
+ color: var(--aura-error);
56
+ }
57
+ }
58
+
59
+ &&-warning {
60
+ .aura-result-icon {
61
+ color: var(--aura-warning);
62
+ }
63
+ }
64
+
65
+ &&-info {
66
+ .aura-result-icon {
67
+ color: var(--aura-info);
68
+ }
69
+ }
70
+
71
+ &&-404,
72
+ &&-403,
73
+ &&-500 {
74
+ .aura-result-icon {
75
+ color: var(--aura-text-tertiary);
76
+ }
77
+ }
78
+ }
79
+
80
+ /* ===== 图标缩放入场动画 ===== */
81
+ @keyframes aura-result-icon-in {
82
+ from {
83
+ opacity: 0;
84
+ transform: scale(0.5);
85
+ }
86
+ to {
87
+ opacity: 1;
88
+ transform: scale(1);
89
+ }
90
+ }
91
+
92
+ /* ===== 暗色模式 ===== */
93
+ [data-theme="dark"] {
94
+ .aura-result {
95
+ &-title {
96
+ color: var(--aura-text);
97
+ }
98
+
99
+ &-subtitle {
100
+ color: var(--aura-text-secondary);
101
+ }
102
+ }
103
+ }