@wikicasa-dev/components 2.2.9-alpha.11 → 2.2.9-alpha.13

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