adverich-kun-ui 0.1.496 → 0.1.497

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,14 +1,14 @@
1
- import { ref as S, computed as q, watch as G, nextTick as y } from "vue";
1
+ import { ref as w, computed as q, watch as G, nextTick as V } from "vue";
2
2
  import { format as h, clamp as x, toRawNumberString as D, fromRawString as C } from "./numberFormatUtils.js";
3
- function W(i, o) {
4
- const l = S(""), c = S(null), k = S(null), R = S(!1), s = S(0);
3
+ function W(i, s) {
4
+ const l = w(""), a = w(null), K = w(null), R = w(!1), o = w(0);
5
5
  let t = "";
6
- const F = q(() => {
6
+ const L = q(() => {
7
7
  const e = Number(i.precision);
8
8
  return e > 0 ? e + 1 : 1;
9
9
  });
10
- function v(e) {
11
- return Number(i.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(F.value, "0");
10
+ function N(e) {
11
+ return Number(i.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(L.value, "0");
12
12
  }
13
13
  G(
14
14
  [() => i.modelValue, () => i.precision],
@@ -16,61 +16,61 @@ function W(i, o) {
16
16
  if (e == null || isNaN(e))
17
17
  l.value = h(0, { ...i, precision: n }), t = "0".repeat(Number(n) + 1);
18
18
  else {
19
- const N = parseFloat(e), g = x(N, i.min, i.max);
19
+ const v = parseFloat(e), g = x(v, i.min, i.max);
20
20
  t = D(g, Number(n)), t.length < Number(n) + 1 && (t = t.padStart(Number(n) + 1, "0")), l.value = h(g, { ...i, precision: n });
21
21
  }
22
22
  },
23
23
  { immediate: !0 }
24
24
  );
25
- function K(e) {
26
- const { key: n, target: r } = e, u = /^[0-9]$/.test(n), N = n === "Backspace", g = n === "Delete", b = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(n), d = e.ctrlKey || e.metaKey, m = n === "Home", U = n === "End";
25
+ function k(e) {
26
+ const { key: n, target: r } = e, u = /^[0-9]$/.test(n), v = n === "Backspace", g = n === "Delete", d = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(n), b = e.ctrlKey || e.metaKey, m = n === "Home", U = n === "End";
27
27
  if (n === "Tab")
28
28
  return;
29
29
  if (m) {
30
- y(() => {
31
- if (!c.value) return;
32
- const w = l.value.search(/\d/);
33
- c.value.setSelectionRange(w, w);
30
+ V(() => {
31
+ if (!a.value) return;
32
+ const S = l.value.search(/\d/);
33
+ a.value.setSelectionRange(S, S);
34
34
  });
35
35
  return;
36
36
  }
37
37
  if (U) {
38
- y(() => {
39
- if (!c.value) return;
40
- const a = l.value;
41
- c.value.setSelectionRange(a.length, a.length);
38
+ V(() => {
39
+ if (!a.value) return;
40
+ const c = l.value;
41
+ a.value.setSelectionRange(c.length, c.length);
42
42
  });
43
43
  return;
44
44
  }
45
- if (b || d) return;
46
- const V = B(l.value, r.selectionStart);
45
+ if (d || b) return;
46
+ const T = $(l.value, r.selectionStart);
47
47
  e.preventDefault();
48
- const L = Number(i.precision) + 1;
49
- for (; t.length < L; )
48
+ const F = Number(i.precision) + 1;
49
+ for (; t.length < F; )
50
50
  t = "0" + t;
51
- const f = A(l.value, V);
51
+ const f = y(l.value, T);
52
52
  if (u)
53
- t = t.substring(0, f) + n + t.substring(f), s.value = f + 1;
54
- else if (N && V > 0) {
55
- const a = A(l.value, V), w = a - 1;
53
+ t = t.substring(0, f) + n + t.substring(f), o.value = f + 1;
54
+ else if (v && T > 0) {
55
+ const c = y(l.value, T), S = c - 1;
56
56
  if (t.length <= Number(i.precision) + 1) {
57
- const j = Math.max(0, a - 1);
58
- t = t.slice(0, j) + t.slice(a), t = v(t), s.value = a, T();
57
+ const j = Math.max(0, c - 1);
58
+ t = t.slice(0, j) + t.slice(c), t = N(t), o.value = c, A();
59
59
  return;
60
60
  }
61
- a > 0 && (t = t.slice(0, w) + t.slice(a), t = v(t), s.value = w);
62
- } else g && V < l.value.length && f < t.length && (t = t.substring(0, f) + t.substring(f + 1), s.value = f);
63
- for (t = v(t); t.length < L; )
61
+ c > 0 && (t = t.slice(0, S) + t.slice(c), t = N(t), o.value = S);
62
+ } else g && T < l.value.length && f < t.length && (t = t.substring(0, f) + t.substring(f + 1), o.value = f);
63
+ for (t = N(t); t.length < F; )
64
64
  t = "0" + t;
65
- T();
65
+ A();
66
66
  }
67
- function A(e, n) {
67
+ function y(e, n) {
68
68
  let r = 0;
69
69
  for (let u = 0; u < n; u++)
70
70
  /\d/.test(e[u]) && r++;
71
71
  return r;
72
72
  }
73
- function $(e, n) {
73
+ function E(e, n) {
74
74
  let r = 0;
75
75
  for (let u = 0; u < e.length; u++)
76
76
  if (/\d/.test(e[u])) {
@@ -83,7 +83,7 @@ function W(i, o) {
83
83
  return u + 1;
84
84
  return e.length;
85
85
  }
86
- function B(e, n) {
86
+ function $(e, n) {
87
87
  for (; n < e.length && !/\d/.test(e[n]); )
88
88
  n++;
89
89
  if (n >= e.length)
@@ -92,53 +92,60 @@ function W(i, o) {
92
92
  const r = e.search(/\d/);
93
93
  return n < r && (n = r), n;
94
94
  }
95
- function T() {
95
+ function A() {
96
96
  const e = Number(i.precision) + 1;
97
97
  t.padStart(e, "0");
98
- const n = Math.max(1, t.length - Number(i.precision)), r = t.slice(0, n) || "0", u = t.slice(n).padEnd(Number(i.precision), "0").slice(0, Number(i.precision)), N = `${r}.${u}`, g = parseFloat(N), b = x(g, i.min, i.max);
99
- t = D(b, Number(i.precision)), l.value = h(b, i), o("update:modelValue", b), o("input", b), y(() => {
100
- if (c.value)
98
+ const n = Math.max(1, t.length - Number(i.precision)), r = t.slice(0, n) || "0", u = t.slice(n).padEnd(Number(i.precision), "0").slice(0, Number(i.precision)), v = `${r}.${u}`, g = parseFloat(v), d = x(g, i.min, i.max);
99
+ t = D(d, Number(i.precision)), l.value = h(d, i), s("update:modelValue", d), s("input", d), V(() => {
100
+ if (a.value)
101
101
  try {
102
- const d = l.value;
103
- let m = $(d, s.value);
104
- for (; m < d.length && !/\d/.test(d[m]); )
102
+ const b = l.value;
103
+ let m = E(b, o.value);
104
+ for (; m < b.length && !/\d/.test(b[m]); )
105
105
  m++;
106
- c.value.setSelectionRange(m, m);
106
+ a.value.setSelectionRange(m, m);
107
107
  } catch {
108
- c.value.setSelectionRange(l.value.length, l.value.length);
108
+ a.value.setSelectionRange(l.value.length, l.value.length);
109
109
  }
110
110
  });
111
111
  }
112
- function E() {
113
- R.value = !1, t = v(t);
112
+ function B() {
113
+ R.value = !1, t = N(t);
114
114
  const e = C(t, Number(i.precision)), n = x(e, i.min, i.max);
115
- t = D(n, Number(i.precision)), t = v(t), l.value = h(n, i), o("update:modelValue", n), o("blur");
115
+ t = D(n, Number(i.precision)), t = N(t), l.value = h(n, i), s("update:modelValue", n), s("blur");
116
116
  }
117
- function M() {
118
- var n;
119
- R.value = !0;
120
- const e = ((n = c.value) == null ? void 0 : n.selectionStart) || 0;
121
- s.value = A(l.value, e), o("focus");
117
+ function M(e) {
118
+ R.value = !0, V(() => {
119
+ var r;
120
+ if (!a.value) return;
121
+ if ((e == null ? void 0 : e.relatedTarget) !== void 0 || ((r = e == null ? void 0 : e.sourceCapabilities) == null ? void 0 : r.firesTouchEvents) === !1) {
122
+ const u = l.value.length;
123
+ a.value.setSelectionRange(u, u), o.value = l.value.replace(/\D/g, "").length;
124
+ } else {
125
+ const u = a.value.selectionStart || 0;
126
+ o.value = y(l.value, u);
127
+ }
128
+ }), s("focus");
122
129
  }
123
130
  function H() {
124
131
  let e = C(t, Number(i.precision)) || 0;
125
- e = x(e + Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), o("update:modelValue", e);
132
+ e = x(e + Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), s("update:modelValue", e);
126
133
  }
127
134
  function I() {
128
135
  let e = C(t, Number(i.precision)) || 0;
129
- e = x(e - Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), o("update:modelValue", e);
136
+ e = x(e - Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = h(e, i), s("update:modelValue", e);
130
137
  }
131
138
  function z() {
132
139
  var e;
133
- t = "0".repeat(Number(i.precision) + 1), s.value = Number(i.precision) + 1, T(), (e = c.value) == null || e.focus();
140
+ t = "0".repeat(Number(i.precision) + 1), o.value = Number(i.precision) + 1, A(), (e = a.value) == null || e.focus();
134
141
  }
135
142
  return {
136
143
  inputValue: l,
137
- numberInput: c,
138
- rootRef: k,
139
- validateKey: K,
144
+ numberInput: a,
145
+ rootRef: K,
146
+ validateKey: k,
140
147
  handleFocus: M,
141
- handleBlur: E,
148
+ handleBlur: B,
142
149
  onIncrement: H,
143
150
  onDecrement: I,
144
151
  onClear: z,
@@ -1,7 +1,7 @@
1
1
  import { ref as a, inject as V, computed as E, watch as g, onUnmounted as T } from "vue";
2
2
  import { debounce as j } from "../../../../utils/utils.js";
3
3
  function R(u, r) {
4
- const l = a(u.modelValue ?? ""), o = a(!1), t = a(""), n = a(!1), F = a(null), h = a(null), s = a(!1), d = V("registerField", null), v = V("unregisterField", null), b = E(() => u.error || !!t.value && n.value), c = async () => {
4
+ const l = a(u.modelValue ?? ""), o = a(!1), t = a(""), n = a(!1), F = a(null), h = a(null), s = a(!1), d = V("registerField", null), v = V("unregisterField", null), y = E(() => u.error || !!t.value && n.value), c = async () => {
5
5
  for (const e of u.rules) {
6
6
  const m = await Promise.resolve(e(l.value));
7
7
  if (m !== !0) return m;
@@ -20,7 +20,7 @@ function R(u, r) {
20
20
  }
21
21
  n.value = !0, r("update:modelValue", l.value), u.validateOnBlur || f();
22
22
  });
23
- const y = (e) => {
23
+ const b = (e) => {
24
24
  l.value = e.target.value;
25
25
  }, w = async () => {
26
26
  if (o.value = !1, u.validateOnBlur) {
@@ -29,7 +29,7 @@ function R(u, r) {
29
29
  }
30
30
  r("blur");
31
31
  }, B = () => {
32
- console.log("deberia hacer el focus"), o.value = !0, r("focus");
32
+ console.log("aaa"), o.value = !0, r("focus");
33
33
  }, I = () => {
34
34
  l.value = "", r("update:modelValue", ""), n.value = !0, u.validateOnBlur || f();
35
35
  }, i = async () => {
@@ -49,8 +49,8 @@ function R(u, r) {
49
49
  rootRef: h,
50
50
  inputFocused: o,
51
51
  validationError: t,
52
- hasError: b,
53
- handleInput: y,
52
+ hasError: y,
53
+ handleInput: b,
54
54
  handleBlur: w,
55
55
  focusInput: B,
56
56
  validate: i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.496",
3
+ "version": "0.1.497",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",