@axa-fr/design-system-slash-react 0.2.0-beta.281 → 0.2.0-beta.282
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/IconBg/IconBg.client.js +1 -1
- package/dist/Title/{Title.agent.d.ts → Agent/Title.d.ts} +1 -1
- package/dist/Title/{Title.agent.js → Agent/Title.js} +2 -2
- package/dist/Title/{Title.agent.stories.d.ts → Agent/Title.stories.d.ts} +1 -1
- package/dist/Title/{Title.agent.stories.js → Agent/Title.stories.js} +2 -2
- package/dist/Title/{__tests__ → Agent/__tests__}/Title.test.js +1 -1
- package/dist/Title/Client/Title.d.ts +13 -0
- package/dist/Title/Client/Title.js +11 -0
- package/dist/Title/Client/Title.stories.d.ts +6 -0
- package/dist/Title/Client/Title.stories.js +45 -0
- package/dist/Title/Client/TitleWithSubtitles.d.ts +8 -0
- package/dist/Title/Client/TitleWithSubtitles.js +2 -0
- package/dist/Title/Client/__tests__/Title.test.d.ts +1 -0
- package/dist/Title/Client/__tests__/Title.test.js +28 -0
- package/dist/Title/Client/__tests__/TitleWithSubtitles.test.d.ts +1 -0
- package/dist/Title/Client/__tests__/TitleWithSubtitles.test.js +14 -0
- package/dist/Title/Client/constants.d.ts +4 -0
- package/dist/Title/Client/constants.js +5 -0
- package/dist/Title/Client/index.d.ts +3 -0
- package/dist/Title/Client/index.js +3 -0
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/package.json +2 -2
- /package/dist/Title/{__tests__ → Agent/__tests__}/Title.test.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { getComponentClassName } from "../
|
|
3
|
+
import { getComponentClassName } from "../Form/core";
|
|
4
4
|
export const IconBg = ({ children, className, classModifier, isDisabled = false, }) => {
|
|
5
5
|
const componentClassName = useMemo(() => {
|
|
6
6
|
let newClassModifier = classModifier;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "@axa-fr/design-system-slash-css/dist/Title/Title.
|
|
1
|
+
import "@axa-fr/design-system-slash-css/dist/Title/Agent/Title.scss";
|
|
2
2
|
import { ComponentPropsWithRef, PropsWithChildren } from "react";
|
|
3
3
|
type Headings = "h2" | "h3" | "h4";
|
|
4
4
|
type TitleProps = ComponentPropsWithRef<"h2"> & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import "@axa-fr/design-system-slash-css/dist/Title/Title.
|
|
2
|
+
import "@axa-fr/design-system-slash-css/dist/Title/Agent/Title.scss";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
-
import { getComponentClassName } from "
|
|
4
|
+
import { getComponentClassName } from "../../Form/core";
|
|
5
5
|
export const Title = forwardRef(({ className, classModifier, children, heading: Heading = "h2", ...otherProps }, ref) => {
|
|
6
6
|
const componentClassName = getComponentClassName(className, classModifier, "af-title");
|
|
7
7
|
return (_jsx(Heading, { ref: ref, className: componentClassName, ...otherProps, children: children }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Title } from "./Title
|
|
2
|
+
import { Title } from "./Title";
|
|
3
3
|
declare const meta: Meta<typeof Title>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type StoryProps = Omit<React.ComponentProps<typeof Title>, "classModifier" | "children"> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ButtonAgent as Button } from "../../Button/Button.agent";
|
|
3
|
+
import { Title } from "./Title";
|
|
4
4
|
const meta = {
|
|
5
5
|
title: "Agent/Components/Title",
|
|
6
6
|
component: Title,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from "@testing-library/react";
|
|
3
3
|
import { axe } from "jest-axe";
|
|
4
|
-
import { Title } from "../Title
|
|
4
|
+
import { Title } from "../Title";
|
|
5
5
|
describe("Title", () => {
|
|
6
6
|
it("should render children", () => {
|
|
7
7
|
render(_jsx(Title, { children: "A title" }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { TitleSize } from "./constants";
|
|
3
|
+
type TitleProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
firstSubtitle: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
classModifier?: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
secondSubtitle?: string;
|
|
10
|
+
size?: TitleSize;
|
|
11
|
+
};
|
|
12
|
+
export declare const Title: ({ children: title, className, classModifier, firstSubtitle, icon, secondSubtitle, size, }: TitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo, } from "react";
|
|
3
|
+
import { IconBg } from "../../client";
|
|
4
|
+
import { getComponentClassName } from "../../Form/core";
|
|
5
|
+
import { TitleSize } from "./constants";
|
|
6
|
+
import { TitleWithSubtitles } from "./TitleWithSubtitles";
|
|
7
|
+
export const Title = ({ children: title, className, classModifier, firstSubtitle, icon, secondSubtitle, size = TitleSize.XL, }) => {
|
|
8
|
+
const componentClassName = useMemo(() => getComponentClassName(className, classModifier ? `${classModifier} ${size}` : size, "af-title"), [classModifier, className, size]);
|
|
9
|
+
const TitleWithSubtitlesPart = useCallback(({ ...args }) => (_jsx(TitleWithSubtitles, { title: title, firstSubtitle: firstSubtitle, ...args })), [title, firstSubtitle]);
|
|
10
|
+
return (_jsx("div", { className: componentClassName, children: icon && size === TitleSize.XL ? (_jsxs(_Fragment, { children: [_jsx(IconBg, { className: "af-title__icon af-icon-bg", children: icon }), _jsx("div", { className: "af-title__text-container", children: _jsx(TitleWithSubtitlesPart, { secondSubtitle: secondSubtitle }) })] })) : (_jsx(TitleWithSubtitlesPart, {})) }));
|
|
11
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Title } from ".";
|
|
3
|
+
declare const meta: Meta<typeof Title>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const TitleWithIcon: StoryObj<typeof Title>;
|
|
6
|
+
export declare const TitleWithoutIcon: StoryObj<typeof Title>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import article from "@material-symbols/svg-400/outlined/article-fill.svg";
|
|
3
|
+
import { Title } from ".";
|
|
4
|
+
import { Svg } from "../../Svg";
|
|
5
|
+
import { TitleSize } from "./constants";
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Client/Components/Title",
|
|
8
|
+
component: Title,
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const TitleWithIcon = {
|
|
12
|
+
name: "Title With Icon",
|
|
13
|
+
render: (args) => _jsx(Title, { ...args }),
|
|
14
|
+
args: {
|
|
15
|
+
children: "Titre de la page",
|
|
16
|
+
firstSubtitle: "Sous-titre 1",
|
|
17
|
+
secondSubtitle: "Sous-titre 2",
|
|
18
|
+
icon: _jsx(Svg, { src: article }),
|
|
19
|
+
size: TitleSize.XL,
|
|
20
|
+
},
|
|
21
|
+
argTypes: {
|
|
22
|
+
size: {
|
|
23
|
+
options: Object.values(TitleSize),
|
|
24
|
+
control: { type: "select" },
|
|
25
|
+
defaultValue: TitleSize.XL,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const TitleWithoutIcon = {
|
|
30
|
+
name: "Title Without Icon",
|
|
31
|
+
render: (args) => _jsx(Title, { ...args }),
|
|
32
|
+
args: {
|
|
33
|
+
children: "Titre de la page",
|
|
34
|
+
firstSubtitle: "Sous-titre 1",
|
|
35
|
+
secondSubtitle: "Sous-titre 2",
|
|
36
|
+
size: TitleSize.XL,
|
|
37
|
+
},
|
|
38
|
+
argTypes: {
|
|
39
|
+
size: {
|
|
40
|
+
options: Object.values(TitleSize),
|
|
41
|
+
control: { type: "select" },
|
|
42
|
+
defaultValue: TitleSize.XL,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type TitleTextProps = {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
firstSubtitle?: string;
|
|
5
|
+
secondSubtitle?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const TitleWithSubtitles: ({ title, firstSubtitle, secondSubtitle, }: TitleTextProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const TitleWithSubtitles = ({ title, firstSubtitle, secondSubtitle, }) => (_jsxs(_Fragment, { children: [_jsx("h1", { className: "af-title__title", children: title }), firstSubtitle && (_jsx("span", { className: "af-title__subtitle", children: firstSubtitle })), secondSubtitle && (_jsx("span", { className: "af-title__subtitle", children: secondSubtitle }))] }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Title } from "..";
|
|
4
|
+
import { TitleSize } from "../constants";
|
|
5
|
+
describe("Title", () => {
|
|
6
|
+
it("should render correctly", () => {
|
|
7
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", secondSubtitle: "secondSubtitle", icon: "icon", children: "Title" }));
|
|
8
|
+
expect(screen.getByRole("heading", { name: "Title", level: 1 })).toBeInTheDocument();
|
|
9
|
+
expect(screen.getByText("firstSubtitle")).toBeInTheDocument();
|
|
10
|
+
expect(screen.getByText("secondSubtitle")).toBeInTheDocument();
|
|
11
|
+
expect(screen.getByText("icon")).toBeInTheDocument();
|
|
12
|
+
});
|
|
13
|
+
it("should have custom class", () => {
|
|
14
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", className: "custom-class", children: "Title" }));
|
|
15
|
+
expect(screen.getByText("Title").parentElement).toHaveClass("custom-class");
|
|
16
|
+
});
|
|
17
|
+
it("should have custom class with modifier", () => {
|
|
18
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", className: "custom-class", classModifier: "modifier", children: "Title" }));
|
|
19
|
+
expect(screen.getByText("Title").parentElement).toHaveClass("custom-class custom-class--modifier");
|
|
20
|
+
});
|
|
21
|
+
it('should not display icon and second subtitle when size is "L"', () => {
|
|
22
|
+
render(_jsx(Title, { firstSubtitle: "firstSubtitle", secondSubtitle: "secondSubtitle", icon: "icon", size: TitleSize.L, children: "Title" }));
|
|
23
|
+
expect(screen.getByRole("heading", { name: "Title", level: 1 })).toBeInTheDocument();
|
|
24
|
+
expect(screen.getByText("firstSubtitle")).toBeInTheDocument();
|
|
25
|
+
expect(screen.queryByText("secondSubtitle")).not.toBeInTheDocument();
|
|
26
|
+
expect(screen.queryByText("icon")).not.toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { TitleWithSubtitles } from "../TitleWithSubtitles";
|
|
4
|
+
describe("TitleWithSubtitles", () => {
|
|
5
|
+
it("should render title and the two subtitles", () => {
|
|
6
|
+
const title = "Sample Title";
|
|
7
|
+
const firstSubtitle = "First Subtitle";
|
|
8
|
+
const secondSubtitle = "Second Subtitle";
|
|
9
|
+
render(_jsx(TitleWithSubtitles, { title: title, firstSubtitle: firstSubtitle, secondSubtitle: secondSubtitle }));
|
|
10
|
+
screen.getByRole("heading", { name: title, level: 1 });
|
|
11
|
+
expect(screen.getByText(firstSubtitle)).toBeInTheDocument();
|
|
12
|
+
expect(screen.getByText(secondSubtitle)).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
});
|
package/dist/agent.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { Badge } from "./Badge/Badge";
|
|
|
6
6
|
export { ButtonAgent as Button } from "./Button/Button.agent";
|
|
7
7
|
export { Checkbox, CheckboxInput, CheckboxItem, CheckboxModes, } from "./Form/Checkbox/Agent";
|
|
8
8
|
export { Choice, ChoiceInput } from "./Form/Choice";
|
|
9
|
+
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
9
10
|
export { Date, DateInput } from "./Form/Date";
|
|
10
11
|
export { MultiSelect, MultiSelectInput } from "./Form/MultiSelect";
|
|
11
12
|
export { Number, NumberInput } from "./Form/Number";
|
|
@@ -14,12 +15,11 @@ export { Select, SelectBase, SelectInput } from "./Form/Select/Agent";
|
|
|
14
15
|
export { Slider, SliderInput } from "./Form/Slider";
|
|
15
16
|
export { Text, TextInput } from "./Form/Text/Agent";
|
|
16
17
|
export { Textarea, TextareaInput } from "./Form/Textarea";
|
|
17
|
-
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
18
18
|
export { Footer } from "./Layout/Footer/Agent";
|
|
19
19
|
export { HeaderAgent as Header, Infos, Name, NavBar, NavBarBase, NavBarItem, NavBarItemBase, NavBarItemLink, TitleHeader, ToggleButton, User, } from "./Layout/Header/Agent";
|
|
20
20
|
export { BooleanModal, Modal, ModalBody, ModalFooter, ModalHeader, ModalHeaderBase, } from "./ModalAgent";
|
|
21
21
|
export { Step, StepBase, Steps } from "./Steps";
|
|
22
22
|
export { Svg } from "./Svg";
|
|
23
23
|
export { Tabs } from "./Tabs/Agent/Tabs.agent";
|
|
24
|
-
export { Title } from "./Title/Title
|
|
24
|
+
export { Title } from "./Title/Agent/Title";
|
|
25
25
|
export * from "./Table";
|
package/dist/agent.js
CHANGED
|
@@ -6,6 +6,7 @@ export { Badge } from "./Badge/Badge";
|
|
|
6
6
|
export { ButtonAgent as Button } from "./Button/Button.agent";
|
|
7
7
|
export { Checkbox, CheckboxInput, CheckboxItem, CheckboxModes, } from "./Form/Checkbox/Agent";
|
|
8
8
|
export { Choice, ChoiceInput } from "./Form/Choice";
|
|
9
|
+
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
9
10
|
export { Date, DateInput } from "./Form/Date";
|
|
10
11
|
export { MultiSelect, MultiSelectInput } from "./Form/MultiSelect";
|
|
11
12
|
export { Number, NumberInput } from "./Form/Number";
|
|
@@ -14,12 +15,11 @@ export { Select, SelectBase, SelectInput } from "./Form/Select/Agent";
|
|
|
14
15
|
export { Slider, SliderInput } from "./Form/Slider";
|
|
15
16
|
export { Text, TextInput } from "./Form/Text/Agent";
|
|
16
17
|
export { Textarea, TextareaInput } from "./Form/Textarea";
|
|
17
|
-
export { Field, FieldError, FieldForm, FieldInput, FormClassManager, HelpMessage, InputList, MessageTypes, getComponentClassName, } from "./Form/core";
|
|
18
18
|
export { Footer } from "./Layout/Footer/Agent";
|
|
19
19
|
export { HeaderAgent as Header, Infos, Name, NavBar, NavBarBase, NavBarItem, NavBarItemBase, NavBarItemLink, TitleHeader, ToggleButton, User, } from "./Layout/Header/Agent";
|
|
20
20
|
export { BooleanModal, Modal, ModalBody, ModalFooter, ModalHeader, ModalHeaderBase, } from "./ModalAgent";
|
|
21
21
|
export { Step, StepBase, Steps } from "./Steps";
|
|
22
22
|
export { Svg } from "./Svg";
|
|
23
23
|
export { Tabs } from "./Tabs/Agent/Tabs.agent";
|
|
24
|
-
export { Title } from "./Title/Title
|
|
24
|
+
export { Title } from "./Title/Agent/Title";
|
|
25
25
|
export * from "./Table";
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/design-system-slash-react",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.282",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./agent": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@axa-fr/design-system-slash-css": "0.2.0-beta.
|
|
48
|
+
"@axa-fr/design-system-slash-css": "0.2.0-beta.282",
|
|
49
49
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
50
50
|
"react": ">= 18"
|
|
51
51
|
},
|
|
File without changes
|