@axa-fr/design-system-apollo-react 1.0.5-alpha.334 → 1.0.5-alpha.338

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,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import errorIcon from "@material-symbols/svg-400/outlined/error-fill.svg";
3
2
  import successIcon from "@material-symbols/svg-400/outlined/check_circle-fill.svg";
3
+ import errorIcon from "@material-symbols/svg-400/outlined/error-fill.svg";
4
4
  import { Svg } from "../../Svg/Svg";
5
5
  export const ItemMessage = ({ message, id, messageType = "error", }) => {
6
6
  if (!message) {
7
7
  return null;
8
8
  }
9
- return (_jsxs("small", { className: `af-item-message af-item-message--${messageType}`, role: messageType === "error" ? "alert" : undefined, "aria-live": "assertive", children: [_jsx(Svg, { src: messageType === "error" ? errorIcon : successIcon, className: "af-item-message__icon", "aria-hidden": "true" }), _jsx("span", { id: id, className: "af-item-message__message", children: message })] }));
9
+ return (_jsxs("small", { id: id, className: `af-item-message af-item-message--${messageType}`, role: messageType === "error" ? "alert" : undefined, "aria-live": "assertive", children: [_jsx(Svg, { src: messageType === "error" ? errorIcon : successIcon, className: "af-item-message__icon", "aria-hidden": "true" }), _jsx("span", { className: "af-item-message__message", children: message })] }));
10
10
  };
@@ -1,34 +1,21 @@
1
- import React, { type ComponentProps, ComponentPropsWithRef, type ComponentType, type ReactNode } from "react";
2
- import { Icon } from "../../../Icon/IconCommon";
1
+ import { type ComponentProps, type ComponentType } from "react";
3
2
  import { ItemMessage } from "../../ItemMessage/ItemMessageLF";
4
- import { RadioProps } from "../Radio/RadioCommon";
5
- type RadioComponent = {
6
- RadioComponent: ComponentType<RadioProps>;
7
- };
8
- type IconComponent = {
9
- IconComponent: ComponentType<ComponentProps<typeof Icon>>;
10
- };
11
- export type CardRadioProps = ComponentPropsWithRef<"input"> & {
3
+ import type { RadioCommon } from "../Radio/RadioCommon";
4
+ import type { IconComponent, RadioComponent, TCardRadioItemOption } from "./types";
5
+ export type CardRadioProps = Omit<ComponentProps<typeof RadioCommon>, "size"> & {
12
6
  type: "vertical" | "horizontal";
13
7
  labelGroup?: string;
14
8
  descriptionGroup?: string;
15
9
  isRequired?: boolean;
16
- value?: number;
17
- options: ({
18
- label: ReactNode;
19
- subtitle?: ReactNode;
20
- description?: ReactNode;
21
- hasError?: boolean;
22
- icon?: string;
23
- } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "disabled">)[];
24
- onChange?: React.ChangeEventHandler;
10
+ value?: number | string;
11
+ options: TCardRadioItemOption[];
25
12
  error?: string;
26
13
  };
27
14
  export type CardRadioCommonProps = CardRadioProps & RadioComponent & IconComponent & {
28
15
  ItemMessageComponent: ComponentType<ComponentProps<typeof ItemMessage>>;
29
16
  };
30
17
  declare const CardRadioCommon: {
31
- ({ className, labelGroup, descriptionGroup, RadioComponent, IconComponent, isRequired, options, type, error, name, onChange, ItemMessageComponent, }: CardRadioCommonProps): import("react/jsx-runtime").JSX.Element;
18
+ ({ className, labelGroup, descriptionGroup, RadioComponent, IconComponent, isRequired, options, type, error, name, value, onChange, ItemMessageComponent, ...inputProps }: CardRadioCommonProps): import("react/jsx-runtime").JSX.Element;
32
19
  displayName: string;
33
20
  };
34
21
  export { CardRadioCommon };
@@ -1,15 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useId, } from "react";
2
+ import { useId } from "react";
3
+ import { BREAKPOINT } from "../../../utilities/constants";
3
4
  import { getComponentClassName } from "../../../utilities/getComponentClassName";
4
5
  import { useIsSmallScreen } from "../../../utilities/hook/useIsSmallScreen";
5
- import { BREAKPOINT } from "../../../utilities/constants";
6
- const CardRadioCommon = ({ className, labelGroup, descriptionGroup, RadioComponent, IconComponent, isRequired, options, type = "vertical", error, name, onChange, ItemMessageComponent, }) => {
6
+ import { CardRadioItem } from "./CardRadioItem";
7
+ const CardRadioCommon = ({ className, labelGroup, descriptionGroup, RadioComponent, IconComponent, isRequired, options, type = "vertical", error, name, value, onChange, ItemMessageComponent, ...inputProps }) => {
7
8
  const componentClassName = getComponentClassName("af-card-radio__container", className);
8
9
  const RadioGroupClassName = getComponentClassName("af-card-radio-group", className, type);
9
10
  const errorId = useId();
10
11
  const isMobile = useIsSmallScreen(BREAKPOINT.SM);
11
- const size = isMobile ? "M" : "L";
12
- return (_jsxs("fieldset", { className: componentClassName, children: [labelGroup && (_jsxs("legend", { className: "af-card-radio__legend", children: [_jsxs("p", { children: [labelGroup, isRequired && _jsx("span", { "aria-hidden": true, children: "\u00A0*" })] }), descriptionGroup && (_jsx("p", { className: "af-card-radio__description", children: descriptionGroup }))] })), _jsx("div", { className: RadioGroupClassName, children: options.map(({ label, description, subtitle, icon, hasError, ...inputProps }, index) => (_jsxs("label", { "aria-invalid": Boolean(error) || hasError, htmlFor: `id-${name ?? inputProps.name}-${index}`, className: "af-card-radio-label", children: [_jsx(RadioComponent, { id: `id-${name ?? inputProps.name}-${index}`, errorId: errorId, hasError: Boolean(error) || hasError, ...inputProps, name: name ?? inputProps.name, onChange: onChange }), _jsxs("div", { className: "af-card-radio-content", children: [icon && _jsx(IconComponent, { src: icon, size: size }), _jsxs("div", { className: "af-card-radio-content-description", children: [_jsx("span", { children: label }), description && _jsx("span", { children: description }), subtitle && _jsx("span", { children: subtitle })] })] })] }, `${name ?? inputProps.name}`))) }), _jsx(ItemMessageComponent, { id: errorId, message: error, messageType: "error" })] }));
12
+ const size = isMobile
13
+ ? "M"
14
+ : "L";
15
+ return (_jsxs("fieldset", { className: componentClassName, "aria-invalid": Boolean(error), "aria-errormessage": error ? errorId : undefined, children: [labelGroup && (_jsxs("legend", { className: "af-card-radio__legend", children: [_jsxs("p", { children: [labelGroup, isRequired && _jsx("span", { "aria-hidden": true, children: "\u00A0*" })] }), descriptionGroup && (_jsx("p", { className: "af-card-radio__description", children: descriptionGroup }))] })), _jsx("div", { className: RadioGroupClassName, children: options.map((cardRadioItemProps) => (_jsx(CardRadioItem, { name: name, onChange: onChange, size: size, RadioComponent: RadioComponent, IconComponent: IconComponent, checked: value !== undefined
16
+ ? value === cardRadioItemProps.value
17
+ : undefined, ...inputProps, ...cardRadioItemProps }, `${name}-${crypto.randomUUID()}`))) }), _jsx(ItemMessageComponent, { id: errorId, message: error, messageType: "error" })] }));
13
18
  };
14
19
  CardRadioCommon.displayName = "CardRadioCommon";
15
20
  export { CardRadioCommon };
@@ -0,0 +1,13 @@
1
+ import { type ComponentProps, type ComponentType } from "react";
2
+ import type { Icon as IconCommon } from "../../../Icon/IconCommon";
3
+ import type { RadioCommon } from "../Radio/RadioCommon";
4
+ export type TCardRadioItemProps = Omit<ComponentProps<typeof RadioCommon>, "size"> & {
5
+ label: string;
6
+ description?: string;
7
+ subtitle?: string;
8
+ icon?: ComponentProps<typeof IconCommon>["src"];
9
+ size: ComponentProps<typeof IconCommon>["size"];
10
+ RadioComponent: ComponentType<ComponentProps<typeof RadioCommon>>;
11
+ IconComponent: ComponentType<ComponentProps<typeof IconCommon>>;
12
+ };
13
+ export declare const CardRadioItem: ({ label, description, subtitle, icon, size, RadioComponent, IconComponent, ...inputProps }: TCardRadioItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const CardRadioItem = ({ label, description, subtitle, icon, size, RadioComponent, IconComponent, ...inputProps }) => (_jsxs("label", { className: "af-card-radio-label", children: [_jsx(RadioComponent, { ...inputProps }), _jsxs("div", { className: "af-card-radio-content", children: [icon && _jsx(IconComponent, { src: icon, size: size, role: "presentation" }), _jsxs("div", { className: "af-card-radio-content-description", children: [_jsx("span", { children: label }), description && _jsx("span", { children: description }), subtitle && _jsx("span", { children: subtitle })] })] })] }));
@@ -0,0 +1,11 @@
1
+ import type { ComponentProps, ComponentType } from "react";
2
+ import type { Icon } from "../../../indexLF";
3
+ import type { RadioProps } from "../Radio/RadioCommon";
4
+ import type { TCardRadioItemProps } from "./CardRadioItem";
5
+ export type TCardRadioItemOption = Omit<TCardRadioItemProps, "RadioComponent" | "IconComponent" | "size" | "name">;
6
+ export type RadioComponent = {
7
+ RadioComponent: ComponentType<RadioProps>;
8
+ };
9
+ export type IconComponent = {
10
+ IconComponent: ComponentType<ComponentProps<typeof Icon>>;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,6 @@
1
1
  import React from "react";
2
- export type RadioProps = {
3
- errorId?: string;
4
- hasError?: boolean;
5
- } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "disabled">;
2
+ export type RadioProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "disabled">;
6
3
  export declare const RadioCommon: {
7
- ({ errorId, hasError, ...inputProps }: RadioProps): import("react/jsx-runtime").JSX.Element;
4
+ (inputProps: RadioProps): import("react/jsx-runtime").JSX.Element;
8
5
  displayName: string;
9
6
  };
@@ -1,3 +1,3 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export const RadioCommon = ({ errorId, hasError, ...inputProps }) => (_jsxs("span", { className: "af-radio", "aria-invalid": hasError, "aria-errormessage": errorId, children: [_jsx("input", { ...inputProps, type: "radio" }), _jsx("span", { className: "af-radio__icons" })] }));
2
+ export const RadioCommon = (inputProps) => (_jsxs("span", { className: "af-radio", children: [_jsx("input", { ...inputProps, type: "radio" }), _jsx("span", { className: "af-radio__icons" })] }));
3
3
  RadioCommon.displayName = "RadioCommon";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-apollo-react",
3
- "version": "1.0.5-alpha.334",
3
+ "version": "1.0.5-alpha.338",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "homepage": "https://github.com/AxaFrance/design-system#readme",
48
48
  "peerDependencies": {
49
- "@axa-fr/design-system-apollo-css": "1.0.5-alpha.334",
50
- "@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.334",
49
+ "@axa-fr/design-system-apollo-css": "1.0.5-alpha.338",
50
+ "@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.338",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },