@axa-fr/canopee-react 2.0.0-alpha.76 → 2.0.0-alpha.78
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/distributeur/Button/Button.d.ts +3 -4
- package/dist/distributeur/Button/Button.js +7 -1
- package/dist/distributeur/ClickableGhost.d.ts +36 -0
- package/dist/distributeur/ClickableGhost.js +26 -0
- package/dist/distributeur/Link/LinkAnchor.d.ts +4 -6
- package/dist/distributeur/Link/LinkAnchor.js +2 -2
- package/dist/distributeur.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { type ComponentPropsWithRef, type PropsWithChildren
|
|
1
|
+
import { type ComponentPropsWithRef, type PropsWithChildren } from "react";
|
|
2
2
|
import "@axa-fr/canopee-css/distributeur/Button/Button.css";
|
|
3
|
+
import { type ClickableComponentProps } from "../ClickableGhost";
|
|
3
4
|
export type ButtonVariant = "primary" | "secondary" | "validated" | "danger" | "ghost" | "ghost-reverse";
|
|
4
|
-
type ButtonProps = PropsWithChildren<{
|
|
5
|
+
type ButtonProps = ClickableComponentProps & PropsWithChildren<{
|
|
5
6
|
variant?: ButtonVariant;
|
|
6
7
|
small?: boolean;
|
|
7
|
-
leftIcon?: ReactNode;
|
|
8
|
-
rightIcon?: ReactNode;
|
|
9
8
|
} & ComponentPropsWithRef<"button">>;
|
|
10
9
|
export declare const Button: {
|
|
11
10
|
({ variant, small, leftIcon, rightIcon, className, children, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,12 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import {} from "react";
|
|
4
4
|
import "@axa-fr/canopee-css/distributeur/Button/Button.css";
|
|
5
|
+
import { ClickableGhost, } from "../ClickableGhost";
|
|
5
6
|
const DEFAULT_CLASS_NAME = "af-btn";
|
|
6
|
-
export const Button = ({ variant = "primary", small, leftIcon, rightIcon, className, children, ...props }) =>
|
|
7
|
+
export const Button = ({ variant = "primary", small, leftIcon, rightIcon, className, children, ...props }) => {
|
|
8
|
+
if (variant === "ghost" || variant === "ghost-reverse") {
|
|
9
|
+
return (_jsxs(ClickableGhost, { component: "button", type: "button", variant: variant === "ghost-reverse" ? "reverse" : "ghost", ...props, children: [leftIcon, children, rightIcon] }));
|
|
10
|
+
}
|
|
11
|
+
return (_jsxs("button", { type: "button", className: classNames(DEFAULT_CLASS_NAME, variant !== "primary" && `${DEFAULT_CLASS_NAME}--${variant}`, small && `${DEFAULT_CLASS_NAME}--small`, className), ...props, children: [leftIcon, children, rightIcon] }));
|
|
12
|
+
};
|
|
7
13
|
Button.displayName = "Button";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import { Svg } from "./Svg";
|
|
3
|
+
import "@axa-fr/canopee-css/distributeur/Link/Link.css";
|
|
4
|
+
export type ClickableComponentProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The content to be displayed inside the clickable component.
|
|
7
|
+
*/
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* The icon to be displayed on the left side of the clickable component.
|
|
11
|
+
*/
|
|
12
|
+
leftIcon?: ReactElement<typeof Svg>;
|
|
13
|
+
/**
|
|
14
|
+
* The icon to be displayed on the right side of the clickable component.
|
|
15
|
+
*/
|
|
16
|
+
rightIcon?: ReactElement<typeof Svg>;
|
|
17
|
+
};
|
|
18
|
+
type Props = ClickableComponentProps & {
|
|
19
|
+
className?: string;
|
|
20
|
+
variant?: "ghost" | "reverse";
|
|
21
|
+
} & (({
|
|
22
|
+
component: "a";
|
|
23
|
+
} & AnchorHTMLAttributes<HTMLAnchorElement>) | ({
|
|
24
|
+
component: "button";
|
|
25
|
+
} & ButtonHTMLAttributes<HTMLButtonElement>));
|
|
26
|
+
/**
|
|
27
|
+
* Internal component to render the "ghost" style of interactive elements.
|
|
28
|
+
* This component supports both anchor and button elements, and allows for optional left and right icons.
|
|
29
|
+
*
|
|
30
|
+
* This is used to share the look of the link and the ghost button.
|
|
31
|
+
*
|
|
32
|
+
* @param props The props for the ClickableGhost component.
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export declare const ClickableGhost: ({ children, className, leftIcon, rightIcon, variant, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {} from "react";
|
|
3
|
+
import { getClassName } from "../prospect-client/utilities/getClassName";
|
|
4
|
+
import { Svg } from "./Svg";
|
|
5
|
+
import "@axa-fr/canopee-css/distributeur/Link/Link.css";
|
|
6
|
+
import { linkClassName } from "./Link/linkClassName";
|
|
7
|
+
/**
|
|
8
|
+
* Internal component to render the "ghost" style of interactive elements.
|
|
9
|
+
* This component supports both anchor and button elements, and allows for optional left and right icons.
|
|
10
|
+
*
|
|
11
|
+
* This is used to share the look of the link and the ghost button.
|
|
12
|
+
*
|
|
13
|
+
* @param props The props for the ClickableGhost component.
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export const ClickableGhost = ({ children, className, leftIcon, rightIcon, variant = "ghost", ...props }) => {
|
|
17
|
+
const componentClassName = getClassName({
|
|
18
|
+
baseClassName: linkClassName,
|
|
19
|
+
modifiers: [variant === "reverse" ? "reverse" : ""],
|
|
20
|
+
className,
|
|
21
|
+
});
|
|
22
|
+
if (props.component === "a") {
|
|
23
|
+
return (_jsxs("a", { className: componentClassName, ...props, children: [leftIcon, children, rightIcon] }));
|
|
24
|
+
}
|
|
25
|
+
return (_jsxs("button", { className: componentClassName, type: "button", ...props, children: [leftIcon, children, rightIcon] }));
|
|
26
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
type AnchorLinkProps = {
|
|
4
|
-
leftIcon?: ReactElement<typeof Svg>;
|
|
5
|
-
rightIcon?: ReactElement<typeof Svg>;
|
|
1
|
+
import { type AnchorHTMLAttributes } from "react";
|
|
2
|
+
import { type ClickableComponentProps } from "../ClickableGhost";
|
|
3
|
+
type AnchorLinkProps = ClickableComponentProps & {
|
|
6
4
|
className?: string;
|
|
7
5
|
disabled?: boolean;
|
|
8
6
|
variant?: "default" | "reverse";
|
|
9
7
|
};
|
|
10
|
-
type LinkComponentProps =
|
|
8
|
+
type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & AnchorLinkProps;
|
|
11
9
|
declare const LinkAnchor: {
|
|
12
10
|
({ className, target, rel, leftIcon, children, rightIcon, disabled, variant, ...restProps }: LinkComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
13
11
|
displayName: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
import {} from "react";
|
|
4
|
-
import { Svg } from "../Svg";
|
|
5
4
|
import { linkClassName } from "./linkClassName";
|
|
5
|
+
import { ClickableGhost, } from "../ClickableGhost";
|
|
6
6
|
const LinkAnchor = ({ className, target, rel, leftIcon, children, rightIcon, disabled, variant, ...restProps }) => {
|
|
7
7
|
const finalClassName = classnames(linkClassName, className, {
|
|
8
8
|
[`${linkClassName}--reverse`]: variant === "reverse",
|
|
9
9
|
});
|
|
10
|
-
return (_jsxs("a",
|
|
10
|
+
return (_jsxs(ClickableGhost, { component: "a", className: finalClassName, rel: target === "_blank" ? "noopener noreferrer" : rel, "aria-disabled": disabled ?? restProps["aria-disabled"], target: target, ...restProps, children: [leftIcon, children, rightIcon] }));
|
|
11
11
|
};
|
|
12
12
|
LinkAnchor.displayName = "LinkAnchor";
|
|
13
13
|
export { LinkAnchor };
|
package/dist/distributeur.d.ts
CHANGED
|
@@ -54,5 +54,6 @@ export type { CardDataVariant } from "./distributeur/CardData/CardData";
|
|
|
54
54
|
export { EditorialMessage, type EditorialMessageProps, type EditorialMessageType, } from "./distributeur/EditorialMessage/EditorialMessage";
|
|
55
55
|
export { Timeline, type TimelineProps, type TimelineVariants, } from "./distributeur/Timeline/Timeline";
|
|
56
56
|
export { CardButton, type CardButtonProps, } from "./distributeur/CardButton/CardButton";
|
|
57
|
+
export type { ClickableComponentProps } from "./distributeur/ClickableGhost";
|
|
57
58
|
export { BaseCard, type BaseCardProps } from "./distributeur/Card/BaseCard";
|
|
58
59
|
export { ItemFormHelper, type ItemFormHelperProps, type ItemFormHelperVariant, } from "./distributeur/ItemFormHelper/ItemFormHelper";
|
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.78",
|
|
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.78",
|
|
57
57
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
58
58
|
"@material-symbols/svg-700": ">= 0.19.0",
|
|
59
59
|
"react": ">= 19"
|