@wikicasa-dev/components 1.9.20 → 1.9.22

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,4 +1,4 @@
1
- import { _ as f } from "./chunks/CheckboxGroup.vue_vue_type_script_setup_true_lang.hSeL05pn.js";
1
+ import { _ as f } from "./chunks/CheckboxGroup.vue_vue_type_script_setup_true_lang.ClVBkga-.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,19 +1,20 @@
1
1
  import { CheckboxButtonType, GetterIdType } from '@wikicasa-dev/types';
2
2
 
3
+ type CheckboxGroupData<T extends string | number = string> = Record<T, CheckboxButtonType>;
3
4
  declare function __VLS_template(): {
4
5
  default?(_: {
5
6
  isActive: (elem: CheckboxButtonType) => boolean;
6
7
  handleChange: (checkboxValue: CheckboxButtonType) => void;
7
- checkboxesData: Record<string, CheckboxButtonType>;
8
+ checkboxesData: CheckboxGroupData<string>;
8
9
  }): any;
9
10
  checkbox_elements?(_: {
10
11
  isActive: (elem: CheckboxButtonType) => boolean;
11
12
  handleChange: (checkboxValue: CheckboxButtonType) => void;
12
- checkboxesData: Record<string, CheckboxButtonType>;
13
+ checkboxesData: CheckboxGroupData<string>;
13
14
  }): any;
14
15
  };
15
16
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
16
- valuesObj?: Record<string, CheckboxButtonType>;
17
+ valuesObj?: CheckboxGroupData;
17
18
  formCheckInline?: boolean;
18
19
  customClass?: string;
19
20
  reset?: boolean;
@@ -32,13 +33,13 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
32
33
  autoCheckResetAll: boolean;
33
34
  autoCheckResetEmpty: boolean;
34
35
  manualToggleResetButton: boolean;
35
- getKey(): (checkBtn: CheckboxButtonType) => string | number;
36
+ getKey(): (checkBtn: CheckboxButtonType | string | number) => string | number;
36
37
  }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
37
38
  "update:modelValue": (args_0: CheckboxButtonType[]) => void;
38
39
  resetted: () => void;
39
40
  checkedGroup: (args_0: string) => void;
40
41
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
41
- valuesObj?: Record<string, CheckboxButtonType>;
42
+ valuesObj?: CheckboxGroupData;
42
43
  formCheckInline?: boolean;
43
44
  customClass?: string;
44
45
  reset?: boolean;
@@ -57,14 +58,14 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
57
58
  autoCheckResetAll: boolean;
58
59
  autoCheckResetEmpty: boolean;
59
60
  manualToggleResetButton: boolean;
60
- getKey(): (checkBtn: CheckboxButtonType) => string | number;
61
+ getKey(): (checkBtn: CheckboxButtonType | string | number) => string | number;
61
62
  }>>> & Readonly<{
62
63
  "onUpdate:modelValue"?: ((args_0: CheckboxButtonType[]) => any) | undefined;
63
64
  onResetted?: (() => any) | undefined;
64
65
  onCheckedGroup?: ((args_0: string) => any) | undefined;
65
66
  }>, {
66
67
  reset: boolean;
67
- valuesObj: Record<string, CheckboxButtonType>;
68
+ valuesObj: CheckboxGroupData;
68
69
  formCheckInline: boolean;
69
70
  customClass: string;
70
71
  autoCheckResetAll: boolean;
@@ -0,0 +1,98 @@
1
+ import { defineComponent as y, useAttrs as C, ref as j, computed as i, watch as O, renderSlot as p, createElementVNode as B, normalizeClass as E, openBlock as m, createElementBlock as $, Fragment as R, renderList as w, createBlock as A, unref as K, createCommentVNode as L } from "vue";
2
+ import "./types-B0dZ7OiV.D29wNgoj.js";
3
+ import { s as G } from "./ObjectUtils.BOUbloeg.js";
4
+ import D from "../CheckboxBtn.js";
5
+ const I = (l = "") => !l || !l.trim() ? "" : (l = l.trim(), l.replace(" ", "-").toLowerCase()), M = ["id", "data-cy"], q = /* @__PURE__ */ y({
6
+ inheritAttrs: !1,
7
+ __name: "CheckboxGroup",
8
+ props: {
9
+ valuesObj: { default() {
10
+ return {};
11
+ } },
12
+ formCheckInline: { type: Boolean, default: !1 },
13
+ customClass: { default: "" },
14
+ reset: { type: Boolean, default: !1 },
15
+ autoCheckResetAll: { type: Boolean, default: !1 },
16
+ autoCheckResetEmpty: { type: Boolean, default: !1 },
17
+ manualToggleResetButton: { type: Boolean, default: !1 },
18
+ getKey: { default() {
19
+ return (l) => typeof l == "string" || typeof l == "number" ? l : l.id;
20
+ } }
21
+ },
22
+ emits: ["resetted", "update:modelValue", "checkedGroup"],
23
+ setup(l, { emit: k }) {
24
+ const v = C(), t = l, n = k, r = j(/* @__PURE__ */ new Map()), o = i(() => {
25
+ for (const e in t.valuesObj) {
26
+ const a = t.valuesObj[e];
27
+ if (a.reset) return a;
28
+ }
29
+ return null;
30
+ }), b = i(
31
+ () => Object.keys(t.valuesObj).length
32
+ ), f = i(() => {
33
+ let e = 0;
34
+ return r.value.forEach((a) => {
35
+ a.checked && e++;
36
+ }), e;
37
+ });
38
+ O(
39
+ () => t.reset,
40
+ (e) => {
41
+ e && (h(), n("update:modelValue", []), n("resetted"));
42
+ }
43
+ ), (() => {
44
+ for (const e in t.valuesObj) {
45
+ const a = t.valuesObj[e];
46
+ a.checked = !!a.checked, r.value.set(e, a);
47
+ }
48
+ })();
49
+ const c = (e, a) => {
50
+ const s = r.value.get(e);
51
+ s && r.value.set(e, { ...s, ...a });
52
+ }, h = () => {
53
+ r.value.forEach((e) => {
54
+ e.checked = !1;
55
+ });
56
+ }, u = (e) => r.value.get(t.getKey(e))?.checked ?? !1, d = (e) => {
57
+ if (!t.valuesObj || G(t.valuesObj)) return;
58
+ t.valuesObj[e.id].reset && e.checked ? h() : o.value && !t.valuesObj[e.id].reset && c(t.getKey(o.value), { checked: !1 }), c(e.id, { checked: !!e.checked }), t.autoCheckResetAll && o.value && f.value === b.value - 1 && r.value.forEach((s) => {
59
+ s.checked = !!s.reset;
60
+ }), t.autoCheckResetEmpty && o.value && !f.value && (!t.manualToggleResetButton || !t.valuesObj[e.id].reset) && c(t.getKey(o.value), { checked: !0 });
61
+ const a = [];
62
+ r.value.forEach((s) => {
63
+ s.checked && a.push(s);
64
+ }), n("update:modelValue", a), n("checkedGroup", v["group-id"] || "");
65
+ };
66
+ return (e, a) => p(e.$slots, "default", {
67
+ isActive: u,
68
+ handleChange: d,
69
+ checkboxesData: e.valuesObj
70
+ }, () => [
71
+ B("div", {
72
+ id: e.$attrs["group-id"] || "",
73
+ class: E(["checkbox-group-container", e.$attrs.class || ""]),
74
+ "data-cy": e.$attrs["data-cy"] || ""
75
+ }, [
76
+ p(e.$slots, "checkbox_elements", {
77
+ isActive: u,
78
+ handleChange: d,
79
+ checkboxesData: e.valuesObj
80
+ }, () => [
81
+ e.valuesObj ? (m(!0), $(R, { key: 0 }, w(e.valuesObj, (s, T, g) => (m(), A(D, {
82
+ id: e.getKey(s),
83
+ key: g,
84
+ "data-cy": `checkbox_${K(I)(`${s.label}`)}`,
85
+ label: s.label,
86
+ inline: e.formCheckInline,
87
+ "wrapper-margin-y": e.$attrs["checkbox-padding-y"],
88
+ "model-value": u(s),
89
+ onChange: d
90
+ }, null, 8, ["id", "data-cy", "label", "inline", "wrapper-margin-y", "model-value"]))), 128)) : L("", !0)
91
+ ])
92
+ ], 10, M)
93
+ ]);
94
+ }
95
+ });
96
+ export {
97
+ q as _
98
+ };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { _ as f } from "./chunks/BaseAccordionContent.vue_vue_type_script_setup_
4
4
  import { _ as m } from "./chunks/BaseAccordionItem.vue_vue_type_script_setup_true_lang.CR-nWss7.js";
5
5
  import { _ as l } from "./chunks/SelectItem.vue_vue_type_script_setup_true_lang.GPFf7fjA.js";
6
6
  import { default as d } from "./CheckboxBtn.js";
7
- import { _ as i } from "./chunks/CheckboxGroup.vue_vue_type_script_setup_true_lang.hSeL05pn.js";
7
+ import { _ as i } from "./chunks/CheckboxGroup.vue_vue_type_script_setup_true_lang.ClVBkga-.js";
8
8
  import { _ } from "./chunks/BaseTab.vue_vue_type_script_setup_true_lang.Cu67jd8K.js";
9
9
  import { _ as S } from "./chunks/BaseTabView.vue_vue_type_script_setup_true_lang.RbxW2M0Y.js";
10
10
  import { _ as g } from "./chunks/RadioButton.vue_vue_type_script_setup_true_lang.DR6a7QAi.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikicasa-dev/components",
3
- "version": "1.9.20",
3
+ "version": "1.9.22",
4
4
  "description": "Wikicasa frontend components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,99 +0,0 @@
1
- import { defineComponent as O, useAttrs as v, reactive as g, computed as d, watch as y, onBeforeMount as C, renderSlot as k, createElementVNode as V, normalizeClass as B, openBlock as b, createElementBlock as $, Fragment as R, renderList as A, createBlock as K, unref as w, createCommentVNode as E } from "vue";
2
- import "./types-B0dZ7OiV.D29wNgoj.js";
3
- import { s as L } from "./ObjectUtils.BOUbloeg.js";
4
- import G from "../CheckboxBtn.js";
5
- const D = (l = "") => !l || !l.trim() ? "" : (l = l.trim(), l.replace(" ", "-").toLowerCase()), I = ["id", "data-cy"], S = /* @__PURE__ */ O({
6
- inheritAttrs: !1,
7
- __name: "CheckboxGroup",
8
- props: {
9
- valuesObj: { default() {
10
- return {};
11
- } },
12
- formCheckInline: { type: Boolean, default: !1 },
13
- customClass: { default: "" },
14
- reset: { type: Boolean, default: !1 },
15
- autoCheckResetAll: { type: Boolean, default: !1 },
16
- autoCheckResetEmpty: { type: Boolean, default: !1 },
17
- manualToggleResetButton: { type: Boolean, default: !1 },
18
- getKey: { default() {
19
- return (l) => l.id;
20
- } }
21
- },
22
- emits: ["resetted", "update:modelValue", "checkedGroup"],
23
- setup(l, { emit: f }) {
24
- const m = v(), t = l, o = f, s = g({
25
- checkedValuesObj: {}
26
- }), c = d(() => {
27
- for (const e in t.valuesObj) {
28
- const a = t.valuesObj[e];
29
- if (a.reset) return a;
30
- }
31
- return null;
32
- }), p = d(
33
- () => Object.keys(t.valuesObj).length
34
- ), h = d(
35
- () => Object.values(s.checkedValuesObj).reduce(
36
- (e, a) => a.checked ? e + 1 : e,
37
- 0
38
- )
39
- );
40
- y(
41
- () => t.reset,
42
- (e) => {
43
- e && (i(), o("update:modelValue", []), o("resetted"));
44
- }
45
- ), C(() => {
46
- for (const e in t.valuesObj) {
47
- const a = t.valuesObj[e];
48
- a.checked = !!a.checked, s.checkedValuesObj[e] = a;
49
- }
50
- });
51
- const i = () => {
52
- for (const e in s.checkedValuesObj)
53
- s.checkedValuesObj[e].checked = !1;
54
- }, n = (e) => s.checkedValuesObj[t.getKey(e)].checked, u = (e) => {
55
- if (!(!t.valuesObj || L(t.valuesObj))) {
56
- if (t.valuesObj[e.id].reset && e.checked ? i() : c.value && !t.valuesObj[e.id].reset && (s.checkedValuesObj[t.getKey(c.value)].checked = !1), s.checkedValuesObj[e.id].checked = !!e.checked, t.autoCheckResetAll && c.value && h.value === p.value - 1)
57
- for (const a in s.checkedValuesObj)
58
- s.checkedValuesObj[a].checked = !!s.checkedValuesObj[a].reset;
59
- t.autoCheckResetEmpty && c.value && !h.value && (!t.manualToggleResetButton || !t.valuesObj[e.id].reset) && (s.checkedValuesObj[t.getKey(c.value)].checked = !0), o(
60
- "update:modelValue",
61
- Object.values(s.checkedValuesObj).filter(
62
- (a) => a.checked
63
- )
64
- ), o("checkedGroup", m["group-id"] || "");
65
- }
66
- };
67
- return (e, a) => k(e.$slots, "default", {
68
- isActive: n,
69
- handleChange: u,
70
- checkboxesData: e.valuesObj
71
- }, () => [
72
- V("div", {
73
- id: e.$attrs["group-id"] || "",
74
- class: B(["checkbox-group-container", e.$attrs.class || ""]),
75
- "data-cy": e.$attrs["data-cy"] || ""
76
- }, [
77
- k(e.$slots, "checkbox_elements", {
78
- isActive: n,
79
- handleChange: u,
80
- checkboxesData: e.valuesObj
81
- }, () => [
82
- e.valuesObj ? (b(!0), $(R, { key: 0 }, A(e.valuesObj, (r, N, j) => (b(), K(G, {
83
- id: e.getKey(r),
84
- key: j,
85
- "data-cy": `checkbox_${w(D)(`${r.label}`)}`,
86
- label: r.label,
87
- inline: e.formCheckInline,
88
- "wrapper-margin-y": e.$attrs["checkbox-padding-y"],
89
- "model-value": n(r),
90
- onChange: u
91
- }, null, 8, ["id", "data-cy", "label", "inline", "wrapper-margin-y", "model-value"]))), 128)) : E("", !0)
92
- ])
93
- ], 10, I)
94
- ]);
95
- }
96
- });
97
- export {
98
- S as _
99
- };