@axa-fr/design-system-slash-react 2.0.6-alpha.5 → 2.0.6-alpha.7

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.
@@ -0,0 +1,20 @@
1
+ type getClassNameParams = {
2
+ baseClassName: string;
3
+ modifiers?: Array<string | boolean | undefined>;
4
+ className?: string;
5
+ };
6
+ /**
7
+ * Generates a CSS class string from a base class name, optional modifiers, and an additional class name.
8
+ *
9
+ * @param {string} params.baseClassName - The base class name (required).
10
+ * @param {Array<string|boolean|undefined>} [params.modifiers] - List of modifiers to append as `${baseClassName}--{modifier}`. Falsy values are ignored.
11
+ * @param {string} [params.className] - Additional class name(s) to append to the final string.
12
+ * @returns {string} The concatenated CSS class string, separated by spaces.
13
+ *
14
+ * @example
15
+ * const isLarge = false;
16
+ * getClassName({ baseClassName: 'af-button', modifiers: ['primary', isLarge && 'large'], className: 'custom-class' })
17
+ * // Returns: 'af-button af-button--primary custom-class'
18
+ */
19
+ export declare const getClassName: ({ baseClassName, modifiers, className, }: getClassNameParams) => string;
20
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Generates a CSS class string from a base class name, optional modifiers, and an additional class name.
3
+ *
4
+ * @param {string} params.baseClassName - The base class name (required).
5
+ * @param {Array<string|boolean|undefined>} [params.modifiers] - List of modifiers to append as `${baseClassName}--{modifier}`. Falsy values are ignored.
6
+ * @param {string} [params.className] - Additional class name(s) to append to the final string.
7
+ * @returns {string} The concatenated CSS class string, separated by spaces.
8
+ *
9
+ * @example
10
+ * const isLarge = false;
11
+ * getClassName({ baseClassName: 'af-button', modifiers: ['primary', isLarge && 'large'], className: 'custom-class' })
12
+ * // Returns: 'af-button af-button--primary custom-class'
13
+ */
14
+ export const getClassName = ({ baseClassName, modifiers = [], className = "", }) => {
15
+ const parsedModifiers = modifiers
16
+ .filter(Boolean)
17
+ .map((modifier) => `${baseClassName}--${modifier}`);
18
+ const classList = [
19
+ baseClassName,
20
+ ...parsedModifiers,
21
+ ...className.split(" "),
22
+ ].filter(Boolean);
23
+ return Array.from(new Set(classList)).join(" ");
24
+ };
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * @deprecated This function is deprecated and will be removed in a future release. Use getClassName instead.
2
3
  * Generates a component class name string based on provided class names and modifiers.
3
4
  *
4
5
  * @param {string} [className] - The base class name.
@@ -12,5 +13,8 @@ type getComponentClassNameWithUserClassnameParams = {
12
13
  classModifier?: string;
13
14
  componentClassName: string;
14
15
  };
16
+ /**
17
+ * @deprecated This function is deprecated and will be removed in a future release. Use getClassName instead.
18
+ */
15
19
  export declare const getComponentClassNameWithUserClassname: ({ componentClassName, userClassName, classModifier, }: getComponentClassNameWithUserClassnameParams) => string;
16
20
  export {};
@@ -12,6 +12,7 @@ const listClassModifier = (classModifier) => {
12
12
  return classModifier.split(" ");
13
13
  };
14
14
  /**
15
+ * @deprecated This function is deprecated and will be removed in a future release. Use getClassName instead.
15
16
  * Generates a component class name string based on provided class names and modifiers.
16
17
  *
17
18
  * @param {string} [className] - The base class name.
@@ -34,6 +35,9 @@ export const getComponentClassName = (className, classModifier, defaultClassName
34
35
  });
35
36
  return classNames(classNameToUse, modifiersObject);
36
37
  };
38
+ /**
39
+ * @deprecated This function is deprecated and will be removed in a future release. Use getClassName instead.
40
+ */
37
41
  export const getComponentClassNameWithUserClassname = ({ componentClassName, userClassName, classModifier, }) => {
38
42
  // Fail fast, when no className or componentClassName we don't want to loop on modifier
39
43
  if (!componentClassName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/design-system-slash-react",
3
- "version": "2.0.6-alpha.5",
3
+ "version": "2.0.6-alpha.7",
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.6-alpha.5",
50
+ "@axa-fr/design-system-slash-css": "2.0.6-alpha.7",
51
51
  "@material-symbols/svg-400": ">= 0.19.0",
52
52
  "@material-symbols/svg-700": ">= 0.19.0",
53
53
  "react": ">= 18"