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