adverich-kun-ui 0.1.183 → 0.1.185

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,7 +1,7 @@
1
- import { ref as L, computed as p, createElementBlock as l, openBlock as s, normalizeClass as f, renderSlot as i, createElementVNode as a, normalizeProps as y, guardReactiveProps as k, unref as n, createCommentVNode as d, toDisplayString as m, createBlock as h, resolveDynamicComponent as $, Fragment as q, renderList as J, withDirectives as O, vShow as Q, createTextVNode as U } from "vue";
1
+ import { ref as L, computed as p, createElementBlock as l, openBlock as s, normalizeClass as f, renderSlot as i, createElementVNode as a, normalizeProps as y, guardReactiveProps as k, unref as n, createCommentVNode as d, toDisplayString as g, createBlock as h, resolveDynamicComponent as C, Fragment as q, renderList as J, withDirectives as O, vShow as Q, createTextVNode as U } from "vue";
2
2
  import { kunTextareaProps as W } from "../composables/KunTextareaProps.js";
3
3
  import { useKunTextarea as X } from "../composables/useKunTextareaComposable.js";
4
- import { renderIconSlot as C } from "../../../../utils/renderIcon.js";
4
+ import { renderIconSlot as $ } from "../../../../utils/renderIcon.js";
5
5
  const Y = {
6
6
  key: 0,
7
7
  class: "block text-sm font-medium mb-1"
@@ -27,8 +27,8 @@ const Y = {
27
27
  __name: "KunTextarea",
28
28
  props: W,
29
29
  emits: ["update:modelValue", "click:clear", "click:control", "update:focused", "mousedown:control"],
30
- setup(R, { expose: B, emit: S }) {
31
- const r = R, V = S, u = L(null), {
30
+ setup(B, { expose: R, emit: S }) {
31
+ const r = B, V = S, u = L(null), {
32
32
  isFocused: v,
33
33
  internalValue: c,
34
34
  updateValue: D,
@@ -40,15 +40,22 @@ const Y = {
40
40
  hasError: b,
41
41
  displayedMessages: w
42
42
  } = X(r, V, u), E = p(() => {
43
+ const e = !!r.bgColor;
43
44
  switch (r.variant) {
44
45
  case "filled":
45
- return "bg-gray-100 dark:bg-gray-900 border border-transparent";
46
+ return [
47
+ e ? "" : "bg-gray-100 dark:bg-gray-900",
48
+ "border border-transparent"
49
+ ];
46
50
  case "outlined":
47
51
  return "border border-gray-300 bg-transparent";
48
52
  case "underlined":
49
53
  return "border-b border-gray-300 bg-transparent rounded-none";
50
54
  case "solo":
51
- return "bg-white dark:bg-black shadow-md border-transparent";
55
+ return [
56
+ e ? "" : "bg-white dark:bg-black",
57
+ "shadow-md border-transparent"
58
+ ];
52
59
  default:
53
60
  return "";
54
61
  }
@@ -84,10 +91,10 @@ const Y = {
84
91
  r.class,
85
92
  r.wrapperClass
86
93
  ]), I = p(() => r.counter === !0 ? 25 : typeof r.counter == "number" || typeof r.counter == "string" ? r.counter : null), H = p(() => r.persistentCounter ? !0 : !!r.counter && v.value), K = p(() => typeof r.clearIcon == "string" ? r.clearIcon : "i-heroicons-x-mark-20-solid");
87
- function g(e, t) {
94
+ function m(e, t) {
88
95
  V(`click:${t}`, e);
89
96
  }
90
- return B({
97
+ return R({
91
98
  validate: M,
92
99
  reset: T,
93
100
  resetValidation: A,
@@ -103,24 +110,24 @@ const Y = {
103
110
  var o;
104
111
  return (o = u.value) == null ? void 0 : o.blur();
105
112
  }, props: r })), () => [
106
- e.label ? (s(), l("label", Y, m(e.label), 1)) : d("", !0)
113
+ e.label ? (s(), l("label", Y, g(e.label), 1)) : d("", !0)
107
114
  ]),
108
115
  a("div", Z, [
109
116
  e.prependIcon || e.$slots.prepend ? (s(), l("div", x, [
110
117
  i(e.$slots, "prepend", y(k(e.prependSlotBindings)), () => [
111
118
  a("div", {
112
- onClick: t[0] || (t[0] = (o) => g(o, "prepend"))
119
+ onClick: t[0] || (t[0] = (o) => m(o, "prepend"))
113
120
  }, [
114
- (s(), h($(n(C)(e.prependIcon))))
121
+ (s(), h(C(n($)(e.prependIcon))))
115
122
  ])
116
123
  ])
117
124
  ])) : d("", !0),
118
125
  e.prependInnerIcon || e.$slots["prepend-inner"] ? (s(), l("div", _, [
119
126
  i(e.$slots, "prepend-inner", {}, () => [
120
127
  a("div", {
121
- onClick: t[1] || (t[1] = (o) => g(o, "prependInner"))
128
+ onClick: t[1] || (t[1] = (o) => m(o, "prependInner"))
122
129
  }, [
123
- (s(), h($(n(C)(e.prependInnerIcon))))
130
+ (s(), h(C(n($)(e.prependInnerIcon))))
124
131
  ])
125
132
  ])
126
133
  ])) : d("", !0),
@@ -170,18 +177,18 @@ const Y = {
170
177
  e.appendInnerIcon || e.$slots["append-inner"] ? (s(), l("div", re, [
171
178
  i(e.$slots, "append-inner", {}, () => [
172
179
  a("div", {
173
- onClick: t[8] || (t[8] = (o) => g(o, "appendInner"))
180
+ onClick: t[8] || (t[8] = (o) => m(o, "appendInner"))
174
181
  }, [
175
- (s(), h($(n(C)(e.appendInnerIcon))))
182
+ (s(), h(C(n($)(e.appendInnerIcon))))
176
183
  ])
177
184
  ])
178
185
  ])) : d("", !0),
179
186
  e.appendIcon || e.$slots.append ? (s(), l("div", oe, [
180
187
  i(e.$slots, "append", y(k(e.appendSlotBindings)), () => [
181
188
  a("div", {
182
- onClick: t[9] || (t[9] = (o) => g(o, "append"))
189
+ onClick: t[9] || (t[9] = (o) => m(o, "append"))
183
190
  }, [
184
- (s(), h($(n(C)(e.appendIcon))))
191
+ (s(), h(C(n($)(e.appendIcon))))
185
192
  ])
186
193
  ])
187
194
  ])) : d("", !0),
@@ -207,12 +214,12 @@ const Y = {
207
214
  key: j,
208
215
  message: o
209
216
  }, () => [
210
- a("div", null, m(o), 1)
217
+ a("div", null, g(o), 1)
211
218
  ])), 128)) : e.hint ? i(e.$slots, "hint", {
212
219
  key: 1,
213
220
  hint: e.hint
214
221
  }, () => [
215
- O(a("div", null, m(e.hint), 513), [
222
+ O(a("div", null, g(e.hint), 513), [
216
223
  [Q, e.persistentHint || n(v)]
217
224
  ])
218
225
  ]) : d("", !0)
@@ -224,8 +231,8 @@ const Y = {
224
231
  max: I.value,
225
232
  value: n(c).length
226
233
  }, () => [
227
- U(m(n(c).length), 1),
228
- I.value ? (s(), l("span", le, " / " + m(I.value), 1)) : d("", !0)
234
+ U(g(n(c).length), 1),
235
+ I.value ? (s(), l("span", le, " / " + g(I.value), 1)) : d("", !0)
229
236
  ])
230
237
  ])) : d("", !0)
231
238
  ])
@@ -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.185",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",