@axa-fr/design-system-look-and-feel-react 0.2.0-beta.332 → 0.2.0-beta.334
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/Accordion/Accordion.d.ts +12 -8
- package/dist/Accordion/Accordion.js +10 -6
- package/dist/Accordion/Accordion.stories.d.ts +4 -5
- package/dist/Accordion/Accordion.stories.js +29 -13
- package/dist/Accordion/AccordionTagDateContainer.d.ts +10 -0
- package/dist/Accordion/AccordionTagDateContainer.js +10 -0
- package/dist/Accordion/__tests__/Accordion.test.d.ts +1 -0
- package/dist/Accordion/__tests__/Accordion.test.js +50 -0
- package/dist/Accordion/__tests__/AccordionTagDateContainer.test.d.ts +1 -0
- package/dist/Accordion/__tests__/AccordionTagDateContainer.test.js +23 -0
- package/dist/Accordion/index.d.ts +3 -0
- package/dist/Accordion/index.js +3 -0
- package/dist/AccordionCore/AccordionCore.d.ts +12 -0
- package/dist/AccordionCore/AccordionCore.js +13 -0
- package/dist/AccordionCore/AccordionCore.stories.d.ts +8 -0
- package/dist/AccordionCore/AccordionCore.stories.js +41 -0
- package/dist/AccordionCore/__tests__/AccordionCore.test.d.ts +1 -0
- package/dist/AccordionCore/__tests__/AccordionCore.test.js +47 -0
- package/dist/AccordionCore/index.d.ts +2 -0
- package/dist/AccordionCore/index.js +2 -0
- package/dist/Layout/Footer/MenuLink.js +2 -3
- package/dist/List/ContentTabList/ContentTabList.js +2 -3
- package/dist/List/List.stories.js +1 -1
- package/dist/Pagination/Pagination.js +3 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/utilities/constants.d.ts +6 -0
- package/dist/utilities/constants.js +7 -0
- package/dist/utilities/hooks/useIsSmallScreen.js +1 -1
- package/dist/utilities.d.ts +2 -1
- package/dist/utilities.js +2 -1
- package/package.json +3 -3
- package/dist/Accordion/AccordionItem.d.ts +0 -6
- package/dist/Accordion/AccordionItem.js +0 -10
@@ -1,8 +1,12 @@
|
|
1
|
-
import "
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
2
|
+
import { AccordionCore } from "../AccordionCore/AccordionCore";
|
3
|
+
import { AccordionTagDateContainer } from "./AccordionTagDateContainer";
|
4
|
+
type AccordionProps = {
|
5
|
+
title: string;
|
6
|
+
subtitle?: string;
|
7
|
+
icon?: ReactNode;
|
8
|
+
value?: string;
|
9
|
+
isTitleFirst?: boolean;
|
10
|
+
} & ComponentProps<typeof AccordionTagDateContainer> & Partial<ComponentProps<typeof AccordionCore>>;
|
11
|
+
export declare const Accordion: ({ title, children, icon, subtitle, tagLabel, tagProps, dateLabel, dateProps, value, isTitleFirst, ...accordionCoreProps }: AccordionProps) => import("react/jsx-runtime").JSX.Element;
|
12
|
+
export {};
|
@@ -1,7 +1,11 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import "
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
2
|
+
import { useMemo } from "react";
|
3
|
+
import { AccordionCore } from "../AccordionCore/AccordionCore";
|
4
|
+
import { BREAKPOINT, getComponentClassName, useIsSmallScreen, } from "../utilities";
|
5
|
+
import { AccordionTagDateContainer } from "./AccordionTagDateContainer";
|
6
|
+
export const Accordion = ({ title, children, icon, subtitle, tagLabel, tagProps, dateLabel, dateProps, value, isTitleFirst = true, ...accordionCoreProps }) => {
|
7
|
+
const isMobile = useIsSmallScreen(BREAKPOINT.SM);
|
8
|
+
const isShowingIcon = Boolean(icon && isTitleFirst);
|
9
|
+
const summaryClassName = useMemo(() => getComponentClassName("af-accordion__summary", isTitleFirst ? "title-first" : ""), [isTitleFirst]);
|
10
|
+
return (_jsx(AccordionCore, { summary: _jsxs(_Fragment, { children: [isShowingIcon && isMobile && (_jsx("div", { className: "af-accordion__icon", children: icon })), !isTitleFirst && (_jsx(AccordionTagDateContainer, { tagLabel: tagLabel, dateLabel: dateLabel, tagProps: tagProps, dateProps: dateProps })), _jsxs("div", { className: "af-accordion__title-container", children: [isShowingIcon && !isMobile && (_jsx("div", { className: "af-accordion__icon", children: icon })), _jsx("p", { className: "af-accordion__title", children: title }), subtitle && _jsx("p", { className: "af-accordion__subtitle", children: subtitle })] }), isTitleFirst && (_jsx(AccordionTagDateContainer, { tagLabel: tagLabel, dateLabel: dateLabel, tagProps: tagProps, dateProps: dateProps })), value && _jsx("p", { className: "af-accordion__value", children: value })] }), summaryProps: { className: summaryClassName }, ...accordionCoreProps, children: children }));
|
6
11
|
};
|
7
|
-
Accordion.Item = AccordionItem;
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { Meta, StoryObj } from "@storybook/react";
|
2
|
-
import {
|
2
|
+
import type { ComponentProps } from "react";
|
3
|
+
import { Accordion } from ".";
|
3
4
|
declare const meta: Meta<typeof Accordion>;
|
4
5
|
export default meta;
|
5
|
-
|
6
|
-
|
7
|
-
};
|
8
|
-
export declare const AccordionStory: StoryObj<StoryProps>;
|
6
|
+
export declare const AccordionStory: StoryObj<ComponentProps<typeof Accordion>>;
|
7
|
+
export declare const AccordionWithCardStory: StoryObj<ComponentProps<typeof Accordion>>;
|
@@ -1,24 +1,40 @@
|
|
1
|
-
import {
|
2
|
-
import
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import callIcon from "@material-symbols/svg-400/outlined/call-fill.svg";
|
3
|
+
import { Accordion } from ".";
|
4
|
+
import { Card, Svg } from "..";
|
3
5
|
const meta = {
|
4
6
|
component: Accordion,
|
5
7
|
title: "Components/Accordion",
|
6
|
-
parameters: {
|
7
|
-
layout: "fullscreen",
|
8
|
-
},
|
9
8
|
};
|
10
9
|
export default meta;
|
10
|
+
const defaultArgs = {
|
11
|
+
isTitleFirst: true,
|
12
|
+
icon: _jsx(Svg, { src: callIcon }),
|
13
|
+
title: "Titre onglet",
|
14
|
+
subtitle: "Titre onglet",
|
15
|
+
tagLabel: "En attente",
|
16
|
+
dateLabel: "01/01/2021",
|
17
|
+
dateProps: { dateTime: "2021-01-01" },
|
18
|
+
value: "+ 686,00 €",
|
19
|
+
children: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper magna et tempor blandit.
|
20
|
+
Nulla vitae eros a odio pretium gravida. Sed eget tortor nec massa lobortis bibendum. Morbi eget
|
21
|
+
ligula porttitor, euismod odio vestibulum, porta massa. Aenean vel venenatis tellus, sed iaculis nisl.`,
|
22
|
+
isOpen: undefined,
|
23
|
+
onClick: undefined,
|
24
|
+
};
|
11
25
|
export const AccordionStory = {
|
12
26
|
name: "Accordion",
|
13
|
-
render: ({
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
numberOfItems: 3,
|
27
|
+
render: (args) => _jsx(Accordion, { ...args }),
|
28
|
+
args: defaultArgs,
|
29
|
+
argTypes: {
|
30
|
+
dateLabel: { control: "text" },
|
18
31
|
},
|
32
|
+
};
|
33
|
+
export const AccordionWithCardStory = {
|
34
|
+
name: "Accordion With Card",
|
35
|
+
render: (args) => (_jsx(Card, { classModifier: "large accordion", tabIndex: undefined, children: _jsx(Accordion, { ...args }) })),
|
36
|
+
args: defaultArgs,
|
19
37
|
argTypes: {
|
20
|
-
|
21
|
-
control: { type: "range", min: 1, max: 10 },
|
22
|
-
},
|
38
|
+
dateLabel: { control: "text" },
|
23
39
|
},
|
24
40
|
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { type ComponentProps } from "react";
|
2
|
+
import { Tag } from "../Tag";
|
3
|
+
type AccordionTagDateContainerProps = {
|
4
|
+
tagLabel?: string;
|
5
|
+
tagProps?: ComponentProps<typeof Tag>;
|
6
|
+
dateLabel?: string;
|
7
|
+
dateProps?: ComponentProps<"time">;
|
8
|
+
};
|
9
|
+
export declare const AccordionTagDateContainer: ({ tagLabel, tagProps, dateLabel, dateProps, }: AccordionTagDateContainerProps) => import("react/jsx-runtime").JSX.Element | null;
|
10
|
+
export {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useMemo } from "react";
|
3
|
+
import { Tag } from "../Tag";
|
4
|
+
export const AccordionTagDateContainer = ({ tagLabel, tagProps, dateLabel, dateProps, }) => {
|
5
|
+
const isShowing = useMemo(() => Boolean(tagLabel) || Boolean(dateLabel), [tagLabel, dateLabel]);
|
6
|
+
if (!isShowing) {
|
7
|
+
return null;
|
8
|
+
}
|
9
|
+
return (_jsxs("div", { className: "af-accordion__tag-date-container", children: [tagLabel && (_jsx("div", { className: "af-accordion__tag-container", children: _jsx(Tag, { classModifier: "warning", ...tagProps, children: tagLabel }) })), dateLabel && (_jsx("time", { className: "af-accordion__date", ...dateProps, children: dateLabel }))] }));
|
10
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { render, screen } from "@testing-library/react";
|
3
|
+
import { Accordion } from "../Accordion";
|
4
|
+
describe("Accordion", () => {
|
5
|
+
const originalWindowWidth = global.innerWidth;
|
6
|
+
beforeAll(() => {
|
7
|
+
global.innerWidth = originalWindowWidth;
|
8
|
+
});
|
9
|
+
it("renders correctly with all visual props", () => {
|
10
|
+
const icon = "Accordion Icon";
|
11
|
+
const title = "Accordion Title";
|
12
|
+
const subtitle = "Accordion Subtitle";
|
13
|
+
const children = "Accordion Content";
|
14
|
+
const tag = "Accordion Tag";
|
15
|
+
const date = "Accordion Date";
|
16
|
+
const value = "Accordion Value";
|
17
|
+
render(_jsx(Accordion, { icon: icon, title: title, subtitle: subtitle, tagLabel: tag, dateLabel: date, value: value, children: children }));
|
18
|
+
expect(screen.getByText(icon)).toBeInTheDocument();
|
19
|
+
expect(screen.getByText(title)).toBeInTheDocument();
|
20
|
+
expect(screen.getByText(subtitle)).toBeInTheDocument();
|
21
|
+
expect(screen.getByText(children)).toBeInTheDocument();
|
22
|
+
expect(screen.getByText(tag)).toBeInTheDocument();
|
23
|
+
expect(screen.getByText(date)).toBeInTheDocument();
|
24
|
+
expect(screen.getByText(value)).toBeInTheDocument();
|
25
|
+
expect(screen.getByText("Accordion Content").closest("details")).toHaveClass("af-accordion");
|
26
|
+
});
|
27
|
+
it("renders with isTitleFirst false", () => {
|
28
|
+
render(_jsx(Accordion, { icon: "icon", title: "Accordion Title", dateLabel: "date", isTitleFirst: false, children: "Accordion Content" }));
|
29
|
+
const summary = screen.getByText("Accordion Title").closest("summary");
|
30
|
+
expect(summary).not.toHaveClass("af-accordion__summary--title-first");
|
31
|
+
expect(screen.queryByText("icon")).toBeNull();
|
32
|
+
expect(screen
|
33
|
+
.getByText("date")
|
34
|
+
.compareDocumentPosition(screen.getByText("Accordion Title"))).toBe(Node.DOCUMENT_POSITION_FOLLOWING);
|
35
|
+
});
|
36
|
+
it("renders with isTitleFirst true", () => {
|
37
|
+
render(_jsx(Accordion, { icon: "icon", title: "Accordion Title", dateLabel: "date", isTitleFirst: true, children: "Accordion Content" }));
|
38
|
+
const summary = screen.getByText("Accordion Title").closest("summary");
|
39
|
+
expect(summary).toHaveClass("af-accordion__summary--title-first");
|
40
|
+
expect(screen.getByText("icon").parentElement).toHaveClass("af-accordion__title-container");
|
41
|
+
expect(screen
|
42
|
+
.getByText("date")
|
43
|
+
.compareDocumentPosition(screen.getByText("Accordion Title"))).toBe(Node.DOCUMENT_POSITION_PRECEDING);
|
44
|
+
});
|
45
|
+
it("renders on mobile", () => {
|
46
|
+
global.innerWidth = 500;
|
47
|
+
render(_jsx(Accordion, { icon: "icon", title: "Accordion Title", dateLabel: "date", children: "Accordion Content" }));
|
48
|
+
expect(screen.getByText("icon").parentElement).toHaveClass("af-accordion__summary");
|
49
|
+
});
|
50
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { render, screen } from "@testing-library/react";
|
3
|
+
import { AccordionTagDateContainer } from "../AccordionTagDateContainer";
|
4
|
+
describe("AccordionTagDateContainer", () => {
|
5
|
+
it("renders correctly", () => {
|
6
|
+
const dateLabel = "01/01/2021";
|
7
|
+
const dateTime = "2021-01-01";
|
8
|
+
const tagLabel = "tag";
|
9
|
+
render(_jsx(AccordionTagDateContainer, { tagLabel: tagLabel, dateLabel: dateLabel, dateProps: { dateTime } }));
|
10
|
+
expect(screen.getByText(tagLabel).parentElement).toHaveClass("af-tag af-tag--warning");
|
11
|
+
expect(screen.getByText(dateLabel)).toHaveProperty("dateTime", dateTime);
|
12
|
+
});
|
13
|
+
it("should pass tagProps to Tag", () => {
|
14
|
+
const tag = "tag";
|
15
|
+
const tagProps = { classModifier: "success" };
|
16
|
+
render(_jsx(AccordionTagDateContainer, { tagLabel: tag, tagProps: tagProps }));
|
17
|
+
expect(screen.getByText(tag).parentElement).toHaveClass("af-tag af-tag--success");
|
18
|
+
});
|
19
|
+
it("should return null if no tag or date", () => {
|
20
|
+
const { container } = render(_jsx(AccordionTagDateContainer, {}));
|
21
|
+
expect(container).toBeEmptyDOMElement();
|
22
|
+
});
|
23
|
+
});
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { type ComponentProps, type MouseEvent, type ReactNode } from "react";
|
2
|
+
type AccordionProps = {
|
3
|
+
summary: ReactNode;
|
4
|
+
children: ReactNode;
|
5
|
+
isOpen?: boolean;
|
6
|
+
className?: string;
|
7
|
+
classModifier?: string;
|
8
|
+
summaryProps?: ComponentProps<"summary">;
|
9
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
10
|
+
} & Partial<ComponentProps<"details">>;
|
11
|
+
export declare const AccordionCore: ({ summary, children, className, classModifier, summaryProps, isOpen, onClick, ...detailsProps }: AccordionProps) => import("react/jsx-runtime").JSX.Element;
|
12
|
+
export {};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useCallback, useMemo, } from "react";
|
3
|
+
import { getComponentClassName } from "../utilities";
|
4
|
+
export const AccordionCore = ({ summary, children, className, classModifier, summaryProps, isOpen, onClick, ...detailsProps }) => {
|
5
|
+
const componentClassName = useMemo(() => getComponentClassName(className, classModifier, "af-accordion"), [classModifier, className]);
|
6
|
+
const handleToggle = useCallback((event) => {
|
7
|
+
if (onClick) {
|
8
|
+
event.preventDefault();
|
9
|
+
onClick(event);
|
10
|
+
}
|
11
|
+
}, [onClick]);
|
12
|
+
return (_jsxs("details", { className: componentClassName, open: isOpen, ...detailsProps, children: [_jsx("summary", { className: "af-accordion__summary", onClick: handleToggle, role: "button", tabIndex: 0, ...summaryProps, children: summary }), _jsx("hr", { className: "af-accordion__separator" }), _jsx("div", { className: "af-accordion__content", children: children })] }));
|
13
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import type { ComponentProps } from "react";
|
3
|
+
import { AccordionCore } from ".";
|
4
|
+
declare const meta: Meta<typeof AccordionCore>;
|
5
|
+
export default meta;
|
6
|
+
export declare const AccordionCoreStory: StoryObj<ComponentProps<typeof AccordionCore>>;
|
7
|
+
export declare const AccordionCoreWithCustomStyledSummaryStory: StoryObj<ComponentProps<typeof AccordionCore>>;
|
8
|
+
export declare const AccordionCoreWithCardStory: StoryObj<ComponentProps<typeof AccordionCore>>;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { AccordionCore } from ".";
|
3
|
+
import { Card } from "..";
|
4
|
+
const meta = {
|
5
|
+
component: AccordionCore,
|
6
|
+
title: "Components/AccordionCore",
|
7
|
+
};
|
8
|
+
export default meta;
|
9
|
+
const defaultArgs = {
|
10
|
+
summary: "Titre onglet",
|
11
|
+
children: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper magna et tempor blandit.
|
12
|
+
Nulla vitae eros a odio pretium gravida. Sed eget tortor nec massa lobortis bibendum. Morbi eget
|
13
|
+
ligula porttitor, euismod odio vestibulum, porta massa. Aenean vel venenatis tellus, sed iaculis nisl.`,
|
14
|
+
isOpen: undefined,
|
15
|
+
onClick: undefined,
|
16
|
+
};
|
17
|
+
export const AccordionCoreStory = {
|
18
|
+
name: "AccordionCore",
|
19
|
+
render: (args) => _jsx(AccordionCore, { ...args }),
|
20
|
+
args: defaultArgs,
|
21
|
+
};
|
22
|
+
export const AccordionCoreWithCustomStyledSummaryStory = {
|
23
|
+
name: "AccordionCore With Custom Styled Summary",
|
24
|
+
render: (args) => _jsx(AccordionCore, { ...args }),
|
25
|
+
args: {
|
26
|
+
summary: (_jsx("div", { style: {
|
27
|
+
backgroundColor: "red",
|
28
|
+
paddingBottom: "32px",
|
29
|
+
} })),
|
30
|
+
children: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam semper magna et tempor blandit.
|
31
|
+
Nulla vitae eros a odio pretium gravida. Sed eget tortor nec massa lobortis bibendum. Morbi eget
|
32
|
+
ligula porttitor, euismod odio vestibulum, porta massa. Aenean vel venenatis tellus, sed iaculis nisl.`,
|
33
|
+
isOpen: undefined,
|
34
|
+
onClick: undefined,
|
35
|
+
},
|
36
|
+
};
|
37
|
+
export const AccordionCoreWithCardStory = {
|
38
|
+
name: "AccordionCore With Card",
|
39
|
+
render: (args) => (_jsx(Card, { classModifier: "large accordion", tabIndex: undefined, children: _jsx(AccordionCore, { ...args }) })),
|
40
|
+
args: defaultArgs,
|
41
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { render, screen } from "@testing-library/react";
|
3
|
+
import { AccordionCore } from "../AccordionCore";
|
4
|
+
describe("AccordionCore", () => {
|
5
|
+
it("renders correctly with all visual props", () => {
|
6
|
+
const title = "Accordion Title";
|
7
|
+
const children = "Accordion Content";
|
8
|
+
render(_jsx(AccordionCore, { summary: title, children: children }));
|
9
|
+
expect(screen.getByText(title)).toBeInTheDocument();
|
10
|
+
expect(screen.getByText(children)).toBeInTheDocument();
|
11
|
+
expect(screen.getByText("Accordion Content").closest("details")).toHaveClass("af-accordion");
|
12
|
+
const details = screen.getByText(children).closest("details");
|
13
|
+
expect(details).not.toHaveAttribute("open");
|
14
|
+
const summary = screen.getByText("Accordion Title");
|
15
|
+
summary.click();
|
16
|
+
expect(details).toHaveAttribute("open");
|
17
|
+
summary.click();
|
18
|
+
expect(details).not.toHaveAttribute("open");
|
19
|
+
});
|
20
|
+
it("should have custom class with modifier", () => {
|
21
|
+
const className = "custom-class";
|
22
|
+
const classModifier = "modifier";
|
23
|
+
render(_jsx(AccordionCore, { summary: "Accordion Title", className: className, classModifier: classModifier, children: "Accordion Content" }));
|
24
|
+
expect(screen.getByText("Accordion Content").closest("details")).toHaveClass(`${className} ${className}--${classModifier}`);
|
25
|
+
});
|
26
|
+
it("renders Accordion with open details", () => {
|
27
|
+
render(_jsx(AccordionCore, { summary: "Accordion Title", isOpen: true, children: "Accordion Content" }));
|
28
|
+
const details = screen.getByText("Accordion Content").closest("details");
|
29
|
+
expect(details).toHaveAttribute("open");
|
30
|
+
});
|
31
|
+
it("renders Accordion with close details", () => {
|
32
|
+
render(_jsx(AccordionCore, { summary: "Accordion Title", isOpen: false, children: "Accordion Content" }));
|
33
|
+
const details = screen.getByText("Accordion Content").closest("details");
|
34
|
+
expect(details).not.toHaveAttribute("open");
|
35
|
+
});
|
36
|
+
it("use onClick prop when summary click", () => {
|
37
|
+
const onClick = vi.fn();
|
38
|
+
render(_jsx(AccordionCore, { summary: "Accordion Title", onClick: onClick, children: "Accordion Content" }));
|
39
|
+
const summary = screen.getByText("Accordion Title");
|
40
|
+
summary.click();
|
41
|
+
expect(onClick).toHaveBeenCalled();
|
42
|
+
});
|
43
|
+
it("renders with custom title summary", () => {
|
44
|
+
render(_jsx(AccordionCore, { summary: _jsx("p", { className: "custom-title", children: "Custom Title" }), children: "Accordion Content" }));
|
45
|
+
expect(screen.getByText("Custom Title")).toHaveClass("custom-title");
|
46
|
+
});
|
47
|
+
});
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import classNames from "classnames";
|
3
|
-
import { useIsSmallScreen } from "../../utilities";
|
4
|
-
const BREAKPOINT_SMALL = 1024;
|
3
|
+
import { BREAKPOINT, useIsSmallScreen } from "../../utilities";
|
5
4
|
export const MenuLink = ({ links, isAboutOpen = false }) => {
|
6
|
-
const isSmallScreen = useIsSmallScreen(
|
5
|
+
const isSmallScreen = useIsSmallScreen(BREAKPOINT.MD);
|
7
6
|
if (links.length === 0) {
|
8
7
|
return null;
|
9
8
|
}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import { List } from "../List";
|
3
3
|
import "@axa-fr/design-system-look-and-feel-css/dist/List/ContentTabList/ContentTabList.scss";
|
4
|
-
import { useIsSmallScreen } from "../../utilities";
|
4
|
+
import { BREAKPOINT, useIsSmallScreen } from "../../utilities";
|
5
5
|
import { ContentTabItem } from "./ContentTabItem";
|
6
|
-
const BREAKPOINT_SMALL = 668;
|
7
6
|
export const ContentTabList = ({ items, classModifier, }) => {
|
8
|
-
const isMobile = useIsSmallScreen(
|
7
|
+
const isMobile = useIsSmallScreen(BREAKPOINT.SM);
|
9
8
|
return (_jsx(List, { classModifier: `list large extra-padding content-tab-list ${classModifier}`, tabIndex: -1, children: items.map(({ id, ...item }) => (_jsx(ContentTabItem, { ...item, isMobile: isMobile }, id ?? item.title))) }));
|
10
9
|
};
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import "@axa-fr/design-system-look-and-feel-css/dist/Pagination/Pagination.scss";
|
3
3
|
import { useEffect, useState } from "react";
|
4
|
-
import { useIsSmallScreen } from "../utilities";
|
5
|
-
import { PaginationMobile } from "./PaginationMobile";
|
4
|
+
import { BREAKPOINT, useIsSmallScreen } from "../utilities";
|
6
5
|
import { PaginationDesktop } from "./PaginationDesktop";
|
7
|
-
|
6
|
+
import { PaginationMobile } from "./PaginationMobile";
|
8
7
|
export const Pagination = ({ numberPage, onChangePage, defaultPage, }) => {
|
9
|
-
const isMobile = useIsSmallScreen(
|
8
|
+
const isMobile = useIsSmallScreen(BREAKPOINT.MD);
|
10
9
|
const [currentPage, setCurrentPage] = useState(defaultPage || 1);
|
11
10
|
useEffect(() => {
|
12
11
|
onChangePage(currentPage);
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import "@fontsource/source-sans-pro";
|
2
|
-
export { Accordion } from "./Accordion
|
2
|
+
export { Accordion } from "./Accordion";
|
3
|
+
export { AccordionCore } from "./AccordionCore";
|
3
4
|
export { Alert } from "./Alert/Alert";
|
4
5
|
export type { AlertType } from "./Alert/Alert";
|
5
6
|
export { ButtonClient as Button, Variants as ButtonVariants, } from "./Button/Button";
|
package/dist/index.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import "@fontsource/source-sans-pro";
|
2
|
-
export { Accordion } from "./Accordion
|
2
|
+
export { Accordion } from "./Accordion";
|
3
|
+
export { AccordionCore } from "./AccordionCore";
|
3
4
|
export { Alert } from "./Alert/Alert";
|
4
5
|
export { ButtonClient as Button, Variants as ButtonVariants, } from "./Button/Button";
|
5
6
|
export { Card } from "./Card";
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export var BREAKPOINT;
|
2
|
+
(function (BREAKPOINT) {
|
3
|
+
BREAKPOINT[BREAKPOINT["SM"] = 667] = "SM";
|
4
|
+
BREAKPOINT[BREAKPOINT["MD"] = 1023] = "MD";
|
5
|
+
BREAKPOINT[BREAKPOINT["LG"] = 1279] = "LG";
|
6
|
+
BREAKPOINT[BREAKPOINT["XL"] = 1599] = "XL";
|
7
|
+
})(BREAKPOINT || (BREAKPOINT = {}));
|
@@ -7,7 +7,7 @@ export const useIsSmallScreen = (breakPointToCheck) => {
|
|
7
7
|
};
|
8
8
|
}, []);
|
9
9
|
const getSnapshot = useCallback(() => {
|
10
|
-
return window.innerWidth
|
10
|
+
return window.innerWidth <= breakPointToCheck;
|
11
11
|
}, [breakPointToCheck]);
|
12
12
|
const getServerSnapshot = useCallback(() => false, []);
|
13
13
|
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
package/dist/utilities.d.ts
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
export {
|
1
|
+
export { BREAKPOINT } from "./utilities/constants";
|
2
2
|
export { getComponentClassName } from "./utilities/helpers/getComponentClassName";
|
3
|
+
export { useIsSmallScreen } from "./utilities/hooks/useIsSmallScreen";
|
package/dist/utilities.js
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
export {
|
1
|
+
export { BREAKPOINT } from "./utilities/constants";
|
2
2
|
export { getComponentClassName } from "./utilities/helpers/getComponentClassName";
|
3
|
+
export { useIsSmallScreen } from "./utilities/hooks/useIsSmallScreen";
|
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.
|
3
|
+
"version": "0.2.0-beta.334",
|
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.
|
44
|
+
"@axa-fr/design-system-look-and-feel-css": "0.2.0-beta.334",
|
45
45
|
"@material-symbols/svg-400": ">= 0.19.0",
|
46
46
|
"react": ">= 18"
|
47
47
|
},
|
@@ -84,7 +84,7 @@
|
|
84
84
|
"@typescript-eslint/parser": "^7.16.0",
|
85
85
|
"@vitejs/plugin-react": "^4.3.1",
|
86
86
|
"@vitest/coverage-v8": "^2.0.5",
|
87
|
-
"@vitest/ui": "^2.
|
87
|
+
"@vitest/ui": "^2.1.2",
|
88
88
|
"copyfiles": "^2.4.1",
|
89
89
|
"eslint": "^8.57.0",
|
90
90
|
"eslint-config-airbnb": "^19.0.4",
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { useId, useState } from "react";
|
3
|
-
export const AccordionItem = ({ title, children }) => {
|
4
|
-
const [isOpen, setIsOpen] = useState(false);
|
5
|
-
const id = useId();
|
6
|
-
const onClick = () => {
|
7
|
-
setIsOpen(!isOpen);
|
8
|
-
};
|
9
|
-
return (_jsxs("div", { className: "af-accordion-client__item", children: [_jsx("h3", { children: _jsx("button", { type: "button", "aria-expanded": isOpen, "aria-controls": `accordion-section-${id}`, id: `accordion-title-${id}`, onClick: onClick, children: title }) }), _jsx("div", { role: "region", "aria-labelledby": `accordion-title-${id}`, id: `accordion-section-${id}`, hidden: !isOpen, children: children })] }));
|
10
|
-
};
|