@fangzhongya/vue-archive 0.0.19 → 0.0.21
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/dist/node/index.cjs +110 -58
- package/dist/node/index.js +110 -58
- package/dist/packages/components/compo/index.vue.cjs +1 -1
- package/dist/packages/components/compo/index.vue.js +42 -50
- package/dist/packages/components/use/code.cjs +11 -10
- package/dist/packages/components/use/code.js +128 -111
- package/dist/packages/components/use/index.cjs +1 -1
- package/dist/packages/components/use/index.js +25 -25
- package/dist/packages/components/use/util.cjs +3 -3
- package/dist/packages/components/use/util.d.ts +1 -0
- package/dist/packages/components/use/util.js +49 -27
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -2475,6 +2475,15 @@ function getExposeValue(arr) {
|
|
|
2475
2475
|
return v;
|
|
2476
2476
|
});
|
|
2477
2477
|
}
|
|
2478
|
+
function getSlotValue(arr) {
|
|
2479
|
+
return arr.map((obj) => {
|
|
2480
|
+
const v = {};
|
|
2481
|
+
Object.keys(slot).forEach((key) => {
|
|
2482
|
+
v[key] = slot[key](obj);
|
|
2483
|
+
});
|
|
2484
|
+
return v;
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2478
2487
|
|
|
2479
2488
|
// packages/components/test/index.ts
|
|
2480
2489
|
function getObj(v) {
|
|
@@ -3106,6 +3115,29 @@ function getSonType(type) {
|
|
|
3106
3115
|
}
|
|
3107
3116
|
return arr;
|
|
3108
3117
|
}
|
|
3118
|
+
function getTypeValue(arr) {
|
|
3119
|
+
const type = (arr[0] || "any").toLowerCase();
|
|
3120
|
+
switch (type) {
|
|
3121
|
+
case "string":
|
|
3122
|
+
return '""';
|
|
3123
|
+
case "boolean":
|
|
3124
|
+
return "false";
|
|
3125
|
+
case "number":
|
|
3126
|
+
return "0";
|
|
3127
|
+
case "array":
|
|
3128
|
+
let v = getTypeValue(arr.splice(1));
|
|
3129
|
+
v = v == "undefined" ? "" : v;
|
|
3130
|
+
return `[${v}]`;
|
|
3131
|
+
case "object":
|
|
3132
|
+
return "{}";
|
|
3133
|
+
case "function":
|
|
3134
|
+
return "()=>{}";
|
|
3135
|
+
case "any":
|
|
3136
|
+
return '""';
|
|
3137
|
+
default:
|
|
3138
|
+
return "undefined";
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3109
3141
|
function getType(str) {
|
|
3110
3142
|
let arr = [];
|
|
3111
3143
|
if (str) {
|
|
@@ -3135,7 +3167,7 @@ function getParametersObj(cs) {
|
|
|
3135
3167
|
let arrs = cs.split(",");
|
|
3136
3168
|
return arrs.map((key) => {
|
|
3137
3169
|
let vs = key.split(":");
|
|
3138
|
-
let name = vs[0];
|
|
3170
|
+
let name = vs[0].trim();
|
|
3139
3171
|
let t = vs[1] || "";
|
|
3140
3172
|
let tarr = getSonType(getType(t));
|
|
3141
3173
|
return {
|
|
@@ -3155,15 +3187,18 @@ function getSpecObjs(specs, name) {
|
|
|
3155
3187
|
}
|
|
3156
3188
|
function getParameStr(css) {
|
|
3157
3189
|
return css.map((o) => {
|
|
3158
|
-
|
|
3190
|
+
const name = o.prop || "...arr";
|
|
3191
|
+
return name + ":" + setDataType(o.dataType);
|
|
3159
3192
|
}).join(",");
|
|
3160
3193
|
}
|
|
3161
3194
|
function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
3162
3195
|
const tarr = [];
|
|
3163
3196
|
const sarr = [];
|
|
3164
3197
|
let is = true;
|
|
3165
|
-
const
|
|
3166
|
-
const
|
|
3198
|
+
const ps = getPropsValue2(param.propss || []);
|
|
3199
|
+
const es = getEmitsValue(param.emitss || []);
|
|
3200
|
+
const res = getExposeValue(param.exposes || []);
|
|
3201
|
+
const ss = getSlotValue(param.slots || []);
|
|
3167
3202
|
Object.keys(value).forEach((key) => {
|
|
3168
3203
|
let val = value[key];
|
|
3169
3204
|
if (/^on[A-Z]/.test(key) && typeof val == "function") {
|
|
@@ -3189,13 +3224,16 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3189
3224
|
strs = arr.join("");
|
|
3190
3225
|
}
|
|
3191
3226
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3192
|
-
const
|
|
3227
|
+
const sp = getSpecObjs(es, name);
|
|
3228
|
+
const s = sp.selectable || "";
|
|
3193
3229
|
const css = getParametersObj(s);
|
|
3194
3230
|
const cs = getParameStr(css);
|
|
3231
|
+
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3195
3232
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3196
3233
|
css.forEach((o) => {
|
|
3234
|
+
const name2 = o.prop || "arr";
|
|
3197
3235
|
sarr.push(
|
|
3198
|
-
" console.log('" + o.description +
|
|
3236
|
+
" console.log('" + o.description + name2 + "', " + name2 + ")"
|
|
3199
3237
|
);
|
|
3200
3238
|
});
|
|
3201
3239
|
sarr.push("}");
|
|
@@ -3205,6 +3243,12 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3205
3243
|
z = key + "1";
|
|
3206
3244
|
}
|
|
3207
3245
|
tarr.push(" :" + key + '="' + z + '"');
|
|
3246
|
+
const sp = getSpecObjs(ps, key);
|
|
3247
|
+
const t = getSpecType(sp);
|
|
3248
|
+
sarr.push(
|
|
3249
|
+
`// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
|
|
3250
|
+
);
|
|
3251
|
+
console.log("val", val);
|
|
3208
3252
|
if (typeof val == "function") {
|
|
3209
3253
|
sarr.push(
|
|
3210
3254
|
"const " + key + " = " + getFunctionBody(val, key, propsText)
|
|
@@ -3215,7 +3259,14 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3215
3259
|
sarr.unshift("import { ref } from 'vue';");
|
|
3216
3260
|
}
|
|
3217
3261
|
if (typeof val == "undefined") {
|
|
3218
|
-
|
|
3262
|
+
const tv = getTypeValue(t.dataType);
|
|
3263
|
+
if (tv == "()=>{}") {
|
|
3264
|
+
sarr.push("const " + z + " = " + tv + ";");
|
|
3265
|
+
} else {
|
|
3266
|
+
sarr.push(
|
|
3267
|
+
"const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
|
|
3268
|
+
);
|
|
3269
|
+
}
|
|
3219
3270
|
} else {
|
|
3220
3271
|
let st2 = setValStringify(val, key, propsText);
|
|
3221
3272
|
sarr.push("const " + z + " = ref(" + st2 + ");");
|
|
@@ -3232,27 +3283,36 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3232
3283
|
tarr.unshift(' ref="refDom"');
|
|
3233
3284
|
sarr.push("const refDom = ref()");
|
|
3234
3285
|
ev.forEach((v) => {
|
|
3235
|
-
sarr.push(`-------${v.name}--------`);
|
|
3236
3286
|
const s = getSpecObjs(res, v.name);
|
|
3287
|
+
sarr.push(
|
|
3288
|
+
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3289
|
+
);
|
|
3237
3290
|
const m = v.name + "Value";
|
|
3238
|
-
const css = getParametersObj(s
|
|
3291
|
+
const css = getParametersObj(s?.selectable || "");
|
|
3239
3292
|
const cs = [];
|
|
3240
|
-
v.params
|
|
3241
|
-
|
|
3242
|
-
const
|
|
3243
|
-
if (
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
);
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3293
|
+
const ps2 = v.params || [];
|
|
3294
|
+
css.forEach((c, index) => {
|
|
3295
|
+
const prop = c.prop;
|
|
3296
|
+
if (prop) {
|
|
3297
|
+
const key = prop + v.name;
|
|
3298
|
+
const val = ps2[index];
|
|
3299
|
+
sarr.push(`// ${c.label}`);
|
|
3300
|
+
if (typeof val == "function") {
|
|
3301
|
+
sarr.push(
|
|
3302
|
+
"const " + key + " = " + getFunctionBody(val, prop, v.text)
|
|
3303
|
+
);
|
|
3250
3304
|
} else {
|
|
3251
|
-
|
|
3252
|
-
|
|
3305
|
+
if (typeof val == "undefined") {
|
|
3306
|
+
sarr.push(
|
|
3307
|
+
"const " + key + " = " + getTypeValue(c.dataType) + ";"
|
|
3308
|
+
);
|
|
3309
|
+
} else {
|
|
3310
|
+
let st2 = setValStringify(val, prop, v.text);
|
|
3311
|
+
sarr.push("const " + key + " = " + st2 + ";");
|
|
3312
|
+
}
|
|
3253
3313
|
}
|
|
3314
|
+
cs.push(key);
|
|
3254
3315
|
}
|
|
3255
|
-
cs.push(key);
|
|
3256
3316
|
});
|
|
3257
3317
|
if (v.type === "function") {
|
|
3258
3318
|
sarr.push(
|
|
@@ -3261,13 +3321,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3261
3321
|
} else {
|
|
3262
3322
|
sarr.push(`const ${m} = refDom.value?.${v.name}`);
|
|
3263
3323
|
}
|
|
3264
|
-
sarr.push(`console.log('"${s.
|
|
3324
|
+
sarr.push(`console.log('"${s.type}"', ${m})`);
|
|
3265
3325
|
});
|
|
3266
3326
|
}
|
|
3267
3327
|
if (tarr.length > 0) {
|
|
3268
3328
|
tarr.unshift("");
|
|
3269
3329
|
}
|
|
3270
|
-
const slots = getSlots(slotValue);
|
|
3330
|
+
const slots = getSlots(slotValue, ss);
|
|
3271
3331
|
const st = `<!--${propsname}-->
|
|
3272
3332
|
<template>
|
|
3273
3333
|
<div>
|
|
@@ -3281,12 +3341,14 @@ ${sarr.join("\n")}
|
|
|
3281
3341
|
`;
|
|
3282
3342
|
return st;
|
|
3283
3343
|
}
|
|
3284
|
-
function getSlots(obj = {}) {
|
|
3344
|
+
function getSlots(obj = {}, ss) {
|
|
3285
3345
|
const arr = [];
|
|
3286
3346
|
Object.keys(obj).forEach((key) => {
|
|
3347
|
+
const sp = getSpecObjs(ss, key);
|
|
3287
3348
|
const v = obj[key];
|
|
3288
3349
|
if (v) {
|
|
3289
|
-
const st = `
|
|
3350
|
+
const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
|
|
3351
|
+
<template #${key}="scope">
|
|
3290
3352
|
${vueFormat(v, " ")}
|
|
3291
3353
|
</template>`;
|
|
3292
3354
|
arr.push(st);
|
|
@@ -3311,7 +3373,7 @@ function funstr(v) {
|
|
|
3311
3373
|
let body = `{
|
|
3312
3374
|
${vueFormat(getFunBody(st.body), " ")}
|
|
3313
3375
|
}`;
|
|
3314
|
-
return `function ${st.param} ${body}`;
|
|
3376
|
+
return `function (${st.param}) ${body}`;
|
|
3315
3377
|
} else {
|
|
3316
3378
|
return "undefined";
|
|
3317
3379
|
}
|
|
@@ -3835,15 +3897,6 @@ function gettests(obj, arr, n) {
|
|
|
3835
3897
|
}
|
|
3836
3898
|
}
|
|
3837
3899
|
}
|
|
3838
|
-
function getFFParam(str) {
|
|
3839
|
-
str = str.trim();
|
|
3840
|
-
if (str && str.length > 2) {
|
|
3841
|
-
return str.substring(1, str.length - 1).split(",").map((k) => {
|
|
3842
|
-
return (k.split(":")[0] || "").trim();
|
|
3843
|
-
});
|
|
3844
|
-
}
|
|
3845
|
-
return [];
|
|
3846
|
-
}
|
|
3847
3900
|
function getObjValue(d) {
|
|
3848
3901
|
try {
|
|
3849
3902
|
return new Function(`{ return ${d} }`)();
|
|
@@ -3852,29 +3905,16 @@ function getObjValue(d) {
|
|
|
3852
3905
|
}
|
|
3853
3906
|
}
|
|
3854
3907
|
function getDefaultValue(obj) {
|
|
3855
|
-
const vo = getSpecType(obj)
|
|
3908
|
+
const vo = getSpecType(obj);
|
|
3909
|
+
const v = getTypeValue(vo.dataType);
|
|
3856
3910
|
const d = (obj.default || "").trim();
|
|
3857
|
-
|
|
3858
|
-
let fb = getFunctionFormat(d);
|
|
3859
|
-
if (fb) {
|
|
3860
|
-
return new Function(...getFFParam(fb.param), fb.body);
|
|
3861
|
-
}
|
|
3862
|
-
return new Function("{}");
|
|
3863
|
-
} else if (vo == "array") {
|
|
3864
|
-
return getObjValue(d || "[]");
|
|
3865
|
-
} else if (vo == "object") {
|
|
3866
|
-
return getObjValue(d || "{}");
|
|
3867
|
-
} else if (vo == "number") {
|
|
3868
|
-
return getObjValue(d || "1");
|
|
3869
|
-
} else if (vo == "boolean") {
|
|
3870
|
-
return getObjValue(d || "true");
|
|
3871
|
-
} else {
|
|
3872
|
-
return d;
|
|
3873
|
-
}
|
|
3911
|
+
return getObjValue(d || v);
|
|
3874
3912
|
}
|
|
3875
3913
|
function setVue(propsname, param, url) {
|
|
3876
|
-
const ps = getPropsValue2(param.propss);
|
|
3877
|
-
const es = getEmitsValue(param.emitss);
|
|
3914
|
+
const ps = getPropsValue2(param.propss || []);
|
|
3915
|
+
const es = getEmitsValue(param.emitss || []);
|
|
3916
|
+
const res = getExposeValue(param.exposes || []);
|
|
3917
|
+
const ss = getSlotValue(param.slots || []);
|
|
3878
3918
|
const propsObj = {};
|
|
3879
3919
|
ps.forEach((val) => {
|
|
3880
3920
|
let name = val.name;
|
|
@@ -3882,7 +3922,8 @@ function setVue(propsname, param, url) {
|
|
|
3882
3922
|
let arr = name.split("/");
|
|
3883
3923
|
name = (arr[0] || "").trim();
|
|
3884
3924
|
if (name) {
|
|
3885
|
-
|
|
3925
|
+
const dv = getDefaultValue(val);
|
|
3926
|
+
propsObj[name] = dv;
|
|
3886
3927
|
if (arr && arr.length > 1) {
|
|
3887
3928
|
es.push({
|
|
3888
3929
|
name: "update:" + name,
|
|
@@ -3908,7 +3949,18 @@ function setVue(propsname, param, url) {
|
|
|
3908
3949
|
propsObj[name] = () => {
|
|
3909
3950
|
};
|
|
3910
3951
|
});
|
|
3911
|
-
const
|
|
3952
|
+
const slotValue = {};
|
|
3953
|
+
ss.forEach((v) => {
|
|
3954
|
+
slotValue[v.name] = " ";
|
|
3955
|
+
});
|
|
3956
|
+
const exposeText = {};
|
|
3957
|
+
res.forEach((v) => {
|
|
3958
|
+
exposeText[v.name] = {
|
|
3959
|
+
name: v.name,
|
|
3960
|
+
type: "function"
|
|
3961
|
+
};
|
|
3962
|
+
});
|
|
3963
|
+
const html = getHmtl(propsname, param, propsObj, slotValue, {}, exposeText);
|
|
3912
3964
|
Fang.fileOpen(url, html);
|
|
3913
3965
|
}
|
|
3914
3966
|
function getMdurl(obj) {
|
package/dist/node/index.js
CHANGED
|
@@ -2460,6 +2460,15 @@ function getExposeValue(arr) {
|
|
|
2460
2460
|
return v;
|
|
2461
2461
|
});
|
|
2462
2462
|
}
|
|
2463
|
+
function getSlotValue(arr) {
|
|
2464
|
+
return arr.map((obj) => {
|
|
2465
|
+
const v = {};
|
|
2466
|
+
Object.keys(slot).forEach((key) => {
|
|
2467
|
+
v[key] = slot[key](obj);
|
|
2468
|
+
});
|
|
2469
|
+
return v;
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2463
2472
|
|
|
2464
2473
|
// packages/components/test/index.ts
|
|
2465
2474
|
function getObj(v) {
|
|
@@ -3091,6 +3100,29 @@ function getSonType(type) {
|
|
|
3091
3100
|
}
|
|
3092
3101
|
return arr;
|
|
3093
3102
|
}
|
|
3103
|
+
function getTypeValue(arr) {
|
|
3104
|
+
const type = (arr[0] || "any").toLowerCase();
|
|
3105
|
+
switch (type) {
|
|
3106
|
+
case "string":
|
|
3107
|
+
return '""';
|
|
3108
|
+
case "boolean":
|
|
3109
|
+
return "false";
|
|
3110
|
+
case "number":
|
|
3111
|
+
return "0";
|
|
3112
|
+
case "array":
|
|
3113
|
+
let v = getTypeValue(arr.splice(1));
|
|
3114
|
+
v = v == "undefined" ? "" : v;
|
|
3115
|
+
return `[${v}]`;
|
|
3116
|
+
case "object":
|
|
3117
|
+
return "{}";
|
|
3118
|
+
case "function":
|
|
3119
|
+
return "()=>{}";
|
|
3120
|
+
case "any":
|
|
3121
|
+
return '""';
|
|
3122
|
+
default:
|
|
3123
|
+
return "undefined";
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3094
3126
|
function getType(str) {
|
|
3095
3127
|
let arr = [];
|
|
3096
3128
|
if (str) {
|
|
@@ -3120,7 +3152,7 @@ function getParametersObj(cs) {
|
|
|
3120
3152
|
let arrs = cs.split(",");
|
|
3121
3153
|
return arrs.map((key) => {
|
|
3122
3154
|
let vs = key.split(":");
|
|
3123
|
-
let name = vs[0];
|
|
3155
|
+
let name = vs[0].trim();
|
|
3124
3156
|
let t = vs[1] || "";
|
|
3125
3157
|
let tarr = getSonType(getType(t));
|
|
3126
3158
|
return {
|
|
@@ -3140,15 +3172,18 @@ function getSpecObjs(specs, name) {
|
|
|
3140
3172
|
}
|
|
3141
3173
|
function getParameStr(css) {
|
|
3142
3174
|
return css.map((o) => {
|
|
3143
|
-
|
|
3175
|
+
const name = o.prop || "...arr";
|
|
3176
|
+
return name + ":" + setDataType(o.dataType);
|
|
3144
3177
|
}).join(",");
|
|
3145
3178
|
}
|
|
3146
3179
|
function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
3147
3180
|
const tarr = [];
|
|
3148
3181
|
const sarr = [];
|
|
3149
3182
|
let is = true;
|
|
3150
|
-
const
|
|
3151
|
-
const
|
|
3183
|
+
const ps = getPropsValue2(param.propss || []);
|
|
3184
|
+
const es = getEmitsValue(param.emitss || []);
|
|
3185
|
+
const res = getExposeValue(param.exposes || []);
|
|
3186
|
+
const ss = getSlotValue(param.slots || []);
|
|
3152
3187
|
Object.keys(value).forEach((key) => {
|
|
3153
3188
|
let val = value[key];
|
|
3154
3189
|
if (/^on[A-Z]/.test(key) && typeof val == "function") {
|
|
@@ -3174,13 +3209,16 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3174
3209
|
strs = arr.join("");
|
|
3175
3210
|
}
|
|
3176
3211
|
tarr.push(" @" + name + '="' + strs + '"');
|
|
3177
|
-
const
|
|
3212
|
+
const sp = getSpecObjs(es, name);
|
|
3213
|
+
const s = sp.selectable || "";
|
|
3178
3214
|
const css = getParametersObj(s);
|
|
3179
3215
|
const cs = getParameStr(css);
|
|
3216
|
+
sarr.push(`// ${sp.description} ${sp.name}: (${sp.selectable})`);
|
|
3180
3217
|
sarr.push("function " + strs + "(" + cs + ") {");
|
|
3181
3218
|
css.forEach((o) => {
|
|
3219
|
+
const name2 = o.prop || "arr";
|
|
3182
3220
|
sarr.push(
|
|
3183
|
-
" console.log('" + o.description +
|
|
3221
|
+
" console.log('" + o.description + name2 + "', " + name2 + ")"
|
|
3184
3222
|
);
|
|
3185
3223
|
});
|
|
3186
3224
|
sarr.push("}");
|
|
@@ -3190,6 +3228,12 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3190
3228
|
z = key + "1";
|
|
3191
3229
|
}
|
|
3192
3230
|
tarr.push(" :" + key + '="' + z + '"');
|
|
3231
|
+
const sp = getSpecObjs(ps, key);
|
|
3232
|
+
const t = getSpecType(sp);
|
|
3233
|
+
sarr.push(
|
|
3234
|
+
`// ${sp.description} ${sp.name}: {${sp.type}} (${sp.selectable})`
|
|
3235
|
+
);
|
|
3236
|
+
console.log("val", val);
|
|
3193
3237
|
if (typeof val == "function") {
|
|
3194
3238
|
sarr.push(
|
|
3195
3239
|
"const " + key + " = " + getFunctionBody(val, key, propsText)
|
|
@@ -3200,7 +3244,14 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3200
3244
|
sarr.unshift("import { ref } from 'vue';");
|
|
3201
3245
|
}
|
|
3202
3246
|
if (typeof val == "undefined") {
|
|
3203
|
-
|
|
3247
|
+
const tv = getTypeValue(t.dataType);
|
|
3248
|
+
if (tv == "()=>{}") {
|
|
3249
|
+
sarr.push("const " + z + " = " + tv + ";");
|
|
3250
|
+
} else {
|
|
3251
|
+
sarr.push(
|
|
3252
|
+
"const " + z + " = ref(" + (tv === "undefined" ? "" : tv) + ");"
|
|
3253
|
+
);
|
|
3254
|
+
}
|
|
3204
3255
|
} else {
|
|
3205
3256
|
let st2 = setValStringify(val, key, propsText);
|
|
3206
3257
|
sarr.push("const " + z + " = ref(" + st2 + ");");
|
|
@@ -3217,27 +3268,36 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3217
3268
|
tarr.unshift(' ref="refDom"');
|
|
3218
3269
|
sarr.push("const refDom = ref()");
|
|
3219
3270
|
ev.forEach((v) => {
|
|
3220
|
-
sarr.push(`-------${v.name}--------`);
|
|
3221
3271
|
const s = getSpecObjs(res, v.name);
|
|
3272
|
+
sarr.push(
|
|
3273
|
+
`// ${s.description} ${s.name}\uFF1A(${s.selectable}) ${s.type}`
|
|
3274
|
+
);
|
|
3222
3275
|
const m = v.name + "Value";
|
|
3223
|
-
const css = getParametersObj(s
|
|
3276
|
+
const css = getParametersObj(s?.selectable || "");
|
|
3224
3277
|
const cs = [];
|
|
3225
|
-
v.params
|
|
3226
|
-
|
|
3227
|
-
const
|
|
3228
|
-
if (
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
);
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3278
|
+
const ps2 = v.params || [];
|
|
3279
|
+
css.forEach((c, index) => {
|
|
3280
|
+
const prop = c.prop;
|
|
3281
|
+
if (prop) {
|
|
3282
|
+
const key = prop + v.name;
|
|
3283
|
+
const val = ps2[index];
|
|
3284
|
+
sarr.push(`// ${c.label}`);
|
|
3285
|
+
if (typeof val == "function") {
|
|
3286
|
+
sarr.push(
|
|
3287
|
+
"const " + key + " = " + getFunctionBody(val, prop, v.text)
|
|
3288
|
+
);
|
|
3235
3289
|
} else {
|
|
3236
|
-
|
|
3237
|
-
|
|
3290
|
+
if (typeof val == "undefined") {
|
|
3291
|
+
sarr.push(
|
|
3292
|
+
"const " + key + " = " + getTypeValue(c.dataType) + ";"
|
|
3293
|
+
);
|
|
3294
|
+
} else {
|
|
3295
|
+
let st2 = setValStringify(val, prop, v.text);
|
|
3296
|
+
sarr.push("const " + key + " = " + st2 + ";");
|
|
3297
|
+
}
|
|
3238
3298
|
}
|
|
3299
|
+
cs.push(key);
|
|
3239
3300
|
}
|
|
3240
|
-
cs.push(key);
|
|
3241
3301
|
});
|
|
3242
3302
|
if (v.type === "function") {
|
|
3243
3303
|
sarr.push(
|
|
@@ -3246,13 +3306,13 @@ function getHmtl(propsname, param, value, slotValue, propsText, exposeText) {
|
|
|
3246
3306
|
} else {
|
|
3247
3307
|
sarr.push(`const ${m} = refDom.value?.${v.name}`);
|
|
3248
3308
|
}
|
|
3249
|
-
sarr.push(`console.log('"${s.
|
|
3309
|
+
sarr.push(`console.log('"${s.type}"', ${m})`);
|
|
3250
3310
|
});
|
|
3251
3311
|
}
|
|
3252
3312
|
if (tarr.length > 0) {
|
|
3253
3313
|
tarr.unshift("");
|
|
3254
3314
|
}
|
|
3255
|
-
const slots = getSlots(slotValue);
|
|
3315
|
+
const slots = getSlots(slotValue, ss);
|
|
3256
3316
|
const st = `<!--${propsname}-->
|
|
3257
3317
|
<template>
|
|
3258
3318
|
<div>
|
|
@@ -3266,12 +3326,14 @@ ${sarr.join("\n")}
|
|
|
3266
3326
|
`;
|
|
3267
3327
|
return st;
|
|
3268
3328
|
}
|
|
3269
|
-
function getSlots(obj = {}) {
|
|
3329
|
+
function getSlots(obj = {}, ss) {
|
|
3270
3330
|
const arr = [];
|
|
3271
3331
|
Object.keys(obj).forEach((key) => {
|
|
3332
|
+
const sp = getSpecObjs(ss, key);
|
|
3272
3333
|
const v = obj[key];
|
|
3273
3334
|
if (v) {
|
|
3274
|
-
const st = `
|
|
3335
|
+
const st = ` <!-- ${sp.description} ${sp.name}\uFF1A(${sp.selectable}) -->
|
|
3336
|
+
<template #${key}="scope">
|
|
3275
3337
|
${vueFormat(v, " ")}
|
|
3276
3338
|
</template>`;
|
|
3277
3339
|
arr.push(st);
|
|
@@ -3296,7 +3358,7 @@ function funstr(v) {
|
|
|
3296
3358
|
let body = `{
|
|
3297
3359
|
${vueFormat(getFunBody(st.body), " ")}
|
|
3298
3360
|
}`;
|
|
3299
|
-
return `function ${st.param} ${body}`;
|
|
3361
|
+
return `function (${st.param}) ${body}`;
|
|
3300
3362
|
} else {
|
|
3301
3363
|
return "undefined";
|
|
3302
3364
|
}
|
|
@@ -3820,15 +3882,6 @@ function gettests(obj, arr, n) {
|
|
|
3820
3882
|
}
|
|
3821
3883
|
}
|
|
3822
3884
|
}
|
|
3823
|
-
function getFFParam(str) {
|
|
3824
|
-
str = str.trim();
|
|
3825
|
-
if (str && str.length > 2) {
|
|
3826
|
-
return str.substring(1, str.length - 1).split(",").map((k) => {
|
|
3827
|
-
return (k.split(":")[0] || "").trim();
|
|
3828
|
-
});
|
|
3829
|
-
}
|
|
3830
|
-
return [];
|
|
3831
|
-
}
|
|
3832
3885
|
function getObjValue(d) {
|
|
3833
3886
|
try {
|
|
3834
3887
|
return new Function(`{ return ${d} }`)();
|
|
@@ -3837,29 +3890,16 @@ function getObjValue(d) {
|
|
|
3837
3890
|
}
|
|
3838
3891
|
}
|
|
3839
3892
|
function getDefaultValue(obj) {
|
|
3840
|
-
const vo = getSpecType(obj)
|
|
3893
|
+
const vo = getSpecType(obj);
|
|
3894
|
+
const v = getTypeValue(vo.dataType);
|
|
3841
3895
|
const d = (obj.default || "").trim();
|
|
3842
|
-
|
|
3843
|
-
let fb = getFunctionFormat(d);
|
|
3844
|
-
if (fb) {
|
|
3845
|
-
return new Function(...getFFParam(fb.param), fb.body);
|
|
3846
|
-
}
|
|
3847
|
-
return new Function("{}");
|
|
3848
|
-
} else if (vo == "array") {
|
|
3849
|
-
return getObjValue(d || "[]");
|
|
3850
|
-
} else if (vo == "object") {
|
|
3851
|
-
return getObjValue(d || "{}");
|
|
3852
|
-
} else if (vo == "number") {
|
|
3853
|
-
return getObjValue(d || "1");
|
|
3854
|
-
} else if (vo == "boolean") {
|
|
3855
|
-
return getObjValue(d || "true");
|
|
3856
|
-
} else {
|
|
3857
|
-
return d;
|
|
3858
|
-
}
|
|
3896
|
+
return getObjValue(d || v);
|
|
3859
3897
|
}
|
|
3860
3898
|
function setVue(propsname, param, url) {
|
|
3861
|
-
const ps = getPropsValue2(param.propss);
|
|
3862
|
-
const es = getEmitsValue(param.emitss);
|
|
3899
|
+
const ps = getPropsValue2(param.propss || []);
|
|
3900
|
+
const es = getEmitsValue(param.emitss || []);
|
|
3901
|
+
const res = getExposeValue(param.exposes || []);
|
|
3902
|
+
const ss = getSlotValue(param.slots || []);
|
|
3863
3903
|
const propsObj = {};
|
|
3864
3904
|
ps.forEach((val) => {
|
|
3865
3905
|
let name = val.name;
|
|
@@ -3867,7 +3907,8 @@ function setVue(propsname, param, url) {
|
|
|
3867
3907
|
let arr = name.split("/");
|
|
3868
3908
|
name = (arr[0] || "").trim();
|
|
3869
3909
|
if (name) {
|
|
3870
|
-
|
|
3910
|
+
const dv = getDefaultValue(val);
|
|
3911
|
+
propsObj[name] = dv;
|
|
3871
3912
|
if (arr && arr.length > 1) {
|
|
3872
3913
|
es.push({
|
|
3873
3914
|
name: "update:" + name,
|
|
@@ -3893,7 +3934,18 @@ function setVue(propsname, param, url) {
|
|
|
3893
3934
|
propsObj[name] = () => {
|
|
3894
3935
|
};
|
|
3895
3936
|
});
|
|
3896
|
-
const
|
|
3937
|
+
const slotValue = {};
|
|
3938
|
+
ss.forEach((v) => {
|
|
3939
|
+
slotValue[v.name] = " ";
|
|
3940
|
+
});
|
|
3941
|
+
const exposeText = {};
|
|
3942
|
+
res.forEach((v) => {
|
|
3943
|
+
exposeText[v.name] = {
|
|
3944
|
+
name: v.name,
|
|
3945
|
+
type: "function"
|
|
3946
|
+
};
|
|
3947
|
+
});
|
|
3948
|
+
const html = getHmtl(propsname, param, propsObj, slotValue, {}, exposeText);
|
|
3897
3949
|
Fang.fileOpen(url, html);
|
|
3898
3950
|
}
|
|
3899
3951
|
function getMdurl(obj) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),
|
|
1
|
+
"use strict";const e=require("vue"),_=require("../use/index.cjs"),d=require("./info.vue.cjs"),k=require("./props.vue.cjs"),f=require("../../config.cjs"),g=require("../md/index.vue.cjs");require("./index.cjs");const v=require("../../utils/glob.cjs"),B={class:"compo"},y={key:0,class:"compo-md"},q={key:0,class:"compo-md-list"},C={key:1,class:"compo-use"},h=e.defineComponent({__name:"index",props:{value:Object},setup(c){const t=c,m=f.getConfig("useparam"),l=e.ref(""),u=e.reactive({md:!0}),o=e.ref([]),r=e.ref();function p(n){r.value=n}e.watch(()=>t.value,()=>{a()});function a(){t.value?.key&&(v.getLocalTextComponents(t.value?.key).then(n=>{l.value=n}),o.value=v.getKeyMds(t.value?.key)||[])}return a(),(n,s)=>(e.openBlock(),e.createElementBlock("div",B,[e.createVNode(d,{value:c.value},null,8,["value"]),e.createVNode(k,{onChange:p,value:l.value},null,8,["value"]),o.value&&o.value.length?(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",{onClick:s[0]||(s[0]=i=>u.md=!u.md),class:"compo-md-name"},"说明文档"),u.md?(e.openBlock(),e.createElementBlock("div",q,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,i=>(e.openBlock(),e.createBlock(g,{value:i},null,8,["value"]))),256))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.unref(m)?(e.openBlock(),e.createElementBlock("div",C,[e.createVNode(e.unref(_),{value:t.value,param:r.value},null,8,["value","param"])])):e.createCommentVNode("",!0)]))}});module.exports=h;
|