lkt-table 1.3.3 → 1.3.5

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/build.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare class M {
1
+ declare class F {
2
2
  constructor(r?: {});
3
3
  key: string;
4
4
  label: string;
@@ -946,4 +946,4 @@ declare function Wl(t: any): boolean;
946
946
  declare function Pl(t: any): void;
947
947
  declare function Ul(t: any): boolean;
948
948
  import { Field as He } from "lkt-field";
949
- export { M as Column, wl as createActionColumn, $l as createCheckColumn, Sl as createColumn, Il as createEmailColumn, Ml as createFileColumn, El as createFloatColumn, Fl as createHiddenColumn, Vl as createIntegerColumn, Bl as createLinkColumn, Ll as createSelectColumn, Rl as createSwitchColumn, Tl as createTelColumn, Dl as createTextColumn, Nl as default, Al as setTableCreateButtonSlot, Wl as setTableDropButtonSlot, Pl as setTableEmptySlot, Ul as setTableNavButtonSlot };
949
+ export { F as Column, wl as createActionColumn, $l as createCheckColumn, Sl as createColumn, Il as createEmailColumn, Ml as createFileColumn, El as createFloatColumn, Fl as createHiddenColumn, Vl as createIntegerColumn, Bl as createLinkColumn, Ll as createSelectColumn, Rl as createSwitchColumn, Tl as createTelColumn, Dl as createTextColumn, Nl as default, Al as setTableCreateButtonSlot, Wl as setTableDropButtonSlot, Pl as setTableEmptySlot, Ul as setTableNavButtonSlot };
package/dist/build.js CHANGED
@@ -1,11 +1,11 @@
1
- import { reactive as N, defineComponent as Y, ref as g, watch as W, computed as c, resolveComponent as H, unref as C, openBlock as n, createBlock as B, withCtx as P, createTextVNode as ae, toDisplayString as Q, createElementBlock as s, mergeProps as gt, Fragment as D, withModifiers as ze, resolveDynamicComponent as X, createCommentVNode as p, normalizeClass as O, createElementVNode as R, createVNode as te, renderList as A, renderSlot as F, withDirectives as se, vShow as de, useSlots as Ct, onMounted as St, nextTick as Pe, createSlots as Ke, normalizeProps as ie } from "vue";
1
+ import { reactive as U, defineComponent as Y, ref as g, watch as M, computed as c, resolveComponent as H, unref as C, openBlock as n, createBlock as S, withCtx as P, createTextVNode as ae, toDisplayString as Q, createElementBlock as s, mergeProps as gt, Fragment as D, withModifiers as ze, resolveDynamicComponent as X, createCommentVNode as p, normalizeClass as O, createElementVNode as R, createVNode as te, renderList as A, renderSlot as N, withDirectives as se, vShow as de, useSlots as Ct, onMounted as St, nextTick as Pe, createSlots as Ke, normalizeProps as ie } from "vue";
2
2
  import { Field as He } from "lkt-field";
3
3
  import { __ as ce } from "lkt-i18n";
4
4
  import { replaceAll as Ge, generateRandomString as Bt } from "lkt-string-tools";
5
5
  import { DataState as wt } from "lkt-data-state";
6
6
  import Dt from "sortablejs";
7
7
  import { time as ge } from "lkt-date-tools";
8
- class M {
8
+ class F {
9
9
  constructor(r = {}) {
10
10
  this.key = "", this.label = "", this.sortable = !0, this.hidden = !1, this.editable = !1, this.formatter = void 0, this.checkEmpty = void 0, this.colspan = void 0, this.preferSlot = !0, this.type = "", this.link = "", this.action = void 0, this.isForRowKey = !1, this.extractTitleFromColumn = "", this.slotData = {}, this.field = new He();
11
11
  for (let i in r)
@@ -22,7 +22,7 @@ class M {
22
22
  }
23
23
  }
24
24
  var E = /* @__PURE__ */ ((t) => (t.Text = "text", t.Number = "number", t.Check = "check", t.Switch = "switch", t.Select = "select", t.Email = "email", t.Tel = "tel", t.File = "file", t.Link = "link", t.Action = "action", t.Integer = "int", t.Float = "float", t))(E || {});
25
- const Sl = (t) => N(new M(t)), Bl = (t, r, i, a = !0) => N(new M({ key: t, label: r, sortable: a, type: E.Link, link: i })), wl = (t, r, i, a = !0) => N(new M({ key: t, label: r, sortable: a, type: E.Action, action: i })), Dl = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.Text, sortable: i })), Vl = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.Number, sortable: i })), El = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.Number, sortable: i })), Il = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.Email, sortable: i })), Tl = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.Tel, sortable: i })), $l = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.Check, sortable: i })), Rl = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.Switch, sortable: i })), Ll = (t, r, i, a = !0) => N(new M({ key: t, label: r, type: E.Select, sortable: a })), Ml = (t, r, i = !0) => N(new M({ key: t, label: r, type: E.File, sortable: i })), Fl = (t, r, i = !0) => N(new M({ key: t, label: r, sortable: i, hidden: !0 })), je = (t, r, i, a) => {
25
+ const Sl = (t) => U(new F(t)), Bl = (t, r, i, a = !0) => U(new F({ key: t, label: r, sortable: a, type: E.Link, link: i })), wl = (t, r, i, a = !0) => U(new F({ key: t, label: r, sortable: a, type: E.Action, action: i })), Dl = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.Text, sortable: i })), Vl = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.Number, sortable: i })), El = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.Number, sortable: i })), Il = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.Email, sortable: i })), Tl = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.Tel, sortable: i })), $l = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.Check, sortable: i })), Rl = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.Switch, sortable: i })), Ll = (t, r, i, a = !0) => U(new F({ key: t, label: r, type: E.Select, sortable: a })), Ml = (t, r, i = !0) => U(new F({ key: t, label: r, type: E.File, sortable: i })), Fl = (t, r, i = !0) => U(new F({ key: t, label: r, sortable: i, hidden: !0 })), je = (t, r, i, a) => {
26
26
  if (!i) return 0;
27
27
  let u = t[i.key], l = r[i.key];
28
28
  if (a === "asc") {
@@ -71,7 +71,7 @@ const Sl = (t) => N(new M(t)), Bl = (t, r, i, a = !0) => N(new M({ key: t, label
71
71
  __name: "LktTableCell",
72
72
  props: {
73
73
  modelValue: { default: () => ({}) },
74
- column: { default: () => new M() },
74
+ column: { default: () => new F() },
75
75
  columns: { default: () => [] },
76
76
  i: { default: 0 },
77
77
  editModeEnabled: { type: Boolean, default: !1 }
@@ -79,10 +79,10 @@ const Sl = (t) => N(new M(t)), Bl = (t, r, i, a = !0) => N(new M({ key: t, label
79
79
  emits: ["update:modelValue"],
80
80
  setup(t, { emit: r }) {
81
81
  const i = r, a = t, u = g(a.modelValue), l = g(u.value[a.column.key]), k = g(null);
82
- W(l, (f) => {
82
+ M(l, (f) => {
83
83
  const o = JSON.parse(JSON.stringify(u.value));
84
84
  o[a.column.key] = f, i("update:modelValue", o);
85
- }), W(() => a.modelValue, (f) => {
85
+ }), M(() => a.modelValue, (f) => {
86
86
  u.value = f, l.value = u.value[a.column.key];
87
87
  });
88
88
  const V = c(() => ({ ...a.column.slotData, item: u.value })), h = c(() => {
@@ -126,7 +126,7 @@ const Sl = (t) => N(new M(t)), Bl = (t, r, i, a = !0) => N(new M({ key: t, label
126
126
  }), K = c(() => [E.Integer, E.Float].includes(a.column.type) ? E.Number : a.column.type);
127
127
  return (f, o) => {
128
128
  const v = H("lkt-anchor"), b = H("lkt-field");
129
- return f.column.type === C(E).Link ? (n(), B(v, {
129
+ return f.column.type === C(E).Link ? (n(), S(v, {
130
130
  key: 0,
131
131
  to: f.column.getHref(u.value)
132
132
  }, {
@@ -138,7 +138,7 @@ const Sl = (t) => N(new M(t)), Bl = (t, r, i, a = !0) => N(new M({ key: t, label
138
138
  key: 1,
139
139
  href: "#",
140
140
  onClick: o[0] || (o[0] = (y) => f.column.doAction(u.value))
141
- }, Q(C(le)(f.column, u.value, f.i)), 1)) : f.column.type !== "" ? (n(), B(b, gt({ key: 2 }, f.column.field, {
141
+ }, Q(C(le)(f.column, u.value, f.i)), 1)) : f.column.type !== "" ? (n(), S(b, gt({ key: 2 }, f.column.field, {
142
142
  icon: d.value,
143
143
  download: q.value,
144
144
  type: K.value,
@@ -175,7 +175,7 @@ const Rt = /* @__PURE__ */ Y({
175
175
  const i = r, a = c(() => $.dropButtonSlot !== ""), u = c(() => $.dropButtonSlot);
176
176
  return (l, k) => {
177
177
  const V = H("lkt-button");
178
- return n(), B(V, {
178
+ return n(), S(V, {
179
179
  palette: "table-delete",
180
180
  icon: a.value ? "" : l.icon,
181
181
  text: a.value ? "" : l.text,
@@ -186,7 +186,7 @@ const Rt = /* @__PURE__ */ Y({
186
186
  onClick: k[0] || (k[0] = ze((h) => i("click"), ["prevent", "stop"]))
187
187
  }, {
188
188
  default: P(() => [
189
- a.value ? (n(), B(X(u.value), { key: 0 })) : p("", !0)
189
+ a.value ? (n(), S(X(u.value), { key: 0 })) : p("", !0)
190
190
  ]),
191
191
  _: 1
192
192
  }, 8, ["icon", "text", "resource", "resource-data", "confirm-modal", "disabled"]);
@@ -208,7 +208,7 @@ const Rt = /* @__PURE__ */ Y({
208
208
  const i = r, a = c(() => $.editButtonSlot !== ""), u = c(() => $.editButtonSlot);
209
209
  return (l, k) => {
210
210
  const V = H("lkt-button");
211
- return n(), B(V, {
211
+ return n(), S(V, {
212
212
  palette: "table-delete",
213
213
  icon: a.value ? "" : l.icon,
214
214
  text: a.value ? "" : l.text,
@@ -221,7 +221,7 @@ const Rt = /* @__PURE__ */ Y({
221
221
  onClick: k[0] || (k[0] = ze((h) => i("click"), ["prevent", "stop"]))
222
222
  }, {
223
223
  default: P(() => [
224
- a.value ? (n(), B(X(u.value), { key: 0 })) : p("", !0)
224
+ a.value ? (n(), S(X(u.value), { key: 0 })) : p("", !0)
225
225
  ]),
226
226
  _: 1
227
227
  }, 8, ["icon", "text", "on-click-to", "is-anchor", "resource", "resource-data", "confirm-modal", "disabled"]);
@@ -280,7 +280,7 @@ const Rt = /* @__PURE__ */ Y({
280
280
  i("item-drop", a.i);
281
281
  }, f = () => {
282
282
  };
283
- return W(() => a.modelValue, (o) => u.value = o), W(u, (o) => {
283
+ return M(() => a.modelValue, (o) => u.value = o), M(u, (o) => {
284
284
  i("update:modelValue", o, a.i);
285
285
  }, { deep: !0 }), (o, v) => {
286
286
  const b = H("lkt-button");
@@ -301,7 +301,7 @@ const Rt = /* @__PURE__ */ Y({
301
301
  onClick: q
302
302
  }, {
303
303
  default: P(() => [
304
- I.value ? (n(), B(X(d.value), {
304
+ I.value ? (n(), S(X(d.value), {
305
305
  key: 0,
306
306
  direction: "up"
307
307
  })) : (n(), s(D, { key: 1 }, [
@@ -317,7 +317,7 @@ const Rt = /* @__PURE__ */ Y({
317
317
  onClick: oe
318
318
  }, {
319
319
  default: P(() => [
320
- I.value ? (n(), B(X(d.value), {
320
+ I.value ? (n(), S(X(d.value), {
321
321
  key: 0,
322
322
  direction: "down"
323
323
  })) : (n(), s(D, { key: 1 }, [
@@ -343,13 +343,13 @@ const Rt = /* @__PURE__ */ Y({
343
343
  title: C(le)(y, u.value, o.i, o.visibleColumns),
344
344
  onClick: (Z) => k(Z, u.value)
345
345
  }, [
346
- o.$slots[y.key] && C(Et)(y, u.value) ? F(o.$slots, y.key, {
346
+ o.$slots[y.key] && C(Et)(y, u.value) ? N(o.$slots, y.key, {
347
347
  key: 0,
348
348
  value: u.value[y.key],
349
349
  item: u.value,
350
350
  column: y,
351
351
  i: o.i
352
- }) : u.value ? (n(), B(Je, {
352
+ }) : u.value ? (n(), S(Je, {
353
353
  key: 1,
354
354
  modelValue: u.value,
355
355
  "onUpdate:modelValue": v[1] || (v[1] = (Z) => u.value = Z),
@@ -398,7 +398,7 @@ const Rt = /* @__PURE__ */ Y({
398
398
  emits: ["update:modelValue", "click"],
399
399
  setup(t, { emit: r }) {
400
400
  const i = r, a = t, u = g(a.modelValue), l = (k) => i("click", k);
401
- return W(() => a.modelValue, (k) => u.value = k), W(u, () => i("update:modelValue", u.value)), (k, V) => se((n(), s("tr", Ht, [
401
+ return M(() => a.modelValue, (k) => u.value = k), M(u, () => i("update:modelValue", u.value)), (k, V) => se((n(), s("tr", Ht, [
402
402
  R("td", { colspan: k.hiddenColumnsColSpan }, [
403
403
  R("table", null, [
404
404
  R("tr", null, [
@@ -414,13 +414,13 @@ const Rt = /* @__PURE__ */ Y({
414
414
  title: C(le)(h, u.value, I, k.hiddenColumns),
415
415
  onClick: (d) => l(d, u.value)
416
416
  }, [
417
- k.$slots[h.key] ? F(k.$slots, h.key, {
417
+ k.$slots[h.key] ? N(k.$slots, h.key, {
418
418
  key: 0,
419
419
  value: u.value[h.key],
420
420
  item: u.value,
421
421
  column: h,
422
422
  i: I
423
- }) : (n(), B(Je, {
423
+ }) : (n(), S(Je, {
424
424
  key: 1,
425
425
  column: h,
426
426
  columns: k.hiddenColumns,
@@ -449,7 +449,7 @@ const Rt = /* @__PURE__ */ Y({
449
449
  const i = r, a = c(() => $.createButtonSlot !== ""), u = c(() => $.createButtonSlot);
450
450
  return (l, k) => {
451
451
  const V = H("lkt-button");
452
- return n(), B(V, {
452
+ return n(), S(V, {
453
453
  palette: "table-create",
454
454
  disabled: l.disabled,
455
455
  icon: a.value ? "" : l.icon,
@@ -458,7 +458,7 @@ const Rt = /* @__PURE__ */ Y({
458
458
  onClick: k[0] || (k[0] = (h) => i("click"))
459
459
  }, {
460
460
  default: P(() => [
461
- a.value ? (n(), B(X(u.value), { key: 0 })) : p("", !0)
461
+ a.value ? (n(), S(X(u.value), { key: 0 })) : p("", !0)
462
462
  ]),
463
463
  _: 1
464
464
  }, 8, ["disabled", "icon", "text", "on-click-to"]);
@@ -533,8 +533,9 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
533
533
  initialSorting: { type: Boolean, default: !1 },
534
534
  draggableItemKey: { default: "name" },
535
535
  itemDisplayChecker: {},
536
+ loading: { type: Boolean, default: !1 },
536
537
  page: { default: 1 },
537
- perms: { default: [] },
538
+ perms: { default: () => [] },
538
539
  resource: { default: "" },
539
540
  noResultsText: { default: "No results" },
540
541
  title: { default: "" },
@@ -580,9 +581,23 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
580
581
  requiredItemsForBottomCreate: { default: 0 },
581
582
  slotItemVar: { default: "item" }
582
583
  },
583
- emits: ["update:modelValue", "update:perms", "sort", "click", "save", "error", "before-save", "read-response", "click-create"],
584
+ emits: [
585
+ "update:modelValue",
586
+ "update:perms",
587
+ "update:loading",
588
+ "sort",
589
+ "click",
590
+ "save",
591
+ "error",
592
+ "before-save",
593
+ "read-response",
594
+ "click-create",
595
+ "page"
596
+ ],
584
597
  setup(t, { expose: r, emit: i }) {
585
- const a = i, u = Ct(), l = t, k = {}, V = g(typeof l.sorter == "function" ? l.sorter : je), h = g(Tt(l.columns)), I = g("asc"), d = g(l.modelValue), q = g(k), oe = g(null), K = g(l.columns), f = g(l.page), o = g(!1), v = g(!1), b = g(l.perms), y = g(null), Z = g({}), ee = g(new wt({ items: d.value }, l.dataStateConfig)), L = g(l.editMode), ne = g(0), fe = g(l.type);
598
+ const a = i, u = Ct(), l = t, k = {}, V = g(typeof l.sorter == "function" ? l.sorter : je), h = g(Tt(l.columns)), I = g("asc"), d = g(l.modelValue), q = g(k), oe = g(null), K = g(l.columns), f = g(l.page), o = g(l.loading), v = g(!1), b = g(l.perms), y = g(null), Z = g({}), ee = g(new wt({ items: d.value }, l.dataStateConfig)), L = g(l.editMode), ne = g(0);
599
+ M(o, (e) => a("update:loading", e)), M(f, (e) => a("page", e));
600
+ const fe = g(l.type);
586
601
  l.itemMode && fe.value === J.Table && (fe.value = J.Item);
587
602
  const Oe = (e) => {
588
603
  Array.isArray(e) && (d.value = e), o.value = !1, v.value = !0, ee.value.store({ items: d.value }).turnStoredIntoOriginal();
@@ -597,12 +612,12 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
597
612
  if (!l.hideEmptyColumns) return [];
598
613
  let e = [];
599
614
  return K.value.forEach((m) => {
600
- let w = m.key, U = !1;
615
+ let w = m.key, W = !1;
601
616
  d.value.forEach((z) => {
602
617
  if (typeof z.checkEmpty == "function")
603
618
  return z.checkEmpty(z);
604
- z[w] && (U = !0);
605
- }), U || e.push(w);
619
+ z[w] && (W = !0);
620
+ }), W || e.push(w);
606
621
  }), e;
607
622
  }), pe = c(() => K.value.filter((e) => !e.hidden)), Se = c(() => K.value.filter((e) => e.hidden)), xe = c(() => {
608
623
  let e = pe.value.length + 1;
@@ -654,8 +669,8 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
654
669
  ee.value.turnStoredIntoOriginal(), a("save", m);
655
670
  }, Ue = (e, m, w) => {
656
671
  if (w >= e.length) {
657
- let U = w - e.length + 1;
658
- for (; U--; ) e.push(void 0);
672
+ let W = w - e.length + 1;
673
+ for (; W--; ) e.push(void 0);
659
674
  }
660
675
  return e.splice(w, 0, e.splice(m, 1)[0]), e;
661
676
  }, vt = (e) => {
@@ -671,25 +686,25 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
671
686
  handle: ".handle",
672
687
  animation: 150,
673
688
  onEnd: function(m) {
674
- let w = m.oldIndex, U = m.newIndex;
675
- d.value.splice(U, 0, d.value.splice(w, 1)[0]), ne.value = ge();
689
+ let w = m.oldIndex, W = m.newIndex;
690
+ d.value.splice(W, 0, d.value.splice(w, 1)[0]), ne.value = ge();
676
691
  },
677
692
  onMove: function(m, w) {
678
693
  return ct(m);
679
694
  }
680
695
  });
681
696
  }, We = (e, m, w = !1) => {
682
- let U = [ne.value, me, "row", m];
683
- return w && U.push("hidden"), et.value.forEach((z) => {
697
+ let W = [ne.value, me, "row", m];
698
+ return w && W.push("hidden"), et.value.forEach((z) => {
684
699
  let G = String(e[z.key]).toLowerCase();
685
- G.length > 50 && (G = G.substring(0, 50)), G = Ge(G, " ", "-"), U.push(G);
686
- }), U.join("-");
700
+ G.length > 50 && (G = G.substring(0, 50)), G = Ge(G, " ", "-"), W.push(G);
701
+ }), W.join("-");
687
702
  }, Ae = c(() => typeof l.createEnabledValidator == "function" ? l.createEnabledValidator({ items: d.value }) : !0), ye = c(() => ve.value ? l.canCreateWithoutEdition || l.canCreate && L.value : !1), be = (e) => typeof l.itemDisplayChecker == "function" ? l.itemDisplayChecker(e) : !0;
688
703
  St(() => {
689
704
  l.initialSorting && Re($t(l.columns, h.value)), ee.value.store({ items: d.value }).turnStoredIntoOriginal(), l.sortable && Pe(() => {
690
705
  yt();
691
706
  });
692
- }), W(() => l.perms, (e) => b.value = e), W(b, (e) => a("update:perms", e)), W(() => l.editMode, (e) => L.value = e), W(() => l.columns, (e) => K.value = e), W(() => l.modelValue, (e) => d.value = e), W(d, (e) => {
707
+ }), M(() => l.perms, (e) => b.value = e), M(b, (e) => a("update:perms", e)), M(() => l.editMode, (e) => L.value = e), M(() => l.columns, (e) => K.value = e), M(() => l.modelValue, (e) => d.value = e), M(d, (e) => {
693
708
  ee.value.increment({ items: e }), a("update:modelValue", e);
694
709
  }, { deep: !0 }), r({
695
710
  getItemByEvent: dt,
@@ -697,7 +712,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
697
712
  });
698
713
  const bt = c(() => typeof $.defaultEmptySlot < "u"), ht = c(() => $.defaultEmptySlot);
699
714
  return (e, m) => {
700
- const w = H("lkt-button"), U = H("lkt-field"), z = H("lkt-loader"), G = H("lkt-paginator");
715
+ const w = H("lkt-button"), W = H("lkt-field"), z = H("lkt-loader"), G = H("lkt-paginator");
701
716
  return n(), s("section", {
702
717
  class: "lkt-table-page",
703
718
  id: "lkt-table-page-" + C(me)
@@ -706,7 +721,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
706
721
  key: 0,
707
722
  class: O(e.headerClass)
708
723
  }, [
709
- Be.value ? (n(), B(X(ut.value), { key: 0 }, {
724
+ Be.value ? (n(), S(X(ut.value), { key: 0 }, {
710
725
  default: P(() => [
711
726
  e.titleIcon ? (n(), s("i", {
712
727
  key: 0,
@@ -716,9 +731,9 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
716
731
  ]),
717
732
  _: 1
718
733
  })) : p("", !0),
719
- C(u).title ? F(e.$slots, "title", { key: 1 }) : p("", !0)
734
+ C(u).title ? N(e.$slots, "title", { key: 1 }) : p("", !0)
720
735
  ], 2)) : p("", !0),
721
- (n(), B(X(rt.value), {
736
+ (n(), S(X(rt.value), {
722
737
  class: O(["lkt-table-page-content-wrapper", e.wrapContentClass])
723
738
  }, {
724
739
  default: P(() => [
@@ -736,7 +751,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
736
751
  onClick: pt
737
752
  }, {
738
753
  default: P(() => [
739
- C(u)["button-save"] ? F(e.$slots, "button-save", {
754
+ C(u)["button-save"] ? N(e.$slots, "button-save", {
740
755
  key: 0,
741
756
  items: d.value,
742
757
  editMode: e.editMode,
@@ -747,7 +762,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
747
762
  }, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"]), [
748
763
  [de, Te.value]
749
764
  ]),
750
- ye.value && d.value.length >= e.requiredItemsForTopCreate ? (n(), B(qe, {
765
+ ye.value && d.value.length >= e.requiredItemsForTopCreate ? (n(), S(qe, {
751
766
  key: 0,
752
767
  disabled: !Ae.value || e.createDisabled,
753
768
  text: e.createText,
@@ -756,10 +771,10 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
756
771
  onClick: Ne
757
772
  }, null, 8, ["disabled", "text", "icon", "to"])) : p("", !0),
758
773
  R("div", _t, [
759
- se(te(U, {
774
+ se(te(W, {
760
775
  type: "switch",
761
776
  modelValue: L.value,
762
- "onUpdate:modelValue": m[0] || (m[0] = (S) => L.value = S),
777
+ "onUpdate:modelValue": m[0] || (m[0] = (B) => L.value = B),
763
778
  label: st.value
764
779
  }, null, 8, ["modelValue", "label"]), [
765
780
  [de, e.switchEditionEnabled]
@@ -769,15 +784,15 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
769
784
  [de, lt.value]
770
785
  ]),
771
786
  C(u).buttons ? (n(), s("div", xt, [
772
- F(e.$slots, "buttons")
787
+ N(e.$slots, "buttons")
773
788
  ])) : p("", !0),
774
789
  v.value && C(u).filters ? (n(), s("div", el, [
775
- F(e.$slots, "filters", {
790
+ N(e.$slots, "filters", {
776
791
  items: d.value,
777
792
  isLoading: o.value
778
793
  })
779
794
  ])) : p("", !0),
780
- o.value ? (n(), B(z, { key: 2 })) : p("", !0),
795
+ o.value ? (n(), S(z, { key: 2 })) : p("", !0),
781
796
  se(R("div", {
782
797
  class: "lkt-table",
783
798
  "data-sortable": e.sortable
@@ -788,15 +803,15 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
788
803
  e.sortable && L.value ? (n(), s("th", al)) : p("", !0),
789
804
  e.addNavigation && L.value ? (n(), s("th", ol)) : p("", !0),
790
805
  Ee.value ? (n(), s("th", nl)) : p("", !0),
791
- (n(!0), s(D, null, A(pe.value, (S) => (n(), s(D, null, [
792
- Ce.value.indexOf(S.key) === -1 ? (n(), B(Qt, {
806
+ (n(!0), s(D, null, A(pe.value, (B) => (n(), s(D, null, [
807
+ Ce.value.indexOf(B.key) === -1 ? (n(), S(Qt, {
793
808
  key: 0,
794
- column: S,
809
+ column: B,
795
810
  "sort-by": h.value,
796
811
  "sort-direction": I.value,
797
812
  "amount-of-columns": e.columns.length,
798
813
  items: d.value,
799
- onClick: (T) => Re(S)
814
+ onClick: (T) => Re(B)
800
815
  }, null, 8, ["column", "sort-by", "sort-direction", "amount-of-columns", "items", "onClick"])) : p("", !0)
801
816
  ], 64))), 256)),
802
817
  e.canDrop && re.value && L.value ? (n(), s("th", ul)) : p("", !0),
@@ -804,17 +819,18 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
804
819
  ])
805
820
  ]),
806
821
  R("tbody", {
807
- ref: (S) => oe.value = S,
822
+ ref_key: "tableBody",
823
+ ref: oe,
808
824
  id: "lkt-table-body-" + C(me)
809
825
  }, [
810
- (n(!0), s(D, null, A(d.value, (S, T) => (n(), s(D, null, [
811
- be(S) ? (n(), B(Kt, {
826
+ (n(!0), s(D, null, A(d.value, (B, T) => (n(), s(D, null, [
827
+ be(B) ? (n(), S(Kt, {
812
828
  modelValue: d.value[T],
813
829
  "onUpdate:modelValue": (_) => d.value[T] = _,
814
- key: We(S, T),
830
+ key: We(B, T),
815
831
  i: T,
816
832
  "display-hidden-columns-indicator": Ee.value,
817
- "is-draggable": Fe(S),
833
+ "is-draggable": Fe(B),
818
834
  sortable: e.sortable,
819
835
  "visible-columns": pe.value,
820
836
  "empty-columns": Ce.value,
@@ -840,7 +856,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
840
856
  A(Ie.value, (_) => ({
841
857
  name: _,
842
858
  fn: P((j) => [
843
- F(e.$slots, _, ie({
859
+ N(e.$slots, _, ie({
844
860
  [e.slotItemVar || ""]: j.item,
845
861
  value: j.value,
846
862
  column: j.column
@@ -848,7 +864,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
848
864
  ])
849
865
  }))
850
866
  ]), 1032, ["modelValue", "onUpdate:modelValue", "i", "display-hidden-columns-indicator", "is-draggable", "sortable", "visible-columns", "empty-columns", "add-navigation", "hidden-is-visible", "latest-row", "can-drop", "drop-confirm", "drop-resource", "drop-text", "drop-icon", "can-edit", "edit-text", "edit-icon", "edit-link", "edit-mode-enabled"])) : p("", !0),
851
- Se.value.length > 0 ? (n(!0), s(D, { key: 1 }, A(d.value, (_, j) => (n(), B(Jt, {
867
+ Se.value.length > 0 ? (n(!0), s(D, { key: 1 }, A(d.value, (_, j) => (n(), S(Jt, {
852
868
  modelValue: d.value[j],
853
869
  "onUpdate:modelValue": (he) => d.value[j] = he,
854
870
  key: We(_, j, !0),
@@ -866,7 +882,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
866
882
  A(Ie.value, (he) => ({
867
883
  name: he,
868
884
  fn: P((De) => [
869
- F(e.$slots, he, ie({
885
+ N(e.$slots, he, ie({
870
886
  [e.slotItemVar || ""]: De.item,
871
887
  value: De.value,
872
888
  column: De.column
@@ -880,10 +896,10 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
880
896
  key: 1,
881
897
  class: O(["lkt-table-items-container", e.itemsContainerClass])
882
898
  }, [
883
- (n(!0), s(D, null, A(d.value, (S, T) => (n(), s(D, null, [
884
- be(S) ? (n(), s("div", sl, [
885
- F(e.$slots, "item", ie({
886
- [e.slotItemVar || ""]: S,
899
+ (n(!0), s(D, null, A(d.value, (B, T) => (n(), s(D, null, [
900
+ be(B) ? (n(), s("div", sl, [
901
+ N(e.$slots, "item", ie({
902
+ [e.slotItemVar || ""]: B,
887
903
  index: T,
888
904
  canCreate: ve.value,
889
905
  canRead: we.value,
@@ -898,10 +914,10 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
898
914
  key: 2,
899
915
  class: O(["lkt-table-items-container", e.itemsContainerClass])
900
916
  }, [
901
- (n(!0), s(D, null, A(d.value, (S, T) => (n(), s(D, null, [
902
- be(S) ? (n(), s("li", dl, [
903
- F(e.$slots, "item", ie({
904
- [e.slotItemVar || ""]: S,
917
+ (n(!0), s(D, null, A(d.value, (B, T) => (n(), s(D, null, [
918
+ be(B) ? (n(), s("li", dl, [
919
+ N(e.$slots, "item", ie({
920
+ [e.slotItemVar || ""]: B,
905
921
  index: T,
906
922
  canCreate: ve.value,
907
923
  canRead: we.value,
@@ -916,10 +932,10 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
916
932
  key: 3,
917
933
  class: O(["lkt-table-items-container", e.itemsContainerClass])
918
934
  }, [
919
- (n(!0), s(D, null, A(d.value, (S, T) => (n(), s(D, null, [
920
- be(S) ? (n(), s("li", cl, [
921
- F(e.$slots, "item", ie({
922
- [e.slotItemVar || ""]: S,
935
+ (n(!0), s(D, null, A(d.value, (B, T) => (n(), s(D, null, [
936
+ be(B) ? (n(), s("li", cl, [
937
+ N(e.$slots, "item", ie({
938
+ [e.slotItemVar || ""]: B,
923
939
  index: T,
924
940
  canCreate: ve.value,
925
941
  canRead: we.value,
@@ -935,7 +951,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
935
951
  [de, !o.value && d.value.length > 0]
936
952
  ]),
937
953
  !o.value && d.value.length === 0 ? (n(), s("div", fl, [
938
- C(u).empty ? F(e.$slots, "empty", { key: 0 }) : bt.value ? (n(), B(X(ht.value), {
954
+ C(u).empty ? N(e.$slots, "empty", { key: 0 }) : bt.value ? (n(), S(X(ht.value), {
939
955
  key: 1,
940
956
  message: e.noResultsText
941
957
  }, null, 8, ["message"])) : e.noResultsText ? (n(), s(D, { key: 2 }, [
@@ -943,7 +959,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
943
959
  ], 64)) : p("", !0)
944
960
  ])) : p("", !0),
945
961
  ye.value || C(u).bottomButtons ? (n(), s("div", ml, [
946
- ye.value && d.value.length >= e.requiredItemsForBottomCreate ? (n(), B(qe, {
962
+ ye.value && d.value.length >= e.requiredItemsForBottomCreate ? (n(), S(qe, {
947
963
  key: 0,
948
964
  disabled: !Ae.value || e.createDisabled,
949
965
  text: e.createText,
@@ -951,14 +967,14 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
951
967
  to: e.createRoute,
952
968
  onClick: Ne
953
969
  }, null, 8, ["disabled", "text", "icon", "to"])) : p("", !0),
954
- F(e.$slots, "bottom-buttons")
970
+ N(e.$slots, "bottom-buttons")
955
971
  ])) : p("", !0),
956
- e.resource.length > 0 ? (n(), B(G, {
972
+ e.resource.length > 0 ? (n(), S(G, {
957
973
  key: 5,
958
974
  ref_key: "paginator",
959
975
  ref: y,
960
976
  modelValue: f.value,
961
- "onUpdate:modelValue": m[1] || (m[1] = (S) => f.value = S),
977
+ "onUpdate:modelValue": m[1] || (m[1] = (B) => f.value = B),
962
978
  resource: e.resource,
963
979
  filters: e.filters,
964
980
  onResults: Oe,
@@ -981,7 +997,7 @@ const Xt = ["id"], Yt = { class: "lkt-table-page-buttons" }, Zt = { key: 1 }, _t
981
997
  $.defaultEmptySlot = t;
982
998
  };
983
999
  export {
984
- M as Column,
1000
+ F as Column,
985
1001
  wl as createActionColumn,
986
1002
  $l as createCheckColumn,
987
1003
  Sl as createColumn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-table",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -5,7 +5,7 @@ import {Settings} from "../settings/Settings";
5
5
  const emit = defineEmits(['click']);
6
6
 
7
7
  const props = withDefaults(defineProps<{
8
- disabled: boolean
8
+ disabled?: boolean
9
9
  text: string
10
10
  icon: string
11
11
  to: string
@@ -14,9 +14,21 @@ import TableHeader from "../components/TableHeader.vue";
14
14
  import {__} from "lkt-i18n";
15
15
  import {time} from "lkt-date-tools";
16
16
  import {Settings} from "../settings/Settings";
17
- import {TypeOfTable} from "@/enums/TypeOfTable";
18
-
19
- const emit = defineEmits(['update:modelValue', 'update:perms', 'sort', 'click', 'save', 'error', 'before-save', 'read-response', 'click-create']);
17
+ import {TypeOfTable} from "../enums/TypeOfTable";
18
+
19
+ const emit = defineEmits([
20
+ 'update:modelValue',
21
+ 'update:perms',
22
+ 'update:loading',
23
+ 'sort',
24
+ 'click',
25
+ 'save',
26
+ 'error',
27
+ 'before-save',
28
+ 'read-response',
29
+ 'click-create',
30
+ 'page',
31
+ ]);
20
32
 
21
33
  const slots = useSlots();
22
34
 
@@ -32,6 +44,7 @@ const props = withDefaults(defineProps<{
32
44
  initialSorting?: boolean
33
45
  draggableItemKey?: string
34
46
  itemDisplayChecker?: Function
47
+ loading?: boolean
35
48
 
36
49
 
37
50
  page?: number
@@ -92,10 +105,11 @@ const props = withDefaults(defineProps<{
92
105
  hideEmptyColumns: false,
93
106
  initialSorting: false,
94
107
  draggableItemKey: 'name',
108
+ loading: false,
95
109
 
96
110
 
97
111
  page: 1,
98
- perms: [],
112
+ perms: () => [],
99
113
  resource: '',
100
114
  noResultsText: 'No results',
101
115
  title: '',
@@ -153,7 +167,7 @@ const Sorter = ref(typeof props.sorter === 'function' ? props.sorter : defaultTa
153
167
  Columns = ref(props.columns);
154
168
 
155
169
  const Page = ref(props.page),
156
- loading = ref(false),
170
+ isLoading = ref(props.loading),
157
171
  firstLoadReady = ref(false),
158
172
  permissions = ref(props.perms),
159
173
  paginator = ref(null),
@@ -163,6 +177,10 @@ const Page = ref(props.page),
163
177
  updateTimeStamp = ref(0)
164
178
  ;
165
179
 
180
+ watch(isLoading, v => emit('update:loading', v));
181
+
182
+ watch(Page, (v) => emit('page', v));
183
+
166
184
  const Type = ref(props.type);
167
185
  if (props.itemMode && Type.value === TypeOfTable.Table) {
168
186
  Type.value = TypeOfTable.Item;
@@ -171,7 +189,7 @@ if (props.itemMode && Type.value === TypeOfTable.Table) {
171
189
  const onResults = (r: any) => {
172
190
  //@ts-ignore
173
191
  if (Array.isArray(r)) Items.value = r;
174
- loading.value = false;
192
+ isLoading.value = false;
175
193
  firstLoadReady.value = true;
176
194
  dataState.value.store({items: Items.value}).turnStoredIntoOriginal();
177
195
  },
@@ -184,7 +202,7 @@ const onResults = (r: any) => {
184
202
  onPaginatorResponse = (r: HTTPResponse) => {
185
203
  emit('read-response', r);
186
204
  },
187
- onLoading = () => nextTick(() => loading.value = true),
205
+ onLoading = () => nextTick(() => isLoading.value = true),
188
206
  doRefresh = () => {
189
207
  //@ts-ignore
190
208
  paginator.value.doRefresh();
@@ -232,14 +250,14 @@ const emptyColumns = computed(() => {
232
250
  return Columns.value.map(c => c.key);
233
251
 
234
252
  }),
235
- colSlots = computed((): LktObject => {
236
- let r = [];
253
+ colSlots = computed((): string[] => {
254
+ let r:string[] = [];
237
255
  for (let k in slots) if (columnKeys.value.indexOf(k) !== -1) r.push(k);
238
256
  return r;
239
257
  }),
240
258
  showSaveButton = computed(() => {
241
259
  if (props.hiddenSave) return false;
242
- if (loading.value) return false;
260
+ if (isLoading.value) return false;
243
261
  if (!props.saveResource) return false;
244
262
  if (editModeEnabled.value && dataState.value.changed()) return true;
245
263
 
@@ -357,15 +375,15 @@ const getItemByEvent = (e: any) => {
357
375
  }
358
376
  },
359
377
  onButtonLoading = () => {
360
- loading.value = true;
378
+ isLoading.value = true;
361
379
  },
362
380
  onButtonLoaded = () => {
363
- loading.value = false;
381
+ isLoading.value = false;
364
382
  },
365
383
  onSave = ($event: PointerEvent, r: HTTPResponse) => {
366
384
  emit('before-save');
367
385
  if (props.saveResource) {
368
- loading.value = false;
386
+ isLoading.value = false;
369
387
  if (!r.success) {
370
388
  emit('error', r.httpStatus);
371
389
  return;
@@ -403,7 +421,10 @@ const getItemByEvent = (e: any) => {
403
421
  handle: '.handle',
404
422
  animation: 150,
405
423
  onEnd: function (evt: CustomEvent) {
424
+ //@ts-ignore
406
425
  let oldIndex = evt.oldIndex;
426
+
427
+ //@ts-ignore
407
428
  let newIndex = evt.newIndex;
408
429
  Items.value.splice(newIndex, 0, Items.value.splice(oldIndex, 1)[0]);
409
430
  updateTimeStamp.value = time();
@@ -542,12 +563,12 @@ const hasEmptySlot = computed(() => {
542
563
  </div>
543
564
 
544
565
  <div class="lkt-table-page-filters" v-if="firstLoadReady && slots.filters">
545
- <slot name="filters" :items="Items" :is-loading="loading"/>
566
+ <slot name="filters" :items="Items" :is-loading="isLoading"/>
546
567
  </div>
547
568
 
548
- <lkt-loader v-if="loading"/>
569
+ <lkt-loader v-if="isLoading"/>
549
570
 
550
- <div v-show="!loading && Items.length > 0" class="lkt-table" :data-sortable="sortable">
571
+ <div v-show="!isLoading && Items.length > 0" class="lkt-table" :data-sortable="sortable">
551
572
  <table v-if="Type === TypeOfTable.Table">
552
573
  <thead>
553
574
  <tr>
@@ -576,7 +597,7 @@ const hasEmptySlot = computed(() => {
576
597
  </tr>
577
598
  </thead>
578
599
  <tbody
579
- :ref="(el) => tableBody = el"
600
+ ref="tableBody"
580
601
  :id="'lkt-table-body-' + uniqueId"
581
602
  >
582
603
  <template
@@ -663,7 +684,7 @@ const hasEmptySlot = computed(() => {
663
684
  v-bind:can-read="hasReadPerm"
664
685
  v-bind:can-update="hasUpdatePerm"
665
686
  v-bind:can-drop="hasDropPerm"
666
- v-bind:is-loading="loading"
687
+ v-bind:is-loading="isLoading"
667
688
  v-bind:do-drop="() => onItemDrop(i)"
668
689
  />
669
690
  </div>
@@ -681,7 +702,7 @@ const hasEmptySlot = computed(() => {
681
702
  v-bind:can-read="hasReadPerm"
682
703
  v-bind:can-update="hasUpdatePerm"
683
704
  v-bind:can-drop="hasDropPerm"
684
- v-bind:is-loading="loading"
705
+ v-bind:is-loading="isLoading"
685
706
  v-bind:do-drop="() => onItemDrop(i)"
686
707
  />
687
708
  </li>
@@ -699,7 +720,7 @@ const hasEmptySlot = computed(() => {
699
720
  v-bind:can-read="hasReadPerm"
700
721
  v-bind:can-update="hasUpdatePerm"
701
722
  v-bind:can-drop="hasDropPerm"
702
- v-bind:is-loading="loading"
723
+ v-bind:is-loading="isLoading"
703
724
  v-bind:do-drop="() => onItemDrop(i)"
704
725
  />
705
726
  </li>
@@ -707,7 +728,7 @@ const hasEmptySlot = computed(() => {
707
728
  </ol>
708
729
  </div>
709
730
 
710
- <div class="lkt-table-empty" v-if="!loading && Items.length === 0">
731
+ <div class="lkt-table-empty" v-if="!isLoading && Items.length === 0">
711
732
  <template v-if="slots.empty">
712
733
  <slot name="empty"/>
713
734
  </template>