@wikicasa-dev/components 2.2.9-alpha.28 → 2.2.9-alpha.3
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/Swiper/autoplay.js +1 -1
- package/dist/Swiper/controller.js +1 -1
- package/dist/Swiper/keyboard.js +1 -1
- package/dist/Swiper/thumbs.js +1 -1
- package/dist/UIKit/AccessibleSelect.d.ts +3 -5
- package/dist/UIKit/AccessibleSelect.js +2 -3
- package/dist/UIKit/Autocomplete/ClearableAutocomplete.d.ts +4 -10
- package/dist/UIKit/BaseButton.d.ts +2 -6
- package/dist/UIKit/BaseDropDown.d.ts +2 -16
- package/dist/assets/BaseDropDown.css +1 -1
- package/dist/assets/tailwind.css +1 -1
- package/dist/index.js +83 -84
- package/dist/packages/components/lib/UIKit/AccessibleSelect.vue.js +153 -146
- package/dist/packages/components/lib/UIKit/Autocomplete/ClearableAutocomplete.vue.js +99 -115
- package/dist/packages/components/lib/UIKit/BaseButton.vue.js +23 -26
- package/dist/packages/components/lib/UIKit/BaseDropDown.vue.js +94 -104
- package/dist/packages/components/lib/UIKit/BaseModal.vue.js +38 -44
- package/dist/packages/components/lib/UIKit/BaseSelect/SelectItem.vue.js +17 -18
- package/dist/packages/components/lib/UIKit/Checkbox/CheckboxBtn.vue.js +26 -24
- package/dist/packages/components/lib/UIKit/Checkbox/CheckboxGroup.vue.js +14 -14
- package/package.json +5 -5
- package/dist/assets/AccessibleSelect.css +0 -1
- /package/dist/assets/{swiper-autoplay.css → swiper-thumbs.css} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import q from "
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { defineComponent as H, mergeModels as $, useModel as p, useId as I, computed as M, ref as D, watch as h, onMounted as F, onUnmounted as P, createElementBlock as u, openBlock as n, normalizeClass as a, createElementVNode as o, createCommentVNode as r, withModifiers as c, renderSlot as z, unref as b, createBlock as A, createVNode as E, Fragment as V, renderList as N } from "vue";
|
|
2
|
+
import { useKeyboardController as O } from "@wikicasa-dev/vue-composables";
|
|
3
|
+
import { WarningIconRounded as S, ArrowIcon as q } from "@wikicasa-dev/svg-icons";
|
|
4
|
+
const j = ["id", "innerHTML"], K = ["id", "data-cy", "aria-required", "aria-controls", "aria-labelledby", "aria-expanded", "aria-activedescendant", "aria-invalid", "aria-describedby"], R = ["innerHTML"], U = { class: "uikit-pointer-events-none uikit-mt-1 uikit-inline-flex" }, W = ["innerHTML"], G = ["data-cy"], J = ["id", "aria-selected", "onClick", "onMouseover"], Q = { class: "uikit-inline-block uikit-cursor-pointer uikit-text-sm" }, X = ["name", "checked", "onInput"], Y = ["innerHTML"], Z = ["id", "arial-live", "innerHTML"], _ = ["id", "arial-live", "innerHTML"], le = /* @__PURE__ */ H({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
6
|
__name: "AccessibleSelect",
|
|
7
|
-
props: /* @__PURE__ */
|
|
7
|
+
props: /* @__PURE__ */ $({
|
|
8
8
|
label: { default: "" },
|
|
9
9
|
dropdownPosition: { default: "bottom" },
|
|
10
10
|
namespace: {},
|
|
@@ -28,174 +28,181 @@ const S = { class: "uikit-relative uikit-flex uikit-h-12 uikit-items-center" },
|
|
|
28
28
|
default: () => ({ id: "", label: "" })
|
|
29
29
|
},
|
|
30
30
|
modelModifiers: {},
|
|
31
|
-
open: { type: Boolean, default: !1 },
|
|
32
|
-
openModifiers: {},
|
|
33
31
|
toggleDropdown: { type: Boolean, default: void 0 },
|
|
34
32
|
toggleDropdownModifiers: {}
|
|
35
33
|
}),
|
|
36
|
-
emits: /* @__PURE__ */
|
|
37
|
-
setup(e, { emit:
|
|
38
|
-
const
|
|
39
|
-
|
|
34
|
+
emits: /* @__PURE__ */ $(["click", "update:dropdownState"], ["update:modelValue", "update:toggleDropdown"]),
|
|
35
|
+
setup(e, { emit: L }) {
|
|
36
|
+
const y = L, k = p(e, "modelValue"), g = p(e, "toggleDropdown"), T = I(), l = M(() => e.namespace || T), t = D(!1), m = M(() => !!k.value.label), { activeIdx: v, selectedIdx: B } = O({
|
|
37
|
+
optionsLength: e.options.length,
|
|
38
|
+
isDropdownOpen: t
|
|
39
|
+
}), w = (i) => {
|
|
40
|
+
t.value = !1, k.value = i;
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
42
|
+
h(B, (i) => {
|
|
43
|
+
w(e.options[i]), t.value = !1;
|
|
44
|
+
}), h(g, (i) => {
|
|
45
|
+
i && (t.value = !t.value, g.value = !1);
|
|
46
|
+
}), h(t, (i) => {
|
|
47
|
+
y("update:dropdownState", i);
|
|
48
|
+
});
|
|
49
|
+
const C = ({ target: i }) => {
|
|
50
|
+
`${l.value}_btn` !== i.id && (t.value = !1);
|
|
51
|
+
};
|
|
52
|
+
return F(() => {
|
|
53
|
+
e.closeOnBodyPressed && document.addEventListener("click", C);
|
|
54
|
+
}), P(() => {
|
|
55
|
+
e.closeOnBodyPressed && document.removeEventListener("click", C);
|
|
56
|
+
}), (i, s) => (n(), u("div", {
|
|
57
|
+
class: a(i.$attrs.class)
|
|
58
|
+
}, [
|
|
59
|
+
o("div", {
|
|
60
|
+
class: a(["uikit-relative uikit-flex uikit-h-12 uikit-items-center", e.wrapperClasses])
|
|
61
|
+
}, [
|
|
62
|
+
e.label ? (n(), u("label", {
|
|
63
|
+
key: 0,
|
|
64
|
+
id: `${l.value}_label`,
|
|
65
|
+
class: a(["uikit-pointer-events-none uikit-absolute uikit-z-10 uikit-text-sm uikit-font-medium uikit-transition-all uikit-ease-in-out", [
|
|
66
|
+
m.value ? "as-floating -uikit-top-1 uikit-left-[22px] uikit-text-w-black" : "as-inline uikit-top-4 uikit-text-w-gray",
|
|
67
|
+
e.labelClasses,
|
|
68
|
+
{ "uikit-left-9": i.$slots.lefticon && !m.value },
|
|
69
|
+
{ "uikit-left-4": !i.$slots.lefticon && !m.value }
|
|
70
|
+
]]),
|
|
71
|
+
innerHTML: e.label
|
|
72
|
+
}, null, 10, j)) : r("", !0),
|
|
73
|
+
i.$slots.lefticon ? (n(), u("span", {
|
|
74
|
+
key: 1,
|
|
75
|
+
class: "uikit-z-20 uikit-mt-2 uikit-pl-2",
|
|
76
|
+
onClick: s[0] || (s[0] = c((d) => t.value = !t.value, ["stop"]))
|
|
77
|
+
}, [
|
|
78
|
+
z(i.$slots, "lefticon")
|
|
79
|
+
])) : r("", !0),
|
|
80
|
+
o("button", {
|
|
81
|
+
id: `${l.value}_btn`,
|
|
82
|
+
ref: "btnEl",
|
|
83
|
+
type: "button",
|
|
84
|
+
"data-cy": e.dataCy,
|
|
85
|
+
class: a(["uikit-peer uikit-relative uikit-z-10 uikit-flex uikit-h-full uikit-w-full uikit-items-center uikit-justify-between uikit-truncate uikit-border-0 uikit-bg-transparent uikit-pr-4 uikit-text-left focus-visible:uikit-outline-0", [i.$slots.lefticon ? "uikit-pl-2" : "uikit-pl-4", e.btnClasses]]),
|
|
86
|
+
"aria-required": !!i.$attrs.required,
|
|
87
|
+
role: "combobox",
|
|
88
|
+
"aria-haspopup": "listbox",
|
|
89
|
+
"aria-controls": `${l.value}_dropdown`,
|
|
90
|
+
"aria-labelledby": `${l.value}_label ${l.value}_btn`,
|
|
91
|
+
"aria-expanded": t.value,
|
|
92
|
+
"aria-activedescendant": b(v) >= 0 && t.value ? `${l.value}_element_${e.options[b(v)].label}` : "",
|
|
93
|
+
"aria-invalid": e.isValid === !1,
|
|
94
|
+
"aria-describedby": e.isValid === !1 ? `${l.value}_invalid_msg` : void 0,
|
|
95
|
+
onClick: s[1] || (s[1] = (d) => {
|
|
96
|
+
t.value = !t.value, y("click", d);
|
|
97
|
+
})
|
|
98
|
+
}, [
|
|
99
|
+
o("span", {
|
|
100
|
+
class: a(["uikit-pointer-events-none uikit-mt-1", e.btnTextClasses]),
|
|
101
|
+
innerHTML: k.value.visibleLabel || k.value.label
|
|
102
|
+
}, null, 10, R),
|
|
103
|
+
o("span", U, [
|
|
104
|
+
e.isValid == !1 ? (n(), A(b(S), {
|
|
70
105
|
key: 0,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
106
|
+
class: "uikit-mr-1",
|
|
107
|
+
width: 20,
|
|
108
|
+
height: 20,
|
|
109
|
+
"stroke-color": "#FA4F64"
|
|
110
|
+
})) : r("", !0),
|
|
111
|
+
E(b(q), {
|
|
112
|
+
class: a(["uikit-transition-transform motion-reduce:uikit-transition-none", [
|
|
113
|
+
t.value ? "uikit-rotate-180" : "",
|
|
114
|
+
e.arrowIcon?.classes
|
|
77
115
|
]]),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class: "uikit-z-20 uikit-mt-2 uikit-pl-2",
|
|
83
|
-
onClick: f((d) => s(), ["stop"])
|
|
84
|
-
}, [
|
|
85
|
-
A(i.$slots, "lefticon")
|
|
86
|
-
], 8, j)) : r("", !0),
|
|
87
|
-
n("button", {
|
|
88
|
-
id: `${t.value}_btn`,
|
|
89
|
-
ref: "btnEl",
|
|
90
|
-
type: "button",
|
|
91
|
-
"data-cy": e.dataCy,
|
|
92
|
-
class: o(["uikit-peer uikit-relative uikit-z-10 uikit-flex uikit-h-full uikit-w-full uikit-items-center uikit-justify-between uikit-truncate uikit-border-0 uikit-bg-transparent uikit-pr-4 uikit-text-left focus-visible:uikit-outline-0", [i.$slots.lefticon ? "uikit-pl-2" : "uikit-pl-4", e.btnClasses]]),
|
|
93
|
-
"aria-required": !!i.$attrs.required,
|
|
94
|
-
role: "combobox",
|
|
95
|
-
"aria-haspopup": "listbox",
|
|
96
|
-
"aria-controls": `${t.value}_dropdown`,
|
|
97
|
-
"aria-labelledby": `${t.value}_label ${t.value}_btn`,
|
|
98
|
-
"aria-expanded": b,
|
|
99
|
-
"aria-activedescendant": u >= 0 && b ? `${t.value}_element_${e.options[u].label}` : "",
|
|
100
|
-
"aria-invalid": e.isValid === !1,
|
|
101
|
-
"aria-describedby": e.isValid === !1 ? `${t.value}_invalid_msg` : void 0,
|
|
102
|
-
onClick: (d) => {
|
|
103
|
-
s(), L("click", d);
|
|
104
|
-
}
|
|
105
|
-
}, [
|
|
106
|
-
n("span", {
|
|
107
|
-
class: o(["uikit-pointer-events-none uikit-mt-1", e.btnTextClasses]),
|
|
108
|
-
innerHTML: k.value?.visibleLabel || k.value?.label
|
|
109
|
-
}, null, 10, W),
|
|
110
|
-
n("span", J, [
|
|
111
|
-
e.isValid == !1 ? (l(), E(V(P), {
|
|
112
|
-
key: 0,
|
|
113
|
-
class: "uikit-mr-1",
|
|
114
|
-
width: 20,
|
|
115
|
-
height: 20,
|
|
116
|
-
"stroke-color": "#FA4F64"
|
|
117
|
-
})) : r("", !0),
|
|
118
|
-
$(V(R), {
|
|
119
|
-
class: o(["uikit-transition-transform motion-reduce:uikit-transition-none", [b ? "uikit-rotate-180" : "", e.arrowIcon?.classes]]),
|
|
120
|
-
width: e.arrowIcon?.width ?? 18,
|
|
121
|
-
height: e.arrowIcon?.height ?? 18,
|
|
122
|
-
"stroke-color": e.isValid ? "#2B5DFF" : e.isValid === !1 ? "#FA4F64" : e.arrowIcon?.strokeColor ?? "#222"
|
|
123
|
-
}, null, 8, ["class", "width", "height", "stroke-color"])
|
|
124
|
-
])
|
|
125
|
-
], 10, G),
|
|
126
|
-
n("fieldset", {
|
|
127
|
-
"aria-hidden": "true",
|
|
128
|
-
class: o(["uikit-pointer-events-none uikit-absolute uikit-bottom-0 uikit-left-0 uikit-right-0 uikit-m-0 uikit-box-border uikit-h-12 uikit-cursor-pointer uikit-rounded-xs uikit-bg-white uikit-px-2 uikit-py-0 peer-focus:uikit-border-2", [
|
|
129
|
-
e.fieldsetClasses,
|
|
130
|
-
e.isValid ? "uikit-border-w-primary" : e.isValid === !1 ? "uikit-border-w-danger" : "uikit-border-w-secondary",
|
|
131
|
-
{
|
|
132
|
-
"uikit-border uikit-border-solid peer-focus:uikit-border-w-primary peer-focus-visible:uikit-border-2 peer-focus-visible:uikit-border-w-primary peer-aria-invalid:uikit-border-w-danger": e.border
|
|
133
|
-
},
|
|
134
|
-
{ "uikit-border-0 peer-focus:uikit-border-0": !e.border }
|
|
135
|
-
]])
|
|
136
|
-
}, [
|
|
137
|
-
n("legend", {
|
|
138
|
-
class: o([[e.legendClasses, { "uikit-m-0 uikit-w-0": !e.label }], "uikit-ml-2 uikit-h-3 uikit-px-0 uikit-text-sm"])
|
|
139
|
-
}, [
|
|
140
|
-
e.label ? (l(), a("span", {
|
|
141
|
-
key: 0,
|
|
142
|
-
class: o(["uikit-mx-5px", [
|
|
143
|
-
k.value.label ? "uikit-invisible" : "uikit-hidden"
|
|
144
|
-
]]),
|
|
145
|
-
innerHTML: e.label
|
|
146
|
-
}, null, 10, K)) : r("", !0)
|
|
147
|
-
], 2)
|
|
148
|
-
], 2)
|
|
116
|
+
width: e.arrowIcon?.width ?? 18,
|
|
117
|
+
height: e.arrowIcon?.height ?? 18,
|
|
118
|
+
"stroke-color": e.isValid ? "#2B5DFF" : e.isValid === !1 ? "#FA4F64" : e.arrowIcon?.strokeColor ?? "#222"
|
|
119
|
+
}, null, 8, ["class", "width", "height", "stroke-color"])
|
|
149
120
|
])
|
|
150
|
-
]),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
121
|
+
], 10, K),
|
|
122
|
+
o("fieldset", {
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
class: a(["uikit-pointer-events-none uikit-absolute uikit-bottom-0 uikit-left-0 uikit-right-0 uikit-m-0 uikit-box-border uikit-h-12 uikit-cursor-pointer uikit-rounded-xs uikit-bg-white uikit-px-2 uikit-py-0 peer-focus:uikit-border-2", [
|
|
125
|
+
e.fieldsetClasses,
|
|
126
|
+
e.isValid ? "uikit-border-w-primary" : e.isValid === !1 ? "uikit-border-w-danger" : "uikit-border-w-secondary",
|
|
127
|
+
{
|
|
128
|
+
"uikit-border uikit-border-solid peer-focus:uikit-border-w-primary peer-focus-visible:uikit-border-2 peer-focus-visible:uikit-border-w-primary peer-aria-invalid:uikit-border-w-danger": e.border
|
|
129
|
+
},
|
|
130
|
+
{ "uikit-border-0 peer-focus:uikit-border-0": !e.border }
|
|
131
|
+
]])
|
|
132
|
+
}, [
|
|
133
|
+
o("legend", {
|
|
134
|
+
class: a([[e.legendClasses, { "uikit-m-0 uikit-w-0": !e.label }], "uikit-ml-2 uikit-h-3 uikit-px-0 uikit-text-sm"])
|
|
135
|
+
}, [
|
|
136
|
+
e.label ? (n(), u("span", {
|
|
137
|
+
key: 0,
|
|
138
|
+
class: a(["uikit-mx-5px", [k.value.label ? "uikit-invisible" : "uikit-hidden"]]),
|
|
139
|
+
innerHTML: e.label
|
|
140
|
+
}, null, 10, W)) : r("", !0)
|
|
141
|
+
], 2)
|
|
142
|
+
], 2),
|
|
143
|
+
o("ul", {
|
|
144
|
+
"data-cy": e.dataCy && `${e.dataCy}_dropdown`,
|
|
145
|
+
role: "listbox",
|
|
146
|
+
tabindex: -1,
|
|
147
|
+
"aria-multiselectable": !1,
|
|
148
|
+
class: a(["uikit-absolute uikit-z-30 uikit-m-0 uikit-max-h-[225px] uikit-w-full uikit-min-w-full uikit-list-none uikit-overflow-y-auto uikit-p-0 uikit-no-scrollbar", [
|
|
149
|
+
{ "uikit-h-0 uikit-w-0 uikit-overflow-hidden": !t.value },
|
|
150
|
+
{
|
|
151
|
+
"uikit-rounded-xs uikit-border uikit-border-solid uikit-border-w-secondary uikit-bg-white": t.value
|
|
152
|
+
},
|
|
153
|
+
{ "uikit-bottom-[55px]": e.dropdownPosition === "top" },
|
|
154
|
+
{ "uikit-top-[55px]": e.dropdownPosition === "bottom" },
|
|
155
|
+
e.dropdownClasses
|
|
156
|
+
]]),
|
|
157
|
+
onClick: s[3] || (s[3] = c(() => {
|
|
158
|
+
}, ["stop"]))
|
|
159
|
+
}, [
|
|
160
|
+
(n(!0), u(V, null, N(e.options, (d, f) => (n(), u("li", {
|
|
161
|
+
id: `${l.value}_element_${e.options[f].label}`,
|
|
162
|
+
key: `${d.label}_${f}`,
|
|
155
163
|
role: "option",
|
|
156
|
-
"aria-selected":
|
|
157
|
-
class:
|
|
158
|
-
onClick:
|
|
159
|
-
onMouseover:
|
|
160
|
-
onBlur:
|
|
164
|
+
"aria-selected": b(v) === f,
|
|
165
|
+
class: a(["uikit-m-1 uikit-cursor-pointer uikit-px-20px uikit-py-10px uikit-text aria-selected:uikit-rounded-xs aria-selected:uikit-bg-w-cultured", e.dropdownItemClasses]),
|
|
166
|
+
onClick: c((x) => w(d), ["stop"]),
|
|
167
|
+
onMouseover: c((x) => v.value = f, ["stop"]),
|
|
168
|
+
onBlur: s[2] || (s[2] = c(() => {
|
|
161
169
|
}, ["stop"]))
|
|
162
170
|
}, [
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
o("label", Q, [
|
|
172
|
+
o("input", {
|
|
165
173
|
tabindex: "-1",
|
|
166
174
|
class: "uikit-m-0 uikit-appearance-none",
|
|
167
|
-
name: `${
|
|
175
|
+
name: `${l.value}_radio`,
|
|
168
176
|
type: "radio",
|
|
169
|
-
checked:
|
|
170
|
-
onInput:
|
|
177
|
+
checked: d.label === k.value.label,
|
|
178
|
+
onInput: c((x) => w(d), ["stop"])
|
|
171
179
|
}, null, 40, X),
|
|
172
|
-
|
|
173
|
-
innerHTML:
|
|
180
|
+
o("span", {
|
|
181
|
+
innerHTML: d.label
|
|
174
182
|
}, null, 8, Y)
|
|
175
183
|
])
|
|
176
|
-
], 42,
|
|
177
|
-
])
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
e.feedback.valid ? (l(), a("span", {
|
|
184
|
+
], 42, J))), 128))
|
|
185
|
+
], 10, G)
|
|
186
|
+
], 2),
|
|
187
|
+
e.feedback ? (n(), u(V, { key: 0 }, [
|
|
188
|
+
e.feedback.valid ? (n(), u("span", {
|
|
182
189
|
key: 0,
|
|
183
|
-
id: `${
|
|
190
|
+
id: `${l.value}_valid_msg`,
|
|
184
191
|
"arial-live": i.$attrs["aria-live"],
|
|
185
192
|
class: "uikit-mt-1 uikit-inline-block uikit-text-12",
|
|
186
193
|
innerHTML: e.isValid ? e.feedback.valid : ""
|
|
187
194
|
}, null, 8, Z)) : r("", !0),
|
|
188
|
-
e.feedback.invalid ? (
|
|
195
|
+
e.feedback.invalid ? (n(), u("span", {
|
|
189
196
|
key: 1,
|
|
190
|
-
id: `${
|
|
197
|
+
id: `${l.value}_invalid_msg`,
|
|
191
198
|
"arial-live": i.$attrs["aria-live"],
|
|
192
199
|
class: "uikit-mt-1 uikit-inline-block uikit-text-12 uikit-text-w-danger",
|
|
193
200
|
innerHTML: e.isValid === !1 ? e.feedback.invalid : ""
|
|
194
201
|
}, null, 8, _)) : r("", !0)
|
|
195
202
|
], 64)) : r("", !0)
|
|
196
|
-
]));
|
|
203
|
+
], 2));
|
|
197
204
|
}
|
|
198
205
|
});
|
|
199
206
|
export {
|
|
200
|
-
|
|
207
|
+
le as default
|
|
201
208
|
};
|
|
@@ -1,178 +1,162 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent as L, mergeModels as M, useModel as V, useTemplateRef as m, shallowRef as p, onBeforeMount as W, watch as b, nextTick as I, createBlock as F, openBlock as C, withCtx as y, createElementBlock as N, Fragment as A, renderList as H, renderSlot as f, createElementVNode as u, normalizeClass as v, withDirectives as $, vModelText as G, toDisplayString as P, withModifiers as X, normalizeStyle as j, createTextVNode as q, vShow as J } from "vue";
|
|
2
|
+
import Q from "../BaseDropDown.vue.js";
|
|
3
3
|
import '../../../../../assets/BaseDropDown.css';/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import { debounce as
|
|
6
|
-
const
|
|
4
|
+
import Y from "../BaseSelect/SelectItem.vue.js";
|
|
5
|
+
import { debounce as Z } from "@wikicasa-dev/utilities";
|
|
6
|
+
const _ = ["readonly", "placeholder"], ee = ["innerHTML"], ue = /* @__PURE__ */ L({
|
|
7
7
|
__name: "ClearableAutocomplete",
|
|
8
|
-
props: /* @__PURE__ */
|
|
8
|
+
props: /* @__PURE__ */ M({
|
|
9
9
|
dataCy: {},
|
|
10
10
|
placeholder: {},
|
|
11
11
|
enableKeyboardController: { type: Boolean, default: !0 },
|
|
12
12
|
triggerWrapperClasses: {},
|
|
13
13
|
inputWrapperClasses: {},
|
|
14
14
|
inputClasses: {},
|
|
15
|
-
hiddenTextClasses: {},
|
|
16
15
|
dropdownClasses: {},
|
|
17
16
|
clearButton: {},
|
|
18
17
|
keepState: {},
|
|
19
|
-
disableCb: { type: Boolean, default: !1 },
|
|
20
18
|
onInputChangeCb: { type: Function },
|
|
21
19
|
onOptionSelectedCb: { type: [Function, null] }
|
|
22
20
|
}, {
|
|
23
21
|
open: { type: Boolean, default: !1 },
|
|
24
22
|
openModifiers: {},
|
|
25
23
|
modelValue: { default: null },
|
|
26
|
-
modelModifiers: {}
|
|
27
|
-
inputValue: {
|
|
28
|
-
default: ""
|
|
29
|
-
},
|
|
30
|
-
inputValueModifiers: {}
|
|
24
|
+
modelModifiers: {}
|
|
31
25
|
}),
|
|
32
|
-
emits: /* @__PURE__ */
|
|
33
|
-
setup(
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!l) {
|
|
40
|
-
a.value = [], r.value = !1;
|
|
26
|
+
emits: /* @__PURE__ */ M(["click", "inputClick", "update:inputValue", "keydown"], ["update:open", "update:modelValue"]),
|
|
27
|
+
setup(o, { expose: E, emit: O }) {
|
|
28
|
+
const s = V(o, "open"), a = V(o, "modelValue"), r = O, w = m("inputRef"), n = p(a.value?.label || ""), c = p(0), k = p(!1), g = p(null), i = p([]), h = m("dropdownRef"), S = m("hiddenSpan"), R = () => {
|
|
29
|
+
n.value = "", a.value = null, r("update:inputValue", "");
|
|
30
|
+
}, U = async (t) => {
|
|
31
|
+
if (r("update:inputValue", t), !t) {
|
|
32
|
+
i.value = [], s.value = !1;
|
|
41
33
|
return;
|
|
42
34
|
}
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
const e =
|
|
46
|
-
!e || e.id ===
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
|
|
35
|
+
i.value = await g.value?.(t) || [], k.value = !0, s.value = !!i.value.length;
|
|
36
|
+
}, T = (t = -1) => {
|
|
37
|
+
const e = i.value[t];
|
|
38
|
+
!e || e.id === a.value?.id || (o.onOptionSelectedCb?.(e), n.value = e.label, s.value = !1, a.value = e, i.value = []);
|
|
39
|
+
}, x = () => {
|
|
40
|
+
w.value?.select();
|
|
41
|
+
}, z = () => {
|
|
42
|
+
w.value?.focus();
|
|
51
43
|
};
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
}),
|
|
55
|
-
[
|
|
56
|
-
([,
|
|
57
|
-
|
|
58
|
-
if (!
|
|
59
|
-
const
|
|
60
|
-
|
|
44
|
+
return W(() => {
|
|
45
|
+
g.value = Z({ delay: 300 }, o.onInputChangeCb);
|
|
46
|
+
}), b(
|
|
47
|
+
[n, () => S.value],
|
|
48
|
+
([t, e]) => {
|
|
49
|
+
e && I(() => {
|
|
50
|
+
if (!e) return;
|
|
51
|
+
const l = e.offsetWidth;
|
|
52
|
+
l !== c.value && (console.log("DEBUG:updating icon positioning", {
|
|
53
|
+
curInputValue: t
|
|
54
|
+
}), c.value = l);
|
|
61
55
|
});
|
|
62
56
|
},
|
|
63
57
|
{ immediate: !0 }
|
|
64
|
-
),
|
|
65
|
-
() =>
|
|
66
|
-
(
|
|
67
|
-
const e =
|
|
68
|
-
e !== -1 &&
|
|
58
|
+
), b(
|
|
59
|
+
() => h.value?.selectedIdx,
|
|
60
|
+
(t) => {
|
|
61
|
+
const e = t ?? -1;
|
|
62
|
+
e !== -1 && T(e);
|
|
69
63
|
}
|
|
70
|
-
),
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
|
|
64
|
+
), b(
|
|
65
|
+
a,
|
|
66
|
+
(t, e) => {
|
|
67
|
+
t === e || t?.label === n.value || (n.value = t?.label || "");
|
|
74
68
|
},
|
|
75
69
|
{ immediate: !0 }
|
|
76
|
-
),
|
|
77
|
-
getRootElement: () =>
|
|
78
|
-
select:
|
|
79
|
-
focus:
|
|
80
|
-
}), (
|
|
70
|
+
), E({
|
|
71
|
+
getRootElement: () => h.value?.getRootElement(),
|
|
72
|
+
select: x,
|
|
73
|
+
focus: z
|
|
74
|
+
}), (t, e) => (C(), F(Q, {
|
|
81
75
|
ref: "dropdownRef",
|
|
82
76
|
class: "uikit-clearable-autocomplete",
|
|
83
|
-
"data-cy":
|
|
77
|
+
"data-cy": o.dataCy,
|
|
84
78
|
"dropdown-element": "ul",
|
|
85
|
-
"dropdown-classes": ["uikit-z-30",
|
|
86
|
-
"open-dropdown":
|
|
87
|
-
"keep-state": !
|
|
88
|
-
"activate-keyboard-controller":
|
|
89
|
-
"reset-keyboard-controller":
|
|
90
|
-
"onUpdate:resetKeyboardController": e[
|
|
91
|
-
"onUpdate:dropdownState": e[
|
|
79
|
+
"dropdown-classes": ["uikit-z-30", o.dropdownClasses],
|
|
80
|
+
"open-dropdown": s.value,
|
|
81
|
+
"keep-state": !i.value.length || o.keepState === "closed" ? "closed" : "opened",
|
|
82
|
+
"activate-keyboard-controller": o.enableKeyboardController,
|
|
83
|
+
"reset-keyboard-controller": k.value,
|
|
84
|
+
"onUpdate:resetKeyboardController": e[4] || (e[4] = (l) => k.value = l),
|
|
85
|
+
"onUpdate:dropdownState": e[5] || (e[5] = (l) => s.value = l)
|
|
92
86
|
}, {
|
|
93
|
-
btn_slot:
|
|
94
|
-
|
|
95
|
-
class:
|
|
96
|
-
onClick: e[
|
|
87
|
+
btn_slot: y(() => [
|
|
88
|
+
u("div", {
|
|
89
|
+
class: v(["uikit-text-16", o.triggerWrapperClasses]),
|
|
90
|
+
onClick: e[3] || (e[3] = (l) => r("click", l))
|
|
97
91
|
}, [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class: f(["uikit-relative", t.inputWrapperClasses])
|
|
92
|
+
f(t.$slots, "left-icon"),
|
|
93
|
+
u("div", {
|
|
94
|
+
class: v(["uikit-relative", o.inputWrapperClasses])
|
|
102
95
|
}, [
|
|
103
|
-
|
|
96
|
+
$(u("input", {
|
|
104
97
|
ref: "inputRef",
|
|
105
98
|
"onUpdate:modelValue": [
|
|
106
|
-
e[0] || (e[0] = (
|
|
107
|
-
|
|
99
|
+
e[0] || (e[0] = (l) => n.value = l),
|
|
100
|
+
U
|
|
108
101
|
],
|
|
109
|
-
|
|
110
|
-
"data-cy": t.dataCy ? `ac_input_${t.dataCy}` : "",
|
|
102
|
+
readonly: !!a.value?.label,
|
|
111
103
|
type: "text",
|
|
112
104
|
autocomplete: "off",
|
|
113
|
-
class:
|
|
105
|
+
class: v(["uikit-w-full uikit-border-none focus-visible:uikit-outline-none", o.inputClasses]),
|
|
114
106
|
style: {
|
|
115
107
|
font: "inherit",
|
|
116
108
|
fontSize: "inherit"
|
|
117
109
|
},
|
|
118
|
-
placeholder:
|
|
119
|
-
onKeydown: e[1] || (e[1] = (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
onClick: e[3] || (e[3] = (n) => {
|
|
124
|
-
p("inputClick", n), b.value?.select();
|
|
125
|
-
})
|
|
126
|
-
}, null, 42, ue), [
|
|
127
|
-
[Z, o.value]
|
|
110
|
+
placeholder: o.placeholder,
|
|
111
|
+
onKeydown: e[1] || (e[1] = (l) => r("keydown", l)),
|
|
112
|
+
onClick: e[2] || (e[2] = (l) => r("inputClick", l))
|
|
113
|
+
}, null, 42, _), [
|
|
114
|
+
[G, n.value]
|
|
128
115
|
]),
|
|
129
|
-
|
|
116
|
+
u("span", {
|
|
130
117
|
ref_key: "hiddenSpan",
|
|
131
|
-
ref:
|
|
132
|
-
class:
|
|
118
|
+
ref: S,
|
|
119
|
+
class: "uikit-invisible uikit-absolute uikit-left-0 uikit-top-0 uikit-whitespace-pre",
|
|
133
120
|
style: {
|
|
134
121
|
font: "inherit",
|
|
135
122
|
fontSize: "inherit"
|
|
136
123
|
}
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
ref: "clearButtonRef",
|
|
124
|
+
}, P(n.value), 513),
|
|
125
|
+
$(u("button", {
|
|
140
126
|
type: "button",
|
|
141
|
-
class:
|
|
127
|
+
class: v(["uikit-clear-btn uikit-absolute uikit-top-1/2 -uikit-translate-y-1/2 uikit-appearance-none", o.clearButton?.classes]),
|
|
142
128
|
"aria-label": "Clear input",
|
|
143
|
-
style:
|
|
144
|
-
left: `${
|
|
145
|
-
width: t.clearButton?.width ? `${t.clearButton.width}px` : "auto",
|
|
146
|
-
height: t.clearButton?.height ? `${t.clearButton.height}px` : "auto"
|
|
129
|
+
style: j({
|
|
130
|
+
left: `${c.value + (o.clearButton?.offset || 10)}px`
|
|
147
131
|
}),
|
|
148
|
-
onClick:
|
|
132
|
+
onClick: X(R, ["stop"])
|
|
149
133
|
}, [
|
|
150
|
-
|
|
151
|
-
e[
|
|
134
|
+
f(t.$slots, "clear-icon", {}, () => [
|
|
135
|
+
e[6] || (e[6] = q("X", -1))
|
|
152
136
|
])
|
|
153
137
|
], 6), [
|
|
154
|
-
[
|
|
138
|
+
[J, a.value?.label && c.value]
|
|
155
139
|
])
|
|
156
140
|
], 2),
|
|
157
|
-
|
|
141
|
+
f(t.$slots, "right-icon")
|
|
158
142
|
], 2)
|
|
159
143
|
]),
|
|
160
|
-
default:
|
|
161
|
-
(
|
|
162
|
-
key:
|
|
163
|
-
active:
|
|
144
|
+
default: y(({ activeIdx: l, setActiveIdx: D }) => [
|
|
145
|
+
(C(!0), N(A, null, H(i.value, (B, d) => (C(), F(Y, {
|
|
146
|
+
key: d,
|
|
147
|
+
active: l === d,
|
|
164
148
|
class: "uikit-m-1 uikit-rounded-[5px] uikit-px-5 uikit-py-10px hover:uikit-cursor-pointer",
|
|
165
|
-
onClick: (
|
|
166
|
-
onMouseover: (
|
|
149
|
+
onClick: (K) => T(d),
|
|
150
|
+
onMouseover: (K) => D(d)
|
|
167
151
|
}, {
|
|
168
|
-
default:
|
|
169
|
-
|
|
170
|
-
option:
|
|
171
|
-
idx:
|
|
152
|
+
default: y(() => [
|
|
153
|
+
f(t.$slots, "option-content", {
|
|
154
|
+
option: B,
|
|
155
|
+
idx: d
|
|
172
156
|
}, () => [
|
|
173
|
-
|
|
174
|
-
innerHTML:
|
|
175
|
-
}, null, 8,
|
|
157
|
+
u("span", {
|
|
158
|
+
innerHTML: B.label
|
|
159
|
+
}, null, 8, ee)
|
|
176
160
|
])
|
|
177
161
|
]),
|
|
178
162
|
_: 2
|
|
@@ -183,5 +167,5 @@ const ue = ["id", "data-cy", "placeholder"], se = ["innerHTML"], ke = /* @__PURE
|
|
|
183
167
|
}
|
|
184
168
|
});
|
|
185
169
|
export {
|
|
186
|
-
|
|
170
|
+
ue as default
|
|
187
171
|
};
|