@axa-fr/design-system-apollo-react 1.0.5-alpha.330 → 1.0.5-alpha.331
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/Modal/ModalApollo.d.ts +8 -0
- package/dist/Modal/ModalApollo.js +13 -0
- package/dist/Modal/ModalCommon.d.ts +10 -0
- package/dist/Modal/ModalCommon.js +8 -0
- package/dist/Modal/ModalLF.d.ts +8 -0
- package/dist/Modal/ModalLF.js +13 -0
- package/dist/Modal/components/ModalCore.d.ts +6 -0
- package/dist/Modal/components/ModalCore.js +7 -0
- package/dist/Modal/components/ModalCoreBody.d.ts +2 -0
- package/dist/Modal/components/ModalCoreBody.js +14 -0
- package/dist/Modal/components/ModalCoreFooterApollo.d.ts +2 -0
- package/dist/Modal/components/ModalCoreFooterApollo.js +4 -0
- package/dist/Modal/components/ModalCoreFooterCommon.d.ts +10 -0
- package/dist/Modal/components/ModalCoreFooterCommon.js +12 -0
- package/dist/Modal/components/ModalCoreFooterLF.d.ts +2 -0
- package/dist/Modal/components/ModalCoreFooterLF.js +4 -0
- package/dist/Modal/components/ModalCoreHeaderApollo.d.ts +2 -0
- package/dist/Modal/components/ModalCoreHeaderApollo.js +5 -0
- package/dist/Modal/components/ModalCoreHeaderCommon.d.ts +13 -0
- package/dist/Modal/components/ModalCoreHeaderCommon.js +4 -0
- package/dist/Modal/components/ModalCoreHeaderLF.d.ts +2 -0
- package/dist/Modal/components/ModalCoreHeaderLF.js +5 -0
- package/dist/Modal/types.d.ts +12 -0
- package/dist/Modal/types.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/indexLF.d.ts +1 -0
- package/dist/indexLF.js +1 -0
- package/dist/utilities/hook/useHasScroll.d.ts +6 -0
- package/dist/utilities/hook/useHasScroll.js +30 -0
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "@axa-fr/design-system-apollo-css/dist/Modal/ModalApollo.scss";
|
|
2
|
+
import type { ModalProps } from "./types";
|
|
3
|
+
export { ModalCore, type ModalCoreProps } from "./components/ModalCore";
|
|
4
|
+
export { ModalCoreBody, type ModalCoreBodyProps, } from "./components/ModalCoreBody";
|
|
5
|
+
export { ModalCoreFooter } from "./components/ModalCoreFooterApollo";
|
|
6
|
+
export { ModalCoreHeader } from "./components/ModalCoreHeaderApollo";
|
|
7
|
+
export type { ModalCoreFooterProps, ModalCoreHeaderProps, ModalProps, } from "./types";
|
|
8
|
+
export declare const Modal: import("react").ForwardRefExoticComponent<Omit<ModalProps, "ref"> & import("react").RefAttributes<HTMLDialogElement>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Modal/ModalApollo.scss";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { Button } from "../Button/ButtonApollo";
|
|
5
|
+
import { Heading } from "../Heading/HeadingApollo";
|
|
6
|
+
import { Icon } from "../Icon/IconApollo";
|
|
7
|
+
import { ModalCommon } from "./ModalCommon";
|
|
8
|
+
export { ModalCore } from "./components/ModalCore";
|
|
9
|
+
export { ModalCoreBody, } from "./components/ModalCoreBody";
|
|
10
|
+
export { ModalCoreFooter } from "./components/ModalCoreFooterApollo";
|
|
11
|
+
export { ModalCoreHeader } from "./components/ModalCoreHeaderApollo";
|
|
12
|
+
export const Modal = forwardRef(({ headingProps = {}, icon, iconProps = {}, ...props }, ref) => (_jsx(ModalCommon, { ...props, ref: ref, headingComponent: Heading, headingProps: { ...headingProps, children: props.title }, iconComponent: icon ? Icon : undefined, iconProps: icon ? { src: icon, ...iconProps } : undefined, buttonComponent: Button })));
|
|
13
|
+
Modal.displayName = "Modal";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ModalCoreProps } from "./components/ModalCore";
|
|
2
|
+
import { type ModalCoreBodyProps } from "./components/ModalCoreBody";
|
|
3
|
+
import { type ModalCoreFooterCommonProps, type ModalCoreFooterContainerProps } from "./components/ModalCoreFooterCommon";
|
|
4
|
+
import type { ModalCoreHeaderCommonProps, ModalCoreHeaderContainerProps } from "./components/ModalCoreHeaderCommon";
|
|
5
|
+
export type ModalCommonProps = ModalCoreProps & Omit<ModalCoreHeaderCommonProps, Extract<keyof ModalCoreProps, keyof ModalCoreHeaderCommonProps>> & Omit<ModalCoreFooterCommonProps, Extract<keyof ModalCoreProps, keyof ModalCoreFooterCommonProps>> & {
|
|
6
|
+
modalCoreBodyProps?: ModalCoreBodyProps;
|
|
7
|
+
modalCoreFooterProps?: ModalCoreFooterContainerProps;
|
|
8
|
+
modalCoreHeaderProps?: ModalCoreHeaderContainerProps;
|
|
9
|
+
};
|
|
10
|
+
export declare const ModalCommon: import("react").ForwardRefExoticComponent<Omit<ModalCommonProps, "ref"> & import("react").RefAttributes<HTMLDialogElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { ModalCore } from "./components/ModalCore";
|
|
4
|
+
import { ModalCoreBody, } from "./components/ModalCoreBody";
|
|
5
|
+
import { ModalCoreFooterCommon, } from "./components/ModalCoreFooterCommon";
|
|
6
|
+
import { ModalCoreHeaderCommon } from "./components/ModalCoreHeaderCommon";
|
|
7
|
+
export const ModalCommon = forwardRef(({ children, headingComponent, headingProps, closeButtonAriaLabel, onClose, iconComponent, iconProps, primaryButtonProps, secondaryButtonProps, tertiaryButtonProps, buttonComponent, modalCoreBodyProps, modalCoreFooterProps, modalCoreHeaderProps, ...props }, ref) => (_jsxs(ModalCore, { onClose: onClose, ref: ref, ...props, children: [_jsx(ModalCoreHeaderCommon, { headingComponent: headingComponent, headingProps: headingProps, iconComponent: iconComponent, iconProps: iconProps, onClose: onClose, closeButtonAriaLabel: closeButtonAriaLabel, ...modalCoreHeaderProps }), _jsx(ModalCoreBody, { ...modalCoreBodyProps, children: children }), _jsx(ModalCoreFooterCommon, { buttonComponent: buttonComponent, primaryButtonProps: primaryButtonProps, secondaryButtonProps: secondaryButtonProps, tertiaryButtonProps: tertiaryButtonProps, ...modalCoreFooterProps })] })));
|
|
8
|
+
ModalCommon.displayName = "ModalCommon";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "@axa-fr/design-system-apollo-css/dist/Modal/ModalLF.scss";
|
|
2
|
+
import type { ModalProps } from "./types";
|
|
3
|
+
export { ModalCore, type ModalCoreProps } from "./components/ModalCore";
|
|
4
|
+
export { ModalCoreBody, type ModalCoreBodyProps, } from "./components/ModalCoreBody";
|
|
5
|
+
export { ModalCoreFooter } from "./components/ModalCoreFooterLF";
|
|
6
|
+
export { ModalCoreHeader } from "./components/ModalCoreHeaderLF";
|
|
7
|
+
export type { ModalCoreFooterProps, ModalCoreHeaderProps, ModalProps, } from "./types";
|
|
8
|
+
export declare const Modal: import("react").ForwardRefExoticComponent<Omit<ModalProps, "ref"> & import("react").RefAttributes<HTMLDialogElement>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/design-system-apollo-css/dist/Modal/ModalLF.scss";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { Button } from "../Button/ButtonLF";
|
|
5
|
+
import { Heading } from "../Heading/HeadingLF";
|
|
6
|
+
import { Icon } from "../Icon/IconLF";
|
|
7
|
+
import { ModalCommon } from "./ModalCommon";
|
|
8
|
+
export { ModalCore } from "./components/ModalCore";
|
|
9
|
+
export { ModalCoreBody, } from "./components/ModalCoreBody";
|
|
10
|
+
export { ModalCoreFooter } from "./components/ModalCoreFooterLF";
|
|
11
|
+
export { ModalCoreHeader } from "./components/ModalCoreHeaderLF";
|
|
12
|
+
export const Modal = forwardRef(({ headingProps = {}, icon, iconProps = {}, ...props }, ref) => (_jsx(ModalCommon, { ...props, ref: ref, headingComponent: Heading, headingProps: { ...headingProps, children: props.title }, iconComponent: icon ? Icon : undefined, iconProps: icon ? { src: icon, ...iconProps } : undefined, buttonComponent: Button })));
|
|
13
|
+
Modal.displayName = "Modal";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
2
|
+
export type ModalCoreProps = Omit<ComponentPropsWithRef<"dialog">, "title" | "onClose"> & Required<Pick<ComponentPropsWithRef<"dialog">, "title">> & {
|
|
3
|
+
onClose?: VoidFunction;
|
|
4
|
+
};
|
|
5
|
+
declare const ModalCore: import("react").ForwardRefExoticComponent<Omit<ModalCoreProps, "ref"> & import("react").RefAttributes<HTMLDialogElement>>;
|
|
6
|
+
export { ModalCore };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const ModalCore = forwardRef(({ className, children, ...props }, ref) => (
|
|
4
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events
|
|
5
|
+
_jsx("dialog", { "aria-label": props["aria-label"] ?? props.title, className: ["af-apollo-modal", className].filter(Boolean).join(" "), onClick: props.onClose, ref: ref, ...props, children: _jsx("section", { className: "af-apollo-modal__content", onClick: (e) => e.stopPropagation(), children: children }) })));
|
|
6
|
+
ModalCore.displayName = "ModalCore";
|
|
7
|
+
export { ModalCore };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { useHasScroll } from "../../utilities/hook/useHasScroll";
|
|
4
|
+
export const ModalCoreBody = ({ children, className, ...otherProps }) => {
|
|
5
|
+
const bodyRef = useRef(null);
|
|
6
|
+
const { vertical: hasVerticalScroll } = useHasScroll(bodyRef);
|
|
7
|
+
return (_jsx("main", { className: [
|
|
8
|
+
"af-apollo-modal__body",
|
|
9
|
+
hasVerticalScroll ? "af-apollo-modal__body-vertical-scroll" : undefined,
|
|
10
|
+
className,
|
|
11
|
+
]
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join(" "), ...otherProps, ref: bodyRef, children: children }));
|
|
14
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "../../Button/ButtonApollo";
|
|
3
|
+
import { ModalCoreFooterCommon } from "./ModalCoreFooterCommon";
|
|
4
|
+
export const ModalCoreFooter = (args) => (_jsx(ModalCoreFooterCommon, { buttonComponent: Button, ...args }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ComponentType } from "react";
|
|
2
|
+
import type { ButtonProps } from "../../Button/ButtonCommon";
|
|
3
|
+
export type ModalCoreFooterContainerProps = ComponentPropsWithoutRef<"footer">;
|
|
4
|
+
export type ModalCoreFooterCommonProps = ModalCoreFooterContainerProps & {
|
|
5
|
+
buttonComponent: ComponentType<ButtonProps>;
|
|
6
|
+
primaryButtonProps?: Partial<ButtonProps>;
|
|
7
|
+
secondaryButtonProps?: Partial<ButtonProps>;
|
|
8
|
+
tertiaryButtonProps?: Partial<ButtonProps>;
|
|
9
|
+
};
|
|
10
|
+
export declare const ModalCoreFooterCommon: ({ className, buttonComponent: ButtonComponent, primaryButtonProps, secondaryButtonProps, tertiaryButtonProps, ...rest }: ModalCoreFooterCommonProps) => import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const renderFooterButtons = (ButtonComponent, buttons) => ButtonComponent &&
|
|
3
|
+
buttons.map(([variant, props]) => Boolean(props) && (_jsx(ButtonComponent, { variant: variant, ...props, className: [props?.className, "af-apollo-modal__footer-button"]
|
|
4
|
+
.filter(Boolean)
|
|
5
|
+
.join(" ") }, variant)));
|
|
6
|
+
export const ModalCoreFooterCommon = ({ className, buttonComponent: ButtonComponent, primaryButtonProps, secondaryButtonProps, tertiaryButtonProps, ...rest }) => (primaryButtonProps || secondaryButtonProps || tertiaryButtonProps) && (_jsx("footer", { className: ["af-apollo-modal__footer", className]
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.join(" "), ...rest, children: renderFooterButtons(ButtonComponent, [
|
|
9
|
+
["tertiary", tertiaryButtonProps],
|
|
10
|
+
["secondary", secondaryButtonProps],
|
|
11
|
+
["primary", primaryButtonProps],
|
|
12
|
+
]) }));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "../../Button/ButtonLF";
|
|
3
|
+
import { ModalCoreFooterCommon } from "./ModalCoreFooterCommon";
|
|
4
|
+
export const ModalCoreFooter = (args) => (_jsx(ModalCoreFooterCommon, { buttonComponent: Button, ...args }));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Heading } from "../../Heading/HeadingApollo";
|
|
3
|
+
import { Icon } from "../../Icon/IconApollo";
|
|
4
|
+
import { ModalCoreHeaderCommon } from "./ModalCoreHeaderCommon";
|
|
5
|
+
export const ModalCoreHeader = (args) => (_jsx(ModalCoreHeaderCommon, { headingComponent: Heading, iconComponent: Icon, ...args }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ComponentType } from "react";
|
|
2
|
+
import type { HeadingProps } from "../../Heading/types";
|
|
3
|
+
import type { IconProps } from "../../Icon/IconCommon";
|
|
4
|
+
export type ModalCoreHeaderContainerProps = ComponentPropsWithoutRef<"header">;
|
|
5
|
+
export type ModalCoreHeaderCommonProps = ModalCoreHeaderContainerProps & {
|
|
6
|
+
headingComponent: ComponentType<HeadingProps>;
|
|
7
|
+
headingProps: HeadingProps;
|
|
8
|
+
iconComponent?: ComponentType<IconProps>;
|
|
9
|
+
iconProps?: IconProps;
|
|
10
|
+
onClose?: VoidFunction;
|
|
11
|
+
closeButtonAriaLabel?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const ModalCoreHeaderCommon: ({ className, headingComponent: HeadingComponent, headingProps, iconComponent: IconComponent, iconProps, onClose, closeButtonAriaLabel, ...props }: ModalCoreHeaderCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import close from "@material-symbols/svg-400/rounded/close.svg";
|
|
3
|
+
import { ClickIcon } from "../../ClickIcon/ClickIconCommon";
|
|
4
|
+
export const ModalCoreHeaderCommon = ({ className, headingComponent: HeadingComponent, headingProps, iconComponent: IconComponent, iconProps, onClose, closeButtonAriaLabel = "Fermer la boite de dialogue", ...props }) => (_jsxs("header", { className: ["af-apollo-modal__header", className].filter(Boolean).join(" "), ...props, children: [_jsx(ClickIcon, { className: "af-apollo-modal__header-close-btn", src: close, onClick: onClose, "aria-label": closeButtonAriaLabel }), _jsxs("div", { className: "af-apollo-modal__header-title", children: [IconComponent && iconProps && _jsx(IconComponent, { size: "M", ...iconProps }), _jsx(HeadingComponent, { level: 2, ...headingProps })] })] }));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Heading } from "../../Heading/HeadingLF";
|
|
3
|
+
import { Icon } from "../../Icon/IconLF";
|
|
4
|
+
import { ModalCoreHeaderCommon } from "./ModalCoreHeaderCommon";
|
|
5
|
+
export const ModalCoreHeader = (args) => (_jsx(ModalCoreHeaderCommon, { headingComponent: Heading, iconComponent: Icon, ...args }));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HeadingProps } from "../Heading/types";
|
|
2
|
+
import type { IconProps } from "../Icon/IconCommon";
|
|
3
|
+
import type { ModalCoreFooterCommonProps } from "./components/ModalCoreFooterCommon";
|
|
4
|
+
import type { ModalCoreHeaderCommonProps } from "./components/ModalCoreHeaderCommon";
|
|
5
|
+
import type { ModalCommonProps } from "./ModalCommon";
|
|
6
|
+
export type ModalCoreHeaderProps = Omit<ModalCoreHeaderCommonProps, "headingComponent" | "iconComponent">;
|
|
7
|
+
export type ModalCoreFooterProps = Omit<ModalCoreFooterCommonProps, "buttonComponent">;
|
|
8
|
+
export type ModalProps = Omit<ModalCommonProps, "headingComponent" | "headingProps" | "iconComponent" | "iconProps" | "buttonComponent"> & {
|
|
9
|
+
headingProps?: Omit<HeadingProps, "children">;
|
|
10
|
+
icon?: string;
|
|
11
|
+
iconProps?: Omit<IconProps, "src">;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { ItemTabBar, itemTabBarVariants, type ItemTabBarVariants, } from "./Item
|
|
|
28
28
|
export { Link, linkVariants, type LinkVariants } from "./Link/LinkApollo";
|
|
29
29
|
export { ContentItemDuo } from "./List/ContentItemDuo/ContentItemDuoApollo";
|
|
30
30
|
export { Message, messageVariants, type MessageVariants, } from "./Message/MessageApollo";
|
|
31
|
+
export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./Modal/ModalApollo";
|
|
31
32
|
export { ProgressBar } from "./ProgressBar/ProgressBarApollo";
|
|
32
33
|
export { ProgressBarGroup } from "./ProgressBarGroup/ProgressBarGroupApollo";
|
|
33
34
|
export { Spinner, spinnerVariants, type SpinnerVariants, } from "./Spinner/SpinnerApollo";
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { ItemTabBar, itemTabBarVariants, } from "./ItemTabBar/ItemTabBarApollo";
|
|
|
28
28
|
export { Link, linkVariants } from "./Link/LinkApollo";
|
|
29
29
|
export { ContentItemDuo } from "./List/ContentItemDuo/ContentItemDuoApollo";
|
|
30
30
|
export { Message, messageVariants, } from "./Message/MessageApollo";
|
|
31
|
+
export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./Modal/ModalApollo";
|
|
31
32
|
export { ProgressBar } from "./ProgressBar/ProgressBarApollo";
|
|
32
33
|
export { ProgressBarGroup } from "./ProgressBarGroup/ProgressBarGroupApollo";
|
|
33
34
|
export { Spinner, spinnerVariants, } from "./Spinner/SpinnerApollo";
|
package/dist/indexLF.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export { ItemTabBar, itemTabBarVariants, type ItemTabBarVariants, } from "./Item
|
|
|
33
33
|
export { Link, linkVariants, type LinkVariants } from "./Link/LinkLF";
|
|
34
34
|
export { ContentItemDuo } from "./List/ContentItemDuo/ContentItemDuoLF";
|
|
35
35
|
export { Message, messageVariants, type MessageVariants, } from "./Message/MessageLF";
|
|
36
|
+
export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./Modal/ModalLF";
|
|
36
37
|
export { ProgressBar } from "./ProgressBar/ProgressBarLF";
|
|
37
38
|
export { ProgressBarGroup } from "./ProgressBarGroup/ProgressBarGroupLF";
|
|
38
39
|
export { Spinner, spinnerVariants, type SpinnerVariants, } from "./Spinner/SpinnerLF";
|
package/dist/indexLF.js
CHANGED
|
@@ -33,6 +33,7 @@ export { ItemTabBar, itemTabBarVariants, } from "./ItemTabBar/ItemTabBarLF";
|
|
|
33
33
|
export { Link, linkVariants } from "./Link/LinkLF";
|
|
34
34
|
export { ContentItemDuo } from "./List/ContentItemDuo/ContentItemDuoLF";
|
|
35
35
|
export { Message, messageVariants, } from "./Message/MessageLF";
|
|
36
|
+
export { Modal, ModalCore, ModalCoreBody, ModalCoreFooter, ModalCoreHeader, } from "./Modal/ModalLF";
|
|
36
37
|
export { ProgressBar } from "./ProgressBar/ProgressBarLF";
|
|
37
38
|
export { ProgressBarGroup } from "./ProgressBarGroup/ProgressBarGroupLF";
|
|
38
39
|
export { Spinner, spinnerVariants, } from "./Spinner/SpinnerLF";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState, useLayoutEffect } from "react";
|
|
2
|
+
const defaultHasScrollState = {
|
|
3
|
+
horizontal: false,
|
|
4
|
+
vertical: false,
|
|
5
|
+
};
|
|
6
|
+
export const useHasScroll = (ref) => {
|
|
7
|
+
const [hasScroll, setHasScroll] = useState(defaultHasScrollState);
|
|
8
|
+
useLayoutEffect(() => {
|
|
9
|
+
const htmlElement = ref.current;
|
|
10
|
+
const updateHasScrollState = () => {
|
|
11
|
+
if (htmlElement === null) {
|
|
12
|
+
setHasScroll(defaultHasScrollState);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
setHasScroll({
|
|
16
|
+
horizontal: htmlElement.scrollWidth > htmlElement.clientWidth,
|
|
17
|
+
vertical: htmlElement.scrollHeight > htmlElement.clientHeight,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
updateHasScrollState();
|
|
21
|
+
const observer = new ResizeObserver(updateHasScrollState);
|
|
22
|
+
if (htmlElement) {
|
|
23
|
+
observer.observe(htmlElement, {
|
|
24
|
+
box: "content-box",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return () => observer.disconnect();
|
|
28
|
+
}, [ref]);
|
|
29
|
+
return hasScroll;
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-apollo-react",
|
|
3
|
-
"version": "1.0.5-alpha.
|
|
3
|
+
"version": "1.0.5-alpha.331",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@axa-fr/design-system-apollo-css": "1.0.5-alpha.
|
|
50
|
-
"@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.
|
|
49
|
+
"@axa-fr/design-system-apollo-css": "1.0.5-alpha.331",
|
|
50
|
+
"@axa-fr/design-system-look-and-feel-css": "1.0.5-alpha.331",
|
|
51
51
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
52
52
|
"react": ">= 18"
|
|
53
53
|
},
|