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