adverich-kun-ui 0.1.527 → 0.1.529

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,11 +1,11 @@
1
- import { ref as d, computed as M, watch as H, nextTick as F } from "vue";
2
- import { isArray as S, isObject as O, fullCopy as L } from "../../../../utils/utils.js";
1
+ import { ref as d, computed as F, watch as L, nextTick as N } from "vue";
2
+ import { isArray as S, isObject as O, fullCopy as x } from "../../../../utils/utils.js";
3
3
  function U(t, y, c, v) {
4
- const l = d(null), b = d(null), x = d(null), i = d(!1), g = d(""), N = (e, n) => {
4
+ const l = d(null), b = d(null), T = d(null), i = d(!1), g = d(""), B = (e, n) => {
5
5
  if (t.returnObject) return s(e, t.itemTitle);
6
6
  const u = l.value.find((f) => f[t.itemValue] === e);
7
7
  return s(u, t.itemTitle);
8
- }, B = M(() => l.value !== null && l.value !== void 0 ? S(l.value) ? l.value.length ? s(l.value, t.itemTitle, "hasDefault") : t.placeholderText : O(l.value) ? s(l.value, t.itemTitle, "hasDefault") : l.value.toString() : v.value.length ? t.placeholderText : t.textNoItems), R = M(() => {
8
+ }, R = F(() => l.value !== null && l.value !== void 0 ? S(l.value) ? l.value.length ? s(l.value, t.itemTitle, "hasDefault") : t.placeholderText : O(l.value) ? s(l.value, t.itemTitle, "hasDefault") : l.value.toString() : v.value.length ? t.placeholderText : t.textNoItems), C = F(() => {
9
9
  const e = t.itemText;
10
10
  return typeof e == "string" && e.includes(",") ? e.split(",") : e;
11
11
  });
@@ -40,73 +40,73 @@ function U(t, y, c, v) {
40
40
  }
41
41
  return S(e) ? t.returnObject ? e.map((r) => r[n]).join(" - ") : e.map((r) => r).join(" - ") : u && typeof e != "number" ? e.includes(",") ? e.split(",") : e : ((f = e == null ? void 0 : e.toString) == null ? void 0 : f.call(e)) ?? "";
42
42
  }
43
- function C(e) {
43
+ function D(e) {
44
44
  try {
45
45
  let n = null;
46
- if (l.value = L(e), !t.multiple)
47
- t.returnObject ? n = e : O(e) ? t.itemValue ? n = e[t.itemValue] : n = Object.values(e)[0] : n = e, i.value = !1, j();
48
- else if (T(e)) {
49
- e && I(e);
46
+ if (l.value = x(e), !t.multiple)
47
+ t.returnObject ? n = x(e) : O(e) ? t.itemValue ? n = e[t.itemValue] : n = Object.values(e)[0] : n = e, i.value = !1, j();
48
+ else if (I(e)) {
49
+ e && A(e);
50
50
  return;
51
51
  } else {
52
- const u = t.returnObject ? e : O(e) ? t.itemValue ? e[t.itemValue] : Object.values(e)[0] : e;
52
+ const u = t.returnObject ? x(e) : O(e) ? t.itemValue ? e[t.itemValue] : Object.values(e)[0] : e;
53
53
  n = [...c.value || [], u];
54
54
  }
55
55
  c.value === n ? y("update:modelValue", n) : c.value = n, y("selectedItem", l.value);
56
56
  } catch (n) {
57
57
  console.log(n);
58
58
  } finally {
59
- F(() => {
60
- A();
59
+ N(() => {
60
+ k();
61
61
  });
62
62
  }
63
63
  }
64
- H(
64
+ L(
65
65
  [() => c.value, () => v.value],
66
66
  ([e]) => {
67
- const n = D(e);
67
+ const n = J(e);
68
68
  JSON.stringify(l.value) !== JSON.stringify(n) && (l.value = n);
69
69
  },
70
70
  { immediate: !0 }
71
71
  );
72
- function D(e) {
72
+ function J(e) {
73
73
  return e == null ? null : t.multiple && Array.isArray(e) ? t.returnObject ? e : e.map((u) => v.value.find((f) => f[t.itemValue] === u)).filter(Boolean) : t.returnObject ? e : v.value.find(
74
74
  (u) => typeof u == "object" ? u[t.itemValue] === e : u === e
75
75
  ) ?? e;
76
76
  }
77
- function T(e) {
77
+ function I(e) {
78
78
  if (!c.value || !e) return !1;
79
79
  const n = t.returnObject ? e : e[t.itemValue];
80
80
  return c.value.some((u) => u === n);
81
81
  }
82
- function I(e) {
82
+ function A(e) {
83
83
  const n = t.returnObject ? e : e[t.itemValue];
84
84
  c.value = c.value.filter((u) => u !== n);
85
85
  }
86
- function A(e) {
87
- t.clearSearchOnSelect && (g.value = ""), t.clearOnSelect && E(), t.focusOnSelect && j();
86
+ function k(e) {
87
+ t.clearSearchOnSelect && (g.value = ""), t.clearOnSelect && M(), t.focusOnSelect && j();
88
88
  }
89
- function k() {
89
+ function w() {
90
90
  i.value || (i.value = !0);
91
91
  }
92
- function J() {
92
+ function V() {
93
93
  i.value && (i.value = !1);
94
94
  }
95
- function V() {
95
+ function K() {
96
96
  i.value = !i.value;
97
97
  }
98
- function w(e) {
98
+ function E(e) {
99
99
  return e.length === 1 && e.match(/\w/);
100
100
  }
101
101
  function j() {
102
102
  b.value.inputField.focus();
103
103
  }
104
- function K() {
105
- i.value = !0, x.value && b.value.$el.focus();
104
+ function $() {
105
+ i.value = !0, T.value && b.value.$el.focus();
106
106
  }
107
- function $(e) {
107
+ function q(e) {
108
108
  const n = e.key;
109
- (w(n) || n === "Backspace") && (k(), j(), F(() => {
109
+ (E(n) || n === "Backspace") && (w(), j(), N(() => {
110
110
  var f;
111
111
  const u = (f = b.value) == null ? void 0 : f.inputField;
112
112
  if (u) {
@@ -115,43 +115,43 @@ function U(t, y, c, v) {
115
115
  }
116
116
  }));
117
117
  }
118
- function q() {
118
+ function z() {
119
119
  i.value = !1, y("createItem");
120
120
  }
121
- function z(e) {
121
+ function G(e) {
122
122
  let n = c.value.indexOf(e);
123
123
  c.value.splice(n, 1);
124
124
  }
125
- function E() {
125
+ function M() {
126
126
  g.value !== "" && (g.value = ""), c.value !== null && (c.value = null), l.value !== null && (l.value = null);
127
127
  }
128
- function G(e) {
128
+ function H(e) {
129
129
  return !!e.disabled;
130
130
  }
131
131
  return {
132
132
  selectedItem: l,
133
133
  textFieldRef: b,
134
- listRef: x,
134
+ listRef: T,
135
135
  menuModel: i,
136
136
  search: g,
137
- getArrayText: N,
138
- placeholder: B,
139
- textArr: R,
137
+ getArrayText: B,
138
+ placeholder: R,
139
+ textArr: C,
140
140
  itemToString: s,
141
- getSelectedItem: C,
142
- checkIfValueExist: T,
143
- removeFromArray: I,
144
- lightReset: A,
145
- openMenu: k,
146
- closeMenu: J,
147
- toggleMenu: V,
148
- focusOnMenu: K,
149
- onMenuKeydown: $,
150
- createItem: q,
151
- removeItem: z,
152
- clearSelection: E,
153
- checkDisabled: G,
154
- isAlphanumeric: w
141
+ getSelectedItem: D,
142
+ checkIfValueExist: I,
143
+ removeFromArray: A,
144
+ lightReset: k,
145
+ openMenu: w,
146
+ closeMenu: V,
147
+ toggleMenu: K,
148
+ focusOnMenu: $,
149
+ onMenuKeydown: q,
150
+ createItem: z,
151
+ removeItem: G,
152
+ clearSelection: M,
153
+ checkDisabled: H,
154
+ isAlphanumeric: E
155
155
  };
156
156
  }
157
157
  export {
@@ -1,4 +1,4 @@
1
- import { useAttrs as oe, ref as re, getCurrentInstance as te, computed as a, createElementBlock as l, openBlock as r, mergeProps as M, renderSlot as d, createElementVNode as i, createCommentVNode as u, normalizeClass as b, toDisplayString as g, normalizeProps as R, guardReactiveProps as z, unref as t, createBlock as y, resolveDynamicComponent as m, Fragment as ne, renderList as se, withDirectives as le, vShow as ae, createTextVNode as de } from "vue";
1
+ import { useAttrs as oe, ref as re, getCurrentInstance as ne, computed as d, createElementBlock as l, openBlock as r, mergeProps as M, renderSlot as i, createElementVNode as p, createCommentVNode as a, normalizeClass as b, toDisplayString as g, normalizeProps as R, guardReactiveProps as z, unref as n, createBlock as y, resolveDynamicComponent as m, Fragment as te, renderList as se, withDirectives as le, vShow as ae, createTextVNode as de } from "vue";
2
2
  import { kunTextareaProps as ie } from "../composables/KunTextareaProps.js";
3
3
  import ue from "../composables/useKunTextareaComposable.js";
4
4
  import { renderIconSlot as h } from "../../../../utils/renderIcon.js";
@@ -26,7 +26,7 @@ const ce = { class: "relative" }, ve = {
26
26
  props: { ...ie },
27
27
  emits: ["update:modelValue", "click:clear", "click:control", "update:focused", "mousedown:control"],
28
28
  setup(A, { expose: D, emit: F }) {
29
- const o = A, k = F, G = oe(), p = re(null), B = `textarea-${te().uid}`, {
29
+ const o = A, k = F, G = oe(), u = re(null), B = `textarea-${ne().uid}`, {
30
30
  isFocused: c,
31
31
  internalValue: v,
32
32
  updateModel: P,
@@ -37,7 +37,7 @@ const ce = { class: "relative" }, ve = {
37
37
  hasError: f,
38
38
  displayedMessages: C,
39
39
  adjustHeight: H
40
- } = ue(o, k, p), L = (e) => {
40
+ } = ue(o, k, u), L = (e) => {
41
41
  v.value = e.target.value, j(e.target.value), o.autoGrow && H();
42
42
  }, j = pe((e) => {
43
43
  P(e);
@@ -45,9 +45,9 @@ const ce = { class: "relative" }, ve = {
45
45
  c.value = !0, k("update:focused", !0);
46
46
  }, U = () => {
47
47
  c.value = !1, k("update:focused", !1);
48
- }, V = a(() => c.value || !!v.value || o.dirty), w = a(() => typeof v.value == "string" ? v.value.length : 0), I = a(() => o.counter === !0 ? 25 : o.counter || null), q = a(() => o.persistentCounter || o.counter && c.value), J = a(() => ["relative w-full flex flex-col", o.class, o.wrapperClass]), O = a(
48
+ }, V = d(() => c.value || !!v.value || o.dirty), w = d(() => typeof v.value == "string" ? v.value.length : 0), I = d(() => o.counter === !0 ? 25 : o.counter || null), q = d(() => o.persistentCounter || o.counter && c.value), J = d(() => ["relative w-full flex flex-col", o.class, o.wrapperClass]), O = d(
49
49
  () => o.persistentClear ? "opacity-100" : "hover:opacity-100 opacity-0 transition-opacity duration-200"
50
- ), Q = a(() => {
50
+ ), Q = d(() => {
51
51
  const e = o.bgColor ? "" : o.variant === "filled" ? "bg-field-background" : "";
52
52
  switch (o.variant) {
53
53
  case "filled":
@@ -61,9 +61,9 @@ const ce = { class: "relative" }, ve = {
61
61
  default:
62
62
  return "";
63
63
  }
64
- }), W = a(
64
+ }), W = d(
65
65
  () => o.density === "compact" ? "p-1" : o.density === "comfortable" ? "p-2" : "p-3"
66
- ), X = a(() => [
66
+ ), X = d(() => [
67
67
  "w-full resize-none p-2 transition-colors duration-150",
68
68
  o.inputClass,
69
69
  {
@@ -87,78 +87,78 @@ const ce = { class: "relative" }, ve = {
87
87
  label: o.label,
88
88
  isFocused: c,
89
89
  isActive: V,
90
- controlRef: p,
90
+ controlRef: u,
91
91
  focus: () => {
92
92
  var e;
93
- return (e = p.value) == null ? void 0 : e.focus();
93
+ return (e = u.value) == null ? void 0 : e.focus();
94
94
  },
95
95
  blur: () => {
96
96
  var e;
97
- return (e = p.value) == null ? void 0 : e.blur();
97
+ return (e = u.value) == null ? void 0 : e.blur();
98
98
  },
99
99
  props: o
100
100
  }, $ = {
101
101
  isActive: !!v.value,
102
102
  isFocused: c,
103
- controlRef: p,
103
+ controlRef: u,
104
104
  focus: () => {
105
105
  var e;
106
- return (e = p.value) == null ? void 0 : e.focus();
106
+ return (e = u.value) == null ? void 0 : e.focus();
107
107
  },
108
108
  blur: () => {
109
109
  var e;
110
- return (e = p.value) == null ? void 0 : e.blur();
110
+ return (e = u.value) == null ? void 0 : e.blur();
111
111
  },
112
112
  props: o
113
- }, Z = $, x = $, _ = a(() => {
114
- const { class: e, ...n } = G;
115
- return n;
113
+ }, Z = $, x = $, _ = d(() => {
114
+ const { class: e, ...t } = G;
115
+ return t;
116
116
  });
117
117
  return D({
118
118
  validate: T,
119
119
  reset: E,
120
120
  resetValidation: N,
121
121
  errorMessages: C,
122
- isValid: a(() => !f.value),
122
+ isValid: d(() => !f.value),
123
123
  focus: () => {
124
124
  var e;
125
- return (e = p.value) == null ? void 0 : e.focus();
125
+ return (e = u.value) == null ? void 0 : e.focus();
126
126
  },
127
- rootRef: p
128
- }), (e, n) => (r(), l("div", M({
127
+ rootRef: u
128
+ }), (e, t) => (r(), l("div", M({
129
129
  class: J.value,
130
130
  ref: "rootRef"
131
131
  }, _.value), [
132
- d(e.$slots, "label", M({ for: B }, Y), () => [
132
+ i(e.$slots, "label", M({ for: B }, Y), () => [
133
133
  e.label ? (r(), l("label", {
134
134
  key: 0,
135
135
  for: B,
136
136
  class: b(["absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10", V.value || e.placeholder ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"])
137
- }, g(e.label), 3)) : u("", !0)
137
+ }, g(e.label), 3)) : a("", !0)
138
138
  ]),
139
- i("div", ce, [
139
+ p("div", ce, [
140
140
  e.prependIcon || e.$slots.prepend ? (r(), l("div", ve, [
141
- d(e.$slots, "prepend", R(z(t(Z))), () => [
142
- i("div", {
143
- onClick: n[0] || (n[0] = (s) => e.handleIconClick(s, "prepend"))
141
+ i(e.$slots, "prepend", R(z(n(Z))), () => [
142
+ p("div", {
143
+ onClick: t[0] || (t[0] = (s) => e.handleIconClick(s, "prepend"))
144
144
  }, [
145
- (r(), y(m(t(h)(e.prependIcon))))
145
+ (r(), y(m(n(h)(e.prependIcon))))
146
146
  ])
147
147
  ])
148
- ])) : u("", !0),
148
+ ])) : a("", !0),
149
149
  e.prependInnerIcon || e.$slots["prepend-inner"] ? (r(), l("div", fe, [
150
- d(e.$slots, "prepend-inner", {}, () => [
151
- i("div", {
152
- onClick: n[1] || (n[1] = (s) => e.handleIconClick(s, "prependInner"))
150
+ i(e.$slots, "prepend-inner", {}, () => [
151
+ p("div", {
152
+ onClick: t[1] || (t[1] = (s) => e.handleIconClick(s, "prependInner"))
153
153
  }, [
154
- (r(), y(m(t(h)(e.prependInnerIcon))))
154
+ (r(), y(m(n(h)(e.prependInnerIcon))))
155
155
  ])
156
156
  ])
157
- ])) : u("", !0),
158
- i("textarea", {
157
+ ])) : a("", !0),
158
+ p("textarea", {
159
159
  ref_key: "textareaRef",
160
- ref: p,
161
- value: t(v),
160
+ ref: u,
161
+ value: n(v),
162
162
  rows: e.autoGrow ? void 0 : e.rows,
163
163
  disabled: e.disabled,
164
164
  readonly: e.readonly,
@@ -166,86 +166,87 @@ const ce = { class: "relative" }, ve = {
166
166
  onInput: L,
167
167
  onFocus: K,
168
168
  onBlur: U,
169
- onClick: n[2] || (n[2] = (s) => e.$emit("click:control", s)),
170
- onMousedown: n[3] || (n[3] = (s) => e.$emit("mousedown:control", s)),
169
+ onClick: t[2] || (t[2] = (s) => e.$emit("click:control", s)),
170
+ onMousedown: t[3] || (t[3] = (s) => e.$emit("mousedown:control", s)),
171
171
  class: b(["bg-field-background", [X.value]]),
172
172
  style: { width: "100%", "box-sizing": "border-box", "overflow-y": "hidden" }
173
173
  }, null, 42, be),
174
- e.clearable && t(v) ? (r(), l("div", {
174
+ e.clearable && n(v) ? (r(), l("div", {
175
175
  key: 2,
176
176
  class: b(["absolute right-2 top-2", O.value])
177
177
  }, [
178
- d(e.$slots, "clear", R(z($)), () => [
179
- i("button", {
178
+ i(e.$slots, "clear", R(z($)), () => [
179
+ e.clearIcon ? (r(), l("button", {
180
+ key: 0,
180
181
  type: "button",
181
- onClick: n[4] || (n[4] = (...s) => t(S) && t(S)(...s)),
182
+ onClick: t[4] || (t[4] = (...s) => n(S) && n(S)(...s)),
182
183
  class: "text-gray-500 hover:text-gray-700"
183
184
  }, [
184
- (r(), y(m(t(h)(e.clearIcon))))
185
- ])
185
+ (r(), y(m(n(h)(e.clearIcon))))
186
+ ])) : a("", !0)
186
187
  ])
187
- ], 2)) : u("", !0),
188
+ ], 2)) : a("", !0),
188
189
  e.appendInnerIcon || e.$slots["append-inner"] ? (r(), l("div", ge, [
189
- d(e.$slots, "append-inner", {}, () => [
190
- i("div", {
191
- onClick: n[5] || (n[5] = (s) => e.handleIconClick(s, "appendInner"))
190
+ i(e.$slots, "append-inner", {}, () => [
191
+ p("div", {
192
+ onClick: t[5] || (t[5] = (s) => e.handleIconClick(s, "appendInner"))
192
193
  }, [
193
- (r(), y(m(t(h)(e.appendInnerIcon))))
194
+ (r(), y(m(n(h)(e.appendInnerIcon))))
194
195
  ])
195
196
  ])
196
- ])) : u("", !0),
197
+ ])) : a("", !0),
197
198
  e.appendIcon || e.$slots.append ? (r(), l("div", ye, [
198
- d(e.$slots, "append", R(z(t(x))), () => [
199
- i("div", {
200
- onClick: n[6] || (n[6] = (s) => e.handleIconClick(s, "append"))
199
+ i(e.$slots, "append", R(z(n(x))), () => [
200
+ p("div", {
201
+ onClick: t[6] || (t[6] = (s) => e.handleIconClick(s, "append"))
201
202
  }, [
202
- (r(), y(m(t(h)(e.appendIcon))))
203
+ (r(), y(m(n(h)(e.appendIcon))))
203
204
  ])
204
205
  ])
205
- ])) : u("", !0),
206
+ ])) : a("", !0),
206
207
  e.loading ? (r(), l("div", me, [
207
- d(e.$slots, "loader", {
208
+ i(e.$slots, "loader", {
208
209
  color: e.loadingColor,
209
210
  isActive: !0
210
211
  }, () => [
211
- i("div", he, [
212
- i("div", {
212
+ p("div", he, [
213
+ p("div", {
213
214
  class: b(["h-full transition-all duration-300", [e.loadingColor]]),
214
215
  style: { width: "100%" }
215
216
  }, null, 2)
216
217
  ])
217
218
  ])
218
- ])) : u("", !0),
219
- !e.hideDetails || e.hideDetails === "auto" && (t(C).length || e.hint) ? (r(), l("div", {
219
+ ])) : a("", !0),
220
+ !e.hideDetails || e.hideDetails === "auto" && (n(C).length || e.hint) ? (r(), l("div", {
220
221
  key: 6,
221
- class: b(["text-xs mt-1 space-y-1", { "text-red-500": t(f), "text-gray-500": !t(f) }])
222
+ class: b(["text-xs mt-1 space-y-1", { "text-red-500": n(f), "text-gray-500": !n(f) }])
222
223
  }, [
223
- d(e.$slots, "details", {}, () => [
224
- t(f) ? (r(!0), l(ne, { key: 0 }, se(t(C), (s, ee) => d(e.$slots, "message", {
224
+ i(e.$slots, "details", {}, () => [
225
+ n(f) ? (r(!0), l(te, { key: 0 }, se(n(C), (s, ee) => i(e.$slots, "message", {
225
226
  key: ee,
226
227
  message: s
227
228
  }, () => [
228
- i("div", null, g(s), 1)
229
- ])), 128)) : e.hint ? d(e.$slots, "hint", {
229
+ p("div", null, g(s), 1)
230
+ ])), 128)) : e.hint ? i(e.$slots, "hint", {
230
231
  key: 1,
231
232
  hint: e.hint
232
233
  }, () => [
233
- le(i("div", null, g(e.hint), 513), [
234
- [ae, e.persistentHint || t(c)]
234
+ le(p("div", null, g(e.hint), 513), [
235
+ [ae, e.persistentHint || n(c)]
235
236
  ])
236
- ]) : u("", !0)
237
+ ]) : a("", !0)
237
238
  ])
238
- ], 2)) : u("", !0),
239
+ ], 2)) : a("", !0),
239
240
  q.value ? (r(), l("div", ke, [
240
- d(e.$slots, "counter", {
241
+ i(e.$slots, "counter", {
241
242
  counter: w.value,
242
243
  max: I.value,
243
244
  value: w.value
244
245
  }, () => [
245
246
  de(g(w.value), 1),
246
- I.value ? (r(), l("span", Ce, " / " + g(I.value), 1)) : u("", !0)
247
+ I.value ? (r(), l("span", Ce, " / " + g(I.value), 1)) : a("", !0)
247
248
  ])
248
- ])) : u("", !0)
249
+ ])) : a("", !0)
249
250
  ])
250
251
  ], 16));
251
252
  }
@@ -56,7 +56,8 @@ const e = {
56
56
  flat: Boolean,
57
57
  color: String,
58
58
  focusRingColor: { type: String, default: "focus:ring-slate-400 dark:focus:ring-slate-600" },
59
- loadingColor: String
59
+ loadingColor: String,
60
+ clearIcon: Boolean
60
61
  };
61
62
  export {
62
63
  e as kunTextareaProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.527",
3
+ "version": "0.1.529",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",