adverich-kun-ui 0.1.374 → 0.1.376

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,212 +1,205 @@
1
- import { getCurrentInstance as P, useSlots as R, computed as U, createElementBlock as s, openBlock as l, createCommentVNode as n, createElementVNode as d, normalizeClass as b, unref as r, toDisplayString as u, mergeProps as H, createBlock as I, renderSlot as V, Fragment as K, renderList as L } from "vue";
2
- import { KunNumberFieldProps as q } from "../composables/KunNumberFieldProps.js";
3
- import { useKunNumberField as G } from "../composables/useKunNumberFieldComposable.js";
4
- import j from "../../../KunIcon/src/components/KunIcon.vue.js";
5
- const J = {
1
+ import { getCurrentInstance as $, useSlots as z, computed as E, createElementBlock as l, openBlock as s, createCommentVNode as n, createElementVNode as i, normalizeClass as p, toDisplayString as u, mergeProps as P, unref as o, createBlock as I, renderSlot as V, Fragment as j, renderList as R } from "vue";
2
+ import { KunNumberFieldProps as U } from "../composables/KunNumberFieldProps.js";
3
+ import { useKunNumberField as H } from "../composables/useKunNumberFieldComposable.js";
4
+ import x from "../../../KunIcon/src/components/KunIcon.vue.js";
5
+ const L = {
6
6
  key: 0,
7
7
  class: "h-full"
8
- }, O = ["disabled"], Q = {
8
+ }, q = ["disabled"], G = {
9
9
  key: 1,
10
10
  class: "mx-2"
11
- }, T = {
11
+ }, J = {
12
12
  key: 2,
13
13
  class: "flex items-center justify-center h-full pl-1"
14
- }, W = ["value", "placeholder", "readonly", "disabled", "maxlength", "aria-invalid"], X = ["disabled"], Y = {
14
+ }, O = ["value", "placeholder", "readonly", "disabled", "maxlength", "aria-invalid"], Q = ["disabled"], T = {
15
15
  key: 0,
16
16
  class: "flex items-center h-full"
17
- }, Z = ["disabled"], _ = ["disabled"], ee = {
17
+ }, W = ["disabled"], X = ["disabled"], Y = {
18
18
  key: 1,
19
19
  class: "flex flex-col items-center justify-center border-l border-slate-600"
20
- }, te = ["disabled"], oe = ["disabled"], re = {
20
+ }, Z = ["disabled"], _ = ["disabled"], ee = {
21
21
  key: 5,
22
22
  class: "flex items-center justify-center h-full pr-1"
23
- }, le = {
23
+ }, te = {
24
24
  key: 6,
25
25
  class: "h-full"
26
- }, se = ["disabled"], ne = {
26
+ }, oe = ["disabled"], re = {
27
27
  key: 7,
28
28
  class: "ml-2"
29
- }, de = {
29
+ }, se = {
30
30
  key: 0,
31
31
  class: "h-[1.25rem]"
32
- }, ie = {
32
+ }, le = {
33
33
  key: 0,
34
34
  class: "text-red-500 text-sm text-center"
35
- }, ae = { key: 0 }, ue = { key: 1 }, pe = {
35
+ }, ne = { key: 0 }, ie = { key: 1 }, de = {
36
36
  key: 1,
37
37
  class: "text-xs text-center"
38
- }, ce = {
38
+ }, ye = {
39
39
  __name: "KunNumberField",
40
- props: q,
40
+ props: U,
41
41
  emits: [
42
42
  "update:modelValue",
43
43
  "focus",
44
+ "input",
44
45
  "blur",
45
46
  "handleClick",
46
47
  "keyDown",
47
48
  "keyUp"
48
49
  ],
49
- setup(A, { expose: D, emit: F }) {
50
- const p = A, y = F, c = `number-input-${P().uid}`, m = R(), x = !!m["prepend-icon"], B = !!m["append-icon"], {
51
- inputValue: f,
52
- numberInput: k,
53
- rootRef: v,
54
- inputKey: M,
55
- updateValue: N,
56
- onIncrement: i,
50
+ setup(D, { expose: F, emit: K }) {
51
+ const b = D, y = K, f = `number-input-${$().uid}`, k = z(), A = !!k["prepend-icon"], B = !!k["append-icon"], {
52
+ inputValue: m,
53
+ numberInput: c,
54
+ rootRef: h,
55
+ onIncrement: d,
57
56
  onDecrement: a,
58
- onClear: h,
59
- validateKey: S,
57
+ onClear: v,
58
+ validateKey: M,
60
59
  focus: w,
61
60
  handleFocus: g,
62
- isActive: $,
63
61
  handleBlur: C
64
- } = G(p, y);
65
- D({
66
- numberInput: k,
67
- rootRef: v,
62
+ } = H(b, y);
63
+ F({
64
+ numberInput: c,
65
+ rootRef: h,
68
66
  focus: () => {
69
67
  var e;
70
- return (e = k.value) == null ? void 0 : e.focus();
68
+ return (e = c.value) == null ? void 0 : e.focus();
71
69
  }
72
- }), watch(() => p.modelValue, (e) => {
73
- f.value = e;
74
70
  });
75
- const z = U(() => p.density === "compact" ? "p-1" : p.density === "comfortable" ? "p-2" : "p-3");
76
- return (e, o) => (l(), s("div", {
77
- class: "w-full flex flex-col relative",
71
+ const N = E(() => b.density === "compact" ? "p-1" : b.density === "comfortable" ? "p-2" : "p-3");
72
+ return (e, r) => (s(), l("div", {
73
+ class: "w-full flex flex-col relative h-fit",
78
74
  ref_key: "rootRef",
79
- ref: v
75
+ ref: h
80
76
  }, [
81
- e.label ? (l(), s("label", {
77
+ e.label ? (s(), l("label", {
82
78
  key: 0,
83
- for: c,
84
- class: b([
79
+ for: f,
80
+ class: p([
85
81
  e.labelColor,
86
82
  "absolute left-2 transition-all duration-200 ease-in-out pointer-events-none select-none z-10",
87
- r($) || e.placeholder ? "-top-2.25 text-xs opacity-80" : "top-3 text-sm opacity-80"
83
+ "-top-2.25 text-xs opacity-80"
88
84
  ])
89
85
  }, u(e.label), 3)) : n("", !0),
90
- d("div", H({ class: "w-full flex flex-col justify-center relative" }, e.$attrs), [
91
- d("div", {
92
- class: b(["flex items-center w-full h-full border", [
86
+ i("div", P({ class: "w-full flex flex-col justify-center relative" }, e.$attrs), [
87
+ i("div", {
88
+ class: p(["flex items-center w-full h-full border", [
93
89
  e.bgInput,
94
90
  e.rounded,
95
- r(w) ? "border-blue-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
91
+ o(w) ? "border-blue-600 shadow-[0_0_0_1px_rgba(59,130,246,0.5)]" : e.borderColor,
96
92
  e.disabled ? "opacity-60 cursor-not-allowed" : "cursor-text",
97
93
  e.error ? "bg-red-200 dark:bg-red-900" : ""
98
94
  ]])
99
95
  }, [
100
- !e.noArrows && e.controlVariant === "split" ? (l(), s("div", J, [
101
- d("button", {
96
+ !e.noArrows && e.controlVariant === "split" ? (s(), l("div", L, [
97
+ i("button", {
102
98
  type: "button",
103
99
  class: "p-3 text-lg border-r border-slate-600 text-black dark:text-white disabled:opacity-50 cursor-pointer hover:opacity-80",
104
- onClick: o[0] || (o[0] = (...t) => r(a) && r(a)(...t)),
100
+ onClick: r[0] || (r[0] = (...t) => o(a) && o(a)(...t)),
105
101
  disabled: e.disabled || e.readonly
106
- }, "−", 8, O)
102
+ }, "−", 8, q)
107
103
  ])) : n("", !0),
108
- e.prefix ? (l(), s("div", Q, u(e.prefix), 1)) : n("", !0),
109
- e.prependIcon || x ? (l(), s("div", T, [
110
- e.prependIcon ? (l(), I(j, {
104
+ e.prefix ? (s(), l("div", G, u(e.prefix), 1)) : n("", !0),
105
+ e.prependIcon || A ? (s(), l("div", J, [
106
+ e.prependIcon ? (s(), I(x, {
111
107
  key: 0,
112
108
  icon: e.prependIcon
113
109
  }, null, 8, ["icon"])) : V(e.$slots, "prepend-icon", { key: 1 })
114
110
  ])) : n("", !0),
115
- (l(), s("input", {
116
- id: c,
111
+ i("input", {
112
+ id: f,
117
113
  ref_key: "numberInput",
118
- ref: k,
119
- key: r(M) + e.modelValue,
114
+ ref: c,
120
115
  type: "text",
121
- value: r(f),
116
+ value: o(m),
122
117
  placeholder: e.placeholder,
123
118
  readonly: e.readonly,
124
119
  disabled: e.disabled,
125
120
  maxlength: e.maxlength,
126
121
  autocomplete: "off",
127
- class: b(["w-full h-full bg-transparent rounded focus:outline-none", [z.value, e.textColor, e.placeholderColor, e.textCenter ? "text-center" : ""]]),
122
+ class: p(["w-full h-full bg-transparent rounded focus:outline-none", [N.value, e.textColor, e.placeholderColor, e.textCenter ? "text-center" : ""]]),
128
123
  "aria-invalid": e.error ? "true" : "false",
129
- onKeypress: o[1] || (o[1] = (t) => r(S)(t)),
130
- onBlur: o[2] || (o[2] = (...t) => r(C) && r(C)(...t)),
131
- onFocus: o[3] || (o[3] = (...t) => r(g) && r(g)(...t)),
132
- onInput: o[4] || (o[4] = (t) => r(N)(t.target.value)),
133
- onKeydown: o[5] || (o[5] = (t) => y("keyDown", t)),
134
- onKeyup: o[6] || (o[6] = (t) => y("keyUp", t)),
124
+ onBlur: r[1] || (r[1] = (...t) => o(C) && o(C)(...t)),
125
+ onFocus: r[2] || (r[2] = (...t) => o(g) && o(g)(...t)),
126
+ onKeydown: r[3] || (r[3] = (t) => (o(M)(t), y("keyDown", t))),
127
+ onKeyup: r[4] || (r[4] = (t) => y("keyUp", t)),
135
128
  inputmode: "decimal",
136
129
  pattern: "[0-9]+([\\.,][0-9]+)?"
137
- }, null, 42, W)),
138
- e.clearable && r(f) != null ? (l(), s("button", {
130
+ }, null, 42, O),
131
+ e.clearable && o(m) != null ? (s(), l("button", {
139
132
  key: 3,
140
133
  type: "button",
141
- onClick: o[7] || (o[7] = (...t) => r(h) && r(h)(...t)),
142
- class: b(["ml-2", e.textColor]),
134
+ onClick: r[5] || (r[5] = (...t) => o(v) && o(v)(...t)),
135
+ class: p(["ml-2", e.textColor]),
143
136
  disabled: e.disabled || e.readonly
144
- }, " × ", 10, X)) : n("", !0),
145
- e.noArrows ? n("", !0) : (l(), s(K, { key: 4 }, [
146
- e.controlVariant === "default" ? (l(), s("div", Y, [
147
- d("button", {
137
+ }, " × ", 10, Q)) : n("", !0),
138
+ e.noArrows ? n("", !0) : (s(), l(j, { key: 4 }, [
139
+ e.controlVariant === "default" ? (s(), l("div", T, [
140
+ i("button", {
148
141
  type: "button",
149
142
  class: "flex items-center border-l border-slate-600 p-3 justify-center text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer hover:opacity-80",
150
- onClick: o[8] || (o[8] = (...t) => r(i) && r(i)(...t)),
143
+ onClick: r[6] || (r[6] = (...t) => o(d) && o(d)(...t)),
151
144
  disabled: e.disabled || e.readonly
152
- }, " ▲ ", 8, Z),
153
- d("button", {
145
+ }, " ▲ ", 8, W),
146
+ i("button", {
154
147
  type: "button",
155
148
  class: "flex items-center border-l border-slate-600 p-3 justify-center text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer hover:opacity-80",
156
- onClick: o[9] || (o[9] = (...t) => r(a) && r(a)(...t)),
149
+ onClick: r[7] || (r[7] = (...t) => o(a) && o(a)(...t)),
157
150
  disabled: e.disabled || e.readonly
158
- }, " ▼ ", 8, _)
151
+ }, " ▼ ", 8, X)
159
152
  ])) : n("", !0),
160
- e.controlVariant === "stacked" ? (l(), s("div", ee, [
161
- d("div", {
153
+ e.controlVariant === "stacked" ? (s(), l("div", Y, [
154
+ i("div", {
162
155
  class: "border-b border-slate-600 pb-1 px-3 flex hover:opacity-80 cursor-pointer",
163
- onClick: o[10] || (o[10] = (...t) => r(i) && r(i)(...t))
156
+ onClick: r[8] || (r[8] = (...t) => o(d) && o(d)(...t))
164
157
  }, [
165
- d("button", {
158
+ i("button", {
166
159
  type: "button",
167
160
  class: "text-xs text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer",
168
161
  disabled: e.disabled || e.readonly
169
- }, "▲", 8, te)
162
+ }, "▲", 8, Z)
170
163
  ]),
171
- d("div", {
164
+ i("div", {
172
165
  class: "border-t border-slate-600 pt-1 px-3 flex hover:opacity-80 cursor-pointer",
173
- onClick: o[11] || (o[11] = (...t) => r(a) && r(a)(...t))
166
+ onClick: r[9] || (r[9] = (...t) => o(a) && o(a)(...t))
174
167
  }, [
175
- d("button", {
168
+ i("button", {
176
169
  type: "button",
177
170
  class: "text-xs text-black dark:text-white hover:text-black/80 dark:hover:text-white/80 disabled:opacity-50 cursor-pointer",
178
171
  disabled: e.disabled || e.readonly
179
- }, "▼", 8, oe)
172
+ }, "▼", 8, _)
180
173
  ])
181
174
  ])) : n("", !0)
182
175
  ], 64)),
183
- e.appendIcon || B ? (l(), s("div", re, [
184
- e.appendIcon ? (l(), I(j, {
176
+ e.appendIcon || B ? (s(), l("div", ee, [
177
+ e.appendIcon ? (s(), I(x, {
185
178
  key: 0,
186
179
  icon: e.appendIcon
187
180
  }, null, 8, ["icon"])) : V(e.$slots, "append-icon", { key: 1 })
188
181
  ])) : n("", !0),
189
- !e.noArrows && e.controlVariant === "split" ? (l(), s("div", le, [
190
- d("button", {
182
+ !e.noArrows && e.controlVariant === "split" ? (s(), l("div", te, [
183
+ i("button", {
191
184
  type: "button",
192
185
  class: "p-3 text-lg border-l border-slate-600 text-black dark:text-white disabled:opacity-50 cursor-pointer hover:opacity-80",
193
- onClick: o[12] || (o[12] = (...t) => r(i) && r(i)(...t)),
186
+ onClick: r[10] || (r[10] = (...t) => o(d) && o(d)(...t)),
194
187
  disabled: e.disabled || e.readonly
195
- }, "+", 8, se)
188
+ }, "+", 8, oe)
196
189
  ])) : n("", !0),
197
- e.suffix ? (l(), s("div", ne, u(e.suffix), 1)) : n("", !0)
190
+ e.suffix ? (s(), l("div", re, u(e.suffix), 1)) : n("", !0)
198
191
  ], 2),
199
- e.hideDetails ? n("", !0) : (l(), s("div", de, [
200
- e.error || e.errorMessages ? (l(), s("div", ie, [
201
- Array.isArray(e.errorMessages) ? (l(), s("div", ae, [
202
- (l(!0), s(K, null, L(e.errorMessages, (t, E) => (l(), s("div", { key: E }, u(t), 1))), 128))
203
- ])) : typeof e.errorMessages == "string" ? (l(), s("div", ue, u(e.errorMessages), 1)) : n("", !0)
204
- ])) : e.hint && (e.persistentHint || r(w)) ? (l(), s("div", pe, u(e.hint), 1)) : n("", !0)
192
+ e.hideDetails ? n("", !0) : (s(), l("div", se, [
193
+ e.error || e.errorMessages ? (s(), l("div", le, [
194
+ Array.isArray(e.errorMessages) ? (s(), l("div", ne, [
195
+ (s(!0), l(j, null, R(e.errorMessages, (t, S) => (s(), l("div", { key: S }, u(t), 1))), 128))
196
+ ])) : typeof e.errorMessages == "string" ? (s(), l("div", ie, u(e.errorMessages), 1)) : n("", !0)
197
+ ])) : e.hint && (e.persistentHint || o(w)) ? (s(), l("div", de, u(e.hint), 1)) : n("", !0)
205
198
  ]))
206
199
  ], 16)
207
200
  ], 512));
208
201
  }
209
202
  };
210
203
  export {
211
- ce as default
204
+ ye as default
212
205
  };
@@ -41,7 +41,7 @@ const e = {
41
41
  max: { type: [Number, String], default: 1 / 0 },
42
42
  step: { type: [Number, String], default: 1 },
43
43
  locale: { type: String, default: "es-AR" },
44
- separator: { type: String, default: "." },
44
+ separator: { type: String, default: "," },
45
45
  useGrouping: { type: Boolean, default: !0 },
46
46
  precision: { type: [Number, String], default: 2 }
47
47
  };
@@ -1,7 +1,24 @@
1
- function n(r, l = ",") {
2
- const e = r.replace(/[^\d.,]/g, "");
3
- return l === "," ? e.replace(/\./g, ",") : e.replace(/,/g, ".");
1
+ function o(n, t, r) {
2
+ return Math.min(Math.max(n, Number(t)), Number(r));
3
+ }
4
+ function m(n, t) {
5
+ return new Intl.NumberFormat(t.locale, {
6
+ minimumFractionDigits: t.precision,
7
+ maximumFractionDigits: t.precision,
8
+ useGrouping: t.useGrouping
9
+ }).format(n);
10
+ }
11
+ function u(n, t) {
12
+ return parseFloat(n).toFixed(t).replace(".", "").replace(",", "");
13
+ }
14
+ function c(n, t) {
15
+ if (!n || n.length === 0) return 0;
16
+ const r = n.padStart(t + 1, "0"), e = r.slice(0, -t), i = r.slice(-t), a = `${e}.${i}`;
17
+ return parseFloat(a);
4
18
  }
5
19
  export {
6
- n as normalizeNumber
20
+ o as clamp,
21
+ m as format,
22
+ c as fromRawString,
23
+ u as toRawNumberString
7
24
  };
@@ -1,61 +1,58 @@
1
- import { ref as t, computed as b, watch as g, nextTick as K } from "vue";
2
- import { normalizeNumber as k } from "./numberFormatUtils.js";
3
- function C(e, a) {
4
- const u = t(e.modelValue), r = t(null), s = t(null), f = t(0);
5
- function c(n) {
6
- const l = k(n, e.separator).split(e.separator);
7
- if (l.length > 2) {
8
- d();
1
+ import { ref as o, watch as R } from "vue";
2
+ import { format as i, toRawNumberString as m, fromRawString as r, clamp as f } from "./numberFormatUtils.js";
3
+ function I(e, a) {
4
+ const u = o(""), x = o(null), N = o(null), c = o(!1);
5
+ let t = "";
6
+ R(
7
+ () => e.modelValue,
8
+ (n) => {
9
+ n == null || isNaN(n) ? (u.value = i(0, e), t = "") : (t = m(n, e.precision), u.value = i(parseFloat(n), e));
10
+ },
11
+ { immediate: !0 }
12
+ );
13
+ function V(n) {
14
+ const l = n.key, s = /^[0-9]$/.test(l), v = l === "Backspace";
15
+ if (!s && !v) {
16
+ n.preventDefault();
9
17
  return;
10
18
  }
11
- l.length === 2 && l[1].length > e.precision && (l[1] = l[1].slice(0, e.precision));
12
- const i = l.join(e.separator);
13
- i === u.value ? d() : u.value = i, a("update:modelValue", i);
14
- }
15
- function d() {
16
- f.value++, K(() => {
17
- var n;
18
- (n = r.value) == null || n.focus();
19
- });
19
+ s ? t += l : v && (t = t.slice(0, -1));
20
+ const b = t.padStart(e.precision + 1, "0"), h = b.slice(0, -e.precision), y = b.slice(-e.precision), B = parseFloat(`${h}.${y}`), d = f(B, e.min, e.max);
21
+ u.value = i(d, e), a("input", d), a("update:modelValue", d), n.preventDefault();
20
22
  }
21
- function v() {
22
- c((u.value || 0) + e.step);
23
+ function g() {
24
+ c.value = !1;
25
+ const n = r(t, e.precision), l = f(n, e.min, e.max);
26
+ t = m(l, e.precision), u.value = i(l, e), a("update:modelValue", l), a("blur");
23
27
  }
24
- function m() {
25
- c((u.value || 0) - e.step);
28
+ function k() {
29
+ c.value = !0, a("focus");
26
30
  }
27
- function h() {
28
- u.value = null, a("update:modelValue", null);
29
- }
30
- function V(n) {
31
- ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "‚", ",", "Backspace", "Delete", "ArrowLeft", "ArrowRight"].includes(n.key) || n.preventDefault();
31
+ function D() {
32
+ let n = r(t, e.precision) || 0;
33
+ n = f(n + Number(e.step), e.min, e.max), t = m(n, e.precision), u.value = i(n, e), a("update:modelValue", n);
32
34
  }
33
- const o = t(!1);
34
- function p() {
35
- o.value = !0, u.value || (u.value = ""), a("focus");
35
+ function F() {
36
+ let n = r(t, e.precision) || 0;
37
+ n = f(n - Number(e.step), e.min, e.max), t = m(n, e.precision), u.value = i(n, e), a("update:modelValue", n);
36
38
  }
37
- function I() {
38
- o.value = !1, u.value || (u.value = 0), a("blur");
39
+ function S() {
40
+ t = "", u.value = i(0, e), a("update:modelValue", null);
39
41
  }
40
- const w = b(() => o.value || !!e.modelValue || e.dirty);
41
- return g(() => e.modelValue, (n) => {
42
- u.value = n;
43
- }), {
42
+ return {
44
43
  inputValue: u,
45
- numberInput: r,
46
- rootRef: s,
47
- inputKey: f,
48
- updateValue: c,
49
- onIncrement: v,
50
- onDecrement: m,
51
- onClear: h,
44
+ numberInput: x,
45
+ rootRef: N,
52
46
  validateKey: V,
53
- focus: o,
54
- handleFocus: p,
55
- isActive: w,
56
- handleBlur: I
47
+ handleFocus: k,
48
+ handleBlur: g,
49
+ onIncrement: D,
50
+ onDecrement: F,
51
+ onClear: S,
52
+ isActive: c,
53
+ focus: c
57
54
  };
58
55
  }
59
56
  export {
60
- C as useKunNumberField
57
+ I as useKunNumberField
61
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.374",
3
+ "version": "0.1.376",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",