@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.
@@ -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-autoplay.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-autoplay.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-autoplay.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-autoplay.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 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 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__ */ 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__ */ $(["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__ */ 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
- 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 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 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 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
- ), w(
64
- () => T.value?.selectedIdx,
65
- (t) => {
66
- const e = t ?? -1;
67
- e !== -1 && M(e);
67
+ ), T(
68
+ () => R.value?.selectedIdx,
69
+ (l) => {
70
+ const e = l ?? -1;
71
+ e !== -1 && F(e);
68
72
  }
69
- ), w(
70
- i,
71
- (t, e) => {
72
- t === e || t?.label === o.value || (o.value = t?.label || "");
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
- ), R({
76
- getRootElement: () => T.value?.getRootElement(),
77
- select: z,
78
- focus: K
79
- }), (t, e) => (h(), F(ee, {
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": l.dataCy,
86
+ "data-cy": t.dataCy,
83
87
  "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)
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: g(() => [
93
- u("div", {
94
- class: v(["uikit-text-16", l.triggerWrapperClasses]),
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
- f(t.$slots, "left-icon"),
98
- u("div", {
99
- class: v(["uikit-relative", l.inputWrapperClasses])
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
- O(u("input", {
111
+ E(s("input", {
102
112
  ref: "inputRef",
103
113
  "onUpdate:modelValue": [
104
114
  e[0] || (e[0] = (n) => o.value = n),
105
- U
115
+ A
106
116
  ],
107
- id: q(E),
108
- "data-cy": l.dataCy ? `ac_input_${l.dataCy}` : "",
117
+ id: Z(L),
118
+ "data-cy": t.dataCy ? `ac_input_${t.dataCy}` : "",
109
119
  type: "text",
110
120
  autocomplete: "off",
111
- class: v(["uikit-w-full uikit-border-none focus-visible:uikit-outline-none", l.inputClasses]),
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: l.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), C.value = !1;
129
+ p("input", n), h.value = !1;
120
130
  }),
121
131
  onClick: e[3] || (e[3] = (n) => {
122
- p("inputClick", n), k.value?.select();
132
+ p("inputClick", n), C.value?.select();
123
133
  })
124
- }, null, 42, ne), [
125
- [G, o.value]
134
+ }, null, 42, ue), [
135
+ [_, o.value]
126
136
  ]),
127
- u("span", {
137
+ s("span", {
128
138
  ref_key: "hiddenSpan",
129
- ref: B,
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
- }, J(o.value), 513),
136
- O(u("button", {
145
+ }, ee(o.value), 3),
146
+ E(s("button", {
147
+ ref: "clearButtonRef",
137
148
  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]),
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: Y({
141
- left: `${c.value + (l.clearButton?.offset || 10)}px`
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: Q(I, ["stop"])
156
+ onClick: te(N, ["stop"])
144
157
  }, [
145
- f(t.$slots, "clear-icon", {}, () => [
146
- e[7] || (e[7] = Z("X", -1))
158
+ m(l.$slots, "clear-icon", {}, () => [
159
+ e[7] || (e[7] = le("X", -1))
147
160
  ])
148
161
  ], 6), [
149
- [_, C.value && c.value]
162
+ [ne, h.value && v.value]
150
163
  ])
151
- ], 2),
152
- f(t.$slots, "right-icon")
164
+ ], 6),
165
+ m(l.$slots, "right-icon")
153
166
  ], 2)
154
167
  ]),
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,
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: (W) => M(r),
161
- onMouseover: (W) => L(r)
173
+ onClick: (w) => F(i),
174
+ onMouseover: (w) => y(i)
162
175
  }, {
163
- default: g(() => [
164
- f(t.$slots, "option-content", {
165
- option: V,
166
- idx: r
176
+ default: x(() => [
177
+ m(l.$slots, "option-content", {
178
+ option: k,
179
+ idx: i
167
180
  }, () => [
168
- u("span", {
169
- innerHTML: V.label
170
- }, null, 8, oe)
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
- pe as default
194
+ ke as default
182
195
  };
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.22",
4
4
  "description": "Wikicasa frontend components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",