@fangzhongya/vue-archive 0.0.48 → 0.0.50

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.
@@ -6,99 +6,99 @@ import "@fangzhongya/utils/basic/string/appearNum";
6
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
- import { firstUpper as D } from "@fangzhongya/utils/basic/string/firstUpper";
9
+ import { firstUpper as w } from "@fangzhongya/utils/basic/string/firstUpper";
10
10
  import "@fangzhongya/utils/urls/getSuffix";
11
11
  import "@fangzhongya/utils/basic/array/replaceAfter";
12
- import { getTypeValue as E, parseParamString as T, setDataType as q, vueFormat as w, prettierFormat as G, getFunBody as z } from "./util.js";
12
+ import { getTypeValue as F, parseParamString as T, parseTypeDefinition as q, setDataType as v, vueFormat as D, getFunBody as C, prettierFormat as G } from "./util.js";
13
13
  import { getPropsValue as I, getEmitsValue as K, getExposeValue as M, getSlotValue as Q } from "../../utils/props.js";
14
14
  import { getFunctionFormat as R } from "@fangzhongya/utils/basic/string/toFunction";
15
15
  const W = ["class"];
16
- function S(t, n) {
17
- return t.filter((e) => e.name == n)[0];
16
+ function S(t, e) {
17
+ return t.filter((n) => n.name == e)[0];
18
18
  }
19
- function C(t) {
20
- return t.map((n) => (n.prop || "...arr") + ":" + q(n.dataType)).join(",");
19
+ function P(t) {
20
+ return t.map((e) => (e.prop || "...arr") + ":" + v(e.dataType)).join(",");
21
21
  }
22
- function ht(t, n, e, s, i, h) {
23
- const p = [], r = [];
24
- let d = !0;
25
- const B = I(n.propss || []), J = K(n.emitss || []), N = M(n.exposes || []), A = Q(n.slots || []);
26
- Object.keys(e).forEach((o) => {
27
- let a = e[o];
28
- if (/^on[A-Z]/.test(o) && typeof a == "function") {
29
- let c = o.substring(2);
30
- const u = o.split(":");
22
+ function ht(t, e, n, s, o, h) {
23
+ const l = [], r = [];
24
+ let $ = !0;
25
+ const B = I(e.propss || []), J = K(e.emitss || []), N = M(e.exposes || []), A = Q(e.slots || []);
26
+ Object.keys(n).forEach((i) => {
27
+ let a = n[i];
28
+ if (/^on[A-Z]/.test(i) && typeof a == "function") {
29
+ let c = i.substring(2);
30
+ const u = i.split(":");
31
31
  let m;
32
- if (u.length > 1 ? (m = u[0] + u.slice(1).map((f) => D(f)).join(""), c = Z(c)) : (m = u[0], c = U(c)), u.includes("-")) {
33
- let f = m.split("-");
34
- f = f.map((g, j) => j != 0 ? D(g) : g), m = f.join("");
32
+ if (u.length > 1 ? (m = u[0] + u.slice(1).map((p) => w(p)).join(""), c = Z(c)) : (m = u[0], c = U(c)), u.includes("-")) {
33
+ let p = m.split("-");
34
+ p = p.map((g, j) => j != 0 ? w(g) : g), m = p.join("");
35
35
  }
36
- p.push(" @" + c + '="' + m + '"');
37
- const l = S(J, c) || {}, y = l.selectable || "", b = T(y), $ = C(b);
38
- r.push(`// ${l.description} ${l.name}: (${l.selectable})`), r.push("function " + m + "(" + $ + ") {"), b.forEach((f) => {
39
- const g = f.name || "arr";
40
- r.push(" console.log('" + f.label + "', " + g + ")");
36
+ l.push(" @" + c + '="' + m + '"');
37
+ const f = S(J, c) || {}, d = f.selectable || "", b = T(d), y = P(b);
38
+ r.push(`// ${f.description} ${f.name}: (${f.selectable})`), r.push("function " + m + "(" + y + ") {"), b.forEach((p) => {
39
+ const g = p.name || "arr";
40
+ r.push(" console.log('" + p.label + "', " + g + ")");
41
41
  }), r.push("}");
42
42
  } else {
43
- let c = o;
44
- W.includes(o) && (c = o + "1"), p.push(" :" + o + '="' + c + '"');
45
- const u = S(B, o) || {}, m = P(u);
43
+ let c = i;
44
+ W.includes(i) && (c = i + "1"), l.push(" :" + i + '="' + c + '"');
45
+ const u = S(B, i) || {}, m = z(u);
46
46
  if (r.push(
47
47
  `// ${u.description} ${u.name}: {${u.type}} (${u.selectable})`
48
48
  ), typeof a == "function")
49
49
  r.push(
50
- "const " + o + " = " + x(a, o, i)
50
+ "const " + i + " = " + x(a, i, o)
51
51
  );
52
- else if (d && (d = !1, r.unshift("import { ref } from 'vue';")), typeof a > "u")
52
+ else if ($ && ($ = !1, r.unshift("import { ref } from 'vue';")), typeof a > "u")
53
53
  if (m.type == "function") {
54
- const l = Y(u);
55
- r.push("const " + c + " = " + l + ";");
54
+ const f = Y(u);
55
+ r.push("const " + c + " = " + f + ";");
56
56
  } else {
57
- const l = E(m.dataType);
57
+ const f = F(m.dataType);
58
58
  r.push(
59
- "const " + c + " = ref(" + (l === "undefined" ? "" : l) + ");"
59
+ "const " + c + " = ref(" + (f === "undefined" ? "" : f) + ");"
60
60
  );
61
61
  }
62
62
  else {
63
- let l = L(a, o, i);
64
- r.push("const " + c + " = ref(" + l + ");");
63
+ let f = L(a, i, o);
64
+ r.push("const " + c + " = ref(" + f + ");");
65
65
  }
66
66
  }
67
67
  });
68
68
  const O = Object.values(h || {});
69
- O.length > 0 && (d && (d = !1, r.unshift("import { ref } from 'vue';")), p.unshift(' ref="refDom"'), r.push("const refDom = ref()"), O.forEach((o) => {
70
- const a = S(N, o.name) || {};
69
+ O.length > 0 && ($ && ($ = !1, r.unshift("import { ref } from 'vue';")), l.unshift(' ref="refDom"'), r.push("const refDom = ref()"), O.forEach((i) => {
70
+ const a = S(N, i.name) || {};
71
71
  r.push(
72
72
  `// ${a.description} ${a.name}:(${a.selectable}) ${a.type}`
73
73
  );
74
- const c = o.name + "Value", u = T(a?.selectable || ""), m = [], l = o.params || [];
75
- u.forEach((y, b) => {
76
- const $ = y.name;
77
- if ($) {
78
- const f = $ + o.name, g = l[b];
79
- if (r.push(`// ${y.label}`), typeof g == "function")
74
+ const c = i.name + "Value", u = T(a?.selectable || ""), m = [], f = i.params || [];
75
+ u.forEach((d, b) => {
76
+ const y = d.name;
77
+ if (y) {
78
+ const p = y + i.name, g = f[b];
79
+ if (r.push(`// ${d.label}`), typeof g == "function")
80
80
  r.push(
81
- "const " + f + " = " + x(g, $, o.text)
81
+ "const " + p + " = " + x(g, y, i.text)
82
82
  );
83
83
  else if (typeof g > "u")
84
84
  r.push(
85
- "const " + f + " = " + E(y.dataType) + ";"
85
+ "const " + p + " = " + F(d.dataType) + ";"
86
86
  );
87
87
  else {
88
- let j = L(g, $, o.text);
89
- r.push("const " + f + " = " + j + ";");
88
+ let j = L(g, y, i.text);
89
+ r.push("const " + p + " = " + j + ";");
90
90
  }
91
- m.push(f);
91
+ m.push(p);
92
92
  }
93
- }), o.type === "function" ? r.push(
94
- `const ${c} = refDom.value?.${o.name}(${m.join(", ")})`
95
- ) : r.push(`const ${c} = refDom.value?.${o.name}`), r.push(`console.log('"${a.type}"', ${c})`);
96
- })), p.length > 0 && p.unshift("");
93
+ }), i.type === "function" ? r.push(
94
+ `const ${c} = refDom.value?.${i.name}(${m.join(", ")})`
95
+ ) : r.push(`const ${c} = refDom.value?.${i.name}`), r.push(`console.log('"${a.type}"', ${c})`);
96
+ })), l.length > 0 && l.unshift("");
97
97
  const H = X(s, A);
98
98
  return `<!--${t}-->
99
99
  <template>
100
100
  <div>
101
- <${t}${p.join(`
101
+ <${t}${l.join(`
102
102
  `)}>${H.join(`
103
103
  `)}
104
104
  </${t}>
@@ -110,79 +110,71 @@ ${r.join(`
110
110
  <\/script>
111
111
  `;
112
112
  }
113
- function X(t = {}, n) {
114
- const e = [];
113
+ function X(t = {}, e) {
114
+ const n = [];
115
115
  return Object.keys(t).forEach((s) => {
116
- const i = S(n, s) || {}, h = t[s];
116
+ const o = S(e, s) || {}, h = t[s];
117
117
  if (h) {
118
- const p = ` <!-- ${i.description} ${i.name}:(${i.selectable}) -->
118
+ const l = ` <!-- ${o.description} ${o.name}:(${o.selectable}) -->
119
119
  <template #${s}="scope">
120
- ${w(h, " ")}
120
+ ${D(h, " ")}
121
121
  </template>`;
122
- e.push(p);
122
+ n.push(l);
123
123
  }
124
- }), e && e.length > 0 && e.unshift(""), e;
124
+ }), n && n.length > 0 && n.unshift(""), n;
125
125
  }
126
- function x(t, n, e) {
127
- const s = e ? e[n] : "";
128
- return s && (s.includes("=>") || s.includes("function")) ? s : F(t.toString());
126
+ function x(t, e, n) {
127
+ const s = n ? n[e] : "";
128
+ return s && (s.includes("=>") || s.includes("function")) ? s : E(t.toString());
129
129
  }
130
- function F(t) {
131
- const n = R(G(t));
132
- if (n) {
133
- let e = `{
134
- ${w(z(n.body), " ")}
130
+ function E(t) {
131
+ const e = R(G(t));
132
+ if (e) {
133
+ let n = `{
134
+ ${D(C(e.body), " ")}
135
135
  }`;
136
- return `function (${n.param}) ${e}`;
136
+ return `function (${e.param}) ${n}`;
137
137
  } else
138
138
  return "undefined";
139
139
  }
140
140
  function Y(t) {
141
- const n = T(t.selectable), e = C(n);
141
+ const e = T(t.selectable), n = P(e);
142
142
  let s = "";
143
143
  t.return && (s = "return ");
144
- let i = `{
145
- ${w(z(s), " ")}
144
+ let o = `{
145
+ ${D(C(s), " ")}
146
146
  }`;
147
- return `function (${e}) ${i}`;
147
+ return `function (${n}) ${o}`;
148
148
  }
149
149
  function _(t) {
150
- const n = t.trim();
151
- return /^\(/.test(n) ? F(n) : JSON.stringify(t);
150
+ const e = t.trim();
151
+ return /^\(/.test(e) ? E(e) : JSON.stringify(t);
152
152
  }
153
- function L(t, n, e) {
154
- const s = e ? e[n] : "";
153
+ function L(t, e, n) {
154
+ const s = n ? n[e] : "";
155
155
  return s ? typeof s == "string" ? V(s) : s : typeof t == "string" ? _(t + "") : JSON.stringify(t);
156
156
  }
157
- function P(t) {
158
- let n = v(t?.type), e = "any";
159
- n.length == 1 && (e = n[0].split("<")[0]);
160
- const s = e;
161
- let i = (t?.selectable || "").trim(), h = [];
162
- return i && e != "boolean" && (i.includes("|") ? i.split("|").forEach((p) => {
163
- if (p) {
164
- let r = p.split(":");
165
- h.push({
166
- label: p,
167
- prop: V(r[0].trim())
157
+ function z(t, e) {
158
+ let n = q(t?.type), s = n.dataType, o = e || n.type;
159
+ s.length == 1 ? o = s[0].split("<")[0] : s.length > 0 && (o = "any");
160
+ let h = (t?.selectable || "").trim(), l = [];
161
+ return h && o != "boolean" && (h.includes("|") ? h.split("|").forEach((r) => {
162
+ if (r) {
163
+ let $ = r.split(":");
164
+ l.push({
165
+ label: r,
166
+ prop: V($[0].trim())
168
167
  });
169
168
  }
170
- }) : h = T(i), e == "function" ? e = "function" : e == "array" ? e = "choice" : h.length > 1 && (e = "select")), {
171
- arr: h,
172
- zdtype: s,
173
- type: e,
174
- dataType: n
169
+ }) : l = T(h), o == "function" ? o = "function" : o == "array" ? o = "choice" : l.length > 1 && (o = "select")), {
170
+ arr: l,
171
+ type: o.toLowerCase(),
172
+ dataType: s
175
173
  };
176
174
  }
177
- function v(t) {
178
- let n = [];
179
- return (t || "").trim().toLowerCase().split(",").forEach((s) => {
180
- s = s.trim(), s && n.push(s);
181
- }), [...new Set(n)].sort();
182
- }
183
- function V(t, n) {
175
+ function V(t, e) {
184
176
  try {
185
- if (n?.toLowerCase() == "function")
177
+ if (e?.toLowerCase() == "function")
186
178
  if (typeof t == "string") {
187
179
  if (/^\((.|\n|\r)*\)$/.test(t))
188
180
  return t = t.substring(1, t.length - 1), new Function(`{ return ${t} }`)();
@@ -194,19 +186,19 @@ function V(t, n) {
194
186
  return "" + t;
195
187
  }
196
188
  }
197
- function gt(t, n = !0) {
198
- const e = P(t), s = E(e.dataType);
199
- if (n) {
200
- const i = (t.default || "").trim();
201
- return V(i || s, e.dataType[0]);
189
+ function gt(t, e = !0) {
190
+ const n = z(t), s = F(n.dataType);
191
+ if (e) {
192
+ const o = (t.default || "").trim();
193
+ return V(o || s, n.dataType[0]);
202
194
  } else {
203
- const i = (t.default || "").trim();
204
- return V(i, e.dataType[0]);
195
+ const o = (t.default || "").trim();
196
+ return V(o, n.dataType[0]);
205
197
  }
206
198
  }
207
199
  export {
208
200
  gt as getDefaultValue,
209
201
  ht as getHmtl,
210
- P as getSpecType,
202
+ z as getSpecType,
211
203
  L as setValStringify
212
204
  };
@@ -1 +1 @@
1
- "use strict";const n=require("vue"),i=require("../../util.cjs"),V=require("../form/index.vue.cjs"),h=require("../select/index.vue.cjs");;/* empty css */const j={class:"form-any"},x=n.defineComponent({__name:"index",props:{selects:{type:Object,default(){return{}}},config:{type:Object,default(){return{}}},modelValue:{type:null}},emits:["change"],setup(p,{emit:f}){const o=p,a=n.ref([]),r=n.ref({}),d=f,u=n.ref(""),m=[{label:"string",prop:"string"},{label:"boolean",prop:"boolean"},{label:"number",prop:"number"},{label:"array",prop:"array"},{label:"object",prop:"object"},{label:"function",prop:"function"},{label:"其他",prop:""}];n.watch(()=>o.modelValue,()=>{g()},{immediate:!0});function _(e){for(let l=0;l<a.value.length;l++){const t=a.value[l].prop;if(t===e||t.startsWith(e))return t}}function c(e,l){let t=Object.assign({},o.config);if(l){const s=_(l);s&&(e=s)}let y=i.getSonType(e);t.type=y[0],t.dataType=e,r.value=t}function g(){let e=[];const l=o.config.dataType||[];if(l&&l.length>1)e=l.map(t=>({label:t,prop:t}));else{let t=l[0];t&&t!="any"?e=[{label:t,prop:t}]:e=m}a.value=e,c(e[0].prop,i.isDefaultType(o.modelValue)),u.value=o.modelValue}function b(e){c(e),u.value=""}function v(...e){d("change",...e)}return(e,l)=>(n.openBlock(),n.createElementBlock("div",j,[n.createElementVNode("div",null,[n.createVNode(h,{noValue:"",onChange:b,modelValue:r.value.dataType,list:a.value},null,8,["modelValue","list"])]),n.createVNode(V,{config:r.value,selects:o.selects,modelValue:u.value,onChange:v},null,8,["config","selects","modelValue"])]))}});module.exports=x;
1
+ "use strict";const n=require("vue"),p=require("../../util.cjs"),V=require("../form/index.vue.cjs"),h=require("../select/index.vue.cjs");;/* empty css */const j={class:"form-any"},x=n.defineComponent({__name:"index",props:{selects:{type:Object,default(){return{}}},config:{type:Object,default(){return{}}},modelValue:{type:null}},emits:["change"],setup(f,{emit:d}){const o=f,r=n.ref([]),u=n.ref({}),m=d,s=n.ref(""),_=[{label:"string",prop:"string"},{label:"boolean",prop:"boolean"},{label:"number",prop:"number"},{label:"array",prop:"array"},{label:"object",prop:"object"},{label:"function",prop:"function"},{label:"其他",prop:""}];n.watch(()=>o.modelValue,()=>{b()},{immediate:!0});function g(e){for(let l=0;l<r.value.length;l++){const t=r.value[l].prop;if(t===e||t.startsWith(e))return t}}function c(e,l){let t=Object.assign({},o.config);if(l){const i=g(l);i&&(e=i)}let a=p.getSonType(e);t.type=a[0],t.dataType=e,u.value=t}function b(){let e=[];const l=o.config.dataType||[];if(l&&l.length>1)e=l.map(t=>{const a=t.split("<")[0];return{label:t,prop:a.toLowerCase()}});else{let t=l[0];if(t&&t!="any"){const a=t.split("<")[0];e=[{label:t,prop:a.toLowerCase()}]}else e=_}r.value=e,c(e[0].prop,p.isDefaultType(o.modelValue)),s.value=o.modelValue}function v(e){c(e),s.value=""}function y(...e){m("change",...e)}return(e,l)=>(n.openBlock(),n.createElementBlock("div",j,[n.createElementVNode("div",null,[n.createVNode(h,{noValue:"",onChange:v,modelValue:u.value.type,list:r.value},null,8,["modelValue","list"])]),n.createVNode(V,{config:u.value,selects:o.selects,modelValue:s.value,onChange:y},null,8,["config","selects","modelValue"])]))}});module.exports=x;
@@ -1,9 +1,9 @@
1
- import { defineComponent as h, ref as c, watch as v, createElementBlock as j, openBlock as T, createElementVNode as x, createVNode as u } from "vue";
2
- import { isDefaultType as C, getSonType as O } from "../../util.js";
3
- import k from "../form/index.vue.js";
4
- import B from "../select/index.vue.js";
1
+ import { defineComponent as h, ref as s, watch as v, createElementBlock as j, openBlock as C, createElementVNode as T, createVNode as u } from "vue";
2
+ import { isDefaultType as x, getSonType as w } from "../../util.js";
3
+ import L from "../form/index.vue.js";
4
+ import O from "../select/index.vue.js";
5
5
  /* empty css */
6
- const E = { class: "form-any" }, L = /* @__PURE__ */ h({
6
+ const k = { class: "form-any" }, D = /* @__PURE__ */ h({
7
7
  __name: "index",
8
8
  props: {
9
9
  /**
@@ -29,8 +29,8 @@ const E = { class: "form-any" }, L = /* @__PURE__ */ h({
29
29
  }
30
30
  },
31
31
  emits: ["change"],
32
- setup(s, { emit: f }) {
33
- const o = s, n = c([]), a = c({}), m = f, r = c(""), d = [
32
+ setup(f, { emit: m }) {
33
+ const o = f, a = s([]), r = s({}), d = m, c = s(""), b = [
34
34
  {
35
35
  label: "string",
36
36
  prop: "string"
@@ -63,71 +63,73 @@ const E = { class: "form-any" }, L = /* @__PURE__ */ h({
63
63
  v(
64
64
  () => o.modelValue,
65
65
  () => {
66
- g();
66
+ V();
67
67
  },
68
68
  {
69
69
  immediate: !0
70
70
  }
71
71
  );
72
- function b(e) {
73
- for (let l = 0; l < n.value.length; l++) {
74
- const t = n.value[l].prop;
72
+ function g(e) {
73
+ for (let l = 0; l < a.value.length; l++) {
74
+ const t = a.value[l].prop;
75
75
  if (t === e || t.startsWith(e))
76
76
  return t;
77
77
  }
78
78
  }
79
- function i(e, l) {
79
+ function p(e, l) {
80
80
  let t = Object.assign({}, o.config);
81
81
  if (l) {
82
- const p = b(l);
83
- p && (e = p);
82
+ const i = g(l);
83
+ i && (e = i);
84
84
  }
85
- let _ = O(e);
86
- t.type = _[0], t.dataType = e, a.value = t;
85
+ let n = w(e);
86
+ t.type = n[0], t.dataType = e, r.value = t;
87
87
  }
88
- function g() {
88
+ function V() {
89
89
  let e = [];
90
90
  const l = o.config.dataType || [];
91
91
  if (l && l.length > 1)
92
- e = l.map((t) => ({
93
- label: t,
94
- prop: t
95
- }));
92
+ e = l.map((t) => {
93
+ const n = t.split("<")[0];
94
+ return {
95
+ label: t,
96
+ prop: n.toLowerCase()
97
+ };
98
+ });
96
99
  else {
97
100
  let t = l[0];
98
- t && t != "any" ? e = [
99
- {
100
- label: t,
101
- prop: t
102
- }
103
- ] : e = d;
101
+ if (t && t != "any") {
102
+ const n = t.split("<")[0];
103
+ e = [{ label: t, prop: n.toLowerCase() }];
104
+ } else
105
+ e = b;
104
106
  }
105
- n.value = e, i(e[0].prop, C(o.modelValue)), r.value = o.modelValue;
107
+ a.value = e, p(e[0].prop, x(o.modelValue)), c.value = o.modelValue;
106
108
  }
107
- function V(e) {
108
- i(e), r.value = "";
109
+ function y(e) {
110
+ p(e), c.value = "";
109
111
  }
110
- function y(...e) {
111
- m("change", ...e);
112
+ function _(...e) {
113
+ d("change", ...e);
112
114
  }
113
- return (e, l) => (T(), j("div", E, [
114
- x("div", null, [
115
- u(B, {
115
+ return (e, l) => (C(), j("div", k, [
116
+ T("div", null, [
117
+ u(O, {
116
118
  noValue: "",
117
- onChange: V,
118
- modelValue: a.value.dataType,
119
- list: n.value
119
+ onChange: y,
120
+ modelValue: r.value.type,
121
+ list: a.value
120
122
  }, null, 8, ["modelValue", "list"])
121
123
  ]),
122
- u(k, {
123
- config: a.value,
124
+ u(L, {
125
+ config: r.value,
124
126
  selects: o.selects,
125
- modelValue: r.value,
126
- onChange: y
127
+ modelValue: c.value,
128
+ onChange: _
127
129
  }, null, 8, ["config", "selects", "modelValue"])
128
130
  ]));
129
131
  }
130
132
  });
131
133
  export {
132
- L as default
134
+ D as default
133
135
  };
@@ -1 +1 @@
1
- "use strict";const s=require("vue"),q=require("./retrie/index.vue.cjs");;/* empty css */const o=require("./code.cjs"),T={key:0,class:"set-props"},k=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(i,{emit:p}){const l=i,f=p,c=s.ref({}),m=s.ref(0),a=s.ref({}),n=s.ref([]);function d(){a.value={};const r=[];l.list?.forEach(t=>{let e=t.name;if(!e.includes(".")&&(e=(e.split("/")[0]||"").trim(),e)){a.value[e]=o.getDefaultValue(t,!1);const{arr:g,type:v,dataType:b}=o.getSpecType(t);c.value[e]=g;let V={label:_(e,t),prop:e,type:v,dataType:b,select:e};r.push(V)}}),n.value=r}function _(r,t){let e=r+": { "+(t.type||"any")+" } "+t.description;return t.default&&(e+=" 默认值="+t.default),t.selectable&&(e+=" 可选值="+t.selectable),e}function h(r,t){let e=Object.assign({},r);f("change",e,t)}let u;function y(){clearTimeout(u),u=setTimeout(()=>{d()},400)}return s.watch(()=>l.name,()=>{n.value=[],y()},{immediate:!0}),(r,t)=>n.value&&n.value.length>0?(s.openBlock(),s.createElementBlock("div",T,[s.createVNode(q,{refresh:m.value,modelValue:a.value,selects:c.value,list:n.value,name:l.name,onQuery:h},null,8,["refresh","modelValue","selects","list","name"])])):s.createCommentVNode("",!0)}});module.exports=k;
1
+ "use strict";const s=require("vue"),T=require("./retrie/index.vue.cjs");;/* empty css */const i=require("./code.cjs"),k=require("./util.cjs"),x={key:0,class:"set-props"},j=s.defineComponent({__name:"set-props",props:{name:String,list:Array},emits:["change"],setup(p,{emit:f}){const l=p,m=f,c=s.ref({}),d=s.ref(0),u=s.ref({}),n=s.ref([]);function _(){u.value={};const r=[];l.list?.forEach(t=>{let e=t.name;if(!e.includes(".")&&(e=(e.split("/")[0]||"").trim(),e)){const o=i.getDefaultValue(t,!1);u.value[e]=o;const{arr:g,type:b,dataType:V}=i.getSpecType(t,k.isDefaultType(o));c.value[e]=g;let q={label:h(e,t),prop:e,type:b,dataType:V,select:e};r.push(q)}}),n.value=r}function h(r,t){let e=r+": { "+(t.type||"any")+" } "+t.description;return t.default&&(e+=" 默认值="+t.default),t.selectable&&(e+=" 可选值="+t.selectable),e}function y(r,t){let e=Object.assign({},r);m("change",e,t)}let a;function v(){clearTimeout(a),a=setTimeout(()=>{_()},400)}return s.watch(()=>l.name,()=>{n.value=[],v()},{immediate:!0}),(r,t)=>n.value&&n.value.length>0?(s.openBlock(),s.createElementBlock("div",x,[s.createVNode(T,{refresh:d.value,modelValue:u.value,selects:c.value,list:n.value,name:l.name,onQuery:y},null,8,["refresh","modelValue","selects","list","name"])])):s.createCommentVNode("",!0)}});module.exports=j;
@@ -1,73 +1,78 @@
1
- import { defineComponent as v, ref as a, watch as T, createElementBlock as k, createCommentVNode as j, openBlock as x, createVNode as B } from "vue";
2
- import C from "./retrie/index.vue.js";
1
+ import { defineComponent as T, ref as a, watch as k, createElementBlock as j, createCommentVNode as x, openBlock as B, createVNode as C } from "vue";
2
+ import D from "./retrie/index.vue.js";
3
3
  /* empty css */
4
4
  import { getDefaultValue as E, getSpecType as N } from "./code.js";
5
- const S = {
5
+ import { isDefaultType as S } from "./util.js";
6
+ const w = {
6
7
  key: 0,
7
8
  class: "set-props"
8
- }, Q = /* @__PURE__ */ v({
9
+ }, q = /* @__PURE__ */ T({
9
10
  __name: "set-props",
10
11
  props: {
11
12
  name: String,
12
13
  list: Array
13
14
  },
14
15
  emits: ["change"],
15
- setup(i, { emit: u }) {
16
- const n = i, m = u, r = a({}), p = a(0), o = a({}), l = a([]);
17
- function f() {
16
+ setup(u, { emit: m }) {
17
+ const n = u, p = m, r = a({}), f = a(0), o = a({}), l = a([]);
18
+ function d() {
18
19
  o.value = {};
19
20
  const s = [];
20
21
  n.list?.forEach((t) => {
21
22
  let e = t.name;
22
23
  if (!e.includes(".") && (e = (e.split("/")[0] || "").trim(), e)) {
23
- o.value[e] = E(t, !1);
24
- const { arr: y, type: b, dataType: g } = N(t);
25
- r.value[e] = y;
26
- let V = {
27
- label: d(e, t),
24
+ const i = E(t, !1);
25
+ o.value[e] = i;
26
+ const { arr: b, type: g, dataType: V } = N(
27
+ t,
28
+ S(i)
29
+ );
30
+ r.value[e] = b;
31
+ let v = {
32
+ label: h(e, t),
28
33
  prop: e,
29
- type: b,
30
- dataType: g,
34
+ type: g,
35
+ dataType: V,
31
36
  select: e
32
37
  };
33
- s.push(V);
38
+ s.push(v);
34
39
  }
35
40
  }), l.value = s;
36
41
  }
37
- function d(s, t) {
42
+ function h(s, t) {
38
43
  let e = s + ": { " + (t.type || "any") + " } " + t.description;
39
44
  return t.default && (e += " 默认值=" + t.default), t.selectable && (e += " 可选值=" + t.selectable), e;
40
45
  }
41
- function h(s, t) {
46
+ function _(s, t) {
42
47
  let e = Object.assign({}, s);
43
- m("change", e, t);
48
+ p("change", e, t);
44
49
  }
45
50
  let c;
46
- function _() {
51
+ function y() {
47
52
  clearTimeout(c), c = setTimeout(() => {
48
- f();
53
+ d();
49
54
  }, 400);
50
55
  }
51
- return T(
56
+ return k(
52
57
  () => n.name,
53
58
  () => {
54
- l.value = [], _();
59
+ l.value = [], y();
55
60
  },
56
61
  {
57
62
  immediate: !0
58
63
  }
59
- ), (s, t) => l.value && l.value.length > 0 ? (x(), k("div", S, [
60
- B(C, {
61
- refresh: p.value,
64
+ ), (s, t) => l.value && l.value.length > 0 ? (B(), j("div", w, [
65
+ C(D, {
66
+ refresh: f.value,
62
67
  modelValue: o.value,
63
68
  selects: r.value,
64
69
  list: l.value,
65
70
  name: n.name,
66
- onQuery: h
71
+ onQuery: _
67
72
  }, null, 8, ["refresh", "modelValue", "selects", "list", "name"])
68
- ])) : j("", !0);
73
+ ])) : x("", !0);
69
74
  }
70
75
  });
71
76
  export {
72
- Q as default
77
+ q as default
73
78
  };
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@fangzhongya/utils/basic/string/toFunction"),w=require("@fangzhongya/utils/basic/string/firstLower");function y(e){return e.replace(/\;(\s|\n\r)*$/,"")}function O(e){return e="let a = "+e,y(e).replace(/^let a = /,"")}function A(e){return y(e)}function x(e,n=""){let t=(e+"").trim().split(/\n/);return t=t.map(r=>n+r),t.join(`
2
- `)}function b(e=""){e=e.trim();let n=`[\\s|\\n|\\r]*\\{((.|
3
- |\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?b(r[1]):e}const W=["Boolean","Any","String","Number","Array","Object","Function"];function k(e){return W.includes(e)?w.firstLower(e):e}function v(e){let t=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(t&&t.length>0)return{own:k(t[1]),son:t[2]}}function d(e,n){let t=v(e);t?(n.push(t.own),t.son&&d(t.son,n)):n.push(e)}function h(e){e instanceof Array&&(e=e[0]);const n=[];return e&&d(e,n),n}function T(e){const n=Object.prototype.toString.call(e);let r=/^\[[O|o]bject (.*)\]$/.exec(n),i=typeof e;return r&&r.length>0&&(i=r[1].toLowerCase()),i}function E(e,n){const t=T(e),r=h(n)[0];return r&&r!="any"?t==r:!0}function q(e){if(typeof e=="string"){let n=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(n=!0),n&&(e=e.substring(1,e.length-1)),e+""}else return typeof e=="object"&&e?e.toString():typeof e>"u"||typeof e=="object"&&!e?"":e+""}function B(e){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let n="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?n="string":/^\[(.|\n|\r)*\]$/.test(e)?n="array":/^\{(.|\n|\r)*\}$/.test(e)?n="object":/^[0-9]*$/.test(e)?n="number":e==="true"||e==="false"?n="boolean":e=="undefined"?n="undefined":e=="null"?n="null":e&&(n="string"),n}function F(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let t=F(e.splice(1));return t=t=="undefined"?"":t,`[${t}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function L(e){let n="";return e.forEach((t,r)=>{t=t.trim(),t&&(n&&(n+=" | "),t==="Array"?n+="Array<any>":n+=t)}),n||"any"}const g=(e,n)=>{let t=[],r=[],i="";for(let u=0;u<e.length;u++){const s=e[u];s==="["||s==="<"||s==="("?(t.push(s),i+=s):s==="]"&&t.length>0&&t[t.length-1]==="["||s===">"&&t.length>0&&t[t.length-1]==="<"||s===")"&&t.length>0&&t[t.length-1]==="("?(t.pop(),i+=s):s===n&&t.length===0?(r.push(i.trim()),i=""):i+=s}return i.trim()!==""&&r.push(i.trim()),r},C=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=g(n,",");return{type:t[0]||"any",dataType:t}}else if(e.startsWith("<")&&e.endsWith(">")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=g(n,"|");return{type:t[0]||"any",dataType:t}}else return{type:e,dataType:[e]};else return{type:"any",dataType:["any"]}};function M(e){return g(e,",").map(t=>{const r=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const u=i[1].trim(),s=!i[2],j=i[0].length,c=t.substring(j).trim();let a=[],f="",p="";for(let l=0;l<c.length;l++){const o=c[l];if(o==="["||o==="<"||o==="("?a.push(o):(o==="]"&&a[a.length-1]==="["||o===">"&&a[a.length-1]==="<"||o===")"&&a[a.length-1]==="(")&&a.pop(),a.length===0&&l>0){l==1&&o!=="]"&&o!==">"&&o!==")"?(f="",p=c.substring(0)):(f=c.substring(0,l+1).trim(),p=c.substring(l+1));break}}const{type:N,dataType:m}=C(f),$=h(m);return{name:u,prop:u,type:$[0],dataType:m,must:s,label:r,description:p}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>S.getFunctionFormat});exports.getFunBody=b;exports.getObjType=T;exports.getSonType=h;exports.getString=q;exports.getTypeValue=F;exports.isDefaultType=B;exports.isTypeEqual=E;exports.parseParamString=M;exports.prettierArrFormat=A;exports.prettierFormat=y;exports.prettierObjFormat=O;exports.setDataType=L;exports.vueFormat=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@fangzhongya/utils/basic/string/toFunction"),A=require("@fangzhongya/utils/basic/string/firstLower");function y(e){return e.replace(/\;(\s|\n\r)*$/,"")}function O(e){return e="let a = "+e,y(e).replace(/^let a = /,"")}function v(e){return y(e)}function x(e,n=""){let t=(e+"").trim().split(/\n/);return t=t.map(r=>n+r),t.join(`
2
+ `)}function m(e=""){e=e.trim();let n=`[\\s|\\n|\\r]*\\{((.|
3
+ |\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?m(r[1]):e}const W=["Boolean","Any","String","Number","Array","Object","Function"];function k(e){return W.includes(e)?A.firstLower(e):e}function E(e){let t=new RegExp("^([a-z|A-Z]+)\\<(.+)\\>$").exec(e);if(t&&t.length>0)return{own:k(t[1]),son:t[2]}}function d(e,n){let t=E(e);t?(n.push(t.own),t.son&&d(t.son,n)):n.push(e)}function h(e){e instanceof Array&&(e=e[0]);const n=[];return e&&d(e,n),n}function T(e){const n=Object.prototype.toString.call(e);let r=/^\[[O|o]bject (.*)\]$/.exec(n),i=typeof e;return r&&r.length>0&&(i=r[1].toLowerCase()),i}function q(e,n){const t=T(e),r=h(n)[0];return r&&r!="any"?t==r:!0}function B(e){if(typeof e=="string"){let n=!1;return(/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e))&&(n=!0),n&&(e=e.substring(1,e.length-1)),e+""}else return typeof e=="object"&&e?e.toString():typeof e>"u"||typeof e=="object"&&!e?"":e+""}function L(e){const n=typeof e;if(n=="string"){e=(e+"").replace(/^(\s|\n|r)*/,"").replace(/(\s|\n|r)*$/,"");let t="";return/^\'(.|\n|\r)*\'$/.test(e)||/^\"(.|\n|\r)*\"$/.test(e)||/^\`(.|\n|\r)*\`$/.test(e)?t="string":/^\[(.|\n|\r)*\]$/.test(e)?t="array":/^\{(.|\n|\r)*\}$/.test(e)?t="object":/^[0-9]*$/.test(e)?t="number":e==="true"||e==="false"?t="boolean":e=="undefined"?t="undefined":e=="null"?t="null":e&&(t="string"),t}else return n==="object"?e instanceof Array?"array":n===null?"null":n:n}function j(e){switch((e[0]||"any").toLowerCase()){case"string":return'""';case"boolean":return"false";case"number":return"0";case"array":let t=j(e.splice(1));return t=t=="undefined"?"":t,`[${t}]`;case"object":return"{}";case"function":return"()=>{}";case"any":return'""';default:return"undefined"}}function C(e){let n="";return e.forEach((t,r)=>{t=t.trim(),t&&(n&&(n+=" | "),t==="Array"?n+="Array<any>":n+=t)}),n||"any"}const f=(e,n)=>{let t=[],r=[],i="";for(let u=0;u<e.length;u++){const s=e[u];s==="["||s==="<"||s==="("?(t.push(s),i+=s):s==="]"&&t.length>0&&t[t.length-1]==="["||s===">"&&t.length>0&&t[t.length-1]==="<"||s===")"&&t.length>0&&t[t.length-1]==="("?(t.pop(),i+=s):s===n&&t.length===0?(r.push(i.trim()),i=""):i+=s}return i.trim()!==""&&r.push(i.trim()),r},F=e=>{if(e)if(e.startsWith("[")&&e.endsWith("]")||e.startsWith("(")&&e.endsWith(")")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=f(n,",");return{type:t[0]||"any",dataType:t}}else if(e.startsWith("<")&&e.endsWith(">")){const n=e.slice(1,-1).trim();if(!n)return{type:"any",dataType:["any"]};const t=f(n,"|");return{type:t[0]||"any",dataType:t}}else{const n=f(e,",");return{type:n[0]||"any",dataType:n}}else return{type:"any",dataType:["any"]}};function M(e){return f(e,",").map(t=>{const r=t.trim(),i=t.match(/^([^:?]+)(\??):/);if(!i)return null;const u=i[1].trim(),s=!i[2],$=i[0].length,c=t.substring($).trim();let a=[],p="",g="";for(let l=0;l<c.length;l++){const o=c[l];if(o==="["||o==="<"||o==="("?a.push(o):(o==="]"&&a[a.length-1]==="["||o===">"&&a[a.length-1]==="<"||o===")"&&a[a.length-1]==="(")&&a.pop(),a.length===0&&l>0){l==1&&o!=="]"&&o!==">"&&o!==")"?(p="",g=c.substring(0)):(p=c.substring(0,l+1).trim(),g=c.substring(l+1));break}}const{type:N,dataType:b}=F(p),S=h(b);return{name:u,prop:u,type:S[0],dataType:b,must:s,label:r,description:g}}).filter(Boolean)}Object.defineProperty(exports,"getFunctionFormat",{enumerable:!0,get:()=>w.getFunctionFormat});exports.getFunBody=m;exports.getObjType=T;exports.getSonType=h;exports.getString=B;exports.getTypeValue=j;exports.isDefaultType=L;exports.isTypeEqual=q;exports.parseParamString=M;exports.parseTypeDefinition=F;exports.prettierArrFormat=v;exports.prettierFormat=y;exports.prettierObjFormat=O;exports.setDataType=C;exports.vueFormat=x;
@@ -34,9 +34,13 @@ export declare function getString(st: unknown): string;
34
34
  /**
35
35
  * 配置字符串的类型
36
36
  */
37
- export declare function isDefaultType(st: string): string;
37
+ export declare function isDefaultType(st: any): string;
38
38
  export declare function getTypeValue(arr: string[]): string;
39
39
  export declare function setDataType(arr: string[]): string;
40
+ export declare const parseTypeDefinition: (typeDef: string) => {
41
+ type: string;
42
+ dataType: string[];
43
+ };
40
44
  export declare function parseParamString(input: string): Array<{
41
45
  name: string;
42
46
  prop: string;