@fangzhongya/vue-archive 0.0.38 → 0.0.40
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 +9 -3
- package/dist/node/index.js +9 -3
- package/dist/packages/components/compo/index.cjs +1 -1
- package/dist/packages/components/compo/index.js +1 -1
- package/dist/packages/components/use/code.cjs +7 -7
- package/dist/packages/components/use/code.d.ts +1 -1
- package/dist/packages/components/use/code.js +54 -54
- package/dist/packages/components/use/set-props.vue.cjs +1 -1
- package/dist/packages/components/use/set-props.vue.js +14 -14
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -3487,7 +3487,11 @@ function getChange(str) {
|
|
|
3487
3487
|
function setValStringify(v, key, propsText) {
|
|
3488
3488
|
const text = propsText ? propsText[key] : "";
|
|
3489
3489
|
if (text) {
|
|
3490
|
-
|
|
3490
|
+
if (typeof text == "string") {
|
|
3491
|
+
return getObjValue(text);
|
|
3492
|
+
} else {
|
|
3493
|
+
return text;
|
|
3494
|
+
}
|
|
3491
3495
|
} else {
|
|
3492
3496
|
if (typeof v == "string") {
|
|
3493
3497
|
return getChange(v + "");
|
|
@@ -3524,7 +3528,9 @@ function getSpecType(val) {
|
|
|
3524
3528
|
} else if (type == "array") {
|
|
3525
3529
|
type = "choice";
|
|
3526
3530
|
} else {
|
|
3527
|
-
|
|
3531
|
+
if (arr.length > 1) {
|
|
3532
|
+
type = "select";
|
|
3533
|
+
}
|
|
3528
3534
|
}
|
|
3529
3535
|
}
|
|
3530
3536
|
return {
|
|
@@ -3581,7 +3587,7 @@ function getDefault(ss, iss) {
|
|
|
3581
3587
|
let ci = cs.indexOf(c);
|
|
3582
3588
|
if (ci != -1) {
|
|
3583
3589
|
let reg = new RegExp(
|
|
3584
|
-
"
|
|
3590
|
+
"^\\" + css[ci][0] + "(([^\\" + css[ci][1] + "])*)\\" + css[ci][1] + (iss ? "\\s" : ""),
|
|
3585
3591
|
"gi"
|
|
3586
3592
|
);
|
|
3587
3593
|
let rs = reg.exec(ss);
|
package/dist/node/index.js
CHANGED
|
@@ -3472,7 +3472,11 @@ function getChange(str) {
|
|
|
3472
3472
|
function setValStringify(v, key, propsText) {
|
|
3473
3473
|
const text = propsText ? propsText[key] : "";
|
|
3474
3474
|
if (text) {
|
|
3475
|
-
|
|
3475
|
+
if (typeof text == "string") {
|
|
3476
|
+
return getObjValue(text);
|
|
3477
|
+
} else {
|
|
3478
|
+
return text;
|
|
3479
|
+
}
|
|
3476
3480
|
} else {
|
|
3477
3481
|
if (typeof v == "string") {
|
|
3478
3482
|
return getChange(v + "");
|
|
@@ -3509,7 +3513,9 @@ function getSpecType(val) {
|
|
|
3509
3513
|
} else if (type == "array") {
|
|
3510
3514
|
type = "choice";
|
|
3511
3515
|
} else {
|
|
3512
|
-
|
|
3516
|
+
if (arr.length > 1) {
|
|
3517
|
+
type = "select";
|
|
3518
|
+
}
|
|
3513
3519
|
}
|
|
3514
3520
|
}
|
|
3515
3521
|
return {
|
|
@@ -3566,7 +3572,7 @@ function getDefault(ss, iss) {
|
|
|
3566
3572
|
let ci = cs.indexOf(c);
|
|
3567
3573
|
if (ci != -1) {
|
|
3568
3574
|
let reg = new RegExp(
|
|
3569
|
-
"
|
|
3575
|
+
"^\\" + css[ci][0] + "(([^\\" + css[ci][1] + "])*)\\" + css[ci][1] + (iss ? "\\s" : ""),
|
|
3570
3576
|
"gi"
|
|
3571
3577
|
);
|
|
3572
3578
|
let rs = reg.exec(ss);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../utils/index.cjs");require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");require("@fangzhongya/utils/html/getVueText");const o=require("../../utils/props.cjs"),i={titles:[],propss:[],slots:[],emitss:[],exposes:[]};function x(e,s){let r=e.charAt(0),l=[['"','"'],["'","'"],["`","`"],["(",")"],["{","}"],["[","]"]],a=l.map(p=>p[0]).indexOf(r);if(a!=-1){let n=new RegExp("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../utils/index.cjs");require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");require("@fangzhongya/utils/html/getVueText");const o=require("../../utils/props.cjs"),i={titles:[],propss:[],slots:[],emitss:[],exposes:[]};function x(e,s){let r=e.charAt(0),l=[['"','"'],["'","'"],["`","`"],["(",")"],["{","}"],["[","]"]],a=l.map(p=>p[0]).indexOf(r);if(a!=-1){let n=new RegExp("^\\"+l[a][0]+"(([^\\"+l[a][1]+"])*)\\"+l[a][1]+(s?"\\s":""),"gi").exec(e);if(n)return n[0]}}function E(e){delete e.problems,delete e.source;let s=e.tag,r=e.name,l=e.description,t=e.default,a="";if(s=="default")r=r.trim(),r=x(r)||r;else if(s=="selectable")r=r.trim();else{if(r.includes("=")){const m=r.split("=");r=m[0];const g=m[1]+" "+l,d=x(g,!0);d?(t=d,l=g.replace(d,"")):t=e.default||m[1]||""}const n=/\s*\((.*)\)\s/gi.exec(l);n&&n.length>0&&(a=n[1],l=l.replace(n[0],""))}return e.name=r,e.default=t||"",e.description=l,e.selectable=a,e}function q(e){let s=["title","text","author","date"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),b(l),r.arr.forEach(t=>{f(t.key,t.value)})}function b(e){i.titles.push(e)}function O(e){let s=["props","name","type","default","selectable","description","descriptions","return"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"props"),r.arr.forEach(t=>{f(t.key,t.value)})}function T(e){let s=["slot","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"slot"),r.arr.forEach(t=>{f(t.key,t.value)})}function y(e){let s=["emits","name","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"emits"),r.arr.forEach(t=>{f(t.key,t.value)})}function j(e){let s=["expose","name","type","return","selectable","description","descriptions"],r=u(e),l={};s.forEach(t=>{l[t]=r.obj[t]}),c(l,"expose"),r.arr.forEach(t=>{f(t.key,t.value)})}function c(e,s){const r=i[s+"name"]||[],l=e.name??e[s]?.name,t=r.indexOf(l);t>=0&&(i[s+"s"].splice(t,1),r.splice(t,1)),i[s+"s"].push(e),r.push(l),i[s+"name"]=r}function w(){Object.keys(i).forEach(e=>{i[e]=[]})}function u(e,s){const r={descriptions:e?.description||""},l=[];return e?.tags&&e.tags?.forEach(t=>{let a=t.tag,p=E(t);if(!r.hasOwnProperty(a))r[a]=p;else{const n={};n[a]=p,l.push({key:a,value:n})}}),{arr:l,obj:r}}function f(e,s){switch(e){case"title":return b(s),!0;case"text":return b(s),!0;case"props":return c(s,"props"),!0;case"slot":return c(s,"slot"),!0;case"emits":return c(s,"emits"),!0;case"expose":return c(s,"expose"),!0;default:return!1}}function k(e,s){switch(e){case"title":return q(s),!0;case"props":return O(s),!0;case"slot":return T(s),!0;case"emits":return y(s),!0;case"expose":return j(s),!0;default:return!1}}function N(e){return w(),e?.forEach(s=>{let r=s?.tags||[],l=r?.length||0;if(l>0)for(let t=0;t<l;t++){const a=r[t]||{};if(k(a.tag,s))break}}),i}function P(e){let s=h.getTextNotes(e);return N(s)}const S=[{label:"属性名",prop:"name",formatter:o.props.name},{label:"说明",prop:"description",formatter:o.props.description},{label:"类型",prop:"type",formatter:o.props.type},{label:"可选值",prop:"selectable",formatter:o.props.selectable},{label:"默认值",prop:"default",formatter:o.props.default}],F=[{label:"事件名",prop:"name",formatter:o.emits.name},{label:"说明",prop:"description",formatter:o.emits.description},{label:"回调参数",prop:"selectable",formatter:o.emits.selectable}],v=[{label:"方法名",prop:"name",formatter:o.expose.name},{label:"说明",prop:"description",formatter:o.expose.description},{label:"参数",prop:"selectable",formatter:o.expose.selectable},{label:"返回值",prop:"type",formatter(e){return o.expose.return(e)??o.expose.type(e)}}],z=[{label:"插槽名",prop:"name",formatter:o.slot.name},{label:"说明",prop:"description",formatter:o.slot.description},{label:"作用域参数",prop:"selectable",formatter:o.slot.selectable}];exports.getNotesText=P;exports.temits=F;exports.texpose=v;exports.tprops=S;exports.tslot=z;
|
|
@@ -30,7 +30,7 @@ function O(e, s) {
|
|
|
30
30
|
], o = l.map((c) => c[0]).indexOf(r);
|
|
31
31
|
if (o != -1) {
|
|
32
32
|
let a = new RegExp(
|
|
33
|
-
"
|
|
33
|
+
"^\\" + l[o][0] + "(([^\\" + l[o][1] + "])*)\\" + l[o][1] + (s ? "\\s" : ""),
|
|
34
34
|
"gi"
|
|
35
35
|
).exec(e);
|
|
36
36
|
if (a)
|
|
@@ -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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const H=require("@fangzhongya/utils/name/humpToLine");require("@fangzhongya/utils/name/lineToLargeHump");require("@fangzhongya/utils/basic/string/appearNum");const J=require("@fangzhongya/utils/basic/string/firstLower");require("@fangzhongya/utils/basic/array/duplicateRemoval");require("@fangzhongya/utils/basic/array/asyncMergeArray");const O=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const c=require("./util.cjs"),q=require("../../utils/props.cjs"),N=require("@fangzhongya/utils/basic/string/toFunction"),v=["class"];function V(e,t){return e.filter(n=>n.name==t)[0]}function P(e){return e.map(t=>(t.prop||"...arr")+":"+c.setDataType(t.dataType)).join(",")}function A(e,t,n,s,l,h){const p=[],r=[];let b=!0;const x=q.getPropsValue(t.propss||[]),z=q.getEmitsValue(t.emitss||[]),B=q.getExposeValue(t.exposes||[]),U=q.getSlotValue(t.slots||[]);Object.keys(n).forEach(o=>{let m=n[o];if(/^on[A-Z]/.test(o)&&typeof m=="function"){let i=o.substring(2);const u=o.split(":");let g;if(u.length>1?(g=u[0]+u.slice(1).map(f=>O.firstUpper(f)).join(""),i=J.firstLower(i)):(g=u[0],i=H.humpToLine(i)),u.includes("-")){let f=g.split("-");f=f.map(($,T)=>T!=0?O.firstUpper($):$),g=f.join("")}p.push(" @"+i+'="'+g+'"');const a=V(z,i)||{},d=a.selectable||"",S=c.parseParamString(d),y=P(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 i=o;v.includes(o)&&(i=o+"1"),p.push(" :"+o+'="'+i+'"');const u=V(x,o)||{},g=j(u);if(r.push(`// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`),typeof m=="function")r.push("const "+o+" = "+D(m,o,l));else if(b&&(b=!1,r.unshift("import { ref } from 'vue';")),typeof m>"u")if(g.type=="function"){const a=Z(u);r.push("const "+i+" = "+a+";")}else{const a=c.getTypeValue(g.dataType);r.push("const "+i+" = ref("+(a==="undefined"?"":a)+");")}else{let a=F(m,o,l);r.push("const "+i+" = ref("+a+");")}}});const E=Object.values(h||{});E.length>0&&(b&&(b=!1,r.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),r.push("const refDom = ref()"),E.forEach(o=>{const m=V(B,o.name)||{};r.push(`// ${m.description} ${m.name}:(${m.selectable}) ${m.type}`);const i=o.name+"Value",u=c.parseParamString(m?.selectable||""),g=[],a=o.params||[];u.forEach((d,S)=>{const y=d.name;if(y){const f=y+o.name,$=a[S];if(r.push(`// ${d.label}`),typeof $=="function")r.push("const "+f+" = "+D($,y,o.text));else if(typeof $>"u")r.push("const "+f+" = "+c.getTypeValue(d.dataType)+";");else{let T=F($,y,o.text);r.push("const "+f+" = "+T+";")}g.push(f)}}),o.type==="function"?r.push(`const ${i} = refDom.value?.${o.name}(${g.join(", ")})`):r.push(`const ${i} = refDom.value?.${o.name}`),r.push(`console.log('"${m.type}"', ${i})`)})),p.length>0&&p.unshift("");const C=M(s,U);return`<!--${e}-->
|
|
2
2
|
<template>
|
|
3
3
|
<div>
|
|
4
4
|
<${e}${p.join(`
|
|
5
|
-
`)}>${
|
|
5
|
+
`)}>${C.join(`
|
|
6
6
|
`)}
|
|
7
7
|
</${e}>
|
|
8
8
|
</div>
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
${r.join(`
|
|
12
12
|
`)}
|
|
13
13
|
<\/script>
|
|
14
|
-
`}function
|
|
14
|
+
`}function M(e={},t){const n=[];return Object.keys(e).forEach(s=>{const l=V(t,s)||{},h=e[s];if(h){const p=` <!-- ${l.description} ${l.name}:(${l.selectable}) -->
|
|
15
15
|
<template #${s}="scope">
|
|
16
|
-
${c.vueFormat(
|
|
17
|
-
</template>`;n.push(p)}}),n&&n.length>0&&n.unshift(""),n}function D(e,t,n){const s=n?n[t]:"";return s||w(e.toString())}function w(e){const t=
|
|
16
|
+
${c.vueFormat(h," ")}
|
|
17
|
+
</template>`;n.push(p)}}),n&&n.length>0&&n.unshift(""),n}function D(e,t,n){const s=n?n[t]:"";return s||w(e.toString())}function w(e){const t=N.getFunctionFormat(c.prettierFormat(e));if(t){let n=`{
|
|
18
18
|
${c.vueFormat(c.getFunBody(t.body)," ")}
|
|
19
|
-
}`;return`function (${t.param}) ${n}`}else return"undefined"}function
|
|
19
|
+
}`;return`function (${t.param}) ${n}`}else return"undefined"}function Z(e){const t=c.parseParamString(e.selectable),n=P(t);let s="";e.return&&(s="return ");let l=`{
|
|
20
20
|
${c.vueFormat(c.getFunBody(s)," ")}
|
|
21
|
-
}`;return`function (${n}) ${l}`}function
|
|
21
|
+
}`;return`function (${n}) ${l}`}function G(e){const t=e.trim();return/^\(/.test(t)?w(t):JSON.stringify(e)}function F(e,t,n){const s=n?n[t]:"";return s?typeof s=="string"?L(s):s:typeof e=="string"?G(e+""):JSON.stringify(e)}function j(e){let t=I(e?.type),n="any";t.length==1&&(n=t[0].split("<")[0]);const s=n;let l=(e?.selectable||"").trim(),h=[];return l&&n!="boolean"&&(l.includes("|")?l.split("|").forEach(p=>{if(p){let r=p.split(":");h.push({label:p,prop:r[0].trim()})}}):h=c.parseParamString(l),n=="function"?n="function":n=="array"?n="choice":h.length>1&&(n="select")),{arr:h,zdtype:s,type:n,dataType:t}}function I(e){let t=[];return(e||"").trim().toLowerCase().split(",").forEach(s=>{s=s.trim(),s&&t.push(s)}),[...new Set(t)].sort()}function L(e){try{return new Function(`{ return ${e} }`)()}catch{return""+e}}function K(e){const t=j(e),n=c.getTypeValue(t.dataType),s=(e.default||"").trim();return L(s||n)}exports.getDefaultValue=K;exports.getHmtl=A;exports.getSpecType=j;exports.setValStringify=F;
|
|
@@ -3,7 +3,7 @@ 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): any;
|
|
7
7
|
type SelectsObj = {
|
|
8
8
|
label: string;
|
|
9
9
|
prop: unknown;
|
|
@@ -1,91 +1,91 @@
|
|
|
1
1
|
import "@fangzhongya/utils/basic/object/mergeObject";
|
|
2
2
|
import "@fangzhongya/utils/basic/array/toggleArray";
|
|
3
|
-
import { humpToLine as
|
|
3
|
+
import { humpToLine as U } from "@fangzhongya/utils/name/humpToLine";
|
|
4
4
|
import "@fangzhongya/utils/name/lineToLargeHump";
|
|
5
5
|
import "@fangzhongya/utils/basic/string/appearNum";
|
|
6
|
-
import { firstLower as
|
|
6
|
+
import { firstLower as Z } from "@fangzhongya/utils/basic/string/firstLower";
|
|
7
7
|
import "@fangzhongya/utils/basic/array/duplicateRemoval";
|
|
8
8
|
import "@fangzhongya/utils/basic/array/asyncMergeArray";
|
|
9
9
|
import { firstUpper as O } 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 E, parseParamString as j, setDataType as
|
|
13
|
-
import { getPropsValue as
|
|
14
|
-
import { getFunctionFormat as
|
|
15
|
-
const
|
|
12
|
+
import { getTypeValue as E, parseParamString as j, setDataType as q, vueFormat as F, prettierFormat as G, getFunBody as x } from "./util.js";
|
|
13
|
+
import { getPropsValue as I, getEmitsValue as K, getExposeValue as M, getSlotValue as Q } from "../../utils/props.js";
|
|
14
|
+
import { getFunctionFormat as R } from "@fangzhongya/utils/basic/string/toFunction";
|
|
15
|
+
const W = ["class"];
|
|
16
16
|
function S(t, e) {
|
|
17
17
|
return t.filter((n) => n.name == e)[0];
|
|
18
18
|
}
|
|
19
19
|
function z(t) {
|
|
20
|
-
return t.map((e) => (e.prop || "...arr") + ":" +
|
|
20
|
+
return t.map((e) => (e.prop || "...arr") + ":" + q(e.dataType)).join(",");
|
|
21
21
|
}
|
|
22
|
-
function ht(t, e, n, s,
|
|
22
|
+
function ht(t, e, n, s, l, h) {
|
|
23
23
|
const p = [], o = [];
|
|
24
24
|
let y = !0;
|
|
25
|
-
const
|
|
25
|
+
const C = I(e.propss || []), J = K(e.emitss || []), N = M(e.exposes || []), A = Q(e.slots || []);
|
|
26
26
|
Object.keys(n).forEach((r) => {
|
|
27
27
|
let a = n[r];
|
|
28
28
|
if (/^on[A-Z]/.test(r) && typeof a == "function") {
|
|
29
29
|
let i = r.substring(2);
|
|
30
30
|
const c = r.split(":");
|
|
31
31
|
let m;
|
|
32
|
-
if (c.length > 1 ? (m = c[0] + c.slice(1).map((f) => O(f)).join(""), i =
|
|
32
|
+
if (c.length > 1 ? (m = c[0] + c.slice(1).map((f) => O(f)).join(""), i = Z(i)) : (m = c[0], i = U(i)), c.includes("-")) {
|
|
33
33
|
let f = m.split("-");
|
|
34
|
-
f = f.map((
|
|
34
|
+
f = f.map(($, V) => V != 0 ? O($) : $), m = f.join("");
|
|
35
35
|
}
|
|
36
36
|
p.push(" @" + i + '="' + m + '"');
|
|
37
|
-
const
|
|
38
|
-
o.push(`// ${
|
|
39
|
-
const
|
|
40
|
-
o.push(" console.log('" + f.label + "', " +
|
|
37
|
+
const u = S(J, i) || {}, d = u.selectable || "", b = j(d), g = z(b);
|
|
38
|
+
o.push(`// ${u.description} ${u.name}: (${u.selectable})`), o.push("function " + m + "(" + g + ") {"), b.forEach((f) => {
|
|
39
|
+
const $ = f.name || "arr";
|
|
40
|
+
o.push(" console.log('" + f.label + "', " + $ + ")");
|
|
41
41
|
}), o.push("}");
|
|
42
42
|
} else {
|
|
43
43
|
let i = r;
|
|
44
|
-
|
|
45
|
-
const c = S(
|
|
44
|
+
W.includes(r) && (i = r + "1"), p.push(" :" + r + '="' + i + '"');
|
|
45
|
+
const c = S(C, r) || {}, m = P(c);
|
|
46
46
|
if (o.push(
|
|
47
47
|
`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`
|
|
48
48
|
), typeof a == "function")
|
|
49
49
|
o.push(
|
|
50
|
-
"const " + r + " = " + D(a, r,
|
|
50
|
+
"const " + r + " = " + D(a, r, l)
|
|
51
51
|
);
|
|
52
52
|
else if (y && (y = !1, o.unshift("import { ref } from 'vue';")), typeof a > "u")
|
|
53
53
|
if (m.type == "function") {
|
|
54
|
-
const
|
|
55
|
-
o.push("const " + i + " = " +
|
|
54
|
+
const u = Y(c);
|
|
55
|
+
o.push("const " + i + " = " + u + ";");
|
|
56
56
|
} else {
|
|
57
|
-
const
|
|
57
|
+
const u = E(m.dataType);
|
|
58
58
|
o.push(
|
|
59
|
-
"const " + i + " = ref(" + (
|
|
59
|
+
"const " + i + " = ref(" + (u === "undefined" ? "" : u) + ");"
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
let
|
|
64
|
-
o.push("const " + i + " = ref(" +
|
|
63
|
+
let u = w(a, r, l);
|
|
64
|
+
o.push("const " + i + " = ref(" + u + ");");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
-
const T = Object.values(
|
|
68
|
+
const T = Object.values(h || {});
|
|
69
69
|
T.length > 0 && (y && (y = !1, o.unshift("import { ref } from 'vue';")), p.unshift(' ref="refDom"'), o.push("const refDom = ref()"), T.forEach((r) => {
|
|
70
|
-
const a = S(
|
|
70
|
+
const a = S(N, r.name) || {};
|
|
71
71
|
o.push(
|
|
72
72
|
`// ${a.description} ${a.name}:(${a.selectable}) ${a.type}`
|
|
73
73
|
);
|
|
74
|
-
const i = r.name + "Value", c = j(a?.selectable || ""), m = [],
|
|
74
|
+
const i = r.name + "Value", c = j(a?.selectable || ""), m = [], u = r.params || [];
|
|
75
75
|
c.forEach((d, b) => {
|
|
76
76
|
const g = d.name;
|
|
77
77
|
if (g) {
|
|
78
|
-
const f = g + r.name,
|
|
79
|
-
if (o.push(`// ${d.label}`), typeof
|
|
78
|
+
const f = g + r.name, $ = u[b];
|
|
79
|
+
if (o.push(`// ${d.label}`), typeof $ == "function")
|
|
80
80
|
o.push(
|
|
81
|
-
"const " + f + " = " + D(
|
|
81
|
+
"const " + f + " = " + D($, g, r.text)
|
|
82
82
|
);
|
|
83
|
-
else if (typeof
|
|
83
|
+
else if (typeof $ > "u")
|
|
84
84
|
o.push(
|
|
85
85
|
"const " + f + " = " + E(d.dataType) + ";"
|
|
86
86
|
);
|
|
87
87
|
else {
|
|
88
|
-
let V = w(
|
|
88
|
+
let V = w($, g, r.text);
|
|
89
89
|
o.push("const " + f + " = " + V + ";");
|
|
90
90
|
}
|
|
91
91
|
m.push(f);
|
|
@@ -94,12 +94,12 @@ function ht(t, e, n, s, u, $) {
|
|
|
94
94
|
`const ${i} = refDom.value?.${r.name}(${m.join(", ")})`
|
|
95
95
|
) : o.push(`const ${i} = refDom.value?.${r.name}`), o.push(`console.log('"${a.type}"', ${i})`);
|
|
96
96
|
})), p.length > 0 && p.unshift("");
|
|
97
|
-
const
|
|
97
|
+
const H = X(s, A);
|
|
98
98
|
return `<!--${t}-->
|
|
99
99
|
<template>
|
|
100
100
|
<div>
|
|
101
101
|
<${t}${p.join(`
|
|
102
|
-
`)}>${
|
|
102
|
+
`)}>${H.join(`
|
|
103
103
|
`)}
|
|
104
104
|
</${t}>
|
|
105
105
|
</div>
|
|
@@ -110,14 +110,14 @@ ${o.join(`
|
|
|
110
110
|
<\/script>
|
|
111
111
|
`;
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function X(t = {}, e) {
|
|
114
114
|
const n = [];
|
|
115
115
|
return Object.keys(t).forEach((s) => {
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const p = ` <!-- ${
|
|
116
|
+
const l = S(e, s) || {}, h = t[s];
|
|
117
|
+
if (h) {
|
|
118
|
+
const p = ` <!-- ${l.description} ${l.name}:(${l.selectable}) -->
|
|
119
119
|
<template #${s}="scope">
|
|
120
|
-
${F(
|
|
120
|
+
${F(h, " ")}
|
|
121
121
|
</template>`;
|
|
122
122
|
n.push(p);
|
|
123
123
|
}
|
|
@@ -128,7 +128,7 @@ function D(t, e, n) {
|
|
|
128
128
|
return s || L(t.toString());
|
|
129
129
|
}
|
|
130
130
|
function L(t) {
|
|
131
|
-
const e =
|
|
131
|
+
const e = R(G(t));
|
|
132
132
|
if (e) {
|
|
133
133
|
let n = `{
|
|
134
134
|
${F(x(e.body), " ")}
|
|
@@ -137,50 +137,50 @@ ${F(x(e.body), " ")}
|
|
|
137
137
|
} else
|
|
138
138
|
return "undefined";
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function Y(t) {
|
|
141
141
|
const e = j(t.selectable), n = z(e);
|
|
142
142
|
let s = "";
|
|
143
143
|
t.return && (s = "return ");
|
|
144
|
-
let
|
|
144
|
+
let l = `{
|
|
145
145
|
${F(x(s), " ")}
|
|
146
146
|
}`;
|
|
147
|
-
return `function (${n}) ${
|
|
147
|
+
return `function (${n}) ${l}`;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function _(t) {
|
|
150
150
|
const e = t.trim();
|
|
151
151
|
return /^\(/.test(e) ? L(e) : JSON.stringify(t);
|
|
152
152
|
}
|
|
153
153
|
function w(t, e, n) {
|
|
154
154
|
const s = n ? n[e] : "";
|
|
155
|
-
return s
|
|
155
|
+
return s ? typeof s == "string" ? B(s) : s : typeof t == "string" ? _(t + "") : JSON.stringify(t);
|
|
156
156
|
}
|
|
157
157
|
function P(t) {
|
|
158
|
-
let e =
|
|
158
|
+
let e = v(t?.type), n = "any";
|
|
159
159
|
e.length == 1 && (n = e[0].split("<")[0]);
|
|
160
160
|
const s = n;
|
|
161
|
-
let
|
|
162
|
-
return
|
|
161
|
+
let l = (t?.selectable || "").trim(), h = [];
|
|
162
|
+
return l && n != "boolean" && (l.includes("|") ? l.split("|").forEach((p) => {
|
|
163
163
|
if (p) {
|
|
164
164
|
let o = p.split(":");
|
|
165
|
-
|
|
165
|
+
h.push({
|
|
166
166
|
label: p,
|
|
167
167
|
prop: o[0].trim()
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
|
-
}) :
|
|
171
|
-
arr:
|
|
170
|
+
}) : h = j(l), n == "function" ? n = "function" : n == "array" ? n = "choice" : h.length > 1 && (n = "select")), {
|
|
171
|
+
arr: h,
|
|
172
172
|
zdtype: s,
|
|
173
173
|
type: n,
|
|
174
174
|
dataType: e
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function v(t) {
|
|
178
178
|
let e = [];
|
|
179
179
|
return (t || "").trim().toLowerCase().split(",").forEach((s) => {
|
|
180
180
|
s = s.trim(), s && e.push(s);
|
|
181
181
|
}), [...new Set(e)].sort();
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function B(t) {
|
|
184
184
|
try {
|
|
185
185
|
return new Function(`{ return ${t} }`)();
|
|
186
186
|
} catch {
|
|
@@ -189,7 +189,7 @@ function v(t) {
|
|
|
189
189
|
}
|
|
190
190
|
function $t(t) {
|
|
191
191
|
const e = P(t), n = E(e.dataType), s = (t.default || "").trim();
|
|
192
|
-
return
|
|
192
|
+
return B(s || n);
|
|
193
193
|
}
|
|
194
194
|
export {
|
|
195
195
|
$t as getDefaultValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("vue"),V=require("./retrie/index.vue.cjs");;/* empty css */const T=require("./code.cjs"),k={key:0,class:"set-props"},q=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(
|
|
1
|
+
"use strict";const s=require("vue"),V=require("./retrie/index.vue.cjs");;/* empty css */const T=require("./code.cjs"),k={key:0,class:"set-props"},q=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(o,{emit:i}){const l=o,p=i,u=s.ref({}),m=s.ref(0),c=s.ref({}),n=s.ref([]);function f(){c.value={};const r=[];l.list?.forEach(t=>{let e=t.name;if(e.includes(".")?e="":e=(e.split("/")[0]||"").trim(),e){c.value[e]=(t.default||"").trim();const{arr:y,type:v,dataType:b}=T.getSpecType(t);u.value[e]=y;let g={label:d(e,t),prop:e,type:v,dataType:b,select:e};r.push(g)}}),n.value=r}function d(r,t){let e=r+": { "+(t.type||"any")+" } "+t.description;return t.default&&(e+=" 默认值="+t.default),t.selectable&&(e+=" 可选值="+t.selectable),e}function _(r,t){let e=Object.assign({},r);p("change",e,t)}let a;function h(){clearTimeout(a),a=setTimeout(()=>{f()},400)}return s.watch(()=>l.name,()=>{n.value=[],s.nextTick(()=>{h()})},{immediate:!0}),(r,t)=>n.value&&n.value.length>0?(s.openBlock(),s.createElementBlock("div",k,[s.createVNode(V,{refresh:m.value,modelValue:c.value,selects:u.value,list:n.value,name:l.name,onQuery:_},null,8,["refresh","modelValue","selects","list","name"])])):s.createCommentVNode("",!0)}});module.exports=q;
|
|
@@ -12,19 +12,19 @@ const S = {
|
|
|
12
12
|
list: Array
|
|
13
13
|
},
|
|
14
14
|
emits: ["change"],
|
|
15
|
-
setup(
|
|
16
|
-
const r =
|
|
17
|
-
function
|
|
15
|
+
setup(i, { emit: u }) {
|
|
16
|
+
const r = i, m = u, o = n({}), p = n(0), a = n({}), l = n([]);
|
|
17
|
+
function f() {
|
|
18
18
|
a.value = {};
|
|
19
19
|
const s = [];
|
|
20
20
|
r.list?.forEach((t) => {
|
|
21
21
|
let e = t.name;
|
|
22
22
|
if (e.includes(".") ? e = "" : e = (e.split("/")[0] || "").trim(), e) {
|
|
23
23
|
a.value[e] = (t.default || "").trim();
|
|
24
|
-
const { arr:
|
|
25
|
-
|
|
24
|
+
const { arr: y, type: b, dataType: g } = N(t);
|
|
25
|
+
o.value[e] = y;
|
|
26
26
|
let V = {
|
|
27
|
-
label:
|
|
27
|
+
label: d(e, t),
|
|
28
28
|
prop: e,
|
|
29
29
|
type: b,
|
|
30
30
|
dataType: g,
|
|
@@ -34,25 +34,25 @@ const S = {
|
|
|
34
34
|
}
|
|
35
35
|
}), l.value = s;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function d(s, t) {
|
|
38
38
|
let e = s + ": { " + (t.type || "any") + " } " + t.description;
|
|
39
39
|
return t.default && (e += " 默认值=" + t.default), t.selectable && (e += " 可选值=" + t.selectable), e;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function h(s, t) {
|
|
42
42
|
let e = Object.assign({}, s);
|
|
43
|
-
|
|
43
|
+
m("change", e, t);
|
|
44
44
|
}
|
|
45
45
|
let c;
|
|
46
|
-
function
|
|
46
|
+
function _() {
|
|
47
47
|
clearTimeout(c), c = setTimeout(() => {
|
|
48
|
-
|
|
48
|
+
f();
|
|
49
49
|
}, 400);
|
|
50
50
|
}
|
|
51
51
|
return T(
|
|
52
52
|
() => r.name,
|
|
53
53
|
() => {
|
|
54
54
|
l.value = [], k(() => {
|
|
55
|
-
|
|
55
|
+
_();
|
|
56
56
|
});
|
|
57
57
|
},
|
|
58
58
|
{
|
|
@@ -60,12 +60,12 @@ const S = {
|
|
|
60
60
|
}
|
|
61
61
|
), (s, t) => l.value && l.value.length > 0 ? (B(), x("div", S, [
|
|
62
62
|
C(E, {
|
|
63
|
-
refresh:
|
|
63
|
+
refresh: p.value,
|
|
64
64
|
modelValue: a.value,
|
|
65
65
|
selects: o.value,
|
|
66
66
|
list: l.value,
|
|
67
67
|
name: r.name,
|
|
68
|
-
onQuery:
|
|
68
|
+
onQuery: h
|
|
69
69
|
}, null, 8, ["refresh", "modelValue", "selects", "list", "name"])
|
|
70
70
|
])) : j("", !0);
|
|
71
71
|
}
|