@axa-fr/design-system-slash-react 1.2.1-alpha.71 → 1.2.1-alpha.72

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.
@@ -8,6 +8,7 @@ type Props = Omit<ComponentProps<typeof Radio>, "options" | "value"> & {
8
8
  value: boolean;
9
9
  }>;
10
10
  value?: boolean | string;
11
+ classModifier?: string;
11
12
  };
12
13
  declare const Choice: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
13
14
  export { Choice };
@@ -12,7 +12,7 @@ const Choice = forwardRef(({ children, value, options = defaultOptions, name, ..
12
12
  value: `${o.value}`,
13
13
  })));
14
14
  const generatedId = useId();
15
- return (_jsx(Radio, { ...otherProps, ref: inputRef, name: name ?? `choice_${generatedId}`, value: value?.toString(), options: choiceOptions, children: children }));
15
+ return (_jsx(Radio, { ...otherProps, mode: "default", ref: inputRef, name: name ?? `choice_${generatedId}`, value: value?.toString(), options: choiceOptions, children: children }));
16
16
  });
17
17
  Choice.displayName = "Choice";
18
18
  export { Choice };
@@ -1,31 +1,26 @@
1
- import { ComponentPropsWithoutRef } from "react";
2
1
  import type { Option } from "../core";
3
- import { RadioCardGroup } from "./RadioCardGroup";
4
2
  export declare enum RadioModes {
5
3
  classic = "classic",
6
4
  default = "default",
7
5
  inline = "inline",
8
6
  card = "card"
9
7
  }
10
- declare const Radio: import("react").ForwardRefExoticComponent<(Omit<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "type" | "checked"> & {
11
- classModifier?: string;
12
- optionClassName?: string;
13
- label?: import("react").ReactNode;
14
- isChecked?: boolean;
15
- }, "ref"> & import("react").RefAttributes<HTMLInputElement>, "className" | "id" | "label"> & {
8
+ declare const Radio: import("react").ForwardRefExoticComponent<(({
16
9
  options: Option[];
17
- } & {
18
- mode?: "classic" | "default" | "inline";
19
- }, "ref"> | Omit<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "type" | "checked"> & {
10
+ } & Omit<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & {
11
+ options: Option[];
12
+ orientation?: "horizontal" | "vertical";
13
+ error?: boolean;
14
+ }, "ref"> & {
15
+ mode: "card";
16
+ }) | Omit<{
17
+ options: Option[];
18
+ } & Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "type" | "checked"> & {
20
19
  classModifier?: string;
21
20
  optionClassName?: string;
22
21
  label?: import("react").ReactNode;
23
22
  isChecked?: boolean;
24
23
  }, "ref"> & import("react").RefAttributes<HTMLInputElement>, "className" | "id" | "label"> & {
25
- options: Option[];
26
- } & {
27
- mode: "card";
28
- className?: string;
29
- orientation?: ComponentPropsWithoutRef<typeof RadioCardGroup>["orientation"];
24
+ mode?: "classic" | "default" | "inline";
30
25
  }, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
31
26
  export { Radio };
@@ -22,15 +22,13 @@ const getClassNameMode = (mode) => {
22
22
  return "af-form__radio-custom";
23
23
  }
24
24
  };
25
- const Radio = forwardRef(({ classModifier, options, value = "", children, disabled, ...otherProps }, inputRef) => {
26
- const classNameMode = getClassNameMode(otherProps.mode ?? "default");
27
- // ICI - le if qui permet de rendre un autre composant
28
- if (otherProps.mode === "card") {
29
- return (_jsx(RadioCardGroup, { className: otherProps.className, options: options, error: classModifier === "error", disabled: disabled, orientation: otherProps.orientation, children: children }));
25
+ const Radio = forwardRef(({ options, value = "", children, disabled, ...otherProps }, inputRef) => {
26
+ const { mode, ...onlyNecessaryProps } = otherProps;
27
+ const classNameMode = getClassNameMode(mode ?? "default");
28
+ if (mode === "card") {
29
+ return (_jsx(RadioCardGroup, { ...onlyNecessaryProps, options: options, disabled: disabled, value: value, children: children }));
30
30
  }
31
- const onlyNecessaryProps = { ...otherProps };
32
- delete onlyNecessaryProps.mode;
33
- return options.map((option) => (_createElement(RadioItem, { ...onlyNecessaryProps, key: option.value, isChecked: option.value === value, disabled: option.disabled || disabled, className: classNameMode, classModifier: classModifier, ref: inputRef, ...option }, children)));
31
+ return options.map((option) => (_createElement(RadioItem, { ...onlyNecessaryProps, key: option.value, isChecked: option.value === value, disabled: option.disabled || disabled, className: classNameMode, ref: inputRef, ...option }, children)));
34
32
  });
35
33
  Radio.displayName = "EnhancedInputRadio";
36
34
  export { Radio };
@@ -1,12 +1,10 @@
1
1
  import "@axa-fr/design-system-slash-css/dist/Form/Radio/RadioCardGroup.css";
2
- import { PropsWithChildren } from "react";
2
+ import { ComponentProps } from "react";
3
3
  import type { Option } from "../core";
4
- type Props = PropsWithChildren & {
4
+ type Props = ComponentProps<"input"> & {
5
5
  options: Option[];
6
6
  orientation?: "horizontal" | "vertical";
7
7
  error?: boolean;
8
- disabled?: boolean;
9
- className?: string;
10
8
  };
11
- export declare const RadioCardGroup: ({ children, options, className, orientation, disabled, error, }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const RadioCardGroup: ({ children, options, className, value, orientation, disabled, error, ...otherProps }: Props) => import("react/jsx-runtime").JSX.Element;
12
10
  export {};
@@ -5,7 +5,7 @@ import classNames from "classnames";
5
5
  import { Svg } from "../../Svg";
6
6
  const DEFAULT_CLASSNAME = "af-card";
7
7
  const DEFAULT_CONTAINER_CLASSNAME = "af-form__radio-card-group";
8
- export const RadioCardGroup = ({ children, options, className, orientation = "vertical", disabled = false, error = false, }) => {
8
+ export const RadioCardGroup = ({ children, options, className, value, orientation = "vertical", disabled = false, error = false, ...otherProps }) => {
9
9
  const idGenerated = useId();
10
10
  const radioGroupRef = useRef(null);
11
11
  return (_jsxs("div", { ref: radioGroupRef, role: "radiogroup", className: classNames([
@@ -13,7 +13,7 @@ export const RadioCardGroup = ({ children, options, className, orientation = "ve
13
13
  className,
14
14
  orientation === "horizontal" &&
15
15
  `${DEFAULT_CONTAINER_CLASSNAME}--horizontal`,
16
- ]), children: [options.map(({ name, icon, label, disabled: optionDisabled, checked, ...otherOptionProps }) => {
16
+ ]), children: [options.map(({ name, icon, label, disabled: optionDisabled, value: optionValue, ...otherOptionProps }) => {
17
17
  const newName = name ?? idGenerated;
18
18
  const allClassNames = classNames([
19
19
  DEFAULT_CLASSNAME,
@@ -21,6 +21,6 @@ export const RadioCardGroup = ({ children, options, className, orientation = "ve
21
21
  error && `${DEFAULT_CLASSNAME}--error`,
22
22
  ]);
23
23
  const isDisabled = disabled || optionDisabled;
24
- return (_jsxs("label", { className: allClassNames, children: [_jsx("input", { type: "radio", name: newName, disabled: isDisabled, checked: isDisabled ? false : checked, ...otherOptionProps }), typeof icon === "string" ? _jsx(Svg, { src: icon }) : icon, label] }, otherOptionProps.value));
24
+ return (_jsxs("label", { className: allClassNames, children: [_jsx("input", { ...otherProps, type: "radio", name: newName, disabled: isDisabled, checked: isDisabled ? false : optionValue === value, value: optionValue, ...otherOptionProps }), typeof icon === "string" ? _jsx(Svg, { src: icon }) : icon, label] }, optionValue));
25
25
  }), children] }));
26
26
  };
@@ -2,10 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { Field, useOptionsWithId } from "../core";
4
4
  import { Radio, RadioModes } from "./Radio";
5
- const RadioInput = forwardRef(({ label, mode, options, ...props }, inputRef) => {
5
+ const RadioInput = forwardRef(({ label, mode = "default", options, ...props }, inputRef) => {
6
6
  const labelPosition = mode === RadioModes.classic ? "top" : "center";
7
7
  const newOptions = useOptionsWithId(options);
8
- return (_jsx(Field, { label: label, labelPosition: labelPosition, roleContainer: "radiogroup", ...props, renderInput: ({ classModifier, ariaInvalid, errorId, ...radioProps }) => (_jsx(Radio, { options: newOptions, mode: mode, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...radioProps })) }));
8
+ return (_jsx(Field, { label: label, labelPosition: labelPosition, roleContainer: mode !== "card" ? "radiogroup" : undefined, ...props, renderInput: ({ classModifier, ariaInvalid, errorId, ...radioProps }) => (_jsx(Radio, { options: newOptions, mode: mode, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...radioProps })) }));
9
9
  });
10
10
  RadioInput.displayName = "EnhancedInputRadio";
11
11
  export { RadioInput };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-slash-react",
3
- "version": "1.2.1-alpha.71",
3
+ "version": "1.2.1-alpha.72",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "homepage": "https://github.com/AxaFrance/design-system#readme",
49
49
  "peerDependencies": {
50
- "@axa-fr/design-system-slash-css": "1.2.1-alpha.71",
50
+ "@axa-fr/design-system-slash-css": "1.2.1-alpha.72",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },