UNPKG

3.41 kBTypeScriptView Raw
1import {FormData, VNodeRule} from "@form-create/core";
2import {ButtonProps, ValidateFieldCallback} from "element-plus";
3import {Api} from "./index";
4
5type SizeObject = {
6 span?: number
7 offset?: number
8}
9
10type ComponentSize = 'large' | 'default' | 'small'
11
12type ColProps = {
13 tag?: string | 'div';
14 span?: number | 24;
15 offset?: number | 0;
16 pull?: number | 0;
17 push?: number | 0;
18 xs?: number | SizeObject;
19 sm?: number | SizeObject;
20 md?: number | SizeObject;
21 lg?: number | SizeObject;
22 xl?: number | SizeObject;
23}
24
25type RowProps = {
26 tag?: string | 'div',
27 gutter?: number | 0,
28 justify?: string | 'start',
29 align?: string | 'top',
30}
31
32export interface OptionAttrs {
33 col?: Boolean | ColProps & {
34 labelWidth?: number | string;
35 show?: Boolean;
36 };
37 row?: Boolean | RowProps & {
38 show?: Boolean;
39 };
40 info?: Boolean | VNodeRule & {
41 show?: Boolean;
42 native?: Boolean;
43 icon?: string;
44 align?: 'left' | 'right';
45 info?: string;
46 };
47 wrap?: Boolean | VNodeRule & {
48 labelWidth?: string
49 required?: boolean
50 error?: string
51 showMessage?: boolean
52 inlineMessage?: boolean
53 size?: ComponentSize
54 show?: Boolean;
55 };
56 form?: {
57 inline?: boolean
58 disabled?: boolean
59 labelPosition?: string
60 labelWidth?: string
61 labelSuffix?: string
62 showMessage?: boolean
63 inlineMessage?: boolean
64 statusIcon?: boolean
65 validateOnRuleChange?: boolean
66 size?: ComponentSize
67 className?: any;
68 col?: Boolean;
69 };
70
71 submitBtn?: Boolean | ButtonProps & {
72 click?: Function;
73 innerText?: string;
74 show?: Boolean;
75 };
76
77 resetBtn?: Boolean | ButtonProps & {
78 click?: Function;
79 innerText?: string;
80 show?: Boolean;
81 };
82
83}
84
85declare const optionAttrs: OptionAttrs & {
86 title?: Boolean | VNodeRule & {
87 show?: Boolean;
88 native?: Boolean;
89 title: string;
90 };
91};
92
93export interface CreatorAttrs {
94 col(props: typeof optionAttrs.col): this;
95
96 wrap(props: typeof optionAttrs.wrap): this;
97
98 title(props: string | typeof optionAttrs.title): this;
99
100 info(props: string | typeof optionAttrs.info): this;
101
102 className(prop: string): this;
103
104}
105
106export interface RuleAttrs {
107 col?: typeof optionAttrs.col;
108 wrap?: typeof optionAttrs.wrap;
109 title?: string | typeof optionAttrs.title;
110 info?: string | typeof optionAttrs.info;
111 className?: string;
112}
113
114export interface ApiAttrs {
115 btn: {
116 loading(loading: boolean): void;
117 disabled(disabled: boolean): void;
118 show(show: boolean): void;
119 }
120 resetBtn: {
121 loading(loading: boolean): void;
122 disabled(disabled: boolean): void;
123 show(show: boolean): void;
124 }
125
126 submit(success: (formData: FormData, $f: Api) => void, fail: ($f: Api) => void): Promise<any>;
127
128 clearValidateState(fields?: string | string[], clearSub?: Boolean): void;
129
130 clearSubValidateState(fields?: string | string[]): void;
131
132 validate(callback?: (callback?: (boolean: boolean, object: Object) => void) => void): Promise<any>;
133
134 validateField(field: string, callback?: ValidateFieldCallback): Promise<any>;
135
136 submitBtnProps(props: ButtonProps): void;
137
138 resetBtnProps(props: ButtonProps): void;
139
140}