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