adverich-kun-ui 0.1.316 → 0.1.318

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 be, useModel as Se, ref as y, watch as Q, computed as q, onMounted as Ce, createElementBlock as c, openBlock as l, mergeProps as B, createCommentVNode as u, createElementVNode as V, renderSlot as a, createBlock as S, unref as s, normalizeClass as C, withCtx as x, createVNode as b, withDirectives as G, vModelText as Te, vShow as J, normalizeProps as d, guardReactiveProps as g, Fragment as $e, createSlots as X, renderList as Y, isRef as Fe, nextTick as ke } from "vue";
1
+ import { mergeModels as W, toRefs as be, useModel as Se, ref as y, watch as Q, computed as q, onMounted as Ce, createElementBlock as c, openBlock as l, mergeProps as B, createCommentVNode as u, createElementVNode as V, renderSlot as a, createBlock as S, unref as s, normalizeClass as C, withCtx as z, createVNode as b, withDirectives as G, vModelText as Te, vShow as J, normalizeProps as d, guardReactiveProps as g, Fragment as $e, createSlots as X, renderList as Y, isRef as Fe, nextTick as ke } from "vue";
2
2
  import { isMobile as p } from "../../../../utils/_platform.js";
3
3
  import Z from "../../../KunIcon/src/components/KunIcon.vue.js";
4
4
  import Pe from "../../../../icons/IconFilter.vue.js";
@@ -9,13 +9,13 @@ import Re from "./KunTableRows.vue.js";
9
9
  import Ee from "./KunTableIterators.vue.js";
10
10
  import Be from "../../../KunBtn/src/components/KunBtn.vue.js";
11
11
  import Ve from "./KunTableFilter.vue.js";
12
- import xe from "../../../KunCard/src/components/KunCard.vue.js";
13
- import ze from "../composables/useExpand.js";
14
- import je from "../composables/useOptions.js";
15
- import Ne from "../composables/useSelect.js";
16
- import De from "../composables/useFilter.js";
17
- import Ke from "../composables/KunTableProps.js";
18
- const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key: 0 }, Oe = { key: 5 }, We = {
12
+ import ze from "../../../KunCard/src/components/KunCard.vue.js";
13
+ import je from "../composables/useExpand.js";
14
+ import xe from "../composables/useOptions.js";
15
+ import He from "../composables/useSelect.js";
16
+ import Ne from "../composables/useFilter.js";
17
+ import De from "../composables/KunTableProps.js";
18
+ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto" }, Ue = { key: 0 }, Oe = { key: 5 }, We = {
19
19
  key: 0,
20
20
  class: "h-full"
21
21
  }, Qe = {
@@ -23,36 +23,36 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
23
23
  class: "sticky bottom-0 z-10 print:hidden"
24
24
  }, qe = "overflow-hidden h-full w-full flex flex-col border border-slate-200 dark:border-slate-800 rounded", Ge = "table-auto w-full h-fit text-sm text-left", ps = {
25
25
  __name: "KunTable",
26
- props: /* @__PURE__ */ W(Ke(), {
26
+ props: /* @__PURE__ */ W(De(), {
27
27
  selectedItems: { type: Array, default: () => [] },
28
28
  selectedItemsModifiers: {}
29
29
  }),
30
30
  emits: /* @__PURE__ */ W(["update:page", "update:itemsPerPage", "update:sortBy", "update:search"], ["update:selectedItems"]),
31
- setup(z, { emit: _ }) {
32
- const j = _, m = z, T = be(m), ee = Se(z, "selectedItems"), {
33
- headers: N,
31
+ setup(j, { emit: _ }) {
32
+ const x = _, m = j, T = be(m), ee = Se(j, "selectedItems"), {
33
+ headers: H,
34
34
  showExpand: $,
35
35
  showSelect: F,
36
- rowClass: D,
36
+ rowClass: N,
37
37
  hideDefaultFooter: se,
38
38
  hideDefaultHeader: oe,
39
39
  tableClass: te,
40
40
  wrapperClass: le,
41
41
  pageOptions: ae,
42
42
  items: ne,
43
- searchable: K,
43
+ searchable: D,
44
44
  debounceTime: re
45
45
  } = T, w = y(m.search);
46
46
  Q(() => m.search, (e) => {
47
47
  e !== w.value && (w.value = e);
48
48
  });
49
- const { filteredItems: ie, setSearch: ce, modalFilter: v, applyColumnFilters: ue, clearFilters: de, appliedFilters: pe } = De(T, re);
49
+ const { filteredItems: ie, setSearch: ce, modalFilter: v, applyColumnFilters: ue, clearFilters: de, appliedFilters: pe } = Ne(T, re);
50
50
  Q(w, (e) => {
51
- j("update:search", e), ce(e);
51
+ x("update:search", e), ce(e);
52
52
  });
53
- const { options: r, paginatedItems: f, updateSort: me } = je(T, j, ie), { isSelected: k, toggleSelect: P, toggleSelectAll: fe, allSelected: he, someSelected: ge } = Ne(f, ee), { isExpanded: M, toggleExpand: A } = ze(), h = q(() => ({
53
+ const { options: r, paginatedItems: f, updateSort: me } = xe(T, x, ie), { isSelected: k, toggleSelect: P, toggleSelectAll: fe, allSelected: he, someSelected: ge } = He(f, ee), { isExpanded: M, toggleExpand: A } = je(), h = q(() => ({
54
54
  items: f.value,
55
- headers: N.value,
55
+ headers: H.value,
56
56
  page: r.page,
57
57
  itemsPerPage: r.itemsPerPage,
58
58
  toggleSelect: P,
@@ -61,7 +61,7 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
61
61
  isExpanded: M,
62
62
  sortBy: r.sortBy,
63
63
  hasActions: m.hasActions
64
- })), we = [qe, le.value], ve = [Ge, te.value], L = q(() => m.headers.map((e) => {
64
+ })), we = [qe, le.value], ve = [Ge, te.value], K = q(() => m.headers.map((e) => {
65
65
  var t, i;
66
66
  const o = { ...e };
67
67
  if ((e.columnType === "function" || e.columnType == "objectFunction" || e.columnType == "simpleFunction") && typeof e.columnFunction == "string") {
@@ -78,14 +78,14 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
78
78
  }
79
79
  return o;
80
80
  }));
81
- Ce(() => H());
82
- const U = y(null), I = y(!0), R = y(!1);
81
+ Ce(() => U());
82
+ const L = y(null), I = y(!0), R = y(!1);
83
83
  function ye() {
84
84
  p.value && (O(), ke(() => {
85
- U.value.focus();
85
+ L.value.focus();
86
86
  }));
87
87
  }
88
- function H() {
88
+ function U() {
89
89
  p.value && (E.value = "w-fit", I.value = !1, R.value = !0);
90
90
  }
91
91
  function O() {
@@ -93,7 +93,7 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
93
93
  }
94
94
  const E = y("w-full border max-w-sm");
95
95
  return (e, o) => (l(), c("div", B({ class: we }, e.$attrs, { style: { "user-select": "text" } }), [
96
- s(K) || e.filterable || e.$slots.prependSearch || e.$slots.appendSearch ? (l(), c("div", {
96
+ s(D) || e.filterable || e.$slots.prependSearch || e.$slots.appendSearch ? (l(), c("div", {
97
97
  key: 0,
98
98
  class: C(["p-2 bg-slate-200 dark:bg-slate-800 print:hidden", {
99
99
  "justify-start flex": e.searchPosition === "start",
@@ -110,7 +110,7 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
110
110
  size: "xs",
111
111
  bgColor: "bg-green-200 dark:bg-green-800"
112
112
  }, {
113
- default: x(() => [
113
+ default: z(() => [
114
114
  b(Z, {
115
115
  class: "h-fit",
116
116
  icon: Pe,
@@ -119,7 +119,7 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
119
119
  ]),
120
120
  _: 1
121
121
  })) : u("", !0),
122
- s(K) ? (l(), c("div", {
122
+ s(D) ? (l(), c("div", {
123
123
  key: 1,
124
124
  class: C(["rounded flex mx-2", [E.value]])
125
125
  }, [
@@ -129,10 +129,10 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
129
129
  placeholder: e.searchPlaceholder,
130
130
  class: C(["w-full text-sm", s(p) ? "px-1" : "px-2 py-1"]),
131
131
  ref_key: "searchRef",
132
- ref: U,
132
+ ref: L,
133
133
  onFocus: O,
134
- onBlur: H
135
- }, null, 42, Le), [
134
+ onBlur: U
135
+ }, null, 42, Ke), [
136
136
  [Te, w.value],
137
137
  [J, I.value]
138
138
  ]),
@@ -145,16 +145,16 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
145
145
  ], 2)) : u("", !0),
146
146
  a(e.$slots, "appendSearch")
147
147
  ], 2)) : u("", !0),
148
- V("div", Ue, [
148
+ V("div", Le, [
149
149
  V("table", {
150
150
  class: C(ve)
151
151
  }, [
152
- e.$slots.colgroup && !s(p) ? (l(), c("colgroup", He, [
152
+ e.$slots.colgroup && !s(p) ? (l(), c("colgroup", Ue, [
153
153
  a(e.$slots, "colgroup", d(g(h.value)))
154
154
  ])) : u("", !0),
155
155
  !s(oe) && !s(p) ? (l(), S(Ae, {
156
156
  key: 1,
157
- headers: s(N),
157
+ headers: s(H),
158
158
  "sort-by": s(r).sortBy,
159
159
  "show-select": s(F),
160
160
  "show-expand": s($),
@@ -166,15 +166,16 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
166
166
  "has-actions": e.hasActions,
167
167
  "action-label": e.actionLabel,
168
168
  onSort: s(me),
169
- onToggleSelectAll: s(fe)
170
- }, null, 8, ["headers", "sort-by", "show-select", "show-expand", "all-selected", "some-selected", "thead-class", "tr-class", "th-class", "has-actions", "action-label", "onSort", "onToggleSelectAll"])) : a(e.$slots, "thead", d(B({ key: 2 }, h.value))),
169
+ onToggleSelectAll: s(fe),
170
+ customHeaders: e.customSlots
171
+ }, null, 8, ["headers", "sort-by", "show-select", "show-expand", "all-selected", "some-selected", "thead-class", "tr-class", "th-class", "has-actions", "action-label", "onSort", "onToggleSelectAll", "customHeaders"])) : a(e.$slots, "thead", d(B({ key: 2 }, h.value))),
171
172
  s(f).length && !s(p) ? (l(), c($e, { key: 3 }, [
172
173
  a(e.$slots, "body.prepend", d(g(h.value))),
173
174
  b(Re, {
174
175
  items: s(f),
175
- headers: L.value,
176
+ headers: K.value,
176
177
  "tbody-class": e.tbodyClass,
177
- "row-class": s(D),
178
+ "row-class": s(N),
178
179
  "row-class-condition": e.rowClassCondition,
179
180
  "tr-class": e.trClass,
180
181
  "td-class": e.tdClass,
@@ -192,7 +193,7 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
192
193
  }, X({ _: 2 }, [
193
194
  Y(e.$slots, (t, i) => ({
194
195
  name: i,
195
- fn: x((n) => [
196
+ fn: z((n) => [
196
197
  a(e.$slots, i, d(g(n)))
197
198
  ])
198
199
  }))
@@ -201,8 +202,8 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
201
202
  ], 64)) : s(f).length && s(p) ? (l(), S(Ee, {
202
203
  key: 4,
203
204
  items: s(f),
204
- headers: L.value,
205
- "row-class": s(D),
205
+ headers: K.value,
206
+ "row-class": s(N),
206
207
  "row-class-condition": e.rowClassCondition,
207
208
  "is-selected": s(k),
208
209
  "is-expanded": s(M),
@@ -216,7 +217,7 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
216
217
  }, X({ _: 2 }, [
217
218
  Y(e.$slots, (t, i) => ({
218
219
  name: i,
219
- fn: x((n) => [
220
+ fn: z((n) => [
220
221
  a(e.$slots, i, d(g(n)))
221
222
  ])
222
223
  }))
@@ -226,7 +227,7 @@ const Le = ["placeholder"], Ue = { class: "flex-1 overflow-auto" }, He = { key:
226
227
  ])) : u("", !0)
227
228
  ]),
228
229
  s(f).length ? u("", !0) : (l(), c("div", We, [
229
- b(xe, {
230
+ b(ze, {
230
231
  class: "h-full flex justify-center items-center text-center",
231
232
  title: e.noDataText,
232
233
  titleSize: "text-4xl"
@@ -1,11 +1,11 @@
1
- import { ref as A, onMounted as v, watch as k, createElementBlock as r, openBlock as o, normalizeClass as a, createElementVNode as m, createCommentVNode as d, renderSlot as g, Fragment as E, renderList as T, normalizeStyle as $, toDisplayString as h, createBlock as D, resolveDynamicComponent as z } from "vue";
2
- import I from "../../../../icons/IconArrowUp.vue.js";
3
- import L from "../../../../icons/IconArrowDown.vue.js";
4
- import O from "../../../../icons/IconArrowDownUp.vue.js";
5
- const j = { key: 0 }, N = { key: 1 }, R = ["checked", "aria-checked"], U = ["onClick"], V = {
1
+ import { ref as $, onMounted as E, watch as f, createElementBlock as r, openBlock as a, normalizeClass as o, createElementVNode as k, createCommentVNode as u, renderSlot as g, Fragment as T, renderList as D, normalizeStyle as H, createBlock as h, resolveDynamicComponent as b, toDisplayString as x } from "vue";
2
+ import O from "../../../../icons/IconArrowUp.vue.js";
3
+ import j from "../../../../icons/IconArrowDown.vue.js";
4
+ import z from "../../../../icons/IconArrowDownUp.vue.js";
5
+ const I = { key: 0 }, L = { key: 1 }, N = ["checked", "aria-checked"], R = ["onClick"], U = {
6
6
  key: 0,
7
7
  class: "inline-flex items-center gap-1 ml-1 print:hidden"
8
- }, F = "bg-slate-200 dark:bg-slate-800 sticky top-0 z-5", H = "", K = "px-3 py-2 text-xs font-medium text-slate-700 dark:text-slate-300 uppercase tracking-wider", P = {
8
+ }, V = "bg-slate-200 dark:bg-slate-800 sticky top-0 z-5", F = "", K = "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,
@@ -19,86 +19,96 @@ const j = { key: 0 }, N = { key: 1 }, R = ["checked", "aria-checked"], U = ["onC
19
19
  trClass: String,
20
20
  thClass: String,
21
21
  hasActions: Boolean,
22
- actionLabel: String
22
+ actionLabel: String,
23
+ customHeaders: Object
23
24
  },
24
25
  emits: ["toggle-select-all", "sort", "expandAll", "collapseAll"],
25
- setup(n, { emit: b }) {
26
- const t = n, c = b;
27
- function x() {
26
+ setup(l, { emit: S }) {
27
+ const t = l, c = S;
28
+ function p() {
28
29
  c("toggle-select-all");
29
30
  }
30
- function p(l) {
31
- if (!l.sortable) return;
32
- let s = null;
33
- Array.isArray(t.sortBy) ? s = t.sortBy.find((f) => f.key === l.value) : typeof t.sortBy == "string" && (s = t.sortBy === l.value ? { key: l.value, order: "asc" } : null);
34
- const e = (s == null ? void 0 : s.order) === "asc" ? "desc" : "asc";
35
- c("sort", { key: l.value, order: e });
31
+ function C(s) {
32
+ if (!s.sortable) return;
33
+ let n = null;
34
+ Array.isArray(t.sortBy) ? n = t.sortBy.find((d) => d.key === s.value) : typeof t.sortBy == "string" && (n = t.sortBy === s.value ? { key: s.value, order: "asc" } : null);
35
+ const e = (n == null ? void 0 : n.order) === "asc" ? "desc" : "asc";
36
+ c("sort", { key: s.value, order: e });
36
37
  }
37
- function S(l) {
38
- var s;
38
+ function B(s) {
39
+ var n;
39
40
  if (Array.isArray(t.sortBy))
40
- return (s = t.sortBy.find((e) => e.key === l.value)) == null ? void 0 : s.order;
41
- if (typeof t.sortBy == "string" && t.sortBy === l.value)
41
+ return (n = t.sortBy.find((e) => e.key === s.value)) == null ? void 0 : n.order;
42
+ if (typeof t.sortBy == "string" && t.sortBy === s.value)
42
43
  return "asc";
43
44
  }
44
- const C = (l) => {
45
- const s = S(l);
46
- return s ? s === "asc" ? I : L : O;
47
- }, B = [F, t.theadClass], w = [H, t.trClass], i = [K, t.thClass], u = A(null), y = () => {
48
- u.value && (u.value.indeterminate = t.someSelected && !t.allSelected);
45
+ const w = (s) => {
46
+ const n = B(s);
47
+ return n ? n === "asc" ? O : j : z;
48
+ }, A = [V, t.theadClass], v = [F, t.trClass], i = [K, t.thClass], y = $(null), m = () => {
49
+ y.value && (y.value.indeterminate = t.someSelected && !t.allSelected);
49
50
  };
50
- return v(y), k(() => t.someSelected, y), k(() => t.allSelected, y), (l, s) => (o(), r("thead", {
51
- class: a(B)
51
+ return E(m), f(() => t.someSelected, m), f(() => t.allSelected, m), (s, n) => (a(), r("thead", {
52
+ class: o(A)
52
53
  }, [
53
- m("tr", {
54
- class: a(w)
54
+ k("tr", {
55
+ class: o(v)
55
56
  }, [
56
- n.showExpand ? (o(), r("th", {
57
+ l.showExpand ? (a(), r("th", {
57
58
  key: 0,
58
- class: a([i])
59
+ class: o([i])
59
60
  }, [
60
- l.$slots.expandIcon ? g(l.$slots, "expand-icon", { key: 0 }) : (o(), r("button", {
61
+ s.$slots.expandIcon ? g(s.$slots, "expand-icon", { key: 0 }) : (a(), r("button", {
61
62
  key: 1,
62
- onClick: s[0] || (s[0] = (e) => n.isExpanded ? c("expandAll") : c("collapseAll"))
63
+ onClick: n[0] || (n[0] = (e) => l.isExpanded ? c("expandAll") : c("collapseAll"))
63
64
  }, [
64
- n.isExpanded ? (o(), r("span", j, "−")) : (o(), r("span", N, "+"))
65
+ l.isExpanded ? (a(), r("span", I, "−")) : (a(), r("span", L, "+"))
65
66
  ]))
66
- ], 2)) : d("", !0),
67
- n.showSelect ? (o(), r("th", {
67
+ ], 2)) : u("", !0),
68
+ l.showSelect ? (a(), r("th", {
68
69
  key: 1,
69
- class: a([i, "h-full w-10 flex flex-col items-center justify-center"])
70
+ class: o([i, "h-full w-10 flex flex-col items-center justify-center"])
70
71
  }, [
71
- m("input", {
72
+ k("input", {
72
73
  ref_key: "checkboxRef",
73
- ref: u,
74
+ ref: y,
74
75
  type: "checkbox",
75
- checked: n.allSelected,
76
- "aria-checked": n.someSelected && !n.allSelected ? "mixed" : n.allSelected ? "true" : "false",
77
- onChange: x,
76
+ checked: l.allSelected,
77
+ "aria-checked": l.someSelected && !l.allSelected ? "mixed" : l.allSelected ? "true" : "false",
78
+ onChange: p,
78
79
  class: "h-6 w-6 text-blue-600 transition-all duration-200 ease-in-out rounded print:hidden border-gray-300 dark:border-slate-600 checked:bg-blue-600 checked:border-blue-600 indeterminate:bg-blue-400 indeterminate:border-blue-400"
79
- }, null, 40, R)
80
- ])) : d("", !0),
81
- (o(!0), r(E, null, T(n.headers, (e) => (o(), r("th", {
82
- key: e.key,
83
- class: a([i, e.headerAlign === "right" ? "text-right" : e.headerAlign === "left" ? "text-left" : "text-center"]),
84
- onClick: (f) => p(e),
85
- style: $({ cursor: e.sortable ? "pointer" : "default" })
86
- }, [
87
- g(l.$slots, `header.${e.key}`, { header: e }, () => [
88
- m("span", null, h(e.label ?? e.text), 1),
89
- e.sortable ? (o(), r("span", V, [
90
- (o(), D(z(C(e)), { class: "w-4 h-4 text-gray-500" }))
91
- ])) : d("", !0)
92
- ])
93
- ], 14, U))), 128)),
94
- n.hasActions ? (o(), r("th", {
80
+ }, null, 40, N)
81
+ ])) : u("", !0),
82
+ (a(!0), r(T, null, D(l.headers, (e) => {
83
+ var d;
84
+ return a(), r("th", {
85
+ key: e.key,
86
+ class: o([i, e.headerAlign === "right" ? "text-right" : e.headerAlign === "left" ? "text-left" : "text-center"]),
87
+ onClick: (M) => C(e),
88
+ style: H({ cursor: e.sortable ? "pointer" : "default" })
89
+ }, [
90
+ (d = l.customHeaders) != null && d[`header.${e.value}`] ? (a(), h(b(l.customHeaders[`header.${e.value}`]), {
91
+ key: 0,
92
+ header: e
93
+ }, null, 8, ["header"])) : g(s.$slots, `header.${e.key}`, {
94
+ key: 1,
95
+ header: e
96
+ }, () => [
97
+ k("span", null, x(e.label ?? e.text), 1),
98
+ e.sortable ? (a(), r("span", U, [
99
+ (a(), h(b(w(e)), { class: "w-4 h-4 text-gray-500" }))
100
+ ])) : u("", !0)
101
+ ])
102
+ ], 14, R);
103
+ }), 128)),
104
+ l.hasActions ? (a(), r("th", {
95
105
  key: 2,
96
- class: a([[i], "text-center print:hidden"])
97
- }, h(n.actionLabel), 3)) : d("", !0)
106
+ class: o([[i], "text-center print:hidden"])
107
+ }, x(l.actionLabel), 3)) : u("", !0)
98
108
  ])
99
109
  ]));
100
110
  }
101
111
  };
102
112
  export {
103
- P as default
113
+ Q as default
104
114
  };
@@ -56,6 +56,7 @@ const t = () => ({
56
56
  loadingText: { type: String, default: "Cargando..." },
57
57
  // Slots control
58
58
  customSlots: { type: Object, default: () => ({}) },
59
+ customHeaders: { type: Object, default: () => ({}) },
59
60
  showTopSlot: { type: Boolean, default: !1 },
60
61
  showBottomSlot: { type: Boolean, default: !1 },
61
62
  functionMap: { type: Object, default: () => ({}) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.316",
3
+ "version": "0.1.318",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",