UNPKG

2.61 kBTypeScriptView Raw
1import {FormData, VNodeRule} from "@form-create/core";
2import {Col, Row, Tooltip, Poptip, Button} from "iview";
3import {Api} from "./index";
4
5export interface OptionAttrs {
6 col?: Boolean | Col & {
7 labelWidth?: number | string;
8 show?: Boolean;
9 };
10 row?: Boolean | Row & {
11 show?: Boolean;
12 };
13 info?: Boolean | (Tooltip | Poptip) & VNodeRule & {
14 show?: Boolean;
15 native?: Boolean;
16 icon?: string;
17 align?: 'left' | 'right';
18 info?: string;
19 };
20 wrap?: Boolean | VNodeRule & {
21 labelWidth?: number;
22 labelFor?: string;
23 required?: boolean;
24 error?: string;
25 showMessage?: boolean;
26 show?: Boolean;
27 };
28 form?: {
29 inline?: boolean;
30 labelPosition?: 'left' | 'right' | 'top';
31 labelWidth?: number;
32 showMessage?: boolean;
33 className?: any;
34 col?: Boolean;
35 };
36
37 submitBtn?: Boolean | Button & {
38 click?: Function;
39 innerText?: string;
40 show?: Boolean;
41 };
42
43 resetBtn?: Boolean | Button & {
44 click?: Function;
45 innerText?: string;
46 show?: Boolean;
47 };
48
49}
50
51declare const optionAttrs: OptionAttrs & {
52 title?: Boolean | VNodeRule & {
53 show?: Boolean;
54 native?: Boolean;
55 title?: string;
56 };
57};
58
59export interface CreatorAttrs {
60 col(props: typeof optionAttrs.col): this;
61
62 wrap(props: typeof optionAttrs.wrap): this;
63
64 title(props: string | typeof optionAttrs.title): this;
65
66 info(props: string | typeof optionAttrs.info): this;
67
68 className(prop: string): this;
69
70}
71
72export interface RuleAttrs {
73 col?: typeof optionAttrs.col;
74 wrap?: typeof optionAttrs.wrap;
75 title?: string | typeof optionAttrs.title;
76 info?: string | typeof optionAttrs.info;
77 className?: string;
78}
79
80
81export interface ApiAttrs {
82 btn: {
83 loading(loading: boolean): void;
84 disabled(disabled: boolean): void;
85 show(show: boolean): void;
86 }
87 resetBtn: {
88 loading(loading: boolean): void;
89 disabled(disabled: boolean): void;
90 show(show: boolean): void;
91 }
92
93 submit(success: (formData: FormData, api: Api) => void, fail: (api: Api) => void): void;
94
95 clearValidateState(fields?: string | string[], clearSub?: Boolean): void;
96
97 clearSubValidateState(fields?: string | string[]): void;
98
99 validate(callback?: (valid?: boolean) => void): void;
100
101 validateField(field: string, callback?: (valid?: boolean) => void): void;
102
103 submitBtnProps(props: Button): void;
104
105 resetBtnProps(props: Button): void;
106
107}