@axa-fr/canopee-react 1.5.1-alpha.30 → 1.5.1-alpha.32

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.
@@ -3,11 +3,15 @@ import "@axa-fr/canopee-css/prospect/Modal/ModalApollo.css";
3
3
  import { forwardRef } from "react";
4
4
  import { Button } from "../Button/ButtonApollo";
5
5
  import { Heading } from "../Heading/HeadingApollo";
6
- import { Icon } from "../Icon/IconApollo";
7
6
  import { ModalCommon } from "./ModalCommon";
8
7
  export { ModalCore } from "./components/ModalCore";
9
8
  export { ModalCoreBody, } from "./components/ModalCoreBody";
10
9
  export { ModalCoreFooter } from "./components/ModalCoreFooterApollo";
11
10
  export { ModalCoreHeader } from "./components/ModalCoreHeaderApollo";
12
- export const Modal = forwardRef(({ headingProps = {}, icon, iconProps = {}, ...props }, ref) => (_jsx(ModalCommon, { ...props, ref: ref, headingComponent: Heading, headingProps: { ...headingProps, children: props.title }, iconComponent: icon ? Icon : undefined, iconProps: icon ? { src: icon, ...iconProps } : undefined, buttonComponent: Button })));
11
+ export const Modal = forwardRef(({ headingProps = {}, icon, iconProps, ...props }, ref) => (_jsx(ModalCommon, { ...props, ref: ref, headingComponent: Heading, headingProps: {
12
+ ...headingProps,
13
+ children: props.title,
14
+ icon: headingProps.icon ?? icon,
15
+ iconProps: headingProps.iconProps ?? iconProps,
16
+ }, buttonComponent: Button })));
13
17
  Modal.displayName = "Modal";
@@ -4,5 +4,5 @@ import { ModalCore } from "./components/ModalCore";
4
4
  import { ModalCoreBody, } from "./components/ModalCoreBody";
5
5
  import { ModalCoreFooterCommon, } from "./components/ModalCoreFooterCommon";
6
6
  import { ModalCoreHeaderCommon } from "./components/ModalCoreHeaderCommon";
7
- export const ModalCommon = forwardRef(({ children, headingComponent, headingProps, closeButtonAriaLabel, onClose, iconComponent, iconProps, primaryButtonProps, secondaryButtonProps, tertiaryButtonProps, buttonComponent, modalCoreBodyProps, modalCoreFooterProps, modalCoreHeaderProps, ...props }, ref) => (_jsxs(ModalCore, { onClose: onClose, ref: ref, ...props, children: [_jsx(ModalCoreHeaderCommon, { headingComponent: headingComponent, headingProps: headingProps, iconComponent: iconComponent, iconProps: iconProps, onClose: onClose, closeButtonAriaLabel: closeButtonAriaLabel, ...modalCoreHeaderProps }), _jsx(ModalCoreBody, { ...modalCoreBodyProps, children: children }), _jsx(ModalCoreFooterCommon, { buttonComponent: buttonComponent, primaryButtonProps: primaryButtonProps, secondaryButtonProps: secondaryButtonProps, tertiaryButtonProps: tertiaryButtonProps, ...modalCoreFooterProps })] })));
7
+ export const ModalCommon = forwardRef(({ children, headingComponent, headingProps, closeButtonAriaLabel, onClose, iconProps, primaryButtonProps, secondaryButtonProps, tertiaryButtonProps, buttonComponent, modalCoreBodyProps, modalCoreFooterProps, modalCoreHeaderProps, ...props }, ref) => (_jsxs(ModalCore, { onClose: onClose, ref: ref, ...props, children: [_jsx(ModalCoreHeaderCommon, { headingComponent: headingComponent, headingProps: headingProps, iconProps: iconProps, onClose: onClose, closeButtonAriaLabel: closeButtonAriaLabel, ...modalCoreHeaderProps }), _jsx(ModalCoreBody, { ...modalCoreBodyProps, children: children }), _jsx(ModalCoreFooterCommon, { buttonComponent: buttonComponent, primaryButtonProps: primaryButtonProps, secondaryButtonProps: secondaryButtonProps, tertiaryButtonProps: tertiaryButtonProps, ...modalCoreFooterProps })] })));
8
8
  ModalCommon.displayName = "ModalCommon";
@@ -3,11 +3,15 @@ import "@axa-fr/canopee-css/client/Modal/ModalLF.css";
3
3
  import { forwardRef } from "react";
4
4
  import { Button } from "../Button/ButtonLF";
5
5
  import { Heading } from "../Heading/HeadingLF";
6
- import { Icon } from "../Icon/IconLF";
7
6
  import { ModalCommon } from "./ModalCommon";
8
7
  export { ModalCore } from "./components/ModalCore";
9
8
  export { ModalCoreBody, } from "./components/ModalCoreBody";
10
9
  export { ModalCoreFooter } from "./components/ModalCoreFooterLF";
11
10
  export { ModalCoreHeader } from "./components/ModalCoreHeaderLF";
12
- export const Modal = forwardRef(({ headingProps = {}, icon, iconProps = {}, ...props }, ref) => (_jsx(ModalCommon, { ...props, ref: ref, headingComponent: Heading, headingProps: { ...headingProps, children: props.title }, iconComponent: icon ? Icon : undefined, iconProps: icon ? { src: icon, ...iconProps } : undefined, buttonComponent: Button })));
11
+ export const Modal = forwardRef(({ headingProps = {}, icon, iconProps, ...props }, ref) => (_jsx(ModalCommon, { ...props, ref: ref, headingComponent: Heading, headingProps: {
12
+ ...headingProps,
13
+ children: props.title,
14
+ icon: headingProps.icon ?? icon,
15
+ iconProps: headingProps.iconProps ?? iconProps,
16
+ }, buttonComponent: Button })));
13
17
  Modal.displayName = "Modal";
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Heading } from "../../Heading/HeadingApollo";
3
- import { Icon } from "../../Icon/IconApollo";
4
3
  import { ModalCoreHeaderCommon } from "./ModalCoreHeaderCommon";
5
- export const ModalCoreHeader = (args) => (_jsx(ModalCoreHeaderCommon, { headingComponent: Heading, iconComponent: Icon, ...args }));
4
+ export const ModalCoreHeader = (args) => (_jsx(ModalCoreHeaderCommon, { headingComponent: Heading, ...args }));
@@ -5,9 +5,13 @@ export type ModalCoreHeaderContainerProps = ComponentPropsWithoutRef<"header">;
5
5
  export type ModalCoreHeaderCommonProps = ModalCoreHeaderContainerProps & {
6
6
  headingComponent: ComponentType<HeadingProps>;
7
7
  headingProps: HeadingProps;
8
- iconComponent?: ComponentType<IconProps>;
8
+ /**
9
+ * @deprecated Pass `icon` and `iconProps` (without `src`) inside
10
+ * `headingProps` instead. The legacy `iconProps` is forwarded to the
11
+ * Heading molecule for backward compatibility and will be removed in 2.0.0.
12
+ */
9
13
  iconProps?: IconProps;
10
14
  onClose?: VoidFunction;
11
15
  closeButtonAriaLabel?: string;
12
16
  };
13
- export declare const ModalCoreHeaderCommon: ({ className, headingComponent: HeadingComponent, headingProps, iconComponent: IconComponent, iconProps, onClose, closeButtonAriaLabel, ...props }: ModalCoreHeaderCommonProps) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const ModalCoreHeaderCommon: (props: ModalCoreHeaderCommonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import close from "@material-symbols/svg-400/rounded/close.svg";
3
3
  import { ClickIcon } from "../../ClickIcon/ClickIconCommon";
4
- export const ModalCoreHeaderCommon = ({ className, headingComponent: HeadingComponent, headingProps, iconComponent: IconComponent, iconProps, onClose, closeButtonAriaLabel = "Fermer la boite de dialogue", ...props }) => (_jsxs("header", { className: ["af-modal__header", className].filter(Boolean).join(" "), ...props, children: [_jsx(ClickIcon, { className: "af-modal__header-close-btn", src: close, onClick: onClose, "aria-label": closeButtonAriaLabel }), _jsxs("div", { className: "af-modal__header-title", children: [IconComponent && iconProps ? (_jsx(IconComponent, { size: "M", ...iconProps })) : null, _jsx(HeadingComponent, { level: 2, ...headingProps })] })] }));
4
+ export const ModalCoreHeaderCommon = (props) => {
5
+ const { className, headingComponent: HeadingComponent, headingProps, iconProps, onClose, closeButtonAriaLabel = "Fermer la boite de dialogue", ...rest } = props;
6
+ // Backward-compat: legacy `iconProps` (with `src`) is routed through the
7
+ // Heading molecule, which already renders the icon and title together.
8
+ const { src: legacyIconSrc, ...legacyIconRest } = iconProps ?? {};
9
+ const mergedHeadingProps = legacyIconSrc
10
+ ? {
11
+ ...headingProps,
12
+ icon: headingProps.icon ?? legacyIconSrc,
13
+ iconProps: { ...legacyIconRest, ...(headingProps.iconProps ?? {}) },
14
+ }
15
+ : headingProps;
16
+ return (_jsxs("header", { className: ["af-modal__header", className].filter(Boolean).join(" "), ...rest, children: [_jsx(ClickIcon, { className: "af-modal__header-close-btn", src: close, onClick: onClose, "aria-label": closeButtonAriaLabel }), _jsx("div", { className: "af-modal__header-title", children: _jsx(HeadingComponent, { level: 2, ...mergedHeadingProps }) })] }));
17
+ };
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Heading } from "../../Heading/HeadingLF";
3
- import { Icon } from "../../Icon/IconLF";
4
3
  import { ModalCoreHeaderCommon } from "./ModalCoreHeaderCommon";
5
- export const ModalCoreHeader = (args) => (_jsx(ModalCoreHeaderCommon, { headingComponent: Heading, iconComponent: Icon, ...args }));
4
+ export const ModalCoreHeader = (args) => (_jsx(ModalCoreHeaderCommon, { headingComponent: Heading, ...args }));
@@ -3,10 +3,22 @@ import type { IconProps } from "../Icon/IconCommon";
3
3
  import type { ModalCoreFooterCommonProps } from "./components/ModalCoreFooterCommon";
4
4
  import type { ModalCoreHeaderCommonProps } from "./components/ModalCoreHeaderCommon";
5
5
  import type { ModalCommonProps } from "./ModalCommon";
6
- export type ModalCoreHeaderProps = Omit<ModalCoreHeaderCommonProps, "headingComponent" | "iconComponent">;
6
+ export type ModalCoreHeaderProps = Omit<ModalCoreHeaderCommonProps, "headingComponent">;
7
7
  export type ModalCoreFooterProps = Omit<ModalCoreFooterCommonProps, "buttonComponent">;
8
- export type ModalProps = Omit<ModalCommonProps, "headingComponent" | "headingProps" | "iconComponent" | "iconProps" | "buttonComponent"> & {
8
+ export type ModalProps = Omit<ModalCommonProps, "headingComponent" | "headingProps" | "iconProps" | "buttonComponent"> & {
9
9
  headingProps?: Omit<HeadingProps, "children">;
10
+ /**
11
+ * @deprecated Pass `icon` inside `headingProps` instead
12
+ * (e.g. `headingProps={{ icon }}`). The top-level `icon` prop is
13
+ * forwarded to the Heading molecule for backward compatibility and will
14
+ * be removed in 2.0.0.
15
+ */
10
16
  icon?: string;
17
+ /**
18
+ * @deprecated Pass `iconProps` inside `headingProps` instead
19
+ * (e.g. `headingProps={{ iconProps }}`). The top-level `iconProps`
20
+ * is forwarded to the Heading molecule for backward compatibility and
21
+ * will be removed in 2.0.0.
22
+ */
11
23
  iconProps?: Omit<IconProps, "src">;
12
24
  };
@@ -1,2 +1,3 @@
1
1
  import "@axa-fr/canopee-css/prospect/Toggle/ToggleApollo.css";
2
- export { Toggle } from "./ToggleCommon";
2
+ import { type ToggleProps } from "./ToggleCommon";
3
+ export declare const Toggle: import("react").ForwardRefExoticComponent<ToggleProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,2 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import "@axa-fr/canopee-css/prospect/Toggle/ToggleApollo.css";
2
- export { Toggle } from "./ToggleCommon";
3
+ import { forwardRef } from "react";
4
+ import { Icon } from "../Icon/IconApollo";
5
+ import { ToggleCommon } from "./ToggleCommon";
6
+ export const Toggle = forwardRef((props, ref) => _jsx(ToggleCommon, { IconComponent: Icon, ...props, ref: ref }));
7
+ Toggle.displayName = "Toggle";
@@ -1,3 +1,9 @@
1
- import { type InputHTMLAttributes } from "react";
1
+ import { type ComponentType, type InputHTMLAttributes } from "react";
2
+ import type { IconProps } from "../Icon/IconCommon";
2
3
  export type ToggleProps = Omit<InputHTMLAttributes<HTMLInputElement>, "style" | "type">;
3
- export declare const Toggle: import("react").ForwardRefExoticComponent<ToggleProps & import("react").RefAttributes<HTMLInputElement>>;
4
+ export type ToggleCommonProps = ToggleProps & {
5
+ IconComponent: ComponentType<IconProps>;
6
+ };
7
+ export declare const ToggleCommon: import("react").ForwardRefExoticComponent<ToggleProps & {
8
+ IconComponent: ComponentType<IconProps>;
9
+ } & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useId } from "react";
2
+ import check from "@material-symbols/svg-400/rounded/check.svg";
3
+ import close from "@material-symbols/svg-400/rounded/close.svg";
4
+ import { forwardRef, useId, } from "react";
3
5
  import { getComponentClassName } from "../utilities/getComponentClassName";
4
- export const Toggle = forwardRef(({ className, ...inputProps }, ref) => {
6
+ export const ToggleCommon = forwardRef(({ className, IconComponent, ...inputProps }, ref) => {
5
7
  let inputId = useId();
6
8
  inputId = inputProps.id ?? inputId;
7
- return (_jsxs("label", { className: getComponentClassName("af-toggle", className), htmlFor: inputId, children: [_jsx("div", { className: "af-toggle__root", children: _jsx("span", { className: "af-toggle__handle" }) }), _jsx("input", { ...inputProps, ref: ref, type: "checkbox", id: inputId })] }));
9
+ return (_jsxs("label", { className: getComponentClassName("af-toggle", className), htmlFor: inputId, children: [_jsx("div", { className: "af-toggle__root", children: _jsxs("span", { className: "af-toggle__handle", children: [_jsx(IconComponent, { src: check, "aria-hidden": "true", className: "af-toggle__icon af-toggle__icon--check", size: "XS" }), _jsx(IconComponent, { src: close, "aria-hidden": "true", className: "af-toggle__icon af-toggle__icon--close", size: "XS" })] }) }), _jsx("input", { ...inputProps, ref: ref, type: "checkbox", id: inputId })] }));
8
10
  });
9
- Toggle.displayName = "Toggle";
11
+ ToggleCommon.displayName = "ToggleCommon";
@@ -1,2 +1,3 @@
1
1
  import "@axa-fr/canopee-css/client/Toggle/ToggleLF.css";
2
- export { Toggle } from "./ToggleCommon";
2
+ import { type ToggleProps } from "./ToggleCommon";
3
+ export declare const Toggle: import("react").ForwardRefExoticComponent<ToggleProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,2 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import "@axa-fr/canopee-css/client/Toggle/ToggleLF.css";
2
- export { Toggle } from "./ToggleCommon";
3
+ import { forwardRef } from "react";
4
+ import { Icon } from "../Icon/IconLF";
5
+ import { ToggleCommon } from "./ToggleCommon";
6
+ export const Toggle = forwardRef((props, ref) => _jsx(ToggleCommon, { IconComponent: Icon, ...props, ref: ref }));
7
+ Toggle.displayName = "Toggle";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/canopee-react",
3
- "version": "1.5.1-alpha.30",
3
+ "version": "1.5.1-alpha.32",
4
4
  "description": "Package React - Design System Canopée",
5
5
  "exports": {
6
6
  "./distributeur": {
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "homepage": "https://github.com/AxaFrance/design-system#readme",
51
51
  "peerDependencies": {
52
- "@axa-fr/canopee-css": "1.5.1-alpha.30",
52
+ "@axa-fr/canopee-css": "1.5.1-alpha.32",
53
53
  "@material-symbols/svg-400": ">= 0.19.0",
54
54
  "@material-symbols/svg-700": ">= 0.19.0",
55
55
  "react": ">= 18"