adverich-kun-ui 0.1.371 → 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,22 +1,22 @@
|
|
|
1
|
-
import { getCurrentInstance as P, ref as s, computed as
|
|
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
2
|
import { KunNumberFieldProps as U } from "../composables/KunNumberFieldProps.js";
|
|
3
|
-
import { parseNumber as
|
|
4
|
-
const
|
|
3
|
+
import { parseNumber as C } from "../composables/numberFormatUtils.js";
|
|
4
|
+
const H = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "mx-2"
|
|
7
|
-
},
|
|
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 = {
|
|
11
11
|
key: 3,
|
|
12
12
|
class: "ml-2"
|
|
13
|
-
},
|
|
13
|
+
}, O = {
|
|
14
14
|
key: 0,
|
|
15
15
|
class: "h-[1.25rem]"
|
|
16
|
-
},
|
|
16
|
+
}, Q = ["id"], W = {
|
|
17
17
|
key: 1,
|
|
18
18
|
class: "text-xs text-center"
|
|
19
|
-
},
|
|
19
|
+
}, _ = {
|
|
20
20
|
__name: "KunNumberField",
|
|
21
21
|
props: U,
|
|
22
22
|
emits: [
|
|
@@ -28,7 +28,7 @@ const x = {
|
|
|
28
28
|
"keyUp"
|
|
29
29
|
],
|
|
30
30
|
setup(I, { expose: F, emit: D }) {
|
|
31
|
-
const l = I, n = D, v = `number-input-${P().uid}`, h = s(null),
|
|
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
32
|
function m(e, t = ".", p = 2) {
|
|
33
33
|
return e == null || isNaN(e) ? "" : Number(e).toFixed(p).replace(".", t);
|
|
34
34
|
}
|
|
@@ -40,31 +40,32 @@ const x = {
|
|
|
40
40
|
const t = m(e, l.separator, l.precision);
|
|
41
41
|
t !== r.value && (r.value = t);
|
|
42
42
|
});
|
|
43
|
-
|
|
43
|
+
const B = g(() => l.density === "compact" ? "p-1" : l.density === "comfortable" ? "p-2" : "p-3");
|
|
44
|
+
function E(e) {
|
|
44
45
|
r.value = e.target.value;
|
|
45
|
-
const t =
|
|
46
|
+
const t = C(r.value, l.separator);
|
|
46
47
|
i.value = !0, n("update:modelValue", t);
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function K() {
|
|
49
50
|
d.value = !1, k.value = !0, n("blur");
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function j() {
|
|
52
53
|
d.value = !0, n("focus");
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function x() {
|
|
55
56
|
r.value = "", i.value = !0, n("update:modelValue", null), k.value = !0;
|
|
56
57
|
}
|
|
57
58
|
function z() {
|
|
58
|
-
const t = (
|
|
59
|
+
const t = (C(r.value, l.separator) || 0) + Number(l.step);
|
|
59
60
|
r.value = m(t, l.separator, l.precision), i.value = !0, n("update:modelValue", t);
|
|
60
61
|
}
|
|
61
62
|
function A() {
|
|
62
|
-
const t = (
|
|
63
|
+
const t = (C(r.value, l.separator) || 0) - Number(l.step);
|
|
63
64
|
r.value = m(t, l.separator, l.precision), i.value = !0, n("update:modelValue", t);
|
|
64
65
|
}
|
|
65
66
|
return F({
|
|
66
67
|
inputField: h,
|
|
67
|
-
rootRef:
|
|
68
|
+
rootRef: w,
|
|
68
69
|
focus: () => {
|
|
69
70
|
var e;
|
|
70
71
|
return (e = h.value) == null ? void 0 : e.focus();
|
|
@@ -72,7 +73,7 @@ const x = {
|
|
|
72
73
|
}), (e, t) => (a(), o("div", {
|
|
73
74
|
class: "w-full flex flex-col relative",
|
|
74
75
|
ref_key: "rootRef",
|
|
75
|
-
ref:
|
|
76
|
+
ref: w
|
|
76
77
|
}, [
|
|
77
78
|
e.label ? (a(), o("label", {
|
|
78
79
|
key: 0,
|
|
@@ -93,7 +94,7 @@ const x = {
|
|
|
93
94
|
b.value ? "bg-red-200 dark:bg-red-900" : ""
|
|
94
95
|
]])
|
|
95
96
|
}, [
|
|
96
|
-
e.prefix ? (a(), o("div",
|
|
97
|
+
e.prefix ? (a(), o("div", H, f(e.prefix), 1)) : u("", !0),
|
|
97
98
|
V(e.$slots, "prepend-inner"),
|
|
98
99
|
c("input", {
|
|
99
100
|
ref_key: "inputField",
|
|
@@ -108,48 +109,48 @@ const x = {
|
|
|
108
109
|
autocomplete: "off",
|
|
109
110
|
"aria-invalid": b.value ? "true" : "false",
|
|
110
111
|
"aria-describedby": b.value ? `error-${v}` : null,
|
|
111
|
-
class: y([
|
|
112
|
-
onInput:
|
|
113
|
-
onBlur:
|
|
114
|
-
onFocus:
|
|
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,
|
|
115
116
|
onKeydown: t[0] || (t[0] = (p) => n("keyDown", p)),
|
|
116
117
|
onKeyup: t[1] || (t[1] = (p) => n("keyUp", p))
|
|
117
|
-
}, null, 42,
|
|
118
|
+
}, null, 42, M),
|
|
118
119
|
e.clearable && r.value ? (a(), o("button", {
|
|
119
120
|
key: 1,
|
|
120
121
|
type: "button",
|
|
121
|
-
onClick:
|
|
122
|
+
onClick: x,
|
|
122
123
|
class: y(["ml-2", e.textColor]),
|
|
123
124
|
disabled: e.disabled || e.readonly
|
|
124
|
-
}, " × ", 10,
|
|
125
|
-
e.noArrows ? u("", !0) : (a(), o("div",
|
|
125
|
+
}, " × ", 10, T)) : u("", !0),
|
|
126
|
+
e.noArrows ? u("", !0) : (a(), o("div", q, [
|
|
126
127
|
c("button", {
|
|
127
128
|
type: "button",
|
|
128
129
|
class: "p-2",
|
|
129
130
|
onClick: z,
|
|
130
131
|
disabled: e.disabled || e.readonly
|
|
131
|
-
}, "▲", 8,
|
|
132
|
+
}, "▲", 8, G),
|
|
132
133
|
c("button", {
|
|
133
134
|
type: "button",
|
|
134
135
|
class: "p-2",
|
|
135
136
|
onClick: A,
|
|
136
137
|
disabled: e.disabled || e.readonly
|
|
137
|
-
}, "▼", 8,
|
|
138
|
+
}, "▼", 8, J)
|
|
138
139
|
])),
|
|
139
140
|
V(e.$slots, "append-inner"),
|
|
140
|
-
e.suffix ? (a(), o("div",
|
|
141
|
+
e.suffix ? (a(), o("div", L, f(e.suffix), 1)) : u("", !0)
|
|
141
142
|
], 2),
|
|
142
|
-
e.hideDetails ? u("", !0) : (a(), o("div",
|
|
143
|
+
e.hideDetails ? u("", !0) : (a(), o("div", O, [
|
|
143
144
|
b.value ? (a(), o("div", {
|
|
144
145
|
key: 0,
|
|
145
146
|
id: `error-${v}`,
|
|
146
147
|
class: "text-red-500 text-sm text-center"
|
|
147
|
-
}, f(
|
|
148
|
+
}, f(N.value || e.errorMessage), 9, Q)) : e.hint && (e.persistentHint || d.value) ? (a(), o("div", W, f(e.hint), 1)) : u("", !0)
|
|
148
149
|
]))
|
|
149
150
|
], 16)
|
|
150
151
|
], 512));
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
154
|
export {
|
|
154
|
-
|
|
155
|
+
_ as default
|
|
155
156
|
};
|