adverich-kun-ui 0.1.56 → 0.1.57
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,76 +1,79 @@
|
|
|
1
|
-
import { mergeModels as
|
|
2
|
-
import { icons as
|
|
3
|
-
import { isNotEmpty as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { mergeModels as R, useModel as E, onMounted as oe, ref as U, watch as ne, createBlock as c, openBlock as i, unref as e, isRef as z, createSlots as re, withCtx as r, createElementBlock as L, createCommentVNode as g, createVNode as a, Fragment as ie, renderList as ae, createElementVNode as se, createTextVNode as b, toDisplayString as V, normalizeClass as ue } from "vue";
|
|
2
|
+
import { icons as p } from "../../../../icons/index.js";
|
|
3
|
+
import { isNotEmpty as de, isArray as B } from "../utils/helpers.js";
|
|
4
|
+
import ce from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
|
|
5
|
+
import me from "../../../KunList/src/components/KunList.vue.js";
|
|
6
6
|
import F from "../../../KunListItem/src/components/KunListItem.vue.js";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { useAutocomplete as
|
|
7
|
+
import fe from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
|
|
8
|
+
import pe from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
|
|
9
|
+
import ye from "../../../kunMenu/src/components/kunMenu.vue.js";
|
|
10
|
+
import { useAutocomplete as ve } from "../composables/useAutocomplete.js";
|
|
11
11
|
import { KunAutocompleteProps as ke } from "../composables/KunAutocompleteProps.js";
|
|
12
|
-
import
|
|
12
|
+
import ge from "../../../KunTextField/src/components/KunTextField.vue.js";
|
|
13
13
|
import he from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
14
|
-
import
|
|
14
|
+
import Ce from "../../../KunChip/src/components/KunChip.vue.js";
|
|
15
15
|
import h from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
16
16
|
const be = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "flex justify-center align-center"
|
|
19
|
-
},
|
|
19
|
+
}, Ve = { class: "flex justify-center align-center" }, Be = {
|
|
20
20
|
__name: "KunAutocomplete",
|
|
21
|
-
props: /* @__PURE__ */
|
|
21
|
+
props: /* @__PURE__ */ R(ke, {
|
|
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
|
|
30
|
-
selectedItem:
|
|
31
|
-
textFieldRef:
|
|
32
|
-
listRef:
|
|
33
|
-
menuModel:
|
|
34
|
-
search:
|
|
35
|
-
removeItem:
|
|
36
|
-
clearSelection:
|
|
37
|
-
lightReset:
|
|
38
|
-
openMenu:
|
|
27
|
+
emits: /* @__PURE__ */ R(["createItem", "validation", "search"], ["update:modelValue", "update:items"]),
|
|
28
|
+
setup(C, { emit: N }) {
|
|
29
|
+
const s = E(C, "modelValue"), $ = E(C, "items"), n = C, y = N, {
|
|
30
|
+
selectedItem: m,
|
|
31
|
+
textFieldRef: u,
|
|
32
|
+
listRef: v,
|
|
33
|
+
menuModel: d,
|
|
34
|
+
search: f,
|
|
35
|
+
removeItem: T,
|
|
36
|
+
clearSelection: H,
|
|
37
|
+
lightReset: S,
|
|
38
|
+
openMenu: O,
|
|
39
39
|
onMenuKeydown: w,
|
|
40
|
-
getSelectedItem:
|
|
41
|
-
textArr:
|
|
42
|
-
getItemText:
|
|
43
|
-
createItem:
|
|
44
|
-
checkDisabled:
|
|
40
|
+
getSelectedItem: P,
|
|
41
|
+
textArr: j,
|
|
42
|
+
getItemText: q,
|
|
43
|
+
createItem: W,
|
|
44
|
+
checkDisabled: G,
|
|
45
45
|
itemToString: x,
|
|
46
|
-
placeholder:
|
|
46
|
+
placeholder: I,
|
|
47
47
|
hasCreateItem: J
|
|
48
|
-
} =
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
} = ve(n, y, s, $);
|
|
49
|
+
oe(() => {
|
|
50
|
+
Y(), n.focusOnRender && u.value.focus();
|
|
51
51
|
});
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
function Q(t) {
|
|
53
|
+
return s.value === null || s.value === void 0 ? n.bgItemListColor : n.multiple ? s.value.find((o) => o[n.itemValue] === t[n.itemValue]) ? n.selectedColor : n.bgItemListColor : I.value === t[n.itemTitle] ? n.selectedColor : n.bgItemListColor;
|
|
54
|
+
}
|
|
55
|
+
const k = U(""), _ = (t) => {
|
|
56
|
+
for (const o of n.rules) {
|
|
54
57
|
const l = o(t);
|
|
55
58
|
if (l !== !0)
|
|
56
|
-
return k.value = l,
|
|
59
|
+
return k.value = l, y("validation", !1), !1;
|
|
57
60
|
}
|
|
58
|
-
return k.value = "",
|
|
61
|
+
return k.value = "", y("validation", !0), !0;
|
|
59
62
|
};
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
ne(() => s.value, (t, o) => {
|
|
64
|
+
de(n.rules) && _(t);
|
|
62
65
|
});
|
|
63
66
|
function K() {
|
|
64
|
-
|
|
67
|
+
d.value = !1, u.value.$el.focus();
|
|
65
68
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
69
|
+
function X(t) {
|
|
70
|
+
y("search", f);
|
|
68
71
|
}
|
|
69
|
-
const
|
|
70
|
-
function
|
|
71
|
-
if (
|
|
72
|
-
const t =
|
|
73
|
-
|
|
72
|
+
const M = U({});
|
|
73
|
+
function Y() {
|
|
74
|
+
if (u.value) {
|
|
75
|
+
const t = u.value.$el.getBoundingClientRect();
|
|
76
|
+
M.value = {
|
|
74
77
|
position: "absolute",
|
|
75
78
|
top: `${t.bottom}px`,
|
|
76
79
|
// Posiciona el menú justo debajo
|
|
@@ -81,133 +84,133 @@ const be = {
|
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
|
-
function
|
|
85
|
-
_(
|
|
87
|
+
function Z() {
|
|
88
|
+
_(s), d.value = !0;
|
|
86
89
|
}
|
|
87
|
-
function
|
|
90
|
+
function ee(t) {
|
|
88
91
|
const o = t.key;
|
|
89
92
|
if (o === "Escape") {
|
|
90
93
|
K();
|
|
91
94
|
return;
|
|
92
95
|
}
|
|
93
96
|
if (["ArrowDown", "ArrowUp"].includes(o)) {
|
|
94
|
-
if (!
|
|
95
|
-
|
|
97
|
+
if (!v.value) return;
|
|
98
|
+
v.value.focusWithKey(o);
|
|
96
99
|
return;
|
|
97
100
|
}
|
|
98
101
|
w(t);
|
|
99
102
|
}
|
|
100
|
-
function
|
|
103
|
+
function te(t) {
|
|
101
104
|
w(t);
|
|
102
105
|
}
|
|
103
|
-
return (t, o) => (
|
|
104
|
-
modelValue: e(
|
|
106
|
+
return (t, o) => (i(), c(ge, {
|
|
107
|
+
modelValue: e(f),
|
|
105
108
|
"onUpdate:modelValue": [
|
|
106
|
-
o[3] || (o[3] = (l) =>
|
|
107
|
-
|
|
109
|
+
o[3] || (o[3] = (l) => z(f) ? f.value = l : null),
|
|
110
|
+
X
|
|
108
111
|
],
|
|
109
112
|
label: t.label,
|
|
110
113
|
dirty: "",
|
|
111
114
|
"hide-details": t.hideDetails,
|
|
112
115
|
density: t.density,
|
|
113
116
|
ref_key: "textFieldRef",
|
|
114
|
-
ref:
|
|
117
|
+
ref: u,
|
|
115
118
|
autocomplete: "off",
|
|
116
|
-
onKeyDown:
|
|
117
|
-
onFocusInput:
|
|
118
|
-
onHandleClick: e(
|
|
119
|
-
placeholder: e(B)(e(
|
|
119
|
+
onKeyDown: ee,
|
|
120
|
+
onFocusInput: Z,
|
|
121
|
+
onHandleClick: e(O),
|
|
122
|
+
placeholder: e(B)(e(m)) && e(m).length ? "" : e(I),
|
|
120
123
|
error: !!k.value,
|
|
121
124
|
"error-messages": k.value
|
|
122
|
-
},
|
|
123
|
-
default:
|
|
124
|
-
e(B)(e(
|
|
125
|
-
(
|
|
125
|
+
}, re({
|
|
126
|
+
default: r(() => [
|
|
127
|
+
e(B)(e(m)) ? (i(), L("div", be, [
|
|
128
|
+
(i(!0), L(ie, null, ae(e(m), (l) => (i(), c(Ce, {
|
|
126
129
|
key: l.id ?? l.name,
|
|
127
130
|
size: "small",
|
|
128
131
|
class: "ml-1"
|
|
129
132
|
}, {
|
|
130
|
-
default:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
default: r(() => [
|
|
134
|
+
se("div", Ve, [
|
|
135
|
+
b(V(e(q)(l, t.itemTitle)) + " ", 1),
|
|
136
|
+
a(h, {
|
|
134
137
|
color: "error",
|
|
135
|
-
icon: e(
|
|
138
|
+
icon: e(p).close,
|
|
136
139
|
size: "small",
|
|
137
140
|
class: "ml-1",
|
|
138
|
-
onClick: (
|
|
141
|
+
onClick: (le) => e(T)(l)
|
|
139
142
|
}, null, 8, ["icon", "onClick"])
|
|
140
143
|
])
|
|
141
144
|
]),
|
|
142
145
|
_: 2
|
|
143
146
|
}, 1024))), 128))
|
|
144
|
-
])) :
|
|
145
|
-
|
|
147
|
+
])) : g("", !0),
|
|
148
|
+
a(ye, {
|
|
146
149
|
transition: "fade",
|
|
147
|
-
"onClick:outside": o[1] || (o[1] = (l) => e(
|
|
148
|
-
modelValue: e(
|
|
149
|
-
"onUpdate:modelValue": o[2] || (o[2] = (l) =>
|
|
150
|
+
"onClick:outside": o[1] || (o[1] = (l) => e(S)()),
|
|
151
|
+
modelValue: e(d),
|
|
152
|
+
"onUpdate:modelValue": o[2] || (o[2] = (l) => z(d) ? d.value = l : null),
|
|
150
153
|
activator: "parent",
|
|
151
|
-
"text-field-ref": e(
|
|
154
|
+
"text-field-ref": e(u),
|
|
152
155
|
onHandleEscape: K,
|
|
153
156
|
"close-on-content-click": t.closeOnSelect,
|
|
154
157
|
"max-height": t.maxHeight,
|
|
155
|
-
menuPositionStyle:
|
|
158
|
+
menuPositionStyle: M.value
|
|
156
159
|
}, {
|
|
157
|
-
default:
|
|
158
|
-
|
|
159
|
-
"onUpdate:selected": e(
|
|
160
|
-
"onClick:select": o[0] || (o[0] = (l) => e(
|
|
160
|
+
default: r(() => [
|
|
161
|
+
a(me, {
|
|
162
|
+
"onUpdate:selected": e(P),
|
|
163
|
+
"onClick:select": o[0] || (o[0] = (l) => e(S)()),
|
|
161
164
|
ref_key: "listRef",
|
|
162
|
-
ref:
|
|
163
|
-
onKeyDown:
|
|
165
|
+
ref: v,
|
|
166
|
+
onKeyDown: te
|
|
164
167
|
}, {
|
|
165
|
-
default:
|
|
166
|
-
e(J) ? (
|
|
167
|
-
default:
|
|
168
|
-
|
|
169
|
-
onClick: e(
|
|
168
|
+
default: r(() => [
|
|
169
|
+
e(J) ? (i(), c(F, { key: 0 }, {
|
|
170
|
+
default: r(() => [
|
|
171
|
+
a(he, {
|
|
172
|
+
onClick: e(W),
|
|
170
173
|
class: "w-full",
|
|
171
174
|
color: "bg-green-400"
|
|
172
175
|
}, {
|
|
173
|
-
default:
|
|
174
|
-
|
|
176
|
+
default: r(() => o[4] || (o[4] = [
|
|
177
|
+
b(" Crear item ")
|
|
175
178
|
])),
|
|
176
179
|
_: 1,
|
|
177
180
|
__: [4]
|
|
178
181
|
}, 8, ["onClick"])
|
|
179
182
|
]),
|
|
180
183
|
_: 1
|
|
181
|
-
})) :
|
|
182
|
-
|
|
183
|
-
items:
|
|
184
|
-
search: e(
|
|
185
|
-
"searchable-keys":
|
|
184
|
+
})) : g("", !0),
|
|
185
|
+
a(ce, {
|
|
186
|
+
items: $.value,
|
|
187
|
+
search: e(f),
|
|
188
|
+
"searchable-keys": n.searchableKeys,
|
|
186
189
|
"items-per-intersection": 10,
|
|
187
|
-
enabled: e(
|
|
190
|
+
enabled: e(d),
|
|
188
191
|
virtual: !1,
|
|
189
192
|
"item-height": 48
|
|
190
193
|
}, {
|
|
191
|
-
default:
|
|
192
|
-
var
|
|
194
|
+
default: r(({ item: l, index: le }) => {
|
|
195
|
+
var D, A;
|
|
193
196
|
return [
|
|
194
|
-
(
|
|
197
|
+
(i(), c(F, {
|
|
195
198
|
value: l,
|
|
196
|
-
key: ((
|
|
197
|
-
disabled: e(
|
|
198
|
-
class:
|
|
199
|
+
key: ((D = l.id) == null ? void 0 : D.toString()) ?? l.name,
|
|
200
|
+
disabled: e(G)(l),
|
|
201
|
+
class: ue(Q(l)),
|
|
199
202
|
density: t.density,
|
|
200
|
-
id: ((
|
|
203
|
+
id: ((A = l.id) == null ? void 0 : A.toString()) ?? l.name
|
|
201
204
|
}, {
|
|
202
|
-
default:
|
|
203
|
-
|
|
204
|
-
default:
|
|
205
|
-
|
|
205
|
+
default: r(() => [
|
|
206
|
+
a(fe, { class: "text-wrap" }, {
|
|
207
|
+
default: r(() => [
|
|
208
|
+
b(V(e(x)(l, e(j), "hasDefault")), 1)
|
|
206
209
|
]),
|
|
207
210
|
_: 2
|
|
208
211
|
}, 1024),
|
|
209
|
-
|
|
210
|
-
textContent:
|
|
212
|
+
a(pe, {
|
|
213
|
+
textContent: V(t.itemSubtitle ? e(x)(l, t.itemSubtitle) : "")
|
|
211
214
|
}, null, 8, ["textContent"])
|
|
212
215
|
]),
|
|
213
216
|
_: 2
|
|
@@ -227,28 +230,28 @@ const be = {
|
|
|
227
230
|
}, [
|
|
228
231
|
t.hasIcons ? {
|
|
229
232
|
name: "append-inner",
|
|
230
|
-
fn:
|
|
231
|
-
t.clearable && e(
|
|
233
|
+
fn: r(() => [
|
|
234
|
+
t.clearable && e(m) ? (i(), c(h, {
|
|
232
235
|
key: 0,
|
|
233
|
-
onClick: e(
|
|
236
|
+
onClick: e(H),
|
|
234
237
|
size: "small",
|
|
235
238
|
color: "error",
|
|
236
|
-
icon: e(
|
|
239
|
+
icon: e(p).close,
|
|
237
240
|
class: "mr-1 mt-1"
|
|
238
|
-
}, null, 8, ["onClick", "icon"])) :
|
|
239
|
-
|
|
241
|
+
}, null, 8, ["onClick", "icon"])) : g("", !0),
|
|
242
|
+
a(h, {
|
|
240
243
|
color: "teal-darken-1",
|
|
241
244
|
size: "large",
|
|
242
245
|
class: "cursor-pointer",
|
|
243
|
-
icon: e(
|
|
246
|
+
icon: e(v) ? e(p).menuUpOutline : e(p).menuDownOutline
|
|
244
247
|
}, null, 8, ["icon"]),
|
|
245
|
-
t.required ? (
|
|
248
|
+
t.required ? (i(), c(h, {
|
|
246
249
|
key: 1,
|
|
247
250
|
color: "teal-darken-1",
|
|
248
251
|
size: "x-small",
|
|
249
252
|
class: "mb-4",
|
|
250
|
-
icon: e(
|
|
251
|
-
}, null, 8, ["icon"])) :
|
|
253
|
+
icon: e(p).asterisk
|
|
254
|
+
}, null, 8, ["icon"])) : g("", !0)
|
|
252
255
|
]),
|
|
253
256
|
key: "0"
|
|
254
257
|
} : void 0
|