icarys-fc-vant 1.0.15 → 1.0.17

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.
Files changed (112) hide show
  1. package/README.md +40 -205
  2. package/dist/index.js +7590 -0
  3. package/dist/index.min.js +3 -7407
  4. package/dist/index.min.js.map +1 -0
  5. package/package.json +6 -19
  6. package/src/components/common/subform/LICENSE +21 -0
  7. package/src/components/common/subform/README.md +6 -0
  8. package/src/components/common/subform/package.json +48 -0
  9. package/src/components/common/subform/src/component.jsx +75 -0
  10. package/src/components/common/subform/src/index.js +3 -0
  11. package/src/components/common/wangeditor/LICENSE +21 -0
  12. package/src/components/common/wangeditor/README.md +14 -0
  13. package/src/components/common/wangeditor/package-lock.json +114 -0
  14. package/src/components/common/wangeditor/package.json +52 -0
  15. package/src/components/common/wangeditor/src/component.jsx +74 -0
  16. package/src/components/common/wangeditor/src/index.js +3 -0
  17. package/src/core/LICENSE +21 -0
  18. package/src/core/README.md +120 -0
  19. package/src/core/babel.config.js +13 -0
  20. package/src/core/bili.config.js +34 -0
  21. package/src/core/package-lock.json +13 -0
  22. package/src/core/package.json +61 -0
  23. package/src/core/src/components/formCreate.js +287 -0
  24. package/src/core/src/components/fragment.js +12 -0
  25. package/src/core/src/factory/context.js +264 -0
  26. package/src/core/src/factory/creator.js +63 -0
  27. package/src/core/src/factory/maker.js +17 -0
  28. package/src/core/src/factory/manager.js +87 -0
  29. package/src/core/src/factory/node.js +89 -0
  30. package/src/core/src/factory/parser.js +28 -0
  31. package/src/core/src/frame/api.js +691 -0
  32. package/src/core/src/frame/attrs.js +12 -0
  33. package/src/core/src/frame/dataDriver.js +76 -0
  34. package/src/core/src/frame/fetch.js +128 -0
  35. package/src/core/src/frame/index.js +792 -0
  36. package/src/core/src/frame/language.js +50 -0
  37. package/src/core/src/frame/provider.js +297 -0
  38. package/src/core/src/frame/util.js +311 -0
  39. package/src/core/src/handler/context.js +573 -0
  40. package/src/core/src/handler/effect.js +122 -0
  41. package/src/core/src/handler/index.js +143 -0
  42. package/src/core/src/handler/inject.js +199 -0
  43. package/src/core/src/handler/input.js +199 -0
  44. package/src/core/src/handler/lifecycle.js +55 -0
  45. package/src/core/src/handler/loader.js +375 -0
  46. package/src/core/src/handler/page.js +46 -0
  47. package/src/core/src/handler/render.js +29 -0
  48. package/src/core/src/index.js +12 -0
  49. package/src/core/src/parser/html.js +17 -0
  50. package/src/core/src/render/cache.js +47 -0
  51. package/src/core/src/render/index.js +33 -0
  52. package/src/core/src/render/render.js +418 -0
  53. package/src/core/types/index.d.ts +842 -0
  54. package/src/index.js +5 -0
  55. package/src/utils/LICENSE +21 -0
  56. package/src/utils/README.md +24 -0
  57. package/src/utils/lib/console.js +16 -0
  58. package/src/utils/lib/debounce.js +9 -0
  59. package/src/utils/lib/deepextend.js +51 -0
  60. package/src/utils/lib/deepset.js +14 -0
  61. package/src/utils/lib/extend.js +20 -0
  62. package/src/utils/lib/index.js +14 -0
  63. package/src/utils/lib/json.js +90 -0
  64. package/src/utils/lib/mergeprops.js +62 -0
  65. package/src/utils/lib/mitt.js +43 -0
  66. package/src/utils/lib/modify.js +8 -0
  67. package/src/utils/lib/slot.js +8 -0
  68. package/src/utils/lib/toarray.js +5 -0
  69. package/src/utils/lib/tocase.js +11 -0
  70. package/src/utils/lib/todate.js +10 -0
  71. package/src/utils/lib/toline.js +10 -0
  72. package/src/utils/lib/topromise.js +10 -0
  73. package/src/utils/lib/tostring.js +7 -0
  74. package/src/utils/lib/type.js +45 -0
  75. package/src/utils/lib/unique.js +6 -0
  76. package/src/utils/package.json +32 -0
  77. package/src/vant/LICENSE +21 -0
  78. package/src/vant/auto-import.d.ts +5 -0
  79. package/src/vant/auto-import.js +50 -0
  80. package/src/vant/babel.config.js +10 -0
  81. package/src/vant/bili.config.js +40 -0
  82. package/src/vant/examples/App.vue +96 -0
  83. package/src/vant/examples/main.js +13 -0
  84. package/src/vant/examples/rule.js +366 -0
  85. package/src/vant/package.json +83 -0
  86. package/src/vant/public/index.html +14 -0
  87. package/src/vant/src/components/calendar.jsx +128 -0
  88. package/src/vant/src/components/cascader.jsx +120 -0
  89. package/src/vant/src/components/checkbox.jsx +38 -0
  90. package/src/vant/src/components/datePicker.jsx +87 -0
  91. package/src/vant/src/components/group.jsx +384 -0
  92. package/src/vant/src/components/icon/IconWarning.vue +12 -0
  93. package/src/vant/src/components/index.js +26 -0
  94. package/src/vant/src/components/radio.jsx +38 -0
  95. package/src/vant/src/components/select.jsx +81 -0
  96. package/src/vant/src/components/timePicker.jsx +76 -0
  97. package/src/vant/src/components/uploader.jsx +99 -0
  98. package/src/vant/src/core/alias.js +31 -0
  99. package/src/vant/src/core/api.js +135 -0
  100. package/src/vant/src/core/config.js +35 -0
  101. package/src/vant/src/core/index.js +45 -0
  102. package/src/vant/src/core/manager.js +282 -0
  103. package/src/vant/src/core/provider.js +63 -0
  104. package/src/vant/src/core/utils.js +15 -0
  105. package/src/vant/src/index.js +13 -0
  106. package/src/vant/src/parsers/hidden.js +12 -0
  107. package/src/vant/src/parsers/index.js +59 -0
  108. package/src/vant/src/parsers/row.js +10 -0
  109. package/src/vant/src/style/index.css +495 -0
  110. package/src/vant/types/config.d.ts +99 -0
  111. package/src/vant/types/index.d.ts +27 -0
  112. package/src/vant/vue.config.js +21 -0
@@ -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)