@axa-fr/canopee-react 2.0.1-alpha.56 → 2.0.1-alpha.58
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/distributeur/FormHelper/FormHelper.d.ts +17 -0
- package/dist/distributeur/FormHelper/FormHelper.js +10 -0
- package/dist/distributeur/FormHelper/ListFormHelper.d.ts +26 -0
- package/dist/distributeur/FormHelper/ListFormHelper.js +17 -0
- package/dist/distributeur/FormHelper/types.d.ts +3 -0
- package/dist/distributeur/FormHelper/types.js +1 -0
- package/dist/distributeur/ItemFormHelper/ItemFormHelper.d.ts +17 -3
- package/dist/distributeur/ItemFormHelper/ItemFormHelper.js +3 -3
- package/dist/distributeur.d.ts +3 -0
- package/dist/distributeur.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "@axa-fr/canopee-css/distributeur/FormHelper/FormHelper.css";
|
|
2
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
3
|
+
import type { FormHelperStateLabels } from "./types";
|
|
4
|
+
export type FormHelperProps = Omit<ComponentPropsWithoutRef<"aside">, "title"> & {
|
|
5
|
+
/** Title shown in the blue header, e.g. "Assistant de création". */
|
|
6
|
+
title: string;
|
|
7
|
+
/**
|
|
8
|
+
* Heading level of the title.
|
|
9
|
+
* @default "h2"
|
|
10
|
+
*/
|
|
11
|
+
heading?: "h2" | "h3" | "h4";
|
|
12
|
+
/** Texts of the legend, e.g. for another language. */
|
|
13
|
+
stateLabels?: FormHelperStateLabels;
|
|
14
|
+
/** Body of the helper, usually a `ListFormHelper`. */
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const FormHelper: ({ title, heading: Heading, stateLabels, children, className, "aria-label": ariaLabel, ...otherProps }: FormHelperProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/canopee-css/distributeur/FormHelper/FormHelper.css";
|
|
3
|
+
import { ItemFormHelper, } from "../ItemFormHelper/ItemFormHelper";
|
|
4
|
+
import { getClassName } from "../utilities/helpers/getClassName";
|
|
5
|
+
const legendVariants = [
|
|
6
|
+
"todo",
|
|
7
|
+
"inprogress",
|
|
8
|
+
"validated",
|
|
9
|
+
];
|
|
10
|
+
export const FormHelper = ({ title, heading: Heading = "h2", stateLabels, children, className, "aria-label": ariaLabel = "Progression du formulaire", ...otherProps }) => (_jsxs("aside", { className: getClassName({ baseClassName: "af-form-helper", className }), "aria-label": ariaLabel, ...otherProps, children: [_jsx(Heading, { className: "af-form-helper__title", children: title }), _jsx("ul", { className: "af-form-helper__legend", children: legendVariants.map((variant) => (_jsx("li", { children: _jsx(ItemFormHelper, { variant: variant, stateLabel: stateLabels?.[variant] }) }, variant))) }), _jsx("div", { className: "af-form-helper__body", children: children })] }));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "@axa-fr/canopee-css/distributeur/FormHelper/ListFormHelper.css";
|
|
2
|
+
import type { ComponentPropsWithoutRef, MouseEventHandler } from "react";
|
|
3
|
+
import { type ItemFormHelperVariant } from "../ItemFormHelper/ItemFormHelper";
|
|
4
|
+
import type { FormHelperStateLabels } from "./types";
|
|
5
|
+
export type ListFormHelperStep = {
|
|
6
|
+
/** Name of the form section, e.g. "Tarification". */
|
|
7
|
+
label: string;
|
|
8
|
+
/** State of the section. */
|
|
9
|
+
variant: ItemFormHelperVariant;
|
|
10
|
+
/** Link to the section, e.g. "#tarification". Makes the step clickable. */
|
|
11
|
+
href?: string;
|
|
12
|
+
/** Called when the step link is clicked (only with `href`). */
|
|
13
|
+
onClick?: MouseEventHandler<HTMLAnchorElement>;
|
|
14
|
+
};
|
|
15
|
+
export type ListFormHelperProps = Omit<ComponentPropsWithoutRef<"ol">, "children"> & {
|
|
16
|
+
/** Sections of the form, in order. */
|
|
17
|
+
steps: ListFormHelperStep[];
|
|
18
|
+
/**
|
|
19
|
+
* Accessible name of the navigation, used when a step has a link.
|
|
20
|
+
* @default "étapes du formulaire"
|
|
21
|
+
*/
|
|
22
|
+
navAriaLabel?: string;
|
|
23
|
+
/** Texts of the states read after each step name. */
|
|
24
|
+
stateLabels?: FormHelperStateLabels;
|
|
25
|
+
};
|
|
26
|
+
export declare const ListFormHelper: ({ steps, navAriaLabel, stateLabels, className, ...otherProps }: ListFormHelperProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@axa-fr/canopee-css/distributeur/FormHelper/ListFormHelper.css";
|
|
3
|
+
import { ItemFormHelper, } from "../ItemFormHelper/ItemFormHelper";
|
|
4
|
+
import { getClassName } from "../utilities/helpers/getClassName";
|
|
5
|
+
export const ListFormHelper = ({ steps, navAriaLabel = "étapes du formulaire", stateLabels, className, ...otherProps }) => {
|
|
6
|
+
const currentIndex = steps.findIndex(({ variant }) => variant === "inprogress");
|
|
7
|
+
const hasLinks = steps.some(({ href }) => Boolean(href));
|
|
8
|
+
const list = (_jsx("ol", { className: getClassName({
|
|
9
|
+
baseClassName: "af-list-form-helper",
|
|
10
|
+
className,
|
|
11
|
+
}), ...otherProps, children: steps.map(({ label, variant, href, onClick }, index) => {
|
|
12
|
+
const ariaCurrent = index === currentIndex ? "step" : undefined;
|
|
13
|
+
const item = (_jsx(ItemFormHelper, { variant: variant, label: label, stateLabel: stateLabels?.[variant] }));
|
|
14
|
+
return (_jsx("li", { className: "af-list-form-helper__step", "aria-current": href ? undefined : ariaCurrent, children: href ? (_jsx("a", { className: "af-list-form-helper__link", href: href, onClick: onClick, "aria-current": ariaCurrent, children: item })) : (item) }, href ?? label));
|
|
15
|
+
}) }));
|
|
16
|
+
return hasLinks ? _jsx("nav", { "aria-label": navAriaLabel, children: list }) : list;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import "@axa-fr/canopee-css/distributeur/ItemFormHelper/ItemFormHelper.css";
|
|
2
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
3
|
export type ItemFormHelperVariant = "todo" | "inprogress" | "validated";
|
|
3
|
-
export type ItemFormHelperProps = {
|
|
4
|
+
export type ItemFormHelperProps = Omit<ComponentPropsWithoutRef<"span">, "children"> & {
|
|
5
|
+
/**
|
|
6
|
+
* State of the step. Figma "Step state": Todo = `todo`,
|
|
7
|
+
* Active = `inprogress`, Done = `validated`.
|
|
8
|
+
*/
|
|
4
9
|
variant: ItemFormHelperVariant;
|
|
10
|
+
/**
|
|
11
|
+
* Name of the step, e.g. "Informations clients".
|
|
12
|
+
* Without it, the item shows its state (legend usage).
|
|
13
|
+
*/
|
|
5
14
|
label?: string;
|
|
6
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Text of the state. Visible when there is no `label`; otherwise visually
|
|
17
|
+
* hidden and read by screen readers after the label.
|
|
18
|
+
* @default "à compléter" | "en cours" | "validé"
|
|
19
|
+
*/
|
|
20
|
+
stateLabel?: string;
|
|
7
21
|
};
|
|
8
|
-
export declare const ItemFormHelper: ({ variant, label, className, }: ItemFormHelperProps) => import("react").JSX.Element;
|
|
22
|
+
export declare const ItemFormHelper: ({ variant, label, stateLabel, className, ...otherProps }: ItemFormHelperProps) => import("react").JSX.Element;
|
|
@@ -19,13 +19,13 @@ const variants = {
|
|
|
19
19
|
defaultLabel: "validé",
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
-
export const ItemFormHelper = ({ variant, label, className, }) => {
|
|
22
|
+
export const ItemFormHelper = ({ variant, label, stateLabel, className, ...otherProps }) => {
|
|
23
23
|
const { icon, defaultLabel } = variants[variant];
|
|
24
|
-
const
|
|
24
|
+
const state = stateLabel ?? defaultLabel;
|
|
25
25
|
const componentClassName = getClassName({
|
|
26
26
|
baseClassName: "af-item-form-helper",
|
|
27
27
|
modifiers: [variant],
|
|
28
28
|
className,
|
|
29
29
|
});
|
|
30
|
-
return (_jsxs("
|
|
30
|
+
return (_jsxs("span", { className: componentClassName, ...otherProps, children: [_jsx(Svg, { src: icon, width: 12, height: 12, "aria-hidden": "true" }), _jsx("span", { className: "af-item-form-helper__label", children: label ?? state }), label ? (_jsxs("span", { className: "af-item-form-helper__state", children: [", ", state] })) : null] }));
|
|
31
31
|
};
|
package/dist/distributeur.d.ts
CHANGED
|
@@ -58,3 +58,6 @@ export { CardButton, type CardButtonProps, } from "./distributeur/CardButton/Car
|
|
|
58
58
|
export type { ClickableComponentProps } from "./distributeur/ClickableGhost";
|
|
59
59
|
export { BaseCard, type BaseCardProps } from "./distributeur/Card/BaseCard";
|
|
60
60
|
export { ItemFormHelper, type ItemFormHelperProps, type ItemFormHelperVariant, } from "./distributeur/ItemFormHelper/ItemFormHelper";
|
|
61
|
+
export { FormHelper, type FormHelperProps, } from "./distributeur/FormHelper/FormHelper";
|
|
62
|
+
export { ListFormHelper, type ListFormHelperProps, type ListFormHelperStep, } from "./distributeur/FormHelper/ListFormHelper";
|
|
63
|
+
export type { FormHelperStateLabels } from "./distributeur/FormHelper/types";
|
package/dist/distributeur.js
CHANGED
|
@@ -53,3 +53,5 @@ export { Timeline, } from "./distributeur/Timeline/Timeline";
|
|
|
53
53
|
export { CardButton, } from "./distributeur/CardButton/CardButton";
|
|
54
54
|
export { BaseCard } from "./distributeur/Card/BaseCard";
|
|
55
55
|
export { ItemFormHelper, } from "./distributeur/ItemFormHelper/ItemFormHelper";
|
|
56
|
+
export { FormHelper, } from "./distributeur/FormHelper/FormHelper";
|
|
57
|
+
export { ListFormHelper, } from "./distributeur/FormHelper/ListFormHelper";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/canopee-react",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.58",
|
|
4
4
|
"description": "Package React - Design System Canopée",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/AxaFrance/design-system#readme",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@axa-fr/canopee-css": "2.0.1-alpha.
|
|
57
|
+
"@axa-fr/canopee-css": "2.0.1-alpha.58",
|
|
58
58
|
"@material-symbols/svg-400": ">= 0.19.0",
|
|
59
59
|
"@material-symbols/svg-700": ">= 0.19.0",
|
|
60
60
|
"react": ">= 19"
|