@axa-fr/design-system-look-and-feel-react 0.2.0-beta.315 → 0.2.0-beta.317

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,11 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ type TClickItem = {
3
+ classModifier?: string;
4
+ isDisabled?: boolean;
5
+ } & Omit<ComponentProps<"button">, "disabled"> & ComponentProps<"a"> & {
6
+ label?: ReactNode;
7
+ children?: ReactNode;
8
+ icon?: ReactNode;
9
+ };
10
+ export declare const ClickItem: ({ label, children, icon, href, isDisabled, className, classModifier, ...otherProps }: TClickItem) => import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import chevron from "@material-symbols/svg-400/outlined/chevron_right.svg";
3
+ import { useMemo } from "react";
4
+ import { Svg } from "../../../Svg";
5
+ import { getComponentClassName } from "../../../utilities";
6
+ export const ClickItem = ({ label, children, icon, href, isDisabled = false, className, classModifier = "", ...otherProps }) => {
7
+ const componentClassName = useMemo(() => getComponentClassName(className, `${classModifier}${isDisabled ? " disabled" : ""}`, "af-click-item"), [className, classModifier, isDisabled]);
8
+ const ClickComponent = useMemo(() => (href ? "a" : "button"), [href]);
9
+ const clickComponentProps = useMemo(() => href
10
+ ? { href, "aria-disabled": isDisabled, ...otherProps }
11
+ : {
12
+ type: "button",
13
+ disabled: isDisabled,
14
+ ...otherProps,
15
+ }, [isDisabled, href, otherProps]);
16
+ return (_jsxs(ClickComponent, { className: componentClassName, ...clickComponentProps, 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 || label })] }), _jsx("div", { className: "af-click-item__action", children: _jsx(Svg, { src: chevron }) })] }));
17
+ };
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen } from "@testing-library/react";
3
+ import { ClickItem } from "../ClickItem";
4
+ describe("ClickItem", () => {
5
+ it("should render label correctly with children prop", () => {
6
+ const label = "Sample Label";
7
+ render(_jsx(ClickItem, { children: label }));
8
+ const labelElement = screen.getByText(label);
9
+ expect(labelElement).toBeInTheDocument();
10
+ });
11
+ it("should render label correctly with label prop", () => {
12
+ const label = "Sample Label";
13
+ render(_jsx(ClickItem, { label: label }));
14
+ const labelElement = screen.getByText(label);
15
+ expect(labelElement).toBeInTheDocument();
16
+ });
17
+ it("should have custom class with modifier", () => {
18
+ const label = "Sample Label";
19
+ const className = "custom-class";
20
+ const classModifier = "modifier";
21
+ render(_jsx(ClickItem, { className: className, classModifier: classModifier, children: label }));
22
+ expect(screen.getByRole("button", { name: label })).toHaveClass(`${className} ${className}--${classModifier}`);
23
+ });
24
+ it("should render icon correctly", () => {
25
+ const label = "Sample Label";
26
+ const icon = _jsx("span", { children: "Icon" });
27
+ render(_jsx(ClickItem, { icon: icon, children: label }));
28
+ const iconElement = screen.getByText("Icon");
29
+ expect(iconElement).toBeInTheDocument();
30
+ });
31
+ it("should render as a button by default", () => {
32
+ const label = "Sample Label";
33
+ render(_jsx(ClickItem, { children: label }));
34
+ const buttonElement = screen.getByRole("button", { name: label });
35
+ expect(buttonElement).toBeInTheDocument();
36
+ });
37
+ it("should render as a link when href is provided", () => {
38
+ const label = "Sample Label";
39
+ const href = "https://example.com";
40
+ render(_jsx(ClickItem, { href: href, children: label }));
41
+ const linkElement = screen.getByRole("link", { name: label });
42
+ expect(linkElement).toBeInTheDocument();
43
+ expect(linkElement).toHaveAttribute("href", href);
44
+ });
45
+ it("should be a disabled anchor", () => {
46
+ const label = "Sample Label";
47
+ const href = "https://example.com";
48
+ const disabled = true;
49
+ render(_jsx(ClickItem, { href: href, isDisabled: disabled, children: label }));
50
+ const anchorElement = screen.getByRole("link", { name: label });
51
+ expect(anchorElement).toHaveClass("af-click-item--disabled");
52
+ expect(anchorElement).toHaveAttribute("aria-disabled", "true");
53
+ });
54
+ it("should be a disabled button", () => {
55
+ const label = "Sample Label";
56
+ const disabled = true;
57
+ render(_jsx(ClickItem, { isDisabled: disabled, children: label }));
58
+ const buttonElement = screen.getByRole("button", { name: label });
59
+ expect(buttonElement).toBeDisabled();
60
+ expect(buttonElement).toHaveClass("af-click-item--disabled");
61
+ });
62
+ });
@@ -0,0 +1 @@
1
+ export { ClickItem } from "./ClickItem";
@@ -0,0 +1 @@
1
+ export { ClickItem } from "./ClickItem";
@@ -1,10 +1,7 @@
1
- import type { ComponentProps, ReactNode } from "react";
2
- import "@axa-fr/design-system-look-and-feel-css/dist/List/ClickList/ClickList.scss";
1
+ import type { ComponentProps } from "react";
2
+ import { ClickItem } from "./ClickItem";
3
3
  type TClickList = {
4
- items: Array<ComponentProps<"button"> & {
5
- label: ReactNode;
6
- icon?: ReactNode;
7
- }>;
4
+ items: Array<ComponentProps<typeof ClickItem>>;
8
5
  classModifier?: string;
9
6
  };
10
7
  export declare const ClickList: ({ items, classModifier }: TClickList) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import chevron from "@material-symbols/svg-400/outlined/chevron_right.svg";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import { List } from "..";
4
- import { Svg } from "../../Svg";
5
- import "@axa-fr/design-system-look-and-feel-css/dist/List/ClickList/ClickList.scss";
6
- export const ClickList = ({ items, classModifier }) => (_jsx(List, { classModifier: `list click-list ${classModifier}`, tabIndex: -1, children: items.map(({ id, label, icon, ...buttonProps }) => (_jsxs("button", { id: id, className: "af-list-item__button", type: "button", ...buttonProps, children: [_jsxs("div", { className: "af-list-item__content", children: [icon && _jsx("div", { className: "af-list-item-content__icon", children: icon }), _jsx("div", { className: "af-list-item-content__label", children: label })] }), _jsx("div", { className: "af-list-item__action", children: _jsx(Svg, { src: chevron }) })] }, id ?? label?.toString()))) }));
3
+ import { ClickItem } from "./ClickItem";
4
+ export const ClickList = ({ items, classModifier }) => (_jsx(List, { classModifier: `click-list ${classModifier}`, tabIndex: -1, children: items.map(({ id, ...props }) => (_jsx(ClickItem, { id: id, ...props }, id))) }));
@@ -4,3 +4,4 @@ declare const meta: Meta<typeof ClickList>;
4
4
  export default meta;
5
5
  export declare const ClickListWithIcon: StoryObj<typeof ClickList>;
6
6
  export declare const ClickListWithoutIcon: StoryObj<typeof ClickList>;
7
+ export declare const ClickListLinkWithoutIcon: StoryObj<typeof ClickList>;
@@ -14,15 +14,27 @@ export const ClickListWithIcon = {
14
14
  args: {
15
15
  items: [
16
16
  {
17
- id: "report-claim",
17
+ id: "1",
18
18
  icon: _jsx(Svg, { src: error }),
19
- label: "Déclarer un sinistre",
19
+ children: "Texte principal",
20
+ classModifier: "small",
20
21
  },
21
22
  {
22
- id: "follow-claim",
23
+ id: "2",
24
+ icon: _jsx(Svg, { src: error }),
25
+ children: "Texte principal",
26
+ },
27
+ {
28
+ id: "3",
29
+ icon: _jsx(Svg, { src: error }),
30
+ children: "Texte principal",
31
+ classModifier: "large",
32
+ },
33
+ {
34
+ id: "4",
23
35
  icon: _jsx(Svg, { src: contentPasteGo }),
24
- label: "Suivre mes sinistres",
25
- disabled: true,
36
+ children: "Texte principal",
37
+ isDisabled: true,
26
38
  },
27
39
  ],
28
40
  classModifier: "",
@@ -41,11 +53,42 @@ export const ClickListWithoutIcon = {
41
53
  args: {
42
54
  items: [
43
55
  {
44
- label: (_jsxs(_Fragment, { children: [_jsx("h3", { className: "af-list-item-content-label__title", children: "Fiche Orias pr\u00E9contractuelle" }), _jsx("p", { className: "af-list-item-content-label__subtitle", children: "30 novembre 2021" }), _jsx("p", { className: "af-list-item-content-label__secondary", children: "Sign\u00E9 \u00E9lectroniquement" })] })),
56
+ id: "1",
57
+ children: (_jsxs(_Fragment, { children: [_jsx("h3", { className: "af-click-item__title", children: "Fiche Orias pr\u00E9contractuelle" }), _jsx("p", { className: "af-click-item__subtitle", children: "30 novembre 2021" }), _jsx("p", { className: "af-click-item__secondary", children: "Sign\u00E9 \u00E9lectroniquement" })] })),
58
+ },
59
+ {
60
+ id: "2",
61
+ children: (_jsxs(_Fragment, { children: [_jsx("h3", { className: "af-click-item__title", children: "Fiche Orias pr\u00E9contractuelle" }), _jsx("p", { className: "af-click-item__subtitle", children: "30 novembre 2021" }), _jsx("p", { className: "af-click-item__secondary", children: "Sign\u00E9 \u00E9lectroniquement" })] })),
62
+ isDisabled: true,
63
+ },
64
+ ],
65
+ classModifier: "",
66
+ },
67
+ argTypes: {
68
+ classModifier: {
69
+ options: ["", "large"],
70
+ control: { type: "select" },
71
+ defaultValue: "",
72
+ },
73
+ },
74
+ };
75
+ export const ClickListLinkWithoutIcon = {
76
+ name: "ClickList link without icon",
77
+ render: (args) => _jsx(ClickList, { ...args }),
78
+ args: {
79
+ items: [
80
+ {
81
+ id: "1",
82
+ children: (_jsxs(_Fragment, { children: [_jsx("h3", { className: "af-click-item__title", children: "Fiche Orias pr\u00E9contractuelle" }), _jsx("p", { className: "af-click-item__subtitle", children: "30 novembre 2021" }), _jsx("p", { className: "af-click-item__secondary", children: "Sign\u00E9 \u00E9lectroniquement" })] })),
83
+ href: "https://github.com/AxaFrance/design-system",
84
+ target: "_blank",
45
85
  },
46
86
  {
47
- label: (_jsxs(_Fragment, { children: [_jsx("h3", { className: "af-list-item-content-label__title", children: "Fiche Orias pr\u00E9contractuelle" }), _jsx("p", { className: "af-list-item-content-label__subtitle", children: "30 novembre 2021" }), _jsx("p", { className: "af-list-item-content-label__secondary", children: "Sign\u00E9 \u00E9lectroniquement" })] })),
48
- disabled: true,
87
+ id: "2",
88
+ children: (_jsxs(_Fragment, { children: [_jsx("h3", { className: "af-click-item__title", children: "Fiche Orias pr\u00E9contractuelle" }), _jsx("p", { className: "af-click-item__subtitle", children: "30 novembre 2021" }), _jsx("p", { className: "af-click-item__secondary", children: "Sign\u00E9 \u00E9lectroniquement" })] })),
89
+ href: "https://github.com/AxaFrance/design-system",
90
+ target: "_blank",
91
+ isDisabled: true,
49
92
  },
50
93
  ],
51
94
  classModifier: "",
@@ -1 +1,3 @@
1
+ import "@axa-fr/design-system-look-and-feel-css/dist/List/ClickList/ClickList.scss";
2
+ export { ClickItem } from "./ClickItem";
1
3
  export { ClickList } from "./ClickList";
@@ -1 +1,3 @@
1
+ import "@axa-fr/design-system-look-and-feel-css/dist/List/ClickList/ClickList.scss";
2
+ export { ClickItem } from "./ClickItem";
1
3
  export { ClickList } from "./ClickList";
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export { Footer } from "./Layout/Footer/Footer";
14
14
  export { Header } from "./Layout/Header";
15
15
  export { Link } from "./Link/Link";
16
16
  export { List } from "./List";
17
- export { ClickList } from "./List/ClickList";
17
+ export { ClickItem, ClickList } from "./List/ClickList";
18
18
  export { ContentItemDuo } from "./List/ContentItemDuo";
19
19
  export { ContentItemMono, ContentItemMonoSize } from "./List/ContentItemMono";
20
20
  export { ContentTabList } from "./List/ContentTabList";
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ export { Footer } from "./Layout/Footer/Footer";
13
13
  export { Header } from "./Layout/Header";
14
14
  export { Link } from "./Link/Link";
15
15
  export { List } from "./List";
16
- export { ClickList } from "./List/ClickList";
16
+ export { ClickItem, ClickList } from "./List/ClickList";
17
17
  export { ContentItemDuo } from "./List/ContentItemDuo";
18
18
  export { ContentItemMono, ContentItemMonoSize } from "./List/ContentItemMono";
19
19
  export { ContentTabList } from "./List/ContentTabList";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-look-and-feel-react",
3
- "version": "0.2.0-beta.315",
3
+ "version": "0.2.0-beta.317",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "homepage": "https://github.com/AxaFrance/design-system#readme",
43
43
  "peerDependencies": {
44
- "@axa-fr/design-system-look-and-feel-css": "0.2.0-beta.315",
44
+ "@axa-fr/design-system-look-and-feel-css": "0.2.0-beta.317",
45
45
  "@material-symbols/svg-400": ">= 0.19.0",
46
46
  "react": ">= 18"
47
47
  },