adverich-kun-ui 0.1.126 → 0.1.128
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/adverich-kun-ui.css +1 -1
- package/dist/components/KunDialog/src/components/KunDialog.vue.js +102 -0
- package/dist/components/KunDialog/src/components/KunDialog.vue2.js +4 -0
- package/dist/components/KunDialog/src/components/KunDialogContent.vue.js +23 -0
- package/dist/components/KunDialog/src/components/KunDialogContent.vue2.js +4 -0
- package/dist/components/KunDialog/src/components/KunDialogOverlay.vue.js +20 -0
- package/dist/components/KunDialog/src/components/KunDialogOverlay.vue2.js +4 -0
- package/dist/components/KunTable/src/components/KunTable.vue.js +150 -0
- package/dist/components/KunTable/src/components/KunTableFilter.vue.js +108 -0
- package/dist/components/KunTable/src/components/KunTableFooter.vue.js +53 -0
- package/dist/components/KunTable/src/components/KunTableHeaders.vue.js +86 -0
- package/dist/components/KunTable/src/components/KunTableRow.vue.js +88 -0
- package/dist/components/KunTable/src/components/KunTableRows.vue.js +77 -0
- package/dist/components/KunTable/src/composables/KunTableProps.js +84 -0
- package/dist/components/KunTable/src/composables/useExpand.js +21 -0
- package/dist/components/KunTable/src/composables/useFilter.js +43 -0
- package/dist/components/KunTable/src/composables/useOptions.js +29 -0
- package/dist/components/KunTable/src/composables/useSelect.js +30 -0
- package/dist/components/KunTooltip/src/components/KunTooltip.vue.js +100 -81
- package/dist/index.js +26 -23
- package/package.json +1 -1
- package/dist/components/KunTooltip/src/composables/useTooltip.js +0 -93
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { computed as l, createElementBlock as i, openBlock as c, createElementVNode as a, toDisplayString as r, Fragment as h, renderList as x } from "vue";
|
|
2
|
+
const v = { class: "flex items-center justify-between p-2 text-sm border-t border-slate-300 dark:border-slate-700 bg-slate-50 dark:bg-slate-900" }, k = { class: "text-balck dark:text-white" }, y = { class: "flex items-center gap-2" }, f = ["value"], _ = ["value"], L = ["disabled"], N = { class: "text-slate-700 dark:text-slate-300" }, w = ["disabled"], E = {
|
|
3
|
+
__name: "KunTableFooter",
|
|
4
|
+
props: {
|
|
5
|
+
itemsLength: Number,
|
|
6
|
+
itemsPerPage: Number,
|
|
7
|
+
currentPage: Number,
|
|
8
|
+
pageOptions: {
|
|
9
|
+
type: Array,
|
|
10
|
+
default: () => [5, 10, 25, 50, 100]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
emits: ["update:page", "update:itemsPerPage"],
|
|
14
|
+
setup(t, { emit: g }) {
|
|
15
|
+
const e = t, n = g, d = l(() => Math.ceil(e.itemsLength / e.itemsPerPage)), m = l(() => e.itemsLength === 0 ? 0 : (e.currentPage - 1) * e.itemsPerPage + 1), b = l(() => {
|
|
16
|
+
const o = e.currentPage * e.itemsPerPage;
|
|
17
|
+
return o > e.itemsLength ? e.itemsLength : o;
|
|
18
|
+
}), P = () => {
|
|
19
|
+
e.currentPage > 1 && n("update:page", e.currentPage - 1);
|
|
20
|
+
}, p = () => {
|
|
21
|
+
e.currentPage < d.value && n("update:page", e.currentPage + 1);
|
|
22
|
+
};
|
|
23
|
+
return (o, u) => (c(), i("div", v, [
|
|
24
|
+
a("div", k, " Mostrando " + r(m.value) + " - " + r(b.value) + " de " + r(t.itemsLength), 1),
|
|
25
|
+
a("div", y, [
|
|
26
|
+
a("select", {
|
|
27
|
+
class: "border rounded px-2 py-1 text-sm text-slate-700 dark:text-slate-300",
|
|
28
|
+
value: t.itemsPerPage,
|
|
29
|
+
onChange: u[0] || (u[0] = (s) => n("update:itemsPerPage", +s.target.value))
|
|
30
|
+
}, [
|
|
31
|
+
(c(!0), i(h, null, x(t.pageOptions, (s) => (c(), i("option", {
|
|
32
|
+
key: s,
|
|
33
|
+
value: s
|
|
34
|
+
}, r(s) + " por página ", 9, _))), 128))
|
|
35
|
+
], 40, f),
|
|
36
|
+
a("button", {
|
|
37
|
+
class: "px-2 py-1 border rounded text-slate-700 dark:text-slate-300 hover:bg-gray-200 dark:hover:bg-gray-800 disabled:opacity-50",
|
|
38
|
+
disabled: t.currentPage <= 1,
|
|
39
|
+
onClick: P
|
|
40
|
+
}, " ← ", 8, L),
|
|
41
|
+
a("span", N, " Página " + r(t.currentPage) + " de " + r(d.value), 1),
|
|
42
|
+
a("button", {
|
|
43
|
+
class: "px-2 py-1 border rounded text-slate-700 dark:text-slate-300 hover:bg-gray-200 dark:hover:bg-gray-800 disabled:opacity-50",
|
|
44
|
+
disabled: t.currentPage >= d.value,
|
|
45
|
+
onClick: p
|
|
46
|
+
}, " → ", 8, w)
|
|
47
|
+
])
|
|
48
|
+
]));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
E as default
|
|
53
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createElementBlock as t, openBlock as s, normalizeClass as c, createElementVNode as y, createCommentVNode as d, renderSlot as g, Fragment as S, renderList as B, normalizeStyle as f, toDisplayString as h } from "vue";
|
|
2
|
+
const A = { key: 0 }, E = { key: 1 }, T = ["checked"], w = ["onClick"], $ = { key: 0 }, z = { key: 0 }, L = { key: 1 }, v = "bg-slate-200 dark:bg-slate-800 sticky top-0 z-5", N = "", O = "px-3 py-2 text-xs font-medium text-slate-700 dark:text-slate-300 uppercase tracking-wider", j = {
|
|
3
|
+
__name: "KunTableHeaders",
|
|
4
|
+
props: {
|
|
5
|
+
headers: Array,
|
|
6
|
+
showSelect: Boolean,
|
|
7
|
+
showExpand: Boolean,
|
|
8
|
+
isExpanded: Boolean,
|
|
9
|
+
allSelected: Boolean,
|
|
10
|
+
sortBy: Object,
|
|
11
|
+
// { key, order }
|
|
12
|
+
theadClass: String,
|
|
13
|
+
trClass: String,
|
|
14
|
+
thClass: String,
|
|
15
|
+
hasActions: Boolean,
|
|
16
|
+
actionLabel: String
|
|
17
|
+
},
|
|
18
|
+
emits: ["toggle-select-all", "sort", "expandAll", "collapseAll"],
|
|
19
|
+
setup(l, { emit: u }) {
|
|
20
|
+
const o = l, r = u;
|
|
21
|
+
function m() {
|
|
22
|
+
r("toggle-select-all");
|
|
23
|
+
}
|
|
24
|
+
function x(n) {
|
|
25
|
+
var k;
|
|
26
|
+
if (!n.sortable) return;
|
|
27
|
+
const e = ((k = o.sortBy) == null ? void 0 : k.key) === n.key && o.sortBy.order === "asc" ? "desc" : "asc";
|
|
28
|
+
r("sort", { key: n.key, order: e });
|
|
29
|
+
}
|
|
30
|
+
function C(n) {
|
|
31
|
+
var a;
|
|
32
|
+
return ((a = o.sortBy) == null ? void 0 : a.key) === n.key;
|
|
33
|
+
}
|
|
34
|
+
const b = [v, o.theadClass], p = [N, o.trClass], i = [O, o.thClass];
|
|
35
|
+
return (n, a) => (s(), t("thead", {
|
|
36
|
+
class: c(b)
|
|
37
|
+
}, [
|
|
38
|
+
y("tr", {
|
|
39
|
+
class: c(p)
|
|
40
|
+
}, [
|
|
41
|
+
l.showExpand ? (s(), t("th", {
|
|
42
|
+
key: 0,
|
|
43
|
+
class: c([i])
|
|
44
|
+
}, [
|
|
45
|
+
n.$slots.expandIcon ? g(n.$slots, "expand-icon", { key: 0 }) : (s(), t("button", {
|
|
46
|
+
key: 1,
|
|
47
|
+
onClick: a[0] || (a[0] = (e) => l.isExpanded ? r("expandAll") : r("collapseAll"))
|
|
48
|
+
}, [
|
|
49
|
+
l.isExpanded ? (s(), t("span", A, "−")) : (s(), t("span", E, "+"))
|
|
50
|
+
]))
|
|
51
|
+
], 2)) : d("", !0),
|
|
52
|
+
l.showSelect ? (s(), t("th", {
|
|
53
|
+
key: 1,
|
|
54
|
+
class: c(i)
|
|
55
|
+
}, [
|
|
56
|
+
y("input", {
|
|
57
|
+
type: "checkbox",
|
|
58
|
+
checked: l.allSelected,
|
|
59
|
+
onChange: m,
|
|
60
|
+
class: "form-checkbox"
|
|
61
|
+
}, null, 40, T)
|
|
62
|
+
])) : d("", !0),
|
|
63
|
+
(s(!0), t(S, null, B(l.headers, (e) => (s(), t("th", {
|
|
64
|
+
key: e.key,
|
|
65
|
+
class: c([i, e.headerAlign === "right" ? "text-right" : e.headerAlign === "center" ? "text-center" : "text-left"]),
|
|
66
|
+
onClick: (k) => x(e),
|
|
67
|
+
style: f({ cursor: e.sortable ? "pointer" : "default" })
|
|
68
|
+
}, [
|
|
69
|
+
g(n.$slots, `header.${e.key}`, { header: e }, () => [
|
|
70
|
+
y("span", null, h(e.label), 1),
|
|
71
|
+
e.sortable ? (s(), t("span", $, [
|
|
72
|
+
C(e) ? (s(), t("span", z, h(l.sortBy.order === "asc" ? "⬆️" : "⬇️"), 1)) : (s(), t("span", L, "⇅"))
|
|
73
|
+
])) : d("", !0)
|
|
74
|
+
])
|
|
75
|
+
], 14, w))), 128)),
|
|
76
|
+
l.hasActions ? (s(), t("th", {
|
|
77
|
+
key: 2,
|
|
78
|
+
class: c([[i], "text-center"])
|
|
79
|
+
}, h(l.actionLabel), 3)) : d("", !0)
|
|
80
|
+
])
|
|
81
|
+
]));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
j as default
|
|
86
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createElementBlock as s, openBlock as n, normalizeClass as a, createCommentVNode as r, renderSlot as m, createElementVNode as C, withModifiers as u, Fragment as w, renderList as S, createTextVNode as b, toDisplayString as h } from "vue";
|
|
2
|
+
const y = { key: 0 }, v = { key: 1 }, B = ["checked"], $ = "hover:bg-slate-300 dark:hover:bg-slate-600", f = "", A = "px-3 py-2 whitespace-nowrap text-sm text-black dark:text-white ", T = {
|
|
3
|
+
__name: "KunTableRow",
|
|
4
|
+
props: {
|
|
5
|
+
item: Object,
|
|
6
|
+
index: Number,
|
|
7
|
+
headers: Array,
|
|
8
|
+
showExpand: Boolean,
|
|
9
|
+
showSelect: Boolean,
|
|
10
|
+
isExpanded: Boolean,
|
|
11
|
+
rowClass: String,
|
|
12
|
+
trClass: String,
|
|
13
|
+
tdClass: String,
|
|
14
|
+
selectedClass: String,
|
|
15
|
+
stripedClass: String,
|
|
16
|
+
isSelected: Boolean,
|
|
17
|
+
hasActions: Boolean,
|
|
18
|
+
actionsAlign: String,
|
|
19
|
+
loading: Boolean
|
|
20
|
+
},
|
|
21
|
+
emits: ["toggle-expand", "toggle-select", "row-click"],
|
|
22
|
+
setup(e, { emit: g }) {
|
|
23
|
+
const l = e, c = g, x = [
|
|
24
|
+
$,
|
|
25
|
+
f,
|
|
26
|
+
l.rowClass,
|
|
27
|
+
l.trClass,
|
|
28
|
+
l.stripedClass,
|
|
29
|
+
l.isSelected ? l.selectedClass : ""
|
|
30
|
+
], o = [A, l.tdClass], k = ["text-center", l.actionsAlign];
|
|
31
|
+
return (d, i) => (n(), s("tr", {
|
|
32
|
+
class: a(x),
|
|
33
|
+
onClick: i[2] || (i[2] = (t) => c("row-click", { item: e.item, index: e.index, event: t }))
|
|
34
|
+
}, [
|
|
35
|
+
e.showExpand ? (n(), s("td", {
|
|
36
|
+
key: 0,
|
|
37
|
+
class: a(o)
|
|
38
|
+
}, [
|
|
39
|
+
d.$slots.expandIcon ? m(d.$slots, "expand-icon", {
|
|
40
|
+
key: 0,
|
|
41
|
+
item: e.item,
|
|
42
|
+
index: e.index
|
|
43
|
+
}) : (n(), s("button", {
|
|
44
|
+
key: 1,
|
|
45
|
+
onClick: i[0] || (i[0] = (t) => c("toggle-expand", e.item))
|
|
46
|
+
}, [
|
|
47
|
+
e.isExpanded ? (n(), s("span", y, "−")) : (n(), s("span", v, "+"))
|
|
48
|
+
]))
|
|
49
|
+
])) : r("", !0),
|
|
50
|
+
e.showSelect ? (n(), s("td", {
|
|
51
|
+
key: 1,
|
|
52
|
+
class: a(o)
|
|
53
|
+
}, [
|
|
54
|
+
C("input", {
|
|
55
|
+
type: "checkbox",
|
|
56
|
+
checked: e.isSelected,
|
|
57
|
+
onChange: i[1] || (i[1] = u((t) => c("toggle-select", e.item), ["stop"])),
|
|
58
|
+
class: "form-checkbox"
|
|
59
|
+
}, null, 40, B)
|
|
60
|
+
])) : r("", !0),
|
|
61
|
+
(n(!0), s(w, null, S(e.headers, (t) => (n(), s("td", {
|
|
62
|
+
key: t.value,
|
|
63
|
+
class: a([o, t.align === "right" ? "text-right" : t.align === "center" ? "text-center" : "text-left"])
|
|
64
|
+
}, [
|
|
65
|
+
m(d.$slots, `item.${t.value}`, {
|
|
66
|
+
item: e.item,
|
|
67
|
+
value: e.item[t.value],
|
|
68
|
+
index: e.index
|
|
69
|
+
}, () => [
|
|
70
|
+
b(h(e.item[t.value] ?? "Sin datos"), 1)
|
|
71
|
+
])
|
|
72
|
+
], 2))), 128)),
|
|
73
|
+
e.hasActions ? (n(), s("td", {
|
|
74
|
+
key: 2,
|
|
75
|
+
class: a([o, k])
|
|
76
|
+
}, [
|
|
77
|
+
m(d.$slots, "item.actions", {
|
|
78
|
+
item: e.item,
|
|
79
|
+
index: e.index,
|
|
80
|
+
loading: e.loading
|
|
81
|
+
})
|
|
82
|
+
], 2)) : r("", !0)
|
|
83
|
+
]));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export {
|
|
87
|
+
T as default
|
|
88
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { computed as g, createElementBlock as d, openBlock as l, normalizeClass as p, Fragment as c, renderList as u, createVNode as E, createCommentVNode as S, mergeProps as h, createSlots as b, withCtx as C, renderSlot as f, createElementVNode as m } from "vue";
|
|
2
|
+
import B from "./KunTableRow.vue.js";
|
|
3
|
+
const A = { key: 0 }, $ = ["colspan"], k = "table-auto w-full h-full text-sm text-left", K = {
|
|
4
|
+
__name: "KunTableRows",
|
|
5
|
+
props: {
|
|
6
|
+
items: Array,
|
|
7
|
+
tbodyClass: String,
|
|
8
|
+
isExpanded: {
|
|
9
|
+
type: Function,
|
|
10
|
+
required: !0
|
|
11
|
+
},
|
|
12
|
+
isSelected: {
|
|
13
|
+
type: Function,
|
|
14
|
+
required: !0
|
|
15
|
+
},
|
|
16
|
+
itemKey: {
|
|
17
|
+
type: Function,
|
|
18
|
+
default: (e, s) => s
|
|
19
|
+
},
|
|
20
|
+
headers: Array,
|
|
21
|
+
showExpand: Boolean,
|
|
22
|
+
showSelect: Boolean,
|
|
23
|
+
hasActions: Boolean,
|
|
24
|
+
loading: Boolean,
|
|
25
|
+
actionLoadingMap: Object
|
|
26
|
+
},
|
|
27
|
+
setup(e) {
|
|
28
|
+
const s = e, y = [k, s.tbodyClass], x = g(() => {
|
|
29
|
+
var o;
|
|
30
|
+
let t = ((o = s.headers) == null ? void 0 : o.length) || 0;
|
|
31
|
+
return s.showSelect && (t += 1), s.showExpand && (t += 1), s.hasActions && (t += 1), t;
|
|
32
|
+
});
|
|
33
|
+
return (t, o) => (l(), d("tbody", {
|
|
34
|
+
class: p(y)
|
|
35
|
+
}, [
|
|
36
|
+
(l(!0), d(c, null, u(e.items, (a, n) => (l(), d(c, {
|
|
37
|
+
key: e.itemKey(a, n)
|
|
38
|
+
}, [
|
|
39
|
+
E(B, h({
|
|
40
|
+
item: a,
|
|
41
|
+
index: n,
|
|
42
|
+
headers: e.headers,
|
|
43
|
+
showExpand: e.showExpand,
|
|
44
|
+
showSelect: e.showSelect,
|
|
45
|
+
"is-selected": e.isSelected(a),
|
|
46
|
+
"is-expanded": e.isExpanded(a),
|
|
47
|
+
"has-actions": e.hasActions,
|
|
48
|
+
loading: e.actionLoadingMap[a.id] || !1,
|
|
49
|
+
ref_for: !0
|
|
50
|
+
}, t.$attrs), b({ _: 2 }, [
|
|
51
|
+
u(t.$slots, (F, i) => ({
|
|
52
|
+
name: i,
|
|
53
|
+
fn: C((w) => {
|
|
54
|
+
var r;
|
|
55
|
+
return [
|
|
56
|
+
f(t.$slots, i, h({ ref_for: !0 }, { ...w, item: a, index: n, loading: ((r = e.actionLoadingMap) == null ? void 0 : r[a.id]) || !1 }))
|
|
57
|
+
];
|
|
58
|
+
})
|
|
59
|
+
}))
|
|
60
|
+
]), 1040, ["item", "index", "headers", "showExpand", "showSelect", "is-selected", "is-expanded", "has-actions", "loading"]),
|
|
61
|
+
e.isExpanded(a) ? (l(), d("tr", A, [
|
|
62
|
+
m("td", { colspan: x.value }, [
|
|
63
|
+
f(t.$slots, "expand", {
|
|
64
|
+
item: a,
|
|
65
|
+
index: n
|
|
66
|
+
}, () => [
|
|
67
|
+
o[0] || (o[0] = m("div", { class: "text-center opacity-70 text-sm" }, "No hay contenido expandido.", -1))
|
|
68
|
+
])
|
|
69
|
+
], 8, $)
|
|
70
|
+
])) : S("", !0)
|
|
71
|
+
], 64))), 128))
|
|
72
|
+
]));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
K as default
|
|
77
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const t = () => ({
|
|
2
|
+
items: {
|
|
3
|
+
type: Array,
|
|
4
|
+
default: () => []
|
|
5
|
+
},
|
|
6
|
+
headers: {
|
|
7
|
+
type: Array,
|
|
8
|
+
default: () => []
|
|
9
|
+
},
|
|
10
|
+
hasActions: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: !1
|
|
13
|
+
},
|
|
14
|
+
actionLabel: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "Acciones"
|
|
17
|
+
},
|
|
18
|
+
actionsAlign: String,
|
|
19
|
+
actionLoadingMap: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: () => ({})
|
|
22
|
+
// ej. { 3: true, 5: false }
|
|
23
|
+
},
|
|
24
|
+
filterable: Boolean,
|
|
25
|
+
filters: {
|
|
26
|
+
type: Array,
|
|
27
|
+
default: () => []
|
|
28
|
+
},
|
|
29
|
+
customFilter: { type: Function, default: null },
|
|
30
|
+
// Features
|
|
31
|
+
itemsPerPage: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: 10
|
|
34
|
+
},
|
|
35
|
+
page: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 1
|
|
38
|
+
},
|
|
39
|
+
sortBy: {
|
|
40
|
+
type: Array,
|
|
41
|
+
default: () => []
|
|
42
|
+
},
|
|
43
|
+
pageOptions: {
|
|
44
|
+
type: Array,
|
|
45
|
+
default: () => [5, 10, 25, 50, 100]
|
|
46
|
+
},
|
|
47
|
+
searchable: { type: Boolean, default: !1 },
|
|
48
|
+
searchableKeys: { type: Array, default: null },
|
|
49
|
+
searchPosition: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: "end",
|
|
52
|
+
// 'start' | 'center' | 'end'
|
|
53
|
+
validator: (e) => ["start", "center", "end"].includes(e)
|
|
54
|
+
},
|
|
55
|
+
searchPlaceholder: { type: String, default: "Search..." },
|
|
56
|
+
debounceTime: { type: Number, default: 300 },
|
|
57
|
+
showSelect: Boolean,
|
|
58
|
+
showExpand: Boolean,
|
|
59
|
+
showGroupBy: Boolean,
|
|
60
|
+
// Display
|
|
61
|
+
hideDefaultHeader: Boolean,
|
|
62
|
+
hideDefaultFooter: Boolean,
|
|
63
|
+
// Custom class props
|
|
64
|
+
wrapperClass: { type: String, default: "" },
|
|
65
|
+
tableClass: { type: String, default: "" },
|
|
66
|
+
tbodyClass: { type: String, default: "" },
|
|
67
|
+
theadClass: { type: String, default: "" },
|
|
68
|
+
trClass: { type: String, default: "" },
|
|
69
|
+
thClass: { type: String, default: "" },
|
|
70
|
+
tdClass: { type: String, default: "" },
|
|
71
|
+
selectedClass: { type: String, default: "bg-blue-100" },
|
|
72
|
+
stripedClass: { type: String, default: "" },
|
|
73
|
+
tfootClass: { type: String, default: "" },
|
|
74
|
+
rowClass: String,
|
|
75
|
+
// Misc
|
|
76
|
+
noDataText: { type: String, default: "No data available" },
|
|
77
|
+
loadingText: { type: String, default: "Loading..." },
|
|
78
|
+
// Slots control
|
|
79
|
+
showTopSlot: Boolean,
|
|
80
|
+
showBottomSlot: Boolean
|
|
81
|
+
});
|
|
82
|
+
export {
|
|
83
|
+
t as default
|
|
84
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ref as a } from "vue";
|
|
2
|
+
function u() {
|
|
3
|
+
const e = a([]);
|
|
4
|
+
return {
|
|
5
|
+
expandedItems: e,
|
|
6
|
+
isExpanded: (l) => e.value.includes(l),
|
|
7
|
+
toggleExpand: (l) => {
|
|
8
|
+
const n = e.value.indexOf(l);
|
|
9
|
+
n === -1 ? e.value.push(l) : e.value.splice(n, 1);
|
|
10
|
+
},
|
|
11
|
+
expandAll: (l) => {
|
|
12
|
+
e.value = [...l];
|
|
13
|
+
},
|
|
14
|
+
collapseAll: () => {
|
|
15
|
+
e.value = [];
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
u as default
|
|
21
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { reactive as F, ref as k, computed as w, watch as A } from "vue";
|
|
2
|
+
import { debounce as S } from "../../../../utils/utils.js";
|
|
3
|
+
function j(i, u) {
|
|
4
|
+
const t = F({
|
|
5
|
+
search: "",
|
|
6
|
+
byColumn: {}
|
|
7
|
+
}), { items: c, customFilter: s, searchableKeys: f } = i, y = k(!1), a = (e, r) => e == null ? !1 : String(e).toLowerCase().includes(String(r).toLowerCase()), l = (e, r, n) => {
|
|
8
|
+
const o = e[r];
|
|
9
|
+
return typeof (s == null ? void 0 : s.value) == "function" ? s.value(e, r, n) : Array.isArray(n) ? n.some((b) => a(o, b)) : a(o, n);
|
|
10
|
+
}, m = w(() => Array.isArray(c.value) ? c.value.filter((e) => {
|
|
11
|
+
if (t.search && !(f.value || Object.keys(e)).some((o) => l(e, o, t.search)))
|
|
12
|
+
return !1;
|
|
13
|
+
for (const r in t.byColumn) {
|
|
14
|
+
const n = t.byColumn[r];
|
|
15
|
+
if (n != null && n !== "" && !l(e, r, n))
|
|
16
|
+
return !1;
|
|
17
|
+
}
|
|
18
|
+
return !0;
|
|
19
|
+
}) : []), h = S((e) => {
|
|
20
|
+
t.search = (e == null ? void 0 : e.toString().toLowerCase()) || "";
|
|
21
|
+
}, u), p = (e, r) => {
|
|
22
|
+
t.byColumn[e] = r;
|
|
23
|
+
};
|
|
24
|
+
function C(e) {
|
|
25
|
+
for (const r in e)
|
|
26
|
+
p(r, e[r]);
|
|
27
|
+
}
|
|
28
|
+
const d = () => {
|
|
29
|
+
t.search = "", t.byColumn = {};
|
|
30
|
+
};
|
|
31
|
+
return A(() => c.value, () => {
|
|
32
|
+
}, { deep: !0 }), {
|
|
33
|
+
modalFilter: y,
|
|
34
|
+
appliedFilters: t,
|
|
35
|
+
filteredItems: m,
|
|
36
|
+
setSearch: h,
|
|
37
|
+
applyColumnFilters: C,
|
|
38
|
+
clearFilters: d
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
j as default
|
|
43
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { reactive as x, watch as t, computed as s } from "vue";
|
|
2
|
+
function I(y, a, u) {
|
|
3
|
+
const { page: p, itemsPerPage: d, sortBy: g } = y, r = x({
|
|
4
|
+
page: p.value,
|
|
5
|
+
itemsPerPage: d.value,
|
|
6
|
+
sortBy: [...g.value || []]
|
|
7
|
+
});
|
|
8
|
+
t(() => p.value, (e) => r.page = e), t(() => d.value, (e) => r.itemsPerPage = e), t(() => g.value, (e) => r.sortBy = [...e]), t(() => r.page, (e) => a == null ? void 0 : a("update:page", e)), t(() => r.itemsPerPage, (e) => a == null ? void 0 : a("update:itemsPerPage", e)), t(() => r.sortBy, (e) => a == null ? void 0 : a("update:sortBy", e));
|
|
9
|
+
const v = s(() => (r.page - 1) * r.itemsPerPage), B = s(() => v.value + r.itemsPerPage), P = s(() => Array.isArray(u.value) ? r.sortBy.length ? [...u.value].sort((e, o) => {
|
|
10
|
+
for (const { key: n, order: i } of r.sortBy) {
|
|
11
|
+
const c = e[n], l = o[n];
|
|
12
|
+
if (c !== l)
|
|
13
|
+
return i === "asc" ? c > l ? 1 : -1 : c < l ? 1 : -1;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}) : u.value : []), f = s(() => P.value.slice(v.value, B.value));
|
|
17
|
+
return {
|
|
18
|
+
options: r,
|
|
19
|
+
paginatedItems: f,
|
|
20
|
+
updateSort: (e) => {
|
|
21
|
+
const o = r.sortBy.find((n) => n.key === e);
|
|
22
|
+
o ? o.order = o.order === "asc" ? "desc" : "asc" : r.sortBy = [{ key: e, order: "asc" }];
|
|
23
|
+
},
|
|
24
|
+
sortedItems: P
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
I as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ref as f, computed as g, watch as r } from "vue";
|
|
2
|
+
function h(c, l) {
|
|
3
|
+
const e = f([]), o = (t) => e.value.includes(t), s = (t) => {
|
|
4
|
+
const u = e.value.indexOf(t);
|
|
5
|
+
u === -1 ? e.value.push(t) : e.value.splice(u, 1), l == null || l("update:selectedItems", e.value);
|
|
6
|
+
}, n = () => {
|
|
7
|
+
e.value = [...c.items], l == null || l("update:selectedItems", e.value);
|
|
8
|
+
}, a = () => {
|
|
9
|
+
e.value = [], l == null || l("update:selectedItems", e.value);
|
|
10
|
+
}, v = () => {
|
|
11
|
+
d.value ? a() : n();
|
|
12
|
+
}, d = g(() => {
|
|
13
|
+
var t;
|
|
14
|
+
return ((t = c.items) == null ? void 0 : t.length) > 0 && e.value.length === c.items.length;
|
|
15
|
+
});
|
|
16
|
+
return r(() => c.items, (t, u) => {
|
|
17
|
+
t !== u && a();
|
|
18
|
+
}, { deep: !0 }), {
|
|
19
|
+
selectedItems: e,
|
|
20
|
+
isSelected: o,
|
|
21
|
+
toggleSelect: s,
|
|
22
|
+
selectAll: n,
|
|
23
|
+
clearSelection: a,
|
|
24
|
+
toggleSelectAll: v,
|
|
25
|
+
allSelected: d
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
h as default
|
|
30
|
+
};
|