@axa-fr/canopee-react 1.5.1-alpha.3 → 1.5.1-alpha.31

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.
@@ -11,11 +11,13 @@ export type DataAgentProps = {
11
11
  clickContents?: TupleMax3<ClickItemProps>;
12
12
  texteOrias?: string;
13
13
  isCompact?: boolean;
14
+ /** Display the compact layout (header only) regardless of screen size */
15
+ variant?: "default" | "compact";
14
16
  };
15
17
  type DataAgentCommonProps = DataAgentProps & {
16
18
  DividerComponent: ComponentType<ComponentProps<typeof Divider>>;
17
19
  ContentItemMonoComponent: ComponentType<ContentItemProps>;
18
20
  ClickItemComponent: ComponentType<ClickItemProps>;
19
21
  };
20
- export declare const DataAgentCommon: ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact, }: DataAgentCommonProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const DataAgentCommon: ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact, variant, }: DataAgentCommonProps) => import("react/jsx-runtime").JSX.Element;
21
23
  export {};
@@ -4,7 +4,7 @@ import { Divider } from "../Divider/DividerCommon";
4
4
  import { BREAKPOINT } from "../utilities/constants";
5
5
  import { getComponentClassName } from "../utilities/getComponentClassName";
6
6
  import { useIsSmallScreen } from "../utilities/hook/useIsSmallScreen";
7
- export const DataAgentCommon = ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact = true, }) => {
7
+ export const DataAgentCommon = ({ className, agentProps, agentContractProps, contents, clickContents, texteOrias, DividerComponent, ContentItemMonoComponent, ClickItemComponent, isCompact = true, variant = "default", }) => {
8
8
  const componentClassName = useMemo(() => getComponentClassName("af-data-agent", className), [className]);
9
9
  const isMobile = useIsSmallScreen(BREAKPOINT.SM);
10
10
  const renderForDefaultLayout = () => (_jsxs(_Fragment, { children: [_jsxs("section", { className: "af-data-agent__intro", children: [_jsx(ContentItemMonoComponent, { ...agentProps, type: "picture" }), agentContractProps ? (_jsx(ContentItemMonoComponent, { ...agentContractProps, type: "stick" })) : null] }), _jsx(DividerComponent, {}), contents && contents?.length > 0 ? (_jsx("section", { className: "af-data-agent__info-content", children: contents.map((content) => (_jsxs(Fragment, { children: [_jsx(ContentItemMonoComponent, { ...content, type: "icon" }), _jsx(DividerComponent, { className: "af-data-agent__line" })] }, `content--${crypto.randomUUID()}`))) })) : null, clickContents && clickContents?.length > 0 ? (_jsx("section", { className: "af-data-agent__info-click-content", children: clickContents.map((clickContent) => (_jsxs(Fragment, { children: [_jsx(ClickItemComponent, { ...clickContent, variant: "small" }), _jsx(DividerComponent, { className: "af-data-agent__line" })] }, `clickContent--${crypto.randomUUID()}`))) })) : null, Boolean(texteOrias) && (_jsx("p", { className: "af-data-agent__text-orias", children: texteOrias }))] }));
@@ -12,7 +12,7 @@ export const DataAgentCommon = ({ className, agentProps, agentContractProps, con
12
12
  src: agentProps.picture,
13
13
  alt: agentProps.title,
14
14
  }, variant: "agent" }) }));
15
- return (_jsx("section", { className: componentClassName, children: isMobile && isCompact
15
+ return (_jsx("section", { className: componentClassName, children: (isMobile && isCompact) || variant === "compact"
16
16
  ? renderForMobileLayout()
17
17
  : renderForDefaultLayout() }));
18
18
  };
@@ -6,11 +6,6 @@ import { ItemMessage, } from "../ItemMessage/ItemMessageCommon";
6
6
  import { InputDateAtom } from "./InputDateAtom";
7
7
  import { InputDateTextAtom } from "./InputDateTextAtom";
8
8
  const InputDateCommon = forwardRef(({ className, classModifier = "", helper, error, success, message, messageType, label, description, buttonLabel, moreButtonLabel, onButtonClick, onMoreButtonClick, ItemLabelComponent, ItemMessageComponent, required, hidePicker, max, min, containerProps, ...otherProps }, inputRef) => {
9
- const componentClassName = getClassName({
10
- baseClassName: "af-form__input-date",
11
- modifiers: classModifier.split(" "),
12
- className,
13
- });
14
9
  let inputId = useId();
15
10
  inputId = otherProps.id ?? inputId;
16
11
  const idMessage = useId();
@@ -26,6 +21,12 @@ const InputDateCommon = forwardRef(({ className, classModifier = "", helper, err
26
21
  const hasError = (Boolean(message) && messageType === "error") || Boolean(error);
27
22
  const ariaErrormessage = hasError ? idMessage : undefined;
28
23
  const ariaInvalid = hasError || undefined;
24
+ const hasWarning = Boolean(message) && messageType === "warning" && !hasError;
25
+ const componentClassName = getClassName({
26
+ baseClassName: "af-form__input-date",
27
+ modifiers: [...classModifier.split(" "), hasWarning && "warning"],
28
+ className,
29
+ });
29
30
  return (_jsxs("div", { className: "af-form__input-container", ...containerProps, children: [_jsx(ItemLabelComponent, { description: description, moreButtonLabel: moreButtonLabel ?? buttonLabel, onMoreButtonClick: onMoreButtonClick ?? onButtonClick, required: required, htmlFor: inputId, children: label }), hidePicker ? (_jsx(InputDateTextAtom, { ...otherProps, id: inputId, className: componentClassName, ref: inputRef, "aria-errormessage": ariaErrormessage, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedby, required: required })) : (_jsx(InputDateAtom, { ...otherProps, id: inputId, className: componentClassName, ref: inputRef, "aria-errormessage": ariaErrormessage, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedby, required: required, max: max, min: min })), helper ? (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: idMessage, message: message || error || success, messageType: messageType || (error ? "error" : "success") })] }));
30
31
  });
31
32
  InputDateCommon.displayName = "InputDate";
@@ -11,7 +11,7 @@ const InputTextCommon = forwardRef(({ unit, className, classModifier = "", helpe
11
11
  const ariaDescribedby = [helper && idHelp, success && idMessage].filter(Boolean);
12
12
  return (_jsxs("div", { className: "af-form__input-container", ...containerProps, children: [_jsx(ItemLabelComponent, { description: description, moreButtonLabel: moreButtonLabel ?? buttonLabel, onMoreButtonClick: onMoreButtonClick ?? onButtonClick, sideButtonLabel: sideButtonLabel, onSideButtonClick: onSideButtonClick, required: required, htmlFor: inputId, children: label }), _jsx(InputTextAtomComponent, { id: inputId, ref: inputRef, unit: unit, className: className, classModifier: classModifier, error: (message && messageType === "error") || Boolean(error)
13
13
  ? messageType || error
14
- : undefined, required: required, idMessage: message || error ? idMessage : undefined, idHelp: ariaDescribedby.length > 0 ? ariaDescribedby.join(" ") : undefined, ...otherProps }), helper ? (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: idMessage, message: message || error || success, messageType: messageType || (error ? "error" : "success") })] }));
14
+ : undefined, warning: message && messageType === "warning" ? messageType : undefined, required: required, idMessage: message || error ? idMessage : undefined, idHelp: ariaDescribedby.length > 0 ? ariaDescribedby.join(" ") : undefined, ...otherProps }), helper ? (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })) : null, _jsx(ItemMessageComponent, { id: idMessage, message: message || error || success, messageType: messageType || (error ? "error" : "success") })] }));
15
15
  });
16
16
  InputTextCommon.displayName = "InputText";
17
17
  export { InputTextCommon };
@@ -3,6 +3,7 @@ type InputTextAtomProps = ComponentPropsWithRef<"input"> & {
3
3
  unit?: ReactNode;
4
4
  classModifier?: string;
5
5
  error?: string;
6
+ warning?: string;
6
7
  idMessage?: string;
7
8
  idHelp?: string;
8
9
  };
@@ -1,10 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useId, } from "react";
3
3
  import { getClassName } from "../../utilities/getClassName";
4
- const InputTextAtom = forwardRef(({ unit, className, classModifier = "", error, required, idMessage, idHelp, "aria-errormessage": ariaErrormessage, "aria-describedby": ariaDescribedby, type = "text", ...otherProps }, inputRef) => {
4
+ const InputTextAtom = forwardRef(({ unit, className, classModifier = "", error, warning, required, idMessage, idHelp, "aria-errormessage": ariaErrormessage, "aria-describedby": ariaDescribedby, type = "text", ...otherProps }, inputRef) => {
5
5
  const componentClassName = getClassName({
6
6
  baseClassName: "af-form__input-text",
7
- modifiers: [classModifier, error || ariaErrormessage ? "error" : ""],
7
+ modifiers: [
8
+ classModifier,
9
+ error || ariaErrormessage ? "error" : "",
10
+ !error && !ariaErrormessage && warning ? "warning" : "",
11
+ ],
8
12
  className,
9
13
  });
10
14
  let inputId = useId();
@@ -6,10 +6,11 @@ export type HeadingCommonProps = PropsWithChildren<{
6
6
  level?: HeadingLevel;
7
7
  icon?: string;
8
8
  iconProps?: Omit<IconProps, "src">;
9
+ iconPosition?: "start" | "top";
9
10
  tag?: ReactNode;
10
11
  firstSubtitle?: ReactNode;
11
12
  secondSubtitle?: ReactNode;
12
13
  className?: string;
13
14
  }> & JSX.IntrinsicElements["div"];
14
15
  export declare const DEFAULT_TAG_PROPS: TagProps;
15
- export declare const HeadingCommon: ({ children: title, className, firstSubtitle, secondSubtitle, level, icon, iconProps, tag, ...props }: HeadingCommonProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const HeadingCommon: ({ children: title, className, firstSubtitle, secondSubtitle, level, icon, iconProps, iconPosition, tag, ...props }: HeadingCommonProps) => import("react/jsx-runtime").JSX.Element;
@@ -9,10 +9,11 @@ import { getClassName } from "../utilities/getClassName";
9
9
  export const DEFAULT_TAG_PROPS = {
10
10
  variant: "neutral",
11
11
  };
12
- export const HeadingCommon = ({ children: title, className, firstSubtitle, secondSubtitle, level = 1, icon, iconProps = {}, tag, ...props }) => {
12
+ export const HeadingCommon = ({ children: title, className, firstSubtitle, secondSubtitle, level = 1, icon, iconProps = {}, iconPosition = "start", tag, ...props }) => {
13
13
  const isMobile = useIsSmallScreen(BREAKPOINT.SM);
14
14
  return (_jsxs("div", { className: getClassName({
15
15
  baseClassName: "af-heading",
16
+ modifiers: [iconPosition === "top" && "icon-top"],
16
17
  className,
17
18
  }), ...props, children: [tag && level < 3 ? _jsx("div", { className: "af-heading__label", children: tag }) : null, icon ? (_jsx(Icon, { src: icon, size: isMobile
18
19
  ? headingLevelToIconSizeMobile[level]
@@ -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
  };
@@ -8,6 +8,7 @@ export type TabBarDirection = keyof typeof tabBarDirection;
8
8
  export type TabBarProps = {
9
9
  items: ({
10
10
  content: ReactNode;
11
+ handleSelectTab?: () => void;
11
12
  } & Omit<ItemTabBarProps, "content">)[];
12
13
  preSelectedTabIndex?: number;
13
14
  direction?: TabBarDirection;
@@ -13,11 +13,16 @@ export const TabBarCommon = ({ items, preSelectedTabIndex, direction = "left", I
13
13
  const tablistRef = useRef(null);
14
14
  const totalTabs = items.length;
15
15
  const isActive = (index) => index === selectedTabIndex;
16
+ const handleClickFn = (index) => {
17
+ setSelectedTabIndex(index);
18
+ items[index]?.handleSelectTab?.();
19
+ };
16
20
  const onChangeTab = useCallback((e) => {
17
21
  const firstTabIndex = 0;
18
22
  const lastTabIndex = totalTabs - 1;
19
23
  const goToNextTab = (nextTabIndex) => {
20
24
  setSelectedTabIndex(nextTabIndex);
25
+ items[nextTabIndex]?.handleSelectTab?.();
21
26
  buttonRefs.current[nextTabIndex].focus();
22
27
  e.stopPropagation();
23
28
  e.preventDefault();
@@ -43,7 +48,7 @@ export const TabBarCommon = ({ items, preSelectedTabIndex, direction = "left", I
43
48
  break;
44
49
  }
45
50
  }, [selectedTabIndex, totalTabs]);
46
- return (_jsxs("div", { className: classNames(CLASS_NAME, direction === tabBarDirection.center ? `${CLASS_NAME}--center` : ""), children: [_jsx("div", { role: "tablist", ref: tablistRef, children: items.map(({ title }, index) => (_jsx(ItemTabBarComponent, { id: `tab-${index}`, "aria-selected": isActive(index), "aria-controls": `tabpanel-${index}`, onKeyDown: onChangeTab, onClick: () => setSelectedTabIndex(index), ref: (element) => {
51
+ return (_jsxs("div", { className: classNames(CLASS_NAME, direction === tabBarDirection.center ? `${CLASS_NAME}--center` : ""), children: [_jsx("div", { role: "tablist", ref: tablistRef, children: items.map(({ title }, index) => (_jsx(ItemTabBarComponent, { id: `tab-${index}`, "aria-selected": isActive(index), "aria-controls": `tabpanel-${index}`, onKeyDown: onChangeTab, onClick: () => handleClickFn(index), ref: (element) => {
47
52
  buttonRefs.current[index] = element;
48
53
  }, tabIndex: isActive(index) ? 0 : -1, title: title }, `tab-${title}`))) }), items.map((item, index) => (_jsx("div", { role: "tabpanel", "aria-hidden": !isActive(index), id: `tabpanel-${index}`, "aria-labelledby": `tab-${index}`, children: item.content }, `tabpanel-${item.title}`)))] }));
49
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/canopee-react",
3
- "version": "1.5.1-alpha.3",
3
+ "version": "1.5.1-alpha.31",
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.3",
52
+ "@axa-fr/canopee-css": "1.5.1-alpha.31",
53
53
  "@material-symbols/svg-400": ">= 0.19.0",
54
54
  "@material-symbols/svg-700": ">= 0.19.0",
55
55
  "react": ">= 18"