@wikicasa-dev/components 2.4.2-alpha.9 → 2.5.1-alpha.0

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