@fangzhongya/vue-archive 0.0.3-3 → 0.0.3-4

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.
@@ -66527,22 +66527,76 @@ ${vueFormat(getFunBody(st.body), " ")}
66527
66527
  }
66528
66528
  }
66529
66529
  function getChange(str) {
66530
- return new Function(
66531
- "",
66532
- `{
66533
- var a = ${str};
66534
- return a;
66535
- }`
66536
- );
66530
+ const tr = str.trim();
66531
+ if (/^\(/.test(tr)) {
66532
+ return new Function("", str);
66533
+ } else {
66534
+ return new Function(
66535
+ "",
66536
+ `{
66537
+ var a = ${str};
66538
+ return a;
66539
+ }`
66540
+ );
66541
+ }
66537
66542
  }
66538
66543
  function setValStringify(v, key, propsText) {
66539
66544
  const text = propsText ? propsText[key] : "";
66540
66545
  if (text) {
66541
66546
  return text;
66542
66547
  } else {
66543
- return JSON.stringify(getChange(v + ""));
66548
+ if (typeof v == "string") {
66549
+ return JSON.stringify(getChange(v + ""));
66550
+ } else {
66551
+ return JSON.stringify(v);
66552
+ }
66544
66553
  }
66545
66554
  }
66555
+ function getSpecType(val) {
66556
+ let tarr = getType2(val.type);
66557
+ let type = "any";
66558
+ if (tarr.length == 1) {
66559
+ type = tarr[0].split("<")[0];
66560
+ }
66561
+ const zdtype = type;
66562
+ let selectable = (val.selectable || "").trim();
66563
+ let arr = [];
66564
+ if (selectable && type != "boolean") {
66565
+ selectable.split(",").forEach((v) => {
66566
+ if (v) {
66567
+ let z = v.split(":");
66568
+ arr.push({
66569
+ label: v,
66570
+ prop: z[0].trim()
66571
+ });
66572
+ }
66573
+ });
66574
+ if (type == "function") {
66575
+ type = "function";
66576
+ } else if (type == "array") {
66577
+ type = "choice";
66578
+ } else {
66579
+ type = "select";
66580
+ }
66581
+ }
66582
+ return {
66583
+ arr,
66584
+ zdtype,
66585
+ type,
66586
+ dataType: tarr
66587
+ };
66588
+ }
66589
+ function getType2(value) {
66590
+ let arr = [];
66591
+ let str = (value || "").trim().toLowerCase();
66592
+ str.split(",").forEach((v) => {
66593
+ v = v.trim();
66594
+ if (v) {
66595
+ arr.push(v);
66596
+ }
66597
+ });
66598
+ return [...new Set(arr)].sort();
66599
+ }
66546
66600
 
66547
66601
  // packages/node/index.ts
66548
66602
  var Fang;
@@ -66610,6 +66664,21 @@ function gettests(obj, arr, n) {
66610
66664
  setMd(obj, arr);
66611
66665
  }
66612
66666
  }
66667
+ function getDefaultValue(obj) {
66668
+ const vo = getSpecType(obj).zdtype;
66669
+ const d = (obj.default || "").trim();
66670
+ if (vo == "function") {
66671
+ return new Function("", d);
66672
+ } else {
66673
+ return new Function(
66674
+ "",
66675
+ `{
66676
+ var a = ${d};
66677
+ return a;
66678
+ }`
66679
+ );
66680
+ }
66681
+ }
66613
66682
  function setVue(propsname, param, url) {
66614
66683
  const ps = getPropsValue(param.propss);
66615
66684
  const es = getEmitsValue(param.emitss);
@@ -66620,7 +66689,7 @@ function setVue(propsname, param, url) {
66620
66689
  let arr = name.split("/");
66621
66690
  name = (arr[0] || "").trim();
66622
66691
  if (name) {
66623
- propsObj[name] = val.default;
66692
+ propsObj[name] = getDefaultValue(val);
66624
66693
  if (arr && arr.length > 1) {
66625
66694
  es.push({
66626
66695
  name: "update:" + name,
@@ -66527,22 +66527,76 @@ ${vueFormat(getFunBody(st.body), " ")}
66527
66527
  }
66528
66528
  }
66529
66529
  function getChange(str) {
66530
- return new Function(
66531
- "",
66532
- `{
66533
- var a = ${str};
66534
- return a;
66535
- }`
66536
- );
66530
+ const tr = str.trim();
66531
+ if (/^\(/.test(tr)) {
66532
+ return new Function("", str);
66533
+ } else {
66534
+ return new Function(
66535
+ "",
66536
+ `{
66537
+ var a = ${str};
66538
+ return a;
66539
+ }`
66540
+ );
66541
+ }
66537
66542
  }
66538
66543
  function setValStringify(v, key, propsText) {
66539
66544
  const text = propsText ? propsText[key] : "";
66540
66545
  if (text) {
66541
66546
  return text;
66542
66547
  } else {
66543
- return JSON.stringify(getChange(v + ""));
66548
+ if (typeof v == "string") {
66549
+ return JSON.stringify(getChange(v + ""));
66550
+ } else {
66551
+ return JSON.stringify(v);
66552
+ }
66544
66553
  }
66545
66554
  }
66555
+ function getSpecType(val) {
66556
+ let tarr = getType2(val.type);
66557
+ let type = "any";
66558
+ if (tarr.length == 1) {
66559
+ type = tarr[0].split("<")[0];
66560
+ }
66561
+ const zdtype = type;
66562
+ let selectable = (val.selectable || "").trim();
66563
+ let arr = [];
66564
+ if (selectable && type != "boolean") {
66565
+ selectable.split(",").forEach((v) => {
66566
+ if (v) {
66567
+ let z = v.split(":");
66568
+ arr.push({
66569
+ label: v,
66570
+ prop: z[0].trim()
66571
+ });
66572
+ }
66573
+ });
66574
+ if (type == "function") {
66575
+ type = "function";
66576
+ } else if (type == "array") {
66577
+ type = "choice";
66578
+ } else {
66579
+ type = "select";
66580
+ }
66581
+ }
66582
+ return {
66583
+ arr,
66584
+ zdtype,
66585
+ type,
66586
+ dataType: tarr
66587
+ };
66588
+ }
66589
+ function getType2(value) {
66590
+ let arr = [];
66591
+ let str = (value || "").trim().toLowerCase();
66592
+ str.split(",").forEach((v) => {
66593
+ v = v.trim();
66594
+ if (v) {
66595
+ arr.push(v);
66596
+ }
66597
+ });
66598
+ return [...new Set(arr)].sort();
66599
+ }
66546
66600
 
66547
66601
  // packages/node/index.ts
66548
66602
  var Fang;
@@ -66610,6 +66664,21 @@ function gettests(obj, arr, n) {
66610
66664
  setMd(obj, arr);
66611
66665
  }
66612
66666
  }
66667
+ function getDefaultValue(obj) {
66668
+ const vo = getSpecType(obj).zdtype;
66669
+ const d = (obj.default || "").trim();
66670
+ if (vo == "function") {
66671
+ return new Function("", d);
66672
+ } else {
66673
+ return new Function(
66674
+ "",
66675
+ `{
66676
+ var a = ${d};
66677
+ return a;
66678
+ }`
66679
+ );
66680
+ }
66681
+ }
66613
66682
  function setVue(propsname, param, url) {
66614
66683
  const ps = getPropsValue(param.propss);
66615
66684
  const es = getEmitsValue(param.emitss);
@@ -66620,7 +66689,7 @@ function setVue(propsname, param, url) {
66620
66689
  let arr = name.split("/");
66621
66690
  name = (arr[0] || "").trim();
66622
66691
  if (name) {
66623
- propsObj[name] = val.default;
66692
+ propsObj[name] = getDefaultValue(val);
66624
66693
  if (arr && arr.length > 1) {
66625
66694
  es.push({
66626
66695
  name: "update:" + name,
@@ -1 +1 @@
1
- "use strict";const e=require("vue"),d=require("../use/index.cjs"),k=require("./info.vue.cjs"),f=require("./props.vue.cjs"),g=require("../../config.cjs"),B=require("../md/index.vue.cjs");require("./index.cjs");const v=require("../../utils/glob.cjs"),y={class:"compo"},q={key:0,class:"compo-md"},C={key:0,class:"compo-md-list"},h={key:1,class:"compo-use"},x=e.defineComponent({__name:"index",props:{value:Object},setup(l){const t=l,m=g.getConfig("useparam"),a=e.ref(""),r=e.reactive({md:!0}),c=e.ref([]),s=e.ref({});function p(o){s.value=o}e.watch(()=>t.value,()=>{i()});function i(){var o,n,u;(o=t.value)!=null&&o.key&&(v.getLocalTextComponents((n=t.value)==null?void 0:n.key).then(_=>{a.value=_}),c.value=v.getKeyMds((u=t.value)==null?void 0:u.key)||[])}return i(),(o,n)=>(e.openBlock(),e.createElementBlock("div",y,[e.createVNode(k,{value:l.value},null,8,["value"]),e.createVNode(f,{onChange:p,value:a.value},null,8,["value"]),c.value&&c.value.length?(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",{onClick:n[0]||(n[0]=u=>r.md=!r.md),class:"compo-md-name"}," 说明文档 "),r.md?(e.openBlock(),e.createElementBlock("div",C,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,u=>(e.openBlock(),e.createBlock(B,{value:u},null,8,["value"]))),256))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.unref(m)?(e.openBlock(),e.createElementBlock("div",h,[e.createVNode(e.unref(d),{value:t.value,param:e.unref(s)},null,8,["value","param"])])):e.createCommentVNode("",!0)]))}});module.exports=x;
1
+ "use strict";const e=require("vue"),B=require("../use/index.cjs"),x=require("./info.vue.cjs"),y=require("./props.vue.cjs"),q=require("../../config.cjs"),C=require("../md/index.vue.cjs");require("./index.cjs");const d=require("../../utils/glob.cjs"),h={class:"compo"},N={key:0,class:"compo-md"},V={key:0,class:"compo-md-list"},E={key:1,class:"compo-use"},b=e.defineComponent({__name:"index",props:{value:Object},setup(c){const n=c,k=q.getConfig("useparam"),a=e.ref(""),u=e.reactive({md:!0}),s=e.ref([]),v=e.ref([]),p=e.ref([]),i=e.ref([]),m=e.ref([]);function f(l){let{propss:t,slots:o,emitss:r,exposes:g}=l;v.value=t,m.value=o,p.value=r,i.value=g}e.watch(()=>n.value,()=>{_()});function _(){var l,t,o;(l=n.value)!=null&&l.key&&(d.getLocalTextComponents((t=n.value)==null?void 0:t.key).then(r=>{a.value=r}),s.value=d.getKeyMds((o=n.value)==null?void 0:o.key)||[])}return _(),(l,t)=>(e.openBlock(),e.createElementBlock("div",h,[e.createVNode(x,{value:c.value},null,8,["value"]),e.createVNode(y,{onChange:f,value:a.value},null,8,["value"]),s.value&&s.value.length?(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("div",{onClick:t[0]||(t[0]=o=>u.md=!u.md),class:"compo-md-name"}," 说明文档 "),u.md?(e.openBlock(),e.createElementBlock("div",V,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,o=>(e.openBlock(),e.createBlock(C,{value:o},null,8,["value"]))),256))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.unref(k)?(e.openBlock(),e.createElementBlock("div",E,[e.createVNode(e.unref(B),{value:n.value,param:{props:v.value,slot:m.value,emits:p.value,expose:i.value}},null,8,["value","param"])])):e.createCommentVNode("",!0)]))}});module.exports=b;
@@ -1,70 +1,76 @@
1
- import { defineComponent as h, ref as s, reactive as y, watch as C, openBlock as e, createElementBlock as l, createVNode as u, createElementVNode as x, Fragment as $, renderList as B, createBlock as N, createCommentVNode as c, unref as i } from "vue";
2
- import V from "../use/index.js";
3
- import b from "./info.vue.js";
4
- import j from "./props.vue.js";
5
- import { getConfig as E } from "../../config.js";
6
- import L from "../md/index.vue.js";
1
+ import { defineComponent as $, ref as o, reactive as B, watch as N, openBlock as s, createElementBlock as n, createVNode as c, createElementVNode as V, Fragment as E, renderList as L, createBlock as b, createCommentVNode as v, unref as x } from "vue";
2
+ import j from "../use/index.js";
3
+ import w from "./info.vue.js";
4
+ import D from "./props.vue.js";
5
+ import { getConfig as F } from "../../config.js";
6
+ import K from "../md/index.vue.js";
7
7
  import "./index.js";
8
- import { getLocalTextComponents as w, getKeyMds as D } from "../../utils/glob.js";
9
- const F = { class: "compo" }, K = {
8
+ import { getLocalTextComponents as M, getKeyMds as O } from "../../utils/glob.js";
9
+ const T = { class: "compo" }, U = {
10
10
  key: 0,
11
11
  class: "compo-md"
12
- }, M = {
12
+ }, q = {
13
13
  key: 0,
14
14
  class: "compo-md-list"
15
- }, O = {
15
+ }, z = {
16
16
  key: 1,
17
17
  class: "compo-use"
18
- }, J = /* @__PURE__ */ h({
18
+ }, S = /* @__PURE__ */ $({
19
19
  __name: "index",
20
20
  props: {
21
21
  value: Object
22
22
  },
23
- setup(v) {
24
- const t = v, _ = E("useparam"), p = s(""), r = y({
23
+ setup(i) {
24
+ const a = i, h = F("useparam"), p = o(""), m = B({
25
25
  md: !0
26
- }), m = s([]), d = s({});
27
- function k(o) {
28
- d.value = o;
26
+ }), u = o([]), d = o([]), f = o([]), _ = o([]), k = o([]);
27
+ function y(l) {
28
+ let { propss: e, slots: t, emitss: r, exposes: C } = l;
29
+ d.value = e, k.value = t, f.value = r, _.value = C;
29
30
  }
30
- C(
31
- () => t.value,
31
+ N(
32
+ () => a.value,
32
33
  () => {
33
- f();
34
+ g();
34
35
  }
35
36
  );
36
- function f() {
37
- var o, a, n;
38
- (o = t.value) != null && o.key && (w((a = t.value) == null ? void 0 : a.key).then(
39
- (g) => {
40
- p.value = g;
37
+ function g() {
38
+ var l, e, t;
39
+ (l = a.value) != null && l.key && (M((e = a.value) == null ? void 0 : e.key).then(
40
+ (r) => {
41
+ p.value = r;
41
42
  }
42
- ), m.value = D((n = t.value) == null ? void 0 : n.key) || []);
43
+ ), u.value = O((t = a.value) == null ? void 0 : t.key) || []);
43
44
  }
44
- return f(), (o, a) => (e(), l("div", F, [
45
- u(b, { value: v.value }, null, 8, ["value"]),
46
- u(j, {
47
- onChange: k,
45
+ return g(), (l, e) => (s(), n("div", T, [
46
+ c(w, { value: i.value }, null, 8, ["value"]),
47
+ c(D, {
48
+ onChange: y,
48
49
  value: p.value
49
50
  }, null, 8, ["value"]),
50
- m.value && m.value.length ? (e(), l("div", K, [
51
- x("div", {
52
- onClick: a[0] || (a[0] = (n) => r.md = !r.md),
51
+ u.value && u.value.length ? (s(), n("div", U, [
52
+ V("div", {
53
+ onClick: e[0] || (e[0] = (t) => m.md = !m.md),
53
54
  class: "compo-md-name"
54
55
  }, " 说明文档 "),
55
- r.md ? (e(), l("div", M, [
56
- (e(!0), l($, null, B(m.value, (n) => (e(), N(L, { value: n }, null, 8, ["value"]))), 256))
57
- ])) : c("", !0)
58
- ])) : c("", !0),
59
- i(_) ? (e(), l("div", O, [
60
- u(i(V), {
61
- value: t.value,
62
- param: i(d)
56
+ m.md ? (s(), n("div", q, [
57
+ (s(!0), n(E, null, L(u.value, (t) => (s(), b(K, { value: t }, null, 8, ["value"]))), 256))
58
+ ])) : v("", !0)
59
+ ])) : v("", !0),
60
+ x(h) ? (s(), n("div", z, [
61
+ c(x(j), {
62
+ value: a.value,
63
+ param: {
64
+ props: d.value,
65
+ slot: k.value,
66
+ emits: f.value,
67
+ expose: _.value
68
+ }
63
69
  }, null, 8, ["value", "param"])
64
- ])) : c("", !0)
70
+ ])) : v("", !0)
65
71
  ]));
66
72
  }
67
73
  });
68
74
  export {
69
- J as default
75
+ S as default
70
76
  };
@@ -1,21 +1,21 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-J7CICTHH.cjs"),m=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-EWJJKQIO.cjs"),j=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-4OBNLDTJ.cjs"),p=require("./util.cjs");function v(t,n,i,e){const r=[],o=[];let h=!0;Object.keys(n).forEach(s=>{let f=n[s];if(/^on[A-Z]/.test(s)&&typeof f=="function"){let u=s.substring(2);const l=s.split(":");let c;if(l.length>1?(c=l[0]+l.slice(1).map(a=>m.firstUpper(a)).join(""),u=j.firstLower(u)):(c=l[0],u=F.humpToLine(u)),l.includes("-")){let a=c.split("-");a=a.map((g,$)=>$!=0?m.firstUpper(g):g),c=a.join("")}r.push(" @"+u+'="'+c+'"'),o.push("function "+c+"(...arr) {"),o.push(" console.log('"+c+"', arr)"),o.push("}")}else if(r.push(" :"+s+'="'+s+'"'),typeof f=="function")o.push("const "+s+" = "+O(f,s,e));else if(h&&(h=!1,o.unshift("import { ref } from 'vue';")),typeof f>"u")o.push("const "+s+" = ref();");else{let u=J(f,s,e);o.push("const "+s+" = ref("+u+");")}}),r.length>0&&r.unshift("");const d=b(i);return`<!--${t}-->
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-J7CICTHH.cjs"),d=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-EWJJKQIO.cjs"),b=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-4OBNLDTJ.cjs"),h=require("./util.cjs");function S(t,e,n,r){const i=[],s=[];let l=!0;Object.keys(e).forEach(o=>{let f=e[o];if(/^on[A-Z]/.test(o)&&typeof f=="function"){let u=o.substring(2);const a=o.split(":");let c;if(a.length>1?(c=a[0]+a.slice(1).map(p=>d.firstUpper(p)).join(""),u=b.firstLower(u)):(c=a[0],u=$.humpToLine(u)),a.includes("-")){let p=c.split("-");p=p.map((m,y)=>y!=0?d.firstUpper(m):m),c=p.join("")}i.push(" @"+u+'="'+c+'"'),s.push("function "+c+"(...arr) {"),s.push(" console.log('"+c+"', arr)"),s.push("}")}else if(i.push(" :"+o+'="'+o+'"'),typeof f=="function")s.push("const "+o+" = "+j(f,o,r));else if(l&&(l=!1,s.unshift("import { ref } from 'vue';")),typeof f>"u")s.push("const "+o+" = ref();");else{let u=J(f,o,r);s.push("const "+o+" = ref("+u+");")}}),i.length>0&&i.unshift("");const g=F(n);return`<!--${t}-->
2
2
  <template>
3
3
  <div>
4
- <${t}${r.join(`
5
- `)}>${d.join(`
4
+ <${t}${i.join(`
5
+ `)}>${g.join(`
6
6
  `)}
7
7
  </${t}>
8
8
  </div>
9
9
  </template>
10
10
  <script lang="ts" setup>
11
- ${o.join(`
11
+ ${s.join(`
12
12
  `)}
13
13
  <\/script>
14
- `}function b(t={}){const n=[];return Object.keys(t).forEach(i=>{const e=t[i];if(e){const r=` <template #${i}="scope">
15
- ${p.vueFormat(e," ")}
16
- </template>`;n.push(r)}}),n&&n.length>0&&n.unshift(""),n}function O(t,n,i){const e=i?i[n]:"";if(e)return"function"+e;{const r=p.getFunctionFormat(p.prettierFormat(t.toString()));if(r){let o=`{
17
- ${p.vueFormat(p.getFunBody(r.body)," ")}
18
- }`;return`function${r.param}${o}`}else return"undefined"}}function S(t){return new Function("",`{
19
- var a = ${t};
20
- return a;
21
- }`)}function J(t,n,i){const e=i?i[n]:"";return e||JSON.stringify(S(t+""))}exports.getHmtl=v;
14
+ `}function F(t={}){const e=[];return Object.keys(t).forEach(n=>{const r=t[n];if(r){const i=` <template #${n}="scope">
15
+ ${h.vueFormat(r," ")}
16
+ </template>`;e.push(i)}}),e&&e.length>0&&e.unshift(""),e}function j(t,e,n){const r=n?n[e]:"";if(r)return"function"+r;{const i=h.getFunctionFormat(h.prettierFormat(t.toString()));if(i){let s=`{
17
+ ${h.vueFormat(h.getFunBody(i.body)," ")}
18
+ }`;return`function${i.param}${s}`}else return"undefined"}}function O(t){const e=t.trim();return/^\(/.test(e)?new Function("",t):new Function("",`{
19
+ var a = ${t};
20
+ return a;
21
+ }`)}function J(t,e,n){const r=n?n[e]:"";return r||JSON.stringify(typeof t=="string"?O(t+""):t)}function w(t){let e=E(t.type),n="any";e.length==1&&(n=e[0].split("<")[0]);const r=n;let i=(t.selectable||"").trim(),s=[];return i&&n!="boolean"&&(i.split(",").forEach(l=>{if(l){let g=l.split(":");s.push({label:l,prop:g[0].trim()})}}),n=="function"?n="function":n=="array"?n="choice":n="select"),{arr:s,zdtype:r,type:n,dataType:e}}function E(t){let e=[];return(t||"").trim().toLowerCase().split(",").forEach(r=>{r=r.trim(),r&&e.push(r)}),[...new Set(e)].sort()}exports.getHmtl=S;exports.getSpecType=w;
@@ -1,2 +1,14 @@
1
1
  import type { ObjStr, ObjUnk } from '../../config';
2
+ import type { Spec } from '../../utils/index';
2
3
  export declare function getHmtl(propsname: string, value: ObjUnk, slotValue?: ObjStr, propsText?: ObjStr): string;
4
+ type SelectsObj = {
5
+ label: string;
6
+ prop: unknown;
7
+ };
8
+ export declare function getSpecType(val: Spec): {
9
+ arr: SelectsObj[];
10
+ zdtype: string;
11
+ type: string;
12
+ dataType: string[];
13
+ };
14
+ export {};
@@ -1,108 +1,136 @@
1
- import { humpToLine as F } from "../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-J7CICTHH.js";
2
- import { firstUpper as h } from "../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-EWJJKQIO.js";
3
- import { firstLower as j } from "../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-4OBNLDTJ.js";
4
- import { vueFormat as g, getFunctionFormat as v, prettierFormat as b, getFunBody as S } from "./util.js";
5
- function N(t, n, s, e) {
6
- const r = [], o = [];
7
- let p = !0;
8
- Object.keys(n).forEach((i) => {
9
- let c = n[i];
10
- if (/^on[A-Z]/.test(i) && typeof c == "function") {
11
- let f = i.substring(2);
12
- const l = i.split(":");
13
- let u;
14
- if (l.length > 1 ? (u = l[0] + l.slice(1).map((a) => h(a)).join(""), f = j(f)) : (u = l[0], f = F(f)), l.includes("-")) {
15
- let a = u.split("-");
16
- a = a.map((m, d) => d != 0 ? h(m) : m), u = a.join("");
1
+ import { humpToLine as y } from "../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-J7CICTHH.js";
2
+ import { firstUpper as g } from "../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-EWJJKQIO.js";
3
+ import { firstLower as b } from "../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-4OBNLDTJ.js";
4
+ import { vueFormat as d, getFunctionFormat as F, prettierFormat as S, getFunBody as j } from "./util.js";
5
+ function H(t, e, n, r) {
6
+ const i = [], s = [];
7
+ let u = !0;
8
+ Object.keys(e).forEach((o) => {
9
+ let c = e[o];
10
+ if (/^on[A-Z]/.test(o) && typeof c == "function") {
11
+ let f = o.substring(2);
12
+ const p = o.split(":");
13
+ let l;
14
+ if (p.length > 1 ? (l = p[0] + p.slice(1).map((a) => g(a)).join(""), f = b(f)) : (l = p[0], f = y(f)), p.includes("-")) {
15
+ let a = l.split("-");
16
+ a = a.map((h, $) => $ != 0 ? g(h) : h), l = a.join("");
17
17
  }
18
- r.push(
19
- " @" + f + '="' + u + '"'
20
- ), o.push("function " + u + "(...arr) {"), o.push(
21
- " console.log('" + u + "', arr)"
22
- ), o.push("}");
23
- } else if (r.push(
24
- " :" + i + '="' + i + '"'
18
+ i.push(
19
+ " @" + f + '="' + l + '"'
20
+ ), s.push("function " + l + "(...arr) {"), s.push(
21
+ " console.log('" + l + "', arr)"
22
+ ), s.push("}");
23
+ } else if (i.push(
24
+ " :" + o + '="' + o + '"'
25
25
  ), typeof c == "function")
26
- o.push(
27
- "const " + i + " = " + w(
26
+ s.push(
27
+ "const " + o + " = " + E(
28
28
  c,
29
- i,
30
- e
29
+ o,
30
+ r
31
31
  )
32
32
  );
33
- else if (p && (p = !1, o.unshift(
33
+ else if (u && (u = !1, s.unshift(
34
34
  "import { ref } from 'vue';"
35
35
  )), typeof c > "u")
36
- o.push("const " + i + " = ref();");
36
+ s.push("const " + o + " = ref();");
37
37
  else {
38
- let f = E(
38
+ let f = L(
39
39
  c,
40
- i,
41
- e
40
+ o,
41
+ r
42
42
  );
43
- o.push(
44
- "const " + i + " = ref(" + f + ");"
43
+ s.push(
44
+ "const " + o + " = ref(" + f + ");"
45
45
  );
46
46
  }
47
- }), r.length > 0 && r.unshift("");
48
- const $ = O(s);
47
+ }), i.length > 0 && i.unshift("");
48
+ const m = w(n);
49
49
  return `<!--${t}-->
50
50
  <template>
51
51
  <div>
52
- <${t}${r.join(`
53
- `)}>${$.join(`
52
+ <${t}${i.join(`
53
+ `)}>${m.join(`
54
54
  `)}
55
55
  </${t}>
56
56
  </div>
57
57
  </template>
58
58
  <script lang="ts" setup>
59
- ${o.join(`
59
+ ${s.join(`
60
60
  `)}
61
61
  <\/script>
62
62
  `;
63
63
  }
64
- function O(t = {}) {
65
- const n = [];
66
- return Object.keys(t).forEach((s) => {
67
- const e = t[s];
68
- if (e) {
69
- const r = ` <template #${s}="scope">
70
- ${g(e, " ")}
64
+ function w(t = {}) {
65
+ const e = [];
66
+ return Object.keys(t).forEach((n) => {
67
+ const r = t[n];
68
+ if (r) {
69
+ const i = ` <template #${n}="scope">
70
+ ${d(r, " ")}
71
71
  </template>`;
72
- n.push(r);
72
+ e.push(i);
73
73
  }
74
- }), n && n.length > 0 && n.unshift(""), n;
74
+ }), e && e.length > 0 && e.unshift(""), e;
75
75
  }
76
- function w(t, n, s) {
77
- const e = s ? s[n] : "";
78
- if (e)
79
- return "function" + e;
76
+ function E(t, e, n) {
77
+ const r = n ? n[e] : "";
78
+ if (r)
79
+ return "function" + r;
80
80
  {
81
- const r = v(
82
- b(t.toString())
81
+ const i = F(
82
+ S(t.toString())
83
83
  );
84
- if (r) {
85
- let o = `{
86
- ${g(S(r.body), " ")}
84
+ if (i) {
85
+ let s = `{
86
+ ${d(j(i.body), " ")}
87
87
  }`;
88
- return `function${r.param}${o}`;
88
+ return `function${i.param}${s}`;
89
89
  } else
90
90
  return "undefined";
91
91
  }
92
92
  }
93
- function B(t) {
94
- return new Function(
93
+ function O(t) {
94
+ const e = t.trim();
95
+ return /^\(/.test(e) ? new Function("", t) : new Function(
95
96
  "",
96
97
  `{
97
- var a = ${t};
98
- return a;
99
- }`
98
+ var a = ${t};
99
+ return a;
100
+ }`
100
101
  );
101
102
  }
102
- function E(t, n, s) {
103
- const e = s ? s[n] : "";
104
- return e || JSON.stringify(B(t + ""));
103
+ function L(t, e, n) {
104
+ const r = n ? n[e] : "";
105
+ return r || JSON.stringify(typeof t == "string" ? O(t + "") : t);
106
+ }
107
+ function T(t) {
108
+ let e = z(t.type), n = "any";
109
+ e.length == 1 && (n = e[0].split("<")[0]);
110
+ const r = n;
111
+ let i = (t.selectable || "").trim(), s = [];
112
+ return i && n != "boolean" && (i.split(",").forEach((u) => {
113
+ if (u) {
114
+ let m = u.split(":");
115
+ s.push({
116
+ label: u,
117
+ prop: m[0].trim()
118
+ });
119
+ }
120
+ }), n == "function" ? n = "function" : n == "array" ? n = "choice" : n = "select"), {
121
+ arr: s,
122
+ zdtype: r,
123
+ type: n,
124
+ dataType: e
125
+ };
126
+ }
127
+ function z(t) {
128
+ let e = [];
129
+ return (t || "").trim().toLowerCase().split(",").forEach((r) => {
130
+ r = r.trim(), r && e.push(r);
131
+ }), [...new Set(e)].sort();
105
132
  }
106
133
  export {
107
- N as getHmtl
134
+ H as getHmtl,
135
+ T as getSpecType
108
136
  };
@@ -1 +1 @@
1
- "use strict";const s=require("vue"),x=require("./set-props.vue.cjs"),q=require("./set-emit.vue.cjs"),E=require("./set-code.vue.cjs"),b=require("./set-expose.vue.cjs"),C=require("./set-slot.vue.cjs"),i=require("../../utils/props.cjs"),V=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-EWJJKQIO.cjs"),j=s.defineComponent({props:{value:{type:Object},param:{type:Object}},render(O,T,v,D,a){console.log("render",new Date().getTime());const r=s.reactive({emitValue:{},slotValue:{}}),n=v.value;let c="div";n.component?c=s.defineAsyncComponent(n.component):n.name&&(c=s.resolveComponent(n.name));const u=v.param,d=i.getPropsValue(u.propss||[]),m=i.getEmitsValue(u.emitss||[]),y=i.getExposeValue(u.exposes||[]),h=i.getSlotValue(u.slots||[]),l={},f={};d.forEach(t=>{let e=t.name;if(!e.includes(".")){let o=e.split("/");e=(o[0]||"").trim(),e&&(l[e]=a.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 p=e.split("-");p=p.map((_,U)=>V.firstUpper(_)),e=p.join("")}else e=V.firstUpper(e);const o="on"+e;l[o]=(...p)=>{const _={arr:p,_date_:new Date().getTime()};r.emitValue[t.name]=_}});let g;return h.forEach(t=>{const e=t.name||"default";f[e]=o=>{if(r.slotValue[e])return s.h(s.defineComponent({props:{scope:{type:Object}},template:r.slotValue[e]}),{scope:o})}}),s.h("div",{class:"use"},[s.h("div",{class:"use-props"},s.h(x,{name:n.name,list:d,onChange:(t,e)=>{a.propsValue=t,a.propsText=e}})),s.h("div",{class:"use-component"},s.h(c,{...l,ref:t=>{g=t}},f)),s.h("div",{class:"use-code"},s.h(E,{name:n.name,value:l,propsText:a.propsText,slotValue:r.slotValue})),s.h("div",{class:"use-emit"},s.h(q,{name:n.name,list:m,value:r.emitValue})),s.h("div",{class:"use-expose"},s.h(b,{name:n.name,list:y,getRef:()=>g})),s.h("div",{class:"use-slot"},s.h(C,{name:n.name,list:h,onChange:(t,e)=>{r.slotValue[t]=e}}))])},data(){return{propsValue:{},propsText:{}}}});module.exports=j;
1
+ "use strict";const t=require("vue"),x=require("./set-props.vue.cjs"),q=require("./set-emit.vue.cjs"),E=require("./set-code.vue.cjs"),b=require("./set-expose.vue.cjs"),C=require("./set-slot.vue.cjs"),i=require("../../utils/props.cjs"),V=require("../../../node_modules/.pnpm/@fangzhongya_utils@0.0.7-18/node_modules/@fangzhongya/utils/dist/chunk-EWJJKQIO.cjs"),j=t.defineComponent({props:{value:{type:Object},param:{type:Object}},render(O,T,v,D,a){console.log("render",new Date().getTime());const r=t.reactive({emitValue:{},slotValue:{}}),n=v.value;let c="div";n.component?c=t.defineAsyncComponent(n.component):n.name&&(c=t.resolveComponent(n.name));const u=v.param,d=i.getPropsValue(u.props),m=i.getEmitsValue(u.emits),y=i.getExposeValue(u.expose),h=i.getSlotValue(u.slot),l={},f={};d.forEach(s=>{let e=s.name;if(!e.includes(".")){let o=e.split("/");e=(o[0]||"").trim(),e&&(l[e]=a.propsValue[e],o&&o.length>1&&m.push({name:"update:"+e,description:s.description,selectable:"value:["+s.type+"]"}))}}),m.forEach(s=>{let e=s.name;if(e.includes("-")){let p=e.split("-");p=p.map((_,U)=>V.firstUpper(_)),e=p.join("")}else e=V.firstUpper(e);const o="on"+e;l[o]=(...p)=>{const _={arr:p,_date_:new Date().getTime()};r.emitValue[s.name]=_}});let g;return h.forEach(s=>{const e=s.name||"default";f[e]=o=>{if(r.slotValue[e])return t.h(t.defineComponent({props:{scope:{type:Object}},template:r.slotValue[e]}),{scope:o})}}),t.h("div",{class:"use"},[t.h("div",{class:"use-props"},t.h(x,{name:n.name,list:d,onChange:(s,e)=>{a.propsValue=s,a.propsText=e}})),t.h("div",{class:"use-component"},t.h(c,{...l,ref:s=>{g=s}},f)),t.h("div",{class:"use-code"},t.h(E,{name:n.name,value:l,propsText:a.propsText,slotValue:r.slotValue})),t.h("div",{class:"use-emit"},t.h(q,{name:n.name,list:m,value:r.emitValue})),t.h("div",{class:"use-expose"},t.h(b,{name:n.name,list:y,getRef:()=>g})),t.h("div",{class:"use-slot"},t.h(C,{name:n.name,list:h,onChange:(s,e)=>{r.slotValue[s]=e}}))])},data(){return{propsValue:{},propsText:{}}}});module.exports=j;
@@ -26,7 +26,7 @@ const K = g({
26
26
  }), o = f.value;
27
27
  let i = "div";
28
28
  o.component ? i = j(o.component) : o.name && (i = T(o.name));
29
- const p = f.param, d = D(p.propss || []), c = w(p.emitss || []), x = U(p.exposes || []), V = k(p.slots || []), l = {}, v = {};
29
+ const p = f.param, d = D(p.props), c = w(p.emits), x = U(p.expose), V = k(p.slot), l = {}, v = {};
30
30
  d.forEach((s) => {
31
31
  let e = s.name;
32
32
  if (!e.includes(".")) {
@@ -1 +1 @@
1
- "use strict";const l=require("vue"),w=require("./retrie/index.vue.cjs"),C={key:0,class:"set-props"},j=l.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(d,{emit:_}){const i=d,p=l.ref({}),y=l.ref(0),c=l.ref({}),a=l.ref([]);function b(){var e;c.value={};const r=[];(e=i.list)==null||e.forEach(s=>{let t=s.name;if(t.includes(".")?t="":t=(t.split("/")[0]||"").trim(),t){let o=V(s.type),n="any";o.length==1&&(n=o[0].split("<")[0]),c.value[t]=(s.default||"").trim();let m=(s.selectable||"").trim();if(m&&n!="boolean"){let h=[];m.split(",").forEach(u=>{if(u){let E=u.split(":");h.push({label:u,prop:E[0].trim()})}}),p.value[t]=h,n=="function"?n="function":n=="array"?n="choice":n="select"}let x={label:g(t,s),prop:t,type:n,dataType:o,select:t};r.push(x)}}),a.value=r}function g(r,e){let s=r+": { "+(e.type||"any")+" } "+e.description;return e.default&&(s+=" 默认值="+e.default),e.selectable&&(s+=" 可选值="+e.selectable),s}function V(r){let e=[];return(r||"").trim().toLowerCase().split(",").forEach(t=>{t=t.trim(),t&&e.push(t)}),[...new Set(e)].sort()}function T(r,e){let s=Object.assign({},r);_("change",s,e)}let f;function k(){clearTimeout(f),f=setTimeout(()=>{b()},400)}return l.watch(()=>i.name,()=>{a.value=[],l.nextTick(()=>{k()})},{immediate:!0}),(r,e)=>a.value&&a.value.length>0?(l.openBlock(),l.createElementBlock("div",C,[l.createVNode(w,{refresh:y.value,modelValue:c.value,selects:p.value,list:a.value,name:i.name,onQuery:T},null,8,["refresh","modelValue","selects","list","name"])])):l.createCommentVNode("",!0)}});module.exports=j;
1
+ "use strict";const t=require("vue"),V=require("./retrie/index.vue.cjs"),T=require("./code.cjs"),k={key:0,class:"set-props"},x=t.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(p,{emit:f}){const c=p,u=t.ref({}),m=t.ref(0),a=t.ref({}),l=t.ref([]);function d(){var e;a.value={};const n=[];(e=c.list)==null||e.forEach(s=>{let r=s.name;if(r.includes(".")?r="":r=(r.split("/")[0]||"").trim(),r){a.value[r]=(s.default||"").trim();const{arr:i,type:v,dataType:b}=T.getSpecType(s);u.value[r]=i;let g={label:_(r,s),prop:r,type:v,dataType:b,select:r};i.push(g)}}),l.value=n}function _(n,e){let s=n+": { "+(e.type||"any")+" } "+e.description;return e.default&&(s+=" 默认值="+e.default),e.selectable&&(s+=" 可选值="+e.selectable),s}function h(n,e){let s=Object.assign({},n);f("change",s,e)}let o;function y(){clearTimeout(o),o=setTimeout(()=>{d()},400)}return t.watch(()=>c.name,()=>{l.value=[],t.nextTick(()=>{y()})},{immediate:!0}),(n,e)=>l.value&&l.value.length>0?(t.openBlock(),t.createElementBlock("div",k,[t.createVNode(V,{refresh:m.value,modelValue:a.value,selects:u.value,list:l.value,name:c.name,onQuery:h},null,8,["refresh","modelValue","selects","list","name"])])):t.createCommentVNode("",!0)}});module.exports=x;
@@ -1,92 +1,75 @@
1
- import { defineComponent as x, ref as n, watch as C, nextTick as j, openBlock as B, createElementBlock as L, createVNode as N, createCommentVNode as S } from "vue";
2
- import z from "./retrie/index.vue.js";
3
- const A = {
1
+ import { defineComponent as v, ref as r, watch as T, nextTick as k, openBlock as x, createElementBlock as j, createVNode as B, createCommentVNode as C } from "vue";
2
+ import E from "./retrie/index.vue.js";
3
+ import { getSpecType as N } from "./code.js";
4
+ const S = {
4
5
  key: 0,
5
6
  class: "set-props"
6
- }, $ = /* @__PURE__ */ x({
7
+ }, Q = /* @__PURE__ */ v({
7
8
  __name: "set-props",
8
9
  props: {
9
10
  name: String,
10
11
  list: Array
11
12
  },
12
13
  emits: ["change"],
13
- setup(d, { emit: b }) {
14
- const i = d, f = n({}), y = n(0), o = n({}), a = n([]);
15
- function _() {
14
+ setup(m, { emit: p }) {
15
+ const a = m, c = r({}), f = r(0), o = r({}), n = r([]);
16
+ function d() {
16
17
  var e;
17
18
  o.value = {};
18
- const s = [];
19
- (e = i.list) == null || e.forEach((l) => {
20
- let t = l.name;
21
- if (t.includes(".") ? t = "" : t = (t.split("/")[0] || "").trim(), t) {
22
- let c = V(l.type), r = "any";
23
- c.length == 1 && (r = c[0].split("<")[0]), o.value[t] = (l.default || "").trim();
24
- let m = (l.selectable || "").trim();
25
- if (m && r != "boolean") {
26
- let h = [];
27
- m.split(",").forEach((u) => {
28
- if (u) {
29
- let w = u.split(":");
30
- h.push({
31
- label: u,
32
- prop: w[0].trim()
33
- });
34
- }
35
- }), f.value[t] = h, r == "function" ? r = "function" : r == "array" ? r = "choice" : r = "select";
36
- }
37
- let E = {
38
- label: g(t, l),
39
- prop: t,
40
- type: r,
41
- dataType: c,
42
- select: t
19
+ const l = [];
20
+ (e = a.list) == null || e.forEach((t) => {
21
+ let s = t.name;
22
+ if (s.includes(".") ? s = "" : s = (s.split("/")[0] || "").trim(), s) {
23
+ o.value[s] = (t.default || "").trim();
24
+ const { arr: i, type: b, dataType: g } = N(t);
25
+ c.value[s] = i;
26
+ let V = {
27
+ label: h(s, t),
28
+ prop: s,
29
+ type: b,
30
+ dataType: g,
31
+ select: s
43
32
  };
44
- s.push(E);
33
+ i.push(V);
45
34
  }
46
- }), a.value = s;
35
+ }), n.value = l;
47
36
  }
48
- function g(s, e) {
49
- let l = s + ": { " + (e.type || "any") + " } " + e.description;
50
- return e.default && (l += " 默认值=" + e.default), e.selectable && (l += " 可选值=" + e.selectable), l;
37
+ function h(l, e) {
38
+ let t = l + ": { " + (e.type || "any") + " } " + e.description;
39
+ return e.default && (t += " 默认值=" + e.default), e.selectable && (t += " 可选值=" + e.selectable), t;
51
40
  }
52
- function V(s) {
53
- let e = [];
54
- return (s || "").trim().toLowerCase().split(",").forEach((t) => {
55
- t = t.trim(), t && e.push(t);
56
- }), [...new Set(e)].sort();
41
+ function _(l, e) {
42
+ let t = Object.assign({}, l);
43
+ p("change", t, e);
57
44
  }
58
- function T(s, e) {
59
- let l = Object.assign({}, s);
60
- b("change", l, e);
61
- }
62
- let p;
63
- function k() {
64
- clearTimeout(p), p = setTimeout(() => {
65
- _();
45
+ let u;
46
+ function y() {
47
+ clearTimeout(u), u = setTimeout(() => {
48
+ d();
66
49
  }, 400);
67
50
  }
68
- return C(
69
- () => i.name,
51
+ return T(
52
+ () => a.name,
70
53
  () => {
71
- a.value = [], j(() => {
72
- k();
54
+ n.value = [], k(() => {
55
+ y();
73
56
  });
74
57
  },
75
58
  {
76
59
  immediate: !0
77
60
  }
78
- ), (s, e) => a.value && a.value.length > 0 ? (B(), L("div", A, [
79
- N(z, {
80
- refresh: y.value,
61
+ ), (l, e) => n.value && n.value.length > 0 ? (x(), j("div", S, [
62
+ B(E, {
63
+ refresh: f.value,
81
64
  modelValue: o.value,
82
- selects: f.value,
83
- list: a.value,
84
- name: i.name,
85
- onQuery: T
65
+ selects: c.value,
66
+ list: n.value,
67
+ name: a.name,
68
+ onQuery: _
86
69
  }, null, 8, ["refresh", "modelValue", "selects", "list", "name"])
87
- ])) : S("", !0);
70
+ ])) : C("", !0);
88
71
  }
89
72
  });
90
73
  export {
91
- $ as default
74
+ Q as default
92
75
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/vue-archive",
3
3
  "private": false,
4
- "version": "0.0.3-3",
4
+ "version": "0.0.3-4",
5
5
  "type": "module",
6
6
  "description ": "vue 组件注释生成文档",
7
7
  "author": "fangzhongya ",