@axa-fr/design-system-slash-react 1.1.1-alpha.239 → 1.1.1-alpha.241

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.
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from "react";
2
+ type CustomLinkProps = {
3
+ render: (props: {
4
+ className: string;
5
+ }) => ReactNode;
6
+ };
7
+ declare const CustomLink: (props: CustomLinkProps) => ReactNode;
8
+ export { CustomLink, type CustomLinkProps };
@@ -0,0 +1,6 @@
1
+ import { linkClassName } from "./linkClassName";
2
+ const CustomLink = (props) => {
3
+ const { render } = props;
4
+ return render({ className: linkClassName, ...props });
5
+ };
6
+ export { CustomLink };
@@ -1,10 +1,5 @@
1
- import { type ComponentProps, type ElementType, type ReactNode } from "react";
2
1
  import "@axa-fr/design-system-slash-css/dist/Link/Link.scss";
3
- export type LinkProps<C extends ElementType> = {
4
- component?: C;
5
- leftIcon?: ReactNode;
6
- rightIcon?: ReactNode;
7
- className?: string;
8
- disabled?: boolean;
9
- } & ComponentProps<C>;
10
- export declare const Link: import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
2
+ import { type CustomLinkProps } from "./CustomLink";
3
+ import { type LinkComponentProps } from "./LinkAnchor";
4
+ export type LinkProps = LinkComponentProps | CustomLinkProps;
5
+ export declare const Link: import("react").ForwardRefExoticComponent<(CustomLinkProps | Omit<LinkComponentProps, "ref">) & import("react").RefAttributes<HTMLAnchorElement>>;
package/dist/Link/Link.js CHANGED
@@ -1,8 +1,12 @@
1
- import { jsxs as _jsxs } from "react/jsx-runtime";
2
- import classnames from "classnames";
3
- import { forwardRef, } from "react";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
4
2
  import "@axa-fr/design-system-slash-css/dist/Link/Link.scss";
5
- export const Link = forwardRef(({ className, component: Component = "a", leftIcon, rightIcon, target, rel, disabled, children, ...props }, ref) => {
6
- return (_jsxs(Component, { className: classnames("af-slash-link", className), target: target, rel: target === "_blank" ? "noopener noreferrer" : rel, "aria-disabled": disabled ?? props["aria-disabled"], ...props, ref: ref, children: [leftIcon, children, rightIcon] }));
3
+ import { forwardRef } from "react";
4
+ import { CustomLink } from "./CustomLink";
5
+ import { LinkAnchor } from "./LinkAnchor";
6
+ export const Link = forwardRef((props, ref) => {
7
+ if ("render" in props) {
8
+ return _jsx(CustomLink, { ...props });
9
+ }
10
+ return _jsx(LinkAnchor, { ...props, ref: ref });
7
11
  });
8
12
  Link.displayName = "Link";
@@ -0,0 +1,10 @@
1
+ import { ComponentPropsWithRef, type ReactNode } from "react";
2
+ type AnchorLinkProps = {
3
+ leftIcon?: ReactNode;
4
+ rightIcon?: ReactNode;
5
+ className?: string;
6
+ disabled?: boolean;
7
+ };
8
+ type LinkComponentProps = ComponentPropsWithRef<"a"> & AnchorLinkProps;
9
+ declare const LinkAnchor: import("react").ForwardRefExoticComponent<Omit<LinkComponentProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
10
+ export { LinkAnchor, type LinkComponentProps };
@@ -0,0 +1,10 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import classnames from "classnames";
3
+ import { forwardRef } from "react";
4
+ import { linkClassName } from "./linkClassName";
5
+ const LinkAnchor = forwardRef(({ className, target, rel, leftIcon, children, rightIcon, disabled, ...restProps }, ref) => {
6
+ const finalClassName = classnames(linkClassName, className);
7
+ return (_jsxs("a", { className: finalClassName, rel: target === "_blank" ? "noopener noreferrer" : rel, "aria-disabled": disabled ?? restProps["aria-disabled"], ref: ref, ...restProps, children: [leftIcon, children, rightIcon] }));
8
+ });
9
+ LinkAnchor.displayName = "LinkAnchor";
10
+ export { LinkAnchor };
@@ -0,0 +1 @@
1
+ export declare const linkClassName = "af-slash-link";
@@ -0,0 +1 @@
1
+ export const linkClassName = "af-slash-link";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-slash-react",
3
- "version": "1.1.1-alpha.239",
3
+ "version": "1.1.1-alpha.241",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "homepage": "https://github.com/AxaFrance/design-system#readme",
49
49
  "peerDependencies": {
50
- "@axa-fr/design-system-slash-css": "1.1.1-alpha.239",
50
+ "@axa-fr/design-system-slash-css": "1.1.1-alpha.241",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },