@bdsoft/element 1.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/README.md +90 -0
- package/global/index.ts +6 -0
- package/global/register-properties.ts +10 -0
- package/index.html +13 -0
- package/index.js +84 -0
- package/package-form/core/components/formCreate.js +274 -0
- package/package-form/core/components/fragment.js +12 -0
- package/package-form/core/factory/context.js +257 -0
- package/package-form/core/factory/creator.js +63 -0
- package/package-form/core/factory/maker.js +17 -0
- package/package-form/core/factory/manager.js +79 -0
- package/package-form/core/factory/node.js +85 -0
- package/package-form/core/factory/parser.js +28 -0
- package/package-form/core/frame/api.js +599 -0
- package/package-form/core/frame/attrs.js +12 -0
- package/package-form/core/frame/dataDriver.js +76 -0
- package/package-form/core/frame/fetch.js +119 -0
- package/package-form/core/frame/formCreate.js +274 -0
- package/package-form/core/frame/index.js +760 -0
- package/package-form/core/frame/provider.js +288 -0
- package/package-form/core/frame/util.js +274 -0
- package/package-form/core/handler/context.js +380 -0
- package/package-form/core/handler/effect.js +122 -0
- package/package-form/core/handler/index.js +111 -0
- package/package-form/core/handler/inject.js +145 -0
- package/package-form/core/handler/input.js +197 -0
- package/package-form/core/handler/lifecycle.js +43 -0
- package/package-form/core/handler/loader.js +373 -0
- package/package-form/core/handler/page.js +46 -0
- package/package-form/core/handler/render.js +29 -0
- package/package-form/core/index.js +12 -0
- package/package-form/core/package.json +15 -0
- package/package-form/core/parser/html.js +17 -0
- package/package-form/core/render/cache.js +47 -0
- package/package-form/core/render/index.js +31 -0
- package/package-form/core/render/render.js +393 -0
- package/package-form/element-form/components/checkbox/package.json +17 -0
- package/package-form/element-form/components/checkbox/src/component.jsx +110 -0
- package/package-form/element-form/components/checkbox/src/index.js +3 -0
- package/package-form/element-form/components/frame/package.json +17 -0
- package/package-form/element-form/components/frame/src/IconCircleClose.vue +14 -0
- package/package-form/element-form/components/frame/src/IconDelete.vue +12 -0
- package/package-form/element-form/components/frame/src/IconDocument.vue +12 -0
- package/package-form/element-form/components/frame/src/IconFolderOpened.vue +12 -0
- package/package-form/element-form/components/frame/src/IconView.vue +12 -0
- package/package-form/element-form/components/frame/src/component.jsx +349 -0
- package/package-form/element-form/components/frame/src/index.js +3 -0
- package/package-form/element-form/components/frame/src/style.css +66 -0
- package/package-form/element-form/components/group/package.json +17 -0
- package/package-form/element-form/components/group/src/component.jsx +314 -0
- package/package-form/element-form/components/group/src/index.js +3 -0
- package/package-form/element-form/components/group/src/style.css +125 -0
- package/package-form/element-form/components/index.js +22 -0
- package/package-form/element-form/components/radio/package.json +17 -0
- package/package-form/element-form/components/radio/src/component.jsx +101 -0
- package/package-form/element-form/components/radio/src/index.js +3 -0
- package/package-form/element-form/components/select/package.json +17 -0
- package/package-form/element-form/components/select/src/component.jsx +52 -0
- package/package-form/element-form/components/select/src/index.js +3 -0
- package/package-form/element-form/components/subform/package.json +14 -0
- package/package-form/element-form/components/subform/src/component.jsx +76 -0
- package/package-form/element-form/components/subform/src/index.js +3 -0
- package/package-form/element-form/components/tree/package.json +17 -0
- package/package-form/element-form/components/tree/src/component.jsx +62 -0
- package/package-form/element-form/components/tree/src/index.js +3 -0
- package/package-form/element-form/components/upload/package.json +17 -0
- package/package-form/element-form/components/upload/src/IconUpload.vue +12 -0
- package/package-form/element-form/components/upload/src/component.jsx +129 -0
- package/package-form/element-form/components/upload/src/index.js +3 -0
- package/package-form/element-form/components/upload/src/style.css +11 -0
- package/package-form/element-form/index.js +8 -0
- package/package-form/element-form/package.json +16 -0
- package/package-form/element-form/src/components/icon/IconWarning.vue +12 -0
- package/package-form/element-form/src/components/index.js +22 -0
- package/package-form/element-form/src/core/alias.js +34 -0
- package/package-form/element-form/src/core/api.js +208 -0
- package/package-form/element-form/src/core/config.js +62 -0
- package/package-form/element-form/src/core/index.js +60 -0
- package/package-form/element-form/src/core/maker.js +76 -0
- package/package-form/element-form/src/core/manager.js +315 -0
- package/package-form/element-form/src/core/provider.js +79 -0
- package/package-form/element-form/src/parsers/datePicker.js +31 -0
- package/package-form/element-form/src/parsers/hidden.js +12 -0
- package/package-form/element-form/src/parsers/index.js +17 -0
- package/package-form/element-form/src/parsers/input.js +21 -0
- package/package-form/element-form/src/parsers/row.js +10 -0
- package/package-form/element-form/src/parsers/select.js +15 -0
- package/package-form/element-form/src/parsers/slider.js +21 -0
- package/package-form/element-form/src/parsers/timePicker.js +17 -0
- package/package-form/element-form/src/style/index.css +52 -0
- package/package.json +17 -0
- package/src/App.vue +28 -0
- package/src/assets/css/element.scss +179 -0
- package/src/assets/css/layout.scss +215 -0
- package/src/assets/css/tailwind.scss +67 -0
- package/src/assets/images/banner.gif +0 -0
- package/src/assets/images/banner.png +0 -0
- package/src/assets/images/bg1.svg +22 -0
- package/src/assets/images/bg2.png +0 -0
- package/src/assets/images/ff.png +0 -0
- package/src/assets/images/home-file1.png +0 -0
- package/src/assets/images/ky.png +0 -0
- package/src/assets/images/menu/add.png +0 -0
- package/src/assets/images/menu/del.png +0 -0
- package/src/assets/images/menu/down.png +0 -0
- package/src/assets/images/menu/dr.png +0 -0
- package/src/assets/images/menu/edit.png +0 -0
- package/src/assets/images/menu/kx.png +0 -0
- package/src/assets/images/menu/mb.png +0 -0
- package/src/assets/images/menu/pz.png +0 -0
- package/src/assets/images/menu/save.png +0 -0
- package/src/assets/images/menu/sj.png +0 -0
- package/src/assets/images/menu/sjk.png +0 -0
- package/src/assets/images/menu/up.png +0 -0
- package/src/assets/images/po-i.png +0 -0
- package/src/assets/images/po1-i1.png +0 -0
- package/src/assets/images/po1-i2.png +0 -0
- package/src/assets/images/po1-i3.png +0 -0
- package/src/assets/images/po1-i4.png +0 -0
- package/src/assets/images/po1-i5.png +0 -0
- package/src/assets/images/po1-i6.png +0 -0
- package/src/assets/images/po1-i7.png +0 -0
- package/src/assets/images/po1-i8.png +0 -0
- package/src/assets/images/po2-i1.png +0 -0
- package/src/assets/images/po2-i2.png +0 -0
- package/src/assets/images/po3-i1.png +0 -0
- package/src/assets/images/po4-i1.png +0 -0
- package/src/assets/images/po5-i1.png +0 -0
- package/src/assets/images/po6-i1.png +0 -0
- package/src/assets/images/po6-i2.png +0 -0
- package/src/assets/images/po7-i1.png +0 -0
- package/src/assets/images/tj1.png +0 -0
- package/src/assets/images/tj2.png +0 -0
- package/src/assets/images/tj3.png +0 -0
- package/src/components/3dcloudwords/index.js +346 -0
- package/src/components/3dcloudwords/index.vue +99 -0
- package/src/components/3dcloudwords/readme.md +66 -0
- package/src/components/badge/index.js +167 -0
- package/src/components/badge/index.scss +166 -0
- package/src/components/badge/index.vue +98 -0
- package/src/components/badge/readme.md +18 -0
- package/src/components/basic/Finish.vue +107 -0
- package/src/components/basic/button.vue +19 -0
- package/src/components/basic/readme.md +7 -0
- package/src/components/button/index.vue +48 -0
- package/src/components/button/readme.md +62 -0
- package/src/components/carousel/index.vue +104 -0
- package/src/components/carousel/readme.md +12 -0
- package/src/components/chartconfig/index.vue +141 -0
- package/src/components/chartconfig/readme.md +25 -0
- package/src/components/contextMenu/hookContxtMenu.js +41 -0
- package/src/components/contextMenu/index.vue +245 -0
- package/src/components/contextMenu/readme.md +55 -0
- package/src/components/contextMenu/useElementBounding.js +40 -0
- package/src/components/countup/countUp.js +196 -0
- package/src/components/countup/index.vue +112 -0
- package/src/components/countup/readme.md +9 -0
- package/src/components/empty/assets/build.png +0 -0
- package/src/components/empty/assets/emptybg.gif +0 -0
- package/src/components/empty/assets/emptybg.png +0 -0
- package/src/components/empty/assets/emptybg2.jpg +0 -0
- package/src/components/empty/assets/emptybg3.jpg +0 -0
- package/src/components/empty/assets/wuxiao.png +0 -0
- package/src/components/empty/assets/wuxiao.webp +0 -0
- package/src/components/empty/building.vue +117 -0
- package/src/components/empty/empty.vue +120 -0
- package/src/components/empty/index.js +12 -0
- package/src/components/empty/invalid.vue +56 -0
- package/src/components/error/Error.vue +79 -0
- package/src/components/error/readme.md +20 -0
- package/src/components/form/Form.vue +84 -0
- package/src/components/form/FormItem.vue +143 -0
- package/src/components/form/data.js +52 -0
- package/src/components/form/readme.md +69 -0
- package/src/components/layout/banner.vue +412 -0
- package/src/components/layout/bar.vue +43 -0
- package/src/components/layout/layout1.vue +60 -0
- package/src/components/layout/layout2.vue +134 -0
- package/src/components/layout/layout3.vue +107 -0
- package/src/components/layout/layout4.vue +66 -0
- package/src/components/layout/nav.vue +333 -0
- package/src/components/layout/readme.md +61 -0
- package/src/components/loading/index.vue +122 -0
- package/src/components/loading/readme.md +6 -0
- package/src/components/notice/NoticeList.vue +198 -0
- package/src/components/notice/NoticeListPaging.vue +281 -0
- package/src/components/notice/NoticeView.vue +92 -0
- package/src/components/notice/readme.md +1 -0
- package/src/components/pagination/index.vue +100 -0
- package/src/components/pagination/readme.md +19 -0
- package/src/components/pagination/scroll-to.js +51 -0
- package/src/components/progress/bar.vue +72 -0
- package/src/components/progress/progress.vue +58 -0
- package/src/components/screenfull/index.js +3 -0
- package/src/components/screenfull/index.vue +65 -0
- package/src/components/screenfull/package.json +15 -0
- package/src/components/screenfull/readme.md +6 -0
- package/src/components/statisticalCount/index.vue +80 -0
- package/src/components/statisticalCount/readme.md +21 -0
- package/src/components/username/index.vue +79 -0
- package/src/components/username/readme.md +22 -0
- package/src/components/username//346/225/210/346/236/234/345/233/276.png +0 -0
- package/src/index.js +82 -0
- package/src/utils/index.js +32 -0
- package/src/xm_components/HeadSearch/hook/hookSearch.js +96 -0
- package/src/xm_components/HeadSearch/index.vue +206 -0
- package/src/xm_components/HeadSearch/readme.md +12 -0
- package/src/xm_components/HeadSearch//346/220/234/347/264/242/345/210/227/350/241/250.png +0 -0
- package/src/xm_components/Milestone/index.vue +212 -0
- package/src/xm_components/Milestone/readme.md +15 -0
- package/src/xm_components/readme.md +1 -0
- package/utils/coms/load.jsx +10 -0
- package/utils/func.js +32 -0
- package/utils/hookDialog.js +38 -0
- package/utils/hookPage.js +49 -0
- package/utils/index.js +5 -0
- package/utils/lib/console.js +39 -0
- package/utils/lib/debounce.js +19 -0
- package/utils/lib/deepextend.js +51 -0
- package/utils/lib/deepset.js +14 -0
- package/utils/lib/extend.js +28 -0
- package/utils/lib/index.js +13 -0
- package/utils/lib/json.js +90 -0
- package/utils/lib/mergeprops.js +62 -0
- package/utils/lib/mitt.js +43 -0
- package/utils/lib/modify.js +8 -0
- package/utils/lib/slot.js +19 -0
- package/utils/lib/toarray.js +5 -0
- package/utils/lib/tocase.js +11 -0
- package/utils/lib/todate.js +10 -0
- package/utils/lib/toline.js +10 -0
- package/utils/lib/tostring.js +7 -0
- package/utils/lib/type.js +45 -0
- package/utils/lib/unique.js +6 -0
- package/utils/message.js +166 -0
- package/utils/package.json +16 -0
- package/utils/type.js +45 -0
- package/vite.config.js +51 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import extend, {copy} from '@bdsoft-element/utils/lib/extend';
|
|
2
|
+
import mergeProps from '@bdsoft-element/utils/lib/mergeprops';
|
|
3
|
+
import is from '@bdsoft-element/utils/lib/type';
|
|
4
|
+
import {invoke, makeSlotBag, mergeRule} from '../frame/util';
|
|
5
|
+
import toCase, {lower} from '@bdsoft-element/utils/lib/tocase';
|
|
6
|
+
import {deepSet, toLine} from '@bdsoft-element/utils/lib';
|
|
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.rule.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.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] = () => {
|
|
138
|
+
const rule = this.parseSide(prop.renderSlots[key], ctx);
|
|
139
|
+
return this.renderRule(rule);
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
const slot = this.getTypeSlot(ctx);
|
|
143
|
+
let _vn;
|
|
144
|
+
if (slot) {
|
|
145
|
+
inject.children = children;
|
|
146
|
+
_vn = slot(inject)
|
|
147
|
+
} else {
|
|
148
|
+
_vn = preview ? ctx.parser.preview(copy(children), ctx) : ctx.parser.render(copy(children), ctx);
|
|
149
|
+
}
|
|
150
|
+
_vn = this.renderSides(_vn, ctx);
|
|
151
|
+
if ((!(!ctx.input && is.Undef(prop.native))) && prop.native !== true) {
|
|
152
|
+
this.fc.targetFormDriver('updateWrap', ctx)
|
|
153
|
+
_vn = this.$manager.makeWrap(ctx, _vn);
|
|
154
|
+
}
|
|
155
|
+
if (ctx.none) {
|
|
156
|
+
if (Array.isArray(_vn)) {
|
|
157
|
+
_vn = _vn.map(v => {
|
|
158
|
+
if (!v || !v.__v_isVNode) {
|
|
159
|
+
return v;
|
|
160
|
+
}
|
|
161
|
+
return this.none(v);
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
_vn = this.none(_vn);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
cacheFlag && this.setCache(ctx, () => {
|
|
168
|
+
return this.stable(_vn);
|
|
169
|
+
}, parent);
|
|
170
|
+
return _vn
|
|
171
|
+
};
|
|
172
|
+
this.setCache(ctx, vn, parent);
|
|
173
|
+
}
|
|
174
|
+
return (...args) => {
|
|
175
|
+
const cache = this.getCache(ctx);
|
|
176
|
+
if (cache) {
|
|
177
|
+
return cache(...args);
|
|
178
|
+
} else if (this.cache[ctx.id]) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const _vn = this.renderCtx(ctx, ctx.parent);
|
|
182
|
+
if (_vn) {
|
|
183
|
+
return _vn();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
} catch (e) {
|
|
187
|
+
console.error(e);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
none(vn) {
|
|
192
|
+
if (vn) {
|
|
193
|
+
vn.props.class = this.mergeClass(vn.props.class, 'fc-none')
|
|
194
|
+
return vn;
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
mergeClass(target, value) {
|
|
198
|
+
if (Array.isArray(target)) {
|
|
199
|
+
target.push(value);
|
|
200
|
+
} else {
|
|
201
|
+
return target ? [target, value] : value;
|
|
202
|
+
}
|
|
203
|
+
return target;
|
|
204
|
+
},
|
|
205
|
+
stable(vn) {
|
|
206
|
+
const list = Array.isArray(vn) ? vn : [vn];
|
|
207
|
+
list.forEach(v => {
|
|
208
|
+
if (v && v.__v_isVNode && v.children && typeof v.children === 'object') {
|
|
209
|
+
v.children.$stable = true;
|
|
210
|
+
this.stable(v.children);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return vn;
|
|
214
|
+
},
|
|
215
|
+
getModelField(ctx) {
|
|
216
|
+
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';
|
|
217
|
+
},
|
|
218
|
+
isFragment(ctx) {
|
|
219
|
+
return ctx.type === 'fragment' || ctx.type === 'template';
|
|
220
|
+
},
|
|
221
|
+
injectProp(ctx) {
|
|
222
|
+
const state = this.vm.setupState;
|
|
223
|
+
if (!state.ctxInject[ctx.id]) {
|
|
224
|
+
state.ctxInject[ctx.id] = {
|
|
225
|
+
api: this.$handle.api,
|
|
226
|
+
form: this.fc.create,
|
|
227
|
+
subForm: subForm => {
|
|
228
|
+
this.$handle.addSubForm(ctx, subForm);
|
|
229
|
+
},
|
|
230
|
+
getSubForm: () => {
|
|
231
|
+
return this.$handle.subForm[ctx.id];
|
|
232
|
+
},
|
|
233
|
+
slots: () => {
|
|
234
|
+
return this.vm.setupState.top.slots;
|
|
235
|
+
},
|
|
236
|
+
options: [],
|
|
237
|
+
children: [],
|
|
238
|
+
preview: false,
|
|
239
|
+
id: ctx.id,
|
|
240
|
+
field: ctx.field,
|
|
241
|
+
rule: ctx.rule,
|
|
242
|
+
input: ctx.input,
|
|
243
|
+
t: (...args) => {
|
|
244
|
+
return this.$handle.api.t(...args);
|
|
245
|
+
},
|
|
246
|
+
updateValue: (data) => {
|
|
247
|
+
this.$handle.onUpdateValue(ctx, data);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const inject = state.ctxInject[ctx.id];
|
|
252
|
+
extend(inject, {
|
|
253
|
+
preview: ctx.prop.preview,
|
|
254
|
+
options: ctx.prop.options,
|
|
255
|
+
children: ctx.loadChildrenPending()
|
|
256
|
+
});
|
|
257
|
+
return inject;
|
|
258
|
+
},
|
|
259
|
+
ctxProp(ctx) {
|
|
260
|
+
const {ref, key, rule} = ctx;
|
|
261
|
+
this.$manager.mergeProp(ctx);
|
|
262
|
+
ctx.parser.mergeProp(ctx);
|
|
263
|
+
const props = [
|
|
264
|
+
{
|
|
265
|
+
ref: ref,
|
|
266
|
+
key: rule.key || `${key}fc`,
|
|
267
|
+
slot: undefined,
|
|
268
|
+
on: {
|
|
269
|
+
vnodeMounted: (vn) => {
|
|
270
|
+
vn.el.__rule__ = ctx.rule;
|
|
271
|
+
this.onMounted(ctx, vn.el);
|
|
272
|
+
},
|
|
273
|
+
'fc.updateValue': (data) => {
|
|
274
|
+
this.$handle.onUpdateValue(ctx, data);
|
|
275
|
+
},
|
|
276
|
+
'fc.el': (el) => {
|
|
277
|
+
ctx.exportEl = el;
|
|
278
|
+
if (el) {
|
|
279
|
+
(el.$el || el).__rule__ = ctx.rule;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
|
|
286
|
+
if (ctx.input) {
|
|
287
|
+
if (this.vm.props.disabled === true) {
|
|
288
|
+
ctx.prop.props.disabled = true;
|
|
289
|
+
}
|
|
290
|
+
const field = this.getModelField(ctx);
|
|
291
|
+
const model = {
|
|
292
|
+
callback: (value) => {
|
|
293
|
+
this.onInput(ctx, value);
|
|
294
|
+
},
|
|
295
|
+
modelField: field,
|
|
296
|
+
value: this.$handle.getFormData(ctx)
|
|
297
|
+
};
|
|
298
|
+
props.push({
|
|
299
|
+
on: {
|
|
300
|
+
[`update:${field}`]: model.callback,
|
|
301
|
+
...(ctx.prop.modelEmit ? {
|
|
302
|
+
[ctx.prop.modelEmit]: () => this.onEmitInput(ctx)
|
|
303
|
+
} : {}),
|
|
304
|
+
},
|
|
305
|
+
props: {
|
|
306
|
+
[field]: model.value
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
ctx.prop.model = model;
|
|
310
|
+
}
|
|
311
|
+
mergeProps(props, ctx.prop);
|
|
312
|
+
return ctx.prop;
|
|
313
|
+
},
|
|
314
|
+
onMounted(ctx, el) {
|
|
315
|
+
ctx.el = this.vm.refs[ctx.ref] || el;
|
|
316
|
+
ctx.parser.mounted(ctx);
|
|
317
|
+
this.$handle.effect(ctx, 'mounted');
|
|
318
|
+
this.$handle.targetHook(ctx, 'mounted');
|
|
319
|
+
},
|
|
320
|
+
onInput(ctx, value) {
|
|
321
|
+
if (ctx.prop.modelEmit) {
|
|
322
|
+
this.$handle.onBaseInput(ctx, value);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
this.$handle.onInput(ctx, value);
|
|
326
|
+
},
|
|
327
|
+
onEmitInput(ctx) {
|
|
328
|
+
this.$handle.setValue(ctx, ctx.parser.toValue(ctx.modelValue, ctx), ctx.modelValue);
|
|
329
|
+
},
|
|
330
|
+
renderChildren(children, ctx) {
|
|
331
|
+
if (!is.trueArray(children)) return {};
|
|
332
|
+
const slotBag = makeSlotBag()
|
|
333
|
+
children.map(child => {
|
|
334
|
+
if (!child) return;
|
|
335
|
+
if (is.String(child)) return slotBag.setSlot(null, child);
|
|
336
|
+
if (child.__fc__) {
|
|
337
|
+
return this.renderSlot(slotBag, child.__fc__, ctx);
|
|
338
|
+
}
|
|
339
|
+
if (child.type) {
|
|
340
|
+
nextTick(() => {
|
|
341
|
+
this.$handle.loadChildren(children, ctx);
|
|
342
|
+
this.$handle.refresh();
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
return slotBag.getSlots();
|
|
347
|
+
},
|
|
348
|
+
defaultRender(ctx, children) {
|
|
349
|
+
const prop = ctx.prop;
|
|
350
|
+
if (prop.component) {
|
|
351
|
+
if (typeof prop.component === 'string') {
|
|
352
|
+
return this.vNode.make(prop.component, prop, children);
|
|
353
|
+
} else {
|
|
354
|
+
return this.vNode.makeComponent(prop.component, prop, children);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (this.vNode[ctx.type])
|
|
358
|
+
return this.vNode[ctx.type](prop, children);
|
|
359
|
+
if (this.vNode[ctx.originType])
|
|
360
|
+
return this.vNode[ctx.originType](prop, children);
|
|
361
|
+
return this.vNode.make(lower(prop.type), prop, children);
|
|
362
|
+
},
|
|
363
|
+
renderRule(rule, children, origin) {
|
|
364
|
+
if (!rule) return undefined;
|
|
365
|
+
if (is.String(rule)) return rule;
|
|
366
|
+
|
|
367
|
+
let type;
|
|
368
|
+
if (origin) {
|
|
369
|
+
type = rule.type;
|
|
370
|
+
} else {
|
|
371
|
+
type = rule.is;
|
|
372
|
+
if (rule.type) {
|
|
373
|
+
type = toCase(rule.type);
|
|
374
|
+
const alias = this.vNode.aliasMap[type];
|
|
375
|
+
if (alias) type = toCase(alias);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (!type) return undefined;
|
|
380
|
+
|
|
381
|
+
const slotBag = makeSlotBag();
|
|
382
|
+
if (is.trueArray(rule.children)) {
|
|
383
|
+
rule.children.forEach(v => {
|
|
384
|
+
v && slotBag.setSlot(v?.slot, () => this.renderRule(v));
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
const props = {...rule};
|
|
388
|
+
delete props.type;
|
|
389
|
+
delete props.is;
|
|
390
|
+
return this.vNode.make(type, props, slotBag.mergeBag(children).getSlots());
|
|
391
|
+
}
|
|
392
|
+
})
|
|
393
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bdsoft-element/form-checkbox",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.min.js",
|
|
6
|
+
"module": "./dist/index.esm.js",
|
|
7
|
+
"unpkg": "./dist/index.min.js",
|
|
8
|
+
"jsdelivr": "./dist/index.min.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf dist/",
|
|
11
|
+
"bili": "cross-env bili",
|
|
12
|
+
"build": "npm-run-all clean bili"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@bdsoft-element/utils": "workspace:^1.0.1"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {computed, defineComponent, ref, resolveComponent, toRef, watch} from 'vue';
|
|
2
|
+
import getSlot from '@bdsoft-element/utils/lib/slot';
|
|
3
|
+
import toArray from '@bdsoft-element/utils/lib/toarray';
|
|
4
|
+
|
|
5
|
+
const NAME = 'fcCheckbox';
|
|
6
|
+
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
name: NAME,
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
props: {
|
|
11
|
+
formCreateInject: Object,
|
|
12
|
+
modelValue: {
|
|
13
|
+
type: Array,
|
|
14
|
+
default: () => []
|
|
15
|
+
},
|
|
16
|
+
type: String,
|
|
17
|
+
options: Array,
|
|
18
|
+
input: Boolean,
|
|
19
|
+
inputValue: String,
|
|
20
|
+
},
|
|
21
|
+
emits: ['update:modelValue', 'fc.el'],
|
|
22
|
+
setup(props, _) {
|
|
23
|
+
const options = toRef(props.formCreateInject, 'options', []);
|
|
24
|
+
const opt = toRef(props, 'options');
|
|
25
|
+
const value = toRef(props, 'modelValue');
|
|
26
|
+
const inputValue = toRef(props, 'inputValue', '');
|
|
27
|
+
const customValue = ref(inputValue.value);
|
|
28
|
+
const input = toRef(props, 'input', false);
|
|
29
|
+
const updateCustomValue = (n) => {
|
|
30
|
+
const _value = [...toArray(value.value)];
|
|
31
|
+
const idx = _value.indexOf(customValue.value);
|
|
32
|
+
customValue.value = n;
|
|
33
|
+
if (idx > -1) {
|
|
34
|
+
_value.splice(idx, 1);
|
|
35
|
+
_value.push(n);
|
|
36
|
+
onInput(_value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
watch(inputValue, (n) => {
|
|
40
|
+
if (!input.value) {
|
|
41
|
+
customValue.value = n;
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
updateCustomValue(n);
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const _options = computed(() => {
|
|
48
|
+
let arr = options.value || [];
|
|
49
|
+
if (opt.value) {
|
|
50
|
+
arr = opt.value || [];
|
|
51
|
+
}
|
|
52
|
+
return Array.isArray(arr) ? arr : [];
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
watch(value, (n) => {
|
|
57
|
+
let value = null;
|
|
58
|
+
if (!inputValue.value && n != null && Array.isArray(n) && n.length > 0 && input.value) {
|
|
59
|
+
const values = _options.value.map(item => {
|
|
60
|
+
return item.value;
|
|
61
|
+
});
|
|
62
|
+
n.forEach((val) => {
|
|
63
|
+
if (values.indexOf(val) === -1) {
|
|
64
|
+
value = val;
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
if (value != null) {
|
|
69
|
+
customValue.value = value;
|
|
70
|
+
}
|
|
71
|
+
}, {immediate: true});
|
|
72
|
+
|
|
73
|
+
const onInput = (n) => {
|
|
74
|
+
_.emit('update:modelValue', n);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
options: _options,
|
|
79
|
+
value,
|
|
80
|
+
onInput,
|
|
81
|
+
updateCustomValue,
|
|
82
|
+
makeInput(Type) {
|
|
83
|
+
if (!input.value) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
return <Type value={customValue.value || undefined} label={customValue.value || undefined}>
|
|
87
|
+
<ElInput size="small" modelValue={customValue.value}
|
|
88
|
+
onUpdate:modelValue={updateCustomValue}></ElInput>
|
|
89
|
+
</Type>
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
render() {
|
|
94
|
+
const name = this.type === 'button' ? 'ElCheckboxButton' : 'ElCheckbox';
|
|
95
|
+
const Type = resolveComponent(name);
|
|
96
|
+
return <ElCheckboxGroup {...this.$attrs} modelValue={this.value} v-slots={getSlot(this.$slots, ['default'])}
|
|
97
|
+
onUpdate:modelValue={this.onInput} ref="el">{this.options.map((opt, index) => {
|
|
98
|
+
const props = {...opt};
|
|
99
|
+
const value = props.value;
|
|
100
|
+
const label = props.label;
|
|
101
|
+
delete props.value;
|
|
102
|
+
delete props.label;
|
|
103
|
+
return <Type {...props} label={value} value={value}
|
|
104
|
+
key={name + index + '-' + value}>{label || value || ''}</Type>
|
|
105
|
+
})}{this.$slots.default?.()}{this.makeInput(Type)}</ElCheckboxGroup>
|
|
106
|
+
},
|
|
107
|
+
mounted() {
|
|
108
|
+
this.$emit('fc.el', this.$refs.el);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bdsoft-element/form-frame",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.min.js",
|
|
6
|
+
"module": "./dist/index.esm.js",
|
|
7
|
+
"unpkg": "./dist/index.min.js",
|
|
8
|
+
"jsdelivr": "./dist/index.min.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf dist/",
|
|
11
|
+
"bili": "cross-env bili",
|
|
12
|
+
"build": "npm-run-all clean bili"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@bdsoft-element/utils": "workspace:^1.0.1"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="currentColor"
|
|
4
|
+
d="M466.752 512l-90.496-90.496a32 32 0 0145.248-45.248L512 466.752l90.496-90.496a32 32 0 1145.248 45.248L557.248 512l90.496 90.496a32 32 0 11-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 01-45.248-45.248L466.752 512z"></path>
|
|
5
|
+
<path fill="currentColor"
|
|
6
|
+
d="M512 896a384 384 0 100-768 384 384 0 000 768zm0 64a448 448 0 110-896 448 448 0 010 896z"></path>
|
|
7
|
+
</svg>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
export default {
|
|
12
|
+
name: 'IconCircleClose'
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="currentColor"
|
|
4
|
+
d="M160 256H96a32 32 0 010-64h256V95.936a32 32 0 0132-32h256a32 32 0 0132 32V192h256a32 32 0 110 64h-64v672a32 32 0 01-32 32H192a32 32 0 01-32-32V256zm448-64v-64H416v64h192zM224 896h576V256H224v640zm192-128a32 32 0 01-32-32V416a32 32 0 0164 0v320a32 32 0 01-32 32zm192 0a32 32 0 01-32-32V416a32 32 0 0164 0v320a32 32 0 01-32 32z"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: 'IconDelete'
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="currentColor"
|
|
4
|
+
d="M832 384H576V128H192v768h640V384zm-26.496-64L640 154.496V320h165.504zM160 64h480l256 256v608a32 32 0 01-32 32H160a32 32 0 01-32-32V96a32 32 0 0132-32zm160 448h384v64H320v-64zm0-192h160v64H320v-64zm0 384h384v64H320v-64z"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: 'IconDocument'
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="currentColor"
|
|
4
|
+
d="M878.08 448H241.92l-96 384h636.16l96-384zM832 384v-64H485.76L357.504 192H128v448l57.92-231.744A32 32 0 01216.96 384H832zm-24.96 512H96a32 32 0 01-32-32V160a32 32 0 0132-32h287.872l128.384 128H864a32 32 0 0132 32v96h23.04a32 32 0 0131.04 39.744l-112 448A32 32 0 01807.04 896z"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: 'IconFolderOpened'
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill="currentColor"
|
|
4
|
+
d="M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352zm0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288zm0 64a224 224 0 110 448 224 224 0 010-448zm0 64a160.192 160.192 0 00-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160z"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: 'IconView'
|
|
11
|
+
}
|
|
12
|
+
</script>
|