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