adverich-kun-ui 0.1.432 → 0.1.433
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 +74 -74
- package/dist/components/KunAutocomplete/src/composables/KunAutocompleteProps.js +7 -7
- package/dist/components/KunAutocomplete/src/composables/useAutocomplete.js +77 -68
- package/dist/components/KunInfiniteScroll/src/composables/useKunInfiniteScroll.js +34 -32
- package/package.json +1 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { mergeModels as z, useModel as R, onMounted as
|
|
1
|
+
import { mergeModels as z, useModel as R, onMounted as ie, ref as S, watch as ne, createElementBlock as v, openBlock as a, createVNode as n, unref as l, isRef as A, createSlots as re, withCtx as i, createCommentVNode as k, Fragment as ae, renderList as se, createBlock as m, createElementVNode as ue, createTextVNode as b, toDisplayString as I, normalizeClass as de, withModifiers as ce } from "vue";
|
|
2
2
|
import { icons as f } from "../../../../icons/index.js";
|
|
3
|
-
import { isNotEmpty as
|
|
3
|
+
import { isNotEmpty as _, isArray as B } from "../../../../utils/utils.js";
|
|
4
4
|
import me from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
|
|
5
5
|
import fe from "../../../KunList/src/components/KunList.vue.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import F from "../../../KunListItem/src/components/KunListItem.vue.js";
|
|
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
10
|
import { useAutocomplete as ve } from "../composables/useAutocomplete.js";
|
|
11
11
|
import { KunAutocompleteProps as ke } from "../composables/KunAutocompleteProps.js";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
12
|
+
import be from "../../../KunTextField/src/components/KunTextField.vue.js";
|
|
13
|
+
import ye from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
14
14
|
import ge from "../../../KunChip/src/components/KunChip.vue.js";
|
|
15
|
-
import
|
|
15
|
+
import y from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
16
16
|
const Ce = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "w-full flex overflow-x-auto whitespace-nowrap space-x-1"
|
|
19
19
|
}, we = { class: "flex items-center" }, Ve = {
|
|
20
20
|
key: 0,
|
|
21
|
-
class: "sticky top-0 z-10 p-2 border-b"
|
|
21
|
+
class: "sticky top-0 z-10 p-2 border-b bg-select-background"
|
|
22
22
|
}, Le = {
|
|
23
23
|
__name: "KunAutocomplete",
|
|
24
24
|
props: /* @__PURE__ */ z(ke, {
|
|
@@ -28,29 +28,29 @@ const Ce = {
|
|
|
28
28
|
itemsModifiers: {}
|
|
29
29
|
}),
|
|
30
30
|
emits: /* @__PURE__ */ z(["update:modelValue", "selectedItem", "createItem", "validation", "search"], ["update:modelValue", "update:items"]),
|
|
31
|
-
setup(g, { emit:
|
|
32
|
-
const
|
|
31
|
+
setup(g, { emit: E }) {
|
|
32
|
+
const r = R(g, "modelValue"), M = R(g, "items"), u = g, p = E, {
|
|
33
33
|
textFieldRef: C,
|
|
34
34
|
listRef: w,
|
|
35
35
|
menuModel: s,
|
|
36
36
|
search: c,
|
|
37
|
-
removeItem:
|
|
38
|
-
clearSelection:
|
|
39
|
-
lightReset:
|
|
37
|
+
removeItem: N,
|
|
38
|
+
clearSelection: L,
|
|
39
|
+
lightReset: O,
|
|
40
40
|
openMenu: V,
|
|
41
|
-
closeMenu:
|
|
42
|
-
toggleMenu:
|
|
43
|
-
onMenuKeydown:
|
|
44
|
-
getSelectedItem:
|
|
45
|
-
textArr:
|
|
46
|
-
getItemText:
|
|
47
|
-
isAlphanumeric:
|
|
48
|
-
createItem:
|
|
49
|
-
checkDisabled:
|
|
41
|
+
closeMenu: U,
|
|
42
|
+
toggleMenu: x,
|
|
43
|
+
onMenuKeydown: H,
|
|
44
|
+
getSelectedItem: q,
|
|
45
|
+
textArr: P,
|
|
46
|
+
getItemText: W,
|
|
47
|
+
isAlphanumeric: j,
|
|
48
|
+
createItem: G,
|
|
49
|
+
checkDisabled: J,
|
|
50
50
|
itemToString: D,
|
|
51
|
-
placeholder:
|
|
52
|
-
} = ve(u, p,
|
|
53
|
-
|
|
51
|
+
placeholder: Q
|
|
52
|
+
} = ve(u, p, r, M);
|
|
53
|
+
ie(() => {
|
|
54
54
|
u.focusOnRender && C.value.focus();
|
|
55
55
|
});
|
|
56
56
|
const K = S(null), h = S(""), $ = (e) => {
|
|
@@ -61,43 +61,43 @@ const Ce = {
|
|
|
61
61
|
}
|
|
62
62
|
return h.value = "", p("validation", !0), !0;
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
ne(() => r.value, (e, o) => {
|
|
65
|
+
_(u.rules) && $(e);
|
|
66
66
|
});
|
|
67
|
-
function
|
|
67
|
+
function X() {
|
|
68
68
|
var e;
|
|
69
69
|
s.value = !1, (e = C.value.inputField) == null || e.focus();
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function Y(e) {
|
|
72
72
|
var t, d;
|
|
73
73
|
const o = e.key;
|
|
74
74
|
if (o === "Tab" || o === "Shift") {
|
|
75
|
-
|
|
75
|
+
U();
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
(
|
|
78
|
+
(j(o) || o === "Backspace") && V(), ["ArrowUp", "ArrowDown"].includes(o) && (e.preventDefault(), s.value || V(), console.log("listRef.value", w.value), (d = (t = w.value) == null ? void 0 : t.focusWithKey) == null || d.call(t, o));
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function Z(e) {
|
|
81
81
|
p("search", c);
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
$(
|
|
83
|
+
function ee() {
|
|
84
|
+
$(r);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
86
|
+
function le(e) {
|
|
87
|
+
H(e);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function te() {
|
|
90
90
|
}
|
|
91
|
-
return (e, o) => (
|
|
91
|
+
return (e, o) => (a(), v("div", {
|
|
92
92
|
class: "w-full h-fit",
|
|
93
93
|
ref_key: "parentRef",
|
|
94
94
|
ref: K
|
|
95
95
|
}, [
|
|
96
|
-
n(
|
|
96
|
+
n(be, {
|
|
97
97
|
modelValue: l(c),
|
|
98
98
|
"onUpdate:modelValue": [
|
|
99
99
|
o[1] || (o[1] = (t) => A(c) ? c.value = t : null),
|
|
100
|
-
|
|
100
|
+
Z
|
|
101
101
|
],
|
|
102
102
|
label: e.label,
|
|
103
103
|
dirty: "",
|
|
@@ -106,30 +106,30 @@ const Ce = {
|
|
|
106
106
|
ref_key: "textFieldRef",
|
|
107
107
|
ref: C,
|
|
108
108
|
autocomplete: "off",
|
|
109
|
-
onFocusInput:
|
|
110
|
-
onHandleClick: l(
|
|
109
|
+
onFocusInput: ee,
|
|
110
|
+
onHandleClick: l(x),
|
|
111
111
|
rounded: l(s) ? "rounded-t" : "rounded",
|
|
112
|
-
onBlur:
|
|
113
|
-
onKeyDown:
|
|
114
|
-
placeholder: u.multiple && l(
|
|
112
|
+
onBlur: te,
|
|
113
|
+
onKeyDown: Y,
|
|
114
|
+
placeholder: u.multiple && l(B)(r.value) && r.value.length ? "" : l(Q),
|
|
115
115
|
error: !!h.value,
|
|
116
116
|
"error-messages": h.value
|
|
117
|
-
},
|
|
117
|
+
}, re({
|
|
118
118
|
default: i(() => [
|
|
119
|
-
l(_)(
|
|
120
|
-
(
|
|
119
|
+
l(B)(r.value) && l(_)(r.value) ? (a(), v("div", Ce, [
|
|
120
|
+
(a(!0), v(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
|
-
|
|
126
|
-
|
|
127
|
-
n(
|
|
125
|
+
ue("div", we, [
|
|
126
|
+
b(I(l(W)(t, e.itemTitle)) + " ", 1),
|
|
127
|
+
n(y, {
|
|
128
128
|
color: "error",
|
|
129
129
|
icon: l(f).close,
|
|
130
130
|
size: "small",
|
|
131
131
|
class: "ml-1",
|
|
132
|
-
onClick: (d) => l(
|
|
132
|
+
onClick: (d) => l(N)(t)
|
|
133
133
|
}, null, 8, ["icon", "onClick"])
|
|
134
134
|
])
|
|
135
135
|
]),
|
|
@@ -138,14 +138,14 @@ const Ce = {
|
|
|
138
138
|
])) : k("", !0),
|
|
139
139
|
n(he, {
|
|
140
140
|
transition: "fade",
|
|
141
|
-
"onClick:outside": l(
|
|
141
|
+
"onClick:outside": l(O),
|
|
142
142
|
modelValue: l(s),
|
|
143
143
|
"onUpdate:modelValue": o[0] || (o[0] = (t) => A(s) ? s.value = t : null),
|
|
144
144
|
activator: "parent",
|
|
145
145
|
"z-index": e.zIndex,
|
|
146
146
|
"parent-ref": K.value,
|
|
147
147
|
origin: e.menuOrigin,
|
|
148
|
-
onHandleEscape:
|
|
148
|
+
onHandleEscape: X,
|
|
149
149
|
bgColor: e.bgMenuColor,
|
|
150
150
|
"close-on-content-click": e.closeOnSelect,
|
|
151
151
|
width: "w-full",
|
|
@@ -153,23 +153,23 @@ const Ce = {
|
|
|
153
153
|
"hide-details": e.hideDetails
|
|
154
154
|
}, {
|
|
155
155
|
default: i(() => [
|
|
156
|
-
e.hasCreateItem ? (
|
|
157
|
-
n(
|
|
158
|
-
onClick: l(
|
|
156
|
+
e.hasCreateItem ? (a(), v("div", Ve, [
|
|
157
|
+
n(ye, {
|
|
158
|
+
onClick: l(G),
|
|
159
159
|
bgColor: e.btnCreateBg,
|
|
160
|
-
class:
|
|
160
|
+
class: de(e.btnCreateClass)
|
|
161
161
|
}, {
|
|
162
162
|
default: i(() => [
|
|
163
|
-
|
|
163
|
+
b(I(e.btnCreateText), 1)
|
|
164
164
|
]),
|
|
165
165
|
_: 1
|
|
166
166
|
}, 8, ["onClick", "bgColor", "class"])
|
|
167
167
|
])) : k("", !0),
|
|
168
168
|
n(fe, {
|
|
169
|
-
"onClick:select": l(
|
|
169
|
+
"onClick:select": l(q),
|
|
170
170
|
ref_key: "listRef",
|
|
171
171
|
ref: w,
|
|
172
|
-
onKeyDown:
|
|
172
|
+
onKeyDown: le,
|
|
173
173
|
selectable: !0
|
|
174
174
|
}, {
|
|
175
175
|
default: i(() => [
|
|
@@ -182,12 +182,12 @@ const Ce = {
|
|
|
182
182
|
enabled: l(s),
|
|
183
183
|
"item-height": 48
|
|
184
184
|
}, {
|
|
185
|
-
default: i(({ item: t, index: d, empty:
|
|
186
|
-
!
|
|
185
|
+
default: i(({ item: t, index: d, empty: oe }) => [
|
|
186
|
+
!oe && t != null ? (a(), m(F, {
|
|
187
187
|
value: t,
|
|
188
188
|
key: `kun-list-${d + 1}`,
|
|
189
189
|
id: `kun-item-${d + 1}`,
|
|
190
|
-
disabled: l(
|
|
190
|
+
disabled: l(J)(t),
|
|
191
191
|
"bg-items": e.bgItemListColor,
|
|
192
192
|
"hover-bg": e.hoverItemListColor,
|
|
193
193
|
activeClass: e.selectedItemListColor,
|
|
@@ -195,9 +195,9 @@ const Ce = {
|
|
|
195
195
|
selectable: !0
|
|
196
196
|
}, {
|
|
197
197
|
default: i(() => [
|
|
198
|
-
n(
|
|
198
|
+
n(T, { class: "text-wrap" }, {
|
|
199
199
|
default: i(() => [
|
|
200
|
-
|
|
200
|
+
b(I(l(D)(t, e.itemTitle ?? l(P), "hasDefault")), 1)
|
|
201
201
|
]),
|
|
202
202
|
_: 2
|
|
203
203
|
}, 1024),
|
|
@@ -206,14 +206,14 @@ const Ce = {
|
|
|
206
206
|
}, null, 8, ["text"])
|
|
207
207
|
]),
|
|
208
208
|
_: 2
|
|
209
|
-
}, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (
|
|
209
|
+
}, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (a(), m(F, {
|
|
210
210
|
key: 1,
|
|
211
211
|
disabled: ""
|
|
212
212
|
}, {
|
|
213
213
|
default: i(() => [
|
|
214
|
-
n(
|
|
214
|
+
n(T, { class: "text-center w-full text-gray-500" }, {
|
|
215
215
|
default: i(() => o[2] || (o[2] = [
|
|
216
|
-
|
|
216
|
+
b(" No hay elementos disponibles ")
|
|
217
217
|
])),
|
|
218
218
|
_: 1,
|
|
219
219
|
__: [2]
|
|
@@ -236,22 +236,22 @@ const Ce = {
|
|
|
236
236
|
e.hasIcons ? {
|
|
237
237
|
name: "append-inner",
|
|
238
238
|
fn: i(() => [
|
|
239
|
-
e.clearable &&
|
|
239
|
+
e.clearable && r.value ? (a(), m(y, {
|
|
240
240
|
key: 0,
|
|
241
|
-
onClick: l(
|
|
241
|
+
onClick: l(L),
|
|
242
242
|
size: "small",
|
|
243
243
|
color: "error",
|
|
244
244
|
icon: l(f).close,
|
|
245
245
|
class: "mr-1 mt-1"
|
|
246
246
|
}, null, 8, ["onClick", "icon"])) : k("", !0),
|
|
247
|
-
n(
|
|
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:
|
|
252
|
+
onClick: ce(l(V), ["stop"])
|
|
253
253
|
}, null, 8, ["icon", "onClick"]),
|
|
254
|
-
e.required ? (
|
|
254
|
+
e.required ? (a(), m(y, {
|
|
255
255
|
key: 1,
|
|
256
256
|
color: "teal-darken-1",
|
|
257
257
|
size: "x-small",
|
|
@@ -4,19 +4,19 @@ const e = {
|
|
|
4
4
|
},
|
|
5
5
|
itemValue: {
|
|
6
6
|
type: String,
|
|
7
|
-
default:
|
|
7
|
+
default: null
|
|
8
8
|
},
|
|
9
9
|
itemTitle: {
|
|
10
|
-
type: String,
|
|
11
|
-
default:
|
|
10
|
+
type: [String, Array],
|
|
11
|
+
default: null
|
|
12
12
|
},
|
|
13
13
|
itemText: {
|
|
14
|
-
type: String,
|
|
15
|
-
default:
|
|
14
|
+
type: [String, Array],
|
|
15
|
+
default: null
|
|
16
16
|
},
|
|
17
17
|
itemSubtitle: {
|
|
18
|
-
type: String,
|
|
19
|
-
default:
|
|
18
|
+
type: [String, Array],
|
|
19
|
+
default: null
|
|
20
20
|
},
|
|
21
21
|
returnObject: {
|
|
22
22
|
type: Boolean,
|
|
@@ -1,76 +1,85 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { isArray as
|
|
3
|
-
function U(
|
|
4
|
-
const l =
|
|
5
|
-
function j(e,
|
|
6
|
-
var
|
|
7
|
-
if (
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { ref as s, computed as M, watch as H, nextTick as F } from "vue";
|
|
2
|
+
import { isArray as y, isObject as h, fullCopy as L } from "../../../../utils/utils.js";
|
|
3
|
+
function U(t, g, i, d) {
|
|
4
|
+
const l = s(null), v = s(null), S = s(null), f = s(!1), b = s(""), N = (e, n) => n.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 ? j(l.value, t.itemTitle, "hasDefault") : t.placeholderText : h(l.value) ? j(l.value, t.itemTitle, "hasDefault") : l.value.toString() : d.value.length ? t.placeholderText : t.textNoItems), R = M(() => t.itemText.includes(",") ? t.itemText.split(",") : t.itemText);
|
|
5
|
+
function j(e, n, u) {
|
|
6
|
+
var c;
|
|
7
|
+
if (h(e)) {
|
|
8
|
+
if (n) {
|
|
9
|
+
if (y(n))
|
|
10
|
+
return n.map((r) => {
|
|
11
|
+
if (r.includes(".")) {
|
|
12
|
+
const o = r.split(".");
|
|
13
|
+
let a = e;
|
|
14
|
+
for (const O of o)
|
|
15
|
+
a = a != null ? a[O] : void 0;
|
|
16
|
+
return a ?? "No definido";
|
|
17
|
+
}
|
|
18
|
+
return e[r] ?? "No definido";
|
|
19
|
+
}).join(" - ");
|
|
20
|
+
if (n.includes(","))
|
|
21
|
+
return n.split(",").map((r) => e[r]).join(" - ");
|
|
22
|
+
if (n.includes(".")) {
|
|
23
|
+
const r = n.split(".");
|
|
24
|
+
let o = e;
|
|
25
|
+
for (const a of r)
|
|
26
|
+
o = o[a];
|
|
27
|
+
return o;
|
|
19
28
|
}
|
|
20
|
-
return !
|
|
29
|
+
return !t.returnObject && typeof e[n] == "number" ? e[n].toString() : e[n] !== void 0 && e[n] !== null ? (console.log(n), e[n].toString()) : "";
|
|
21
30
|
}
|
|
22
31
|
if (u)
|
|
23
32
|
return Object.values(e)[0];
|
|
24
33
|
}
|
|
25
|
-
return
|
|
34
|
+
return y(e) ? t.returnObject ? e.map((r) => r[n]).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)) ?? "";
|
|
26
35
|
}
|
|
27
36
|
function V(e) {
|
|
28
37
|
try {
|
|
29
|
-
let
|
|
30
|
-
if (l.value = L(e), !
|
|
31
|
-
|
|
32
|
-
else if (
|
|
33
|
-
e &&
|
|
38
|
+
let n = null;
|
|
39
|
+
if (l.value = L(e), !t.multiple)
|
|
40
|
+
t.returnObject ? n = e : h(e) ? t.itemValue ? n = e[t.itemValue] : n = Object.values(e)[0] : n = e, f.value = !1, x();
|
|
41
|
+
else if (T(e)) {
|
|
42
|
+
e && I(e);
|
|
34
43
|
return;
|
|
35
44
|
} else {
|
|
36
|
-
const u =
|
|
37
|
-
|
|
45
|
+
const u = t.returnObject ? e : h(e) ? t.itemValue ? e[t.itemValue] : Object.values(e)[0] : e;
|
|
46
|
+
n = [...i.value || [], u];
|
|
38
47
|
}
|
|
39
|
-
i.value ===
|
|
40
|
-
} catch (
|
|
41
|
-
console.log(
|
|
48
|
+
i.value === n ? g("update:modelValue", n) : i.value = n, g("selectedItem", l.value);
|
|
49
|
+
} catch (n) {
|
|
50
|
+
console.log(n);
|
|
42
51
|
} finally {
|
|
43
52
|
F(() => {
|
|
44
|
-
|
|
53
|
+
A();
|
|
45
54
|
});
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
H(
|
|
49
|
-
[() => i.value, () =>
|
|
58
|
+
[() => i.value, () => d.value],
|
|
50
59
|
([e]) => {
|
|
51
|
-
const
|
|
52
|
-
JSON.stringify(l.value) !== JSON.stringify(
|
|
60
|
+
const n = C(e);
|
|
61
|
+
JSON.stringify(l.value) !== JSON.stringify(n) && (l.value = n);
|
|
53
62
|
},
|
|
54
63
|
{ immediate: !0 }
|
|
55
64
|
);
|
|
56
65
|
function C(e) {
|
|
57
|
-
return e == null ? null :
|
|
58
|
-
(u) => typeof u == "object" ? u[
|
|
66
|
+
return e == null ? null : t.multiple && Array.isArray(e) ? t.returnObject ? e : e.map((u) => d.value.find((c) => c[t.itemValue] === u)).filter(Boolean) : t.returnObject ? e : d.value.find(
|
|
67
|
+
(u) => typeof u == "object" ? u[t.itemValue] === e : u === e
|
|
59
68
|
) ?? e;
|
|
60
69
|
}
|
|
61
|
-
function
|
|
70
|
+
function T(e) {
|
|
62
71
|
if (!i.value || !e) return !1;
|
|
63
|
-
const
|
|
64
|
-
return i.value.some((u) => (
|
|
72
|
+
const n = t.returnObject ? e[t.itemValue] : e;
|
|
73
|
+
return i.value.some((u) => (t.returnObject ? u[t.itemValue] : u) === n);
|
|
65
74
|
}
|
|
66
|
-
function
|
|
67
|
-
const
|
|
75
|
+
function I(e) {
|
|
76
|
+
const n = t.returnObject ? e[t.itemValue] : e, u = i.value.filter((c) => (t.returnObject ? c[t.itemValue] : c) !== n);
|
|
68
77
|
i.value = u;
|
|
69
78
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
79
|
+
function A(e) {
|
|
80
|
+
t.clearSearchOnSelect && (b.value = ""), t.clearOnSelect && E(), t.focusOnSelect && x();
|
|
72
81
|
}
|
|
73
|
-
function
|
|
82
|
+
function k() {
|
|
74
83
|
f.value || (f.value = !0);
|
|
75
84
|
}
|
|
76
85
|
function D() {
|
|
@@ -79,63 +88,63 @@ function U(n, h, i, s) {
|
|
|
79
88
|
function J() {
|
|
80
89
|
f.value = !f.value;
|
|
81
90
|
}
|
|
82
|
-
function
|
|
91
|
+
function w(e) {
|
|
83
92
|
return e.length === 1 && e.match(/\w/);
|
|
84
93
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
94
|
+
function x() {
|
|
95
|
+
v.value.inputField.focus();
|
|
87
96
|
}
|
|
88
97
|
function K() {
|
|
89
|
-
f.value = !0,
|
|
98
|
+
f.value = !0, S.value && v.value.$el.focus();
|
|
90
99
|
}
|
|
91
100
|
function $(e) {
|
|
92
|
-
const
|
|
93
|
-
(
|
|
94
|
-
var
|
|
95
|
-
const u = (
|
|
101
|
+
const n = e.key;
|
|
102
|
+
(w(n) || n === "Backspace") && (k(), x(), F(() => {
|
|
103
|
+
var c;
|
|
104
|
+
const u = (c = v.value) == null ? void 0 : c.inputField;
|
|
96
105
|
if (u) {
|
|
97
|
-
const
|
|
98
|
-
u.value =
|
|
106
|
+
const r = u.selectionStart, o = u.selectionEnd, a = u.value, O = e.key.length === 1 ? e.key : "";
|
|
107
|
+
u.value = a.slice(0, r) + O + a.slice(o), u.selectionStart = u.selectionEnd = r + O.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
99
108
|
}
|
|
100
109
|
}));
|
|
101
110
|
}
|
|
102
111
|
function q() {
|
|
103
|
-
f.value = !1,
|
|
112
|
+
f.value = !1, g("createItem");
|
|
104
113
|
}
|
|
105
114
|
function z(e) {
|
|
106
|
-
let
|
|
107
|
-
i.value.splice(
|
|
115
|
+
let n = i.value.indexOf(e);
|
|
116
|
+
i.value.splice(n, 1);
|
|
108
117
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
118
|
+
function E() {
|
|
119
|
+
b.value !== "" && (b.value = ""), i.value !== null && (i.value = null), l.value !== null && (l.value = null);
|
|
111
120
|
}
|
|
112
121
|
function G(e) {
|
|
113
122
|
return !!e.disabled;
|
|
114
123
|
}
|
|
115
124
|
return {
|
|
116
125
|
selectedItem: l,
|
|
117
|
-
textFieldRef:
|
|
118
|
-
listRef:
|
|
126
|
+
textFieldRef: v,
|
|
127
|
+
listRef: S,
|
|
119
128
|
menuModel: f,
|
|
120
|
-
search:
|
|
129
|
+
search: b,
|
|
121
130
|
getItemText: N,
|
|
122
131
|
placeholder: B,
|
|
123
132
|
textArr: R,
|
|
124
133
|
itemToString: j,
|
|
125
134
|
getSelectedItem: V,
|
|
126
|
-
checkIfValueExist:
|
|
127
|
-
removeFromArray:
|
|
128
|
-
lightReset:
|
|
129
|
-
openMenu:
|
|
135
|
+
checkIfValueExist: T,
|
|
136
|
+
removeFromArray: I,
|
|
137
|
+
lightReset: A,
|
|
138
|
+
openMenu: k,
|
|
130
139
|
closeMenu: D,
|
|
131
140
|
toggleMenu: J,
|
|
132
141
|
focusOnMenu: K,
|
|
133
142
|
onMenuKeydown: $,
|
|
134
143
|
createItem: q,
|
|
135
144
|
removeItem: z,
|
|
136
|
-
clearSelection:
|
|
145
|
+
clearSelection: E,
|
|
137
146
|
checkDisabled: G,
|
|
138
|
-
isAlphanumeric:
|
|
147
|
+
isAlphanumeric: w
|
|
139
148
|
};
|
|
140
149
|
}
|
|
141
150
|
export {
|
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
import { ref as I, computed as t, watch as
|
|
1
|
+
import { ref as I, computed as t, watch as b, nextTick as k } from "vue";
|
|
2
2
|
function q({
|
|
3
|
-
items:
|
|
3
|
+
items: g,
|
|
4
4
|
search: i,
|
|
5
5
|
searchableKeys: v = [],
|
|
6
6
|
itemsPerIntersection: r = 20
|
|
7
7
|
}) {
|
|
8
|
-
const l = I(1), f = I(null),
|
|
8
|
+
const l = I(1), f = I(null), n = t(
|
|
9
9
|
() => Array.isArray(v) ? v : []
|
|
10
|
-
),
|
|
10
|
+
), w = t(
|
|
11
11
|
() => typeof r == "number" && r > 0 ? r : 20
|
|
12
|
-
),
|
|
13
|
-
var
|
|
14
|
-
const e =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
), u = t(() => {
|
|
13
|
+
var d;
|
|
14
|
+
const e = g.value || [], a = (d = i.value) == null ? void 0 : d.trim().toLowerCase();
|
|
15
|
+
if (!a || !n.value) return e;
|
|
16
|
+
const o = Array.isArray(n.value) ? n.value : [n.value];
|
|
17
|
+
return e.filter((A) => o.some((C) => {
|
|
18
|
+
const p = C.split(".").reduce((y, T) => y != null ? y[T] : void 0, A);
|
|
19
|
+
return p == null ? !1 : String(p).toLowerCase().includes(a);
|
|
18
20
|
}));
|
|
19
|
-
}),
|
|
20
|
-
() =>
|
|
21
|
+
}), x = t(() => u.value.length), s = t(
|
|
22
|
+
() => u.value.slice(
|
|
21
23
|
0,
|
|
22
|
-
l.value *
|
|
24
|
+
l.value * w.value
|
|
23
25
|
)
|
|
24
|
-
),
|
|
25
|
-
() =>
|
|
26
|
-
),
|
|
27
|
-
function
|
|
28
|
-
|
|
26
|
+
), c = t(
|
|
27
|
+
() => s.value.length >= u.value.length
|
|
28
|
+
), B = t(() => l.value === 1);
|
|
29
|
+
function h() {
|
|
30
|
+
c.value || l.value++;
|
|
29
31
|
}
|
|
30
|
-
function
|
|
32
|
+
function m() {
|
|
31
33
|
l.value = 1;
|
|
32
34
|
}
|
|
33
|
-
|
|
35
|
+
b(
|
|
34
36
|
() => i.value,
|
|
35
37
|
() => {
|
|
36
|
-
|
|
38
|
+
m();
|
|
37
39
|
},
|
|
38
40
|
{ flush: "pre" }
|
|
39
41
|
);
|
|
40
|
-
async function
|
|
42
|
+
async function S(e) {
|
|
41
43
|
if (typeof e != "number" || e < 0) return;
|
|
42
44
|
f.value = e;
|
|
43
|
-
const a =
|
|
44
|
-
for (;
|
|
45
|
-
|
|
45
|
+
const a = u.value.length - 1, o = Math.min(e, a);
|
|
46
|
+
for (; o >= s.value.length && !c.value; )
|
|
47
|
+
h(), await k();
|
|
46
48
|
}
|
|
47
49
|
return {
|
|
48
|
-
visibleItems:
|
|
49
|
-
loadNextBatch:
|
|
50
|
-
resetCurrentBatchStep:
|
|
51
|
-
lastBatchReached:
|
|
52
|
-
isFirstBatch:
|
|
53
|
-
totalItems:
|
|
54
|
-
setScrollToIndex:
|
|
50
|
+
visibleItems: s,
|
|
51
|
+
loadNextBatch: h,
|
|
52
|
+
resetCurrentBatchStep: m,
|
|
53
|
+
lastBatchReached: c,
|
|
54
|
+
isFirstBatch: B,
|
|
55
|
+
totalItems: x,
|
|
56
|
+
setScrollToIndex: S,
|
|
55
57
|
scrollToIndex: f
|
|
56
58
|
// opcional, si lo necesitás desde el componente padre
|
|
57
59
|
};
|