@bonprix-ds/react-checkbox-group 1.0.2 → 1.0.4

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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,14 @@
1
- import { FC } from 'react';
1
+ import { default as default_2 } from 'react';
2
2
  import { SelectionControlGroupProps } from '@bonprix-ds/internal-components';
3
3
 
4
- declare const CheckboxGroup: FC<CheckboxGroupProps> & Subcomponents;
4
+ declare const CheckboxGroup: {
5
+ (props: CheckboxGroupProps): default_2.JSX.Element;
6
+ displayName: string;
7
+ Item: {
8
+ ({ label, value }: CheckboxGroupItemProps): default_2.JSX.Element;
9
+ displayName: string;
10
+ };
11
+ };
5
12
  export default CheckboxGroup;
6
13
 
7
14
  declare interface CheckboxGroupBaseProps extends Omit<SelectionControlGroupProps, "componentName" | "divider" | "horizontalPadding"> {
@@ -11,8 +18,6 @@ declare interface CheckboxGroupBaseProps extends Omit<SelectionControlGroupProps
11
18
  name: string;
12
19
  }
13
20
 
14
- declare const CheckboxGroupItem: FC<CheckboxGroupItemProps>;
15
-
16
21
  declare interface CheckboxGroupItemProps {
17
22
  /** Value of the checkbox group item, which will be submitted. Defaults to the label if not provided. */
18
23
  value?: string;
@@ -31,10 +36,6 @@ declare interface ControlledCheckboxGroupProps extends CheckboxGroupBaseProps {
31
36
  onChange: (value: string[]) => void;
32
37
  }
33
38
 
34
- declare interface Subcomponents {
35
- Item: typeof CheckboxGroupItem;
36
- }
37
-
38
39
  declare interface UncontrolledCheckboxGroupProps extends CheckboxGroupBaseProps {
39
40
  values?: never;
40
41
  defaultValues: string[];
package/dist/index.js CHANGED
@@ -1,59 +1,2 @@
1
- "use client";
2
- import { CheckboxBase as e, SelectionControlGroup as t } from "@bonprix-ds/internal-components";
3
- import { createContext as n, useContext as r, useId as i } from "react";
4
- import { jsx as a } from "react/jsx-runtime";
5
- //#region src/CheckboxGroupContext.ts
6
- var o = n({
7
- values: [],
8
- name: "",
9
- onChange: () => null,
10
- disabled: !1,
11
- error: !1,
12
- required: !1,
13
- helperTextId: "",
14
- errorTextId: ""
15
- }), s = ({ label: t, value: n = t }) => {
16
- let { values: i, onChange: s, ...c } = r(o), l = i.includes(n), u = () => {
17
- let e = l ? i.filter((e) => e !== n) : [...i, n];
18
- s?.(e);
19
- };
20
- return /* @__PURE__ */ a(e, {
21
- ...c,
22
- checked: l,
23
- onChange: u,
24
- label: t,
25
- value: n
26
- });
27
- }, c = ({ label: e, name: n, values: r, defaultValues: s, children: c, onChange: l, error: u = !1, errorText: d, disabled: f = !1, helperText: p, required: m = !1 }) => {
28
- let h = {
29
- values: r === void 0 ? s : r,
30
- name: n,
31
- onChange: l,
32
- disabled: f,
33
- error: u,
34
- required: m,
35
- helperTextId: i(),
36
- errorTextId: i()
37
- };
38
- return /* @__PURE__ */ a(t, {
39
- label: e,
40
- error: u,
41
- errorText: d,
42
- disabled: f,
43
- helperText: p,
44
- required: m,
45
- componentName: "checkbox-group",
46
- children: /* @__PURE__ */ a("div", {
47
- className: "preflight flex flex-wrap flex-col",
48
- children: /* @__PURE__ */ a(o.Provider, {
49
- value: h,
50
- children: c
51
- })
52
- })
53
- });
54
- };
55
- c.displayName = "CheckboxGroup", c.Item = s, c.Item.displayName = "CheckboxGroup.Item";
56
- //#endregion
57
- export { c as default };
58
-
59
- //# sourceMappingURL=index.js.map
1
+ import e from "./src/CheckboxGroup.js";
2
+ export { e as default };
@@ -0,0 +1,11 @@
1
+ import e from "./CheckboxGroupItem/index.js";
2
+ import t from "./CheckboxGroupRoot.js";
3
+ import "react";
4
+ import { jsx as n } from "react/jsx-runtime";
5
+ //#region src/CheckboxGroup.tsx
6
+ var r = (e) => /* @__PURE__ */ n(t, { ...e });
7
+ r.displayName = "CheckboxGroup", r.Item = e;
8
+ //#endregion
9
+ export { r as default };
10
+
11
+ //# sourceMappingURL=CheckboxGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxGroup.js","names":[],"sources":["../../src/CheckboxGroup.tsx"],"sourcesContent":["import React from \"react\";\n\nimport CheckboxGroupItem from \"./CheckboxGroupItem\";\nimport CheckboxGroupRoot, { type Props } from \"./CheckboxGroupRoot\";\n\nexport type { Props };\n\nconst CheckboxGroup = (props: Props) => <CheckboxGroupRoot {...props} />;\n\nCheckboxGroup.displayName = \"CheckboxGroup\";\n\nCheckboxGroup.Item = CheckboxGroupItem;\n\nexport default CheckboxGroup;\n"],"mappings":";;;;;AAOA,IAAM,KAAiB,MAAiB,kBAAC,GAAD,EAAmB,GAAI,EAAQ,CAAA;AAEvE,EAAc,cAAc,iBAE5B,EAAc,OAAO"}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { createContext as e } from "react";
3
+ //#region src/CheckboxGroupContext.ts
4
+ var t = e({
5
+ values: [],
6
+ name: "",
7
+ onChange: () => null,
8
+ disabled: !1,
9
+ error: !1,
10
+ required: !1,
11
+ helperTextId: "",
12
+ errorTextId: ""
13
+ });
14
+ //#endregion
15
+ export { t as default };
16
+
17
+ //# sourceMappingURL=CheckboxGroupContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxGroupContext.js","names":[],"sources":["../../src/CheckboxGroupContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\ninterface CheckboxGroupContextProps {\n values: string[];\n name: string;\n onChange?: (value: string[]) => void;\n disabled: boolean;\n error: boolean;\n required: boolean;\n helperTextId: string;\n errorTextId: string;\n}\n\nconst CheckboxGroupContext = createContext<CheckboxGroupContextProps>({\n values: [],\n name: \"\",\n onChange: () => null,\n disabled: false,\n error: false,\n required: false,\n helperTextId: \"\",\n errorTextId: \"\",\n});\n\nexport default CheckboxGroupContext;\n"],"mappings":";;;AAeA,IAAM,IAAuB,EAAyC;CACpE,QAAQ,CAAC;CACT,MAAM;CACN,gBAAgB;CAChB,UAAU;CACV,OAAO;CACP,UAAU;CACV,cAAc;CACd,aAAa;AACf,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import e from "../CheckboxGroupContext.js";
3
+ import { useContext as t } from "react";
4
+ import { CheckboxBase as n } from "@bonprix-ds/internal-components";
5
+ import { jsx as r } from "react/jsx-runtime";
6
+ //#region src/CheckboxGroupItem/CheckboxGroupItem.tsx
7
+ var i = ({ label: i, value: a = i }) => {
8
+ let { values: o, onChange: s, ...c } = t(e), l = o.includes(a), u = () => {
9
+ let e = l ? o.filter((e) => e !== a) : [...o, a];
10
+ s?.(e);
11
+ };
12
+ return /* @__PURE__ */ r(n, {
13
+ ...c,
14
+ checked: l,
15
+ onChange: u,
16
+ label: i,
17
+ value: a
18
+ });
19
+ };
20
+ i.displayName = "CheckboxGroup.Item";
21
+ //#endregion
22
+ export { i as default };
23
+
24
+ //# sourceMappingURL=CheckboxGroupItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxGroupItem.js","names":[],"sources":["../../../src/CheckboxGroupItem/CheckboxGroupItem.tsx"],"sourcesContent":["\"use client\";\n\nimport { CheckboxBase } from \"@bonprix-ds/internal-components\";\nimport React, { useContext } from \"react\";\n\nimport CheckboxGroupContext from \"../CheckboxGroupContext\";\n\nexport interface CheckboxGroupItemProps {\n /** Value of the checkbox group item, which will be submitted. Defaults to the label if not provided. */\n value?: string;\n /** The label for the checkbox group item. */\n label: string;\n}\n\nconst CheckboxGroupItem = ({ label, value = label }: CheckboxGroupItemProps) => {\n const { values, onChange, ...rest } = useContext(CheckboxGroupContext);\n const checked = values.includes(value);\n\n const handleChange = () => {\n const newValues = checked ? values.filter((v) => v !== value) : [...values, value];\n onChange?.(newValues);\n };\n\n return <CheckboxBase {...rest} checked={checked} onChange={handleChange} label={label} value={value} />;\n};\n\nCheckboxGroupItem.displayName = \"CheckboxGroup.Item\";\n\nexport default CheckboxGroupItem;\n"],"mappings":";;;;;;AAcA,IAAM,KAAqB,EAAE,UAAO,WAAQ,QAAoC;CAC9E,IAAM,EAAE,WAAQ,aAAU,GAAG,MAAS,EAAW,CAAoB,GAC/D,IAAU,EAAO,SAAS,CAAK,GAE/B,UAAqB;EACzB,IAAM,IAAY,IAAU,EAAO,QAAQ,MAAM,MAAM,CAAK,IAAI,CAAC,GAAG,GAAQ,CAAK;EACjF,IAAW,CAAS;CACtB;CAEA,OAAO,kBAAC,GAAD;EAAc,GAAI;EAAe;EAAS,UAAU;EAAqB;EAAc;CAAQ,CAAA;AACxG;AAEA,EAAkB,cAAc"}
@@ -0,0 +1,7 @@
1
+ import e from "./CheckboxGroupItem.js";
2
+ //#region src/CheckboxGroupItem/index.ts
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/CheckboxGroupItem/index.ts"],"sourcesContent":["import CheckboxGroupItem from \"./CheckboxGroupItem\";\n\nexport default CheckboxGroupItem;\n"],"mappings":";;AAEA,IAAA,IAAe"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import e from "./CheckboxGroupContext.js";
3
+ import { useId as t } from "react";
4
+ import { SelectionControlGroup as n } from "@bonprix-ds/internal-components";
5
+ import { jsx as r } from "react/jsx-runtime";
6
+ //#region src/CheckboxGroupRoot.tsx
7
+ var i = ({ label: i, name: a, values: o, defaultValues: s, children: c, onChange: l, error: u = !1, errorText: d, disabled: f = !1, helperText: p, required: m = !1 }) => {
8
+ let h = {
9
+ values: o === void 0 ? s : o,
10
+ name: a,
11
+ onChange: l,
12
+ disabled: f,
13
+ error: u,
14
+ required: m,
15
+ helperTextId: t(),
16
+ errorTextId: t()
17
+ };
18
+ return /* @__PURE__ */ r(n, {
19
+ label: i,
20
+ error: u,
21
+ errorText: d,
22
+ disabled: f,
23
+ helperText: p,
24
+ required: m,
25
+ componentName: "checkbox-group",
26
+ children: /* @__PURE__ */ r("div", {
27
+ className: "preflight flex flex-wrap flex-col",
28
+ children: /* @__PURE__ */ r(e.Provider, {
29
+ value: h,
30
+ children: c
31
+ })
32
+ })
33
+ });
34
+ };
35
+ i.displayName = "CheckboxGroup";
36
+ //#endregion
37
+ export { i as default };
38
+
39
+ //# sourceMappingURL=CheckboxGroupRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxGroupRoot.js","names":[],"sources":["../../src/CheckboxGroupRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { SelectionControlGroup, SelectionControlGroupProps } from \"@bonprix-ds/internal-components\";\nimport React, { useId } from \"react\";\n\nimport CheckboxGroupContext from \"./CheckboxGroupContext\";\n\ninterface CheckboxGroupBaseProps extends Omit<SelectionControlGroupProps, \"componentName\" | \"divider\" | \"horizontalPadding\"> {\n /** The caption for the checkbox group. */\n label: string;\n /** The name of the checkbox group. Will be used as the `name` attribute for every item. */\n name: string;\n}\n\ninterface ControlledCheckboxGroupProps extends CheckboxGroupBaseProps {\n /** The current values of the checkbox group. Should be used in conjunction with `onChange`, when controlling the values. Should be `undefined` otherwise. */\n values: string[];\n /** The default values of the checkbox group. Should be used when the checkbox group is uncontrolled. */\n defaultValues?: never;\n /** Callback function that is called when the checkbox group state changes. `values` should be adjusted appropriately. */\n onChange: (value: string[]) => void;\n}\n\ninterface UncontrolledCheckboxGroupProps extends CheckboxGroupBaseProps {\n values?: never;\n defaultValues: string[];\n onChange?: (value: string[]) => void;\n}\n\nexport type Props = ControlledCheckboxGroupProps | UncontrolledCheckboxGroupProps;\n\nconst CheckboxGroupRoot = ({\n label,\n name,\n values: controlledValues,\n defaultValues,\n children,\n onChange,\n error = false,\n errorText,\n disabled = false,\n helperText,\n required = false,\n}: Props) => {\n const isControlled = controlledValues !== undefined;\n const values = isControlled ? controlledValues : defaultValues;\n const helperTextId = useId();\n const errorTextId = useId();\n const contextProps = { values, name, onChange, disabled, error, required, helperTextId, errorTextId };\n\n return (\n <SelectionControlGroup\n label={label}\n error={error}\n errorText={errorText}\n disabled={disabled}\n helperText={helperText}\n required={required}\n componentName=\"checkbox-group\"\n >\n <div className=\"preflight flex flex-wrap flex-col\">\n <CheckboxGroupContext.Provider value={contextProps}>{children}</CheckboxGroupContext.Provider>\n </div>\n </SelectionControlGroup>\n );\n};\n\nCheckboxGroupRoot.displayName = \"CheckboxGroup\";\n\nexport default CheckboxGroupRoot;\n"],"mappings":";;;;;;AA+BA,IAAM,KAAqB,EACzB,UACA,SACA,QAAQ,GACR,kBACA,aACA,aACA,WAAQ,IACR,cACA,cAAW,IACX,eACA,cAAW,SACA;CAKX,IAAM,IAAe;EAAE,QAJF,MAAqB,KAAA,IACO,IAAnB;EAGC;EAAM;EAAU;EAAU;EAAO;EAAU,cAFrD,EAEqD;EAAc,aADpE,EACoE;CAAY;CAEpG,OACE,kBAAC,GAAD;EACS;EACA;EACI;EACD;EACE;EACF;EACV,eAAc;EAEd,UAAA,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAAC,EAAqB,UAAtB;IAA+B,OAAO;IAAe;GAAwC,CAAA;EAC1F,CAAA;CACgB,CAAA;AAE3B;AAEA,EAAkB,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-checkbox-group",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "CheckboxGroup component, implemented in React, for the Bonprix Design System.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -29,8 +29,8 @@
29
29
  "directory": "packages/react/checkbox-group"
30
30
  },
31
31
  "dependencies": {
32
- "@bonprix-ds/internal-components": "0.1.1",
33
- "@bonprix-ds/utils": "0.1.2"
32
+ "@bonprix-ds/internal-components": "0.1.3",
33
+ "@bonprix-ds/utils": "0.2.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^19.0.0",
@@ -38,7 +38,7 @@
38
38
  "tailwind-variants": "0.3.1"
39
39
  },
40
40
  "devDependencies": {
41
- "vite": "8.2.0",
41
+ "vite": "8.2.1",
42
42
  "@types/react": "19.2.18",
43
43
  "@vitejs/plugin-react": "6.0.5",
44
44
  "rollup-preserve-directives": "1.1.3",
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/CheckboxGroupContext.ts","../src/CheckboxGroupItem/CheckboxGroupItem.tsx","../src/CheckboxGroupItem/index.ts","../src/CheckboxGroup.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\ninterface CheckboxGroupContextProps {\n values: string[];\n name: string;\n onChange?: (value: string[]) => void;\n disabled: boolean;\n error: boolean;\n required: boolean;\n helperTextId: string;\n errorTextId: string;\n}\n\nconst CheckboxGroupContext = createContext<CheckboxGroupContextProps>({\n values: [],\n name: \"\",\n onChange: () => null,\n disabled: false,\n error: false,\n required: false,\n helperTextId: \"\",\n errorTextId: \"\",\n});\n\nexport default CheckboxGroupContext;\n","\"use client\";\n\nimport { CheckboxBase } from \"@bonprix-ds/internal-components\";\nimport React, { FC, useContext } from \"react\";\n\nimport CheckboxGroupContext from \"../CheckboxGroupContext\";\n\ninterface CheckboxGroupItemProps {\n /** Value of the checkbox group item, which will be submitted. Defaults to the label if not provided. */\n value?: string;\n /** The label for the checkbox group item. */\n label: string;\n}\n\nconst CheckboxGroupItem: FC<CheckboxGroupItemProps> = ({ label, value = label }) => {\n const { values, onChange, ...rest } = useContext(CheckboxGroupContext);\n const checked = values.includes(value);\n\n const handleChange = () => {\n const newValues = checked ? values.filter((v) => v !== value) : [...values, value];\n onChange?.(newValues);\n };\n\n return <CheckboxBase {...rest} checked={checked} onChange={handleChange} label={label} value={value} />;\n};\n\nexport default CheckboxGroupItem;\n","import CheckboxGroupItem from \"./CheckboxGroupItem\";\n\nexport default CheckboxGroupItem;\n","\"use client\";\n\nimport { SelectionControlGroup, SelectionControlGroupProps } from \"@bonprix-ds/internal-components\";\nimport React, { FC, useId } from \"react\";\n\nimport CheckboxGroupContext from \"./CheckboxGroupContext\";\nimport CheckboxGroupItem from \"./CheckboxGroupItem\";\n\ninterface Subcomponents {\n Item: typeof CheckboxGroupItem;\n}\n\ninterface CheckboxGroupBaseProps extends Omit<SelectionControlGroupProps, \"componentName\" | \"divider\" | \"horizontalPadding\"> {\n /** The caption for the checkbox group. */\n label: string;\n /** The name of the checkbox group. Will be used as the `name` attribute for every item. */\n name: string;\n}\n\ninterface ControlledCheckboxGroupProps extends CheckboxGroupBaseProps {\n /** The current values of the checkbox group. Should be used in conjunction with `onChange`, when controlling the values. Should be `undefined` otherwise. */\n values: string[];\n /** The default values of the checkbox group. Should be used when the checkbox group is uncontrolled. */\n defaultValues?: never;\n /** Callback function that is called when the checkbox group state changes. `values` should be adjusted appropriately. */\n onChange: (value: string[]) => void;\n}\n\ninterface UncontrolledCheckboxGroupProps extends CheckboxGroupBaseProps {\n values?: never;\n defaultValues: string[];\n onChange?: (value: string[]) => void;\n}\n\nexport type Props = ControlledCheckboxGroupProps | UncontrolledCheckboxGroupProps;\n\nconst CheckboxGroup: FC<Props> & Subcomponents = ({\n label,\n name,\n values: controlledValues,\n defaultValues,\n children,\n onChange,\n error = false,\n errorText,\n disabled = false,\n helperText,\n required = false,\n}) => {\n const isControlled = controlledValues !== undefined;\n const values = isControlled ? controlledValues : defaultValues;\n const helperTextId = useId();\n const errorTextId = useId();\n const contextProps = { values, name, onChange, disabled, error, required, helperTextId, errorTextId };\n\n return (\n <SelectionControlGroup\n label={label}\n error={error}\n errorText={errorText}\n disabled={disabled}\n helperText={helperText}\n required={required}\n componentName=\"checkbox-group\"\n >\n <div className=\"preflight flex flex-wrap flex-col\">\n <CheckboxGroupContext.Provider value={contextProps}>{children}</CheckboxGroupContext.Provider>\n </div>\n </SelectionControlGroup>\n );\n};\n\nCheckboxGroup.displayName = \"CheckboxGroup\";\n\nCheckboxGroup.Item = CheckboxGroupItem;\nCheckboxGroup.Item.displayName = \"CheckboxGroup.Item\";\n\nexport default CheckboxGroup;\n"],"mappings":";;;;;AAeA,IAAM,IAAuB,EAAyC;CACpE,QAAQ,CAAC;CACT,MAAM;CACN,gBAAgB;CAChB,UAAU;CACV,OAAO;CACP,UAAU;CACV,cAAc;CACd,aAAa;AACf,CAAC,GEtBD,KDYuD,EAAE,UAAO,WAAQ,QAAY;CAClF,IAAM,EAAE,WAAQ,aAAU,GAAG,MAAS,EAAW,CAAoB,GAC/D,IAAU,EAAO,SAAS,CAAK,GAE/B,UAAqB;EACzB,IAAM,IAAY,IAAU,EAAO,QAAQ,MAAM,MAAM,CAAK,IAAI,CAAC,GAAG,GAAQ,CAAK;EACjF,IAAW,CAAS;CACtB;CAEA,OAAO,kBAAC,GAAD;EAAc,GAAI;EAAe;EAAS,UAAU;EAAqB;EAAc;CAAQ,CAAA;AACxG,GEYM,KAA4C,EAChD,UACA,SACA,QAAQ,GACR,kBACA,aACA,aACA,WAAQ,IACR,cACA,cAAW,IACX,eACA,cAAW,SACP;CAKJ,IAAM,IAAe;EAAE,QAJF,MAAqB,KAAA,IACO,IAAnB;EAGC;EAAM;EAAU;EAAU;EAAO;EAAU,cAFrD,EAEqD;EAAc,aADpE,EACoE;CAAY;CAEpG,OACE,kBAAC,GAAD;EACS;EACA;EACI;EACD;EACE;EACF;EACV,eAAc;EAEd,UAAA,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAAC,EAAqB,UAAtB;IAA+B,OAAO;IAAe;GAAwC,CAAA;EAC1F,CAAA;CACgB,CAAA;AAE3B;AAEA,EAAc,cAAc,iBAE5B,EAAc,OAAO,GACrB,EAAc,KAAK,cAAc"}