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