adverich-kun-ui 0.1.370 → 0.1.372

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,10 @@
1
- import { getCurrentInstance as A, computed as F, useSlots as P, createElementBlock as r, openBlock as s, createCommentVNode as n, createElementVNode as i, normalizeClass as b, toDisplayString as d, mergeProps as R, unref as t, renderSlot as D } from "vue";
2
- import U from "../composables/useKunNumberFieldComposable.js";
3
- import { KunNumberFieldProps as x } from "../composables/KunNumberFieldProps.js";
1
+ import { getCurrentInstance as P, ref as s, computed as g, watch as R, createElementBlock as o, openBlock as a, createCommentVNode as u, createElementVNode as c, normalizeClass as y, toDisplayString as f, mergeProps as S, renderSlot as V } from "vue";
2
+ import { KunNumberFieldProps as U } from "../composables/KunNumberFieldProps.js";
3
+ import { parseNumber as C } from "../composables/numberFormatUtils.js";
4
4
  const H = {
5
5
  key: 0,
6
6
  class: "mx-2"
7
- }, M = ["value", "placeholder", "disabled", "readonly", "maxlength", "aria-invalid", "aria-describedby"], q = {
7
+ }, M = ["value", "placeholder", "disabled", "readonly", "maxlength", "aria-invalid", "aria-describedby"], T = ["disabled"], q = {
8
8
  key: 2,
9
9
  class: "flex flex-col items-center justify-center border-l border-slate-600"
10
10
  }, G = ["disabled"], J = ["disabled"], L = {
@@ -13,12 +13,12 @@ const H = {
13
13
  }, O = {
14
14
  key: 0,
15
15
  class: "h-[1.25rem]"
16
- }, Q = ["id"], T = {
16
+ }, Q = ["id"], W = {
17
17
  key: 1,
18
18
  class: "text-xs text-center"
19
- }, Z = {
19
+ }, _ = {
20
20
  __name: "KunNumberField",
21
- props: x,
21
+ props: U,
22
22
  emits: [
23
23
  "update:modelValue",
24
24
  "focus",
@@ -27,118 +27,130 @@ const H = {
27
27
  "keyDown",
28
28
  "keyUp"
29
29
  ],
30
- setup($, { expose: K, emit: N }) {
31
- const a = $, f = N, {
32
- rawInput: m,
33
- inputField: y,
34
- rootRef: k,
35
- inputFocused: v,
36
- handleInput: c,
37
- handleBlur: C,
38
- focusInput: g,
39
- clearInput: h,
40
- validationError: B,
41
- hasError: u,
42
- onIncrement: w,
43
- onDecrement: I,
44
- validate: E,
45
- reset: V,
46
- resetValidation: S
47
- } = U(a, f), p = `number-input-${A().uid}`, j = F(() => v.value || !!m.value || a.dirty);
48
- K({
49
- inputField: y,
50
- rootRef: k,
51
- validate: E,
52
- reset: V,
53
- resetValidation: S,
30
+ setup(I, { expose: F, emit: D }) {
31
+ const l = I, n = D, v = `number-input-${P().uid}`, h = s(null), w = s(null), d = s(!1), N = s(""), k = s(!1), i = s(!1), r = s(l.modelValue != null ? m(l.modelValue, l.separator, l.precision) : ""), b = g(() => l.error || !!N.value && k.value), $ = g(() => d.value || !!r.value || l.dirty);
32
+ function m(e, t = ".", p = 2) {
33
+ return e == null || isNaN(e) ? "" : Number(e).toFixed(p).replace(".", t);
34
+ }
35
+ R(() => l.modelValue, (e) => {
36
+ if (i.value) {
37
+ i.value = !1;
38
+ return;
39
+ }
40
+ const t = m(e, l.separator, l.precision);
41
+ t !== r.value && (r.value = t);
42
+ });
43
+ const B = g(() => l.density === "compact" ? "p-1" : l.density === "comfortable" ? "p-2" : "p-3");
44
+ function E(e) {
45
+ r.value = e.target.value;
46
+ const t = C(r.value, l.separator);
47
+ i.value = !0, n("update:modelValue", t);
48
+ }
49
+ function K() {
50
+ d.value = !1, k.value = !0, n("blur");
51
+ }
52
+ function j() {
53
+ d.value = !0, n("focus");
54
+ }
55
+ function x() {
56
+ r.value = "", i.value = !0, n("update:modelValue", null), k.value = !0;
57
+ }
58
+ function z() {
59
+ const t = (C(r.value, l.separator) || 0) + Number(l.step);
60
+ r.value = m(t, l.separator, l.precision), i.value = !0, n("update:modelValue", t);
61
+ }
62
+ function A() {
63
+ const t = (C(r.value, l.separator) || 0) - Number(l.step);
64
+ r.value = m(t, l.separator, l.precision), i.value = !0, n("update:modelValue", t);
65
+ }
66
+ return F({
67
+ inputField: h,
68
+ rootRef: w,
54
69
  focus: () => {
55
70
  var e;
56
- return (e = y.value) == null ? void 0 : e.focus();
71
+ return (e = h.value) == null ? void 0 : e.focus();
57
72
  }
58
- }), P();
59
- const z = F(
60
- () => a.density === "compact" ? "p-1" : a.density === "comfortable" ? "p-2" : "p-3"
61
- );
62
- return (e, o) => (s(), r("div", {
73
+ }), (e, t) => (a(), o("div", {
63
74
  class: "w-full flex flex-col relative",
64
75
  ref_key: "rootRef",
65
- ref: k
76
+ ref: w
66
77
  }, [
67
- e.label ? (s(), r("label", {
78
+ e.label ? (a(), o("label", {
68
79
  key: 0,
69
- for: p,
70
- class: b([
80
+ for: v,
81
+ class: y([
71
82
  e.labelColor,
72
83
  "absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10",
73
- j.value ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"
84
+ $.value ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"
74
85
  ])
75
- }, d(e.label), 3)) : n("", !0),
76
- i("div", R({ class: "w-full flex flex-col justify-center relative" }, e.$attrs), [
77
- i("div", {
78
- class: b(["flex items-center w-full border", [
86
+ }, f(e.label), 3)) : u("", !0),
87
+ c("div", S({ class: "w-full flex flex-col justify-center relative" }, e.$attrs), [
88
+ c("div", {
89
+ class: y(["flex items-center w-full border", [
79
90
  e.bgInput,
80
91
  e.rounded,
81
- t(v) ? "border-blue-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
92
+ d.value ? "border-blue-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
82
93
  e.disabled ? "opacity-60 cursor-not-allowed" : "cursor-text",
83
- t(u) ? "bg-red-200 dark:bg-red-900" : ""
94
+ b.value ? "bg-red-200 dark:bg-red-900" : ""
84
95
  ]])
85
96
  }, [
86
- e.prefix ? (s(), r("div", H, d(e.prefix), 1)) : n("", !0),
87
- D(e.$slots, "prepend-inner"),
88
- i("input", {
97
+ e.prefix ? (a(), o("div", H, f(e.prefix), 1)) : u("", !0),
98
+ V(e.$slots, "prepend-inner"),
99
+ c("input", {
89
100
  ref_key: "inputField",
90
- ref: y,
91
- id: p,
101
+ ref: h,
102
+ id: v,
92
103
  type: "text",
93
- value: t(m),
104
+ value: r.value,
94
105
  placeholder: e.placeholder,
95
106
  disabled: e.disabled,
96
107
  readonly: e.readonly,
97
108
  maxlength: e.maxlength,
98
109
  autocomplete: "off",
99
- "aria-invalid": t(u) ? "true" : "false",
100
- "aria-describedby": t(u) ? `error-${p}` : null,
101
- class: b([z.value, e.textColor, e.placeholderColor, e.textCenter ? "text-center" : "", "w-full h-full bg-transparent focus:outline-none"]),
102
- onInput: o[0] || (o[0] = (...l) => t(c) && t(c)(...l)),
103
- onBlur: o[1] || (o[1] = (...l) => t(C) && t(C)(...l)),
104
- onFocus: o[2] || (o[2] = (...l) => t(g) && t(g)(...l)),
105
- onKeydown: o[3] || (o[3] = (l) => f("keyDown", l)),
106
- onKeyup: o[4] || (o[4] = (l) => f("keyUp", l))
110
+ "aria-invalid": b.value ? "true" : "false",
111
+ "aria-describedby": b.value ? `error-${v}` : null,
112
+ class: y([B.value, e.textColor, e.placeholderColor, e.textCenter ? "text-center" : "", "w-full h-full bg-transparent focus:outline-none"]),
113
+ onInput: E,
114
+ onBlur: K,
115
+ onFocus: j,
116
+ onKeydown: t[0] || (t[0] = (p) => n("keyDown", p)),
117
+ onKeyup: t[1] || (t[1] = (p) => n("keyUp", p))
107
118
  }, null, 42, M),
108
- e.clearable && t(m) ? (s(), r("button", {
119
+ e.clearable && r.value ? (a(), o("button", {
109
120
  key: 1,
110
121
  type: "button",
111
- onClick: o[5] || (o[5] = (...l) => t(h) && t(h)(...l)),
112
- class: b(["ml-2", e.textColor])
113
- }, " × ", 2)) : n("", !0),
114
- e.noArrows ? n("", !0) : (s(), r("div", q, [
115
- i("button", {
122
+ onClick: x,
123
+ class: y(["ml-2", e.textColor]),
124
+ disabled: e.disabled || e.readonly
125
+ }, " × ", 10, T)) : u("", !0),
126
+ e.noArrows ? u("", !0) : (a(), o("div", q, [
127
+ c("button", {
116
128
  type: "button",
117
129
  class: "p-2",
118
- onClick: o[6] || (o[6] = (...l) => t(w) && t(w)(...l)),
130
+ onClick: z,
119
131
  disabled: e.disabled || e.readonly
120
132
  }, "▲", 8, G),
121
- i("button", {
133
+ c("button", {
122
134
  type: "button",
123
135
  class: "p-2",
124
- onClick: o[7] || (o[7] = (...l) => t(I) && t(I)(...l)),
136
+ onClick: A,
125
137
  disabled: e.disabled || e.readonly
126
138
  }, "▼", 8, J)
127
139
  ])),
128
- D(e.$slots, "append-inner"),
129
- e.suffix ? (s(), r("div", L, d(e.suffix), 1)) : n("", !0)
140
+ V(e.$slots, "append-inner"),
141
+ e.suffix ? (a(), o("div", L, f(e.suffix), 1)) : u("", !0)
130
142
  ], 2),
131
- e.hideDetails ? n("", !0) : (s(), r("div", O, [
132
- t(u) ? (s(), r("div", {
143
+ e.hideDetails ? u("", !0) : (a(), o("div", O, [
144
+ b.value ? (a(), o("div", {
133
145
  key: 0,
134
- id: `error-${p}`,
146
+ id: `error-${v}`,
135
147
  class: "text-red-500 text-sm text-center"
136
- }, d(t(B) || e.errorMessage), 9, Q)) : e.hint && (e.persistentHint || t(v)) ? (s(), r("div", T, d(e.hint), 1)) : n("", !0)
148
+ }, f(N.value || e.errorMessage), 9, Q)) : e.hint && (e.persistentHint || d.value) ? (a(), o("div", W, f(e.hint), 1)) : u("", !0)
137
149
  ]))
138
150
  ], 16)
139
151
  ], 512));
140
152
  }
141
153
  };
142
154
  export {
143
- Z as default
155
+ _ as default
144
156
  };
@@ -1,18 +1,7 @@
1
- function t(e, n = ",") {
2
- const r = e.replace(/[^\d.,]/g, "");
3
- return n === "," ? r.replace(/\./g, ",") : r.replace(/,/g, ".");
4
- }
5
- function l(e, n = ",") {
6
- const r = e.replace(new RegExp(`\\${n}`, "g"), "."), a = parseFloat(r);
7
- return isNaN(a) ? null : a;
8
- }
9
- function c(e, n = ",", r = 2) {
10
- if (e === null || isNaN(e)) return "";
11
- const a = Number(e).toFixed(r);
12
- return n === "," ? a.replace(".", ",") : a;
1
+ function o(r, n = ",") {
2
+ const a = r.replace(new RegExp(`\\${n}`, "g"), "."), e = parseFloat(a);
3
+ return isNaN(e) ? null : e;
13
4
  }
14
5
  export {
15
- c as formatNumber,
16
- t as normalizeNumber,
17
- l as parseNumber
6
+ o as parseNumber
18
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.370",
3
+ "version": "0.1.372",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",
@@ -1,75 +0,0 @@
1
- import { ref as t, inject as N, computed as D, watch as K, onUnmounted as P } from "vue";
2
- import { debounce as R } from "../../../../utils/utils.js";
3
- import { formatNumber as i, normalizeNumber as T, parseNumber as U } from "./numberFormatUtils.js";
4
- function C(e, n) {
5
- const l = t(i(e.modelValue, e.separator, e.precision)), a = t(e.modelValue), d = t(!1), r = t(""), o = t(!1), F = t(null), g = t(null), h = t(!1), f = N("registerField", null), m = N("unregisterField", null), I = D(() => e.error || !!r.value && o.value), b = async () => {
6
- for (const u of e.rules) {
7
- const c = await Promise.resolve(u(a.value));
8
- if (c !== !0) return c;
9
- }
10
- return !0;
11
- }, V = R(async () => {
12
- const u = await b();
13
- r.value = u === !0 ? "" : u;
14
- }, e.debounce ?? 300);
15
- K(() => e.modelValue, (u) => {
16
- u !== a.value && (h.value = !0, a.value = u, l.value = i(u, e.separator, e.precision));
17
- });
18
- function y(u) {
19
- const c = T(u.target.value, e.separator);
20
- l.value = c;
21
- const s = U(c, e.separator);
22
- isNaN(s) || (a.value = s, n("update:modelValue", s), e.validateOnBlur || V());
23
- }
24
- function B() {
25
- d.value = !1, l.value = i(a.value, e.separator, e.precision), e.validateOnBlur && v(), n("blur");
26
- }
27
- function w() {
28
- d.value = !0, n("focus");
29
- }
30
- function O() {
31
- l.value = "", a.value = null, n("update:modelValue", null), o.value = !0, e.validateOnBlur || V();
32
- }
33
- function E() {
34
- let u = a.value || 0;
35
- u += Number(e.step), a.value = u, l.value = i(u, e.separator, e.precision), n("update:modelValue", u);
36
- }
37
- function j() {
38
- let u = a.value || 0;
39
- u -= Number(e.step), a.value = u, l.value = i(u, e.separator, e.precision), n("update:modelValue", u);
40
- }
41
- async function v() {
42
- o.value = !0;
43
- const u = await b();
44
- return r.value = u === !0 ? "" : u, u === !0;
45
- }
46
- function x() {
47
- a.value = e.modelValue, l.value = i(e.modelValue, e.separator, e.precision), o.value = !1, r.value = "";
48
- }
49
- function z() {
50
- o.value = !1, r.value = "";
51
- }
52
- return f && f({ validate: v }), P(() => {
53
- m && m({ validate: v });
54
- }), {
55
- rawInput: l,
56
- inputValue: a,
57
- inputField: F,
58
- rootRef: g,
59
- inputFocused: d,
60
- validationError: r,
61
- hasError: I,
62
- handleInput: y,
63
- handleBlur: B,
64
- focusInput: w,
65
- clearInput: O,
66
- onIncrement: E,
67
- onDecrement: j,
68
- validate: v,
69
- reset: x,
70
- resetValidation: z
71
- };
72
- }
73
- export {
74
- C as default
75
- };