adverich-kun-ui 0.1.523 → 0.1.525

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 { mergeModels as g, ref as v, useModel as D, provide as p, computed as B, onUpdated as C, createElementBlock as M, openBlock as S, mergeProps as I, withModifiers as E, renderSlot as L } from "vue";
1
+ import { mergeModels as g, ref as v, useModel as D, provide as b, computed as h, onUpdated as B, createElementBlock as E, openBlock as I, mergeProps as S, renderSlot as M } from "vue";
2
2
  const R = {
3
3
  __name: "KunList",
4
4
  props: /* @__PURE__ */ g({
@@ -21,15 +21,15 @@ const R = {
21
21
  selectedModifiers: {}
22
22
  }),
23
23
  emits: /* @__PURE__ */ g(["keyDown", "click:select", "update:selected"], ["update:selected"]),
24
- setup(o, { expose: w, emit: b }) {
25
- const c = o, a = b, f = v(null), s = v([]), i = D(o, "selected");
26
- p("registerListItemRef", (e) => {
24
+ setup(o, { expose: p, emit: w }) {
25
+ const c = o, a = w, f = v(null), s = v([]), i = D(o, "selected");
26
+ b("registerListItemRef", (e) => {
27
27
  e ? e.isConnected && !s.value.includes(e) && (s.value.push(e), s.value.sort((t, n) => {
28
28
  const r = t.id ?? "", l = n.id ?? "";
29
29
  return r.localeCompare(l, void 0, { numeric: !0, sensitivity: "base" });
30
30
  })) : s.value = s.value.filter((t) => t && t.isConnected);
31
31
  });
32
- const m = B(() => c.selectable && c.selectionMode === "multiple");
32
+ const m = h(() => c.selectable && c.selectionMode === "multiple");
33
33
  function y(e) {
34
34
  if (!(!c.selectable || e == null))
35
35
  if (m.value) {
@@ -38,20 +38,21 @@ const R = {
38
38
  } else
39
39
  i.value = e;
40
40
  }
41
- C(() => {
41
+ B(() => {
42
42
  s.value = s.value.filter((e) => e && e.isConnected);
43
43
  });
44
- function k(e) {
44
+ function A(e) {
45
45
  var t, n;
46
46
  return !c.selectable || e == null ? !1 : m.value ? (n = (t = i.value) == null ? void 0 : t.includes) == null ? void 0 : n.call(t, e) : i.value === e;
47
47
  }
48
- p("kunListContext", {
48
+ b("kunListContext", {
49
49
  toggleItem: y,
50
- isSelected: k
50
+ isSelected: A
51
51
  });
52
- function A(e) {
52
+ function k(e) {
53
53
  var r;
54
- a("keyDown", e);
54
+ if (a("keyDown", e), ["INPUT", "TEXTAREA"].includes(e.target.tagName) || e.target.isContentEditable)
55
+ return;
55
56
  const t = e.key, n = s.value.filter((l) => l && l.isConnected);
56
57
  if (!(!n.length || !["ArrowUp", "ArrowDown", "Enter"].includes(t))) {
57
58
  if (t === "Enter") {
@@ -61,7 +62,7 @@ const R = {
61
62
  }
62
63
  if (t === "ArrowUp" || t === "ArrowDown") {
63
64
  e.preventDefault();
64
- const l = n.findIndex((x) => x === document.activeElement);
65
+ const l = n.findIndex((C) => C === document.activeElement);
65
66
  let d = -1;
66
67
  l === -1 ? d = t === "ArrowDown" ? 0 : n.length - 1 : t === "ArrowDown" ? d = (l + 1) % n.length : t === "ArrowUp" && (d = (l - 1 + n.length) % n.length);
67
68
  const u = n[d];
@@ -70,17 +71,17 @@ const R = {
70
71
  }
71
72
  }
72
73
  }
73
- function h(e = "ArrowDown") {
74
+ function x(e = "ArrowDown") {
74
75
  var l;
75
76
  const t = s.value.filter(Boolean);
76
77
  if (!t.length) return;
77
78
  const n = e === "ArrowDown" ? 0 : t.length - 1, r = t[n];
78
79
  (l = r == null ? void 0 : r.focus) == null || l.call(r);
79
80
  }
80
- return w({ focusWithKey: h, focus: () => {
81
+ return p({ focusWithKey: x, focus: () => {
81
82
  var e, t;
82
83
  return (t = (e = f.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
83
- } }), (e, t) => (S(), M("ul", I({
84
+ } }), (e, t) => (I(), E("ul", S({
84
85
  ref_key: "ulRef",
85
86
  ref: f,
86
87
  role: "list",
@@ -95,10 +96,10 @@ const R = {
95
96
  }
96
97
  ]],
97
98
  tabindex: "-1",
98
- onKeydown: E(A, ["prevent"]),
99
+ onKeydown: k,
99
100
  onSelect: t[0] || (t[0] = (n) => a("click:select", n.detail))
100
101
  }, e.$attrs), [
101
- L(e.$slots, "default")
102
+ M(e.$slots, "default")
102
103
  ], 16));
103
104
  }
104
105
  };
@@ -1,4 +1,4 @@
1
- import { ref as V, computed as Z, watch as _, nextTick as b } from "vue";
1
+ import { ref as V, computed as Z, watch as _, nextTick as d } from "vue";
2
2
  import { clamp as v, toRawNumberString as k, fromRawString as M } from "./numberFormatUtils.js";
3
3
  function te(n, s) {
4
4
  const r = V(""), o = V(null), T = V(null), w = V(!1), h = V(0);
@@ -7,7 +7,7 @@ function te(n, s) {
7
7
  const e = Number(n.precision);
8
8
  return e > 0 ? e + 1 : 1;
9
9
  });
10
- function d(e, t = 2, l = !1) {
10
+ function b(e, t = 2, l = !1) {
11
11
  if (e == null || isNaN(e)) return "";
12
12
  const u = Number(t), f = Number(e) < 0 ? "-" : "", i = Math.abs(Number(e));
13
13
  let c = k(i, u);
@@ -31,7 +31,7 @@ function te(n, s) {
31
31
  const u = Number(n.precision), f = t.selectionStart || 0;
32
32
  if (u === 0) {
33
33
  let i = l.replace(/[^0-9\-]/g, "");
34
- i = i.replace(/^0+(\d)/, "$1"), r.value = i, b(() => {
34
+ i = i.replace(/^0+(\d)/, "$1"), r.value = i, d(() => {
35
35
  if (!o.value) return;
36
36
  o.value.value = i;
37
37
  const c = Math.min(i.length, f);
@@ -47,7 +47,7 @@ function te(n, s) {
47
47
  const [i, c = ""] = l.split(","), m = c.slice(0, u);
48
48
  l = i + (m.length ? "," + m : ",");
49
49
  }
50
- r.value = l, b(A), b(() => {
50
+ r.value = l, d(A), d(() => {
51
51
  const i = f;
52
52
  t.setSelectionRange(i, i);
53
53
  }), s("input", l);
@@ -62,10 +62,19 @@ function te(n, s) {
62
62
  r.value = "", s("focus");
63
63
  return;
64
64
  }
65
+ if (t === 0) {
66
+ r.value = "", d(() => {
67
+ try {
68
+ o.value.setSelectionRange(0, 0);
69
+ } catch {
70
+ }
71
+ }), s("focus");
72
+ return;
73
+ }
65
74
  let u = k(Math.abs(t), l);
66
75
  const f = u.slice(0, u.length - l) || "0";
67
76
  let i = l > 0 ? u.slice(-l) : "";
68
- l > 0 && (i = i.replace(/0+$/, "")), r.value = (t < 0 ? "-" : "") + f + (i.length ? "," + i : ""), b(() => {
77
+ l > 0 && (i = i.replace(/0+$/, "")), r.value = (t < 0 ? "-" : "") + f + (i.length ? "," + i : ""), d(() => {
69
78
  try {
70
79
  const c = r.value.length;
71
80
  o.value.setSelectionRange(c, c);
@@ -78,12 +87,12 @@ function te(n, s) {
78
87
  let e = (r.value ?? "").toString().trim();
79
88
  e || (e = "0");
80
89
  let t = L(e);
81
- isNaN(t) && (t = 0), t = v(t, n.min, n.max), r.value = d(t, Number(n.precision), !1), s("update:modelValue", t), s("blur");
90
+ isNaN(t) && (t = 0), t = v(t, n.min, n.max), r.value = b(t, Number(n.precision), !1), s("update:modelValue", t), s("blur");
82
91
  }
83
92
  function x(e) {
84
93
  return Number(n.precision) === 0 ? e === "" ? "0" : e.replace(/^0+(\d)/, "$1") : e.padStart(I.value, "0");
85
94
  }
86
- function F(e, t) {
95
+ function y(e, t) {
87
96
  let l = 0;
88
97
  for (let u = 0; u < t; u++)
89
98
  /\d/.test(e[u]) && l++;
@@ -100,11 +109,11 @@ function te(n, s) {
100
109
  if (/\d/.test(e[u])) return u + 1;
101
110
  return e.length;
102
111
  }
103
- function y() {
112
+ function F() {
104
113
  const e = Number(n.precision) + 1;
105
114
  a = String(a || "").padStart(e, "0");
106
115
  const t = Math.max(1, a.length - Number(n.precision)), l = a.slice(0, t) || "0", u = a.slice(t).padEnd(Number(n.precision), "0").slice(0, Number(n.precision)), f = `${l}.${u}`, i = parseFloat(f), c = v(i, n.min, n.max);
107
- a = k(c, Number(n.precision)), r.value = d(c, Number(n.precision), !1), s("update:modelValue", c), s("input", c), b(() => {
116
+ a = k(c, Number(n.precision)), r.value = b(c, Number(n.precision), !1), s("update:modelValue", c), s("input", c), d(() => {
108
117
  if (o.value)
109
118
  try {
110
119
  const m = r.value;
@@ -119,10 +128,10 @@ function te(n, s) {
119
128
  function H() {
120
129
  w.value = !1, a = x(a);
121
130
  const e = M(a, Number(n.precision)), t = v(e, n.min, n.max);
122
- a = k(t, Number(n.precision)), a = x(a), r.value = d(t, Number(n.precision), !1), s("update:modelValue", t), s("blur");
131
+ a = k(t, Number(n.precision)), a = x(a), r.value = b(t, Number(n.precision), !1), s("update:modelValue", t), s("blur");
123
132
  }
124
133
  function j(e) {
125
- w.value = !0, b(() => {
134
+ w.value = !0, d(() => {
126
135
  var l;
127
136
  if (!o.value) return;
128
137
  if ((e == null ? void 0 : e.relatedTarget) !== void 0 || ((l = e == null ? void 0 : e.sourceCapabilities) == null ? void 0 : l.firesTouchEvents) === !1) {
@@ -130,7 +139,7 @@ function te(n, s) {
130
139
  o.value.setSelectionRange(u, u), h.value = r.value.replace(/\D/g, "").length;
131
140
  } else {
132
141
  const u = o.value.selectionStart || 0;
133
- h.value = F(r.value, u);
142
+ h.value = y(r.value, u);
134
143
  }
135
144
  }), s("focus");
136
145
  }
@@ -143,7 +152,7 @@ function te(n, s) {
143
152
  const { key: t, target: l } = e, u = /^[0-9]$/.test(t), f = t === "Backspace", i = t === "Delete", c = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(t), m = e.ctrlKey || e.metaKey, N = t === "Home", S = t === "End";
144
153
  if (t === "Tab") return;
145
154
  if (N) {
146
- b(() => {
155
+ d(() => {
147
156
  if (!o.value) return;
148
157
  const P = r.value.search(/\d/);
149
158
  o.value.setSelectionRange(P, P);
@@ -151,7 +160,7 @@ function te(n, s) {
151
160
  return;
152
161
  }
153
162
  if (S) {
154
- b(() => {
163
+ d(() => {
155
164
  if (!o.value) return;
156
165
  const R = r.value;
157
166
  o.value.setSelectionRange(R.length, R.length);
@@ -159,7 +168,7 @@ function te(n, s) {
159
168
  return;
160
169
  }
161
170
  if (c || m) return;
162
- const X = (l == null ? void 0 : l.selectionStart) ?? 0, Y = r.value || "", g = F(Y, X);
171
+ const X = (l == null ? void 0 : l.selectionStart) ?? 0, Y = r.value || "", g = y(Y, X);
163
172
  e.preventDefault();
164
173
  const B = Number(n.precision) + 1;
165
174
  for (; a.length < B; ) a = "0" + a;
@@ -174,21 +183,21 @@ function te(n, s) {
174
183
  g < a.length && (a = a.substring(0, g) + a.substring(g + 1), h.value = g);
175
184
  else return;
176
185
  for (; a.length < B; ) a = "0" + a;
177
- y();
186
+ F();
178
187
  }
179
188
  function z() {
180
189
  let e;
181
- n.formatMode === "bank" ? (e = M(a, Number(n.precision)) || 0, e = v(e + Number(n.step), n.min, n.max), a = k(e, Number(n.precision)), r.value = d(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e)) : (e = Number(n.modelValue ?? 0) || 0, e = v(e + Number(n.step), n.min, n.max), r.value = d(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e));
190
+ n.formatMode === "bank" ? (e = M(a, Number(n.precision)) || 0, e = v(e + Number(n.step), n.min, n.max), a = k(e, Number(n.precision)), r.value = b(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e)) : (e = Number(n.modelValue ?? 0) || 0, e = v(e + Number(n.step), n.min, n.max), r.value = b(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e));
182
191
  }
183
192
  function G() {
184
193
  let e;
185
- n.formatMode === "bank" ? (e = M(a, Number(n.precision)) || 0, e = v(e - Number(n.step), n.min, n.max), a = k(e, Number(n.precision)), r.value = d(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e)) : (e = Number(n.modelValue ?? 0) || 0, e = v(e - Number(n.step), n.min, n.max), r.value = d(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e));
194
+ n.formatMode === "bank" ? (e = M(a, Number(n.precision)) || 0, e = v(e - Number(n.step), n.min, n.max), a = k(e, Number(n.precision)), r.value = b(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e)) : (e = Number(n.modelValue ?? 0) || 0, e = v(e - Number(n.step), n.min, n.max), r.value = b(e, Number(n.precision), !1), s("update:modelValue", e), s("input", e));
186
195
  }
187
196
  function J() {
188
- n.formatMode === "bank" ? (a = "0".repeat(Number(n.precision) + 1), h.value = Number(n.precision) + 1, y(), b(() => {
197
+ n.formatMode === "bank" ? (a = "0".repeat(Number(n.precision) + 1), h.value = Number(n.precision) + 1, F(), d(() => {
189
198
  var e, t;
190
199
  return (t = (e = o.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
191
- })) : (r.value = "", s("update:modelValue", null), b(() => {
200
+ })) : (r.value = "", s("update:modelValue", null), d(() => {
192
201
  var e, t;
193
202
  return (t = (e = o.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
194
203
  }));
@@ -197,14 +206,14 @@ function te(n, s) {
197
206
  [() => n.modelValue, () => n.precision, () => n.formatMode],
198
207
  ([e, t, l]) => {
199
208
  if (l !== "bank") {
200
- r.value = d(Number(e ?? 0), Number(t), !1);
209
+ r.value = b(Number(e ?? 0), Number(t), !1);
201
210
  return;
202
211
  }
203
212
  if (e == null || isNaN(e))
204
- r.value = d(0, Number(t), !1), a = "0".repeat(Number(t) + 1);
213
+ r.value = b(0, Number(t), !1), a = "0".repeat(Number(t) + 1);
205
214
  else {
206
215
  const u = Number(e), f = v(u, n.min, n.max);
207
- a = k(f, Number(t)), a.length < Number(t) + 1 && (a = a.padStart(Number(t) + 1, "0")), r.value = d(f, Number(t), !1);
216
+ a = k(f, Number(t)), a.length < Number(t) + 1 && (a = a.padStart(Number(t) + 1, "0")), r.value = b(f, Number(t), !1);
208
217
  }
209
218
  },
210
219
  { immediate: !0 }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.523",
3
+ "version": "0.1.525",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",