adverich-kun-ui 0.1.367 → 0.1.369
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,43 +1,44 @@
|
|
|
1
1
|
import { ref as o, computed as M, watch as H, nextTick as F } from "vue";
|
|
2
|
-
import { isArray as
|
|
3
|
-
function U(
|
|
4
|
-
const l = o(null), d = o(null), y = o(null), f = o(!1), v = o(""), N = (e,
|
|
5
|
-
function
|
|
2
|
+
import { isArray as x, isObject as O, fullCopy as L } from "../../../../utils/utils.js";
|
|
3
|
+
function U(n, h, i, s) {
|
|
4
|
+
const l = o(null), d = o(null), y = o(null), f = o(!1), v = o(""), N = (e, t) => t.split(".").reduce((u, r) => u && u[r] !== void 0 ? u[r] : null, e), B = M(() => l.value ? x(l.value) ? l.value.length ? j(l.value, n.itemTitle, "hasDefault") : n.placeholderText : O(l.value) ? j(l.value, n.itemTitle, "hasDefault") : l.value.toString() : s.value.length ? n.placeholderText : n.textNoItems), R = M(() => n.itemText.includes(",") ? n.itemText.split(",") : n.itemText);
|
|
5
|
+
function j(e, t, u) {
|
|
6
6
|
var r;
|
|
7
|
-
if (
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
7
|
+
if (O(e)) {
|
|
8
|
+
if (t) {
|
|
9
|
+
if (x(t))
|
|
10
|
+
return t.map((c) => e[c] ?? "No definido").join(" - ");
|
|
11
|
+
if (t.includes(","))
|
|
12
|
+
return t.split(",").map((c) => e[c]).join(" - ");
|
|
13
|
+
if (t.includes(".")) {
|
|
14
|
+
const c = t.split(".");
|
|
15
15
|
let a = e;
|
|
16
|
-
for (const
|
|
17
|
-
a = a[
|
|
16
|
+
for (const b of c)
|
|
17
|
+
a = a[b];
|
|
18
18
|
return a;
|
|
19
19
|
}
|
|
20
|
-
return !
|
|
20
|
+
return !n.returnObject && typeof e[t] == "number" || e[t] !== void 0 && e[t] !== null ? e[t].toString() : "";
|
|
21
21
|
}
|
|
22
22
|
if (u)
|
|
23
23
|
return Object.values(e)[0];
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return x(e) ? n.returnObject ? e.map((c) => c[t]).join(" - ") : e.map((c) => c).join(" - ") : u && typeof e != "number" ? e.includes(",") ? e.split(",") : e : ((r = e == null ? void 0 : e.toString) == null ? void 0 : r.call(e)) ?? "";
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function V(e) {
|
|
28
28
|
try {
|
|
29
|
-
let
|
|
30
|
-
if (l.value = L(e), !
|
|
31
|
-
|
|
32
|
-
else if (S(e))
|
|
29
|
+
let t = null;
|
|
30
|
+
if (l.value = L(e), !n.multiple)
|
|
31
|
+
n.returnObject ? t = e : O(e) ? n.itemValue ? t = e[n.itemValue] : t = Object.values(e)[0] : t = e, f.value = !1, g();
|
|
32
|
+
else if (S(e)) {
|
|
33
33
|
e && T(e);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
return;
|
|
35
|
+
} else {
|
|
36
|
+
const u = n.returnObject ? e : O(e) ? n.itemValue ? e[n.itemValue] : Object.values(e)[0] : e;
|
|
37
|
+
t = [...i.value || [], u];
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
} catch (
|
|
40
|
-
console.log(
|
|
39
|
+
i.value === t ? h("update:modelValue", t) : i.value = t, h("selectedItem", l.value);
|
|
40
|
+
} catch (t) {
|
|
41
|
+
console.log(t);
|
|
41
42
|
} finally {
|
|
42
43
|
F(() => {
|
|
43
44
|
I();
|
|
@@ -45,37 +46,29 @@ function U(t, h, c, s) {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
H(
|
|
48
|
-
[() =>
|
|
49
|
+
[() => i.value, () => s.value],
|
|
49
50
|
([e]) => {
|
|
50
|
-
const
|
|
51
|
-
JSON.stringify(l.value) !== JSON.stringify(
|
|
51
|
+
const t = C(e);
|
|
52
|
+
JSON.stringify(l.value) !== JSON.stringify(t) && (l.value = t);
|
|
52
53
|
},
|
|
53
54
|
{ immediate: !0 }
|
|
54
55
|
);
|
|
55
56
|
function C(e) {
|
|
56
|
-
return e == null ? null :
|
|
57
|
-
(u) => typeof u == "object" ? u[
|
|
57
|
+
return e == null ? null : n.multiple && Array.isArray(e) ? n.returnObject ? e : e.map((u) => s.value.find((r) => r[n.itemValue] === u)).filter(Boolean) : n.returnObject ? e : s.value.find(
|
|
58
|
+
(u) => typeof u == "object" ? u[n.itemValue] === e : u === e
|
|
58
59
|
) ?? e;
|
|
59
60
|
}
|
|
60
61
|
function S(e) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
) :
|
|
62
|
+
if (!i.value || !e) return !1;
|
|
63
|
+
const t = n.returnObject ? e[n.itemValue] : e;
|
|
64
|
+
return i.value.some((u) => (n.returnObject ? u[n.itemValue] : u) === t);
|
|
64
65
|
}
|
|
65
66
|
function T(e) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const u = n.find(
|
|
69
|
-
(i) => i[t.itemValue] === e[t.itemValue]
|
|
70
|
-
), r = n.indexOf(u);
|
|
71
|
-
n.splice(r, 1);
|
|
72
|
-
} else {
|
|
73
|
-
const u = n.indexOf(e[t.itemValue]);
|
|
74
|
-
n.splice(u, 1);
|
|
75
|
-
}
|
|
67
|
+
const t = n.returnObject ? e[n.itemValue] : e, u = i.value.filter((r) => (n.returnObject ? r[n.itemValue] : r) !== t);
|
|
68
|
+
i.value = u;
|
|
76
69
|
}
|
|
77
70
|
function I(e) {
|
|
78
|
-
|
|
71
|
+
n.clearSearchOnSelect && (v.value = ""), n.clearOnSelect && w(), n.focusOnSelect && g();
|
|
79
72
|
}
|
|
80
73
|
function A() {
|
|
81
74
|
f.value || (f.value = !0);
|
|
@@ -96,13 +89,13 @@ function U(t, h, c, s) {
|
|
|
96
89
|
f.value = !0, y.value && d.value.$el.focus();
|
|
97
90
|
}
|
|
98
91
|
function $(e) {
|
|
99
|
-
const
|
|
100
|
-
(k(
|
|
92
|
+
const t = e.key;
|
|
93
|
+
(k(t) || t === "Backspace") && (A(), g(), F(() => {
|
|
101
94
|
var r;
|
|
102
95
|
const u = (r = d.value) == null ? void 0 : r.inputField;
|
|
103
96
|
if (u) {
|
|
104
|
-
const
|
|
105
|
-
u.value =
|
|
97
|
+
const c = u.selectionStart, a = u.selectionEnd, b = u.value, E = e.key.length === 1 ? e.key : "";
|
|
98
|
+
u.value = b.slice(0, c) + E + b.slice(a), u.selectionStart = u.selectionEnd = c + E.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
106
99
|
}
|
|
107
100
|
}));
|
|
108
101
|
}
|
|
@@ -110,11 +103,11 @@ function U(t, h, c, s) {
|
|
|
110
103
|
f.value = !1, h("createItem");
|
|
111
104
|
}
|
|
112
105
|
function z(e) {
|
|
113
|
-
let
|
|
114
|
-
|
|
106
|
+
let t = i.value.indexOf(e);
|
|
107
|
+
i.value.splice(t, 1);
|
|
115
108
|
}
|
|
116
109
|
function w() {
|
|
117
|
-
|
|
110
|
+
v.value !== "" && (v.value = ""), i.value !== null && (i.value = null), l.value !== null && (l.value = null);
|
|
118
111
|
}
|
|
119
112
|
function G(e) {
|
|
120
113
|
return !!e.disabled;
|
|
@@ -126,10 +119,10 @@ function U(t, h, c, s) {
|
|
|
126
119
|
menuModel: f,
|
|
127
120
|
search: v,
|
|
128
121
|
getItemText: N,
|
|
129
|
-
placeholder:
|
|
130
|
-
textArr:
|
|
131
|
-
itemToString:
|
|
132
|
-
getSelectedItem:
|
|
122
|
+
placeholder: B,
|
|
123
|
+
textArr: R,
|
|
124
|
+
itemToString: j,
|
|
125
|
+
getSelectedItem: V,
|
|
133
126
|
checkIfValueExist: S,
|
|
134
127
|
removeFromArray: T,
|
|
135
128
|
lightReset: I,
|