@axa-fr/design-system-slash-react 2.0.0-alpha.23 → 2.0.0-alpha.34

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.
@@ -5,8 +5,10 @@ import { 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?: string;
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, children, onlyOne = false, }) => {
9
+ const componentClassName = getComponentClassNameWithUserClassname({
10
+ componentClassName: defaultClassName,
11
+ userClassName: className,
12
+ classModifier: classModifier || 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 } 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?: string;
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 } 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?: string;
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-slash-react",
3
- "version": "2.0.0-alpha.23",
3
+ "version": "2.0.0-alpha.34",
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-alpha.23",
50
+ "@axa-fr/design-system-slash-css": "2.0.0-alpha.34",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },