adverich-kun-ui 0.1.183 → 0.1.184

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,15 +1,16 @@
1
1
  const e = {
2
- modelValue: [String, Number],
2
+ modelValue: [String, Number, Array, Object, Boolean],
3
+ formatModel: {
4
+ type: String,
5
+ default: "auto"
6
+ // auto | raw | json
7
+ },
3
8
  label: String,
4
9
  placeholder: String,
5
- rows: {
6
- type: [String, Number],
7
- default: 1
8
- },
10
+ rows: { type: [String, Number], default: 1 },
9
11
  autoGrow: Boolean,
10
12
  noResize: Boolean,
11
13
  maxRows: [Number, String],
12
- // 🔧 Agregado
13
14
  clearable: Boolean,
14
15
  clearIcon: {
15
16
  type: [String, Function, Object],
@@ -17,14 +18,8 @@ const e = {
17
18
  },
18
19
  disabled: Boolean,
19
20
  readonly: Boolean,
20
- variant: {
21
- type: String,
22
- default: "filled"
23
- },
24
- density: {
25
- type: String,
26
- default: "default"
27
- },
21
+ variant: { type: String, default: "filled" },
22
+ density: { type: String, default: "default" },
28
23
  // Estilo
29
24
  rounded: [Boolean, String, Number],
30
25
  tile: Boolean,
@@ -60,17 +55,11 @@ const e = {
60
55
  validateOn: String,
61
56
  hint: String,
62
57
  persistentHint: Boolean,
63
- hideDetails: {
64
- type: [Boolean, String],
65
- default: !1
66
- },
58
+ hideDetails: { type: [Boolean, String], default: !1 },
67
59
  persistentCounter: Boolean,
68
60
  // Loader
69
61
  loading: Boolean,
70
- loadingColor: {
71
- type: String,
72
- default: "bg-slate-500"
73
- }
62
+ loadingColor: { type: String, default: "bg-slate-500" }
74
63
  };
75
64
  export {
76
65
  e as kunTextareaProps
@@ -1,58 +1,76 @@
1
- import { ref as i, watch as E, nextTick as m, onMounted as k, computed as y } from "vue";
2
- function F(t, n, h) {
3
- const f = i(!1), s = i(t.modelValue ?? "");
4
- E(() => t.modelValue, (e) => {
5
- s.value = e ?? "", t.autoGrow && m(c);
1
+ import { ref as n, watch as N, nextTick as M, onMounted as T, computed as V } from "vue";
2
+ function k(t, s, l) {
3
+ const h = n(!1), w = n(t.modelValue), g = (e) => {
4
+ if (t.formatModel === "raw") return String(e ?? "");
5
+ if ((t.formatModel === "json" || t.formatModel === "auto") && typeof e == "object" && e !== null)
6
+ try {
7
+ return JSON.stringify(e, null, 2);
8
+ } catch {
9
+ return String(e);
10
+ }
11
+ return String(e ?? "");
12
+ }, m = (e) => {
13
+ if (t.formatModel === "raw") return e;
14
+ try {
15
+ const a = JSON.parse(e);
16
+ if (t.formatModel === "json" || t.formatModel === "auto")
17
+ return a;
18
+ } catch {
19
+ }
20
+ return e;
21
+ }, o = n(g(t.modelValue));
22
+ N(() => t.modelValue, (e) => {
23
+ w.value = e, o.value = g(e), t.autoGrow && M(c);
6
24
  });
7
- const g = (e) => {
8
- s.value = e, n("update:modelValue", e);
9
- }, x = () => {
10
- g(""), n("click:clear");
25
+ const v = (e) => {
26
+ o.value = e;
27
+ const a = m(e);
28
+ s("update:modelValue", a);
29
+ }, H = () => {
30
+ v(""), s("click:clear");
11
31
  }, c = () => {
12
- if (!h.value) return;
13
- const e = h.value;
14
- e.style.height = "auto", e.style.overflowY = "hidden";
15
- const u = e.scrollHeight, d = getComputedStyle(e).lineHeight, o = parseFloat(d) || 24, l = Number(t.maxRows || 0);
16
- if (t.maxRows && l > 0) {
17
- const r = l * o;
18
- e.style.height = Math.min(u, r) + "px";
32
+ if (!l.value) return;
33
+ l.value.style.height = "auto", l.value.style.overflowY = "hidden";
34
+ const e = l.value.scrollHeight, a = parseFloat(getComputedStyle(l.value).lineHeight || "24"), i = Number(t.maxRows || 0);
35
+ if (t.maxRows && i > 0) {
36
+ const u = i * a;
37
+ l.value.style.height = Math.min(e, u) + "px";
19
38
  } else
20
- e.style.height = u + "px";
39
+ l.value.style.height = e + "px";
21
40
  };
22
- k(() => {
23
- t.autoGrow && m(c);
41
+ T(() => {
42
+ t.autoGrow && M(c);
24
43
  });
25
- const a = i([]), V = i(!0), w = (e = !1) => {
26
- const u = t.validationValue ?? s.value, d = t.rules ?? [], o = [];
27
- for (const l of d) {
28
- const r = typeof l == "function" ? l(u) : l;
29
- typeof r == "string" ? o.push(r) : r === !1 && o.push("Campo inválido");
44
+ const r = n([]), S = n(!0), j = (e = !1) => {
45
+ const a = t.validationValue ?? m(o.value), i = t.rules ?? [], u = [];
46
+ for (const d of i) {
47
+ const f = typeof d == "function" ? d(a) : d;
48
+ typeof f == "string" ? u.push(f) : f === !1 && u.push("Campo inválido");
30
49
  }
31
- return a.value = o.slice(0, t.maxErrors ?? 1), e || n("update:focused", f.value), a.value;
32
- }, v = () => {
33
- a.value = [];
34
- }, H = () => {
35
- s.value = "", v(), n("update:modelValue", "");
36
- }, M = y(() => t.error || a.value.length > 0), C = y(() => {
50
+ return r.value = u.slice(0, t.maxErrors ?? 1), e || s("update:focused", h.value), r.value;
51
+ }, y = () => {
52
+ r.value = [];
53
+ }, x = () => {
54
+ o.value = "", y(), s("update:modelValue", "");
55
+ }, C = V(() => t.error || r.value.length > 0), E = V(() => {
37
56
  var e;
38
- return (e = t.errorMessages) != null && e.length ? Array.isArray(t.errorMessages) ? t.errorMessages : [t.errorMessages] : a.value;
57
+ return (e = t.errorMessages) != null && e.length ? Array.isArray(t.errorMessages) ? t.errorMessages : [t.errorMessages] : r.value;
39
58
  });
40
59
  return {
41
- isFocused: f,
42
- internalValue: s,
43
- updateValue: g,
44
- handleClear: x,
60
+ isFocused: h,
61
+ internalValue: o,
62
+ updateValue: v,
63
+ handleClear: H,
45
64
  adjustHeight: c,
46
- // validación
47
- isPristine: V,
48
- validate: w,
49
- reset: H,
50
- resetValidation: v,
51
- validationErrors: a,
52
- hasError: M,
53
- displayedMessages: C
65
+ isPristine: S,
66
+ validate: j,
67
+ reset: x,
68
+ resetValidation: y,
69
+ validationErrors: r,
70
+ hasError: C,
71
+ displayedMessages: E
54
72
  };
55
73
  }
56
74
  export {
57
- F as useKunTextarea
75
+ k as useKunTextarea
58
76
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.183",
3
+ "version": "0.1.184",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",