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
|
|
2
|
-
import { KunNumberFieldProps as
|
|
3
|
-
import { useKunNumberField as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
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
|
-
},
|
|
8
|
+
}, Q = ["disabled"], T = {
|
|
9
9
|
key: 1,
|
|
10
10
|
class: "mx-2"
|
|
11
|
-
},
|
|
11
|
+
}, W = {
|
|
12
12
|
key: 2,
|
|
13
13
|
class: "flex items-center justify-center h-full pl-1"
|
|
14
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
20
|
+
}, oe = ["disabled"], re = ["disabled"], le = {
|
|
21
21
|
key: 5,
|
|
22
22
|
class: "flex items-center justify-center h-full pr-1"
|
|
23
|
-
},
|
|
23
|
+
}, se = {
|
|
24
24
|
key: 6,
|
|
25
25
|
class: "h-full"
|
|
26
|
-
},
|
|
26
|
+
}, ne = ["disabled"], de = {
|
|
27
27
|
key: 7,
|
|
28
28
|
class: "ml-2"
|
|
29
|
-
},
|
|
29
|
+
}, ie = {
|
|
30
30
|
key: 0,
|
|
31
31
|
class: "h-[1.25rem]"
|
|
32
|
-
},
|
|
32
|
+
}, ae = {
|
|
33
33
|
key: 0,
|
|
34
34
|
class: "text-red-500 text-sm text-center"
|
|
35
|
-
},
|
|
35
|
+
}, ue = { key: 0 }, pe = { key: 1 }, be = {
|
|
36
36
|
key: 1,
|
|
37
37
|
class: "text-xs text-center"
|
|
38
|
-
},
|
|
38
|
+
}, me = {
|
|
39
39
|
__name: "KunNumberField",
|
|
40
|
-
props:
|
|
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
|
|
51
|
-
inputValue:
|
|
52
|
-
numberInput:
|
|
53
|
-
rootRef:
|
|
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:
|
|
56
|
+
onIncrement: i,
|
|
57
57
|
onDecrement: a,
|
|
58
|
-
onClear:
|
|
58
|
+
onClear: h,
|
|
59
|
+
validateKey: S,
|
|
59
60
|
focus: w,
|
|
60
61
|
handleFocus: g,
|
|
61
|
-
isActive:
|
|
62
|
+
isActive: $,
|
|
62
63
|
handleBlur: C
|
|
63
|
-
} =
|
|
64
|
+
} = J(p, y);
|
|
64
65
|
D({
|
|
65
|
-
numberInput:
|
|
66
|
-
rootRef:
|
|
66
|
+
numberInput: k,
|
|
67
|
+
rootRef: v,
|
|
67
68
|
focus: () => {
|
|
68
69
|
var e;
|
|
69
|
-
return (e =
|
|
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
|
|
73
|
-
return (e,
|
|
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:
|
|
79
|
+
ref: v
|
|
77
80
|
}, [
|
|
78
|
-
e.label ? (
|
|
81
|
+
e.label ? (l(), s("label", {
|
|
79
82
|
key: 0,
|
|
80
83
|
for: c,
|
|
81
|
-
class:
|
|
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
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
class:
|
|
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
|
-
|
|
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" ? (
|
|
98
|
-
|
|
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:
|
|
104
|
+
onClick: o[0] || (o[0] = (...t) => r(a) && r(a)(...t)),
|
|
102
105
|
disabled: e.disabled || e.readonly
|
|
103
|
-
}, "−", 8,
|
|
106
|
+
}, "−", 8, Q)
|
|
104
107
|
])) : n("", !0),
|
|
105
|
-
e.prefix ? (
|
|
106
|
-
e.prependIcon ||
|
|
107
|
-
e.prependIcon ? (
|
|
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
|
-
(
|
|
115
|
+
(l(), s("input", {
|
|
113
116
|
id: c,
|
|
114
117
|
ref_key: "numberInput",
|
|
115
|
-
ref:
|
|
116
|
-
key:
|
|
118
|
+
ref: k,
|
|
119
|
+
key: r(M) + e.modelValue,
|
|
117
120
|
type: "text",
|
|
118
|
-
value:
|
|
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:
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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:
|
|
136
|
-
class:
|
|
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,
|
|
139
|
-
e.noArrows ? n("", !0) : (
|
|
140
|
-
e.controlVariant === "default" ? (
|
|
141
|
-
|
|
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:
|
|
150
|
+
onClick: o[8] || (o[8] = (...t) => r(i) && r(i)(...t)),
|
|
145
151
|
disabled: e.disabled || e.readonly
|
|
146
|
-
}, " ▲ ", 8,
|
|
147
|
-
|
|
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:
|
|
156
|
+
onClick: o[9] || (o[9] = (...t) => r(a) && r(a)(...t)),
|
|
151
157
|
disabled: e.disabled || e.readonly
|
|
152
|
-
}, " ▼ ", 8,
|
|
158
|
+
}, " ▼ ", 8, ee)
|
|
153
159
|
])) : n("", !0),
|
|
154
|
-
e.controlVariant === "stacked" ? (
|
|
155
|
-
|
|
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:
|
|
163
|
+
onClick: o[10] || (o[10] = (...t) => r(i) && r(i)(...t))
|
|
158
164
|
}, [
|
|
159
|
-
|
|
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,
|
|
169
|
+
}, "▲", 8, oe)
|
|
164
170
|
]),
|
|
165
|
-
|
|
171
|
+
d("div", {
|
|
166
172
|
class: "border-t border-slate-600 pt-1 px-3 flex hover:opacity-80 cursor-pointer",
|
|
167
|
-
onClick:
|
|
173
|
+
onClick: o[11] || (o[11] = (...t) => r(a) && r(a)(...t))
|
|
168
174
|
}, [
|
|
169
|
-
|
|
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,
|
|
179
|
+
}, "▼", 8, re)
|
|
174
180
|
])
|
|
175
181
|
])) : n("", !0)
|
|
176
182
|
], 64)),
|
|
177
|
-
e.appendIcon || B ? (
|
|
178
|
-
e.appendIcon ? (
|
|
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" ? (
|
|
184
|
-
|
|
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:
|
|
193
|
+
onClick: o[12] || (o[12] = (...t) => r(i) && r(i)(...t)),
|
|
188
194
|
disabled: e.disabled || e.readonly
|
|
189
|
-
}, "+", 8,
|
|
195
|
+
}, "+", 8, ne)
|
|
190
196
|
])) : n("", !0),
|
|
191
|
-
e.suffix ? (
|
|
197
|
+
e.suffix ? (l(), s("div", de, u(e.suffix), 1)) : n("", !0)
|
|
192
198
|
], 2),
|
|
193
|
-
e.hideDetails ? n("", !0) : (
|
|
194
|
-
e.error || e.errorMessages ? (
|
|
195
|
-
Array.isArray(e.errorMessages) ? (
|
|
196
|
-
(
|
|
197
|
-
])) : typeof e.errorMessages == "string" ? (
|
|
198
|
-
])) : e.hint && (e.persistentHint ||
|
|
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
|
-
|
|
211
|
+
me as default
|
|
206
212
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ref as t, computed as
|
|
2
|
-
import { normalizeNumber as
|
|
3
|
-
function
|
|
4
|
-
const u = t(e.modelValue), r = t(null),
|
|
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 =
|
|
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++,
|
|
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
|
|
24
|
+
function m() {
|
|
25
25
|
c((u.value || 0) - e.step);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
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
|
|
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
|
|
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:
|
|
46
|
+
rootRef: s,
|
|
44
47
|
inputKey: f,
|
|
45
48
|
updateValue: c,
|
|
46
49
|
onIncrement: v,
|
|
47
|
-
onDecrement:
|
|
48
|
-
onClear:
|
|
50
|
+
onDecrement: m,
|
|
51
|
+
onClear: h,
|
|
52
|
+
validateKey: V,
|
|
49
53
|
focus: o,
|
|
50
|
-
handleFocus:
|
|
51
|
-
isActive:
|
|
54
|
+
handleFocus: p,
|
|
55
|
+
isActive: w,
|
|
52
56
|
handleBlur: I
|
|
53
57
|
};
|
|
54
58
|
}
|
|
55
59
|
export {
|
|
56
|
-
|
|
60
|
+
C as useKunNumberField
|
|
57
61
|
};
|