@fangzhongya/vue-archive 0.0.35 → 0.0.36

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.
@@ -3531,6 +3531,19 @@ function getType(value) {
3531
3531
  });
3532
3532
  return [...new Set(arr)].sort();
3533
3533
  }
3534
+ function getObjValue(d) {
3535
+ try {
3536
+ return new Function(`{ return ${d} }`)();
3537
+ } catch (error) {
3538
+ return "" + d;
3539
+ }
3540
+ }
3541
+ function getDefaultValue(obj) {
3542
+ const vo = getSpecType(obj);
3543
+ const v = getTypeValue(vo.dataType);
3544
+ const d = (obj.default || "").trim();
3545
+ return getObjValue(d || v);
3546
+ }
3534
3547
 
3535
3548
  // packages/components/compo/index.ts
3536
3549
  var notesObj = {
@@ -3986,19 +3999,6 @@ function gettests(obj, arr, n) {
3986
3999
  }
3987
4000
  }
3988
4001
  }
3989
- function getObjValue(d) {
3990
- try {
3991
- return new Function(`{ return ${d} }`)();
3992
- } catch (error) {
3993
- return "" + d;
3994
- }
3995
- }
3996
- function getDefaultValue(obj) {
3997
- const vo = getSpecType(obj);
3998
- const v = getTypeValue(vo.dataType);
3999
- const d = (obj.default || "").trim();
4000
- return getObjValue(d || v);
4001
- }
4002
4002
  function setVue(propsname, param, url) {
4003
4003
  const ps = getPropsValue2(param.propss || []);
4004
4004
  const es = getEmitsValue(param.emitss || []);
@@ -3516,6 +3516,19 @@ function getType(value) {
3516
3516
  });
3517
3517
  return [...new Set(arr)].sort();
3518
3518
  }
3519
+ function getObjValue(d) {
3520
+ try {
3521
+ return new Function(`{ return ${d} }`)();
3522
+ } catch (error) {
3523
+ return "" + d;
3524
+ }
3525
+ }
3526
+ function getDefaultValue(obj) {
3527
+ const vo = getSpecType(obj);
3528
+ const v = getTypeValue(vo.dataType);
3529
+ const d = (obj.default || "").trim();
3530
+ return getObjValue(d || v);
3531
+ }
3519
3532
 
3520
3533
  // packages/components/compo/index.ts
3521
3534
  var notesObj = {
@@ -3971,19 +3984,6 @@ function gettests(obj, arr, n) {
3971
3984
  }
3972
3985
  }
3973
3986
  }
3974
- function getObjValue(d) {
3975
- try {
3976
- return new Function(`{ return ${d} }`)();
3977
- } catch (error) {
3978
- return "" + d;
3979
- }
3980
- }
3981
- function getDefaultValue(obj) {
3982
- const vo = getSpecType(obj);
3983
- const v = getTypeValue(vo.dataType);
3984
- const d = (obj.default || "").trim();
3985
- return getObjValue(d || v);
3986
- }
3987
3987
  function setVue(propsname, param, url) {
3988
3988
  const ps = getPropsValue2(param.propss || []);
3989
3989
  const es = getEmitsValue(param.emitss || []);
@@ -1,21 +1,21 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const C=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 E=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const f=require("./util.cjs"),q=require("../../utils/props.cjs"),J=require("@fangzhongya/utils/basic/string/toFunction"),N=["class"];function j(s,t){return s.filter(e=>e.name==t)[0]}function P(s){return s.map(t=>(t.prop||"...arr")+":"+f.setDataType(t.dataType)).join(",")}function A(s,t,e,o,u,$){const p=[],n=[];let b=!0;const L=q.getPropsValue(t.propss||[]),x=q.getEmitsValue(t.emitss||[]),z=q.getExposeValue(t.exposes||[]),B=q.getSlotValue(t.slots||[]);Object.keys(e).forEach(r=>{let m=e[r];if(/^on[A-Z]/.test(r)&&typeof m=="function"){let i=r.substring(2);const c=r.split(":");let h;if(c.length>1?(h=c[0]+c.slice(1).map(a=>E.firstUpper(a)).join(""),i=H.firstLower(i)):(h=c[0],i=C.humpToLine(i)),c.includes("-")){let a=h.split("-");a=a.map((g,F)=>F!=0?E.firstUpper(g):g),h=a.join("")}p.push(" @"+i+'="'+h+'"');const l=j(x,i)||{},y=l.selectable||"",S=f.parseParamString(y),d=P(S);n.push(`// ${l.description} ${l.name}: (${l.selectable})`),n.push("function "+h+"("+d+") {"),S.forEach(a=>{const g=a.name||"arr";n.push(" console.log('"+a.label+"', "+g+")")}),n.push("}")}else{let i=r;N.includes(r)&&(i=r+"1"),p.push(" :"+r+'="'+i+'"');const c=j(L,r)||{},h=D(c);if(n.push(`// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`),typeof m=="function")n.push("const "+r+" = "+O(m,r,u));else if(b&&(b=!1,n.unshift("import { ref } from 'vue';")),typeof m>"u")if(h.type=="function"){const l=Z(c);n.push("const "+i+" = "+l+";")}else{const l=f.getTypeValue(h.dataType);n.push("const "+i+" = ref("+(l==="undefined"?"":l)+");")}else{let l=T(m,r,u);n.push("const "+i+" = ref("+l+");")}}});const V=Object.values($||{});V.length>0&&(b&&(b=!1,n.unshift("import { ref } from 'vue';")),p.unshift(' ref="refDom"'),n.push("const refDom = ref()"),V.forEach(r=>{const m=j(z,r.name)||{};n.push(`// ${m.description} ${m.name}:(${m.selectable}) ${m.type}`);const i=r.name+"Value",c=f.parseParamString(m?.selectable||""),h=[],l=r.params||[];c.forEach((y,S)=>{const d=y.name;if(d){const a=d+r.name,g=l[S];if(n.push(`// ${y.label}`),typeof g=="function")n.push("const "+a+" = "+O(g,d,r.text));else if(typeof g>"u")n.push("const "+a+" = "+f.getTypeValue(y.dataType)+";");else{let F=T(g,d,r.text);n.push("const "+a+" = "+F+";")}h.push(a)}}),r.type==="function"?n.push(`const ${i} = refDom.value?.${r.name}(${h.join(", ")})`):n.push(`const ${i} = refDom.value?.${r.name}`),n.push(`console.log('"${m.type}"', ${i})`)})),p.length>0&&p.unshift("");const U=M(o,B);return`<!--${s}-->
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@fangzhongya/utils/basic/object/mergeObject");require("@fangzhongya/utils/basic/array/toggleArray");const C=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 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"),J=require("@fangzhongya/utils/basic/string/toFunction"),N=["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 v(e,t,n,s,l,$){const p=[],r=[];let b=!0;const L=q.getPropsValue(t.propss||[]),x=q.getEmitsValue(t.emitss||[]),z=q.getExposeValue(t.exposes||[]),B=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=H.firstLower(i)):(g=u[0],i=C.humpToLine(i)),u.includes("-")){let f=g.split("-");f=f.map((h,T)=>T!=0?O.firstUpper(h):h),g=f.join("")}p.push(" @"+i+'="'+g+'"');const a=V(x,i)||{},y=a.selectable||"",S=c.parseParamString(y),d=P(S);r.push(`// ${a.description} ${a.name}: (${a.selectable})`),r.push("function "+g+"("+d+") {"),S.forEach(f=>{const h=f.name||"arr";r.push(" console.log('"+f.label+"', "+h+")")}),r.push("}")}else{let i=o;N.includes(o)&&(i=o+"1"),p.push(" :"+o+'="'+i+'"');const u=V(L,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=M(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($||{});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(z,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((y,S)=>{const d=y.name;if(d){const f=d+o.name,h=a[S];if(r.push(`// ${y.label}`),typeof h=="function")r.push("const "+f+" = "+D(h,d,o.text));else if(typeof h>"u")r.push("const "+f+" = "+c.getTypeValue(y.dataType)+";");else{let T=F(h,d,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 U=A(s,B);return`<!--${e}-->
2
2
  <template>
3
3
  <div>
4
- <${s}${p.join(`
4
+ <${e}${p.join(`
5
5
  `)}>${U.join(`
6
6
  `)}
7
- </${s}>
7
+ </${e}>
8
8
  </div>
9
9
  </template>
10
10
  <script lang="ts" setup>
11
- ${n.join(`
11
+ ${r.join(`
12
12
  `)}
13
13
  <\/script>
14
- `}function M(s={},t){const e=[];return Object.keys(s).forEach(o=>{const u=j(t,o)||{},$=s[o];if($){const p=` <!-- ${u.description} ${u.name}:(${u.selectable}) -->
15
- <template #${o}="scope">
16
- ${f.vueFormat($," ")}
17
- </template>`;e.push(p)}}),e&&e.length>0&&e.unshift(""),e}function O(s,t,e){const o=e?e[t]:"";return o||w(s.toString())}function w(s){const t=J.getFunctionFormat(f.prettierFormat(s));if(t){let e=`{
18
- ${f.vueFormat(f.getFunBody(t.body)," ")}
19
- }`;return`function (${t.param}) ${e}`}else return"undefined"}function Z(s){const t=f.parseParamString(s.selectable),e=P(t);let o="";s.return&&(o="return ");let u=`{
20
- ${f.vueFormat(f.getFunBody(o)," ")}
21
- }`;return`function (${e}) ${u}`}function G(s){const t=s.trim();return/^\(/.test(t)?w(t):JSON.stringify(s)}function T(s,t,e){const o=e?e[t]:"";return o||(typeof s=="string"?G(s+""):JSON.stringify(s))}function D(s){let t=I(s?.type),e="any";t.length==1&&(e=t[0].split("<")[0]);const o=e;let u=(s?.selectable||"").trim(),$=[];return u&&e!="boolean"&&(u.includes("|")?u.split("|").forEach(p=>{if(p){let n=p.split(":");$.push({label:p,prop:n[0].trim()})}}):$=f.parseParamString(u),e=="function"?e="function":e=="array"?e="choice":e="select"),{arr:$,zdtype:o,type:e,dataType:t}}function I(s){let t=[];return(s||"").trim().toLowerCase().split(",").forEach(o=>{o=o.trim(),o&&t.push(o)}),[...new Set(t)].sort()}exports.getHmtl=A;exports.getSpecType=D;exports.setValStringify=T;
14
+ `}function A(e={},t){const n=[];return Object.keys(e).forEach(s=>{const l=V(t,s)||{},$=e[s];if($){const p=` <!-- ${l.description} ${l.name}:(${l.selectable}) -->
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=J.getFunctionFormat(c.prettierFormat(e));if(t){let n=`{
18
+ ${c.vueFormat(c.getFunBody(t.body)," ")}
19
+ }`;return`function (${t.param}) ${n}`}else return"undefined"}function M(e){const t=c.parseParamString(e.selectable),n=P(t);let s="";e.return&&(s="return ");let l=`{
20
+ ${c.vueFormat(c.getFunBody(s)," ")}
21
+ }`;return`function (${n}) ${l}`}function Z(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 e=="string"?Z(e+""):JSON.stringify(e))}function j(e){let t=G(e?.type),n="any";t.length==1&&(n=t[0].split("<")[0]);const s=n;let l=(e?.selectable||"").trim(),$=[];return l&&n!="boolean"&&(l.includes("|")?l.split("|").forEach(p=>{if(p){let r=p.split(":");$.push({label:p,prop:r[0].trim()})}}):$=c.parseParamString(l),n=="function"?n="function":n=="array"?n="choice":n="select"),{arr:$,zdtype:s,type:n,dataType:t}}function G(e){let t=[];return(e||"").trim().toLowerCase().split(",").forEach(s=>{s=s.trim(),s&&t.push(s)}),[...new Set(t)].sort()}function I(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 I(s||n)}exports.getDefaultValue=K;exports.getHmtl=v;exports.getSpecType=j;exports.setValStringify=F;
@@ -14,4 +14,5 @@ export declare function getSpecType(val: Spec): {
14
14
  type: string;
15
15
  dataType: string[];
16
16
  };
17
+ export declare function getDefaultValue(obj: Spec): any;
17
18
  export {};
@@ -1,187 +1,199 @@
1
1
  import "@fangzhongya/utils/basic/object/mergeObject";
2
2
  import "@fangzhongya/utils/basic/array/toggleArray";
3
- import { humpToLine as A } from "@fangzhongya/utils/name/humpToLine";
3
+ import { humpToLine as H } from "@fangzhongya/utils/name/humpToLine";
4
4
  import "@fangzhongya/utils/name/lineToLargeHump";
5
5
  import "@fangzhongya/utils/basic/string/appearNum";
6
- import { firstLower as H } from "@fangzhongya/utils/basic/string/firstLower";
6
+ import { firstLower as U } from "@fangzhongya/utils/basic/string/firstLower";
7
7
  import "@fangzhongya/utils/basic/array/duplicateRemoval";
8
8
  import "@fangzhongya/utils/basic/array/asyncMergeArray";
9
- import { firstUpper as T } from "@fangzhongya/utils/basic/string/firstUpper";
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 { parseParamString as j, getTypeValue as O, setDataType as U, vueFormat as V, prettierFormat as Z, getFunBody as x } from "./util.js";
13
- import { getPropsValue as q, getEmitsValue as G, getExposeValue as I, getSlotValue as K } from "../../utils/props.js";
14
- import { getFunctionFormat as M } from "@fangzhongya/utils/basic/string/toFunction";
15
- const Q = ["class"];
16
- function S(s, e) {
17
- return s.filter((t) => t.name == e)[0];
12
+ import { getTypeValue as E, parseParamString as j, setDataType as Z, vueFormat as F, prettierFormat as q, getFunBody as x } from "./util.js";
13
+ import { getPropsValue as G, getEmitsValue as I, getExposeValue as K, getSlotValue as M } from "../../utils/props.js";
14
+ import { getFunctionFormat as Q } from "@fangzhongya/utils/basic/string/toFunction";
15
+ const R = ["class"];
16
+ function S(t, e) {
17
+ return t.filter((n) => n.name == e)[0];
18
18
  }
19
- function z(s) {
20
- return s.map((e) => (e.prop || "...arr") + ":" + U(e.dataType)).join(",");
19
+ function z(t) {
20
+ return t.map((e) => (e.prop || "...arr") + ":" + Z(e.dataType)).join(",");
21
21
  }
22
- function mt(s, e, t, r, l, $) {
23
- const p = [], n = [];
22
+ function ht(t, e, n, s, u, $) {
23
+ const p = [], o = [];
24
24
  let y = !0;
25
- const P = q(e.propss || []), B = G(e.emitss || []), C = I(e.exposes || []), J = K(e.slots || []);
26
- Object.keys(t).forEach((o) => {
27
- let a = t[o];
28
- if (/^on[A-Z]/.test(o) && typeof a == "function") {
29
- let i = o.substring(2);
30
- const c = o.split(":");
25
+ const B = G(e.propss || []), C = I(e.emitss || []), J = K(e.exposes || []), N = M(e.slots || []);
26
+ Object.keys(n).forEach((r) => {
27
+ let a = n[r];
28
+ if (/^on[A-Z]/.test(r) && typeof a == "function") {
29
+ let i = r.substring(2);
30
+ const c = r.split(":");
31
31
  let m;
32
- if (c.length > 1 ? (m = c[0] + c.slice(1).map((u) => T(u)).join(""), i = H(i)) : (m = c[0], i = A(i)), c.includes("-")) {
33
- let u = m.split("-");
34
- u = u.map((h, E) => E != 0 ? T(h) : h), m = u.join("");
32
+ if (c.length > 1 ? (m = c[0] + c.slice(1).map((f) => O(f)).join(""), i = U(i)) : (m = c[0], i = H(i)), c.includes("-")) {
33
+ let f = m.split("-");
34
+ f = f.map((h, V) => V != 0 ? O(h) : h), m = f.join("");
35
35
  }
36
36
  p.push(" @" + i + '="' + m + '"');
37
- const f = S(B, i) || {}, d = f.selectable || "", b = j(d), g = z(b);
38
- n.push(`// ${f.description} ${f.name}: (${f.selectable})`), n.push("function " + m + "(" + g + ") {"), b.forEach((u) => {
39
- const h = u.name || "arr";
40
- n.push(" console.log('" + u.label + "', " + h + ")");
41
- }), n.push("}");
37
+ const l = S(C, i) || {}, d = l.selectable || "", b = j(d), g = z(b);
38
+ o.push(`// ${l.description} ${l.name}: (${l.selectable})`), o.push("function " + m + "(" + g + ") {"), b.forEach((f) => {
39
+ const h = f.name || "arr";
40
+ o.push(" console.log('" + f.label + "', " + h + ")");
41
+ }), o.push("}");
42
42
  } else {
43
- let i = o;
44
- Q.includes(o) && (i = o + "1"), p.push(" :" + o + '="' + i + '"');
45
- const c = S(P, o) || {}, m = Y(c);
46
- if (n.push(
43
+ let i = r;
44
+ R.includes(r) && (i = r + "1"), p.push(" :" + r + '="' + i + '"');
45
+ const c = S(B, r) || {}, m = P(c);
46
+ if (o.push(
47
47
  `// ${c.description} ${c.name}: {${c.type}} (${c.selectable})`
48
48
  ), typeof a == "function")
49
- n.push(
50
- "const " + o + " = " + D(a, o, l)
49
+ o.push(
50
+ "const " + r + " = " + D(a, r, u)
51
51
  );
52
- else if (y && (y = !1, n.unshift("import { ref } from 'vue';")), typeof a > "u")
52
+ else if (y && (y = !1, o.unshift("import { ref } from 'vue';")), typeof a > "u")
53
53
  if (m.type == "function") {
54
- const f = W(c);
55
- n.push("const " + i + " = " + f + ";");
54
+ const l = X(c);
55
+ o.push("const " + i + " = " + l + ";");
56
56
  } else {
57
- const f = O(m.dataType);
58
- n.push(
59
- "const " + i + " = ref(" + (f === "undefined" ? "" : f) + ");"
57
+ const l = E(m.dataType);
58
+ o.push(
59
+ "const " + i + " = ref(" + (l === "undefined" ? "" : l) + ");"
60
60
  );
61
61
  }
62
62
  else {
63
- let f = w(a, o, l);
64
- n.push("const " + i + " = ref(" + f + ");");
63
+ let l = w(a, r, u);
64
+ o.push("const " + i + " = ref(" + l + ");");
65
65
  }
66
66
  }
67
67
  });
68
- const F = Object.values($ || {});
69
- F.length > 0 && (y && (y = !1, n.unshift("import { ref } from 'vue';")), p.unshift(' ref="refDom"'), n.push("const refDom = ref()"), F.forEach((o) => {
70
- const a = S(C, o.name) || {};
71
- n.push(
68
+ const T = Object.values($ || {});
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(J, r.name) || {};
71
+ o.push(
72
72
  `// ${a.description} ${a.name}:(${a.selectable}) ${a.type}`
73
73
  );
74
- const i = o.name + "Value", c = j(a?.selectable || ""), m = [], f = o.params || [];
74
+ const i = r.name + "Value", c = j(a?.selectable || ""), m = [], l = r.params || [];
75
75
  c.forEach((d, b) => {
76
76
  const g = d.name;
77
77
  if (g) {
78
- const u = g + o.name, h = f[b];
79
- if (n.push(`// ${d.label}`), typeof h == "function")
80
- n.push(
81
- "const " + u + " = " + D(h, g, o.text)
78
+ const f = g + r.name, h = l[b];
79
+ if (o.push(`// ${d.label}`), typeof h == "function")
80
+ o.push(
81
+ "const " + f + " = " + D(h, g, r.text)
82
82
  );
83
83
  else if (typeof h > "u")
84
- n.push(
85
- "const " + u + " = " + O(d.dataType) + ";"
84
+ o.push(
85
+ "const " + f + " = " + E(d.dataType) + ";"
86
86
  );
87
87
  else {
88
- let E = w(h, g, o.text);
89
- n.push("const " + u + " = " + E + ";");
88
+ let V = w(h, g, r.text);
89
+ o.push("const " + f + " = " + V + ";");
90
90
  }
91
- m.push(u);
91
+ m.push(f);
92
92
  }
93
- }), o.type === "function" ? n.push(
94
- `const ${i} = refDom.value?.${o.name}(${m.join(", ")})`
95
- ) : n.push(`const ${i} = refDom.value?.${o.name}`), n.push(`console.log('"${a.type}"', ${i})`);
93
+ }), r.type === "function" ? o.push(
94
+ `const ${i} = refDom.value?.${r.name}(${m.join(", ")})`
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 N = R(r, J);
98
- return `<!--${s}-->
97
+ const A = W(s, N);
98
+ return `<!--${t}-->
99
99
  <template>
100
100
  <div>
101
- <${s}${p.join(`
102
- `)}>${N.join(`
101
+ <${t}${p.join(`
102
+ `)}>${A.join(`
103
103
  `)}
104
- </${s}>
104
+ </${t}>
105
105
  </div>
106
106
  </template>
107
107
  <script lang="ts" setup>
108
- ${n.join(`
108
+ ${o.join(`
109
109
  `)}
110
110
  <\/script>
111
111
  `;
112
112
  }
113
- function R(s = {}, e) {
114
- const t = [];
115
- return Object.keys(s).forEach((r) => {
116
- const l = S(e, r) || {}, $ = s[r];
113
+ function W(t = {}, e) {
114
+ const n = [];
115
+ return Object.keys(t).forEach((s) => {
116
+ const u = S(e, s) || {}, $ = t[s];
117
117
  if ($) {
118
- const p = ` <!-- ${l.description} ${l.name}:(${l.selectable}) -->
119
- <template #${r}="scope">
120
- ${V($, " ")}
118
+ const p = ` <!-- ${u.description} ${u.name}:(${u.selectable}) -->
119
+ <template #${s}="scope">
120
+ ${F($, " ")}
121
121
  </template>`;
122
- t.push(p);
122
+ n.push(p);
123
123
  }
124
- }), t && t.length > 0 && t.unshift(""), t;
124
+ }), n && n.length > 0 && n.unshift(""), n;
125
125
  }
126
- function D(s, e, t) {
127
- const r = t ? t[e] : "";
128
- return r || L(s.toString());
126
+ function D(t, e, n) {
127
+ const s = n ? n[e] : "";
128
+ return s || L(t.toString());
129
129
  }
130
- function L(s) {
131
- const e = M(Z(s));
130
+ function L(t) {
131
+ const e = Q(q(t));
132
132
  if (e) {
133
- let t = `{
134
- ${V(x(e.body), " ")}
133
+ let n = `{
134
+ ${F(x(e.body), " ")}
135
135
  }`;
136
- return `function (${e.param}) ${t}`;
136
+ return `function (${e.param}) ${n}`;
137
137
  } else
138
138
  return "undefined";
139
139
  }
140
- function W(s) {
141
- const e = j(s.selectable), t = z(e);
142
- let r = "";
143
- s.return && (r = "return ");
144
- let l = `{
145
- ${V(x(r), " ")}
140
+ function X(t) {
141
+ const e = j(t.selectable), n = z(e);
142
+ let s = "";
143
+ t.return && (s = "return ");
144
+ let u = `{
145
+ ${F(x(s), " ")}
146
146
  }`;
147
- return `function (${t}) ${l}`;
147
+ return `function (${n}) ${u}`;
148
148
  }
149
- function X(s) {
150
- const e = s.trim();
151
- return /^\(/.test(e) ? L(e) : JSON.stringify(s);
149
+ function Y(t) {
150
+ const e = t.trim();
151
+ return /^\(/.test(e) ? L(e) : JSON.stringify(t);
152
152
  }
153
- function w(s, e, t) {
154
- const r = t ? t[e] : "";
155
- return r || (typeof s == "string" ? X(s + "") : JSON.stringify(s));
153
+ function w(t, e, n) {
154
+ const s = n ? n[e] : "";
155
+ return s || (typeof t == "string" ? Y(t + "") : JSON.stringify(t));
156
156
  }
157
- function Y(s) {
158
- let e = _(s?.type), t = "any";
159
- e.length == 1 && (t = e[0].split("<")[0]);
160
- const r = t;
161
- let l = (s?.selectable || "").trim(), $ = [];
162
- return l && t != "boolean" && (l.includes("|") ? l.split("|").forEach((p) => {
157
+ function P(t) {
158
+ let e = _(t?.type), n = "any";
159
+ e.length == 1 && (n = e[0].split("<")[0]);
160
+ const s = n;
161
+ let u = (t?.selectable || "").trim(), $ = [];
162
+ return u && n != "boolean" && (u.includes("|") ? u.split("|").forEach((p) => {
163
163
  if (p) {
164
- let n = p.split(":");
164
+ let o = p.split(":");
165
165
  $.push({
166
166
  label: p,
167
- prop: n[0].trim()
167
+ prop: o[0].trim()
168
168
  });
169
169
  }
170
- }) : $ = j(l), t == "function" ? t = "function" : t == "array" ? t = "choice" : t = "select"), {
170
+ }) : $ = j(u), n == "function" ? n = "function" : n == "array" ? n = "choice" : n = "select"), {
171
171
  arr: $,
172
- zdtype: r,
173
- type: t,
172
+ zdtype: s,
173
+ type: n,
174
174
  dataType: e
175
175
  };
176
176
  }
177
- function _(s) {
177
+ function _(t) {
178
178
  let e = [];
179
- return (s || "").trim().toLowerCase().split(",").forEach((r) => {
180
- r = r.trim(), r && e.push(r);
179
+ return (t || "").trim().toLowerCase().split(",").forEach((s) => {
180
+ s = s.trim(), s && e.push(s);
181
181
  }), [...new Set(e)].sort();
182
182
  }
183
+ function v(t) {
184
+ try {
185
+ return new Function(`{ return ${t} }`)();
186
+ } catch {
187
+ return "" + t;
188
+ }
189
+ }
190
+ function $t(t) {
191
+ const e = P(t), n = E(e.dataType), s = (t.default || "").trim();
192
+ return v(s || n);
193
+ }
183
194
  export {
184
- mt as getHmtl,
185
- Y as getSpecType,
195
+ $t as getDefaultValue,
196
+ ht as getHmtl,
197
+ P as getSpecType,
186
198
  w as setValStringify
187
199
  };
@@ -1 +1 @@
1
- "use strict";const s=require("vue"),g=require("./set-props.vue.cjs"),y=require("./set-emit.vue.cjs");;/* empty css */const T=require("./set-code.vue.cjs"),C=require("./set-expose.vue.cjs");;/* empty css */const b=require("./set-slot.vue.cjs"),l=require("../../utils/props.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");const x=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const E=s.defineComponent({props:{value:{type:Object},param:{type:Object}},render(j,O,v,U,p){const u=s.reactive({emitValue:{},slotValue:{}}),r=v.value;let c="div";r.component?c=s.defineAsyncComponent(r.component):r.name&&(c=s.resolveComponent(r.name));const i=v.param||{},h=l.getPropsValue(i.propss||[]),m=l.getEmitsValue(i.emitss||[]),V=l.getExposeValue(i.exposes||[]),f=l.getSlotValue(i.slots||[]),a={},q={};h.forEach(t=>{let e=t.name;if(!e.includes(".")){let o=e.split("/");e=(o[0]||"").trim(),e&&(a[e]=p.propsValue[e],o&&o.length>1&&m.push({name:"update:"+e,description:t.description,selectable:"value:["+t.type+"]"}))}}),m.forEach(t=>{let e=t.name;if(e.includes("-")){let n=e.split("-");n=n.map((_,D)=>x.firstUpper(_)),e=n.join("")}else e=x.firstUpper(e);const o="on"+e;a[o]=(...n)=>{const _={arr:n,_date_:new Date().getTime()};u.emitValue[t.name]=_}});let d;return f.forEach(t=>{const e=t.name||"default";q[e]=o=>{if(u.slotValue[e]){const n=u.slotValue[e];return s.h(s.defineComponent({props:{scope:{type:Object}},template:n}),{scope:o})}}}),s.h("div",{class:"use"},[s.h("div",{class:"use-props"},s.h(g,{name:r.name,list:h,onChange:(t,e)=>{p.propsValue=t,p.propsText=e}})),s.h("div",{class:"use-component"},s.h(c,{...a,ref:t=>{d=t}},q)),s.h("div",{class:"use-code"},s.h(T,{name:r.name,param:i,value:a,propsText:p.propsText,exposeText:p.exposeText,slotValue:u.slotValue})),s.h("div",{class:"use-emit"},s.h(y,{name:r.name,list:m,value:u.emitValue})),s.h("div",{class:"use-expose"},s.h(C,{name:r.name,list:V,getRef:()=>d,onChange:t=>{p.exposeText=t}})),s.h("div",{class:"use-slot"},s.h(b,{name:r.name,list:f,onChange:(t,e)=>{u.slotValue[t]=e}}))])},data(){return{propsValue:{},propsText:{},exposeText:{}}}});module.exports=E;
1
+ "use strict";const s=require("vue"),g=require("./set-props.vue.cjs"),y=require("./set-emit.vue.cjs");;/* empty css */const T=require("./set-code.vue.cjs"),C=require("./set-expose.vue.cjs");;/* empty css */const b=require("./set-slot.vue.cjs"),E=require("./code.cjs"),l=require("../../utils/props.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");const x=require("@fangzhongya/utils/basic/string/firstUpper");require("@fangzhongya/utils/urls/getSuffix");require("@fangzhongya/utils/basic/array/replaceAfter");const j=s.defineComponent({props:{value:{type:Object},param:{type:Object}},render(O,U,v,D,u){const p=s.reactive({emitValue:{},slotValue:{}}),r=v.value;let c="div";r.component?c=s.defineAsyncComponent(r.component):r.name&&(c=s.resolveComponent(r.name));const i=v.param||{},h=l.getPropsValue(i.propss||[]),m=l.getEmitsValue(i.emitss||[]),V=l.getExposeValue(i.exposes||[]),f=l.getSlotValue(i.slots||[]),a={},q={};h.forEach(t=>{let e=t.name;if(!e.includes(".")){let o=e.split("/");e=(o[0]||"").trim(),e&&(a[e]=u.propsValue[e]??E.getDefaultValue(t),o&&o.length>1&&m.push({name:"update:"+e,description:t.description,selectable:"value:["+t.type+"]"}))}}),m.forEach(t=>{let e=t.name;if(e.includes("-")){let n=e.split("-");n=n.map((_,P)=>x.firstUpper(_)),e=n.join("")}else e=x.firstUpper(e);const o="on"+e;a[o]=(...n)=>{const _={arr:n,_date_:new Date().getTime()};p.emitValue[t.name]=_}});let d;return f.forEach(t=>{const e=t.name||"default";q[e]=o=>{if(p.slotValue[e]){const n=p.slotValue[e];return s.h(s.defineComponent({props:{scope:{type:Object}},template:n}),{scope:o})}}}),s.h("div",{class:"use"},[s.h("div",{class:"use-props"},s.h(g,{name:r.name,list:h,onChange:(t,e)=>{u.propsValue=t,u.propsText=e}})),s.h("div",{class:"use-component"},s.h(c,{...a,ref:t=>{d=t}},q)),s.h("div",{class:"use-code"},s.h(T,{name:r.name,param:i,value:a,propsText:u.propsText,exposeText:u.exposeText,slotValue:p.slotValue})),s.h("div",{class:"use-emit"},s.h(y,{name:r.name,list:m,value:p.emitValue})),s.h("div",{class:"use-expose"},s.h(C,{name:r.name,list:V,getRef:()=>d,onChange:t=>{u.exposeText=t}})),s.h("div",{class:"use-slot"},s.h(b,{name:r.name,list:f,onChange:(t,e)=>{p.slotValue[t]=e}}))])},data(){return{propsValue:{},propsText:{},exposeText:{}}}});module.exports=j;
@@ -6,7 +6,8 @@ import E from "./set-code.vue.js";
6
6
  import O from "./set-expose.vue.js";
7
7
  /* empty css */
8
8
  import $ from "./set-slot.vue.js";
9
- import { getPropsValue as D, getEmitsValue as U, getExposeValue as k, getSlotValue as w } from "../../utils/props.js";
9
+ import { getDefaultValue as D } from "./code.js";
10
+ import { getPropsValue as U, getEmitsValue as k, getExposeValue as w, getSlotValue as A } from "../../utils/props.js";
10
11
  import "@fangzhongya/utils/basic/object/mergeObject";
11
12
  import "@fangzhongya/utils/basic/array/toggleArray";
12
13
  import "@fangzhongya/utils/name/humpToLine";
@@ -18,7 +19,7 @@ import "@fangzhongya/utils/basic/array/asyncMergeArray";
18
19
  import { firstUpper as g } from "@fangzhongya/utils/basic/string/firstUpper";
19
20
  import "@fangzhongya/utils/urls/getSuffix";
20
21
  import "@fangzhongya/utils/basic/array/replaceAfter";
21
- const oe = _({
22
+ const me = _({
22
23
  /**
23
24
  * @props {Stinrg} value 插入数据
24
25
  */
@@ -30,19 +31,19 @@ const oe = _({
30
31
  type: Object
31
32
  }
32
33
  },
33
- render(A, P, f, R, n) {
34
- const r = T({
34
+ render(P, R, f, S, r) {
35
+ const n = T({
35
36
  emitValue: {},
36
37
  slotValue: {}
37
38
  }), o = f.value;
38
39
  let l = "div";
39
40
  o.component ? l = b(o.component) : o.name && (l = j(o.name));
40
- const a = f.param || {}, d = D(a.propss || []), c = U(a.emitss || []), h = k(a.exposes || []), x = w(a.slots || []), i = {}, V = {};
41
+ const a = f.param || {}, d = U(a.propss || []), c = k(a.emitss || []), h = w(a.exposes || []), V = A(a.slots || []), i = {}, x = {};
41
42
  d.forEach((t) => {
42
43
  let e = t.name;
43
44
  if (!e.includes(".")) {
44
45
  let p = e.split("/");
45
- e = (p[0] || "").trim(), e && (i[e] = n.propsValue[e], p && p.length > 1 && c.push({
46
+ e = (p[0] || "").trim(), e && (i[e] = r.propsValue[e] ?? D(t), p && p.length > 1 && c.push({
46
47
  name: "update:" + e,
47
48
  description: t.description,
48
49
  selectable: "value:[" + t.type + "]"
@@ -52,7 +53,7 @@ const oe = _({
52
53
  let e = t.name;
53
54
  if (e.includes("-")) {
54
55
  let m = e.split("-");
55
- m = m.map((u, S) => g(u)), e = m.join("");
56
+ m = m.map((u, q) => g(u)), e = m.join("");
56
57
  } else
57
58
  e = g(e);
58
59
  const p = "on" + e;
@@ -61,15 +62,15 @@ const oe = _({
61
62
  arr: m,
62
63
  _date_: (/* @__PURE__ */ new Date()).getTime()
63
64
  };
64
- r.emitValue[t.name] = u;
65
+ n.emitValue[t.name] = u;
65
66
  };
66
67
  });
67
68
  let v;
68
- return x.forEach((t) => {
69
+ return V.forEach((t) => {
69
70
  const e = t.name || "default";
70
- V[e] = (p) => {
71
- if (r.slotValue[e]) {
72
- const m = r.slotValue[e];
71
+ x[e] = (p) => {
72
+ if (n.slotValue[e]) {
73
+ const m = n.slotValue[e];
73
74
  return s(
74
75
  _({
75
76
  props: {
@@ -100,7 +101,7 @@ const oe = _({
100
101
  name: o.name,
101
102
  list: d,
102
103
  onChange: (t, e) => {
103
- n.propsValue = t, n.propsText = e;
104
+ r.propsValue = t, r.propsText = e;
104
105
  }
105
106
  })
106
107
  ),
@@ -117,7 +118,7 @@ const oe = _({
117
118
  v = t;
118
119
  }
119
120
  },
120
- V
121
+ x
121
122
  )
122
123
  ),
123
124
  s(
@@ -129,9 +130,9 @@ const oe = _({
129
130
  name: o.name,
130
131
  param: a,
131
132
  value: i,
132
- propsText: n.propsText,
133
- exposeText: n.exposeText,
134
- slotValue: r.slotValue
133
+ propsText: r.propsText,
134
+ exposeText: r.exposeText,
135
+ slotValue: n.slotValue
135
136
  })
136
137
  ),
137
138
  s(
@@ -142,7 +143,7 @@ const oe = _({
142
143
  s(y, {
143
144
  name: o.name,
144
145
  list: c,
145
- value: r.emitValue
146
+ value: n.emitValue
146
147
  })
147
148
  ),
148
149
  s(
@@ -155,7 +156,7 @@ const oe = _({
155
156
  list: h,
156
157
  getRef: () => v,
157
158
  onChange: (t) => {
158
- n.exposeText = t;
159
+ r.exposeText = t;
159
160
  }
160
161
  })
161
162
  ),
@@ -166,9 +167,9 @@ const oe = _({
166
167
  },
167
168
  s($, {
168
169
  name: o.name,
169
- list: x,
170
+ list: V,
170
171
  onChange: (t, e) => {
171
- r.slotValue[t] = e;
172
+ n.slotValue[t] = e;
172
173
  }
173
174
  })
174
175
  )
@@ -191,5 +192,5 @@ const oe = _({
191
192
  // },
192
193
  });
193
194
  export {
194
- oe as default
195
+ me as default
195
196
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/vue-archive",
3
3
  "private": false,
4
- "version": "0.0.35",
4
+ "version": "0.0.36",
5
5
  "type": "module",
6
6
  "description ": "vue 组件注释生成文档",
7
7
  "author": "fangzhongya ",