@form-create/element-ui 3.0.0-alpha.2 → 3.1.0

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/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
  }
@@ -27,13 +27,23 @@ function tidyBool(opt, name) {
27
27
 
28
28
  export default {
29
29
  validate() {
30
- return this.form().validate();
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().validateField(field, (res) => {
35
- res ? reject(res) : resolve(null);
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: 'el-icon-warning',
75
+ icon: true,
66
76
  },
67
77
  title: {},
68
78
  col: {span: 24},
@@ -132,36 +142,41 @@ export default {
132
142
  const isTip = isTooltip(infoProp);
133
143
  const form = this.options.form;
134
144
  const children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
135
- const titleFn = () => this.$r(mergeProps([titleProp, {
136
- props: titleProp,
137
- key: `${uni}tit`,
138
- type: titleProp.type || 'span',
139
- }]), children);
140
145
 
141
- if (!isFalse(infoProp.show) && (infoProp.info || infoProp.native)) {
142
- if (infoProp.icon !== false) {
143
- children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r({
144
- type: 'i',
145
- class: infoProp.icon === true ? 'el-icon-warning' : infoProp.icon,
146
- key: `${uni}i`
147
- }, {}, true));
148
- }
146
+ if (!isFalse(infoProp.show) && (infoProp.info || infoProp.native) && !isFalse(infoProp.icon)) {
149
147
  const prop = {
150
148
  type: infoProp.type || 'popover',
151
149
  props: {...infoProp},
152
150
  key: `${uni}pop`
153
151
  };
154
152
 
153
+ delete prop.props.icon;
154
+ delete prop.props.show;
155
+ delete prop.props.info;
156
+
155
157
  const field = 'content';
156
158
  if (infoProp.info && !hasProperty(prop.props, field)) {
157
159
  prop.props[field] = infoProp.info;
158
160
  }
159
161
 
160
- return this.$r(mergeProps([infoProp, prop]), {
161
- [titleProp.slot || (isTip ? 'default' : 'reference')]: () => titleFn()
162
- })
162
+ children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), {
163
+ [titleProp.slot || (isTip ? 'default' : 'reference')]: () => this.$r({
164
+ type: 'ElIcon',
165
+ style: 'top:2px',
166
+ key: `${uni}i`
167
+ }, {
168
+ default: () => this.$r({
169
+ type: infoProp.icon === true ? 'warning' : infoProp.icon
170
+ })
171
+ }, true)
172
+ }));
163
173
  }
164
- return titleFn();
174
+
175
+ return this.$r(mergeProps([titleProp, {
176
+ props: titleProp,
177
+ key: `${uni}tit`,
178
+ type: titleProp.type || 'span',
179
+ }]), children);
165
180
  },
166
181
  makeCol(rule, uni, children) {
167
182
  const col = rule.col;
@@ -205,9 +220,10 @@ export default {
205
220
  key: `${this.key}fc`
206
221
  }, [item]);
207
222
  },
223
+
208
224
  makeResetBtn() {
209
225
  const resetBtn = {...this.options.resetBtn};
210
- const text = resetBtn.innerText;
226
+ const innerText = resetBtn.innerText;
211
227
  delete resetBtn.innerText;
212
228
  return this.$r({
213
229
  type: 'button',
@@ -222,13 +238,12 @@ export default {
222
238
  }
223
239
  },
224
240
  key: `${this.key}b2`,
225
- }, [text]);
241
+ }, [innerText]);
226
242
  },
227
243
  makeSubmitBtn() {
228
244
  const submitBtn = {...this.options.submitBtn};
229
- const text = submitBtn.innerText;
245
+ const innerText = submitBtn.innerText;
230
246
  delete submitBtn.innerText;
231
-
232
247
  return this.$r({
233
248
  type: 'button',
234
249
  props: submitBtn,
@@ -242,6 +257,6 @@ export default {
242
257
  }
243
258
  },
244
259
  key: `${this.key}b1`,
245
- }, [text]);
260
+ }, [innerText]);
246
261
  }
247
262
  }
@@ -7,5 +7,5 @@
7
7
  }
8
8
 
9
9
  .form-create{
10
- transform: rotateZ(0);
10
+ width: 100%;
11
11
  }
@@ -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
+ }
@@ -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
@@ -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;