@axa-fr/design-system-slash-react 2.0.0-RC.3 → 2.0.0-RC.4

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.
@@ -1,12 +1,14 @@
1
1
  import "@axa-fr/design-system-slash-css/dist/Accordion/Accordion.scss";
2
2
  import React from "react";
3
3
  import { CollapseProps } from "./CollapseCard";
4
- import { TDefaultProps } from "./types";
4
+ import { AccordionVariant, TDefaultProps } from "./types";
5
5
  export type EnhancedProps = Partial<TDefaultProps> & {
6
6
  onlyOne?: boolean;
7
7
  className?: string;
8
+ /** @deprecated Use `variant` instead. */
8
9
  classModifier?: string;
10
+ variant?: AccordionVariant;
9
11
  children: React.ReactElement<CollapseProps>[] | React.ReactElement<CollapseProps>;
10
12
  };
11
- declare const Accordion: ({ className, classModifier, children, onlyOne, }: EnhancedProps) => import("react/jsx-runtime").JSX.Element;
13
+ declare const Accordion: ({ className, classModifier, variant, children, onlyOne, }: EnhancedProps) => import("react/jsx-runtime").JSX.Element;
12
14
  export { Accordion };
@@ -2,13 +2,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createElement as _createElement } from "react";
3
3
  import "@axa-fr/design-system-slash-css/dist/Accordion/Accordion.scss";
4
4
  import { useId } from "react";
5
- import { getComponentClassName } from "../utilities";
5
+ import { getComponentClassNameWithUserClassname } from "../utilities/helpers/getComponentClassName";
6
6
  import { CollapseCard } from "./CollapseCard";
7
7
  const defaultClassName = "af-accordion";
8
- const Accordion = ({ className, classModifier, children, onlyOne = false, }) => {
9
- const componentClassName = getComponentClassName(className, classModifier, defaultClassName);
8
+ const Accordion = ({ className, classModifier, variant = "default", children, onlyOne = false, }) => {
9
+ const componentClassName = getComponentClassNameWithUserClassname({
10
+ componentClassName: defaultClassName,
11
+ userClassName: className,
12
+ classModifier: classModifier || (variant !== "default" && variant) || "",
13
+ });
10
14
  const id = useId();
11
15
  const childrenArray = Array.isArray(children) ? children : [children];
12
- return (_jsx("div", { className: componentClassName, children: childrenArray.map((child) => (_createElement(CollapseCard, { ...child.props, name: onlyOne ? id : undefined, key: child.props.id }, child.props.children))) }));
16
+ return (_jsx("div", { className: componentClassName, children: childrenArray.map((child) => (_createElement(CollapseCard, { ...child.props, name: onlyOne ? id : undefined, key: child.props.id, variant: variant }, child.props.children))) }));
13
17
  };
14
18
  export { Accordion };
@@ -1,4 +1,5 @@
1
1
  import type { DetailsHTMLAttributes, ReactNode } from "react";
2
+ import type { AccordionActions, AccordionVariant } from "./types";
2
3
  export type CollapseProps = {
3
4
  id: string;
4
5
  title: ReactNode;
@@ -8,5 +9,7 @@ export type CollapseProps = {
8
9
  onToggle?: DetailsHTMLAttributes<HTMLDetailsElement>["onToggle"];
9
10
  className?: string;
10
11
  classModifier?: string;
12
+ actions?: AccordionActions;
13
+ variant?: AccordionVariant;
11
14
  };
12
- export declare const CollapseCard: ({ children, name, title, id, open, onToggle, className, classModifier, }: CollapseProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const CollapseCard: ({ children, name, title, id, open, onToggle, className, classModifier, actions, variant, }: CollapseProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Body } from "./Body";
3
3
  import { Header } from "./Header";
4
4
  import { getComponentClassName } from "../utilities";
5
- export const CollapseCard = ({ children, name, title, id, open, onToggle, className, classModifier = "", }) => {
5
+ export const CollapseCard = ({ children, name, title, id, open, onToggle, className, classModifier = "", actions, variant, }) => {
6
6
  const headerId = id;
7
7
  let newClassModifier = open ? "open" : "";
8
8
  newClassModifier += ` ${classModifier}`;
9
9
  const componentClassName = getComponentClassName(className, newClassModifier.trim(), "af-accordion__details");
10
- return (_jsxs("details", { open: open, name: name, className: componentClassName, onToggle: onToggle, children: [_jsx(Header, { id: headerId, children: title }), _jsx(Body, { children: children })] }));
10
+ return (_jsxs("details", { open: open, name: name, className: componentClassName, onToggle: onToggle, children: [_jsx(Header, { id: headerId, actions: actions, variant: variant, children: title }), _jsx(Body, { children: children })] }));
11
11
  };
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import type { AccordionActions, AccordionVariant } from "./types";
2
3
  export type HeaderToggleElement = {
3
4
  isOpen: boolean;
4
5
  index: number;
@@ -9,6 +10,8 @@ export type HeaderProps = {
9
10
  className?: string;
10
11
  classModifier?: string;
11
12
  id?: string;
13
+ actions?: AccordionActions;
14
+ variant?: AccordionVariant;
12
15
  };
13
- declare const Header: ({ children, className, classModifier, id }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
16
+ declare const Header: ({ children, className, classModifier, id, actions, variant, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
14
17
  export { Header };
@@ -1,8 +1,20 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import arrow from "@material-symbols/svg-400/rounded/keyboard_arrow_down.svg";
3
+ import { Title } from "../Title/Title";
4
+ import { Button } from "../Button/Button";
5
+ import { Svg } from "../Svg/Svg";
2
6
  import { getComponentClassName } from "../utilities";
3
7
  const defaultClassName = "af-accordion__item-header";
4
- const Header = ({ children, className, classModifier, id }) => {
8
+ const Header = ({ children, className, classModifier, id, actions, variant, }) => {
5
9
  const componentClassName = getComponentClassName(className, classModifier, defaultClassName);
6
- return (_jsxs("summary", { className: componentClassName, id: id, children: [_jsx("h3", { className: "af-accordion__item-title", children: children }), _jsx("span", { className: "glyphicon glyphicon-menu-down" })] }));
10
+ return (_jsx("summary", { className: componentClassName, id: id, children: variant === "light" ? (_jsxs(Title, { heading: "h3", children: [_jsx(Svg, { src: arrow, className: "af-accordion__item-header-icon" }), children, actions
11
+ ? actions
12
+ .filter((action) => Boolean(action))
13
+ .map(({ key, label, leftIcon, rightIcon, onClick }) => (_jsx(Button, { onClick: onClick, leftIcon: leftIcon ? _jsx(Svg, { src: leftIcon }) : undefined, rightIcon: rightIcon ? _jsx(Svg, { src: rightIcon }) : undefined, variant: "ghost", children: label }, key)))
14
+ : null] })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "af-accordion__header-left", children: _jsx("h3", { className: "af-accordion__item-title", children: children }) }), _jsxs("div", { className: "af-accordion__header-right", children: [actions
15
+ ? actions
16
+ .filter((action) => Boolean(action))
17
+ .map(({ key, label, leftIcon, rightIcon, onClick }) => (_jsx(Button, { onClick: onClick, leftIcon: leftIcon ? _jsx(Svg, { src: leftIcon }) : undefined, rightIcon: rightIcon ? _jsx(Svg, { src: rightIcon }) : undefined, variant: variant === "white" ? "ghost" : "ghost-reverse", children: label }, key)))
18
+ : null, _jsx(Svg, { src: arrow, className: "af-accordion__item-header-icon" })] })] })) }));
7
19
  };
8
20
  export { Header };
@@ -1,2 +1,3 @@
1
1
  export { Accordion } from "./Accordion";
2
2
  export { CollapseCard, type CollapseProps } from "./CollapseCard";
3
+ export type * from "./types";
@@ -8,6 +8,7 @@ type CardProps = ComponentProps<"button"> & {
8
8
  * import villaIcon from "@material-symbols/svg-400/outlined/villa.svg"; */
9
9
  iconSrc?: string;
10
10
  error?: boolean;
11
+ active?: boolean;
11
12
  };
12
- export declare const Card: ({ children, className, iconSrc, orientation, error, ...otherProps }: CardProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const Card: ({ children, className, iconSrc, orientation, error, active, ...otherProps }: CardProps) => import("react/jsx-runtime").JSX.Element;
13
14
  export {};
package/dist/Card/Card.js CHANGED
@@ -3,4 +3,4 @@ import classNames from "classnames";
3
3
  import { Svg } from "../Svg";
4
4
  import "@axa-fr/design-system-slash-css/dist/Card/Card.css";
5
5
  const DEFAULT_CLASS_NAME = "af-card";
6
- export const Card = ({ children, className, iconSrc, orientation = "vertical", error = false, ...otherProps }) => (_jsxs("button", { type: "button", className: classNames(DEFAULT_CLASS_NAME, error && `${DEFAULT_CLASS_NAME}--error`, orientation === "horizontal" && `${DEFAULT_CLASS_NAME}--${orientation}`, className), ...otherProps, children: [iconSrc ? _jsx(Svg, { src: iconSrc }) : null, children] }));
6
+ export const Card = ({ children, className, iconSrc, orientation = "vertical", error = false, active = false, ...otherProps }) => (_jsxs("button", { type: "button", className: classNames(DEFAULT_CLASS_NAME, active && `${DEFAULT_CLASS_NAME}--active`, error && `${DEFAULT_CLASS_NAME}--error`, orientation === "horizontal" && `${DEFAULT_CLASS_NAME}--${orientation}`, className), ...otherProps, children: [iconSrc ? _jsx(Svg, { src: iconSrc }) : null, children] }));
@@ -3,7 +3,7 @@ export declare enum RadioModes {
3
3
  classic = "classic",
4
4
  default = "default",
5
5
  inline = "inline",
6
- card = "card"
6
+ cardRadio = "cardRadio"
7
7
  }
8
8
  declare const Radio: import("react").ForwardRefExoticComponent<(({
9
9
  options: Option[];
@@ -12,7 +12,7 @@ declare const Radio: import("react").ForwardRefExoticComponent<(({
12
12
  orientation?: "horizontal" | "vertical";
13
13
  error?: boolean;
14
14
  }, "ref"> & {
15
- mode: "card";
15
+ mode: "cardRadio";
16
16
  }) | Omit<{
17
17
  options: Option[];
18
18
  } & Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "type" | "checked"> & {
@@ -1,6 +1,7 @@
1
1
  import { createElement as _createElement } from "react";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { forwardRef, } from "react";
4
+ import classNames from "classnames";
4
5
  import { RadioCardGroup } from "./RadioCardGroup";
5
6
  import { RadioItem } from "./RadioItem";
6
7
  export var RadioModes;
@@ -8,7 +9,7 @@ export var RadioModes;
8
9
  RadioModes["classic"] = "classic";
9
10
  RadioModes["default"] = "default";
10
11
  RadioModes["inline"] = "inline";
11
- RadioModes["card"] = "card";
12
+ RadioModes["cardRadio"] = "cardRadio";
12
13
  })(RadioModes || (RadioModes = {}));
13
14
  const getClassNameMode = (mode) => {
14
15
  switch (mode) {
@@ -16,7 +17,7 @@ const getClassNameMode = (mode) => {
16
17
  return "af-form__radio";
17
18
  case RadioModes.inline:
18
19
  return "af-form__radio-inline";
19
- case RadioModes.card:
20
+ case RadioModes.cardRadio:
20
21
  return "af-form__radio-card";
21
22
  default:
22
23
  return "af-form__radio-custom";
@@ -25,10 +26,12 @@ const getClassNameMode = (mode) => {
25
26
  const Radio = forwardRef(({ options, value = "", children, disabled, ...otherProps }, inputRef) => {
26
27
  const { mode, ...onlyNecessaryProps } = otherProps;
27
28
  const classNameMode = getClassNameMode(mode ?? "default");
28
- if (mode === "card") {
29
+ if (mode === "cardRadio") {
29
30
  return (_jsx(RadioCardGroup, { ...onlyNecessaryProps, options: options, disabled: disabled, value: value, children: children }));
30
31
  }
31
- return (_jsx("div", { className: "af-form__radio-group", children: options.map((option) => (_createElement(RadioItem, { ...onlyNecessaryProps, key: option.value, isChecked: option.value === value, disabled: option.disabled || disabled, className: classNameMode, ref: inputRef, ...option }, children))) }));
32
+ return (_jsx("div", { className: classNames("af-form__radio-group", [
33
+ { "af-form__radio-group-classic": mode === RadioModes.classic },
34
+ ]), children: options.map((option) => (_createElement(RadioItem, { ...onlyNecessaryProps, key: option.value, isChecked: option.value === value, disabled: option.disabled || disabled, className: classNameMode, ref: inputRef, ...option }, children))) }));
32
35
  });
33
36
  Radio.displayName = "EnhancedInputRadio";
34
37
  export { Radio };
@@ -5,7 +5,7 @@ import { Radio, RadioModes } from "./Radio";
5
5
  const RadioInput = forwardRef(({ label, mode = "default", options, children, ...props }, inputRef) => {
6
6
  const labelPosition = mode === RadioModes.classic ? "top" : "center";
7
7
  const newOptions = useOptionsWithId(options);
8
- return (_jsx(Field, { label: label, labelPosition: labelPosition, roleContainer: mode !== "card" ? "radiogroup" : undefined, ...props, renderInput: ({ classModifier, ariaInvalid, errorId, ...radioProps }) => (_jsxs(_Fragment, { children: [_jsx(Radio, { options: newOptions, mode: mode, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...radioProps }), children] })) }));
8
+ return (_jsx(Field, { label: label, labelPosition: labelPosition, roleContainer: mode !== "cardRadio" ? "radiogroup" : undefined, ...props, renderInput: ({ classModifier, ariaInvalid, errorId, ...radioProps }) => (_jsxs(_Fragment, { children: [_jsx(Radio, { options: newOptions, mode: mode, classModifier: classModifier, ref: inputRef, "aria-describedby": errorId, "aria-invalid": ariaInvalid, ...radioProps }), children] })) }));
9
9
  });
10
10
  RadioInput.displayName = "EnhancedInputRadio";
11
11
  export { RadioInput };
@@ -2,47 +2,28 @@ import { ReactNode } from "react";
2
2
  import type { VerticalStepMode } from "./types";
3
3
  import "@axa-fr/design-system-slash-css/dist/Steps/VerticalStep.css";
4
4
  type Props = {
5
- /**
6
- * title - The title of the step.
7
- */
5
+ /** The title of the step. */
8
6
  title: string;
9
- /**
10
- * id - The id of the step, used for accessibility.
11
- * It should be unique within the document.
12
- */
7
+ /** The id of the step, used for accessibility. It should be unique within the document. */
13
8
  id: string;
14
- /**
15
- * stepMode - The mode of the step, can be "edited", "validated", or "locked".
16
- */
9
+ /** The mode of the step, can be "edited", "validated", or "locked". */
17
10
  stepMode: VerticalStepMode;
18
- /**
19
- * onEdit - The function to call when the edit button is clicked.
20
- */
11
+ /** The function to call when the edit button is clicked. */
21
12
  onEdit: React.MouseEventHandler<HTMLButtonElement>;
22
- /**
23
- * form - The content of the form to display when the step is in "edited" mode.
24
- */
13
+ /** The content of the form to display when the step is in "edited" mode. */
25
14
  form: ReactNode;
26
- /**
27
- * restitution - The content to display when the step is in "validated" mode.
28
- */
15
+ /** The content to display when the step is in "validated" mode. */
29
16
  restitution: ReactNode;
30
- /**
31
- * editButtonLabel - The label of the edit button.
32
- */
17
+ /** The label of the edit button. */
33
18
  editButtonLabel?: string;
34
- /**
35
- * editButtonAriaLabel - The aria-label of the edit button.
36
- */
19
+ /** The aria-label of the edit button. */
37
20
  editButtonAriaLabel?: string;
38
- /**
39
- * showRestitution - Whether to show the restitution content when the step is validated.
40
- */
21
+ /** Whether to show the restitution content when the step is validated. */
41
22
  showRestitution?: boolean;
42
- /**
43
- * contentRight - Additional content to display on the right side of the title.
44
- */
23
+ /** Additional content to display on the right side of the title. */
45
24
  contentRight?: string;
25
+ /** The aria-label for the additional content on the right side of the title. */
26
+ contentRightAriaLabel?: string;
46
27
  };
47
- export declare const VerticalStep: ({ title, id, stepMode, editButtonLabel, editButtonAriaLabel, onEdit, form, restitution, showRestitution, contentRight, }: Props) => import("react/jsx-runtime").JSX.Element;
28
+ export declare const VerticalStep: ({ title, id, stepMode, editButtonLabel, editButtonAriaLabel, contentRightAriaLabel, onEdit, form, restitution, showRestitution, contentRight, }: Props) => import("react/jsx-runtime").JSX.Element;
48
29
  export {};
@@ -8,15 +8,15 @@ import { Title } from "../Title/Title";
8
8
  import "@axa-fr/design-system-slash-css/dist/Steps/VerticalStep.css";
9
9
  import { Button } from "../Button/Button";
10
10
  const defaultClassName = "af-vertical-step";
11
- export const VerticalStep = ({ title, id, stepMode, editButtonLabel = "Modifier", editButtonAriaLabel = `Modifier l'étape ${title}`, onEdit, form, restitution, showRestitution = true, contentRight, }) => {
11
+ export const VerticalStep = ({ title, id, stepMode, editButtonLabel = "Modifier", editButtonAriaLabel = `Modifier l'étape ${title}`, contentRightAriaLabel = `Contenu supplémentaire étape verticale ${title}`, onEdit, form, restitution, showRestitution = true, contentRight, }) => {
12
12
  const isStepInEdition = stepMode === "edited";
13
13
  const isStepValidated = stepMode === "validated";
14
14
  const isStepLocked = stepMode === "locked";
15
- return (_jsxs("div", { className: classNames(defaultClassName, {
15
+ return (_jsxs("section", { className: classNames(defaultClassName, {
16
16
  [`${defaultClassName}--edition`]: isStepInEdition,
17
- }), children: [_jsxs("div", { className: classNames("af-vertical-step-icon", {
17
+ }), "aria-label": `Étape verticale ${title}`, children: [_jsxs("div", { className: classNames("af-vertical-step-icon", {
18
18
  [`${defaultClassName}-icon--validated`]: isStepValidated,
19
19
  [`${defaultClassName}-icon--locked`]: isStepLocked,
20
20
  [`${defaultClassName}-icon--edited`]: isStepInEdition,
21
- }), children: [isStepValidated ? _jsx(Svg, { role: "presentation", src: check }) : null, isStepLocked ? _jsx(Svg, { role: "presentation", src: lock }) : null, isStepInEdition ? _jsx(Svg, { role: "presentation", src: edit }) : null] }), _jsx(Title, { id: id, contentLeft: isStepValidated ? (_jsx(Button, { "aria-label": editButtonAriaLabel, onClick: onEdit, variant: "ghost", leftIcon: _jsx(Svg, { role: "presentation", src: edit }), children: editButtonLabel })) : undefined, contentRight: contentRight, children: title }), isStepInEdition ? _jsx("section", { children: form }) : null, isStepValidated && showRestitution ? (_jsx("section", { children: restitution })) : null, isStepInEdition ? (_jsx("div", { className: classNames(`${defaultClassName}-icon ${defaultClassName}-icon--lastIcon`), children: _jsx(Svg, { role: "presentation", src: check }) })) : null] }));
21
+ }), children: [isStepValidated ? _jsx(Svg, { role: "presentation", src: check }) : null, isStepLocked ? _jsx(Svg, { role: "presentation", src: lock }) : null, isStepInEdition ? _jsx(Svg, { role: "presentation", src: edit }) : null] }), _jsx(Title, { id: id, contentLeft: isStepValidated ? (_jsx(Button, { "aria-label": editButtonAriaLabel, onClick: onEdit, variant: "ghost", leftIcon: _jsx(Svg, { role: "presentation", src: edit }), children: editButtonLabel })) : undefined, contentRight: _jsx("section", { "aria-label": contentRightAriaLabel, children: contentRight }), children: title }), isStepInEdition ? _jsx("section", { children: form }) : null, isStepValidated && showRestitution ? (_jsx("section", { children: restitution })) : null, isStepInEdition ? (_jsx("div", { className: classNames(`${defaultClassName}-icon ${defaultClassName}-icon--lastIcon`), children: _jsx(Svg, { role: "presentation", src: check }) })) : null] }));
22
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-slash-react",
3
- "version": "2.0.0-RC.3",
3
+ "version": "2.0.0-RC.4",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "homepage": "https://github.com/AxaFrance/design-system#readme",
49
49
  "peerDependencies": {
50
- "@axa-fr/design-system-slash-css": "2.0.0-RC.3",
50
+ "@axa-fr/design-system-slash-css": "2.0.0-RC.4",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "@material-symbols/svg-700": ">= 0.19.0",
53
53
  "react": ">= 18"