lkt-table 1.0.13 → 1.0.14

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.
@@ -1,24 +1,32 @@
1
- var ae = Object.defineProperty;
2
- var ne = (e, t, a) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
- var $ = (e, t, a) => (ne(e, typeof t != "symbol" ? t + "" : t, a), a);
4
- import { defineComponent as x, openBlock as s, createElementBlock as o, createCommentVNode as C, normalizeClass as ie, Fragment as k, renderList as g, unref as v, renderSlot as B, createTextVNode as Y, toDisplayString as L, withDirectives as re, createElementVNode as p, vShow as se, useSlots as oe, ref as V, computed as I, onMounted as de, watch as Q, createBlock as N, withCtx as H, createSlots as M } from "vue";
5
- import ue from "vuedraggable";
6
- import { createLktEvent as U } from "lkt-events";
7
- import { generateRandomString as ce } from "lkt-string-tools";
8
- class Z {
9
- constructor(t = "", a = "") {
10
- $(this, "key");
11
- $(this, "label");
12
- $(this, "sortable");
13
- $(this, "hidden");
14
- $(this, "formatter");
15
- $(this, "checkEmpty");
16
- $(this, "colspan");
17
- this.key = t, this.label = a, this.sortable = !0, this.hidden = !1, this.formatter = void 0, this.checkEmpty = void 0, this.colspan = void 0;
1
+ var oe = Object.defineProperty;
2
+ var ue = (e, t, l) => t in e ? oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: l }) : e[t] = l;
3
+ var g = (e, t, l) => (ue(e, typeof t != "symbol" ? t + "" : t, l), l);
4
+ import { defineComponent as R, ref as S, watch as T, resolveComponent as O, openBlock as o, createBlock as C, withCtx as U, createTextVNode as Z, toDisplayString as x, unref as p, createElementBlock as f, Fragment as B, createCommentVNode as w, normalizeClass as re, renderList as $, renderSlot as D, withDirectives as se, createElementVNode as E, vShow as de, useSlots as me, computed as N, onMounted as ce, createSlots as Q } from "vue";
5
+ import fe from "vuedraggable";
6
+ import { createLktEvent as W } from "lkt-events";
7
+ import { generateRandomString as ye } from "lkt-string-tools";
8
+ class I {
9
+ constructor(t = "", l = "") {
10
+ g(this, "key");
11
+ g(this, "label");
12
+ g(this, "sortable");
13
+ g(this, "hidden");
14
+ g(this, "editable");
15
+ g(this, "formatter");
16
+ g(this, "checkEmpty");
17
+ g(this, "colspan");
18
+ g(this, "type");
19
+ g(this, "link");
20
+ g(this, "action");
21
+ g(this, "options");
22
+ this.key = t, this.label = l, this.sortable = !0, this.hidden = !1, this.formatter = void 0, this.checkEmpty = void 0, this.colspan = void 0;
18
23
  }
19
24
  setIsSortable(t = !0) {
20
25
  return this.sortable = t, this;
21
26
  }
27
+ setIsEditable(t = !0) {
28
+ return this.editable = t, this;
29
+ }
22
30
  setIsHidden(t = !0) {
23
31
  return this.hidden = t, this;
24
32
  }
@@ -31,58 +39,169 @@ class Z {
31
39
  setColSpan(t = void 0) {
32
40
  return this.colspan = void 0, this;
33
41
  }
42
+ getHref(t) {
43
+ return typeof this.link == "function" ? this.link(t) : this.link;
44
+ }
45
+ doAction(t) {
46
+ if (typeof this.action == "function")
47
+ return this.action(t);
48
+ console.warn("No action defined");
49
+ }
50
+ defineAsLink(t) {
51
+ return this.type = "link", this.link = t, this;
52
+ }
53
+ defineAsText() {
54
+ return this.type = "text", this;
55
+ }
56
+ defineAsEmail() {
57
+ return this.type = "email", this;
58
+ }
59
+ defineAsTel() {
60
+ return this.type = "tel", this;
61
+ }
62
+ defineAsInt() {
63
+ return this.type = "int", this;
64
+ }
65
+ defineAsFloat() {
66
+ return this.type = "float", this;
67
+ }
68
+ defineAsCheck() {
69
+ return this.type = "check", this;
70
+ }
71
+ defineAsSwitch() {
72
+ return this.type = "switch", this;
73
+ }
74
+ defineAsAction(t) {
75
+ return this.type = "action", this.action = t, this;
76
+ }
77
+ defineAsSelect(t) {
78
+ return this.type = "select", this.options = t, this;
79
+ }
34
80
  }
35
- const qe = (e, t, a = !0) => new Z(e, t).setIsSortable(a), Me = (e, t, a = !0) => new Z(e, t).setIsSortable(a).setIsHidden(!0), W = (e, t, a, c) => {
36
- if (!a)
81
+ const Me = (e, t, l = !0) => new I(e, t).setIsSortable(l), Ge = (e, t, l, s = !0) => new I(e, t).setIsSortable(s).defineAsLink(l), Pe = (e, t, l, s = !0) => new I(e, t).setIsSortable(s).defineAsAction(l), Qe = (e, t, l = !0) => new I(e, t).setIsSortable(l).defineAsText(), We = (e, t, l = !0) => new I(e, t).setIsSortable(l).defineAsEmail(), Xe = (e, t, l = !0) => new I(e, t).setIsSortable(l).defineAsTel(), Ye = (e, t, l = !0) => new I(e, t).setIsSortable(l).defineAsCheck(), Ze = (e, t, l = !0) => new I(e, t).setIsSortable(l).defineAsSwitch(), _e = (e, t, l, s = !0) => new I(e, t).setIsSortable(s).defineAsSelect(l), et = (e, t, l = !0) => new I(e, t).setIsSortable(l).setIsHidden(!0), _ = (e, t, l, s) => {
82
+ if (!l)
37
83
  return 0;
38
- let f = e[a.key], n = t[a.key];
39
- if (c === "asc") {
40
- if (f > n)
84
+ let r = e[l.key], n = t[l.key];
85
+ if (s === "asc") {
86
+ if (r > n)
41
87
  return 1;
42
- if (n > f)
88
+ if (n > r)
43
89
  return -1;
44
90
  } else {
45
- if (f > n)
91
+ if (r > n)
46
92
  return -1;
47
- if (n > f)
93
+ if (n > r)
48
94
  return 1;
49
95
  }
50
96
  return 0;
51
- }, T = (e, t, a) => e.formatter && typeof e.formatter == "function" ? e.formatter(t[e.key], t, e, a) : t[e.key], fe = (e, t, a) => {
97
+ }, F = (e, t, l) => e.formatter && typeof e.formatter == "function" ? e.formatter(t[e.key], t, e, l) : t[e.key], he = (e, t, l) => {
52
98
  if (!e.colspan)
53
99
  return -1;
54
- let c = t;
55
- return a.forEach((f) => {
56
- let n = G(e, f);
57
- n > 0 && n < c && (c = n);
58
- }), c;
59
- }, G = (e, t) => e.colspan === !1 ? !1 : typeof e.colspan == "function" ? e.colspan(t) : e.colspan, me = (e, t, a) => {
100
+ let s = t;
101
+ return l.forEach((r) => {
102
+ let n = X(e, r);
103
+ n > 0 && n < s && (s = n);
104
+ }), s;
105
+ }, X = (e, t) => e.colspan === !1 ? !1 : typeof e.colspan == "function" ? e.colspan(t) : e.colspan, ve = (e, t, l) => {
60
106
  if (typeof e != "object" || !e.key || t.indexOf(e.key) > -1)
61
107
  return !1;
62
- let c = G(e, a);
63
- return typeof e.colspan > "u" ? !0 : (typeof e.colspan < "u" && (typeof e.colspan == "function" ? c = parseInt(e.colspan()) : c = parseInt(e.colspan)), c > 0);
64
- }, ye = (e = []) => {
108
+ let s = X(e, l);
109
+ return typeof e.colspan > "u" ? !0 : (typeof e.colspan < "u" && (typeof e.colspan == "function" ? s = parseInt(e.colspan()) : s = parseInt(e.colspan)), s > 0);
110
+ }, ke = (e = []) => {
65
111
  if (e.length > 0) {
66
112
  for (let t = 0; t < e.length; ++t)
67
113
  if (e[t].sortable)
68
114
  return e[t].key;
69
115
  }
70
116
  return "";
71
- }, he = (e, t) => {
117
+ }, be = (e, t) => {
72
118
  if (e.length > 0) {
73
- for (let a = 0; a < e.length; ++a)
74
- if (e[a].key === t)
75
- return e[a];
119
+ for (let l = 0; l < e.length; ++l)
120
+ if (e[l].key === t)
121
+ return e[l];
76
122
  }
77
123
  return null;
78
- }, be = ["data-i", "data-handle-drag"], ve = {
124
+ }, ge = { name: "LktTableCell", inheritAttrs: !1 }, te = /* @__PURE__ */ R({
125
+ ...ge,
126
+ props: {
127
+ column: { type: Object, default: () => ({}) },
128
+ i: { type: [Number], default: 0 },
129
+ modelValue: { type: Object, default: () => ({}) }
130
+ },
131
+ emits: ["edited"],
132
+ setup(e, { emit: t }) {
133
+ const l = t, s = e, r = S(s.modelValue), n = S(r.value[s.column.key]), h = S(null);
134
+ return T(n, () => {
135
+ const k = JSON.parse(JSON.stringify(r.value));
136
+ k[s.column.key] = n.value, l("edited", k, s.i);
137
+ }), T(() => s.modelValue, (k) => {
138
+ r.value = k, n.value = r.value[s.column.key];
139
+ }), (k, a) => {
140
+ const y = O("router-link"), u = O("lkt-field-text"), A = O("lkt-field-check"), K = O("lkt-field-switch"), L = O("lkt-field-select");
141
+ return e.column.type === "link" ? (o(), C(y, {
142
+ key: 0,
143
+ to: e.column.getHref(r.value)
144
+ }, {
145
+ default: U(() => [
146
+ Z(x(p(F)(e.column, r.value, e.i)), 1)
147
+ ]),
148
+ _: 1
149
+ }, 8, ["to"])) : e.column.type === "action" ? (o(), f("a", {
150
+ key: 1,
151
+ href: "#",
152
+ onClick: a[0] || (a[0] = (c) => e.column.doAction(r.value))
153
+ }, x(p(F)(e.column, r.value, e.i)), 1)) : e.column.type === "text" ? (o(), C(u, {
154
+ key: 2,
155
+ "read-mode": !e.column.editable,
156
+ ref: (c) => h.value = c,
157
+ modelValue: n.value,
158
+ "onUpdate:modelValue": a[1] || (a[1] = (c) => n.value = c)
159
+ }, null, 8, ["read-mode", "modelValue"])) : e.column.type === "email" ? (o(), C(u, {
160
+ key: 3,
161
+ "read-mode": !e.column.editable,
162
+ ref: (c) => h.value = c,
163
+ "is-email": "",
164
+ modelValue: n.value,
165
+ "onUpdate:modelValue": a[2] || (a[2] = (c) => n.value = c)
166
+ }, null, 8, ["read-mode", "modelValue"])) : e.column.type === "tel" ? (o(), C(u, {
167
+ key: 4,
168
+ "read-mode": !e.column.editable,
169
+ ref: (c) => h.value = c,
170
+ "is-tel": "",
171
+ modelValue: n.value,
172
+ "onUpdate:modelValue": a[3] || (a[3] = (c) => n.value = c)
173
+ }, null, 8, ["read-mode", "modelValue"])) : e.column.type === "check" ? (o(), C(A, {
174
+ key: 5,
175
+ "read-mode": !e.column.editable,
176
+ ref: (c) => h.value = c,
177
+ modelValue: n.value,
178
+ "onUpdate:modelValue": a[4] || (a[4] = (c) => n.value = c)
179
+ }, null, 8, ["read-mode", "modelValue"])) : e.column.type === "switch" ? (o(), C(K, {
180
+ key: 6,
181
+ "read-mode": !e.column.editable,
182
+ ref: (c) => h.value = c,
183
+ modelValue: n.value,
184
+ "onUpdate:modelValue": a[5] || (a[5] = (c) => n.value = c)
185
+ }, null, 8, ["read-mode", "modelValue"])) : e.column.type === "select" ? (o(), C(L, {
186
+ key: 7,
187
+ "read-mode": !e.column.editable,
188
+ ref: (c) => h.value = c,
189
+ modelValue: n.value,
190
+ "onUpdate:modelValue": a[6] || (a[6] = (c) => n.value = c),
191
+ options: e.column.options
192
+ }, null, 8, ["read-mode", "modelValue", "options"])) : (o(), f(B, { key: 8 }, [
193
+ Z(x(p(F)(e.column, r.value, e.i)), 1)
194
+ ], 64));
195
+ };
196
+ }
197
+ }), Ce = ["data-i", "data-handle-drag"], pe = {
79
198
  key: 0,
80
199
  "data-role": "drag-indicator"
81
- }, ke = {
200
+ }, Ve = {
82
201
  key: 1,
83
202
  "data-role": "invalid-drag-indicator"
84
- }, ge = ["data-column", "colspan", "title", "onClick"], Ce = { name: "LktTableRow", inheritAttrs: !1 }, X = /* @__PURE__ */ x({
85
- ...Ce,
203
+ }, Se = ["data-column", "colspan", "title", "onClick"], Ae = { name: "LktTableRow", inheritAttrs: !1 }, ee = /* @__PURE__ */ R({
204
+ ...Ae,
86
205
  props: {
87
206
  isDraggable: { type: Boolean, default: !0 },
88
207
  sortable: { type: Boolean, default: !0 },
@@ -93,47 +212,54 @@ const qe = (e, t, a = !0) => new Z(e, t).setIsSortable(a), Me = (e, t, a = !0) =
93
212
  hiddenIsVisible: { type: Boolean, default: !1 },
94
213
  item: { type: Object, default: () => ({}) }
95
214
  },
96
- emits: ["click", "show"],
215
+ emits: ["edited", "click", "show"],
97
216
  setup(e, { emit: t }) {
98
- const a = t, c = (n, d, u) => {
99
- a("click", n, U("", { item: d, column: u }));
100
- }, f = (n, d) => {
101
- a("show", n, U("", { i: d }));
217
+ const l = t, s = e, r = S(s.item), n = (a, y, u) => {
218
+ l("click", a, W("", { item: y, column: u }));
219
+ }, h = (a, y) => {
220
+ l("show", a, W("", { i: y }));
221
+ }, k = (a, y) => {
222
+ r.value = a;
102
223
  };
103
- return (n, d) => (s(), o("tr", {
224
+ return T(() => s.item, (a) => r.value = a), T(r, () => l("edited", r.value, s.i)), (a, y) => (o(), f("tr", {
104
225
  "data-i": e.i,
105
226
  "data-handle-drag": e.isDraggable
106
227
  }, [
107
- e.sortable && e.isDraggable ? (s(), o("td", ve)) : e.sortable ? (s(), o("td", ke)) : C("", !0),
108
- e.displayHiddenColumnsIndicator ? (s(), o("td", {
228
+ e.sortable && e.isDraggable ? (o(), f("td", pe)) : e.sortable ? (o(), f("td", Ve)) : w("", !0),
229
+ e.displayHiddenColumnsIndicator ? (o(), f("td", {
109
230
  key: 2,
110
- onClick: d[0] || (d[0] = (u) => f(u, e.i)),
231
+ onClick: y[0] || (y[0] = (u) => h(u, e.i)),
111
232
  "data-role": "show-more",
112
- class: ie(e.hiddenIsVisible ? "state-open" : "")
113
- }, null, 2)) : C("", !0),
114
- (s(!0), o(k, null, g(e.visibleColumns, (u) => (s(), o(k, null, [
115
- v(me)(u, e.emptyColumns, e.item) ? (s(), o("td", {
233
+ class: re(e.hiddenIsVisible ? "state-open" : "")
234
+ }, null, 2)) : w("", !0),
235
+ (o(!0), f(B, null, $(e.visibleColumns, (u) => (o(), f(B, null, [
236
+ p(ve)(u, e.emptyColumns, e.item) ? (o(), f("td", {
116
237
  key: 0,
117
238
  "data-column": u.key,
118
- colspan: v(G)(u, e.item),
119
- title: v(T)(u, e.item, e.i),
120
- onClick: (S) => c(S, e.item, u)
239
+ colspan: p(X)(u, e.item),
240
+ title: p(F)(u, e.item, e.i),
241
+ onClick: (A) => n(A, e.item, u)
121
242
  }, [
122
- n.$slots[u.key] ? B(n.$slots, u.key, {
243
+ a.$slots[u.key] ? D(a.$slots, u.key, {
123
244
  key: 0,
124
245
  value: e.item[u.key],
125
246
  item: e.item,
126
247
  column: u,
127
248
  i: e.i
128
- }) : e.item ? (s(), o(k, { key: 1 }, [
129
- Y(L(v(T)(u, e.item, e.i)), 1)
130
- ], 64)) : C("", !0)
131
- ], 8, ge)) : C("", !0)
249
+ }) : e.item ? (o(), C(te, {
250
+ key: 1,
251
+ column: u,
252
+ modelValue: r.value,
253
+ "onUpdate:modelValue": y[1] || (y[1] = (A) => r.value = A),
254
+ i: e.i,
255
+ onEdited: k
256
+ }, null, 8, ["column", "modelValue", "i"])) : w("", !0)
257
+ ], 8, Se)) : w("", !0)
132
258
  ], 64))), 256))
133
- ], 8, be));
259
+ ], 8, Ce));
134
260
  }
135
- }), pe = { "data-role": "hidden-row" }, Se = ["colspan"], $e = ["data-column"], Ie = ["data-i"], Ve = ["data-column", "title", "onClick"], Be = { name: "LktHiddenRow", inheritAttrs: !1 }, Ee = /* @__PURE__ */ x({
136
- ...Be,
261
+ }), Ie = { "data-role": "hidden-row" }, $e = ["colspan"], we = ["data-column"], Ee = ["data-i"], Be = ["data-column", "title", "onClick"], Ne = { name: "LktHiddenRow", inheritAttrs: !1 }, Te = /* @__PURE__ */ R({
262
+ ...Ne,
137
263
  props: {
138
264
  isDraggable: { type: Boolean, default: !0 },
139
265
  sortable: { type: Boolean, default: !0 },
@@ -143,58 +269,62 @@ const qe = (e, t, a = !0) => new Z(e, t).setIsSortable(a), Me = (e, t, a = !0) =
143
269
  hiddenColumns: { type: Array, default: () => [] },
144
270
  emptyColumns: { type: Array, default: () => [] },
145
271
  hiddenIsVisible: { type: Boolean, default: !1 },
146
- item: { type: Object, default: () => ({}) }
272
+ modelValue: { type: Object, default: () => ({}) }
147
273
  },
148
- emits: ["click"],
274
+ emits: ["update:modelValue", "click"],
149
275
  setup(e, { emit: t }) {
150
- const a = t, c = (f, n, d) => {
151
- a("click", f, U("", { item: n, column: d }));
276
+ const l = t, s = e, r = S(s.modelValue), n = (h, k, a) => {
277
+ l("click", h, W("", { item: k, column: a }));
152
278
  };
153
- return (f, n) => re((s(), o("tr", pe, [
154
- p("td", { colspan: e.hiddenColumnsColSpan }, [
155
- p("table", null, [
156
- p("tr", null, [
157
- (s(!0), o(k, null, g(e.hiddenColumns, (d) => (s(), o("th", {
158
- "data-column": d.key
279
+ return T(() => s.modelValue, (h) => r.value = h), T(r, () => l("update:modelValue", r.value)), (h, k) => se((o(), f("tr", Ie, [
280
+ E("td", { colspan: e.hiddenColumnsColSpan }, [
281
+ E("table", null, [
282
+ E("tr", null, [
283
+ (o(!0), f(B, null, $(e.hiddenColumns, (a) => (o(), f("th", {
284
+ "data-column": a.key
159
285
  }, [
160
- p("div", null, L(d.label), 1)
161
- ], 8, $e))), 256))
286
+ E("div", null, x(a.label), 1)
287
+ ], 8, we))), 256))
162
288
  ]),
163
- p("tr", { "data-i": e.i }, [
164
- (s(!0), o(k, null, g(e.hiddenColumns, (d, u) => (s(), o("td", {
165
- "data-column": d.key,
166
- title: v(T)(d, e.item, u),
167
- onClick: (S) => c(S, e.item, d)
289
+ E("tr", { "data-i": e.i }, [
290
+ (o(!0), f(B, null, $(e.hiddenColumns, (a, y) => (o(), f("td", {
291
+ "data-column": a.key,
292
+ title: p(F)(a, r.value, y),
293
+ onClick: (u) => n(u, r.value, a)
168
294
  }, [
169
- f.$slots[d.key] ? B(f.$slots, d.key, {
295
+ h.$slots[a.key] ? D(h.$slots, a.key, {
170
296
  key: 0,
171
- value: e.item[d.key],
172
- item: e.item,
173
- column: d,
174
- i: u
175
- }) : (s(), o(k, { key: 1 }, [
176
- Y(L(v(T)(d, e.item, u)), 1)
177
- ], 64))
178
- ], 8, Ve))), 256))
179
- ], 8, Ie)
297
+ value: r.value[a.key],
298
+ item: r.value,
299
+ column: a,
300
+ i: y
301
+ }) : (o(), C(te, {
302
+ key: 1,
303
+ column: a,
304
+ modelValue: r.value,
305
+ "onUpdate:modelValue": k[0] || (k[0] = (u) => r.value = u),
306
+ i: y
307
+ }, null, 8, ["column", "modelValue", "i"]))
308
+ ], 8, Be))), 256))
309
+ ], 8, Ee)
180
310
  ])
181
- ], 8, Se)
311
+ ], 8, $e)
182
312
  ], 512)), [
183
- [se, e.hiddenIsVisible]
313
+ [de, e.hiddenIsVisible]
184
314
  ]);
185
315
  }
186
- }), De = ["data-sortable"], we = {
316
+ }), De = ["data-sortable"], Le = {
187
317
  key: 0,
188
318
  "data-role": "drag-indicator"
189
- }, Ae = { key: 1 }, Ne = ["data-column", "data-sortable", "data-sort", "colspan", "title", "onClick"], He = { key: 1 }, Le = {
319
+ }, He = { key: 1 }, Oe = ["data-column", "data-sortable", "data-sort", "colspan", "title", "onClick"], Ue = { key: 1 }, xe = {
190
320
  key: 1,
191
321
  class: "lkt-empty-table"
192
- }, Te = { name: "LktTable", inheritAttrs: !1 }, Ke = /* @__PURE__ */ x({
193
- ...Te,
322
+ }, Fe = { name: "LktTable", inheritAttrs: !1 }, Ke = /* @__PURE__ */ R({
323
+ ...Fe,
194
324
  props: {
195
325
  modelValue: { type: Array, default: () => [] },
196
326
  columns: { type: Array, default: () => [] },
197
- sorter: { type: Function, default: W },
327
+ sorter: { type: Function, default: _ },
198
328
  sortable: { type: Boolean, default: !1 },
199
329
  hideEmptyColumns: { type: Boolean, default: !1 },
200
330
  draggableChecker: { type: Function, default: (e) => !0 },
@@ -202,172 +332,185 @@ const qe = (e, t, a = !0) => new Z(e, t).setIsSortable(a), Me = (e, t, a = !0) =
202
332
  draggableItemKey: { type: String, default: "name" }
203
333
  },
204
334
  emits: ["update:modelValue", "sort", "click"],
205
- setup(e, { expose: t, emit: a }) {
206
- const c = a, f = oe(), n = e, d = {}, u = V(typeof n.sorter == "function" ? n.sorter : W), S = V(ye(n.columns)), E = V("asc"), h = V(n.modelValue), w = V(d), J = V(!1), K = ce(12), _ = I(() => h.value.length > 0), A = I(() => {
335
+ setup(e, { expose: t, emit: l }) {
336
+ const s = l, r = me(), n = e, h = {}, k = S(typeof n.sorter == "function" ? n.sorter : _), a = S(ke(n.columns)), y = S("asc"), u = S(n.modelValue), A = S(h), K = S(!1), L = ye(12), c = N(() => u.value.length > 0), j = N(() => {
207
337
  if (!n.hideEmptyColumns)
208
338
  return [];
209
- let l = [];
210
- return n.columns.forEach((i) => {
211
- let r = i.key, m = !1;
212
- h.value.forEach((y) => {
213
- if (typeof y.checkEmpty == "function")
214
- return y.checkEmpty(y);
215
- y[r] && (m = !0);
216
- }), m || l.push(r);
217
- }), l;
218
- }), D = I(() => n.columns.filter((l) => !l.hidden)), F = I(() => n.columns.filter((l) => l.hidden)), ee = I(() => {
219
- let l = D.value.length + 1;
220
- return n.sortable && ++l, l;
221
- }), O = I(() => F.value.length > 0 && !n.sortable), te = I(() => n.columns.map((l) => l.key)), R = I(() => {
222
- let l = [];
223
- for (let i in f)
224
- te.value.indexOf(i) !== -1 && l.push(i);
225
- return l;
226
- }), le = (l) => {
227
- let i = l.target;
228
- if (typeof i.dataset.column > "u")
339
+ let i = [];
340
+ return n.columns.forEach((d) => {
341
+ let m = d.key, v = !1;
342
+ u.value.forEach((b) => {
343
+ if (typeof b.checkEmpty == "function")
344
+ return b.checkEmpty(b);
345
+ b[m] && (v = !0);
346
+ }), v || i.push(m);
347
+ }), i;
348
+ }), H = N(() => n.columns.filter((i) => !i.hidden)), z = N(() => n.columns.filter((i) => i.hidden)), le = N(() => {
349
+ let i = H.value.length + 1;
350
+ return n.sortable && ++i, i;
351
+ }), J = N(() => z.value.length > 0 && !n.sortable), ae = N(() => n.columns.map((i) => i.key)), q = N(() => {
352
+ let i = [];
353
+ for (let d in r)
354
+ ae.value.indexOf(d) !== -1 && i.push(d);
355
+ return i;
356
+ }), ne = (i) => {
357
+ let d = i.target;
358
+ if (typeof d.dataset.column > "u")
229
359
  do
230
- i = i.parentNode;
231
- while (typeof i.dataset.column > "u" && i.tagName !== "TABLE" && i.tagName !== "body");
232
- if (i.tagName === "TD" && (i = i.parentNode, i = i.dataset.i, typeof i < "u"))
233
- return h.value[i];
234
- }, j = (l) => w.value["tr_" + l] === !0, P = (l) => {
235
- !l || l.sortable && (h.value = h.value.sort((i, r) => u.value(i, r, l, E.value)), E.value = E.value === "asc" ? "desc" : "asc", S.value = l.key, c("sort", [S.value, E.value]));
236
- }, z = (l, i) => {
237
- c("click", l, i);
238
- }, q = (l, i) => {
239
- let r = "tr_" + i.value.i;
240
- w.value[r] = typeof w.value[r] > "u" ? !0 : !w.value[r];
360
+ d = d.parentNode;
361
+ while (typeof d.dataset.column > "u" && d.tagName !== "TABLE" && d.tagName !== "body");
362
+ if (d.tagName === "TD" && (d = d.parentNode, d = d.dataset.i, typeof d < "u"))
363
+ return u.value[d];
364
+ }, M = (i) => A.value["tr_" + i] === !0, Y = (i) => {
365
+ !i || i.sortable && (u.value = u.value.sort((d, m) => k.value(d, m, i, y.value)), y.value = y.value === "asc" ? "desc" : "asc", a.value = i.key, s("sort", [a.value, y.value]));
366
+ }, G = (i, d) => {
367
+ s("click", i, d);
368
+ }, P = (i, d) => {
369
+ let m = "tr_" + d.value.i;
370
+ A.value[m] = typeof A.value[m] > "u" ? !0 : !A.value[m];
371
+ }, ie = (i, d) => {
372
+ u.value[d] = i;
241
373
  };
242
- return de(() => {
243
- P(he(n.columns, S.value));
244
- }), Q(() => n.modelValue, (l) => h.value = l), Q(h, (l) => c("update:modelValue", l)), t({ getItemByEvent: le }), (l, i) => _.value ? (s(), o("div", {
374
+ return ce(() => {
375
+ Y(be(n.columns, a.value));
376
+ }), T(() => n.modelValue, (i) => u.value = i), T(u, (i) => {
377
+ s("update:modelValue", i);
378
+ }), t({ getItemByEvent: ne }), (i, d) => c.value ? (o(), f("div", {
245
379
  key: 0,
246
380
  class: "lkt-table",
247
381
  "data-sortable": e.sortable
248
382
  }, [
249
- p("table", null, [
250
- p("thead", null, [
251
- p("tr", null, [
252
- e.sortable ? (s(), o("th", we)) : C("", !0),
253
- O.value ? (s(), o("th", Ae)) : C("", !0),
254
- (s(!0), o(k, null, g(D.value, (r) => (s(), o(k, null, [
255
- A.value.indexOf(r.key) === -1 ? (s(), o("th", {
383
+ E("table", null, [
384
+ E("thead", null, [
385
+ E("tr", null, [
386
+ e.sortable ? (o(), f("th", Le)) : w("", !0),
387
+ J.value ? (o(), f("th", He)) : w("", !0),
388
+ (o(!0), f(B, null, $(H.value, (m) => (o(), f(B, null, [
389
+ j.value.indexOf(m.key) === -1 ? (o(), f("th", {
256
390
  key: 0,
257
- "data-column": r.key,
258
- "data-sortable": r.sortable === !0,
259
- "data-sort": r.sortable === !0 && S.value === r.key ? E.value : "",
260
- colspan: v(fe)(r, e.columns.length, h.value),
261
- title: r.label,
262
- onClick: (m) => P(r)
391
+ "data-column": m.key,
392
+ "data-sortable": m.sortable === !0,
393
+ "data-sort": m.sortable === !0 && a.value === m.key ? y.value : "",
394
+ colspan: p(he)(m, e.columns.length, u.value),
395
+ title: m.label,
396
+ onClick: (v) => Y(m)
263
397
  }, [
264
- p("div", null, L(r.label), 1)
265
- ], 8, Ne)) : C("", !0)
398
+ E("div", null, x(m.label), 1)
399
+ ], 8, Oe)) : w("", !0)
266
400
  ], 64))), 256))
267
401
  ])
268
402
  ]),
269
- e.sortable ? (s(), N(v(ue), {
403
+ e.sortable ? (o(), C(p(fe), {
270
404
  key: 0,
271
- modelValue: h.value,
272
- "onUpdate:modelValue": i[0] || (i[0] = (r) => h.value = r),
405
+ modelValue: u.value,
406
+ "onUpdate:modelValue": d[0] || (d[0] = (m) => u.value = m),
273
407
  move: e.checkValidDrag,
274
408
  itemKey: e.draggableItemKey,
275
- onStart: i[1] || (i[1] = (r) => J.value = !0),
276
- onEnd: i[2] || (i[2] = (r) => J.value = !1),
409
+ onStart: d[1] || (d[1] = (m) => K.value = !0),
410
+ onEnd: d[2] || (d[2] = (m) => K.value = !1),
277
411
  tag: "tbody",
278
412
  class: "lkt-sortable-table",
279
413
  handle: "[data-handle-drag]"
280
414
  }, {
281
- item: H(({ element: r, index: m }) => [
282
- (s(), N(X, {
283
- key: v(K) + "-" + m,
284
- i: m,
285
- item: r,
286
- "display-hidden-columns-indicator": O.value,
287
- "is-draggable": e.draggableChecker ? e.draggableChecker(r) : !0,
415
+ item: U(({ element: m, index: v }) => [
416
+ (o(), C(ee, {
417
+ key: p(L) + "-" + v,
418
+ i: v,
419
+ item: m,
420
+ "display-hidden-columns-indicator": J.value,
421
+ "is-draggable": e.draggableChecker ? e.draggableChecker(m) : !0,
288
422
  sortable: e.sortable,
289
- "visible-columns": D.value,
290
- "empty-columns": A.value,
291
- "hidden-is-visible": j(m),
292
- onClick: z,
293
- onShow: q
294
- }, M({ _: 2 }, [
295
- g(R.value, (y) => ({
296
- name: y,
297
- fn: H((b) => [
298
- B(l.$slots, y, {
299
- item: b.item,
300
- value: b.value,
301
- column: b.column
423
+ "visible-columns": H.value,
424
+ "empty-columns": j.value,
425
+ "hidden-is-visible": M(v),
426
+ onClick: G,
427
+ onShow: P
428
+ }, Q({ _: 2 }, [
429
+ $(q.value, (b) => ({
430
+ name: b,
431
+ fn: U((V) => [
432
+ D(i.$slots, b, {
433
+ item: V.item,
434
+ value: V.value,
435
+ column: V.column
302
436
  })
303
437
  ])
304
438
  }))
305
439
  ]), 1032, ["i", "item", "display-hidden-columns-indicator", "is-draggable", "sortable", "visible-columns", "empty-columns", "hidden-is-visible"]))
306
440
  ]),
307
441
  _: 3
308
- }, 8, ["modelValue", "move", "itemKey"])) : (s(), o("tbody", He, [
309
- (s(!0), o(k, null, g(h.value, (r, m) => (s(), N(X, {
310
- key: v(K) + "-" + m,
311
- i: m,
312
- item: r,
313
- "display-hidden-columns-indicator": O.value,
314
- "is-draggable": e.draggableChecker ? e.draggableChecker(r) : !0,
442
+ }, 8, ["modelValue", "move", "itemKey"])) : (o(), f("tbody", Ue, [
443
+ (o(!0), f(B, null, $(u.value, (m, v) => (o(), C(ee, {
444
+ key: p(L) + "-" + v,
445
+ i: v,
446
+ item: m,
447
+ "display-hidden-columns-indicator": J.value,
448
+ "is-draggable": e.draggableChecker ? e.draggableChecker(m) : !0,
315
449
  sortable: e.sortable,
316
- "visible-columns": D.value,
317
- "empty-columns": A.value,
318
- "hidden-is-visible": j(m),
319
- onClick: z,
320
- onShow: q
321
- }, M({ _: 2 }, [
322
- g(R.value, (y) => ({
323
- name: y,
324
- fn: H((b) => [
325
- B(l.$slots, y, {
326
- item: b.item,
327
- value: b.value,
328
- column: b.column
450
+ "visible-columns": H.value,
451
+ "empty-columns": j.value,
452
+ "hidden-is-visible": M(v),
453
+ onClick: G,
454
+ onShow: P,
455
+ onEdited: ie
456
+ }, Q({ _: 2 }, [
457
+ $(q.value, (b) => ({
458
+ name: b,
459
+ fn: U((V) => [
460
+ D(i.$slots, b, {
461
+ item: V.item,
462
+ value: V.value,
463
+ column: V.column
329
464
  })
330
465
  ])
331
466
  }))
332
467
  ]), 1032, ["i", "item", "display-hidden-columns-indicator", "is-draggable", "sortable", "visible-columns", "empty-columns", "hidden-is-visible"]))), 128)),
333
- F.value.length > 0 ? (s(!0), o(k, { key: 0 }, g(h.value, (r, m) => (s(), N(Ee, {
334
- key: v(K) + "-" + m,
335
- i: m,
336
- item: r,
337
- "hidden-columns": F.value,
338
- "hidden-columns-col-span": ee.value,
339
- "is-draggable": e.draggableChecker ? e.draggableChecker(r) : !0,
468
+ z.value.length > 0 ? (o(!0), f(B, { key: 0 }, $(u.value, (m, v) => (o(), C(Te, {
469
+ key: p(L) + "-" + v,
470
+ i: v,
471
+ item: m,
472
+ "hidden-columns": z.value,
473
+ "hidden-columns-col-span": le.value,
474
+ "is-draggable": e.draggableChecker ? e.draggableChecker(m) : !0,
340
475
  sortable: e.sortable,
341
- "visible-columns": D.value,
342
- "empty-columns": A.value,
343
- "hidden-is-visible": j(m),
344
- onClick: z,
345
- onShow: q
346
- }, M({ _: 2 }, [
347
- g(R.value, (y) => ({
348
- name: y,
349
- fn: H((b) => [
350
- B(l.$slots, y, {
351
- item: b.item,
352
- value: b.value,
353
- column: b.column
476
+ "visible-columns": H.value,
477
+ "empty-columns": j.value,
478
+ "hidden-is-visible": M(v),
479
+ onClick: G,
480
+ onShow: P
481
+ }, Q({ _: 2 }, [
482
+ $(q.value, (b) => ({
483
+ name: b,
484
+ fn: U((V) => [
485
+ D(i.$slots, b, {
486
+ item: V.item,
487
+ value: V.value,
488
+ column: V.column
354
489
  })
355
490
  ])
356
491
  }))
357
- ]), 1032, ["i", "item", "hidden-columns", "hidden-columns-col-span", "is-draggable", "sortable", "visible-columns", "empty-columns", "hidden-is-visible"]))), 128)) : C("", !0)
492
+ ]), 1032, ["i", "item", "hidden-columns", "hidden-columns-col-span", "is-draggable", "sortable", "visible-columns", "empty-columns", "hidden-is-visible"]))), 128)) : w("", !0)
358
493
  ]))
359
494
  ])
360
- ], 8, De)) : l.$slots["no-items"] ? (s(), o("div", Le, [
361
- B(l.$slots, "no-items")
362
- ])) : C("", !0);
495
+ ], 8, De)) : i.$slots["no-items"] ? (o(), f("div", xe, [
496
+ D(i.$slots, "no-items")
497
+ ])) : w("", !0);
363
498
  }
364
- }), Ue = {
499
+ }), tt = {
365
500
  install: (e) => {
366
501
  e.component("lkt-table", Ke);
367
502
  }
368
503
  };
369
504
  export {
370
- qe as createColumn,
371
- Me as createHiddenColumn,
372
- Ue as default
505
+ Pe as createActionColumn,
506
+ Ye as createCheckColumn,
507
+ Me as createColumn,
508
+ We as createEmailColumn,
509
+ et as createHiddenColumn,
510
+ Ge as createLinkColumn,
511
+ _e as createSelectColumn,
512
+ Ze as createSwitchColumn,
513
+ Xe as createTelColumn,
514
+ Qe as createTextColumn,
515
+ tt as default
373
516
  };