@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.
@@ -1,10 +1,10 @@
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,
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__ */ $(["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;
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
- 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), {
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
- 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
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, 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}`,
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": 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(() => {
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
- o("label", Q, [
172
- o("input", {
164
+ n("label", Q, [
165
+ n("input", {
173
166
  tabindex: "-1",
174
167
  class: "uikit-m-0 uikit-appearance-none",
175
- name: `${l.value}_radio`,
168
+ name: `${t.value}_radio`,
176
169
  type: "radio",
177
- checked: d.label === k.value.label,
178
- onInput: c((x) => w(d), ["stop"])
170
+ checked: u.label === k.value.label,
171
+ onInput: f((p) => w(u), ["stop"])
179
172
  }, null, 40, X),
180
- o("span", {
181
- innerHTML: d.label
173
+ n("span", {
174
+ innerHTML: u.label
182
175
  }, null, 8, Y)
183
176
  ])
184
- ], 42, J))), 128))
185
- ], 10, G)
186
- ], 2),
187
- e.feedback ? (n(), u(V, { key: 0 }, [
188
- e.feedback.valid ? (n(), u("span", {
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: `${l.value}_valid_msg`,
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 ? (n(), u("span", {
189
+ e.feedback.invalid ? (l(), a("span", {
196
190
  key: 1,
197
- id: `${l.value}_invalid_msg`,
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
- ], 2));
197
+ ]));
204
198
  }
205
199
  });
206
200
  export {
207
- le as default
201
+ ae as default
208
202
  };
@@ -1,162 +1,178 @@
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";
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 Y from "../BaseSelect/SelectItem.vue.js";
5
- import { debounce as Z } from "@wikicasa-dev/utilities";
6
- const _ = ["readonly", "placeholder"], ee = ["innerHTML"], ue = /* @__PURE__ */ L({
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__ */ M({
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__ */ 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;
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
- 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();
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 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);
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
- ), b(
59
- () => h.value?.selectedIdx,
60
- (t) => {
61
- const e = t ?? -1;
62
- e !== -1 && T(e);
64
+ ), T(
65
+ () => M.value?.selectedIdx,
66
+ (l) => {
67
+ const e = l ?? -1;
68
+ e !== -1 && R(e);
63
69
  }
64
- ), b(
65
- a,
66
- (t, e) => {
67
- t === e || t?.label === n.value || (n.value = t?.label || "");
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
- ), E({
71
- getRootElement: () => h.value?.getRootElement(),
72
- select: x,
73
- focus: z
74
- }), (t, e) => (C(), F(Q, {
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": o.dataCy,
83
+ "data-cy": t.dataCy,
78
84
  "dropdown-element": "ul",
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)
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: y(() => [
88
- u("div", {
89
- class: v(["uikit-text-16", o.triggerWrapperClasses]),
90
- onClick: e[3] || (e[3] = (l) => r("click", l))
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
- f(t.$slots, "left-icon"),
93
- u("div", {
94
- class: v(["uikit-relative", o.inputWrapperClasses])
98
+ C(l.$slots, "left-icon"),
99
+ s("div", {
100
+ ref: "inputWrapperRef",
101
+ class: f(["uikit-relative", t.inputWrapperClasses])
95
102
  }, [
96
- $(u("input", {
103
+ W(s("input", {
97
104
  ref: "inputRef",
98
105
  "onUpdate:modelValue": [
99
- e[0] || (e[0] = (l) => n.value = l),
100
- U
106
+ e[0] || (e[0] = (n) => o.value = n),
107
+ K
101
108
  ],
102
- readonly: !!a.value?.label,
109
+ id: Y(I),
110
+ "data-cy": t.dataCy ? `ac_input_${t.dataCy}` : "",
103
111
  type: "text",
104
112
  autocomplete: "off",
105
- class: v(["uikit-w-full uikit-border-none focus-visible:uikit-outline-none", o.inputClasses]),
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: 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]
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
- u("span", {
129
+ s("span", {
117
130
  ref_key: "hiddenSpan",
118
- ref: S,
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
- }, P(n.value), 513),
125
- $(u("button", {
137
+ }, _(o.value), 3),
138
+ W(s("button", {
139
+ ref: "clearButtonRef",
126
140
  type: "button",
127
- class: v(["uikit-clear-btn uikit-absolute uikit-top-1/2 -uikit-translate-y-1/2 uikit-appearance-none", o.clearButton?.classes]),
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: j({
130
- left: `${c.value + (o.clearButton?.offset || 10)}px`
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: X(R, ["stop"])
148
+ onClick: ee(D, ["stop"])
133
149
  }, [
134
- f(t.$slots, "clear-icon", {}, () => [
135
- e[6] || (e[6] = q("X", -1))
150
+ C(l.$slots, "clear-icon", {}, () => [
151
+ e[7] || (e[7] = le("X", -1))
136
152
  ])
137
153
  ], 6), [
138
- [J, a.value?.label && c.value]
154
+ [ne, k.value && v.value]
139
155
  ])
140
156
  ], 2),
141
- f(t.$slots, "right-icon")
157
+ C(l.$slots, "right-icon")
142
158
  ], 2)
143
159
  ]),
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,
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: (K) => T(d),
150
- onMouseover: (K) => D(d)
165
+ onClick: (w) => R(i),
166
+ onMouseover: (w) => h(i)
151
167
  }, {
152
- default: y(() => [
153
- f(t.$slots, "option-content", {
154
- option: B,
155
- idx: d
168
+ default: S(() => [
169
+ C(l.$slots, "option-content", {
170
+ option: m,
171
+ idx: i
156
172
  }, () => [
157
- u("span", {
158
- innerHTML: B.label
159
- }, null, 8, ee)
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
- ue as default
186
+ ke as default
171
187
  };