@wikicasa-dev/components 2.2.9-alpha.46 → 2.2.9-alpha.49
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,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent as j, mergeModels as U, useModel as S, useId as q, useTemplateRef as d, shallowRef as c, onBeforeMount as G, onMounted as J, onUnmounted as Q, watch as E, nextTick as Y, createBlock as z, openBlock as M, withCtx as W, createElementBlock as Z, Fragment as _, renderList as ee, renderSlot as m, createElementVNode as s, normalizeClass as f, withDirectives as I, unref as te, vModelText as le, toDisplayString as ne, withModifiers as oe, normalizeStyle as ae, createTextVNode as ie, vShow as ue } from "vue";
|
|
2
|
+
import se from "../BaseDropDown.vue.js";
|
|
3
3
|
import '../../../../../assets/BaseDropDown.css';/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import { debounce as
|
|
6
|
-
const
|
|
4
|
+
import re from "../BaseSelect/SelectItem.vue.js";
|
|
5
|
+
import { debounce as de } from "@wikicasa-dev/utilities";
|
|
6
|
+
const ce = ["id", "data-cy", "placeholder"], fe = ["innerHTML"], ye = /* @__PURE__ */ j({
|
|
7
7
|
__name: "ClearableAutocomplete",
|
|
8
|
-
props: /* @__PURE__ */
|
|
8
|
+
props: /* @__PURE__ */ U({
|
|
9
9
|
dataCy: {},
|
|
10
10
|
placeholder: {},
|
|
11
11
|
enableKeyboardController: { type: Boolean, default: !0 },
|
|
@@ -29,55 +29,60 @@ const ue = ["id", "data-cy", "placeholder"], se = ["innerHTML"], ke = /* @__PURE
|
|
|
29
29
|
},
|
|
30
30
|
inputValueModifiers: {}
|
|
31
31
|
}),
|
|
32
|
-
emits: /* @__PURE__ */
|
|
33
|
-
setup(t, { expose:
|
|
34
|
-
const r =
|
|
32
|
+
emits: /* @__PURE__ */ U(["input", "click", "inputClick", "keydown"], ["update:open", "update:modelValue", "update:inputValue"]),
|
|
33
|
+
setup(t, { expose: L, emit: D }) {
|
|
34
|
+
const r = S(t, "open"), u = S(t, "modelValue"), o = S(t, "inputValue");
|
|
35
35
|
o.value = o.value ?? u.value?.label ?? "";
|
|
36
|
-
const p =
|
|
36
|
+
const p = D, K = q(), C = d("inputRef"), v = c(0), y = c(!1), k = c(!!u.value?.label), x = c(null), a = c([]), O = d("dropdownRef"), h = d("hiddenSpan"), w = d("inputWrapperRef"), R = d("clearButtonRef"), N = () => {
|
|
37
37
|
o.value = "", u.value = null, k.value = !1;
|
|
38
|
-
},
|
|
38
|
+
}, A = async (l) => {
|
|
39
39
|
if (!l) {
|
|
40
40
|
a.value = [], r.value = !1;
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
t.disableCb || (a.value = await x.value?.(l) || [], y.value = !0, r.value = !!a.value.length);
|
|
44
|
-
},
|
|
44
|
+
}, F = (l = -1) => {
|
|
45
45
|
const e = a.value[l];
|
|
46
46
|
!e || e.id === u.value?.id || (t.onOptionSelectedCb?.(e), o.value = e.label, r.value = !1, u.value = e, k.value = !0, a.value = []);
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
|
|
47
|
+
}, P = () => {
|
|
48
|
+
C.value?.select();
|
|
49
|
+
}, H = () => {
|
|
50
|
+
C.value?.focus();
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
let B = null;
|
|
53
|
+
const $ = () => {
|
|
54
|
+
const l = h.value, e = w.value, n = R.value;
|
|
55
|
+
if (!l || !e) return;
|
|
56
|
+
const T = l.offsetWidth, b = e.offsetWidth, i = t.clearButton?.offset || 0, g = t.clearButton?.width || n?.offsetWidth || 0, X = b - i - g, V = Math.min(T, X);
|
|
57
|
+
V !== v.value && (v.value = V);
|
|
58
|
+
};
|
|
59
|
+
return G(() => {
|
|
60
|
+
x.value = de({ delay: 300 }, t.onInputChangeCb);
|
|
61
|
+
}), J(() => {
|
|
62
|
+
w.value && (B = new ResizeObserver(() => {
|
|
63
|
+
$();
|
|
64
|
+
}), B.observe(w.value));
|
|
65
|
+
}), Q(() => {
|
|
66
|
+
B?.disconnect();
|
|
67
|
+
}), E([o, h, R], () => {
|
|
68
|
+
Y($);
|
|
69
|
+
}), E(
|
|
70
|
+
() => O.value?.selectedIdx,
|
|
66
71
|
(l) => {
|
|
67
72
|
const e = l ?? -1;
|
|
68
|
-
e !== -1 &&
|
|
73
|
+
e !== -1 && F(e);
|
|
69
74
|
}
|
|
70
|
-
),
|
|
75
|
+
), E(
|
|
71
76
|
u,
|
|
72
77
|
(l, e) => {
|
|
73
78
|
l === e || l?.label === o.value || (o.value = l?.label || "");
|
|
74
79
|
},
|
|
75
80
|
{ immediate: !0 }
|
|
76
|
-
),
|
|
77
|
-
getRootElement: () =>
|
|
78
|
-
select:
|
|
79
|
-
focus:
|
|
80
|
-
}), (l, e) => (
|
|
81
|
+
), L({
|
|
82
|
+
getRootElement: () => O.value?.getRootElement(),
|
|
83
|
+
select: P,
|
|
84
|
+
focus: H
|
|
85
|
+
}), (l, e) => (M(), z(se, {
|
|
81
86
|
ref: "dropdownRef",
|
|
82
87
|
class: "uikit-clearable-autocomplete",
|
|
83
88
|
"data-cy": t.dataCy,
|
|
@@ -90,23 +95,23 @@ const ue = ["id", "data-cy", "placeholder"], se = ["innerHTML"], ke = /* @__PURE
|
|
|
90
95
|
open: r.value,
|
|
91
96
|
"onUpdate:open": e[6] || (e[6] = (n) => r.value = n)
|
|
92
97
|
}, {
|
|
93
|
-
btn_slot:
|
|
98
|
+
btn_slot: W(() => [
|
|
94
99
|
s("div", {
|
|
95
100
|
class: f(["uikit-text-16", t.triggerWrapperClasses]),
|
|
96
101
|
onClick: e[4] || (e[4] = (n) => p("click", n))
|
|
97
102
|
}, [
|
|
98
|
-
|
|
103
|
+
m(l.$slots, "left-icon"),
|
|
99
104
|
s("div", {
|
|
100
105
|
ref: "inputWrapperRef",
|
|
101
106
|
class: f(["uikit-relative", t.inputWrapperClasses])
|
|
102
107
|
}, [
|
|
103
|
-
|
|
108
|
+
I(s("input", {
|
|
104
109
|
ref: "inputRef",
|
|
105
110
|
"onUpdate:modelValue": [
|
|
106
111
|
e[0] || (e[0] = (n) => o.value = n),
|
|
107
|
-
|
|
112
|
+
A
|
|
108
113
|
],
|
|
109
|
-
id:
|
|
114
|
+
id: te(K),
|
|
110
115
|
"data-cy": t.dataCy ? `ac_input_${t.dataCy}` : "",
|
|
111
116
|
type: "text",
|
|
112
117
|
autocomplete: "off",
|
|
@@ -121,58 +126,58 @@ const ue = ["id", "data-cy", "placeholder"], se = ["innerHTML"], ke = /* @__PURE
|
|
|
121
126
|
p("input", n), k.value = !1;
|
|
122
127
|
}),
|
|
123
128
|
onClick: e[3] || (e[3] = (n) => {
|
|
124
|
-
p("inputClick", n),
|
|
129
|
+
p("inputClick", n), C.value?.select();
|
|
125
130
|
})
|
|
126
|
-
}, null, 42,
|
|
127
|
-
[
|
|
131
|
+
}, null, 42, ce), [
|
|
132
|
+
[le, o.value]
|
|
128
133
|
]),
|
|
129
134
|
s("span", {
|
|
130
135
|
ref_key: "hiddenSpan",
|
|
131
|
-
ref:
|
|
136
|
+
ref: h,
|
|
132
137
|
class: f(["uikit-invisible uikit-absolute uikit-left-0 uikit-top-0 uikit-whitespace-pre", t.hiddenTextClasses]),
|
|
133
138
|
style: {
|
|
134
139
|
font: "inherit",
|
|
135
140
|
fontSize: "inherit"
|
|
136
141
|
}
|
|
137
|
-
},
|
|
138
|
-
|
|
142
|
+
}, ne(o.value), 3),
|
|
143
|
+
I(s("button", {
|
|
139
144
|
ref: "clearButtonRef",
|
|
140
145
|
type: "button",
|
|
141
146
|
class: f(["uikit-clear-btn uikit-absolute uikit-top-1/2 -uikit-translate-y-1/2 uikit-appearance-none", t.clearButton?.classes]),
|
|
142
147
|
"aria-label": "Clear input",
|
|
143
|
-
style:
|
|
148
|
+
style: ae({
|
|
144
149
|
left: `${v.value + (t.clearButton?.offset || 0)}px`,
|
|
145
150
|
width: t.clearButton?.width ? `${t.clearButton.width}px` : "auto",
|
|
146
151
|
height: t.clearButton?.height ? `${t.clearButton.height}px` : "auto"
|
|
147
152
|
}),
|
|
148
|
-
onClick:
|
|
153
|
+
onClick: oe(N, ["stop"])
|
|
149
154
|
}, [
|
|
150
|
-
|
|
151
|
-
e[7] || (e[7] =
|
|
155
|
+
m(l.$slots, "clear-icon", {}, () => [
|
|
156
|
+
e[7] || (e[7] = ie("X", -1))
|
|
152
157
|
])
|
|
153
158
|
], 6), [
|
|
154
|
-
[
|
|
159
|
+
[ue, k.value && v.value]
|
|
155
160
|
])
|
|
156
161
|
], 2),
|
|
157
|
-
|
|
162
|
+
m(l.$slots, "right-icon")
|
|
158
163
|
], 2)
|
|
159
164
|
]),
|
|
160
|
-
default:
|
|
161
|
-
(
|
|
165
|
+
default: W(({ activeIdx: n, setActiveIdx: T }) => [
|
|
166
|
+
(M(!0), Z(_, null, ee(a.value, (b, i) => (M(), z(re, {
|
|
162
167
|
key: i,
|
|
163
168
|
active: n === i,
|
|
164
169
|
class: "uikit-m-1 uikit-rounded-[5px] uikit-px-5 uikit-py-10px hover:uikit-cursor-pointer",
|
|
165
|
-
onClick: (
|
|
166
|
-
onMouseover: (
|
|
170
|
+
onClick: (g) => F(i),
|
|
171
|
+
onMouseover: (g) => T(i)
|
|
167
172
|
}, {
|
|
168
|
-
default:
|
|
169
|
-
|
|
170
|
-
option:
|
|
173
|
+
default: W(() => [
|
|
174
|
+
m(l.$slots, "option-content", {
|
|
175
|
+
option: b,
|
|
171
176
|
idx: i
|
|
172
177
|
}, () => [
|
|
173
178
|
s("span", {
|
|
174
|
-
innerHTML:
|
|
175
|
-
}, null, 8,
|
|
179
|
+
innerHTML: b.label
|
|
180
|
+
}, null, 8, fe)
|
|
176
181
|
])
|
|
177
182
|
]),
|
|
178
183
|
_: 2
|
|
@@ -183,5 +188,5 @@ const ue = ["id", "data-cy", "placeholder"], se = ["innerHTML"], ke = /* @__PURE
|
|
|
183
188
|
}
|
|
184
189
|
});
|
|
185
190
|
export {
|
|
186
|
-
|
|
191
|
+
ye as default
|
|
187
192
|
};
|