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