@bonprix-ds/react-radio-group 1.0.6 → 1.0.8

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,39 +1,2 @@
1
- import { ControlGroupProps } from '@bonprix-ds/utils';
2
- import { default as default_2 } from 'react';
3
- import { ReactNode } from 'react';
4
-
5
- declare interface ControlledInputProps extends Omit<ControlGroupProps, "componentName"> {
6
- value: string;
7
- onChange: (value: string) => void;
8
- }
9
-
10
- declare const RadioGroup: {
11
- (props: RadioGroupProps): default_2.JSX.Element;
12
- displayName: string;
13
- Item: {
14
- ({ value, label, additional, suffix }: RadioGroupItemProps): default_2.JSX.Element;
15
- displayName: string;
16
- };
17
- };
18
- export default RadioGroup;
19
-
20
- declare interface RadioGroupItemProps {
21
- /** The value of the radio button. */
22
- value: string;
23
- /** The label of the radio button. */
24
- label: ReactNode;
25
- /** Suffix that will be placed on the far right side inside the `<label>` to further visualize the item's value, e.g. with icon(s) or logo(s). Make sure to only include allowed children here to avoid irregular HTML markup. */
26
- suffix?: ReactNode;
27
- /** Additional content to be displayed when item is selected. */
28
- additional?: ReactNode;
29
- }
30
-
31
- export declare type RadioGroupProps = ControlledInputProps | UncontrolledInputProps;
32
-
33
- declare interface UncontrolledInputProps extends Omit<ControlGroupProps, "componentName"> {
34
- value?: never;
35
- defaultValue: string;
36
- onChange?: (value: string) => void;
37
- }
38
-
39
- export { }
1
+ export { default } from "./src/RadioGroup";
2
+ export type { Props as RadioGroupProps } from "./src/RadioGroup";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from "./src/RadioGroup2.js";
1
+ import e from "./src/RadioGroup.js";
2
2
  export { e as default };
@@ -0,0 +1,14 @@
1
+ [data-bpds-has-divider="true"] {
2
+ [role="radiogroup"] [data-bpds-radio-group-item]:not(:last-child)::after {
3
+ background-color: var(--bpds-color-bg-main-light);
4
+ block-size: var(--bpds-spacing-0-25);
5
+ content: "";
6
+ display: block;
7
+ margin-block: var(--bpds-spacing-0-5);
8
+ margin-inline: var(--divider-margin-inline, 0);
9
+ }
10
+
11
+ &[data-bpds-has-horizontal-padding="true"] {
12
+ --divider-margin-inline: calc(var(--bpds-spacing-3) * -1);
13
+ }
14
+ }
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { type Props } from "./RadioGroupRoot";
3
+ export type { Props };
4
+ declare const RadioGroup: {
5
+ (props: Props): React.JSX.Element;
6
+ displayName: string;
7
+ Item: {
8
+ ({ value, label, additional, suffix }: import("./RadioGroupItem").RadioGroupItemProps): React.JSX.Element;
9
+ displayName: string;
10
+ };
11
+ };
12
+ export default RadioGroup;
@@ -8,4 +8,4 @@ r.displayName = "RadioGroup", r.Item = e;
8
8
  //#endregion
9
9
  export { r as default };
10
10
 
11
- //# sourceMappingURL=RadioGroup2.js.map
11
+ //# sourceMappingURL=RadioGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroup.js","names":[],"sources":["../../src/RadioGroup.tsx"],"sourcesContent":["import React from \"react\";\n\nimport RadioGroupItem from \"./RadioGroupItem\";\nimport RadioGroupRoot, { type Props } from \"./RadioGroupRoot\";\n\nexport type { Props };\n\nconst RadioGroup = (props: Props) => <RadioGroupRoot {...props} />;\n\nRadioGroup.displayName = \"RadioGroup\";\n\nRadioGroup.Item = RadioGroupItem;\n\nexport default RadioGroup;\n"],"mappings":";;;;;AAOA,IAAM,KAAc,MAAiB,kBAAC,GAAD,EAAgB,GAAI,EAAQ,CAAA;AAEjE,EAAW,cAAc,cAEzB,EAAW,OAAO"}
@@ -0,0 +1,6 @@
1
+ export interface RadioGroupContextProps {
2
+ disabled: boolean;
3
+ checkedValue: string;
4
+ }
5
+ declare const RadioGroupContext: import("react").Context<RadioGroupContextProps>;
6
+ export default RadioGroupContext;
@@ -0,0 +1,16 @@
1
+ import React, { ReactNode } from "react";
2
+ export interface RadioGroupItemProps {
3
+ /** The value of the radio button. */
4
+ value: string;
5
+ /** The label of the radio button. */
6
+ label: ReactNode;
7
+ /** Suffix that will be placed on the far right side inside the `<label>` to further visualize the item's value, e.g. with icon(s) or logo(s). Make sure to only include allowed children here to avoid irregular HTML markup. */
8
+ suffix?: ReactNode;
9
+ /** Additional content to be displayed when item is selected. */
10
+ additional?: ReactNode;
11
+ }
12
+ declare const RadioGroupItem: {
13
+ ({ value, label, additional, suffix }: RadioGroupItemProps): React.JSX.Element;
14
+ displayName: string;
15
+ };
16
+ export default RadioGroupItem;
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import e from "./useConsumeRadioGroup.js";
3
3
  import "react";
4
- import { tv as t } from "tailwind-variants";
5
- import * as n from "@radix-ui/react-radio-group";
4
+ import * as t from "@radix-ui/react-radio-group";
5
+ import { tv as n } from "tailwind-variants";
6
6
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
7
7
  //#region src/RadioGroupItem.tsx
8
- var a = t({
8
+ var a = n({
9
9
  base: "preflight typography-input-text flex gap-2 justify-between text-clr-primary",
10
10
  slots: {
11
11
  item: ["w-6 h-6 border text-inherit border-current rounded-full shrink-0", "focus-visible:outline outline-current outline-2 outline-offset-2"],
@@ -20,8 +20,8 @@ var a = t({
20
20
  },
21
21
  false: { base: "hover:cursor-pointer hover:text-clr-on-bg-low" }
22
22
  } }
23
- }), o = ({ value: t, label: o, additional: s, suffix: c }) => {
24
- let { disabled: l, checkedValue: u } = e(), { base: d, item: f, indicatorAndLabel: p, indicator: m, suffix: h } = a({ disabled: l }), g = t === "" ? "hidden" : void 0, _ = t === u;
23
+ }), o = ({ value: n, label: o, additional: s, suffix: c }) => {
24
+ let { disabled: l, checkedValue: u } = e(), { base: d, item: f, indicatorAndLabel: p, indicator: m, suffix: h } = a({ disabled: l }), g = n === "" ? "hidden" : void 0, _ = n === u;
25
25
  return /* @__PURE__ */ i("div", {
26
26
  className: g,
27
27
  "data-bpds-radio-group-item": "",
@@ -31,11 +31,11 @@ var a = t({
31
31
  className: d(),
32
32
  children: [/* @__PURE__ */ i("span", {
33
33
  className: p(),
34
- children: [/* @__PURE__ */ r(n.Item, {
35
- value: t,
34
+ children: [/* @__PURE__ */ r(t.Item, {
35
+ value: n,
36
36
  className: f(),
37
37
  disabled: l,
38
- children: /* @__PURE__ */ r(n.Indicator, { className: m() })
38
+ children: /* @__PURE__ */ r(t.Indicator, { className: m() })
39
39
  }), o]
40
40
  }), c && /* @__PURE__ */ r("span", {
41
41
  className: h(),
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroupItem.js","names":[],"sources":["../../src/RadioGroupItem.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode } from \"react\";\nimport { tv } from \"tailwind-variants\";\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\n\nimport useConsumeRadioGroup from \"./useConsumeRadioGroup\";\n\nconst generateClasses = tv({\n base: \"preflight typography-input-text flex gap-2 justify-between text-clr-primary\",\n slots: {\n item: [\n \"w-6 h-6 border text-inherit border-current rounded-full shrink-0\",\n \"focus-visible:outline outline-current outline-2 outline-offset-2\",\n ],\n // py is used instead of h-8, because h-8 will make the item label vertically centered\n indicatorAndLabel: \"flex gap-2 py-3 flex-1 items-center\",\n indicator: [\n \"flex items-center justify-center w-full h-full relative after:content-[''] after:block after:w-2.5\",\n \"after:h-2.5 after:bg-current after:rounded-[50%]\",\n ],\n // set height explicitly to prevent suffix from breaking layout and spacings\n suffix: \"h-12 flex-none\",\n },\n variants: {\n disabled: {\n true: {\n base: \"text-clr-disabled\",\n item: \"bg-clr-bg-disabled\",\n },\n false: {\n base: \"hover:cursor-pointer hover:text-clr-on-bg-low\",\n },\n },\n },\n});\n\nexport interface RadioGroupItemProps {\n /** The value of the radio button. */\n value: string;\n /** The label of the radio button. */\n label: ReactNode;\n /** Suffix that will be placed on the far right side inside the `<label>` to further visualize the item's value, e.g. with icon(s) or logo(s). Make sure to only include allowed children here to avoid irregular HTML markup. */\n suffix?: ReactNode;\n /** Additional content to be displayed when item is selected. */\n additional?: ReactNode;\n}\n\nconst RadioGroupItem = ({ value, label, additional, suffix }: RadioGroupItemProps) => {\n const { disabled, checkedValue } = useConsumeRadioGroup();\n const { base, item, indicatorAndLabel, indicator, suffix: suffixClasses } = generateClasses({ disabled });\n const hidden = value === \"\" ? \"hidden\" : undefined;\n\n const isChecked = value === checkedValue;\n\n return (\n <div className={hidden} data-bpds-radio-group-item=\"\" data-bpds-has-suffix={!!suffix} data-bpds-has-additional={!!additional}>\n <label className={base()}>\n <span className={indicatorAndLabel()}>\n <RadioGroupPrimitive.Item value={value} className={item()} disabled={disabled}>\n <RadioGroupPrimitive.Indicator className={indicator()} />\n </RadioGroupPrimitive.Item>\n {label}\n </span>\n {suffix && <span className={suffixClasses()}>{suffix}</span>}\n </label>\n {additional && isChecked && <div>{additional}</div>}\n </div>\n );\n};\n\nRadioGroupItem.displayName = \"RadioGroup.Item\";\n\nexport default RadioGroupItem;\n"],"mappings":";;;;;;;AAQA,IAAM,IAAkB,EAAG;CACzB,MAAM;CACN,OAAO;EACL,MAAM,CACJ,oEACA,kEACF;EAEA,mBAAmB;EACnB,WAAW,CACT,sGACA,kDACF;EAEA,QAAQ;CACV;CACA,UAAU,EACR,UAAU;EACR,MAAM;GACJ,MAAM;GACN,MAAM;EACR;EACA,OAAO,EACL,MAAM,gDACR;CACF,EACF;AACF,CAAC,GAaK,KAAkB,EAAE,UAAO,UAAO,eAAY,gBAAkC;CACpF,IAAM,EAAE,aAAU,oBAAiB,EAAqB,GAClD,EAAE,SAAM,SAAM,sBAAmB,cAAW,QAAQ,MAAkB,EAAgB,EAAE,YAAS,CAAC,GAClG,IAAS,MAAU,KAAK,WAAW,KAAA,GAEnC,IAAY,MAAU;CAE5B,OACE,kBAAC,OAAD;EAAK,WAAW;EAAQ,8BAA2B;EAAG,wBAAsB,CAAC,CAAC;EAAQ,4BAA0B,CAAC,CAAC;EAAlH,UAAA,CACE,kBAAC,SAAD;GAAO,WAAW,EAAK;GAAvB,UAAA,CACE,kBAAC,QAAD;IAAM,WAAW,EAAkB;IAAnC,UAAA,CACE,kBAAC,EAAoB,MAArB;KAAiC;KAAO,WAAW,EAAK;KAAa;KACnE,UAAA,kBAAC,EAAoB,WAArB,EAA+B,WAAW,EAAU,EAAI,CAAA;IAChC,CAAA,GACzB,CACG;GACL,CAAA,GAAA,KAAU,kBAAC,QAAD;IAAM,WAAW,EAAc;IAAI,UAAA;GAAa,CAAA,CACtD;EACN,CAAA,GAAA,KAAc,KAAa,kBAAC,OAAD,EAAA,UAAM,EAAgB,CAAA,CAC/C;;AAET;AAEA,EAAe,cAAc"}
1
+ {"version":3,"file":"RadioGroupItem.js","names":[],"sources":["../../src/RadioGroupItem.tsx"],"sourcesContent":["\"use client\";\n\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\nimport React, { ReactNode } from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport useConsumeRadioGroup from \"./useConsumeRadioGroup\";\n\nconst generateClasses = tv({\n base: \"preflight typography-input-text flex gap-2 justify-between text-clr-primary\",\n slots: {\n item: [\n \"w-6 h-6 border text-inherit border-current rounded-full shrink-0\",\n \"focus-visible:outline outline-current outline-2 outline-offset-2\",\n ],\n // py is used instead of h-8, because h-8 will make the item label vertically centered\n indicatorAndLabel: \"flex gap-2 py-3 flex-1 items-center\",\n indicator: [\n \"flex items-center justify-center w-full h-full relative after:content-[''] after:block after:w-2.5\",\n \"after:h-2.5 after:bg-current after:rounded-[50%]\",\n ],\n // set height explicitly to prevent suffix from breaking layout and spacings\n suffix: \"h-12 flex-none\",\n },\n variants: {\n disabled: {\n true: {\n base: \"text-clr-disabled\",\n item: \"bg-clr-bg-disabled\",\n },\n false: {\n base: \"hover:cursor-pointer hover:text-clr-on-bg-low\",\n },\n },\n },\n});\n\nexport interface RadioGroupItemProps {\n /** The value of the radio button. */\n value: string;\n /** The label of the radio button. */\n label: ReactNode;\n /** Suffix that will be placed on the far right side inside the `<label>` to further visualize the item's value, e.g. with icon(s) or logo(s). Make sure to only include allowed children here to avoid irregular HTML markup. */\n suffix?: ReactNode;\n /** Additional content to be displayed when item is selected. */\n additional?: ReactNode;\n}\n\nconst RadioGroupItem = ({ value, label, additional, suffix }: RadioGroupItemProps) => {\n const { disabled, checkedValue } = useConsumeRadioGroup();\n const { base, item, indicatorAndLabel, indicator, suffix: suffixClasses } = generateClasses({ disabled });\n const hidden = value === \"\" ? \"hidden\" : undefined;\n\n const isChecked = value === checkedValue;\n\n return (\n <div className={hidden} data-bpds-radio-group-item=\"\" data-bpds-has-suffix={!!suffix} data-bpds-has-additional={!!additional}>\n <label className={base()}>\n <span className={indicatorAndLabel()}>\n <RadioGroupPrimitive.Item value={value} className={item()} disabled={disabled}>\n <RadioGroupPrimitive.Indicator className={indicator()} />\n </RadioGroupPrimitive.Item>\n {label}\n </span>\n {suffix && <span className={suffixClasses()}>{suffix}</span>}\n </label>\n {additional && isChecked && <div>{additional}</div>}\n </div>\n );\n};\n\nRadioGroupItem.displayName = \"RadioGroup.Item\";\n\nexport default RadioGroupItem;\n"],"mappings":";;;;;;;AAQA,IAAM,IAAkB,EAAG;CACzB,MAAM;CACN,OAAO;EACL,MAAM,CACJ,oEACA,kEACF;EAEA,mBAAmB;EACnB,WAAW,CACT,sGACA,kDACF;EAEA,QAAQ;CACV;CACA,UAAU,EACR,UAAU;EACR,MAAM;GACJ,MAAM;GACN,MAAM;EACR;EACA,OAAO,EACL,MAAM,gDACR;CACF,EACF;AACF,CAAC,GAaK,KAAkB,EAAE,UAAO,UAAO,eAAY,gBAAkC;CACpF,IAAM,EAAE,aAAU,oBAAiB,EAAqB,GAClD,EAAE,SAAM,SAAM,sBAAmB,cAAW,QAAQ,MAAkB,EAAgB,EAAE,YAAS,CAAC,GAClG,IAAS,MAAU,KAAK,WAAW,KAAA,GAEnC,IAAY,MAAU;CAE5B,OACE,kBAAC,OAAD;EAAK,WAAW;EAAQ,8BAA2B;EAAG,wBAAsB,CAAC,CAAC;EAAQ,4BAA0B,CAAC,CAAC;EAAlH,UAAA,CACE,kBAAC,SAAD;GAAO,WAAW,EAAK;GAAvB,UAAA,CACE,kBAAC,QAAD;IAAM,WAAW,EAAkB;IAAnC,UAAA,CACE,kBAAC,EAAoB,MAArB;KAAiC;KAAO,WAAW,EAAK;KAAa;KACnE,UAAA,kBAAC,EAAoB,WAArB,EAA+B,WAAW,EAAU,EAAI,CAAA;IAChC,CAAA,GACzB,CACG;GACL,CAAA,GAAA,KAAU,kBAAC,QAAD;IAAM,WAAW,EAAc;IAAI,UAAA;GAAa,CAAA,CACtD;EACN,CAAA,GAAA,KAAc,KAAa,kBAAC,OAAD,EAAA,UAAM,EAAgB,CAAA,CAC/C;;AAET;AAEA,EAAe,cAAc"}
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { ControlGroupProps as RadioControlGroupProps } from "@bonprix-ds/utils";
3
+ import "./RadioGroup.css";
4
+ interface ControlledInputProps extends Omit<RadioControlGroupProps, "componentName"> {
5
+ value: string;
6
+ onChange: (value: string) => void;
7
+ }
8
+ interface UncontrolledInputProps extends Omit<RadioControlGroupProps, "componentName"> {
9
+ value?: never;
10
+ defaultValue: string;
11
+ onChange?: (value: string) => void;
12
+ }
13
+ export type Props = ControlledInputProps | UncontrolledInputProps;
14
+ declare const RadioGroupRoot: {
15
+ ({ value, onChange, label, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, name, disabled, error, errorText, helperText, required, divider, horizontalPadding, ...unionProps }: Props): React.JSX.Element;
16
+ displayName: string;
17
+ };
18
+ export default RadioGroupRoot;
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import e from "./RadioGroupContext.js";
3
3
  import t from "./RadioGroupItem.js";
4
- /* empty css */
5
4
  import { useState as n } from "react";
6
5
  import * as r from "@radix-ui/react-radio-group";
7
6
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
8
7
  import { SelectionControlGroup as o } from "@bonprix-ds/internal-components";
8
+ import "./RadioGroup.css";
9
9
  //#region src/RadioGroupRoot.tsx
10
10
  var s = ({ value: s, onChange: c, label: l, "aria-label": u, "aria-labelledby": d, children: f, name: p, disabled: m = !1, error: h = !1, errorText: g = "", helperText: _, required: v = !1, divider: y = !1, horizontalPadding: b = !1, ...x }) => {
11
11
  let S = "defaultValue" in x ? x.defaultValue : void 0, [C, w] = n(S ?? ""), T = s !== void 0, E = T ? s : C;
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroupRoot.js","names":[],"sources":["../../src/RadioGroupRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { SelectionControlGroup } from \"@bonprix-ds/internal-components\";\nimport { ControlGroupProps as RadioControlGroupProps } from \"@bonprix-ds/utils\";\nimport React, { useState } from \"react\";\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\n\nimport RadioGroupContext from \"./RadioGroupContext\";\nimport RadioGroupItem from \"./RadioGroupItem\";\n\nimport \"./RadioGroup.css\";\n\ninterface ControlledInputProps extends Omit<RadioControlGroupProps, \"componentName\"> {\n value: string;\n onChange: (value: string) => void;\n}\n\ninterface UncontrolledInputProps extends Omit<RadioControlGroupProps, \"componentName\"> {\n value?: never;\n defaultValue: string;\n onChange?: (value: string) => void;\n}\n\nexport type Props = ControlledInputProps | UncontrolledInputProps;\n\nconst RadioGroupRoot = ({\n value,\n onChange,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n children,\n name,\n disabled = false,\n error = false,\n errorText = \"\",\n helperText,\n required = false,\n divider = false,\n horizontalPadding = false,\n ...unionProps\n}: Props) => {\n const defaultValue = \"defaultValue\" in unionProps ? unionProps.defaultValue : undefined;\n\n // For the uncontrolled variant, track the checked value internally so the Context\n // (and therefore `isChecked` in `RadioGroup.Item`) stays up-to-date.\n const [internalValue, setInternalValue] = useState(defaultValue ?? \"\");\n const isControlled = value !== undefined;\n const checkedValue = isControlled ? value : internalValue;\n\n const handleValueChange = (newValue: string) => {\n if (!isControlled) setInternalValue(newValue);\n onChange?.(newValue);\n };\n\n return (\n <SelectionControlGroup\n label={label}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n name={name}\n disabled={disabled}\n helperText={helperText}\n error={error}\n errorText={errorText}\n required={required}\n componentName=\"radio-group\"\n divider={divider}\n horizontalPadding={horizontalPadding}\n >\n <RadioGroupPrimitive.Root\n name={name}\n value={value}\n onValueChange={handleValueChange}\n orientation=\"vertical\" // disable navigation via \"←\" and \"→\" keys, only \"↑\" and \"↓\" can be used\n disabled={disabled}\n required={required}\n defaultValue={defaultValue}\n >\n <RadioGroupContext value={{ disabled, checkedValue }}>\n {/* Creating a 'phantom' option is technically more correct for the case when we pass an empty string as a value (initially to not preselect any option in the group). */}\n <RadioGroupItem label=\"\" value=\"\" />\n {children}\n </RadioGroupContext>\n </RadioGroupPrimitive.Root>\n </SelectionControlGroup>\n );\n};\n\nRadioGroupRoot.displayName = \"RadioGroup\";\n\nexport default RadioGroupRoot;\n"],"mappings":";;;;;;;;;AAyBA,IAAM,KAAkB,EACtB,UACA,aACA,UACA,cAAc,GACd,mBAAmB,GACnB,aACA,SACA,cAAW,IACX,WAAQ,IACR,eAAY,IACZ,eACA,cAAW,IACX,aAAU,IACV,uBAAoB,IACpB,GAAG,QACQ;CACX,IAAM,IAAe,kBAAkB,IAAa,EAAW,eAAe,KAAA,GAIxE,CAAC,GAAe,KAAoB,EAAS,KAAgB,EAAE,GAC/D,IAAe,MAAU,KAAA,GACzB,IAAe,IAAe,IAAQ;CAO5C,OACE,kBAAC,GAAD;EACS;EACP,cAAY;EACZ,mBAAiB;EACX;EACI;EACE;EACL;EACI;EACD;EACV,eAAc;EACL;EACU;EAEnB,UAAA,kBAAC,EAAoB,MAArB;GACQ;GACC;GACP,gBAvBqB,MAAqB;IAE9C,AADK,KAAc,EAAiB,CAAQ,GAC5C,IAAW,CAAQ;GACrB;GAqBM,aAAY;GACF;GACA;GACI;GAEd,UAAA,kBAAC,GAAD;IAAmB,OAAO;KAAE;KAAU;IAAa;IAAnD,UAAA,CAEE,kBAAC,GAAD;KAAgB,OAAM;KAAG,OAAM;IAAI,CAAA,GAClC,CACgB;;EACK,CAAA;CACL,CAAA;AAE3B;AAEA,EAAe,cAAc"}
1
+ {"version":3,"file":"RadioGroupRoot.js","names":[],"sources":["../../src/RadioGroupRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\nimport React, { useState } from \"react\";\n\nimport { SelectionControlGroup } from \"@bonprix-ds/internal-components\";\nimport { ControlGroupProps as RadioControlGroupProps } from \"@bonprix-ds/utils\";\n\nimport RadioGroupContext from \"./RadioGroupContext\";\nimport RadioGroupItem from \"./RadioGroupItem\";\n\nimport \"./RadioGroup.css\";\n\ninterface ControlledInputProps extends Omit<RadioControlGroupProps, \"componentName\"> {\n value: string;\n onChange: (value: string) => void;\n}\n\ninterface UncontrolledInputProps extends Omit<RadioControlGroupProps, \"componentName\"> {\n value?: never;\n defaultValue: string;\n onChange?: (value: string) => void;\n}\n\nexport type Props = ControlledInputProps | UncontrolledInputProps;\n\nconst RadioGroupRoot = ({\n value,\n onChange,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n children,\n name,\n disabled = false,\n error = false,\n errorText = \"\",\n helperText,\n required = false,\n divider = false,\n horizontalPadding = false,\n ...unionProps\n}: Props) => {\n const defaultValue = \"defaultValue\" in unionProps ? unionProps.defaultValue : undefined;\n\n // For the uncontrolled variant, track the checked value internally so the Context\n // (and therefore `isChecked` in `RadioGroup.Item`) stays up-to-date.\n const [internalValue, setInternalValue] = useState(defaultValue ?? \"\");\n const isControlled = value !== undefined;\n const checkedValue = isControlled ? value : internalValue;\n\n const handleValueChange = (newValue: string) => {\n if (!isControlled) setInternalValue(newValue);\n onChange?.(newValue);\n };\n\n return (\n <SelectionControlGroup\n label={label}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n name={name}\n disabled={disabled}\n helperText={helperText}\n error={error}\n errorText={errorText}\n required={required}\n componentName=\"radio-group\"\n divider={divider}\n horizontalPadding={horizontalPadding}\n >\n <RadioGroupPrimitive.Root\n name={name}\n value={value}\n onValueChange={handleValueChange}\n orientation=\"vertical\" // disable navigation via \"←\" and \"→\" keys, only \"↑\" and \"↓\" can be used\n disabled={disabled}\n required={required}\n defaultValue={defaultValue}\n >\n <RadioGroupContext value={{ disabled, checkedValue }}>\n {/* Creating a 'phantom' option is technically more correct for the case when we pass an empty string as a value (initially to not preselect any option in the group). */}\n <RadioGroupItem label=\"\" value=\"\" />\n {children}\n </RadioGroupContext>\n </RadioGroupPrimitive.Root>\n </SelectionControlGroup>\n );\n};\n\nRadioGroupRoot.displayName = \"RadioGroup\";\n\nexport default RadioGroupRoot;\n"],"mappings":";;;;;;;;;AA0BA,IAAM,KAAkB,EACtB,UACA,aACA,UACA,cAAc,GACd,mBAAmB,GACnB,aACA,SACA,cAAW,IACX,WAAQ,IACR,eAAY,IACZ,eACA,cAAW,IACX,aAAU,IACV,uBAAoB,IACpB,GAAG,QACQ;CACX,IAAM,IAAe,kBAAkB,IAAa,EAAW,eAAe,KAAA,GAIxE,CAAC,GAAe,KAAoB,EAAS,KAAgB,EAAE,GAC/D,IAAe,MAAU,KAAA,GACzB,IAAe,IAAe,IAAQ;CAO5C,OACE,kBAAC,GAAD;EACS;EACP,cAAY;EACZ,mBAAiB;EACX;EACI;EACE;EACL;EACI;EACD;EACV,eAAc;EACL;EACU;EAEnB,UAAA,kBAAC,EAAoB,MAArB;GACQ;GACC;GACP,gBAvBqB,MAAqB;IAE9C,AADK,KAAc,EAAiB,CAAQ,GAC5C,IAAW,CAAQ;GACrB;GAqBM,aAAY;GACF;GACA;GACI;GAEd,UAAA,kBAAC,GAAD;IAAmB,OAAO;KAAE;KAAU;IAAa;IAAnD,UAAA,CAEE,kBAAC,GAAD;KAAgB,OAAM;KAAG,OAAM;IAAI,CAAA,GAClC,CACgB;;EACK,CAAA;CACL,CAAA;AAE3B;AAEA,EAAe,cAAc"}
@@ -0,0 +1,2 @@
1
+ declare const useConsumeRadioGroup: () => import("./RadioGroupContext").RadioGroupContextProps;
2
+ export default useConsumeRadioGroup;
package/package.json CHANGED
@@ -1,16 +1,27 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-radio-group",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "RadioGroup component, implemented in React, for the Bonprix Design System.",
5
- "type": "module",
6
- "publishConfig": {
7
- "access": "public",
8
- "provenance": true
5
+ "keywords": [],
6
+ "license": "UNLICENSED",
7
+ "author": "",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/bonprix/design-system.git",
11
+ "directory": "packages/react/radio-group"
9
12
  },
10
- "module": "./dist/index.js",
13
+ "files": [
14
+ "dist",
15
+ "!dist/tsconfig.tsbuildinfo",
16
+ "!dist/vite.config.d.ts",
17
+ "!dist/**/*.test.d.ts"
18
+ ],
19
+ "type": "module",
11
20
  "sideEffects": [
12
21
  "**/*.css"
13
22
  ],
23
+ "module": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
14
25
  "exports": {
15
26
  ".": {
16
27
  "import": "./dist/index.js",
@@ -18,35 +29,26 @@
18
29
  "default": "./dist/index.js"
19
30
  }
20
31
  },
21
- "types": "./dist/index.d.ts",
22
- "files": [
23
- "dist"
24
- ],
25
- "keywords": [],
26
- "author": "",
27
- "license": "UNLICENSED",
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/bonprix/design-system.git",
31
- "directory": "packages/react/radio-group"
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": true
32
35
  },
33
36
  "dependencies": {
34
37
  "@radix-ui/react-radio-group": "1.4.7",
35
- "@bonprix-ds/internal-components": "0.1.5",
36
- "@bonprix-ds/utils": "0.2.1"
37
- },
38
- "peerDependencies": {
39
- "react": "^19.0.0",
40
- "react-dom": "^19.0.0",
41
- "tailwind-variants": "0.3.1"
38
+ "@bonprix-ds/internal-components": "0.2.1",
39
+ "@bonprix-ds/utils": "0.2.2"
42
40
  },
43
41
  "devDependencies": {
44
- "vite": "8.2.2",
45
- "@types/react": "19.2.18",
46
- "@vitejs/plugin-react": "6.1.0",
42
+ "@types/react": "19.3.0",
43
+ "@vitejs/plugin-react": "6.1.1",
47
44
  "rollup-preserve-directives": "1.1.3",
48
- "unplugin-dts": "1.0.3",
49
- "@microsoft/api-extractor": "7.59.0"
45
+ "vite": "8.3.0",
46
+ "@bonprix-ds/vite-config": "0.0.0"
47
+ },
48
+ "peerDependencies": {
49
+ "react": "^19.3.0",
50
+ "react-dom": "^19.3.0",
51
+ "tailwind-variants": "0.3.1"
50
52
  },
51
53
  "scripts": {
52
54
  "build": "vite build"
@@ -1,2 +0,0 @@
1
- [data-bpds-has-divider=true] [role=radiogroup] [data-bpds-radio-group-item]:not(:last-child):after{background-color:var(--color-bg-main-light);block-size:var(--spacing-0-25);content:"";margin-block:var(--spacing-0-5);margin-inline:var(--divider-margin-inline,0);display:block}[data-bpds-has-divider=true][data-bpds-has-horizontal-padding=true]{--divider-margin-inline:calc(var(--spacing-3) * -1)}
2
- /*$vite$:1*/
@@ -1 +0,0 @@
1
- {"version":3,"file":"RadioGroup2.js","names":[],"sources":["../../src/RadioGroup.tsx"],"sourcesContent":["import React from \"react\";\n\nimport RadioGroupItem from \"./RadioGroupItem\";\nimport RadioGroupRoot, { type Props } from \"./RadioGroupRoot\";\n\nexport type { Props };\n\nconst RadioGroup = (props: Props) => <RadioGroupRoot {...props} />;\n\nRadioGroup.displayName = \"RadioGroup\";\n\nRadioGroup.Item = RadioGroupItem;\n\nexport default RadioGroup;\n"],"mappings":";;;;;AAOA,IAAM,KAAc,MAAiB,kBAAC,GAAD,EAAgB,GAAI,EAAQ,CAAA;AAEjE,EAAW,cAAc,cAEzB,EAAW,OAAO"}