@wikicasa-dev/components 2.2.9-alpha.46 → 2.2.9-alpha.49

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