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