adverich-kun-ui 0.1.585 → 0.1.586

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,39 +1,42 @@
1
- import { ref as a, computed as x } from "vue";
2
- function q(n, p, u, w) {
3
- const f = a({}), c = a(null), g = a(null), H = {
1
+ import { ref as u, computed as R } from "vue";
2
+ function K(e, $, d, y) {
3
+ const v = u({}), f = u(null), x = u(null), c = u(null), w = u("bottom"), B = {
4
4
  top: { class: "origin-bottom" },
5
5
  bottom: { class: "origin-top" },
6
6
  left: { class: "origin-right" },
7
7
  right: { class: "origin-left" }
8
- }, M = x(() => {
8
+ }, F = R(() => {
9
9
  var t;
10
- return ((t = H[n.location]) == null ? void 0 : t.class) || "origin-top";
10
+ return w.value === "top" ? "origin-bottom" : ((t = B[e.location]) == null ? void 0 : t.class) || "origin-top";
11
11
  });
12
- function s(t = 0) {
13
- const o = n.parentRef || g.value, i = c.value;
14
- if (!(o instanceof HTMLElement) || !(i instanceof HTMLElement)) return;
15
- const e = o.getBoundingClientRect();
16
- if ((e.width < 1 || e.height < 1) && t < 10) {
17
- requestAnimationFrame(() => s(t + 1));
12
+ function m(t = 0) {
13
+ const l = e.parentRef || x.value, o = f.value;
14
+ if (!(l instanceof HTMLElement) || !(o instanceof HTMLElement)) return;
15
+ const n = l.getBoundingClientRect();
16
+ if ((n.width < 1 || n.height < 1) && t < 10) {
17
+ requestAnimationFrame(() => m(t + 1));
18
18
  return;
19
19
  }
20
20
  requestAnimationFrame(() => {
21
- const h = i.getBoundingClientRect();
22
- if ((h.width < 1 || h.height < 1) && t < 10) {
23
- requestAnimationFrame(() => s(t + 1));
21
+ const b = o.getBoundingClientRect();
22
+ if ((b.width < 1 || b.height < 1) && t < 10) {
23
+ requestAnimationFrame(() => m(t + 1));
24
24
  return;
25
25
  }
26
- const A = n.origin || L(n.location), [d, m] = A.split(" "), F = n.hideDetails ? 0 : 19, v = i.offsetWidth, E = i.offsetHeight;
27
- let l = 0, r = 0;
28
- m === "right" ? r = e.right - v : m === "center" ? r = e.left + e.width / 2 - v / 2 : r = e.left, d === "top" ? l = e.top - E : d === "center" ? l = e.top + e.height / 2 - E / 2 : l = e.bottom - F, f.value = {
26
+ const H = window.innerHeight, M = window.innerWidth, a = 8, E = e.hideDetails ? 0 : 19, s = o.offsetWidth, p = o.offsetHeight, g = H - n.bottom + E - a, h = n.top - a, S = g >= p, T = h >= p, L = !S && (T || h > g);
27
+ w.value = L ? "top" : "bottom";
28
+ const z = e.origin && e.origin !== "auto" ? e.origin : W(e.location), [, A] = z.split(" ");
29
+ let i = 0;
30
+ A === "right" ? i = n.right - s : A === "center" ? i = n.left + n.width / 2 - s / 2 : i = n.left, i + s > M - a && (i = M - s - a), i < a && (i = a);
31
+ const r = {
29
32
  position: "fixed",
30
- top: `${l}px`,
31
- left: `${r}px`,
32
- width: n.width === "w-full" ? `${e.width}px` : void 0
33
+ left: `${i}px`,
34
+ width: e.width === "w-full" ? `${n.width}px` : void 0
33
35
  };
36
+ L ? (r.top = "auto", r.bottom = `${H - n.top}px`, c.value = h) : (r.top = `${n.bottom - E}px`, r.bottom = "auto", c.value = g), v.value = r;
34
37
  });
35
38
  }
36
- function L(t) {
39
+ function W(t) {
37
40
  switch (t) {
38
41
  case "top":
39
42
  return "top left";
@@ -47,26 +50,29 @@ function q(n, p, u, w) {
47
50
  return "bottom left";
48
51
  }
49
52
  }
50
- function b() {
51
- var o, i;
52
- const t = ((o = n.parentRef) == null ? void 0 : o.$el) || ((i = c.value) == null ? void 0 : i.parentElement);
53
+ function q() {
54
+ var l, o;
55
+ const t = ((l = e.parentRef) == null ? void 0 : l.$el) || ((o = f.value) == null ? void 0 : o.parentElement);
53
56
  if (!(t instanceof HTMLElement)) {
54
57
  console.warn("[KunMenu] Activator no válido:", t);
55
58
  return;
56
59
  }
57
- t.addEventListener("click", p), t.addEventListener("mouseenter", () => u("enter")), t.addEventListener("mouseleave", () => u("leave")), t.addEventListener("focus", w);
60
+ t.addEventListener("click", $), t.addEventListener("mouseenter", () => d("enter")), t.addEventListener("mouseleave", () => d("leave")), t.addEventListener("focus", y);
58
61
  }
59
- const R = x(() => typeof n.maxHeight == "number" ? n.maxHeight + "px" : n.maxHeight);
62
+ const C = R(() => {
63
+ const t = typeof e.maxHeight == "number" ? e.maxHeight : e.maxHeight ? parseInt(e.maxHeight) : null;
64
+ return c.value !== null ? `${t ? Math.min(t, c.value) : c.value}px` : typeof e.maxHeight == "number" ? e.maxHeight + "px" : e.maxHeight;
65
+ });
60
66
  return {
61
- initializeMenu: b,
62
- repositionMenu: s,
63
- contentEl: c,
64
- activatorEl: g,
65
- originClass: M,
66
- computedMaxHeight: R,
67
- menuPositionStyle: f
67
+ initializeMenu: q,
68
+ repositionMenu: m,
69
+ contentEl: f,
70
+ activatorEl: x,
71
+ originClass: F,
72
+ computedMaxHeight: C,
73
+ menuPositionStyle: v
68
74
  };
69
75
  }
70
76
  export {
71
- q as useKunMenuStyles
77
+ K as useKunMenuStyles
72
78
  };
@@ -1,4 +1,4 @@
1
- import { computed as i, openBlock as l, createElementBlock as o, normalizeClass as a, renderSlot as u, createCommentVNode as p, createVNode as $, Fragment as S, renderList as T, createBlock as V, resolveDynamicComponent as h, unref as r, createTextVNode as x, toDisplayString as R } from "vue";
1
+ import { computed as i, openBlock as l, createElementBlock as o, normalizeClass as a, renderSlot as u, createCommentVNode as p, createVNode as $, Fragment as S, renderList as T, createBlock as V, resolveDynamicComponent as h, unref as r, createTextVNode as R, toDisplayString as x } from "vue";
2
2
  import B from "../../../KunCheckbox/src/components/KunCheckbox.vue.js";
3
3
  import { getValue as c, formatValue as E } from "../../../../utils/tableFormatters.js";
4
4
  import { kunTableRowProps as N } from "../composables/kunTableRowProps.js";
@@ -73,7 +73,7 @@ const A = { key: 0 }, D = { key: 1 }, j = "px-1 py-2 whitespace-normal word-brea
73
73
  index: e.index,
74
74
  header: t
75
75
  }, () => [
76
- x(R(r(E)(t, r(c)(t, e.item))), 1)
76
+ R(x(r(E)(t, r(c)(t, e.item), e.item)), 1)
77
77
  ])
78
78
  ], 2);
79
79
  }), 128)),
@@ -0,0 +1,14 @@
1
+ const e = {
2
+ documentTypes: [],
3
+ countries: []
4
+ }, t = {
5
+ get documentTypes() {
6
+ return e.documentTypes;
7
+ },
8
+ get countries() {
9
+ return e.countries;
10
+ }
11
+ };
12
+ export {
13
+ t as kunDocumentConfig
14
+ };
@@ -1,22 +1,143 @@
1
- import { kunConfig as c } from "../config/kunConfig.js";
2
- function p(t, n) {
3
- var e;
1
+ import { kunConfig as l } from "../config/kunConfig.js";
2
+ import { kunDocumentConfig as _ } from "../config/kunDocumentConfig.js";
3
+ const S = {
4
+ doc_ar: {
5
+ cuit: { mask: [2, 8, 1] },
6
+ cuil: { mask: [2, 8, 1] },
7
+ dni: { thousandsSep: "." }
8
+ },
9
+ doc_bo: {
10
+ nit: { mask: null },
11
+ ci: { mask: null }
12
+ },
13
+ doc_br: {
14
+ cpf: { mask: [3, 3, 3, 2], separators: [".", ".", "-"] },
15
+ cnpj: { mask: [2, 3, 3, 4, 2], separators: [".", ".", "/", "-"] }
16
+ },
17
+ doc_cl: {
18
+ rut: { rutFormat: !0, thousandsSep: "." },
19
+ run: { rutFormat: !0, thousandsSep: "." }
20
+ },
21
+ doc_co: {
22
+ nit: { mask: [9, 1] }
23
+ },
24
+ doc_cr: {
25
+ cedula: { mask: [1, 4, 5] },
26
+ dimex: { mask: [1, 4, 5] },
27
+ nite: { mask: [1, 3, 6] }
28
+ },
29
+ doc_do: {
30
+ cedula: { mask: [3, 7, 1] }
31
+ },
32
+ doc_es: {
33
+ dni: { mask: [8, 1] },
34
+ nie: { mask: [1, 7, 1] }
35
+ },
36
+ doc_gb: {
37
+ vat: { mask: [2, 3, 4, 2], separators: [" ", " ", " "] },
38
+ ni: { mask: [2, 2, 2, 2, 1], separators: [" ", " ", " ", " "] }
39
+ },
40
+ doc_de: {
41
+ stnr: { mask: [2, 3, 5], separators: ["/", "/"] }
42
+ },
43
+ doc_fr: {
44
+ siret: { mask: [3, 3, 3, 5], separators: [" ", " ", " "] },
45
+ siren: { mask: [3, 3, 3], separators: [" ", " "] },
46
+ tva: { mask: [4, 9], separators: [" "] }
47
+ },
48
+ doc_gt: {
49
+ nit: { mask: [8, 1] }
50
+ },
51
+ doc_hn: {
52
+ dni: { mask: [4, 4, 5] }
53
+ },
54
+ doc_ni: {
55
+ cedula: { mask: [9, 1] }
56
+ },
57
+ doc_pa: {
58
+ cedula: { mask: [1, 3, 4] },
59
+ ruc: { mask: [7, 1, 2] }
60
+ },
61
+ doc_py: {
62
+ ruc: { mask: [7, 1] }
63
+ },
64
+ doc_ve: {
65
+ cedula: { mask: [1, 8] },
66
+ rif: { mask: [1, 8, 1] }
67
+ },
68
+ doc_pt: {
69
+ passaporte: { mask: [1, 8] }
70
+ }
71
+ };
72
+ function D(t) {
73
+ return String(t || "").toUpperCase().replace(/[^A-Z0-9]/g, "");
74
+ }
75
+ function F(t, n) {
76
+ let r = "";
77
+ for (let o = 0; o < t.length; o++)
78
+ o > 0 && (t.length - o) % 3 === 0 && (r += n), r += t[o];
79
+ return r;
80
+ }
81
+ function C(t, n, r) {
82
+ let o = "", e = 0;
83
+ for (let s = 0; s < n.length && e < t.length; s++)
84
+ o += t.substring(e, e + n[s]), e += n[s], s < n.length - 1 && e < t.length && (o += r ? r[s] ?? "-" : "-");
85
+ return o;
86
+ }
87
+ function h(t, n, r) {
88
+ var s;
89
+ const o = D(String(t ?? ""));
90
+ if (!o) return t ?? "";
91
+ const e = (s = S[n]) == null ? void 0 : s[r];
92
+ return e ? e.rutFormat ? o.length < 2 ? o : F(o.slice(0, -1), e.thousandsSep || ".") + "-" + o.slice(-1) : e.thousandsSep ? F(o, e.thousandsSep) : e.mask ? C(o, e.mask, e.separators ?? null) : o : o;
93
+ }
94
+ function $(t, n) {
95
+ var o;
4
96
  if (!t || !t.value) return;
5
97
  if (t.columnType === "relation") {
6
- const r = f(n, t.relationPath);
7
- return u(r);
98
+ const e = x(n, t.relationPath);
99
+ return m(e);
8
100
  }
9
101
  if (t.columnType === "function") {
10
- const r = (e = t.columnFunction) == null ? void 0 : e.call(t, n, t);
11
- return u(r);
102
+ const e = (o = t.columnFunction) == null ? void 0 : o.call(t, n, t);
103
+ return m(e);
12
104
  }
13
- const o = n == null ? void 0 : n[t.value];
14
- return u(o);
105
+ const r = n == null ? void 0 : n[t.value];
106
+ return m(r);
15
107
  }
16
- function g(t, n) {
17
- return t.columnType === "toComplete" ? "" : n == null ? "Sin datos" : t.columnType === "dateTime" || t.columnType === "date" ? (i[t.columnType] || i.default)(n) : (i[t.columnFormat] || i.default)(n);
108
+ function N(t, n, r, o) {
109
+ var d, p, g, k;
110
+ const e = D(String(t ?? ""));
111
+ if (!e || !n || !(r != null && r.length)) return e;
112
+ const s = r.find((c) => c.id == n);
113
+ if (!s) return e;
114
+ const a = s.country_id ?? ((d = s.country) == null ? void 0 : d.id);
115
+ let i = null;
116
+ if (a && (o != null && o.length)) {
117
+ const c = o.find((w) => w.id == a), y = (c == null ? void 0 : c.iso2) || (c == null ? void 0 : c.iso_code) || (c == null ? void 0 : c.code);
118
+ y && (i = `doc_${y.toLowerCase()}`);
119
+ }
120
+ if (!i) {
121
+ const c = s.country_iso2 || ((p = s.country) == null ? void 0 : p.iso2);
122
+ c && (i = `doc_${c.toLowerCase()}`);
123
+ }
124
+ if (!i) return e;
125
+ const f = ((g = s.short_name) == null ? void 0 : g.toLowerCase()) || ((k = s.name) == null ? void 0 : k.toLowerCase());
126
+ return f ? h(t, i, f) : e;
18
127
  }
19
- const i = {
128
+ function L(t, n, r = null) {
129
+ var e, s;
130
+ if (t.columnType === "toComplete") return "";
131
+ if (n == null) return "Sin datos";
132
+ if (t.columnType === "dateTime" || t.columnType === "date")
133
+ return (u[t.columnType] || u.default)(n);
134
+ if (t.columnType === "document") {
135
+ const a = (r == null ? void 0 : r.document_type_id) ?? ((e = r == null ? void 0 : r.entity) == null ? void 0 : e.document_type_id) ?? null;
136
+ return N(n, a, _.documentTypes, _.countries);
137
+ }
138
+ return (s = t.columnType) != null && s.startsWith("doc_") ? h(n, t.columnType, t.columnFormat) : (u[t.columnFormat] || u.default)(n);
139
+ }
140
+ const u = {
20
141
  default: (t) => t,
21
142
  // TEXTS
22
143
  text: (t) => String(t),
@@ -25,16 +146,16 @@ const i = {
25
146
  // ya está procesado por getComposedValue
26
147
  // NUMBERS - Usa config global directamente
27
148
  number: (t) => {
28
- const n = c.locale;
149
+ const n = l.locale;
29
150
  return Number(t).toLocaleString(n);
30
151
  },
31
152
  money: (t) => {
32
- const n = c.current, o = n.locale, e = n.precision, r = n.currency;
33
- return new Intl.NumberFormat(o, {
153
+ const n = l.current, r = n.locale, o = n.precision, e = n.currency;
154
+ return new Intl.NumberFormat(r, {
34
155
  style: "currency",
35
- currency: r.value,
36
- minimumFractionDigits: e,
37
- maximumFractionDigits: e
156
+ currency: e.value,
157
+ minimumFractionDigits: o,
158
+ maximumFractionDigits: o
38
159
  }).format(t ?? 0);
39
160
  },
40
161
  noDecimal: (t) => parseFloat(t ?? 0).toFixed(0),
@@ -42,22 +163,22 @@ const i = {
42
163
  noCeros: (t) => parseFloat(t ?? 0),
43
164
  percentage: (t) => `${parseFloat(t ?? 0)}%`,
44
165
  date: (t) => {
45
- var s;
46
- if (!t || t === "0000-00-00" || !m(t)) return "Nunca";
47
- const [n, o, e] = t.split("-").map(Number), r = new Date(n, o - 1, e, 12, 0, 0), a = c.current, l = a.locale;
48
- return new Intl.DateTimeFormat(l, {
166
+ var i;
167
+ if (!t || t === "0000-00-00" || !T(t)) return "Nunca";
168
+ const [n, r, o] = t.split("-").map(Number), e = new Date(n, r - 1, o, 12, 0, 0), s = l.current, a = s.locale;
169
+ return new Intl.DateTimeFormat(a, {
49
170
  weekday: "short",
50
171
  day: "2-digit",
51
172
  month: "short",
52
173
  year: "2-digit",
53
- ...(s = a.date) == null ? void 0 : s.dateFormat
54
- }).format(r);
174
+ ...(i = s.date) == null ? void 0 : i.dateFormat
175
+ }).format(e);
55
176
  },
56
177
  dateTime: (t) => {
57
- var r;
58
- if (!t || t === "0000-00-00" || !m(t)) return "Nunca";
59
- const n = new Date(t), o = c.current, e = o.locale;
60
- return new Intl.DateTimeFormat(e, {
178
+ var e;
179
+ if (!t || t === "0000-00-00" || !T(t)) return "Nunca";
180
+ const n = new Date(t), r = l.current, o = r.locale;
181
+ return new Intl.DateTimeFormat(o, {
61
182
  weekday: "short",
62
183
  day: "2-digit",
63
184
  month: "short",
@@ -66,29 +187,29 @@ const i = {
66
187
  minute: "2-digit",
67
188
  second: "2-digit",
68
189
  hourCycle: "h23",
69
- ...(r = o.date) == null ? void 0 : r.dateTimeFormat
190
+ ...(e = r.date) == null ? void 0 : e.dateTimeFormat
70
191
  }).format(n);
71
192
  },
72
- secondsToTime: (t) => d(t ?? 0)
193
+ secondsToTime: (t) => I(t ?? 0)
73
194
  };
74
- function f(t, n) {
75
- return !t || !n ? t : n.split(".").reduce((o, e) => o == null ? void 0 : o[e], t);
195
+ function x(t, n) {
196
+ return !t || !n ? t : n.split(".").reduce((r, o) => r == null ? void 0 : r[o], t);
76
197
  }
77
- function d(t) {
78
- const n = Math.floor(t / 3600), o = Math.floor(t % 3600 / 60), e = t % 60;
79
- return `${n} horas, ${o} minutos y ${e} segundos`;
198
+ function I(t) {
199
+ const n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), o = t % 60;
200
+ return `${n} horas, ${r} minutos y ${o} segundos`;
80
201
  }
81
- function u(t) {
202
+ function m(t) {
82
203
  if (t != null && !(t === "null" || t === "undefined"))
83
204
  return t;
84
205
  }
85
- function m(t) {
206
+ function T(t) {
86
207
  const n = new Date(t);
87
208
  return !isNaN(n.getTime());
88
209
  }
89
210
  export {
90
- g as formatValue,
91
- i as formatters,
92
- f as getNestedValue,
93
- p as getValue
211
+ L as formatValue,
212
+ u as formatters,
213
+ x as getNestedValue,
214
+ $ as getValue
94
215
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.585",
3
+ "version": "0.1.586",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",