adverich-kun-ui 0.1.370 → 0.1.371

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,24 +1,24 @@
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";
4
- const H = {
1
+ import { getCurrentInstance as P, ref as s, computed as N, 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 g } from "../composables/numberFormatUtils.js";
4
+ const x = {
5
5
  key: 0,
6
6
  class: "mx-2"
7
- }, M = ["value", "placeholder", "disabled", "readonly", "maxlength", "aria-invalid", "aria-describedby"], q = {
7
+ }, H = ["value", "placeholder", "disabled", "readonly", "maxlength", "aria-invalid", "aria-describedby"], M = ["disabled"], T = {
8
8
  key: 2,
9
9
  class: "flex flex-col items-center justify-center border-l border-slate-600"
10
- }, G = ["disabled"], J = ["disabled"], L = {
10
+ }, q = ["disabled"], G = ["disabled"], J = {
11
11
  key: 3,
12
12
  class: "ml-2"
13
- }, O = {
13
+ }, L = {
14
14
  key: 0,
15
15
  class: "h-[1.25rem]"
16
- }, Q = ["id"], T = {
16
+ }, O = ["id"], Q = {
17
17
  key: 1,
18
18
  class: "text-xs text-center"
19
19
  }, Z = {
20
20
  __name: "KunNumberField",
21
- props: x,
21
+ props: U,
22
22
  emits: [
23
23
  "update:modelValue",
24
24
  "focus",
@@ -27,113 +27,124 @@ 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), C = s(null), d = s(!1), w = s(""), k = s(!1), i = s(!1), r = s(l.modelValue != null ? m(l.modelValue, l.separator, l.precision) : ""), b = N(() => l.error || !!w.value && k.value), $ = N(() => 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
+ function B(e) {
44
+ r.value = e.target.value;
45
+ const t = g(r.value, l.separator);
46
+ i.value = !0, n("update:modelValue", t);
47
+ }
48
+ function E() {
49
+ d.value = !1, k.value = !0, n("blur");
50
+ }
51
+ function K() {
52
+ d.value = !0, n("focus");
53
+ }
54
+ function j() {
55
+ r.value = "", i.value = !0, n("update:modelValue", null), k.value = !0;
56
+ }
57
+ function z() {
58
+ const t = (g(r.value, l.separator) || 0) + Number(l.step);
59
+ r.value = m(t, l.separator, l.precision), i.value = !0, n("update:modelValue", t);
60
+ }
61
+ function A() {
62
+ const t = (g(r.value, l.separator) || 0) - Number(l.step);
63
+ r.value = m(t, l.separator, l.precision), i.value = !0, n("update:modelValue", t);
64
+ }
65
+ return F({
66
+ inputField: h,
67
+ rootRef: C,
54
68
  focus: () => {
55
69
  var e;
56
- return (e = y.value) == null ? void 0 : e.focus();
70
+ return (e = h.value) == null ? void 0 : e.focus();
57
71
  }
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", {
72
+ }), (e, t) => (a(), o("div", {
63
73
  class: "w-full flex flex-col relative",
64
74
  ref_key: "rootRef",
65
- ref: k
75
+ ref: C
66
76
  }, [
67
- e.label ? (s(), r("label", {
77
+ e.label ? (a(), o("label", {
68
78
  key: 0,
69
- for: p,
70
- class: b([
79
+ for: v,
80
+ class: y([
71
81
  e.labelColor,
72
82
  "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"
83
+ $.value ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"
74
84
  ])
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", [
85
+ }, f(e.label), 3)) : u("", !0),
86
+ c("div", S({ class: "w-full flex flex-col justify-center relative" }, e.$attrs), [
87
+ c("div", {
88
+ class: y(["flex items-center w-full border", [
79
89
  e.bgInput,
80
90
  e.rounded,
81
- t(v) ? "border-blue-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
91
+ d.value ? "border-blue-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
82
92
  e.disabled ? "opacity-60 cursor-not-allowed" : "cursor-text",
83
- t(u) ? "bg-red-200 dark:bg-red-900" : ""
93
+ b.value ? "bg-red-200 dark:bg-red-900" : ""
84
94
  ]])
85
95
  }, [
86
- e.prefix ? (s(), r("div", H, d(e.prefix), 1)) : n("", !0),
87
- D(e.$slots, "prepend-inner"),
88
- i("input", {
96
+ e.prefix ? (a(), o("div", x, f(e.prefix), 1)) : u("", !0),
97
+ V(e.$slots, "prepend-inner"),
98
+ c("input", {
89
99
  ref_key: "inputField",
90
- ref: y,
91
- id: p,
100
+ ref: h,
101
+ id: v,
92
102
  type: "text",
93
- value: t(m),
103
+ value: r.value,
94
104
  placeholder: e.placeholder,
95
105
  disabled: e.disabled,
96
106
  readonly: e.readonly,
97
107
  maxlength: e.maxlength,
98
108
  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))
107
- }, null, 42, M),
108
- e.clearable && t(m) ? (s(), r("button", {
109
+ "aria-invalid": b.value ? "true" : "false",
110
+ "aria-describedby": b.value ? `error-${v}` : null,
111
+ class: y([e.inputDensity, e.textColor, e.placeholderColor, e.textCenter ? "text-center" : "", "w-full h-full bg-transparent focus:outline-none"]),
112
+ onInput: B,
113
+ onBlur: E,
114
+ onFocus: K,
115
+ onKeydown: t[0] || (t[0] = (p) => n("keyDown", p)),
116
+ onKeyup: t[1] || (t[1] = (p) => n("keyUp", p))
117
+ }, null, 42, H),
118
+ e.clearable && r.value ? (a(), o("button", {
109
119
  key: 1,
110
120
  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", {
121
+ onClick: j,
122
+ class: y(["ml-2", e.textColor]),
123
+ disabled: e.disabled || e.readonly
124
+ }, " × ", 10, M)) : u("", !0),
125
+ e.noArrows ? u("", !0) : (a(), o("div", T, [
126
+ c("button", {
116
127
  type: "button",
117
128
  class: "p-2",
118
- onClick: o[6] || (o[6] = (...l) => t(w) && t(w)(...l)),
129
+ onClick: z,
119
130
  disabled: e.disabled || e.readonly
120
- }, "▲", 8, G),
121
- i("button", {
131
+ }, "▲", 8, q),
132
+ c("button", {
122
133
  type: "button",
123
134
  class: "p-2",
124
- onClick: o[7] || (o[7] = (...l) => t(I) && t(I)(...l)),
135
+ onClick: A,
125
136
  disabled: e.disabled || e.readonly
126
- }, "▼", 8, J)
137
+ }, "▼", 8, G)
127
138
  ])),
128
- D(e.$slots, "append-inner"),
129
- e.suffix ? (s(), r("div", L, d(e.suffix), 1)) : n("", !0)
139
+ V(e.$slots, "append-inner"),
140
+ e.suffix ? (a(), o("div", J, f(e.suffix), 1)) : u("", !0)
130
141
  ], 2),
131
- e.hideDetails ? n("", !0) : (s(), r("div", O, [
132
- t(u) ? (s(), r("div", {
142
+ e.hideDetails ? u("", !0) : (a(), o("div", L, [
143
+ b.value ? (a(), o("div", {
133
144
  key: 0,
134
- id: `error-${p}`,
145
+ id: `error-${v}`,
135
146
  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)
147
+ }, f(w.value || e.errorMessage), 9, O)) : e.hint && (e.persistentHint || d.value) ? (a(), o("div", Q, f(e.hint), 1)) : u("", !0)
137
148
  ]))
138
149
  ], 16)
139
150
  ], 512));
@@ -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.371",
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
- };