adverich-kun-ui 0.1.91 → 0.1.92
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.
- package/dist/components/KunAutocomplete/src/components/KunAutocomplete.vue.js +89 -88
- package/dist/components/KunAutocomplete/src/composables/useAutocomplete.js +83 -113
- package/dist/components/KunList/src/components/KunList.vue.js +39 -31
- package/dist/components/KunListItem/src/components/KunListItem.vue.js +30 -20
- package/package.json +1 -1
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
import { mergeModels as
|
|
1
|
+
import { mergeModels as A, useModel as E, onMounted as le, ref as oe, watch as ne, createBlock as d, openBlock as i, unref as e, isRef as L, createSlots as re, withCtx as r, createElementBlock as R, createCommentVNode as h, createVNode as a, Fragment as ie, renderList as ae, createElementVNode as se, createTextVNode as b, toDisplayString as V, normalizeClass as ue, withModifiers as de } from "vue";
|
|
2
2
|
import { icons as f } from "../../../../icons/index.js";
|
|
3
|
-
import { isNotEmpty as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { useAutocomplete as
|
|
11
|
-
import { KunAutocompleteProps as
|
|
12
|
-
import
|
|
3
|
+
import { isNotEmpty as ce, isArray as U } from "../../../../utils/utils.js";
|
|
4
|
+
import me from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
|
|
5
|
+
import fe from "../../../KunList/src/components/KunList.vue.js";
|
|
6
|
+
import z from "../../../KunListItem/src/components/KunListItem.vue.js";
|
|
7
|
+
import pe from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
|
|
8
|
+
import ke from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
|
|
9
|
+
import ye from "../../../kunMenu/src/components/kunMenu.vue.js";
|
|
10
|
+
import { useAutocomplete as he } from "../composables/useAutocomplete.js";
|
|
11
|
+
import { KunAutocompleteProps as ve } from "../composables/KunAutocompleteProps.js";
|
|
12
|
+
import ge from "../../../KunTextField/src/components/KunTextField.vue.js";
|
|
13
13
|
import Ce from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
14
|
-
import
|
|
14
|
+
import be from "../../../KunChip/src/components/KunChip.vue.js";
|
|
15
15
|
import v from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
16
|
-
const
|
|
16
|
+
const Ve = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "flex justify-center align-center"
|
|
19
|
-
},
|
|
19
|
+
}, Ie = { class: "flex justify-center align-center" }, Fe = {
|
|
20
20
|
__name: "KunAutocomplete",
|
|
21
|
-
props: /* @__PURE__ */
|
|
21
|
+
props: /* @__PURE__ */ A(ve, {
|
|
22
22
|
modelValue: { default: null },
|
|
23
23
|
modelModifiers: {},
|
|
24
24
|
items: { default: [], type: Array, required: !0 },
|
|
25
25
|
itemsModifiers: {}
|
|
26
26
|
}),
|
|
27
|
-
emits: /* @__PURE__ */
|
|
28
|
-
setup(
|
|
29
|
-
const u =
|
|
27
|
+
emits: /* @__PURE__ */ A(["update:model-value", "createItem", "validation", "search"], ["update:modelValue", "update:items"]),
|
|
28
|
+
setup(g, { emit: B }) {
|
|
29
|
+
const u = E(g, "modelValue"), I = E(g, "items"), n = g, p = B, {
|
|
30
30
|
selectedItem: c,
|
|
31
31
|
textFieldRef: k,
|
|
32
|
-
listRef:
|
|
32
|
+
listRef: C,
|
|
33
33
|
menuModel: s,
|
|
34
34
|
search: m,
|
|
35
|
-
removeItem:
|
|
36
|
-
clearSelection:
|
|
35
|
+
removeItem: F,
|
|
36
|
+
clearSelection: N,
|
|
37
37
|
lightReset: w,
|
|
38
|
-
openMenu:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
openMenu: T,
|
|
39
|
+
toggleMenu: H,
|
|
40
|
+
onMenuKeydown: K,
|
|
41
|
+
getSelectedItem: O,
|
|
42
|
+
textArr: j,
|
|
43
|
+
getItemText: q,
|
|
44
|
+
createItem: P,
|
|
45
|
+
checkDisabled: W,
|
|
46
|
+
itemToString: _,
|
|
47
|
+
placeholder: M,
|
|
48
|
+
hasCreateItem: G
|
|
49
|
+
} = he(n, p, u, I);
|
|
50
|
+
le(() => {
|
|
50
51
|
n.focusOnRender && k.value.focus();
|
|
51
52
|
});
|
|
52
|
-
function
|
|
53
|
-
return u.value === null || u.value === void 0 ? n.bgItemListColor : n.multiple ? u.value.find((o) => o[n.itemValue] === t[n.itemValue]) ? n.selectedColor : n.bgItemListColor :
|
|
53
|
+
function J(t) {
|
|
54
|
+
return u.value === null || u.value === void 0 ? n.bgItemListColor : n.multiple ? u.value.find((o) => o[n.itemValue] === t[n.itemValue]) ? n.selectedColor : n.bgItemListColor : M.value === t[n.itemTitle] ? n.selectedColor : n.bgItemListColor;
|
|
54
55
|
}
|
|
55
|
-
const y =
|
|
56
|
+
const y = oe(""), S = (t) => {
|
|
56
57
|
for (const o of n.rules) {
|
|
57
58
|
const l = o(t);
|
|
58
59
|
if (l !== !0)
|
|
@@ -60,43 +61,43 @@ const be = {
|
|
|
60
61
|
}
|
|
61
62
|
return y.value = "", p("validation", !0), !0;
|
|
62
63
|
};
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
ne(() => u.value, (t, o) => {
|
|
65
|
+
ce(n.rules) && S(t);
|
|
65
66
|
});
|
|
66
|
-
function
|
|
67
|
+
function D() {
|
|
67
68
|
var t;
|
|
68
69
|
s.value = !1, (t = k.value.inputField) == null || t.focus();
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function Q(t) {
|
|
71
72
|
p("search", m);
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
74
|
+
function X() {
|
|
75
|
+
S(u);
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
+
function Y(t) {
|
|
77
78
|
const o = t.key;
|
|
78
79
|
if (o === "Escape") {
|
|
79
|
-
|
|
80
|
+
D();
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
83
|
if (["ArrowDown", "ArrowUp"].includes(o)) {
|
|
83
|
-
if (!
|
|
84
|
-
|
|
84
|
+
if (!C.value) return;
|
|
85
|
+
C.value.focusWithKey(o);
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
K(t);
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
90
|
+
function Z(t) {
|
|
91
|
+
K(t);
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function ee() {
|
|
93
94
|
s.value = !1;
|
|
94
95
|
}
|
|
95
|
-
return (t, o) => (i(), d(
|
|
96
|
+
return (t, o) => (i(), d(ge, {
|
|
96
97
|
modelValue: e(m),
|
|
97
98
|
"onUpdate:modelValue": [
|
|
98
|
-
o[2] || (o[2] = (l) =>
|
|
99
|
-
|
|
99
|
+
o[2] || (o[2] = (l) => L(m) ? m.value = l : null),
|
|
100
|
+
Q
|
|
100
101
|
],
|
|
101
102
|
label: t.label,
|
|
102
103
|
dirty: "",
|
|
@@ -105,61 +106,61 @@ const be = {
|
|
|
105
106
|
ref_key: "textFieldRef",
|
|
106
107
|
ref: k,
|
|
107
108
|
autocomplete: "off",
|
|
108
|
-
onKeyDown:
|
|
109
|
-
onFocusInput:
|
|
110
|
-
onHandleClick: e(
|
|
111
|
-
onBlurInput:
|
|
112
|
-
placeholder: n.multiple && e(
|
|
109
|
+
onKeyDown: Y,
|
|
110
|
+
onFocusInput: X,
|
|
111
|
+
onHandleClick: e(H),
|
|
112
|
+
onBlurInput: ee,
|
|
113
|
+
placeholder: n.multiple && e(U)(e(c)) && e(c).length ? "" : e(M),
|
|
113
114
|
error: !!y.value,
|
|
114
115
|
"error-messages": y.value
|
|
115
|
-
},
|
|
116
|
+
}, re({
|
|
116
117
|
default: r(() => [
|
|
117
|
-
e(
|
|
118
|
-
(i(!0),
|
|
118
|
+
e(U)(e(c)) ? (i(), R("div", Ve, [
|
|
119
|
+
(i(!0), R(ie, null, ae(e(c), (l) => (i(), d(be, {
|
|
119
120
|
key: l.id ?? l.name,
|
|
120
121
|
size: "small",
|
|
121
122
|
class: "ml-1"
|
|
122
123
|
}, {
|
|
123
124
|
default: r(() => [
|
|
124
|
-
|
|
125
|
-
b(V(e(
|
|
125
|
+
se("div", Ie, [
|
|
126
|
+
b(V(e(q)(l, t.itemTitle)) + " ", 1),
|
|
126
127
|
a(v, {
|
|
127
128
|
color: "error",
|
|
128
129
|
icon: e(f).close,
|
|
129
130
|
size: "small",
|
|
130
131
|
class: "ml-1",
|
|
131
|
-
onClick: (
|
|
132
|
+
onClick: (te) => e(F)(l)
|
|
132
133
|
}, null, 8, ["icon", "onClick"])
|
|
133
134
|
])
|
|
134
135
|
]),
|
|
135
136
|
_: 2
|
|
136
137
|
}, 1024))), 128))
|
|
137
138
|
])) : h("", !0),
|
|
138
|
-
a(
|
|
139
|
+
a(ye, {
|
|
139
140
|
transition: "fade",
|
|
140
141
|
"onClick:outside": e(w),
|
|
141
142
|
modelValue: e(s),
|
|
142
|
-
"onUpdate:modelValue": o[1] || (o[1] = (l) =>
|
|
143
|
+
"onUpdate:modelValue": o[1] || (o[1] = (l) => L(s) ? s.value = l : null),
|
|
143
144
|
activator: "parent",
|
|
144
145
|
"parent-ref": e(k),
|
|
145
|
-
onHandleEscape:
|
|
146
|
+
onHandleEscape: D,
|
|
146
147
|
"close-on-content-click": t.closeOnSelect,
|
|
147
148
|
"max-height": t.maxHeight,
|
|
148
149
|
"hide-details": t.hideDetails
|
|
149
150
|
}, {
|
|
150
151
|
default: r(() => [
|
|
151
|
-
a(
|
|
152
|
-
"onUpdate:selected": e(
|
|
152
|
+
a(fe, {
|
|
153
|
+
"onUpdate:selected": e(O),
|
|
153
154
|
"onClick:select": o[0] || (o[0] = (l) => e(w)()),
|
|
154
155
|
ref_key: "listRef",
|
|
155
|
-
ref:
|
|
156
|
-
onKeyDown:
|
|
156
|
+
ref: C,
|
|
157
|
+
onKeyDown: Z
|
|
157
158
|
}, {
|
|
158
159
|
default: r(() => [
|
|
159
|
-
e(
|
|
160
|
+
e(G) ? (i(), d(z, { key: 0 }, {
|
|
160
161
|
default: r(() => [
|
|
161
162
|
a(Ce, {
|
|
162
|
-
onClick: e(
|
|
163
|
+
onClick: e(P),
|
|
163
164
|
class: "w-full",
|
|
164
165
|
color: "bg-green-400"
|
|
165
166
|
}, {
|
|
@@ -172,7 +173,7 @@ const be = {
|
|
|
172
173
|
]),
|
|
173
174
|
_: 1
|
|
174
175
|
})) : h("", !0),
|
|
175
|
-
a(
|
|
176
|
+
a(me, {
|
|
176
177
|
items: I.value,
|
|
177
178
|
search: e(m),
|
|
178
179
|
"searchable-keys": n.searchableKeys,
|
|
@@ -181,26 +182,26 @@ const be = {
|
|
|
181
182
|
virtual: !1,
|
|
182
183
|
"item-height": 48
|
|
183
184
|
}, {
|
|
184
|
-
default: r(({ item: l, index:
|
|
185
|
-
var x
|
|
185
|
+
default: r(({ item: l, index: te }) => {
|
|
186
|
+
var $, x;
|
|
186
187
|
return [
|
|
187
|
-
(i(), d(
|
|
188
|
+
(i(), d(z, {
|
|
188
189
|
value: l,
|
|
189
|
-
key: ((
|
|
190
|
-
disabled: e(
|
|
191
|
-
class:
|
|
190
|
+
key: (($ = l.id) == null ? void 0 : $.toString()) ?? l.name,
|
|
191
|
+
disabled: e(W)(l),
|
|
192
|
+
class: ue(J(l)),
|
|
192
193
|
density: t.density,
|
|
193
|
-
id: ((
|
|
194
|
+
id: ((x = l.id) == null ? void 0 : x.toString()) ?? l.name
|
|
194
195
|
}, {
|
|
195
196
|
default: r(() => [
|
|
196
|
-
a(
|
|
197
|
+
a(pe, { class: "text-wrap" }, {
|
|
197
198
|
default: r(() => [
|
|
198
|
-
b(V(e(
|
|
199
|
+
b(V(e(_)(l, e(j), "hasDefault")), 1)
|
|
199
200
|
]),
|
|
200
201
|
_: 2
|
|
201
202
|
}, 1024),
|
|
202
|
-
a(
|
|
203
|
-
textContent: V(t.itemSubtitle ? e(
|
|
203
|
+
a(ke, {
|
|
204
|
+
textContent: V(t.itemSubtitle ? e(_)(l, t.itemSubtitle) : "")
|
|
204
205
|
}, null, 8, ["textContent"])
|
|
205
206
|
]),
|
|
206
207
|
_: 2
|
|
@@ -223,7 +224,7 @@ const be = {
|
|
|
223
224
|
fn: r(() => [
|
|
224
225
|
t.clearable && e(c) ? (i(), d(v, {
|
|
225
226
|
key: 0,
|
|
226
|
-
onClick: e(
|
|
227
|
+
onClick: e(N),
|
|
227
228
|
size: "small",
|
|
228
229
|
color: "error",
|
|
229
230
|
icon: e(f).close,
|
|
@@ -234,7 +235,7 @@ const be = {
|
|
|
234
235
|
size: "large",
|
|
235
236
|
class: "cursor-pointer",
|
|
236
237
|
icon: e(s) ? e(f).menuUpOutline : e(f).menuDownOutline,
|
|
237
|
-
onClick:
|
|
238
|
+
onClick: de(e(T), ["stop"])
|
|
238
239
|
}, null, 8, ["icon", "onClick"]),
|
|
239
240
|
t.required ? (i(), d(v, {
|
|
240
241
|
key: 1,
|
|
@@ -250,5 +251,5 @@ const be = {
|
|
|
250
251
|
}
|
|
251
252
|
};
|
|
252
253
|
export {
|
|
253
|
-
|
|
254
|
+
Fe as default
|
|
254
255
|
};
|
|
@@ -1,143 +1,113 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { isArray as o, isObject as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!a(f) && !o(f))
|
|
19
|
-
return f;
|
|
20
|
-
}), i = [t].reduce((f, F) => u.searchableKeys.map((y) => y.includes(".") ? y.split(".").reduce((K, z) => K && K[z], F) : F[y]), []), s = u.searchableKeys.length ? i : r;
|
|
21
|
-
return s ? s.some(
|
|
22
|
-
(f) => f ? f.toString().toLowerCase().includes(c.value.toLowerCase()) : ""
|
|
23
|
-
) : c.value ? t == c.value : t;
|
|
24
|
-
}
|
|
25
|
-
return t.toString().toLowerCase().includes(c.value.toLowerCase());
|
|
26
|
-
})), R = d(() => u.itemText.includes(",") ? u.itemText.split(",") : u.itemText);
|
|
27
|
-
function x(e, t, r) {
|
|
28
|
-
if (a(e)) {
|
|
29
|
-
if (t) {
|
|
30
|
-
if (o(t))
|
|
31
|
-
return t.map((i) => e[i] ?? "No definido").join(" - ");
|
|
32
|
-
if (t.includes(","))
|
|
33
|
-
return t.split(",").map((i) => e[i]).join(" - ");
|
|
34
|
-
if (t.includes(".")) {
|
|
35
|
-
const i = t.split(".");
|
|
36
|
-
let s = e;
|
|
37
|
-
for (const f of i)
|
|
38
|
-
s = s[f];
|
|
39
|
-
return s;
|
|
1
|
+
import { ref as a, computed as S } from "vue";
|
|
2
|
+
import { isArray as o, isObject as c } from "../../../../utils/utils.js";
|
|
3
|
+
function z(u, O, r, T, P) {
|
|
4
|
+
const t = a(null), v = a(null), b = a(null), i = a(!1), s = a(""), A = (e, n) => n.split(".").reduce((f, l) => f && f[l] !== void 0 ? f[l] : null, e), M = S(() => t.value ? o(t.value) ? t.value.length ? d(t.value, u.itemTitle, "hasDefault") : u.placeholderText : c(t.value) ? d(t.value, u.itemTitle, "hasDefault") : t.value.toString() : T.value.length ? u.placeholderText : u.textNoItems), V = S(() => u.itemText.includes(",") ? u.itemText.split(",") : u.itemText);
|
|
5
|
+
function d(e, n, f) {
|
|
6
|
+
if (c(e)) {
|
|
7
|
+
if (n) {
|
|
8
|
+
if (o(n))
|
|
9
|
+
return n.map((l) => e[l] ?? "No definido").join(" - ");
|
|
10
|
+
if (n.includes(","))
|
|
11
|
+
return n.split(",").map((l) => e[l]).join(" - ");
|
|
12
|
+
if (n.includes(".")) {
|
|
13
|
+
const l = n.split(".");
|
|
14
|
+
let x = e;
|
|
15
|
+
for (const K of l)
|
|
16
|
+
x = x[K];
|
|
17
|
+
return x;
|
|
40
18
|
}
|
|
41
|
-
return !u.returnObject && typeof e[
|
|
19
|
+
return !u.returnObject && typeof e[n] == "number" || e[n] ? e[n].toString() : "";
|
|
42
20
|
}
|
|
43
|
-
if (
|
|
21
|
+
if (f)
|
|
44
22
|
return Object.values(e)[0];
|
|
45
23
|
}
|
|
46
|
-
return o(e) ? u.returnObject ? e.map((
|
|
24
|
+
return o(e) ? u.returnObject ? e.map((l) => l[n]).join(" - ") : e.map((l) => l).join(" - ") : f && typeof e != "number" && e.includes(",") ? e.split(",") : e;
|
|
47
25
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (u.returnObject && n.value.push(t), !u.returnObject && a(t))
|
|
56
|
-
if (u.itemValue)
|
|
57
|
-
n.value.push(t[u.itemValue]);
|
|
58
|
-
else {
|
|
59
|
-
l.value = n.value.push(Object.values(t)[0]);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
l.value = n.value;
|
|
26
|
+
function F(e) {
|
|
27
|
+
try {
|
|
28
|
+
u.multiple ? (t.value || (t.value = []), m(e) ? e && g(e) : u.returnObject ? t.value.push(e) : c(e) ? u.itemValue ? t.value.push(e[u.itemValue]) : t.value.push(Object.values(e)[0]) : t.value.push(e)) : (u.returnObject ? t.value = e : c(result) ? u.itemValue ? t.value = e[u.itemValue] : t.value = Object.values(result)[0] : t.value = result, i.value = !1), O("update:model-value", t.value), u.clearOnSelect && I();
|
|
29
|
+
} catch (n) {
|
|
30
|
+
console.log(n);
|
|
31
|
+
} finally {
|
|
32
|
+
h();
|
|
63
33
|
}
|
|
64
|
-
u.clearOnSelect && w(), j();
|
|
65
34
|
}
|
|
66
|
-
function
|
|
67
|
-
return
|
|
68
|
-
(
|
|
35
|
+
function m(e) {
|
|
36
|
+
return t.value === null ? !1 : e ? t.value.some(
|
|
37
|
+
(n) => u.returnObject ? n[u.itemValue] === e[u.itemValue] : n === e[u.itemValue]
|
|
69
38
|
) : !0;
|
|
70
39
|
}
|
|
71
|
-
function
|
|
40
|
+
function g(e) {
|
|
72
41
|
if (u.returnObject) {
|
|
73
|
-
|
|
74
|
-
(
|
|
75
|
-
),
|
|
76
|
-
|
|
42
|
+
const n = t.value.find(
|
|
43
|
+
(l) => l[u.itemValue] === e[u.itemValue]
|
|
44
|
+
), f = t.value.indexOf(n);
|
|
45
|
+
t.value.splice(f, 1);
|
|
77
46
|
} else {
|
|
78
|
-
|
|
79
|
-
|
|
47
|
+
const n = t.value.indexOf(e[u.itemValue]);
|
|
48
|
+
t.value.splice(n, 1);
|
|
80
49
|
}
|
|
81
50
|
}
|
|
82
|
-
function
|
|
83
|
-
u.clearSearchOnSelect && (
|
|
51
|
+
function k(e) {
|
|
52
|
+
u.clearSearchOnSelect && (s.value = ""), u.focusOnSelect && h();
|
|
53
|
+
}
|
|
54
|
+
function j() {
|
|
55
|
+
i.value || (i.value = !0);
|
|
84
56
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
57
|
+
function R() {
|
|
58
|
+
i.value = !i.value;
|
|
87
59
|
}
|
|
88
|
-
function
|
|
60
|
+
function y(e) {
|
|
89
61
|
return e.length === 1 && e.match(/\w/);
|
|
90
62
|
}
|
|
91
|
-
function
|
|
92
|
-
|
|
63
|
+
function h() {
|
|
64
|
+
v.value.inputField.focus();
|
|
93
65
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
66
|
+
function w() {
|
|
67
|
+
i.value = !0, b.value && v.value.$el.focus();
|
|
96
68
|
}
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
(
|
|
69
|
+
function D(e) {
|
|
70
|
+
const n = e.key;
|
|
71
|
+
(y(n) || n === "Backspace") && (j(), h());
|
|
100
72
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
73
|
+
function N() {
|
|
74
|
+
i.value = !1, O("createItem");
|
|
103
75
|
}
|
|
104
|
-
function
|
|
105
|
-
let
|
|
106
|
-
|
|
76
|
+
function B(e) {
|
|
77
|
+
let n = t.value.indexOf(e);
|
|
78
|
+
t.value.splice(n, 1);
|
|
107
79
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
80
|
+
function I() {
|
|
81
|
+
s.value = "", o(r.value) && (t.value = []), c(r.value) && (t.value = null), typeof r.value == "number" && r.value && (t.value = null), typeof r.value == "string" && r.value && (t.value = null), typeof r.value == "boolean" && (t.value = !1);
|
|
110
82
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
if (e.disabledItem) return !0;
|
|
83
|
+
function E(e) {
|
|
84
|
+
return !!e.disabledItem;
|
|
114
85
|
}
|
|
115
86
|
return {
|
|
116
|
-
selectedItem:
|
|
117
|
-
textFieldRef:
|
|
118
|
-
listRef:
|
|
119
|
-
menuModel:
|
|
120
|
-
search:
|
|
121
|
-
getItemText:
|
|
122
|
-
setSelectedItemValue: L,
|
|
87
|
+
selectedItem: t,
|
|
88
|
+
textFieldRef: v,
|
|
89
|
+
listRef: b,
|
|
90
|
+
menuModel: i,
|
|
91
|
+
search: s,
|
|
92
|
+
getItemText: A,
|
|
123
93
|
placeholder: M,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
focusOnMenu:
|
|
133
|
-
onMenuKeydown:
|
|
134
|
-
createItem:
|
|
135
|
-
removeItem:
|
|
136
|
-
clearSelection:
|
|
137
|
-
checkDisabled:
|
|
138
|
-
isAlphanumeric:
|
|
94
|
+
textArr: V,
|
|
95
|
+
itemToString: d,
|
|
96
|
+
getSelectedItem: F,
|
|
97
|
+
checkIfValueExist: m,
|
|
98
|
+
removeFromArray: g,
|
|
99
|
+
lightReset: k,
|
|
100
|
+
openMenu: j,
|
|
101
|
+
toggleMenu: R,
|
|
102
|
+
focusOnMenu: w,
|
|
103
|
+
onMenuKeydown: D,
|
|
104
|
+
createItem: N,
|
|
105
|
+
removeItem: B,
|
|
106
|
+
clearSelection: I,
|
|
107
|
+
checkDisabled: E,
|
|
108
|
+
isAlphanumeric: y
|
|
139
109
|
};
|
|
140
110
|
}
|
|
141
111
|
export {
|
|
142
|
-
|
|
112
|
+
z as useAutocomplete
|
|
143
113
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useKunList as
|
|
3
|
-
const
|
|
1
|
+
import { ref as d, provide as h, createElementBlock as k, openBlock as A, mergeProps as B, renderSlot as S } from "vue";
|
|
2
|
+
import { useKunList as D } from "../composables/useKunList.js";
|
|
3
|
+
const L = {
|
|
4
4
|
__name: "KunList",
|
|
5
5
|
props: {
|
|
6
6
|
nav: Boolean,
|
|
@@ -9,7 +9,7 @@ const K = {
|
|
|
9
9
|
selectable: {
|
|
10
10
|
type: [Boolean, String],
|
|
11
11
|
default: !1,
|
|
12
|
-
validator: (
|
|
12
|
+
validator: (l) => ["single", "multiple", !0, !1].includes(l)
|
|
13
13
|
},
|
|
14
14
|
bgList: {
|
|
15
15
|
type: String,
|
|
@@ -20,61 +20,69 @@ const K = {
|
|
|
20
20
|
default: "border-gray-300 dark:border-gray-700"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
emits: ["keyDown"],
|
|
24
|
-
setup(
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const u =
|
|
28
|
-
|
|
23
|
+
emits: ["keyDown", "click:select", "update:selected"],
|
|
24
|
+
setup(l, { expose: m, emit: g }) {
|
|
25
|
+
const p = l, s = g;
|
|
26
|
+
D(p);
|
|
27
|
+
const u = d(null), r = d([]);
|
|
28
|
+
m({
|
|
29
29
|
focusWithKey: (e) => {
|
|
30
30
|
var n, o;
|
|
31
|
-
const t =
|
|
31
|
+
const t = r.value.filter(Boolean);
|
|
32
32
|
t.length !== 0 && (e === "ArrowDown" ? (n = t[0]) == null || n.focus() : e === "ArrowUp" && ((o = t[t.length - 1]) == null || o.focus()));
|
|
33
33
|
},
|
|
34
34
|
focus: () => {
|
|
35
35
|
var e, t;
|
|
36
36
|
(t = (e = u.value) == null ? void 0 : e.focus) == null || t.call(e);
|
|
37
37
|
}
|
|
38
|
-
}),
|
|
39
|
-
e ?
|
|
38
|
+
}), h("registerListItemRef", (e) => {
|
|
39
|
+
e ? r.value.includes(e) || r.value.push(e) : r.value = r.value.filter((t) => t !== e);
|
|
40
40
|
});
|
|
41
|
-
function
|
|
42
|
-
var
|
|
41
|
+
function w(e) {
|
|
42
|
+
var a, c, f;
|
|
43
43
|
const t = e.key;
|
|
44
|
-
if (
|
|
44
|
+
if (s("keyDown", e), !["ArrowDown", "ArrowUp"].includes(t)) return;
|
|
45
45
|
e.preventDefault();
|
|
46
|
-
const n =
|
|
46
|
+
const n = r.value.filter(Boolean);
|
|
47
47
|
if (n.length === 0) return;
|
|
48
|
-
const o = n.findIndex((
|
|
48
|
+
const o = n.findIndex((b) => b === document.activeElement);
|
|
49
49
|
if (o === -1) {
|
|
50
|
-
t === "ArrowDown" ? (
|
|
50
|
+
t === "ArrowDown" ? (a = n[0]) == null || a.focus() : t === "ArrowUp" && ((c = n[n.length - 1]) == null || c.focus());
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
let
|
|
54
|
-
t === "ArrowDown" ?
|
|
53
|
+
let i = o;
|
|
54
|
+
t === "ArrowDown" ? i = (o + 1) % n.length : t === "ArrowUp" && (i = (o - 1 + n.length) % n.length), (f = n[i]) == null || f.focus();
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
function y(e) {
|
|
57
|
+
s("click:select", e.detail);
|
|
58
|
+
}
|
|
59
|
+
function v(e) {
|
|
60
|
+
s("update:selected", e.detail);
|
|
61
|
+
}
|
|
62
|
+
return (e, t) => (A(), k("ul", B({
|
|
57
63
|
role: "list",
|
|
58
64
|
class: ["w-full", [
|
|
59
65
|
"kun-list",
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
l.bgList,
|
|
67
|
+
l.borderColor,
|
|
62
68
|
{
|
|
63
|
-
"space-y-1": !
|
|
64
|
-
"space-y-0.5":
|
|
65
|
-
"pl-4 border-l-2":
|
|
66
|
-
"p-2 rounded-md":
|
|
69
|
+
"space-y-1": !l.dense,
|
|
70
|
+
"space-y-0.5": l.dense,
|
|
71
|
+
"pl-4 border-l-2": l.sub,
|
|
72
|
+
"p-2 rounded-md": l.nav
|
|
67
73
|
}
|
|
68
74
|
]],
|
|
69
75
|
ref_key: "ulRef",
|
|
70
76
|
ref: u,
|
|
71
77
|
tabindex: "-1",
|
|
72
|
-
onKeydown:
|
|
78
|
+
onKeydown: w,
|
|
79
|
+
onSelect: y,
|
|
80
|
+
onSelected: v
|
|
73
81
|
}, e.$attrs), [
|
|
74
|
-
|
|
82
|
+
S(e.$slots, "default")
|
|
75
83
|
], 16));
|
|
76
84
|
}
|
|
77
85
|
};
|
|
78
86
|
export {
|
|
79
|
-
|
|
87
|
+
L as default
|
|
80
88
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
1
|
+
import { ref as b, inject as d, onMounted as v, onBeforeUnmount as g, computed as c, createElementBlock as m, openBlock as y, mergeProps as k, renderSlot as h } from "vue";
|
|
2
|
+
const B = ["aria-selected", "aria-disabled"], p = {
|
|
3
3
|
__name: "KunListItem",
|
|
4
4
|
props: {
|
|
5
5
|
value: {
|
|
@@ -34,25 +34,35 @@ const k = ["aria-selected", "aria-disabled"], h = {
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
setup(e) {
|
|
37
|
-
const a = e,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
-
|
|
37
|
+
const a = e, n = b(null), u = d("registerListItemRef", null), t = d("kun-list", null);
|
|
38
|
+
v(() => {
|
|
39
|
+
u && n.value && u(n.value);
|
|
40
|
+
}), g(() => {
|
|
41
|
+
u && u(null);
|
|
42
42
|
});
|
|
43
|
-
const
|
|
43
|
+
const r = c(() => {
|
|
44
44
|
var l;
|
|
45
45
|
return ((l = t == null ? void 0 : t.isSelected) == null ? void 0 : l.call(t, a.value)) ?? !1;
|
|
46
|
-
}),
|
|
47
|
-
function
|
|
48
|
-
var l;
|
|
49
|
-
a.disabled || t && a.value !== null && ((l = t.toggleItem) == null || l.call(t, a.value))
|
|
46
|
+
}), o = c(() => a.active);
|
|
47
|
+
function f() {
|
|
48
|
+
var l, i, s;
|
|
49
|
+
a.disabled || (t && a.value !== null && ((l = t.toggleItem) == null || l.call(t, a.value)), (i = n.value) == null || i.dispatchEvent(
|
|
50
|
+
new CustomEvent("select", {
|
|
51
|
+
detail: a.value,
|
|
52
|
+
bubbles: !0
|
|
53
|
+
})
|
|
54
|
+
), (s = n.value) == null || s.dispatchEvent(
|
|
55
|
+
new CustomEvent("selected", {
|
|
56
|
+
detail: a.value,
|
|
57
|
+
bubbles: !0
|
|
58
|
+
})
|
|
59
|
+
));
|
|
50
60
|
}
|
|
51
|
-
return (l,
|
|
61
|
+
return (l, i) => (y(), m("li", k({
|
|
52
62
|
ref_key: "liRef",
|
|
53
|
-
ref:
|
|
63
|
+
ref: n,
|
|
54
64
|
role: "option",
|
|
55
|
-
"aria-selected":
|
|
65
|
+
"aria-selected": r.value || o.value,
|
|
56
66
|
"aria-disabled": e.disabled,
|
|
57
67
|
tabindex: "-1",
|
|
58
68
|
class: ["w-full flex flex-col", [
|
|
@@ -63,16 +73,16 @@ const k = ["aria-selected", "aria-disabled"], h = {
|
|
|
63
73
|
{
|
|
64
74
|
"cursor-not-allowed opacity-50": e.disabled,
|
|
65
75
|
[`cursor-pointer ${e.hoverBg}`]: !e.disabled,
|
|
66
|
-
[e.activeClass]:
|
|
76
|
+
[e.activeClass]: r.value || o.value,
|
|
67
77
|
"px-4 py-2": !e.noGutters
|
|
68
78
|
}
|
|
69
79
|
]],
|
|
70
|
-
onClick:
|
|
80
|
+
onClick: f
|
|
71
81
|
}, l.$attrs), [
|
|
72
|
-
|
|
73
|
-
], 16,
|
|
82
|
+
h(l.$slots, "default")
|
|
83
|
+
], 16, B));
|
|
74
84
|
}
|
|
75
85
|
};
|
|
76
86
|
export {
|
|
77
|
-
|
|
87
|
+
p as default
|
|
78
88
|
};
|