@wikicasa-dev/components 2.2.8-alpha.18 → 2.2.8-alpha.2

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,7 +1,7 @@
1
- import { defineComponent as p, ref as v, computed as h, watch as D, renderSlot as b, createElementVNode as E, normalizeClass as $, createElementBlock as B, createCommentVNode as A, openBlock as g, Fragment as I, renderList as R, createBlock as K, unref as V } from "vue";
2
- import { stringToHyphened as L, isArrNullOrEmpty as G } from "@wikicasa-dev/utilities";
3
- import N from "./CheckboxBtn.vue.js";
4
- const T = ["id", "data-cy"], S = /* @__PURE__ */ p({
1
+ import { defineComponent as x, ref as p, computed as h, watch as v, renderSlot as b, createElementVNode as D, normalizeClass as E, createElementBlock as $, createCommentVNode as B, openBlock as g, Fragment as A, renderList as I, createBlock as R, unref as K } from "vue";
2
+ import { stringToHyphened as V, isArrNullOrEmpty as L } from "@wikicasa-dev/utilities";
3
+ import G from "./CheckboxBtn.vue.js";
4
+ const N = ["id", "data-cy"], O = /* @__PURE__ */ x({
5
5
  inheritAttrs: !1,
6
6
  __name: "CheckboxGroup",
7
7
  props: {
@@ -14,38 +14,36 @@ const T = ["id", "data-cy"], S = /* @__PURE__ */ p({
14
14
  autoCheckResetAll: { type: Boolean, default: !1 },
15
15
  autoCheckResetEmpty: { type: Boolean, default: !1 },
16
16
  manualToggleResetButton: { type: Boolean, default: !1 },
17
- getKey: { type: Function, default: (a) => typeof a == "string" || typeof a == "number" ? `${a}` : `${a.id}` },
17
+ getKey: { type: Function, default: (t) => typeof t == "string" || typeof t == "number" ? `${t}` : `${t.id}` },
18
18
  groupId: { default: "" },
19
19
  dataCy: { default: "" }
20
20
  },
21
21
  emits: ["resetted", "update:modelValue", "checkedGroup"],
22
- setup(a, { emit: C }) {
23
- const o = a, s = C, l = v(
24
- /* @__PURE__ */ new Map()
25
- ), r = h(() => {
22
+ setup(t, { emit: C }) {
23
+ const o = t, s = C, l = p(/* @__PURE__ */ new Map()), r = h(() => {
26
24
  for (const e of o.checkboxData)
27
25
  if (e.reset) return e;
28
26
  return null;
29
27
  }), y = h(() => o.checkboxData.length), f = h(() => {
30
28
  let e = 0;
31
- return l.value.forEach((t) => {
32
- t.checked && e++;
29
+ return l.value.forEach((a) => {
30
+ a.checked && e++;
33
31
  }), e;
34
32
  });
35
33
  (() => {
36
34
  const e = [];
37
- for (const t of o.checkboxData)
38
- l.value.set(`${t.id}`, {
39
- ...t,
40
- checked: !!t.checked
41
- }), t.checked && e.push(t);
35
+ for (const a of o.checkboxData)
36
+ a.checked = !!a.checked, l.value.set(
37
+ `${a.id}`,
38
+ a
39
+ ), a.checked && e.push(a);
42
40
  s("update:modelValue", e);
43
41
  })();
44
- const u = (e, t) => {
42
+ const u = (e, a) => {
45
43
  const c = l.value.get(e);
46
44
  if (c) {
47
- if (t) {
48
- l.value.set(e, { ...c, ...t });
45
+ if (a) {
46
+ l.value.set(e, { ...c, ...a });
49
47
  return;
50
48
  }
51
49
  l.value.set(e, { ...c, checked: !c.checked });
@@ -57,55 +55,55 @@ const T = ["id", "data-cy"], S = /* @__PURE__ */ p({
57
55
  }, m = () => {
58
56
  k(), s("update:modelValue", []), s("resetted");
59
57
  }, d = (e) => l.value.get(o.getKey(e))?.checked ?? !1, i = (e) => {
60
- if (G(o.checkboxData)) return;
61
- const t = l.value.get(e.id);
62
- t?.reset && e.checked ? k() : r.value && !t?.reset && u(o.getKey(r.value), { checked: !1 }), u(`${e.id}`), o.autoCheckResetAll && r.value && f.value === y.value - 1 && l.value.forEach((n) => {
58
+ if (L(o.checkboxData)) return;
59
+ const a = l.value.get(e.id);
60
+ a?.reset && e.checked ? k() : r.value && !a?.reset && u(o.getKey(r.value), { checked: !1 }), u(`${e.id}`), o.autoCheckResetAll && r.value && f.value === y.value - 1 && l.value.forEach((n) => {
63
61
  n.checked = !!n.reset;
64
- }), o.autoCheckResetEmpty && r.value && !f.value && (!o.manualToggleResetButton || !t?.reset) && u(o.getKey(r.value), { checked: !0 });
62
+ }), o.autoCheckResetEmpty && r.value && !f.value && (!o.manualToggleResetButton || !a?.reset) && u(o.getKey(r.value), { checked: !0 });
65
63
  const c = [];
66
64
  l.value.forEach((n) => {
67
65
  n.checked && c.push(n);
68
66
  }), s("update:modelValue", c), s("checkedGroup", o.groupId);
69
67
  };
70
- return D(
68
+ return v(
71
69
  () => o.reset,
72
70
  (e) => {
73
71
  e && m();
74
72
  }
75
- ), (e, t) => b(e.$slots, "default", {
73
+ ), (e, a) => b(e.$slots, "default", {
76
74
  isActive: d,
77
75
  handleChange: i,
78
- checkboxesData: a.checkboxData
76
+ checkboxesData: t.checkboxData
79
77
  }, () => [
80
- E("div", {
81
- id: a.groupId,
82
- class: $(["checkbox-group-container", e.$attrs.class || ""]),
83
- "data-cy": a.dataCy
78
+ D("div", {
79
+ id: t.groupId,
80
+ class: E(["checkbox-group-container", e.$attrs.class || ""]),
81
+ "data-cy": t.dataCy
84
82
  }, [
85
83
  b(e.$slots, "checkbox_elements", {
86
84
  isActive: d,
87
85
  handleChange: i,
88
- checkboxesData: a.checkboxData,
86
+ checkboxesData: t.checkboxData,
89
87
  reset: m
90
88
  }, () => [
91
- a.checkboxData ? (g(!0), B(I, { key: 0 }, R(a.checkboxData, (c, n) => (g(), K(N, {
92
- id: a.getKey(c),
89
+ t.checkboxData ? (g(!0), $(A, { key: 0 }, I(t.checkboxData, (c, n) => (g(), R(G, {
90
+ id: t.getKey(c),
93
91
  key: n,
94
- "data-cy": c.dataCy ?? `checkbox_${V(L)(`${c.label}`)}`,
92
+ "data-cy": c.dataCy ?? `checkbox_${K(V)(`${c.label}`)}`,
95
93
  label: c.label,
96
- inline: a.formCheckInline,
94
+ inline: t.formCheckInline,
97
95
  "model-value": d(c),
98
96
  "container-class": [
99
- a.formCheckInline ? "uikit-mr-10px" : "uikit-mb-10px",
100
- a.checkboxContainerClasses
97
+ t.formCheckInline ? "uikit-mr-10px" : "uikit-mb-10px",
98
+ t.checkboxContainerClasses
101
99
  ],
102
- onChange: t[0] || (t[0] = (x) => i(x))
103
- }, null, 8, ["id", "data-cy", "label", "inline", "model-value", "container-class"]))), 128)) : A("", !0)
100
+ onChange: i
101
+ }, null, 8, ["id", "data-cy", "label", "inline", "model-value", "container-class"]))), 128)) : B("", !0)
104
102
  ])
105
- ], 10, T)
103
+ ], 10, N)
106
104
  ]);
107
105
  }
108
106
  });
109
107
  export {
110
- S as default
108
+ O as default
111
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikicasa-dev/components",
3
- "version": "2.2.8-alpha.18",
3
+ "version": "2.2.8-alpha.2",
4
4
  "description": "Wikicasa frontend components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "vue": "^3.5.0",
45
45
  "date-fns": "^4.0.0",
46
46
  "@wikicasa-dev/svg-icons": "^1.2.24",
47
- "@wikicasa-dev/vue-composables": "^0.0.27",
47
+ "@wikicasa-dev/vue-composables": "^0.0.25",
48
48
  "@wikicasa-dev/types": "^2.4.0",
49
49
  "@wikicasa-dev/utilities": "^1.2.0"
50
50
  },
@@ -64,7 +64,7 @@
64
64
  "@vue/eslint-config-prettier": "^10.2.0",
65
65
  "@vue/eslint-config-typescript": "^14.6.0",
66
66
  "@wikicasa-dev/svg-icons": "1.2.24",
67
- "@wikicasa-dev/vue-composables": "0.0.27",
67
+ "@wikicasa-dev/vue-composables": "0.0.25",
68
68
  "@wikicasa-dev/tailwind-plugins": "^0.0.3",
69
69
  "@wikicasa-dev/types": "2.4.6",
70
70
  "@wikicasa-dev/utilities": "1.2.0",
@@ -1,52 +0,0 @@
1
- import { AccessibleSelectOptions } from '../AccessibleSelect';
2
- import { ClassTypeProp } from '../types';
3
- import { Nullable } from '@wikicasa-dev/types';
4
- export interface ClearableAutocompleteProps<TID extends string | number | undefined, TPayload> {
5
- dataCy?: string;
6
- placeholder?: string;
7
- enableKeyboardController?: boolean;
8
- triggerWrapperClasses?: ClassTypeProp;
9
- inputWrapperClasses?: ClassTypeProp;
10
- inputClasses?: ClassTypeProp;
11
- dropdownClasses?: ClassTypeProp;
12
- clearButton?: {
13
- classes?: ClassTypeProp;
14
- /** Space between the input element and the clear button */
15
- offset?: number;
16
- };
17
- keepState?: Nullable<"closed" | "open">;
18
- onInputChangeCb: (v: string) => Promise<AccessibleSelectOptions<TPayload, TID>[]>;
19
- onOptionSelectedCb?: Nullable<(v: AccessibleSelectOptions<TPayload, TID>) => void>;
20
- }
21
- declare const _default: <TID extends string | number | undefined, TPayload>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
22
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
23
- readonly "onUpdate:modelValue"?: ((value: Nullable<AccessibleSelectOptions<TPayload, TID>>) => any) | undefined;
24
- readonly onClick?: (() => any) | undefined;
25
- readonly onKeydown?: ((args_0: KeyboardEvent) => any) | undefined;
26
- readonly "onUpdate:open"?: ((value: boolean) => any) | undefined;
27
- readonly "onUpdate:inputValue"?: ((args_0: string) => any) | undefined;
28
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:modelValue" | "onClick" | "onKeydown" | "onUpdate:open" | "onUpdate:inputValue"> & ({
29
- open?: boolean;
30
- modelValue?: Nullable<AccessibleSelectOptions<TPayload, TID>>;
31
- } & ClearableAutocompleteProps<TID, TPayload>) & Partial<{}>> & import('vue').PublicProps;
32
- expose(exposed: import('vue').ShallowUnwrapRef<{
33
- select: () => void;
34
- }>): void;
35
- attrs: any;
36
- slots: {
37
- 'left-icon'?(_: {}): any;
38
- 'clear-icon'?(_: {}): any;
39
- 'right-icon'?(_: {}): any;
40
- 'option-content'?(_: {
41
- option: AccessibleSelectOptions<TPayload, TID>;
42
- idx: number;
43
- }): any;
44
- };
45
- emit: (((evt: "click") => void) & ((evt: "keydown", args_0: KeyboardEvent) => void) & ((evt: "update:inputValue", args_0: string) => void)) & (((evt: "update:modelValue", value: Nullable<AccessibleSelectOptions<TPayload, TID>>) => void) & ((evt: "update:open", value: boolean) => void));
46
- }>) => import('vue').VNode & {
47
- __ctx?: Awaited<typeof __VLS_setup>;
48
- };
49
- export default _default;
50
- type __VLS_PrettifyLocal<T> = {
51
- [K in keyof T]: T[K];
52
- } & {};
@@ -1,5 +0,0 @@
1
- import o from "../../packages/components/lib/UIKit/Autocomplete/ClearableAutocomplete.vue.js";
2
- import '../../assets/ClearableAutocomplete.css';/* empty css */
3
- export {
4
- o as default
5
- };
@@ -1 +0,0 @@
1
- .uikit-clearable-autocomplete{--input-padding: 0;--input-margin: 0}.uikit-clearable-autocomplete input{margin:var(--input-margin);padding:var(--input-padding)}.uikit-clearable-autocomplete .uikit-clear-btn{--bg-color: transparent;background-color:var(--bg-color)}
@@ -1,161 +0,0 @@
1
- import { defineComponent as K, mergeModels as T, useModel as B, useTemplateRef as m, shallowRef as s, onBeforeMount as L, watch as b, nextTick as N, createBlock as M, openBlock as c, withCtx as y, createElementBlock as V, Fragment as W, renderList as I, renderSlot as f, createElementVNode as d, normalizeClass as v, withDirectives as A, createCommentVNode as H, vModelText as G, toDisplayString as P, withModifiers as X, normalizeStyle as j, createTextVNode as q } from "vue";
2
- import J from "../BaseDropDown.vue.js";
3
- import '../../../../../assets/BaseDropDown.css';/* empty css */
4
- import Q from "../BaseSelect/SelectItem.vue.js";
5
- import { debounce as Y } from "@wikicasa-dev/utilities";
6
- const Z = ["readonly", "placeholder"], _ = ["innerHTML"], ie = /* @__PURE__ */ K({
7
- __name: "ClearableAutocomplete",
8
- props: /* @__PURE__ */ T({
9
- dataCy: {},
10
- placeholder: {},
11
- enableKeyboardController: { type: Boolean, default: !0 },
12
- triggerWrapperClasses: {},
13
- inputWrapperClasses: {},
14
- inputClasses: {},
15
- dropdownClasses: {},
16
- clearButton: {},
17
- keepState: {},
18
- onInputChangeCb: { type: Function },
19
- onOptionSelectedCb: { type: [Function, null] }
20
- }, {
21
- open: { type: Boolean, default: !1 },
22
- openModifiers: {},
23
- modelValue: { default: null },
24
- modelModifiers: {}
25
- }),
26
- emits: /* @__PURE__ */ T(["click", "update:inputValue", "keydown"], ["update:open", "update:modelValue"]),
27
- setup(l, { expose: $, emit: F }) {
28
- const u = B(l, "open"), a = B(l, "modelValue"), p = F, U = m("inputRef"), n = s(a.value?.label || ""), C = s(0), k = s(!1), w = s(null), i = s([]), O = m("dropdownRef"), h = m("hiddenSpan"), x = () => {
29
- n.value = "", a.value = null, p("update:inputValue", "");
30
- }, E = async (t) => {
31
- if (p("update:inputValue", t), !t) {
32
- i.value = [], u.value = !1;
33
- return;
34
- }
35
- i.value = await w.value?.(t) || [], k.value = !0, u.value = !!i.value.length;
36
- }, g = (t = -1) => {
37
- const e = i.value[t];
38
- !e || e.id === a.value?.id || (l.onOptionSelectedCb?.(e), n.value = e.label, u.value = !1, a.value = e, i.value = []);
39
- }, R = () => {
40
- U.value?.select();
41
- };
42
- return L(() => {
43
- w.value = Y({ delay: 300 }, l.onInputChangeCb);
44
- }), b(
45
- [n, () => h.value],
46
- ([t, e]) => {
47
- e && N(() => {
48
- e && (console.log("DEBUG:updating icon positioning", {
49
- curInputValue: t
50
- }), C.value = e.offsetWidth);
51
- });
52
- },
53
- { immediate: !0 }
54
- ), b(
55
- () => O.value?.selectedIdx,
56
- (t) => {
57
- const e = t ?? -1;
58
- e !== -1 && g(e);
59
- }
60
- ), b(
61
- a,
62
- (t, e) => {
63
- t === e || t?.label === n.value || (n.value = t?.label || "");
64
- },
65
- { immediate: !0 }
66
- ), $({
67
- select: R
68
- }), (t, e) => (c(), M(J, {
69
- ref: "dropdownRef",
70
- class: "uikit-clearable-autocomplete",
71
- "data-cy": l.dataCy,
72
- "dropdown-element": "ul",
73
- "dropdown-classes": ["uikit-z-30", l.dropdownClasses],
74
- "open-dropdown": u.value,
75
- "keep-state": !i.value.length || l.keepState === "closed" ? "closed" : "opened",
76
- "activate-keyboard-controller": l.enableKeyboardController,
77
- "reset-keyboard-controller": k.value,
78
- "onUpdate:resetKeyboardController": e[2] || (e[2] = (o) => k.value = o),
79
- "onUpdate:dropdownState": e[3] || (e[3] = (o) => u.value = o),
80
- onClick: e[4] || (e[4] = (o) => p("click"))
81
- }, {
82
- btn_slot: y(() => [
83
- d("div", {
84
- class: v(["uikit-text-16", l.triggerWrapperClasses])
85
- }, [
86
- f(t.$slots, "left-icon"),
87
- d("div", {
88
- class: v(["uikit-relative", l.inputWrapperClasses])
89
- }, [
90
- A(d("input", {
91
- ref: "inputRef",
92
- "onUpdate:modelValue": [
93
- e[0] || (e[0] = (o) => n.value = o),
94
- E
95
- ],
96
- readonly: !!a.value?.label,
97
- class: v(["uikit-w-full uikit-border-none focus-visible:uikit-outline-none", l.inputClasses]),
98
- style: {
99
- font: "inherit",
100
- fontSize: "inherit"
101
- },
102
- placeholder: l.placeholder,
103
- onKeydown: e[1] || (e[1] = (o) => p("keydown", o))
104
- }, null, 42, Z), [
105
- [G, n.value]
106
- ]),
107
- d("span", {
108
- ref_key: "hiddenSpan",
109
- ref: h,
110
- class: "uikit-invisible uikit-absolute uikit-left-0 uikit-top-0 uikit-whitespace-pre",
111
- style: {
112
- font: "inherit",
113
- fontSize: "inherit"
114
- }
115
- }, P(n.value), 513),
116
- a.value?.label ? (c(), V("button", {
117
- key: 0,
118
- type: "button",
119
- class: v(["uikit-clear-btn uikit-absolute uikit-top-1/2 -uikit-translate-y-1/2 uikit-appearance-none", l.clearButton?.classes]),
120
- "aria-label": "Clear input",
121
- style: j({
122
- left: `${C.value + (l.clearButton?.offset || 10)}px`
123
- }),
124
- onClick: X(x, ["stop"])
125
- }, [
126
- f(t.$slots, "clear-icon", {}, () => [
127
- e[5] || (e[5] = q("X", -1))
128
- ])
129
- ], 6)) : H("", !0)
130
- ], 2),
131
- f(t.$slots, "right-icon")
132
- ], 2)
133
- ]),
134
- default: y(({ activeIdx: o, setActiveIdx: z }) => [
135
- (c(!0), V(W, null, I(i.value, (S, r) => (c(), M(Q, {
136
- key: r,
137
- active: o === r,
138
- class: "uikit-m-1 uikit-rounded-[5px] uikit-px-5 uikit-py-10px hover:uikit-cursor-pointer",
139
- onClick: (D) => g(r),
140
- onMouseover: (D) => z(r)
141
- }, {
142
- default: y(() => [
143
- f(t.$slots, "option-content", {
144
- option: S,
145
- idx: r
146
- }, () => [
147
- d("span", {
148
- innerHTML: S.label
149
- }, null, 8, _)
150
- ])
151
- ]),
152
- _: 2
153
- }, 1032, ["active", "onClick", "onMouseover"]))), 128))
154
- ]),
155
- _: 3
156
- }, 8, ["data-cy", "dropdown-classes", "open-dropdown", "keep-state", "activate-keyboard-controller", "reset-keyboard-controller"]));
157
- }
158
- });
159
- export {
160
- ie as default
161
- };