lkt-table 1.0.14 → 1.0.16

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