@xto/business 0.1.0

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/es/index.mjs ADDED
@@ -0,0 +1,661 @@
1
+ import { defineComponent as N, ref as R, computed as L, openBlock as c, createElementBlock as d, normalizeClass as a, unref as t, createVNode as H, withCtx as E, Fragment as W, renderList as M, createBlock as I, withKeys as Q, createCommentVNode as B, createTextVNode as P, createElementVNode as u, renderSlot as K, toDisplayString as S, normalizeStyle as j, reactive as Y, withDirectives as D, vModelSelect as Z, watch as _, vShow as G, nextTick as ee } from "vue";
2
+ import { useNamespace as F } from "@xto/core";
3
+ import { Space as A, Button as q } from "@xto/base";
4
+ import { Input as X } from "@xto/form";
5
+ import { Pagination as te } from "@xto/data";
6
+ const le = ["colspan"], ae = ["colspan"], ne = ["value"], ye = /* @__PURE__ */ N({
7
+ name: "XProTable",
8
+ __name: "index",
9
+ props: {
10
+ columns: {},
11
+ data: { default: () => [] },
12
+ loading: { type: Boolean, default: !1 },
13
+ pagination: { type: Boolean, default: !0 },
14
+ pageSize: { default: 10 },
15
+ currentPage: { default: 1 },
16
+ total: { default: 0 },
17
+ selection: { type: Boolean, default: !1 },
18
+ index: { type: Boolean, default: !1 },
19
+ indexLabel: { default: "#" }
20
+ },
21
+ emits: ["update:data", "update:currentPage", "update:pageSize", "search", "refresh", "reset"],
22
+ setup(e, { emit: p }) {
23
+ const o = e, n = p, l = F("pro-table"), s = R({});
24
+ R([]), L({
25
+ get: () => o.data,
26
+ set: (i) => n("update:data", i)
27
+ });
28
+ const $ = (i) => {
29
+ n("update:currentPage", i), n("search", { ...s.value, page: i });
30
+ }, g = (i) => {
31
+ n("update:pageSize", i), n("search", { ...s.value, pageSize: i });
32
+ }, x = () => {
33
+ n("search", s.value);
34
+ }, v = () => {
35
+ s.value = {}, n("reset"), n("search", {});
36
+ }, y = () => {
37
+ n("refresh");
38
+ }, r = L(
39
+ () => o.columns.filter((i) => i.search)
40
+ );
41
+ return (i, f) => (c(), d("div", {
42
+ class: a(t(l).b())
43
+ }, [
44
+ r.value.length > 0 ? (c(), d("div", {
45
+ key: 0,
46
+ class: a(t(l).e("search"))
47
+ }, [
48
+ H(t(A), null, {
49
+ default: E(() => [
50
+ (c(!0), d(W, null, M(r.value, (h) => (c(), d(W, {
51
+ key: h.prop
52
+ }, [
53
+ h.searchType === "input" || !h.searchType ? (c(), I(t(X), {
54
+ key: 0,
55
+ modelValue: s.value[h.prop],
56
+ "onUpdate:modelValue": (b) => s.value[h.prop] = b,
57
+ placeholder: `请输入${h.label}`,
58
+ clearable: "",
59
+ onKeyup: Q(x, ["enter"])
60
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : B("", !0)
61
+ ], 64))), 128)),
62
+ H(t(q), {
63
+ type: "primary",
64
+ onClick: x
65
+ }, {
66
+ default: E(() => [...f[0] || (f[0] = [
67
+ P("搜索", -1)
68
+ ])]),
69
+ _: 1
70
+ }),
71
+ H(t(q), { onClick: v }, {
72
+ default: E(() => [...f[1] || (f[1] = [
73
+ P("重置", -1)
74
+ ])]),
75
+ _: 1
76
+ }),
77
+ H(t(q), { onClick: y }, {
78
+ default: E(() => [...f[2] || (f[2] = [
79
+ P("刷新", -1)
80
+ ])]),
81
+ _: 1
82
+ })
83
+ ]),
84
+ _: 1
85
+ })
86
+ ], 2)) : B("", !0),
87
+ u("div", {
88
+ class: a(t(l).e("toolbar"))
89
+ }, [
90
+ H(t(A), null, {
91
+ default: E(() => [
92
+ K(i.$slots, "toolbar")
93
+ ]),
94
+ _: 3
95
+ })
96
+ ], 2),
97
+ u("div", {
98
+ class: a(t(l).e("table-wrapper"))
99
+ }, [
100
+ u("table", {
101
+ class: a(t(l).e("table"))
102
+ }, [
103
+ u("thead", null, [
104
+ u("tr", null, [
105
+ e.selection ? (c(), d("th", {
106
+ key: 0,
107
+ class: a(t(l).e("selection"))
108
+ }, [...f[3] || (f[3] = [
109
+ u("input", { type: "checkbox" }, null, -1)
110
+ ])], 2)) : B("", !0),
111
+ e.index ? (c(), d("th", {
112
+ key: 1,
113
+ class: a(t(l).e("index"))
114
+ }, S(e.indexLabel), 3)) : B("", !0),
115
+ (c(!0), d(W, null, M(e.columns, (h) => (c(), d("th", {
116
+ key: h.prop,
117
+ class: a(t(l).e("column")),
118
+ style: j({
119
+ width: h.width,
120
+ minWidth: h.minWidth,
121
+ textAlign: h.align || "left"
122
+ })
123
+ }, S(h.label), 7))), 128))
124
+ ])
125
+ ]),
126
+ u("tbody", null, [
127
+ e.loading ? (c(), d("tr", {
128
+ key: 0,
129
+ class: a(t(l).e("loading-row"))
130
+ }, [
131
+ u("td", {
132
+ colspan: e.columns.length + (e.selection ? 1 : 0) + (e.index ? 1 : 0)
133
+ }, [
134
+ u("div", {
135
+ class: a(t(l).e("loading"))
136
+ }, " 加载中... ", 2)
137
+ ], 8, le)
138
+ ], 2)) : e.data.length === 0 ? (c(), d("tr", {
139
+ key: 1,
140
+ class: a(t(l).e("empty-row"))
141
+ }, [
142
+ u("td", {
143
+ colspan: e.columns.length + (e.selection ? 1 : 0) + (e.index ? 1 : 0)
144
+ }, [
145
+ u("div", {
146
+ class: a(t(l).e("empty"))
147
+ }, " 暂无数据 ", 2)
148
+ ], 8, ae)
149
+ ], 2)) : (c(!0), d(W, { key: 2 }, M(e.data, (h, b) => (c(), d("tr", {
150
+ key: b,
151
+ class: a(t(l).e("row"))
152
+ }, [
153
+ e.selection ? (c(), d("td", {
154
+ key: 0,
155
+ class: a(t(l).e("selection"))
156
+ }, [
157
+ u("input", {
158
+ type: "checkbox",
159
+ value: h
160
+ }, null, 8, ne)
161
+ ], 2)) : B("", !0),
162
+ e.index ? (c(), d("td", {
163
+ key: 1,
164
+ class: a(t(l).e("index"))
165
+ }, S((e.currentPage - 1) * e.pageSize + b + 1), 3)) : B("", !0),
166
+ (c(!0), d(W, null, M(e.columns, (C) => {
167
+ var V;
168
+ return c(), d("td", {
169
+ key: C.prop,
170
+ class: a(t(l).e("cell")),
171
+ style: j({ textAlign: C.align || "left" })
172
+ }, [
173
+ K(i.$slots, (V = C.slots) == null ? void 0 : V.default, {
174
+ row: h,
175
+ column: C
176
+ }, () => [
177
+ P(S(C.formatter ? C.formatter(h, C, h[C.prop]) : h[C.prop]), 1)
178
+ ])
179
+ ], 6);
180
+ }), 128))
181
+ ], 2))), 128))
182
+ ])
183
+ ], 2)
184
+ ], 2),
185
+ e.pagination ? (c(), d("div", {
186
+ key: 1,
187
+ class: a(t(l).e("pagination"))
188
+ }, [
189
+ H(t(te), {
190
+ total: e.total,
191
+ "page-size": e.pageSize,
192
+ "current-page": e.currentPage,
193
+ layout: "total, sizes, prev, pager, next, jumper",
194
+ onCurrentChange: $,
195
+ onSizeChange: g
196
+ }, null, 8, ["total", "page-size", "current-page"])
197
+ ], 2)) : B("", !0)
198
+ ], 2));
199
+ }
200
+ }), se = ["onUpdate:modelValue"], oe = ["value"], be = /* @__PURE__ */ N({
201
+ name: "XSearchForm",
202
+ __name: "index",
203
+ props: {
204
+ columns: { default: () => [] },
205
+ model: { default: () => ({}) },
206
+ labelWidth: { default: "100px" },
207
+ labelPosition: { default: "right" }
208
+ },
209
+ emits: ["search", "reset"],
210
+ setup(e, { emit: p }) {
211
+ const o = e, n = p, l = F("search-form"), s = Y({});
212
+ o.columns.forEach((v) => {
213
+ v.defaultValue !== void 0 ? s[v.prop] = v.defaultValue : o.model[v.prop] !== void 0 && (s[v.prop] = o.model[v.prop]);
214
+ });
215
+ const $ = () => {
216
+ n("search", { ...s });
217
+ }, g = () => {
218
+ o.columns.forEach((v) => {
219
+ s[v.prop] = v.defaultValue;
220
+ }), n("reset");
221
+ }, x = L(() => ({
222
+ width: typeof o.labelWidth == "number" ? `${o.labelWidth}px` : o.labelWidth
223
+ }));
224
+ return (v, y) => (c(), d("div", {
225
+ class: a(t(l).b())
226
+ }, [
227
+ u("div", {
228
+ class: a(t(l).e("items"))
229
+ }, [
230
+ (c(!0), d(W, null, M(e.columns, (r) => (c(), d("div", {
231
+ key: r.prop,
232
+ class: a(t(l).e("item"))
233
+ }, [
234
+ u("label", {
235
+ class: a(t(l).e("label")),
236
+ style: j(x.value)
237
+ }, S(r.label), 7),
238
+ u("div", {
239
+ class: a(t(l).e("content"))
240
+ }, [
241
+ r.type === "input" || !r.type ? (c(), I(t(X), {
242
+ key: 0,
243
+ modelValue: s[r.prop],
244
+ "onUpdate:modelValue": (i) => s[r.prop] = i,
245
+ placeholder: r.placeholder || `请输入${r.label}`,
246
+ clearable: ""
247
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : r.type === "select" ? D((c(), d("select", {
248
+ key: 1,
249
+ "onUpdate:modelValue": (i) => s[r.prop] = i,
250
+ class: a(t(l).e("select"))
251
+ }, [
252
+ y[0] || (y[0] = u("option", { value: "" }, "请选择", -1)),
253
+ (c(!0), d(W, null, M(r.options, (i) => (c(), d("option", {
254
+ key: i.value,
255
+ value: i.value
256
+ }, S(i.label), 9, oe))), 128))
257
+ ], 10, se)), [
258
+ [Z, s[r.prop]]
259
+ ]) : r.type === "date" ? (c(), I(t(X), {
260
+ key: 2,
261
+ modelValue: s[r.prop],
262
+ "onUpdate:modelValue": (i) => s[r.prop] = i,
263
+ type: "date",
264
+ placeholder: r.placeholder || `请选择${r.label}`
265
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : (c(), I(t(X), {
266
+ key: 3,
267
+ modelValue: s[r.prop],
268
+ "onUpdate:modelValue": (i) => s[r.prop] = i,
269
+ placeholder: r.placeholder || `请输入${r.label}`
270
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"]))
271
+ ], 2)
272
+ ], 2))), 128))
273
+ ], 2),
274
+ u("div", {
275
+ class: a(t(l).e("actions"))
276
+ }, [
277
+ H(t(A), null, {
278
+ default: E(() => [
279
+ H(t(q), {
280
+ type: "primary",
281
+ onClick: $
282
+ }, {
283
+ default: E(() => [...y[1] || (y[1] = [
284
+ P("搜索", -1)
285
+ ])]),
286
+ _: 1
287
+ }),
288
+ H(t(q), { onClick: g }, {
289
+ default: E(() => [...y[2] || (y[2] = [
290
+ P("重置", -1)
291
+ ])]),
292
+ _: 1
293
+ })
294
+ ]),
295
+ _: 1
296
+ })
297
+ ], 2)
298
+ ], 2));
299
+ }
300
+ }), ke = /* @__PURE__ */ N({
301
+ name: "XStatistic",
302
+ __name: "index",
303
+ props: {
304
+ title: { default: "" },
305
+ value: { default: 0 },
306
+ suffix: { default: "" },
307
+ prefix: { default: "" },
308
+ precision: { default: 0 },
309
+ trend: { default: "" },
310
+ trendValue: { default: 0 },
311
+ color: {},
312
+ titleColor: {},
313
+ valueColor: {}
314
+ },
315
+ setup(e) {
316
+ const p = e, o = F("statistic"), n = L(() => typeof p.value == "number" ? p.value.toFixed(p.precision) : p.value), l = L(() => [
317
+ o.e("trend"),
318
+ o.em("trend", p.trend)
319
+ ]), s = L(() => p.trend === "up" ? "↑" : p.trend === "down" ? "↓" : "");
320
+ return ($, g) => (c(), d("div", {
321
+ class: a(t(o).b())
322
+ }, [
323
+ u("div", {
324
+ class: a(t(o).e("title")),
325
+ style: j({ color: e.titleColor })
326
+ }, S(e.title), 7),
327
+ u("div", {
328
+ class: a(t(o).e("content"))
329
+ }, [
330
+ e.prefix ? (c(), d("span", {
331
+ key: 0,
332
+ class: a(t(o).e("prefix"))
333
+ }, S(e.prefix), 3)) : B("", !0),
334
+ u("span", {
335
+ class: a(t(o).e("value")),
336
+ style: j({ color: e.valueColor })
337
+ }, S(n.value), 7),
338
+ e.suffix ? (c(), d("span", {
339
+ key: 1,
340
+ class: a(t(o).e("suffix"))
341
+ }, S(e.suffix), 3)) : B("", !0)
342
+ ], 2),
343
+ e.trend ? (c(), d("div", {
344
+ key: 0,
345
+ class: a(l.value)
346
+ }, [
347
+ u("span", {
348
+ class: a(t(o).e("trend-icon"))
349
+ }, S(s.value), 3),
350
+ u("span", {
351
+ class: a(t(o).e("trend-value"))
352
+ }, S(e.trendValue), 3)
353
+ ], 2)) : B("", !0)
354
+ ], 2));
355
+ }
356
+ }), $e = /* @__PURE__ */ N({
357
+ name: "XExport",
358
+ __name: "index",
359
+ props: {
360
+ data: { default: () => [] },
361
+ filename: { default: "export" },
362
+ sheetName: { default: "Sheet1" },
363
+ columns: { default: () => [] }
364
+ },
365
+ setup(e) {
366
+ const p = e, o = R(!1), n = () => {
367
+ if (p.data.length !== 0) {
368
+ o.value = !0;
369
+ try {
370
+ const l = p.columns.length > 0 ? p.columns.map((y) => y.title) : Object.keys(p.data[0]), s = p.columns.length > 0 ? p.columns.map((y) => y.key) : Object.keys(p.data[0]), $ = [
371
+ l.join(","),
372
+ ...p.data.map(
373
+ (y) => s.map((r) => {
374
+ const i = y[r];
375
+ return typeof i == "string" && (i.includes(",") || i.includes('"')) ? `"${i.replace(/"/g, '""')}"` : i;
376
+ }).join(",")
377
+ )
378
+ ].join(`
379
+ `), g = new Blob([$], { type: "text/csv;charset=utf-8;" }), x = URL.createObjectURL(g), v = document.createElement("a");
380
+ v.href = x, v.download = `${p.filename}.csv`, document.body.appendChild(v), v.click(), document.body.removeChild(v), URL.revokeObjectURL(x);
381
+ } catch (l) {
382
+ console.error("Export failed:", l);
383
+ } finally {
384
+ o.value = !1;
385
+ }
386
+ }
387
+ };
388
+ return (l, s) => (c(), I(t(q), {
389
+ loading: o.value,
390
+ onClick: n
391
+ }, {
392
+ default: E(() => [...s[0] || (s[0] = [
393
+ P("导出", -1)
394
+ ])]),
395
+ icon: E(() => [...s[1] || (s[1] = [
396
+ P("📥", -1)
397
+ ])]),
398
+ _: 1
399
+ }, 8, ["loading"]));
400
+ }
401
+ });
402
+ function J(e) {
403
+ const p = {
404
+ "&": "&",
405
+ "<": "&lt;",
406
+ ">": "&gt;",
407
+ '"': "&quot;",
408
+ "'": "&#039;"
409
+ };
410
+ return e.replace(/[&<>"']/g, (o) => p[o]);
411
+ }
412
+ function z(e) {
413
+ return e = e.replace(/`([^`]+)`/g, '<code class="md-code">$1</code>'), e = e.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>"), e = e.replace(/__([^_]+)__/g, "<strong>$1</strong>"), e = e.replace(/\*([^*]+)\*/g, "<em>$1</em>"), e = e.replace(/_([^_]+)_/g, "<em>$1</em>"), e = e.replace(/~~([^~]+)~~/g, "<del>$1</del>"), e = e.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" class="md-link">$1</a>'), e = e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" class="md-image" />'), e;
414
+ }
415
+ function ie(e, p = {}) {
416
+ const o = e.split(`
417
+ `), n = [];
418
+ let l = !1, s = "", $ = [], g = !1, x = "", v = !1, y = !1;
419
+ const r = () => {
420
+ g && (n.push(`</${x}>`), g = !1, x = "");
421
+ }, i = () => {
422
+ v && (n.push("</blockquote>"), v = !1);
423
+ }, f = () => {
424
+ y && (n.push("</table>"), y = !1);
425
+ };
426
+ for (let h = 0; h < o.length; h++) {
427
+ let b = o[h];
428
+ if (b.startsWith("```")) {
429
+ l ? (n.push(`<pre class="md-code-block"><code class="language-${s}">${J($.join(`
430
+ `))}</code></pre>`), l = !1, s = "", $ = []) : (r(), i(), f(), l = !0, s = b.slice(3).trim(), $ = []);
431
+ continue;
432
+ }
433
+ if (l) {
434
+ $.push(b);
435
+ continue;
436
+ }
437
+ if (b.trim().startsWith("|") && b.trim().endsWith("|")) {
438
+ y || (r(), i(), y = !0, n.push('<table class="md-table">'));
439
+ const m = b.trim().slice(1, -1).split("|").map((T) => T.trim());
440
+ if (m.every((T) => /^[-:]+$/.test(T)))
441
+ continue;
442
+ if ((h === 0 || h > 0 && !o[h - 1].trim().startsWith("|")) && h < o.length - 1) {
443
+ const T = o[h + 1];
444
+ if (T && T.trim().startsWith("|") && T.trim().endsWith("|") && T.trim().slice(1, -1).split("|").map((U) => U.trim()).every((U) => /^[-:]+$/.test(U))) {
445
+ n.push("<thead><tr>"), m.forEach((U) => {
446
+ n.push(`<th>${z(U)}</th>`);
447
+ }), n.push("</tr></thead><tbody>");
448
+ continue;
449
+ }
450
+ }
451
+ n.push("<tr>"), m.forEach((T) => {
452
+ n.push(`<td>${z(T)}</td>`);
453
+ }), n.push("</tr>");
454
+ continue;
455
+ } else y && (n.push("</tbody>"), f());
456
+ if (!b.trim()) {
457
+ r(), i(), f();
458
+ continue;
459
+ }
460
+ if (b.startsWith(">")) {
461
+ r(), v || (n.push('<blockquote class="md-blockquote">'), v = !0);
462
+ const m = b.replace(/^>\s?/, "");
463
+ n.push(`<p>${z(m)}</p>`);
464
+ continue;
465
+ } else v && i();
466
+ const C = b.match(/^(#{1,6})\s+(.+)$/);
467
+ if (C) {
468
+ r();
469
+ const m = C[1].length, w = z(C[2]);
470
+ n.push(`<h${m} class="md-heading md-h${m}">${w}</h${m}>`);
471
+ continue;
472
+ }
473
+ if (/^[-*_]{3,}$/.test(b.trim())) {
474
+ r(), n.push('<hr class="md-hr" />');
475
+ continue;
476
+ }
477
+ const V = b.match(/^[-*+]\s+(.+)$/);
478
+ if (V) {
479
+ (!g || x !== "ul") && (r(), n.push('<ul class="md-list">'), g = !0, x = "ul"), n.push(`<li>${z(V[1])}</li>`);
480
+ continue;
481
+ }
482
+ const k = b.match(/^(\d+)\.\s+(.+)$/);
483
+ if (k) {
484
+ (!g || x !== "ol") && (r(), n.push('<ol class="md-list">'), g = !0, x = "ol"), n.push(`<li>${z(k[2])}</li>`);
485
+ continue;
486
+ }
487
+ r(), p.breaks !== !1 ? n.push(`<p class="md-paragraph">${z(b)}</p>`) : n.push(`<p class="md-paragraph">${z(b)}</p>`);
488
+ }
489
+ return r(), i(), f(), l && n.push(`<pre class="md-code-block"><code>${J($.join(`
490
+ `))}</code></pre>`), n.join(`
491
+ `);
492
+ }
493
+ function re(e) {
494
+ const p = [];
495
+ return e.split(`
496
+ `).forEach((n, l) => {
497
+ const s = n.match(/^(#{1,6})\s+(.+)$/);
498
+ if (s) {
499
+ const $ = s[1].length, g = s[2].trim(), x = `heading-${l}`;
500
+ p.push({ level: $, text: g, id: x });
501
+ }
502
+ }), p;
503
+ }
504
+ const ce = ["title", "disabled", "onClick"], ue = { key: 0 }, de = ["value", "placeholder", "disabled"], pe = ["innerHTML"], xe = /* @__PURE__ */ N({
505
+ name: "XMarkdownEditor",
506
+ __name: "index",
507
+ props: {
508
+ modelValue: { default: "" },
509
+ placeholder: { default: "请输入 Markdown 内容..." },
510
+ height: { default: 400 },
511
+ mode: { default: "split" },
512
+ showToolbar: { type: Boolean, default: !0 },
513
+ showToc: { type: Boolean, default: !1 },
514
+ disabled: { type: Boolean, default: !1 }
515
+ },
516
+ emits: ["update:modelValue", "change"],
517
+ setup(e, { emit: p }) {
518
+ const o = e, n = p, l = F("markdown-editor"), s = R(o.modelValue), $ = R(), g = R(o.mode), x = L(() => ie(s.value)), v = L(() => re(s.value)), y = L(() => ({
519
+ height: typeof o.height == "number" ? `${o.height}px` : o.height
520
+ }));
521
+ _(() => o.modelValue, (V) => {
522
+ s.value = V;
523
+ });
524
+ const r = (V) => {
525
+ const k = V.target.value;
526
+ s.value = k, n("update:modelValue", k), n("change", k);
527
+ }, i = (V) => {
528
+ g.value = V;
529
+ }, f = (V, k = "") => {
530
+ if (!$.value || o.disabled) return;
531
+ const m = $.value, w = m.selectionStart, T = m.selectionEnd, O = s.value.substring(w, T), U = s.value.substring(0, w) + V + O + k + s.value.substring(T);
532
+ s.value = U, n("update:modelValue", U), n("change", U), ee(() => {
533
+ m.focus(), m.setSelectionRange(w + V.length, w + V.length + O.length);
534
+ });
535
+ }, h = [
536
+ { icon: "H1", title: "标题1", action: () => f("# ", "") },
537
+ { icon: "H2", title: "标题2", action: () => f("## ", "") },
538
+ { icon: "H3", title: "标题3", action: () => f("### ", "") },
539
+ { type: "divider" },
540
+ { icon: "B", title: "粗体", action: () => f("**", "**") },
541
+ { icon: "I", title: "斜体", action: () => f("*", "*") },
542
+ { icon: "S", title: "删除线", action: () => f("~~", "~~") },
543
+ { type: "divider" },
544
+ { icon: "•", title: "无序列表", action: () => f("- ", "") },
545
+ { icon: "1.", title: "有序列表", action: () => f("1. ", "") },
546
+ { type: "divider" },
547
+ { icon: "🔗", title: "链接", action: () => f("[", "](url)") },
548
+ { icon: "🖼", title: "图片", action: () => f("![alt](", ")") },
549
+ { icon: "</>", title: "代码", action: () => f("`", "`") },
550
+ { type: "divider" },
551
+ { icon: "—", title: "分割线", action: () => f(`
552
+ ---
553
+ `, "") },
554
+ { icon: "□", title: "引用", action: () => f("> ", "") },
555
+ { icon: "```", title: "代码块", action: () => f("\n```\n", "\n```\n") }
556
+ ], b = L(() => [
557
+ l.b(),
558
+ l.is("disabled", o.disabled),
559
+ l.is(`mode-${g.value}`)
560
+ ]), C = (V) => {
561
+ if (g.value !== "split") return;
562
+ const k = document.querySelector(".x-markdown-editor__preview");
563
+ if (!k) return;
564
+ const m = V.target, w = m.scrollTop / (m.scrollHeight - m.clientHeight);
565
+ k.scrollTop = w * (k.scrollHeight - k.clientHeight);
566
+ };
567
+ return (V, k) => (c(), d("div", {
568
+ class: a(b.value),
569
+ style: j(y.value)
570
+ }, [
571
+ e.showToolbar ? (c(), d("div", {
572
+ key: 0,
573
+ class: a(t(l).e("toolbar"))
574
+ }, [
575
+ u("div", {
576
+ class: a(t(l).e("toolbar-left"))
577
+ }, [
578
+ (c(), d(W, null, M(h, (m, w) => u("button", {
579
+ key: w,
580
+ class: a([t(l).e("toolbar-btn"), { "is-divider": m.type === "divider" }]),
581
+ title: m.title,
582
+ disabled: e.disabled,
583
+ onClick: m.action
584
+ }, [
585
+ m.type ? B("", !0) : (c(), d("span", ue, S(m.icon), 1))
586
+ ], 10, ce)), 64))
587
+ ], 2),
588
+ u("div", {
589
+ class: a(t(l).e("toolbar-right"))
590
+ }, [
591
+ u("button", {
592
+ class: a([t(l).e("mode-btn"), { "is-active": g.value === "edit" }]),
593
+ onClick: k[0] || (k[0] = (m) => i("edit"))
594
+ }, " 编辑 ", 2),
595
+ u("button", {
596
+ class: a([t(l).e("mode-btn"), { "is-active": g.value === "split" }]),
597
+ onClick: k[1] || (k[1] = (m) => i("split"))
598
+ }, " 分屏 ", 2),
599
+ u("button", {
600
+ class: a([t(l).e("mode-btn"), { "is-active": g.value === "preview" }]),
601
+ onClick: k[2] || (k[2] = (m) => i("preview"))
602
+ }, " 预览 ", 2)
603
+ ], 2)
604
+ ], 2)) : B("", !0),
605
+ u("div", {
606
+ class: a(t(l).e("body"))
607
+ }, [
608
+ e.showToc && v.value.length > 0 ? (c(), d("div", {
609
+ key: 0,
610
+ class: a(t(l).e("toc"))
611
+ }, [
612
+ u("div", {
613
+ class: a(t(l).e("toc-title"))
614
+ }, "目录", 2),
615
+ u("ul", {
616
+ class: a(t(l).e("toc-list"))
617
+ }, [
618
+ (c(!0), d(W, null, M(v.value, (m, w) => (c(), d("li", {
619
+ key: w,
620
+ class: a(t(l).e("toc-item")),
621
+ style: j({ paddingLeft: (m.level - 1) * 12 + "px" })
622
+ }, S(m.text), 7))), 128))
623
+ ], 2)
624
+ ], 2)) : B("", !0),
625
+ u("div", {
626
+ class: a(t(l).e("content"))
627
+ }, [
628
+ D(u("div", {
629
+ class: a(t(l).e("editor-wrapper"))
630
+ }, [
631
+ u("textarea", {
632
+ ref_key: "editorRef",
633
+ ref: $,
634
+ class: a(t(l).e("editor")),
635
+ value: s.value,
636
+ placeholder: e.placeholder,
637
+ disabled: e.disabled,
638
+ onInput: r,
639
+ onScroll: C
640
+ }, null, 42, de)
641
+ ], 2), [
642
+ [G, g.value !== "preview"]
643
+ ]),
644
+ D(u("div", {
645
+ class: a(t(l).e("preview")),
646
+ innerHTML: x.value
647
+ }, null, 10, pe), [
648
+ [G, g.value !== "edit"]
649
+ ])
650
+ ], 2)
651
+ ], 2)
652
+ ], 6));
653
+ }
654
+ });
655
+ export {
656
+ $e as Export,
657
+ xe as MarkdownEditor,
658
+ ye as ProTable,
659
+ be as SearchForm,
660
+ ke as Statistic
661
+ };
package/es/style.css ADDED
@@ -0,0 +1 @@
1
+ .x-pro-table{background-color:#fff;border-radius:4px}.x-pro-table__search{padding:18px 20px 0;margin-bottom:16px}.x-pro-table__toolbar{padding:0 20px 16px;display:flex;justify-content:space-between;align-items:center}.x-pro-table__table-wrapper{width:100%;overflow-x:auto}.x-pro-table__table{width:100%;border-collapse:collapse}.x-pro-table__table th,.x-pro-table__table td{padding:12px 16px;border-bottom:1px solid #ebeef5;font-size:14px;text-align:left}.x-pro-table__table th{background-color:#fafafa;font-weight:500;color:#606266;-webkit-user-select:none;user-select:none}.x-pro-table__table td{color:#606266}.x-pro-table__table tr:hover td{background-color:#f5f7fa}.x-pro-table__selection{width:50px;text-align:center!important}.x-pro-table__selection input{cursor:pointer}.x-pro-table__index{width:60px;text-align:center!important}.x-pro-table__column{padding:12px 16px;text-align:left}.x-pro-table__cell{padding:12px 16px}.x-pro-table__loading,.x-pro-table__empty{padding:40px 0;text-align:center;color:#909399;font-size:14px}.x-pro-table__pagination{display:flex;justify-content:flex-end;padding:16px 20px;border-top:1px solid #ebeef5}.x-search-form{display:flex;flex-wrap:wrap;gap:16px;padding:16px 20px;background-color:#fff;border-radius:4px}.x-search-form__items{display:flex;flex-wrap:wrap;gap:16px;flex:1}.x-search-form__item{display:flex;align-items:center}.x-search-form__label{padding-right:12px;font-size:14px;color:#606266;text-align:right;flex-shrink:0}.x-search-form__content{flex:1;min-width:180px}.x-search-form__select{width:100%;height:32px;padding:0 12px;font-size:14px;color:#606266;background-color:#fff;border:1px solid #dcdfe6;border-radius:4px;cursor:pointer}.x-search-form__select:hover{border-color:#c0c4cc}.x-search-form__select:focus{border-color:#409eff;outline:none}.x-search-form__actions{display:flex;align-items:center}.x-statistic{display:flex;flex-direction:column;padding:16px 20px;background-color:#fff;border-radius:8px;box-shadow:0 2px 12px #00000014}.x-statistic__title{font-size:14px;color:#909399;margin-bottom:8px}.x-statistic__content{display:flex;align-items:baseline;gap:4px}.x-statistic__prefix{font-size:16px;color:#606266;margin-right:4px}.x-statistic__value{font-size:24px;font-weight:600;color:#303133}.x-statistic__suffix{font-size:14px;color:#606266;margin-left:4px}.x-statistic__trend{display:flex;align-items:center;margin-top:8px;font-size:14px}.x-statistic__trend-icon{margin-right:4px}.x-statistic__trend--up{color:#67c23a}.x-statistic__trend--down{color:#f56c6c}.x-markdown-editor{display:flex;flex-direction:column;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;overflow:hidden}.x-markdown-editor.is-disabled{background-color:#f5f7fa;cursor:not-allowed}.x-markdown-editor.is-disabled .x-markdown-editor__editor{cursor:not-allowed;color:#c0c4cc}.x-markdown-editor__toolbar{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;background-color:#fafafa;border-bottom:1px solid #e8e8e8;flex-shrink:0}.x-markdown-editor__toolbar-left,.x-markdown-editor__toolbar-right{display:flex;align-items:center;gap:4px}.x-markdown-editor__toolbar-btn{min-width:28px;height:28px;padding:0 6px;border:none;background:none;cursor:pointer;font-size:14px;color:#606266;border-radius:4px;display:flex;align-items:center;justify-content:center}.x-markdown-editor__toolbar-btn:hover:not(:disabled){background-color:#e8e8e8}.x-markdown-editor__toolbar-btn:disabled{cursor:not-allowed;color:#c0c4cc}.x-markdown-editor__toolbar-btn.is-divider{width:1px;height:20px;min-width:1px;padding:0;margin:0 4px;background-color:#dcdfe6;cursor:default}.x-markdown-editor__toolbar-btn.is-divider:hover{background-color:#dcdfe6}.x-markdown-editor__mode-btn{padding:4px 12px;border:1px solid #dcdfe6;background:#fff;cursor:pointer;font-size:13px;color:#606266;border-radius:4px}.x-markdown-editor__mode-btn:hover{color:#409eff;border-color:#c6e2ff;background-color:#ecf5ff}.x-markdown-editor__mode-btn.is-active{color:#fff;background-color:#409eff;border-color:#409eff}.x-markdown-editor__body{display:flex;flex:1;overflow:hidden}.x-markdown-editor__toc{width:200px;padding:16px;border-right:1px solid #e8e8e8;background-color:#fafafa;overflow-y:auto;flex-shrink:0}.x-markdown-editor__toc-title{font-size:14px;font-weight:600;color:#303133;margin-bottom:12px}.x-markdown-editor__toc-list{list-style:none;padding:0;margin:0}.x-markdown-editor__toc-item{font-size:13px;color:#606266;padding:6px 0;cursor:pointer}.x-markdown-editor__toc-item:hover{color:#409eff}.x-markdown-editor__content,.x-markdown-editor__editor-wrapper{flex:1;display:flex;overflow:hidden}.is-mode-split .x-markdown-editor__editor-wrapper{border-right:1px solid #e8e8e8}.x-markdown-editor__editor{flex:1;padding:16px;border:none;resize:none;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:14px;line-height:1.6;color:#303133;background-color:transparent;outline:none}.x-markdown-editor__editor::placeholder{color:#c0c4cc}.x-markdown-editor__preview{flex:1;padding:16px;overflow-y:auto;font-size:14px;line-height:1.8;color:#303133}.x-markdown-editor__preview .md-heading{margin:16px 0 8px;font-weight:600;color:#303133}.x-markdown-editor__preview .md-heading.md-h1{font-size:28px;margin-top:0}.x-markdown-editor__preview .md-heading.md-h2{font-size:24px}.x-markdown-editor__preview .md-heading.md-h3{font-size:20px}.x-markdown-editor__preview .md-heading.md-h4{font-size:18px}.x-markdown-editor__preview .md-heading.md-h5{font-size:16px}.x-markdown-editor__preview .md-heading.md-h6{font-size:14px}.x-markdown-editor__preview .md-paragraph{margin:12px 0}.x-markdown-editor__preview .md-code{padding:2px 6px;background-color:#f5f7fa;border-radius:3px;font-family:Monaco,Menlo,monospace;font-size:13px;color:#e96900}.x-markdown-editor__preview .md-code-block{margin:12px 0;padding:16px;background-color:#f8f8f8;border-radius:4px;overflow-x:auto}.x-markdown-editor__preview .md-code-block code{font-family:Monaco,Menlo,monospace;font-size:13px;line-height:1.6;color:#303133}.x-markdown-editor__preview .md-link{color:#409eff;text-decoration:none}.x-markdown-editor__preview .md-link:hover{text-decoration:underline}.x-markdown-editor__preview .md-image{max-width:100%;border-radius:4px;margin:8px 0}.x-markdown-editor__preview .md-list{padding-left:24px;margin:12px 0}.x-markdown-editor__preview .md-list li{margin:4px 0}.x-markdown-editor__preview .md-blockquote{margin:12px 0;padding:12px 16px;border-left:4px solid #409eff;background-color:#f0f7ff;color:#606266}.x-markdown-editor__preview .md-blockquote p{margin:4px 0}.x-markdown-editor__preview .md-hr{margin:16px 0;border:none;border-top:1px solid #e8e8e8}.x-markdown-editor__preview .md-table{width:100%;border-collapse:collapse;margin:12px 0}.x-markdown-editor__preview .md-table th,.x-markdown-editor__preview .md-table td{padding:8px 12px;border:1px solid #e8e8e8;text-align:left}.x-markdown-editor__preview .md-table th{background-color:#fafafa;font-weight:600}.x-markdown-editor.is-mode-edit .x-markdown-editor__editor-wrapper,.x-markdown-editor.is-mode-preview .x-markdown-editor__preview{width:100%}
package/lib/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),x=require("@xto/core"),E=require("@xto/base"),z=require("@xto/form"),w=require("@xto/data"),T=["colspan"],L=["colspan"],D=["value"],U=e.defineComponent({name:"XProTable",__name:"index",props:{columns:{},data:{default:()=>[]},loading:{type:Boolean,default:!1},pagination:{type:Boolean,default:!0},pageSize:{default:10},currentPage:{default:1},total:{default:0},selection:{type:Boolean,default:!1},index:{type:Boolean,default:!1},indexLabel:{default:"#"}},emits:["update:data","update:currentPage","update:pageSize","search","refresh","reset"],setup(t,{emit:c}){const o=t,n=c,l=x.useNamespace("pro-table"),a=e.ref({});e.ref([]),e.computed({get:()=>o.data,set:r=>n("update:data",r)});const v=r=>{n("update:currentPage",r),n("search",{...a.value,page:r})},p=r=>{n("update:pageSize",r),n("search",{...a.value,pageSize:r})},g=()=>{n("search",a.value)},m=()=>{a.value={},n("reset"),n("search",{})},f=()=>{n("refresh")},s=e.computed(()=>o.columns.filter(r=>r.search));return(r,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(l).b())},[s.value.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(l).e("search"))},[e.createVNode(e.unref(E.Space),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,u=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:u.prop},[u.searchType==="input"||!u.searchType?(e.openBlock(),e.createBlock(e.unref(z.Input),{key:0,modelValue:a.value[u.prop],"onUpdate:modelValue":h=>a.value[u.prop]=h,placeholder:`请输入${u.label}`,clearable:"",onKeyup:e.withKeys(g,["enter"])},null,8,["modelValue","onUpdate:modelValue","placeholder"])):e.createCommentVNode("",!0)],64))),128)),e.createVNode(e.unref(E.Button),{type:"primary",onClick:g},{default:e.withCtx(()=>[...d[0]||(d[0]=[e.createTextVNode("搜索",-1)])]),_:1}),e.createVNode(e.unref(E.Button),{onClick:m},{default:e.withCtx(()=>[...d[1]||(d[1]=[e.createTextVNode("重置",-1)])]),_:1}),e.createVNode(e.unref(E.Button),{onClick:f},{default:e.withCtx(()=>[...d[2]||(d[2]=[e.createTextVNode("刷新",-1)])]),_:1})]),_:1})],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("toolbar"))},[e.createVNode(e.unref(E.Space),null,{default:e.withCtx(()=>[e.renderSlot(r.$slots,"toolbar")]),_:3})],2),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("table-wrapper"))},[e.createElementVNode("table",{class:e.normalizeClass(e.unref(l).e("table"))},[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[t.selection?(e.openBlock(),e.createElementBlock("th",{key:0,class:e.normalizeClass(e.unref(l).e("selection"))},[...d[3]||(d[3]=[e.createElementVNode("input",{type:"checkbox"},null,-1)])],2)):e.createCommentVNode("",!0),t.index?(e.openBlock(),e.createElementBlock("th",{key:1,class:e.normalizeClass(e.unref(l).e("index"))},e.toDisplayString(t.indexLabel),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,u=>(e.openBlock(),e.createElementBlock("th",{key:u.prop,class:e.normalizeClass(e.unref(l).e("column")),style:e.normalizeStyle({width:u.width,minWidth:u.minWidth,textAlign:u.align||"left"})},e.toDisplayString(u.label),7))),128))])]),e.createElementVNode("tbody",null,[t.loading?(e.openBlock(),e.createElementBlock("tr",{key:0,class:e.normalizeClass(e.unref(l).e("loading-row"))},[e.createElementVNode("td",{colspan:t.columns.length+(t.selection?1:0)+(t.index?1:0)},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("loading"))}," 加载中... ",2)],8,T)],2)):t.data.length===0?(e.openBlock(),e.createElementBlock("tr",{key:1,class:e.normalizeClass(e.unref(l).e("empty-row"))},[e.createElementVNode("td",{colspan:t.columns.length+(t.selection?1:0)+(t.index?1:0)},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("empty"))}," 暂无数据 ",2)],8,L)],2)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(t.data,(u,h)=>(e.openBlock(),e.createElementBlock("tr",{key:h,class:e.normalizeClass(e.unref(l).e("row"))},[t.selection?(e.openBlock(),e.createElementBlock("td",{key:0,class:e.normalizeClass(e.unref(l).e("selection"))},[e.createElementVNode("input",{type:"checkbox",value:u},null,8,D)],2)):e.createCommentVNode("",!0),t.index?(e.openBlock(),e.createElementBlock("td",{key:1,class:e.normalizeClass(e.unref(l).e("index"))},e.toDisplayString((t.currentPage-1)*t.pageSize+h+1),3)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,C=>{var y;return e.openBlock(),e.createElementBlock("td",{key:C.prop,class:e.normalizeClass(e.unref(l).e("cell")),style:e.normalizeStyle({textAlign:C.align||"left"})},[e.renderSlot(r.$slots,(y=C.slots)==null?void 0:y.default,{row:u,column:C},()=>[e.createTextVNode(e.toDisplayString(C.formatter?C.formatter(u,C,u[C.prop]):u[C.prop]),1)])],6)}),128))],2))),128))])],2)],2),t.pagination?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(e.unref(l).e("pagination"))},[e.createVNode(e.unref(w.Pagination),{total:t.total,"page-size":t.pageSize,"current-page":t.currentPage,layout:"total, sizes, prev, pager, next, jumper",onCurrentChange:v,onSizeChange:p},null,8,["total","page-size","current-page"])],2)):e.createCommentVNode("",!0)],2))}}),H=["onUpdate:modelValue"],M=["value"],P=e.defineComponent({name:"XSearchForm",__name:"index",props:{columns:{default:()=>[]},model:{default:()=>({})},labelWidth:{default:"100px"},labelPosition:{default:"right"}},emits:["search","reset"],setup(t,{emit:c}){const o=t,n=c,l=x.useNamespace("search-form"),a=e.reactive({});o.columns.forEach(m=>{m.defaultValue!==void 0?a[m.prop]=m.defaultValue:o.model[m.prop]!==void 0&&(a[m.prop]=o.model[m.prop])});const v=()=>{n("search",{...a})},p=()=>{o.columns.forEach(m=>{a[m.prop]=m.defaultValue}),n("reset")},g=e.computed(()=>({width:typeof o.labelWidth=="number"?`${o.labelWidth}px`:o.labelWidth}));return(m,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(l).b())},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("items"))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,s=>(e.openBlock(),e.createElementBlock("div",{key:s.prop,class:e.normalizeClass(e.unref(l).e("item"))},[e.createElementVNode("label",{class:e.normalizeClass(e.unref(l).e("label")),style:e.normalizeStyle(g.value)},e.toDisplayString(s.label),7),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("content"))},[s.type==="input"||!s.type?(e.openBlock(),e.createBlock(e.unref(z.Input),{key:0,modelValue:a[s.prop],"onUpdate:modelValue":r=>a[s.prop]=r,placeholder:s.placeholder||`请输入${s.label}`,clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"])):s.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:1,"onUpdate:modelValue":r=>a[s.prop]=r,class:e.normalizeClass(e.unref(l).e("select"))},[f[0]||(f[0]=e.createElementVNode("option",{value:""},"请选择",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.options,r=>(e.openBlock(),e.createElementBlock("option",{key:r.value,value:r.value},e.toDisplayString(r.label),9,M))),128))],10,H)),[[e.vModelSelect,a[s.prop]]]):s.type==="date"?(e.openBlock(),e.createBlock(e.unref(z.Input),{key:2,modelValue:a[s.prop],"onUpdate:modelValue":r=>a[s.prop]=r,type:"date",placeholder:s.placeholder||`请选择${s.label}`},null,8,["modelValue","onUpdate:modelValue","placeholder"])):(e.openBlock(),e.createBlock(e.unref(z.Input),{key:3,modelValue:a[s.prop],"onUpdate:modelValue":r=>a[s.prop]=r,placeholder:s.placeholder||`请输入${s.label}`},null,8,["modelValue","onUpdate:modelValue","placeholder"]))],2)],2))),128))],2),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("actions"))},[e.createVNode(e.unref(E.Space),null,{default:e.withCtx(()=>[e.createVNode(e.unref(E.Button),{type:"primary",onClick:v},{default:e.withCtx(()=>[...f[1]||(f[1]=[e.createTextVNode("搜索",-1)])]),_:1}),e.createVNode(e.unref(E.Button),{onClick:p},{default:e.withCtx(()=>[...f[2]||(f[2]=[e.createTextVNode("重置",-1)])]),_:1})]),_:1})],2)],2))}}),W=e.defineComponent({name:"XStatistic",__name:"index",props:{title:{default:""},value:{default:0},suffix:{default:""},prefix:{default:""},precision:{default:0},trend:{default:""},trendValue:{default:0},color:{},titleColor:{},valueColor:{}},setup(t){const c=t,o=x.useNamespace("statistic"),n=e.computed(()=>typeof c.value=="number"?c.value.toFixed(c.precision):c.value),l=e.computed(()=>[o.e("trend"),o.em("trend",c.trend)]),a=e.computed(()=>c.trend==="up"?"↑":c.trend==="down"?"↓":"");return(v,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(o).b())},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(o).e("title")),style:e.normalizeStyle({color:t.titleColor})},e.toDisplayString(t.title),7),e.createElementVNode("div",{class:e.normalizeClass(e.unref(o).e("content"))},[t.prefix?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(o).e("prefix"))},e.toDisplayString(t.prefix),3)):e.createCommentVNode("",!0),e.createElementVNode("span",{class:e.normalizeClass(e.unref(o).e("value")),style:e.normalizeStyle({color:t.valueColor})},e.toDisplayString(n.value),7),t.suffix?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(e.unref(o).e("suffix"))},e.toDisplayString(t.suffix),3)):e.createCommentVNode("",!0)],2),t.trend?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(l.value)},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(o).e("trend-icon"))},e.toDisplayString(a.value),3),e.createElementVNode("span",{class:e.normalizeClass(e.unref(o).e("trend-value"))},e.toDisplayString(t.trendValue),3)],2)):e.createCommentVNode("",!0)],2))}}),j=e.defineComponent({name:"XExport",__name:"index",props:{data:{default:()=>[]},filename:{default:"export"},sheetName:{default:"Sheet1"},columns:{default:()=>[]}},setup(t){const c=t,o=e.ref(!1),n=()=>{if(c.data.length!==0){o.value=!0;try{const l=c.columns.length>0?c.columns.map(f=>f.title):Object.keys(c.data[0]),a=c.columns.length>0?c.columns.map(f=>f.key):Object.keys(c.data[0]),v=[l.join(","),...c.data.map(f=>a.map(s=>{const r=f[s];return typeof r=="string"&&(r.includes(",")||r.includes('"'))?`"${r.replace(/"/g,'""')}"`:r}).join(","))].join(`
2
+ `),p=new Blob([v],{type:"text/csv;charset=utf-8;"}),g=URL.createObjectURL(p),m=document.createElement("a");m.href=g,m.download=`${c.filename}.csv`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(g)}catch(l){console.error("Export failed:",l)}finally{o.value=!1}}};return(l,a)=>(e.openBlock(),e.createBlock(e.unref(E.Button),{loading:o.value,onClick:n},{default:e.withCtx(()=>[...a[0]||(a[0]=[e.createTextVNode("导出",-1)])]),icon:e.withCtx(()=>[...a[1]||(a[1]=[e.createTextVNode("📥",-1)])]),_:1},8,["loading"]))}});function S(t){const c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return t.replace(/[&<>"']/g,o=>c[o])}function N(t){return t=t.replace(/`([^`]+)`/g,'<code class="md-code">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^_]+)__/g,"<strong>$1</strong>"),t=t.replace(/\*([^*]+)\*/g,"<em>$1</em>"),t=t.replace(/_([^_]+)_/g,"<em>$1</em>"),t=t.replace(/~~([^~]+)~~/g,"<del>$1</del>"),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" class="md-link">$1</a>'),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="md-image" />'),t}function q(t,c={}){const o=t.split(`
3
+ `),n=[];let l=!1,a="",v=[],p=!1,g="",m=!1,f=!1;const s=()=>{p&&(n.push(`</${g}>`),p=!1,g="")},r=()=>{m&&(n.push("</blockquote>"),m=!1)},d=()=>{f&&(n.push("</table>"),f=!1)};for(let u=0;u<o.length;u++){let h=o[u];if(h.startsWith("```")){l?(n.push(`<pre class="md-code-block"><code class="language-${a}">${S(v.join(`
4
+ `))}</code></pre>`),l=!1,a="",v=[]):(s(),r(),d(),l=!0,a=h.slice(3).trim(),v=[]);continue}if(l){v.push(h);continue}if(h.trim().startsWith("|")&&h.trim().endsWith("|")){f||(s(),r(),f=!0,n.push('<table class="md-table">'));const i=h.trim().slice(1,-1).split("|").map(V=>V.trim());if(i.every(V=>/^[-:]+$/.test(V)))continue;if((u===0||u>0&&!o[u-1].trim().startsWith("|"))&&u<o.length-1){const V=o[u+1];if(V&&V.trim().startsWith("|")&&V.trim().endsWith("|")&&V.trim().slice(1,-1).split("|").map(b=>b.trim()).every(b=>/^[-:]+$/.test(b))){n.push("<thead><tr>"),i.forEach(b=>{n.push(`<th>${N(b)}</th>`)}),n.push("</tr></thead><tbody>");continue}}n.push("<tr>"),i.forEach(V=>{n.push(`<td>${N(V)}</td>`)}),n.push("</tr>");continue}else f&&(n.push("</tbody>"),d());if(!h.trim()){s(),r(),d();continue}if(h.startsWith(">")){s(),m||(n.push('<blockquote class="md-blockquote">'),m=!0);const i=h.replace(/^>\s?/,"");n.push(`<p>${N(i)}</p>`);continue}else m&&r();const C=h.match(/^(#{1,6})\s+(.+)$/);if(C){s();const i=C[1].length,B=N(C[2]);n.push(`<h${i} class="md-heading md-h${i}">${B}</h${i}>`);continue}if(/^[-*_]{3,}$/.test(h.trim())){s(),n.push('<hr class="md-hr" />');continue}const y=h.match(/^[-*+]\s+(.+)$/);if(y){(!p||g!=="ul")&&(s(),n.push('<ul class="md-list">'),p=!0,g="ul"),n.push(`<li>${N(y[1])}</li>`);continue}const k=h.match(/^(\d+)\.\s+(.+)$/);if(k){(!p||g!=="ol")&&(s(),n.push('<ol class="md-list">'),p=!0,g="ol"),n.push(`<li>${N(k[2])}</li>`);continue}s(),c.breaks!==!1?n.push(`<p class="md-paragraph">${N(h)}</p>`):n.push(`<p class="md-paragraph">${N(h)}</p>`)}return s(),r(),d(),l&&n.push(`<pre class="md-code-block"><code>${S(v.join(`
5
+ `))}</code></pre>`),n.join(`
6
+ `)}function F(t){const c=[];return t.split(`
7
+ `).forEach((n,l)=>{const a=n.match(/^(#{1,6})\s+(.+)$/);if(a){const v=a[1].length,p=a[2].trim(),g=`heading-${l}`;c.push({level:v,text:p,id:g})}}),c}const R=["title","disabled","onClick"],I={key:0},O=["value","placeholder","disabled"],X=["innerHTML"],A=e.defineComponent({name:"XMarkdownEditor",__name:"index",props:{modelValue:{default:""},placeholder:{default:"请输入 Markdown 内容..."},height:{default:400},mode:{default:"split"},showToolbar:{type:Boolean,default:!0},showToc:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(t,{emit:c}){const o=t,n=c,l=x.useNamespace("markdown-editor"),a=e.ref(o.modelValue),v=e.ref(),p=e.ref(o.mode),g=e.computed(()=>q(a.value)),m=e.computed(()=>F(a.value)),f=e.computed(()=>({height:typeof o.height=="number"?`${o.height}px`:o.height}));e.watch(()=>o.modelValue,y=>{a.value=y});const s=y=>{const k=y.target.value;a.value=k,n("update:modelValue",k),n("change",k)},r=y=>{p.value=y},d=(y,k="")=>{if(!v.value||o.disabled)return;const i=v.value,B=i.selectionStart,V=i.selectionEnd,$=a.value.substring(B,V),b=a.value.substring(0,B)+y+$+k+a.value.substring(V);a.value=b,n("update:modelValue",b),n("change",b),e.nextTick(()=>{i.focus(),i.setSelectionRange(B+y.length,B+y.length+$.length)})},u=[{icon:"H1",title:"标题1",action:()=>d("# ","")},{icon:"H2",title:"标题2",action:()=>d("## ","")},{icon:"H3",title:"标题3",action:()=>d("### ","")},{type:"divider"},{icon:"B",title:"粗体",action:()=>d("**","**")},{icon:"I",title:"斜体",action:()=>d("*","*")},{icon:"S",title:"删除线",action:()=>d("~~","~~")},{type:"divider"},{icon:"•",title:"无序列表",action:()=>d("- ","")},{icon:"1.",title:"有序列表",action:()=>d("1. ","")},{type:"divider"},{icon:"🔗",title:"链接",action:()=>d("[","](url)")},{icon:"🖼",title:"图片",action:()=>d("![alt](",")")},{icon:"</>",title:"代码",action:()=>d("`","`")},{type:"divider"},{icon:"—",title:"分割线",action:()=>d(`
8
+ ---
9
+ `,"")},{icon:"□",title:"引用",action:()=>d("> ","")},{icon:"```",title:"代码块",action:()=>d("\n```\n","\n```\n")}],h=e.computed(()=>[l.b(),l.is("disabled",o.disabled),l.is(`mode-${p.value}`)]),C=y=>{if(p.value!=="split")return;const k=document.querySelector(".x-markdown-editor__preview");if(!k)return;const i=y.target,B=i.scrollTop/(i.scrollHeight-i.clientHeight);k.scrollTop=B*(k.scrollHeight-k.clientHeight)};return(y,k)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(h.value),style:e.normalizeStyle(f.value)},[t.showToolbar?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(l).e("toolbar"))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("toolbar-left"))},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(u,(i,B)=>e.createElementVNode("button",{key:B,class:e.normalizeClass([e.unref(l).e("toolbar-btn"),{"is-divider":i.type==="divider"}]),title:i.title,disabled:t.disabled,onClick:i.action},[i.type?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",I,e.toDisplayString(i.icon),1))],10,R)),64))],2),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("toolbar-right"))},[e.createElementVNode("button",{class:e.normalizeClass([e.unref(l).e("mode-btn"),{"is-active":p.value==="edit"}]),onClick:k[0]||(k[0]=i=>r("edit"))}," 编辑 ",2),e.createElementVNode("button",{class:e.normalizeClass([e.unref(l).e("mode-btn"),{"is-active":p.value==="split"}]),onClick:k[1]||(k[1]=i=>r("split"))}," 分屏 ",2),e.createElementVNode("button",{class:e.normalizeClass([e.unref(l).e("mode-btn"),{"is-active":p.value==="preview"}]),onClick:k[2]||(k[2]=i=>r("preview"))}," 预览 ",2)],2)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("body"))},[t.showToc&&m.value.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(l).e("toc"))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("toc-title"))},"目录",2),e.createElementVNode("ul",{class:e.normalizeClass(e.unref(l).e("toc-list"))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(i,B)=>(e.openBlock(),e.createElementBlock("li",{key:B,class:e.normalizeClass(e.unref(l).e("toc-item")),style:e.normalizeStyle({paddingLeft:(i.level-1)*12+"px"})},e.toDisplayString(i.text),7))),128))],2)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("content"))},[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("editor-wrapper"))},[e.createElementVNode("textarea",{ref_key:"editorRef",ref:v,class:e.normalizeClass(e.unref(l).e("editor")),value:a.value,placeholder:t.placeholder,disabled:t.disabled,onInput:s,onScroll:C},null,42,O)],2),[[e.vShow,p.value!=="preview"]]),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("preview")),innerHTML:g.value},null,10,X),[[e.vShow,p.value!=="edit"]])],2)],2)],6))}});exports.Export=j;exports.MarkdownEditor=A;exports.ProTable=U;exports.SearchForm=P;exports.Statistic=W;
package/lib/style.css ADDED
@@ -0,0 +1 @@
1
+ .x-pro-table{background-color:#fff;border-radius:4px}.x-pro-table__search{padding:18px 20px 0;margin-bottom:16px}.x-pro-table__toolbar{padding:0 20px 16px;display:flex;justify-content:space-between;align-items:center}.x-pro-table__table-wrapper{width:100%;overflow-x:auto}.x-pro-table__table{width:100%;border-collapse:collapse}.x-pro-table__table th,.x-pro-table__table td{padding:12px 16px;border-bottom:1px solid #ebeef5;font-size:14px;text-align:left}.x-pro-table__table th{background-color:#fafafa;font-weight:500;color:#606266;-webkit-user-select:none;user-select:none}.x-pro-table__table td{color:#606266}.x-pro-table__table tr:hover td{background-color:#f5f7fa}.x-pro-table__selection{width:50px;text-align:center!important}.x-pro-table__selection input{cursor:pointer}.x-pro-table__index{width:60px;text-align:center!important}.x-pro-table__column{padding:12px 16px;text-align:left}.x-pro-table__cell{padding:12px 16px}.x-pro-table__loading,.x-pro-table__empty{padding:40px 0;text-align:center;color:#909399;font-size:14px}.x-pro-table__pagination{display:flex;justify-content:flex-end;padding:16px 20px;border-top:1px solid #ebeef5}.x-search-form{display:flex;flex-wrap:wrap;gap:16px;padding:16px 20px;background-color:#fff;border-radius:4px}.x-search-form__items{display:flex;flex-wrap:wrap;gap:16px;flex:1}.x-search-form__item{display:flex;align-items:center}.x-search-form__label{padding-right:12px;font-size:14px;color:#606266;text-align:right;flex-shrink:0}.x-search-form__content{flex:1;min-width:180px}.x-search-form__select{width:100%;height:32px;padding:0 12px;font-size:14px;color:#606266;background-color:#fff;border:1px solid #dcdfe6;border-radius:4px;cursor:pointer}.x-search-form__select:hover{border-color:#c0c4cc}.x-search-form__select:focus{border-color:#409eff;outline:none}.x-search-form__actions{display:flex;align-items:center}.x-statistic{display:flex;flex-direction:column;padding:16px 20px;background-color:#fff;border-radius:8px;box-shadow:0 2px 12px #00000014}.x-statistic__title{font-size:14px;color:#909399;margin-bottom:8px}.x-statistic__content{display:flex;align-items:baseline;gap:4px}.x-statistic__prefix{font-size:16px;color:#606266;margin-right:4px}.x-statistic__value{font-size:24px;font-weight:600;color:#303133}.x-statistic__suffix{font-size:14px;color:#606266;margin-left:4px}.x-statistic__trend{display:flex;align-items:center;margin-top:8px;font-size:14px}.x-statistic__trend-icon{margin-right:4px}.x-statistic__trend--up{color:#67c23a}.x-statistic__trend--down{color:#f56c6c}.x-markdown-editor{display:flex;flex-direction:column;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;overflow:hidden}.x-markdown-editor.is-disabled{background-color:#f5f7fa;cursor:not-allowed}.x-markdown-editor.is-disabled .x-markdown-editor__editor{cursor:not-allowed;color:#c0c4cc}.x-markdown-editor__toolbar{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;background-color:#fafafa;border-bottom:1px solid #e8e8e8;flex-shrink:0}.x-markdown-editor__toolbar-left,.x-markdown-editor__toolbar-right{display:flex;align-items:center;gap:4px}.x-markdown-editor__toolbar-btn{min-width:28px;height:28px;padding:0 6px;border:none;background:none;cursor:pointer;font-size:14px;color:#606266;border-radius:4px;display:flex;align-items:center;justify-content:center}.x-markdown-editor__toolbar-btn:hover:not(:disabled){background-color:#e8e8e8}.x-markdown-editor__toolbar-btn:disabled{cursor:not-allowed;color:#c0c4cc}.x-markdown-editor__toolbar-btn.is-divider{width:1px;height:20px;min-width:1px;padding:0;margin:0 4px;background-color:#dcdfe6;cursor:default}.x-markdown-editor__toolbar-btn.is-divider:hover{background-color:#dcdfe6}.x-markdown-editor__mode-btn{padding:4px 12px;border:1px solid #dcdfe6;background:#fff;cursor:pointer;font-size:13px;color:#606266;border-radius:4px}.x-markdown-editor__mode-btn:hover{color:#409eff;border-color:#c6e2ff;background-color:#ecf5ff}.x-markdown-editor__mode-btn.is-active{color:#fff;background-color:#409eff;border-color:#409eff}.x-markdown-editor__body{display:flex;flex:1;overflow:hidden}.x-markdown-editor__toc{width:200px;padding:16px;border-right:1px solid #e8e8e8;background-color:#fafafa;overflow-y:auto;flex-shrink:0}.x-markdown-editor__toc-title{font-size:14px;font-weight:600;color:#303133;margin-bottom:12px}.x-markdown-editor__toc-list{list-style:none;padding:0;margin:0}.x-markdown-editor__toc-item{font-size:13px;color:#606266;padding:6px 0;cursor:pointer}.x-markdown-editor__toc-item:hover{color:#409eff}.x-markdown-editor__content,.x-markdown-editor__editor-wrapper{flex:1;display:flex;overflow:hidden}.is-mode-split .x-markdown-editor__editor-wrapper{border-right:1px solid #e8e8e8}.x-markdown-editor__editor{flex:1;padding:16px;border:none;resize:none;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:14px;line-height:1.6;color:#303133;background-color:transparent;outline:none}.x-markdown-editor__editor::placeholder{color:#c0c4cc}.x-markdown-editor__preview{flex:1;padding:16px;overflow-y:auto;font-size:14px;line-height:1.8;color:#303133}.x-markdown-editor__preview .md-heading{margin:16px 0 8px;font-weight:600;color:#303133}.x-markdown-editor__preview .md-heading.md-h1{font-size:28px;margin-top:0}.x-markdown-editor__preview .md-heading.md-h2{font-size:24px}.x-markdown-editor__preview .md-heading.md-h3{font-size:20px}.x-markdown-editor__preview .md-heading.md-h4{font-size:18px}.x-markdown-editor__preview .md-heading.md-h5{font-size:16px}.x-markdown-editor__preview .md-heading.md-h6{font-size:14px}.x-markdown-editor__preview .md-paragraph{margin:12px 0}.x-markdown-editor__preview .md-code{padding:2px 6px;background-color:#f5f7fa;border-radius:3px;font-family:Monaco,Menlo,monospace;font-size:13px;color:#e96900}.x-markdown-editor__preview .md-code-block{margin:12px 0;padding:16px;background-color:#f8f8f8;border-radius:4px;overflow-x:auto}.x-markdown-editor__preview .md-code-block code{font-family:Monaco,Menlo,monospace;font-size:13px;line-height:1.6;color:#303133}.x-markdown-editor__preview .md-link{color:#409eff;text-decoration:none}.x-markdown-editor__preview .md-link:hover{text-decoration:underline}.x-markdown-editor__preview .md-image{max-width:100%;border-radius:4px;margin:8px 0}.x-markdown-editor__preview .md-list{padding-left:24px;margin:12px 0}.x-markdown-editor__preview .md-list li{margin:4px 0}.x-markdown-editor__preview .md-blockquote{margin:12px 0;padding:12px 16px;border-left:4px solid #409eff;background-color:#f0f7ff;color:#606266}.x-markdown-editor__preview .md-blockquote p{margin:4px 0}.x-markdown-editor__preview .md-hr{margin:16px 0;border:none;border-top:1px solid #e8e8e8}.x-markdown-editor__preview .md-table{width:100%;border-collapse:collapse;margin:12px 0}.x-markdown-editor__preview .md-table th,.x-markdown-editor__preview .md-table td{padding:8px 12px;border:1px solid #e8e8e8;text-align:left}.x-markdown-editor__preview .md-table th{background-color:#fafafa;font-weight:600}.x-markdown-editor.is-mode-edit .x-markdown-editor__editor-wrapper,.x-markdown-editor.is-mode-preview .x-markdown-editor__preview{width:100%}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@xto/business",
3
+ "version": "0.1.0",
4
+ "description": "Xto Business - Business components",
5
+ "main": "./lib/index.cjs",
6
+ "module": "./es/index.mjs",
7
+ "types": "./es/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./es/index.mjs",
11
+ "require": "./lib/index.cjs",
12
+ "types": "./es/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "es",
17
+ "lib"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@xto/data": "0.1.0",
24
+ "@xto/base": "0.1.0",
25
+ "@xto/core": "0.1.0",
26
+ "@xto/form": "0.1.0"
27
+ },
28
+ "peerDependencies": {
29
+ "vue": "^3.4.0"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "^5.4.2",
33
+ "vite": "^5.2.0",
34
+ "vitest": "^1.4.0",
35
+ "vue": "^3.4.21",
36
+ "@xto/build": "0.1.0"
37
+ },
38
+ "scripts": {
39
+ "build": "vite build"
40
+ }
41
+ }