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