@axa-fr/design-system-look-and-feel-react 0.2.0-beta.306
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 +8 -0
- package/dist/Accordion/Accordion.js +7 -0
- package/dist/Accordion/Accordion.stories.d.ts +8 -0
- package/dist/Accordion/Accordion.stories.js +24 -0
- package/dist/Accordion/AccordionItem.d.ts +6 -0
- package/dist/Accordion/AccordionItem.js +10 -0
- package/dist/Alert/Alert.d.ts +12 -0
- package/dist/Alert/Alert.js +26 -0
- package/dist/Alert/Alert.stories.d.ts +5 -0
- package/dist/Alert/Alert.stories.js +26 -0
- package/dist/Button/Button.d.ts +17 -0
- package/dist/Button/Button.js +15 -0
- package/dist/Button/Button.stories.d.ts +22 -0
- package/dist/Button/Button.stories.js +99 -0
- package/dist/Card/Card.d.ts +6 -0
- package/dist/Card/Card.js +9 -0
- package/dist/Card/Card.stories.d.ts +6 -0
- package/dist/Card/Card.stories.js +40 -0
- package/dist/Card/__tests__/Card.test.d.ts +1 -0
- package/dist/Card/__tests__/Card.test.js +27 -0
- package/dist/Card/index.d.ts +2 -0
- package/dist/Card/index.js +2 -0
- package/dist/Form/Checkbox/Checkbox.d.ts +7 -0
- package/dist/Form/Checkbox/Checkbox.js +15 -0
- package/dist/Form/Checkbox/Checkbox.stories.d.ts +6 -0
- package/dist/Form/Checkbox/Checkbox.stories.js +38 -0
- package/dist/Form/Checkbox/CheckboxSelect.d.ts +15 -0
- package/dist/Form/Checkbox/CheckboxSelect.js +7 -0
- package/dist/Form/Checkbox/CheckboxSelect.stories.d.ts +6 -0
- package/dist/Form/Checkbox/CheckboxSelect.stories.js +55 -0
- package/dist/Form/Checkbox/index.d.ts +2 -0
- package/dist/Form/Checkbox/index.js +2 -0
- package/dist/Form/FileUpload/FIleUpload.stories.d.ts +6 -0
- package/dist/Form/FileUpload/FIleUpload.stories.js +54 -0
- package/dist/Form/FileUpload/FileUpload.d.ts +32 -0
- package/dist/Form/FileUpload/FileUpload.js +51 -0
- package/dist/Form/FileUpload/index.d.ts +1 -0
- package/dist/Form/FileUpload/index.js +1 -0
- package/dist/Form/InputError/InputError.d.ts +7 -0
- package/dist/Form/InputError/InputError.js +5 -0
- package/dist/Form/InputError/InputError.stories.d.ts +5 -0
- package/dist/Form/InputError/InputError.stories.js +12 -0
- package/dist/Form/InputError/index.d.ts +1 -0
- package/dist/Form/InputError/index.js +1 -0
- package/dist/Form/Radio/Radio.d.ts +7 -0
- package/dist/Form/Radio/Radio.js +14 -0
- package/dist/Form/Radio/Radio.stories.d.ts +6 -0
- package/dist/Form/Radio/Radio.stories.js +38 -0
- package/dist/Form/Radio/RadioSelect.d.ts +18 -0
- package/dist/Form/Radio/RadioSelect.js +16 -0
- package/dist/Form/Radio/RadioSelect.stories.d.ts +7 -0
- package/dist/Form/Radio/RadioSelect.stories.js +90 -0
- package/dist/Form/Radio/index.d.ts +2 -0
- package/dist/Form/Radio/index.js +2 -0
- package/dist/Form/Select/CustomOption.d.ts +4 -0
- package/dist/Form/Select/CustomOption.js +8 -0
- package/dist/Form/Select/DropdownIndicator.d.ts +4 -0
- package/dist/Form/Select/DropdownIndicator.js +11 -0
- package/dist/Form/Select/Select.d.ts +27 -0
- package/dist/Form/Select/Select.js +27 -0
- package/dist/Form/Select/Select.stories.d.ts +10 -0
- package/dist/Form/Select/Select.stories.js +31 -0
- package/dist/Form/Select/index.d.ts +1 -0
- package/dist/Form/Select/index.js +1 -0
- package/dist/Form/Text/Text.d.ts +12 -0
- package/dist/Form/Text/Text.js +12 -0
- package/dist/Form/Text/Text.stories.d.ts +8 -0
- package/dist/Form/Text/Text.stories.js +46 -0
- package/dist/Form/Text/index.d.ts +1 -0
- package/dist/Form/Text/index.js +1 -0
- package/dist/Form/core/Field.d.ts +16 -0
- package/dist/Form/core/Field.js +12 -0
- package/dist/Form/core/FieldError.d.ts +7 -0
- package/dist/Form/core/FieldError.js +8 -0
- package/dist/Form/core/FieldForm.d.ts +59 -0
- package/dist/Form/core/FieldForm.js +151 -0
- package/dist/Form/core/FieldInput.d.ts +9 -0
- package/dist/Form/core/FieldInput.js +9 -0
- package/dist/Form/core/FormClassManager.d.ts +7 -0
- package/dist/Form/core/FormClassManager.js +33 -0
- package/dist/Form/core/HelpMessage.d.ts +7 -0
- package/dist/Form/core/HelpMessage.js +2 -0
- package/dist/Form/core/InputList.d.ts +8 -0
- package/dist/Form/core/InputList.js +4 -0
- package/dist/Form/core/MessageTypes.d.ts +5 -0
- package/dist/Form/core/MessageTypes.js +6 -0
- package/dist/Form/core/getComponentClassName.d.ts +1 -0
- package/dist/Form/core/getComponentClassName.js +27 -0
- package/dist/Form/core/getFirstId.d.ts +2 -0
- package/dist/Form/core/getFirstId.js +1 -0
- package/dist/Form/core/getOptionClassName.d.ts +1 -0
- package/dist/Form/core/getOptionClassName.js +10 -0
- package/dist/Form/core/index.d.ts +31 -0
- package/dist/Form/core/index.js +13 -0
- package/dist/Form/core/useInputClassModifier.d.ts +4 -0
- package/dist/Form/core/useInputClassModifier.js +12 -0
- package/dist/Form/core/useOptionsWithId.d.ts +2 -0
- package/dist/Form/core/useOptionsWithId.js +13 -0
- package/dist/IconBg/IconBg.d.ts +9 -0
- package/dist/IconBg/IconBg.js +13 -0
- package/dist/IconBg/IconBg.stories.d.ts +5 -0
- package/dist/IconBg/IconBg.stories.js +23 -0
- package/dist/IconBg/__tests__/IconBg.test.d.ts +1 -0
- package/dist/IconBg/__tests__/IconBg.test.js +22 -0
- package/dist/IconBg/index.d.ts +2 -0
- package/dist/IconBg/index.js +2 -0
- package/dist/Layout/Footer/DynamicIcons.d.ts +4 -0
- package/dist/Layout/Footer/DynamicIcons.js +20 -0
- package/dist/Layout/Footer/Footer.d.ts +14 -0
- package/dist/Layout/Footer/Footer.js +16 -0
- package/dist/Layout/Footer/Footer.stories.d.ts +14 -0
- package/dist/Layout/Footer/Footer.stories.js +48 -0
- package/dist/Layout/Footer/MenuIcons.d.ts +9 -0
- package/dist/Layout/Footer/MenuIcons.js +8 -0
- package/dist/Layout/Footer/MenuLink.d.ts +11 -0
- package/dist/Layout/Footer/MenuLink.js +11 -0
- package/dist/Layout/Header/Header.d.ts +9 -0
- package/dist/Layout/Header/Header.js +11 -0
- package/dist/Layout/Header/Header.stories.d.ts +10 -0
- package/dist/Layout/Header/Header.stories.js +52 -0
- package/dist/Layout/Header/NavBar/NavBar.d.ts +8 -0
- package/dist/Layout/Header/NavBar/NavBar.js +13 -0
- package/dist/Layout/Header/NavBar/NavBar.stories.d.ts +8 -0
- package/dist/Layout/Header/NavBar/NavBar.stories.js +17 -0
- package/dist/Layout/Header/NavBar/index.d.ts +1 -0
- package/dist/Layout/Header/NavBar/index.js +1 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.d.ts +7 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.js +14 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.stories.d.ts +8 -0
- package/dist/Layout/Header/PreviousLink/PreviousLink.stories.js +16 -0
- package/dist/Layout/Header/PreviousLink/index.d.ts +1 -0
- package/dist/Layout/Header/PreviousLink/index.js +1 -0
- package/dist/Layout/Header/index.d.ts +1 -0
- package/dist/Layout/Header/index.js +1 -0
- package/dist/Link/Link.d.ts +7 -0
- package/dist/Link/Link.js +11 -0
- package/dist/Link/Link.stories.d.ts +5 -0
- package/dist/Link/Link.stories.js +14 -0
- package/dist/List/ClickList/ClickList.d.ts +11 -0
- package/dist/List/ClickList/ClickList.js +6 -0
- package/dist/List/ClickList/ClickList.stories.d.ts +6 -0
- package/dist/List/ClickList/ClickList.stories.js +60 -0
- package/dist/List/ClickList/__tests__/ClickList.client.test.d.ts +1 -0
- package/dist/List/ClickList/__tests__/ClickList.client.test.js +18 -0
- package/dist/List/ClickList/index.d.ts +1 -0
- package/dist/List/ClickList/index.js +1 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.d.ts +13 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.js +18 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.stories.d.ts +28 -0
- package/dist/List/ContentItemDuo/ContentItemDuo.stories.js +86 -0
- package/dist/List/ContentItemDuo/__tests__/ContentItemDuo.test.d.ts +1 -0
- package/dist/List/ContentItemDuo/__tests__/ContentItemDuo.test.js +40 -0
- package/dist/List/ContentItemDuo/index.d.ts +2 -0
- package/dist/List/ContentItemDuo/index.js +2 -0
- package/dist/List/ContentItemMono/ContentItemMono.d.ts +16 -0
- package/dist/List/ContentItemMono/ContentItemMono.js +16 -0
- package/dist/List/ContentItemMono/ContentItemMono.stories.d.ts +16 -0
- package/dist/List/ContentItemMono/ContentItemMono.stories.js +99 -0
- package/dist/List/ContentItemMono/__tests__/ContentItemMono.test.d.ts +1 -0
- package/dist/List/ContentItemMono/__tests__/ContentItemMono.test.js +45 -0
- package/dist/List/ContentItemMono/constants.d.ts +4 -0
- package/dist/List/ContentItemMono/constants.js +5 -0
- package/dist/List/ContentItemMono/index.d.ts +3 -0
- package/dist/List/ContentItemMono/index.js +3 -0
- package/dist/List/ContentTabList/ContentTabItem/ContentTabItem.d.ts +6 -0
- package/dist/List/ContentTabList/ContentTabItem/ContentTabItem.js +6 -0
- package/dist/List/ContentTabList/ContentTabItem/__tests__/ContentTabItem.test.d.ts +1 -0
- package/dist/List/ContentTabList/ContentTabItem/__tests__/ContentTabItem.test.js +100 -0
- package/dist/List/ContentTabList/ContentTabItem/index.d.ts +2 -0
- package/dist/List/ContentTabList/ContentTabItem/index.js +1 -0
- package/dist/List/ContentTabList/ContentTabList.d.ts +8 -0
- package/dist/List/ContentTabList/ContentTabList.js +10 -0
- package/dist/List/ContentTabList/ContentTabList.stories.d.ts +7 -0
- package/dist/List/ContentTabList/ContentTabList.stories.js +78 -0
- package/dist/List/ContentTabList/__tests__/ContentTabList.test.d.ts +1 -0
- package/dist/List/ContentTabList/__tests__/ContentTabList.test.js +57 -0
- package/dist/List/ContentTabList/index.d.ts +1 -0
- package/dist/List/ContentTabList/index.js +1 -0
- package/dist/List/List.d.ts +6 -0
- package/dist/List/List.js +9 -0
- package/dist/List/List.stories.d.ts +8 -0
- package/dist/List/List.stories.js +56 -0
- package/dist/List/__tests__/List.test.d.ts +1 -0
- package/dist/List/__tests__/List.test.js +30 -0
- package/dist/List/index.d.ts +1 -0
- package/dist/List/index.js +1 -0
- package/dist/Loader/Loader.d.ts +11 -0
- package/dist/Loader/Loader.js +10 -0
- package/dist/Loader/Loader.stories.d.ts +6 -0
- package/dist/Loader/Loader.stories.js +15 -0
- package/dist/Loader/index.d.ts +1 -0
- package/dist/Loader/index.js +1 -0
- package/dist/ModalClient/Modal.d.ts +23 -0
- package/dist/ModalClient/Modal.js +44 -0
- package/dist/ModalClient/Modal.stories.d.ts +20 -0
- package/dist/ModalClient/Modal.stories.js +37 -0
- package/dist/Pagination/Pagination.d.ts +9 -0
- package/dist/Pagination/Pagination.js +15 -0
- package/dist/Pagination/Pagination.stories.d.ts +11 -0
- package/dist/Pagination/Pagination.stories.js +19 -0
- package/dist/Pagination/PaginationDesktop.d.ts +9 -0
- package/dist/Pagination/PaginationDesktop.js +31 -0
- package/dist/Pagination/PaginationMobile.d.ts +9 -0
- package/dist/Pagination/PaginationMobile.js +10 -0
- package/dist/Stepper/Stepper.d.ts +12 -0
- package/dist/Stepper/Stepper.js +22 -0
- package/dist/Stepper/Stepper.stories.d.ts +16 -0
- package/dist/Stepper/Stepper.stories.js +23 -0
- package/dist/Svg/Svg.d.ts +7 -0
- package/dist/Svg/Svg.js +47 -0
- package/dist/Svg/Svg.stories.d.ts +7 -0
- package/dist/Svg/Svg.stories.js +40 -0
- package/dist/Svg/__tests__/Svg.test.d.ts +1 -0
- package/dist/Svg/__tests__/Svg.test.js +38 -0
- package/dist/Svg/index.d.ts +1 -0
- package/dist/Svg/index.js +1 -0
- package/dist/Svg/svgInjector.d.ts +12 -0
- package/dist/Svg/svgInjector.js +28 -0
- package/dist/Tabs/Tabs.d.ts +16 -0
- package/dist/Tabs/Tabs.js +48 -0
- package/dist/Tabs/Tabs.stories.d.ts +17 -0
- package/dist/Tabs/Tabs.stories.js +89 -0
- package/dist/Tag/Tag.d.ts +6 -0
- package/dist/Tag/Tag.js +7 -0
- package/dist/Tag/Tag.stories.d.ts +5 -0
- package/dist/Tag/Tag.stories.js +22 -0
- package/dist/Tag/__test__/Tag.test.d.ts +1 -0
- package/dist/Tag/__test__/Tag.test.js +18 -0
- package/dist/Tag/index.d.ts +2 -0
- package/dist/Tag/index.js +2 -0
- package/dist/Title/Title.d.ts +13 -0
- package/dist/Title/Title.js +11 -0
- package/dist/Title/Title.stories.d.ts +6 -0
- package/dist/Title/Title.stories.js +45 -0
- package/dist/Title/TitleWithSubtitles.d.ts +8 -0
- package/dist/Title/TitleWithSubtitles.js +2 -0
- package/dist/Title/__tests__/Title.test.d.ts +1 -0
- package/dist/Title/__tests__/Title.test.js +28 -0
- package/dist/Title/__tests__/TitleWithSubtitles.test.d.ts +1 -0
- package/dist/Title/__tests__/TitleWithSubtitles.test.js +14 -0
- package/dist/Title/constants.d.ts +4 -0
- package/dist/Title/constants.js +5 -0
- package/dist/Title/index.d.ts +3 -0
- package/dist/Title/index.js +3 -0
- package/dist/assets/svg/facebook.svg +1 -0
- package/dist/assets/svg/linkedin.svg +1 -0
- package/dist/assets/svg/twitterx.svg +1 -0
- package/dist/assets/svg/youtube.svg +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +27 -0
- package/dist/utilities/helpers/getComponentClassName.d.ts +1 -0
- package/dist/utilities/helpers/getComponentClassName.js +27 -0
- package/dist/utilities/hooks/useIsSmallScreen.d.ts +1 -0
- package/dist/utilities/hooks/useIsSmallScreen.js +14 -0
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +2 -0
- package/package.json +119 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import download from "@material-symbols/svg-400/rounded/download_2-fill.svg";
|
3
|
+
import visibility from "@material-symbols/svg-400/rounded/visibility-fill.svg";
|
4
|
+
import { render, screen } from "@testing-library/react";
|
5
|
+
import { ButtonVariants, Svg } from "../../..";
|
6
|
+
import { ContentTabList } from "../ContentTabList";
|
7
|
+
describe("ContentTabList", () => {
|
8
|
+
const items = [
|
9
|
+
{
|
10
|
+
id: "1",
|
11
|
+
title: "Title 1",
|
12
|
+
subtitle: "Subtitle 1",
|
13
|
+
tag: "Tag 1",
|
14
|
+
date: "Date 1",
|
15
|
+
buttons: [
|
16
|
+
{
|
17
|
+
id: "download_button",
|
18
|
+
children: "Télécharger",
|
19
|
+
variant: ButtonVariants.ghost,
|
20
|
+
iconLeft: _jsx(Svg, { src: download, fill: "#00008F" }),
|
21
|
+
onClick: vi.fn(),
|
22
|
+
},
|
23
|
+
{
|
24
|
+
id: "display_button",
|
25
|
+
children: "Afficher",
|
26
|
+
variant: ButtonVariants.ghost,
|
27
|
+
iconLeft: _jsx(Svg, { src: visibility, fill: "#00008F" }),
|
28
|
+
onClick: vi.fn(),
|
29
|
+
},
|
30
|
+
],
|
31
|
+
},
|
32
|
+
{
|
33
|
+
id: "2",
|
34
|
+
title: "Title 2",
|
35
|
+
subtitle: "Subtitle 2",
|
36
|
+
tag: "Tag 2",
|
37
|
+
date: "Date 2",
|
38
|
+
value: "Value 2",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
id: "3",
|
42
|
+
title: "Title 3",
|
43
|
+
value: "Value 3",
|
44
|
+
},
|
45
|
+
{
|
46
|
+
title: "Title 4",
|
47
|
+
date: "Date 4",
|
48
|
+
},
|
49
|
+
];
|
50
|
+
it("should render the list correctly", () => {
|
51
|
+
render(_jsx(ContentTabList, { items: items }));
|
52
|
+
expect(screen.getByText("Title 1")).toBeInTheDocument();
|
53
|
+
expect(screen.getByText("Title 2")).toBeInTheDocument();
|
54
|
+
expect(screen.getByText("Title 3")).toBeInTheDocument();
|
55
|
+
expect(screen.getByText("Title 4")).toBeInTheDocument();
|
56
|
+
});
|
57
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { ContentTabList } from "./ContentTabList";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { ContentTabList } from "./ContentTabList";
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { type ComponentProps } from "react";
|
2
|
+
import { Card } from "..";
|
3
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/List/List.scss";
|
4
|
+
type TList = ComponentProps<typeof Card>;
|
5
|
+
export declare const List: ({ children, classModifier, ...cardProps }: TList) => import("react/jsx-runtime").JSX.Element;
|
6
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import React, { Children, isValidElement, useMemo, } from "react";
|
3
|
+
import { Card } from "..";
|
4
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/List/List.scss";
|
5
|
+
const defaultClassName = "af-list";
|
6
|
+
export const List = ({ children, classModifier, ...cardProps }) => {
|
7
|
+
const validChildren = useMemo(() => (Children.map(children, (child) => isValidElement(child) && child) ?? []).filter(Boolean), [children]);
|
8
|
+
return (_jsx(Card, { classModifier: `list ${classModifier}`, ...cardProps, children: _jsx("ul", { className: defaultClassName, children: Children.map(validChildren, (child, index) => (_jsxs(React.Fragment, { children: [_jsx("li", { className: `${defaultClassName}__item`, children: child }), index < validChildren.length - 1 && (_jsx("hr", { className: `${defaultClassName}__separator` }))] }, child.key))) }) }));
|
9
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import type { ComponentProps } from "react";
|
3
|
+
import { List } from "./List";
|
4
|
+
declare const meta: Meta<typeof List>;
|
5
|
+
export default meta;
|
6
|
+
export declare const Default: StoryObj<Omit<ComponentProps<typeof List>, "classModifier"> & {
|
7
|
+
classModifier: string[];
|
8
|
+
}>;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import arrow from "@material-symbols/svg-400/outlined/arrow_right.svg";
|
3
|
+
import trash from "@material-symbols/svg-400/outlined/delete.svg";
|
4
|
+
import sync from "@material-symbols/svg-400/outlined/sync-fill.svg";
|
5
|
+
import { Svg } from "../Svg";
|
6
|
+
import { List } from "./List";
|
7
|
+
const meta = {
|
8
|
+
title: "Components/List",
|
9
|
+
component: List,
|
10
|
+
};
|
11
|
+
export default meta;
|
12
|
+
export const Default = {
|
13
|
+
name: "List",
|
14
|
+
render: ({ classModifier, ...args }) => (_jsx(List, { classModifier: classModifier.join(" "), ...args })),
|
15
|
+
args: {
|
16
|
+
children: [
|
17
|
+
_jsx("div", { children: _jsx("span", { children: "Pr\u00E9nom NOM" }) }, "list-item-1"),
|
18
|
+
_jsx("div", { children: _jsx("span", { children: "nom.pr\u00E9nom@mail.fr" }) }, "list-item-2"),
|
19
|
+
_jsxs("div", { style: {
|
20
|
+
display: "flex",
|
21
|
+
flexDirection: "row",
|
22
|
+
alignItems: "center",
|
23
|
+
gap: "0.5rem",
|
24
|
+
}, children: [_jsx(Svg, { src: sync }), _jsxs("div", { style: {
|
25
|
+
display: "flex",
|
26
|
+
flexDirection: "row",
|
27
|
+
alignItems: "center",
|
28
|
+
justifyContent: "space-between",
|
29
|
+
width: "100%",
|
30
|
+
}, children: [_jsx("span", { children: "Modifier le profil" }), _jsx(Svg, { src: arrow })] })] }, "list-item-3"),
|
31
|
+
_jsx("div", { style: {
|
32
|
+
display: "flex",
|
33
|
+
flexDirection: "row",
|
34
|
+
alignItems: "center",
|
35
|
+
gap: "4rem",
|
36
|
+
}, children: _jsxs("div", { style: {
|
37
|
+
display: "flex",
|
38
|
+
flexDirection: "row",
|
39
|
+
alignItems: "center",
|
40
|
+
gap: "0.5rem",
|
41
|
+
}, children: [_jsx(Svg, { src: trash }), _jsx("span", { children: "Supprimer le profil" })] }) }, "list-element-3"),
|
42
|
+
],
|
43
|
+
classModifier: [],
|
44
|
+
},
|
45
|
+
argTypes: {
|
46
|
+
classModifier: {
|
47
|
+
options: [
|
48
|
+
"large",
|
49
|
+
"first-separator-full-width",
|
50
|
+
"first-separator-full-width",
|
51
|
+
],
|
52
|
+
control: { type: "multi-select" },
|
53
|
+
defaultValue: [],
|
54
|
+
},
|
55
|
+
},
|
56
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { render, screen } from "@testing-library/react";
|
3
|
+
import { List } from "../List";
|
4
|
+
describe("List", () => {
|
5
|
+
it("should render children", () => {
|
6
|
+
const children = _jsx("div", { children: "Child 1" });
|
7
|
+
render(_jsx(List, { children: children }));
|
8
|
+
expect(screen.getByRole("list")).toHaveClass("af-list");
|
9
|
+
expect(screen.getByText("Child 1")).toBeInTheDocument();
|
10
|
+
expect(screen.queryByRole("separator")).toBeNull();
|
11
|
+
});
|
12
|
+
it("should render with empty children", () => {
|
13
|
+
const children = undefined;
|
14
|
+
render(_jsx(List, { children: children }));
|
15
|
+
expect(screen.getByRole("list")).toHaveClass("af-list");
|
16
|
+
expect(screen.queryByRole("separator")).toBeNull();
|
17
|
+
});
|
18
|
+
it("should render multiple children with separators", () => {
|
19
|
+
const children = [
|
20
|
+
_jsx("div", { children: "Child 1" }, "1"),
|
21
|
+
_jsx("div", { children: "Child 2" }, "2"),
|
22
|
+
_jsx("div", { children: "Child 3" }, "3"),
|
23
|
+
];
|
24
|
+
render(_jsx(List, { children: children }));
|
25
|
+
expect(screen.getByText("Child 1")).toBeInTheDocument();
|
26
|
+
expect(screen.getByText("Child 2")).toBeInTheDocument();
|
27
|
+
expect(screen.getByText("Child 3")).toBeInTheDocument();
|
28
|
+
expect(screen.getAllByRole("separator")).toHaveLength(2);
|
29
|
+
});
|
30
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { List } from "./List";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { List } from "./List";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Loader/Loader.scss";
|
2
|
+
import { ComponentPropsWithRef } from "react";
|
3
|
+
type Props = ComponentPropsWithRef<"input"> & {
|
4
|
+
size: number;
|
5
|
+
border: number;
|
6
|
+
};
|
7
|
+
declare const Loader: {
|
8
|
+
({ size, border }: Props): import("react/jsx-runtime").JSX.Element;
|
9
|
+
displayName: string;
|
10
|
+
};
|
11
|
+
export { Loader };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Loader/Loader.scss";
|
3
|
+
const Loader = ({ size = 60, border = 5 }) => (_jsx("div", { className: "af-loader__container", style: {
|
4
|
+
width: `${size}px`,
|
5
|
+
height: `${size}px`,
|
6
|
+
border: `${border}px solid #f3f3f3`,
|
7
|
+
borderTop: `${border}px solid #00008f`,
|
8
|
+
}, children: _jsx("div", { className: "af-loader__container-spin", "aria-hidden": "true" }) }));
|
9
|
+
Loader.displayName = "Loader";
|
10
|
+
export { Loader };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Loader } from "./Loader";
|
3
|
+
const meta = {
|
4
|
+
component: Loader,
|
5
|
+
title: "Components/Loader",
|
6
|
+
};
|
7
|
+
export default meta;
|
8
|
+
export const LoaderStory = {
|
9
|
+
name: "Loader",
|
10
|
+
render: ({ ...args }) => _jsx(Loader, { ...args }),
|
11
|
+
args: {
|
12
|
+
size: 60,
|
13
|
+
border: 5,
|
14
|
+
},
|
15
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Loader } from "./Loader";
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Loader } from "./Loader";
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { PropsWithChildren, ReactNode } from "react";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
|
3
|
+
export type ButtonAction = {
|
4
|
+
text: string;
|
5
|
+
disabled?: boolean;
|
6
|
+
callback: () => void;
|
7
|
+
};
|
8
|
+
type ModalProps = {
|
9
|
+
isOpen: boolean;
|
10
|
+
hasCloseBtn?: boolean;
|
11
|
+
onClose?: () => void;
|
12
|
+
title: string;
|
13
|
+
subtitle?: string;
|
14
|
+
iconTitle?: ReactNode;
|
15
|
+
fullWidthButtons?: boolean;
|
16
|
+
actions?: {
|
17
|
+
primary?: ButtonAction;
|
18
|
+
secondary?: ButtonAction;
|
19
|
+
tertiary?: ButtonAction;
|
20
|
+
};
|
21
|
+
};
|
22
|
+
export declare const Modal: ({ isOpen, hasCloseBtn, onClose, children, title, subtitle, iconTitle, actions, fullWidthButtons, }: PropsWithChildren<ModalProps>) => import("react/jsx-runtime").JSX.Element;
|
23
|
+
export {};
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useEffect, useId, useRef, useState, } from "react";
|
3
|
+
import close from "@material-symbols/svg-400/outlined/close.svg";
|
4
|
+
import { ButtonClient as Button, Variants as ButtonVariants, } from "../Button/Button";
|
5
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Modal/Modal.scss";
|
6
|
+
import { Svg } from "../Svg";
|
7
|
+
export const Modal = ({ isOpen, hasCloseBtn = true, onClose, children, title, subtitle, iconTitle, actions, fullWidthButtons, }) => {
|
8
|
+
const [isModalOpen, setIsModalOpen] = useState(isOpen);
|
9
|
+
const modalRef = useRef(null);
|
10
|
+
const idTitle = useId();
|
11
|
+
const idContent = useId();
|
12
|
+
useEffect(() => {
|
13
|
+
setIsModalOpen(isOpen);
|
14
|
+
}, [isOpen]);
|
15
|
+
useEffect(() => {
|
16
|
+
const modalElement = modalRef.current;
|
17
|
+
if (!modalRef.current) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
if (isModalOpen) {
|
21
|
+
document.body.style.overflow = "hidden";
|
22
|
+
modalElement.showModal();
|
23
|
+
}
|
24
|
+
else {
|
25
|
+
document.body.style.overflow = "inherit";
|
26
|
+
modalElement.close();
|
27
|
+
}
|
28
|
+
}, [isModalOpen]);
|
29
|
+
useEffect(() => {
|
30
|
+
return () => {
|
31
|
+
document.body.style.overflow = "inherit";
|
32
|
+
};
|
33
|
+
}, []);
|
34
|
+
const handleCloseModal = () => {
|
35
|
+
onClose?.();
|
36
|
+
setIsModalOpen(false);
|
37
|
+
};
|
38
|
+
const handleKeyDown = (event) => {
|
39
|
+
if (event.key === "Escape") {
|
40
|
+
handleCloseModal();
|
41
|
+
}
|
42
|
+
};
|
43
|
+
return (_jsxs("dialog", { ref: modalRef, onKeyDown: handleKeyDown, onClick: (e) => e.target === modalRef.current && handleCloseModal(), className: "af-modal", "aria-labelledby": idTitle, "aria-describedby": idContent, children: [_jsxs("div", { id: idTitle, className: "af-modal__top", children: [iconTitle, _jsxs("h2", { className: "af-modal__top-title", children: [_jsxs("div", { children: [_jsx("div", { className: "af-modal__top-title-text", children: title }), subtitle && (_jsx("span", { className: "af-modal__top-title-subtitle", children: subtitle }))] }), hasCloseBtn && (_jsx(Button, { className: "af-modal__top-title-close-btn", onClick: handleCloseModal, type: "button", "aria-label": "close", children: _jsx(Svg, { src: close, width: 32, height: 32 }) }))] })] }), _jsxs("div", { id: idContent, className: "af-modal__content", children: [children, actions && (_jsxs("div", { className: `af-modal__actions${fullWidthButtons ? " af-modal__actions--fullWidth" : ""} `, children: [actions?.primary && (_jsx(Button, { variant: ButtonVariants.primary, onClick: actions?.primary.callback, disabled: actions?.primary.disabled, children: actions?.primary.text })), actions?.secondary && (_jsx(Button, { variant: ButtonVariants.secondary, onClick: actions?.secondary.callback, disabled: actions?.secondary.disabled, children: actions?.secondary.text })), actions?.tertiary && (_jsx(Button, { variant: ButtonVariants.tertiary, onClick: actions?.tertiary.callback, disabled: actions?.tertiary.disabled, children: actions?.tertiary.text }))] }))] })] }));
|
44
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import { ReactNode } from "react";
|
3
|
+
import { ButtonAction, Modal } from "./Modal";
|
4
|
+
declare const meta: Meta<typeof Modal>;
|
5
|
+
export default meta;
|
6
|
+
type StoryProps = Omit<React.ComponentProps<typeof Modal>, "isOpen" | "hasCloseBtn" | "onClose" | "title" | "iconTitle" | "fullWidthButtons" | "actions"> & {
|
7
|
+
isOpen: boolean;
|
8
|
+
hasCloseBtn?: boolean;
|
9
|
+
onClose?: () => void;
|
10
|
+
title: string;
|
11
|
+
iconTitle?: ReactNode;
|
12
|
+
fullWidthButtons?: boolean;
|
13
|
+
actions?: {
|
14
|
+
primary?: ButtonAction;
|
15
|
+
secondary?: ButtonAction;
|
16
|
+
tertiary?: ButtonAction;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
type Story = StoryObj<StoryProps>;
|
20
|
+
export declare const Playground: Story;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useState } from "react";
|
3
|
+
import bluetoothAudio from "@material-symbols/svg-400/outlined/bluetooth_searching.svg";
|
4
|
+
import { Modal } from "./Modal";
|
5
|
+
import { Svg } from "../Svg";
|
6
|
+
const meta = {
|
7
|
+
title: "Components/Modal",
|
8
|
+
component: Modal,
|
9
|
+
parameters: {
|
10
|
+
layout: "centered",
|
11
|
+
},
|
12
|
+
};
|
13
|
+
export default meta;
|
14
|
+
const Container = (props) => {
|
15
|
+
const [isOpen, setIsOpen] = useState(false);
|
16
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => setIsOpen(true), children: "open modal" }), _jsx(Modal, { ...props, isOpen: isOpen, onClose: () => setIsOpen(false), actions: {
|
17
|
+
primary: { text: "Save", callback: () => setIsOpen(false) },
|
18
|
+
secondary: { text: "Cancel", callback: () => setIsOpen(false) },
|
19
|
+
tertiary: {
|
20
|
+
text: "Reset",
|
21
|
+
callback: () => setIsOpen(false),
|
22
|
+
disabled: true,
|
23
|
+
},
|
24
|
+
} })] }));
|
25
|
+
};
|
26
|
+
export const Playground = {
|
27
|
+
name: "Modal",
|
28
|
+
render: (args) => _jsx(Container, { ...args }),
|
29
|
+
args: {
|
30
|
+
hasCloseBtn: true,
|
31
|
+
title: "Modal title",
|
32
|
+
children: "Vestibulum nunc neque, sodales non luctus in, dictum vitae nisl. Curabitur vitae massa non nisl lacinia tempus. Pellentesque id nulla tortor.",
|
33
|
+
iconTitle: _jsx(Svg, { src: bluetoothAudio }),
|
34
|
+
subtitle: "Info complémentaire",
|
35
|
+
fullWidthButtons: false,
|
36
|
+
},
|
37
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Pagination/Pagination.scss";
|
2
|
+
import { ComponentPropsWithoutRef } from "react";
|
3
|
+
type PaginationProps = {
|
4
|
+
numberPage: number;
|
5
|
+
onChangePage: (page: number) => void;
|
6
|
+
defaultPage?: number;
|
7
|
+
} & ComponentPropsWithoutRef<"div">;
|
8
|
+
export declare const Pagination: ({ numberPage, onChangePage, defaultPage, }: PaginationProps) => import("react/jsx-runtime").JSX.Element;
|
9
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Pagination/Pagination.scss";
|
3
|
+
import { useEffect, useState } from "react";
|
4
|
+
import { useIsSmallScreen } from "../utilities";
|
5
|
+
import { PaginationMobile } from "./PaginationMobile";
|
6
|
+
import { PaginationDesktop } from "./PaginationDesktop";
|
7
|
+
const BREAKPOINT_SMALL = 1024;
|
8
|
+
export const Pagination = ({ numberPage, onChangePage, defaultPage, }) => {
|
9
|
+
const isMobile = useIsSmallScreen(BREAKPOINT_SMALL);
|
10
|
+
const [currentPage, setCurrentPage] = useState(defaultPage || 1);
|
11
|
+
useEffect(() => {
|
12
|
+
onChangePage(currentPage);
|
13
|
+
}, [currentPage, onChangePage]);
|
14
|
+
return (_jsx("div", { className: "af-container-pagination", children: isMobile ? (_jsx(PaginationMobile, { numberPage: numberPage, currentPage: currentPage, setCurrentPage: setCurrentPage })) : (_jsx(PaginationDesktop, { numberPage: numberPage, currentPage: currentPage, setCurrentPage: setCurrentPage })) }));
|
15
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import { Pagination } from "./Pagination";
|
3
|
+
declare const meta: Meta<typeof Pagination>;
|
4
|
+
export default meta;
|
5
|
+
type StoryProps = Omit<React.ComponentProps<typeof Pagination>, "numberPage"> & {
|
6
|
+
numberPage: number;
|
7
|
+
onChangePage: (page: number) => void;
|
8
|
+
defaultPage?: number;
|
9
|
+
};
|
10
|
+
type Story = StoryObj<StoryProps>;
|
11
|
+
export declare const Playground: Story;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Pagination } from "./Pagination";
|
3
|
+
const meta = {
|
4
|
+
component: Pagination,
|
5
|
+
title: "Components/Pagination",
|
6
|
+
parameters: {
|
7
|
+
layout: "centered",
|
8
|
+
},
|
9
|
+
};
|
10
|
+
export default meta;
|
11
|
+
export const Playground = {
|
12
|
+
name: "Pagination",
|
13
|
+
render: ({ numberPage, onChangePage, defaultPage }) => (_jsx(Pagination, { numberPage: numberPage, defaultPage: defaultPage, onChangePage: onChangePage })),
|
14
|
+
args: {
|
15
|
+
numberPage: 20,
|
16
|
+
defaultPage: 2,
|
17
|
+
onChangePage: () => { },
|
18
|
+
},
|
19
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Pagination/PaginationDesktop.scss";
|
2
|
+
import { ComponentPropsWithoutRef } from "react";
|
3
|
+
type PropsPaginationDesktop = {
|
4
|
+
numberPage: number;
|
5
|
+
currentPage: number;
|
6
|
+
setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
|
7
|
+
} & ComponentPropsWithoutRef<"div">;
|
8
|
+
export declare const PaginationDesktop: ({ numberPage, currentPage, setCurrentPage, }: PropsPaginationDesktop) => import("react/jsx-runtime").JSX.Element;
|
9
|
+
export {};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Pagination/PaginationDesktop.scss";
|
3
|
+
const SEVEN_PAGE = 7;
|
4
|
+
const LAST_FOUR_PAGE = 4;
|
5
|
+
const FIVE_PAGE = 5;
|
6
|
+
export const PaginationDesktop = ({ numberPage, currentPage, setCurrentPage, }) => {
|
7
|
+
const pages = Array.from({ length: numberPage }, (_, index) => index + 1);
|
8
|
+
let filteredNumbers = [...pages];
|
9
|
+
let classNamePagination = "";
|
10
|
+
if (numberPage > SEVEN_PAGE) {
|
11
|
+
if (currentPage < FIVE_PAGE) {
|
12
|
+
classNamePagination = "first";
|
13
|
+
filteredNumbers = [...pages.slice(0, FIVE_PAGE), pages[pages.length - 1]];
|
14
|
+
}
|
15
|
+
else if (currentPage > numberPage - LAST_FOUR_PAGE) {
|
16
|
+
classNamePagination = "last";
|
17
|
+
filteredNumbers = [pages[0], ...pages.slice(-FIVE_PAGE)];
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
classNamePagination = "between";
|
21
|
+
filteredNumbers = [
|
22
|
+
pages[0],
|
23
|
+
currentPage - 1,
|
24
|
+
currentPage,
|
25
|
+
currentPage + 1,
|
26
|
+
pages[pages.length - 1],
|
27
|
+
];
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return (_jsx("div", { className: "af-pagination-desktop", children: _jsx("ul", { className: classNamePagination, children: filteredNumbers.map((page) => (_jsx("li", { "aria-label": `page-${page}`, "aria-current": currentPage === page ? "page" : undefined, children: _jsx("button", { type: "button", onClick: () => setCurrentPage(page), children: page }) }, `page-${page}`))) }) }));
|
31
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Pagination/PaginationMobile.scss";
|
2
|
+
import { ComponentPropsWithoutRef } from "react";
|
3
|
+
type PropsPaginationMobile = {
|
4
|
+
numberPage: number;
|
5
|
+
currentPage: number;
|
6
|
+
setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
|
7
|
+
} & ComponentPropsWithoutRef<"div">;
|
8
|
+
export declare const PaginationMobile: ({ numberPage, currentPage, setCurrentPage, }: PropsPaginationMobile) => import("react/jsx-runtime").JSX.Element;
|
9
|
+
export {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Pagination/PaginationMobile.scss";
|
3
|
+
import arrowBackIos from "@material-symbols/svg-400/outlined/arrow_back_ios.svg";
|
4
|
+
import arrowForwardIos from "@material-symbols/svg-400/outlined/arrow_forward_ios.svg";
|
5
|
+
import { Svg } from "../Svg";
|
6
|
+
export const PaginationMobile = ({ numberPage, currentPage, setCurrentPage, }) => {
|
7
|
+
const isFirstPage = currentPage === 1;
|
8
|
+
const isLastPage = currentPage === numberPage;
|
9
|
+
return (_jsxs("div", { className: "af-pagination-mobile", children: [_jsx("button", { type: "button", onClick: () => setCurrentPage(currentPage - 1), disabled: isFirstPage, "aria-label": "Page pr\u00E9c\u00E9dente", children: _jsx(Svg, { src: arrowBackIos, className: "arrow" }) }), _jsxs("span", { children: [currentPage, " sur ", numberPage] }), _jsx("button", { type: "button", onClick: () => setCurrentPage(currentPage + 1), disabled: isLastPage, "aria-label": "Page suivant", children: _jsx(Svg, { src: arrowForwardIos, className: "arrow" }) })] }));
|
10
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { HTMLAttributes } from "react";
|
2
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Stepper/Stepper.scss";
|
3
|
+
export type StepperProps = {
|
4
|
+
currentStepProgress?: number;
|
5
|
+
currentStep: number;
|
6
|
+
currentSubtitle?: string;
|
7
|
+
currentTitle?: string;
|
8
|
+
nbSteps: 2 | 3 | 4 | 5 | 6;
|
9
|
+
isTitleVisible?: boolean;
|
10
|
+
isSubtitleVisible?: boolean;
|
11
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, "role">;
|
12
|
+
export declare const Stepper: ({ currentStepProgress, currentTitle, nbSteps, currentStep, currentSubtitle, isTitleVisible, isSubtitleVisible, className, ...props }: StepperProps) => import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useCallback, useId } from "react";
|
3
|
+
import classNames from "classnames";
|
4
|
+
import "@axa-fr/design-system-look-and-feel-css/dist/Stepper/Stepper.scss";
|
5
|
+
const INITIAL_STEPPER_PROGRESS = 10;
|
6
|
+
const MAX_STEPPER_PROGRESS = 100;
|
7
|
+
export const Stepper = ({ currentStepProgress = INITIAL_STEPPER_PROGRESS, currentTitle, nbSteps, currentStep, currentSubtitle, isTitleVisible = true, isSubtitleVisible = true, className, ...props }) => {
|
8
|
+
const stepperId = useId();
|
9
|
+
const getCurrentProgress = useCallback((index) => {
|
10
|
+
if (index < currentStep) {
|
11
|
+
return MAX_STEPPER_PROGRESS;
|
12
|
+
}
|
13
|
+
if (index === currentStep) {
|
14
|
+
if (currentStepProgress === 0) {
|
15
|
+
return INITIAL_STEPPER_PROGRESS;
|
16
|
+
}
|
17
|
+
return currentStepProgress;
|
18
|
+
}
|
19
|
+
return 0;
|
20
|
+
}, [currentStep, currentStepProgress]);
|
21
|
+
return (_jsxs("div", { className: "af-stepper-client", ...props, children: [isTitleVisible && currentTitle && (_jsx("h2", { className: "af-stepper-client__title", "aria-describedby": stepperId, children: currentTitle })), isSubtitleVisible && currentSubtitle && (_jsx("p", { className: "af-stepper-client__subtitle", children: currentSubtitle })), _jsx("div", { id: stepperId, role: "group", "aria-label": currentTitle, className: classNames("af-stepper-client__content", className), children: [...Array(nbSteps).keys()].map((index) => (_jsx("div", { className: "af-stepper-client__progressbar", "aria-current": index === currentStep, "aria-hidden": index !== currentStep, "aria-label": `${getCurrentProgress(index)}%`, children: _jsx("div", { className: "af-stepper-client__progress", style: { width: `${getCurrentProgress(index)}%` } }) }, `${stepperId}-${index}`))) })] }));
|
22
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
2
|
+
import { ComponentProps } from "react";
|
3
|
+
import { Stepper } from "./Stepper";
|
4
|
+
declare const meta: Meta<typeof Stepper>;
|
5
|
+
export default meta;
|
6
|
+
type StoryProps = Omit<ComponentProps<typeof Stepper>, "currentStep" | "currentStepProgress" | "isTitleVisible" | "isSubtitleVisible" | "currentTitle" | "nbSteps"> & {
|
7
|
+
currentStep: number;
|
8
|
+
currentSubtitle: string;
|
9
|
+
currentStepProgress: number;
|
10
|
+
isTitleVisible: boolean;
|
11
|
+
isSubtitleVisible: boolean;
|
12
|
+
currentTitle: string;
|
13
|
+
nbSteps: 2 | 3 | 4 | 5 | 6;
|
14
|
+
};
|
15
|
+
type Story = StoryObj<StoryProps>;
|
16
|
+
export declare const Playground: Story;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Stepper } from "./Stepper";
|
3
|
+
const meta = {
|
4
|
+
component: Stepper,
|
5
|
+
title: "Components/Stepper",
|
6
|
+
parameters: {
|
7
|
+
layout: "centered",
|
8
|
+
},
|
9
|
+
};
|
10
|
+
export default meta;
|
11
|
+
export const Playground = {
|
12
|
+
name: "Stepper",
|
13
|
+
render: (props) => (_jsx("div", { style: { minWidth: "70vw" }, children: _jsx(Stepper, { ...props }) })),
|
14
|
+
args: {
|
15
|
+
nbSteps: 3,
|
16
|
+
currentTitle: "Step title",
|
17
|
+
currentStep: 2,
|
18
|
+
currentSubtitle: "Step subtitle",
|
19
|
+
currentStepProgress: 50,
|
20
|
+
isTitleVisible: true,
|
21
|
+
isSubtitleVisible: true,
|
22
|
+
},
|
23
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type SVGAttributes } from "react";
|
2
|
+
type SvgProps = SVGAttributes<SVGSVGElement> & {
|
3
|
+
src: string;
|
4
|
+
alt?: string;
|
5
|
+
};
|
6
|
+
export declare const Svg: ({ src, alt, width, height, ...props }: SvgProps) => import("react/jsx-runtime").JSX.Element | null;
|
7
|
+
export {};
|
package/dist/Svg/Svg.js
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useLayoutEffect, useRef, useState, } from "react";
|
3
|
+
import { svgInjector } from "./svgInjector";
|
4
|
+
const cloneAttributes = (from, to) => {
|
5
|
+
const attributes = from.getAttributeNames();
|
6
|
+
attributes.forEach((attribute) => {
|
7
|
+
to.setAttribute(attribute, from.getAttribute(attribute));
|
8
|
+
});
|
9
|
+
};
|
10
|
+
export const Svg = ({ src, alt, width = 24, height = 24, ...props }) => {
|
11
|
+
const rootRef = useRef(null);
|
12
|
+
const [hasError, setHasError] = useState(false);
|
13
|
+
useLayoutEffect(() => {
|
14
|
+
if (hasError) {
|
15
|
+
setHasError(false);
|
16
|
+
}
|
17
|
+
}, [src]);
|
18
|
+
useLayoutEffect(() => {
|
19
|
+
if (hasError) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
const root = rootRef.current;
|
23
|
+
if (root) {
|
24
|
+
const parent = document.createElement("div");
|
25
|
+
const svg = document.createElement("svg");
|
26
|
+
parent.appendChild(svg);
|
27
|
+
cloneAttributes(root, svg);
|
28
|
+
svg.setAttribute("width", width.toString());
|
29
|
+
svg.setAttribute("height", height.toString());
|
30
|
+
svgInjector(svg, {
|
31
|
+
afterEach: (error, svgInject) => {
|
32
|
+
if (error) {
|
33
|
+
setHasError(true);
|
34
|
+
}
|
35
|
+
if (svgInject) {
|
36
|
+
root.innerHTML = svgInject.innerHTML;
|
37
|
+
cloneAttributes(svgInject, root);
|
38
|
+
}
|
39
|
+
},
|
40
|
+
});
|
41
|
+
}
|
42
|
+
}, [src, width, height, hasError]);
|
43
|
+
if (hasError) {
|
44
|
+
return alt ? (_jsx("span", { ...props, children: alt })) : null;
|
45
|
+
}
|
46
|
+
return _jsx("svg", { ref: rootRef, "data-src": src, ...props });
|
47
|
+
};
|