aha-components 1.8.1 → 1.8.2
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/dist/Input.esm.js +1 -1
- package/dist/Input.esm.js.map +1 -1
- package/dist/Input.js +1 -1
- package/dist/Input.js.map +1 -1
- package/dist/Pagination.esm.js +1 -1
- package/dist/Pagination.esm.js.map +1 -1
- package/dist/Pagination.js +1 -1
- package/dist/Pagination.js.map +1 -1
- package/dist/Table.esm.js +1 -1
- package/dist/Table.esm.js.map +1 -1
- package/dist/Table.js +1 -1
- package/dist/Table.js.map +1 -1
- package/dist/Textarea.esm.js +1 -1
- package/dist/Textarea.esm.js.map +1 -1
- package/dist/Textarea.js +1 -1
- package/dist/Textarea.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.stories 2.d.ts +12 -0
- package/dist/components/Checkbox/index 2.d.ts +12 -0
- package/dist/components/DatePicker/DatePicker.stories 2.d.ts +25 -0
- package/dist/components/DatePicker/index 2.d.ts +96 -0
- package/dist/components/Drawer/Drawer.stories 2.d.ts +9 -0
- package/dist/components/Drawer/index 2.d.ts +58 -0
- package/dist/components/Form/Form.stories 2.d.ts +15 -0
- package/dist/components/Form/FormContext 2.d.ts +41 -0
- package/dist/components/Form/FormItem 2.d.ts +58 -0
- package/dist/components/Form/index 2.d.ts +85 -0
- package/dist/components/Input/Input.stories 2.d.ts +16 -0
- package/dist/components/Input/Input.stories.d.ts +7 -4
- package/dist/components/Input/InputGroup.d.ts +25 -0
- package/dist/components/Input/InputTags.d.ts +17 -0
- package/dist/components/Input/index 2.d.ts +41 -0
- package/dist/components/Input/index.d.ts +7 -18
- package/dist/components/Loading/Loading.stories 2.d.ts +11 -0
- package/dist/components/Loading/index 2.d.ts +10 -0
- package/dist/components/MenuList/MenuList.stories 2.d.ts +17 -0
- package/dist/components/MenuList/MenuList.test 2.d.ts +1 -0
- package/dist/components/MenuList/index 2.d.ts +85 -0
- package/dist/components/Pagination/Pagination.stories 2.d.ts +16 -0
- package/dist/components/Pagination/index 2.d.ts +27 -0
- package/dist/components/Popover/Popover.stories 2.d.ts +11 -0
- package/dist/components/Popover/index 2.d.ts +31 -0
- package/dist/components/Progress/Progress.stories 2.d.ts +18 -0
- package/dist/components/Progress/Progress.test 2.d.ts +1 -0
- package/dist/components/Progress/index 2.d.ts +33 -0
- package/dist/components/Radio/Radio.stories 2.d.ts +10 -0
- package/dist/components/Radio/index 2.d.ts +13 -0
- package/dist/components/Select/Select.stories 2.d.ts +17 -0
- package/dist/components/Select/index 2.d.ts +74 -0
- package/dist/components/Switch/Switch.stories 2.d.ts +14 -0
- package/dist/components/Switch/index 2.d.ts +27 -0
- package/dist/components/Tab/Tab.stories 2.d.ts +19 -0
- package/dist/components/Tab/index 2.d.ts +26 -0
- package/dist/components/Table/Table.stories 2.d.ts +21 -0
- package/dist/components/Table/index 2.d.ts +167 -0
- package/dist/components/Textarea/Textarea.stories 2.d.ts +15 -0
- package/dist/components/Textarea/Textarea.stories.d.ts +3 -6
- package/dist/components/Textarea/TextareaTags.d.ts +8 -0
- package/dist/components/Textarea/index 2.d.ts +38 -0
- package/dist/components/Textarea/index.d.ts +6 -17
- package/dist/components/Tooltip/Tooltip.stories 2.d.ts +20 -0
- package/dist/components/Tooltip/index 2.d.ts +35 -0
- package/dist/icons/index 2.d.ts +33 -0
- package/dist/index.css +962 -1
- package/dist/index.d.ts +54 -36
- package/dist/index.esm.css +962 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/stories/DesignTokens.stories 2.d.ts +5 -0
- package/dist/theme/Theme.stories 2.d.ts +10 -0
- package/dist/theme/ThemeContext 2.d.ts +11 -0
- package/dist/theme/utils 2.d.ts +10 -0
- package/dist/tokens.d.ts +2 -0
- package/package.json +1 -1
- package/dist/AlertComponent.esm.js +0 -2
- package/dist/AlertComponent.esm.js.map +0 -1
- package/dist/AlertComponent.js +0 -2
- package/dist/AlertComponent.js.map +0 -1
- package/dist/Card.esm.js +0 -2
- package/dist/Card.esm.js.map +0 -1
- package/dist/Card.js +0 -2
- package/dist/Card.js.map +0 -1
- package/dist/TestComponent.esm.js +0 -2
- package/dist/TestComponent.esm.js.map +0 -1
- package/dist/TestComponent.js +0 -2
- package/dist/TestComponent.js.map +0 -1
- package/dist/Toast.css +0 -1
- package/dist/Toast.esm.css +0 -1
- package/dist/components/AlertComponent/index.d.ts +0 -9
- package/dist/components/Card/index.d.ts +0 -10
- package/dist/components/TestComponent/index.d.ts +0 -7
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DateRange {
|
|
3
|
+
startDate: Date | null;
|
|
4
|
+
endDate: Date | null;
|
|
5
|
+
}
|
|
6
|
+
export interface PresetRange {
|
|
7
|
+
label: string;
|
|
8
|
+
range: DateRange;
|
|
9
|
+
}
|
|
10
|
+
export interface DatePickerBaseProps {
|
|
11
|
+
/** 是否禁用 */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** 是否显示错误状态 */
|
|
14
|
+
error?: boolean;
|
|
15
|
+
/** 占位符(单个日期模式) */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
/** 开始日期占位符(范围模式) */
|
|
18
|
+
startPlaceholder?: string;
|
|
19
|
+
/** 结束日期占位符(范围模式) */
|
|
20
|
+
endPlaceholder?: string;
|
|
21
|
+
/** 尺寸 */
|
|
22
|
+
size?: 'small' | 'mediumSmall' | 'medium' | 'large';
|
|
23
|
+
/** 是否允许清除 */
|
|
24
|
+
allowClear?: boolean;
|
|
25
|
+
/** 日期格式 */
|
|
26
|
+
format?: string;
|
|
27
|
+
/** 聚焦回调 */
|
|
28
|
+
onFocus?: (e: React.FocusEvent) => void;
|
|
29
|
+
/** 失焦回调 */
|
|
30
|
+
onBlur?: (e: React.FocusEvent) => void;
|
|
31
|
+
/** 下拉框打开回调 */
|
|
32
|
+
onOpenChange?: (open: boolean) => void;
|
|
33
|
+
/** 自定义类名 */
|
|
34
|
+
className?: string;
|
|
35
|
+
/** 自定义样式 */
|
|
36
|
+
style?: React.CSSProperties;
|
|
37
|
+
/** 下拉框类名 */
|
|
38
|
+
dropdownClassName?: string;
|
|
39
|
+
/** 下拉框样式 */
|
|
40
|
+
dropdownStyle?: React.CSSProperties;
|
|
41
|
+
/** 是否默认打开 */
|
|
42
|
+
defaultOpen?: boolean;
|
|
43
|
+
/** 是否打开(受控) */
|
|
44
|
+
open?: boolean;
|
|
45
|
+
/** 最小日期 */
|
|
46
|
+
minDate?: Date;
|
|
47
|
+
/** 最大日期 */
|
|
48
|
+
maxDate?: Date;
|
|
49
|
+
/** 分隔符(范围模式) */
|
|
50
|
+
separator?: string;
|
|
51
|
+
/** 预设日期范围列表(仅在范围模式下有效) */
|
|
52
|
+
presetRanges?: PresetRange[] | boolean;
|
|
53
|
+
/** 显示日历数量:1=单月,2=双月(仅在范围模式下有效,默认1) */
|
|
54
|
+
calendarCount?: 1 | 2;
|
|
55
|
+
/** 是否显示 Apply/Cancel 按钮(仅在范围模式下有效) */
|
|
56
|
+
showApplyCancel?: boolean;
|
|
57
|
+
/** Apply 按钮文本 */
|
|
58
|
+
applyText?: string;
|
|
59
|
+
/** Cancel 按钮文本 */
|
|
60
|
+
cancelText?: string;
|
|
61
|
+
/** Apply 按钮回调 */
|
|
62
|
+
onApply?: (range: DateRange) => void;
|
|
63
|
+
/** Cancel 按钮回调 */
|
|
64
|
+
onCancel?: () => void;
|
|
65
|
+
/** 是否显示选中的日期段(仅在范围模式下有效,默认false) */
|
|
66
|
+
showSelectedRange?: boolean;
|
|
67
|
+
/** 选中的开始日期段文本 */
|
|
68
|
+
startSelectedRangeText?: string;
|
|
69
|
+
/** 选中的结束日期段文本 */
|
|
70
|
+
endSelectedRangeText?: string;
|
|
71
|
+
/** 范围显示模式:'range'=显示两个输入框(xxx - xxx),'text'=显示一句话(仅在范围模式下有效,默认'range') */
|
|
72
|
+
rangeDisplayMode?: 'range' | 'text';
|
|
73
|
+
}
|
|
74
|
+
export interface DatePickerSingleProps extends DatePickerBaseProps {
|
|
75
|
+
/** 模式:单个日期 */
|
|
76
|
+
mode?: 'date';
|
|
77
|
+
/** 当前选中的值 */
|
|
78
|
+
value?: Date | null;
|
|
79
|
+
/** 默认选中的值 */
|
|
80
|
+
defaultValue?: Date | null;
|
|
81
|
+
/** 变化回调 */
|
|
82
|
+
onChange?: (date: Date | null) => void;
|
|
83
|
+
}
|
|
84
|
+
export interface DatePickerRangeProps extends DatePickerBaseProps {
|
|
85
|
+
/** 模式:日期范围 */
|
|
86
|
+
mode: 'range';
|
|
87
|
+
/** 当前选中的值 */
|
|
88
|
+
value?: DateRange;
|
|
89
|
+
/** 默认选中的值 */
|
|
90
|
+
defaultValue?: DateRange;
|
|
91
|
+
/** 变化回调 */
|
|
92
|
+
onChange?: (range: DateRange) => void;
|
|
93
|
+
}
|
|
94
|
+
export type DatePickerProps = DatePickerSingleProps | DatePickerRangeProps;
|
|
95
|
+
declare const DatePicker: React.FC<DatePickerProps>;
|
|
96
|
+
export default DatePicker;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import Drawer from "./index";
|
|
3
|
+
declare const meta: Meta<typeof Drawer>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Drawer>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const Placements: Story;
|
|
8
|
+
export declare const NonControlled: Story;
|
|
9
|
+
export declare const MobileWidthDemo: Story;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type DrawerPlacement = "left" | "right" | "top" | "bottom";
|
|
3
|
+
export interface DrawerProps {
|
|
4
|
+
/** 是否打开(受控) */
|
|
5
|
+
open?: boolean;
|
|
6
|
+
/** 默认是否打开(非受控) */
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
/** 关闭回调 */
|
|
9
|
+
onClose?: (e?: React.MouseEvent | React.KeyboardEvent) => void;
|
|
10
|
+
/** 打开/关闭动画结束回调 */
|
|
11
|
+
afterOpenChange?: (open: boolean) => void;
|
|
12
|
+
/** 抽屉标题 */
|
|
13
|
+
title?: React.ReactNode;
|
|
14
|
+
/** 头部右侧内容 */
|
|
15
|
+
extra?: React.ReactNode;
|
|
16
|
+
/** 底部内容 */
|
|
17
|
+
footer?: React.ReactNode;
|
|
18
|
+
/** 内容 */
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/** 打开方向 */
|
|
21
|
+
placement?: DrawerPlacement;
|
|
22
|
+
/** PC 端宽度(移动端始终使用 100vw) */
|
|
23
|
+
width?: number | string;
|
|
24
|
+
/** 高度(top/bottom 生效,移动端同样支持) */
|
|
25
|
+
height?: number | string;
|
|
26
|
+
/** 是否显示遮罩 */
|
|
27
|
+
mask?: boolean;
|
|
28
|
+
/** 点击遮罩是否关闭 */
|
|
29
|
+
maskClosable?: boolean;
|
|
30
|
+
/** 是否显示右上角关闭按钮 */
|
|
31
|
+
closable?: boolean;
|
|
32
|
+
/** 自定义关闭图标 */
|
|
33
|
+
closeIcon?: React.ReactNode;
|
|
34
|
+
/** 是否支持 Esc 关闭 */
|
|
35
|
+
keyboard?: boolean;
|
|
36
|
+
/** 是否在关闭后销毁内容 */
|
|
37
|
+
destroyOnClose?: boolean;
|
|
38
|
+
/** 层级 */
|
|
39
|
+
zIndex?: number;
|
|
40
|
+
/** 移动端断点 */
|
|
41
|
+
mobileBreakpoint?: number;
|
|
42
|
+
/** 容器类名 */
|
|
43
|
+
className?: string;
|
|
44
|
+
/** 容器样式 */
|
|
45
|
+
style?: React.CSSProperties;
|
|
46
|
+
/** 抽屉面板类名 */
|
|
47
|
+
drawerStyle?: React.CSSProperties;
|
|
48
|
+
/** 头部样式 */
|
|
49
|
+
headerStyle?: React.CSSProperties;
|
|
50
|
+
/** 内容样式 */
|
|
51
|
+
bodyStyle?: React.CSSProperties;
|
|
52
|
+
/** 底部样式 */
|
|
53
|
+
footerStyle?: React.CSSProperties;
|
|
54
|
+
/** 遮罩样式 */
|
|
55
|
+
maskStyle?: React.CSSProperties;
|
|
56
|
+
}
|
|
57
|
+
declare const Drawer: React.FC<DrawerProps>;
|
|
58
|
+
export default Drawer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Form from './index';
|
|
3
|
+
declare const meta: Meta<typeof Form>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Form>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const Complete: Story;
|
|
8
|
+
export declare const Layouts: Story;
|
|
9
|
+
export declare const ValidationRules: Story;
|
|
10
|
+
export declare const WithFormInstance: Story;
|
|
11
|
+
export declare const WithHelpAndExtra: Story;
|
|
12
|
+
export declare const WithTooltip: Story;
|
|
13
|
+
export declare const ProgrammaticSubmit: Story;
|
|
14
|
+
export declare const SingleFieldOperations: Story;
|
|
15
|
+
export declare const FormLevelOperations: Story;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FieldData {
|
|
3
|
+
value?: any;
|
|
4
|
+
error?: string;
|
|
5
|
+
touched?: boolean;
|
|
6
|
+
validating?: boolean;
|
|
7
|
+
rules?: any[];
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface FormContextValue {
|
|
11
|
+
fields: Record<string, FieldData>;
|
|
12
|
+
getFieldValue: (name: string) => any;
|
|
13
|
+
setFieldValue: (name: string, value: any) => void;
|
|
14
|
+
getFieldError: (name: string) => string | undefined;
|
|
15
|
+
setFieldError: (name: string, error: string | undefined) => void;
|
|
16
|
+
isFieldTouched: (name: string) => boolean;
|
|
17
|
+
setFieldTouched: (name: string, touched: boolean) => void;
|
|
18
|
+
isFieldValidating: (name: string) => boolean;
|
|
19
|
+
setFieldValidating: (name: string, validating: boolean) => void;
|
|
20
|
+
registerField: (name: string, options: {
|
|
21
|
+
rules?: any[];
|
|
22
|
+
required?: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
unregisterField: (name: string) => void;
|
|
25
|
+
validateField: (name: string) => Promise<string | undefined>;
|
|
26
|
+
validateFields: (nameList?: string[]) => Promise<any>;
|
|
27
|
+
resetFields: (nameList?: string[]) => void;
|
|
28
|
+
getFieldsValue: (nameList?: string[]) => any;
|
|
29
|
+
setFieldsValue: (values: Record<string, any>) => void;
|
|
30
|
+
submit: () => Promise<any>;
|
|
31
|
+
setFields: (fields: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
value?: any;
|
|
34
|
+
errors?: string[];
|
|
35
|
+
}>) => void;
|
|
36
|
+
scrollToField: (name: string, options?: ScrollIntoViewOptions) => void;
|
|
37
|
+
registerFieldRef: (name: string, element: HTMLElement | null) => void;
|
|
38
|
+
labelWidth?: number | string;
|
|
39
|
+
labelAlign?: 'left' | 'right';
|
|
40
|
+
}
|
|
41
|
+
export declare const FormContext: React.Context<FormContextValue | null>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FormItemProps {
|
|
3
|
+
/** 字段名 */
|
|
4
|
+
name?: string;
|
|
5
|
+
/** 标签 */
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
/** 标签的 HTML for 属性 */
|
|
8
|
+
htmlFor?: string;
|
|
9
|
+
/** 标签布局 */
|
|
10
|
+
labelCol?: {
|
|
11
|
+
span?: number;
|
|
12
|
+
offset?: number;
|
|
13
|
+
};
|
|
14
|
+
/** 输入控件布局 */
|
|
15
|
+
wrapperCol?: {
|
|
16
|
+
span?: number;
|
|
17
|
+
offset?: number;
|
|
18
|
+
};
|
|
19
|
+
/** 是否必填(显示红色星号) */
|
|
20
|
+
required?: boolean;
|
|
21
|
+
/** 校验规则 */
|
|
22
|
+
rules?: Array<{
|
|
23
|
+
required?: boolean;
|
|
24
|
+
message?: string;
|
|
25
|
+
validator?: (rule: any, value: any) => Promise<void> | void;
|
|
26
|
+
pattern?: RegExp;
|
|
27
|
+
min?: number;
|
|
28
|
+
max?: number;
|
|
29
|
+
len?: number;
|
|
30
|
+
type?: 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email';
|
|
31
|
+
whitespace?: boolean;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}>;
|
|
34
|
+
/** 是否显示校验信息 */
|
|
35
|
+
hasFeedback?: boolean;
|
|
36
|
+
/** 校验状态 */
|
|
37
|
+
validateStatus?: 'success' | 'warning' | 'error' | 'validating';
|
|
38
|
+
/** 帮助信息 */
|
|
39
|
+
help?: React.ReactNode;
|
|
40
|
+
/** 额外的提示信息 */
|
|
41
|
+
extra?: React.ReactNode;
|
|
42
|
+
/** 自定义类名 */
|
|
43
|
+
className?: string;
|
|
44
|
+
/** 自定义样式 */
|
|
45
|
+
style?: React.CSSProperties;
|
|
46
|
+
/** 子元素 */
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
/** 标签对齐方式 */
|
|
49
|
+
labelAlign?: 'left' | 'right';
|
|
50
|
+
/** 标签宽度 */
|
|
51
|
+
labelWidth?: number | string;
|
|
52
|
+
/** 是否隐藏 */
|
|
53
|
+
hidden?: boolean;
|
|
54
|
+
/** 标签提示信息(tooltip) */
|
|
55
|
+
tooltip?: React.ReactNode;
|
|
56
|
+
}
|
|
57
|
+
declare const FormItem: React.FC<FormItemProps>;
|
|
58
|
+
export default FormItem;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FormItem from './FormItem';
|
|
3
|
+
export interface FormProps {
|
|
4
|
+
/** 表单初始值 */
|
|
5
|
+
initialValues?: Record<string, any>;
|
|
6
|
+
/** 表单值变化回调 */
|
|
7
|
+
onValuesChange?: (changedValues: Record<string, any>, allValues: Record<string, any>) => void;
|
|
8
|
+
/** 表单提交回调 */
|
|
9
|
+
onFinish?: (values: Record<string, any>) => void;
|
|
10
|
+
/** 表单提交失败回调 */
|
|
11
|
+
onFinishFailed?: (errorInfo: {
|
|
12
|
+
values: Record<string, any>;
|
|
13
|
+
errorFields: Array<{
|
|
14
|
+
name: string;
|
|
15
|
+
errors: string[];
|
|
16
|
+
}>;
|
|
17
|
+
}) => void;
|
|
18
|
+
/** 标签宽度 */
|
|
19
|
+
labelWidth?: number | string;
|
|
20
|
+
/** 标签对齐方式 */
|
|
21
|
+
labelAlign?: 'left' | 'right';
|
|
22
|
+
/** 布局方式 */
|
|
23
|
+
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
24
|
+
/** 尺寸 */
|
|
25
|
+
size?: 'small' | 'medium' | 'large';
|
|
26
|
+
/** 自定义类名 */
|
|
27
|
+
className?: string;
|
|
28
|
+
/** 自定义样式 */
|
|
29
|
+
style?: React.CSSProperties;
|
|
30
|
+
/** 子元素 */
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/** scrollToField 的选项,与 Element.scrollIntoView 一致 */
|
|
34
|
+
export type ScrollToFieldOptions = ScrollIntoViewOptions;
|
|
35
|
+
/** 校验失败时抛出的错误,携带 values 和 errorFields,便于 catch 后使用 */
|
|
36
|
+
export declare class FormValidationError extends Error {
|
|
37
|
+
/** 当前表单值 */
|
|
38
|
+
values: Record<string, any>;
|
|
39
|
+
/** 校验失败的字段列表 */
|
|
40
|
+
errorFields: Array<{
|
|
41
|
+
name: string;
|
|
42
|
+
errors: string[];
|
|
43
|
+
}>;
|
|
44
|
+
constructor(message: string, values: Record<string, any>, errorFields: Array<{
|
|
45
|
+
name: string;
|
|
46
|
+
errors: string[];
|
|
47
|
+
}>);
|
|
48
|
+
}
|
|
49
|
+
export interface FormInstance {
|
|
50
|
+
/** 获取字段值 */
|
|
51
|
+
getFieldValue: (name: string) => any;
|
|
52
|
+
/** 获取所有字段值 */
|
|
53
|
+
getFieldsValue: (nameList?: string[]) => any;
|
|
54
|
+
/** 设置字段值 */
|
|
55
|
+
setFieldValue: (name: string, value: any) => void;
|
|
56
|
+
/** 设置所有字段值 */
|
|
57
|
+
setFieldsValue: (values: Record<string, any>) => void;
|
|
58
|
+
/** 批量设置字段(值 + 错误),类似 antd 的 setFields */
|
|
59
|
+
setFields: (fields: Array<{
|
|
60
|
+
name: string;
|
|
61
|
+
value?: any;
|
|
62
|
+
errors?: string[];
|
|
63
|
+
}>) => void;
|
|
64
|
+
/** 获取字段错误 */
|
|
65
|
+
getFieldError: (name: string) => string | undefined;
|
|
66
|
+
/** 校验字段 */
|
|
67
|
+
validateField: (name: string) => Promise<string | undefined>;
|
|
68
|
+
/** 校验所有字段 */
|
|
69
|
+
validateFields: (nameList?: string[]) => Promise<any>;
|
|
70
|
+
/** 重置字段 */
|
|
71
|
+
resetFields: (nameList?: string[]) => void;
|
|
72
|
+
/** 提交表单:校验通过时 resolve 表单值,校验失败时 reject 为 FormValidationError(需 await 或 .catch() 才能捕获) */
|
|
73
|
+
submit: () => Promise<any>;
|
|
74
|
+
/** 滚动到指定字段(如第一个报错项) */
|
|
75
|
+
scrollToField: (name: string, options?: ScrollToFieldOptions) => void;
|
|
76
|
+
}
|
|
77
|
+
declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<FormInstance>>;
|
|
78
|
+
/** 获取表单实例的 hook,用法与 antd Form.useForm() 一致,返回的 ref 传给 <Form ref={formRef} /> 后即可使用 formRef.current?.setFieldValue 等方法 */
|
|
79
|
+
declare function useForm(): [React.RefObject<FormInstance | null>];
|
|
80
|
+
declare const FormWithItem: typeof Form & {
|
|
81
|
+
Item: typeof FormItem;
|
|
82
|
+
useForm: typeof useForm;
|
|
83
|
+
};
|
|
84
|
+
export default FormWithItem;
|
|
85
|
+
export { useForm };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Input from './index';
|
|
3
|
+
declare const meta: Meta<typeof Input>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Input>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const Sizes: Story;
|
|
8
|
+
export declare const Disabled: Story;
|
|
9
|
+
export declare const Error: Story;
|
|
10
|
+
export declare const ReadOnly: Story;
|
|
11
|
+
export declare const WithPrefix: Story;
|
|
12
|
+
export declare const WithSuffix: Story;
|
|
13
|
+
export declare const WithClear: Story;
|
|
14
|
+
export declare const WithPressEnter: Story;
|
|
15
|
+
export declare const Controlled: Story;
|
|
16
|
+
export declare const AllStates: Story;
|
|
@@ -9,8 +9,11 @@ export declare const Disabled: Story;
|
|
|
9
9
|
export declare const Error: Story;
|
|
10
10
|
export declare const ReadOnly: Story;
|
|
11
11
|
export declare const WithPrefix: Story;
|
|
12
|
-
export declare const WithSuffix: Story;
|
|
13
12
|
export declare const WithClear: Story;
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
13
|
+
export declare const LeadingText: Story;
|
|
14
|
+
export declare const LeadingDropdown: Story;
|
|
15
|
+
export declare const TrailingDropdown: Story;
|
|
16
|
+
export declare const TrailingButton: Story;
|
|
17
|
+
export declare const PaymentInput: Story;
|
|
18
|
+
export declare const Tags: Story;
|
|
19
|
+
export declare const AllVariants: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface InputGroupProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'suffix'> {
|
|
3
|
+
size?: 'small' | 'mediumSmall' | 'medium' | 'large';
|
|
4
|
+
error?: boolean;
|
|
5
|
+
readOnly?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
prefix?: React.ReactNode;
|
|
8
|
+
suffix?: React.ReactNode;
|
|
9
|
+
/** Text addon on the left (e.g. "https://") — auto-styled with correct padding */
|
|
10
|
+
leadingText?: React.ReactNode;
|
|
11
|
+
/** Text addon on the right (e.g. "USD") — auto-styled with correct padding */
|
|
12
|
+
trailingText?: React.ReactNode;
|
|
13
|
+
/** Raw ReactNode on the left (dropdown, icon button, etc.) — no padding added */
|
|
14
|
+
leadingAddon?: React.ReactNode;
|
|
15
|
+
/** Raw ReactNode on the right (button, select, etc.) — no padding added */
|
|
16
|
+
trailingAddon?: React.ReactNode;
|
|
17
|
+
onPressEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
label?: string;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
hintText?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const InputGroup: React.ForwardRefExoticComponent<InputGroupProps & React.RefAttributes<HTMLInputElement>>;
|
|
25
|
+
export default InputGroup;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface InputTagsProps {
|
|
3
|
+
value?: string[];
|
|
4
|
+
defaultValue?: string[];
|
|
5
|
+
onChange?: (tags: string[]) => void;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
error?: boolean;
|
|
9
|
+
size?: 'small' | 'mediumSmall' | 'medium' | 'large';
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
label?: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
hintText?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const InputTags: React.FC<InputTagsProps>;
|
|
17
|
+
export default InputTags;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'suffix'> {
|
|
3
|
+
/** 输入框大小 */
|
|
4
|
+
size?: 'small' | 'mediumSmall' | 'medium' | 'large';
|
|
5
|
+
/** 是否禁用 */
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/** 是否显示错误状态 */
|
|
8
|
+
error?: boolean;
|
|
9
|
+
/** 是否只读 */
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
/** 输入框前缀图标 */
|
|
12
|
+
prefix?: React.ReactNode;
|
|
13
|
+
/** 输入框后缀图标 */
|
|
14
|
+
suffix?: React.ReactNode;
|
|
15
|
+
/** 允许清除 */
|
|
16
|
+
allowClear?: boolean;
|
|
17
|
+
/** 清除回调 */
|
|
18
|
+
onClear?: () => void;
|
|
19
|
+
/** 自定义类名 */
|
|
20
|
+
className?: string;
|
|
21
|
+
/** 自定义样式 */
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
/** 输入框类型 */
|
|
24
|
+
type?: string;
|
|
25
|
+
/** 占位符 */
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** 值 */
|
|
28
|
+
value?: string;
|
|
29
|
+
/** 默认值 */
|
|
30
|
+
defaultValue?: string;
|
|
31
|
+
/** 变化回调 */
|
|
32
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
33
|
+
/** 聚焦回调 */
|
|
34
|
+
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
35
|
+
/** 失焦回调 */
|
|
36
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
37
|
+
/** 按下回车回调 */
|
|
38
|
+
onPressEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
39
|
+
}
|
|
40
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
41
|
+
export default Input;
|
|
@@ -1,41 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'suffix'> {
|
|
3
|
-
/** 输入框大小 */
|
|
4
3
|
size?: 'small' | 'mediumSmall' | 'medium' | 'large';
|
|
5
|
-
/** 是否禁用 */
|
|
6
4
|
disabled?: boolean;
|
|
7
|
-
/** 是否显示错误状态 */
|
|
8
5
|
error?: boolean;
|
|
9
|
-
/** 是否只读 */
|
|
10
6
|
readOnly?: boolean;
|
|
11
|
-
/** 输入框前缀图标 */
|
|
12
7
|
prefix?: React.ReactNode;
|
|
13
|
-
/** 输入框后缀图标 */
|
|
14
8
|
suffix?: React.ReactNode;
|
|
15
|
-
/** 允许清除 */
|
|
16
9
|
allowClear?: boolean;
|
|
17
|
-
/** 清除回调 */
|
|
18
10
|
onClear?: () => void;
|
|
19
|
-
/** 自定义类名 */
|
|
20
11
|
className?: string;
|
|
21
|
-
/** 自定义样式 */
|
|
22
12
|
style?: React.CSSProperties;
|
|
23
|
-
/** 输入框类型 */
|
|
24
13
|
type?: string;
|
|
25
|
-
/** 占位符 */
|
|
26
14
|
placeholder?: string;
|
|
27
|
-
/** 值 */
|
|
28
15
|
value?: string;
|
|
29
|
-
/** 默认值 */
|
|
30
16
|
defaultValue?: string;
|
|
31
|
-
/** 变化回调 */
|
|
32
17
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
33
|
-
/** 聚焦回调 */
|
|
34
18
|
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
35
|
-
/** 失焦回调 */
|
|
36
19
|
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
37
|
-
/** 按下回车回调 */
|
|
38
20
|
onPressEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
21
|
+
label?: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
hintText?: string;
|
|
39
24
|
}
|
|
40
25
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
41
26
|
export default Input;
|
|
27
|
+
export { default as InputGroup } from './InputGroup';
|
|
28
|
+
export type { InputGroupProps } from './InputGroup';
|
|
29
|
+
export { default as InputTags } from './InputTags';
|
|
30
|
+
export type { InputTagsProps } from './InputTags';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Loading from './index';
|
|
3
|
+
import '../../index.css';
|
|
4
|
+
declare const meta: Meta<typeof Loading>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<typeof Loading>;
|
|
7
|
+
export declare const Basic: Story;
|
|
8
|
+
export declare const DifferentSizes: Story;
|
|
9
|
+
export declare const CustomColors: Story;
|
|
10
|
+
export declare const StrokeWidthVariants: Story;
|
|
11
|
+
export declare const InlineUsage: Story;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import MenuList from './index';
|
|
3
|
+
declare const meta: Meta<typeof MenuList>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof MenuList>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const WithoutIcons: Story;
|
|
8
|
+
export declare const MixedIcons: Story;
|
|
9
|
+
export declare const FullExample: Story;
|
|
10
|
+
export declare const WithUserProfile: Story;
|
|
11
|
+
export declare const WithDisabled: Story;
|
|
12
|
+
export declare const WithDanger: Story;
|
|
13
|
+
export declare const Controlled: Story;
|
|
14
|
+
export declare const CustomRender: Story;
|
|
15
|
+
export declare const CustomUserProfile: Story;
|
|
16
|
+
export declare const ClickEvents: Story;
|
|
17
|
+
export declare const UnifiedClickEvent: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MenuItemType {
|
|
3
|
+
/** 唯一标识 */
|
|
4
|
+
key: string;
|
|
5
|
+
/** 菜单项标签 */
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
/** 菜单项图标 */
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
/** 菜单项右侧图标 */
|
|
10
|
+
suffixIcon?: React.ReactNode;
|
|
11
|
+
/** 是否禁用 */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** 是否危险项(红色) */
|
|
14
|
+
danger?: boolean;
|
|
15
|
+
/** 自定义渲染函数,如果提供则完全自定义该项的渲染 */
|
|
16
|
+
render?: (item: MenuItemType, isSelected: boolean) => React.ReactNode;
|
|
17
|
+
/** 自定义类名 */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** 自定义样式 */
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
/** 点击事件 */
|
|
22
|
+
onClick?: (info: {
|
|
23
|
+
key: string;
|
|
24
|
+
keyPath: string[];
|
|
25
|
+
}) => void;
|
|
26
|
+
/** 是否跳过全局点击事件(MenuList 的 onClick),默认为 false */
|
|
27
|
+
skipGlobalClick?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface MenuGroupType {
|
|
30
|
+
/** 分组标题 */
|
|
31
|
+
title?: React.ReactNode;
|
|
32
|
+
/** 分组下的菜单项 */
|
|
33
|
+
children: MenuItemType[];
|
|
34
|
+
/** 自定义类名 */
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface UserProfileType {
|
|
38
|
+
/** 用户头像 */
|
|
39
|
+
avatar?: React.ReactNode;
|
|
40
|
+
/** 用户姓名 */
|
|
41
|
+
name: React.ReactNode;
|
|
42
|
+
/** 用户邮箱 */
|
|
43
|
+
email?: React.ReactNode;
|
|
44
|
+
/** 在线状态 */
|
|
45
|
+
online?: boolean;
|
|
46
|
+
/** 自定义渲染函数,如果提供则完全自定义用户资料的渲染 */
|
|
47
|
+
render?: (profile: UserProfileType) => React.ReactNode;
|
|
48
|
+
/** 点击事件 */
|
|
49
|
+
onClick?: () => void;
|
|
50
|
+
}
|
|
51
|
+
export interface MenuListProps {
|
|
52
|
+
/** 菜单项数据 */
|
|
53
|
+
items: (MenuItemType | MenuGroupType)[];
|
|
54
|
+
/** 用户资料信息(显示在顶部) */
|
|
55
|
+
userProfile?: UserProfileType;
|
|
56
|
+
/** 当前选中的菜单项 key */
|
|
57
|
+
selectedKeys?: string[];
|
|
58
|
+
/** 默认选中的菜单项 key */
|
|
59
|
+
defaultSelectedKeys?: string[];
|
|
60
|
+
/** 选中项变化时的回调 */
|
|
61
|
+
onSelect?: (info: {
|
|
62
|
+
key: string;
|
|
63
|
+
keyPath: string[];
|
|
64
|
+
selectedKeys: string[];
|
|
65
|
+
}) => void;
|
|
66
|
+
/** 取消选中时的回调 */
|
|
67
|
+
onDeselect?: (info: {
|
|
68
|
+
key: string;
|
|
69
|
+
keyPath: string[];
|
|
70
|
+
selectedKeys: string[];
|
|
71
|
+
}) => void;
|
|
72
|
+
/** 统一的点击事件,无论点击哪个子项都会触发 */
|
|
73
|
+
onClick?: (info: {
|
|
74
|
+
key: string;
|
|
75
|
+
keyPath: string[];
|
|
76
|
+
}) => void;
|
|
77
|
+
/** 自定义类名 */
|
|
78
|
+
className?: string;
|
|
79
|
+
/** 自定义样式 */
|
|
80
|
+
style?: React.CSSProperties;
|
|
81
|
+
/** 菜单宽度 */
|
|
82
|
+
width?: number | string;
|
|
83
|
+
}
|
|
84
|
+
declare const MenuList: React.FC<MenuListProps>;
|
|
85
|
+
export default MenuList;
|