icarys-fc-vant 1.0.15 → 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 -67
- package/dist/index.min.js +0 -7411
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import extend from '../../../utils/lib/extend';
|
|
2
|
+
import {byCtx, condition, copyRule, enumerable, getRule, invoke, parseFn, parseJson, toJson} from '../frame/util';
|
|
3
|
+
import is, {hasProperty} from '../../../utils/lib/type';
|
|
4
|
+
import {baseRule} from '../factory/creator';
|
|
5
|
+
import RuleContext from '../factory/context';
|
|
6
|
+
import mergeProps from '../../../utils/lib/mergeprops';
|
|
7
|
+
import {nextTick} from 'vue';
|
|
8
|
+
|
|
9
|
+
export default function useLoader(Handler) {
|
|
10
|
+
extend(Handler.prototype, {
|
|
11
|
+
nextRefresh(fn) {
|
|
12
|
+
const id = this.loadedId;
|
|
13
|
+
nextTick(() => {
|
|
14
|
+
id === this.loadedId && (fn ? fn() : this.refresh());
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
parseRule(_rule) {
|
|
18
|
+
const rule = getRule(_rule);
|
|
19
|
+
|
|
20
|
+
Object.defineProperties(rule, {
|
|
21
|
+
__origin__: enumerable(_rule, true)
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
fullRule(rule);
|
|
25
|
+
this.appendValue(rule);
|
|
26
|
+
|
|
27
|
+
[rule, rule['prefix'], rule['suffix']].forEach(item => {
|
|
28
|
+
if (!item) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.loadFn(item, rule);
|
|
32
|
+
});
|
|
33
|
+
this.loadCtrl(rule);
|
|
34
|
+
if (rule.update) {
|
|
35
|
+
rule.update = parseFn(rule.update);
|
|
36
|
+
}
|
|
37
|
+
return rule;
|
|
38
|
+
},
|
|
39
|
+
loadFn(item, rule) {
|
|
40
|
+
['on', 'props', 'deep'].forEach(k => {
|
|
41
|
+
item[k] && this.parseInjectEvent(rule, item[k]);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
loadCtrl(rule) {
|
|
45
|
+
rule.control && rule.control.forEach(ctrl => {
|
|
46
|
+
if (ctrl.handle) {
|
|
47
|
+
ctrl.handle = parseFn(ctrl.handle)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
syncProp(ctx) {
|
|
52
|
+
const rule = ctx.rule;
|
|
53
|
+
is.trueArray(rule.sync) && mergeProps([{
|
|
54
|
+
on: rule.sync.reduce((pre, prop) => {
|
|
55
|
+
pre[(typeof prop === 'object' && prop.event) || `update:${prop}`] = (val) => {
|
|
56
|
+
rule.props[(typeof prop === 'object' && prop.prop) || prop] = val;
|
|
57
|
+
this.vm.emit('sync', prop, val, rule, this.fapi);
|
|
58
|
+
}
|
|
59
|
+
return pre
|
|
60
|
+
}, {})
|
|
61
|
+
}], ctx.computed)
|
|
62
|
+
},
|
|
63
|
+
loadRule() {
|
|
64
|
+
// console.warn('%c load', 'color:blue');
|
|
65
|
+
this.cycleLoad = false;
|
|
66
|
+
this.loading = true;
|
|
67
|
+
if (this.pageEnd) {
|
|
68
|
+
this.bus.$emit('load-start');
|
|
69
|
+
}
|
|
70
|
+
this.deferSyncValue(() => {
|
|
71
|
+
this._loadRule(this.rules);
|
|
72
|
+
this.loading = false;
|
|
73
|
+
if (this.cycleLoad && this.pageEnd) {
|
|
74
|
+
return this.loadRule();
|
|
75
|
+
}
|
|
76
|
+
this.syncForm();
|
|
77
|
+
if (this.pageEnd) {
|
|
78
|
+
this.bus.$emit('load-end');
|
|
79
|
+
}
|
|
80
|
+
this.vm.setupState.renderRule();
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
loadChildren(children, parent) {
|
|
84
|
+
this.cycleLoad = false;
|
|
85
|
+
this.loading = true;
|
|
86
|
+
this.bus.$emit('load-start');
|
|
87
|
+
this._loadRule(children, parent);
|
|
88
|
+
this.loading = false;
|
|
89
|
+
if (this.cycleLoad) {
|
|
90
|
+
return this.loadRule();
|
|
91
|
+
} else {
|
|
92
|
+
this.syncForm();
|
|
93
|
+
this.bus.$emit('load-end');
|
|
94
|
+
}
|
|
95
|
+
this.$render.clearCache(parent);
|
|
96
|
+
},
|
|
97
|
+
_loadRule(rules, parent) {
|
|
98
|
+
|
|
99
|
+
const preIndex = (i) => {
|
|
100
|
+
let pre = rules[i - 1];
|
|
101
|
+
if (!pre || !pre.__fc__) {
|
|
102
|
+
return i > 0 ? preIndex(i - 1) : -1;
|
|
103
|
+
}
|
|
104
|
+
let index = this.sort.indexOf(pre.__fc__.id);
|
|
105
|
+
return index > -1 ? index : preIndex(i - 1);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const loadChildren = (children, parent) => {
|
|
109
|
+
if (is.trueArray(children)) {
|
|
110
|
+
this._loadRule(children, parent);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const ctxs = rules.map((_rule, index) => {
|
|
115
|
+
if (parent && !is.Object(_rule)) return;
|
|
116
|
+
if (!this.pageEnd && !parent && index >= this.first) return;
|
|
117
|
+
|
|
118
|
+
if (_rule.__fc__ && _rule.__fc__.root === rules && this.ctxs[_rule.__fc__.id]) {
|
|
119
|
+
loadChildren(_rule.__fc__.loadChildrenPending(), _rule.__fc__);
|
|
120
|
+
return _rule.__fc__;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let rule = getRule(_rule);
|
|
124
|
+
|
|
125
|
+
const isRepeat = () => {
|
|
126
|
+
return !!(rule.field && this.fieldCtx[rule.field] && this.fieldCtx[rule.field][0] !== _rule.__fc__)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this.fc.targetFormDriver('loadRule', {rule, api: this.api}, this.fc);
|
|
130
|
+
this.ruleEffect(rule, 'init', {repeat: isRepeat()});
|
|
131
|
+
|
|
132
|
+
if (isRepeat()) {
|
|
133
|
+
this.vm.emit('repeat-field', _rule, this.api);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let ctx;
|
|
137
|
+
let isCopy = false;
|
|
138
|
+
let isInit = !!_rule.__fc__;
|
|
139
|
+
let defaultValue = rule.value;
|
|
140
|
+
if (isInit) {
|
|
141
|
+
ctx = _rule.__fc__;
|
|
142
|
+
defaultValue = ctx.defaultValue;
|
|
143
|
+
if (ctx.deleted) {
|
|
144
|
+
if (isCtrl(ctx)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
ctx.update(this);
|
|
148
|
+
} else {
|
|
149
|
+
if (!ctx.check(this)) {
|
|
150
|
+
if (isCtrl(ctx)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
rules[index] = _rule = _rule._clone ? _rule._clone() : parseJson(toJson(_rule));
|
|
154
|
+
ctx = null;
|
|
155
|
+
isCopy = true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!ctx) {
|
|
160
|
+
const rule = this.parseRule(_rule);
|
|
161
|
+
ctx = new RuleContext(this, rule, defaultValue);
|
|
162
|
+
this.bindParser(ctx);
|
|
163
|
+
} else {
|
|
164
|
+
if (ctx.originType !== ctx.rule.type) {
|
|
165
|
+
ctx.updateType();
|
|
166
|
+
}
|
|
167
|
+
this.bindParser(ctx);
|
|
168
|
+
this.appendValue(ctx.rule);
|
|
169
|
+
if (ctx.parent && ctx.parent !== parent) {
|
|
170
|
+
this.rmSubRuleData(ctx);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
this.parseEmit(ctx);
|
|
174
|
+
this.syncProp(ctx);
|
|
175
|
+
ctx.parent = parent || null;
|
|
176
|
+
ctx.root = rules;
|
|
177
|
+
this.setCtx(ctx);
|
|
178
|
+
|
|
179
|
+
if (!isCopy && !isInit) {
|
|
180
|
+
this.effect(ctx, 'load');
|
|
181
|
+
this.targetHook(ctx, 'load');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this.effect(ctx, 'created');
|
|
185
|
+
|
|
186
|
+
const _load = ctx.loadChildrenPending()
|
|
187
|
+
ctx.parser.loadChildren === false || loadChildren(_load, ctx);
|
|
188
|
+
|
|
189
|
+
if (!parent) {
|
|
190
|
+
const _preIndex = preIndex(index);
|
|
191
|
+
if (_preIndex > -1 || !index) {
|
|
192
|
+
this.sort.splice(_preIndex + 1, 0, ctx.id);
|
|
193
|
+
} else {
|
|
194
|
+
this.sort.push(ctx.id);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const r = ctx.rule;
|
|
199
|
+
if (!ctx.updated) {
|
|
200
|
+
ctx.updated = true;
|
|
201
|
+
if (is.Function(r.update)) {
|
|
202
|
+
this.bus.$once('load-end', () => {
|
|
203
|
+
this.refreshUpdate(ctx, r.value, 'init');
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
this.effect(ctx, 'loaded');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// if (ctx.input)
|
|
210
|
+
// Object.defineProperty(r, 'value', this.valueHandle(ctx));
|
|
211
|
+
if (this.refreshControl(ctx)) this.cycleLoad = true;
|
|
212
|
+
return ctx;
|
|
213
|
+
}).filter(v => !!v);
|
|
214
|
+
if (parent) {
|
|
215
|
+
parent.children = ctxs;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
refreshControl(ctx) {
|
|
219
|
+
return ctx.input && ctx.rule.control && this.useCtrl(ctx);
|
|
220
|
+
},
|
|
221
|
+
useCtrl(ctx) {
|
|
222
|
+
const controls = getCtrl(ctx), validate = [], api = this.api;
|
|
223
|
+
if (!controls.length) return false;
|
|
224
|
+
|
|
225
|
+
for (let i = 0; i < controls.length; i++) {
|
|
226
|
+
const control = controls[i], handleFn = control.handle || function (val) {
|
|
227
|
+
return ((condition[control.condition || '=='] || condition['=='])(val, control.value));
|
|
228
|
+
};
|
|
229
|
+
if (!is.trueArray(control.rule)) continue;
|
|
230
|
+
const data = {
|
|
231
|
+
...control,
|
|
232
|
+
valid: invoke(() => handleFn(ctx.rule.value, api)),
|
|
233
|
+
ctrl: findCtrl(ctx, control.rule),
|
|
234
|
+
isHidden: is.String(control.rule[0]),
|
|
235
|
+
};
|
|
236
|
+
if ((data.valid && data.ctrl) || (!data.valid && !data.ctrl && !data.isHidden)) continue;
|
|
237
|
+
validate.push(data);
|
|
238
|
+
}
|
|
239
|
+
if (!validate.length) return false;
|
|
240
|
+
|
|
241
|
+
const hideLst = [];
|
|
242
|
+
let flag = false;
|
|
243
|
+
this.deferSyncValue(() => {
|
|
244
|
+
validate.reverse().forEach(({isHidden, valid, rule, prepend, append, child, ctrl, method}) => {
|
|
245
|
+
if (isHidden) {
|
|
246
|
+
valid ? ctx.ctrlRule.push({
|
|
247
|
+
__ctrl: true,
|
|
248
|
+
children: rule,
|
|
249
|
+
valid
|
|
250
|
+
})
|
|
251
|
+
: (ctrl && ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl) >>> 0, 1));
|
|
252
|
+
hideLst[valid ? 'push' : 'unshift'](() => {
|
|
253
|
+
if (method === 'disabled' || method === 'enabled') {
|
|
254
|
+
this.api.disabled(!valid, rule);
|
|
255
|
+
} else if (method === 'display' || method === 'show') {
|
|
256
|
+
this.api.display(valid, rule);
|
|
257
|
+
} else if (method === 'required') {
|
|
258
|
+
rule.forEach(item => {
|
|
259
|
+
this.api.setEffect(item, 'required', valid);
|
|
260
|
+
})
|
|
261
|
+
if (!valid) {
|
|
262
|
+
this.api.clearValidateState(rule);
|
|
263
|
+
}
|
|
264
|
+
} else if (method === 'if') {
|
|
265
|
+
this.api.hidden(!valid, rule);
|
|
266
|
+
} else {
|
|
267
|
+
this.api.hidden(!valid, rule);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (valid) {
|
|
273
|
+
flag = true;
|
|
274
|
+
const ruleCon = {
|
|
275
|
+
type: 'fragment',
|
|
276
|
+
native: true,
|
|
277
|
+
__ctrl: true,
|
|
278
|
+
children: rule,
|
|
279
|
+
}
|
|
280
|
+
ctx.ctrlRule.push(ruleCon);
|
|
281
|
+
this.bus.$once('load-start', () => {
|
|
282
|
+
// this.cycleLoad = true;
|
|
283
|
+
if (prepend) {
|
|
284
|
+
api.prepend(ruleCon, prepend, child)
|
|
285
|
+
} else if (append || child) {
|
|
286
|
+
api.append(ruleCon, append || ctx.id, child)
|
|
287
|
+
} else {
|
|
288
|
+
ctx.root.splice(ctx.root.indexOf(ctx.origin) + 1, 0, ruleCon);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
} else {
|
|
292
|
+
ctx.ctrlRule.splice(ctx.ctrlRule.indexOf(ctrl), 1);
|
|
293
|
+
const ctrlCtx = byCtx(ctrl);
|
|
294
|
+
ctrlCtx && ctrlCtx.rm();
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
if (hideLst.length) {
|
|
299
|
+
if (this.loading) {
|
|
300
|
+
hideLst.length && this.bus.$once('load-end', () => {
|
|
301
|
+
hideLst.forEach(v => v());
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
hideLst.length && nextTick(() => {
|
|
305
|
+
hideLst.forEach(v => v());
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
this.vm.emit('control', ctx.origin, this.api);
|
|
310
|
+
this.effect(ctx, 'control');
|
|
311
|
+
return flag;
|
|
312
|
+
},
|
|
313
|
+
reloadRule(rules) {
|
|
314
|
+
return this._reloadRule(rules);
|
|
315
|
+
},
|
|
316
|
+
_reloadRule(rules) {
|
|
317
|
+
// console.warn('%c reload', 'color:red');
|
|
318
|
+
if (!rules) rules = this.rules;
|
|
319
|
+
|
|
320
|
+
const ctxs = {...this.ctxs};
|
|
321
|
+
|
|
322
|
+
this.clearNextTick();
|
|
323
|
+
this.initData(rules);
|
|
324
|
+
this.fc.rules = rules;
|
|
325
|
+
|
|
326
|
+
this.deferSyncValue(() => {
|
|
327
|
+
this.bus.$once('load-end', () => {
|
|
328
|
+
Object.keys(ctxs).filter(id => this.ctxs[id] === undefined)
|
|
329
|
+
.forEach(id => this.rmCtx(ctxs[id]));
|
|
330
|
+
this.$render.clearCacheAll();
|
|
331
|
+
});
|
|
332
|
+
this.reloading = true;
|
|
333
|
+
this.loadRule();
|
|
334
|
+
this.reloading = false;
|
|
335
|
+
this.refresh();
|
|
336
|
+
this.bus.$emit('reloading', this.api);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
this.bus.$off('next-tick', this.nextReload);
|
|
340
|
+
this.bus.$once('next-tick', this.nextReload);
|
|
341
|
+
this.bus.$emit('update', this.api);
|
|
342
|
+
},
|
|
343
|
+
//todo 组件生成全部通过 alias
|
|
344
|
+
refresh() {
|
|
345
|
+
this.vm.setupState.refresh();
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function fullRule(rule) {
|
|
351
|
+
const def = baseRule();
|
|
352
|
+
|
|
353
|
+
Object.keys(def).forEach(k => {
|
|
354
|
+
if (!hasProperty(rule, k)) rule[k] = def[k];
|
|
355
|
+
});
|
|
356
|
+
return rule;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function getCtrl(ctx) {
|
|
360
|
+
const control = ctx.rule.control || [];
|
|
361
|
+
if (is.Object(control)) return [control];
|
|
362
|
+
else return control;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function findCtrl(ctx, rule) {
|
|
366
|
+
for (let i = 0; i < ctx.ctrlRule.length; i++) {
|
|
367
|
+
const ctrl = ctx.ctrlRule[i];
|
|
368
|
+
if (ctrl.children === rule)
|
|
369
|
+
return ctrl;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function isCtrl(ctx) {
|
|
374
|
+
return !!ctx.rule.__ctrl;
|
|
375
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import extend from '../../../utils/lib/extend';
|
|
2
|
+
import is from '../../../utils/lib/type';
|
|
3
|
+
|
|
4
|
+
const EVENT = ['hook:updated', 'hook:mounted'];
|
|
5
|
+
|
|
6
|
+
export default function usePage(Handler) {
|
|
7
|
+
extend(Handler.prototype, {
|
|
8
|
+
usePage() {
|
|
9
|
+
const page = this.options.page;
|
|
10
|
+
if (!page) return;
|
|
11
|
+
let first = 25;
|
|
12
|
+
let limit = getLimit(this.rules);
|
|
13
|
+
if (is.Object(page)) {
|
|
14
|
+
if (page.first) first = parseInt(page.first, 10) || first;
|
|
15
|
+
if (page.limit) limit = parseInt(page.limit, 10) || limit;
|
|
16
|
+
}
|
|
17
|
+
extend(this, {
|
|
18
|
+
first,
|
|
19
|
+
limit,
|
|
20
|
+
pageEnd: this.rules.length <= first,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
this.bus.$on('page-end', () => this.vm.emit('page-end', this.api));
|
|
24
|
+
this.pageLoad();
|
|
25
|
+
},
|
|
26
|
+
pageLoad() {
|
|
27
|
+
const pageFn = () => {
|
|
28
|
+
if (this.pageEnd) {
|
|
29
|
+
this.bus.$off(EVENT, pageFn);
|
|
30
|
+
this.bus.$emit('page-end');
|
|
31
|
+
} else {
|
|
32
|
+
this.first += this.limit;
|
|
33
|
+
this.pageEnd = this.rules.length <= this.first;
|
|
34
|
+
this.loadRule();
|
|
35
|
+
this.refresh();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this.bus.$on(EVENT, pageFn);
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
function getLimit(rules) {
|
|
45
|
+
return rules.length < 31 ? 31 : Math.ceil(rules.length / 3);
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import extend from '../../../utils/lib/extend';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default function useRender(Handler) {
|
|
5
|
+
extend(Handler.prototype, {
|
|
6
|
+
clearNextTick() {
|
|
7
|
+
this.nextTick && clearTimeout(this.nextTick);
|
|
8
|
+
this.nextTick = null;
|
|
9
|
+
},
|
|
10
|
+
bindNextTick(fn) {
|
|
11
|
+
this.clearNextTick();
|
|
12
|
+
this.nextTick = setTimeout(() => {
|
|
13
|
+
fn()
|
|
14
|
+
this.nextTick = null;
|
|
15
|
+
}, 10);
|
|
16
|
+
},
|
|
17
|
+
render() {
|
|
18
|
+
// console.warn('%c render', 'color:green');
|
|
19
|
+
++this.loadedId;
|
|
20
|
+
|
|
21
|
+
if (this.vm.setupState.unique > 0)
|
|
22
|
+
return this.$render.render();
|
|
23
|
+
else {
|
|
24
|
+
this.vm.setupState.unique = 1;
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import FormCreateFactory from './frame/index';
|
|
2
|
+
import fragment from './components/fragment';
|
|
3
|
+
import Creator, {creatorFactory} from './factory/creator';
|
|
4
|
+
import Manager from './factory/manager';
|
|
5
|
+
import {copyRule, copyRules, mergeRule, parseJson, toJson} from './frame/util';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
creatorFactory, Creator, Manager,
|
|
9
|
+
parseJson, toJson, copyRule, copyRules, mergeRule, fragment
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default FormCreateFactory;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import is from '../../../utils/lib/type';
|
|
2
|
+
|
|
3
|
+
const name = 'html';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name,
|
|
7
|
+
loadChildren: false,
|
|
8
|
+
render(children, ctx) {
|
|
9
|
+
ctx.prop.props.innerHTML = children.default();
|
|
10
|
+
return ctx.vNode.make(ctx.prop.props.tag || 'div', ctx.prop);
|
|
11
|
+
},
|
|
12
|
+
renderChildren(children) {
|
|
13
|
+
return {
|
|
14
|
+
default: () => children.filter(v => is.String(v)).join('')
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import extend from '../../../utils/lib/extend';
|
|
2
|
+
|
|
3
|
+
export default function useCache(Render) {
|
|
4
|
+
extend(Render.prototype, {
|
|
5
|
+
initCache() {
|
|
6
|
+
this.clearCacheAll();
|
|
7
|
+
},
|
|
8
|
+
clearCache(ctx) {
|
|
9
|
+
if (ctx.rule.cache) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!this.cache[ctx.id]) {
|
|
13
|
+
if (ctx.parent) {
|
|
14
|
+
this.clearCache(ctx.parent);
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (this.cache[ctx.id].use === true || this.cache[ctx.id].parent) {
|
|
19
|
+
this.$handle.refresh();
|
|
20
|
+
}
|
|
21
|
+
if (this.cache[ctx.id].parent) {
|
|
22
|
+
this.clearCache(this.cache[ctx.id].parent);
|
|
23
|
+
}
|
|
24
|
+
this.cache[ctx.id] = null;
|
|
25
|
+
},
|
|
26
|
+
clearCacheAll() {
|
|
27
|
+
this.cache = {};
|
|
28
|
+
},
|
|
29
|
+
setCache(ctx, vnode, parent) {
|
|
30
|
+
this.cache[ctx.id] = {
|
|
31
|
+
vnode,
|
|
32
|
+
use: false,
|
|
33
|
+
parent,
|
|
34
|
+
slot: ctx.rule.slot
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
getCache(ctx) {
|
|
38
|
+
const cache = this.cache[ctx.id];
|
|
39
|
+
if (cache) {
|
|
40
|
+
cache.use = true;
|
|
41
|
+
return cache.vnode;
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import useCache from './cache';
|
|
2
|
+
import useRender from './render';
|
|
3
|
+
import extend from '../../../utils/lib/extend';
|
|
4
|
+
import {funcProxy} from '../frame/util';
|
|
5
|
+
|
|
6
|
+
let id = 1;
|
|
7
|
+
export default function Render(handle) {
|
|
8
|
+
extend(this, {
|
|
9
|
+
$handle: handle,
|
|
10
|
+
fc: handle.fc,
|
|
11
|
+
vm: handle.vm,
|
|
12
|
+
$manager: handle.$manager,
|
|
13
|
+
vNode: new handle.fc.CreateNode(handle),
|
|
14
|
+
force: false,
|
|
15
|
+
tmpInput: null,
|
|
16
|
+
id: id++
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
funcProxy(this, {
|
|
20
|
+
options() {
|
|
21
|
+
return handle.options;
|
|
22
|
+
},
|
|
23
|
+
sort() {
|
|
24
|
+
return handle.sort;
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
this.initCache();
|
|
29
|
+
this.initRender();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
useCache(Render);
|
|
33
|
+
useRender(Render)
|