@xto/form 1.6.8 → 1.7.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 (75) hide show
  1. package/es/AutoComplete/index.d.ts +29 -0
  2. package/es/AutoComplete/index.vue.d.ts +70 -0
  3. package/es/Cascader/index.d.ts +40 -0
  4. package/es/Cascader/index.vue.d.ts +58 -0
  5. package/es/Checkbox/group.vue.d.ts +34 -0
  6. package/es/Checkbox/index.d.ts +49 -0
  7. package/es/Checkbox/index.vue.d.ts +31 -0
  8. package/es/Checkbox/types.d.ts +106 -0
  9. package/es/ColorPicker/index.d.ts +15 -0
  10. package/es/ColorPicker/index.vue.d.ts +29 -0
  11. package/es/DatePicker/components/DateTable.vue.d.ts +36 -0
  12. package/es/DatePicker/components/MonthTable.vue.d.ts +14 -0
  13. package/es/DatePicker/components/YearTable.vue.d.ts +14 -0
  14. package/es/DatePicker/index.d.ts +35 -0
  15. package/es/DatePicker/index.vue.d.ts +57 -0
  16. package/es/DatePicker/types.d.ts +112 -0
  17. package/es/DatePicker/utils.d.ts +21 -0
  18. package/es/DynamicFields/index.d.ts +2 -0
  19. package/es/DynamicFields/index.vue.d.ts +52 -0
  20. package/es/DynamicFields/types.d.ts +36 -0
  21. package/es/Form/index.d.ts +77 -0
  22. package/es/Form/index.vue.d.ts +64 -0
  23. package/es/Form/item.vue.d.ts +31 -0
  24. package/es/Form/types.d.ts +239 -0
  25. package/es/Form/validators.d.ts +60 -0
  26. package/es/Input/index.d.ts +29 -0
  27. package/es/Input/index.vue.d.ts +70 -0
  28. package/es/Input/types.d.ts +97 -0
  29. package/es/InputNumber/index.vue.d.ts +57 -0
  30. package/es/InputNumber/types.d.ts +83 -0
  31. package/es/Mention/index.d.ts +27 -0
  32. package/es/Mention/index.vue.d.ts +45 -0
  33. package/es/Radio/button.vue.d.ts +29 -0
  34. package/es/Radio/group.vue.d.ts +35 -0
  35. package/es/Radio/index.d.ts +61 -0
  36. package/es/Radio/index.vue.d.ts +30 -0
  37. package/es/Radio/types.d.ts +83 -0
  38. package/es/Rate/index.d.ts +41 -0
  39. package/es/Rate/index.vue.d.ts +49 -0
  40. package/es/Rate/types.d.ts +71 -0
  41. package/es/RichEditor/index.d.ts +19 -0
  42. package/es/RichEditor/index.vue.d.ts +41 -0
  43. package/es/Segmented/index.d.ts +20 -0
  44. package/es/Segmented/index.vue.d.ts +52 -0
  45. package/es/Select/Option.vue.d.ts +9 -0
  46. package/es/Select/index.d.ts +48 -0
  47. package/es/Select/index.vue.d.ts +93 -0
  48. package/es/Select/types.d.ts +137 -0
  49. package/es/Select/utils.d.ts +8 -0
  50. package/es/Slider/index.d.ts +52 -0
  51. package/es/Slider/index.vue.d.ts +39 -0
  52. package/es/Slider/types.d.ts +77 -0
  53. package/es/Switch/index.d.ts +16 -0
  54. package/es/Switch/index.vue.d.ts +44 -0
  55. package/es/Switch/types.d.ts +69 -0
  56. package/es/Textarea/index.d.ts +48 -0
  57. package/es/Textarea/index.vue.d.ts +51 -0
  58. package/es/Textarea/types.d.ts +91 -0
  59. package/es/TimePicker/components/TimePanel.vue.d.ts +28 -0
  60. package/es/TimePicker/index.d.ts +39 -0
  61. package/es/TimePicker/index.vue.d.ts +57 -0
  62. package/es/TimePicker/types.d.ts +117 -0
  63. package/es/TimePicker/utils.d.ts +10 -0
  64. package/es/Transfer/index.d.ts +58 -0
  65. package/es/Transfer/index.vue.d.ts +62 -0
  66. package/es/Transfer/types.d.ts +117 -0
  67. package/es/Upload/index.d.ts +110 -0
  68. package/es/Upload/index.vue.d.ts +140 -0
  69. package/es/Upload/types.d.ts +238 -0
  70. package/es/index.d.ts +41 -0
  71. package/es/index.mjs +504 -497
  72. package/es/style.css +1 -1
  73. package/lib/index.cjs +1 -1
  74. package/lib/style.css +1 -1
  75. package/package.json +10 -10
@@ -0,0 +1,112 @@
1
+ import { ComponentSize } from '@xto/core';
2
+ /**
3
+ * DatePicker 类型
4
+ */
5
+ export type DatePickerType = 'date' | 'daterange' | 'month' | 'year';
6
+ /**
7
+ * DatePicker Props
8
+ */
9
+ export interface DatePickerProps {
10
+ /**
11
+ * 绑定值
12
+ */
13
+ modelValue?: Date | string | number | [Date | string | number, Date | string | number] | null;
14
+ /**
15
+ * 绑定值(备用)
16
+ */
17
+ value?: Date | string | number | [Date | string | number, Date | string | number] | null;
18
+ /**
19
+ * 选择器类型
20
+ * @default 'date'
21
+ */
22
+ type?: DatePickerType;
23
+ /**
24
+ * 占位符
25
+ * @default '请选择日期'
26
+ */
27
+ placeholder?: string;
28
+ /**
29
+ * 开始日期占位符
30
+ * @default '开始日期'
31
+ */
32
+ startPlaceholder?: string;
33
+ /**
34
+ * 结束日期占位符
35
+ * @default '结束日期'
36
+ */
37
+ endPlaceholder?: string;
38
+ /**
39
+ * 是否禁用
40
+ * @default false
41
+ */
42
+ disabled?: boolean;
43
+ /**
44
+ * 是否只读
45
+ * @default false
46
+ */
47
+ readonly?: boolean;
48
+ /**
49
+ * 是否可清空
50
+ * @default false
51
+ */
52
+ clearable?: boolean;
53
+ /**
54
+ * 选择器尺寸
55
+ * @default 'default'
56
+ */
57
+ size?: ComponentSize;
58
+ /**
59
+ * 显示格式
60
+ * @default 'YYYY-MM-DD'
61
+ */
62
+ format?: string;
63
+ /**
64
+ * 值格式
65
+ */
66
+ valueFormat?: string;
67
+ /**
68
+ * 禁用日期函数
69
+ */
70
+ disabledDate?: (date: Date) => boolean;
71
+ /**
72
+ * 最小日期
73
+ */
74
+ minDate?: Date | string | null;
75
+ /**
76
+ * 最大日期
77
+ */
78
+ maxDate?: Date | string | null;
79
+ /**
80
+ * 是否显示时间选择
81
+ * @default false
82
+ */
83
+ showTime?: boolean;
84
+ }
85
+ /**
86
+ * DatePicker Emits
87
+ */
88
+ export interface DatePickerEmits {
89
+ (e: 'update:modelValue', value: Date | string | number | [Date | string | number, Date | string | number] | null): void;
90
+ (e: 'update:value', value: Date | string | number | [Date | string | number, Date | string | number] | null): void;
91
+ (e: 'change', value: Date | string | number | [Date | string | number, Date | string | number] | null): void;
92
+ (e: 'focus', event: FocusEvent): void;
93
+ (e: 'blur', event: FocusEvent): void;
94
+ (e: 'clear'): void;
95
+ }
96
+ /**
97
+ * DatePicker Expose
98
+ */
99
+ export interface DatePickerExpose {
100
+ /**
101
+ * 获取焦点
102
+ */
103
+ focus: () => void;
104
+ /**
105
+ * 失去焦点
106
+ */
107
+ blur: () => void;
108
+ }
109
+ /**
110
+ * DatePicker 组件实例类型
111
+ */
112
+ export type DatePickerInstance = InstanceType<typeof import('./index.vue').default>;
@@ -0,0 +1,21 @@
1
+ export declare function getDaysInMonth(year: number, month: number): number;
2
+ export declare function getFirstDayOfMonth(year: number, month: number): number;
3
+ export declare function isSameDay(date1: Date, date2: Date): boolean;
4
+ export declare function isSameMonth(date1: Date, date2: Date): boolean;
5
+ export declare function isSameYear(date1: Date, date2: Date): boolean;
6
+ export declare function isDateInRange(date: Date, startDate: Date | null, endDate: Date | null): boolean;
7
+ export declare function getWeekDays(date: Date, firstDayOfWeek?: number): Date[];
8
+ export declare function getMonthWeeks(year: number, month: number, firstDayOfWeek?: number): Date[][];
9
+ export declare function formatDate(date: Date | null | undefined, format?: string): string;
10
+ export declare function parseDate(value: string | Date | number | null | undefined | unknown): Date | null;
11
+ export declare function getPrevMonth(date: Date): Date;
12
+ export declare function getNextMonth(date: Date): Date;
13
+ export declare function getPrevYear(date: Date): Date;
14
+ export declare function getNextYear(date: Date): Date;
15
+ export declare function getDecadeRange(year: number): [number, number];
16
+ export declare function cloneDate(date: Date): Date;
17
+ export declare function clearTime(date: Date): Date;
18
+ export declare function isDateDisabled(date: Date, disabledDate?: (date: Date) => boolean, minDate?: Date | null, maxDate?: Date | null): boolean;
19
+ export declare const monthNames: string[];
20
+ export declare const weekNames: string[];
21
+ export declare const weekNamesShort: string[];
@@ -0,0 +1,2 @@
1
+ export { default as DynamicFields } from './index.vue';
2
+ export type { DynamicField, DynamicFieldsProps, DynamicFieldsEmits } from './types';
@@ -0,0 +1,52 @@
1
+ export interface DynamicField {
2
+ id: string;
3
+ name: string;
4
+ label: string;
5
+ type: 'input' | 'textarea' | 'select' | 'number' | 'switch' | 'date' | 'file';
6
+ required?: boolean;
7
+ defaultValue?: any;
8
+ placeholder?: string;
9
+ options?: Array<{
10
+ label: string;
11
+ value: any;
12
+ }>;
13
+ order?: number;
14
+ }
15
+ export interface DynamicFieldsProps {
16
+ /** 字段列表 */
17
+ fields?: DynamicField[];
18
+ /** 是否可编辑 */
19
+ editable?: boolean;
20
+ /** 是否显示排序按钮 */
21
+ showSort?: boolean;
22
+ /** 最大字段数 */
23
+ maxFields?: number;
24
+ /** 可用的字段类型 */
25
+ availableTypes?: Array<{
26
+ label: string;
27
+ value: string;
28
+ }>;
29
+ }
30
+ declare const _default: import('vue').DefineComponent<DynamicFieldsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
31
+ sort: (fields: DynamicField[]) => any;
32
+ add: (field: DynamicField) => any;
33
+ remove: (fieldId: string) => any;
34
+ "update:fields": (fields: DynamicField[]) => any;
35
+ update: (fieldId: string, field: DynamicField) => any;
36
+ }, string, import('vue').PublicProps, Readonly<DynamicFieldsProps> & Readonly<{
37
+ onSort?: ((fields: DynamicField[]) => any) | undefined;
38
+ onAdd?: ((field: DynamicField) => any) | undefined;
39
+ onRemove?: ((fieldId: string) => any) | undefined;
40
+ "onUpdate:fields"?: ((fields: DynamicField[]) => any) | undefined;
41
+ onUpdate?: ((fieldId: string, field: DynamicField) => any) | undefined;
42
+ }>, {
43
+ fields: DynamicField[];
44
+ editable: boolean;
45
+ showSort: boolean;
46
+ maxFields: number;
47
+ availableTypes: Array<{
48
+ label: string;
49
+ value: string;
50
+ }>;
51
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
52
+ export default _default;
@@ -0,0 +1,36 @@
1
+ export interface DynamicField {
2
+ id: string;
3
+ name: string;
4
+ label: string;
5
+ type: 'input' | 'textarea' | 'select' | 'number' | 'switch' | 'date' | 'file';
6
+ required?: boolean;
7
+ defaultValue?: any;
8
+ placeholder?: string;
9
+ options?: Array<{
10
+ label: string;
11
+ value: any;
12
+ }>;
13
+ order?: number;
14
+ }
15
+ export interface DynamicFieldsProps {
16
+ /** 字段列表 */
17
+ fields?: DynamicField[];
18
+ /** 是否可编辑 */
19
+ editable?: boolean;
20
+ /** 是否显示排序按钮 */
21
+ showSort?: boolean;
22
+ /** 最大字段数 */
23
+ maxFields?: number;
24
+ /** 可用的字段类型 */
25
+ availableTypes?: Array<{
26
+ label: string;
27
+ value: string;
28
+ }>;
29
+ }
30
+ export interface DynamicFieldsEmits {
31
+ 'update:fields': [fields: DynamicField[]];
32
+ 'add': [field: DynamicField];
33
+ 'remove': [fieldId: string];
34
+ 'sort': [fields: DynamicField[]];
35
+ 'update': [fieldId: string, field: DynamicField];
36
+ }
@@ -0,0 +1,77 @@
1
+ import { ExtractPropTypes, PropType } from 'vue';
2
+ export interface FormRule {
3
+ required?: boolean;
4
+ message?: string;
5
+ trigger?: 'blur' | 'change';
6
+ min?: number;
7
+ max?: number;
8
+ pattern?: RegExp;
9
+ validator?: (rule: FormRule, value: any, callback: (error?: Error) => void) => void;
10
+ }
11
+ export interface FormItemContext {
12
+ prop: string;
13
+ validate: (trigger?: string) => Promise<boolean>;
14
+ resetField: () => void;
15
+ clearValidate: () => void;
16
+ }
17
+ export declare const formProps: {
18
+ readonly model: {
19
+ readonly type: PropType<Record<string, any>>;
20
+ readonly default: () => {};
21
+ };
22
+ readonly rules: {
23
+ readonly type: PropType<Record<string, FormRule[]>>;
24
+ readonly default: () => {};
25
+ };
26
+ readonly labelWidth: {
27
+ readonly type: PropType<string | number>;
28
+ readonly default: "100px";
29
+ };
30
+ readonly labelPosition: {
31
+ readonly type: PropType<"left" | "right" | "top">;
32
+ readonly default: "right";
33
+ };
34
+ readonly inline: {
35
+ readonly type: BooleanConstructor;
36
+ readonly default: false;
37
+ };
38
+ readonly disabled: {
39
+ readonly type: BooleanConstructor;
40
+ readonly default: false;
41
+ };
42
+ readonly size: {
43
+ readonly type: PropType<"large" | "default" | "small">;
44
+ readonly default: "default";
45
+ };
46
+ };
47
+ export declare const formItemProps: {
48
+ readonly prop: {
49
+ readonly type: StringConstructor;
50
+ readonly default: undefined;
51
+ };
52
+ readonly label: {
53
+ readonly type: StringConstructor;
54
+ readonly default: undefined;
55
+ };
56
+ readonly labelWidth: {
57
+ readonly type: PropType<string | number>;
58
+ readonly default: undefined;
59
+ };
60
+ readonly required: {
61
+ readonly type: BooleanConstructor;
62
+ readonly default: false;
63
+ };
64
+ readonly rules: {
65
+ readonly type: PropType<FormRule[]>;
66
+ readonly default: undefined;
67
+ };
68
+ readonly showMessage: {
69
+ readonly type: BooleanConstructor;
70
+ readonly default: true;
71
+ };
72
+ };
73
+ export type FormProps = ExtractPropTypes<typeof formProps>;
74
+ export type FormItemProps = ExtractPropTypes<typeof formItemProps>;
75
+ export { default as Form } from './index.vue';
76
+ export { default as FormItem } from './item.vue';
77
+ export * from './validators';
@@ -0,0 +1,64 @@
1
+ export interface FormRule {
2
+ required?: boolean;
3
+ message?: string;
4
+ trigger?: 'blur' | 'change';
5
+ min?: number;
6
+ max?: number;
7
+ pattern?: RegExp;
8
+ validator?: (rule: FormRule, value: any, callback: (error?: Error) => void) => void;
9
+ }
10
+ export interface FormItemContext {
11
+ prop: string;
12
+ validate: (trigger?: string) => Promise<boolean>;
13
+ resetField: () => void;
14
+ clearValidate: () => void;
15
+ }
16
+ type __VLS_Props = {
17
+ model?: Record<string, any>;
18
+ rules?: Record<string, FormRule[]>;
19
+ labelWidth?: string | number;
20
+ labelPosition?: 'left' | 'right' | 'top';
21
+ layout?: 'inline' | 'horizontal' | 'vertical';
22
+ inline?: boolean;
23
+ disabled?: boolean;
24
+ size?: 'large' | 'default' | 'small';
25
+ };
26
+ declare function __VLS_template(): {
27
+ attrs: Partial<{}>;
28
+ slots: {
29
+ default?(_: {}): any;
30
+ };
31
+ refs: {};
32
+ rootEl: HTMLFormElement;
33
+ };
34
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
35
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {
36
+ validate: () => Promise<boolean>;
37
+ validateField: (props: string | string[]) => Promise<boolean>;
38
+ resetFields: () => void;
39
+ clearValidate: (props?: string | string[]) => void;
40
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
41
+ reset: () => any;
42
+ submit: () => any;
43
+ validate: (prop: string, valid: boolean, message: string) => any;
44
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
45
+ onReset?: (() => any) | undefined;
46
+ onSubmit?: (() => any) | undefined;
47
+ onValidate?: ((prop: string, valid: boolean, message: string) => any) | undefined;
48
+ }>, {
49
+ size: "large" | "default" | "small";
50
+ disabled: boolean;
51
+ inline: boolean;
52
+ model: Record<string, any>;
53
+ rules: Record<string, FormRule[]>;
54
+ labelWidth: string | number;
55
+ labelPosition: "left" | "right" | "top";
56
+ layout: "inline" | "horizontal" | "vertical";
57
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLFormElement>;
58
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
59
+ export default _default;
60
+ type __VLS_WithTemplateSlots<T, S> = T & {
61
+ new (): {
62
+ $slots: S;
63
+ };
64
+ };
@@ -0,0 +1,31 @@
1
+ import { FormRule } from './index.vue';
2
+ type __VLS_Props = {
3
+ prop?: string;
4
+ label?: string;
5
+ labelWidth?: string | number;
6
+ required?: boolean;
7
+ rules?: FormRule[];
8
+ showMessage?: boolean;
9
+ };
10
+ declare function __VLS_template(): {
11
+ attrs: Partial<{}>;
12
+ slots: {
13
+ label?(_: {}): any;
14
+ default?(_: {}): any;
15
+ };
16
+ refs: {};
17
+ rootEl: HTMLDivElement;
18
+ };
19
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
20
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {
21
+ validate: (trigger?: string) => Promise<boolean>;
22
+ resetField: () => void;
23
+ clearValidate: () => void;
24
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
25
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
26
+ export default _default;
27
+ type __VLS_WithTemplateSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
@@ -0,0 +1,239 @@
1
+ import { Ref, ComponentSize } from 'vue';
2
+ /**
3
+ * 表单验证规则
4
+ */
5
+ export interface FormRule {
6
+ /**
7
+ * 是否必填
8
+ */
9
+ required?: boolean;
10
+ /**
11
+ * 错误提示信息
12
+ */
13
+ message?: string;
14
+ /**
15
+ * 触发方式
16
+ */
17
+ trigger?: 'blur' | 'change';
18
+ /**
19
+ * 最小长度
20
+ */
21
+ min?: number;
22
+ /**
23
+ * 最大长度
24
+ */
25
+ max?: number;
26
+ /**
27
+ * 正则表达式
28
+ */
29
+ pattern?: RegExp;
30
+ /**
31
+ * 自定义验证函数
32
+ */
33
+ validator?: (rule: FormRule, value: any, callback: (error?: Error) => void) => void;
34
+ }
35
+ /**
36
+ * 表单规则映射
37
+ */
38
+ export type FormRules = Record<string, FormRule[]>;
39
+ /**
40
+ * 表单项上下文
41
+ */
42
+ export interface FormItemContext {
43
+ /**
44
+ * 字段名
45
+ */
46
+ prop: string;
47
+ /**
48
+ * 验证方法
49
+ */
50
+ validate: (trigger?: string) => Promise<boolean>;
51
+ /**
52
+ * 重置字段
53
+ */
54
+ resetField: () => void;
55
+ /**
56
+ * 清除验证
57
+ */
58
+ clearValidate: () => void;
59
+ }
60
+ /**
61
+ * 表单上下文(注入到子组件)
62
+ */
63
+ export interface FormContext {
64
+ /**
65
+ * 表单数据模型
66
+ */
67
+ model: Ref<Record<string, any>>;
68
+ /**
69
+ * 验证规则
70
+ */
71
+ rules: FormRules;
72
+ /**
73
+ * 标签宽度
74
+ */
75
+ labelWidth: string | number;
76
+ /**
77
+ * 标签位置
78
+ */
79
+ labelPosition: string;
80
+ /**
81
+ * 是否禁用
82
+ */
83
+ disabled: boolean;
84
+ /**
85
+ * 组件尺寸
86
+ */
87
+ size: string;
88
+ /**
89
+ * 标签样式
90
+ */
91
+ labelStyle: Ref<Record<string, string>>;
92
+ /**
93
+ * 添加字段
94
+ */
95
+ addField: (field: FormItemContext) => void;
96
+ /**
97
+ * 移除字段
98
+ */
99
+ removeField: (field: FormItemContext) => void;
100
+ /**
101
+ * 触发事件
102
+ */
103
+ emit: (event: string, prop: string, valid: boolean, message: string) => void;
104
+ }
105
+ /**
106
+ * Form Props
107
+ */
108
+ export interface FormProps {
109
+ /**
110
+ * 表单数据对象
111
+ */
112
+ model?: Record<string, any>;
113
+ /**
114
+ * 表单验证规则
115
+ */
116
+ rules?: FormRules;
117
+ /**
118
+ * 标签宽度
119
+ * @default '100px'
120
+ */
121
+ labelWidth?: string | number;
122
+ /**
123
+ * 标签位置
124
+ * @default 'right'
125
+ */
126
+ labelPosition?: 'left' | 'right' | 'top';
127
+ /**
128
+ * 表单布局
129
+ * @default 'horizontal'
130
+ */
131
+ layout?: 'inline' | 'horizontal' | 'vertical';
132
+ /**
133
+ * 是否内联表单
134
+ * @default false
135
+ */
136
+ inline?: boolean;
137
+ /**
138
+ * 是否禁用所有表单项
139
+ * @default false
140
+ */
141
+ disabled?: boolean;
142
+ /**
143
+ * 组件尺寸
144
+ * @default 'default'
145
+ */
146
+ size?: ComponentSize;
147
+ }
148
+ /**
149
+ * Form Emits
150
+ */
151
+ export interface FormEmits {
152
+ /**
153
+ * 验证事件
154
+ */
155
+ (e: 'validate', prop: string, valid: boolean, message: string): void;
156
+ /**
157
+ * 提交事件
158
+ */
159
+ (e: 'submit'): void;
160
+ /**
161
+ * 重置事件
162
+ */
163
+ (e: 'reset'): void;
164
+ }
165
+ /**
166
+ * Form Expose
167
+ */
168
+ export interface FormExpose {
169
+ /**
170
+ * 验证整个表单
171
+ */
172
+ validate: () => Promise<boolean>;
173
+ /**
174
+ * 验证指定字段
175
+ */
176
+ validateField: (props: string | string[]) => Promise<boolean>;
177
+ /**
178
+ * 重置表单
179
+ */
180
+ resetFields: () => void;
181
+ /**
182
+ * 清除验证
183
+ */
184
+ clearValidate: (props?: string | string[]) => void;
185
+ }
186
+ /**
187
+ * Form 组件实例类型
188
+ */
189
+ export type FormInstance = InstanceType<typeof import('./index.vue').default>;
190
+ /**
191
+ * FormItem Props
192
+ */
193
+ export interface FormItemProps {
194
+ /**
195
+ * 字段名
196
+ */
197
+ prop?: string;
198
+ /**
199
+ * 标签文本
200
+ */
201
+ label?: string;
202
+ /**
203
+ * 标签宽度
204
+ */
205
+ labelWidth?: string | number;
206
+ /**
207
+ * 是否必填
208
+ */
209
+ required?: boolean;
210
+ /**
211
+ * 验证规则
212
+ */
213
+ rules?: FormRule[];
214
+ /**
215
+ * 是否显示错误信息
216
+ */
217
+ showMessage?: boolean;
218
+ }
219
+ /**
220
+ * FormItem Expose
221
+ */
222
+ export interface FormItemExpose {
223
+ /**
224
+ * 验证方法
225
+ */
226
+ validate: (trigger?: string) => Promise<boolean>;
227
+ /**
228
+ * 重置字段
229
+ */
230
+ resetField: () => void;
231
+ /**
232
+ * 清除验证
233
+ */
234
+ clearValidate: () => void;
235
+ }
236
+ /**
237
+ * FormItem 组件实例类型
238
+ */
239
+ export type FormItemInstance = InstanceType<typeof import('./item.vue').default>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * 内置验证规则
3
+ * 提供常用的表单验证规则
4
+ */
5
+ export type ValidatorRule = {
6
+ required?: boolean;
7
+ message?: string;
8
+ trigger?: 'blur' | 'change';
9
+ min?: number;
10
+ max?: number;
11
+ pattern?: RegExp;
12
+ validator?: (rule: any, value: any, callback: (error?: Error) => void) => void;
13
+ };
14
+ export declare const required: (message?: string) => ValidatorRule;
15
+ export declare const email: (message?: string) => ValidatorRule;
16
+ export declare const phone: (message?: string) => ValidatorRule;
17
+ export declare const idCard: (message?: string) => ValidatorRule;
18
+ export declare const url: (message?: string) => ValidatorRule;
19
+ export declare const number: (message?: string) => ValidatorRule;
20
+ export declare const integer: (message?: string) => ValidatorRule;
21
+ export declare const positiveInteger: (message?: string) => ValidatorRule;
22
+ export declare const letter: (message?: string) => ValidatorRule;
23
+ export declare const alphanumeric: (message?: string) => ValidatorRule;
24
+ export declare const chinese: (message?: string) => ValidatorRule;
25
+ export declare const range: (min: number, max: number, message?: string) => ValidatorRule;
26
+ export declare const minLength: (min: number, message?: string) => ValidatorRule;
27
+ export declare const maxLength: (max: number, message?: string) => ValidatorRule;
28
+ export declare const password: (message?: string) => ValidatorRule;
29
+ export declare const strongPassword: (message?: string) => ValidatorRule;
30
+ export declare const ip: (message?: string) => ValidatorRule;
31
+ export declare const port: (message?: string) => ValidatorRule;
32
+ export declare const bankCard: (message?: string) => ValidatorRule;
33
+ export declare const carNumber: (message?: string) => ValidatorRule;
34
+ export declare const pattern: (regexp: RegExp, message: string) => ValidatorRule;
35
+ export declare const validator: (validateFn: (value: any) => boolean | string | Promise<boolean | string>, message?: string) => ValidatorRule;
36
+ export declare const validators: {
37
+ required: (message?: string) => ValidatorRule;
38
+ email: (message?: string) => ValidatorRule;
39
+ phone: (message?: string) => ValidatorRule;
40
+ idCard: (message?: string) => ValidatorRule;
41
+ url: (message?: string) => ValidatorRule;
42
+ number: (message?: string) => ValidatorRule;
43
+ integer: (message?: string) => ValidatorRule;
44
+ positiveInteger: (message?: string) => ValidatorRule;
45
+ letter: (message?: string) => ValidatorRule;
46
+ alphanumeric: (message?: string) => ValidatorRule;
47
+ chinese: (message?: string) => ValidatorRule;
48
+ range: (min: number, max: number, message?: string) => ValidatorRule;
49
+ minLength: (min: number, message?: string) => ValidatorRule;
50
+ maxLength: (max: number, message?: string) => ValidatorRule;
51
+ password: (message?: string) => ValidatorRule;
52
+ strongPassword: (message?: string) => ValidatorRule;
53
+ ip: (message?: string) => ValidatorRule;
54
+ port: (message?: string) => ValidatorRule;
55
+ bankCard: (message?: string) => ValidatorRule;
56
+ carNumber: (message?: string) => ValidatorRule;
57
+ pattern: (regexp: RegExp, message: string) => ValidatorRule;
58
+ validator: (validateFn: (value: any) => boolean | string | Promise<boolean | string>, message?: string) => ValidatorRule;
59
+ };
60
+ export default validators;