@fangzhongya/vue-archive 0.0.51 → 0.0.54
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 +13 -19
- package/dist/node/index.js +13 -19
- package/dist/packages/components/use/code.cjs +8 -8
- package/dist/packages/components/use/code.d.ts +2 -2
- package/dist/packages/components/use/code.js +94 -94
- package/dist/packages/components/use/set-props.vue.cjs +1 -1
- package/dist/packages/components/use/set-props.vue.js +24 -28
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -3530,11 +3530,7 @@ function getChange(str) {
|
|
|
3530
3530
|
function setValStringify(v, key, propsText) {
|
|
3531
3531
|
const text = propsText ? propsText[key] : "";
|
|
3532
3532
|
if (text) {
|
|
3533
|
-
|
|
3534
|
-
return getObjValue(text);
|
|
3535
|
-
} else {
|
|
3536
|
-
return text;
|
|
3537
|
-
}
|
|
3533
|
+
return text;
|
|
3538
3534
|
} else {
|
|
3539
3535
|
if (typeof v == "string") {
|
|
3540
3536
|
return getChange(v + "");
|
|
@@ -3543,24 +3539,24 @@ function setValStringify(v, key, propsText) {
|
|
|
3543
3539
|
}
|
|
3544
3540
|
}
|
|
3545
3541
|
}
|
|
3546
|
-
function getSpecType(val
|
|
3542
|
+
function getSpecType(val) {
|
|
3547
3543
|
let ds = parseTypeDefinition(val?.type);
|
|
3548
3544
|
let tarr = ds.dataType;
|
|
3549
|
-
let type =
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3545
|
+
let type = ds.type;
|
|
3546
|
+
type = type.split("<")[0];
|
|
3547
|
+
type = type.trim().toLowerCase();
|
|
3548
|
+
if (tarr.length > 1) {
|
|
3553
3549
|
type = "any";
|
|
3554
3550
|
}
|
|
3555
3551
|
let selectable = (val?.selectable || "").trim();
|
|
3556
3552
|
let arr = [];
|
|
3557
3553
|
if (selectable && type != "boolean") {
|
|
3558
3554
|
if (selectable.includes("|")) {
|
|
3559
|
-
selectable.split("|").forEach((
|
|
3560
|
-
if (
|
|
3561
|
-
let z =
|
|
3555
|
+
selectable.split("|").forEach((v) => {
|
|
3556
|
+
if (v) {
|
|
3557
|
+
let z = v.split(":");
|
|
3562
3558
|
arr.push({
|
|
3563
|
-
label:
|
|
3559
|
+
label: v,
|
|
3564
3560
|
prop: getObjValue(z[0].trim())
|
|
3565
3561
|
});
|
|
3566
3562
|
}
|
|
@@ -3568,19 +3564,17 @@ function getSpecType(val, v) {
|
|
|
3568
3564
|
} else {
|
|
3569
3565
|
arr = parseParamString(selectable);
|
|
3570
3566
|
}
|
|
3571
|
-
if (type == "
|
|
3572
|
-
type = "function";
|
|
3573
|
-
} else if (type == "array") {
|
|
3567
|
+
if (type == "array") {
|
|
3574
3568
|
type = "choice";
|
|
3575
3569
|
} else {
|
|
3576
|
-
if (arr.length > 1) {
|
|
3570
|
+
if (type != "function" && arr.length > 1) {
|
|
3577
3571
|
type = "select";
|
|
3578
3572
|
}
|
|
3579
3573
|
}
|
|
3580
3574
|
}
|
|
3581
3575
|
return {
|
|
3582
3576
|
arr,
|
|
3583
|
-
type
|
|
3577
|
+
type,
|
|
3584
3578
|
dataType: tarr
|
|
3585
3579
|
};
|
|
3586
3580
|
}
|
package/dist/node/index.js
CHANGED
|
@@ -3515,11 +3515,7 @@ function getChange(str) {
|
|
|
3515
3515
|
function setValStringify(v, key, propsText) {
|
|
3516
3516
|
const text = propsText ? propsText[key] : "";
|
|
3517
3517
|
if (text) {
|
|
3518
|
-
|
|
3519
|
-
return getObjValue(text);
|
|
3520
|
-
} else {
|
|
3521
|
-
return text;
|
|
3522
|
-
}
|
|
3518
|
+
return text;
|
|
3523
3519
|
} else {
|
|
3524
3520
|
if (typeof v == "string") {
|
|
3525
3521
|
return getChange(v + "");
|
|
@@ -3528,24 +3524,24 @@ function setValStringify(v, key, propsText) {
|
|
|
3528
3524
|
}
|
|
3529
3525
|
}
|
|
3530
3526
|
}
|
|
3531
|
-
function getSpecType(val
|
|
3527
|
+
function getSpecType(val) {
|
|
3532
3528
|
let ds = parseTypeDefinition(val?.type);
|
|
3533
3529
|
let tarr = ds.dataType;
|
|
3534
|
-
let type =
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3530
|
+
let type = ds.type;
|
|
3531
|
+
type = type.split("<")[0];
|
|
3532
|
+
type = type.trim().toLowerCase();
|
|
3533
|
+
if (tarr.length > 1) {
|
|
3538
3534
|
type = "any";
|
|
3539
3535
|
}
|
|
3540
3536
|
let selectable = (val?.selectable || "").trim();
|
|
3541
3537
|
let arr = [];
|
|
3542
3538
|
if (selectable && type != "boolean") {
|
|
3543
3539
|
if (selectable.includes("|")) {
|
|
3544
|
-
selectable.split("|").forEach((
|
|
3545
|
-
if (
|
|
3546
|
-
let z =
|
|
3540
|
+
selectable.split("|").forEach((v) => {
|
|
3541
|
+
if (v) {
|
|
3542
|
+
let z = v.split(":");
|
|
3547
3543
|
arr.push({
|
|
3548
|
-
label:
|
|
3544
|
+
label: v,
|
|
3549
3545
|
prop: getObjValue(z[0].trim())
|
|
3550
3546
|
});
|
|
3551
3547
|
}
|
|
@@ -3553,19 +3549,17 @@ function getSpecType(val, v) {
|
|
|
3553
3549
|
} else {
|
|
3554
3550
|
arr = parseParamString(selectable);
|
|
3555
3551
|
}
|
|
3556
|
-
if (type == "
|
|
3557
|
-
type = "function";
|
|
3558
|
-
} else if (type == "array") {
|
|
3552
|
+
if (type == "array") {
|
|
3559
3553
|
type = "choice";
|
|
3560
3554
|
} else {
|
|
3561
|
-
if (arr.length > 1) {
|
|
3555
|
+
if (type != "function" && arr.length > 1) {
|
|
3562
3556
|
type = "select";
|
|
3563
3557
|
}
|
|
3564
3558
|
}
|
|
3565
3559
|
}
|
|
3566
3560
|
return {
|
|
3567
3561
|
arr,
|
|
3568
|
-
type
|
|
3562
|
+
type,
|
|
3569
3563
|
dataType: tarr
|
|
3570
3564
|
};
|
|
3571
3565
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const z=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const H=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const w=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const c=require("./util.cjs"),T=require("../../utils/props.cjs"),J=require("@fangzhongya/utils/basic/string/toFunction"),N=["class"];function q(e,t){return e.filter(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const z=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const H=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const w=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const c=require("./util.cjs"),T=require("../../utils/props.cjs"),J=require("@fangzhongya/utils/basic/string/toFunction"),N=["class"];function q(e,t){return e.filter(s=>s.name==t)[0]}function L(e){return e.map(t=>(t.prop||"...arr")+":"+c.setDataType(t.dataType)).join(",")}function A(e,t,s,n,o,h){const p=[],r=[];let b=!0;const v=T.getPropsValue(t.propss||[]),x=T.getEmitsValue(t.emitss||[]),B=T.getExposeValue(t.exposes||[]),C=T.getSlotValue(t.slots||[]);Object.keys(s).forEach(i=>{let m=s[i];if(/^on[A-Z]/.test(i)&&typeof m=="function"){let u=i.substring(2);const l=i.split(":");let g;if(l.length>1?(g=l[0]+l.slice(1).map(f=>w.firstUpper(f)).join(""),u=H.firstLower(u)):(g=l[0],u=z.humpToLine(u)),l.includes("-")){let f=g.split("-");f=f.map(($,V)=>V!=0?w.firstUpper($):$),g=f.join("")}p.push(" @"+u+'="'+g+'"');const a=q(x,u)||{},d=a.selectable||"",S=c.parseParamString(d),y=L(S);r.push(`// ${a.description} ${a.name}: (${a.selectable})`),r.push("function "+g+"("+y+") {"),S.forEach(f=>{const $=f.name||"arr";r.push(" console.log('"+f.label+"', "+$+")")}),r.push("}")}else{let u=i;N.includes(i)&&(u=i+"1"),p.push(" :"+i+'="'+u+'"');const l=q(v,i)||{},g=E(l);if(r.push(`// ${l.description} ${l.name}: {${l.type}} (${l.selectable})`),typeof m=="function")r.push("const "+i+" = "+P(m,i,o));else if(b&&(b=!1,r.unshift("import { ref } from 'vue';")),typeof m>"u")if(g.type=="function"){const a=Z(l);r.push("const "+u+" = "+a+";")}else{const a=c.getTypeValue(g.dataType);r.push("const "+u+" = ref("+(a==="undefined"?"":a)+");")}else{let a=j(m,i,o);r.push("const "+u+" = ref("+a+");")}}});const O=Object.values(h||{});O.length>0&&(b&&(b=!1,r.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),r.push("const refDom = ref()"),O.forEach(i=>{const m=q(B,i.name)||{};r.push(`// ${m.description} ${m.name}:(${m.selectable}) ${m.type}`);const u=i.name+"Value",l=c.parseParamString(m?.selectable||""),g=[],a=i.params||[];l.forEach((d,S)=>{const y=d.name;if(y){const f=y+i.name,$=a[S];if(r.push(`// ${d.label}`),typeof $=="function")r.push("const "+f+" = "+P($,y,i.text));else if(typeof $>"u")r.push("const "+f+" = "+c.getTypeValue(d.dataType)+";");else{let V=j($,y,i.text);r.push("const "+f+" = "+V+";")}g.push(f)}}),i.type==="function"?r.push(`const ${u} = refDom.value?.${i.name}(${g.join(", ")})`):r.push(`const ${u} = refDom.value?.${i.name}`),r.push(`console.log('"${m.type}"', ${u})`)})),p.length>0&&p.unshift("");const U=M(n,C);return`<!--${e}-->
|
|
2
2
|
<template>
|
|
3
3
|
<div>
|
|
4
|
-
<${e}${
|
|
4
|
+
<${e}${p.join(`
|
|
5
5
|
`)}>${U.join(`
|
|
6
6
|
`)}
|
|
7
7
|
</${e}>
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
${r.join(`
|
|
12
12
|
`)}
|
|
13
13
|
<\/script>
|
|
14
|
-
`}function M(e={},t){const
|
|
15
|
-
<template #${
|
|
14
|
+
`}function M(e={},t){const s=[];return Object.keys(e).forEach(n=>{const o=q(t,n)||{},h=e[n];if(h){const p=` <!-- ${o.description} ${o.name}:(${o.selectable}) -->
|
|
15
|
+
<template #${n}="scope">
|
|
16
16
|
${c.vueFormat(h," ")}
|
|
17
|
-
</template>`;
|
|
17
|
+
</template>`;s.push(p)}}),s&&s.length>0&&s.unshift(""),s}function P(e,t,s){const n=s?s[t]:"";return n&&(n.includes("=>")||n.includes("function"))?n:F(e.toString())}function F(e){const t=J.getFunctionFormat(c.prettierFormat(e));if(t){let s=`{
|
|
18
18
|
${c.vueFormat(c.getFunBody(t.body)," ")}
|
|
19
|
-
}`;return`function (${t.param}) ${
|
|
20
|
-
${c.vueFormat(c.getFunBody(
|
|
21
|
-
}`;return`function (${
|
|
19
|
+
}`;return`function (${t.param}) ${s}`}else return"undefined"}function Z(e){const t=c.parseParamString(e.selectable),s=L(t);let n="";e.return&&(n="return ");let o=`{
|
|
20
|
+
${c.vueFormat(c.getFunBody(n)," ")}
|
|
21
|
+
}`;return`function (${s}) ${o}`}function G(e){const t=e.trim();return/^\(/.test(t)?F(t):JSON.stringify(e)}function j(e,t,s){const n=s?s[t]:"";return n||(typeof e=="string"?G(e+""):JSON.stringify(e))}function E(e){let t=c.parseTypeDefinition(e?.type),s=t.dataType,n=t.type;n=n.split("<")[0],n=n.trim().toLowerCase(),s.length>1&&(n="any");let o=(e?.selectable||"").trim(),h=[];return o&&n!="boolean"&&(o.includes("|")?o.split("|").forEach(p=>{if(p){let r=p.split(":");h.push({label:p,prop:D(r[0].trim())})}}):h=c.parseParamString(o),n=="array"?n="choice":n!="function"&&h.length>1&&(n="select")),{arr:h,type:n,dataType:s}}function D(e,t){try{if(t?.toLowerCase()=="function")if(typeof e=="string"){if(/^\((.|\n|\r)*\)$/.test(e))return e=e.substring(1,e.length-1),new Function(`{ return ${e} }`)()}else return e;else return new Function(`{ return ${e} }`)()}catch{return""+e}}function I(e,t=!0){const s=E(e),n=c.getTypeValue(s.dataType);if(t){const o=(e.default||"").trim();return D(o||n,s.dataType[0])}else{const o=(e.default||"").trim();return D(o,s.dataType[0])}}exports.getDefaultValue=I;exports.getHmtl=A;exports.getSpecType=E;exports.setValStringify=j;
|
|
@@ -3,12 +3,12 @@ import { SpecObjs, Spec } from '../../utils/index';
|
|
|
3
3
|
export declare function getHmtl(propsname: string, param: {
|
|
4
4
|
[key: string]: SpecObjs[];
|
|
5
5
|
}, value: ObjUnk, slotValue?: ObjStr, propsText?: ObjStr, exposeText?: ObjUnk): string;
|
|
6
|
-
export declare function setValStringify(v: unknown, key: string, propsText?: ObjStr):
|
|
6
|
+
export declare function setValStringify(v: unknown, key: string, propsText?: ObjStr): string;
|
|
7
7
|
type SelectsObj = {
|
|
8
8
|
label: string;
|
|
9
9
|
prop: unknown;
|
|
10
10
|
};
|
|
11
|
-
export declare function getSpecType(val: Spec
|
|
11
|
+
export declare function getSpecType(val: Spec): {
|
|
12
12
|
arr: SelectsObj[];
|
|
13
13
|
type: string;
|
|
14
14
|
dataType: string[];
|
|
@@ -9,96 +9,96 @@ import "@fangzhongya/utils/basic/array/asyncMergeArray";
|
|
|
9
9
|
import { firstUpper as w } from "@fangzhongya/utils/basic/string/firstUpper";
|
|
10
10
|
import "@fangzhongya/utils/urls/getSuffix";
|
|
11
11
|
import "@fangzhongya/utils/basic/array/replaceAfter";
|
|
12
|
-
import { getTypeValue as
|
|
12
|
+
import { getTypeValue as j, parseParamString as T, parseTypeDefinition as q, setDataType as v, vueFormat as D, getFunBody as C, prettierFormat as G } from "./util.js";
|
|
13
13
|
import { getPropsValue as I, getEmitsValue as K, getExposeValue as M, getSlotValue as Q } from "../../utils/props.js";
|
|
14
14
|
import { getFunctionFormat as R } from "@fangzhongya/utils/basic/string/toFunction";
|
|
15
15
|
const W = ["class"];
|
|
16
16
|
function S(t, e) {
|
|
17
|
-
return t.filter((
|
|
17
|
+
return t.filter((s) => s.name == e)[0];
|
|
18
18
|
}
|
|
19
19
|
function P(t) {
|
|
20
20
|
return t.map((e) => (e.prop || "...arr") + ":" + v(e.dataType)).join(",");
|
|
21
21
|
}
|
|
22
|
-
function ht(t, e,
|
|
23
|
-
const
|
|
24
|
-
let
|
|
22
|
+
function ht(t, e, s, n, i, h) {
|
|
23
|
+
const a = [], r = [];
|
|
24
|
+
let y = !0;
|
|
25
25
|
const B = I(e.propss || []), J = K(e.emitss || []), N = M(e.exposes || []), A = Q(e.slots || []);
|
|
26
|
-
Object.keys(
|
|
27
|
-
let
|
|
28
|
-
if (/^on[A-Z]/.test(
|
|
29
|
-
let c =
|
|
30
|
-
const u =
|
|
26
|
+
Object.keys(s).forEach((o) => {
|
|
27
|
+
let p = s[o];
|
|
28
|
+
if (/^on[A-Z]/.test(o) && typeof p == "function") {
|
|
29
|
+
let c = o.substring(2);
|
|
30
|
+
const u = o.split(":");
|
|
31
31
|
let m;
|
|
32
|
-
if (u.length > 1 ? (m = u[0] + u.slice(1).map((
|
|
33
|
-
let
|
|
34
|
-
|
|
32
|
+
if (u.length > 1 ? (m = u[0] + u.slice(1).map((f) => w(f)).join(""), c = Z(c)) : (m = u[0], c = U(c)), u.includes("-")) {
|
|
33
|
+
let f = m.split("-");
|
|
34
|
+
f = f.map(($, V) => V != 0 ? w($) : $), m = f.join("");
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
r.push(`// ${
|
|
39
|
-
const
|
|
40
|
-
r.push(" console.log('" +
|
|
36
|
+
a.push(" @" + c + '="' + m + '"');
|
|
37
|
+
const l = S(J, c) || {}, d = l.selectable || "", b = T(d), g = P(b);
|
|
38
|
+
r.push(`// ${l.description} ${l.name}: (${l.selectable})`), r.push("function " + m + "(" + g + ") {"), b.forEach((f) => {
|
|
39
|
+
const $ = f.name || "arr";
|
|
40
|
+
r.push(" console.log('" + f.label + "', " + $ + ")");
|
|
41
41
|
}), r.push("}");
|
|
42
42
|
} else {
|
|
43
|
-
let c =
|
|
44
|
-
W.includes(
|
|
45
|
-
const u = S(B,
|
|
43
|
+
let c = o;
|
|
44
|
+
W.includes(o) && (c = o + "1"), a.push(" :" + o + '="' + c + '"');
|
|
45
|
+
const u = S(B, o) || {}, m = z(u);
|
|
46
46
|
if (r.push(
|
|
47
47
|
`// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`
|
|
48
|
-
), typeof
|
|
48
|
+
), typeof p == "function")
|
|
49
49
|
r.push(
|
|
50
|
-
"const " +
|
|
50
|
+
"const " + o + " = " + x(p, o, i)
|
|
51
51
|
);
|
|
52
|
-
else if (
|
|
52
|
+
else if (y && (y = !1, r.unshift("import { ref } from 'vue';")), typeof p > "u")
|
|
53
53
|
if (m.type == "function") {
|
|
54
|
-
const
|
|
55
|
-
r.push("const " + c + " = " +
|
|
54
|
+
const l = Y(u);
|
|
55
|
+
r.push("const " + c + " = " + l + ";");
|
|
56
56
|
} else {
|
|
57
|
-
const
|
|
57
|
+
const l = j(m.dataType);
|
|
58
58
|
r.push(
|
|
59
|
-
"const " + c + " = ref(" + (
|
|
59
|
+
"const " + c + " = ref(" + (l === "undefined" ? "" : l) + ");"
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
let
|
|
64
|
-
r.push("const " + c + " = ref(" +
|
|
63
|
+
let l = L(p, o, i);
|
|
64
|
+
r.push("const " + c + " = ref(" + l + ");");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
const O = Object.values(h || {});
|
|
69
|
-
O.length > 0 && (
|
|
70
|
-
const
|
|
69
|
+
O.length > 0 && (y && (y = !1, r.unshift("import { ref } from 'vue';")), a.unshift(' ref="refDom"'), r.push("const refDom = ref()"), O.forEach((o) => {
|
|
70
|
+
const p = S(N, o.name) || {};
|
|
71
71
|
r.push(
|
|
72
|
-
`// ${
|
|
72
|
+
`// ${p.description} ${p.name}:(${p.selectable}) ${p.type}`
|
|
73
73
|
);
|
|
74
|
-
const c =
|
|
74
|
+
const c = o.name + "Value", u = T(p?.selectable || ""), m = [], l = o.params || [];
|
|
75
75
|
u.forEach((d, b) => {
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
if (r.push(`// ${d.label}`), typeof
|
|
76
|
+
const g = d.name;
|
|
77
|
+
if (g) {
|
|
78
|
+
const f = g + o.name, $ = l[b];
|
|
79
|
+
if (r.push(`// ${d.label}`), typeof $ == "function")
|
|
80
80
|
r.push(
|
|
81
|
-
"const " +
|
|
81
|
+
"const " + f + " = " + x($, g, o.text)
|
|
82
82
|
);
|
|
83
|
-
else if (typeof
|
|
83
|
+
else if (typeof $ > "u")
|
|
84
84
|
r.push(
|
|
85
|
-
"const " +
|
|
85
|
+
"const " + f + " = " + j(d.dataType) + ";"
|
|
86
86
|
);
|
|
87
87
|
else {
|
|
88
|
-
let
|
|
89
|
-
r.push("const " +
|
|
88
|
+
let V = L($, g, o.text);
|
|
89
|
+
r.push("const " + f + " = " + V + ";");
|
|
90
90
|
}
|
|
91
|
-
m.push(
|
|
91
|
+
m.push(f);
|
|
92
92
|
}
|
|
93
|
-
}),
|
|
94
|
-
`const ${c} = refDom.value?.${
|
|
95
|
-
) : r.push(`const ${c} = refDom.value?.${
|
|
96
|
-
})),
|
|
97
|
-
const H = X(
|
|
93
|
+
}), o.type === "function" ? r.push(
|
|
94
|
+
`const ${c} = refDom.value?.${o.name}(${m.join(", ")})`
|
|
95
|
+
) : r.push(`const ${c} = refDom.value?.${o.name}`), r.push(`console.log('"${p.type}"', ${c})`);
|
|
96
|
+
})), a.length > 0 && a.unshift("");
|
|
97
|
+
const H = X(n, A);
|
|
98
98
|
return `<!--${t}-->
|
|
99
99
|
<template>
|
|
100
100
|
<div>
|
|
101
|
-
<${t}${
|
|
101
|
+
<${t}${a.join(`
|
|
102
102
|
`)}>${H.join(`
|
|
103
103
|
`)}
|
|
104
104
|
</${t}>
|
|
@@ -111,68 +111,68 @@ ${r.join(`
|
|
|
111
111
|
`;
|
|
112
112
|
}
|
|
113
113
|
function X(t = {}, e) {
|
|
114
|
-
const
|
|
115
|
-
return Object.keys(t).forEach((
|
|
116
|
-
const
|
|
114
|
+
const s = [];
|
|
115
|
+
return Object.keys(t).forEach((n) => {
|
|
116
|
+
const i = S(e, n) || {}, h = t[n];
|
|
117
117
|
if (h) {
|
|
118
|
-
const
|
|
119
|
-
<template #${
|
|
118
|
+
const a = ` <!-- ${i.description} ${i.name}:(${i.selectable}) -->
|
|
119
|
+
<template #${n}="scope">
|
|
120
120
|
${D(h, " ")}
|
|
121
121
|
</template>`;
|
|
122
|
-
|
|
122
|
+
s.push(a);
|
|
123
123
|
}
|
|
124
|
-
}),
|
|
124
|
+
}), s && s.length > 0 && s.unshift(""), s;
|
|
125
125
|
}
|
|
126
|
-
function x(t, e,
|
|
127
|
-
const
|
|
128
|
-
return
|
|
126
|
+
function x(t, e, s) {
|
|
127
|
+
const n = s ? s[e] : "";
|
|
128
|
+
return n && (n.includes("=>") || n.includes("function")) ? n : F(t.toString());
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function F(t) {
|
|
131
131
|
const e = R(G(t));
|
|
132
132
|
if (e) {
|
|
133
|
-
let
|
|
133
|
+
let s = `{
|
|
134
134
|
${D(C(e.body), " ")}
|
|
135
135
|
}`;
|
|
136
|
-
return `function (${e.param}) ${
|
|
136
|
+
return `function (${e.param}) ${s}`;
|
|
137
137
|
} else
|
|
138
138
|
return "undefined";
|
|
139
139
|
}
|
|
140
140
|
function Y(t) {
|
|
141
|
-
const e = T(t.selectable),
|
|
142
|
-
let
|
|
143
|
-
t.return && (
|
|
144
|
-
let
|
|
145
|
-
${D(C(
|
|
141
|
+
const e = T(t.selectable), s = P(e);
|
|
142
|
+
let n = "";
|
|
143
|
+
t.return && (n = "return ");
|
|
144
|
+
let i = `{
|
|
145
|
+
${D(C(n), " ")}
|
|
146
146
|
}`;
|
|
147
|
-
return `function (${
|
|
147
|
+
return `function (${s}) ${i}`;
|
|
148
148
|
}
|
|
149
149
|
function _(t) {
|
|
150
150
|
const e = t.trim();
|
|
151
|
-
return /^\(/.test(e) ?
|
|
151
|
+
return /^\(/.test(e) ? F(e) : JSON.stringify(t);
|
|
152
152
|
}
|
|
153
|
-
function L(t, e,
|
|
154
|
-
const
|
|
155
|
-
return
|
|
153
|
+
function L(t, e, s) {
|
|
154
|
+
const n = s ? s[e] : "";
|
|
155
|
+
return n || (typeof t == "string" ? _(t + "") : JSON.stringify(t));
|
|
156
156
|
}
|
|
157
|
-
function z(t
|
|
158
|
-
let
|
|
159
|
-
|
|
160
|
-
let
|
|
161
|
-
return
|
|
162
|
-
if (
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
label:
|
|
166
|
-
prop:
|
|
157
|
+
function z(t) {
|
|
158
|
+
let e = q(t?.type), s = e.dataType, n = e.type;
|
|
159
|
+
n = n.split("<")[0], n = n.trim().toLowerCase(), s.length > 1 && (n = "any");
|
|
160
|
+
let i = (t?.selectable || "").trim(), h = [];
|
|
161
|
+
return i && n != "boolean" && (i.includes("|") ? i.split("|").forEach((a) => {
|
|
162
|
+
if (a) {
|
|
163
|
+
let r = a.split(":");
|
|
164
|
+
h.push({
|
|
165
|
+
label: a,
|
|
166
|
+
prop: E(r[0].trim())
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
}) :
|
|
170
|
-
arr:
|
|
171
|
-
type:
|
|
169
|
+
}) : h = T(i), n == "array" ? n = "choice" : n != "function" && h.length > 1 && (n = "select")), {
|
|
170
|
+
arr: h,
|
|
171
|
+
type: n,
|
|
172
172
|
dataType: s
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function E(t, e) {
|
|
176
176
|
try {
|
|
177
177
|
if (e?.toLowerCase() == "function")
|
|
178
178
|
if (typeof t == "string") {
|
|
@@ -186,18 +186,18 @@ function V(t, e) {
|
|
|
186
186
|
return "" + t;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
const
|
|
189
|
+
function $t(t, e = !0) {
|
|
190
|
+
const s = z(t), n = j(s.dataType);
|
|
191
191
|
if (e) {
|
|
192
|
-
const
|
|
193
|
-
return
|
|
192
|
+
const i = (t.default || "").trim();
|
|
193
|
+
return E(i || n, s.dataType[0]);
|
|
194
194
|
} else {
|
|
195
|
-
const
|
|
196
|
-
return
|
|
195
|
+
const i = (t.default || "").trim();
|
|
196
|
+
return E(i, s.dataType[0]);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
export {
|
|
200
|
-
|
|
200
|
+
$t as getDefaultValue,
|
|
201
201
|
ht as getHmtl,
|
|
202
202
|
z as getSpecType,
|
|
203
203
|
L as setValStringify
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("vue"),T=require("./retrie/index.vue.cjs");;/* empty css */const
|
|
1
|
+
"use strict";const s=require("vue"),T=require("./retrie/index.vue.cjs");;/* empty css */const o=require("./code.cjs"),k={key:0,class:"set-props"},x=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(i,{emit:p}){const l=i,f=p,a=s.ref({}),m=s.ref(0),c=s.ref({}),r=s.ref([]);function d(){c.value={};const n=[];l.list?.forEach(t=>{let e=t.name;if(!e.includes(".")&&(e=(e.split("/")[0]||"").trim(),e)){const y=o.getDefaultValue(t,!1);c.value[e]=y;const{arr:g,type:b,dataType:V}=o.getSpecType(t);a.value[e]=g;let q={label:_(e,t),prop:e,type:b,dataType:V,select:e};n.push(q)}}),r.value=n}function _(n,t){let e=n+": { "+(t.type||"any")+" } "+t.description;return t.default&&(e+=" 默认值="+t.default),t.selectable&&(e+=" 可选值="+t.selectable),e}function h(n,t){let e=Object.assign({},n);f("change",e,t)}let u;function v(){clearTimeout(u),u=setTimeout(()=>{d()},400)}return s.watch(()=>l.name,()=>{r.value=[],v()},{immediate:!0}),(n,t)=>r.value&&r.value.length>0?(s.openBlock(),s.createElementBlock("div",k,[s.createVNode(T,{refresh:m.value,modelValue:c.value,selects:a.value,list:r.value,name:l.name,onQuery:h},null,8,["refresh","modelValue","selects","list","name"])])):s.createCommentVNode("",!0)}});module.exports=x;
|
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
import { defineComponent as T, ref as
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent as T, ref as n, watch as k, createElementBlock as j, createCommentVNode as x, openBlock as B, createVNode as C } from "vue";
|
|
2
|
+
import E from "./retrie/index.vue.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import { getDefaultValue as
|
|
5
|
-
import { isDefaultType as S } from "./util.js";
|
|
4
|
+
import { getDefaultValue as N, getSpecType as S } from "./code.js";
|
|
6
5
|
const w = {
|
|
7
6
|
key: 0,
|
|
8
7
|
class: "set-props"
|
|
9
|
-
},
|
|
8
|
+
}, R = /* @__PURE__ */ T({
|
|
10
9
|
__name: "set-props",
|
|
11
10
|
props: {
|
|
12
11
|
name: String,
|
|
13
12
|
list: Array
|
|
14
13
|
},
|
|
15
14
|
emits: ["change"],
|
|
16
|
-
setup(
|
|
17
|
-
const
|
|
18
|
-
function
|
|
15
|
+
setup(i, { emit: u }) {
|
|
16
|
+
const a = i, m = u, r = n({}), p = n(0), o = n({}), l = n([]);
|
|
17
|
+
function f() {
|
|
19
18
|
o.value = {};
|
|
20
19
|
const s = [];
|
|
21
|
-
|
|
20
|
+
a.list?.forEach((t) => {
|
|
22
21
|
let e = t.name;
|
|
23
22
|
if (!e.includes(".") && (e = (e.split("/")[0] || "").trim(), e)) {
|
|
24
|
-
const
|
|
25
|
-
o.value[e] =
|
|
26
|
-
const { arr: b, type: g, dataType: V } =
|
|
27
|
-
t,
|
|
28
|
-
S(i)
|
|
29
|
-
);
|
|
23
|
+
const y = N(t, !1);
|
|
24
|
+
o.value[e] = y;
|
|
25
|
+
const { arr: b, type: g, dataType: V } = S(t);
|
|
30
26
|
r.value[e] = b;
|
|
31
27
|
let v = {
|
|
32
|
-
label:
|
|
28
|
+
label: d(e, t),
|
|
33
29
|
prop: e,
|
|
34
30
|
type: g,
|
|
35
31
|
dataType: V,
|
|
@@ -39,40 +35,40 @@ const w = {
|
|
|
39
35
|
}
|
|
40
36
|
}), l.value = s;
|
|
41
37
|
}
|
|
42
|
-
function
|
|
38
|
+
function d(s, t) {
|
|
43
39
|
let e = s + ": { " + (t.type || "any") + " } " + t.description;
|
|
44
40
|
return t.default && (e += " 默认值=" + t.default), t.selectable && (e += " 可选值=" + t.selectable), e;
|
|
45
41
|
}
|
|
46
|
-
function
|
|
42
|
+
function h(s, t) {
|
|
47
43
|
let e = Object.assign({}, s);
|
|
48
|
-
|
|
44
|
+
m("change", e, t);
|
|
49
45
|
}
|
|
50
46
|
let c;
|
|
51
|
-
function
|
|
47
|
+
function _() {
|
|
52
48
|
clearTimeout(c), c = setTimeout(() => {
|
|
53
|
-
|
|
49
|
+
f();
|
|
54
50
|
}, 400);
|
|
55
51
|
}
|
|
56
52
|
return k(
|
|
57
|
-
() =>
|
|
53
|
+
() => a.name,
|
|
58
54
|
() => {
|
|
59
|
-
l.value = [],
|
|
55
|
+
l.value = [], _();
|
|
60
56
|
},
|
|
61
57
|
{
|
|
62
58
|
immediate: !0
|
|
63
59
|
}
|
|
64
60
|
), (s, t) => l.value && l.value.length > 0 ? (B(), j("div", w, [
|
|
65
|
-
C(
|
|
66
|
-
refresh:
|
|
61
|
+
C(E, {
|
|
62
|
+
refresh: p.value,
|
|
67
63
|
modelValue: o.value,
|
|
68
64
|
selects: r.value,
|
|
69
65
|
list: l.value,
|
|
70
|
-
name:
|
|
71
|
-
onQuery:
|
|
66
|
+
name: a.name,
|
|
67
|
+
onQuery: h
|
|
72
68
|
}, null, 8, ["refresh", "modelValue", "selects", "list", "name"])
|
|
73
69
|
])) : x("", !0);
|
|
74
70
|
}
|
|
75
71
|
});
|
|
76
72
|
export {
|
|
77
|
-
|
|
73
|
+
R as default
|
|
78
74
|
};
|