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