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.
Files changed (101) hide show
  1. package/README.md +87 -278
  2. package/dist/components/common/subform/package.json +48 -0
  3. package/dist/components/common/subform/src/component.jsx +75 -0
  4. package/dist/components/common/subform/src/index.js +3 -0
  5. package/dist/components/common/wangeditor/package-lock.json +114 -0
  6. package/dist/components/common/wangeditor/package.json +52 -0
  7. package/dist/components/common/wangeditor/src/component.jsx +74 -0
  8. package/dist/components/common/wangeditor/src/index.js +3 -0
  9. package/dist/core/babel.config.js +13 -0
  10. package/dist/core/bili.config.js +34 -0
  11. package/dist/core/package-lock.json +13 -0
  12. package/dist/core/package.json +61 -0
  13. package/dist/core/src/components/formCreate.js +287 -0
  14. package/dist/core/src/components/fragment.js +12 -0
  15. package/dist/core/src/factory/context.js +264 -0
  16. package/dist/core/src/factory/creator.js +63 -0
  17. package/dist/core/src/factory/maker.js +17 -0
  18. package/dist/core/src/factory/manager.js +87 -0
  19. package/dist/core/src/factory/node.js +89 -0
  20. package/dist/core/src/factory/parser.js +28 -0
  21. package/dist/core/src/frame/api.js +691 -0
  22. package/dist/core/src/frame/attrs.js +12 -0
  23. package/dist/core/src/frame/dataDriver.js +76 -0
  24. package/dist/core/src/frame/fetch.js +128 -0
  25. package/dist/core/src/frame/index.js +792 -0
  26. package/dist/core/src/frame/language.js +50 -0
  27. package/dist/core/src/frame/provider.js +297 -0
  28. package/dist/core/src/frame/util.js +311 -0
  29. package/dist/core/src/handler/context.js +573 -0
  30. package/dist/core/src/handler/effect.js +122 -0
  31. package/dist/core/src/handler/index.js +143 -0
  32. package/dist/core/src/handler/inject.js +199 -0
  33. package/dist/core/src/handler/input.js +199 -0
  34. package/dist/core/src/handler/lifecycle.js +55 -0
  35. package/dist/core/src/handler/loader.js +375 -0
  36. package/dist/core/src/handler/page.js +46 -0
  37. package/dist/core/src/handler/render.js +29 -0
  38. package/dist/core/src/index.js +12 -0
  39. package/dist/core/src/parser/html.js +17 -0
  40. package/dist/core/src/render/cache.js +47 -0
  41. package/dist/core/src/render/index.js +33 -0
  42. package/dist/core/src/render/render.js +418 -0
  43. package/dist/core/types/index.d.ts +842 -0
  44. package/dist/icarys-fc-vant.umd.js +17 -0
  45. package/dist/index.d.ts +27 -0
  46. package/dist/index.esm.js +39 -0
  47. package/dist/index.js +46 -0
  48. package/dist/utils/lib/console.js +16 -0
  49. package/dist/utils/lib/debounce.js +9 -0
  50. package/dist/utils/lib/deepextend.js +51 -0
  51. package/dist/utils/lib/deepset.js +14 -0
  52. package/dist/utils/lib/extend.js +20 -0
  53. package/dist/utils/lib/index.js +14 -0
  54. package/dist/utils/lib/json.js +90 -0
  55. package/dist/utils/lib/mergeprops.js +62 -0
  56. package/dist/utils/lib/mitt.js +43 -0
  57. package/dist/utils/lib/modify.js +8 -0
  58. package/dist/utils/lib/slot.js +8 -0
  59. package/dist/utils/lib/toarray.js +5 -0
  60. package/dist/utils/lib/tocase.js +11 -0
  61. package/dist/utils/lib/todate.js +10 -0
  62. package/dist/utils/lib/toline.js +10 -0
  63. package/dist/utils/lib/topromise.js +10 -0
  64. package/dist/utils/lib/tostring.js +7 -0
  65. package/dist/utils/lib/type.js +45 -0
  66. package/dist/utils/lib/unique.js +6 -0
  67. package/dist/utils/package.json +32 -0
  68. package/dist/vant/auto-import.d.ts +5 -0
  69. package/dist/vant/auto-import.js +50 -0
  70. package/dist/vant/babel.config.js +10 -0
  71. package/dist/vant/bili.config.js +40 -0
  72. package/dist/vant/examples/main.js +13 -0
  73. package/dist/vant/examples/rule.js +366 -0
  74. package/dist/vant/package.json +83 -0
  75. package/dist/vant/src/components/calendar.jsx +128 -0
  76. package/dist/vant/src/components/cascader.jsx +120 -0
  77. package/dist/vant/src/components/checkbox.jsx +38 -0
  78. package/dist/vant/src/components/datePicker.jsx +87 -0
  79. package/dist/vant/src/components/group.jsx +384 -0
  80. package/dist/vant/src/components/index.js +26 -0
  81. package/dist/vant/src/components/radio.jsx +38 -0
  82. package/dist/vant/src/components/select.jsx +81 -0
  83. package/dist/vant/src/components/timePicker.jsx +76 -0
  84. package/dist/vant/src/components/uploader.jsx +99 -0
  85. package/dist/vant/src/core/alias.js +31 -0
  86. package/dist/vant/src/core/api.js +135 -0
  87. package/dist/vant/src/core/config.js +35 -0
  88. package/dist/vant/src/core/index.js +45 -0
  89. package/dist/vant/src/core/manager.js +282 -0
  90. package/dist/vant/src/core/provider.js +63 -0
  91. package/dist/vant/src/core/utils.js +15 -0
  92. package/dist/vant/src/index.js +13 -0
  93. package/dist/vant/src/parsers/hidden.js +12 -0
  94. package/dist/vant/src/parsers/index.js +59 -0
  95. package/dist/vant/src/parsers/row.js +10 -0
  96. package/dist/vant/src/style/index.css +495 -0
  97. package/dist/vant/types/config.d.ts +99 -0
  98. package/dist/vant/types/index.d.ts +27 -0
  99. package/dist/vant/vue.config.js +21 -0
  100. package/package.json +29 -67
  101. package/dist/index.min.js +0 -7411
@@ -0,0 +1,418 @@
1
+ import extend, {copy} from '../../../utils/lib/extend';
2
+ import mergeProps from '../../../utils/lib/mergeprops';
3
+ import is from '../../../utils/lib/type';
4
+ import {invoke, makeSlotBag, mergeRule} from '../frame/util';
5
+ import toCase, {lower} from '../../../utils/lib/tocase';
6
+ import {deepSet, toLine} from '@form-create/utils';
7
+ import {computed, nextTick} from 'vue';
8
+
9
+ export default function useRender(Render) {
10
+ extend(Render.prototype, {
11
+ initRender() {
12
+ this.cacheConfig = {};
13
+ },
14
+ getTypeSlot(ctx) {
15
+ const _fn = (vm) => {
16
+ if (vm) {
17
+ let slot = undefined;
18
+ if (ctx.rule.field) {
19
+ slot = vm.slots['field-' + toLine(ctx.rule.field)] || vm.slots['field-' + ctx.rule.field];
20
+ }
21
+ if (!slot) {
22
+ slot = vm.slots['type-' + toLine(ctx.type)] || vm.slots['type-' + ctx.type];
23
+ }
24
+ if (slot) {
25
+ return slot;
26
+ }
27
+ return _fn(vm.setupState.parent);
28
+ }
29
+ }
30
+ return _fn(this.vm);
31
+ },
32
+ render() {
33
+ // console.warn('renderrrrr', this.id);
34
+ if (!this.vm.setupState.isShow) {
35
+ return;
36
+ }
37
+ this.$manager.beforeRender();
38
+ const slotBag = makeSlotBag();
39
+ this.sort.forEach((k) => {
40
+ this.renderSlot(slotBag, this.$handle.ctxs[k]);
41
+ });
42
+
43
+ return this.$manager.render(slotBag);
44
+ },
45
+ renderSlot(slotBag, ctx, parent) {
46
+ if (this.isFragment(ctx)) {
47
+ ctx.initProp();
48
+ this.mergeGlobal(ctx);
49
+ ctx.initNone();
50
+ const slots = this.renderChildren(ctx.loadChildrenPending(), ctx);
51
+ const def = slots.default;
52
+ def && slotBag.setSlot(ctx.rule.slot, () => def());
53
+ delete slots.default;
54
+ slotBag.mergeBag(slots);
55
+ } else {
56
+ slotBag.setSlot(ctx.rule.slot, this.renderCtx(ctx, parent));
57
+ }
58
+ },
59
+ mergeGlobal(ctx) {
60
+ const g = this.$handle.options.global;
61
+ if (!g) return;
62
+ if (!this.cacheConfig[ctx.trueType]) {
63
+ this.cacheConfig[ctx.trueType] = computed(() => {
64
+ const g = this.$handle.options.global;
65
+ return mergeRule({}, [g['*'] || g.default || {}, g[ctx.originType] || g[ctx.type] || g[ctx.type] || {}]);
66
+ });
67
+ }
68
+ ctx.prop = mergeRule({}, [this.cacheConfig[ctx.trueType].value, ctx.prop]);
69
+ },
70
+ setOptions(ctx) {
71
+ const opt = ctx.loadPending({key: 'options', origin: ctx.prop.options, def: []});
72
+ ctx.prop.options = opt;
73
+ if (ctx.prop.optionsTo && opt) {
74
+ deepSet(ctx.prop, ctx.prop.optionsTo, opt);
75
+ }
76
+ },
77
+ deepSet(ctx) {
78
+ const deep = ctx.prop.deep;
79
+ deep && Object.keys(deep).sort((a, b) => a.length < b.length ? -1 : 1).forEach(str => {
80
+ deepSet(ctx.prop, str, deep[str]);
81
+ });
82
+ },
83
+ parseSide(side, ctx) {
84
+ return is.Object(side) ? mergeRule({props: {formCreateInject: ctx.prop.props.formCreateInject}}, side) : side;
85
+ },
86
+ renderSides(vn, ctx, temp) {
87
+ const prop = ctx[temp ? 'rule' : 'prop'];
88
+ return [this.renderRule(this.parseSide(prop.prefix, ctx)), vn, this.renderRule(this.parseSide(prop.suffix, ctx))];
89
+ },
90
+ renderId(name, type) {
91
+ const ctxs = this.$handle[type === 'field' ? 'fieldCtx' : 'nameCtx'][name]
92
+ return ctxs ? ctxs.map(ctx => this.renderCtx(ctx, ctx.parent)) : undefined;
93
+ },
94
+ renderCtx(ctx, parent) {
95
+ try {
96
+ if (ctx.type === 'hidden') return;
97
+ const rule = ctx.rule;
98
+ if (this.force || (!this.cache[ctx.id]) || this.cache[ctx.id].slot !== rule.slot) {
99
+ let vn;
100
+ ctx.initProp();
101
+ this.mergeGlobal(ctx);
102
+ ctx.initNone();
103
+ this.$manager.tidyRule(ctx);
104
+ this.deepSet(ctx);
105
+ this.setOptions(ctx);
106
+ this.ctxProp(ctx);
107
+ let prop = ctx.prop;
108
+ prop.preview = !!(prop.preview != null ? prop.preview : this.$handle.preview);
109
+ prop.props.formCreateInject = this.injectProp(ctx);
110
+ let cacheFlag = prop.cache !== false;
111
+ const preview = prop.preview;
112
+
113
+ if (prop.hidden) {
114
+ this.setCache(ctx, undefined, parent);
115
+ return;
116
+ }
117
+ vn = (...slotValue) => {
118
+ const inject = {
119
+ rule,
120
+ prop,
121
+ preview,
122
+ api: this.$handle.api,
123
+ model: prop.model || {},
124
+ slotValue
125
+ }
126
+ if (slotValue.length && rule.slotUpdate) {
127
+ invoke(() => rule.slotUpdate(inject))
128
+ }
129
+ let children = {};
130
+ const _load = ctx.loadChildrenPending();
131
+ if (ctx.parser.renderChildren) {
132
+ children = ctx.parser.renderChildren(_load, ctx);
133
+ } else if (ctx.parser.loadChildren !== false) {
134
+ children = this.renderChildren(_load, ctx);
135
+ }
136
+ Object.keys(prop.renderSlots || {}).forEach(key => {
137
+ children[key] = (...args) => {
138
+ if (is.Function(prop.renderSlots[key])) {
139
+ return invoke(() => prop.renderSlots[key](...args));
140
+ }
141
+ const rule = this.parseSide(prop.renderSlots[key], ctx);
142
+ return this.renderRule(rule);
143
+ }
144
+ })
145
+ const slot = this.getTypeSlot(ctx);
146
+ let _vn;
147
+ if (slot) {
148
+ inject.children = children;
149
+ _vn = slot(inject)
150
+ } else {
151
+ _vn = preview ? ctx.parser.preview(copy(children), ctx) : ctx.parser.render(copy(children), ctx);
152
+ }
153
+ _vn = this.renderSides(_vn, ctx);
154
+ if ((!(!ctx.input && is.Undef(prop.native))) && prop.native !== true) {
155
+ this.fc.targetFormDriver('updateWrap', ctx)
156
+ _vn = this.$manager.makeWrap(ctx, _vn);
157
+ }
158
+ if (ctx.none) {
159
+ if (Array.isArray(_vn)) {
160
+ _vn = _vn.map(v => {
161
+ if (!v || !v.__v_isVNode) {
162
+ return v;
163
+ }
164
+ return this.none(v);
165
+ });
166
+ } else {
167
+ _vn = this.none(_vn);
168
+ }
169
+ }
170
+ cacheFlag && this.setCache(ctx, () => {
171
+ return this.stable(_vn);
172
+ }, parent);
173
+ return _vn
174
+ };
175
+ this.setCache(ctx, vn, parent);
176
+ }
177
+ return (...args) => {
178
+ const cache = this.getCache(ctx);
179
+ if (cache) {
180
+ return cache(...args);
181
+ } else if (this.cache[ctx.id]) {
182
+ return;
183
+ }
184
+ const _vn = this.renderCtx(ctx, ctx.parent);
185
+ if (_vn) {
186
+ return _vn();
187
+ }
188
+ };
189
+ } catch (e) {
190
+ console.error(e);
191
+ return;
192
+ }
193
+ },
194
+ none(vn) {
195
+ if (vn) {
196
+ vn.props.class = this.mergeClass(vn.props.class, 'fc-none')
197
+ return vn;
198
+ }
199
+ },
200
+ mergeClass(target, value) {
201
+ if (Array.isArray(target)) {
202
+ target.push(value);
203
+ } else {
204
+ return target ? [target, value] : value;
205
+ }
206
+ return target;
207
+ },
208
+ stable(vn) {
209
+ const list = Array.isArray(vn) ? vn : [vn];
210
+ list.forEach(v => {
211
+ if (v && v.__v_isVNode && v.children && typeof v.children === 'object') {
212
+ v.children.$stable = true;
213
+ this.stable(v.children);
214
+ }
215
+ });
216
+ return vn;
217
+ },
218
+ getModelField(ctx) {
219
+ return ctx.prop.modelField || ctx.parser.modelField || this.fc.modelFields[this.vNode.aliasMap[ctx.type]] || this.fc.modelFields[ctx.type] || this.fc.modelFields[ctx.originType] || 'modelValue';
220
+ },
221
+ isFragment(ctx) {
222
+ return ctx.type === 'fragment' || ctx.type === 'template';
223
+ },
224
+ injectProp(ctx) {
225
+ const state = this.vm.setupState;
226
+ if (!state.ctxInject[ctx.id]) {
227
+ state.ctxInject[ctx.id] = {
228
+ api: this.$handle.api,
229
+ form: this.fc.create,
230
+ subForm: subForm => {
231
+ this.$handle.addSubForm(ctx, subForm);
232
+ },
233
+ getSubForm: () => {
234
+ return this.$handle.subForm[ctx.id];
235
+ },
236
+ slots: () => {
237
+ return this.vm.setupState.top.slots;
238
+ },
239
+ getWrap: () => {
240
+ return this.vm.refs[ctx.wrapRef];
241
+ },
242
+ options: [],
243
+ children: [],
244
+ preview: false,
245
+ id: ctx.id,
246
+ field: ctx.field,
247
+ rule: ctx.rule,
248
+ input: ctx.input,
249
+ t: (...args) => {
250
+ return this.$handle.api.t(...args);
251
+ },
252
+ updateValue: (data) => {
253
+ this.$handle.onUpdateValue(ctx, data);
254
+ }
255
+ }
256
+ }
257
+ const inject = state.ctxInject[ctx.id];
258
+ extend(inject, {
259
+ preview: ctx.prop.preview,
260
+ options: ctx.prop.options,
261
+ children: ctx.loadChildrenPending()
262
+ });
263
+ return inject;
264
+ },
265
+ ctxProp(ctx) {
266
+ const {ref, key, rule} = ctx;
267
+ this.$manager.mergeProp(ctx);
268
+ ctx.parser.mergeProp(ctx);
269
+ const props = [
270
+ {
271
+ ref: ref,
272
+ key: rule.key || `${key}fc`,
273
+ slot: undefined,
274
+ on: {
275
+ vnodeMounted: (vn) => {
276
+ vn.el.__rule__ = ctx.rule;
277
+ this.onMounted(ctx, vn.el);
278
+ },
279
+ 'fc.updateValue': (data) => {
280
+ this.$handle.onUpdateValue(ctx, data);
281
+ },
282
+ 'fc.el': (el) => {
283
+ ctx.exportEl = el;
284
+ if (el) {
285
+ (el.$el || el).__rule__ = ctx.rule;
286
+ }
287
+ }
288
+ }
289
+ }
290
+ ]
291
+
292
+ if (ctx.input) {
293
+ const tmpInput = this.tmpInput;
294
+ if (this.vm.props.disabled === true) {
295
+ ctx.prop.props.disabled = true;
296
+ }
297
+ const field = this.getModelField(ctx);
298
+ const model = {
299
+ callback: (value) => {
300
+ tmpInput && tmpInput(ctx.field, value, ctx.rule);
301
+ this.onInput(ctx, value);
302
+ },
303
+ modelField: field,
304
+ value: this.$handle.getFormData(ctx)
305
+ };
306
+ props.push({
307
+ on: {
308
+ [`update:${field}`]: model.callback,
309
+ ...(ctx.prop.modelEmit ? {
310
+ [ctx.prop.modelEmit]: () => this.onEmitInput(ctx)
311
+ } : {}),
312
+ },
313
+ props: {
314
+ [field]: model.value
315
+ }
316
+ })
317
+ ctx.prop.model = model;
318
+ }
319
+ mergeProps(props, ctx.prop);
320
+ return ctx.prop;
321
+ },
322
+ onMounted(ctx, el) {
323
+ ctx.el = this.vm.refs[ctx.ref] || el;
324
+ ctx.parser.mounted(ctx);
325
+ this.$handle.effect(ctx, 'mounted');
326
+ this.$handle.targetHook(ctx, 'mounted');
327
+ },
328
+ onInput(ctx, value) {
329
+ if (ctx.prop.modelEmit) {
330
+ this.$handle.onBaseInput(ctx, value);
331
+ return;
332
+ }
333
+ this.$handle.onInput(ctx, value);
334
+ },
335
+ onEmitInput(ctx) {
336
+ this.$handle.setValue(ctx, ctx.parser.toValue(ctx.modelValue, ctx), ctx.modelValue);
337
+ },
338
+ renderChildren(children, ctx) {
339
+ if (!is.trueArray(children)) return {};
340
+ const slotBag = makeSlotBag()
341
+ children.map(child => {
342
+ if (!child) return;
343
+ if (is.String(child) || is.Number(child)) return slotBag.setSlot(null, `${child}`);
344
+ if (child.__fc__) {
345
+ return this.renderSlot(slotBag, child.__fc__, ctx);
346
+ }
347
+ if (child.type) {
348
+ nextTick(() => {
349
+ this.$handle.loadChildren(children, ctx);
350
+ this.$handle.refresh();
351
+ });
352
+ }
353
+ });
354
+ return slotBag.getSlots();
355
+ },
356
+ defaultRender(ctx, children) {
357
+ const prop = ctx.prop;
358
+ if (prop.component) {
359
+ if (typeof prop.component === 'string') {
360
+ return this.vNode.make(prop.component, prop, children);
361
+ } else {
362
+ return this.vNode.makeComponent(prop.component, prop, children);
363
+ }
364
+ }
365
+ if (this.vNode[ctx.type])
366
+ return this.vNode[ctx.type](prop, children);
367
+ if (this.vNode[ctx.originType])
368
+ return this.vNode[ctx.originType](prop, children);
369
+ return this.vNode.make(lower(prop.type), prop, children);
370
+ },
371
+ createChildrenVnodes(ctx, onInput, force) {
372
+ this.force = force !== false;
373
+ this.tmpInput = onInput;
374
+ const res = this.renderChildren(ctx.rule.children, ctx);
375
+ this.force = false;
376
+ this.tmpInput = null;
377
+ return res;
378
+ },
379
+ createRuleVnode(ctx, onInput, force) {
380
+ this.force = force !== false;
381
+ this.tmpInput = onInput;
382
+ const slotBag = makeSlotBag();
383
+ this.renderSlot(slotBag, ctx, ctx.parent);
384
+ this.force = false;
385
+ this.tmpInput = null;
386
+ return slotBag.getSlots();
387
+ },
388
+ renderRule(rule, children, origin) {
389
+ if (!rule) return undefined;
390
+ if (is.String(rule) || is.Number(rule)) return `${rule}`;
391
+
392
+ let type;
393
+ if (origin) {
394
+ type = rule.type;
395
+ } else {
396
+ type = rule.is;
397
+ if (rule.type) {
398
+ type = toCase(rule.type);
399
+ const alias = this.vNode.aliasMap[type];
400
+ if (alias) type = toCase(alias);
401
+ }
402
+ }
403
+
404
+ if (!type) return undefined;
405
+
406
+ const slotBag = makeSlotBag();
407
+ if (is.trueArray(rule.children)) {
408
+ rule.children.forEach(v => {
409
+ v && slotBag.setSlot(v?.slot, () => this.renderRule(v));
410
+ });
411
+ }
412
+ const props = {...rule};
413
+ delete props.type;
414
+ delete props.is;
415
+ return this.vNode.make(type, props, slotBag.mergeBag(children).getSlots());
416
+ }
417
+ })
418
+ }