@axa-fr/design-system-slash-react 1.2.1-alpha.112 → 1.2.1-alpha.118

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,7 +1,11 @@
1
- import "@axa-fr/design-system-slash-css/dist/Button/Button.scss";
2
- import { ComponentPropsWithoutRef, PropsWithChildren } from "react";
3
- type ButtonProps = {
4
- classModifier?: string;
5
- } & ComponentPropsWithoutRef<"button">;
6
- export declare const Button: ({ children, classModifier, className, ...args }: PropsWithChildren<ButtonProps>) => import("react/jsx-runtime").JSX.Element;
7
- export {};
1
+ import { ReactNode } from "react";
2
+ import "@axa-fr/design-system-slash-css/dist/Button/Button.css";
3
+ export type ButtonVariant = "primary" | "secondary" | "validated" | "danger" | "ghost" | "ghost-reverse";
4
+ export declare const Button: import("react").ForwardRefExoticComponent<{
5
+ variant?: ButtonVariant;
6
+ small?: boolean;
7
+ leftIcon?: ReactNode;
8
+ rightIcon?: ReactNode;
9
+ } & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
10
+ children?: ReactNode | undefined;
11
+ } & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import "@axa-fr/design-system-slash-css/dist/Button/Button.scss";
3
- import { getComponentClassName } from "../utilities";
4
- export const Button = ({ children, classModifier, className, ...args }) => {
5
- const componentClassName = getComponentClassName(className, classModifier, "af-btn");
6
- return (_jsx("button", { className: componentClassName, type: "button", ...args, children: children }));
7
- };
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, } from "react";
3
+ import classNames from "classnames";
4
+ import "@axa-fr/design-system-slash-css/dist/Button/Button.css";
5
+ const DEFAULT_CLASS_NAME = "af-btn";
6
+ export const Button = forwardRef(({ variant = "primary", small, leftIcon, rightIcon, className, children, ...props }, ref) => (_jsxs("button", { type: "button", className: classNames(DEFAULT_CLASS_NAME, variant !== "primary" && `${DEFAULT_CLASS_NAME}--${variant}`, small && `${DEFAULT_CLASS_NAME}--small`, className), ...props, ref: ref, children: [leftIcon, children, rightIcon] })));
7
+ Button.displayName = "Button";
@@ -55,6 +55,6 @@ const File = ({ className, classModifier, id, name, disabled, onChange, multiple
55
55
  disabled,
56
56
  });
57
57
  const componentClassName = getComponentClassName(className, classModifier, "af-form__file-input");
58
- return (_jsxs("div", { className: componentClassName, children: [_jsxs("div", { ...getRootProps({ className: "drop-box" }), children: [_jsx("input", { ...getInputProps({ id, name, readOnly, ...otherProps }) }), _jsx("div", { children: placeholder })] }), _jsxs(Button, { type: "button", className: "af-btn", classModifier: "file hasIconLeft", onClick: open, disabled: disabled, children: [_jsx("i", { className: `glyphicon glyphicon-${icon}` }), " ", label] })] }));
58
+ return (_jsxs("div", { className: componentClassName, children: [_jsxs("div", { ...getRootProps({ className: "drop-box" }), children: [_jsx("input", { ...getInputProps({ id, name, readOnly, ...otherProps }) }), _jsx("div", { children: placeholder })] }), _jsx(Button, { className: "af-btn--file", leftIcon: _jsx("i", { className: `glyphicon glyphicon-${icon}` }), onClick: open, disabled: disabled, children: label })] }));
59
59
  };
60
60
  export { File };
@@ -7,7 +7,7 @@ import { Header } from "./components/Header";
7
7
  const defaultClassName = "af-modal";
8
8
  const BooleanModal = forwardRef(({ children, title, submitTitle = "Valider", cancelTitle = "Annuler", className = defaultClassName, classModifier, onCancel, onSubmit, closeButtonAriaLabel, ...props }, ref) => {
9
9
  const componentClassName = getComponentClassName(className, classModifier, defaultClassName);
10
- return (_jsxs(Modal, { className: componentClassName, onOutsideTap: onCancel, title: title, ref: ref, ...props, children: [_jsx(Header, { title: title, onCancel: onCancel, closeButtonAriaLabel: closeButtonAriaLabel }), _jsx(Body, { children: children }), _jsxs(Footer, { children: [_jsx(Button, { classModifier: "reverse", onClick: onCancel, children: cancelTitle }), _jsx(Button, { onClick: onSubmit, classModifier: "success", children: submitTitle })] })] }));
10
+ return (_jsxs(Modal, { className: componentClassName, onOutsideTap: onCancel, title: title, ref: ref, ...props, children: [_jsx(Header, { title: title, onCancel: onCancel, closeButtonAriaLabel: closeButtonAriaLabel }), _jsx(Body, { children: children }), _jsxs(Footer, { children: [_jsx(Button, { variant: "secondary", onClick: onCancel, children: cancelTitle }), _jsx(Button, { onClick: onSubmit, variant: "validated", children: submitTitle })] })] }));
11
11
  });
12
12
  BooleanModal.displayName = "BooleanModal";
13
13
  export { BooleanModal };
@@ -0,0 +1,29 @@
1
+ import { ComponentPropsWithRef, PropsWithChildren } from "react";
2
+ import "@axa-fr/design-system-slash-css/dist/Tag/Tag.scss";
3
+ type TagModifier = "success" | "information" | "warning" | "error" | "default" | "dark" | "purple" | "gray";
4
+ /**
5
+ * @deprecated instead use warning
6
+ */
7
+ type TagModifierDecrepated = "danger";
8
+ type TagProps = ComponentPropsWithRef<"span"> & {
9
+ classModifier?: `${TagModifier | TagModifierDecrepated}` | string;
10
+ disabled?: boolean;
11
+ };
12
+ /**
13
+ * Tag component to display a label with various styles.
14
+ *
15
+ * @component
16
+ * @example
17
+ * // Basic usage
18
+ * <Tag classModifier="success">Success Tag</Tag>
19
+ *
20
+ * @param {object} props - The properties object.
21
+ * @param {React.ReactNode} props.children - The content to be displayed inside the tag.
22
+ * @param {string} [props.className] - Additional class names to apply to the tag.
23
+ * @param {string} [props.classModifier] - Modifier class to apply specific styles. Note: "danger" is deprecated, use "warning" instead.
24
+ * @param {boolean} [props.disabled] - If true, the tag will be disabled.
25
+ * @param {React.Ref<HTMLSpanElement>} ref - The ref to the span element.
26
+ * @returns {JSX.Element} The rendered Tag component.
27
+ */
28
+ export declare const Tag: import("react").ForwardRefExoticComponent<Omit<PropsWithChildren<TagProps>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
29
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { getComponentClassName } from "../utilities";
4
+ import "@axa-fr/design-system-slash-css/dist/Tag/Tag.scss";
5
+ /**
6
+ * Tag component to display a label with various styles.
7
+ *
8
+ * @component
9
+ * @example
10
+ * // Basic usage
11
+ * <Tag classModifier="success">Success Tag</Tag>
12
+ *
13
+ * @param {object} props - The properties object.
14
+ * @param {React.ReactNode} props.children - The content to be displayed inside the tag.
15
+ * @param {string} [props.className] - Additional class names to apply to the tag.
16
+ * @param {string} [props.classModifier] - Modifier class to apply specific styles. Note: "danger" is deprecated, use "warning" instead.
17
+ * @param {boolean} [props.disabled] - If true, the tag will be disabled.
18
+ * @param {React.Ref<HTMLSpanElement>} ref - The ref to the span element.
19
+ * @returns {JSX.Element} The rendered Tag component.
20
+ */
21
+ export const Tag = forwardRef(({ children, className, classModifier = "default", ...otherProps }, ref) => {
22
+ const componentClassName = getComponentClassName(className, classModifier, "af-tag");
23
+ // Kept for backward compatibility. May be removed in a future version
24
+ const badgeClassName = getComponentClassName(className, classModifier, "af-badge");
25
+ return (_jsx("span", { ref: ref, className: `${componentClassName} ${badgeClassName}`, ...otherProps, children: children }));
26
+ });
27
+ Tag.displayName = "Tag";
package/dist/index.d.ts CHANGED
@@ -2,10 +2,18 @@ import "@axa-fr/design-system-slash-css/dist/common/icons.scss";
2
2
  import "@axa-fr/design-system-slash-css/dist/common/reboot.scss";
3
3
  import "@axa-fr/design-system-slash-css/dist/common/tokens.css";
4
4
  import "@fontsource/source-sans-pro";
5
+ import "@fontsource/source-sans-pro/700.css";
5
6
  import { Message } from "./Messages/Message";
7
+ import { Tag } from "./Tag/Tag";
6
8
  export { Action } from "./Action/Action";
7
- export { Badge } from "./Badge/Badge";
9
+ /** @deprecated Use `Tag` instead. */
10
+ declare const Badge: import("react").ForwardRefExoticComponent<Omit<import("react").PropsWithChildren<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
11
+ classModifier?: `${("error" | "warning" | "success" | "information" | "default" | "dark" | "purple" | "gray") | "danger"}` | string;
12
+ disabled?: boolean;
13
+ }>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
14
+ export { Badge, Tag };
8
15
  export { Button } from "./Button/Button";
16
+ export type { ButtonVariant } from "./Button/Button";
9
17
  export { Card } from "./Card/Card";
10
18
  export { Divider } from "./Divider/Divider";
11
19
  export { Checkbox, CheckboxInput, CheckboxItem, CheckboxModes, } from "./Form/Checkbox";
package/dist/index.js CHANGED
@@ -2,9 +2,13 @@ import "@axa-fr/design-system-slash-css/dist/common/icons.scss";
2
2
  import "@axa-fr/design-system-slash-css/dist/common/reboot.scss";
3
3
  import "@axa-fr/design-system-slash-css/dist/common/tokens.css";
4
4
  import "@fontsource/source-sans-pro";
5
+ import "@fontsource/source-sans-pro/700.css";
5
6
  import { Message } from "./Messages/Message";
7
+ import { Tag } from "./Tag/Tag";
6
8
  export { Action } from "./Action/Action";
7
- export { Badge } from "./Badge/Badge";
9
+ /** @deprecated Use `Tag` instead. */
10
+ const Badge = Tag;
11
+ export { Badge, Tag };
8
12
  export { Button } from "./Button/Button";
9
13
  export { Card } from "./Card/Card";
10
14
  export { Divider } from "./Divider/Divider";
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Generates a component class name string based on provided class names and modifiers.
3
+ *
4
+ * @param {string} [className] - The base class name.
5
+ * @param {string} [classModifier] - A space-separated string of class modifiers.
6
+ * @param {string} [defaultClassName] - The default class name to use if className is not provided.
7
+ * @returns {string} The generated class name string.
8
+ */
1
9
  export declare const getComponentClassName: (className?: string, classModifier?: string, defaultClassName?: string) => string;
2
10
  type getComponentClassNameWithUserClassnameParams = {
3
11
  userClassName?: string;
@@ -11,6 +11,14 @@ const listClassModifier = (classModifier) => {
11
11
  }
12
12
  return classModifier.split(" ");
13
13
  };
14
+ /**
15
+ * Generates a component class name string based on provided class names and modifiers.
16
+ *
17
+ * @param {string} [className] - The base class name.
18
+ * @param {string} [classModifier] - A space-separated string of class modifiers.
19
+ * @param {string} [defaultClassName] - The default class name to use if className is not provided.
20
+ * @returns {string} The generated class name string.
21
+ */
14
22
  export const getComponentClassName = (className, classModifier, defaultClassName) => {
15
23
  const classNameToUse = className || defaultClassName;
16
24
  // Fail fast, when no className or defaultClassName we don't want to loop on modifier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-slash-react",
3
- "version": "1.2.1-alpha.112",
3
+ "version": "1.2.1-alpha.118",
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": "1.2.1-alpha.112",
50
+ "@axa-fr/design-system-slash-css": "1.2.1-alpha.118",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "react": ">= 18"
53
53
  },
@@ -1,8 +0,0 @@
1
- import { ComponentPropsWithRef, PropsWithChildren } from "react";
2
- import "@axa-fr/design-system-slash-css/dist/Badge/Badge.scss";
3
- type BadgeProps = ComponentPropsWithRef<"span"> & {
4
- classModifier?: string;
5
- disabled?: boolean;
6
- };
7
- export declare const Badge: import("react").ForwardRefExoticComponent<Omit<PropsWithChildren<BadgeProps>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
8
- export {};
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { getComponentClassName } from "../utilities";
4
- import "@axa-fr/design-system-slash-css/dist/Badge/Badge.scss";
5
- export const Badge = forwardRef(({ children, className, classModifier, ...otherProps }, ref) => {
6
- const componentClassName = getComponentClassName(className, classModifier, "af-badge");
7
- return (_jsx("span", { ref: ref, className: componentClassName, ...otherProps, children: children }));
8
- });
9
- Badge.displayName = "Badge";