@wikicasa-dev/components 2.2.9-alpha.20 → 2.2.9-alpha.22
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/Autocomplete/ClearableAutocomplete.d.ts +3 -0
- package/dist/packages/components/lib/UIKit/Autocomplete/ClearableAutocomplete.vue.js +111 -98
- package/package.json +1 -1
- /package/dist/assets/{swiper-controller.css → swiper-autoplay.css} +0 -0
package/dist/Swiper/autoplay.js
CHANGED
package/dist/Swiper/keyboard.js
CHANGED
package/dist/Swiper/thumbs.js
CHANGED
|
@@ -8,11 +8,14 @@ export interface ClearableAutocompleteProps<TID extends string | number | undefi
|
|
|
8
8
|
triggerWrapperClasses?: ClassTypeProp;
|
|
9
9
|
inputWrapperClasses?: ClassTypeProp;
|
|
10
10
|
inputClasses?: ClassTypeProp;
|
|
11
|
+
hiddenTextClasses?: ClassTypeProp;
|
|
11
12
|
dropdownClasses?: ClassTypeProp;
|
|
12
13
|
clearButton?: {
|
|
13
14
|
classes?: ClassTypeProp;
|
|
14
15
|
/** Space between the input element and the clear button */
|
|
15
16
|
offset?: number;
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
16
19
|
};
|
|
17
20
|
keepState?: Nullable<"closed" | "open">;
|
|
18
21
|
disableCb?: boolean;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent as G, mergeModels as V, useModel as g, useId as X, useTemplateRef as d, shallowRef as c, onBeforeMount as j, watch as T, nextTick as q, createBlock as W, openBlock as S, withCtx as x, createElementBlock as J, Fragment as Q, renderList as Y, renderSlot as m, createElementVNode as s, normalizeClass as f, normalizeStyle as U, withDirectives as E, unref as Z, vModelText as _, toDisplayString as ee, withModifiers 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__ */ G({
|
|
7
7
|
__name: "ClearableAutocomplete",
|
|
8
|
-
props: /* @__PURE__ */
|
|
8
|
+
props: /* @__PURE__ */ V({
|
|
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: {},
|
|
@@ -28,146 +29,158 @@ const ne = ["id", "data-cy", "placeholder"], oe = ["innerHTML"], pe = /* @__PURE
|
|
|
28
29
|
},
|
|
29
30
|
inputValueModifiers: {}
|
|
30
31
|
}),
|
|
31
|
-
emits: /* @__PURE__ */
|
|
32
|
-
setup(
|
|
33
|
-
const
|
|
34
|
-
o.value = o.value ??
|
|
35
|
-
const p =
|
|
36
|
-
o.value = "",
|
|
37
|
-
},
|
|
38
|
-
if (!
|
|
39
|
-
a.value = [],
|
|
32
|
+
emits: /* @__PURE__ */ V(["input", "click", "inputClick", "keydown"], ["update:open", "update:modelValue", "update:inputValue"]),
|
|
33
|
+
setup(t, { expose: I, emit: D }) {
|
|
34
|
+
const r = g(t, "open"), u = g(t, "modelValue"), o = g(t, "inputValue");
|
|
35
|
+
o.value = o.value ?? u.value?.label ?? "";
|
|
36
|
+
const p = D, L = X(), C = d("inputRef"), v = c(0), b = c(!1), h = c(!!u.value?.label), M = c(null), a = c([]), R = d("dropdownRef"), $ = d("hiddenSpan"), z = d("inputWrapperRef"), K = d("clearButtonRef"), N = () => {
|
|
37
|
+
o.value = "", u.value = null;
|
|
38
|
+
}, A = async (l) => {
|
|
39
|
+
if (!l) {
|
|
40
|
+
a.value = [], r.value = !1;
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
const e = a.value[
|
|
45
|
-
!e || e.id ===
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
43
|
+
t.disableCb || (a.value = await M.value?.(l) || [], b.value = !0, r.value = !!a.value.length);
|
|
44
|
+
}, F = (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, h.value = !0, a.value = []);
|
|
47
|
+
}, H = () => {
|
|
48
|
+
C.value?.select();
|
|
49
|
+
}, P = () => {
|
|
50
|
+
C.value?.focus();
|
|
50
51
|
};
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
[o,
|
|
55
|
-
([,
|
|
56
|
-
|
|
57
|
-
if (!
|
|
58
|
-
const e = t.offsetWidth;
|
|
59
|
-
|
|
52
|
+
return j(() => {
|
|
53
|
+
M.value = ie({ delay: 300 }, t.onInputChangeCb);
|
|
54
|
+
}), T(
|
|
55
|
+
[o, $, z, K],
|
|
56
|
+
([, l, e, n]) => {
|
|
57
|
+
!l || !e || q(() => {
|
|
58
|
+
if (!l || !e) return;
|
|
59
|
+
const y = l.offsetWidth, k = e.offsetWidth, i = t.clearButton?.offset || 0, w = t.clearButton?.width || n?.offsetWidth || 0, O = k - i - w, B = Math.min(y, O);
|
|
60
|
+
console.log("DEBUG:", {
|
|
61
|
+
maxPosition: O,
|
|
62
|
+
newOffset: B
|
|
63
|
+
}), B !== v.value && (v.value = B);
|
|
60
64
|
});
|
|
61
65
|
},
|
|
62
66
|
{ immediate: !0 }
|
|
63
|
-
),
|
|
64
|
-
() =>
|
|
65
|
-
(
|
|
66
|
-
const e =
|
|
67
|
-
e !== -1 &&
|
|
67
|
+
), T(
|
|
68
|
+
() => R.value?.selectedIdx,
|
|
69
|
+
(l) => {
|
|
70
|
+
const e = l ?? -1;
|
|
71
|
+
e !== -1 && F(e);
|
|
68
72
|
}
|
|
69
|
-
),
|
|
70
|
-
|
|
71
|
-
(
|
|
72
|
-
|
|
73
|
+
), T(
|
|
74
|
+
u,
|
|
75
|
+
(l, e) => {
|
|
76
|
+
l === e || l?.label === o.value || (o.value = l?.label || "");
|
|
73
77
|
},
|
|
74
78
|
{ immediate: !0 }
|
|
75
|
-
),
|
|
76
|
-
getRootElement: () =>
|
|
77
|
-
select:
|
|
78
|
-
focus:
|
|
79
|
-
}), (
|
|
79
|
+
), I({
|
|
80
|
+
getRootElement: () => R.value?.getRootElement(),
|
|
81
|
+
select: H,
|
|
82
|
+
focus: P
|
|
83
|
+
}), (l, e) => (S(), W(oe, {
|
|
80
84
|
ref: "dropdownRef",
|
|
81
85
|
class: "uikit-clearable-autocomplete",
|
|
82
|
-
"data-cy":
|
|
86
|
+
"data-cy": t.dataCy,
|
|
83
87
|
"dropdown-element": "ul",
|
|
84
|
-
"dropdown-classes": ["uikit-z-30",
|
|
85
|
-
"open-dropdown":
|
|
86
|
-
"keep-state": !a.value.length ||
|
|
87
|
-
"activate-keyboard-controller":
|
|
88
|
-
"reset-keyboard-controller":
|
|
89
|
-
"onUpdate:resetKeyboardController": e[5] || (e[5] = (n) =>
|
|
90
|
-
"onUpdate:dropdownState": e[6] || (e[6] = (n) =>
|
|
88
|
+
"dropdown-classes": ["uikit-z-30", t.dropdownClasses],
|
|
89
|
+
"open-dropdown": r.value,
|
|
90
|
+
"keep-state": !a.value.length || t.keepState === "closed" ? "closed" : "opened",
|
|
91
|
+
"activate-keyboard-controller": t.enableKeyboardController,
|
|
92
|
+
"reset-keyboard-controller": b.value,
|
|
93
|
+
"onUpdate:resetKeyboardController": e[5] || (e[5] = (n) => b.value = n),
|
|
94
|
+
"onUpdate:dropdownState": e[6] || (e[6] = (n) => r.value = n)
|
|
91
95
|
}, {
|
|
92
|
-
btn_slot:
|
|
93
|
-
|
|
94
|
-
class:
|
|
96
|
+
btn_slot: x(() => [
|
|
97
|
+
s("div", {
|
|
98
|
+
class: f(["uikit-text-16", t.triggerWrapperClasses]),
|
|
95
99
|
onClick: e[4] || (e[4] = (n) => p("click", n))
|
|
96
100
|
}, [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
m(l.$slots, "left-icon"),
|
|
102
|
+
s("div", {
|
|
103
|
+
ref: "inputWrapperRef",
|
|
104
|
+
class: f(["uikit-relative", t.inputWrapperClasses]),
|
|
105
|
+
style: U(
|
|
106
|
+
t.clearButton?.width ? {
|
|
107
|
+
paddingRight: `${t.clearButton.width}px`
|
|
108
|
+
} : {}
|
|
109
|
+
)
|
|
100
110
|
}, [
|
|
101
|
-
|
|
111
|
+
E(s("input", {
|
|
102
112
|
ref: "inputRef",
|
|
103
113
|
"onUpdate:modelValue": [
|
|
104
114
|
e[0] || (e[0] = (n) => o.value = n),
|
|
105
|
-
|
|
115
|
+
A
|
|
106
116
|
],
|
|
107
|
-
id:
|
|
108
|
-
"data-cy":
|
|
117
|
+
id: Z(L),
|
|
118
|
+
"data-cy": t.dataCy ? `ac_input_${t.dataCy}` : "",
|
|
109
119
|
type: "text",
|
|
110
120
|
autocomplete: "off",
|
|
111
|
-
class:
|
|
121
|
+
class: f(["uikit-w-full uikit-border-none focus-visible:uikit-outline-none", t.inputClasses]),
|
|
112
122
|
style: {
|
|
113
123
|
font: "inherit",
|
|
114
124
|
fontSize: "inherit"
|
|
115
125
|
},
|
|
116
|
-
placeholder:
|
|
126
|
+
placeholder: t.placeholder,
|
|
117
127
|
onKeydown: e[1] || (e[1] = (n) => p("keydown", n)),
|
|
118
128
|
onInput: e[2] || (e[2] = (n) => {
|
|
119
|
-
p("input", n),
|
|
129
|
+
p("input", n), h.value = !1;
|
|
120
130
|
}),
|
|
121
131
|
onClick: e[3] || (e[3] = (n) => {
|
|
122
|
-
p("inputClick", n),
|
|
132
|
+
p("inputClick", n), C.value?.select();
|
|
123
133
|
})
|
|
124
|
-
}, null, 42,
|
|
125
|
-
[
|
|
134
|
+
}, null, 42, ue), [
|
|
135
|
+
[_, o.value]
|
|
126
136
|
]),
|
|
127
|
-
|
|
137
|
+
s("span", {
|
|
128
138
|
ref_key: "hiddenSpan",
|
|
129
|
-
ref:
|
|
130
|
-
class: "uikit-invisible uikit-absolute uikit-left-0 uikit-top-0 uikit-whitespace-pre",
|
|
139
|
+
ref: $,
|
|
140
|
+
class: f(["uikit-invisible uikit-absolute uikit-left-0 uikit-top-0 uikit-whitespace-pre", t.hiddenTextClasses]),
|
|
131
141
|
style: {
|
|
132
142
|
font: "inherit",
|
|
133
143
|
fontSize: "inherit"
|
|
134
144
|
}
|
|
135
|
-
},
|
|
136
|
-
|
|
145
|
+
}, ee(o.value), 3),
|
|
146
|
+
E(s("button", {
|
|
147
|
+
ref: "clearButtonRef",
|
|
137
148
|
type: "button",
|
|
138
|
-
class:
|
|
149
|
+
class: f(["uikit-clear-btn uikit-absolute uikit-top-1/2 -uikit-translate-y-1/2 uikit-appearance-none", t.clearButton?.classes]),
|
|
139
150
|
"aria-label": "Clear input",
|
|
140
|
-
style:
|
|
141
|
-
left: `${
|
|
151
|
+
style: U({
|
|
152
|
+
left: `${v.value + (t.clearButton?.offset || 0)}px`,
|
|
153
|
+
width: t.clearButton?.width ? `${t.clearButton.width}px` : "auto",
|
|
154
|
+
height: t.clearButton?.height ? `${t.clearButton.height}px` : "auto"
|
|
142
155
|
}),
|
|
143
|
-
onClick:
|
|
156
|
+
onClick: te(N, ["stop"])
|
|
144
157
|
}, [
|
|
145
|
-
|
|
146
|
-
e[7] || (e[7] =
|
|
158
|
+
m(l.$slots, "clear-icon", {}, () => [
|
|
159
|
+
e[7] || (e[7] = le("X", -1))
|
|
147
160
|
])
|
|
148
161
|
], 6), [
|
|
149
|
-
[
|
|
162
|
+
[ne, h.value && v.value]
|
|
150
163
|
])
|
|
151
|
-
],
|
|
152
|
-
|
|
164
|
+
], 6),
|
|
165
|
+
m(l.$slots, "right-icon")
|
|
153
166
|
], 2)
|
|
154
167
|
]),
|
|
155
|
-
default:
|
|
156
|
-
(
|
|
157
|
-
key:
|
|
158
|
-
active: n ===
|
|
168
|
+
default: x(({ activeIdx: n, setActiveIdx: y }) => [
|
|
169
|
+
(S(!0), J(Q, null, Y(a.value, (k, i) => (S(), W(ae, {
|
|
170
|
+
key: i,
|
|
171
|
+
active: n === i,
|
|
159
172
|
class: "uikit-m-1 uikit-rounded-[5px] uikit-px-5 uikit-py-10px hover:uikit-cursor-pointer",
|
|
160
|
-
onClick: (
|
|
161
|
-
onMouseover: (
|
|
173
|
+
onClick: (w) => F(i),
|
|
174
|
+
onMouseover: (w) => y(i)
|
|
162
175
|
}, {
|
|
163
|
-
default:
|
|
164
|
-
|
|
165
|
-
option:
|
|
166
|
-
idx:
|
|
176
|
+
default: x(() => [
|
|
177
|
+
m(l.$slots, "option-content", {
|
|
178
|
+
option: k,
|
|
179
|
+
idx: i
|
|
167
180
|
}, () => [
|
|
168
|
-
|
|
169
|
-
innerHTML:
|
|
170
|
-
}, null, 8,
|
|
181
|
+
s("span", {
|
|
182
|
+
innerHTML: k.label
|
|
183
|
+
}, null, 8, se)
|
|
171
184
|
])
|
|
172
185
|
]),
|
|
173
186
|
_: 2
|
|
@@ -178,5 +191,5 @@ const ne = ["id", "data-cy", "placeholder"], oe = ["innerHTML"], pe = /* @__PURE
|
|
|
178
191
|
}
|
|
179
192
|
});
|
|
180
193
|
export {
|
|
181
|
-
|
|
194
|
+
ke as default
|
|
182
195
|
};
|
package/package.json
CHANGED
|
File without changes
|