adverich-kun-ui 0.1.405 → 0.1.407

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 { useAttrs as re, ref as se, getCurrentInstance as le, computed as a, createElementBlock as l, openBlock as r, mergeProps as E, renderSlot as i, createElementVNode as d, createCommentVNode as u, normalizeClass as b, toDisplayString as y, normalizeProps as S, guardReactiveProps as V, unref as s, createBlock as m, resolveDynamicComponent as h, withKeys as ae, Fragment as ie, renderList as de, withDirectives as ue, vShow as pe, createTextVNode as ce, nextTick as ve } from "vue";
1
+ import { useAttrs as se, ref as re, getCurrentInstance as le, computed as a, createElementBlock as l, openBlock as s, mergeProps as E, renderSlot as i, createElementVNode as d, createCommentVNode as u, normalizeClass as b, toDisplayString as y, normalizeProps as S, guardReactiveProps as V, unref as r, createBlock as m, resolveDynamicComponent as h, withKeys as ae, Fragment as ie, renderList as de, withDirectives as ue, vShow as pe, createTextVNode as ce, nextTick as ve } from "vue";
2
2
  import { kunTextareaProps as fe } from "../composables/KunTextareaProps.js";
3
3
  import ge from "../composables/useKunTextareaComposable.js";
4
4
  import { renderIconSlot as k } from "../../../../utils/renderIcon.js";
@@ -24,8 +24,8 @@ const be = { class: "relative" }, ye = {
24
24
  __name: "KunTextarea",
25
25
  props: { ...fe },
26
26
  emits: ["update:modelValue", "click:clear", "click:control", "update:focused", "mousedown:control"],
27
- setup(F, { expose: G, emit: P }) {
28
- const o = F, C = P, K = re(), p = se(null), N = `textarea-${le().uid}`, {
27
+ setup(F, { expose: P, emit: G }) {
28
+ const o = F, C = G, K = se(), p = re(null), N = `textarea-${le().uid}`, {
29
29
  isFocused: c,
30
30
  internalValue: v,
31
31
  rootRef: B,
@@ -102,7 +102,7 @@ const be = { class: "relative" }, ye = {
102
102
  const { class: e, ...t } = K;
103
103
  return t;
104
104
  });
105
- return G({
105
+ return P({
106
106
  validate: j,
107
107
  reset: H,
108
108
  resetValidation: L,
@@ -113,41 +113,41 @@ const be = { class: "relative" }, ye = {
113
113
  var e;
114
114
  return (e = p.value) == null ? void 0 : e.focus();
115
115
  }
116
- }), (e, t) => (r(), l("div", E({
116
+ }), (e, t) => (s(), l("div", E({
117
117
  class: X.value,
118
118
  ref_key: "rootRef",
119
119
  ref: B
120
120
  }, ne.value), [
121
121
  i(e.$slots, "label", E({ for: N }, ee), () => [
122
- e.label ? (r(), l("label", {
122
+ e.label ? (s(), l("label", {
123
123
  key: 0,
124
124
  class: b(["absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10", A.value || e.placeholder ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"])
125
125
  }, y(e.label), 3)) : u("", !0)
126
126
  ]),
127
127
  d("div", be, [
128
- e.prependIcon || e.$slots.prepend ? (r(), l("div", ye, [
129
- i(e.$slots, "prepend", S(V(s(oe))), () => [
128
+ e.prependIcon || e.$slots.prepend ? (s(), l("div", ye, [
129
+ i(e.$slots, "prepend", S(V(r(oe))), () => [
130
130
  d("div", {
131
131
  onClick: t[0] || (t[0] = (n) => e.handleIconClick(n, "prepend"))
132
132
  }, [
133
- (r(), m(h(s(k)(e.prependIcon))))
133
+ (s(), m(h(r(k)(e.prependIcon))))
134
134
  ])
135
135
  ])
136
136
  ])) : u("", !0),
137
- e.prependInnerIcon || e.$slots["prepend-inner"] ? (r(), l("div", me, [
137
+ e.prependInnerIcon || e.$slots["prepend-inner"] ? (s(), l("div", me, [
138
138
  i(e.$slots, "prepend-inner", {}, () => [
139
139
  d("div", {
140
140
  onClick: t[1] || (t[1] = (n) => e.handleIconClick(n, "prependInner"))
141
141
  }, [
142
- (r(), m(h(s(k)(e.prependInnerIcon))))
142
+ (s(), m(h(r(k)(e.prependInnerIcon))))
143
143
  ])
144
144
  ])
145
145
  ])) : u("", !0),
146
146
  d("textarea", {
147
147
  ref_key: "textareaRef",
148
148
  ref: p,
149
- value: s(v),
150
- rows: e.autoGrow ? 1 : e.rows,
149
+ value: r(v),
150
+ rows: e.rows,
151
151
  disabled: e.disabled,
152
152
  readonly: e.readonly,
153
153
  placeholder: e.placeholder,
@@ -160,39 +160,39 @@ const be = { class: "relative" }, ye = {
160
160
  onClick: t[2] || (t[2] = (n) => e.$emit("click:control", n)),
161
161
  onMousedown: t[3] || (t[3] = (n) => e.$emit("mousedown:control", n))
162
162
  }, null, 42, he),
163
- e.clearable && s(v) ? (r(), l("div", {
163
+ e.clearable && r(v) ? (s(), l("div", {
164
164
  key: 2,
165
165
  class: b(["absolute right-2 top-2", Y.value])
166
166
  }, [
167
167
  i(e.$slots, "clear", S(V(R)), () => [
168
168
  d("button", {
169
169
  type: "button",
170
- onClick: t[4] || (t[4] = (...n) => s(D) && s(D)(...n)),
170
+ onClick: t[4] || (t[4] = (...n) => r(D) && r(D)(...n)),
171
171
  class: "text-gray-500 hover:text-gray-700"
172
172
  }, [
173
- (r(), m(h(s(k)(e.clearIcon))))
173
+ (s(), m(h(r(k)(e.clearIcon))))
174
174
  ])
175
175
  ])
176
176
  ], 2)) : u("", !0),
177
- e.appendInnerIcon || e.$slots["append-inner"] ? (r(), l("div", ke, [
177
+ e.appendInnerIcon || e.$slots["append-inner"] ? (s(), l("div", ke, [
178
178
  i(e.$slots, "append-inner", {}, () => [
179
179
  d("div", {
180
180
  onClick: t[5] || (t[5] = (n) => e.handleIconClick(n, "appendInner"))
181
181
  }, [
182
- (r(), m(h(s(k)(e.appendInnerIcon))))
182
+ (s(), m(h(r(k)(e.appendInnerIcon))))
183
183
  ])
184
184
  ])
185
185
  ])) : u("", !0),
186
- e.appendIcon || e.$slots.append ? (r(), l("div", Ce, [
187
- i(e.$slots, "append", S(V(s(te))), () => [
186
+ e.appendIcon || e.$slots.append ? (s(), l("div", Ce, [
187
+ i(e.$slots, "append", S(V(r(te))), () => [
188
188
  d("div", {
189
189
  onClick: t[6] || (t[6] = (n) => e.handleIconClick(n, "append"))
190
190
  }, [
191
- (r(), m(h(s(k)(e.appendIcon))))
191
+ (s(), m(h(r(k)(e.appendIcon))))
192
192
  ])
193
193
  ])
194
194
  ])) : u("", !0),
195
- e.loading ? (r(), l("div", we, [
195
+ e.loading ? (s(), l("div", we, [
196
196
  i(e.$slots, "loader", {
197
197
  color: e.loadingColor,
198
198
  isActive: !0
@@ -205,12 +205,12 @@ const be = { class: "relative" }, ye = {
205
205
  ])
206
206
  ])
207
207
  ])) : u("", !0),
208
- !e.hideDetails || e.hideDetails === "auto" && (s(w).length || e.hint) ? (r(), l("div", {
208
+ !e.hideDetails || e.hideDetails === "auto" && (r(w).length || e.hint) ? (s(), l("div", {
209
209
  key: 6,
210
- class: b(["text-xs mt-1 space-y-1", { "text-red-500": s(f), "text-gray-500": !s(f) }])
210
+ class: b(["text-xs mt-1 space-y-1", { "text-red-500": r(f), "text-gray-500": !r(f) }])
211
211
  }, [
212
212
  i(e.$slots, "details", {}, () => [
213
- s(f) ? (r(!0), l(ie, { key: 0 }, de(s(w), (n, g) => i(e.$slots, "message", {
213
+ r(f) ? (s(!0), l(ie, { key: 0 }, de(r(w), (n, g) => i(e.$slots, "message", {
214
214
  key: g,
215
215
  message: n
216
216
  }, () => [
@@ -220,19 +220,19 @@ const be = { class: "relative" }, ye = {
220
220
  hint: e.hint
221
221
  }, () => [
222
222
  ue(d("div", null, y(e.hint), 513), [
223
- [pe, e.persistentHint || s(c)]
223
+ [pe, e.persistentHint || r(c)]
224
224
  ])
225
225
  ]) : u("", !0)
226
226
  ])
227
227
  ], 2)) : u("", !0),
228
- W.value ? (r(), l("div", $e, [
228
+ W.value ? (s(), l("div", $e, [
229
229
  i(e.$slots, "counter", {
230
230
  counter: I.value,
231
231
  max: $.value,
232
232
  value: I.value
233
233
  }, () => [
234
234
  ce(y(I.value), 1),
235
- $.value ? (r(), l("span", Re, " / " + y($.value), 1)) : u("", !0)
235
+ $.value ? (s(), l("span", Re, " / " + y($.value), 1)) : u("", !0)
236
236
  ])
237
237
  ])) : u("", !0)
238
238
  ])
@@ -1,8 +1,8 @@
1
- import { ref as l, computed as m, watch as H, nextTick as v, onMounted as R, onBeforeUnmount as T } from "vue";
2
- function q(n, y) {
3
- const i = l(null), r = l(""), c = l(n.modelValue), O = l(!1), s = l([]), f = l(null), d = m(() => n.formatModel === "json" || n.formatModel === "auto" && typeof n.modelValue == "object");
4
- function M(e) {
5
- if (d.value && e != null)
1
+ import { ref as l, computed as y, watch as C, nextTick as f, onMounted as F, onBeforeUnmount as G } from "vue";
2
+ function k(t, M) {
3
+ const d = l(null), a = l(""), g = l(t.modelValue), O = l(!1), i = l([]), S = l(null), h = y(() => t.formatModel === "json" || t.formatModel === "auto" && typeof t.modelValue == "object");
4
+ function V(e) {
5
+ if (h.value && e != null)
6
6
  try {
7
7
  return JSON.stringify(e, null, 2);
8
8
  } catch {
@@ -10,8 +10,8 @@ function q(n, y) {
10
10
  }
11
11
  return e ?? "";
12
12
  }
13
- function S(e) {
14
- if (d.value && typeof e == "string")
13
+ function w(e) {
14
+ if (h.value && typeof e == "string")
15
15
  try {
16
16
  return JSON.parse(e);
17
17
  } catch {
@@ -19,68 +19,72 @@ function q(n, y) {
19
19
  }
20
20
  return e;
21
21
  }
22
- function A(e) {
23
- const t = S(e);
24
- c.value = t, y("update:modelValue", t), y("change", t);
22
+ function E(e) {
23
+ const n = w(e);
24
+ g.value = n, M("update:modelValue", n), M("change", n);
25
25
  }
26
- H(() => n.modelValue, (e) => {
27
- const t = JSON.stringify(e), u = JSON.stringify(c.value);
28
- t !== u && (c.value = e, r.value = M(e), n.autoGrow && v(g));
26
+ C(() => t.modelValue, (e) => {
27
+ const n = JSON.stringify(e), u = JSON.stringify(g.value);
28
+ n !== u && (g.value = e, a.value = V(e), t.autoGrow && f(m));
29
29
  });
30
- function g() {
31
- const e = i.value;
32
- if (!e || !n.autoGrow) return;
33
- const t = e.selectionStart;
34
- e.style.height = "auto", f.value = requestAnimationFrame(() => {
35
- e.style.height = `${Math.min(e.scrollHeight, n.maxHeight || 9999)}px`, e.setSelectionRange(t, t);
30
+ function m() {
31
+ const e = d.value;
32
+ !e || !t.autoGrow || f(() => {
33
+ e.style.height = "auto";
34
+ const n = parseFloat(getComputedStyle(e).lineHeight) || 24, u = Number(t.rows) || 5, r = n * u, o = e.scrollHeight, s = t.maxHeight || 9999, v = Math.min(o, s);
35
+ e.style.height = `${Math.max(r, v)}px`;
36
+ const c = e.selectionStart;
37
+ e.setSelectionRange(c, c);
36
38
  });
37
39
  }
38
- R(() => {
39
- r.value = M(n.modelValue), n.autoGrow && v(g);
40
- }), T(() => {
41
- f.value && cancelAnimationFrame(f.value);
40
+ F(() => {
41
+ a.value = V(t.modelValue), f(() => {
42
+ t.autoGrow && m();
43
+ });
44
+ }), G(() => {
45
+ S.value && cancelAnimationFrame(S.value);
42
46
  });
43
- const V = m(() => {
47
+ const x = y(() => {
44
48
  var e;
45
- return !!(s.value.length || (e = n.errorMessages) != null && e.length);
46
- }), E = m(() => V.value ? [...n.errorMessages || [], ...s.value].slice(0, n.maxErrors) : []);
47
- function I() {
48
- const e = n.rules || [], t = n.required && !r.value ? null : S(r.value), u = [];
49
- for (const o of e) {
50
- const a = typeof o == "function" ? o(t) : o;
51
- Array.isArray(a) ? u.push(...a) : typeof a == "string" ? u.push(a) : a === !1 && u.push("Campo inválido");
49
+ return !!(i.value.length || (e = t.errorMessages) != null && e.length);
50
+ }), I = y(() => x.value ? [...t.errorMessages || [], ...i.value].slice(0, t.maxErrors) : []);
51
+ function b() {
52
+ const e = t.rules || [], n = t.required && !a.value ? null : w(a.value), u = [];
53
+ for (const r of e) {
54
+ const o = typeof r == "function" ? r(n) : r;
55
+ Array.isArray(o) ? u.push(...o) : typeof o == "string" ? u.push(o) : o === !1 && u.push("Campo inválido");
52
56
  }
53
- return s.value = u, u.length === 0;
57
+ return i.value = u, u.length === 0;
54
58
  }
55
- function N() {
56
- s.value = [];
59
+ function j() {
60
+ i.value = [];
57
61
  }
58
- function j(e) {
59
- var x;
60
- if (!d.value || e.key !== "Enter") return;
61
- const t = i.value;
62
- if (!t) return;
63
- const u = t.selectionStart, o = r.value, a = " ", h = o.slice(0, u), F = o.slice(u), G = h.lastIndexOf(`
64
- `) + 1, w = `
65
- ${((x = h.slice(G).match(/^\s*/)) == null ? void 0 : x[0]) ?? ""}${a}`;
66
- r.value = h + w + F, v(() => {
67
- const J = u + w.length;
68
- t.setSelectionRange(J, J);
62
+ function A(e) {
63
+ var J;
64
+ if (!h.value || e.key !== "Enter") return;
65
+ const n = d.value;
66
+ if (!n) return;
67
+ const u = n.selectionStart, r = a.value, o = " ", s = r.slice(0, u), v = r.slice(u), c = s.lastIndexOf(`
68
+ `) + 1, H = `
69
+ ${((J = s.slice(c).match(/^\s*/)) == null ? void 0 : J[0]) ?? ""}${o}`;
70
+ a.value = s + H + v, f(() => {
71
+ const N = u + H.length;
72
+ n.setSelectionRange(N, N);
69
73
  }), e.preventDefault();
70
74
  }
71
75
  return {
72
- inputRef: i,
73
- internalValue: r,
76
+ inputRef: d,
77
+ internalValue: a,
74
78
  isFocused: O,
75
- hasError: V,
76
- displayedMessages: E,
77
- validate: I,
78
- resetValidation: N,
79
- updateModel: A,
80
- adjustHeight: g,
81
- handleJsonEnter: j
79
+ hasError: x,
80
+ displayedMessages: I,
81
+ validate: b,
82
+ resetValidation: j,
83
+ updateModel: E,
84
+ adjustHeight: m,
85
+ handleJsonEnter: A
82
86
  };
83
87
  }
84
88
  export {
85
- q as default
89
+ k as default
86
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.405",
3
+ "version": "0.1.407",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",