@wikicasa-dev/components 2.8.0 → 2.8.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,18 +1,18 @@
1
1
  import e from "../BaseSelect/SelectItem.js";
2
2
  import t from "../BaseDropDown.js";
3
- import { Fragment as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, defineComponent as c, mergeModels as l, nextTick as u, normalizeClass as d, normalizeStyle as f, onMounted as p, onUnmounted as m, openBlock as h, renderList as g, renderSlot as _, shallowRef as v, toDisplayString as y, unref as b, useId as x, useModel as S, useTemplateRef as C, vModelText as w, vShow as T, watch as E, withCtx as D, withDirectives as O, withModifiers as ee } from "vue";
3
+ import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, defineComponent as l, isMemoSame as u, mergeModels as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onMounted as ee, onUnmounted as te, openBlock as h, renderList as g, renderSlot as _, shallowRef as v, toDisplayString as y, unref as ne, useId as re, useModel as b, useTemplateRef as x, vModelText as ie, vShow as S, watch as C, withCtx as w, withDirectives as T, withModifiers as E } from "vue";
4
4
  import '../../assets/ClearableAutocomplete.css';//#region lib/UIKit/Autocomplete/ClearableAutocomplete.vue?vue&type=script&setup=true&lang.ts
5
- var te = [
5
+ var ae = [
6
6
  "id",
7
7
  "data-cy",
8
8
  "placeholder"
9
- ], ne = ["data-cy"], re = {
9
+ ], oe = ["data-cy"], se = {
10
10
  key: 1,
11
11
  name: "loading-state",
12
12
  class: "uikit-progress-bar-track uikit-absolute uikit-left-0 uikit-top-0 uikit-w-full"
13
- }, ie = ["innerHTML"], k = /*@__PURE__*/ c({
13
+ }, ce = ["innerHTML"], D = /*@__PURE__*/ l({
14
14
  __name: "ClearableAutocomplete",
15
- props: /*@__PURE__*/ l({
15
+ props: /*@__PURE__*/ d({
16
16
  dataCy: {},
17
17
  placeholder: {},
18
18
  enableKeyboardController: {
@@ -43,7 +43,7 @@ var te = [
43
43
  inputValue: { default: "" },
44
44
  inputValueModifiers: {}
45
45
  }),
46
- emits: /*@__PURE__*/ l([
46
+ emits: /*@__PURE__*/ d([
47
47
  "input",
48
48
  "click",
49
49
  "inputClick",
@@ -53,45 +53,45 @@ var te = [
53
53
  "update:modelValue",
54
54
  "update:inputValue"
55
55
  ]),
56
- setup(c, { expose: l, emit: k }) {
57
- let A = S(c, "open"), j = S(c, "modelValue"), M = S(c, "inputValue"), N = k, P = x(), F = C("inputRef"), I = v(0), L = v(!1), R = v(!1), z = v(-1), B = v(-1), V = v([]), H = null, U = 0, ae = C("dropdownRef"), W = C("hiddenSpan"), G = C("inputWrapperRef"), K = C("clearButtonRef"), q = () => {
58
- z.value = -1, B.value = -1;
56
+ setup(l, { expose: d, emit: D }) {
57
+ let O = b(l, "open"), k = b(l, "modelValue"), A = b(l, "inputValue"), j = D, le = re(), M = x("inputRef"), N = v(0), P = v(!1), F = v(!1), I = v(!1), L = v(-1), R = v(-1), z = v([]), B = r(() => ["uikit-z-30", l.dropdownClasses]), V = null, H = 0, U = x("dropdownRef"), W = x("hiddenSpan"), G = x("inputWrapperRef"), K = x("clearButtonRef"), q = () => {
58
+ L.value = -1, R.value = -1;
59
59
  }, J = () => {
60
- H &&= (clearTimeout(H), null), U += 1, R.value = !1;
61
- }, oe = (e) => {
60
+ V &&= (clearTimeout(V), null), H += 1, F.value = !1, I.value = !1;
61
+ }, ue = (e) => {
62
62
  J();
63
- let t = U;
64
- R.value = !0, H = setTimeout(async () => {
65
- H = null, A.value = !0;
63
+ let t = H;
64
+ F.value = !0, V = setTimeout(async () => {
65
+ V = null, O.value = !0, I.value = !0;
66
66
  let n = [];
67
67
  try {
68
- n = await c.onInputChangeCb(e);
68
+ n = await l.onInputChangeCb(e);
69
69
  } catch {
70
70
  n = [];
71
71
  }
72
- t === U && (V.value = n, q(), R.value = !1, A.value = !!V.value.length);
72
+ t === H && (z.value = n, q(), F.value = !1, I.value = !1, O.value = !!z.value.length);
73
73
  }, 300);
74
74
  }, Y = () => {
75
- J(), V.value = [], A.value = !1, M.value = "", j.value = null, L.value = !1, q();
76
- }, se = () => {
75
+ J(), z.value = [], O.value = !1, A.value = "", k.value = null, P.value = !1, N.value = 0, q();
76
+ }, de = () => {
77
77
  Y();
78
- }, ce = (e) => {
78
+ }, fe = (e) => {
79
79
  if (!e) {
80
80
  Y();
81
81
  return;
82
82
  }
83
- if (c.disableCb && e === j.value?.label) {
83
+ if (l.disableCb && e === k.value?.label) {
84
84
  J();
85
85
  return;
86
86
  }
87
- oe(e);
88
- }, le = (e) => {
89
- N("input", e), L.value = !1;
87
+ ue(e);
88
+ }, pe = (e) => {
89
+ j("input", e), P.value = !1, N.value = 0;
90
90
  }, X = (e = -1, t) => {
91
- let n = V.value[e];
92
- !n || n.id === j.value?.id || (B.value = e, c.onOptionSelectedCb?.(n, { trigger: t }), M.value = n.label, A.value = !1, j.value = n, L.value = !0, J(), V.value = []);
91
+ let n = z.value[e];
92
+ !n || n.id === k.value?.id || (R.value = e, l.onOptionSelectedCb?.(n, { trigger: t }), A.value = n.label, O.value = !1, k.value = n, P.value = !0, J(), z.value = []);
93
93
  }, Z = (e) => {
94
- if (!c.enableKeyboardController || !A.value || ![
94
+ if (!l.enableKeyboardController || !O.value || ![
95
95
  "ArrowUp",
96
96
  "ArrowDown",
97
97
  "Enter",
@@ -102,11 +102,11 @@ var te = [
102
102
  "End"
103
103
  ].includes(e.key)) return;
104
104
  if (e.key === "Escape") {
105
- z.value = B.value, A.value = !1, e.stopPropagation();
105
+ L.value = R.value, O.value = !1, e.stopPropagation();
106
106
  return;
107
107
  }
108
- if (!V.value.length) return;
109
- let t = V.value.length - 1;
108
+ if (!z.value.length) return;
109
+ let t = z.value.length - 1;
110
110
  if ([
111
111
  "ArrowUp",
112
112
  "ArrowDown",
@@ -114,130 +114,145 @@ var te = [
114
114
  "Home",
115
115
  "PageDown",
116
116
  "End"
117
- ].includes(e.key) && e.preventDefault(), e.key === "ArrowUp") z.value = z.value <= 0 ? t : z.value - 1;
118
- else if (e.key === "ArrowDown") z.value = z.value >= t ? 0 : z.value + 1;
117
+ ].includes(e.key) && e.preventDefault(), e.key === "ArrowUp") L.value = L.value <= 0 ? t : L.value - 1;
118
+ else if (e.key === "ArrowDown") L.value = L.value >= t ? 0 : L.value + 1;
119
119
  else if (e.key === "Enter") {
120
- if (z.value === -1) return;
121
- e.preventDefault(), X(z.value, "enter");
122
- } else e.key === "PageUp" || e.key === "Home" ? z.value = 0 : (e.key === "PageDown" || e.key === "End") && (z.value = t);
120
+ if (L.value === -1) return;
121
+ e.preventDefault(), X(L.value, "enter");
122
+ } else e.key === "PageUp" || e.key === "Home" ? L.value = 0 : (e.key === "PageDown" || e.key === "End") && (L.value = t);
123
123
  e.stopPropagation();
124
- }, ue = (e) => {
125
- N("keydown", e), Z(e);
126
- }, de = () => {
127
- F.value?.select();
128
- }, fe = () => {
129
- F.value?.focus();
124
+ }, me = (e) => {
125
+ j("keydown", e), Z(e);
126
+ }, he = () => {
127
+ M.value?.select();
128
+ }, ge = () => {
129
+ M.value?.focus();
130
130
  }, Q = null, $ = () => {
131
+ if (!P.value) return;
131
132
  let e = W.value, t = G.value, n = K.value;
132
133
  if (!e || !t) return;
133
- let r = e.offsetWidth, i = t.offsetWidth, a = c.clearButton?.offset || 0, o = c.clearButton?.width || n?.offsetWidth || 0, s = i - a - o, l = Math.min(r, s);
134
- l !== I.value && (I.value = l);
134
+ let r = e.offsetWidth, i = t.offsetWidth;
135
+ if (!i) return;
136
+ let a = l.clearButton?.offset || 0, o = l.clearButton?.width || n?.offsetWidth || 0, s = i - a - o, c = Math.min(r, s);
137
+ c !== N.value && (N.value = c);
135
138
  };
136
- return p(() => {
139
+ return ee(() => {
137
140
  G.value && (Q = new ResizeObserver(() => {
138
141
  $();
139
142
  }), Q.observe(G.value));
140
- }), m(() => {
143
+ }), te(() => {
141
144
  Q?.disconnect(), J();
142
- }), E([
143
- M,
145
+ }), C([
146
+ A,
147
+ P,
144
148
  W,
145
149
  K
146
150
  ], () => {
147
- u($);
148
- }), E(j, (e) => {
149
- if (e?.label === M.value) return;
151
+ f($);
152
+ }), C(k, (e) => {
153
+ if (e?.label === A.value) return;
150
154
  let t = e?.label || "";
151
- M.value = t, t && (L.value = !0);
152
- }, { immediate: !0 }), l({
153
- getRootElement: () => ae.value?.getRootElement(),
154
- select: de,
155
- focus: fe
156
- }), (l, u) => (h(), r(t, {
155
+ A.value = t, t && (P.value = !0);
156
+ }, { immediate: !0 }), d({
157
+ getRootElement: () => U.value?.getRootElement(),
158
+ select: he,
159
+ focus: ge
160
+ }), (r, d) => (h(), i(t, {
157
161
  ref: "dropdownRef",
158
162
  class: "uikit-clearable-autocomplete",
159
- "data-cy": c.dataCy,
163
+ "data-cy": l.dataCy,
160
164
  "dropdown-element": "ul",
161
- "dropdown-classes": ["uikit-z-30", c.dropdownClasses],
162
- "keep-state": c.keepState === "closed" ? "closed" : "opened",
165
+ "dropdown-classes": B.value,
166
+ "keep-state": l.keepState === "closed" ? "closed" : "opened",
163
167
  "activate-keyboard-controller": !1,
164
- open: A.value,
165
- "onUpdate:open": u[3] ||= (e) => A.value = e
168
+ open: O.value,
169
+ "onUpdate:open": d[5] ||= (e) => O.value = e
166
170
  }, {
167
- btn_slot: D(() => [o("div", {
168
- class: d(["uikit-text-16", c.triggerWrapperClasses]),
169
- onClick: u[2] ||= (e) => N("click", e)
171
+ btn_slot: w(() => [s("div", {
172
+ class: p(["uikit-text-16", l.triggerWrapperClasses]),
173
+ onClick: d[2] ||= (e) => j("click", e)
170
174
  }, [
171
- _(l.$slots, "left-icon"),
172
- o("div", {
175
+ _(r.$slots, "left-icon"),
176
+ s("div", {
173
177
  ref: "inputWrapperRef",
174
- class: d(["uikit-relative", c.inputWrapperClasses])
178
+ class: p(["uikit-relative", l.inputWrapperClasses])
175
179
  }, [
176
- O(o("input", {
180
+ T(s("input", {
177
181
  ref: "inputRef",
178
- "onUpdate:modelValue": [u[0] ||= (e) => M.value = e, ce],
179
- id: b(P),
180
- "data-cy": c.dataCy ? `ac_input_${c.dataCy}` : "",
182
+ "onUpdate:modelValue": [d[0] ||= (e) => A.value = e, fe],
183
+ id: ne(le),
184
+ "data-cy": l.dataCy ? `ac_input_${l.dataCy}` : "",
181
185
  type: "text",
182
186
  autocomplete: "off",
183
- class: d(["uikit-w-full uikit-border-none focus-visible:uikit-outline-none", c.inputClasses]),
187
+ class: p(["uikit-w-full uikit-border-none focus-visible:uikit-outline-none", l.inputClasses]),
184
188
  style: {
185
189
  font: "inherit",
186
190
  fontSize: "inherit"
187
191
  },
188
- placeholder: c.placeholder,
189
- onKeydown: ue,
190
- onInput: le,
191
- onClick: u[1] ||= (e) => {
192
- N("inputClick", e), F.value?.select();
192
+ placeholder: l.placeholder,
193
+ onKeydown: me,
194
+ onInput: pe,
195
+ onClick: d[1] ||= (e) => {
196
+ j("inputClick", e), M.value?.select();
193
197
  }
194
- }, null, 42, te), [[w, M.value]]),
195
- o("span", {
198
+ }, null, 42, ae), [[ie, A.value]]),
199
+ s("span", {
196
200
  ref_key: "hiddenSpan",
197
201
  ref: W,
198
- class: d(["uikit-invisible uikit-absolute uikit-left-0 uikit-top-0 uikit-max-w-full uikit-overflow-hidden uikit-whitespace-pre", c.hiddenTextClasses]),
202
+ class: p(["uikit-invisible uikit-absolute uikit-left-0 uikit-top-0 uikit-max-w-full uikit-overflow-hidden uikit-whitespace-pre", l.hiddenTextClasses]),
199
203
  style: {
200
204
  font: "inherit",
201
205
  fontSize: "inherit"
202
206
  }
203
- }, y(M.value), 3),
204
- O(o("button", {
207
+ }, y(A.value), 3),
208
+ T(s("button", {
205
209
  ref: "clearButtonRef",
206
210
  type: "button",
207
- class: d(["uikit-clear-btn uikit-absolute uikit-top-1/2 -uikit-translate-y-1/2 uikit-appearance-none", c.clearButton?.classes]),
208
- "data-cy": c.clearButton?.dataCy || "clear-btn",
211
+ class: p(["uikit-clear-btn uikit-absolute uikit-top-1/2 -uikit-translate-y-1/2 uikit-appearance-none", l.clearButton?.classes]),
212
+ "data-cy": l.clearButton?.dataCy || "clear-btn",
209
213
  "aria-label": "Clear input",
210
- style: f({
211
- left: `${I.value + (c.clearButton?.offset || 0)}px`,
212
- width: c.clearButton?.width ? `${c.clearButton.width}px` : "auto",
213
- height: c.clearButton?.height ? `${c.clearButton.height}px` : "auto"
214
+ style: m({
215
+ left: `${N.value + (l.clearButton?.offset || 0)}px`,
216
+ width: l.clearButton?.width ? `${l.clearButton.width}px` : "auto",
217
+ height: l.clearButton?.height ? `${l.clearButton.height}px` : "auto"
214
218
  }),
215
- onClick: ee(se, ["stop"])
216
- }, [_(l.$slots, "clear-icon", {}, () => [u[4] ||= s("X", -1)])], 14, ne), [[T, L.value && I.value]])
219
+ onClick: E(de, ["stop"])
220
+ }, [_(r.$slots, "clear-icon", {}, () => [d[6] ||= c("X", -1)])], 14, oe), [[S, P.value && N.value]])
217
221
  ], 2),
218
- _(l.$slots, "right-icon")
222
+ _(r.$slots, "right-icon")
219
223
  ], 2)]),
220
- default: D(() => [
221
- R.value && !V.value.length ? _(l.$slots, "loading-state", { key: 0 }) : i("", !0),
222
- R.value && V.value.length ? (h(), a("div", re, [...u[5] ||= [o("div", { class: "uikit-progress-bar-fill" }, null, -1)]])) : i("", !0),
223
- V.value.length ? (h(!0), a(n, { key: 2 }, g(V.value, (t, n) => (h(), r(e, {
224
- key: n,
225
- active: z.value === n,
226
- class: "uikit-m-1 uikit-rounded-[5px] uikit-px-5 uikit-py-10px hover:uikit-cursor-pointer",
227
- onClick: (e) => X(n, "click"),
228
- onKeydown: Z,
229
- onMouseover: (e) => z.value = n
230
- }, {
231
- default: D(() => [_(l.$slots, "option-content", {
232
- option: t,
233
- idx: n
234
- }, () => [o("span", { innerHTML: t.label }, null, 8, ie)])]),
235
- _: 2
236
- }, 1032, [
237
- "active",
238
- "onClick",
239
- "onMouseover"
240
- ]))), 128)) : i("", !0)
224
+ default: w(() => [
225
+ I.value && !z.value.length ? _(r.$slots, "loading-state", { key: 0 }) : a("", !0),
226
+ F.value && z.value.length ? (h(), o("div", se, [...d[7] ||= [s("div", { class: "uikit-progress-bar-fill" }, null, -1)]])) : a("", !0),
227
+ z.value.length ? (h(!0), o(n, { key: 2 }, g(z.value, (t, n, a, o) => {
228
+ let c = [
229
+ t,
230
+ L.value === n,
231
+ l.enableKeyboardController
232
+ ];
233
+ if (o && o.el && o.key === n && u(o, c)) return o;
234
+ let d = (h(), i(e, {
235
+ key: n,
236
+ active: L.value === n,
237
+ "focus-on-active": l.enableKeyboardController,
238
+ class: "uikit-m-1 uikit-rounded-[5px] uikit-px-5 uikit-py-10px hover:uikit-cursor-pointer",
239
+ onClick: (e) => X(n, "click"),
240
+ onKeydown: Z,
241
+ onMouseover: (e) => L.value = n
242
+ }, {
243
+ default: w(() => [_(r.$slots, "option-content", {
244
+ option: t,
245
+ idx: n
246
+ }, () => [s("span", { innerHTML: t.label }, null, 8, ce)])]),
247
+ _: 2
248
+ }, 1032, [
249
+ "active",
250
+ "focus-on-active",
251
+ "onClick",
252
+ "onMouseover"
253
+ ]));
254
+ return d.memo = c, d;
255
+ }, d, 3), 128)) : a("", !0)
241
256
  ]),
242
257
  _: 3
243
258
  }, 8, [
@@ -249,4 +264,4 @@ var te = [
249
264
  }
250
265
  });
251
266
  //#endregion
252
- export { k as default };
267
+ export { D as default };
@@ -2,6 +2,17 @@ type __VLS_Props = {
2
2
  label?: string;
3
3
  active?: boolean;
4
4
  idx?: number;
5
+ /**
6
+ * Whether becoming active should move real DOM focus onto the item.
7
+ *
8
+ * Focus exists here to serve keyboard navigation. Consumers that drive
9
+ * `active` from pointer events alone (touch synthesises `mouseover` before
10
+ * `click`) should turn this off: focusing the item runs scroll-into-view
11
+ * against every scrollable ancestor and blurs whatever held focus - on
12
+ * mobile that dismisses the soft keyboard, and both cost a forced layout
13
+ * before the tap is even processed.
14
+ */
15
+ focusOnActive?: boolean;
5
16
  };
6
17
  declare var __VLS_1: {
7
18
  itemIdx: number;
@@ -19,6 +30,7 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {},
19
30
  label: string;
20
31
  active: boolean;
21
32
  idx: number;
33
+ focusOnActive: boolean;
22
34
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
23
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
24
36
  declare const _default: typeof __VLS_export;
@@ -8,13 +8,17 @@ var l = ["data-active", "tabindex"], u = ["innerHTML"], d = /*@__PURE__*/ n({
8
8
  type: Boolean,
9
9
  default: !1
10
10
  },
11
- idx: { default: -1 }
11
+ idx: { default: -1 },
12
+ focusOnActive: {
13
+ type: Boolean,
14
+ default: !0
15
+ }
12
16
  },
13
17
  emits: ["click", "mouseover"],
14
18
  setup(n, { emit: d }) {
15
19
  let f = d, p = n, m = s("liItem");
16
20
  return c(() => p.active, (e) => {
17
- e && r(() => {
21
+ e && p.focusOnActive && r(() => {
18
22
  m.value && m.value.focus();
19
23
  });
20
24
  }, { immediate: !0 }), (r, s) => (a(), e("li", {
@@ -1,3 +1,3 @@
1
- import '../../../assets/swiper-thumbs.css';/* empty css */
1
+ import '../../../assets/swiper-keyboard.css';/* empty css */
2
2
  import { Autoplay as e } from "swiper/modules";
3
3
  export { e as default };
@@ -1,3 +1,3 @@
1
- import '../../../assets/swiper-thumbs.css';/* empty css */
1
+ import '../../../assets/swiper-keyboard.css';/* empty css */
2
2
  import { Controller as e } from "swiper/modules";
3
3
  export { e as default };
@@ -1,3 +1,3 @@
1
- import '../../../assets/swiper-thumbs.css';/* empty css */
1
+ import '../../../assets/swiper-keyboard.css';/* empty css */
2
2
  import { Keyboard as e } from "swiper/modules";
3
3
  export { e as default };
@@ -1,3 +1,3 @@
1
- import '../../../assets/swiper-thumbs.css';/* empty css */
1
+ import '../../../assets/swiper-keyboard.css';/* empty css */
2
2
  import { Thumbs as e } from "swiper/modules";
3
3
  export { e as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikicasa-dev/components",
3
- "version": "2.8.0",
3
+ "version": "2.8.1-alpha.0",
4
4
  "description": "Wikicasa frontend components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -82,13 +82,13 @@
82
82
  "vitest-browser-vue": "^2.1.0",
83
83
  "vue-router": "^5.1.0",
84
84
  "vue-tsc": "^3.3.3",
85
- "@wikicasa-dev/tsconfig": "0.0.0",
86
85
  "@wikicasa-dev/svg-icons": "1.3.7",
87
- "@wikicasa-dev/tailwind-plugins": "0.0.7",
88
- "@wikicasa-dev/eslint-config": "0.0.0",
89
86
  "@wikicasa-dev/utilities": "1.2.11",
90
87
  "@wikicasa-dev/types": "2.8.0",
91
- "@wikicasa-dev/vue-composables": "0.2.0"
88
+ "@wikicasa-dev/tsconfig": "0.0.0",
89
+ "@wikicasa-dev/tailwind-plugins": "0.0.7",
90
+ "@wikicasa-dev/vue-composables": "0.2.0",
91
+ "@wikicasa-dev/eslint-config": "0.0.0"
92
92
  },
93
93
  "readme": "ERROR: No README data found!",
94
94
  "scripts": {