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