ss-component-new 1.1.72 → 1.1.73

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.
@@ -0,0 +1,288 @@
1
+ import { ref as _, watch as V, createElementBlock as C, createCommentVNode as I, openBlock as f, Fragment as le, renderList as se, createElementVNode as O, createBlock as Z, toDisplayString as v, resolveDynamicComponent as ue, onMounted as ce, createVNode as A } from "vue";
2
+ import { m as ie, a as me, b as de } from "./index-CN2pLnQT.js";
3
+ import { p as E, e as ye, g as fe, a as ge } from "./array-BtcGNRWC.js";
4
+ import { u as ee } from "./modelComp-BdUI1DVP.js";
5
+ import { s as te, u as he } from "./menu-Dez5HOn4.js";
6
+ import { _ as ne } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
+ import { c as k } from "./cloneDeep-BcUiE4Tq.js";
8
+ const x = [
9
+ {
10
+ key: "FormName",
11
+ value: "Form"
12
+ },
13
+ {
14
+ key: "TableName",
15
+ value: "Table"
16
+ }
17
+ ], s = [
18
+ {
19
+ key: "FormDirect",
20
+ value: "formFlex"
21
+ },
22
+ {
23
+ key: "Form",
24
+ value: "formContent"
25
+ },
26
+ {
27
+ key: "FormButton",
28
+ value: "formButton"
29
+ },
30
+ {
31
+ key: "TableColumns",
32
+ value: "header"
33
+ },
34
+ {
35
+ key: "TableButton",
36
+ value: "extraButton"
37
+ },
38
+ {
39
+ key: "LineButton",
40
+ value: "rowButton"
41
+ },
42
+ {
43
+ key: "Table",
44
+ value: "tableContents"
45
+ },
46
+ {
47
+ key: "TableIndex",
48
+ value: "tableIndex"
49
+ }
50
+ ], ke = {
51
+ key: 0,
52
+ class: "show-content"
53
+ }, _e = { class: "item-view-group" }, Ce = {
54
+ __name: "index",
55
+ props: {
56
+ content: String,
57
+ jsonContents: Array
58
+ },
59
+ emits: ["change"],
60
+ setup(F, { emit: B }) {
61
+ const e = F, $ = B, h = ee(E), { itemData: p } = te(h), b = _([]), w = _([]), L = (l) => {
62
+ $("change", {
63
+ wholeValue: b.value,
64
+ editValue: l
65
+ });
66
+ }, D = (l) => {
67
+ const g = k(b.value), S = g == null ? void 0 : g.map((c, j) => (j === (l == null ? void 0 : l.index) && (c.compData = l == null ? void 0 : l.contents), c));
68
+ b.value = S;
69
+ };
70
+ V(
71
+ () => p.value,
72
+ () => {
73
+ var l;
74
+ !p.value || ((l = p.value) == null ? void 0 : l.length) === 0 || (w.value = p.value, b.value = p.value);
75
+ },
76
+ { deep: !0, immediate: !0 }
77
+ ), V(
78
+ () => [e == null ? void 0 : e.content, e == null ? void 0 : e.jsonContents],
79
+ () => {
80
+ var g;
81
+ if (((g = e == null ? void 0 : e.jsonContents) == null ? void 0 : g.length) > 0) {
82
+ h.setOriginalData(e == null ? void 0 : e.jsonContents), h.setItemData(e == null ? void 0 : e.jsonContents);
83
+ return;
84
+ }
85
+ if (!(e != null && e.content) || (e == null ? void 0 : e.content) === "") return;
86
+ const l = ye(e == null ? void 0 : e.content);
87
+ h.setOriginalData(l), h.setItemData(l);
88
+ },
89
+ { deep: !0, immediate: !0 }
90
+ );
91
+ const N = (l) => fe(l);
92
+ return (l, g) => {
93
+ var S;
94
+ return ((S = w.value) == null ? void 0 : S.length) > 0 ? (f(), C("div", ke, [
95
+ (f(!0), C(le, null, se(w.value, (c, j) => (f(), C("div", {
96
+ class: "item-content",
97
+ key: j
98
+ }, [
99
+ O("div", _e, v(c.name), 1),
100
+ (f(), Z(ue(N(c.comp)), {
101
+ itemData: c == null ? void 0 : c.compData,
102
+ childItemData: c == null ? void 0 : c.itemChildData,
103
+ key: j,
104
+ onChange: L,
105
+ index: j,
106
+ onContentChange: D
107
+ }, null, 40, ["itemData", "childItemData", "index"]))
108
+ ]))), 128))
109
+ ])) : I("", !0);
110
+ };
111
+ }
112
+ }, pe = /* @__PURE__ */ ne(Ce, [["__scopeId", "data-v-869e6e20"]]), be = { class: "add-model-content" }, we = {
113
+ key: 0,
114
+ class: "model-import-data"
115
+ }, je = { class: "import-button" }, Se = { key: 0 }, xe = {
116
+ key: 1,
117
+ class: "model-operate"
118
+ }, Oe = { class: "model-select" }, Ie = { class: "model-fill" }, Ne = {
119
+ key: 2,
120
+ class: "model-view ssComponent"
121
+ }, Te = {
122
+ __name: "main",
123
+ props: {
124
+ mode: {
125
+ type: String,
126
+ default: "view"
127
+ },
128
+ content: {
129
+ type: String,
130
+ default: ""
131
+ },
132
+ jsonContents: {
133
+ type: Array,
134
+ default: () => []
135
+ },
136
+ showButton: {
137
+ type: Boolean,
138
+ default: !0
139
+ }
140
+ },
141
+ emits: ["change"],
142
+ setup(F, { emit: B }) {
143
+ const e = F, $ = B, h = _(""), p = _([]), b = _(0), w = ee(E);
144
+ he(E);
145
+ const { itemData: L, originalData: D } = te(w), N = _(null), l = _(0), g = _(""), S = () => {
146
+ b.value = window.innerWidth;
147
+ }, c = async (o) => {
148
+ var u;
149
+ const a = (u = k(o == null ? void 0 : o.wholeValue)) == null ? void 0 : u.map((n) => {
150
+ var d;
151
+ return (n == null ? void 0 : n.comp) === "Form" && (n.compData = (d = n.compData) == null ? void 0 : d.map((y) => ((y == null ? void 0 : y.key) === "formContent" && (y.contents = ge(y == null ? void 0 : y.contents)), y))), n;
152
+ });
153
+ $("change", {
154
+ originalContents: D.value,
155
+ currentContents: o == null ? void 0 : o.wholeValue,
156
+ editContent: o == null ? void 0 : o.editValue,
157
+ stringContent: j(k(o == null ? void 0 : o.wholeValue)),
158
+ arrayToContents: a
159
+ });
160
+ }, j = (o) => {
161
+ var u;
162
+ let a = [];
163
+ return (u = k(o)) == null || u.forEach((n) => {
164
+ var d, y;
165
+ x != null && x.find((t) => (t == null ? void 0 : t.value) === (n == null ? void 0 : n.comp)) && a.push(((d = x == null ? void 0 : x.find((t) => (t == null ? void 0 : t.value) === (n == null ? void 0 : n.comp))) == null ? void 0 : d.key) + "=" + n.name + "/r/n"), (y = n == null ? void 0 : n.compData) == null || y.forEach((t) => {
166
+ var M, R, z, W, q, G, H, K, P, Q, U, X;
167
+ if (s != null && s.find((i) => (i == null ? void 0 : i.value) === (t == null ? void 0 : t.key)))
168
+ if (!((M = t == null ? void 0 : t.contents) != null && M.length))
169
+ a.push(((R = s == null ? void 0 : s.find((i) => (i == null ? void 0 : i.value) === (t == null ? void 0 : t.key))) == null ? void 0 : R.key) + "=" + (t.contents === !0 ? '""' : "Vertical") + "/r/n");
170
+ else {
171
+ let i = (z = t == null ? void 0 : t.contents) == null ? void 0 : z[0];
172
+ if (!i) return;
173
+ if (Object.keys(i).includes("label") && Object.keys(i).includes("key") && Object.keys(i).includes("width"))
174
+ if (((q = (W = t.contents) == null ? void 0 : W.filter((m) => m.width !== 1)) == null ? void 0 : q.length) === 0) {
175
+ const m = (G = k(t == null ? void 0 : t.contents)) == null ? void 0 : G.map((r) => ({ [r.label]: r.value }));
176
+ a.push(((H = s == null ? void 0 : s.find((r) => (r == null ? void 0 : r.value) === (t == null ? void 0 : t.key))) == null ? void 0 : H.key) + "=" + JSON.stringify(m) + "/r/n");
177
+ } else {
178
+ let m = [];
179
+ (K = k(t == null ? void 0 : t.contents)) == null || K.reduce((r, J) => {
180
+ var Y;
181
+ return r[J.label] = J.key, ((Y = Object.keys(k(r))) == null ? void 0 : Y.length) >= J.width && (m.push(k(r)), r = {}), r;
182
+ }, {}), a.push(((P = s == null ? void 0 : s.find((r) => (r == null ? void 0 : r.value) === (t == null ? void 0 : t.key))) == null ? void 0 : P.key) + "=" + JSON.stringify(m) + "/r/n");
183
+ }
184
+ else if (Object.keys(i).includes("label")) {
185
+ const m = (Q = k(t == null ? void 0 : t.contents)) == null ? void 0 : Q.map((r) => r.label);
186
+ a.push(((U = s == null ? void 0 : s.find((r) => (r == null ? void 0 : r.value) === (t == null ? void 0 : t.key))) == null ? void 0 : U.key) + "=" + JSON.stringify(m) + "/r/n");
187
+ } else
188
+ a.push(((X = s == null ? void 0 : s.find((m) => (m == null ? void 0 : m.value) === (t == null ? void 0 : t.key))) == null ? void 0 : X.key) + "=" + JSON.stringify(t == null ? void 0 : t.contents) + "/r/n");
189
+ }
190
+ });
191
+ }), JSON.stringify(a);
192
+ }, T = _([]), ae = () => {
193
+ N.value.click();
194
+ }, oe = (o) => {
195
+ const a = o.target.files[0];
196
+ if (!a) return;
197
+ const u = new FileReader();
198
+ u.onload = (n) => {
199
+ try {
200
+ h.value = n.target.result, T.value = re(n.target.result), l.value++;
201
+ } catch (d) {
202
+ console.error("解析失败:", d);
203
+ }
204
+ }, u.onerror = (n) => {
205
+ console.error("文件读取错误:", n);
206
+ }, u.readAsText(a);
207
+ };
208
+ ce(() => {
209
+ window.addEventListener("resize", S);
210
+ }), V(
211
+ () => [e == null ? void 0 : e.content, e == null ? void 0 : e.jsonContents],
212
+ () => {
213
+ h.value = e == null ? void 0 : e.content, p.value = e == null ? void 0 : e.jsonContents;
214
+ },
215
+ { deep: !0, immediate: !0 }
216
+ ), V(
217
+ () => l.value,
218
+ () => {
219
+ var o;
220
+ ((o = T.value) == null ? void 0 : o.length) !== 0 && (w.setOriginalData(T.value), w.setItemData(T.value));
221
+ },
222
+ { deep: !0, immediate: !0 }
223
+ );
224
+ const re = (o) => {
225
+ let a = o.replace(/,/g, ",").replace(/;/g, ";").replace(/:/g, ":");
226
+ a = a.replace(/(\w+)\s*:/g, "$1:"), a = a.replace(/\r\n/g, "").replace(/\n/g, "").replace(/\t/g, "").replace(/\s+/g, " ").trim(), a = a.replace(/,\s*([}\]])/g, "$1"), a = a.replace(/:(\s*)([^"{}\[\],\s]+)(\s*)([,}])/g, ": $2$4");
227
+ try {
228
+ return JSON.parse(a);
229
+ } catch (u) {
230
+ try {
231
+ const d = new Function(`return ${a}`)();
232
+ if (Array.isArray(d) || typeof d == "object")
233
+ return d;
234
+ throw new Error(`解析结果不是有效的数组或对象: ${u}`);
235
+ } catch (n) {
236
+ throw new Error(`无法解析JSON: ${n.message}`);
237
+ }
238
+ }
239
+ };
240
+ return (o, a) => {
241
+ var u;
242
+ return f(), C("div", be, [
243
+ ((u = e == null ? void 0 : e.jsonContents) == null ? void 0 : u.length) === 0 ? (f(), C("div", we, [
244
+ O("div", je, [
245
+ O("input", {
246
+ type: "file",
247
+ ref_key: "fileInput",
248
+ ref: N,
249
+ accept: ".txt",
250
+ onChange: oe,
251
+ style: { display: "none" }
252
+ }, null, 544),
253
+ O("button", {
254
+ onClick: ae,
255
+ class: "import-button-content"
256
+ }, "导入文件"),
257
+ g.value ? (f(), C("span", Se, v(g.value), 1)) : I("", !0)
258
+ ])
259
+ ])) : I("", !0),
260
+ (e == null ? void 0 : e.mode) === "edit" ? (f(), C("div", xe, [
261
+ O("div", Oe, [
262
+ A(ie)
263
+ ]),
264
+ (f(), C("div", {
265
+ class: "model-show",
266
+ key: b.value
267
+ }, [
268
+ A(me)
269
+ ])),
270
+ O("div", Ie, [
271
+ A(de)
272
+ ])
273
+ ])) : I("", !0),
274
+ (e == null ? void 0 : e.mode) === "view" ? (f(), C("div", Ne, [
275
+ (f(), Z(pe, {
276
+ content: h.value,
277
+ onChange: c,
278
+ jsonContents: p.value,
279
+ key: b.value
280
+ }, null, 8, ["content", "jsonContents"]))
281
+ ])) : I("", !0)
282
+ ]);
283
+ };
284
+ }
285
+ }, Ee = /* @__PURE__ */ ne(Te, [["__scopeId", "data-v-b25bde75"]]);
286
+ export {
287
+ Ee as default
288
+ };