adverich-kun-ui 0.1.619 → 0.1.620
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/AGENTS.md +1 -0
- package/dist/AGENTS.md +1 -0
- package/dist/components/KunAutocomplete/src/components/KunAutocomplete.vue.js +131 -127
- package/dist/components/KunAutocomplete/src/composables/KunAutocompleteProps.js +4 -0
- package/dist/components/KunAutocomplete/src/composables/useAutocomplete.js +81 -78
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -145,6 +145,7 @@ Selector con autocompletado y búsqueda.
|
|
|
145
145
|
| itemSubtitle | String/Array | null | Campo(s) para subtítulo |
|
|
146
146
|
| returnObject | Boolean | false | Retorna objeto completo |
|
|
147
147
|
| multiple | Boolean | false | Selección múltiple |
|
|
148
|
+
| disabled | Boolean | false | Deshabilita el campo y sus acciones |
|
|
148
149
|
| clearable | Boolean | false | Botón de limpiar |
|
|
149
150
|
| searchableKeys | Array | [] | Campos para búsqueda |
|
|
150
151
|
| hasCreateItem | Boolean | false | Muestra botón de crear |
|
package/dist/AGENTS.md
CHANGED
|
@@ -145,6 +145,7 @@ Selector con autocompletado y búsqueda.
|
|
|
145
145
|
| itemSubtitle | String/Array | null | Campo(s) para subtítulo |
|
|
146
146
|
| returnObject | Boolean | false | Retorna objeto completo |
|
|
147
147
|
| multiple | Boolean | false | Selección múltiple |
|
|
148
|
+
| disabled | Boolean | false | Deshabilita el campo y sus acciones |
|
|
148
149
|
| clearable | Boolean | false | Botón de limpiar |
|
|
149
150
|
| searchableKeys | Array | [] | Campos para búsqueda |
|
|
150
151
|
| hasCreateItem | Boolean | false | Muestra botón de crear |
|
|
@@ -1,246 +1,250 @@
|
|
|
1
|
-
import { useModel as
|
|
1
|
+
import { useModel as E, onMounted as ue, ref as F, watch as O, nextTick as R, openBlock as c, createElementBlock as y, createVNode as s, unref as t, withKeys as de, withModifiers as V, isRef as x, createSlots as ce, withCtx as a, normalizeClass as fe, createTextVNode as h, toDisplayString as D, createCommentVNode as g, createBlock as p, Fragment as me, renderList as pe, createElementVNode as ve, mergeModels as B } from "vue";
|
|
2
2
|
import { icons as v } 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
|
|
3
|
+
import { isNotEmpty as N, isArray as T } from "../../../../utils/utils.js";
|
|
4
|
+
import be from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
|
|
5
|
+
import ke from "../../../KunList/src/components/KunList.vue.js";
|
|
6
|
+
import U from "../../../KunListItem/src/components/KunListItem.vue.js";
|
|
7
|
+
import j from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
|
|
8
|
+
import ye from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
|
|
9
|
+
import he from "../../../KunMenu/src/components/KunMenu.vue.js";
|
|
10
|
+
import { useAutocomplete as ge } from "../composables/useAutocomplete.js";
|
|
11
|
+
import { KunAutocompleteProps as Ce } from "../composables/KunAutocompleteProps.js";
|
|
12
12
|
import we from "../../../KunTextField/src/components/KunTextField.vue.js";
|
|
13
13
|
import Se from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
14
14
|
import Ve from "../../../KunChip/src/components/KunChip.vue.js";
|
|
15
|
-
import
|
|
15
|
+
import C from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
16
16
|
const De = { class: "flex items-center" }, Ie = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "sticky top-0 z-10 p-2 border-b bg-select-background"
|
|
19
19
|
}, je = {
|
|
20
20
|
__name: "KunAutocomplete",
|
|
21
|
-
props: /* @__PURE__ */
|
|
21
|
+
props: /* @__PURE__ */ B(Ce, {
|
|
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(w, { expose:
|
|
29
|
-
const u =
|
|
30
|
-
textFieldRef:
|
|
27
|
+
emits: /* @__PURE__ */ B(["update:modelValue", "selectedItem", "createItem", "validation", "search", "keyDown", "keyDownEnter", "notFound", "cleared"], ["update:modelValue", "update:items"]),
|
|
28
|
+
setup(w, { expose: H, emit: q }) {
|
|
29
|
+
const u = E(w, "modelValue"), m = E(w, "items"), n = w, f = q, {
|
|
30
|
+
textFieldRef: b,
|
|
31
31
|
listRef: I,
|
|
32
32
|
menuModel: d,
|
|
33
|
-
search:
|
|
34
|
-
removeItem:
|
|
35
|
-
clearSelection:
|
|
36
|
-
lightReset:
|
|
33
|
+
search: r,
|
|
34
|
+
removeItem: _,
|
|
35
|
+
clearSelection: P,
|
|
36
|
+
lightReset: W,
|
|
37
37
|
openMenu: S,
|
|
38
|
-
closeMenu:
|
|
39
|
-
toggleMenu:
|
|
40
|
-
onMenuKeydown:
|
|
41
|
-
getSelectedItem:
|
|
42
|
-
textArr:
|
|
43
|
-
getArrayText:
|
|
44
|
-
isAlphanumeric:
|
|
45
|
-
createItem:
|
|
46
|
-
checkDisabled:
|
|
47
|
-
itemToString:
|
|
48
|
-
placeholder:
|
|
49
|
-
} =
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
closeMenu: K,
|
|
39
|
+
toggleMenu: L,
|
|
40
|
+
onMenuKeydown: G,
|
|
41
|
+
getSelectedItem: M,
|
|
42
|
+
textArr: J,
|
|
43
|
+
getArrayText: Q,
|
|
44
|
+
isAlphanumeric: X,
|
|
45
|
+
createItem: Y,
|
|
46
|
+
checkDisabled: Z,
|
|
47
|
+
itemToString: $,
|
|
48
|
+
placeholder: ee
|
|
49
|
+
} = ge(n, f, u, m);
|
|
50
|
+
ue(() => {
|
|
51
|
+
n.focusOnRender && b.value.focus();
|
|
52
52
|
});
|
|
53
|
-
const
|
|
54
|
-
for (const o of
|
|
53
|
+
const z = F(null), k = F(""), A = (e) => {
|
|
54
|
+
for (const o of n.rules) {
|
|
55
55
|
const l = o(e);
|
|
56
56
|
if (l !== !0)
|
|
57
|
-
return
|
|
57
|
+
return k.value = l, f("validation", !1), !1;
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return k.value = "", f("validation", !0), !0;
|
|
60
60
|
};
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
O(() => u.value, (e, o) => {
|
|
62
|
+
N(n.rules) && A(e);
|
|
63
|
+
}), O(() => n.disabled, (e) => {
|
|
64
|
+
e && K();
|
|
63
65
|
});
|
|
64
|
-
function
|
|
66
|
+
function le() {
|
|
65
67
|
var e;
|
|
66
|
-
d.value = !1, (e =
|
|
68
|
+
d.value = !1, (e = b.value.inputField) == null || e.focus();
|
|
67
69
|
}
|
|
68
|
-
function
|
|
70
|
+
function te(e) {
|
|
69
71
|
var l, i;
|
|
72
|
+
if (n.disabled) return;
|
|
70
73
|
const o = e.key;
|
|
71
74
|
if (o === "Tab" || o === "Shift" || o === "Escape") {
|
|
72
|
-
|
|
75
|
+
K(), f("keyDown", o);
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
|
-
(
|
|
78
|
+
(X(o) || o === "Backspace") && S(), ["ArrowUp", "ArrowDown"].includes(o) && (e.preventDefault(), d.value || S(), (i = (l = I.value) == null ? void 0 : l.focusWithKey) == null || i.call(l, o));
|
|
76
79
|
}
|
|
77
|
-
function
|
|
78
|
-
f("search",
|
|
80
|
+
function oe(e) {
|
|
81
|
+
f("search", r);
|
|
79
82
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
83
|
+
function ne() {
|
|
84
|
+
n.disabled || A(u);
|
|
82
85
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
86
|
+
function re(e) {
|
|
87
|
+
G(e);
|
|
85
88
|
}
|
|
86
|
-
function
|
|
89
|
+
function ae() {
|
|
87
90
|
}
|
|
88
|
-
function
|
|
89
|
-
if (
|
|
91
|
+
function ie(e) {
|
|
92
|
+
if (n.disabled || !r.value) return;
|
|
90
93
|
let o = null;
|
|
91
|
-
|
|
94
|
+
n.returnObject ? o = m.value.find(
|
|
92
95
|
(l) => Object.values(l).some(
|
|
93
|
-
(i) => String(i).toLowerCase() === String(
|
|
96
|
+
(i) => String(i).toLowerCase() === String(r.value).toLowerCase()
|
|
94
97
|
)
|
|
95
|
-
) :
|
|
96
|
-
(l) => String(l[
|
|
98
|
+
) : n.itemValue ? o = m.value.find(
|
|
99
|
+
(l) => String(l[n.itemValue]).toLowerCase() === String(r.value).toLowerCase()
|
|
97
100
|
) : o = m.value.find(
|
|
98
|
-
(l) => typeof l == "object" ? Object.values(l).some((i) => String(i).toLowerCase() === String(
|
|
99
|
-
), o ?
|
|
101
|
+
(l) => typeof l == "object" ? Object.values(l).some((i) => String(i).toLowerCase() === String(r.value).toLowerCase()) : String(l).toLowerCase() === String(r.value).toLowerCase()
|
|
102
|
+
), o ? M(o) : (f("notFound", r.value), n.clearOnNotFound && (r.value = "", d.value = !1)), R(() => {
|
|
100
103
|
f("keyDownEnter", e);
|
|
101
104
|
});
|
|
102
105
|
}
|
|
103
|
-
return
|
|
104
|
-
focus: () =>
|
|
106
|
+
return H({
|
|
107
|
+
focus: () => !n.disabled && R(() => {
|
|
105
108
|
var e;
|
|
106
|
-
return (e =
|
|
109
|
+
return (e = b.value) == null ? void 0 : e.focus();
|
|
107
110
|
})
|
|
108
|
-
}), (e, o) => (c(),
|
|
111
|
+
}), (e, o) => (c(), y("div", {
|
|
109
112
|
class: "w-full h-fit",
|
|
110
113
|
ref_key: "parentRef",
|
|
111
|
-
ref:
|
|
114
|
+
ref: z
|
|
112
115
|
}, [
|
|
113
116
|
s(we, {
|
|
114
|
-
modelValue: t(
|
|
117
|
+
modelValue: t(r),
|
|
115
118
|
"onUpdate:modelValue": [
|
|
116
|
-
o[2] || (o[2] = (l) => x(
|
|
117
|
-
|
|
119
|
+
o[2] || (o[2] = (l) => x(r) ? r.value = l : null),
|
|
120
|
+
oe
|
|
118
121
|
],
|
|
119
122
|
label: e.label,
|
|
123
|
+
disabled: e.disabled,
|
|
120
124
|
dirty: "",
|
|
121
125
|
"hide-details": e.hideDetails,
|
|
122
126
|
density: e.density,
|
|
123
127
|
ref_key: "textFieldRef",
|
|
124
|
-
ref:
|
|
128
|
+
ref: b,
|
|
125
129
|
autocomplete: "off",
|
|
126
|
-
onFocusInput:
|
|
127
|
-
onHandleClick: t(
|
|
130
|
+
onFocusInput: ne,
|
|
131
|
+
onHandleClick: t(L),
|
|
128
132
|
rounded: t(d) ? "rounded-t" : "rounded",
|
|
129
|
-
onBlur:
|
|
133
|
+
onBlur: ae,
|
|
130
134
|
onKeyDown: [
|
|
131
|
-
|
|
132
|
-
de(
|
|
135
|
+
te,
|
|
136
|
+
de(V(ie, ["prevent"]), ["enter"])
|
|
133
137
|
],
|
|
134
|
-
placeholder:
|
|
135
|
-
error: !!
|
|
136
|
-
"error-messages":
|
|
138
|
+
placeholder: n.multiple && t(T)(u.value) && u.value.length ? "" : t(ee),
|
|
139
|
+
error: !!k.value,
|
|
140
|
+
"error-messages": k.value
|
|
137
141
|
}, ce({
|
|
138
|
-
"prepend-input-content":
|
|
139
|
-
t(
|
|
142
|
+
"prepend-input-content": a(() => [
|
|
143
|
+
t(T)(u.value) && t(N)(u.value) ? (c(), y("div", {
|
|
140
144
|
key: 0,
|
|
141
145
|
class: "flex flex-nowrap items-center space-x-1 min-w-[calc(100%-56px)] overflow-x-auto overflow-y-hidden",
|
|
142
|
-
onClick: o[0] || (o[0] = (
|
|
146
|
+
onClick: o[0] || (o[0] = (l) => !e.disabled && t(L)())
|
|
143
147
|
}, [
|
|
144
|
-
(c(!0),
|
|
148
|
+
(c(!0), y(me, null, pe(u.value, (l) => (c(), p(Ve, {
|
|
145
149
|
key: l.id ?? l.name,
|
|
146
150
|
size: "small",
|
|
147
151
|
variant: "pill"
|
|
148
152
|
}, {
|
|
149
|
-
default:
|
|
153
|
+
default: a(() => [
|
|
150
154
|
ve("div", De, [
|
|
151
|
-
|
|
152
|
-
s(
|
|
155
|
+
h(D(t(Q)(l)) + " ", 1),
|
|
156
|
+
s(C, {
|
|
153
157
|
color: "error",
|
|
154
158
|
icon: t(v).close,
|
|
155
159
|
size: "small",
|
|
156
160
|
class: "ml-1",
|
|
157
|
-
onClick: (i) => t(
|
|
161
|
+
onClick: V((i) => t(_)(l), ["stop"])
|
|
158
162
|
}, null, 8, ["icon", "onClick"])
|
|
159
163
|
])
|
|
160
164
|
]),
|
|
161
165
|
_: 2
|
|
162
166
|
}, 1024))), 128))
|
|
163
|
-
])) :
|
|
167
|
+
])) : g("", !0)
|
|
164
168
|
]),
|
|
165
|
-
default:
|
|
166
|
-
s(
|
|
169
|
+
default: a(() => [
|
|
170
|
+
s(he, {
|
|
167
171
|
transition: "fade",
|
|
168
|
-
"onClick:outside": t(
|
|
172
|
+
"onClick:outside": t(W),
|
|
169
173
|
modelValue: t(d),
|
|
170
174
|
"onUpdate:modelValue": o[1] || (o[1] = (l) => x(d) ? d.value = l : null),
|
|
171
175
|
activator: "parent",
|
|
172
176
|
"z-index": e.zIndex,
|
|
173
|
-
"parent-ref":
|
|
177
|
+
"parent-ref": z.value,
|
|
174
178
|
origin: e.menuOrigin,
|
|
175
|
-
onHandleEscape:
|
|
179
|
+
onHandleEscape: le,
|
|
176
180
|
bgColor: e.bgMenuColor,
|
|
177
181
|
"close-on-content-click": e.closeOnSelect,
|
|
178
182
|
width: "w-full",
|
|
179
183
|
"max-height": e.maxHeight,
|
|
180
184
|
"hide-details": e.hideDetails
|
|
181
185
|
}, {
|
|
182
|
-
default:
|
|
183
|
-
e.hasCreateItem ? (c(),
|
|
186
|
+
default: a(() => [
|
|
187
|
+
e.hasCreateItem ? (c(), y("div", Ie, [
|
|
184
188
|
s(Se, {
|
|
185
|
-
onClick: t(
|
|
189
|
+
onClick: t(Y),
|
|
186
190
|
bgColor: e.btnCreateBg,
|
|
187
191
|
class: fe(e.btnCreateClass)
|
|
188
192
|
}, {
|
|
189
|
-
default:
|
|
190
|
-
|
|
193
|
+
default: a(() => [
|
|
194
|
+
h(D(e.btnCreateText), 1)
|
|
191
195
|
]),
|
|
192
196
|
_: 1
|
|
193
197
|
}, 8, ["onClick", "bgColor", "class"])
|
|
194
|
-
])) :
|
|
195
|
-
s(
|
|
196
|
-
"onClick:select": t(
|
|
198
|
+
])) : g("", !0),
|
|
199
|
+
s(ke, {
|
|
200
|
+
"onClick:select": t(M),
|
|
197
201
|
ref_key: "listRef",
|
|
198
202
|
ref: I,
|
|
199
|
-
onKeyDown:
|
|
203
|
+
onKeyDown: re,
|
|
200
204
|
selectable: !0
|
|
201
205
|
}, {
|
|
202
|
-
default:
|
|
203
|
-
s(
|
|
206
|
+
default: a(() => [
|
|
207
|
+
s(be, {
|
|
204
208
|
items: m.value,
|
|
205
|
-
search: t(
|
|
206
|
-
"searchable-keys":
|
|
209
|
+
search: t(r),
|
|
210
|
+
"searchable-keys": n.searchableKeys,
|
|
207
211
|
virtual: !1,
|
|
208
212
|
"items-per-intersection": 10,
|
|
209
213
|
enabled: t(d),
|
|
210
214
|
"item-height": 48
|
|
211
215
|
}, {
|
|
212
|
-
default:
|
|
213
|
-
!
|
|
216
|
+
default: a(({ item: l, index: i, empty: se }) => [
|
|
217
|
+
!se && l != null ? (c(), p(U, {
|
|
214
218
|
value: l,
|
|
215
219
|
key: `kun-list-${i + 1}`,
|
|
216
220
|
id: `kun-item-${i + 1}`,
|
|
217
|
-
disabled: t(
|
|
221
|
+
disabled: t(Z)(l),
|
|
218
222
|
"bg-items": e.bgItemListColor,
|
|
219
223
|
"hover-bg": e.hoverItemListColor,
|
|
220
224
|
activeClass: e.selectedItemListColor,
|
|
221
225
|
density: e.density,
|
|
222
226
|
selectable: !0
|
|
223
227
|
}, {
|
|
224
|
-
default:
|
|
225
|
-
s(
|
|
226
|
-
default:
|
|
227
|
-
|
|
228
|
+
default: a(() => [
|
|
229
|
+
s(j, { class: "text-wrap" }, {
|
|
230
|
+
default: a(() => [
|
|
231
|
+
h(D(t($)(l, e.itemTitle ?? t(J), "hasDefault")), 1)
|
|
228
232
|
]),
|
|
229
233
|
_: 2
|
|
230
234
|
}, 1024),
|
|
231
|
-
s(
|
|
232
|
-
text: e.itemSubtitle ? t(
|
|
235
|
+
s(ye, {
|
|
236
|
+
text: e.itemSubtitle ? t($)(l, e.itemSubtitle) : ""
|
|
233
237
|
}, null, 8, ["text"])
|
|
234
238
|
]),
|
|
235
239
|
_: 2
|
|
236
|
-
}, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (c(), p(
|
|
240
|
+
}, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (c(), p(U, {
|
|
237
241
|
key: 1,
|
|
238
242
|
disabled: ""
|
|
239
243
|
}, {
|
|
240
|
-
default:
|
|
241
|
-
s(
|
|
242
|
-
default:
|
|
243
|
-
|
|
244
|
+
default: a(() => [
|
|
245
|
+
s(j, { class: "text-center w-full text-gray-500" }, {
|
|
246
|
+
default: a(() => [...o[3] || (o[3] = [
|
|
247
|
+
h(" No hay elementos disponibles ", -1)
|
|
244
248
|
])]),
|
|
245
249
|
_: 1
|
|
246
250
|
})
|
|
@@ -261,33 +265,33 @@ const De = { class: "flex items-center" }, Ie = {
|
|
|
261
265
|
}, [
|
|
262
266
|
e.hasIcons ? {
|
|
263
267
|
name: "append-inner",
|
|
264
|
-
fn:
|
|
265
|
-
e.clearable && u.value ? (c(), p(
|
|
268
|
+
fn: a(() => [
|
|
269
|
+
e.clearable && u.value ? (c(), p(C, {
|
|
266
270
|
key: 0,
|
|
267
|
-
onClick: t(
|
|
271
|
+
onClick: t(P),
|
|
268
272
|
size: "small",
|
|
269
273
|
color: "error",
|
|
270
274
|
icon: t(v).close,
|
|
271
275
|
class: "mr-1 mt-1"
|
|
272
|
-
}, null, 8, ["onClick", "icon"])) :
|
|
273
|
-
s(
|
|
276
|
+
}, null, 8, ["onClick", "icon"])) : g("", !0),
|
|
277
|
+
s(C, {
|
|
274
278
|
color: "teal-darken-1",
|
|
275
279
|
size: "large",
|
|
276
280
|
class: "cursor-pointer",
|
|
277
281
|
icon: t(d) ? t(v).menuUpOutline : t(v).menuDownOutline,
|
|
278
|
-
onClick:
|
|
282
|
+
onClick: V(t(S), ["stop"])
|
|
279
283
|
}, null, 8, ["icon", "onClick"]),
|
|
280
|
-
e.required ? (c(), p(
|
|
284
|
+
e.required ? (c(), p(C, {
|
|
281
285
|
key: 1,
|
|
282
286
|
color: "teal-darken-1",
|
|
283
287
|
size: "x-small",
|
|
284
288
|
class: "mb-4",
|
|
285
289
|
icon: t(v).asterisk
|
|
286
|
-
}, null, 8, ["icon"])) :
|
|
290
|
+
}, null, 8, ["icon"])) : g("", !0)
|
|
287
291
|
]),
|
|
288
292
|
key: "0"
|
|
289
293
|
} : void 0
|
|
290
|
-
]), 1032, ["modelValue", "label", "hide-details", "density", "onHandleClick", "rounded", "onKeyDown", "placeholder", "error", "error-messages"])
|
|
294
|
+
]), 1032, ["modelValue", "label", "disabled", "hide-details", "density", "onHandleClick", "rounded", "onKeyDown", "placeholder", "error", "error-messages"])
|
|
291
295
|
], 512));
|
|
292
296
|
}
|
|
293
297
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { ref as d, computed as
|
|
1
|
+
import { ref as d, computed as N, watch as P, nextTick as R } from "vue";
|
|
2
2
|
import { isArray as S, isObject as v, fullCopy as T } from "../../../../utils/utils.js";
|
|
3
|
-
function W(t,
|
|
4
|
-
const l = d(null),
|
|
5
|
-
if (t.returnObject) return
|
|
6
|
-
const u = l.value.find((
|
|
7
|
-
return
|
|
8
|
-
},
|
|
3
|
+
function W(t, b, i, y) {
|
|
4
|
+
const l = d(null), g = d(null), I = d(null), f = d(!1), h = d(""), B = (e, n) => {
|
|
5
|
+
if (t.returnObject) return o(e, t.itemTitle);
|
|
6
|
+
const u = l.value.find((c) => c[t.itemValue] === e);
|
|
7
|
+
return o(u, t.itemTitle);
|
|
8
|
+
}, C = N(() => l.value !== null && l.value !== void 0 ? S(l.value) ? l.value.length ? o(l.value, t.itemTitle, "hasDefault") : t.placeholderText : v(l.value) ? o(l.value, t.itemTitle, "hasDefault") : l.value.toString() : y.value.length ? t.placeholderText : t.textNoItems), D = N(() => {
|
|
9
9
|
const e = t.itemText;
|
|
10
10
|
return typeof e == "string" && e.includes(",") ? e.split(",") : e;
|
|
11
11
|
});
|
|
12
|
-
function
|
|
13
|
-
var
|
|
12
|
+
function o(e, n, u) {
|
|
13
|
+
var c;
|
|
14
14
|
if (v(e)) {
|
|
15
15
|
if (n) {
|
|
16
16
|
if (S(n))
|
|
17
17
|
return n.map((r) => {
|
|
18
18
|
if (r.includes(".")) {
|
|
19
|
-
const
|
|
19
|
+
const s = r.split(".");
|
|
20
20
|
let a = e;
|
|
21
|
-
for (const j of
|
|
21
|
+
for (const j of s)
|
|
22
22
|
a = a != null ? a[j] : "";
|
|
23
23
|
return a ?? "No definido";
|
|
24
24
|
}
|
|
@@ -28,56 +28,57 @@ function W(t, y, c, g) {
|
|
|
28
28
|
return n.split(",").map((r) => e[r]).join(" - ");
|
|
29
29
|
if (n.includes(".")) {
|
|
30
30
|
const r = n.split(".");
|
|
31
|
-
let
|
|
31
|
+
let s = e;
|
|
32
32
|
for (const a of r)
|
|
33
|
-
|
|
34
|
-
return
|
|
33
|
+
s = s != null ? s[a] : "";
|
|
34
|
+
return s;
|
|
35
35
|
}
|
|
36
36
|
return !t.returnObject && typeof e[n] == "number" || e[n] !== void 0 && e[n] !== null ? e[n].toString() : "";
|
|
37
37
|
}
|
|
38
38
|
if (u)
|
|
39
39
|
return Object.values(e)[0];
|
|
40
40
|
}
|
|
41
|
-
return S(e) ? t.returnObject ? e.map((r) => r[n]).join(" - ") : e.map((r) => r).join(" - ") : u && typeof e != "number" ? e.includes(",") ? e.split(",") : e : ((
|
|
42
|
-
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
return S(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)) ?? "";
|
|
42
|
+
}
|
|
43
|
+
function J(e) {
|
|
44
|
+
if (!(t.disabled || F(e)))
|
|
45
|
+
try {
|
|
46
|
+
let n = null;
|
|
47
|
+
if (l.value = T(e), !t.multiple)
|
|
48
|
+
t.returnObject ? n = T(e) : v(e) ? t.itemValue ? n = e[t.itemValue] : n = Object.values(e)[0] : n = e, f.value = !1, x();
|
|
49
|
+
else if (k(e)) {
|
|
50
|
+
e && A(e);
|
|
51
|
+
return;
|
|
52
|
+
} else {
|
|
53
|
+
const u = t.returnObject ? T(e) : v(e) ? t.itemValue ? e[t.itemValue] : Object.values(e)[0] : e;
|
|
54
|
+
n = [...i.value || [], u];
|
|
55
|
+
}
|
|
56
|
+
i.value === n ? b("update:modelValue", n) : i.value = n, b("selectedItem", l.value);
|
|
57
|
+
} catch (n) {
|
|
58
|
+
console.log(n);
|
|
59
|
+
} finally {
|
|
60
|
+
R(() => {
|
|
61
|
+
K();
|
|
62
|
+
});
|
|
54
63
|
}
|
|
55
|
-
c.value === n ? y("update:modelValue", n) : c.value = n, y("selectedItem", l.value);
|
|
56
|
-
} catch (n) {
|
|
57
|
-
console.log(n);
|
|
58
|
-
} finally {
|
|
59
|
-
N(() => {
|
|
60
|
-
K();
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
64
|
}
|
|
64
65
|
P(
|
|
65
|
-
[() =>
|
|
66
|
+
[() => i.value, () => y.value],
|
|
66
67
|
([e]) => {
|
|
67
|
-
const n =
|
|
68
|
+
const n = V(e);
|
|
68
69
|
JSON.stringify(l.value) !== JSON.stringify(n) && (l.value = n);
|
|
69
70
|
},
|
|
70
71
|
{ immediate: !0 }
|
|
71
72
|
);
|
|
72
|
-
function
|
|
73
|
-
return e == null ? null : t.multiple && Array.isArray(e) ? t.returnObject ? e : e.map((u) =>
|
|
73
|
+
function V(e) {
|
|
74
|
+
return e == null ? null : t.multiple && Array.isArray(e) ? t.returnObject ? e : e.map((u) => y.value.find((c) => c[t.itemValue] === u)).filter(Boolean) : t.returnObject ? e : y.value.find(
|
|
74
75
|
(u) => typeof u == "object" ? u[t.itemValue] === e : u === e
|
|
75
76
|
) ?? e;
|
|
76
77
|
}
|
|
77
78
|
function k(e) {
|
|
78
|
-
if (!
|
|
79
|
+
if (!i.value || !e) return !1;
|
|
79
80
|
const n = O(e);
|
|
80
|
-
return
|
|
81
|
+
return i.value.some((u) => O(u) === n);
|
|
81
82
|
}
|
|
82
83
|
function O(e) {
|
|
83
84
|
if (!v(e))
|
|
@@ -90,78 +91,80 @@ function W(t, y, c, g) {
|
|
|
90
91
|
return n.length > 0 ? n[0] : e;
|
|
91
92
|
}
|
|
92
93
|
function A(e) {
|
|
93
|
-
if (!
|
|
94
|
+
if (!i.value) return;
|
|
94
95
|
const n = O(e);
|
|
95
|
-
|
|
96
|
+
i.value = i.value.filter((u) => O(u) !== n);
|
|
96
97
|
}
|
|
97
98
|
function K(e) {
|
|
98
|
-
t.clearSearchOnSelect && (
|
|
99
|
+
t.clearSearchOnSelect && (h.value = ""), t.clearOnSelect && M(), t.focusOnSelect && x();
|
|
99
100
|
}
|
|
100
101
|
function w() {
|
|
101
|
-
f.value || (f.value = !0);
|
|
102
|
+
t.disabled || f.value || (f.value = !0);
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
+
function $() {
|
|
104
105
|
f.value && (f.value = !1);
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
-
f.value = !f.value;
|
|
107
|
+
function q() {
|
|
108
|
+
t.disabled || (f.value = !f.value);
|
|
108
109
|
}
|
|
109
110
|
function E(e) {
|
|
110
111
|
return e.length === 1 && e.match(/\w/);
|
|
111
112
|
}
|
|
112
113
|
function x() {
|
|
113
|
-
|
|
114
|
+
g.value.inputField.focus();
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
-
f.value = !0, I.value &&
|
|
116
|
+
function z() {
|
|
117
|
+
f.value = !0, I.value && g.value.$el.focus();
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
+
function G(e) {
|
|
120
|
+
if (t.disabled) return;
|
|
119
121
|
const n = e.key;
|
|
120
|
-
(E(n) || n === "Backspace") && (w(), x(),
|
|
121
|
-
var
|
|
122
|
-
const u = (
|
|
122
|
+
(E(n) || n === "Backspace") && (w(), x(), R(() => {
|
|
123
|
+
var c;
|
|
124
|
+
const u = (c = g.value) == null ? void 0 : c.inputField;
|
|
123
125
|
if (u) {
|
|
124
|
-
const r = u.selectionStart,
|
|
125
|
-
u.value = a.slice(0, r) + j + a.slice(
|
|
126
|
+
const r = u.selectionStart, s = u.selectionEnd, a = u.value, j = e.key.length === 1 ? e.key : "";
|
|
127
|
+
u.value = a.slice(0, r) + j + a.slice(s), u.selectionStart = u.selectionEnd = r + j.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
126
128
|
}
|
|
127
129
|
}));
|
|
128
130
|
}
|
|
129
|
-
function
|
|
130
|
-
f.value = !1,
|
|
131
|
+
function H() {
|
|
132
|
+
t.disabled || (f.value = !1, b("createItem"));
|
|
131
133
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
function L(e) {
|
|
135
|
+
if (t.disabled) return;
|
|
136
|
+
let n = i.value.indexOf(e);
|
|
137
|
+
i.value.splice(n, 1);
|
|
135
138
|
}
|
|
136
139
|
function M() {
|
|
137
|
-
|
|
140
|
+
t.disabled || (h.value !== "" && (h.value = ""), i.value !== null && (i.value = null), l.value !== null && (l.value = null), b("cleared"));
|
|
138
141
|
}
|
|
139
|
-
function
|
|
142
|
+
function F(e) {
|
|
140
143
|
return !!e.disabled;
|
|
141
144
|
}
|
|
142
145
|
return {
|
|
143
146
|
selectedItem: l,
|
|
144
|
-
textFieldRef:
|
|
147
|
+
textFieldRef: g,
|
|
145
148
|
listRef: I,
|
|
146
149
|
menuModel: f,
|
|
147
|
-
search:
|
|
148
|
-
getArrayText:
|
|
149
|
-
placeholder:
|
|
150
|
-
textArr:
|
|
151
|
-
itemToString:
|
|
152
|
-
getSelectedItem:
|
|
150
|
+
search: h,
|
|
151
|
+
getArrayText: B,
|
|
152
|
+
placeholder: C,
|
|
153
|
+
textArr: D,
|
|
154
|
+
itemToString: o,
|
|
155
|
+
getSelectedItem: J,
|
|
153
156
|
checkIfValueExist: k,
|
|
154
157
|
removeFromArray: A,
|
|
155
158
|
lightReset: K,
|
|
156
159
|
openMenu: w,
|
|
157
|
-
closeMenu:
|
|
158
|
-
toggleMenu:
|
|
159
|
-
focusOnMenu:
|
|
160
|
-
onMenuKeydown:
|
|
161
|
-
createItem:
|
|
162
|
-
removeItem:
|
|
160
|
+
closeMenu: $,
|
|
161
|
+
toggleMenu: q,
|
|
162
|
+
focusOnMenu: z,
|
|
163
|
+
onMenuKeydown: G,
|
|
164
|
+
createItem: H,
|
|
165
|
+
removeItem: L,
|
|
163
166
|
clearSelection: M,
|
|
164
|
-
checkDisabled:
|
|
167
|
+
checkDisabled: F,
|
|
165
168
|
isAlphanumeric: E
|
|
166
169
|
};
|
|
167
170
|
}
|