adverich-kun-ui 0.1.167 → 0.1.168

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,11 +1,11 @@
1
- import { createElementBlock as o, openBlock as l, normalizeClass as a, createElementVNode as u, createCommentVNode as m, renderSlot as g, Fragment as w, renderList as B, normalizeStyle as A, toDisplayString as k, createBlock as E, resolveDynamicComponent as T } from "vue";
2
- import v from "../../../../icons/IconArrowUp.vue.js";
3
- import $ from "../../../../icons/IconArrowDown.vue.js";
4
- import D from "../../../../icons/IconArrowDownUp.vue.js";
5
- const z = { key: 0 }, L = { key: 1 }, O = ["checked"], I = ["onClick"], N = {
1
+ import { createElementBlock as n, openBlock as o, normalizeClass as a, createElementVNode as y, createCommentVNode as d, renderSlot as g, Fragment as b, renderList as S, normalizeStyle as A, toDisplayString as m, createBlock as w, resolveDynamicComponent as v } from "vue";
2
+ import E from "../../../../icons/IconArrowUp.vue.js";
3
+ import T from "../../../../icons/IconArrowDown.vue.js";
4
+ import $ from "../../../../icons/IconArrowDownUp.vue.js";
5
+ const D = { key: 0 }, z = { key: 1 }, L = ["checked"], O = ["onClick"], I = {
6
6
  key: 0,
7
7
  class: "inline-flex items-center gap-1 ml-1"
8
- }, U = "bg-slate-200 dark:bg-slate-800 sticky top-0 z-5", V = "", j = "px-3 py-2 text-xs font-medium text-slate-700 dark:text-slate-300 uppercase tracking-wider", G = {
8
+ }, N = "bg-slate-200 dark:bg-slate-800 sticky top-0 z-5", U = "", V = "px-3 py-2 text-xs font-medium text-slate-700 dark:text-slate-300 uppercase tracking-wider", q = {
9
9
  __name: "KunTableHeaders",
10
10
  props: {
11
11
  headers: Array,
@@ -22,74 +22,78 @@ const z = { key: 0 }, L = { key: 1 }, O = ["checked"], I = ["onClick"], N = {
22
22
  actionLabel: String
23
23
  },
24
24
  emits: ["toggle-select-all", "sort", "expandAll", "collapseAll"],
25
- setup(n, { emit: y }) {
26
- const r = n, i = y;
27
- function h() {
28
- i("toggle-select-all");
25
+ setup(r, { emit: k }) {
26
+ const l = r, c = k;
27
+ function f() {
28
+ c("toggle-select-all");
29
29
  }
30
- function p(s) {
31
- var c;
32
- if (!s.sortable) return;
33
- const t = (c = r.sortBy) == null ? void 0 : c.find((S) => S.key === s.value), e = (t == null ? void 0 : t.order) === "asc" ? "desc" : "asc";
34
- i("sort", { key: s.value, order: e });
30
+ function p(t) {
31
+ if (!t.sortable) return;
32
+ let s = null;
33
+ Array.isArray(l.sortBy) ? s = l.sortBy.find((u) => u.key === t.value) : typeof l.sortBy == "string" && (s = l.sortBy === t.value ? { key: t.value, order: "asc" } : null);
34
+ const e = (s == null ? void 0 : s.order) === "asc" ? "desc" : "asc";
35
+ c("sort", { key: t.value, order: e });
35
36
  }
36
- function x(s) {
37
- var t, e;
38
- return (e = (t = r.sortBy) == null ? void 0 : t.find((c) => c.key === s.value)) == null ? void 0 : e.order;
37
+ function h(t) {
38
+ var s;
39
+ if (Array.isArray(l.sortBy))
40
+ return (s = l.sortBy.find((e) => e.key === t.value)) == null ? void 0 : s.order;
41
+ if (typeof l.sortBy == "string" && l.sortBy === t.value)
42
+ return "asc";
39
43
  }
40
- const C = (s) => {
41
- const t = x(s);
42
- return t ? t === "asc" ? v : $ : D;
43
- }, f = [U, r.theadClass], b = [V, r.trClass], d = [j, r.thClass];
44
- return (s, t) => (l(), o("thead", {
45
- class: a(f)
44
+ const x = (t) => {
45
+ const s = h(t);
46
+ return s ? s === "asc" ? E : T : $;
47
+ }, C = [N, l.theadClass], B = [U, l.trClass], i = [V, l.thClass];
48
+ return (t, s) => (o(), n("thead", {
49
+ class: a(C)
46
50
  }, [
47
- u("tr", {
48
- class: a(b)
51
+ y("tr", {
52
+ class: a(B)
49
53
  }, [
50
- n.showExpand ? (l(), o("th", {
54
+ r.showExpand ? (o(), n("th", {
51
55
  key: 0,
52
- class: a([d])
56
+ class: a([i])
53
57
  }, [
54
- s.$slots.expandIcon ? g(s.$slots, "expand-icon", { key: 0 }) : (l(), o("button", {
58
+ t.$slots.expandIcon ? g(t.$slots, "expand-icon", { key: 0 }) : (o(), n("button", {
55
59
  key: 1,
56
- onClick: t[0] || (t[0] = (e) => n.isExpanded ? i("expandAll") : i("collapseAll"))
60
+ onClick: s[0] || (s[0] = (e) => r.isExpanded ? c("expandAll") : c("collapseAll"))
57
61
  }, [
58
- n.isExpanded ? (l(), o("span", z, "−")) : (l(), o("span", L, "+"))
62
+ r.isExpanded ? (o(), n("span", D, "−")) : (o(), n("span", z, "+"))
59
63
  ]))
60
- ], 2)) : m("", !0),
61
- n.showSelect ? (l(), o("th", {
64
+ ], 2)) : d("", !0),
65
+ r.showSelect ? (o(), n("th", {
62
66
  key: 1,
63
- class: a(d)
67
+ class: a(i)
64
68
  }, [
65
- u("input", {
69
+ y("input", {
66
70
  type: "checkbox",
67
- checked: n.allSelected,
68
- onChange: h,
71
+ checked: r.allSelected,
72
+ onChange: f,
69
73
  class: "form-checkbox"
70
- }, null, 40, O)
71
- ])) : m("", !0),
72
- (l(!0), o(w, null, B(n.headers, (e) => (l(), o("th", {
74
+ }, null, 40, L)
75
+ ])) : d("", !0),
76
+ (o(!0), n(b, null, S(r.headers, (e) => (o(), n("th", {
73
77
  key: e.key,
74
- class: a([d, e.headerAlign === "right" ? "text-right" : e.headerAlign === "center" ? "text-center" : "text-left"]),
75
- onClick: (c) => p(e),
78
+ class: a([i, e.headerAlign === "right" ? "text-right" : e.headerAlign === "center" ? "text-center" : "text-left"]),
79
+ onClick: (u) => p(e),
76
80
  style: A({ cursor: e.sortable ? "pointer" : "default" })
77
81
  }, [
78
- g(s.$slots, `header.${e.key}`, { header: e }, () => [
79
- u("span", null, k(e.label ?? e.text), 1),
80
- e.sortable ? (l(), o("span", N, [
81
- (l(), E(T(C(e)), { class: "w-4 h-4 text-gray-500" }))
82
- ])) : m("", !0)
82
+ g(t.$slots, `header.${e.key}`, { header: e }, () => [
83
+ y("span", null, m(e.label ?? e.text), 1),
84
+ e.sortable ? (o(), n("span", I, [
85
+ (o(), w(v(x(e)), { class: "w-4 h-4 text-gray-500" }))
86
+ ])) : d("", !0)
83
87
  ])
84
- ], 14, I))), 128)),
85
- n.hasActions ? (l(), o("th", {
88
+ ], 14, O))), 128)),
89
+ r.hasActions ? (o(), n("th", {
86
90
  key: 2,
87
- class: a([[d], "text-center"])
88
- }, k(n.actionLabel), 3)) : m("", !0)
91
+ class: a([[i], "text-center"])
92
+ }, m(r.actionLabel), 3)) : d("", !0)
89
93
  ])
90
94
  ]));
91
95
  }
92
96
  };
93
97
  export {
94
- G as default
98
+ q as default
95
99
  };
@@ -11,7 +11,10 @@ const t = () => ({
11
11
  // Features
12
12
  itemsPerPage: { type: Number, default: 10 },
13
13
  page: { type: Number, default: 1 },
14
- sortBy: { type: Array, default: () => [] },
14
+ sortBy: {
15
+ type: [Array, String],
16
+ default: () => []
17
+ },
15
18
  mutliSort: Boolean,
16
19
  pageOptions: { type: Array, default: () => [5, 10, 25, 50, 100] },
17
20
  searchable: { type: Boolean, default: !1 },
@@ -1,47 +1,47 @@
1
- import { reactive as x, watch as c, computed as f } from "vue";
2
- function A(y, u, l) {
3
- const { page: p, itemsPerPage: g, sortBy: P, mutliSort: m } = y, e = x({
1
+ import { reactive as A, watch as c, computed as f } from "vue";
2
+ function D(v, o, l) {
3
+ const { page: p, itemsPerPage: g, sortBy: P, mutliSort: B } = v, b = (e) => typeof e == "string" ? [{ key: e, order: "asc" }] : Array.isArray(e) ? e.map((u) => typeof u == "string" ? { key: u, order: "asc" } : u) : [], t = A({
4
4
  page: p.value,
5
5
  itemsPerPage: g.value,
6
- sortBy: [...P.value || []]
6
+ sortBy: b(P.value)
7
7
  });
8
- c(() => p.value, (t) => e.page = t), c(() => g.value, (t) => e.itemsPerPage = t), c(() => e.page, (t) => u == null ? void 0 : u("update:page", t)), c(() => e.itemsPerPage, (t) => u == null ? void 0 : u("update:itemsPerPage", t));
9
- const d = f(() => (e.page - 1) * e.itemsPerPage), B = f(() => d.value + e.itemsPerPage), v = f(() => Array.isArray(l.value) ? e.sortBy.length ? [...l.value].sort((t, s) => {
10
- for (const { key: i, order: o } of e.sortBy) {
11
- const n = t[i], r = s[i];
12
- if (!(n == null && r == null)) {
13
- if (n == null) return o === "asc" ? -1 : 1;
14
- if (r == null) return o === "asc" ? 1 : -1;
15
- if (n instanceof Date && r instanceof Date) {
16
- const a = n.getTime() - r.getTime();
17
- if (a !== 0) return o === "asc" ? a : -a;
8
+ c(() => p.value, (e) => t.page = e), c(() => g.value, (e) => t.itemsPerPage = e), c(() => t.sortBy, (e) => o == null ? void 0 : o("update:sortBy", e)), c(() => t.page, (e) => o == null ? void 0 : o("update:page", e)), c(() => t.itemsPerPage, (e) => o == null ? void 0 : o("update:itemsPerPage", e));
9
+ const y = f(() => (t.page - 1) * t.itemsPerPage), m = f(() => y.value + t.itemsPerPage), d = f(() => Array.isArray(l.value) ? t.sortBy.length ? [...l.value].sort((e, u) => {
10
+ for (const { key: i, order: s } of t.sortBy) {
11
+ const r = e[i], n = u[i];
12
+ if (!(r == null && n == null)) {
13
+ if (r == null) return s === "asc" ? -1 : 1;
14
+ if (n == null) return s === "asc" ? 1 : -1;
15
+ if (r instanceof Date && n instanceof Date) {
16
+ const a = r.getTime() - n.getTime();
17
+ if (a !== 0) return s === "asc" ? a : -a;
18
18
  continue;
19
19
  }
20
- if (typeof n == "number" && typeof r == "number") {
21
- const a = n - r;
22
- if (a !== 0) return o === "asc" ? a : -a;
20
+ if (typeof r == "number" && typeof n == "number") {
21
+ const a = r - n;
22
+ if (a !== 0) return s === "asc" ? a : -a;
23
23
  continue;
24
24
  }
25
- if (typeof n == "string" && typeof r == "string") {
26
- const a = n.localeCompare(r, void 0, { sensitivity: "base" });
27
- if (a !== 0) return o === "asc" ? a : -a;
25
+ if (typeof r == "string" && typeof n == "string") {
26
+ const a = r.localeCompare(n, void 0, { sensitivity: "base" });
27
+ if (a !== 0) return s === "asc" ? a : -a;
28
28
  continue;
29
29
  }
30
- if (n !== r) return o === "asc" ? n > r ? 1 : -1 : n < r ? 1 : -1;
30
+ if (r !== n) return s === "asc" ? r > n ? 1 : -1 : r < n ? 1 : -1;
31
31
  }
32
32
  }
33
33
  return 0;
34
- }) : l.value : []), b = f(() => v.value.slice(d.value, B.value));
34
+ }) : l.value : []), x = f(() => d.value.slice(y.value, m.value));
35
35
  return {
36
- options: e,
37
- paginatedItems: b,
38
- updateSort: ({ key: t, order: s }) => {
39
- const i = e.sortBy.find((o) => o.key === t);
40
- i ? i.order = s : m.value ? e.sortBy.push({ key: t, order: s }) : e.sortBy = [{ key: t, order: s }];
36
+ options: t,
37
+ paginatedItems: x,
38
+ updateSort: ({ key: e, order: u }) => {
39
+ const i = t.sortBy.find((s) => s.key === e);
40
+ i ? i.order = u : B.value ? t.sortBy.push({ key: e, order: u }) : t.sortBy = [{ key: e, order: u }];
41
41
  },
42
- sortedItems: v
42
+ sortedItems: d
43
43
  };
44
44
  }
45
45
  export {
46
- A as default
46
+ D as default
47
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.167",
3
+ "version": "0.1.168",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",