adverich-kun-ui 0.1.97 → 0.1.98
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
|
-
import { ref as
|
|
1
|
+
import { ref as c, computed as A, watch as z } from "vue";
|
|
2
2
|
import { isArray as b, isObject as a } from "../../../../utils/utils.js";
|
|
3
|
-
function
|
|
4
|
-
const i =
|
|
3
|
+
function J(t, M, u, s, C) {
|
|
4
|
+
const i = c(null), o = c(null), d = c(null), f = c(!1), v = c(""), w = (e, n) => n.split(".").reduce((r, l) => r && r[l] !== void 0 ? r[l] : null, e), F = A(() => i.value ? b(i.value) ? i.value.length ? h(i.value, t.itemTitle, "hasDefault") : t.placeholderText : a(i.value) ? h(i.value, t.itemTitle, "hasDefault") : i.value.toString() : s.value.length ? t.placeholderText : t.textNoItems), k = A(() => t.itemText.includes(",") ? t.itemText.split(",") : t.itemText);
|
|
5
5
|
function h(e, n, r) {
|
|
6
6
|
if (a(e)) {
|
|
7
7
|
if (n) {
|
|
@@ -11,10 +11,10 @@ function L(t, M, u, s, G) {
|
|
|
11
11
|
return n.split(",").map((l) => e[l]).join(" - ");
|
|
12
12
|
if (n.includes(".")) {
|
|
13
13
|
const l = n.split(".");
|
|
14
|
-
let
|
|
15
|
-
for (const
|
|
16
|
-
|
|
17
|
-
return
|
|
14
|
+
let g = e;
|
|
15
|
+
for (const q of l)
|
|
16
|
+
g = g[q];
|
|
17
|
+
return g;
|
|
18
18
|
}
|
|
19
19
|
return !t.returnObject && typeof e[n] == "number" || e[n] ? e[n].toString() : "";
|
|
20
20
|
}
|
|
@@ -25,21 +25,21 @@ function L(t, M, u, s, G) {
|
|
|
25
25
|
}
|
|
26
26
|
function B(e) {
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
x.value = !1, i.value = e, t.multiple ? (u.value || (u.value = []), j(e) ? e && I(e) : t.returnObject ? u.value.push(e) : a(e) ? t.itemValue ? u.value.push(e[t.itemValue]) : u.value.push(Object.values(e)[0]) : u.value.push(e)) : (t.returnObject ? u.value = e : a(e) ? t.itemValue ? (console.log(1), console.log(e), u.value = e[t.itemValue]) : (console.log(2), u.value = Object.values(e)[0]) : u.value = e, f.value = !1), t.clearOnSelect && T(), x.value = !0;
|
|
29
29
|
} catch (n) {
|
|
30
30
|
console.log(n);
|
|
31
31
|
} finally {
|
|
32
|
-
|
|
32
|
+
O();
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const x = c(!0);
|
|
36
|
+
z(() => u.value, (e) => {
|
|
37
|
+
x.value && (i.value = R(e));
|
|
38
38
|
}, { immediate: !0 });
|
|
39
39
|
function R(e) {
|
|
40
40
|
return e ? t.returnObject ? e : t.multiple && Array.isArray(e) ? e.map((n) => s.value.find((r) => r[t.itemValue] === n)).filter(Boolean) : s.value.find((n) => n[t.itemValue] === e) || null : null;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function j(e) {
|
|
43
43
|
return u.value === null ? !1 : e ? u.value.some(
|
|
44
44
|
(n) => t.returnObject ? n[t.itemValue] === e[t.itemValue] : n === e[t.itemValue]
|
|
45
45
|
) : !0;
|
|
@@ -56,65 +56,65 @@ function L(t, M, u, s, G) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
function D(e) {
|
|
59
|
-
t.clearSearchOnSelect && (
|
|
59
|
+
t.clearSearchOnSelect && (v.value = ""), t.focusOnSelect && O();
|
|
60
60
|
}
|
|
61
61
|
function y() {
|
|
62
|
-
|
|
62
|
+
f.value || (f.value = !0);
|
|
63
63
|
}
|
|
64
64
|
function N() {
|
|
65
|
-
|
|
65
|
+
f.value = !f.value;
|
|
66
66
|
}
|
|
67
67
|
function S(e) {
|
|
68
68
|
return e.length === 1 && e.match(/\w/);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
70
|
+
function O() {
|
|
71
|
+
o.value.inputField.focus();
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
73
|
+
function m() {
|
|
74
|
+
f.value = !0, d.value && o.value.$el.focus();
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function E(e) {
|
|
77
77
|
const n = e.key;
|
|
78
|
-
(S(n) || n === "Backspace") && (y(),
|
|
78
|
+
(S(n) || n === "Backspace") && (y(), O());
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
80
|
+
function K() {
|
|
81
|
+
f.value = !1, M("createItem");
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function P(e) {
|
|
84
84
|
let n = u.value.indexOf(e);
|
|
85
85
|
u.value.splice(n, 1);
|
|
86
86
|
}
|
|
87
87
|
function T() {
|
|
88
|
-
|
|
88
|
+
v.value = "", u.value = null, i.value = null;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function $(e) {
|
|
91
91
|
return !!e.disabledItem;
|
|
92
92
|
}
|
|
93
93
|
return {
|
|
94
94
|
selectedItem: i,
|
|
95
|
-
textFieldRef:
|
|
96
|
-
listRef:
|
|
97
|
-
menuModel:
|
|
98
|
-
search:
|
|
95
|
+
textFieldRef: o,
|
|
96
|
+
listRef: d,
|
|
97
|
+
menuModel: f,
|
|
98
|
+
search: v,
|
|
99
99
|
getItemText: w,
|
|
100
100
|
placeholder: F,
|
|
101
101
|
textArr: k,
|
|
102
102
|
itemToString: h,
|
|
103
103
|
getSelectedItem: B,
|
|
104
|
-
checkIfValueExist:
|
|
104
|
+
checkIfValueExist: j,
|
|
105
105
|
removeFromArray: I,
|
|
106
106
|
lightReset: D,
|
|
107
107
|
openMenu: y,
|
|
108
108
|
toggleMenu: N,
|
|
109
|
-
focusOnMenu:
|
|
110
|
-
onMenuKeydown:
|
|
111
|
-
createItem:
|
|
112
|
-
removeItem:
|
|
109
|
+
focusOnMenu: m,
|
|
110
|
+
onMenuKeydown: E,
|
|
111
|
+
createItem: K,
|
|
112
|
+
removeItem: P,
|
|
113
113
|
clearSelection: T,
|
|
114
|
-
checkDisabled:
|
|
114
|
+
checkDisabled: $,
|
|
115
115
|
isAlphanumeric: S
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
export {
|
|
119
|
-
|
|
119
|
+
J as useAutocomplete
|
|
120
120
|
};
|