@axa-fr/design-system-look-and-feel-react 1.0.5-ci.3 → 1.0.5-ci.30
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/AccordionCore/AccordionCore.js +1 -1
- package/dist/Alert/Alert.d.ts +2 -2
- package/dist/Alert/Alert.js +6 -6
- package/dist/Card/Card.js +1 -1
- package/dist/Divider/Divider.js +1 -1
- package/dist/Form/Checkbox/Checkbox.d.ts +5 -1
- package/dist/Form/Checkbox/Checkbox.js +4 -4
- package/dist/Form/Checkbox/CheckboxSelect.d.ts +7 -5
- package/dist/Form/Checkbox/CheckboxSelect.js +31 -8
- package/dist/Form/FileUpload/FileUpload.js +2 -2
- package/dist/Form/Radio/Radio.js +2 -2
- package/dist/Form/Radio/RadioSelect.d.ts +2 -1
- package/dist/Form/Radio/RadioSelect.js +5 -2
- package/dist/Form/Select/Select.d.ts +6 -9
- package/dist/Form/Select/Select.js +11 -7
- package/dist/Form/Select/arialiveMessagesDefault.d.ts +7 -0
- package/dist/Form/Select/arialiveMessagesDefault.js +53 -0
- package/dist/Form/Text/Text.d.ts +1 -0
- package/dist/Form/Text/Text.js +7 -3
- package/dist/Form/TextArea/TextArea.js +2 -2
- package/dist/Grid/renderExampleForm.js +46 -3
- package/dist/IconBg/IconBg.js +1 -1
- package/dist/Link/Link.js +1 -1
- package/dist/List/ClickList/ClickItem/ClickItem.js +1 -1
- package/dist/List/ContentItemDuo/ContentItemDuo.js +1 -1
- package/dist/List/ContentItemMono/ContentItemMono.js +1 -1
- package/dist/Modal/Modal.d.ts +12 -0
- package/dist/Modal/Modal.js +10 -0
- package/dist/Modal/ModalCore.d.ts +11 -0
- package/dist/Modal/ModalCore.js +6 -0
- package/dist/Modal/components/ModalCoreBody.d.ts +2 -0
- package/dist/Modal/components/ModalCoreBody.js +2 -0
- package/dist/Modal/components/ModalCoreFooter.d.ts +2 -0
- package/dist/Modal/components/ModalCoreFooter.js +2 -0
- package/dist/Modal/components/ModalCoreHeader.d.ts +11 -0
- package/dist/Modal/components/ModalCoreHeader.js +8 -0
- package/dist/Modal/index.d.ts +5 -0
- package/dist/Modal/index.js +5 -0
- package/dist/Tag/Tag.js +1 -1
- package/dist/Title/Title.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/utilities/helpers/getComponentClassName.d.ts +1 -1
- package/dist/utilities/helpers/getComponentClassName.js +7 -8
- package/package.json +3 -57
- package/dist/ModalClient/Modal.container.d.ts +0 -4
- package/dist/ModalClient/Modal.container.js +0 -45
- package/dist/ModalClient/Modal.d.ts +0 -4
- package/dist/ModalClient/Modal.hook.d.ts +0 -6
- package/dist/ModalClient/Modal.hook.js +0 -25
- package/dist/ModalClient/Modal.js +0 -6
- package/dist/ModalClient/index.d.ts +0 -1
- package/dist/ModalClient/index.js +0 -1
- package/dist/ModalClient/type.d.ts +0 -38
- package/dist/ModalClient/type.js +0 -1
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo, } from "react";
|
3
3
|
import { getComponentClassName } from "../utilities";
|
4
4
|
export const AccordionCore = ({ summary, children, className, classModifier, summaryProps, isOpen, onClick, ...detailsProps }) => {
|
5
|
-
const componentClassName = useMemo(() => getComponentClassName(
|
5
|
+
const componentClassName = useMemo(() => getComponentClassName("af-accordion", className, classModifier), [classModifier, className]);
|
6
6
|
const handleToggle = useCallback((event) => {
|
7
7
|
if (onClick) {
|
8
8
|
event.preventDefault();
|
package/dist/Alert/Alert.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { ComponentPropsWithoutRef, PropsWithChildren, ReactElement } from "react";
|
2
1
|
import "@axa-fr/design-system-look-and-feel-css/dist/Alert/Alert.scss";
|
3
|
-
import {
|
2
|
+
import { ComponentPropsWithoutRef, PropsWithChildren, ReactElement } from "react";
|
4
3
|
import { ButtonClient } from "../Button/Button";
|
4
|
+
import { Link } from "../Link/Link";
|
5
5
|
type Headings = "h2" | "h3" | "h4" | "h5" | "h6";
|
6
6
|
export declare const alertTypes: {
|
7
7
|
readonly validation: "validation";
|
package/dist/Alert/Alert.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import infoIcon from "@material-symbols/svg-400/outlined/info.svg";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Alert/Alert.scss";
|
3
|
+
import checkCircleOutline from "@material-symbols/svg-400/outlined/check_circle.svg";
|
5
4
|
import errorIcon from "@material-symbols/svg-400/outlined/emergency_home.svg";
|
6
5
|
import errorOutline from "@material-symbols/svg-400/outlined/error.svg";
|
7
|
-
import
|
8
|
-
import "@
|
6
|
+
import infoIcon from "@material-symbols/svg-400/outlined/info.svg";
|
7
|
+
import wbIncandescentOutlined from "@material-symbols/svg-400/outlined/wb_incandescent.svg";
|
8
|
+
import { useMemo, } from "react";
|
9
9
|
import { Svg } from "../Svg";
|
10
10
|
export const alertTypes = {
|
11
11
|
validation: "validation",
|
@@ -23,5 +23,5 @@ const getIconFromType = (type) => ({
|
|
23
23
|
})[type] || wbIncandescentOutlined;
|
24
24
|
export const Alert = ({ type = alertTypes.information, title, children, action, iconSize = 24, heading: Heading = "h4", }) => {
|
25
25
|
const icon = useMemo(() => getIconFromType(type), [type]);
|
26
|
-
return (_jsxs("div", { className: `af-alert af-alert--${type}`, role: "alert", children: [_jsx(Svg, { src: icon, width: iconSize, height: iconSize, className: "af-alert__icon", "aria-hidden": true }), _jsxs("div", { className: "af-alert-client__content", children: [title && _jsx(Heading, { className: "af-alert__title", children: title }), children, action && _jsx("
|
26
|
+
return (_jsxs("div", { className: `af-alert af-alert--${type}`, role: "alert", children: [_jsx(Svg, { src: icon, width: iconSize, height: iconSize, className: "af-alert__icon", "aria-hidden": true }), _jsxs("div", { className: "af-alert-client__content", children: [title && _jsx(Heading, { className: "af-alert__title", children: title }), children, action && _jsx("div", { className: "af-alert__action", children: action })] })] }));
|
27
27
|
};
|
package/dist/Card/Card.js
CHANGED
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
3
3
|
import { getComponentClassName } from "../utilities";
|
4
4
|
export const Card = ({ children, className, classModifier, onClick, ...otherProps }) => {
|
5
|
-
const componentClassName = useMemo(() => getComponentClassName(
|
5
|
+
const componentClassName = useMemo(() => getComponentClassName("af-card", className, classModifier), [className, classModifier]);
|
6
6
|
const Component = useMemo(() => (onClick ? "button" : "section"), [onClick]);
|
7
7
|
return (_jsx(Component, { className: componentClassName, ...(onClick ? { type: "button", onClick } : {}), ...otherProps, children: children }));
|
8
8
|
};
|
package/dist/Divider/Divider.js
CHANGED
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
3
3
|
import { getComponentClassName } from "../utilities";
|
4
4
|
export const Divider = ({ className, classModifier }) => {
|
5
|
-
const componentClassName = useMemo(() => getComponentClassName(
|
5
|
+
const componentClassName = useMemo(() => getComponentClassName("af-divider", className, classModifier), [className, classModifier]);
|
6
6
|
return _jsx("hr", { className: componentClassName });
|
7
7
|
};
|
@@ -1,7 +1,11 @@
|
|
1
1
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Checkbox/Checkbox.scss";
|
2
2
|
import React, { ReactNode } from "react";
|
3
3
|
declare const Checkbox: React.ForwardRefExoticComponent<{
|
4
|
-
label:
|
4
|
+
label: ReactNode;
|
5
|
+
subtitle?: ReactNode;
|
6
|
+
description?: ReactNode;
|
7
|
+
icon?: ReactNode;
|
5
8
|
errorMessage?: string;
|
9
|
+
showErrorMessage?: boolean;
|
6
10
|
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "label"> & React.RefAttributes<HTMLInputElement>>;
|
7
11
|
export { Checkbox };
|
@@ -1,16 +1,16 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Checkbox/Checkbox.scss";
|
3
3
|
import checkBoxIcon from "@material-symbols/svg-400/outlined/check_box-fill.svg";
|
4
4
|
import checkBoxOutlineBlankIcon from "@material-symbols/svg-400/outlined/check_box_outline_blank.svg";
|
5
|
-
import errorOutline from "@material-symbols/svg-400/outlined/error.svg";
|
6
5
|
import { forwardRef, useId } from "react";
|
7
6
|
import classNames from "classnames";
|
8
7
|
import { Svg } from "../../Svg";
|
9
|
-
|
8
|
+
import { InputError } from "../InputError";
|
9
|
+
const Checkbox = forwardRef(({ label, icon, description, subtitle, errorMessage, className, showErrorMessage = true, ...inputProps }, ref) => {
|
10
10
|
const idError = useId();
|
11
11
|
let inputId = useId();
|
12
12
|
inputId = inputProps.id || inputId;
|
13
|
-
return (_jsxs(
|
13
|
+
return (_jsxs("div", { children: [_jsx("div", { className: classNames("af-checkbox", className), children: _jsxs("label", { htmlFor: inputId, children: [_jsx("input", { ref: ref, ...inputProps, type: "checkbox", id: inputId, "aria-errormessage": idError, "aria-invalid": Boolean(errorMessage) && !inputProps.disabled }), _jsxs("div", { className: "af-checkbox__icons", children: [_jsx(Svg, { src: checkBoxOutlineBlankIcon, className: "af-checkbox__unchecked" }), _jsx(Svg, { src: checkBoxIcon, className: "af-checkbox__checked" })] }), _jsxs("div", { className: "af-checkbox__content", children: [icon, _jsxs("div", { className: "af-checkbox__content-description", children: [_jsx("span", { children: label }), description && _jsx("span", { children: description }), subtitle && _jsx("span", { children: subtitle })] })] })] }, inputProps.name) }), errorMessage && showErrorMessage && (_jsx(InputError, { id: idError, message: errorMessage }))] }));
|
14
14
|
});
|
15
15
|
Checkbox.displayName = "Checkbox";
|
16
16
|
export { Checkbox };
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Checkbox/Checkbox.scss";
|
2
|
-
import React, {
|
3
|
-
type
|
2
|
+
import React, { ComponentPropsWithRef, ReactNode } from "react";
|
3
|
+
type Props = ComponentPropsWithRef<"input"> & {
|
4
4
|
type: "vertical" | "horizontal";
|
5
|
+
border?: boolean;
|
5
6
|
labelGroup?: string;
|
6
7
|
descriptionGroup?: string;
|
7
8
|
isRequired?: boolean;
|
@@ -12,7 +13,8 @@ type CheckboxProps = {
|
|
12
13
|
icon?: ReactNode;
|
13
14
|
} & React.InputHTMLAttributes<HTMLInputElement>)[];
|
14
15
|
errorMessage?: string;
|
15
|
-
onChange?:
|
16
|
+
onChange?: (...event: unknown[]) => void;
|
17
|
+
value?: unknown[];
|
16
18
|
};
|
17
|
-
|
18
|
-
export {};
|
19
|
+
declare const CheckboxSelect: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
20
|
+
export { CheckboxSelect };
|
@@ -1,11 +1,34 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Checkbox/Checkbox.scss";
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
|
8
|
-
|
3
|
+
import { forwardRef, useEffect, useId, useState, } from "react";
|
4
|
+
import { Checkbox } from "./Checkbox";
|
5
|
+
import { getComponentClassName } from "../core";
|
6
|
+
import { InputError } from "../InputError";
|
7
|
+
const CheckboxSelect = forwardRef(({ options, errorMessage, onChange, value, type = "vertical", className, labelGroup, descriptionGroup, isRequired, border = true, }, ref) => {
|
8
|
+
const [checkedState, setCheckedState] = useState(options.map((x) => Boolean(value?.includes(x.value))));
|
9
9
|
const optionId = useId();
|
10
|
-
|
11
|
-
|
10
|
+
const idError = useId();
|
11
|
+
const handleOnChange = (position) => {
|
12
|
+
const updatedCheckedState = checkedState.map((item, index) => index === position ? !item : item);
|
13
|
+
setCheckedState(updatedCheckedState);
|
14
|
+
if (onChange) {
|
15
|
+
const arr = [];
|
16
|
+
updatedCheckedState.forEach((x, idx) => {
|
17
|
+
if (x === true) {
|
18
|
+
arr.push(options[idx].value);
|
19
|
+
}
|
20
|
+
});
|
21
|
+
onChange(arr);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
useEffect(() => {
|
25
|
+
setCheckedState(options.map((x) => Boolean(value?.includes(x.value))));
|
26
|
+
}, [setCheckedState, options, value]);
|
27
|
+
const componentClassName = getComponentClassName("af-checkbox__container", className);
|
28
|
+
const checkboxGroupClassName = getComponentClassName(`af-checkbox${border ? " af-checkbox-select" : ""} af-checkbox-select--${type}`, className);
|
29
|
+
return (_jsxs("div", { className: componentClassName, children: [_jsxs("div", { className: "af-checkbox__label-container", children: [labelGroup && (_jsxs("span", { className: "af-checkbox__label", id: optionId, children: [labelGroup, isRequired && _jsx("span", { "aria-hidden": "true", children: "\u00A0*" })] })), descriptionGroup && (_jsx("span", { className: "af-checkbox__description", children: descriptionGroup }))] }), _jsx("div", { role: "group", className: checkboxGroupClassName, children: _jsx("ul", { children: options.map(({ label, value: valueOption, ...inputProps }, idx) => (_jsx("li", { children: _jsx(Checkbox, { ...inputProps, showErrorMessage: false, ref: idx === 0 ? ref : null, value: valueOption, checked: checkedState[idx], onChange: () => handleOnChange(idx), id: `id-${inputProps.name}`, label: label, errorMessage: errorMessage, "aria-errormessage": Boolean(errorMessage) && !inputProps.disabled
|
30
|
+
? idError
|
31
|
+
: undefined }) }, `key-${inputProps.name}`))) }) }), errorMessage && _jsx(InputError, { id: idError, message: errorMessage })] }));
|
32
|
+
});
|
33
|
+
CheckboxSelect.displayName = "CheckboxSelect";
|
34
|
+
export { CheckboxSelect };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import { useId } from "react";
|
3
3
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/FileUpload/FileUpload.scss";
|
4
4
|
import visibility from "@material-symbols/svg-400/outlined/visibility-fill.svg";
|
@@ -34,7 +34,7 @@ const FileUpload = ({ id, label, buttonLabel, instructions, dropzoneDescription,
|
|
34
34
|
}
|
35
35
|
return (_jsx(Svg, { src: check, className: "af-form__file-title-container-icon-success" }));
|
36
36
|
};
|
37
|
-
return (_jsxs(
|
37
|
+
return (_jsxs("div", { children: [_jsxs("label", { className: "af-form__group--label", htmlFor: id, children: [label, " ", required ? "*" : ""] }), _jsxs("div", { className: classNames("af-form__file-input", globalError && "af-form__file-input--error", (isMobile || !dropzoneDescription) && "is-mobile"), children: [_jsx("input", { type: "file", name: "file-input", id: id, "aria-errormessage": idError, "aria-invalid": Boolean(globalError), ...otherProps }), dropzoneDescription && (_jsxs("div", { className: "af-form__file-input-dropdown-text", children: [_jsx("p", { children: dropzoneDescription }), _jsx("p", { children: "ou" })] })), _jsx(Button, { variant: Variants.tertiary, onClick: () => document.getElementById(id)?.click(), iconLeft: _jsx(Svg, { src: plus, className: "af-form__file-input-icon" }), children: buttonLabel })] }), globalError && _jsx(InputError, { id: idError, message: globalError }), _jsx("small", { className: "af-form__file-input-help", children: instructions }), _jsx("div", { className: "custom-table-file af-file-table", children: _jsx("ul", { className: "af-form__file-list", children: files.map(({ id: fileId, name, size, isLoading }) => {
|
38
38
|
const effectiveSize = getReadableFileSizeString(size);
|
39
39
|
const isInError = errors.some((fileError) => fileError.id === fileId);
|
40
40
|
const errorMessage = errors.find((fileError) => fileError.id === fileId)?.message;
|
package/dist/Form/Radio/Radio.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Radio/Radio.scss";
|
3
3
|
import radioIcon from "@material-symbols/svg-400/outlined/radio_button_checked.svg";
|
4
4
|
import radioOutlineBlankIcon from "@material-symbols/svg-400/outlined/radio_button_unchecked.svg";
|
@@ -9,7 +9,7 @@ const Radio = forwardRef(({ label, errorMessage, ...inputProps }, ref) => {
|
|
9
9
|
let inputId = useId();
|
10
10
|
inputId = inputProps.id || inputId;
|
11
11
|
const idError = useId();
|
12
|
-
return (_jsxs(
|
12
|
+
return (_jsxs("div", { children: [_jsx("div", { className: "af-radio", role: "radiogroup", "aria-invalid": Boolean(errorMessage), "aria-errormessage": idError, children: _jsxs("label", { htmlFor: inputId, children: [_jsx("input", { ref: ref, ...inputProps, type: "radio", id: inputId }), _jsxs("div", { className: "af-radio__icons", children: [_jsx(Svg, { src: radioOutlineBlankIcon, className: "af-radio__unchecked" }), _jsx(Svg, { src: radioIcon, className: "af-radio__checked" })] }), label] }, inputProps.name) }), errorMessage && _jsx(InputError, { id: idError, message: errorMessage })] }));
|
13
13
|
});
|
14
14
|
Radio.displayName = "Radio";
|
15
15
|
export { Radio };
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Radio/Radio.scss";
|
2
2
|
import React, { ComponentPropsWithRef, ReactNode } from "react";
|
3
|
-
type RadioSelectProps = {
|
3
|
+
type RadioSelectProps = ComponentPropsWithRef<"input"> & {
|
4
4
|
type: "vertical" | "horizontal";
|
5
5
|
label?: string;
|
6
|
+
description?: string;
|
6
7
|
isRequired?: boolean;
|
7
8
|
options: ({
|
8
9
|
label: ReactNode;
|
@@ -5,7 +5,10 @@ import radioOutlineBlankIcon from "@material-symbols/svg-400/outlined/radio_butt
|
|
5
5
|
import { forwardRef, useCallback, useId, } from "react";
|
6
6
|
import { Svg } from "../../Svg";
|
7
7
|
import { InputError } from "../InputError";
|
8
|
-
|
8
|
+
import { getComponentClassName } from "../../utilities/helpers/getComponentClassName";
|
9
|
+
export const RadioSelect = forwardRef(({ className, id, label, description, options, errorMessage, onChange, type = "vertical", name, value, isDisabled, isRequired, ...rest }, ref) => {
|
10
|
+
const componentClassName = getComponentClassName("af-radio__container", className);
|
11
|
+
const radioGroupClassName = getComponentClassName(`af-radio af-radio-select af-radio-select--${type}`, className);
|
9
12
|
const generatedId = useId();
|
10
13
|
const optionId = id || generatedId;
|
11
14
|
const getRef = useCallback((index, reference, val, inputVal) => {
|
@@ -14,6 +17,6 @@ export const RadioSelect = forwardRef(({ id, label, options, errorMessage, onCha
|
|
14
17
|
}
|
15
18
|
return null;
|
16
19
|
}, []);
|
17
|
-
return (_jsxs("div", { className: "af-
|
20
|
+
return (_jsxs("div", { className: componentClassName, children: [_jsxs("div", { className: "af-radio__label-container", children: [label && (_jsxs("span", { className: "af-radio__label", id: optionId, children: [label, isRequired && _jsx("span", { "aria-hidden": "true", children: "\u00A0*" })] })), description && (_jsx("span", { className: "af-radio__description", children: description }))] }), _jsx("div", { ...rest, role: "radiogroup", className: radioGroupClassName, "aria-invalid": Boolean(errorMessage), "aria-labelledby": optionId, "aria-errormessage": `${optionId}-error`, children: options.map(({ label: inputLabel, description: inputDescription, subtitle, icon, disabled: inputDisabled, ...inputProps }, idx) => (_jsxs("label", { htmlFor: `${optionId}-${inputLabel}`, children: [_jsx("input", { type: "radio", ...(isDisabled || inputDisabled ? { disabled: true } : null), ...inputProps, name: name, id: `${optionId}-${inputLabel}`, onChange: onChange, "aria-checked": value === inputProps.value, checked: value === inputProps.value, ref: getRef(idx, ref, value, inputProps.value) }), _jsxs("div", { className: "af-radio__icons", children: [_jsx(Svg, { src: radioOutlineBlankIcon, className: "af-radio__unchecked" }), _jsx(Svg, { src: radioIcon, className: "af-radio__checked" })] }), _jsxs("div", { className: "af-radio__content", children: [icon, _jsxs("div", { className: "af-radio__content-description", children: [_jsx("span", { children: inputLabel }), inputDescription && _jsx("span", { children: inputDescription }), subtitle && _jsx("span", { children: subtitle })] })] })] }, inputLabel))) }), errorMessage && (_jsx(InputError, { id: `${optionId}-error`, message: errorMessage }))] }));
|
18
21
|
});
|
19
22
|
RadioSelect.displayName = "RadioSelect";
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Select/Select.scss";
|
2
|
-
import ReactSelect, { ActionMeta, SingleValue } from "react-select";
|
3
|
-
import {
|
2
|
+
import ReactSelect, { ActionMeta, GroupBase, SelectInstance, SingleValue } from "react-select";
|
3
|
+
import { ComponentPropsWithRef } from "react";
|
4
4
|
type Option = {
|
5
5
|
label: string;
|
6
6
|
value: string | number;
|
7
7
|
};
|
8
|
-
type Props = Omit<
|
9
|
-
id
|
10
|
-
label
|
8
|
+
type Props = Omit<ComponentPropsWithRef<ReactSelect>, "placeholder" | "noOptionsMessage"> & {
|
9
|
+
id?: string;
|
10
|
+
label?: string;
|
11
11
|
options: {
|
12
12
|
label: string;
|
13
13
|
value?: string | number | readonly string[];
|
@@ -20,8 +20,5 @@ type Props = Omit<ComponentPropsWithoutRef<ReactSelect>, "placeholder" | "noOpti
|
|
20
20
|
disabled?: boolean;
|
21
21
|
required?: boolean;
|
22
22
|
};
|
23
|
-
declare const Select:
|
24
|
-
({ id, required, disabled, label, errorLabel, noOptionsMessage, ...otherProps }: PropsWithChildren<Props>): import("react/jsx-runtime").JSX.Element;
|
25
|
-
displayName: string;
|
26
|
-
};
|
23
|
+
declare const Select: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<SelectInstance<unknown, boolean, GroupBase<unknown>>>>;
|
27
24
|
export { Select };
|
@@ -1,13 +1,17 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Select/Select.scss";
|
3
|
-
import ErrorOutline from "@material-symbols/svg-400/outlined/error.svg";
|
4
3
|
import ReactSelect from "react-select";
|
4
|
+
import { forwardRef, useId } from "react";
|
5
5
|
import classNames from "classnames";
|
6
6
|
import { DropdownIndicator } from "./DropdownIndicator";
|
7
|
-
import { Svg } from "../../Svg";
|
8
7
|
import { CustomOption } from "./CustomOption";
|
9
|
-
|
10
|
-
|
8
|
+
import { defaultAriaLiveMessages } from "./arialiveMessagesDefault";
|
9
|
+
import { InputError } from "../InputError";
|
10
|
+
const Select = forwardRef(({ id, required, disabled, label, errorLabel, noOptionsMessage, ...otherProps }, inputRef) => {
|
11
|
+
const idError = useId();
|
12
|
+
let inputId = useId();
|
13
|
+
inputId = id || inputId;
|
14
|
+
return (_jsxs("div", { children: [label && (_jsxs("label", { htmlFor: inputId, className: "af-form__select-label", children: [label, required && _jsx("span", { "aria-hidden": "true", children: " *" })] })), _jsx(ReactSelect, { inputId: inputId, "aria-errormessage": idError, "aria-invalid": Boolean(errorLabel), ariaLiveMessages: defaultAriaLiveMessages, screenReaderStatus: ({ count }) => `${count} résultat${count > 1 ? "s" : ""} disponible${count > 1 ? "s" : ""}`, unstyled: true, isDisabled: disabled, noOptionsMessage: () => noOptionsMessage || "Aucun résultat", components: {
|
11
15
|
DropdownIndicator,
|
12
16
|
Option: CustomOption,
|
13
17
|
}, classNames: {
|
@@ -21,7 +25,7 @@ const Select = ({ id, required, disabled, label, errorLabel, noOptionsMessage, .
|
|
21
25
|
option: ({ isSelected, isFocused, }) => classNames("af-form__input-select-menu-options", isSelected && "af-form__input-select-menu-options-selected", isFocused && "af-form__input-select-menu-options-focused"),
|
22
26
|
singleValue: ({ isDisabled, }) => classNames("af-form__select-single-value", isDisabled && "af-form__select-single-value-disabled"),
|
23
27
|
dropdownIndicator: () => "af-form__select-dropdown-indicator",
|
24
|
-
}, className: "af-form__input-select", ...otherProps }), errorLabel && (
|
25
|
-
};
|
28
|
+
}, className: "af-form__input-select", ...otherProps, ref: inputRef }), errorLabel && _jsx(InputError, { id: idError, message: errorLabel })] }));
|
29
|
+
});
|
26
30
|
Select.displayName = "Select";
|
27
31
|
export { Select };
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { AriaGuidanceProps, AriaOnChangeProps, AriaOnFilterProps, AriaOnFocusProps, GroupBase } from "react-select";
|
2
|
+
export declare const defaultAriaLiveMessages: {
|
3
|
+
guidance: (props: AriaGuidanceProps) => string;
|
4
|
+
onChange: <Option, IsMulti extends boolean>(props: AriaOnChangeProps<Option, IsMulti>) => string;
|
5
|
+
onFocus: <Option, Group extends GroupBase<Option>>(props: AriaOnFocusProps<Option, Group>) => string;
|
6
|
+
onFilter: (props: AriaOnFilterProps) => string;
|
7
|
+
};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
export const defaultAriaLiveMessages = {
|
2
|
+
guidance: (props) => {
|
3
|
+
const { isSearchable, isMulti, tabSelectsValue, context, isInitialFocus } = props;
|
4
|
+
switch (context) {
|
5
|
+
case "menu":
|
6
|
+
return `Utilisez les flèches Haut et Bas pour choisir des options, appuyez sur Entrée pour sélectionner l'option actuellement mise au point, appuyez sur Échap pour quitter le menu${tabSelectsValue ? ", appuyez sur Tab pour sélectionner l'option et quitter le menu" : ""}.`;
|
7
|
+
case "input":
|
8
|
+
return isInitialFocus
|
9
|
+
? `${props["aria-label"] || "Sélectionner"} est sélectionné ${isSearchable ? ", tapez du texte pour affiner la liste" : ""}, appuyez sur Bas pour ouvrir le menu, ${isMulti ? " appuyez sur Gauche pour mettre au point les valeurs sélectionnées" : ""}`
|
10
|
+
: "";
|
11
|
+
case "value":
|
12
|
+
return "Utilisez les flèches Gauche et Droite pour basculer entre les valeurs sélectionnées, appuyez sur Retour arrière pour supprimer la valeur actuellement sélectionnée.";
|
13
|
+
default:
|
14
|
+
return "";
|
15
|
+
}
|
16
|
+
},
|
17
|
+
onChange: (props) => {
|
18
|
+
const { action, label = "", labels, isDisabled } = props;
|
19
|
+
switch (action) {
|
20
|
+
case "deselect-option":
|
21
|
+
case "pop-value":
|
22
|
+
case "remove-value":
|
23
|
+
return `option ${label}, désélectionnée.`;
|
24
|
+
case "clear":
|
25
|
+
return "Toutes les options sélectionnées ont été effacées.";
|
26
|
+
case "initial-input-focus":
|
27
|
+
return `${labels.length > 1 ? "les " : "l'"}option${labels.length > 1 ? "s" : ""} ${labels.join(",")} ${labels.length > 1 ? "sont" : "est"} sélectionnée${labels.length > 1 ? "s" : ""}.`;
|
28
|
+
case "select-option":
|
29
|
+
return isDisabled
|
30
|
+
? `l'option ${label} est désactivée. Sélectionnez une autre option.`
|
31
|
+
: `l'option ${label} est sélectionnée.`;
|
32
|
+
default:
|
33
|
+
return "";
|
34
|
+
}
|
35
|
+
},
|
36
|
+
onFocus: (props) => {
|
37
|
+
const { context, focused, options, label = "", selectValue, isDisabled, isSelected, isAppleDevice, } = props;
|
38
|
+
const getArrayIndex = (arr, item) => arr && arr.length ? `${arr.indexOf(item) + 1} sur ${arr.length}` : "";
|
39
|
+
if (context === "value" && selectValue) {
|
40
|
+
return `la valeur ${label} est sélectionnée, ${getArrayIndex(selectValue, focused)}.`;
|
41
|
+
}
|
42
|
+
if (context === "menu" && isAppleDevice) {
|
43
|
+
const disabled = isDisabled ? " désactivé" : "";
|
44
|
+
const status = `${isSelected ? " sélectionné" : ""}${disabled}`;
|
45
|
+
return `${label}${status}, ${getArrayIndex(options, focused)}.`;
|
46
|
+
}
|
47
|
+
return "";
|
48
|
+
},
|
49
|
+
onFilter: (props) => {
|
50
|
+
const { inputValue, resultsMessage } = props;
|
51
|
+
return `${resultsMessage}${inputValue ? ` pour le terme de recherche : ${inputValue}` : ""}.`;
|
52
|
+
},
|
53
|
+
};
|
package/dist/Form/Text/Text.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import "@axa-fr/design-system-look-and-feel-css/dist/Form/Text/Text.scss";
|
2
2
|
import { ComponentPropsWithRef, MouseEventHandler } from "react";
|
3
3
|
type Props = ComponentPropsWithRef<"input"> & {
|
4
|
+
unit?: React.ReactNode;
|
4
5
|
classModifier?: string;
|
5
6
|
helper?: string;
|
6
7
|
error?: string;
|
package/dist/Form/Text/Text.js
CHANGED
@@ -7,12 +7,16 @@ import { Variants } from "../../Button/Button";
|
|
7
7
|
import { Svg } from "../../Svg";
|
8
8
|
import { getComponentClassName } from "../../utilities";
|
9
9
|
import { InputError } from "../InputError";
|
10
|
-
const Text = forwardRef(({ className, classModifier = "", label, description, helper, error, buttonLabel, onButtonClick, required, ...otherProps }, inputRef) => {
|
11
|
-
const componentClassName = getComponentClassName(
|
10
|
+
const Text = forwardRef(({ unit, className, classModifier = "", label, description, helper, error, buttonLabel, onButtonClick, required, ...otherProps }, inputRef) => {
|
11
|
+
const componentClassName = getComponentClassName("af-form__input-text", className, classModifier +
|
12
|
+
(error || otherProps["aria-errormessage"] ? " error" : ""));
|
12
13
|
let inputId = useId();
|
13
14
|
inputId = otherProps.id || inputId;
|
15
|
+
const idDescription = useId();
|
14
16
|
const idError = useId();
|
15
|
-
|
17
|
+
const idHelp = useId();
|
18
|
+
const idLabel = useId();
|
19
|
+
return (_jsxs("div", { className: "af-form__input-container", children: [(label || description || buttonLabel) && (_jsxs("div", { className: "af-form__label-container", children: [_jsxs("label", { htmlFor: inputId, id: idLabel, "aria-describedby": idDescription, className: "af-form__input-label", children: [label, " ", required && _jsx("span", { "aria-hidden": "true", children: " *" })] }), description && (_jsx("span", { id: idDescription, className: "af-form__input-description", children: description })), buttonLabel && (_jsx(Button, { className: "af-form__input-more", variant: Variants.ghost, iconLeft: _jsx(Svg, { src: infoIcon }), onClick: onButtonClick, children: buttonLabel }))] })), _jsxs("div", { className: "af-form__input-variant", children: [_jsx("input", { id: inputId, className: componentClassName, type: "text", ref: inputRef, "aria-labelledby": idLabel, "aria-errormessage": otherProps["aria-errormessage"] ?? idError, "aria-invalid": Boolean(error || otherProps["aria-errormessage"]), "aria-describedby": idHelp, ...otherProps }), unit] }), helper && (_jsx("span", { id: idHelp, className: "af-form__input-helper", children: helper })), !otherProps["aria-errormessage"] && error && (_jsx(InputError, { id: idError, message: error }))] }));
|
16
20
|
});
|
17
21
|
Text.displayName = "Text";
|
18
22
|
export { Text };
|
@@ -6,11 +6,11 @@ import { Button, Svg } from "../..";
|
|
6
6
|
import { Variants } from "../../Button/Button";
|
7
7
|
import { InputError } from "../InputError";
|
8
8
|
const TextArea = forwardRef(({ className, classModifier = "", label, description, helper, error, buttonLabel, onButtonClick, required, ...otherProps }, inputRef) => {
|
9
|
-
const componentClassName = getComponentClassName(
|
9
|
+
const componentClassName = getComponentClassName("af-form__input-textarea", className, classModifier);
|
10
10
|
let inputId = useId();
|
11
11
|
inputId = otherProps.id || inputId;
|
12
12
|
const idError = useId();
|
13
|
-
return (_jsxs("div", { className: "af-form__input-container", children: [_jsxs("label", { htmlFor: inputId, className: "af-form__input-label", children: [label, " ", required && _jsx("span", { children: " *" })] }), description && (_jsx("span", { className: "af-form__input-description", children: description })), buttonLabel && (_jsx(Button, { className: "af-form__input-more", variant: Variants.ghost, iconLeft: _jsx(Svg, { src: infoIcon }), onClick: onButtonClick, children: buttonLabel })), _jsx("textarea", { id: inputId, className: componentClassName, ref: inputRef, "aria-errormessage": idError, "aria-invalid": Boolean(error), ...otherProps }), helper && _jsx("span", { className: "af-form__input-helper", children: helper }), error && _jsx(InputError, { id: idError, message: error })] }));
|
13
|
+
return (_jsxs("div", { className: "af-form__input-container", children: [label && (_jsxs("div", { className: "af-form__label-container", children: [_jsxs("label", { htmlFor: inputId, className: "af-form__input-label", children: [label, " ", required && _jsx("span", { children: " *" })] }), description && (_jsx("span", { className: "af-form__input-description", children: description })), buttonLabel && (_jsx(Button, { className: "af-form__input-more", variant: Variants.ghost, iconLeft: _jsx(Svg, { src: infoIcon }), onClick: onButtonClick, children: buttonLabel }))] })), _jsx("textarea", { id: inputId, className: componentClassName, ref: inputRef, "aria-errormessage": idError, "aria-invalid": Boolean(error), ...otherProps }), helper && _jsx("span", { className: "af-form__input-helper", children: helper }), error && _jsx(InputError, { id: idError, message: error })] }));
|
14
14
|
});
|
15
15
|
TextArea.displayName = "TextArea";
|
16
16
|
export { TextArea };
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import home from "@material-symbols/svg-400/outlined/home.svg";
|
2
3
|
import { MyFooter } from "./components/MyFooter";
|
3
4
|
import { MyHeader } from "./components/MyHeader";
|
4
|
-
import { Button, ButtonVariants, TextInput, Title } from "..";
|
5
|
+
import { Button, ButtonVariants, CheckboxSelect, RadioSelect, Svg, TextInput, Title, } from "..";
|
5
6
|
import { DebugGrid } from "./DebugGrid";
|
6
7
|
function capitalizeFirstLetter(val) {
|
7
8
|
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
|
@@ -17,7 +18,7 @@ const setAttributesFields = (value, label, type = "text") => ({
|
|
17
18
|
placeholder: `Votre ${label}`,
|
18
19
|
description: `Saisissez un ${label}`,
|
19
20
|
error: `Un ${label} est obligatoire`,
|
20
|
-
className: "subgrid
|
21
|
+
className: "subgrid",
|
21
22
|
helper: "Do you need help ?",
|
22
23
|
buttonLabel: "En savoir plus",
|
23
24
|
});
|
@@ -27,4 +28,46 @@ const FIELDS = [
|
|
27
28
|
setAttributesFields("samuel.gomez@axa.fr", "email", "email"),
|
28
29
|
setAttributesFields("0601020304", "téléphone"),
|
29
30
|
];
|
30
|
-
export const render = () => (_jsxs(_Fragment, { children: [_jsx(DebugGrid, { isCheckedByDefault: true }), _jsx(MyHeader, {}), _jsx("main", { className: "grid example-form", children: _jsxs("form", { className: "form", children: [_jsxs("div", { className: "form__header subgrid", children: [_jsx(Title, { children: "Mon formulaire" }), _jsx("p", { children: "Les mentions avec * sont obligatoires" })] }),
|
31
|
+
export const render = () => (_jsxs(_Fragment, { children: [_jsx(DebugGrid, { isCheckedByDefault: true }), _jsx(MyHeader, {}), _jsx("main", { className: "grid example-form", children: _jsxs("form", { className: "form", children: [_jsxs("div", { className: "form__header subgrid", children: [_jsx(Title, { children: "Mon formulaire" }), _jsx("p", { children: "Les mentions avec * sont obligatoires" })] }), _jsxs("div", { className: "form__fields subgrid", children: [_jsx(RadioSelect, { className: "subgrid", label: "Genre", type: "horizontal", options: [
|
32
|
+
{ label: "Homme", value: "H", icon: _jsx(Svg, { src: home }) },
|
33
|
+
{ label: "Femme", value: "F", icon: _jsx(Svg, { src: home }) },
|
34
|
+
{ label: "Les deux", value: "HF", icon: _jsx(Svg, { src: home }) },
|
35
|
+
{
|
36
|
+
label: "Ne se prononce pas",
|
37
|
+
value: "N",
|
38
|
+
icon: _jsx(Svg, { src: home }),
|
39
|
+
},
|
40
|
+
], name: "radio-name" }), _jsx(CheckboxSelect, { className: "subgrid", type: "horizontal", labelGroup: "Titre", options: [
|
41
|
+
{
|
42
|
+
label: "Développeur",
|
43
|
+
value: "H",
|
44
|
+
name: "Développeur",
|
45
|
+
icon: _jsx(Svg, { src: home }),
|
46
|
+
},
|
47
|
+
{ label: "BA", value: "F", name: "BA", icon: _jsx(Svg, { src: home }) },
|
48
|
+
{
|
49
|
+
label: "EM",
|
50
|
+
value: "HF",
|
51
|
+
name: "EM",
|
52
|
+
icon: _jsx(Svg, { src: home }),
|
53
|
+
},
|
54
|
+
{ label: "PO", value: "A", name: "PO", icon: _jsx(Svg, { src: home }) },
|
55
|
+
{
|
56
|
+
label: "DBA",
|
57
|
+
value: "Au",
|
58
|
+
name: "DBA",
|
59
|
+
icon: _jsx(Svg, { src: home }),
|
60
|
+
},
|
61
|
+
{
|
62
|
+
label: "Scrum Master",
|
63
|
+
value: "P",
|
64
|
+
name: "Scrum Master",
|
65
|
+
icon: _jsx(Svg, { src: home }),
|
66
|
+
},
|
67
|
+
{
|
68
|
+
label: "Ne se prononce pas",
|
69
|
+
value: "N",
|
70
|
+
name: "Ne se prononce pas",
|
71
|
+
icon: _jsx(Svg, { src: home }),
|
72
|
+
},
|
73
|
+
] }), FIELDS.map((field) => (_jsx(TextInput, { ...field, classModifier: field.error ? "error" : "" }, field.id)))] }), _jsxs("div", { className: "form__actions subgrid", children: [_jsx(Button, { variant: ButtonVariants.secondary, children: "Pr\u00E9c\u00E9dent" }), _jsx(Button, { variant: ButtonVariants.primary, children: "Valider" })] })] }) }), _jsx(MyFooter, {})] }));
|
package/dist/IconBg/IconBg.js
CHANGED
@@ -7,7 +7,7 @@ export const IconBg = ({ children, className, classModifier, isDisabled = false,
|
|
7
7
|
if (isDisabled) {
|
8
8
|
newClassModifier += " disabled";
|
9
9
|
}
|
10
|
-
return getComponentClassName(
|
10
|
+
return getComponentClassName("af-icon-bg", className, newClassModifier);
|
11
11
|
}, [classModifier, isDisabled, className]);
|
12
12
|
return _jsx("div", { className: componentClassName, children: children });
|
13
13
|
};
|
package/dist/Link/Link.js
CHANGED
@@ -8,7 +8,7 @@ export const Link = ({ href, openInNewTab = false, leftIcon, rightIcon, children
|
|
8
8
|
target: "_blank",
|
9
9
|
rel: "noopener noreferrer",
|
10
10
|
};
|
11
|
-
const componentClassName = useMemo(() => getComponentClassName(className, `${classModifier}${!className && openInNewTab ? " openInNewTab" : ""}
|
11
|
+
const componentClassName = useMemo(() => getComponentClassName("af-link", className, `${classModifier}${!className && openInNewTab ? " openInNewTab" : ""}`), [classModifier, className, openInNewTab]);
|
12
12
|
return (_jsxs("a", { className: componentClassName, href: href, ...newTabProps, ...props, children: [leftIcon, children, (openInNewTab || Boolean(rightIcon)) &&
|
13
13
|
(rightIcon ?? _jsx(Svg, { src: openInNew }))] }));
|
14
14
|
};
|
@@ -4,6 +4,6 @@ import { useMemo } from "react";
|
|
4
4
|
import { Svg } from "../../../Svg";
|
5
5
|
import { getComponentClassName } from "../../../utilities";
|
6
6
|
export const ClickItem = ({ children, icon, parentClickComponent: ClickComponent = ({ children: parentClickComponentChildren, ...parentClickComponentProps }) => (_jsx("button", { type: "button", ...parentClickComponentProps, children: parentClickComponentChildren })), isDisabled = false, className, classModifier = "", actionIcon = _jsx(Svg, { src: chevron, "aria-hidden": true }), ...otherProps }) => {
|
7
|
-
const componentClassName = useMemo(() => getComponentClassName(className, `${classModifier}${isDisabled ? " disabled" : ""}
|
7
|
+
const componentClassName = useMemo(() => getComponentClassName("af-click-item", className, `${classModifier}${isDisabled ? " disabled" : ""}`), [className, classModifier, isDisabled]);
|
8
8
|
return (_jsxs(ClickComponent, { className: componentClassName, disabled: isDisabled, "aria-disabled": isDisabled, ...otherProps, children: [_jsxs("div", { className: "af-click-item__content", children: [icon && _jsx("div", { className: "af-click-item__icon", children: icon }), _jsx("div", { className: "af-click-item__label", children: children })] }), _jsx("div", { className: "af-click-item__action", children: actionIcon })] }));
|
9
9
|
};
|
@@ -11,7 +11,7 @@ export const ContentItemDuo = ({ label, value, isVertical = false, className, cl
|
|
11
11
|
if (isVertical) {
|
12
12
|
classModifiers.push("vertical");
|
13
13
|
}
|
14
|
-
return getComponentClassName(className, classModifiers.filter(Boolean).join(" ")
|
14
|
+
return getComponentClassName("af-content-item-duo", className, classModifiers.filter(Boolean).join(" "));
|
15
15
|
}, [classModifier, className, isVertical]);
|
16
16
|
const iconContainerModifier = useMemo(() => ` af-content-item-duo__icon--${isShowingDoneIcon ? "done" : "close"}`, [isShowingDoneIcon]);
|
17
17
|
return (_jsxs("div", { className: componentClassName, children: [(isShowingDoneIcon || isShowingCloseIcon) && (_jsxs("div", { className: `af-content-item-duo__icon${iconContainerModifier}`, children: [isShowingDoneIcon && _jsx(Svg, { src: checkIcon }), isShowingCloseIcon && _jsx(Svg, { src: closeIcon })] })), _jsx("p", { className: "af-content-item-duo__label", children: label }), _jsx("p", { className: "af-content-item-duo__value", children: value }), buttonText && (_jsx("div", { className: "af-content-item-duo__button", children: _jsx(Button, { variant: Variants.ghost, onClick: onButtonClick, children: buttonText }) }))] }));
|
@@ -8,7 +8,7 @@ export const ContentItemMono = ({ children, className, classModifier, secondaryT
|
|
8
8
|
if (isDisabled) {
|
9
9
|
classModifiers.push("disabled");
|
10
10
|
}
|
11
|
-
return getComponentClassName(className, classModifiers.filter(Boolean).join(" ")
|
11
|
+
return getComponentClassName("af-content-item-mono", className, classModifiers.filter(Boolean).join(" "));
|
12
12
|
}, [classModifier, isDisabled, size, className]);
|
13
13
|
return (_jsxs("div", { className: componentClassName, children: [hasStick && (_jsx("div", { className: "af-content-item-mono__stick", role: "presentation" })), leftElement && (_jsx("div", { className: `af-content-item-mono__left-container${isLeftElementCentered
|
14
14
|
? " af-content-item-mono__left-container--center"
|
@@ -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,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/Tag/Tag.js
CHANGED
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
3
3
|
import { getComponentClassName } from "../utilities";
|
4
4
|
export const Tag = ({ children, className, classModifier = "", ...divProps }) => {
|
5
|
-
const componentClassName = useMemo(() => getComponentClassName(
|
5
|
+
const componentClassName = useMemo(() => getComponentClassName("af-tag", className, classModifier), [className, classModifier]);
|
6
6
|
return (_jsx("div", { className: componentClassName, ...divProps, children: _jsx("span", { className: "af-tag__label", children: children }) }));
|
7
7
|
};
|
package/dist/Title/Title.js
CHANGED
@@ -5,7 +5,7 @@ import { getComponentClassName } from "../utilities";
|
|
5
5
|
import { TitleSize } from "./constants";
|
6
6
|
import { TitleWithSubtitles } from "./TitleWithSubtitles";
|
7
7
|
export const Title = ({ children: title, className, classModifier, firstSubtitle, icon, secondSubtitle, size = TitleSize.XL, level = size === TitleSize.L ? 2 : 1, }) => {
|
8
|
-
const componentClassName = useMemo(() => getComponentClassName(className, classModifier ? `${classModifier} ${size}` : size
|
8
|
+
const componentClassName = useMemo(() => getComponentClassName("af-title", className, classModifier ? `${classModifier} ${size}` : size), [classModifier, className, size]);
|
9
9
|
const TitleWithSubtitlesPart = useCallback(({ ...args }) => (_jsx(TitleWithSubtitles, { title: title, firstSubtitle: firstSubtitle, level: level, ...args })), [title, firstSubtitle, level]);
|
10
10
|
return (_jsx("header", { className: componentClassName, children: icon && size === TitleSize.XL ? (_jsxs(_Fragment, { children: [_jsx(IconBg, { className: "af-title__icon af-icon-bg", children: icon }), _jsx(TitleWithSubtitlesPart, { secondSubtitle: secondSubtitle })] })) : (_jsx(TitleWithSubtitlesPart, {})) }));
|
11
11
|
};
|
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";
|
@@ -33,3 +31,6 @@ export { TabsClient as Tabs, Direction as TabsDirection } from "./Tabs/Tabs";
|
|
33
31
|
export { Tag } from "./Tag";
|
34
32
|
export { Title, TitleSize, type TitleLevel } from "./Title";
|
35
33
|
export { DebugGrid } from "./Grid/DebugGrid";
|
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";
|
@@ -31,3 +30,5 @@ export { TabsClient as Tabs, Direction as TabsDirection } from "./Tabs/Tabs";
|
|
31
30
|
export { Tag } from "./Tag";
|
32
31
|
export { Title, TitleSize } from "./Title";
|
33
32
|
export { DebugGrid } from "./Grid/DebugGrid";
|
33
|
+
export { Divider } from "./Divider";
|
34
|
+
export { Modal, ModalCore, ModalCoreHeader, ModalCoreFooter, ModalCoreBody, } from "./Modal";
|
@@ -1 +1 @@
|
|
1
|
-
export declare const getComponentClassName: (
|
1
|
+
export declare const getComponentClassName: (defaultClassName: string, className?: string, classModifier?: string) => string;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import classNames from "classnames";
|
2
|
-
const getLastClassName = (
|
3
|
-
if (!
|
2
|
+
const getLastClassName = (defaultClassName) => {
|
3
|
+
if (!defaultClassName) {
|
4
4
|
return null;
|
5
5
|
}
|
6
|
-
return
|
6
|
+
return defaultClassName.split(" ").filter(Boolean).at(-1);
|
7
7
|
};
|
8
8
|
const listClassModifier = (classModifier) => {
|
9
9
|
if (!classModifier) {
|
@@ -11,17 +11,16 @@ const listClassModifier = (classModifier) => {
|
|
11
11
|
}
|
12
12
|
return classModifier.split(" ");
|
13
13
|
};
|
14
|
-
export const getComponentClassName = (className, classModifier
|
15
|
-
|
16
|
-
if (!classNameToUse) {
|
14
|
+
export const getComponentClassName = (defaultClassName, className, classModifier) => {
|
15
|
+
if (!defaultClassName) {
|
17
16
|
return "";
|
18
17
|
}
|
19
|
-
const classWithoutModifier = getLastClassName(
|
18
|
+
const classWithoutModifier = getLastClassName(defaultClassName);
|
20
19
|
const modifiers = listClassModifier(classModifier);
|
21
20
|
const modifiersObject = modifiers
|
22
21
|
.filter((it) => /\S/.test(it))
|
23
22
|
.map((it) => {
|
24
23
|
return `${classWithoutModifier}--${it}`;
|
25
24
|
});
|
26
|
-
return classNames(
|
25
|
+
return classNames(defaultClassName, className, modifiersObject);
|
27
26
|
};
|
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.
|
3
|
+
"version": "1.0.5-ci.30",
|
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.
|
48
|
+
"@axa-fr/design-system-look-and-feel-css": "1.0.5-ci.30",
|
49
49
|
"@material-symbols/svg-400": ">= 0.19.0",
|
50
50
|
"react": ">= 18"
|
51
51
|
},
|
@@ -63,66 +63,12 @@
|
|
63
63
|
"rc-slider": "^11.1.7",
|
64
64
|
"react-select": "^5.9.0"
|
65
65
|
},
|
66
|
-
"devDependencies": {
|
67
|
-
"@chromatic-com/storybook": "^1.9.0",
|
68
|
-
"@material-symbols/svg-400": "*",
|
69
|
-
"@storybook/addon-docs": "^8.3.5",
|
70
|
-
"@storybook/addon-essentials": "^8.3.5",
|
71
|
-
"@storybook/addon-interactions": "^8.3.5",
|
72
|
-
"@storybook/addon-links": "^8.3.5",
|
73
|
-
"@storybook/addon-mdx-gfm": "^8.3.5",
|
74
|
-
"@storybook/addon-onboarding": "^8.3.5",
|
75
|
-
"@storybook/blocks": "^8.3.5",
|
76
|
-
"@storybook/manager-api": "^8.3.5",
|
77
|
-
"@storybook/react": "^8.3.5",
|
78
|
-
"@storybook/react-vite": "^8.3.5",
|
79
|
-
"@storybook/test": "^8.3.5",
|
80
|
-
"@storybook/theming": "^8.3.5",
|
81
|
-
"@testing-library/dom": "^10.1.0",
|
82
|
-
"@testing-library/jest-dom": "^6.5.0",
|
83
|
-
"@testing-library/react": "^15.0.7",
|
84
|
-
"@testing-library/user-event": "^14.5.2",
|
85
|
-
"@types/dompurify": "^3.0.5",
|
86
|
-
"@types/jest": "^29.5.12",
|
87
|
-
"@types/jest-axe": "^3.5.9",
|
88
|
-
"@types/node": "^20.14.9",
|
89
|
-
"@types/react": "^18.3.2",
|
90
|
-
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
91
|
-
"@typescript-eslint/parser": "^8.17.0",
|
92
|
-
"@vitejs/plugin-react": "^4.3.1",
|
93
|
-
"@vitest/coverage-v8": "^2.0.5",
|
94
|
-
"@vitest/ui": "^2.1.2",
|
95
|
-
"chromatic": "^11.12.0",
|
96
|
-
"copyfiles": "^2.4.1",
|
97
|
-
"eslint": "^8.57.0",
|
98
|
-
"eslint-config-airbnb": "^19.0.4",
|
99
|
-
"eslint-config-prettier": "^9.1.0",
|
100
|
-
"eslint-import-resolver-typescript": "^3.6.1",
|
101
|
-
"eslint-plugin-import": "^2.29.1",
|
102
|
-
"eslint-plugin-jsx-a11y": "^6.8.0",
|
103
|
-
"eslint-plugin-prettier": "^5.1.3",
|
104
|
-
"eslint-plugin-react": "^7.36.1",
|
105
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
106
|
-
"eslint-plugin-storybook": "^0.9.0",
|
107
|
-
"jest-axe": "^8.0.0",
|
108
|
-
"jsdom": "^25.0.1",
|
109
|
-
"prettier": "^3.3.3",
|
110
|
-
"prop-types": "^15.8.1",
|
111
|
-
"react": "^18.3.1",
|
112
|
-
"react-dom": "^18.2.0",
|
113
|
-
"rimraf": "^6.0.1",
|
114
|
-
"storybook": "^8.3.5",
|
115
|
-
"tsc-files": "^1.1.4",
|
116
|
-
"typescript": "^5.6.3",
|
117
|
-
"vitest": "^2.0.5"
|
118
|
-
},
|
119
66
|
"lint-staged": {
|
120
67
|
"*.(js|jsx|ts|tsx)": "eslint --fix",
|
121
68
|
"*.(ts|tsx)": "tsc-files --noEmit",
|
122
69
|
"*.mdx": "prettier --write"
|
123
70
|
},
|
124
71
|
"volta": {
|
125
|
-
"
|
126
|
-
"npm": "10.2.5"
|
72
|
+
"extends": "../../../package.json"
|
127
73
|
}
|
128
74
|
}
|
@@ -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,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
|
-
};
|
package/dist/ModalClient/type.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|