adverich-kun-ui 0.1.98 → 0.1.100
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,31 +1,31 @@
|
|
|
1
1
|
import { ref as c, computed as A, watch as z } from "vue";
|
|
2
|
-
import { isArray as
|
|
2
|
+
import { isArray as d, isObject as a } from "../../../../utils/utils.js";
|
|
3
3
|
function J(t, M, u, s, C) {
|
|
4
|
-
const
|
|
4
|
+
const l = c(null), v = c(null), j = c(null), f = c(!1), o = c(""), w = (e, n) => n.split(".").reduce((r, i) => r && r[i] !== void 0 ? r[i] : null, e), F = A(() => l.value ? d(l.value) ? l.value.length ? h(l.value, t.itemTitle, "hasDefault") : t.placeholderText : a(l.value) ? h(l.value, t.itemTitle, "hasDefault") : l.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) {
|
|
8
|
-
if (
|
|
9
|
-
return n.map((
|
|
8
|
+
if (d(n))
|
|
9
|
+
return n.map((i) => e[i] ?? "No definido").join(" - ");
|
|
10
10
|
if (n.includes(","))
|
|
11
|
-
return n.split(",").map((
|
|
11
|
+
return n.split(",").map((i) => e[i]).join(" - ");
|
|
12
12
|
if (n.includes(".")) {
|
|
13
|
-
const
|
|
14
|
-
let
|
|
15
|
-
for (const q of
|
|
16
|
-
|
|
17
|
-
return
|
|
13
|
+
const i = n.split(".");
|
|
14
|
+
let b = e;
|
|
15
|
+
for (const q of i)
|
|
16
|
+
b = b[q];
|
|
17
|
+
return b;
|
|
18
18
|
}
|
|
19
19
|
return !t.returnObject && typeof e[n] == "number" || e[n] ? e[n].toString() : "";
|
|
20
20
|
}
|
|
21
21
|
if (r)
|
|
22
22
|
return Object.values(e)[0];
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return d(e) ? t.returnObject ? e.map((i) => i[n]).join(" - ") : e.map((i) => i).join(" - ") : r && typeof e != "number" && e.includes(",") ? e.split(",") : e;
|
|
25
25
|
}
|
|
26
26
|
function B(e) {
|
|
27
27
|
try {
|
|
28
|
-
x.value = !1,
|
|
28
|
+
x.value = !1, l.value = e, t.multiple ? (u.value || (u.value = []), g(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 ? u.value = e[t.itemValue] : 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 {
|
|
@@ -34,12 +34,12 @@ function J(t, M, u, s, C) {
|
|
|
34
34
|
}
|
|
35
35
|
const x = c(!0);
|
|
36
36
|
z(() => u.value, (e) => {
|
|
37
|
-
x.value && (
|
|
37
|
+
x.value && (l.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 g(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;
|
|
@@ -47,7 +47,7 @@ function J(t, M, u, s, C) {
|
|
|
47
47
|
function I(e) {
|
|
48
48
|
if (t.returnObject) {
|
|
49
49
|
const n = u.value.find(
|
|
50
|
-
(
|
|
50
|
+
(i) => i[t.itemValue] === e[t.itemValue]
|
|
51
51
|
), r = u.value.indexOf(n);
|
|
52
52
|
u.value.splice(r, 1);
|
|
53
53
|
} else {
|
|
@@ -55,23 +55,23 @@ function J(t, M, u, s, C) {
|
|
|
55
55
|
u.value.splice(n, 1);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
t.clearSearchOnSelect && (
|
|
58
|
+
function m(e) {
|
|
59
|
+
t.clearSearchOnSelect && (o.value = ""), t.focusOnSelect && O();
|
|
60
60
|
}
|
|
61
61
|
function y() {
|
|
62
62
|
f.value || (f.value = !0);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function D() {
|
|
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
70
|
function O() {
|
|
71
|
-
|
|
71
|
+
v.value.inputField.focus();
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
f.value = !0,
|
|
73
|
+
function N() {
|
|
74
|
+
f.value = !0, j.value && v.value.$el.focus();
|
|
75
75
|
}
|
|
76
76
|
function E(e) {
|
|
77
77
|
const n = e.key;
|
|
@@ -85,28 +85,28 @@ function J(t, M, u, s, C) {
|
|
|
85
85
|
u.value.splice(n, 1);
|
|
86
86
|
}
|
|
87
87
|
function T() {
|
|
88
|
-
|
|
88
|
+
o.value = "", u.value = null, l.value = null;
|
|
89
89
|
}
|
|
90
90
|
function $(e) {
|
|
91
91
|
return !!e.disabledItem;
|
|
92
92
|
}
|
|
93
93
|
return {
|
|
94
|
-
selectedItem:
|
|
95
|
-
textFieldRef:
|
|
96
|
-
listRef:
|
|
94
|
+
selectedItem: l,
|
|
95
|
+
textFieldRef: v,
|
|
96
|
+
listRef: j,
|
|
97
97
|
menuModel: f,
|
|
98
|
-
search:
|
|
98
|
+
search: o,
|
|
99
99
|
getItemText: w,
|
|
100
100
|
placeholder: F,
|
|
101
101
|
textArr: k,
|
|
102
102
|
itemToString: h,
|
|
103
103
|
getSelectedItem: B,
|
|
104
|
-
checkIfValueExist:
|
|
104
|
+
checkIfValueExist: g,
|
|
105
105
|
removeFromArray: I,
|
|
106
|
-
lightReset:
|
|
106
|
+
lightReset: m,
|
|
107
107
|
openMenu: y,
|
|
108
|
-
toggleMenu:
|
|
109
|
-
focusOnMenu:
|
|
108
|
+
toggleMenu: D,
|
|
109
|
+
focusOnMenu: N,
|
|
110
110
|
onMenuKeydown: E,
|
|
111
111
|
createItem: K,
|
|
112
112
|
removeItem: P,
|