adverich-kun-ui 0.1.373 → 0.1.375

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