adverich-kun-ui 0.1.480 → 0.1.481

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,69 +1,68 @@
1
- import { ref as w, computed as q, watch as G, nextTick as T } from "vue";
2
- import { format as d, clamp as x, toRawNumberString as D, fromRawString as y } from "./numberFormatUtils.js";
3
- function W(i, s) {
4
- const l = w(""), c = w(null), k = w(null), R = w(!1), m = w(0);
1
+ import { ref as S, computed as q, watch as G, nextTick as y } from "vue";
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);
5
5
  let t = "";
6
6
  const F = q(() => {
7
7
  const e = Number(i.precision);
8
8
  return e > 0 ? e + 1 : 1;
9
9
  });
10
- function h(e) {
10
+ function v(e) {
11
11
  return Number(i.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(F.value, "0");
12
12
  }
13
13
  G(
14
14
  [() => i.modelValue, () => i.precision],
15
15
  ([e, n], [r, u]) => {
16
- const N = Number(n) !== Number(u);
17
16
  if (e == null || isNaN(e))
18
- l.value = d(0, { ...i, precision: n }), t = "0".repeat(Number(n) + 1);
17
+ l.value = h(0, { ...i, precision: n }), t = "0".repeat(Number(n) + 1);
19
18
  else {
20
- const v = parseFloat(e), o = x(v, i.min, i.max);
21
- N && (t = D(o, Number(n))), t.length < Number(n) + 1 && (t = t.padStart(Number(n) + 1, "0")), l.value = d(o, { ...i, precision: n });
19
+ const N = parseFloat(e), g = x(N, i.min, i.max);
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 });
22
21
  }
23
22
  },
24
23
  { immediate: !0 }
25
24
  );
26
25
  function K(e) {
27
- const { key: n, target: r } = e, u = /^[0-9]$/.test(n), N = n === "Backspace", v = n === "Delete", o = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(n), b = e.ctrlKey || e.metaKey, f = n === "Home", U = n === "End";
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";
28
27
  if (n === "Tab")
29
28
  return;
30
- if (f) {
31
- T(() => {
29
+ if (m) {
30
+ y(() => {
32
31
  if (!c.value) return;
33
- const S = l.value.search(/\d/);
34
- c.value.setSelectionRange(S, S);
32
+ const w = l.value.search(/\d/);
33
+ c.value.setSelectionRange(w, w);
35
34
  });
36
35
  return;
37
36
  }
38
37
  if (U) {
39
- T(() => {
38
+ y(() => {
40
39
  if (!c.value) return;
41
40
  const a = l.value;
42
41
  c.value.setSelectionRange(a.length, a.length);
43
42
  });
44
43
  return;
45
44
  }
46
- if (o || b) return;
45
+ if (b || d) return;
47
46
  const V = B(l.value, r.selectionStart);
48
47
  e.preventDefault();
49
48
  const L = Number(i.precision) + 1;
50
49
  for (; t.length < L; )
51
50
  t = "0" + t;
52
- const g = A(l.value, V);
51
+ const f = A(l.value, V);
53
52
  if (u)
54
- t = t.substring(0, g) + n + t.substring(g), m.value = g + 1;
53
+ t = t.substring(0, f) + n + t.substring(f), s.value = f + 1;
55
54
  else if (N && V > 0) {
56
- const a = A(l.value, V), S = a - 1;
55
+ const a = A(l.value, V), w = a - 1;
57
56
  if (t.length <= Number(i.precision) + 1) {
58
57
  const j = Math.max(0, a - 1);
59
- t = t.slice(0, j) + t.slice(a), t = h(t), m.value = a, C();
58
+ t = t.slice(0, j) + t.slice(a), t = v(t), s.value = a, T();
60
59
  return;
61
60
  }
62
- a > 0 && (t = t.slice(0, S) + t.slice(a), t = h(t), m.value = S);
63
- } else v && V < l.value.length && g < t.length && (t = t.substring(0, g) + t.substring(g + 1), m.value = g);
64
- for (t = h(t); t.length < L; )
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; )
65
64
  t = "0" + t;
66
- C();
65
+ T();
67
66
  }
68
67
  function A(e, n) {
69
68
  let r = 0;
@@ -93,45 +92,45 @@ function W(i, s) {
93
92
  const r = e.search(/\d/);
94
93
  return n < r && (n = r), n;
95
94
  }
96
- function C() {
95
+ function T() {
97
96
  const e = Number(i.precision) + 1;
98
97
  t.padStart(e, "0");
99
- 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}`, v = parseFloat(N), o = x(v, i.min, i.max);
100
- t = D(o, Number(i.precision)), l.value = d(o, i), s("update:modelValue", o), s("input", o), T(() => {
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(() => {
101
100
  if (c.value)
102
101
  try {
103
- const b = l.value;
104
- let f = $(b, m.value);
105
- for (; f < b.length && !/\d/.test(b[f]); )
106
- f++;
107
- c.value.setSelectionRange(f, f);
102
+ const d = l.value;
103
+ let m = $(d, s.value);
104
+ for (; m < d.length && !/\d/.test(d[m]); )
105
+ m++;
106
+ c.value.setSelectionRange(m, m);
108
107
  } catch {
109
108
  c.value.setSelectionRange(l.value.length, l.value.length);
110
109
  }
111
110
  });
112
111
  }
113
112
  function E() {
114
- R.value = !1, t = h(t);
115
- const e = y(t, Number(i.precision)), n = x(e, i.min, i.max);
116
- t = D(n, Number(i.precision)), t = h(t), l.value = d(n, i), s("update:modelValue", n), s("blur");
113
+ R.value = !1, t = v(t);
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");
117
116
  }
118
117
  function M() {
119
118
  var n;
120
119
  R.value = !0;
121
120
  const e = ((n = c.value) == null ? void 0 : n.selectionStart) || 0;
122
- m.value = A(l.value, e), s("focus");
121
+ s.value = A(l.value, e), o("focus");
123
122
  }
124
123
  function H() {
125
- let e = y(t, Number(i.precision)) || 0;
126
- e = x(e + Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = d(e, i), s("update:modelValue", e);
124
+ 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);
127
126
  }
128
127
  function I() {
129
- let e = y(t, Number(i.precision)) || 0;
130
- e = x(e - Number(i.step), i.min, i.max), t = D(e, Number(i.precision)), l.value = d(e, i), s("update:modelValue", e);
128
+ 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);
131
130
  }
132
131
  function z() {
133
132
  var e;
134
- t = "0".repeat(Number(i.precision) + 1), m.value = Number(i.precision) + 1, C(), (e = c.value) == null || e.focus();
133
+ t = "0".repeat(Number(i.precision) + 1), s.value = Number(i.precision) + 1, T(), (e = c.value) == null || e.focus();
135
134
  }
136
135
  return {
137
136
  inputValue: l,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.480",
3
+ "version": "0.1.481",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",