@lumx/core 3.21.2-alpha.3 → 4.0.0

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.
@@ -6,7 +6,6 @@ export type { HasCloseMode } from './HasCloseMode';
6
6
  export type { HasTheme } from './HasTheme';
7
7
  export type { GenericProps } from './GenericProps';
8
8
  export type { HeadingElement } from './HeadingElement';
9
- export type { KebabCase } from './KebabCase';
10
9
  export type { Point } from './Point';
11
10
  export type { Predicate } from './Predicate';
12
11
  export type { RectSize } from './RectSize';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Get the basic CSS class for the given type.
3
+ *
4
+ * @param prefix The class name prefix for the generated CSS class.
5
+ * @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).
6
+ * @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).
7
+ * @return The basic CSS class.
8
+ */
9
+ export declare function getBasicClass({ prefix, type, value, }: {
10
+ prefix: string;
11
+ type: string;
12
+ value: string | number | boolean | undefined;
13
+ }): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Return all basic LumX CSS classes which are available for every components.
3
+ *
4
+ * @see {@link /src/components/index.d.ts} for the possible values of each parameter.
5
+ *
6
+ * @param prefix The class name prefix for the generated CSS class.
7
+ * @param props All the other props you want to generate a class.
8
+ * The rule of thumb: the key is the name of the prop in the class, the value a string that will
9
+ * be used in the classname to represent the value of the given prop.
10
+ * @return All LumX basic CSS classes.
11
+ */
12
+ export declare function handleBasicClasses({ prefix, ...props }: {
13
+ prefix: string;
14
+ [prop: string]: any;
15
+ }): string;
@@ -0,0 +1,2 @@
1
+ export { handleBasicClasses } from './handleBasicClasses';
2
+ export { getBasicClass } from './getBasicClass';
@@ -3,4 +3,3 @@ export * from './color';
3
3
  export * from './typography';
4
4
  export * from './spacing';
5
5
  export * from './visually-hidden';
6
- export * as bem from './bem';
@@ -3,5 +3,3 @@ export { background, color, font } from './color/index.js';
3
3
  export { typography } from './typography/index.js';
4
4
  export { margin, margins, padding, paddings, spacing, spacings } from './spacing/index.js';
5
5
  export { visuallyHidden } from './visually-hidden/index.js';
6
- import * as index from './bem/index.js';
7
- export { index as bem };
package/package.json CHANGED
@@ -35,7 +35,7 @@
35
35
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
36
36
  },
37
37
  "sideEffects": false,
38
- "version": "3.21.2-alpha.3",
38
+ "version": "4.0.0",
39
39
  "devDependencies": {
40
40
  "@rollup/plugin-typescript": "^12.3.0",
41
41
  "@types/react": "^17.0.2",
@@ -1,18 +0,0 @@
1
- import type { ClassValue } from 'classnames/types';
2
- import { type Modifier } from './generateBEMClass';
3
- /**
4
- * Creates a BEM block class generator function for the given base class.
5
- * Returns a function that generates BEM class names with optional modifiers.
6
- *
7
- * @param baseClass - The base BEM block class name (e.g., 'button', 'card')
8
- * @returns A function that accepts:
9
- * - modifier - Optional BEM modifier (string, object, or array)
10
- * - additionalClasses - Optional additional classes to include
11
- *
12
- * @example
13
- * const button = block('my-button');
14
- * button(); // 'my-button'
15
- * button('primary'); // 'my-button my-button--primary'
16
- * button({ active: true }); // 'my-button my-button--active'
17
- */
18
- export declare const block: (baseClass: string) => (modifier?: Modifier, additionalClasses?: ClassValue | ClassValue[]) => string;
@@ -1,20 +0,0 @@
1
- import { generateBEMClass } from './generateBEMClass.js';
2
-
3
- /**
4
- * Creates a BEM block class generator function for the given base class.
5
- * Returns a function that generates BEM class names with optional modifiers.
6
- *
7
- * @param baseClass - The base BEM block class name (e.g., 'button', 'card')
8
- * @returns A function that accepts:
9
- * - modifier - Optional BEM modifier (string, object, or array)
10
- * - additionalClasses - Optional additional classes to include
11
- *
12
- * @example
13
- * const button = block('my-button');
14
- * button(); // 'my-button'
15
- * button('primary'); // 'my-button my-button--primary'
16
- * button({ active: true }); // 'my-button my-button--active'
17
- */
18
- const block = (baseClass) => (modifier, additionalClasses) => generateBEMClass(baseClass, modifier, additionalClasses);
19
-
20
- export { block };
@@ -1,19 +0,0 @@
1
- import type { ClassValue } from 'classnames/types';
2
- import { type Modifier } from './generateBEMClass';
3
- /**
4
- * Creates a BEM element class generator function for the given base class.
5
- * Returns a function that generates BEM element class names with optional modifiers.
6
- *
7
- * @param baseClass - The base BEM block class name (e.g., 'button', 'card')
8
- * @returns A function that accepts:
9
- * - elem - The BEM element name (e.g., 'icon', 'title')
10
- * - modifier - Optional BEM modifier (string, object, or array)
11
- * - additionalClasses - Optional additional classes to include
12
- *
13
- * @example
14
- * const button = element('my-button');
15
- * button('icon'); // 'my-button__icon'
16
- * button('icon', 'large'); // 'my-button__icon my-button__icon--large'
17
- * button('icon', { active: true }); // 'my-button__icon my-button__icon--active'
18
- */
19
- export declare const element: (baseClass: string) => (elem: string, modifier?: Modifier, additionalClasses?: ClassValue | ClassValue[]) => string;
@@ -1,21 +0,0 @@
1
- import { generateBEMClass } from './generateBEMClass.js';
2
-
3
- /**
4
- * Creates a BEM element class generator function for the given base class.
5
- * Returns a function that generates BEM element class names with optional modifiers.
6
- *
7
- * @param baseClass - The base BEM block class name (e.g., 'button', 'card')
8
- * @returns A function that accepts:
9
- * - elem - The BEM element name (e.g., 'icon', 'title')
10
- * - modifier - Optional BEM modifier (string, object, or array)
11
- * - additionalClasses - Optional additional classes to include
12
- *
13
- * @example
14
- * const button = element('my-button');
15
- * button('icon'); // 'my-button__icon'
16
- * button('icon', 'large'); // 'my-button__icon my-button__icon--large'
17
- * button('icon', { active: true }); // 'my-button__icon my-button__icon--active'
18
- */
19
- const element = (baseClass) => (elem, modifier, additionalClasses) => generateBEMClass(`${baseClass}__${elem}`, modifier, additionalClasses);
20
-
21
- export { element };
@@ -1,27 +0,0 @@
1
- import type { ClassValue } from 'classnames/types';
2
- /**
3
- * Modifier
4
- * @example 'is-disabled'
5
- * @example { 'is-disabled': true, 'is-selected': false }
6
- * @example ['another-class'] // => Added as-is, not as a BEM modifier suffix
7
- */
8
- export type Modifier = string | Record<string, boolean | undefined | null> | ClassValue[];
9
- /**
10
- * Generates a BEM (Block Element Modifier) class name string.
11
- * Combines a base class with optional modifiers and additional classes.
12
- *
13
- * @param baseClass - The base BEM class (block or element)
14
- * @param modifier - Optional modifier as:
15
- * - string: creates `baseClass--modifier`
16
- * - object: creates `baseClass--key` for each truthy value
17
- * - array: passes through as additional classes
18
- * @param additionalClasses - Optional additional classes to include
19
- * @returns Combined class name string
20
- *
21
- * @example
22
- * generateBEMClass('button'); // 'button'
23
- * generateBEMClass('button', 'primary'); // 'button button--primary'
24
- * generateBEMClass('button', { active: true, disabled: false }); // 'button button--active'
25
- * generateBEMClass('button', 'primary', 'my-class'); // 'button button--primary my-class'
26
- */
27
- export declare function generateBEMClass(baseClass: string, modifier?: Modifier, additionalClasses?: ClassValue | ClassValue[]): string;
@@ -1,48 +0,0 @@
1
- import classnames from 'classnames';
2
-
3
- function generateModifierClasses(baseClass, modifier) {
4
- if (!modifier) {
5
- return undefined;
6
- }
7
- if (Array.isArray(modifier)) {
8
- return modifier;
9
- }
10
- if (typeof modifier === 'string') {
11
- return `${baseClass}--${modifier}`;
12
- }
13
- const classes = [];
14
- for (const [key, value] of Object.entries(modifier)) {
15
- if (value)
16
- classes.push(`${baseClass}--${key}`);
17
- }
18
- return classes;
19
- }
20
- /**
21
- * Generates a BEM (Block Element Modifier) class name string.
22
- * Combines a base class with optional modifiers and additional classes.
23
- *
24
- * @param baseClass - The base BEM class (block or element)
25
- * @param modifier - Optional modifier as:
26
- * - string: creates `baseClass--modifier`
27
- * - object: creates `baseClass--key` for each truthy value
28
- * - array: passes through as additional classes
29
- * @param additionalClasses - Optional additional classes to include
30
- * @returns Combined class name string
31
- *
32
- * @example
33
- * generateBEMClass('button'); // 'button'
34
- * generateBEMClass('button', 'primary'); // 'button button--primary'
35
- * generateBEMClass('button', { active: true, disabled: false }); // 'button button--active'
36
- * generateBEMClass('button', 'primary', 'my-class'); // 'button button--primary my-class'
37
- */
38
- function generateBEMClass(baseClass, modifier, additionalClasses) {
39
- return classnames(
40
- // Base class
41
- baseClass,
42
- // Modifier(s)
43
- generateModifierClasses(baseClass, modifier),
44
- // Additional classes
45
- additionalClasses);
46
- }
47
-
48
- export { generateBEMClass };
@@ -1,2 +0,0 @@
1
- export { block } from './block';
2
- export { element } from './element';
@@ -1,2 +0,0 @@
1
- export { block } from './block.js';
2
- export { element } from './element.js';