icarys-fc-vant 1.0.14 → 1.0.16
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/README.md +87 -278
- package/dist/components/common/subform/package.json +48 -0
- package/dist/components/common/subform/src/component.jsx +75 -0
- package/dist/components/common/subform/src/index.js +3 -0
- package/dist/components/common/wangeditor/package-lock.json +114 -0
- package/dist/components/common/wangeditor/package.json +52 -0
- package/dist/components/common/wangeditor/src/component.jsx +74 -0
- package/dist/components/common/wangeditor/src/index.js +3 -0
- package/dist/core/babel.config.js +13 -0
- package/dist/core/bili.config.js +34 -0
- package/dist/core/package-lock.json +13 -0
- package/dist/core/package.json +61 -0
- package/dist/core/src/components/formCreate.js +287 -0
- package/dist/core/src/components/fragment.js +12 -0
- package/dist/core/src/factory/context.js +264 -0
- package/dist/core/src/factory/creator.js +63 -0
- package/dist/core/src/factory/maker.js +17 -0
- package/dist/core/src/factory/manager.js +87 -0
- package/dist/core/src/factory/node.js +89 -0
- package/dist/core/src/factory/parser.js +28 -0
- package/dist/core/src/frame/api.js +691 -0
- package/dist/core/src/frame/attrs.js +12 -0
- package/dist/core/src/frame/dataDriver.js +76 -0
- package/dist/core/src/frame/fetch.js +128 -0
- package/dist/core/src/frame/index.js +792 -0
- package/dist/core/src/frame/language.js +50 -0
- package/dist/core/src/frame/provider.js +297 -0
- package/dist/core/src/frame/util.js +311 -0
- package/dist/core/src/handler/context.js +573 -0
- package/dist/core/src/handler/effect.js +122 -0
- package/dist/core/src/handler/index.js +143 -0
- package/dist/core/src/handler/inject.js +199 -0
- package/dist/core/src/handler/input.js +199 -0
- package/dist/core/src/handler/lifecycle.js +55 -0
- package/dist/core/src/handler/loader.js +375 -0
- package/dist/core/src/handler/page.js +46 -0
- package/dist/core/src/handler/render.js +29 -0
- package/dist/core/src/index.js +12 -0
- package/dist/core/src/parser/html.js +17 -0
- package/dist/core/src/render/cache.js +47 -0
- package/dist/core/src/render/index.js +33 -0
- package/dist/core/src/render/render.js +418 -0
- package/dist/core/types/index.d.ts +842 -0
- package/dist/icarys-fc-vant.umd.js +17 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.esm.js +39 -0
- package/dist/index.js +46 -0
- package/dist/utils/lib/console.js +16 -0
- package/dist/utils/lib/debounce.js +9 -0
- package/dist/utils/lib/deepextend.js +51 -0
- package/dist/utils/lib/deepset.js +14 -0
- package/dist/utils/lib/extend.js +20 -0
- package/dist/utils/lib/index.js +14 -0
- package/dist/utils/lib/json.js +90 -0
- package/dist/utils/lib/mergeprops.js +62 -0
- package/dist/utils/lib/mitt.js +43 -0
- package/dist/utils/lib/modify.js +8 -0
- package/dist/utils/lib/slot.js +8 -0
- package/dist/utils/lib/toarray.js +5 -0
- package/dist/utils/lib/tocase.js +11 -0
- package/dist/utils/lib/todate.js +10 -0
- package/dist/utils/lib/toline.js +10 -0
- package/dist/utils/lib/topromise.js +10 -0
- package/dist/utils/lib/tostring.js +7 -0
- package/dist/utils/lib/type.js +45 -0
- package/dist/utils/lib/unique.js +6 -0
- package/dist/utils/package.json +32 -0
- package/dist/vant/auto-import.d.ts +5 -0
- package/dist/vant/auto-import.js +50 -0
- package/dist/vant/babel.config.js +10 -0
- package/dist/vant/bili.config.js +40 -0
- package/dist/vant/examples/main.js +13 -0
- package/dist/vant/examples/rule.js +366 -0
- package/dist/vant/package.json +83 -0
- package/dist/vant/src/components/calendar.jsx +128 -0
- package/dist/vant/src/components/cascader.jsx +120 -0
- package/dist/vant/src/components/checkbox.jsx +38 -0
- package/dist/vant/src/components/datePicker.jsx +87 -0
- package/dist/vant/src/components/group.jsx +384 -0
- package/dist/vant/src/components/index.js +26 -0
- package/dist/vant/src/components/radio.jsx +38 -0
- package/dist/vant/src/components/select.jsx +81 -0
- package/dist/vant/src/components/timePicker.jsx +76 -0
- package/dist/vant/src/components/uploader.jsx +99 -0
- package/dist/vant/src/core/alias.js +31 -0
- package/dist/vant/src/core/api.js +135 -0
- package/dist/vant/src/core/config.js +35 -0
- package/dist/vant/src/core/index.js +45 -0
- package/dist/vant/src/core/manager.js +282 -0
- package/dist/vant/src/core/provider.js +63 -0
- package/dist/vant/src/core/utils.js +15 -0
- package/dist/vant/src/index.js +13 -0
- package/dist/vant/src/parsers/hidden.js +12 -0
- package/dist/vant/src/parsers/index.js +59 -0
- package/dist/vant/src/parsers/row.js +10 -0
- package/dist/vant/src/style/index.css +495 -0
- package/dist/vant/types/config.d.ts +99 -0
- package/dist/vant/types/index.d.ts +27 -0
- package/dist/vant/vue.config.js +21 -0
- package/package.json +29 -52
- package/dist/index.min.js +0 -7411
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import unique from '../../../utils/lib/unique';
|
|
2
|
+
import toCase from '../../../utils/lib/tocase';
|
|
3
|
+
import extend from '../../../utils/lib/extend';
|
|
4
|
+
import {enumerable, invoke, mergeRule} from '../frame/util';
|
|
5
|
+
import {deepCopy} from '../../../utils/lib/deepextend';
|
|
6
|
+
import {markRaw, reactive} from 'vue';
|
|
7
|
+
import is from '../../../utils/lib/type';
|
|
8
|
+
import toArray from '../../../utils/lib/toarray';
|
|
9
|
+
|
|
10
|
+
function bind(ctx) {
|
|
11
|
+
Object.defineProperties(ctx.origin, {
|
|
12
|
+
__fc__: enumerable(markRaw(ctx), true)
|
|
13
|
+
});
|
|
14
|
+
if(ctx.rule !== ctx.origin) {
|
|
15
|
+
Object.defineProperties(ctx.rule, {
|
|
16
|
+
__fc__: enumerable(markRaw(ctx), true)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function RuleContext(handle, rule, defaultValue) {
|
|
22
|
+
const id = unique();
|
|
23
|
+
const isInput = !!rule.field;
|
|
24
|
+
extend(this, {
|
|
25
|
+
id,
|
|
26
|
+
ref: id,
|
|
27
|
+
wrapRef: id + 'fi',
|
|
28
|
+
rule,
|
|
29
|
+
origin: rule.__origin__ || rule,
|
|
30
|
+
name: rule.name,
|
|
31
|
+
pending: {},
|
|
32
|
+
none: false,
|
|
33
|
+
watch: [],
|
|
34
|
+
linkOn: [],
|
|
35
|
+
root: [],
|
|
36
|
+
ctrlRule: [],
|
|
37
|
+
children: [],
|
|
38
|
+
parent: null,
|
|
39
|
+
group: rule.subRule ? this : null,
|
|
40
|
+
cacheConfig: null,
|
|
41
|
+
prop: {...rule},
|
|
42
|
+
computed: {},
|
|
43
|
+
payload: {},
|
|
44
|
+
refRule: {},
|
|
45
|
+
input: isInput,
|
|
46
|
+
el: undefined,
|
|
47
|
+
exportEl: undefined,
|
|
48
|
+
defaultValue: isInput ? deepCopy(defaultValue) : undefined,
|
|
49
|
+
field: rule.field || undefined
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
this.updateKey();
|
|
53
|
+
bind(this);
|
|
54
|
+
this.update(handle, true);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
extend(RuleContext.prototype, {
|
|
58
|
+
getParentGroup() {
|
|
59
|
+
let ctx = this.parent;
|
|
60
|
+
while (ctx) {
|
|
61
|
+
if (ctx.group) {
|
|
62
|
+
return ctx;
|
|
63
|
+
}
|
|
64
|
+
ctx = ctx.parent;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
loadChildrenPending() {
|
|
68
|
+
const children = this.rule.children || [];
|
|
69
|
+
if (Array.isArray(children))
|
|
70
|
+
return children;
|
|
71
|
+
return this.loadPending({
|
|
72
|
+
key: 'children', origin: children, def: [],
|
|
73
|
+
onLoad: (data) => {
|
|
74
|
+
this.$handle && this.$handle.loadChildren(data, this);
|
|
75
|
+
}, onUpdate: (value, oldValue) => {
|
|
76
|
+
if (this.$handle) {
|
|
77
|
+
value === oldValue ? this.$handle.loadChildren(value, this) : this.$handle.updateChildren(this, value, oldValue);
|
|
78
|
+
}
|
|
79
|
+
}, onReload: (value) => {
|
|
80
|
+
if (this.$handle) {
|
|
81
|
+
this.$handle.updateChildren(this, [], value);
|
|
82
|
+
} else {
|
|
83
|
+
delete this.pending.children;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
loadPending(config) {
|
|
89
|
+
const {key, origin, def, onLoad, onReload, onUpdate} = config;
|
|
90
|
+
|
|
91
|
+
if (this.pending[key] && this.pending[key].origin === origin) {
|
|
92
|
+
return this.getPending(key, def);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
delete this.pending[key];
|
|
96
|
+
|
|
97
|
+
let value = origin;
|
|
98
|
+
if (is.Function(origin)) {
|
|
99
|
+
let source = invoke(() => origin({
|
|
100
|
+
rule: this.rule, api: this.$api, update: (data) => {
|
|
101
|
+
const value = data || def;
|
|
102
|
+
const oldValue = this.getPending(key, def);
|
|
103
|
+
this.setPending(key, origin, value);
|
|
104
|
+
onUpdate && onUpdate(value, oldValue);
|
|
105
|
+
}, reload: () => {
|
|
106
|
+
const oldValue = this.getPending(key, def);
|
|
107
|
+
delete this.pending[key];
|
|
108
|
+
onReload && onReload(oldValue);
|
|
109
|
+
this.$api && this.$api.sync(this.rule);
|
|
110
|
+
}
|
|
111
|
+
}));
|
|
112
|
+
if (source && is.Function(source.then)) {
|
|
113
|
+
source.then((data) => {
|
|
114
|
+
const value = data || def;
|
|
115
|
+
this.setPending(key, origin, value);
|
|
116
|
+
onLoad && onLoad(value);
|
|
117
|
+
this.$api && this.$api.sync(this.rule);
|
|
118
|
+
}).catch(e => {
|
|
119
|
+
console.error(e);
|
|
120
|
+
})
|
|
121
|
+
value = def;
|
|
122
|
+
this.setPending(key, origin, value);
|
|
123
|
+
} else {
|
|
124
|
+
value = source || def;
|
|
125
|
+
this.setPending(key, origin, value);
|
|
126
|
+
onLoad && onLoad(value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
},
|
|
131
|
+
getPending(key, def) {
|
|
132
|
+
return (this.pending[key] && this.pending[key].value) || def;
|
|
133
|
+
},
|
|
134
|
+
setPending(key, origin, value) {
|
|
135
|
+
this.pending[key] = {
|
|
136
|
+
origin,
|
|
137
|
+
value: reactive(value)
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
effectData(name) {
|
|
141
|
+
if (!this.payload[name]) {
|
|
142
|
+
this.payload[name] = {};
|
|
143
|
+
}
|
|
144
|
+
return this.payload[name];
|
|
145
|
+
},
|
|
146
|
+
clearEffectData(name) {
|
|
147
|
+
if (name === undefined) {
|
|
148
|
+
this.payload = {};
|
|
149
|
+
} else {
|
|
150
|
+
delete this.payload[name];
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
updateKey(flag) {
|
|
154
|
+
this.key = unique();
|
|
155
|
+
flag && this.parent && this.parent.updateKey(flag);
|
|
156
|
+
},
|
|
157
|
+
updateType() {
|
|
158
|
+
this.originType = this.rule.type;
|
|
159
|
+
this.type = toCase(this.rule.type);
|
|
160
|
+
this.trueType = this.$handle.getType(this.originType);
|
|
161
|
+
},
|
|
162
|
+
setParser(parser) {
|
|
163
|
+
this.parser = parser;
|
|
164
|
+
parser.init(this);
|
|
165
|
+
},
|
|
166
|
+
initProp() {
|
|
167
|
+
const rule = {...this.rule};
|
|
168
|
+
delete rule.children;
|
|
169
|
+
delete rule.validate;
|
|
170
|
+
this.prop = mergeRule({}, [rule, ...Object.keys(this.payload).map(k => this.payload[k]), this.computed]);
|
|
171
|
+
this.prop.validate = [...this.refRule?.__$validate?.value || [], ...this.prop.validate || []]
|
|
172
|
+
},
|
|
173
|
+
initNone() {
|
|
174
|
+
this.none = !(is.Undef(this.prop.display) || !!this.prop.display)
|
|
175
|
+
},
|
|
176
|
+
hasHidden() {
|
|
177
|
+
return (!!this.rule.hidden) || (this.parent ? this.parent.hasHidden() : false);
|
|
178
|
+
},
|
|
179
|
+
injectValidate() {
|
|
180
|
+
return this.prop.validate;
|
|
181
|
+
},
|
|
182
|
+
check(handle) {
|
|
183
|
+
return this.vm === handle.vm
|
|
184
|
+
},
|
|
185
|
+
unwatch() {
|
|
186
|
+
this.watch.forEach(un => un());
|
|
187
|
+
this.watch = [];
|
|
188
|
+
Object.keys(this.refRule).forEach(key => {
|
|
189
|
+
if (key.indexOf('__$') !== 0) {
|
|
190
|
+
delete this.refRule[key];
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
},
|
|
194
|
+
unlink() {
|
|
195
|
+
this.linkOn.forEach(un => un());
|
|
196
|
+
this.linkOn = [];
|
|
197
|
+
},
|
|
198
|
+
link() {
|
|
199
|
+
this.unlink();
|
|
200
|
+
this.$handle.appendLink(this);
|
|
201
|
+
},
|
|
202
|
+
watchTo() {
|
|
203
|
+
this.$handle.watchCtx(this);
|
|
204
|
+
},
|
|
205
|
+
delete() {
|
|
206
|
+
this.unwatch();
|
|
207
|
+
this.unlink();
|
|
208
|
+
this.rmCtrl();
|
|
209
|
+
if (this.parent) {
|
|
210
|
+
this.parent.children.splice(this.parent.children.indexOf(this) >>> 0, 1);
|
|
211
|
+
}
|
|
212
|
+
extend(this, {
|
|
213
|
+
deleted: true,
|
|
214
|
+
computed: {},
|
|
215
|
+
parent: null,
|
|
216
|
+
children: [],
|
|
217
|
+
cacheConfig: null,
|
|
218
|
+
none: false,
|
|
219
|
+
})
|
|
220
|
+
},
|
|
221
|
+
rmCtrl() {
|
|
222
|
+
this.ctrlRule.forEach(ctrl => ctrl.__fc__ && ctrl.__fc__.rm());
|
|
223
|
+
this.ctrlRule = [];
|
|
224
|
+
},
|
|
225
|
+
rm() {
|
|
226
|
+
const _rm = () => {
|
|
227
|
+
let index = this.root.indexOf(this.origin);
|
|
228
|
+
if (index > -1) {
|
|
229
|
+
this.root.splice(index, 1);
|
|
230
|
+
this.$handle && this.$handle.refresh();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (this.deleted) {
|
|
234
|
+
_rm();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
this.$handle.noWatch(() => {
|
|
238
|
+
this.$handle.deferSyncValue(() => {
|
|
239
|
+
this.rmCtrl();
|
|
240
|
+
_rm();
|
|
241
|
+
this.$handle.rmCtx(this);
|
|
242
|
+
extend(this, {
|
|
243
|
+
root: []
|
|
244
|
+
});
|
|
245
|
+
}, this.input);
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
update(handle, init) {
|
|
249
|
+
extend(this, {
|
|
250
|
+
deleted: false,
|
|
251
|
+
$handle: handle,
|
|
252
|
+
$render: handle.$render,
|
|
253
|
+
$api: handle.api,
|
|
254
|
+
vm: handle.vm,
|
|
255
|
+
vNode: handle.$render.vNode,
|
|
256
|
+
updated: false,
|
|
257
|
+
cacheValue: this.rule.value
|
|
258
|
+
});
|
|
259
|
+
!init && this.unwatch();
|
|
260
|
+
this.watchTo();
|
|
261
|
+
this.link();
|
|
262
|
+
this.updateType();
|
|
263
|
+
}
|
|
264
|
+
})
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import extend from '../../../utils/lib/extend';
|
|
2
|
+
import is from '../../../utils/lib/type';
|
|
3
|
+
import {attrs} from '../frame/attrs';
|
|
4
|
+
import {copyRule, mergeRule} from '../frame/util';
|
|
5
|
+
import {$set} from '../../../utils/lib/modify';
|
|
6
|
+
|
|
7
|
+
export function baseRule() {
|
|
8
|
+
return {
|
|
9
|
+
props: {},
|
|
10
|
+
on: {},
|
|
11
|
+
options: [],
|
|
12
|
+
children: [],
|
|
13
|
+
hidden: false,
|
|
14
|
+
display: true,
|
|
15
|
+
value: undefined,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function creatorFactory(name, init) {
|
|
20
|
+
return (title, field, value, props = {}) => {
|
|
21
|
+
const maker = new Creator(name, title, field, value, props);
|
|
22
|
+
if (init) {
|
|
23
|
+
if (is.Function(init)) init(maker);
|
|
24
|
+
else maker.props(init);
|
|
25
|
+
}
|
|
26
|
+
return maker;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function Creator(type, title, field, value, props) {
|
|
31
|
+
this._data = extend(baseRule(), {type, title, field, value, props: props || {}});
|
|
32
|
+
this.event = this.on;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
extend(Creator.prototype, {
|
|
36
|
+
getRule() {
|
|
37
|
+
return this._data;
|
|
38
|
+
},
|
|
39
|
+
setProp(key, value) {
|
|
40
|
+
$set(this._data, key, value);
|
|
41
|
+
return this;
|
|
42
|
+
},
|
|
43
|
+
modelField(field) {
|
|
44
|
+
this._data.modelField = field;
|
|
45
|
+
return this;
|
|
46
|
+
},
|
|
47
|
+
_clone() {
|
|
48
|
+
const clone = new this.constructor();
|
|
49
|
+
clone._data = copyRule(this._data);
|
|
50
|
+
return clone;
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export function appendProto(attrs) {
|
|
55
|
+
attrs.forEach(name => {
|
|
56
|
+
Creator.prototype[name] = function (key) {
|
|
57
|
+
mergeRule(this._data, {[name]: arguments.length < 2 ? key : {[key]: arguments[1]}})
|
|
58
|
+
return this;
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
appendProto(attrs());
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {creatorFactory} from './creator';
|
|
2
|
+
|
|
3
|
+
const commonMaker = creatorFactory('');
|
|
4
|
+
|
|
5
|
+
export function create(type, field, title) {
|
|
6
|
+
let make = commonMaker('', field);
|
|
7
|
+
make._data.type = type;
|
|
8
|
+
make._data.title = title;
|
|
9
|
+
return make;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function makerFactory() {
|
|
13
|
+
return {
|
|
14
|
+
create,
|
|
15
|
+
factory: creatorFactory
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import mergeProps from '../../../utils/lib/mergeprops';
|
|
2
|
+
import unique from '../../../utils/lib/unique';
|
|
3
|
+
import extend from '../../../utils/lib/extend';
|
|
4
|
+
import {invoke} from '../frame/util';
|
|
5
|
+
|
|
6
|
+
export function createManager(proto) {
|
|
7
|
+
class CustomManager extends Manager {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Object.assign(CustomManager.prototype, proto);
|
|
11
|
+
return CustomManager;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function Manager(handler) {
|
|
15
|
+
extend(this, {
|
|
16
|
+
$handle: handler,
|
|
17
|
+
vm: handler.vm,
|
|
18
|
+
options: {},
|
|
19
|
+
ref: 'fcForm',
|
|
20
|
+
mergeOptionsRule: {
|
|
21
|
+
normal: ['form', 'row', 'info', 'submitBtn', 'resetBtn']
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
this.updateKey();
|
|
25
|
+
this.init();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
extend(Manager.prototype, {
|
|
29
|
+
__init() {
|
|
30
|
+
this.$render = this.$handle.$render;
|
|
31
|
+
this.$r = (...args) => this.$render.renderRule(...args);
|
|
32
|
+
},
|
|
33
|
+
updateKey() {
|
|
34
|
+
this.key = unique();
|
|
35
|
+
},
|
|
36
|
+
//TODO interface
|
|
37
|
+
init() {
|
|
38
|
+
},
|
|
39
|
+
update() {
|
|
40
|
+
},
|
|
41
|
+
beforeRender() {
|
|
42
|
+
},
|
|
43
|
+
form() {
|
|
44
|
+
return this.vm.refs[this.ref];
|
|
45
|
+
},
|
|
46
|
+
adapterValidate(validate, validator) {
|
|
47
|
+
validate.validator = (rule, value, callback) => {
|
|
48
|
+
return validator(value, callback);
|
|
49
|
+
}
|
|
50
|
+
return validate;
|
|
51
|
+
},
|
|
52
|
+
getSlot(name) {
|
|
53
|
+
const _fn = (vm) => {
|
|
54
|
+
if (vm) {
|
|
55
|
+
let slot = vm.slots[name];
|
|
56
|
+
if (slot) {
|
|
57
|
+
return slot;
|
|
58
|
+
}
|
|
59
|
+
return _fn(vm.setupState.parent);
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
return _fn(this.vm);
|
|
64
|
+
},
|
|
65
|
+
mergeOptions(args, opt) {
|
|
66
|
+
return mergeProps(args.map(v => this.tidyOptions(v)), opt, this.mergeOptionsRule);
|
|
67
|
+
},
|
|
68
|
+
updateOptions(options) {
|
|
69
|
+
this.$handle.fc.targetFormDriver('updateOptions', options, {handle: this.$handle, api: this.$handle.api})
|
|
70
|
+
this.options = this.mergeOptions([options], this.getDefaultOptions());
|
|
71
|
+
this.update();
|
|
72
|
+
},
|
|
73
|
+
tidyOptions(options) {
|
|
74
|
+
return options;
|
|
75
|
+
},
|
|
76
|
+
tidyRule(ctx) {
|
|
77
|
+
},
|
|
78
|
+
mergeProp(ctx) {
|
|
79
|
+
},
|
|
80
|
+
getDefaultOptions() {
|
|
81
|
+
return {};
|
|
82
|
+
},
|
|
83
|
+
fieldChange(ctx, value, formValue, setFlag) {
|
|
84
|
+
},
|
|
85
|
+
render(children) {
|
|
86
|
+
}
|
|
87
|
+
})
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import toLine from '../../../utils/lib/toline';
|
|
2
|
+
import toString from '../../../utils/lib/tostring';
|
|
3
|
+
import extend from '../../../utils/lib/extend';
|
|
4
|
+
import {toProps} from '../frame/util';
|
|
5
|
+
import {createVNode, getCurrentInstance, resolveComponent, resolveDirective, withDirectives} from 'vue';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function tidyDirectives(directives) {
|
|
9
|
+
return Object.keys(directives).map(n => {
|
|
10
|
+
const data = directives[n];
|
|
11
|
+
const directive = resolveDirective(n);
|
|
12
|
+
if (!directive) return;
|
|
13
|
+
return [
|
|
14
|
+
directive, data.value, data.arg, data.modifiers
|
|
15
|
+
]
|
|
16
|
+
}).filter(v => !!v);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function makeDirective(data, vn) {
|
|
20
|
+
let directives = data.directives;
|
|
21
|
+
if (!directives) return vn;
|
|
22
|
+
if (!Array.isArray(directives)) {
|
|
23
|
+
directives = [directives];
|
|
24
|
+
}
|
|
25
|
+
return withDirectives(vn, directives.reduce((lst, v) => {
|
|
26
|
+
return lst.concat(tidyDirectives(v));
|
|
27
|
+
}, []))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function CreateNodeFactory() {
|
|
31
|
+
|
|
32
|
+
const aliasMap = {};
|
|
33
|
+
|
|
34
|
+
function CreateNode(handle) {
|
|
35
|
+
this.vm = handle.vm;
|
|
36
|
+
this.handle = handle;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
extend(CreateNode.prototype, {
|
|
40
|
+
make(tag, data, children) {
|
|
41
|
+
return makeDirective(data, this.h(tag, toProps(data), children));
|
|
42
|
+
},
|
|
43
|
+
makeComponent(type, data, children) {
|
|
44
|
+
try {
|
|
45
|
+
return makeDirective(data, createVNode(type, toProps(data), children));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error(e);
|
|
48
|
+
return createVNode('');
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
h(tag, data, children) {
|
|
52
|
+
const vm = this.vm || getCurrentInstance();
|
|
53
|
+
const isNativeTag = vm.appContext.config.isNativeTag(tag);
|
|
54
|
+
const component = this.handle.fc.prop.components[tag];
|
|
55
|
+
if (!component && isNativeTag) {
|
|
56
|
+
delete data.formCreateInject;
|
|
57
|
+
}
|
|
58
|
+
try{
|
|
59
|
+
return createVNode(component || (isNativeTag ? tag : resolveComponent(tag)), data, children);
|
|
60
|
+
}catch (e){
|
|
61
|
+
console.error(e);
|
|
62
|
+
return createVNode('');
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
aliasMap
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
extend(CreateNode, {
|
|
69
|
+
aliasMap,
|
|
70
|
+
alias(alias, name) {
|
|
71
|
+
aliasMap[alias] = name;
|
|
72
|
+
},
|
|
73
|
+
use(nodes) {
|
|
74
|
+
Object.keys(nodes).forEach((k) => {
|
|
75
|
+
const line = toLine(k);
|
|
76
|
+
const lower = toString(k).toLocaleLowerCase();
|
|
77
|
+
const v = nodes[k];
|
|
78
|
+
CreateNode.alias(k, v);
|
|
79
|
+
[k, line, lower].forEach(n => {
|
|
80
|
+
CreateNode.prototype[n] = function (data, children) {
|
|
81
|
+
return this.make(aliasMap[k] || n, data, children);
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
return CreateNode;
|
|
89
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const BaseParser = {
|
|
2
|
+
init(ctx) {
|
|
3
|
+
},
|
|
4
|
+
toFormValue(value, ctx) {
|
|
5
|
+
return value
|
|
6
|
+
},
|
|
7
|
+
toValue(formValue, ctx) {
|
|
8
|
+
return formValue;
|
|
9
|
+
},
|
|
10
|
+
mounted(ctx) {
|
|
11
|
+
},
|
|
12
|
+
render(children, ctx) {
|
|
13
|
+
if(ctx.$handle.fc.renderDriver && ctx.$handle.fc.renderDriver.defaultRender){
|
|
14
|
+
return ctx.$handle.fc.renderDriver.defaultRender(ctx, children);
|
|
15
|
+
}
|
|
16
|
+
return ctx.$render.defaultRender(ctx, children);
|
|
17
|
+
},
|
|
18
|
+
preview(children, ctx) {
|
|
19
|
+
if(ctx.$handle.fc.renderDriver && ctx.$handle.fc.renderDriver.defaultPreview){
|
|
20
|
+
return ctx.$handle.fc.renderDriver.defaultPreview(ctx, children);
|
|
21
|
+
}
|
|
22
|
+
return this.render(children, ctx);
|
|
23
|
+
},
|
|
24
|
+
mergeProp(ctx) {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default BaseParser;
|