@wikicasa-dev/components 2.2.9-alpha.20 → 2.2.9-alpha.21

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