@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.
- package/dist/node/index.cjs +30 -39
- package/dist/node/index.js +30 -39
- package/dist/packages/components/aside/index.vue.cjs +1 -1
- package/dist/packages/components/aside/index.vue.js +1 -1
- package/dist/packages/components/use/code.cjs +9 -9
- package/dist/packages/components/use/code.d.ts +1 -2
- package/dist/packages/components/use/code.js +100 -108
- package/dist/packages/components/use/retrie/any/index.vue.cjs +1 -1
- package/dist/packages/components/use/retrie/any/index.vue.js +45 -43
- package/dist/packages/components/use/set-props.vue.cjs +1 -1
- package/dist/packages/components/use/set-props.vue.js +33 -28
- package/dist/packages/components/use/util.cjs +3 -3
- package/dist/packages/components/use/util.d.ts +5 -1
- package/dist/packages/components/use/util.js +33 -26
- package/package.json +2 -2
|
@@ -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
|
|
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
|
|
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,
|
|
17
|
-
return t.filter((
|
|
16
|
+
function S(t, e) {
|
|
17
|
+
return t.filter((n) => n.name == e)[0];
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return t.map((
|
|
19
|
+
function P(t) {
|
|
20
|
+
return t.map((e) => (e.prop || "...arr") + ":" + v(e.dataType)).join(",");
|
|
21
21
|
}
|
|
22
|
-
function ht(t,
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
const B = I(
|
|
26
|
-
Object.keys(
|
|
27
|
-
let a =
|
|
28
|
-
if (/^on[A-Z]/.test(
|
|
29
|
-
let c =
|
|
30
|
-
const u =
|
|
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((
|
|
33
|
-
let
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
const
|
|
38
|
-
r.push(`// ${
|
|
39
|
-
const g =
|
|
40
|
-
r.push(" console.log('" +
|
|
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 =
|
|
44
|
-
W.includes(
|
|
45
|
-
const u = S(B,
|
|
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 " +
|
|
50
|
+
"const " + i + " = " + x(a, i, o)
|
|
51
51
|
);
|
|
52
|
-
else if (
|
|
52
|
+
else if ($ && ($ = !1, r.unshift("import { ref } from 'vue';")), typeof a > "u")
|
|
53
53
|
if (m.type == "function") {
|
|
54
|
-
const
|
|
55
|
-
r.push("const " + c + " = " +
|
|
54
|
+
const f = Y(u);
|
|
55
|
+
r.push("const " + c + " = " + f + ";");
|
|
56
56
|
} else {
|
|
57
|
-
const
|
|
57
|
+
const f = F(m.dataType);
|
|
58
58
|
r.push(
|
|
59
|
-
"const " + c + " = ref(" + (
|
|
59
|
+
"const " + c + " = ref(" + (f === "undefined" ? "" : f) + ");"
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
let
|
|
64
|
-
r.push("const " + c + " = ref(" +
|
|
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 && (
|
|
70
|
-
const a = S(N,
|
|
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 =
|
|
75
|
-
u.forEach((
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
if (r.push(`// ${
|
|
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 " +
|
|
81
|
+
"const " + p + " = " + x(g, y, i.text)
|
|
82
82
|
);
|
|
83
83
|
else if (typeof g > "u")
|
|
84
84
|
r.push(
|
|
85
|
-
"const " +
|
|
85
|
+
"const " + p + " = " + F(d.dataType) + ";"
|
|
86
86
|
);
|
|
87
87
|
else {
|
|
88
|
-
let j = L(g,
|
|
89
|
-
r.push("const " +
|
|
88
|
+
let j = L(g, y, i.text);
|
|
89
|
+
r.push("const " + p + " = " + j + ";");
|
|
90
90
|
}
|
|
91
|
-
m.push(
|
|
91
|
+
m.push(p);
|
|
92
92
|
}
|
|
93
|
-
}),
|
|
94
|
-
`const ${c} = refDom.value?.${
|
|
95
|
-
) : r.push(`const ${c} = refDom.value?.${
|
|
96
|
-
})),
|
|
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}${
|
|
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 = {},
|
|
114
|
-
const
|
|
113
|
+
function X(t = {}, e) {
|
|
114
|
+
const n = [];
|
|
115
115
|
return Object.keys(t).forEach((s) => {
|
|
116
|
-
const
|
|
116
|
+
const o = S(e, s) || {}, h = t[s];
|
|
117
117
|
if (h) {
|
|
118
|
-
const
|
|
118
|
+
const l = ` <!-- ${o.description} ${o.name}:(${o.selectable}) -->
|
|
119
119
|
<template #${s}="scope">
|
|
120
|
-
${
|
|
120
|
+
${D(h, " ")}
|
|
121
121
|
</template>`;
|
|
122
|
-
|
|
122
|
+
n.push(l);
|
|
123
123
|
}
|
|
124
|
-
}),
|
|
124
|
+
}), n && n.length > 0 && n.unshift(""), n;
|
|
125
125
|
}
|
|
126
|
-
function x(t,
|
|
127
|
-
const s =
|
|
128
|
-
return s && (s.includes("=>") || s.includes("function")) ? s :
|
|
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
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
133
|
-
let
|
|
134
|
-
${
|
|
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 (${
|
|
136
|
+
return `function (${e.param}) ${n}`;
|
|
137
137
|
} else
|
|
138
138
|
return "undefined";
|
|
139
139
|
}
|
|
140
140
|
function Y(t) {
|
|
141
|
-
const
|
|
141
|
+
const e = T(t.selectable), n = P(e);
|
|
142
142
|
let s = "";
|
|
143
143
|
t.return && (s = "return ");
|
|
144
|
-
let
|
|
145
|
-
${
|
|
144
|
+
let o = `{
|
|
145
|
+
${D(C(s), " ")}
|
|
146
146
|
}`;
|
|
147
|
-
return `function (${
|
|
147
|
+
return `function (${n}) ${o}`;
|
|
148
148
|
}
|
|
149
149
|
function _(t) {
|
|
150
|
-
const
|
|
151
|
-
return /^\(/.test(
|
|
150
|
+
const e = t.trim();
|
|
151
|
+
return /^\(/.test(e) ? E(e) : JSON.stringify(t);
|
|
152
152
|
}
|
|
153
|
-
function L(t,
|
|
154
|
-
const s =
|
|
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
|
|
158
|
-
let n =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
}) :
|
|
171
|
-
arr:
|
|
172
|
-
|
|
173
|
-
|
|
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
|
|
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 (
|
|
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,
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
return V(
|
|
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
|
|
204
|
-
return V(
|
|
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
|
-
|
|
202
|
+
z as getSpecType,
|
|
211
203
|
L as setValStringify
|
|
212
204
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("vue"),
|
|
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
|
|
2
|
-
import { isDefaultType as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
|
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(
|
|
33
|
-
const o =
|
|
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
|
-
|
|
66
|
+
V();
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
immediate: !0
|
|
70
70
|
}
|
|
71
71
|
);
|
|
72
|
-
function
|
|
73
|
-
for (let l = 0; l <
|
|
74
|
-
const t =
|
|
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
|
|
79
|
+
function p(e, l) {
|
|
80
80
|
let t = Object.assign({}, o.config);
|
|
81
81
|
if (l) {
|
|
82
|
-
const
|
|
83
|
-
|
|
82
|
+
const i = g(l);
|
|
83
|
+
i && (e = i);
|
|
84
84
|
}
|
|
85
|
-
let
|
|
86
|
-
t.type =
|
|
85
|
+
let n = w(e);
|
|
86
|
+
t.type = n[0], t.dataType = e, r.value = t;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
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
|
-
|
|
94
|
-
|
|
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"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
107
|
+
a.value = e, p(e[0].prop, x(o.modelValue)), c.value = o.modelValue;
|
|
106
108
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
+
function y(e) {
|
|
110
|
+
p(e), c.value = "";
|
|
109
111
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
+
function _(...e) {
|
|
113
|
+
d("change", ...e);
|
|
112
114
|
}
|
|
113
|
-
return (e, l) => (
|
|
114
|
-
|
|
115
|
-
u(
|
|
115
|
+
return (e, l) => (C(), j("div", k, [
|
|
116
|
+
T("div", null, [
|
|
117
|
+
u(O, {
|
|
116
118
|
noValue: "",
|
|
117
|
-
onChange:
|
|
118
|
-
modelValue:
|
|
119
|
-
list:
|
|
119
|
+
onChange: y,
|
|
120
|
+
modelValue: r.value.type,
|
|
121
|
+
list: a.value
|
|
120
122
|
}, null, 8, ["modelValue", "list"])
|
|
121
123
|
]),
|
|
122
|
-
u(
|
|
123
|
-
config:
|
|
124
|
+
u(L, {
|
|
125
|
+
config: r.value,
|
|
124
126
|
selects: o.selects,
|
|
125
|
-
modelValue:
|
|
126
|
-
onChange:
|
|
127
|
+
modelValue: c.value,
|
|
128
|
+
onChange: _
|
|
127
129
|
}, null, 8, ["config", "selects", "modelValue"])
|
|
128
130
|
]));
|
|
129
131
|
}
|
|
130
132
|
});
|
|
131
133
|
export {
|
|
132
|
-
|
|
134
|
+
D as default
|
|
133
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("vue"),
|
|
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
|
|
2
|
-
import
|
|
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
|
-
|
|
5
|
+
import { isDefaultType as S } from "./util.js";
|
|
6
|
+
const w = {
|
|
6
7
|
key: 0,
|
|
7
8
|
class: "set-props"
|
|
8
|
-
},
|
|
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(
|
|
16
|
-
const n =
|
|
17
|
-
function
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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:
|
|
30
|
-
dataType:
|
|
34
|
+
type: g,
|
|
35
|
+
dataType: V,
|
|
31
36
|
select: e
|
|
32
37
|
};
|
|
33
|
-
s.push(
|
|
38
|
+
s.push(v);
|
|
34
39
|
}
|
|
35
40
|
}), l.value = s;
|
|
36
41
|
}
|
|
37
|
-
function
|
|
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
|
|
46
|
+
function _(s, t) {
|
|
42
47
|
let e = Object.assign({}, s);
|
|
43
|
-
|
|
48
|
+
p("change", e, t);
|
|
44
49
|
}
|
|
45
50
|
let c;
|
|
46
|
-
function
|
|
51
|
+
function y() {
|
|
47
52
|
clearTimeout(c), c = setTimeout(() => {
|
|
48
|
-
|
|
53
|
+
d();
|
|
49
54
|
}, 400);
|
|
50
55
|
}
|
|
51
|
-
return
|
|
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 ? (
|
|
60
|
-
|
|
61
|
-
refresh:
|
|
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:
|
|
71
|
+
onQuery: _
|
|
67
72
|
}, null, 8, ["refresh", "modelValue", "selects", "list", "name"])
|
|
68
|
-
])) :
|
|
73
|
+
])) : x("", !0);
|
|
69
74
|
}
|
|
70
75
|
});
|
|
71
76
|
export {
|
|
72
|
-
|
|
77
|
+
q as default
|
|
73
78
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)}function
|
|
3
|
-
|\r)+?)\\}[\\s|\\n|\\r]*`,r=new RegExp("^"+n+"$").exec(e);return r&&r.length>0?
|
|
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:
|
|
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;
|