adverich-kun-ui 0.1.498 → 0.1.500
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,7 +1,7 @@
|
|
|
1
1
|
import { ref as d, computed as M, watch as H, nextTick as F } from "vue";
|
|
2
2
|
import { isArray as S, isObject as O, fullCopy as L } from "../../../../utils/utils.js";
|
|
3
3
|
function U(t, y, c, v) {
|
|
4
|
-
const l = d(null),
|
|
4
|
+
const l = d(null), b = d(null), x = d(null), i = d(!1), g = d(""), N = (e, n) => {
|
|
5
5
|
if (t.returnObject) return s(e, t.itemTitle);
|
|
6
6
|
const u = l.value.find((f) => f[t.itemValue] === e);
|
|
7
7
|
return s(u, t.itemTitle);
|
|
@@ -41,7 +41,6 @@ function U(t, y, c, v) {
|
|
|
41
41
|
return S(e) ? t.returnObject ? e.map((r) => r[n]).join(" - ") : e.map((r) => r).join(" - ") : u && typeof e != "number" ? e.includes(",") ? e.split(",") : e : ((f = e == null ? void 0 : e.toString) == null ? void 0 : f.call(e)) ?? "";
|
|
42
42
|
}
|
|
43
43
|
function C(e) {
|
|
44
|
-
console.log(e);
|
|
45
44
|
try {
|
|
46
45
|
let n = null;
|
|
47
46
|
if (l.value = L(e), !t.multiple)
|
|
@@ -85,7 +84,7 @@ function U(t, y, c, v) {
|
|
|
85
84
|
c.value = c.value.filter((u) => u !== n);
|
|
86
85
|
}
|
|
87
86
|
function A(e) {
|
|
88
|
-
t.clearSearchOnSelect && (
|
|
87
|
+
t.clearSearchOnSelect && (g.value = ""), t.clearOnSelect && E(), t.focusOnSelect && j();
|
|
89
88
|
}
|
|
90
89
|
function k() {
|
|
91
90
|
i.value || (i.value = !0);
|
|
@@ -100,16 +99,16 @@ function U(t, y, c, v) {
|
|
|
100
99
|
return e.length === 1 && e.match(/\w/);
|
|
101
100
|
}
|
|
102
101
|
function j() {
|
|
103
|
-
|
|
102
|
+
b.value.inputField.focus();
|
|
104
103
|
}
|
|
105
104
|
function K() {
|
|
106
|
-
i.value = !0, x.value &&
|
|
105
|
+
i.value = !0, x.value && b.value.$el.focus();
|
|
107
106
|
}
|
|
108
107
|
function $(e) {
|
|
109
108
|
const n = e.key;
|
|
110
109
|
(w(n) || n === "Backspace") && (k(), j(), F(() => {
|
|
111
110
|
var f;
|
|
112
|
-
const u = (f =
|
|
111
|
+
const u = (f = b.value) == null ? void 0 : f.inputField;
|
|
113
112
|
if (u) {
|
|
114
113
|
const r = u.selectionStart, o = u.selectionEnd, a = u.value, h = e.key.length === 1 ? e.key : "";
|
|
115
114
|
u.value = a.slice(0, r) + h + a.slice(o), u.selectionStart = u.selectionEnd = r + h.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
@@ -124,17 +123,17 @@ function U(t, y, c, v) {
|
|
|
124
123
|
c.value.splice(n, 1);
|
|
125
124
|
}
|
|
126
125
|
function E() {
|
|
127
|
-
|
|
126
|
+
g.value !== "" && (g.value = ""), c.value !== null && (c.value = null), l.value !== null && (l.value = null);
|
|
128
127
|
}
|
|
129
128
|
function G(e) {
|
|
130
129
|
return !!e.disabled;
|
|
131
130
|
}
|
|
132
131
|
return {
|
|
133
132
|
selectedItem: l,
|
|
134
|
-
textFieldRef:
|
|
133
|
+
textFieldRef: b,
|
|
135
134
|
listRef: x,
|
|
136
135
|
menuModel: i,
|
|
137
|
-
search:
|
|
136
|
+
search: g,
|
|
138
137
|
getArrayText: N,
|
|
139
138
|
placeholder: B,
|
|
140
139
|
textArr: R,
|
|
@@ -44,10 +44,11 @@ const R = { class: "absolute inset-0 flex items-center justify-center z-10" }, G
|
|
|
44
44
|
icon: [Boolean, String, Function, Object, Array],
|
|
45
45
|
prependIcon: [String, Function, Object, Array],
|
|
46
46
|
appendIcon: [String, Function, Object, Array],
|
|
47
|
-
iconSize: { type: String, default: null }
|
|
47
|
+
iconSize: { type: String, default: null },
|
|
48
|
+
focusColor: { type: String, default: null }
|
|
48
49
|
},
|
|
49
50
|
setup(n, { expose: v }) {
|
|
50
|
-
const
|
|
51
|
+
const g = O(), a = W(), t = n, k = r(() => !!t.to || !!t.href), S = r(() => !k.value), $ = r(() => t.href ? "a" : t.to ? H : "button"), f = (e) => !e || e === !1 || e === !0 && !t.icon ? null : q(P, {
|
|
51
52
|
icon: e,
|
|
52
53
|
size: z.value,
|
|
53
54
|
color: t.textColor ?? "text-font-color",
|
|
@@ -119,7 +120,7 @@ const R = { class: "absolute inset-0 flex items-center justify-center z-10" }, G
|
|
|
119
120
|
default:
|
|
120
121
|
return `${e} ${s}`;
|
|
121
122
|
}
|
|
122
|
-
}), j = r(() => !!t.text),
|
|
123
|
+
}), j = r(() => !!t.text), h = r(() => {
|
|
123
124
|
var e, s, o;
|
|
124
125
|
return ((e = a.class) == null ? void 0 : e.includes("w-")) || ((s = a.class) == null ? void 0 : s.includes("min-w-")) || ((o = a.class) == null ? void 0 : o.includes("max-w-"));
|
|
125
126
|
}), I = r(() => {
|
|
@@ -127,8 +128,8 @@ const R = { class: "absolute inset-0 flex items-center justify-center z-10" }, G
|
|
|
127
128
|
return ((e = a.class) == null ? void 0 : e.includes("h-")) || ((s = a.class) == null ? void 0 : s.includes("min-h-")) || ((o = a.class) == null ? void 0 : o.includes("max-h-"));
|
|
128
129
|
}), p = r(() => {
|
|
129
130
|
var s;
|
|
130
|
-
const e = ((s = t.text) == null ? void 0 : s.length) === 1 && !
|
|
131
|
-
return !!t.icon && !t.text && !
|
|
131
|
+
const e = ((s = t.text) == null ? void 0 : s.length) === 1 && !g.default && !t.icon;
|
|
132
|
+
return !!t.icon && !t.text && !g.default || e;
|
|
132
133
|
}), A = r(() => {
|
|
133
134
|
const e = [
|
|
134
135
|
"inline-flex items-center justify-center break-keep transition-all whitespace-nowrap",
|
|
@@ -171,8 +172,9 @@ const R = { class: "absolute inset-0 flex items-center justify-center z-10" }, G
|
|
|
171
172
|
t.ring ? "focus:ring-2 focus:ring-offset-2" : "",
|
|
172
173
|
"active:scale-[.98]",
|
|
173
174
|
"transition duration-100 ease-in-out",
|
|
174
|
-
"cursor-pointer"
|
|
175
|
-
|
|
175
|
+
"cursor-pointer",
|
|
176
|
+
t.focusColor ? `focus:${t.focusColor}` : ""
|
|
177
|
+
) : (e.push("pointer-events-none"), t.disabled && e.push("opacity-50 cursor-not-allowed")), j.value && !p.value && !h.value && e.push(t.minWidth), e.filter(Boolean);
|
|
176
178
|
}), b = E(null);
|
|
177
179
|
return v({
|
|
178
180
|
focus: () => {
|
|
@@ -189,7 +191,7 @@ const R = { class: "absolute inset-0 flex items-center justify-center z-10" }, G
|
|
|
189
191
|
}), {
|
|
190
192
|
default: V(() => [
|
|
191
193
|
x("div", {
|
|
192
|
-
class: y(["relative flex items-center justify-center",
|
|
194
|
+
class: y(["relative flex items-center justify-center", h.value ? "" : "w-full", I.value ? "" : "h-full"])
|
|
193
195
|
}, [
|
|
194
196
|
n.loading ? u(e.$slots, "loader", { key: 0 }, () => [
|
|
195
197
|
x("div", R, [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ref as a, inject as V, computed as E, watch as
|
|
1
|
+
import { ref as a, inject as V, computed as E, watch as F, onUnmounted as T } from "vue";
|
|
2
2
|
import { debounce as j } from "../../../../utils/utils.js";
|
|
3
3
|
function R(u, r) {
|
|
4
|
-
const l = a(u.modelValue ?? ""), o = a(!1), t = a(""), n = a(!1),
|
|
4
|
+
const l = a(u.modelValue ?? ""), o = a(!1), t = a(""), n = a(!1), g = a(null), h = a(null), s = a(!1), d = V("registerField", null), v = V("unregisterField", null), y = E(() => u.error || !!t.value && n.value), c = async () => {
|
|
5
5
|
for (const e of u.rules) {
|
|
6
6
|
const m = await Promise.resolve(e(l.value));
|
|
7
7
|
if (m !== !0) return m;
|
|
@@ -11,9 +11,9 @@ function R(u, r) {
|
|
|
11
11
|
const e = await c();
|
|
12
12
|
t.value = e === !0 ? "" : e;
|
|
13
13
|
}, u.debounce ?? 300);
|
|
14
|
-
|
|
14
|
+
F(() => u.modelValue, (e) => {
|
|
15
15
|
e !== l.value && (s.value = !0, l.value = e ?? "");
|
|
16
|
-
}),
|
|
16
|
+
}), F(l, () => {
|
|
17
17
|
if (s.value) {
|
|
18
18
|
s.value = !1;
|
|
19
19
|
return;
|
|
@@ -29,7 +29,7 @@ function R(u, r) {
|
|
|
29
29
|
}
|
|
30
30
|
r("blur");
|
|
31
31
|
}, B = () => {
|
|
32
|
-
|
|
32
|
+
o.value = !0, r("focus");
|
|
33
33
|
}, I = () => {
|
|
34
34
|
l.value = "", r("update:modelValue", ""), n.value = !0, u.validateOnBlur || f();
|
|
35
35
|
}, i = async () => {
|
|
@@ -44,7 +44,7 @@ function R(u, r) {
|
|
|
44
44
|
return d && d({ validate: i }), T(() => {
|
|
45
45
|
v && v({ validate: i });
|
|
46
46
|
}), {
|
|
47
|
-
inputField:
|
|
47
|
+
inputField: g,
|
|
48
48
|
inputValue: l,
|
|
49
49
|
rootRef: h,
|
|
50
50
|
inputFocused: o,
|