vue3-smart-table 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,8 @@ class ke {
12
12
  this.renderers.has(e) && process.env.NODE_ENV === "development" && console.debug(`[SmartTable] Renderer "${e}" already registered, skipping.`), this.renderers.set(e, n);
13
13
  }
14
14
  registerMultiple(e) {
15
- Object.entries(e).forEach(([n, o]) => {
16
- this.renderers.has(n) || this.renderers.set(n, o);
15
+ Object.entries(e).forEach(([n, r]) => {
16
+ this.renderers.has(n) || this.renderers.set(n, r);
17
17
  });
18
18
  }
19
19
  get(e) {
@@ -44,7 +44,7 @@ function Y(t) {
44
44
  }
45
45
  });
46
46
  }
47
- function E(t) {
47
+ function S(t) {
48
48
  return O({
49
49
  props: ["row", "col", "onCellChange", "onCellBlur", "onCellEnter", "onClick"],
50
50
  setup(e) {
@@ -88,12 +88,12 @@ function He(t, e) {
88
88
  }
89
89
  function v(t, e) {
90
90
  if (!(!t || !e))
91
- return e.split(".").reduce((n, o) => n == null ? void 0 : n[o], t);
91
+ return e.split(".").reduce((n, r) => n == null ? void 0 : n[r], t);
92
92
  }
93
93
  function G(t, e, n) {
94
94
  if (!t || !e) return;
95
- const o = e.split("."), r = o.pop(), l = o.reduce((i, c) => (i[c] || (i[c] = {}), i[c]), t);
96
- l[r] = n;
95
+ const r = e.split("."), o = r.pop(), l = r.reduce((i, c) => (i[c] || (i[c] = {}), i[c]), t);
96
+ l[o] = n;
97
97
  }
98
98
  const we = /* @__PURE__ */ O({
99
99
  __name: "input",
@@ -108,10 +108,10 @@ const we = /* @__PURE__ */ O({
108
108
  z(n, (l) => {
109
109
  G(e.row, e.col.key, l);
110
110
  });
111
- const o = () => {
111
+ const r = () => {
112
112
  var l;
113
113
  return (l = e.onCellBlur) == null ? void 0 : l.call(e, e.row, e.col);
114
- }, r = () => {
114
+ }, o = () => {
115
115
  var l;
116
116
  return (l = e.onCellEnter) == null ? void 0 : l.call(e, e.row, e.col);
117
117
  };
@@ -121,8 +121,8 @@ const we = /* @__PURE__ */ O({
121
121
  modelValue: n.value,
122
122
  "onUpdate:modelValue": i[0] || (i[0] = (d) => n.value = d)
123
123
  }, { placeholder: "", size: "small", clearable: !0, ...t.col.renderProps }, {
124
- onBlur: o,
125
- onKeyup: U(r, ["enter"])
124
+ onBlur: r,
125
+ onKeyup: U(o, ["enter"])
126
126
  }), null, 16, ["modelValue"]);
127
127
  };
128
128
  }
@@ -141,10 +141,10 @@ const we = /* @__PURE__ */ O({
141
141
  var i;
142
142
  G(e.row, e.col.key, l), (i = e.onCellChange) == null || i.call(e, e.row, e.col);
143
143
  });
144
- const o = () => {
144
+ const r = () => {
145
145
  var l;
146
146
  return (l = e.onCellBlur) == null ? void 0 : l.call(e, e.row, e.col);
147
- }, r = () => {
147
+ }, o = () => {
148
148
  var l;
149
149
  return (l = e.onCellEnter) == null ? void 0 : l.call(e, e.row, e.col);
150
150
  };
@@ -154,8 +154,8 @@ const we = /* @__PURE__ */ O({
154
154
  modelValue: n.value,
155
155
  "onUpdate:modelValue": i[0] || (i[0] = (d) => n.value = d)
156
156
  }, { min: 0, max: 99999, controls: !1, size: "small", ...t.col.renderProps }, {
157
- onBlur: o,
158
- onKeyup: U(r, ["enter"])
157
+ onBlur: r,
158
+ onKeyup: U(o, ["enter"])
159
159
  }), null, 16, ["modelValue"]);
160
160
  };
161
161
  }
@@ -173,10 +173,10 @@ const we = /* @__PURE__ */ O({
173
173
  z(n, (i) => {
174
174
  G(e.row, e.col.key, i);
175
175
  });
176
- const o = () => {
176
+ const r = () => {
177
177
  var i;
178
178
  return (i = e.onCellChange) == null ? void 0 : i.call(e, e.row, e.col);
179
- }, r = () => {
179
+ }, o = () => {
180
180
  var i;
181
181
  return (i = e.onCellBlur) == null ? void 0 : i.call(e, e.row, e.col);
182
182
  }, l = () => {
@@ -189,8 +189,8 @@ const we = /* @__PURE__ */ O({
189
189
  modelValue: n.value,
190
190
  "onUpdate:modelValue": c[0] || (c[0] = (b) => n.value = b)
191
191
  }, { placeholder: "请选择", size: "small", clearable: !0, ...t.col.renderProps }, {
192
- onChange: o,
193
- onBlur: r,
192
+ onChange: r,
193
+ onBlur: o,
194
194
  onKeyup: U(l, ["enter"])
195
195
  }), {
196
196
  default: A(() => {
@@ -207,24 +207,24 @@ const we = /* @__PURE__ */ O({
207
207
  }, 16, ["modelValue"]);
208
208
  };
209
209
  }
210
- }), Be = Y(we), Ee = Y(_e), Se = Y(xe), Te = E((t) => {
210
+ }), Be = Y(we), Se = Y(_e), Ee = Y(xe), Te = S((t) => {
211
211
  const e = t.col.renderProps || {}, n = v(t.row, t.col.key);
212
212
  return f(Ce, {
213
213
  type: e.type || "primary",
214
214
  ...e,
215
215
  onClick: () => {
216
- var o;
217
- return (o = t.onClick) == null ? void 0 : o.call(t, t.row, t.col);
216
+ var r;
217
+ return (r = t.onClick) == null ? void 0 : r.call(t, t.row, t.col);
218
218
  }
219
219
  }, () => e.label || n);
220
- }), Ve = E((t) => {
220
+ }), Ve = S((t) => {
221
221
  const e = t.col.renderProps || {}, n = v(t.row, t.col.key);
222
222
  return f("a", {
223
223
  href: e.href || "#",
224
224
  target: e.blank ? "_blank" : "_self",
225
225
  style: e.style || "color:#409EFF;cursor:pointer;"
226
226
  }, e.label || n);
227
- }), Ae = E((t) => {
227
+ }), Ae = S((t) => {
228
228
  var n;
229
229
  const e = v(t.row, t.col.key);
230
230
  return f("div", {
@@ -232,8 +232,8 @@ const we = /* @__PURE__ */ O({
232
232
  innerHTML: e ?? "",
233
233
  ...((n = t.col) == null ? void 0 : n.renderProps) || {}
234
234
  });
235
- }), Me = E((t) => {
236
- const e = v(t.row, t.col.key) ?? "", n = t.col.renderProps ?? {}, o = {
235
+ }), Me = S((t) => {
236
+ const e = v(t.row, t.col.key) ?? "", n = t.col.renderProps ?? {}, r = {
237
237
  position: "absolute",
238
238
  right: "-5px",
239
239
  top: "50%",
@@ -243,6 +243,13 @@ const we = /* @__PURE__ */ O({
243
243
  "font-size": "12px",
244
244
  color: n.iconColor || "#409EFF",
245
245
  "user-select": "none"
246
+ }, o = {
247
+ "padding-right": "10px",
248
+ display: "-webkit-box",
249
+ "-webkit-box-orient": "vertical",
250
+ "-webkit-line-clamp": n.lineClamp ?? 2,
251
+ overflow: "hidden",
252
+ ...n.textStyles
246
253
  };
247
254
  return f(
248
255
  "div",
@@ -252,12 +259,13 @@ const we = /* @__PURE__ */ O({
252
259
  },
253
260
  [
254
261
  f("span", {
255
- class: "st_copy_text line-clamp-1",
256
- style: "padding-right: 10px; display: block;"
262
+ class: `st_copy_text ${n.textClass ?? ""}`,
263
+ style: o,
264
+ title: e
257
265
  }, e),
258
266
  e && f("span", {
259
267
  class: "st_copy_btn",
260
- style: o,
268
+ style: r,
261
269
  title: n.copyTitle || "复制",
262
270
  onClick: () => {
263
271
  if (e)
@@ -269,10 +277,10 @@ const we = /* @__PURE__ */ O({
269
277
  $.error(n.errorText ?? "复制失败");
270
278
  });
271
279
  else {
272
- const r = document.createElement("textarea");
273
- r.value = e, r.style.position = "fixed", r.style.opacity = "0", document.body.appendChild(r), r.select();
274
- const l = document.execCommand("copy");
275
- document.body.removeChild(r), l ? $.success(n.successText ?? "复制成功") : $.error(n.errorText ?? "复制失败");
280
+ const l = document.createElement("textarea");
281
+ l.value = e, l.style.position = "fixed", l.style.opacity = "0", document.body.appendChild(l), l.select();
282
+ const i = document.execCommand("copy");
283
+ document.body.removeChild(l), i ? $.success(n.successText ?? "复制成功") : $.error(n.errorText ?? "复制失败");
276
284
  }
277
285
  } catch {
278
286
  $.error(n.errorText ?? "复制失败");
@@ -283,20 +291,20 @@ const we = /* @__PURE__ */ O({
283
291
  })])
284
292
  ].filter(Boolean)
285
293
  );
286
- }), Oe = E((t) => {
294
+ }), Oe = S((t) => {
287
295
  var i;
288
- const e = v(t.row, t.col.key) ?? "", n = ((i = t.col) == null ? void 0 : i.renderProps) || {}, r = e ? Array.isArray(e) ? e.filter((c) => c && typeof c == "string") : [e] : [];
289
- if (r.length === 0)
296
+ const e = v(t.row, t.col.key) ?? "", n = ((i = t.col) == null ? void 0 : i.renderProps) || {}, o = e ? Array.isArray(e) ? e.filter((c) => c && typeof c == "string") : [e] : [];
297
+ if (o.length === 0)
290
298
  return n.placeholder || "";
291
299
  const l = {
292
300
  width: n.width || "80px",
293
301
  height: n.height || "80px",
294
- marginRight: r.length > 1 ? "4px" : "0",
302
+ marginRight: o.length > 1 ? "4px" : "0",
295
303
  ...n.style || {}
296
304
  };
297
- return r.length === 1 ? f(q, {
298
- src: r[0],
299
- previewSrcList: n.previewSrcList || r,
305
+ return o.length === 1 ? f(q, {
306
+ src: o[0],
307
+ previewSrcList: n.previewSrcList || o,
300
308
  fit: n.fit || "contain",
301
309
  style: l,
302
310
  ...n
@@ -308,41 +316,41 @@ const we = /* @__PURE__ */ O({
308
316
  },
309
317
  [
310
318
  f(q, {
311
- src: r[0],
312
- previewSrcList: n.previewSrcList || r,
319
+ src: o[0],
320
+ previewSrcList: n.previewSrcList || o,
313
321
  fit: n.fit || "contain",
314
322
  style: l,
315
323
  ...n
316
324
  }),
317
- r.length > 1 && f("span", {
325
+ o.length > 1 && f("span", {
318
326
  class: "st_img_total",
319
327
  style: "position: absolute; top: 0; right: 0; ",
320
- title: `${r.length}`
328
+ title: `${o.length}`
321
329
  }, [f(be, { style: "width: 1em; height: 1em; " })])
322
330
  ]
323
331
  );
324
- }), $e = E((t) => {
325
- const e = v(t.row, t.col.key) ?? "", n = t.col.renderProps || {}, o = n.options ?? [], r = n.showValue ?? !1;
332
+ }), $e = S((t) => {
333
+ const e = v(t.row, t.col.key) ?? "", n = t.col.renderProps || {}, r = n.options ?? [], o = n.showValue ?? !1;
326
334
  if (e == null || e === "") return "";
327
- const l = Array.isArray(e) ? e.map(String) : [String(e)], i = o.filter((g) => l.includes(String(g.value))), c = l.filter((g) => !o.some((b) => String(b.value) === g)), d = i.map((g, b) => f(
335
+ const l = Array.isArray(e) ? e.map(String) : [String(e)], i = r.filter((g) => l.includes(String(g.value))), c = l.filter((g) => !r.some((b) => String(b.value) === g)), d = i.map((g, b) => f(
328
336
  he,
329
337
  { key: g.value, type: g.listClass, class: g.cssClass, disableTransitions: !0 },
330
338
  { default: () => g.label + " " }
331
339
  ));
332
- return r && c.length > 0 && d.push(f("span", {}, c.join(" "))), f("div", {}, d);
333
- }), Fe = E((t) => {
334
- var o;
335
- const e = v(t.row, t.col.key) ?? "", n = ((o = t.col.renderProps) == null ? void 0 : o.options) ?? {};
340
+ return o && c.length > 0 && d.push(f("span", {}, c.join(" "))), f("div", {}, d);
341
+ }), Fe = S((t) => {
342
+ var r;
343
+ const e = v(t.row, t.col.key) ?? "", n = ((r = t.col.renderProps) == null ? void 0 : r.options) ?? {};
336
344
  return e != null ? n[e] ?? "" : "";
337
345
  });
338
346
  function Re(t) {
339
347
  return typeof t.formatter == "function";
340
348
  }
341
- const ze = E((t) => {
342
- var r;
343
- const { col: e, row: n } = t, o = v(t.row, t.col.key) ?? "";
344
- return Re(e) ? (r = e.formatter) == null ? void 0 : r.call(e, o, n) : o ?? "";
345
- }), Ke = E((t) => {
349
+ const ze = S((t) => {
350
+ var o;
351
+ const { col: e, row: n } = t, r = v(t.row, t.col.key) ?? "";
352
+ return Re(e) ? (o = e.formatter) == null ? void 0 : o.call(e, r, n) : r ?? "";
353
+ }), Ke = S((t) => {
346
354
  const e = v(t.row, t.col.key) ?? "", n = t.col.renderProps || {};
347
355
  return e ? /^https?:\/\//.test(e) ? f(q, {
348
356
  src: e,
@@ -361,8 +369,8 @@ const ze = E((t) => {
361
369
  }) : "";
362
370
  }), le = {
363
371
  input: Be,
364
- "input-number": Ee,
365
- select: Se,
372
+ "input-number": Se,
373
+ select: Ee,
366
374
  button: Te,
367
375
  link: Ve,
368
376
  html: Ae,
@@ -380,17 +388,17 @@ function Ye() {
380
388
  return le;
381
389
  }
382
390
  function Ne(t, e = 10, n = []) {
383
- const r = "*:*:*", l = (s) => {
391
+ const o = "*:*:*", l = (s) => {
384
392
  if (!s) return !0;
385
393
  const y = Array.isArray(s) ? s : [s];
386
394
  return n.some(
387
- (p) => p === r || y.includes(p)
395
+ (p) => p === o || y.includes(p)
388
396
  );
389
397
  }, i = F(() => t.some((s) => l(s.permission))), c = F(() => t.filter((y) => l(y.permission)).slice(0, e).reduce(
390
398
  (y, p) => y + (p.width ?? 60),
391
399
  0
392
400
  )), d = (s, y) => l(s.permission) && (s.visible ? s.visible(y) : !0), g = (s) => t.filter((p) => d(p, s)).slice(0, e).reduce(
393
- (p, S) => p + (S.width ?? 60),
401
+ (p, E) => p + (E.width ?? 60),
394
402
  0
395
403
  );
396
404
  return {
@@ -415,11 +423,11 @@ const De = ["title"], Ie = /* @__PURE__ */ O({
415
423
  },
416
424
  emits: ["cellBlur", "cellEnter", "cellChange", "cellClick"],
417
425
  setup(t, { emit: e }) {
418
- const n = t, o = e, r = (u) => {
426
+ const n = t, r = e, o = (u) => {
419
427
  var T, w;
420
428
  const C = (T = n.pagination) == null ? void 0 : T.page, x = (w = n.pagination) == null ? void 0 : w.size;
421
429
  return C && x ? (C - 1) * x + u + 1 : u + 1;
422
- }, { col: l } = ae(n), i = (u, C) => o("cellChange", u, C), c = (u, C) => o("cellBlur", u, C), d = (u, C) => o("cellEnter", u, C), g = (u, C) => o("cellClick", u, C);
430
+ }, { col: l } = ae(n), i = (u, C) => r("cellChange", u, C), c = (u, C) => r("cellBlur", u, C), d = (u, C) => r("cellEnter", u, C), g = (u, C) => r("cellClick", u, C);
423
431
  Le(J());
424
432
  const b = F(() => {
425
433
  const u = J(), C = {};
@@ -437,9 +445,9 @@ const De = ["title"], Ie = /* @__PURE__ */ O({
437
445
  l.value.buttons || [],
438
446
  l.value.maxbtn ?? 10,
439
447
  n.permissions || []
440
- ), S = F(() => (l.value.buttons || []).length ? (l.value.__rows || []).length ? k(l.value.__rows || []) : m.value : !1), N = F(() => l.value.__rows ? y(l.value.__rows) : s.value);
448
+ ), E = F(() => (l.value.buttons || []).length ? (l.value.__rows || []).length ? k(l.value.__rows || []) : m.value : !1), N = F(() => l.value.__rows ? y(l.value.__rows) : s.value);
441
449
  function oe(u) {
442
- return !(u.type === "selection" || u.type === "index" || u.type === "operation" && !S.value || u.visible === !1);
450
+ return !(u.type === "selection" || u.type === "index" || u.type === "operation" && !E.value || u.visible === !1);
443
451
  }
444
452
  return (u, C) => {
445
453
  const x = M("el-table-column"), T = M("el-button");
@@ -453,10 +461,10 @@ const De = ["title"], Ie = /* @__PURE__ */ O({
453
461
  align: "center"
454
462
  }, a(l).columnProps), {
455
463
  default: A(({ $index: w }) => [
456
- Z(W(r(w)), 1)
464
+ Z(W(o(w)), 1)
457
465
  ]),
458
466
  _: 1
459
- }, 16, ["label"])) : a(l).type === "operation" && S.value ? (h(), _(x, B({
467
+ }, 16, ["label"])) : a(l).type === "operation" && E.value ? (h(), _(x, B({
460
468
  key: 2,
461
469
  label: a(l).label || "操作",
462
470
  align: "center"
@@ -510,21 +518,21 @@ const De = ["title"], Ie = /* @__PURE__ */ O({
510
518
  function ee(t, e) {
511
519
  if (!(e != null && e.length)) return t;
512
520
  const n = new Map(
513
- e.map((o) => [o.key, o])
521
+ e.map((r) => [r.key, r])
514
522
  );
515
- return t.map((o) => {
516
- const r = n.get(o.key);
517
- return r ? {
518
- ...o,
519
- visible: typeof r.visible == "boolean" ? r.visible : o.visible
520
- } : o;
523
+ return t.map((r) => {
524
+ const o = n.get(r.key);
525
+ return o ? {
526
+ ...r,
527
+ visible: typeof o.visible == "boolean" ? o.visible : r.visible
528
+ } : r;
521
529
  });
522
530
  }
523
531
  function We(t, e) {
524
- const { cacheKey: n, storage: o = localStorage } = e || {}, r = n ? o.getItem(n) : null, l = R(
532
+ const { cacheKey: n, storage: r = localStorage } = e || {}, o = n ? r.getItem(n) : null, l = R(
525
533
  ee(
526
534
  t,
527
- r ? JSON.parse(r) : []
535
+ o ? JSON.parse(o) : []
528
536
  )
529
537
  );
530
538
  return z(
@@ -536,7 +544,7 @@ function We(t, e) {
536
544
  visible: d.visible,
537
545
  columnOpts: d.columnOpts
538
546
  }));
539
- o.setItem(
547
+ r.setItem(
540
548
  n,
541
549
  JSON.stringify(c)
542
550
  );
@@ -553,7 +561,7 @@ function We(t, e) {
553
561
  l.value = ee(
554
562
  t,
555
563
  i
556
- ), n && o.setItem(
564
+ ), n && r.setItem(
557
565
  n,
558
566
  JSON.stringify(i)
559
567
  );
@@ -562,7 +570,7 @@ function We(t, e) {
562
570
  * 重置为默认列配置
563
571
  */
564
572
  resetColumns() {
565
- l.value = t, n && o.removeItem(n);
573
+ l.value = t, n && r.removeItem(n);
566
574
  }
567
575
  };
568
576
  }
@@ -588,20 +596,20 @@ const Ge = /* @__PURE__ */ O({
588
596
  "cell-click"
589
597
  ],
590
598
  setup(t, { expose: e, emit: n }) {
591
- const o = t, r = n, { columns: l } = We(o.columns, {
592
- cacheKey: o.cacheKey ?? ""
599
+ const r = t, o = n, { columns: l } = We(r.columns, {
600
+ cacheKey: r.cacheKey ?? ""
593
601
  });
594
602
  z(
595
603
  l,
596
- (m) => r("update:columns", m),
604
+ (m) => o("update:columns", m),
597
605
  { deep: !0, immediate: !0 }
598
606
  );
599
- const i = (m, k) => r("cellChange", m, k), c = (m, k) => {
600
- r("cellBlur", m, k);
607
+ const i = (m, k) => o("cellChange", m, k), c = (m, k) => {
608
+ o("cellBlur", m, k);
601
609
  }, d = (m, k) => {
602
- console.log("enter"), r("cellEnter", m, k);
610
+ console.log("enter"), o("cellEnter", m, k);
603
611
  }, g = (m, k) => {
604
- k && r("cell-click", m, k);
612
+ k && o("cell-click", m, k);
605
613
  }, b = R();
606
614
  return e({
607
615
  tableRef: b
@@ -626,10 +634,10 @@ const Ge = /* @__PURE__ */ O({
626
634
  onCellEnter: d,
627
635
  onCellClick: g
628
636
  }, ge({ _: 2 }, [
629
- L(a(l), (S) => ({
630
- name: S.key,
637
+ L(a(l), (E) => ({
638
+ name: E.key,
631
639
  fn: A((N) => [
632
- ne(m.$slots, S.key, B({ ref_for: !0 }, N))
640
+ ne(m.$slots, E.key, B({ ref_for: !0 }, N))
633
641
  ])
634
642
  }))
635
643
  ]), 1032, ["col", "permissions", "pagination"]))), 128))
@@ -681,10 +689,10 @@ class Pe {
681
689
  * 深度合并配置
682
690
  */
683
691
  mergeConfig(e, n) {
684
- const o = { ...e };
685
- for (const r in n)
686
- n[r] && typeof n[r] == "object" && !Array.isArray(n[r]) ? o[r] = this.mergeConfig(e[r] || {}, n[r]) : o[r] = n[r];
687
- return o;
692
+ const r = { ...e };
693
+ for (const o in n)
694
+ n[o] && typeof n[o] == "object" && !Array.isArray(n[o]) ? r[o] = this.mergeConfig(e[o] || {}, n[o]) : r[o] = n[o];
695
+ return r;
688
696
  }
689
697
  }
690
698
  let j = null;
@@ -706,7 +714,7 @@ function Ze(t, e) {
706
714
  export {
707
715
  Ge as SmartTable,
708
716
  le as builtInRenderers,
709
- E as createFunctionalRenderer,
717
+ S as createFunctionalRenderer,
710
718
  Ye as createRenderer,
711
719
  Ge as default,
712
720
  Ze as defineColumn,