@axa-fr/design-system-slash-react 1.2.1-alpha.41 → 1.2.1-alpha.44
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/ModalAgent/BooleanModal.d.ts +28 -3
- package/dist/ModalAgent/BooleanModal.js +1 -1
- package/dist/ModalAgent/Modal.d.ts +17 -3
- package/dist/ModalAgent/Modal.js +15 -2
- package/dist/ModalAgent/components/Header.d.ts +25 -5
- package/dist/ModalAgent/components/Header.js +4 -3
- package/package.json +2 -2
|
@@ -1,15 +1,40 @@
|
|
|
1
|
-
import React, { type ReactNode
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
2
|
import { type HeaderProps } from "./components/Header";
|
|
3
|
-
|
|
3
|
+
import { ModalProps } from "./Modal";
|
|
4
|
+
export type BooleanModalProps = React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> & Omit<HeaderProps, "children" | "onCancel" | "title"> & Pick<ModalProps, "size"> & {
|
|
5
|
+
/**
|
|
6
|
+
* Title of the modal, displayed in the header.
|
|
7
|
+
* Also used as the `aria-label` of the <dialog> element for accessibility.
|
|
8
|
+
*/
|
|
9
|
+
title: string;
|
|
10
|
+
/**
|
|
11
|
+
* Callback function called when the modal is submitted.
|
|
12
|
+
* @param event The event that triggered the submission, can be a mouse click or a keyboard event.
|
|
13
|
+
* @returns void
|
|
14
|
+
*/
|
|
4
15
|
onSubmit: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Callback function called when the modal is cancelled.
|
|
18
|
+
* @param event The event that triggered the cancellation, can be a mouse click or a keyboard event.
|
|
19
|
+
* @returns void
|
|
20
|
+
*/
|
|
5
21
|
onCancel: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
6
22
|
id: string;
|
|
7
23
|
children: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Text content of the submit button.
|
|
26
|
+
*/
|
|
8
27
|
submitTitle?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Text content of the cancel button.
|
|
30
|
+
*/
|
|
9
31
|
cancelTitle?: string;
|
|
10
32
|
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use `size` prop instead.
|
|
35
|
+
* Class modifier for the modal. Can be used to apply custom styles.
|
|
36
|
+
*/
|
|
11
37
|
classModifier?: string;
|
|
12
|
-
ref?: Ref<HTMLDialogElement>;
|
|
13
38
|
};
|
|
14
39
|
declare const BooleanModal: React.ForwardRefExoticComponent<Omit<BooleanModalProps, "ref"> & React.RefAttributes<HTMLDialogElement>>;
|
|
15
40
|
export { BooleanModal };
|
|
@@ -7,7 +7,7 @@ import { Header } from "./components/Header";
|
|
|
7
7
|
const defaultClassName = "af-modal";
|
|
8
8
|
const BooleanModal = forwardRef(({ children, title, submitTitle = "Valider", cancelTitle = "Annuler", className = defaultClassName, classModifier, onCancel, onSubmit, closeButtonAriaLabel, ...props }, ref) => {
|
|
9
9
|
const componentClassName = getComponentClassName(className, classModifier, defaultClassName);
|
|
10
|
-
return (_jsxs(Modal, { className: componentClassName, onOutsideTap: onCancel, title: title, ref: ref, ...props, children: [_jsx(Header, { title: title, onCancel: onCancel, closeButtonAriaLabel: closeButtonAriaLabel }), _jsx(Body, { children: children }), _jsxs(Footer, { children: [_jsx(Button, { classModifier: "reverse", onClick: onCancel, children: cancelTitle }), _jsx(Button, { onClick: onSubmit, children: submitTitle })] })] }));
|
|
10
|
+
return (_jsxs(Modal, { className: componentClassName, onOutsideTap: onCancel, title: title, ref: ref, ...props, children: [_jsx(Header, { title: title, onCancel: onCancel, closeButtonAriaLabel: closeButtonAriaLabel }), _jsx(Body, { children: children }), _jsxs(Footer, { children: [_jsx(Button, { classModifier: "reverse", onClick: onCancel, children: cancelTitle }), _jsx(Button, { onClick: onSubmit, classModifier: "success", children: submitTitle })] })] }));
|
|
11
11
|
});
|
|
12
12
|
BooleanModal.displayName = "BooleanModal";
|
|
13
13
|
export { BooleanModal };
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
export type ModalProps = React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> & {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
size?: "lg" | "sm";
|
|
4
|
+
/**
|
|
5
|
+
* The content of the modal.
|
|
6
|
+
*/
|
|
6
7
|
children: ReactNode;
|
|
8
|
+
onOutsideTap: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
9
|
+
/**
|
|
10
|
+
* `aria-label` of the modal, used for accessibility.
|
|
11
|
+
*/
|
|
12
|
+
title?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use `size` prop instead.
|
|
16
|
+
* Class modifier for the modal. Can be used to apply custom styles.
|
|
17
|
+
*/
|
|
7
18
|
classModifier?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Size of the modal. Overrides classModifier if set
|
|
21
|
+
*/
|
|
8
22
|
ref?: React.Ref<HTMLDialogElement>;
|
|
9
23
|
};
|
|
10
24
|
declare const Modal: import("react").ForwardRefExoticComponent<Omit<ModalProps, "ref"> & import("react").RefAttributes<HTMLDialogElement>>;
|
package/dist/ModalAgent/Modal.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { getComponentClassName } from "..";
|
|
4
|
-
const Modal = forwardRef(({ className, title = "", onOutsideTap, children, classModifier, ...props }, ref) => {
|
|
5
|
-
|
|
4
|
+
const Modal = forwardRef(({ className, title = "", onOutsideTap, children, classModifier, size, ...props }, ref) => {
|
|
5
|
+
// If size is set to 'lg' or 'sm', use it as the classModifier, otherwise use the provided classModifier
|
|
6
|
+
let effectiveClassModifier;
|
|
7
|
+
if (size) {
|
|
8
|
+
if (classModifier && classModifier !== "lg" && classModifier !== "sm") {
|
|
9
|
+
effectiveClassModifier = `${size} ${classModifier}`;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
effectiveClassModifier = size;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
effectiveClassModifier = classModifier;
|
|
17
|
+
}
|
|
18
|
+
const componentClassName = getComponentClassName(className, effectiveClassModifier, "af-modal");
|
|
6
19
|
return (
|
|
7
20
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events
|
|
8
21
|
_jsx("dialog", { "aria-label": title, className: componentClassName, onClick: onOutsideTap, ref: ref, ...props, children: _jsx("div", { className: "af-modal__dialog", onClick: (event) => event.stopPropagation(), children: _jsx("div", { className: "af-modal__content", children: children }) }) }));
|
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
import type { MouseEventHandler } from "react";
|
|
1
|
+
import type { MouseEventHandler, ReactNode } from "react";
|
|
2
2
|
export type HeaderProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Text displayed in the header.
|
|
5
|
+
* @deprecated Use `children` instead to allow for more flexible content.
|
|
6
|
+
*/
|
|
5
7
|
title?: string;
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Text displayed in the header, overrides `title` if both are set.
|
|
10
|
+
*/
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Callback function called when the close button is clicked.
|
|
14
|
+
*/
|
|
15
|
+
onCancel: MouseEventHandler<HTMLButtonElement>;
|
|
16
|
+
/**
|
|
17
|
+
* Aria label for the close button, used for accessibility.
|
|
18
|
+
*/
|
|
7
19
|
closeButtonAriaLabel?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Class modifier for the header. Can be used to apply custom styles.
|
|
22
|
+
*/
|
|
23
|
+
classModifier?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Prop to override the style of the header. Will totally remove the default styles.
|
|
26
|
+
*/
|
|
27
|
+
className?: string;
|
|
8
28
|
};
|
|
9
|
-
declare const Header: ({ className, classModifier, title, closeButtonAriaLabel, onCancel, ...props }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
declare const Header: ({ className, classModifier, title, closeButtonAriaLabel, onCancel, children, ...props }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
30
|
export { Header };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import closeIcon from "@material-symbols/svg-400/outlined/close.svg";
|
|
3
|
+
import { getComponentClassName, Svg } from "../..";
|
|
4
|
+
const Header = ({ className, classModifier, title, closeButtonAriaLabel = "Fermer la boite de dialogue", onCancel, children, ...props }) => {
|
|
4
5
|
const componentClassName = getComponentClassName(className, classModifier, "af-modal__header");
|
|
5
|
-
return (_jsxs("header", { className: componentClassName, ...props, children: [_jsx("h4", { className: "af-modal__header-title", children: title }), _jsx("button", { className: "af-modal__header-close-btn", type: "button", "aria-label": closeButtonAriaLabel, onClick: onCancel, children: _jsx(
|
|
6
|
+
return (_jsxs("header", { className: componentClassName, ...props, children: [_jsx("h4", { className: "af-modal__header-title", children: children ?? title }), _jsx("button", { className: "af-modal__header-close-btn", type: "button", "aria-label": closeButtonAriaLabel, onClick: onCancel, children: _jsx(Svg, { src: closeIcon }) })] }));
|
|
6
7
|
};
|
|
7
8
|
export { Header };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-slash-react",
|
|
3
|
-
"version": "1.2.1-alpha.
|
|
3
|
+
"version": "1.2.1-alpha.44",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@axa-fr/design-system-slash-css": "1.2.1-alpha.
|
|
50
|
+
"@axa-fr/design-system-slash-css": "1.2.1-alpha.44",
|
|
51
51
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
52
52
|
"react": ">= 18"
|
|
53
53
|
},
|