@axa-fr/canopee-react 2.0.0-alpha.43 → 2.0.0-alpha.45
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/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/prospect-client/AccordionCore/AccordionCoreCommon.d.ts +3 -1
- package/dist/prospect-client/AccordionCore/AccordionCoreCommon.js +8 -2
- package/dist/prospect-client/MessageBar/MessageBarAction.d.ts +8 -0
- package/dist/prospect-client/MessageBar/MessageBarAction.js +11 -0
- package/dist/prospect-client/MessageBar/MessageBarApollo.d.ts +5 -0
- package/dist/prospect-client/MessageBar/MessageBarApollo.js +7 -0
- package/dist/prospect-client/MessageBar/MessageBarCommon.d.ts +26 -0
- package/dist/prospect-client/MessageBar/MessageBarCommon.js +33 -0
- package/dist/prospect-client/MessageBar/MessageBarDescription.d.ts +6 -0
- package/dist/prospect-client/MessageBar/MessageBarDescription.js +8 -0
- package/dist/prospect-client/MessageBar/MessageBarLF.d.ts +5 -0
- package/dist/prospect-client/MessageBar/MessageBarLF.js +7 -0
- package/dist/prospect-client/MessageBar/MessageBarSummary.d.ts +11 -0
- package/dist/prospect-client/MessageBar/MessageBarSummary.js +2 -0
- package/dist/prospect-client/MessageBar/types.d.ts +1 -0
- package/dist/prospect-client/MessageBar/types.js +1 -0
- package/dist/prospect.d.ts +1 -0
- package/dist/prospect.js +1 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -78,3 +78,4 @@ export { TagList, type TagListProps, } from "./prospect-client/TagList/TagListLF
|
|
|
78
78
|
export { TimelineVertical } from "./prospect-client/TimelineVertical/TimelineVerticalLF";
|
|
79
79
|
export { Toggle } from "./prospect-client/Toggle/ToggleLF";
|
|
80
80
|
export type { GridContainerProps } from "./prospect-client/utilities/types/GridContainerProps";
|
|
81
|
+
export { MessageBar, type MessageBarProps, type MessageBarVariant, } from "./prospect-client/MessageBar/MessageBarLF";
|
package/dist/client.js
CHANGED
|
@@ -77,3 +77,4 @@ export { Tag, tagVariants, } from "./prospect-client/Tag/TagLF";
|
|
|
77
77
|
export { TagList, } from "./prospect-client/TagList/TagListLF";
|
|
78
78
|
export { TimelineVertical } from "./prospect-client/TimelineVertical/TimelineVerticalLF";
|
|
79
79
|
export { Toggle } from "./prospect-client/Toggle/ToggleLF";
|
|
80
|
+
export { MessageBar, } from "./prospect-client/MessageBar/MessageBarLF";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ComponentProps, type ComponentType, type MouseEventHandler, type ReactNode } from "react";
|
|
2
|
+
import type { ClickIconVariant } from "../ClickIcon/ClickIconCommon";
|
|
2
3
|
import type { IconProps } from "../Icon/IconCommon";
|
|
3
4
|
type SummaryOnClick = MouseEventHandler<HTMLElement>;
|
|
4
5
|
export type AccordionCoreProps = {
|
|
@@ -6,10 +7,11 @@ export type AccordionCoreProps = {
|
|
|
6
7
|
summaryProps?: Omit<ComponentProps<"summary">, "onClick">;
|
|
7
8
|
onClick?: SummaryOnClick;
|
|
8
9
|
showArrowAsClickIcon?: boolean;
|
|
10
|
+
arrowClickIconVariant?: ClickIconVariant;
|
|
9
11
|
arrowIconVariant?: IconProps["variant"];
|
|
10
12
|
} & ComponentProps<"details">;
|
|
11
13
|
export type AccordionPropsCommonProps = AccordionCoreProps & {
|
|
12
14
|
IconComponent: ComponentType<IconProps>;
|
|
13
15
|
};
|
|
14
|
-
export declare const AccordionCoreCommon: ({ summary, children, className, summaryProps, IconComponent, onClick, showArrowAsClickIcon, arrowIconVariant, ...detailsProps }: AccordionPropsCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const AccordionCoreCommon: ({ summary, children, className, summaryProps, IconComponent, onClick, showArrowAsClickIcon, arrowClickIconVariant, arrowIconVariant, ...detailsProps }: AccordionPropsCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
export {};
|
|
@@ -2,13 +2,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import keyboardDown from "@material-symbols/svg-400/rounded/keyboard_arrow_down-fill.svg";
|
|
3
3
|
import { useCallback, } from "react";
|
|
4
4
|
import { getClassName } from "../utilities/getClassName";
|
|
5
|
-
export const AccordionCoreCommon = ({ summary, children, className, summaryProps, IconComponent, onClick, showArrowAsClickIcon = true, arrowIconVariant, ...detailsProps }) => {
|
|
5
|
+
export const AccordionCoreCommon = ({ summary, children, className, summaryProps, IconComponent, onClick, showArrowAsClickIcon = true, arrowClickIconVariant = "default", arrowIconVariant, ...detailsProps }) => {
|
|
6
6
|
const handleSummaryClick = useCallback((event) => {
|
|
7
7
|
if (onClick) {
|
|
8
8
|
event.preventDefault();
|
|
9
9
|
onClick(event);
|
|
10
10
|
}
|
|
11
11
|
}, [onClick]);
|
|
12
|
+
const arrowClassName = showArrowAsClickIcon
|
|
13
|
+
? getClassName({
|
|
14
|
+
baseClassName: "af-click-icon",
|
|
15
|
+
modifiers: [arrowClickIconVariant === "ghost" && arrowClickIconVariant],
|
|
16
|
+
})
|
|
17
|
+
: undefined;
|
|
12
18
|
return (_jsxs("details", { className: getClassName({
|
|
13
19
|
baseClassName: "af-apollo-accordion",
|
|
14
20
|
className,
|
|
@@ -17,6 +23,6 @@ export const AccordionCoreCommon = ({ summary, children, className, summaryProps
|
|
|
17
23
|
className: summaryProps?.className,
|
|
18
24
|
}), children: [summary, _jsx("div", { className: getClassName({
|
|
19
25
|
baseClassName: "af-accordion__arrow",
|
|
20
|
-
className:
|
|
26
|
+
className: arrowClassName,
|
|
21
27
|
}), children: _jsx(IconComponent, { src: keyboardDown, role: "presentation", variant: arrowIconVariant }) })] }), children] }));
|
|
22
28
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { ButtonProps } from "../Button/ButtonCommon";
|
|
3
|
+
type MessageBarActionProps = {
|
|
4
|
+
buttonProps?: ButtonProps;
|
|
5
|
+
ButtonComponent: ComponentType<ButtonProps>;
|
|
6
|
+
};
|
|
7
|
+
export declare const MessageBarAction: ({ buttonProps, ButtonComponent, }: MessageBarActionProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getClassName } from "../utilities/getClassName";
|
|
3
|
+
export const MessageBarAction = ({ buttonProps, ButtonComponent, }) => {
|
|
4
|
+
if (!buttonProps) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return (_jsx(ButtonComponent, { ...buttonProps, className: getClassName({
|
|
8
|
+
baseClassName: "af-message-bar__action",
|
|
9
|
+
className: buttonProps.className,
|
|
10
|
+
}) }));
|
|
11
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "@axa-fr/canopee-css/prospect/MessageBar/MessageBarAll.css";
|
|
2
|
+
import { type MessageBarProps } from "./MessageBarCommon";
|
|
3
|
+
export type { MessageBarProps } from "./MessageBarCommon";
|
|
4
|
+
export type { MessageBarVariant } from "./types";
|
|
5
|
+
export declare const MessageBar: (props: MessageBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/canopee-css/prospect/MessageBar/MessageBarAll.css";
|
|
3
|
+
import { AccordionCore } from "../AccordionCore/AccordionCoreApollo";
|
|
4
|
+
import { Button } from "../Button/ButtonApollo";
|
|
5
|
+
import { Icon } from "../Icon/IconApollo";
|
|
6
|
+
import { MessageBarCommon } from "./MessageBarCommon";
|
|
7
|
+
export const MessageBar = (props) => (_jsx(MessageBarCommon, { ...props, AccordionCoreComponent: AccordionCore, ButtonComponent: Button, IconComponent: Icon }));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ComponentType, type ReactNode } from "react";
|
|
2
|
+
import type { AccordionCoreProps } from "../AccordionCore/AccordionCoreCommon";
|
|
3
|
+
import type { ButtonProps } from "../Button/ButtonCommon";
|
|
4
|
+
import type { IconProps } from "../Icon/IconCommon";
|
|
5
|
+
import type { MessageBarVariant } from "./types";
|
|
6
|
+
export type MessageBarProps = {
|
|
7
|
+
/** Message title. */
|
|
8
|
+
title: string;
|
|
9
|
+
/** Description. Always visible on desktop and collapsible on mobile. */
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
/** Icon displayed before the title. */
|
|
12
|
+
icon: string;
|
|
13
|
+
/** Visual variant. */
|
|
14
|
+
variant?: MessageBarVariant;
|
|
15
|
+
/** Initial mobile expanded state for the description. */
|
|
16
|
+
defaultDescriptionOpen?: boolean;
|
|
17
|
+
/** Action button props. No button is rendered when omitted. */
|
|
18
|
+
buttonProps?: ButtonProps;
|
|
19
|
+
} & Omit<ComponentPropsWithoutRef<"section">, "children">;
|
|
20
|
+
type MessageBarCommonProps = MessageBarProps & {
|
|
21
|
+
AccordionCoreComponent: ComponentType<AccordionCoreProps>;
|
|
22
|
+
ButtonComponent: ComponentType<ButtonProps>;
|
|
23
|
+
IconComponent: ComponentType<IconProps>;
|
|
24
|
+
};
|
|
25
|
+
export declare const MessageBarCommon: ({ title, description, icon, variant, defaultDescriptionOpen, buttonProps, className, AccordionCoreComponent, ButtonComponent, IconComponent, ...sectionProps }: MessageBarCommonProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, } from "react";
|
|
3
|
+
import { BREAKPOINT } from "../utilities/constants";
|
|
4
|
+
import { getClassName } from "../utilities/getClassName";
|
|
5
|
+
import { useIsSmallScreen } from "../utilities/hook/useIsSmallScreen";
|
|
6
|
+
import { MessageBarAction } from "./MessageBarAction";
|
|
7
|
+
import { MessageBarDescription } from "./MessageBarDescription";
|
|
8
|
+
import { MessageBarSummary } from "./MessageBarSummary";
|
|
9
|
+
const iconVariantByMessageBarVariant = {
|
|
10
|
+
info: "primary",
|
|
11
|
+
error: "error",
|
|
12
|
+
};
|
|
13
|
+
export const MessageBarCommon = ({ title, description, icon, variant = "info", defaultDescriptionOpen = false, buttonProps, className, AccordionCoreComponent, ButtonComponent, IconComponent, ...sectionProps }) => {
|
|
14
|
+
const titleId = useId();
|
|
15
|
+
const isMobile = useIsSmallScreen(BREAKPOINT.MD);
|
|
16
|
+
const hasDescription = Boolean(description);
|
|
17
|
+
const sectionAriaLabelledBy = sectionProps["aria-label"] || sectionProps["aria-labelledby"]
|
|
18
|
+
? undefined
|
|
19
|
+
: titleId;
|
|
20
|
+
const iconVariant = iconVariantByMessageBarVariant[variant];
|
|
21
|
+
const componentClassName = getClassName({
|
|
22
|
+
baseClassName: "af-message-bar",
|
|
23
|
+
modifiers: [variant],
|
|
24
|
+
className,
|
|
25
|
+
});
|
|
26
|
+
const summary = (_jsx(MessageBarSummary, { title: title, titleId: titleId, icon: icon, iconVariant: iconVariant, IconComponent: IconComponent }));
|
|
27
|
+
const action = (_jsx(MessageBarAction, { buttonProps: buttonProps, ButtonComponent: ButtonComponent }));
|
|
28
|
+
const body = _jsx(MessageBarDescription, { description: description });
|
|
29
|
+
if (hasDescription && isMobile) {
|
|
30
|
+
return (_jsxs(AccordionCoreComponent, { className: componentClassName, role: "region", "aria-labelledby": sectionAriaLabelledBy, open: defaultDescriptionOpen, summary: summary, summaryProps: { className: "af-message-bar__header" }, arrowClickIconVariant: "ghost", arrowIconVariant: iconVariant, ...sectionProps, children: [body, action] }));
|
|
31
|
+
}
|
|
32
|
+
return (_jsxs("section", { className: componentClassName, "aria-labelledby": sectionAriaLabelledBy, ...sectionProps, children: [_jsx("div", { className: "af-message-bar__header", children: summary }), body, action] }));
|
|
33
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const MessageBarDescription = ({ description, }) => {
|
|
3
|
+
if (!description) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const Component = typeof description === "string" ? "p" : "div";
|
|
7
|
+
return _jsx(Component, { className: "af-message-bar__body", children: description });
|
|
8
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "@axa-fr/canopee-css/client/MessageBar/MessageBarAll.css";
|
|
2
|
+
import { type MessageBarProps } from "./MessageBarCommon";
|
|
3
|
+
export type { MessageBarProps } from "./MessageBarCommon";
|
|
4
|
+
export type { MessageBarVariant } from "./types";
|
|
5
|
+
export declare const MessageBar: (props: MessageBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/canopee-css/client/MessageBar/MessageBarAll.css";
|
|
3
|
+
import { AccordionCore } from "../AccordionCore/AccordionCoreLF";
|
|
4
|
+
import { Button } from "../Button/ButtonLF";
|
|
5
|
+
import { Icon } from "../Icon/IconLF";
|
|
6
|
+
import { MessageBarCommon } from "./MessageBarCommon";
|
|
7
|
+
export const MessageBar = (props) => (_jsx(MessageBarCommon, { ...props, AccordionCoreComponent: AccordionCore, ButtonComponent: Button, IconComponent: Icon }));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { IconProps } from "../Icon/IconCommon";
|
|
3
|
+
type MessageBarSummaryProps = {
|
|
4
|
+
title: string;
|
|
5
|
+
titleId: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
iconVariant: IconProps["variant"];
|
|
8
|
+
IconComponent: ComponentType<IconProps>;
|
|
9
|
+
};
|
|
10
|
+
export declare const MessageBarSummary: ({ title, titleId, icon, iconVariant, IconComponent, }: MessageBarSummaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const MessageBarSummary = ({ title, titleId, icon, iconVariant, IconComponent, }) => (_jsxs(_Fragment, { children: [_jsx(IconComponent, { src: icon, className: "af-message-bar__icon", role: "presentation", variant: iconVariant }), _jsx("p", { id: titleId, className: "af-message-bar__title", children: title })] }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MessageBarVariant = "info" | "error";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/prospect.d.ts
CHANGED
|
@@ -78,3 +78,4 @@ export { TagList, type TagListProps, } from "./prospect-client/TagList/TagListAp
|
|
|
78
78
|
export { TimelineVertical } from "./prospect-client/TimelineVertical/TimelineVerticalApollo";
|
|
79
79
|
export { Toggle } from "./prospect-client/Toggle/ToggleApollo";
|
|
80
80
|
export type { GridContainerProps } from "./prospect-client/utilities/types/GridContainerProps";
|
|
81
|
+
export { MessageBar, type MessageBarProps, type MessageBarVariant, } from "./prospect-client/MessageBar/MessageBarApollo";
|
package/dist/prospect.js
CHANGED
|
@@ -77,3 +77,4 @@ export { Tag, tagVariants, } from "./prospect-client/Tag/TagApollo";
|
|
|
77
77
|
export { TagList, } from "./prospect-client/TagList/TagListApollo";
|
|
78
78
|
export { TimelineVertical } from "./prospect-client/TimelineVertical/TimelineVerticalApollo";
|
|
79
79
|
export { Toggle } from "./prospect-client/Toggle/ToggleApollo";
|
|
80
|
+
export { MessageBar, } from "./prospect-client/MessageBar/MessageBarApollo";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/canopee-react",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.45",
|
|
4
4
|
"description": "Package React - Design System Canopée",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./distributeur": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@axa-fr/canopee-css": "2.0.0-alpha.
|
|
56
|
+
"@axa-fr/canopee-css": "2.0.0-alpha.45",
|
|
57
57
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
58
58
|
"@material-symbols/svg-700": ">= 0.19.0",
|
|
59
59
|
"react": ">= 19"
|