@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
@@ -0,0 +1,258 @@
1
+ .aura-form {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--aura-spacing-4);
5
+
6
+ /* ===== size 变体 ===== */
7
+ &-sm {
8
+ gap: var(--aura-spacing-3);
9
+
10
+ .aura-form-item-label {
11
+ font-size: var(--aura-font-size-xs);
12
+ }
13
+ }
14
+
15
+ &-lg {
16
+ gap: var(--aura-spacing-5);
17
+
18
+ .aura-form-item-label {
19
+ font-size: var(--aura-font-size-md);
20
+ }
21
+ }
22
+
23
+ /* ===== inline 模式 ===== */
24
+ &&-inline {
25
+ flex-direction: row;
26
+ flex-wrap: wrap;
27
+ align-items: center;
28
+ gap: var(--aura-spacing-3);
29
+
30
+ .aura-form-item {
31
+ flex-direction: row;
32
+ align-items: center;
33
+ gap: var(--aura-spacing-2);
34
+
35
+ .aura-form-item-label {
36
+ padding-bottom: 0;
37
+ }
38
+ }
39
+
40
+ .aura-form-item-errors {
41
+ position: absolute;
42
+ top: 100%;
43
+ left: 0;
44
+ }
45
+ }
46
+
47
+ /* ===== FormItem ===== */
48
+ &-item {
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: var(--aura-spacing-1);
52
+ position: relative;
53
+ min-width: 0;
54
+
55
+ /* ===== horizontal 布局 ===== */
56
+ &-horizontal {
57
+ flex-direction: row;
58
+ align-items: center;
59
+ gap: var(--aura-spacing-3);
60
+
61
+ .aura-form-item-label {
62
+ justify-content: flex-end;
63
+ width: 80px;
64
+ flex-shrink: 0;
65
+ padding-bottom: 0;
66
+ }
67
+
68
+ .aura-form-item-label-left {
69
+ justify-content: flex-start;
70
+ }
71
+
72
+ .aura-form-item-control {
73
+ flex: 1;
74
+ min-width: 0;
75
+ }
76
+
77
+ .aura-form-item-errors {
78
+ position: absolute;
79
+ top: 100%;
80
+ left: 80px;
81
+ }
82
+ }
83
+
84
+ /* ===== vertical 布局(默认) ===== */
85
+ &-vertical {
86
+ flex-direction: column;
87
+ }
88
+
89
+ /* ===== 标签 ===== */
90
+ &-label {
91
+ display: inline-flex;
92
+ align-items: center;
93
+ justify-content: flex-start;
94
+ gap: 2px;
95
+ font-size: var(--aura-font-size-sm);
96
+ color: var(--aura-text);
97
+ line-height: 1.5;
98
+ padding-bottom: var(--aura-spacing-1);
99
+ white-space: nowrap;
100
+ }
101
+
102
+ /* ===== 冒号 ===== */
103
+ &-colon {
104
+ margin-left: 2px;
105
+ }
106
+
107
+ /* ===== 必填星号 ===== */
108
+ &-required-star {
109
+ color: var(--aura-error);
110
+ margin-right: 2px;
111
+ font-size: var(--aura-font-size-md);
112
+ line-height: 1;
113
+ }
114
+
115
+ /* ===== 控制区 ===== */
116
+ &-control {
117
+ display: flex;
118
+ flex-direction: column;
119
+ gap: var(--aura-spacing-1);
120
+ flex: 1;
121
+ }
122
+
123
+ /* ===== 输入区 ===== */
124
+ &-input {
125
+ width: 100%;
126
+ }
127
+
128
+ /* ===== 错误信息 ===== */
129
+ &-errors {
130
+ display: flex;
131
+ flex-direction: column;
132
+ gap: 2px;
133
+ animation: aura-form-error-in var(--aura-duration-normal)
134
+ cubic-bezier(0.4, 0, 0.2, 1);
135
+ }
136
+
137
+ &-error-text {
138
+ font-size: var(--aura-font-size-xs);
139
+ color: var(--aura-error);
140
+ line-height: 1.5;
141
+ }
142
+
143
+ /* ===== 错误状态 ===== */
144
+ &-error {
145
+ .aura-form-item-label {
146
+ color: var(--aura-error);
147
+ }
148
+ }
149
+
150
+ /* ===== 禁用状态 ===== */
151
+ &-disabled {
152
+ opacity: 0.6;
153
+ pointer-events: none;
154
+ }
155
+ }
156
+ }
157
+
158
+ /* ===== Form.List ===== */
159
+ .aura-form-list {
160
+ display: flex;
161
+ flex-direction: column;
162
+ gap: var(--aura-spacing-3);
163
+ }
164
+
165
+ /* 紧凑模式:同行 Input 无中间圆角、边框重叠,看起来一体 */
166
+ .aura-form-list-compact {
167
+ .aura-input {
168
+ border-radius: 0;
169
+
170
+ &:focus-within {
171
+ transform: none;
172
+ }
173
+ }
174
+
175
+ > div > .aura-form-item + .aura-form-item .aura-input {
176
+ margin-left: -1px;
177
+ }
178
+
179
+ > div > .aura-form-item:first-of-type .aura-input {
180
+ border-top-left-radius: var(--aura-radius-md);
181
+ border-bottom-left-radius: var(--aura-radius-md);
182
+ }
183
+
184
+ > div > .aura-form-item:last-of-type .aura-input {
185
+ border-top-right-radius: var(--aura-radius-md);
186
+ border-bottom-right-radius: var(--aura-radius-md);
187
+ }
188
+
189
+ // 同行任一聚焦时,整行统一高亮
190
+ > div:focus-within .aura-input {
191
+ border-color: var(--aura-primary-500);
192
+ }
193
+ }
194
+
195
+ .aura-form-list-remove {
196
+ display: inline-flex;
197
+ align-items: center;
198
+ justify-content: center;
199
+ width: 32px;
200
+ height: 32px;
201
+ margin-top: 4px;
202
+ border: none;
203
+ background: transparent;
204
+ color: var(--aura-text-tertiary);
205
+ border-radius: var(--aura-radius-sm);
206
+ cursor: pointer;
207
+ flex-shrink: 0;
208
+ transition: all var(--aura-duration-normal) var(--aura-easing);
209
+
210
+ &:hover {
211
+ color: var(--aura-error);
212
+ background: rgba(255, 0, 0, 0.06);
213
+ }
214
+ }
215
+
216
+ .aura-form-list-add {
217
+ display: inline-flex;
218
+ align-items: center;
219
+ gap: var(--aura-spacing-1);
220
+ padding: 6px 12px;
221
+ border: 1px dashed var(--aura-border);
222
+ border-radius: var(--aura-radius-sm);
223
+ background: transparent;
224
+ color: var(--aura-primary-700);
225
+ cursor: pointer;
226
+ font-size: var(--aura-font-size-sm);
227
+ width: 100%;
228
+ justify-content: center;
229
+ transition: all var(--aura-duration-normal) var(--aura-easing);
230
+
231
+ &:hover {
232
+ border-color: var(--aura-primary-700);
233
+ color: var(--aura-primary-700);
234
+ }
235
+ }
236
+
237
+ /* ===== 错误信息入场动画 ===== */
238
+ @keyframes aura-form-error-in {
239
+ from {
240
+ opacity: 0;
241
+ transform: translateY(-4px);
242
+ }
243
+ to {
244
+ opacity: 1;
245
+ transform: translateY(0);
246
+ }
247
+ }
248
+
249
+ /* ===== 暗色模式 ===== */
250
+ [data-theme='dark'] {
251
+ .aura-form {
252
+ &-item {
253
+ &-label {
254
+ color: var(--aura-text);
255
+ }
256
+ }
257
+ }
258
+ }
@@ -0,0 +1,6 @@
1
+ declare module '*.less' {
2
+ const classes: Record<string, string>;
3
+ export default classes;
4
+ }
5
+
6
+ declare module '*.css';
package/esm/index.d.ts ADDED
@@ -0,0 +1,78 @@
1
+ export { ThemeProvider, useTheme } from './theme';
2
+ export type { Theme } from './theme';
3
+ export { Button } from './button';
4
+ export type { ButtonProps } from './button';
5
+ export { Typography, Title, Text, Paragraph } from './typography';
6
+ export type { TypographyProps, TitleProps, TextProps, ParagraphProps } from './typography';
7
+ export { Space } from './space';
8
+ export type { SpaceProps } from './space';
9
+ export { Divider } from './divider';
10
+ export type { DividerProps } from './divider';
11
+ export { Switch } from './switch';
12
+ export type { SwitchProps } from './switch';
13
+ export { Alert } from './alert';
14
+ export type { AlertProps } from './alert';
15
+ export { Spin } from './spin';
16
+ export type { SpinProps } from './spin';
17
+ export { Input } from './input';
18
+ export type { InputProps, PasswordProps, SearchProps, GroupProps } from './input';
19
+ export { Textarea } from './textarea';
20
+ export type { TextareaProps } from './textarea';
21
+ export { Select } from './select';
22
+ export type { SelectProps, SelectOption, LabelInValueObject, SelectOutValue } from './select';
23
+ export { Checkbox, CheckboxGroup } from './checkbox';
24
+ export type { CheckboxProps, CheckboxGroupProps } from './checkbox';
25
+ export { Radio, RadioGroup } from './radio';
26
+ export type { RadioProps, RadioGroupProps } from './radio';
27
+ export { Tag } from './tag';
28
+ export type { TagProps } from './tag';
29
+ export { TagCheckable } from './tag';
30
+ export type { TagCheckableProps } from './tag';
31
+ export { TagGroup } from './tag';
32
+ export type { TagGroupProps } from './tag';
33
+ export { Badge } from './badge';
34
+ export type { BadgeProps } from './badge';
35
+ export { Avatar } from './avatar';
36
+ export type { AvatarProps } from './avatar';
37
+ export { AvatarGroup } from './avatar';
38
+ export type { AvatarGroupProps } from './avatar';
39
+ export { Tooltip } from './tooltip';
40
+ export type { TooltipProps } from './tooltip';
41
+ export { Card } from './card';
42
+ export type { CardProps } from './card';
43
+ export { Collapse } from './collapse';
44
+ export type { CollapseProps } from './collapse';
45
+ export { TabsWithSub as Tabs, TabItem } from './tabs';
46
+ export type { TabsProps } from './tabs';
47
+ export { Empty } from './empty';
48
+ export type { EmptyProps } from './empty';
49
+ export { message } from './message';
50
+ export { notification } from './notification';
51
+ export { Dropdown } from './dropdown';
52
+ export type { DropdownProps, DropdownMenuItem } from './dropdown';
53
+ export { Slider } from './slider';
54
+ export type { SliderProps } from './slider';
55
+ export { Rate } from './rate';
56
+ export type { RateProps } from './rate';
57
+ export { Menu } from './menu';
58
+ export type { MenuProps, MenuItemProps, SubMenuProps, MenuGroupProps, MenuDividerProps } from './menu';
59
+ export { Breadcrumb } from './breadcrumb';
60
+ export type { BreadcrumbProps, BreadcrumbItemProps } from './breadcrumb';
61
+ export { Pagination } from './pagination';
62
+ export type { PaginationProps } from './pagination';
63
+ export { Steps } from './steps';
64
+ export type { StepsProps, StepProps } from './steps';
65
+ export { Upload } from './upload';
66
+ export type { UploadProps, UploadFile, CustomRequestOptions, DraggerProps } from './upload';
67
+ export { Form } from './form';
68
+ export type { FormProps, FormItemProps, FormError, FormInstance, FormListProps, FormListFieldData, FormListOperation } from './form';
69
+ export { Result } from './result';
70
+ export type { ResultProps } from './result';
71
+ export { Popconfirm } from './popconfirm';
72
+ export type { PopconfirmProps } from './popconfirm';
73
+ export { Layout } from './layout';
74
+ export type { LayoutProps, LayoutHeaderProps, LayoutBodyProps, LayoutSiderProps, LayoutFooterProps } from './layout';
75
+ export { Flex } from './flex';
76
+ export type { FlexProps } from './flex';
77
+ export { Scrollbar } from './scrollbar';
78
+ export type { ScrollbarProps } from './scrollbar';
package/esm/index.js ADDED
@@ -0,0 +1,41 @@
1
+ import "./theme/tokens.css";
2
+ export { ThemeProvider, useTheme } from "./theme";
3
+ export { Button } from "./button";
4
+ export { Typography, Title, Text, Paragraph } from "./typography";
5
+ export { Space } from "./space";
6
+ export { Divider } from "./divider";
7
+ export { Switch } from "./switch";
8
+ export { Alert } from "./alert";
9
+ export { Spin } from "./spin";
10
+ export { Input } from "./input";
11
+ export { Textarea } from "./textarea";
12
+ export { Select } from "./select";
13
+ export { Checkbox, CheckboxGroup } from "./checkbox";
14
+ export { Radio, RadioGroup } from "./radio";
15
+ export { Tag } from "./tag";
16
+ export { TagCheckable } from "./tag";
17
+ export { TagGroup } from "./tag";
18
+ export { Badge } from "./badge";
19
+ export { Avatar } from "./avatar";
20
+ export { AvatarGroup } from "./avatar";
21
+ export { Tooltip } from "./tooltip";
22
+ export { Card } from "./card";
23
+ export { Collapse } from "./collapse";
24
+ export { TabsWithSub as Tabs, TabItem } from "./tabs";
25
+ export { Empty } from "./empty";
26
+ export { message } from "./message";
27
+ export { notification } from "./notification";
28
+ export { Dropdown } from "./dropdown";
29
+ export { Slider } from "./slider";
30
+ export { Rate } from "./rate";
31
+ export { Menu } from "./menu";
32
+ export { Breadcrumb } from "./breadcrumb";
33
+ export { Pagination } from "./pagination";
34
+ export { Steps } from "./steps";
35
+ export { Upload } from "./upload";
36
+ export { Form } from "./form";
37
+ export { Result } from "./result";
38
+ export { Popconfirm } from "./popconfirm";
39
+ export { Layout } from "./layout";
40
+ export { Flex } from "./flex";
41
+ export { Scrollbar } from "./scrollbar";
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ export interface InputCountConfig {
3
+ /** 自定义字数统计文案渲染 */
4
+ formatter?: (args: {
5
+ value: string;
6
+ count: number;
7
+ maxLength?: number;
8
+ }) => React.ReactNode;
9
+ }
10
+ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {
11
+ variant?: 'default' | 'filled' | 'bordered';
12
+ size?: 'sm' | 'md' | 'lg';
13
+ disabled?: boolean;
14
+ prefix?: React.ReactNode;
15
+ suffix?: React.ReactNode;
16
+ allowClear?: boolean;
17
+ status?: 'default' | 'error' | 'warning';
18
+ /** 输入框前置附加内容(如 `https://`、`¥`),与 prefix 的区别是渲染在边框外 */
19
+ addonBefore?: React.ReactNode;
20
+ /** 输入框后置附加内容(如 `.com`、`元`),与 suffix 的区别是渲染在边框外 */
21
+ addonAfter?: React.ReactNode;
22
+ /** 是否显示字数统计;传对象可用 `formatter` 自定义渲染 */
23
+ showCount?: boolean | InputCountConfig;
24
+ /** 按下回车键的回调 */
25
+ onPressEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
26
+ }
27
+ export interface PasswordProps extends Omit<InputProps, 'type'> {
28
+ defaultVisible?: boolean;
29
+ }
30
+ declare const Password: React.ForwardRefExoticComponent<PasswordProps & React.RefAttributes<HTMLInputElement>>;
31
+ export interface SearchProps extends Omit<InputProps, 'suffix'> {
32
+ /**
33
+ * 自定义搜索按钮文案。
34
+ * 不传时展示搜索图标(默认形态);传入时以该文案替代图标,
35
+ * 并同时作为按钮的可访问名称。
36
+ */
37
+ searchButtonText?: string;
38
+ onSearch?: (value: string) => void;
39
+ }
40
+ declare const Search: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLInputElement>>;
41
+ export interface GroupProps extends React.HTMLAttributes<HTMLDivElement> {
42
+ compact?: boolean;
43
+ }
44
+ declare const Group: React.ForwardRefExoticComponent<GroupProps & React.RefAttributes<HTMLDivElement>>;
45
+ interface InputComponent extends React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>> {
46
+ Password: typeof Password;
47
+ Search: typeof Search;
48
+ Group: typeof Group;
49
+ }
50
+ declare const Input: InputComponent;
51
+ export { Input };
@@ -0,0 +1,217 @@
1
+ import React, { forwardRef, useState, useCallback, useRef } from 'react';
2
+ import { classNames, prefixCls } from '@aura-react-comp/shared';
3
+ import { EyeOpen, EyeClosed, Search as SearchIcon } from '@aura-react-comp/icons';
4
+ import "./index.less";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const InputBase = /*#__PURE__*/forwardRef(({
9
+ variant = 'default',
10
+ size = 'md',
11
+ disabled = false,
12
+ prefix: prefixNode,
13
+ suffix: suffixNode,
14
+ allowClear = false,
15
+ status = 'default',
16
+ addonBefore,
17
+ addonAfter,
18
+ showCount = false,
19
+ onPressEnter,
20
+ className,
21
+ style,
22
+ value,
23
+ defaultValue,
24
+ onChange,
25
+ onKeyDown,
26
+ maxLength,
27
+ ...rest
28
+ }, ref) => {
29
+ const [internalValue, setInternalValue] = useState(defaultValue ?? '');
30
+ const isControlled = value !== undefined;
31
+ const currentValue = isControlled ? String(value ?? '') : internalValue;
32
+ const handleChange = useCallback(e => {
33
+ if (!isControlled) setInternalValue(e.target.value);
34
+ onChange?.(e);
35
+ }, [isControlled, onChange]);
36
+ const handleKeyDown = useCallback(e => {
37
+ if (e.key === 'Enter') onPressEnter?.(e);
38
+ onKeyDown?.(e);
39
+ }, [onPressEnter, onKeyDown]);
40
+ const handleClear = useCallback(() => {
41
+ if (disabled) return;
42
+ if (!isControlled) setInternalValue('');
43
+ const syntheticEvent = {
44
+ target: {
45
+ value: ''
46
+ },
47
+ currentTarget: {
48
+ value: ''
49
+ }
50
+ };
51
+ onChange?.(syntheticEvent);
52
+ }, [disabled, isControlled, onChange]);
53
+ const showClear = allowClear && currentValue.length > 0 && !disabled;
54
+ const countConfig = typeof showCount === 'object' ? showCount : undefined;
55
+ const showCountNode = Boolean(showCount);
56
+ const countNode = showCountNode ? /*#__PURE__*/_jsx("span", {
57
+ className: prefixCls('input-count'),
58
+ children: countConfig?.formatter ? countConfig.formatter({
59
+ value: currentValue,
60
+ count: currentValue.length,
61
+ maxLength
62
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
63
+ children: [currentValue.length, maxLength != null && ` / ${maxLength}`]
64
+ })
65
+ }) : null;
66
+ const hasAddon = Boolean(addonBefore) || Boolean(addonAfter);
67
+ const innerCls = classNames(prefixCls('input'), variant !== 'default' && prefixCls(`input-${variant}`), prefixCls(`input-${size}`), status !== 'default' && prefixCls(`input-${status}`), disabled && prefixCls('input-disabled'), Boolean(prefixNode) && prefixCls('input-with-prefix'), (Boolean(suffixNode) || allowClear || showCountNode) && prefixCls('input-with-suffix'));
68
+ const innerInput = /*#__PURE__*/_jsxs(_Fragment, {
69
+ children: [prefixNode && /*#__PURE__*/_jsx("span", {
70
+ className: prefixCls('input-prefix'),
71
+ children: prefixNode
72
+ }), /*#__PURE__*/_jsx("input", {
73
+ ref: ref,
74
+ className: prefixCls('input-element'),
75
+ value: isControlled ? value : internalValue,
76
+ onChange: handleChange,
77
+ onKeyDown: handleKeyDown,
78
+ disabled: disabled,
79
+ maxLength: maxLength,
80
+ ...rest
81
+ }), countNode, showClear && /*#__PURE__*/_jsx("span", {
82
+ className: prefixCls('input-clear'),
83
+ onClick: handleClear,
84
+ role: "button",
85
+ "aria-label": "\u6E05\u9664",
86
+ children: "\xD7"
87
+ }), !showClear && suffixNode && /*#__PURE__*/_jsx("span", {
88
+ className: prefixCls('input-suffix'),
89
+ children: suffixNode
90
+ })]
91
+ });
92
+
93
+ // 有 addon 时:外层包裹 addon,className / style 落在包裹层
94
+ if (hasAddon) {
95
+ const wrapperCls = classNames(prefixCls('input-group-wrapper'), prefixCls(`input-group-wrapper-${size}`), disabled && prefixCls('input-group-wrapper-disabled'), className);
96
+ return /*#__PURE__*/_jsxs("div", {
97
+ className: wrapperCls,
98
+ style: style,
99
+ children: [addonBefore && /*#__PURE__*/_jsx("span", {
100
+ className: prefixCls('input-addon'),
101
+ children: addonBefore
102
+ }), /*#__PURE__*/_jsx("div", {
103
+ className: innerCls,
104
+ children: innerInput
105
+ }), addonAfter && /*#__PURE__*/_jsx("span", {
106
+ className: prefixCls('input-addon'),
107
+ children: addonAfter
108
+ })]
109
+ });
110
+ }
111
+ return /*#__PURE__*/_jsx("div", {
112
+ className: classNames(innerCls, className),
113
+ style: style,
114
+ children: innerInput
115
+ });
116
+ });
117
+ InputBase.displayName = 'Input';
118
+
119
+ /* ===== Input.Password ===== */
120
+
121
+ const Password = /*#__PURE__*/forwardRef(({
122
+ defaultVisible = false,
123
+ ...rest
124
+ }, ref) => {
125
+ const [visible, setVisible] = useState(defaultVisible);
126
+ const suffix = /*#__PURE__*/_jsx("span", {
127
+ className: classNames(prefixCls('input-eye'), visible && prefixCls('input-eye-visible')),
128
+ onClick: () => setVisible(v => !v),
129
+ role: "button",
130
+ "aria-label": visible ? '隐藏密码' : '显示密码',
131
+ children: visible ? /*#__PURE__*/_jsx(EyeOpen, {
132
+ size: 16
133
+ }) : /*#__PURE__*/_jsx(EyeClosed, {
134
+ size: 16
135
+ })
136
+ });
137
+ return /*#__PURE__*/_jsx(InputBase, {
138
+ ref: ref,
139
+ type: visible ? 'text' : 'password',
140
+ suffix: suffix,
141
+ ...rest
142
+ });
143
+ });
144
+ Password.displayName = 'Input.Password';
145
+
146
+ /* ===== Input.Search ===== */
147
+
148
+ const Search = /*#__PURE__*/forwardRef(({
149
+ searchButtonText,
150
+ onSearch,
151
+ onKeyDown,
152
+ ...rest
153
+ }, ref) => {
154
+ // 持有内部 input 引用:点击按钮时需要读取当前输入值
155
+ const inputRef = useRef(null);
156
+ const handleKeyDown = e => {
157
+ if (e.key === 'Enter') onSearch?.(e.currentTarget.value);
158
+ onKeyDown?.(e);
159
+ };
160
+ const triggerSearch = () => onSearch?.(inputRef.current?.value ?? '');
161
+ const label = searchButtonText ?? '搜索';
162
+ const suffix = /*#__PURE__*/_jsx("span", {
163
+ className: prefixCls('input-search-btn'),
164
+ role: "button",
165
+ "aria-label": label,
166
+ tabIndex: 0,
167
+ onClick: triggerSearch,
168
+ onKeyDown: e => {
169
+ if (e.key === 'Enter' || e.key === ' ') {
170
+ e.preventDefault();
171
+ triggerSearch();
172
+ }
173
+ },
174
+ children: searchButtonText ? /*#__PURE__*/_jsx("span", {
175
+ className: prefixCls('input-search-btn-text'),
176
+ children: searchButtonText
177
+ }) : /*#__PURE__*/_jsx(SearchIcon, {
178
+ size: 16
179
+ })
180
+ });
181
+ return /*#__PURE__*/_jsx(InputBase, {
182
+ ref: node => {
183
+ inputRef.current = node;
184
+ if (typeof ref === 'function') ref(node);else if (ref) ref.current = node;
185
+ },
186
+ suffix: suffix,
187
+ onKeyDown: handleKeyDown,
188
+ ...rest
189
+ });
190
+ });
191
+ Search.displayName = 'Input.Search';
192
+
193
+ /* ===== Input.Group ===== */
194
+
195
+ const Group = /*#__PURE__*/forwardRef(({
196
+ compact = false,
197
+ className,
198
+ children,
199
+ ...rest
200
+ }, ref) => {
201
+ const cls = classNames(prefixCls('input-group'), compact && prefixCls('input-group-compact'), className);
202
+ return /*#__PURE__*/_jsx("div", {
203
+ ref: ref,
204
+ className: cls,
205
+ ...rest,
206
+ children: children
207
+ });
208
+ });
209
+ Group.displayName = 'Input.Group';
210
+
211
+ /* ===== 复合组件导出 ===== */
212
+
213
+ const Input = InputBase;
214
+ Input.Password = Password;
215
+ Input.Search = Search;
216
+ Input.Group = Group;
217
+ export { Input };