adverich-kun-ui 0.1.434 → 0.1.435
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,4 +1,4 @@
|
|
|
1
|
-
import { mergeModels as z, useModel as
|
|
1
|
+
import { mergeModels as z, useModel as S, onMounted as ie, ref as A, watch as ne, createElementBlock as k, openBlock as a, createVNode as n, unref as l, isRef as R, createSlots as re, withCtx as i, createCommentVNode as v, Fragment as ae, renderList as se, createBlock as m, createElementVNode as ue, createTextVNode as b, toDisplayString as V, normalizeClass as de, withModifiers as ce } from "vue";
|
|
2
2
|
import { icons as f } from "../../../../icons/index.js";
|
|
3
3
|
import { isNotEmpty as _, isArray as B } from "../../../../utils/utils.js";
|
|
4
4
|
import me from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
|
|
@@ -7,8 +7,8 @@ import F from "../../../KunListItem/src/components/KunListItem.vue.js";
|
|
|
7
7
|
import T from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
|
|
8
8
|
import pe from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
|
|
9
9
|
import he from "../../../KunMenu/src/components/KunMenu.vue.js";
|
|
10
|
-
import { useAutocomplete as
|
|
11
|
-
import { KunAutocompleteProps as
|
|
10
|
+
import { useAutocomplete as ke } from "../composables/useAutocomplete.js";
|
|
11
|
+
import { KunAutocompleteProps as ve } from "../composables/KunAutocompleteProps.js";
|
|
12
12
|
import be from "../../../KunTextField/src/components/KunTextField.vue.js";
|
|
13
13
|
import ye from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
14
14
|
import ge from "../../../KunChip/src/components/KunChip.vue.js";
|
|
@@ -21,7 +21,7 @@ const Ce = {
|
|
|
21
21
|
class: "sticky top-0 z-10 p-2 border-b bg-select-background"
|
|
22
22
|
}, Le = {
|
|
23
23
|
__name: "KunAutocomplete",
|
|
24
|
-
props: /* @__PURE__ */ z(
|
|
24
|
+
props: /* @__PURE__ */ z(ve, {
|
|
25
25
|
modelValue: { default: null },
|
|
26
26
|
modelModifiers: {},
|
|
27
27
|
items: { default: [], type: Array, required: !0 },
|
|
@@ -29,15 +29,15 @@ const Ce = {
|
|
|
29
29
|
}),
|
|
30
30
|
emits: /* @__PURE__ */ z(["update:modelValue", "selectedItem", "createItem", "validation", "search"], ["update:modelValue", "update:items"]),
|
|
31
31
|
setup(g, { emit: E }) {
|
|
32
|
-
const r =
|
|
32
|
+
const r = S(g, "modelValue"), I = S(g, "items"), u = g, p = E, {
|
|
33
33
|
textFieldRef: C,
|
|
34
|
-
listRef:
|
|
34
|
+
listRef: M,
|
|
35
35
|
menuModel: s,
|
|
36
36
|
search: c,
|
|
37
37
|
removeItem: N,
|
|
38
38
|
clearSelection: L,
|
|
39
39
|
lightReset: O,
|
|
40
|
-
openMenu:
|
|
40
|
+
openMenu: w,
|
|
41
41
|
closeMenu: U,
|
|
42
42
|
toggleMenu: x,
|
|
43
43
|
onMenuKeydown: H,
|
|
@@ -49,11 +49,11 @@ const Ce = {
|
|
|
49
49
|
checkDisabled: J,
|
|
50
50
|
itemToString: D,
|
|
51
51
|
placeholder: Q
|
|
52
|
-
} =
|
|
52
|
+
} = ke(u, p, r, I);
|
|
53
53
|
ie(() => {
|
|
54
54
|
u.focusOnRender && C.value.focus();
|
|
55
55
|
});
|
|
56
|
-
const K =
|
|
56
|
+
const K = A(null), h = A(""), $ = (e) => {
|
|
57
57
|
for (const o of u.rules) {
|
|
58
58
|
const t = o(e);
|
|
59
59
|
if (t !== !0)
|
|
@@ -75,7 +75,7 @@ const Ce = {
|
|
|
75
75
|
U();
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
(j(o) || o === "Backspace") &&
|
|
78
|
+
(j(o) || o === "Backspace") && w(), ["ArrowUp", "ArrowDown"].includes(o) && (e.preventDefault(), s.value || w(), (d = (t = M.value) == null ? void 0 : t.focusWithKey) == null || d.call(t, o));
|
|
79
79
|
}
|
|
80
80
|
function Z(e) {
|
|
81
81
|
p("search", c);
|
|
@@ -88,7 +88,7 @@ const Ce = {
|
|
|
88
88
|
}
|
|
89
89
|
function te() {
|
|
90
90
|
}
|
|
91
|
-
return (e, o) => (a(),
|
|
91
|
+
return (e, o) => (a(), k("div", {
|
|
92
92
|
class: "w-full h-fit",
|
|
93
93
|
ref_key: "parentRef",
|
|
94
94
|
ref: K
|
|
@@ -96,7 +96,7 @@ const Ce = {
|
|
|
96
96
|
n(be, {
|
|
97
97
|
modelValue: l(c),
|
|
98
98
|
"onUpdate:modelValue": [
|
|
99
|
-
o[1] || (o[1] = (t) =>
|
|
99
|
+
o[1] || (o[1] = (t) => R(c) ? c.value = t : null),
|
|
100
100
|
Z
|
|
101
101
|
],
|
|
102
102
|
label: e.label,
|
|
@@ -116,14 +116,14 @@ const Ce = {
|
|
|
116
116
|
"error-messages": h.value
|
|
117
117
|
}, re({
|
|
118
118
|
default: i(() => [
|
|
119
|
-
l(B)(r.value) && l(_)(r.value) ? (a(),
|
|
120
|
-
(a(!0),
|
|
119
|
+
l(B)(r.value) && l(_)(r.value) ? (a(), k("div", Ce, [
|
|
120
|
+
(a(!0), k(ae, null, se(r.value, (t) => (a(), m(ge, {
|
|
121
121
|
key: t.id ?? t.name,
|
|
122
122
|
size: "small"
|
|
123
123
|
}, {
|
|
124
124
|
default: i(() => [
|
|
125
125
|
ue("div", we, [
|
|
126
|
-
b(
|
|
126
|
+
b(V(l(W)(t, e.itemTitle)) + " ", 1),
|
|
127
127
|
n(y, {
|
|
128
128
|
color: "error",
|
|
129
129
|
icon: l(f).close,
|
|
@@ -135,12 +135,12 @@ const Ce = {
|
|
|
135
135
|
]),
|
|
136
136
|
_: 2
|
|
137
137
|
}, 1024))), 128))
|
|
138
|
-
])) :
|
|
138
|
+
])) : v("", !0),
|
|
139
139
|
n(he, {
|
|
140
140
|
transition: "fade",
|
|
141
141
|
"onClick:outside": l(O),
|
|
142
142
|
modelValue: l(s),
|
|
143
|
-
"onUpdate:modelValue": o[0] || (o[0] = (t) =>
|
|
143
|
+
"onUpdate:modelValue": o[0] || (o[0] = (t) => R(s) ? s.value = t : null),
|
|
144
144
|
activator: "parent",
|
|
145
145
|
"z-index": e.zIndex,
|
|
146
146
|
"parent-ref": K.value,
|
|
@@ -153,28 +153,28 @@ const Ce = {
|
|
|
153
153
|
"hide-details": e.hideDetails
|
|
154
154
|
}, {
|
|
155
155
|
default: i(() => [
|
|
156
|
-
e.hasCreateItem ? (a(),
|
|
156
|
+
e.hasCreateItem ? (a(), k("div", Ve, [
|
|
157
157
|
n(ye, {
|
|
158
158
|
onClick: l(G),
|
|
159
159
|
bgColor: e.btnCreateBg,
|
|
160
160
|
class: de(e.btnCreateClass)
|
|
161
161
|
}, {
|
|
162
162
|
default: i(() => [
|
|
163
|
-
b(
|
|
163
|
+
b(V(e.btnCreateText), 1)
|
|
164
164
|
]),
|
|
165
165
|
_: 1
|
|
166
166
|
}, 8, ["onClick", "bgColor", "class"])
|
|
167
|
-
])) :
|
|
167
|
+
])) : v("", !0),
|
|
168
168
|
n(fe, {
|
|
169
169
|
"onClick:select": l(q),
|
|
170
170
|
ref_key: "listRef",
|
|
171
|
-
ref:
|
|
171
|
+
ref: M,
|
|
172
172
|
onKeyDown: le,
|
|
173
173
|
selectable: !0
|
|
174
174
|
}, {
|
|
175
175
|
default: i(() => [
|
|
176
176
|
n(me, {
|
|
177
|
-
items:
|
|
177
|
+
items: I.value,
|
|
178
178
|
search: l(c),
|
|
179
179
|
"searchable-keys": u.searchableKeys,
|
|
180
180
|
virtual: !1,
|
|
@@ -197,7 +197,7 @@ const Ce = {
|
|
|
197
197
|
default: i(() => [
|
|
198
198
|
n(T, { class: "text-wrap" }, {
|
|
199
199
|
default: i(() => [
|
|
200
|
-
b(
|
|
200
|
+
b(V(l(D)(t, e.itemTitle ?? l(P), "hasDefault")), 1)
|
|
201
201
|
]),
|
|
202
202
|
_: 2
|
|
203
203
|
}, 1024),
|
|
@@ -243,13 +243,13 @@ const Ce = {
|
|
|
243
243
|
color: "error",
|
|
244
244
|
icon: l(f).close,
|
|
245
245
|
class: "mr-1 mt-1"
|
|
246
|
-
}, null, 8, ["onClick", "icon"])) :
|
|
246
|
+
}, null, 8, ["onClick", "icon"])) : v("", !0),
|
|
247
247
|
n(y, {
|
|
248
248
|
color: "teal-darken-1",
|
|
249
249
|
size: "large",
|
|
250
250
|
class: "cursor-pointer",
|
|
251
251
|
icon: l(s) ? l(f).menuUpOutline : l(f).menuDownOutline,
|
|
252
|
-
onClick: ce(l(
|
|
252
|
+
onClick: ce(l(w), ["stop"])
|
|
253
253
|
}, null, 8, ["icon", "onClick"]),
|
|
254
254
|
e.required ? (a(), m(y, {
|
|
255
255
|
key: 1,
|
|
@@ -257,7 +257,7 @@ const Ce = {
|
|
|
257
257
|
size: "x-small",
|
|
258
258
|
class: "mb-4",
|
|
259
259
|
icon: l(f).asterisk
|
|
260
|
-
}, null, 8, ["icon"])) :
|
|
260
|
+
}, null, 8, ["icon"])) : v("", !0)
|
|
261
261
|
]),
|
|
262
262
|
key: "0"
|
|
263
263
|
} : void 0
|
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
import { ref as s, computed as M, watch as H, nextTick as F } from "vue";
|
|
2
2
|
import { isArray as y, isObject as h, fullCopy as L } from "../../../../utils/utils.js";
|
|
3
|
-
function U(
|
|
4
|
-
const l = s(null), v = s(null), S = s(null), f = s(!1), b = s(""), N = (e,
|
|
5
|
-
function
|
|
3
|
+
function U(n, j, i, d) {
|
|
4
|
+
const l = s(null), v = s(null), S = s(null), f = s(!1), b = s(""), N = (e, t) => t.split(".").reduce((u, c) => u && u[c] !== void 0 ? u[c] : null, e), B = M(() => l.value !== null && l.value !== void 0 ? y(l.value) ? l.value.length ? g(l.value, n.itemTitle, "hasDefault") : n.placeholderText : h(l.value) ? g(l.value, n.itemTitle, "hasDefault") : l.value.toString() : d.value.length ? n.placeholderText : n.textNoItems), R = M(() => n.itemText.includes(",") ? n.itemText.split(",") : n.itemText);
|
|
5
|
+
function g(e, t, u) {
|
|
6
6
|
var c;
|
|
7
7
|
if (h(e)) {
|
|
8
|
-
if (
|
|
9
|
-
if (y(
|
|
10
|
-
return
|
|
8
|
+
if (t) {
|
|
9
|
+
if (y(t))
|
|
10
|
+
return t.map((r) => {
|
|
11
11
|
if (r.includes(".")) {
|
|
12
12
|
const o = r.split(".");
|
|
13
13
|
let a = e;
|
|
14
14
|
for (const O of o)
|
|
15
|
-
a = a != null ? a[O] :
|
|
15
|
+
a = a != null ? a[O] : "";
|
|
16
16
|
return a ?? "No definido";
|
|
17
17
|
}
|
|
18
18
|
return e[r] ?? "No definido";
|
|
19
19
|
}).join(" - ");
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
if (
|
|
23
|
-
const r =
|
|
20
|
+
if (t.includes(","))
|
|
21
|
+
return t.split(",").map((r) => e[r]).join(" - ");
|
|
22
|
+
if (t.includes(".")) {
|
|
23
|
+
const r = t.split(".");
|
|
24
24
|
let o = e;
|
|
25
25
|
for (const a of r)
|
|
26
|
-
o = o != null ? o[a] :
|
|
26
|
+
o = o != null ? o[a] : "";
|
|
27
27
|
return o;
|
|
28
28
|
}
|
|
29
|
-
return !
|
|
29
|
+
return !n.returnObject && typeof e[t] == "number" || e[t] !== void 0 && e[t] !== null ? e[t].toString() : "";
|
|
30
30
|
}
|
|
31
31
|
if (u)
|
|
32
32
|
return Object.values(e)[0];
|
|
33
33
|
}
|
|
34
|
-
return y(e) ?
|
|
34
|
+
return y(e) ? n.returnObject ? e.map((r) => r[t]).join(" - ") : e.map((r) => r).join(" - ") : u && typeof e != "number" ? e.includes(",") ? e.split(",") : e : ((c = e == null ? void 0 : e.toString) == null ? void 0 : c.call(e)) ?? "";
|
|
35
35
|
}
|
|
36
36
|
function V(e) {
|
|
37
37
|
try {
|
|
38
|
-
let
|
|
39
|
-
if (l.value = L(e), !
|
|
40
|
-
|
|
38
|
+
let t = null;
|
|
39
|
+
if (l.value = L(e), !n.multiple)
|
|
40
|
+
n.returnObject ? t = e : h(e) ? n.itemValue ? t = e[n.itemValue] : t = Object.values(e)[0] : t = e, f.value = !1, x();
|
|
41
41
|
else if (T(e)) {
|
|
42
42
|
e && I(e);
|
|
43
43
|
return;
|
|
44
44
|
} else {
|
|
45
|
-
const u =
|
|
46
|
-
|
|
45
|
+
const u = n.returnObject ? e : h(e) ? n.itemValue ? e[n.itemValue] : Object.values(e)[0] : e;
|
|
46
|
+
t = [...i.value || [], u];
|
|
47
47
|
}
|
|
48
|
-
i.value ===
|
|
49
|
-
} catch (
|
|
50
|
-
console.log(
|
|
48
|
+
i.value === t ? j("update:modelValue", t) : i.value = t, j("selectedItem", l.value);
|
|
49
|
+
} catch (t) {
|
|
50
|
+
console.log(t);
|
|
51
51
|
} finally {
|
|
52
52
|
F(() => {
|
|
53
53
|
A();
|
|
@@ -57,27 +57,27 @@ function U(t, g, i, d) {
|
|
|
57
57
|
H(
|
|
58
58
|
[() => i.value, () => d.value],
|
|
59
59
|
([e]) => {
|
|
60
|
-
const
|
|
61
|
-
JSON.stringify(l.value) !== JSON.stringify(
|
|
60
|
+
const t = C(e);
|
|
61
|
+
JSON.stringify(l.value) !== JSON.stringify(t) && (l.value = t);
|
|
62
62
|
},
|
|
63
63
|
{ immediate: !0 }
|
|
64
64
|
);
|
|
65
65
|
function C(e) {
|
|
66
|
-
return e == null ? null :
|
|
67
|
-
(u) => typeof u == "object" ? u[
|
|
66
|
+
return e == null ? null : n.multiple && Array.isArray(e) ? n.returnObject ? e : e.map((u) => d.value.find((c) => c[n.itemValue] === u)).filter(Boolean) : n.returnObject ? e : d.value.find(
|
|
67
|
+
(u) => typeof u == "object" ? u[n.itemValue] === e : u === e
|
|
68
68
|
) ?? e;
|
|
69
69
|
}
|
|
70
70
|
function T(e) {
|
|
71
71
|
if (!i.value || !e) return !1;
|
|
72
|
-
const
|
|
73
|
-
return i.value.some((u) => (
|
|
72
|
+
const t = n.returnObject ? e[n.itemValue] : e;
|
|
73
|
+
return i.value.some((u) => (n.returnObject ? u[n.itemValue] : u) === t);
|
|
74
74
|
}
|
|
75
75
|
function I(e) {
|
|
76
|
-
const
|
|
76
|
+
const t = n.returnObject ? e[n.itemValue] : e, u = i.value.filter((c) => (n.returnObject ? c[n.itemValue] : c) !== t);
|
|
77
77
|
i.value = u;
|
|
78
78
|
}
|
|
79
79
|
function A(e) {
|
|
80
|
-
|
|
80
|
+
n.clearSearchOnSelect && (b.value = ""), n.clearOnSelect && E(), n.focusOnSelect && x();
|
|
81
81
|
}
|
|
82
82
|
function k() {
|
|
83
83
|
f.value || (f.value = !0);
|
|
@@ -98,8 +98,8 @@ function U(t, g, i, d) {
|
|
|
98
98
|
f.value = !0, S.value && v.value.$el.focus();
|
|
99
99
|
}
|
|
100
100
|
function $(e) {
|
|
101
|
-
const
|
|
102
|
-
(w(
|
|
101
|
+
const t = e.key;
|
|
102
|
+
(w(t) || t === "Backspace") && (k(), x(), F(() => {
|
|
103
103
|
var c;
|
|
104
104
|
const u = (c = v.value) == null ? void 0 : c.inputField;
|
|
105
105
|
if (u) {
|
|
@@ -109,11 +109,11 @@ function U(t, g, i, d) {
|
|
|
109
109
|
}));
|
|
110
110
|
}
|
|
111
111
|
function q() {
|
|
112
|
-
f.value = !1,
|
|
112
|
+
f.value = !1, j("createItem");
|
|
113
113
|
}
|
|
114
114
|
function z(e) {
|
|
115
|
-
let
|
|
116
|
-
i.value.splice(
|
|
115
|
+
let t = i.value.indexOf(e);
|
|
116
|
+
i.value.splice(t, 1);
|
|
117
117
|
}
|
|
118
118
|
function E() {
|
|
119
119
|
b.value !== "" && (b.value = ""), i.value !== null && (i.value = null), l.value !== null && (l.value = null);
|
|
@@ -130,7 +130,7 @@ function U(t, g, i, d) {
|
|
|
130
130
|
getItemText: N,
|
|
131
131
|
placeholder: B,
|
|
132
132
|
textArr: R,
|
|
133
|
-
itemToString:
|
|
133
|
+
itemToString: g,
|
|
134
134
|
getSelectedItem: V,
|
|
135
135
|
checkIfValueExist: T,
|
|
136
136
|
removeFromArray: I,
|