@form-create/element-ui 3.0.0-alpha.3 → 3.1.1
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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/auto-import.js +83 -0
- package/dist/form-create.esm.js +595 -499
- package/dist/form-create.esm.min.js +3 -3
- package/dist/form-create.js +598 -505
- package/dist/form-create.min.js +3 -3
- package/package.json +19 -15
- package/src/core/alias.js +1 -1
- package/src/core/config.js +0 -1
- package/src/core/index.js +7 -7
- package/src/core/maker.js +3 -3
- package/src/core/manager.js +27 -13
- package/src/style/index.css +1 -1
- package/types/config.d.ts +144 -0
- package/types/index.d.ts +28 -0
- package/types/maker.d.ts +14 -0
package/src/core/maker.js
CHANGED
|
@@ -20,8 +20,8 @@ function useAlias(maker) {
|
|
|
20
20
|
function useSelect(maker) {
|
|
21
21
|
const select = 'select';
|
|
22
22
|
const multiple = 'multiple';
|
|
23
|
-
maker['selectMultiple'] = creatorFactory(select, {[multiple]:true});
|
|
24
|
-
maker['selectOne'] = creatorFactory(select, {[multiple]:false});
|
|
23
|
+
maker['selectMultiple'] = creatorFactory(select, {[multiple]: true});
|
|
24
|
+
maker['selectOne'] = creatorFactory(select, {[multiple]: false});
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function useTree(maker) {
|
|
@@ -29,7 +29,7 @@ function useTree(maker) {
|
|
|
29
29
|
const types = {'treeSelected': 'selected', 'treeChecked': 'checked'};
|
|
30
30
|
|
|
31
31
|
Object.keys(types).reduce((m, key) => {
|
|
32
|
-
m[key] = creatorFactory(name, {type:types[key]});
|
|
32
|
+
m[key] = creatorFactory(name, {type: types[key]});
|
|
33
33
|
return m;
|
|
34
34
|
}, maker);
|
|
35
35
|
}
|
package/src/core/manager.js
CHANGED
|
@@ -27,13 +27,23 @@ function tidyBool(opt, name) {
|
|
|
27
27
|
|
|
28
28
|
export default {
|
|
29
29
|
validate() {
|
|
30
|
-
|
|
30
|
+
const form = this.form();
|
|
31
|
+
if (form) {
|
|
32
|
+
return form.validate();
|
|
33
|
+
} else {
|
|
34
|
+
return new Promise(v => v());
|
|
35
|
+
}
|
|
31
36
|
},
|
|
32
37
|
validateField(field) {
|
|
33
38
|
return new Promise((resolve, reject) => {
|
|
34
|
-
this.form()
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const form = this.form();
|
|
40
|
+
if (form) {
|
|
41
|
+
form.validateField(field, (res) => {
|
|
42
|
+
res ? reject(res) : resolve(null);
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
resolve();
|
|
46
|
+
}
|
|
37
47
|
});
|
|
38
48
|
},
|
|
39
49
|
clearValidateState(ctx) {
|
|
@@ -62,7 +72,7 @@ export default {
|
|
|
62
72
|
info: {
|
|
63
73
|
trigger: 'hover',
|
|
64
74
|
placement: 'top-start',
|
|
65
|
-
icon:
|
|
75
|
+
icon: true,
|
|
66
76
|
},
|
|
67
77
|
title: {},
|
|
68
78
|
col: {span: 24},
|
|
@@ -151,10 +161,14 @@ export default {
|
|
|
151
161
|
|
|
152
162
|
children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), {
|
|
153
163
|
[titleProp.slot || (isTip ? 'default' : 'reference')]: () => this.$r({
|
|
154
|
-
type: '
|
|
155
|
-
|
|
164
|
+
type: 'ElIcon',
|
|
165
|
+
style: 'top:2px',
|
|
156
166
|
key: `${uni}i`
|
|
157
|
-
}, {
|
|
167
|
+
}, {
|
|
168
|
+
default: () => this.$r({
|
|
169
|
+
type: infoProp.icon === true ? 'warning' : infoProp.icon
|
|
170
|
+
})
|
|
171
|
+
}, true)
|
|
158
172
|
}));
|
|
159
173
|
}
|
|
160
174
|
|
|
@@ -206,9 +220,10 @@ export default {
|
|
|
206
220
|
key: `${this.key}fc`
|
|
207
221
|
}, [item]);
|
|
208
222
|
},
|
|
223
|
+
|
|
209
224
|
makeResetBtn() {
|
|
210
225
|
const resetBtn = {...this.options.resetBtn};
|
|
211
|
-
const
|
|
226
|
+
const innerText = resetBtn.innerText;
|
|
212
227
|
delete resetBtn.innerText;
|
|
213
228
|
return this.$r({
|
|
214
229
|
type: 'button',
|
|
@@ -223,13 +238,12 @@ export default {
|
|
|
223
238
|
}
|
|
224
239
|
},
|
|
225
240
|
key: `${this.key}b2`,
|
|
226
|
-
}, [
|
|
241
|
+
}, [innerText]);
|
|
227
242
|
},
|
|
228
243
|
makeSubmitBtn() {
|
|
229
244
|
const submitBtn = {...this.options.submitBtn};
|
|
230
|
-
const
|
|
245
|
+
const innerText = submitBtn.innerText;
|
|
231
246
|
delete submitBtn.innerText;
|
|
232
|
-
|
|
233
247
|
return this.$r({
|
|
234
248
|
type: 'button',
|
|
235
249
|
props: submitBtn,
|
|
@@ -243,6 +257,6 @@ export default {
|
|
|
243
257
|
}
|
|
244
258
|
},
|
|
245
259
|
key: `${this.key}b1`,
|
|
246
|
-
}, [
|
|
260
|
+
}, [innerText]);
|
|
247
261
|
}
|
|
248
262
|
}
|
package/src/style/index.css
CHANGED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {FormData, VNodeData} from "@form-create/core";
|
|
2
|
+
import {ButtonProps, ValidateFieldCallback} from "element-plus";
|
|
3
|
+
import {Api} from "./index";
|
|
4
|
+
|
|
5
|
+
type SizeObject = {
|
|
6
|
+
span: number
|
|
7
|
+
offset: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type ComponentSize = 'large' | 'default' | 'small'
|
|
11
|
+
|
|
12
|
+
type 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
|
+
|
|
25
|
+
type RowProps = {
|
|
26
|
+
tag: string | 'div',
|
|
27
|
+
gutter: number | 0,
|
|
28
|
+
justify: string | 'start',
|
|
29
|
+
align: string | 'top',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export 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 | VNodeData & {
|
|
41
|
+
show?: Boolean;
|
|
42
|
+
native?: Boolean;
|
|
43
|
+
icon?: string;
|
|
44
|
+
align?: 'left' | 'right';
|
|
45
|
+
info?: string;
|
|
46
|
+
};
|
|
47
|
+
wrap?: Boolean | VNodeData & {
|
|
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
|
+
|
|
85
|
+
declare const optionAttrs: OptionAttrs & {
|
|
86
|
+
title?: Boolean | VNodeData & {
|
|
87
|
+
show?: Boolean;
|
|
88
|
+
native?: Boolean;
|
|
89
|
+
title?: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
interface children {
|
|
94
|
+
children?: VNodeData[]
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface CreatorAttrs {
|
|
98
|
+
col(props: typeof optionAttrs.col): this;
|
|
99
|
+
|
|
100
|
+
wrap(props: typeof optionAttrs.wrap): this;
|
|
101
|
+
|
|
102
|
+
title(props: string | typeof optionAttrs.title & children): this;
|
|
103
|
+
|
|
104
|
+
info(props: string | typeof optionAttrs.info & children): this;
|
|
105
|
+
|
|
106
|
+
className(prop: string): this;
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface RuleAttrs {
|
|
111
|
+
col?: typeof optionAttrs.col;
|
|
112
|
+
wrap?: typeof optionAttrs.wrap;
|
|
113
|
+
title?: string | typeof optionAttrs.title & children;
|
|
114
|
+
info?: string | typeof optionAttrs.info & children;
|
|
115
|
+
className?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ApiAttrs {
|
|
119
|
+
btn: {
|
|
120
|
+
loading(loading: boolean): void;
|
|
121
|
+
disabled(disabled: boolean): void;
|
|
122
|
+
show(show: boolean): void;
|
|
123
|
+
}
|
|
124
|
+
resetBtn: {
|
|
125
|
+
loading(loading: boolean): void;
|
|
126
|
+
disabled(disabled: boolean): void;
|
|
127
|
+
show(show: boolean): void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
submit(success: (formData: FormData, $f: Api) => void, fail: ($f: Api) => void): Promise<any>;
|
|
131
|
+
|
|
132
|
+
clearValidateState(fields?: string | string[], clearSub?: Boolean): void;
|
|
133
|
+
|
|
134
|
+
clearSubValidateState(fields?: string | string[]): void;
|
|
135
|
+
|
|
136
|
+
validate(callback?: (callback?: (boolean: boolean, object: Object) => void) => void): Promise<any>;
|
|
137
|
+
|
|
138
|
+
validateField(field: string, callback?: ValidateFieldCallback): Promise<any>;
|
|
139
|
+
|
|
140
|
+
submitBtnProps(props: ButtonProps): void;
|
|
141
|
+
|
|
142
|
+
resetBtnProps(props: ButtonProps): void;
|
|
143
|
+
|
|
144
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormCreate,
|
|
3
|
+
FormCreateProps as $FormCreateProps,
|
|
4
|
+
FormRule as $FormRule,
|
|
5
|
+
Options as $Options,
|
|
6
|
+
Rule as $Rule,
|
|
7
|
+
Creator as $Creator,
|
|
8
|
+
Control as $Control,
|
|
9
|
+
Api as $Api,
|
|
10
|
+
Effect as $Effect,
|
|
11
|
+
Parser as $Parser,
|
|
12
|
+
} from "@form-create/core";
|
|
13
|
+
import Maker from "./maker";
|
|
14
|
+
import {ApiAttrs, CreatorAttrs, OptionAttrs, RuleAttrs} from "./config";
|
|
15
|
+
import {ExtractPropTypes} from "vue";
|
|
16
|
+
|
|
17
|
+
declare const formCreate: FormCreate<Maker, OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>;
|
|
18
|
+
export default formCreate;
|
|
19
|
+
export declare const maker: typeof formCreate.maker;
|
|
20
|
+
export type FormRule = $FormRule<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
21
|
+
export type Options = $Options<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
22
|
+
export type Rule = $Rule<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
23
|
+
export type Effect = $Effect<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
24
|
+
export type Creator = $Creator<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
25
|
+
export type Control = $Control<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
26
|
+
export type Api = $Api<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
27
|
+
export type FormCreateProps = ExtractPropTypes<$FormCreateProps<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>>
|
|
28
|
+
export type Parser = $Parser
|
package/types/maker.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {CreatorHelper} from "@form-create/core";
|
|
2
|
+
import {CreatorAttrs, OptionAttrs, RuleAttrs, ApiAttrs} from "./config";
|
|
3
|
+
|
|
4
|
+
declare const makerFactory: CreatorHelper<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>
|
|
5
|
+
|
|
6
|
+
declare enum MakerName {
|
|
7
|
+
"datePicker", "year", "month", "date", "dates", "week", "datetime", "datetimeRange", "dateRange", "monthRange", "hidden", "input", "password", "url", "email", "text", "textarea", "idate", "slider", "sliderRange", "timePicker", "time", "timeRange", "group", "tree", "switch", "upload", "autoComplete", "checkbox", "cascader", "colorPicker", "frame", "inputNumber", "radio", "rate", "select", "auto", "number", "color", "selectMultiple", "selectOne", "treeSelected", "treeChecked", "image", "file", "uploadFileOne", "uploadImageOne", "uploadImage", "uploadFile", "frameInputs", "frameFiles", "frameImages", "frameInputOne", "frameFileOne", "frameImageOne", "frameInput", "frameFile", "frameImage"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type Maker = {
|
|
11
|
+
[name in keyof typeof MakerName]: typeof makerFactory;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default Maker;
|