1 | import { ElementUIComponent, ElementUIComponentSize } from './component'
|
2 |
|
3 | export type FormItemLabelPosition = 'left' | 'right' | 'top'
|
4 |
|
5 | export interface ValidateCallback {
|
6 | /**
|
7 | * The callback to tell the validation result
|
8 | *
|
9 | * @param isValid Whether the form is valid
|
10 | * @param invalidFields fields that fail validation
|
11 | */
|
12 | (isValid: boolean, invalidFields: object): void
|
13 | }
|
14 |
|
15 | export interface ValidateFieldCallback {
|
16 | /**
|
17 | * The callback to tell the field validation result
|
18 | *
|
19 | * @param errorMessage The error message. It will be empty if there is no error
|
20 | */
|
21 | (errorMessage: string): void
|
22 | }
|
23 |
|
24 | /** Form Component */
|
25 | export declare class ElForm extends ElementUIComponent {
|
26 | /** Data of form component */
|
27 | model: object
|
28 |
|
29 | /** Validation rules of form */
|
30 | rules: object
|
31 |
|
32 | /** Whether the form is inline */
|
33 | inline: boolean
|
34 |
|
35 | /** Whether the form is disabled */
|
36 | disabled: boolean
|
37 |
|
38 | /** Position of label */
|
39 | labelPosition: FormItemLabelPosition
|
40 |
|
41 | /** Width of label, and all form items will inherit from Form */
|
42 | labelWidth: string
|
43 |
|
44 | /** Suffix of the label */
|
45 | labelSuffix: string
|
46 |
|
47 | /** Whether to show the error message */
|
48 | showMessage: boolean
|
49 |
|
50 | /** Whether to display the error message inline with the form item */
|
51 | inlineMessage: boolean
|
52 |
|
53 | /** Whether to display an icon indicating the validation result */
|
54 | statusIcon: boolean
|
55 |
|
56 | /** Whether to trigger validation when the `rules` prop is changed */
|
57 | validateOnRuleChange: boolean
|
58 |
|
59 | /** Controls the size of components in this form */
|
60 | size: ElementUIComponentSize
|
61 |
|
62 | /**
|
63 | * Validate the whole form
|
64 | *
|
65 | * @param callback A callback to tell the validation result
|
66 | */
|
67 | validate (callback: ValidateCallback): void
|
68 | validate (): Promise<boolean>
|
69 | /**
|
70 | * Validate a certain form item
|
71 | *
|
72 | * @param prop The property of `model` that is going to validate
|
73 | * @param callback A callback to tell the field validation result
|
74 | */
|
75 | validateField (prop: string, callback: ValidateFieldCallback): void
|
76 |
|
77 | /** reset all the fields and remove validation result */
|
78 | resetFields (): void
|
79 |
|
80 | /** clear validation message for certain fields */
|
81 | clearValidate (props?: string[]): void
|
82 | }
|