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