adverich-kun-ui 0.1.613 → 0.1.614

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,10 +1,7 @@
1
- import { ref as f, watch as E, computed as m, openBlock as l, createElementBlock as o, toDisplayString as a, createCommentVNode as i, createElementVNode as y, mergeProps as M, renderSlot as b, unref as k, withModifiers as K, Fragment as P, renderList as j, createTextVNode as D } from "vue";
1
+ import { ref as h, watch as M, computed as f, openBlock as l, createElementBlock as o, normalizeClass as K, toDisplayString as a, createCommentVNode as u, createElementVNode as y, mergeProps as L, renderSlot as b, unref as k, withModifiers as P, Fragment as j, renderList as x, createTextVNode as D } from "vue";
2
2
  import { renderIconSlot as g } from "../../../../utils/renderIcon.js";
3
3
  import { kunFileInputProps as G } from "../composables/kunFileInputProps.js";
4
- const L = { class: "relative w-full" }, T = {
5
- key: 0,
6
- class: "block text-sm font-medium mb-1"
7
- }, q = { key: 0 }, H = ["multiple", "disabled"], J = { class: "flex-1 truncate" }, O = { key: 0 }, Q = {
4
+ const T = { class: "relative flex w-full flex-col" }, q = { key: 0 }, H = ["multiple", "disabled"], J = { class: "flex-1 truncate" }, O = { key: 0 }, Q = {
8
5
  key: 1,
9
6
  class: "text-gray-400"
10
7
  }, U = { key: 0 }, W = { key: 0 }, X = { key: 1 }, Y = {
@@ -13,13 +10,13 @@ const L = { class: "relative w-full" }, T = {
13
10
  }, Z = {
14
11
  key: 0,
15
12
  class: "text-red-500"
16
- }, x = {
13
+ }, ee = {
17
14
  key: 1,
18
15
  class: "text-gray-500"
19
- }, ee = {
16
+ }, te = {
20
17
  key: 2,
21
18
  class: "mt-1 text-xs text-gray-400 text-right"
22
- }, te = { key: 0 }, re = {
19
+ }, le = { key: 0 }, re = {
23
20
  __name: "KunFileInput",
24
21
  props: G,
25
22
  emits: [
@@ -28,64 +25,70 @@ const L = { class: "relative w-full" }, T = {
28
25
  "click:control",
29
26
  "update:focused"
30
27
  ],
31
- setup(w, { expose: S, emit: $ }) {
32
- const u = w, c = $, B = f(null), v = f(!1), d = f([]), r = f([]);
33
- E(
34
- () => u.modelValue,
28
+ setup(_, { expose: S, emit: $ }) {
29
+ const i = _, c = $, B = h(null), v = h(!1), d = h([]), n = h([]);
30
+ M(
31
+ () => i.modelValue,
35
32
  (e) => {
36
33
  d.value = Array.isArray(e) ? e : e ? [e] : [];
37
34
  },
38
35
  { immediate: !0 }
39
36
  );
40
- function C(e) {
37
+ function z(e) {
41
38
  const t = e.target.files;
42
39
  if (!t) return;
43
40
  const s = Array.from(t);
44
- d.value = u.multiple ? s : [s[0]], c("update:modelValue", u.multiple ? s : s[0]), I();
41
+ d.value = i.multiple ? s : [s[0]], c("update:modelValue", i.multiple ? s : s[0]), I();
45
42
  }
46
43
  function V() {
47
- d.value = [], c("update:modelValue", u.multiple ? [] : null), c("click:clear"), r.value = [];
44
+ d.value = [], c("update:modelValue", i.multiple ? [] : null), c("click:clear"), n.value = [];
48
45
  }
49
- function N() {
46
+ function C() {
50
47
  v.value = !0, c("update:focused", !0);
51
48
  }
52
- function z() {
49
+ function A() {
53
50
  v.value = !1, c("update:focused", !1);
54
51
  }
55
- const p = m(() => d.value.map((e) => e.name)), F = m(() => d.value.reduce((e, t) => e + t.size, 0)), _ = m(() => {
56
- const e = F.value, t = u.showSize === 1024 ? 1024 : 1e3, s = ["B", "KB", "MB", "GB"];
57
- let n = 0, h = e;
58
- for (; h >= t && n < s.length - 1; )
59
- h /= t, n++;
60
- return `${h.toFixed(1)} ${s[n]}`;
52
+ const p = f(() => d.value.map((e) => e.name)), N = f(() => i.dirty || v.value || p.value.length > 0), F = f(() => d.value.reduce((e, t) => e + t.size, 0)), w = f(() => {
53
+ const e = F.value, t = i.showSize === 1024 ? 1024 : 1e3, s = ["B", "KB", "MB", "GB"];
54
+ let r = 0, m = e;
55
+ for (; m >= t && r < s.length - 1; )
56
+ m /= t, r++;
57
+ return `${m.toFixed(1)} ${s[r]}`;
61
58
  });
62
59
  async function I(e = !1) {
63
60
  const t = [];
64
- for (const s of u.rules) {
65
- const n = typeof s == "function" ? s(u.multiple ? d.value : d.value[0]) : !0;
66
- typeof n == "string" ? t.push(n) : n === !1 && t.push("Valor inválido");
61
+ for (const s of i.rules) {
62
+ const r = typeof s == "function" ? s(i.multiple ? d.value : d.value[0]) : !0;
63
+ typeof r == "string" ? t.push(r) : r === !1 && t.push("Valor inválido");
67
64
  }
68
- return r.value = t, !e && t.length && c("update:focused", !0), t;
65
+ return n.value = t, !e && t.length && c("update:focused", !0), t;
69
66
  }
70
- async function A() {
67
+ async function R() {
71
68
  V();
72
69
  }
73
- async function R() {
74
- r.value = [];
70
+ async function E() {
71
+ n.value = [];
75
72
  }
76
73
  return S({
77
- reset: A,
78
- resetValidation: R,
74
+ reset: R,
75
+ resetValidation: E,
79
76
  validate: I,
80
- isValid: m(() => r.value.length === 0),
81
- errorMessages: r
82
- }), (e, t) => (l(), o("div", L, [
83
- e.label ? (l(), o("label", T, a(e.label), 1)) : i("", !0),
84
- y("div", M({
77
+ isValid: f(() => n.value.length === 0),
78
+ errorMessages: n
79
+ }), (e, t) => (l(), o("div", T, [
80
+ e.label ? (l(), o("label", {
81
+ key: 0,
82
+ class: K([
83
+ "absolute left-2 z-10 px-1 text-black/80 transition-all duration-200 ease-in-out pointer-events-none select-none dark:text-white/80",
84
+ N.value ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"
85
+ ])
86
+ }, a(e.label), 3)) : u("", !0),
87
+ y("div", L({
85
88
  class: ["flex items-center gap-2 rounded px-3 py-2 cursor-pointer transition", [
86
89
  e.variant === "outlined" ? "border border-slate-400 dark:border-slate-600" : e.variant === "solo" ? "border-slate-400 dark:border-slate-600 shadow-inner" : "bg-surface border border-slate-400 dark:border-slate-600",
87
90
  e.disabled ? "border-slate-400 dark:border-slate-600 cursor-not-allowed" : "hover:border-blue-500",
88
- e.error || r.value.length ? "border-red-500" : "",
91
+ e.error || n.value.length ? "border-red-500" : "",
89
92
  v.value ? "ring-2 ring-blue-500" : ""
90
93
  ]]
91
94
  }, e.$attrs, {
@@ -93,11 +96,11 @@ const L = { class: "relative w-full" }, T = {
93
96
  var s;
94
97
  return (s = B.value) == null ? void 0 : s.click();
95
98
  }),
96
- onFocusin: N,
97
- onFocusout: z
99
+ onFocusin: C,
100
+ onFocusout: A
98
101
  }), [
99
102
  b(e.$slots, "prepend", {}, () => [
100
- e.prependIcon ? (l(), o("span", q, a(k(g)(e.prependIcon)), 1)) : i("", !0)
103
+ e.prependIcon ? (l(), o("span", q, a(k(g)(e.prependIcon)), 1)) : u("", !0)
101
104
  ]),
102
105
  y("input", {
103
106
  ref_key: "inputRef",
@@ -106,37 +109,37 @@ const L = { class: "relative w-full" }, T = {
106
109
  class: "hidden",
107
110
  multiple: e.multiple,
108
111
  disabled: e.disabled,
109
- onChange: C
112
+ onChange: z
110
113
  }, null, 40, H),
111
114
  y("div", J, [
112
115
  b(e.$slots, "selection", {
113
116
  fileNames: p.value,
114
117
  totalBytes: F.value,
115
- totalBytesReadable: _.value
118
+ totalBytesReadable: w.value
116
119
  }, () => [
117
120
  p.value.length ? (l(), o("span", O, a(p.value.join(", ")), 1)) : (l(), o("span", Q, "Seleccionar archivo"))
118
121
  ])
119
122
  ]),
120
123
  b(e.$slots, "append", {}, () => [
121
- e.appendIcon ? (l(), o("span", U, a(k(g)(e.appendIcon)), 1)) : i("", !0)
124
+ e.appendIcon ? (l(), o("span", U, a(k(g)(e.appendIcon)), 1)) : u("", !0)
122
125
  ]),
123
126
  e.clearable && p.value.length ? (l(), o("button", {
124
127
  key: 0,
125
- onClick: K(V, ["stop"]),
126
- class: "text-gray-500 hover:text-red-500"
128
+ onClick: P(V, ["stop"]),
129
+ class: "cursor-pointer text-gray-500 hover:text-red-500"
127
130
  }, [
128
131
  e.clearIcon ? (l(), o("span", W, a(k(g)(e.clearIcon)), 1)) : (l(), o("span", X, "✕"))
129
- ])) : i("", !0)
132
+ ])) : u("", !0)
130
133
  ], 16),
131
- e.hint || r.value.length ? (l(), o("div", Y, [
132
- r.value.length ? (l(), o("div", Z, [
133
- (l(!0), o(P, null, j(r.value, (s, n) => (l(), o("div", { key: n }, a(s), 1))), 128))
134
- ])) : e.hint ? (l(), o("div", x, a(e.hint), 1)) : i("", !0)
135
- ])) : i("", !0),
136
- e.counter ? (l(), o("div", ee, [
134
+ e.hint || n.value.length ? (l(), o("div", Y, [
135
+ n.value.length ? (l(), o("div", Z, [
136
+ (l(!0), o(j, null, x(n.value, (s, r) => (l(), o("div", { key: r }, a(s), 1))), 128))
137
+ ])) : e.hint ? (l(), o("div", ee, a(e.hint), 1)) : u("", !0)
138
+ ])) : u("", !0),
139
+ e.counter ? (l(), o("div", te, [
137
140
  D(a(e.counterString ?? `${p.value.length} archivo(s)`) + " ", 1),
138
- e.showSize ? (l(), o("span", te, " — " + a(_.value), 1)) : i("", !0)
139
- ])) : i("", !0)
141
+ e.showSize ? (l(), o("span", le, " — " + a(w.value), 1)) : u("", !0)
142
+ ])) : u("", !0)
140
143
  ]));
141
144
  }
142
145
  };
@@ -5,6 +5,10 @@ const e = {
5
5
  chips: Boolean,
6
6
  showSize: [Boolean, Number],
7
7
  label: String,
8
+ dirty: {
9
+ type: Boolean,
10
+ default: !0
11
+ },
8
12
  disabled: Boolean,
9
13
  error: Boolean,
10
14
  errorMessages: [String, Array],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.613",
3
+ "version": "0.1.614",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",