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