UNPKG

2.81 kBTypeScriptView Raw
1import {FormData, VNodeRule} from "@form-create/core";
2import {Col, Row, Tooltip, Poptip, Button, Form, FormItem} from "iview";
3import {Api} from "./index";
4
5export interface OptionAttrs {
6 col?: Boolean | Partial<Col & {
7 labelWidth?: number | string;
8 show?: Boolean;
9 }>;
10 row?: Boolean | Partial<Row & {
11 show?: Boolean;
12 }>;
13 info?: Boolean | Partial<(Tooltip | Poptip) & VNodeRule & {
14 show?: Boolean;
15 native?: Boolean;
16 icon?: string;
17 align?: 'left' | 'right';
18 info?: string;
19 }>;
20 wrap?: Boolean | Partial<VNodeRule & {
21 labelWidth?: number;
22 labelFor?: string;
23 required?: boolean;
24 error?: string;
25 showMessage?: boolean;
26 show?: Boolean;
27 }>;
28 form?: Partial<{
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 | Partial<Button & {
38 click?: Function;
39 innerText?: string;
40 show?: Boolean;
41 }>;
42
43 resetBtn?: Boolean | Partial<Button & {
44 click?: Function;
45 innerText?: string;
46 show?: Boolean;
47 }>;
48
49}
50
51declare const optionAttrs: Partial<OptionAttrs & {
52 title?: Boolean | Partial<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 formEl(): undefined | Form;
94
95 wrapEl(id: string): undefined | FormItem;
96
97 submit(success: (formData: FormData, api: Api) => void, fail: (api: Api) => void): void;
98
99 clearValidateState(fields?: string | string[], clearSub?: Boolean): void;
100
101 clearSubValidateState(fields?: string | string[]): void;
102
103 validate(callback?: (valid?: boolean) => void): Promise<any>;
104
105 validateField(field: string, callback?: (valid?: boolean) => void): Promise<any>;
106
107 submitBtnProps(props: Button): void;
108
109 resetBtnProps(props: Button): void;
110
111}