aha-components 1.7.12 → 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/README.md +10 -0
- package/dist/Avatar.esm.js +2 -0
- package/dist/Avatar.esm.js.map +1 -0
- package/dist/Avatar.js +2 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.esm.js +2 -0
- package/dist/Badge.esm.js.map +1 -0
- package/dist/Badge.js +2 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Checkbox.esm.js +1 -1
- package/dist/Checkbox.esm.js.map +1 -1
- package/dist/Checkbox.js +1 -1
- package/dist/Checkbox.js.map +1 -1
- 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/Radio.esm.js +1 -1
- package/dist/Radio.esm.js.map +1 -1
- package/dist/Radio.js +1 -1
- package/dist/Radio.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/Tag.esm.js +1 -1
- package/dist/Tag.esm.js.map +1 -1
- package/dist/Tag.js +1 -1
- package/dist/Tag.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/Avatar/Avatar.stories.d.ts +12 -0
- package/dist/components/Avatar/index.d.ts +42 -0
- package/dist/components/Badge/Badge.stories.d.ts +15 -0
- package/dist/components/Badge/index.d.ts +71 -0
- package/dist/components/Checkbox/Checkbox.stories 2.d.ts +12 -0
- package/dist/components/Checkbox/Checkbox.stories.d.ts +5 -4
- package/dist/components/Checkbox/index 2.d.ts +12 -0
- package/dist/components/Checkbox/index.d.ts +6 -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/Radio.stories.d.ts +6 -4
- package/dist/components/Radio/index 2.d.ts +13 -0
- package/dist/components/Radio/index.d.ts +6 -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/Tag/Tag.stories.d.ts +5 -8
- package/dist/components/Tag/index.d.ts +24 -2
- 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/design-tokens/theme.css +26 -0
- package/dist/design-tokens/theme.tailwind4.css +26 -0
- package/dist/icons/index 2.d.ts +33 -0
- package/dist/index.css +4810 -1
- package/dist/index.d.ts +195 -39
- package/dist/index.esm.css +4810 -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/theme.css +26 -0
- package/dist/tokens.d.ts +30 -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,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MouseEventHandler, ReactNode } from 'react';
|
|
3
|
+
export type BadgeColor = 'gray' | 'brand' | 'error' | 'warning' | 'success' | 'grayBlue' | 'blueLight' | 'blue' | 'indigo' | 'purple' | 'pink' | 'orange';
|
|
4
|
+
export type BadgeVariant = 'pill' | 'badge' | 'modern';
|
|
5
|
+
export type BadgeSize = 'sm' | 'md' | 'lg';
|
|
6
|
+
export type BadgeIconComponent = React.FC<{
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export interface BadgeProps {
|
|
11
|
+
variant?: BadgeVariant;
|
|
12
|
+
size?: BadgeSize;
|
|
13
|
+
color?: BadgeColor;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const Badge: React.FC<BadgeProps>;
|
|
19
|
+
export interface BadgeWithDotProps {
|
|
20
|
+
variant?: BadgeVariant;
|
|
21
|
+
size?: BadgeSize;
|
|
22
|
+
color?: BadgeColor;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const BadgeWithDot: React.FC<BadgeWithDotProps>;
|
|
28
|
+
export interface BadgeWithIconProps {
|
|
29
|
+
variant?: BadgeVariant;
|
|
30
|
+
size?: BadgeSize;
|
|
31
|
+
color?: BadgeColor;
|
|
32
|
+
iconLeading?: BadgeIconComponent;
|
|
33
|
+
iconTrailing?: BadgeIconComponent;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
style?: React.CSSProperties;
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare const BadgeWithIcon: React.FC<BadgeWithIconProps>;
|
|
39
|
+
export interface BadgeWithButtonProps {
|
|
40
|
+
variant?: BadgeVariant;
|
|
41
|
+
size?: BadgeSize;
|
|
42
|
+
color?: BadgeColor;
|
|
43
|
+
icon?: BadgeIconComponent;
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
buttonLabel?: string;
|
|
46
|
+
onButtonClick?: MouseEventHandler<HTMLButtonElement>;
|
|
47
|
+
style?: React.CSSProperties;
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const BadgeWithButton: React.FC<BadgeWithButtonProps>;
|
|
51
|
+
export interface BadgeIconProps {
|
|
52
|
+
variant?: BadgeVariant;
|
|
53
|
+
size?: BadgeSize;
|
|
54
|
+
color?: BadgeColor;
|
|
55
|
+
icon: BadgeIconComponent;
|
|
56
|
+
style?: React.CSSProperties;
|
|
57
|
+
className?: string;
|
|
58
|
+
}
|
|
59
|
+
export declare const BadgeIcon: React.FC<BadgeIconProps>;
|
|
60
|
+
export interface BadgeWithImageProps {
|
|
61
|
+
variant?: Exclude<BadgeVariant, 'modern'>;
|
|
62
|
+
size?: BadgeSize;
|
|
63
|
+
color?: BadgeColor;
|
|
64
|
+
imgSrc: string;
|
|
65
|
+
imgAlt?: string;
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
style?: React.CSSProperties;
|
|
68
|
+
className?: string;
|
|
69
|
+
}
|
|
70
|
+
export declare const BadgeWithImage: React.FC<BadgeWithImageProps>;
|
|
71
|
+
export default Badge;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Checkbox from './index';
|
|
3
|
+
declare const meta: Meta<typeof Checkbox>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Checkbox>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const WithLabel: Story;
|
|
8
|
+
export declare const Checked: Story;
|
|
9
|
+
export declare const Indeterminate: Story;
|
|
10
|
+
export declare const Disabled: Story;
|
|
11
|
+
export declare const AllStates: Story;
|
|
12
|
+
export declare const Controlled: Story;
|
|
@@ -3,10 +3,11 @@ import Checkbox from './index';
|
|
|
3
3
|
declare const meta: Meta<typeof Checkbox>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof Checkbox>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const Default: Story;
|
|
7
7
|
export declare const WithLabel: Story;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const Disabled: Story;
|
|
8
|
+
export declare const WithHint: Story;
|
|
9
|
+
export declare const Sizes: Story;
|
|
11
10
|
export declare const AllStates: Story;
|
|
11
|
+
export declare const Focused: Story;
|
|
12
|
+
export declare const WithHintAllStates: Story;
|
|
12
13
|
export declare const Controlled: Story;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CheckboxProps {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
indeterminate?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
declare const Checkbox: React.FC<CheckboxProps>;
|
|
12
|
+
export default Checkbox;
|
|
@@ -7,6 +7,12 @@ export interface CheckboxProps {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
style?: React.CSSProperties;
|
|
9
9
|
children?: React.ReactNode;
|
|
10
|
+
/** sm = 16px, md = 20px */
|
|
11
|
+
size?: 'sm' | 'md';
|
|
12
|
+
/** Secondary description rendered below the label */
|
|
13
|
+
hint?: React.ReactNode;
|
|
14
|
+
/** Force focused appearance (useful for Storybook demos) */
|
|
15
|
+
isFocused?: boolean;
|
|
10
16
|
}
|
|
11
17
|
declare const Checkbox: React.FC<CheckboxProps>;
|
|
12
18
|
export default Checkbox;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import DatePicker from './index';
|
|
3
|
+
declare const meta: Meta<typeof DatePicker>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof DatePicker>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const Sizes: Story;
|
|
8
|
+
export declare const RangeWithPresets: Story;
|
|
9
|
+
export declare const RangeWithPresetsAndDoubleCalendar: Story;
|
|
10
|
+
export declare const RangeDoubleCalendar: Story;
|
|
11
|
+
export declare const RangeWithCustomPresets: Story;
|
|
12
|
+
export declare const Disabled: Story;
|
|
13
|
+
export declare const Error: Story;
|
|
14
|
+
export declare const WithClear: Story;
|
|
15
|
+
export declare const CustomFormat: Story;
|
|
16
|
+
export declare const Controlled: Story;
|
|
17
|
+
export declare const WithDateRange: Story;
|
|
18
|
+
export declare const AllStates: Story;
|
|
19
|
+
export declare const RangeMode: Story;
|
|
20
|
+
export declare const RangeWithDefault: Story;
|
|
21
|
+
export declare const RangeCustomFormat: Story;
|
|
22
|
+
export declare const CustomPlaceholders: Story;
|
|
23
|
+
export declare const ShowSelectedRange: Story;
|
|
24
|
+
export declare const RangeDisplayMode: Story;
|
|
25
|
+
export declare const TextModeWithSelectedRange: Story;
|
|
@@ -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;
|