@axa-fr/canopee-react 2.0.1-alpha.60 → 2.0.1-alpha.68
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/distributeur/ButtonMultiActions/ButtonMultiActions.js +1 -1
- package/dist/distributeur/HelpButton/index.d.ts +1 -1
- package/dist/distributeur/HelpButton/index.js +4 -2
- package/dist/distributeur/Layout/Header/HeaderTitle/HeaderTitle.d.ts +9 -1
- package/dist/distributeur/Layout/Header/HeaderTitle/HeaderTitle.js +3 -4
- package/dist/distributeur/Layout/Header/MenuTitleWrapper/MenuTitleWrapper.js +1 -1
- package/dist/distributeur/Layout/Header/NavBar/NavBar.helpers.d.ts +5 -0
- package/dist/distributeur/Layout/Header/NavBar/NavBar.helpers.js +12 -0
- package/dist/distributeur/Layout/Header/NavBar/NavBar.js +0 -3
- package/dist/distributeur/Layout/Header/NavBar/NavBarBase.js +4 -1
- package/dist/distributeur/Layout/Header/NavBar/NavBarItem/NavBarItem.js +4 -1
- package/dist/distributeur/Layout/Header/NavBar/NavBarItem/NavBarItemBase.js +5 -2
- package/dist/distributeur/Popover/AnimatedPopover.d.ts +3 -1
- package/dist/distributeur/Popover/AnimatedPopover.js +2 -2
- package/dist/distributeur/Popover/Popover.d.ts +3 -1
- package/dist/distributeur/Popover/Popover.js +2 -2
- package/dist/distributeur/Popover/Popover.types.d.ts +1 -0
- package/dist/distributeur/Popover/PopoverBase.d.ts +2 -1
- package/dist/distributeur/Popover/PopoverBase.js +2 -2
- package/dist/distributeur/Popover/PopoverClick.d.ts +1 -1
- package/dist/distributeur/Popover/PopoverClick.js +3 -2
- package/dist/distributeur/Popover/PopoverOver.d.ts +1 -1
- package/dist/distributeur/Popover/PopoverOver.js +3 -2
- package/dist/distributeur/Tabs/components/TabsStateless.d.ts +5 -1
- package/dist/distributeur/Tabs/components/TabsStateless.js +4 -4
- package/package.json +2 -2
|
@@ -41,7 +41,7 @@ export const ButtonMultiActions = ({ label = "Actions", menuLabel = "Actions sup
|
|
|
41
41
|
menuRef.current?.hidePopover();
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
return (_jsxs("div", { className: "af-button-multi-actions", ref: containerRef, children: [_jsx(Button, { ref: triggerRef, variant: "ghost", className: getClassName({
|
|
44
|
+
return (_jsxs("div", { className: "af-button-multi-actions", ref: containerRef, children: [_jsx(Button, { ref: triggerRef, id: id, variant: "ghost", className: getClassName({
|
|
45
45
|
baseClassName: "af-button-multi-actions__trigger",
|
|
46
46
|
modifiers: [align],
|
|
47
47
|
className,
|
|
@@ -5,5 +5,5 @@ type HelpProps = Omit<ComponentPropsWithoutRef<typeof Popover>, "popoverElement"
|
|
|
5
5
|
helpButtonContent?: ReactNode;
|
|
6
6
|
variant?: "default" | "inverse";
|
|
7
7
|
};
|
|
8
|
-
export declare const HelpButton: ({ className, children, mode, placement, variant, helpButtonContent, }: HelpProps) => import("react").JSX.Element;
|
|
8
|
+
export declare const HelpButton: ({ className, children, mode, placement, variant, helpButtonContent, triggerAriaLabel, }: HelpProps) => import("react").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -5,11 +5,13 @@ import info from "@material-symbols/svg-400/rounded/info_i-fill.svg";
|
|
|
5
5
|
import { Popover } from "../Popover";
|
|
6
6
|
import { getClassName } from "../utilities/helpers/getClassName";
|
|
7
7
|
import { Svg } from "../Svg";
|
|
8
|
-
export const HelpButton = ({ className, children, mode = "click", placement = "right", variant = "default", helpButtonContent
|
|
8
|
+
export const HelpButton = ({ className, children, mode = "click", placement = "right", variant = "default", helpButtonContent, triggerAriaLabel, }) => {
|
|
9
|
+
// The default icon is decorative: the trigger is named by its aria-label
|
|
10
|
+
const hasDefaultContent = helpButtonContent === undefined;
|
|
9
11
|
const buttonClassName = classNames("btn", getClassName({
|
|
10
12
|
baseClassName: "af-btn--circle",
|
|
11
13
|
modifiers: [variant === "inverse" && "inverse"],
|
|
12
14
|
className,
|
|
13
15
|
}));
|
|
14
|
-
return (_jsx(Popover, { className: classNames("af-help-button", className), placement: placement, mode: mode, popoverElement: children, children: _jsx("div", { className: buttonClassName, children: helpButtonContent }) }));
|
|
16
|
+
return (_jsx(Popover, { className: classNames("af-help-button", className), placement: placement, mode: mode, popoverElement: children, triggerAriaLabel: triggerAriaLabel ?? (hasDefaultContent ? "Aide" : undefined), children: _jsx("div", { className: buttonClassName, children: hasDefaultContent ? _jsx(Svg, { src: info }) : helpButtonContent }) }));
|
|
15
17
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "@axa-fr/canopee-css/distributeur/Action/Action.css";
|
|
1
2
|
import "@axa-fr/canopee-css/distributeur/Layout/Header/HeaderTitle/HeaderTitle.css";
|
|
2
3
|
import type { ReactNode } from "react";
|
|
3
4
|
import { type AnchorNavBarItem } from "../AnchorNavBar/AnchorNavBar";
|
|
@@ -10,7 +11,14 @@ type Props = {
|
|
|
10
11
|
subtitle?: string;
|
|
11
12
|
title: string;
|
|
12
13
|
toggleMenu?: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the menu opened by the toggle is open, exposed by aria-expanded.
|
|
16
|
+
* When set, the toggle also points to the NavBar ("mainmenu") with aria-controls.
|
|
17
|
+
*/
|
|
18
|
+
isMenuOpen?: boolean;
|
|
19
|
+
/** Accessible name of the menu toggle */
|
|
20
|
+
toggleMenuLabel?: string;
|
|
13
21
|
anchorNavBarItems?: AnchorNavBarItem[];
|
|
14
22
|
};
|
|
15
|
-
declare const HeaderTitle: ({ children, className, isSticky, contentLeft, contentRight, subtitle, title, toggleMenu, anchorNavBarItems, }: Props) => import("react").JSX.Element;
|
|
23
|
+
declare const HeaderTitle: ({ children, className, isSticky, contentLeft, contentRight, subtitle, title, toggleMenu, isMenuOpen, toggleMenuLabel, anchorNavBarItems, }: Props) => import("react").JSX.Element;
|
|
16
24
|
export { HeaderTitle };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/canopee-css/distributeur/Action/Action.css";
|
|
2
3
|
import "@axa-fr/canopee-css/distributeur/Layout/Header/HeaderTitle/HeaderTitle.css";
|
|
3
4
|
import classNames from "classnames";
|
|
4
|
-
import { Action } from "../../../Action/Action";
|
|
5
5
|
import { getClassName } from "../../../utilities";
|
|
6
6
|
import { AnchorNavBar, } from "../AnchorNavBar/AnchorNavBar";
|
|
7
|
-
import { ToggleButton } from "../ToggleButton/ToggleButton";
|
|
8
7
|
const defaultClassName = "af-title-bar";
|
|
9
|
-
const HeaderTitle = ({ children, className, isSticky = true, contentLeft, contentRight, subtitle, title, toggleMenu, anchorNavBarItems, }) => {
|
|
8
|
+
const HeaderTitle = ({ children, className, isSticky = true, contentLeft, contentRight, subtitle, title, toggleMenu, isMenuOpen, toggleMenuLabel = "Menu principal", anchorNavBarItems, }) => {
|
|
10
9
|
const componentClassName = getClassName({
|
|
11
10
|
baseClassName: defaultClassName,
|
|
12
11
|
modifiers: [isSticky && "sticky"],
|
|
13
12
|
className,
|
|
14
13
|
});
|
|
15
14
|
const isAnchorNavBarPresent = anchorNavBarItems && anchorNavBarItems.length > 0;
|
|
16
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classNames("af-container", componentClassName), children: [Boolean(toggleMenu) && (_jsx("div", { className: "burger-container", children: _jsx(
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classNames("af-container", componentClassName), children: [Boolean(toggleMenu) && (_jsx("div", { className: "burger-container", children: _jsx("button", { type: "button", className: "btn af-btn--circle af-title-bar__mobile-menu", id: "togglemenu", "aria-controls": isMenuOpen === undefined ? undefined : "mainmenu", "aria-expanded": isMenuOpen, "aria-label": toggleMenuLabel, onClick: toggleMenu, children: _jsx("i", { "aria-hidden": "true", className: "glyphicon glyphicon-menu-hamburger" }) }) })), _jsxs("div", { className: `${defaultClassName}__leftSection`, children: [contentLeft, _jsxs("h1", { className: `${defaultClassName}__title`, children: [title, subtitle ? (_jsx("span", { className: `${defaultClassName}__subtitle`, children: subtitle })) : null] }), children] }), contentRight ? (_jsx("div", { className: `${defaultClassName}__rightSection`, children: contentRight })) : null] }), isAnchorNavBarPresent ? (_jsx(AnchorNavBar, { items: anchorNavBarItems })) : null] }));
|
|
17
16
|
};
|
|
18
17
|
export { HeaderTitle };
|
|
@@ -9,6 +9,6 @@ const MenuTitleWrapper = ({ children, menuVisible, subtitle, title, navBarProps,
|
|
|
9
9
|
body.classList.toggle("af-menu-open");
|
|
10
10
|
setIsMenuVisible((prev) => !prev);
|
|
11
11
|
}, []);
|
|
12
|
-
return (_jsxs(_Fragment, { children: [_jsx(NavBar, { isVisible: isMenuVisible, onClick: handleClick, ...navBarProps, children: children }), _jsx(HeaderTitle, { title: title, subtitle: subtitle, toggleMenu: handleClick })] }));
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsx(NavBar, { isVisible: isMenuVisible, onClick: handleClick, ...navBarProps, children: children }), _jsx(HeaderTitle, { title: title, subtitle: subtitle, toggleMenu: handleClick, isMenuOpen: navBarProps?.isVisible ?? isMenuVisible })] }));
|
|
13
13
|
};
|
|
14
14
|
export { MenuTitleWrapper };
|
|
@@ -1 +1,6 @@
|
|
|
1
1
|
export declare const getPosition: (max: number, position: number, direction: string) => number;
|
|
2
|
+
/**
|
|
3
|
+
* Only the keys the NavBar handles lose their default action: Tab, Shift+Tab
|
|
4
|
+
* and Enter keep their native behavior (leave the menu, follow the link).
|
|
5
|
+
*/
|
|
6
|
+
export declare const isHandledKey: (key: string) => boolean;
|
|
@@ -10,3 +10,15 @@ export const getPosition = (max, position, direction) => {
|
|
|
10
10
|
return position;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
const HANDLED_KEYS = new Set([
|
|
14
|
+
"ArrowLeft",
|
|
15
|
+
"ArrowRight",
|
|
16
|
+
"ArrowUp",
|
|
17
|
+
"ArrowDown",
|
|
18
|
+
"Escape",
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* Only the keys the NavBar handles lose their default action: Tab, Shift+Tab
|
|
22
|
+
* and Enter keep their native behavior (leave the menu, follow the link).
|
|
23
|
+
*/
|
|
24
|
+
export const isHandledKey = (key) => HANDLED_KEYS.has(key);
|
|
@@ -7,9 +7,6 @@ const NavBar = ({ positionInit = 0, children, ...otherProps }) => {
|
|
|
7
7
|
const [position, setPosition] = useState(positionInit);
|
|
8
8
|
const validChildren = useMemo(() => (React.Children.map(children, (child) => isValidElement(child) && child) ?? []).filter((c) => Boolean(c)), [children]);
|
|
9
9
|
const handleKeys = useCallback((key) => {
|
|
10
|
-
if (key === "Escape") {
|
|
11
|
-
setIsMenuFocused(false);
|
|
12
|
-
}
|
|
13
10
|
if (key === "ArrowRight" || key === "ArrowLeft") {
|
|
14
11
|
const newPosition = getPosition(validChildren.length, position, key);
|
|
15
12
|
setPosition(newPosition);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import { getClassName } from "../../../utilities/helpers/getClassName";
|
|
4
|
+
import { isHandledKey } from "./NavBar.helpers";
|
|
4
5
|
const defaultClassName = "af-nav-container";
|
|
5
6
|
const NavBarBase = ({ onClick, id = "mainmenu", toggleMenuId = "togglemenu", isMenuFocused, className, handleKeys, onFocus, onBlur, children, isVisible, }) => {
|
|
6
7
|
const componentClassName = getClassName({
|
|
@@ -13,7 +14,9 @@ const NavBarBase = ({ onClick, id = "mainmenu", toggleMenuId = "togglemenu", isM
|
|
|
13
14
|
className: "af-drawer left",
|
|
14
15
|
});
|
|
15
16
|
return (_jsxs("div", { className: classNames("af-container", componentClassName), children: [isVisible ? (_jsx("button", { "aria-controls": id, "aria-haspopup": "true", type: "button", onClick: onClick, className: "mask fade", id: `open-${toggleMenuId}`, "aria-label": "Close Menu" })) : null, _jsxs("nav", { className: navClassName, role: "navigation", "aria-label": "Menu principal", children: [_jsxs("div", { className: "af-nav__aside-header", children: [_jsx("h4", { className: "af-nav__aside-title", children: "Menu" }), _jsx("button", { "aria-controls": id, "aria-haspopup": "true", onClick: onClick, type: "button", className: "af-nav__aside-close", id: `close-${toggleMenuId}`, "aria-label": "Close Menu", children: "\u00D7" })] }), _jsx("ul", { onKeyDown: (e) => {
|
|
16
|
-
e.
|
|
17
|
+
if (isHandledKey(e.key)) {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
}
|
|
17
20
|
handleKeys(e.key);
|
|
18
21
|
}, onFocus: (e) => {
|
|
19
22
|
onFocus({ e });
|
|
@@ -40,7 +40,10 @@ const NavBarItem = ({ children, hasFocus = false, actionElt, ariaLabel = "", tab
|
|
|
40
40
|
moveBykey(key);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
if (key === "ArrowRight" ||
|
|
43
|
+
if (key === "ArrowRight" ||
|
|
44
|
+
key === "ArrowLeft" ||
|
|
45
|
+
key === "Escape" ||
|
|
46
|
+
key === "Tab") {
|
|
44
47
|
closeMenu();
|
|
45
48
|
}
|
|
46
49
|
}, [children, isMenuOpen, position, moveBykey, openMenu, closeMenu]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, } from "react";
|
|
3
3
|
import { getClassName } from "../../../../utilities";
|
|
4
|
+
import { isHandledKey } from "../NavBar.helpers";
|
|
4
5
|
import { handleLinkFocus } from "./NavBarItemBase.helpers";
|
|
5
6
|
export const NavBarItemBase = ({ tabIndex = -1, role = "menuitem", children, hasFocus, handleKeys, isMenuOpen, className, actionElt, ...otherProps }) => {
|
|
6
7
|
const componentClassName = getClassName({
|
|
@@ -16,7 +17,9 @@ export const NavBarItemBase = ({ tabIndex = -1, role = "menuitem", children, has
|
|
|
16
17
|
*/
|
|
17
18
|
const openClass = useMemo(() => (hasFocus && isMenuOpen && children ? "af-nav__item--open" : ""), [children, hasFocus, isMenuOpen]);
|
|
18
19
|
return (_jsxs("li", { className: `${componentClassName} ${openClass}`, role: "none", onKeyDown: (e) => {
|
|
19
|
-
e.
|
|
20
|
+
if (isHandledKey(e.key)) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
}
|
|
20
23
|
handleKeys(e);
|
|
21
|
-
}, children: [_jsx(actionElt.type, { ...actionElt.props, ...otherProps, role: role, tabIndex: tabIndex, "aria-expanded": isMenuOpen }, actionElt.key), children] }));
|
|
24
|
+
}, children: [_jsx(actionElt.type, { ...actionElt.props, ...otherProps, role: role, tabIndex: tabIndex, "aria-expanded": isMenuOpen, ref: ref }, actionElt.key), children] }));
|
|
22
25
|
};
|
|
@@ -6,8 +6,10 @@ type PropsAnimatedPopover = {
|
|
|
6
6
|
isOpen: boolean;
|
|
7
7
|
target: React.ReactNode;
|
|
8
8
|
className?: string;
|
|
9
|
+
/** Id of the popover content, so that the trigger can reference it */
|
|
10
|
+
contentId?: string;
|
|
9
11
|
onMouseEnter?: (event: React.MouseEvent) => void;
|
|
10
12
|
onMouseLeave?: (event: React.MouseEvent) => void;
|
|
11
13
|
};
|
|
12
|
-
export declare const AnimatedPopover: ({ placement, children, isOpen, target, className, onMouseEnter, onMouseLeave, }: PropsAnimatedPopover) => React.JSX.Element;
|
|
14
|
+
export declare const AnimatedPopover: ({ placement, children, isOpen, target, className, contentId, onMouseEnter, onMouseLeave, }: PropsAnimatedPopover) => React.JSX.Element;
|
|
13
15
|
export {};
|
|
@@ -4,7 +4,7 @@ import { arrow, FloatingArrow, offset, useFloating, } from "@floating-ui/react";
|
|
|
4
4
|
import React, { useRef } from "react";
|
|
5
5
|
import { getClassName } from "../utilities/helpers/getClassName";
|
|
6
6
|
const defaultClassName = "af-popover__container";
|
|
7
|
-
export const AnimatedPopover = ({ placement, children, isOpen, target, className, onMouseEnter, onMouseLeave, }) => {
|
|
7
|
+
export const AnimatedPopover = ({ placement, children, isOpen, target, className, contentId, onMouseEnter, onMouseLeave, }) => {
|
|
8
8
|
const componentClassName = getClassName({
|
|
9
9
|
baseClassName: defaultClassName,
|
|
10
10
|
className,
|
|
@@ -17,5 +17,5 @@ export const AnimatedPopover = ({ placement, children, isOpen, target, className
|
|
|
17
17
|
elements: { reference: referenceElement, floating: popperElement },
|
|
18
18
|
middleware: [offset(12), arrow({ element: arrowRef })],
|
|
19
19
|
});
|
|
20
|
-
return (_jsxs("div", { className: componentClassName, children: [_jsx("div", { ref: setReferenceElement, className: "af-popover__container-over", role: "presentation", children: target }), isOpen ? (_jsxs("div", { ref: setPopperElement, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: floatingStyles, "data-popper-placement": placement, className: "af-popover__container-pop", children: [_jsx("div", { children: children }), _jsx(FloatingArrow, { ref: arrowRef, context: context, fill: "white", width: 16, height: 10 })] })) : null] }));
|
|
20
|
+
return (_jsxs("div", { className: componentClassName, children: [_jsx("div", { ref: setReferenceElement, className: "af-popover__container-over", role: "presentation", children: target }), isOpen ? (_jsxs("div", { ref: setPopperElement, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: floatingStyles, "data-popper-placement": placement, className: "af-popover__container-pop", children: [_jsx("div", { id: contentId, children: children }), _jsx(FloatingArrow, { ref: arrowRef, context: context, fill: "white", width: 16, height: 10 })] })) : null] }));
|
|
21
21
|
};
|
|
@@ -7,6 +7,8 @@ type Props = {
|
|
|
7
7
|
mode: PopoverModes;
|
|
8
8
|
popoverElement: React.ReactNode;
|
|
9
9
|
children: React.ReactNode;
|
|
10
|
+
/** Accessible name of the trigger, when its content does not give one */
|
|
11
|
+
triggerAriaLabel?: string;
|
|
10
12
|
};
|
|
11
|
-
declare const Popover: ({ children, placement, className, mode, popoverElement: content, }: Props) => React.JSX.Element;
|
|
13
|
+
declare const Popover: ({ children, placement, className, mode, popoverElement: content, triggerAriaLabel, }: Props) => React.JSX.Element;
|
|
12
14
|
export { Popover };
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { PopoverClick } from "./PopoverClick";
|
|
4
4
|
import { PopoverOver } from "./PopoverOver";
|
|
5
|
-
const Popover = ({ children, placement = "top", className, mode = "click", popoverElement: content, }) => {
|
|
5
|
+
const Popover = ({ children, placement = "top", className, mode = "click", popoverElement: content, triggerAriaLabel, }) => {
|
|
6
6
|
const Component = mode === "click" ? PopoverClick : PopoverOver;
|
|
7
|
-
return (_jsx(Component, { className: className, placement: placement, element: content, children: children }));
|
|
7
|
+
return (_jsx(Component, { className: className, placement: placement, element: content, triggerAriaLabel: triggerAriaLabel, children: children }));
|
|
8
8
|
};
|
|
9
9
|
export { Popover };
|
|
@@ -7,8 +7,9 @@ type Props = {
|
|
|
7
7
|
element: React.ReactNode;
|
|
8
8
|
children: React.ReactNode | React.ReactNode[];
|
|
9
9
|
isOpen: boolean;
|
|
10
|
+
contentId?: string;
|
|
10
11
|
onMouseEnter?: (event: React.MouseEvent) => void;
|
|
11
12
|
onMouseLeave?: (event: React.MouseEvent) => void;
|
|
12
13
|
};
|
|
13
|
-
declare const PopoverBase: ({ children, isOpen, placement, className, element, onMouseEnter, onMouseLeave, }: Props) => React.JSX.Element;
|
|
14
|
+
declare const PopoverBase: ({ children, isOpen, placement, className, element, contentId, onMouseEnter, onMouseLeave, }: Props) => React.JSX.Element;
|
|
14
15
|
export { PopoverBase };
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { AnimatedPopover } from "./AnimatedPopover";
|
|
4
4
|
import "@axa-fr/canopee-css/distributeur/Popover/Popover.css";
|
|
5
|
-
const PopoverBase = ({ children, isOpen, placement = "right", className, element, onMouseEnter, onMouseLeave, }) => {
|
|
6
|
-
return (_jsx(AnimatedPopover, { target: children, placement: placement, isOpen: isOpen, className: className, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: element }));
|
|
5
|
+
const PopoverBase = ({ children, isOpen, placement = "right", className, element, contentId, onMouseEnter, onMouseLeave, }) => {
|
|
6
|
+
return (_jsx(AnimatedPopover, { target: children, placement: placement, isOpen: isOpen, className: className, contentId: contentId, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: element }));
|
|
7
7
|
};
|
|
8
8
|
export { PopoverBase };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { PopoverProps } from "./Popover.types";
|
|
3
|
-
export declare const PopoverClick: ({ children, placement, className, element, }: PopoverProps) => React.JSX.Element;
|
|
3
|
+
export declare const PopoverClick: ({ children, placement, className, element, triggerAriaLabel, }: PopoverProps) => React.JSX.Element;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { PopoverBase } from "./PopoverBase";
|
|
4
|
-
export const PopoverClick = ({ children, placement, className, element, }) => {
|
|
4
|
+
export const PopoverClick = ({ children, placement, className, element, triggerAriaLabel, }) => {
|
|
5
5
|
const wrapperRef = React.useRef(null);
|
|
6
|
+
const contentId = React.useId();
|
|
6
7
|
const [isOpen, setOpen] = React.useState(false);
|
|
7
8
|
const [isPopoverHover, setPopoverHover] = React.useState(false);
|
|
8
9
|
const handleClick = (event, isOpenValue) => {
|
|
@@ -23,5 +24,5 @@ export const PopoverClick = ({ children, placement, className, element, }) => {
|
|
|
23
24
|
const handleMouseLeavePopover = () => {
|
|
24
25
|
setPopoverHover(false);
|
|
25
26
|
};
|
|
26
|
-
return (_jsx("div", { role: "button", tabIndex: 0, ref: wrapperRef, className: "af-popover__wrapper af-popover__wrapper--click", onKeyDown: handleKeyDown, onClick: handleClick, onBlur: (event) => handleClick(event, false), children: _jsx(PopoverBase, { onMouseEnter: handleMouseEnterPopover, onMouseLeave: handleMouseLeavePopover, isOpen: isOpen, placement: placement, className: className, element: element, children: children }) }));
|
|
27
|
+
return (_jsx("div", { role: "button", tabIndex: 0, "aria-label": triggerAriaLabel, "aria-describedby": isOpen && triggerAriaLabel ? contentId : undefined, ref: wrapperRef, className: "af-popover__wrapper af-popover__wrapper--click", onKeyDown: handleKeyDown, onClick: handleClick, onBlur: (event) => handleClick(event, false), children: _jsx(PopoverBase, { onMouseEnter: handleMouseEnterPopover, onMouseLeave: handleMouseLeavePopover, isOpen: isOpen, placement: placement, className: className, element: element, contentId: contentId, children: children }) }));
|
|
27
28
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { PopoverProps } from "./Popover.types";
|
|
3
|
-
export declare const PopoverOver: ({ children, placement, className, element: content, }: PopoverProps) => React.JSX.Element;
|
|
3
|
+
export declare const PopoverOver: ({ children, placement, className, element: content, triggerAriaLabel, }: PopoverProps) => React.JSX.Element;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { PopoverBase } from "./PopoverBase";
|
|
4
|
-
export const PopoverOver = ({ children, placement, className, element: content, }) => {
|
|
4
|
+
export const PopoverOver = ({ children, placement, className, element: content, triggerAriaLabel, }) => {
|
|
5
5
|
const [isOpen, setOpen] = React.useState(false);
|
|
6
|
+
const contentId = React.useId();
|
|
6
7
|
const handleMouseEnter = () => {
|
|
7
8
|
setOpen(true);
|
|
8
9
|
};
|
|
9
10
|
const handleMouseLeave = () => {
|
|
10
11
|
setOpen(false);
|
|
11
12
|
};
|
|
12
|
-
return (_jsx("div", { role: "button", tabIndex: 0, className: "af-popover__wrapper af-popover__wrapper--over", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleMouseEnter, onBlur: handleMouseLeave, children: _jsx(PopoverBase, { isOpen: isOpen, placement: placement, className: className, element: content, children: children }) }));
|
|
13
|
+
return (_jsx("div", { role: "button", tabIndex: 0, "aria-label": triggerAriaLabel, "aria-describedby": isOpen && triggerAriaLabel ? contentId : undefined, className: "af-popover__wrapper af-popover__wrapper--over", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleMouseEnter, onBlur: handleMouseLeave, children: _jsx(PopoverBase, { isOpen: isOpen, placement: placement, className: className, element: content, contentId: contentId, children: children }) }));
|
|
13
14
|
};
|
|
@@ -4,10 +4,14 @@ export type TabsStatelessProps = {
|
|
|
4
4
|
children: ReactElement<TabProps> | ReactElement<TabProps>[];
|
|
5
5
|
activeIndex: number;
|
|
6
6
|
className?: string;
|
|
7
|
+
/** Accessible name of the tab list */
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
/** Id of the element that names the tab list */
|
|
10
|
+
"aria-labelledby"?: string;
|
|
7
11
|
};
|
|
8
12
|
export type TabsStatelessHandlers = {
|
|
9
13
|
onChange: (event: SyntheticEvent<HTMLButtonElement>, index: number) => void;
|
|
10
14
|
};
|
|
11
15
|
type Props = TabsStatelessProps & TabsStatelessHandlers;
|
|
12
|
-
declare const TabsStateless: ({ activeIndex, className, children, onChange, }: Props) => import("react").JSX.Element;
|
|
16
|
+
declare const TabsStateless: ({ activeIndex, className, children, onChange, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: Props) => import("react").JSX.Element;
|
|
13
17
|
export { TabsStateless };
|
|
@@ -22,7 +22,7 @@ function handleKeyDown(event, moveToTab, index, totalNumberOfTabs) {
|
|
|
22
22
|
event.stopPropagation();
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
const TabsStateless = ({ activeIndex, className = "af-tabs", children, onChange, }) => {
|
|
25
|
+
const TabsStateless = ({ activeIndex, className = "af-tabs", children, onChange, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }) => {
|
|
26
26
|
const componentClassName = getClassName({
|
|
27
27
|
baseClassName: "af-tabs",
|
|
28
28
|
className,
|
|
@@ -37,13 +37,13 @@ const TabsStateless = ({ activeIndex, className = "af-tabs", children, onChange,
|
|
|
37
37
|
onChange(event, index);
|
|
38
38
|
};
|
|
39
39
|
const id = useId();
|
|
40
|
-
return (_jsxs("div", { className: componentClassName,
|
|
40
|
+
return (_jsxs("div", { className: componentClassName, children: [_jsx("ul", { className: "af-tabs__control", role: "tablist", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children: Children.map(children, (child, index) => isValidElement(child) && (_jsx("li", { role: "presentation", className: getClassName({
|
|
41
41
|
className,
|
|
42
42
|
modifiers: [activeIndex === index && "active"],
|
|
43
43
|
baseClassName: "af-tabs__item",
|
|
44
|
-
}), children: _jsx("button", { type: "button", id: `${id}-tab-${index}`, ref: (el) => {
|
|
44
|
+
}), children: _jsx("button", { type: "button", role: "tab", "aria-selected": activeIndex === index, id: `${id}-tab-${index}`, ref: (el) => {
|
|
45
45
|
tabRefs.current[index] = el;
|
|
46
|
-
}, "aria-controls": `${id}-pane-${index}`,
|
|
46
|
+
}, "aria-controls": `${id}-pane-${index}`, onKeyDown: (event) => {
|
|
47
47
|
handleKeyDown(event, moveToTab, index, Children.count(children));
|
|
48
48
|
}, className: "af-tabs__link", onClick: (event) => onChange(event, index), tabIndex: activeIndex === index ? 0 : -1, children: child.props.title }) }))) }), _jsx("div", { className: "af-tabs__content", children: Children.map(children, (child, index) => isValidElement(child) && (_jsx("div", { id: `${id}-pane-${index}`, "aria-labelledby": `${id}-tab-${index}`, className: getClassName({
|
|
49
49
|
baseClassName: "af-tabs__pane",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/canopee-react",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.68",
|
|
4
4
|
"description": "Package React - Design System Canopée",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@axa-fr/canopee-css": "2.0.1-alpha.
|
|
57
|
+
"@axa-fr/canopee-css": "2.0.1-alpha.68",
|
|
58
58
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
59
59
|
"@material-symbols/svg-700": ">= 0.19.0",
|
|
60
60
|
"react": ">= 19"
|