@axa-fr/design-system-look-and-feel-react 1.0.5-ci.28 → 1.0.5-ci.29

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.
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { type ModalCoreProps } from "./ModalCore";
3
+ import { type ModalCoreHeaderProps } from "./components/ModalCoreHeader";
4
+ export type ModalProps = Omit<ModalCoreProps, "onOutsideTap" | "title"> & ModalCoreHeaderProps & {
5
+ onSubmit?: (event: React.MouseEvent | React.KeyboardEvent) => void;
6
+ submitTitle?: string;
7
+ cancelTitle?: string;
8
+ submitDisabled?: boolean;
9
+ cancelDisabled?: boolean;
10
+ };
11
+ declare const Modal: React.ForwardRefExoticComponent<Omit<ModalProps, "ref"> & React.RefAttributes<HTMLDialogElement>>;
12
+ export { Modal };
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { ModalCore } from "./ModalCore";
4
+ import { ButtonClient, Variants as ButtonVariants } from "../Button/Button";
5
+ import { ModalCoreHeader, } from "./components/ModalCoreHeader";
6
+ import { ModalCoreBody } from "./components/ModalCoreBody";
7
+ import { ModalCoreFooter } from "./components/ModalCoreFooter";
8
+ const Modal = forwardRef(({ children, title, submitTitle, cancelTitle, className, onCancel, onSubmit, closeButtonAriaLabel, cancelDisabled, submitDisabled, subtitle, iconTitle, levelTitle, ...props }, ref) => (_jsxs(ModalCore, { className: className, onOutsideTap: onCancel, title: title, ref: ref, ...props, children: [_jsx(ModalCoreHeader, { title: title, subtitle: subtitle, iconTitle: iconTitle, levelTitle: levelTitle, onCancel: onCancel, closeButtonAriaLabel: closeButtonAriaLabel }), _jsx(ModalCoreBody, { children: children }), _jsxs(ModalCoreFooter, { children: [onCancel && cancelTitle && (_jsx(ButtonClient, { variant: ButtonVariants.secondary, onClick: onCancel, disabled: cancelDisabled, children: cancelTitle })), onSubmit && submitTitle && (_jsx(ButtonClient, { variant: ButtonVariants.primary, onClick: onSubmit, disabled: submitDisabled, children: submitTitle }))] })] })));
9
+ Modal.displayName = "Modal";
10
+ export { Modal };
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
3
+ export type ModalCoreProps = React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> & {
4
+ className?: string;
5
+ title: string;
6
+ onOutsideTap: (event: React.MouseEvent | React.KeyboardEvent) => void;
7
+ children: ReactNode;
8
+ ref?: React.Ref<HTMLDialogElement>;
9
+ };
10
+ declare const ModalCore: import("react").ForwardRefExoticComponent<Omit<ModalCoreProps, "ref"> & import("react").RefAttributes<HTMLDialogElement>>;
11
+ export { ModalCore };
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
4
+ const ModalCore = forwardRef(({ className, title = "", onOutsideTap, children, ...props }, ref) => (_jsx("dialog", { "aria-describedby": title, className: ["af-modal", className].filter(Boolean).join(" "), onClick: onOutsideTap, ref: ref, ...props, children: _jsx("div", { className: "af-modal__dialog", onClick: (e) => e.stopPropagation(), children: _jsx("div", { className: "af-modal__content", children: children }) }) })));
5
+ ModalCore.displayName = "ModalCore";
6
+ export { ModalCore };
@@ -0,0 +1,2 @@
1
+ export type ModalCoreBodyProps = React.HTMLAttributes<HTMLDivElement>;
2
+ export declare const ModalCoreBody: ({ children, className, ...otherProps }: ModalCoreBodyProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const ModalCoreBody = ({ children, className, ...otherProps }) => (_jsx("section", { className: ["af-modal__body", className].filter(Boolean).join(" "), ...otherProps, children: children }));
@@ -0,0 +1,2 @@
1
+ export type ModalCoreFooterProps = React.HTMLAttributes<HTMLDivElement>;
2
+ export declare const ModalCoreFooter: ({ className, ...rest }: ModalCoreFooterProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const ModalCoreFooter = ({ className, ...rest }) => (_jsx("footer", { className: ["af-modal__footer", className].filter(Boolean).join(" "), ...rest }));
@@ -0,0 +1,11 @@
1
+ import type { TitleLevel } from "../../Title";
2
+ export type ModalCoreHeaderProps = React.HTMLAttributes<HTMLDivElement> & {
3
+ className?: string;
4
+ title: string;
5
+ subtitle?: string;
6
+ iconTitle?: string;
7
+ levelTitle?: TitleLevel;
8
+ onCancel: (event: React.MouseEvent | React.KeyboardEvent) => void;
9
+ closeButtonAriaLabel?: string;
10
+ };
11
+ export declare const ModalCoreHeader: ({ className, title, subtitle, iconTitle, levelTitle, onCancel, closeButtonAriaLabel, ...props }: ModalCoreHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import closeSmall from "@material-symbols/svg-400/outlined/close.svg";
3
+ import { ButtonClient, Variants } from "../../Button/Button";
4
+ import { Svg } from "../../Svg";
5
+ export const ModalCoreHeader = ({ className, title, subtitle, iconTitle, levelTitle = 2, onCancel, closeButtonAriaLabel = "Fermer la boite de dialogue", ...props }) => {
6
+ const HLevel = `h${levelTitle}`;
7
+ return (_jsxs("header", { className: ["af-modal__header", className].filter(Boolean).join(" "), ...props, children: [_jsx(ButtonClient, { variant: Variants.ghost, iconLeft: _jsx(Svg, { src: closeSmall, width: 32, height: 32, role: "graphics-document" }), "aria-label": closeButtonAriaLabel, onClick: onCancel }), _jsxs("div", { className: "af-modal__header-title", children: [iconTitle && (_jsx(Svg, { src: iconTitle, width: 32, height: 32, role: "graphics-document" })), _jsx(HLevel, { className: "af-modal__header-title-heading", children: title }), subtitle && (_jsx("span", { className: "af-modal__header-title-subtitle", children: subtitle }))] })] }));
8
+ };
@@ -0,0 +1,5 @@
1
+ export { Modal, type ModalProps } from "./Modal";
2
+ export { ModalCore, type ModalCoreProps } from "./ModalCore";
3
+ export { ModalCoreFooter, type ModalCoreFooterProps, } from "./components/ModalCoreFooter";
4
+ export { ModalCoreHeader, type ModalCoreHeaderProps, } from "./components/ModalCoreHeader";
5
+ export { ModalCoreBody, type ModalCoreBodyProps, } from "./components/ModalCoreBody";
@@ -0,0 +1,5 @@
1
+ export { Modal } from "./Modal";
2
+ export { ModalCore } from "./ModalCore";
3
+ export { ModalCoreFooter, } from "./components/ModalCoreFooter";
4
+ export { ModalCoreHeader, } from "./components/ModalCoreHeader";
5
+ export { ModalCoreBody, } from "./components/ModalCoreBody";
package/dist/index.d.ts CHANGED
@@ -22,8 +22,6 @@ export { ContentItemDuo } from "./List/ContentItemDuo";
22
22
  export { ContentItemMono, ContentItemMonoSize } from "./List/ContentItemMono";
23
23
  export { ContentTabItem, ContentTabList } from "./List/ContentTabList";
24
24
  export { Loader } from "./Loader";
25
- export { Modal } from "./ModalClient";
26
- export type { ButtonAction as ModalButtonAction } from "./ModalClient/type";
27
25
  export { Pagination } from "./Pagination/Pagination";
28
26
  export { Skeleton } from "./Skeleton/Skeleton";
29
27
  export { SkeletonList } from "./SkeletonList/SkeletonList";
@@ -34,3 +32,5 @@ export { Tag } from "./Tag";
34
32
  export { Title, TitleSize, type TitleLevel } from "./Title";
35
33
  export { DebugGrid } from "./Grid/DebugGrid";
36
34
  export { Divider } from "./Divider";
35
+ export { Modal, ModalCore, ModalCoreHeader, ModalCoreFooter, ModalCoreBody, } from "./Modal";
36
+ export type { ModalProps, ModalCoreProps, ModalCoreHeaderProps, ModalCoreFooterProps, ModalCoreBodyProps, } from "./Modal";
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ export { ContentItemDuo } from "./List/ContentItemDuo";
21
21
  export { ContentItemMono, ContentItemMonoSize } from "./List/ContentItemMono";
22
22
  export { ContentTabItem, ContentTabList } from "./List/ContentTabList";
23
23
  export { Loader } from "./Loader";
24
- export { Modal } from "./ModalClient";
25
24
  export { Pagination } from "./Pagination/Pagination";
26
25
  export { Skeleton } from "./Skeleton/Skeleton";
27
26
  export { SkeletonList } from "./SkeletonList/SkeletonList";
@@ -32,3 +31,4 @@ export { Tag } from "./Tag";
32
31
  export { Title, TitleSize } from "./Title";
33
32
  export { DebugGrid } from "./Grid/DebugGrid";
34
33
  export { Divider } from "./Divider";
34
+ export { Modal, ModalCore, ModalCoreHeader, ModalCoreFooter, ModalCoreBody, } from "./Modal";
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-ci.28",
3
+ "version": "1.0.5-ci.29",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "homepage": "https://github.com/AxaFrance/design-system#readme",
47
47
  "peerDependencies": {
48
- "@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.28",
48
+ "@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.29",
49
49
  "@material-symbols/svg-400": ">= 0.19.0",
50
50
  "react": ">= 18"
51
51
  },
@@ -1,4 +0,0 @@
1
- import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
2
- import { PropsWithChildren } from "react";
3
- import { ModalProps } from "./type";
4
- export declare const ModalContainer: ({ open, setIsOpen, hasCloseButton, onClose, onClickOutside, children, title, subtitle, iconTitle, actions, fullWidthButtons, }: PropsWithChildren<ModalProps>) => import("react").ReactPortal;
@@ -1,45 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
3
- import { useEffect, useId, useRef } from "react";
4
- import { createPortal } from "react-dom";
5
- import { Modal } from "./Modal";
6
- import { useModal } from "./Modal.hook";
7
- export const ModalContainer = ({ open, setIsOpen, hasCloseButton = true, onClose, onClickOutside, children, title, subtitle, iconTitle, actions, fullWidthButtons, }) => {
8
- const { handleClickOutside, handleKeyDown, handleCloseModal } = useModal({
9
- setIsOpen,
10
- onClose,
11
- onClickOutside,
12
- });
13
- const modalRef = useRef(null);
14
- const idTitle = useId();
15
- const idContent = useId();
16
- const actionCallback = (callback) => {
17
- callback?.();
18
- setIsOpen(false);
19
- };
20
- useEffect(() => {
21
- const modalElement = modalRef.current;
22
- if (modalElement) {
23
- if (open) {
24
- document.body.style.overflow = "hidden";
25
- modalElement.showModal?.();
26
- }
27
- else {
28
- document.body.style.overflow = "inherit";
29
- modalElement.close?.();
30
- }
31
- }
32
- return () => {
33
- document.body.style.overflow = "inherit";
34
- };
35
- }, [open]);
36
- useEffect(() => {
37
- document.body.addEventListener("keydown", handleKeyDown);
38
- document.body.addEventListener("click", handleClickOutside);
39
- return () => {
40
- document.body.removeEventListener("keydown", handleKeyDown);
41
- document.body.removeEventListener("click", handleClickOutside);
42
- };
43
- }, [handleClickOutside, handleKeyDown]);
44
- return createPortal(_jsx(Modal, { modalRef: modalRef, idTitle: idTitle, idContent: idContent, iconTitle: iconTitle, title: title, subtitle: subtitle, hasCloseButton: hasCloseButton, handleCloseModal: handleCloseModal, actionCallback: actionCallback, actions: actions, fullWidthButtons: fullWidthButtons, children: children }), document.body);
45
- };
@@ -1,4 +0,0 @@
1
- import { PropsWithChildren } from "react";
2
- import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
3
- import { TModalType } from "./type";
4
- export declare const Modal: ({ modalRef, idTitle, idContent, iconTitle, title, subtitle, hasCloseButton, handleCloseModal, actionCallback, children, actions, fullWidthButtons, }: PropsWithChildren<TModalType>) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import { TModalHook } from "./type";
2
- export declare const useModal: ({ setIsOpen, onClose, onClickOutside, }: TModalHook) => {
3
- handleClickOutside: (event: MouseEvent) => void;
4
- handleKeyDown: (event: KeyboardEvent) => void;
5
- handleCloseModal: () => void;
6
- };
@@ -1,25 +0,0 @@
1
- import { useCallback } from "react";
2
- export const useModal = ({ setIsOpen, onClose, onClickOutside, }) => {
3
- const handleCloseModal = useCallback(() => {
4
- onClose?.();
5
- setIsOpen(false);
6
- }, [onClose, setIsOpen]);
7
- const handleClickOutside = useCallback((event) => {
8
- if (event.target.tagName !== "DIALOG") {
9
- return;
10
- }
11
- if (onClickOutside) {
12
- onClickOutside();
13
- setIsOpen(false);
14
- }
15
- else {
16
- handleCloseModal();
17
- }
18
- }, [handleCloseModal, onClickOutside, setIsOpen]);
19
- const handleKeyDown = useCallback((event) => {
20
- if (event.key === "Escape") {
21
- handleCloseModal();
22
- }
23
- }, [handleCloseModal]);
24
- return { handleClickOutside, handleKeyDown, handleCloseModal };
25
- };
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import close from "@material-symbols/svg-400/outlined/close.svg";
3
- import { ButtonClient as Button, Variants, Variants as ButtonVariants, } from "../Button/Button";
4
- import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
5
- import { Svg } from "../Svg";
6
- export const Modal = ({ modalRef, idTitle, idContent, iconTitle, title, subtitle, hasCloseButton, handleCloseModal, actionCallback, children, actions, fullWidthButtons, }) => (_jsxs("dialog", { ref: modalRef, className: "af-modal", "aria-labelledby": idTitle, "aria-describedby": idContent, children: [_jsxs("div", { id: idTitle, className: "af-modal__top", children: [iconTitle, _jsxs("h2", { className: "af-modal__top-title", children: [_jsxs("div", { children: [_jsx("div", { className: "af-modal__top-title-text", children: title }), subtitle && (_jsx("span", { className: "af-modal__top-title-subtitle", children: subtitle }))] }), hasCloseButton && (_jsx(Button, { className: "af-modal__top-title-close-btn", onClick: handleCloseModal, variant: Variants.ghost, type: "button", "aria-label": "close", children: _jsx(Svg, { src: close, width: 32, height: 32 }) }))] })] }), _jsxs("div", { id: idContent, className: "af-modal__content", children: [children, actions && (_jsxs("div", { className: `af-modal__actions${fullWidthButtons ? " af-modal__actions--fullWidth" : ""} `, children: [actions?.primary && (_jsx(Button, { variant: ButtonVariants.primary, onClick: () => actionCallback(actions?.primary?.callback), disabled: actions?.primary.disabled, children: actions?.primary.text })), actions?.secondary && (_jsx(Button, { variant: ButtonVariants.secondary, onClick: () => actionCallback(actions?.secondary?.callback), disabled: actions?.secondary.disabled, children: actions?.secondary.text })), actions?.tertiary && (_jsx(Button, { variant: ButtonVariants.tertiary, onClick: () => actionCallback(actions?.tertiary?.callback), disabled: actions?.tertiary.disabled, children: actions?.tertiary.text }))] }))] })] }));
@@ -1 +0,0 @@
1
- export { ModalContainer as Modal } from "./Modal.container";
@@ -1 +0,0 @@
1
- export { ModalContainer as Modal } from "./Modal.container";
@@ -1,38 +0,0 @@
1
- import { ReactNode, RefObject } from "react";
2
- export type ButtonAction = {
3
- text: string;
4
- disabled?: boolean;
5
- callback: () => void;
6
- };
7
- export type TActionButton = {
8
- primary?: ButtonAction;
9
- secondary?: ButtonAction;
10
- tertiary?: ButtonAction;
11
- };
12
- export type TModalHook = {
13
- setIsOpen: (value: boolean) => void;
14
- onClose?: () => void;
15
- onClickOutside?: () => void;
16
- };
17
- export type ModalProps = TModalHook & {
18
- open: boolean;
19
- hasCloseButton?: boolean;
20
- title: string;
21
- subtitle?: string;
22
- iconTitle?: ReactNode;
23
- fullWidthButtons?: boolean;
24
- actions?: TActionButton;
25
- };
26
- export type TModalType = {
27
- modalRef: RefObject<HTMLDialogElement>;
28
- idTitle: string;
29
- idContent: string;
30
- iconTitle: ReactNode;
31
- title: string;
32
- subtitle?: string;
33
- hasCloseButton: boolean;
34
- handleCloseModal: () => void;
35
- actionCallback: (callback?: () => void) => void;
36
- actions?: TActionButton;
37
- fullWidthButtons?: boolean;
38
- };
@@ -1 +0,0 @@
1
- export {};