adverich-kun-ui 0.1.390 → 0.1.392
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,4 +1,4 @@
|
|
|
1
|
-
import { mergeModels as W, toRefs as
|
|
1
|
+
import { mergeModels as W, toRefs as be, useModel as Ce, ref as v, watch as Q, computed as q, onMounted as Te, createElementBlock as r, openBlock as l, mergeProps as V, createCommentVNode as u, createElementVNode as O, renderSlot as a, createBlock as b, unref as s, normalizeClass as C, withCtx as j, createVNode as T, withDirectives as G, vModelText as Fe, vShow as J, normalizeProps as d, guardReactiveProps as g, Fragment as ke, createSlots as X, renderList as Y, toDisplayString as $e, isRef as Pe, nextTick as Me } from "vue";
|
|
2
2
|
import { isMobile as m } from "../../../../utils/_platform.js";
|
|
3
3
|
import Z from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
4
4
|
import Ae from "../../../../icons/IconFilter.vue.js";
|
|
@@ -7,13 +7,13 @@ import Re from "./KunTableHeaders.vue.js";
|
|
|
7
7
|
import Ee from "./KunTableFooter.vue.js";
|
|
8
8
|
import Be from "./KunTableRows.vue.js";
|
|
9
9
|
import Ve from "./KunTableIterators.vue.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
10
|
+
import Oe from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
11
|
+
import je from "./KunTableFilter.vue.js";
|
|
12
|
+
import xe from "../composables/useExpand.js";
|
|
13
|
+
import ze from "../composables/useOptions.js";
|
|
14
|
+
import De from "../composables/useSelect.js";
|
|
15
|
+
import He from "../composables/useFilter.js";
|
|
16
|
+
import Ne from "../composables/KunTableProps.js";
|
|
17
17
|
const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key: 0 }, We = { key: 5 }, Qe = {
|
|
18
18
|
key: 1,
|
|
19
19
|
class: "h-full flex justify-center items-center"
|
|
@@ -22,36 +22,36 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
22
22
|
class: "sticky bottom-0 z-10 print:hidden"
|
|
23
23
|
}, Je = "overflow-hidden h-full w-full flex flex-col border border-slate-200 dark:border-slate-800 rounded", Xe = "table-auto w-full h-fit text-sm text-left", ms = {
|
|
24
24
|
__name: "KunTable",
|
|
25
|
-
props: /* @__PURE__ */ W(
|
|
25
|
+
props: /* @__PURE__ */ W(Ne(), {
|
|
26
26
|
selectedItems: { type: Array, default: () => [] },
|
|
27
27
|
selectedItemsModifiers: {}
|
|
28
28
|
}),
|
|
29
29
|
emits: /* @__PURE__ */ W(["update:page", "update:itemsPerPage", "update:sortBy", "update:search", "focusOnSearch"], ["update:selectedItems"]),
|
|
30
|
-
setup(
|
|
31
|
-
const
|
|
32
|
-
headers:
|
|
30
|
+
setup(x, { emit: _ }) {
|
|
31
|
+
const S = _, p = x, F = be(p), ee = Ce(x, "selectedItems"), {
|
|
32
|
+
headers: z,
|
|
33
33
|
showExpand: k,
|
|
34
34
|
showSelect: $,
|
|
35
|
-
rowClass:
|
|
35
|
+
rowClass: D,
|
|
36
36
|
hideDefaultFooter: se,
|
|
37
37
|
hideDefaultHeader: oe,
|
|
38
38
|
tableClass: te,
|
|
39
39
|
wrapperClass: le,
|
|
40
40
|
pageOptions: ae,
|
|
41
41
|
items: ne,
|
|
42
|
-
searchable:
|
|
42
|
+
searchable: H,
|
|
43
43
|
debounceTime: re
|
|
44
44
|
} = F, w = v(p.search);
|
|
45
45
|
Q(() => p.search, (e) => {
|
|
46
46
|
e !== w.value && (w.value = e);
|
|
47
47
|
});
|
|
48
|
-
const { filteredItems: ie, setSearch: ce, modalFilter: y, applyColumnFilters: ue, clearFilters: de, appliedFilters: pe } =
|
|
48
|
+
const { filteredItems: ie, setSearch: ce, modalFilter: y, applyColumnFilters: ue, clearFilters: de, appliedFilters: pe } = He(F, re);
|
|
49
49
|
Q(w, (e) => {
|
|
50
|
-
|
|
50
|
+
S("update:search", e), ce(e);
|
|
51
51
|
});
|
|
52
|
-
const { options: i, paginatedItems: f, updateSort: me } =
|
|
52
|
+
const { options: i, paginatedItems: f, updateSort: me } = ze(F, S, ie), { isSelected: P, toggleSelect: M, toggleSelectAll: fe, allSelected: he, someSelected: ge } = De(f, ee), { isExpanded: A, toggleExpand: I } = xe(), h = q(() => ({
|
|
53
53
|
items: f.value,
|
|
54
|
-
headers:
|
|
54
|
+
headers: z.value,
|
|
55
55
|
page: i.page,
|
|
56
56
|
itemsPerPage: i.itemsPerPage,
|
|
57
57
|
toggleSelect: M,
|
|
@@ -60,7 +60,7 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
60
60
|
isExpanded: A,
|
|
61
61
|
sortBy: i.sortBy,
|
|
62
62
|
hasActions: p.hasActions
|
|
63
|
-
})), we = [Je, le.value], ye = [Xe, te.value],
|
|
63
|
+
})), we = [Je, le.value], ye = [Xe, te.value], N = q(() => p.headers.map((e) => {
|
|
64
64
|
var t, c;
|
|
65
65
|
const o = { ...e };
|
|
66
66
|
if ((e.columnType === "function" || e.columnType == "objectFunction" || e.columnType == "simpleFunction") && typeof e.columnFunction == "string") {
|
|
@@ -80,31 +80,31 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
80
80
|
Te(() => L());
|
|
81
81
|
const K = v(null), R = v(!0), E = v(!1);
|
|
82
82
|
function ve() {
|
|
83
|
-
|
|
83
|
+
Se();
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function Se() {
|
|
86
86
|
m.value && (U(), Me(() => {
|
|
87
87
|
K.value.focus();
|
|
88
88
|
}));
|
|
89
89
|
}
|
|
90
90
|
function L() {
|
|
91
|
-
m.value && (B.value = "w-fit", R.value = !1, E.value = !0);
|
|
91
|
+
m.value && (B.value = "w-fit", R.value = !1, E.value = !0, S("focusOnSearch", !1));
|
|
92
92
|
}
|
|
93
93
|
function U() {
|
|
94
|
-
m.value && (B.value = "w-full border", E.value = !1, R.value = !0);
|
|
94
|
+
m.value && (B.value = "w-full border", E.value = !1, R.value = !0, S("focusOnSearch", !0));
|
|
95
95
|
}
|
|
96
96
|
const B = v("w-full border max-w-sm");
|
|
97
97
|
return (e, o) => (l(), r("div", V({ class: we }, e.$attrs, { style: { "user-select": "text" } }), [
|
|
98
|
-
s(
|
|
98
|
+
s(H) || e.filterable || e.$slots.prependSearch || e.$slots.appendSearch ? (l(), r("div", {
|
|
99
99
|
key: 0,
|
|
100
|
-
class:
|
|
100
|
+
class: C(["p-2 bg-slate-200 dark:bg-slate-800 print:hidden", {
|
|
101
101
|
"justify-start flex": e.searchPosition === "start",
|
|
102
102
|
"justify-center flex": e.searchPosition === "center",
|
|
103
103
|
"justify-end flex": e.searchPosition === "end"
|
|
104
104
|
}])
|
|
105
105
|
}, [
|
|
106
106
|
a(e.$slots, "prependSearch"),
|
|
107
|
-
e.filterable && e.filters.length ? (l(), b(
|
|
107
|
+
e.filterable && e.filters.length ? (l(), b(Oe, {
|
|
108
108
|
key: 0,
|
|
109
109
|
class: "h-fit",
|
|
110
110
|
onClick: o[0] || (o[0] = (t) => y.value = !0),
|
|
@@ -112,8 +112,8 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
112
112
|
size: "xs",
|
|
113
113
|
bgColor: "bg-green-200 dark:bg-green-800"
|
|
114
114
|
}, {
|
|
115
|
-
default:
|
|
116
|
-
|
|
115
|
+
default: j(() => [
|
|
116
|
+
T(Z, {
|
|
117
117
|
class: "h-fit",
|
|
118
118
|
icon: Ae,
|
|
119
119
|
size: "text-lg"
|
|
@@ -121,15 +121,15 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
121
121
|
]),
|
|
122
122
|
_: 1
|
|
123
123
|
})) : u("", !0),
|
|
124
|
-
s(
|
|
124
|
+
s(H) ? (l(), r("div", {
|
|
125
125
|
key: 1,
|
|
126
|
-
class:
|
|
126
|
+
class: C(["rounded flex mx-2", [B.value]])
|
|
127
127
|
}, [
|
|
128
|
-
G(
|
|
128
|
+
G(O("input", {
|
|
129
129
|
"onUpdate:modelValue": o[1] || (o[1] = (t) => w.value = t),
|
|
130
130
|
type: "text",
|
|
131
131
|
placeholder: e.searchPlaceholder,
|
|
132
|
-
class:
|
|
132
|
+
class: C(["w-full text-sm", s(m) ? "px-1" : "px-2 py-1"]),
|
|
133
133
|
ref_key: "searchRef",
|
|
134
134
|
ref: K,
|
|
135
135
|
onFocus: U,
|
|
@@ -138,7 +138,7 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
138
138
|
[Fe, w.value],
|
|
139
139
|
[J, R.value]
|
|
140
140
|
]),
|
|
141
|
-
G(
|
|
141
|
+
G(T(Z, {
|
|
142
142
|
icon: Ie,
|
|
143
143
|
onClick: ve
|
|
144
144
|
}, null, 512), [
|
|
@@ -147,17 +147,17 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
147
147
|
], 2)) : u("", !0),
|
|
148
148
|
a(e.$slots, "appendSearch")
|
|
149
149
|
], 2)) : u("", !0),
|
|
150
|
-
|
|
150
|
+
O("div", Le, [
|
|
151
151
|
s(f).length ? (l(), r("table", {
|
|
152
152
|
key: 0,
|
|
153
|
-
class:
|
|
153
|
+
class: C(ye)
|
|
154
154
|
}, [
|
|
155
155
|
e.$slots.colgroup && !s(m) ? (l(), r("colgroup", Ue, [
|
|
156
156
|
a(e.$slots, "colgroup", d(g(h.value)))
|
|
157
157
|
])) : u("", !0),
|
|
158
158
|
!s(oe) && !s(m) ? (l(), b(Re, {
|
|
159
159
|
key: 1,
|
|
160
|
-
headers: s(
|
|
160
|
+
headers: s(z),
|
|
161
161
|
"sort-by": s(i).sortBy,
|
|
162
162
|
"show-select": s($),
|
|
163
163
|
"show-expand": s(k),
|
|
@@ -175,8 +175,8 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
175
175
|
s(m) ? (l(), b(Ve, {
|
|
176
176
|
key: 4,
|
|
177
177
|
items: s(f),
|
|
178
|
-
headers:
|
|
179
|
-
"row-class": s(
|
|
178
|
+
headers: N.value,
|
|
179
|
+
"row-class": s(D),
|
|
180
180
|
"row-class-condition": e.rowClassCondition,
|
|
181
181
|
"is-selected": s(P),
|
|
182
182
|
"is-expanded": s(A),
|
|
@@ -190,17 +190,17 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
190
190
|
}, X({ _: 2 }, [
|
|
191
191
|
Y(e.$slots, (t, c) => ({
|
|
192
192
|
name: c,
|
|
193
|
-
fn:
|
|
193
|
+
fn: j((n) => [
|
|
194
194
|
a(e.$slots, c, d(g(n)))
|
|
195
195
|
])
|
|
196
196
|
}))
|
|
197
197
|
]), 1032, ["items", "headers", "row-class", "row-class-condition", "is-selected", "is-expanded", "show-select", "show-expand", "has-actions", "action-loading-map", "onToggleExpand", "onToggleSelect", "customSlots"])) : (l(), r(ke, { key: 3 }, [
|
|
198
198
|
a(e.$slots, "body.prepend", d(g(h.value))),
|
|
199
|
-
|
|
199
|
+
T(Be, {
|
|
200
200
|
items: s(f),
|
|
201
|
-
headers:
|
|
201
|
+
headers: N.value,
|
|
202
202
|
"tbody-class": e.tbodyClass,
|
|
203
|
-
"row-class": s(
|
|
203
|
+
"row-class": s(D),
|
|
204
204
|
"row-class-condition": e.rowClassCondition,
|
|
205
205
|
"tr-class": e.trClass,
|
|
206
206
|
"td-class": e.tdClass,
|
|
@@ -218,7 +218,7 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
218
218
|
}, X({ _: 2 }, [
|
|
219
219
|
Y(e.$slots, (t, c) => ({
|
|
220
220
|
name: c,
|
|
221
|
-
fn:
|
|
221
|
+
fn: j((n) => [
|
|
222
222
|
a(e.$slots, c, d(g(n)))
|
|
223
223
|
])
|
|
224
224
|
}))
|
|
@@ -230,11 +230,11 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
230
230
|
])) : u("", !0)
|
|
231
231
|
])) : u("", !0),
|
|
232
232
|
s(f).length ? u("", !0) : (l(), r("div", Qe, [
|
|
233
|
-
|
|
233
|
+
O("div", qe, $e(e.noDataText), 1)
|
|
234
234
|
]))
|
|
235
235
|
]),
|
|
236
236
|
s(se) ? a(e.$slots, "footer", d(V({ key: 2 }, h.value))) : (l(), r("div", Ge, [
|
|
237
|
-
|
|
237
|
+
T(Ee, {
|
|
238
238
|
"items-length": s(ne).length,
|
|
239
239
|
"items-per-page": s(i).itemsPerPage,
|
|
240
240
|
"current-page": s(i).page,
|
|
@@ -243,7 +243,7 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key:
|
|
|
243
243
|
"onUpdate:page": o[3] || (o[3] = (t) => s(i).page = t)
|
|
244
244
|
}, null, 8, ["items-length", "items-per-page", "current-page", "page-options"])
|
|
245
245
|
])),
|
|
246
|
-
e.filterable && s(y) ? (l(), b(
|
|
246
|
+
e.filterable && s(y) ? (l(), b(je, {
|
|
247
247
|
key: 3,
|
|
248
248
|
filters: e.filters,
|
|
249
249
|
modelValue: s(y),
|