@axa-fr/design-system-look-and-feel-react 1.0.5-alpha.324 → 1.0.5-alpha.326
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,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import "@axa-fr/design-system-look-and-feel-css/dist/common/reboot.scss";
|
|
3
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Layout/Footer/Footer.scss";
|
|
4
3
|
import expandMore from "@material-symbols/svg-400/outlined/keyboard_arrow_down.svg";
|
|
5
4
|
import classNames from "classnames";
|
|
@@ -4,10 +4,9 @@ import "@axa-fr/design-system-look-and-feel-css/dist/Card/Card.scss";
|
|
|
4
4
|
import "@axa-fr/design-system-look-and-feel-css/dist/List/List.scss";
|
|
5
5
|
import "@axa-fr/design-system-look-and-feel-css/dist/List/ClickItem/ClickItem.scss";
|
|
6
6
|
type BurgerMenuProps = {
|
|
7
|
-
|
|
7
|
+
refModal: React.RefObject<HTMLDialogElement | null>;
|
|
8
8
|
items: ReactElement[];
|
|
9
9
|
setActiveLink: Dispatch<SetStateAction<number | undefined>>;
|
|
10
|
-
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
|
11
10
|
} & ComponentPropsWithoutRef<"nav">;
|
|
12
|
-
declare const BurgerMenu: ({
|
|
11
|
+
declare const BurgerMenu: ({ items, setActiveLink, refModal, ...props }: BurgerMenuProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
12
|
export { BurgerMenu };
|
|
@@ -5,15 +5,15 @@ import "@axa-fr/design-system-look-and-feel-css/dist/List/List.scss";
|
|
|
5
5
|
import "@axa-fr/design-system-look-and-feel-css/dist/List/ClickItem/ClickItem.scss";
|
|
6
6
|
import classNames from "classnames";
|
|
7
7
|
import { ClickItem, createClickItemParent } from "../../../List/ClickItem";
|
|
8
|
-
const BurgerMenu = ({
|
|
8
|
+
const BurgerMenu = ({ items, setActiveLink, refModal, ...props }) => {
|
|
9
9
|
const handleOnClick = (index) => () => {
|
|
10
10
|
setActiveLink(index);
|
|
11
|
-
|
|
11
|
+
refModal.current?.close();
|
|
12
12
|
};
|
|
13
13
|
if (items.length === 0)
|
|
14
14
|
return null;
|
|
15
|
-
return (_jsx("nav", { role: "navigation", "aria-label": "Menu principal mobile", "aria-hidden": !
|
|
16
|
-
open:
|
|
15
|
+
return (_jsx("nav", { role: "navigation", "aria-label": "Menu principal mobile", "aria-hidden": !refModal.current?.open, className: classNames("af-card", "af-card--list", "af-burger-menu", {
|
|
16
|
+
open: refModal.current?.open,
|
|
17
17
|
}), ...props, children: _jsx("ul", { role: "menubar", children: items.map((item, index) => {
|
|
18
18
|
const { key, props: itemProps, type } = item;
|
|
19
19
|
const { children, ...otherProps } = itemProps;
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Layout/Header/Header.scss";
|
|
3
3
|
import logo from "@axa-fr/design-system-look-and-feel-css/logo-axa.svg";
|
|
4
|
-
import { Children, isValidElement, useCallback, useEffect, useMemo, useState, } from "react";
|
|
4
|
+
import { Children, isValidElement, useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
5
5
|
import menu from "@material-symbols/svg-400/outlined/menu.svg";
|
|
6
6
|
import { NavBar } from "./NavBar";
|
|
7
7
|
import { PreviousLink } from "./PreviousLink/PreviousLink";
|
|
8
|
-
import { Button, IconBg, Svg } from "../..";
|
|
8
|
+
import { Button, IconBg, Modal, Svg } from "../..";
|
|
9
9
|
import { BurgerMenu } from "./BurgerMenu";
|
|
10
10
|
import { BREAKPOINT } from "../../utilities";
|
|
11
11
|
export const Header = ({ children, defaultActiveLink, previousLink, rightItem, ...props }) => {
|
|
12
12
|
const [activeLink, setActiveLink] = useState(defaultActiveLink);
|
|
13
|
-
const
|
|
14
|
-
const toggleMenu = () =>
|
|
13
|
+
const ref = useRef(null);
|
|
14
|
+
const toggleMenu = () => {
|
|
15
|
+
ref.current?.showModal();
|
|
16
|
+
};
|
|
15
17
|
const resetActiveLink = useCallback(() => setActiveLink(defaultActiveLink), [defaultActiveLink]);
|
|
16
18
|
useEffect(() => {
|
|
17
19
|
const handleResize = () => {
|
|
18
|
-
if (window.innerWidth > BREAKPOINT.MD &&
|
|
19
|
-
|
|
20
|
+
if (window.innerWidth > BREAKPOINT.MD && ref.current?.open) {
|
|
21
|
+
ref.current?.close();
|
|
20
22
|
}
|
|
21
23
|
};
|
|
22
24
|
window.addEventListener("resize", handleResize);
|
|
23
25
|
return () => window.removeEventListener("resize", handleResize);
|
|
24
|
-
}, [
|
|
26
|
+
}, [ref.current?.open]);
|
|
25
27
|
const burgerMenuItems = useMemo(() => {
|
|
26
28
|
const mapValidElements = (items) => (Children.map(items, (child) => isValidElement(child) && child) ?? []).filter(Boolean);
|
|
27
29
|
const validLinks = mapValidElements(children);
|
|
@@ -33,5 +35,9 @@ export const Header = ({ children, defaultActiveLink, previousLink, rightItem, .
|
|
|
33
35
|
}
|
|
34
36
|
return [...validLinks, rightItem];
|
|
35
37
|
}, [children, rightItem]);
|
|
36
|
-
return (_jsxs(_Fragment, { children: [
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsx("header", { className: "af-header", ...props, children: _jsxs("div", { className: "af-header-container", children: [_jsxs("div", { className: "af-header-left-item", children: [_jsx("img", { className: "af-logo", src: logo, alt: "logo AXA" }), _jsx(NavBar, { activeLink: activeLink, setActiveLink: setActiveLink, children: children })] }), rightItem && _jsx("div", { className: "af-header-right-item", children: rightItem }), burgerMenuItems && burgerMenuItems.length > 0 && (_jsx(Button, { "aria-label": "Ouvrir le menu", onClick: toggleMenu, variant: "ghost", children: _jsx(IconBg, { children: _jsx(Svg, { src: menu, "aria-hidden": "true" }) }) }))] }) }), _jsx(PreviousLink, { handleClick: resetActiveLink, children: previousLink }), _jsx(Modal, { ref: ref, onClose: () => {
|
|
39
|
+
ref.current?.close();
|
|
40
|
+
}, onCancel: () => {
|
|
41
|
+
ref.current?.close();
|
|
42
|
+
}, title: "Menu principal", role: "dialog", children: _jsx(BurgerMenu, { refModal: ref, items: burgerMenuItems, setActiveLink: setActiveLink }) })] }));
|
|
37
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-look-and-feel-react",
|
|
3
|
-
"version": "1.0.5-alpha.
|
|
3
|
+
"version": "1.0.5-alpha.326",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.
|
|
50
|
+
"@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.326",
|
|
51
51
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
52
52
|
"react": ">= 18",
|
|
53
|
-
"@axa-fr/design-system-apollo-react": "1.0.5-alpha.
|
|
53
|
+
"@axa-fr/design-system-apollo-react": "1.0.5-alpha.326"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"@material-symbols/svg-400": {
|