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