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.
- package/dist/README.md.d.ts +2 -0
- package/dist/lkt-table.es.js +368 -225
- package/dist/lkt-table.umd.js +1 -1
- package/dist/{types → src}/components/LktHiddenRow.vue.d.ts +17 -13
- package/dist/src/components/LktTableCell.vue.d.ts +91 -0
- package/dist/{types → src}/components/LktTableRow.vue.d.ts +10 -6
- package/dist/{types → src}/functions/table-functions.d.ts +9 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/vite.config.d.ts +39 -0
- package/package.json +6 -1
- package/src/components/LktHiddenRow.vue +10 -3
- package/src/components/LktTableCell.vue +76 -0
- package/src/components/LktTableRow.vue +14 -2
- package/src/index.ts +1 -1
- package/src/lib-components/LktTable.vue +10 -2
- package/dist/types/index.d.ts +0 -6
- package/dist/types/instances/LktTableColumn.d.ts +0 -16
- package/dist/types/interfaces/TableColumn.d.ts +0 -9
- package/dist/{types → src}/lib-components/LktTable.vue.d.ts +7 -7
package/dist/lkt-table.es.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
import
|
|
6
|
-
import { createLktEvent as
|
|
7
|
-
import { generateRandomString as
|
|
8
|
-
class
|
|
9
|
-
constructor(t = "",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this
|
|
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
|
|
36
|
-
if (!
|
|
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
|
|
39
|
-
if (
|
|
40
|
-
if (
|
|
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 >
|
|
88
|
+
if (n > r)
|
|
43
89
|
return -1;
|
|
44
90
|
} else {
|
|
45
|
-
if (
|
|
91
|
+
if (r > n)
|
|
46
92
|
return -1;
|
|
47
|
-
if (n >
|
|
93
|
+
if (n > r)
|
|
48
94
|
return 1;
|
|
49
95
|
}
|
|
50
96
|
return 0;
|
|
51
|
-
},
|
|
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
|
|
55
|
-
return
|
|
56
|
-
let n =
|
|
57
|
-
n > 0 && n <
|
|
58
|
-
}),
|
|
59
|
-
},
|
|
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
|
|
63
|
-
return typeof e.colspan > "u" ? !0 : (typeof e.colspan < "u" && (typeof e.colspan == "function" ?
|
|
64
|
-
},
|
|
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
|
-
},
|
|
117
|
+
}, be = (e, t) => {
|
|
72
118
|
if (e.length > 0) {
|
|
73
|
-
for (let
|
|
74
|
-
if (e[
|
|
75
|
-
return e[
|
|
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
|
-
},
|
|
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
|
-
},
|
|
200
|
+
}, Ve = {
|
|
82
201
|
key: 1,
|
|
83
202
|
"data-role": "invalid-drag-indicator"
|
|
84
|
-
},
|
|
85
|
-
...
|
|
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
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
|
|
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 (
|
|
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 ? (
|
|
108
|
-
e.displayHiddenColumnsIndicator ? (
|
|
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:
|
|
231
|
+
onClick: y[0] || (y[0] = (u) => h(u, e.i)),
|
|
111
232
|
"data-role": "show-more",
|
|
112
|
-
class:
|
|
113
|
-
}, null, 2)) :
|
|
114
|
-
(
|
|
115
|
-
|
|
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:
|
|
119
|
-
title:
|
|
120
|
-
onClick: (
|
|
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
|
-
|
|
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 ? (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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,
|
|
259
|
+
], 8, Ce));
|
|
134
260
|
}
|
|
135
|
-
}),
|
|
136
|
-
...
|
|
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
|
-
|
|
272
|
+
modelValue: { type: Object, default: () => ({}) }
|
|
147
273
|
},
|
|
148
|
-
emits: ["click"],
|
|
274
|
+
emits: ["update:modelValue", "click"],
|
|
149
275
|
setup(e, { emit: t }) {
|
|
150
|
-
const
|
|
151
|
-
|
|
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 (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
(
|
|
158
|
-
"data-column":
|
|
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
|
-
|
|
161
|
-
], 8,
|
|
286
|
+
E("div", null, x(a.label), 1)
|
|
287
|
+
], 8, we))), 256))
|
|
162
288
|
]),
|
|
163
|
-
|
|
164
|
-
(
|
|
165
|
-
"data-column":
|
|
166
|
-
title:
|
|
167
|
-
onClick: (
|
|
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
|
-
|
|
295
|
+
h.$slots[a.key] ? D(h.$slots, a.key, {
|
|
170
296
|
key: 0,
|
|
171
|
-
value:
|
|
172
|
-
item:
|
|
173
|
-
column:
|
|
174
|
-
i:
|
|
175
|
-
}) : (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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,
|
|
311
|
+
], 8, $e)
|
|
182
312
|
], 512)), [
|
|
183
|
-
[
|
|
313
|
+
[de, e.hiddenIsVisible]
|
|
184
314
|
]);
|
|
185
315
|
}
|
|
186
|
-
}), De = ["data-sortable"],
|
|
316
|
+
}), De = ["data-sortable"], Le = {
|
|
187
317
|
key: 0,
|
|
188
318
|
"data-role": "drag-indicator"
|
|
189
|
-
},
|
|
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
|
-
},
|
|
193
|
-
...
|
|
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:
|
|
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:
|
|
206
|
-
const
|
|
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
|
|
210
|
-
return n.columns.forEach((
|
|
211
|
-
let
|
|
212
|
-
|
|
213
|
-
if (typeof
|
|
214
|
-
return
|
|
215
|
-
|
|
216
|
-
}),
|
|
217
|
-
}),
|
|
218
|
-
}),
|
|
219
|
-
let
|
|
220
|
-
return n.sortable && ++
|
|
221
|
-
}),
|
|
222
|
-
let
|
|
223
|
-
for (let
|
|
224
|
-
|
|
225
|
-
return
|
|
226
|
-
}),
|
|
227
|
-
let
|
|
228
|
-
if (typeof
|
|
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
|
-
|
|
231
|
-
while (typeof
|
|
232
|
-
if (
|
|
233
|
-
return
|
|
234
|
-
},
|
|
235
|
-
!
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
},
|
|
239
|
-
let
|
|
240
|
-
|
|
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
|
|
243
|
-
|
|
244
|
-
}),
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
e.sortable ? (
|
|
253
|
-
|
|
254
|
-
(
|
|
255
|
-
|
|
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":
|
|
258
|
-
"data-sortable":
|
|
259
|
-
"data-sort":
|
|
260
|
-
colspan:
|
|
261
|
-
title:
|
|
262
|
-
onClick: (
|
|
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
|
-
|
|
265
|
-
], 8,
|
|
398
|
+
E("div", null, x(m.label), 1)
|
|
399
|
+
], 8, Oe)) : w("", !0)
|
|
266
400
|
], 64))), 256))
|
|
267
401
|
])
|
|
268
402
|
]),
|
|
269
|
-
e.sortable ? (
|
|
403
|
+
e.sortable ? (o(), C(p(fe), {
|
|
270
404
|
key: 0,
|
|
271
|
-
modelValue:
|
|
272
|
-
"onUpdate:modelValue":
|
|
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:
|
|
276
|
-
onEnd:
|
|
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:
|
|
282
|
-
(
|
|
283
|
-
key:
|
|
284
|
-
i:
|
|
285
|
-
item:
|
|
286
|
-
"display-hidden-columns-indicator":
|
|
287
|
-
"is-draggable": e.draggableChecker ? e.draggableChecker(
|
|
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":
|
|
290
|
-
"empty-columns":
|
|
291
|
-
"hidden-is-visible":
|
|
292
|
-
onClick:
|
|
293
|
-
onShow:
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
name:
|
|
297
|
-
fn:
|
|
298
|
-
|
|
299
|
-
item:
|
|
300
|
-
value:
|
|
301
|
-
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"])) : (
|
|
309
|
-
(
|
|
310
|
-
key:
|
|
311
|
-
i:
|
|
312
|
-
item:
|
|
313
|
-
"display-hidden-columns-indicator":
|
|
314
|
-
"is-draggable": e.draggableChecker ? e.draggableChecker(
|
|
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":
|
|
317
|
-
"empty-columns":
|
|
318
|
-
"hidden-is-visible":
|
|
319
|
-
onClick:
|
|
320
|
-
onShow:
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
334
|
-
key:
|
|
335
|
-
i:
|
|
336
|
-
item:
|
|
337
|
-
"hidden-columns":
|
|
338
|
-
"hidden-columns-col-span":
|
|
339
|
-
"is-draggable": e.draggableChecker ? e.draggableChecker(
|
|
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":
|
|
342
|
-
"empty-columns":
|
|
343
|
-
"hidden-is-visible":
|
|
344
|
-
onClick:
|
|
345
|
-
onShow:
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
name:
|
|
349
|
-
fn:
|
|
350
|
-
|
|
351
|
-
item:
|
|
352
|
-
value:
|
|
353
|
-
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)) :
|
|
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)) :
|
|
361
|
-
|
|
362
|
-
])) :
|
|
495
|
+
], 8, De)) : i.$slots["no-items"] ? (o(), f("div", xe, [
|
|
496
|
+
D(i.$slots, "no-items")
|
|
497
|
+
])) : w("", !0);
|
|
363
498
|
}
|
|
364
|
-
}),
|
|
499
|
+
}), tt = {
|
|
365
500
|
install: (e) => {
|
|
366
501
|
e.component("lkt-table", Ke);
|
|
367
502
|
}
|
|
368
503
|
};
|
|
369
504
|
export {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|
};
|