@lumx/core 3.20.1-alpha.5 → 3.20.1-alpha.50

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.
Files changed (156) hide show
  1. package/CONTRIBUTING.md +1 -5
  2. package/{js/utils/className/resolveColorWithVariants.js → _internal/DPnPEC08.js} +1 -5
  3. package/js/constants/_internal/design-tokens.d.ts +5421 -0
  4. package/js/constants/className/index.d.ts +4 -0
  5. package/js/constants/className/index.js +6 -0
  6. package/js/constants/components/index.d.ts +24 -0
  7. package/js/constants/components/index.js +26 -0
  8. package/js/constants/enums/index.d.ts +200 -0
  9. package/js/constants/enums/index.js +155 -0
  10. package/js/constants/index.d.ts +4 -0
  11. package/js/constants/index.js +4 -218
  12. package/js/constants/keycodes/index.d.ts +36 -0
  13. package/js/constants/{keycodes.js → keycodes/index.js} +1 -13
  14. package/js/types/Direction.d.ts +1 -0
  15. package/js/types/{GenericProps.ts → GenericProps.d.ts} +0 -1
  16. package/js/types/HasAriaLabelOrLabelledBy.d.ts +17 -0
  17. package/js/types/{HasTheme.ts → HasTheme.d.ts} +0 -1
  18. package/js/types/KebabCase.d.ts +2 -0
  19. package/js/types/LumxClassName.d.ts +3 -0
  20. package/js/types/Point.d.ts +7 -0
  21. package/js/types/RectSize.d.ts +7 -0
  22. package/js/types/Spacing.d.ts +1 -0
  23. package/js/types/{TextElement.ts → TextElement.d.ts} +0 -1
  24. package/js/types/{index.ts → index.d.ts} +4 -0
  25. package/js/types/index.js +0 -1
  26. package/js/utils/_internal/color/index.d.ts +1 -0
  27. package/js/utils/_internal/color/resolveColorWithVariants.d.ts +3 -0
  28. package/js/utils/classNames/bem/block.d.ts +18 -0
  29. package/js/utils/classNames/bem/block.js +20 -0
  30. package/js/utils/classNames/bem/element.d.ts +19 -0
  31. package/js/utils/classNames/bem/element.js +21 -0
  32. package/js/utils/classNames/bem/generateBEMClass.d.ts +27 -0
  33. package/js/utils/classNames/bem/generateBEMClass.js +48 -0
  34. package/js/utils/classNames/bem/index.d.ts +2 -0
  35. package/js/utils/classNames/bem/index.js +2 -0
  36. package/js/utils/classNames/color/index.d.ts +43 -0
  37. package/js/utils/classNames/color/index.js +50 -0
  38. package/js/utils/classNames/index.d.ts +6 -0
  39. package/js/utils/classNames/index.js +7 -0
  40. package/js/utils/classNames/spacing/index.d.ts +70 -0
  41. package/js/utils/classNames/spacing/index.js +74 -0
  42. package/js/utils/classNames/typography/index.d.ts +6 -0
  43. package/js/utils/classNames/typography/index.js +9 -0
  44. package/js/utils/classNames/visually-hidden/index.d.ts +5 -0
  45. package/js/utils/classNames/visually-hidden/index.js +10 -0
  46. package/js/utils/events/index.d.ts +2 -0
  47. package/js/utils/events/index.js +2 -0
  48. package/js/utils/events/keyboard.d.ts +24 -0
  49. package/js/utils/events/keyboard.js +44 -0
  50. package/js/utils/events/swipe.d.ts +6 -0
  51. package/js/utils/events/swipe.js +79 -0
  52. package/js/utils/index.d.ts +2 -0
  53. package/js/utils/index.js +4 -223
  54. package/lumx.css +18 -17
  55. package/package.json +11 -15
  56. package/scss/components/list/_index.scss +10 -4
  57. package/scss/components/text-field/_index.scss +4 -6
  58. package/js/components/Icon/Stories.js +0 -40
  59. package/js/components/Icon/Tests.tsx +0 -120
  60. package/js/components/Icon/index.tsx +0 -134
  61. package/js/constants/design-tokens.js +0 -2329
  62. package/js/constants/design-tokens.min.js +0 -1
  63. package/js/constants/design-tokens.ts +0 -2324
  64. package/js/constants/index.min.js +0 -1
  65. package/js/constants/index.ts +0 -231
  66. package/js/constants/keycodes.min.js +0 -1
  67. package/js/constants/keycodes.ts +0 -44
  68. package/js/custom-colors.js +0 -48
  69. package/js/custom-colors.min.js +0 -1
  70. package/js/custom-colors.ts +0 -56
  71. package/js/date-picker.js +0 -71
  72. package/js/date-picker.min.js +0 -1
  73. package/js/date-picker.ts +0 -77
  74. package/js/types/Callback.js +0 -2
  75. package/js/types/Callback.min.js +0 -1
  76. package/js/types/Falsy.js +0 -2
  77. package/js/types/Falsy.min.js +0 -1
  78. package/js/types/GenericProps.js +0 -2
  79. package/js/types/GenericProps.min.js +0 -1
  80. package/js/types/HasAriaLabelOrLabelledBy.js +0 -2
  81. package/js/types/HasAriaLabelOrLabelledBy.min.js +0 -1
  82. package/js/types/HasAriaLabelOrLabelledBy.ts +0 -19
  83. package/js/types/HasClassName.js +0 -2
  84. package/js/types/HasClassName.min.js +0 -1
  85. package/js/types/HasCloseMode.js +0 -2
  86. package/js/types/HasCloseMode.min.js +0 -1
  87. package/js/types/HasTheme.js +0 -2
  88. package/js/types/HasTheme.min.js +0 -1
  89. package/js/types/HeadingElement.js +0 -2
  90. package/js/types/HeadingElement.min.js +0 -1
  91. package/js/types/Point.js +0 -2
  92. package/js/types/Point.min.js +0 -1
  93. package/js/types/Point.ts +0 -4
  94. package/js/types/Predicate.js +0 -2
  95. package/js/types/Predicate.min.js +0 -1
  96. package/js/types/RectSize.js +0 -2
  97. package/js/types/RectSize.min.js +0 -1
  98. package/js/types/RectSize.ts +0 -4
  99. package/js/types/TextElement.js +0 -2
  100. package/js/types/TextElement.min.js +0 -1
  101. package/js/types/ValueOf.js +0 -2
  102. package/js/types/ValueOf.min.js +0 -1
  103. package/js/types/index.min.js +0 -1
  104. package/js/utils/className/fontColorClass.js +0 -20
  105. package/js/utils/className/fontColorClass.min.js +0 -1
  106. package/js/utils/className/fontColorClass.test.js +0 -18
  107. package/js/utils/className/fontColorClass.test.min.js +0 -1
  108. package/js/utils/className/fontColorClass.test.ts +0 -15
  109. package/js/utils/className/fontColorClass.ts +0 -12
  110. package/js/utils/className/getBasicClass.js +0 -36
  111. package/js/utils/className/getBasicClass.min.js +0 -1
  112. package/js/utils/className/getBasicClass.test.js +0 -22
  113. package/js/utils/className/getBasicClass.test.min.js +0 -1
  114. package/js/utils/className/getBasicClass.test.ts +0 -20
  115. package/js/utils/className/getBasicClass.ts +0 -36
  116. package/js/utils/className/getRootClassName.js +0 -33
  117. package/js/utils/className/getRootClassName.min.js +0 -1
  118. package/js/utils/className/getRootClassName.test.js +0 -15
  119. package/js/utils/className/getRootClassName.test.min.js +0 -1
  120. package/js/utils/className/getRootClassName.test.ts +0 -11
  121. package/js/utils/className/getRootClassName.ts +0 -25
  122. package/js/utils/className/getTypographyClassName.js +0 -13
  123. package/js/utils/className/getTypographyClassName.min.js +0 -1
  124. package/js/utils/className/getTypographyClassName.test.js +0 -9
  125. package/js/utils/className/getTypographyClassName.test.min.js +0 -1
  126. package/js/utils/className/getTypographyClassName.test.ts +0 -7
  127. package/js/utils/className/getTypographyClassName.ts +0 -9
  128. package/js/utils/className/handleBasicClasses.js +0 -52
  129. package/js/utils/className/handleBasicClasses.min.js +0 -1
  130. package/js/utils/className/handleBasicClasses.test.js +0 -35
  131. package/js/utils/className/handleBasicClasses.test.min.js +0 -1
  132. package/js/utils/className/handleBasicClasses.test.ts +0 -28
  133. package/js/utils/className/handleBasicClasses.ts +0 -44
  134. package/js/utils/className/index.js +0 -25
  135. package/js/utils/className/index.min.js +0 -1
  136. package/js/utils/className/index.ts +0 -6
  137. package/js/utils/className/resolveColorWithVariants.min.js +0 -1
  138. package/js/utils/className/resolveColorWithVariants.test.js +0 -30
  139. package/js/utils/className/resolveColorWithVariants.test.min.js +0 -1
  140. package/js/utils/className/resolveColorWithVariants.test.ts +0 -33
  141. package/js/utils/className/resolveColorWithVariants.ts +0 -11
  142. package/js/utils/index.min.js +0 -1
  143. package/js/utils/index.ts +0 -221
  144. package/lumx.min.css +0 -1
  145. package/stories/controls/color.ts +0 -7
  146. package/stories/controls/icons.ts +0 -126
  147. package/stories/controls/selectArgType.ts +0 -8
  148. package/stories/controls/withUndefined.ts +0 -1
  149. package/testing/utils/queries.ts +0 -19
  150. /package/js/types/{Callback.ts → Callback.d.ts} +0 -0
  151. /package/js/types/{Falsy.ts → Falsy.d.ts} +0 -0
  152. /package/js/types/{HasClassName.ts → HasClassName.d.ts} +0 -0
  153. /package/js/types/{HasCloseMode.ts → HasCloseMode.d.ts} +0 -0
  154. /package/js/types/{HeadingElement.ts → HeadingElement.d.ts} +0 -0
  155. /package/js/types/{Predicate.ts → Predicate.d.ts} +0 -0
  156. /package/js/types/{ValueOf.ts → ValueOf.d.ts} +0 -0
@@ -1,7 +1,3 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
1
  /**
6
2
  * The down key code.
7
3
  */
@@ -39,12 +35,4 @@ const UP_KEY_CODE = 38;
39
35
  */
40
36
  const BACKSPACE_KEY_CODE = 8;
41
37
 
42
- exports.BACKSPACE_KEY_CODE = BACKSPACE_KEY_CODE;
43
- exports.DOWN_KEY_CODE = DOWN_KEY_CODE;
44
- exports.ENTER_KEY_CODE = ENTER_KEY_CODE;
45
- exports.ESCAPE_KEY_CODE = ESCAPE_KEY_CODE;
46
- exports.LEFT_KEY_CODE = LEFT_KEY_CODE;
47
- exports.RIGHT_KEY_CODE = RIGHT_KEY_CODE;
48
- exports.SPACE_KEY_CODE = SPACE_KEY_CODE;
49
- exports.TAB_KEY_CODE = TAB_KEY_CODE;
50
- exports.UP_KEY_CODE = UP_KEY_CODE;
38
+ export { BACKSPACE_KEY_CODE, DOWN_KEY_CODE, ENTER_KEY_CODE, ESCAPE_KEY_CODE, LEFT_KEY_CODE, RIGHT_KEY_CODE, SPACE_KEY_CODE, TAB_KEY_CODE, UP_KEY_CODE };
@@ -0,0 +1 @@
1
+ export type Direction = 'top' | 'right' | 'bottom' | 'left' | 'vertical' | 'horizontal' | 'all';
@@ -1,5 +1,4 @@
1
1
  import type { HasClassName } from './HasClassName';
2
-
3
2
  /**
4
3
  * Define a generic props types.
5
4
  */
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Require either `aria-label` or `arial-labelledby` prop.
3
+ * If none are set, the order will prioritize `aria-labelledby` over `aria-label` as it
4
+ * needs a visible element.
5
+ */
6
+ export type HasAriaLabelOrLabelledBy<T = string | undefined> = T extends string ? {
7
+ /**
8
+ * The id of the element to use as title of the dialog. Can be within or out of the dialog.
9
+ * Although it is not recommended, aria-label can be used instead if no visible element is available.
10
+ */
11
+ 'aria-labelledby': T;
12
+ /** The label of the dialog. */
13
+ 'aria-label'?: undefined;
14
+ } : {
15
+ 'aria-label': string;
16
+ 'aria-labelledby'?: undefined;
17
+ };
@@ -1,5 +1,4 @@
1
1
  import type { Theme } from '../constants';
2
-
3
2
  export interface HasTheme {
4
3
  /**
5
4
  * Theme adapting the component to light or dark background.
@@ -0,0 +1,2 @@
1
+ /** Transform a string literal into kebab case */
2
+ export type KebabCase<S> = S extends `${infer C}${infer T}` ? T extends Uncapitalize<T> ? `${Uncapitalize<C>}${KebabCase<T>}` : `${Uncapitalize<C>}-${KebabCase<T>}` : S;
@@ -0,0 +1,3 @@
1
+ import type { KebabCase } from './KebabCase';
2
+ /** Transform the component name into the lumx class name. */
3
+ export type LumxClassName<TComponentName extends string> = `lumx-${KebabCase<TComponentName>}`;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A point coordinate in 2D space
3
+ */
4
+ export type Point = {
5
+ x: number;
6
+ y: number;
7
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Rectangle size
3
+ */
4
+ export type RectSize = {
5
+ width: number;
6
+ height: number;
7
+ };
@@ -0,0 +1 @@
1
+ export type Spacing = 'margin' | 'padding';
@@ -1,4 +1,3 @@
1
1
  import type { HeadingElement } from './HeadingElement';
2
-
3
2
  /** Union type of all text elements */
4
3
  export type TextElement = 'span' | 'p' | HeadingElement;
@@ -6,8 +6,12 @@ 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';
9
10
  export type { Point } from './Point';
10
11
  export type { Predicate } from './Predicate';
11
12
  export type { RectSize } from './RectSize';
12
13
  export type { TextElement } from './TextElement';
13
14
  export type { ValueOf } from './ValueOf';
15
+ export type { LumxClassName } from './LumxClassName';
16
+ export type { Direction } from './Direction';
17
+ export type { Spacing } from './Spacing';
package/js/types/index.js CHANGED
@@ -1,2 +1 @@
1
- 'use strict';
2
1
 
@@ -0,0 +1 @@
1
+ export { resolveColorWithVariants } from './resolveColorWithVariants';
@@ -0,0 +1,3 @@
1
+ import type { ColorPalette, ColorVariant, ColorWithVariants } from '@lumx/core/js/constants';
2
+ /** Resolve color & color variant from a `ColorWithVariants` and optionally a `ColorVariant`. */
3
+ export declare function resolveColorWithVariants(colorWithVariants?: ColorWithVariants, colorVariant?: ColorVariant): [color?: ColorPalette, colorVariant?: ColorVariant];
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,20 @@
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 };
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,21 @@
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 };
@@ -0,0 +1,27 @@
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;
@@ -0,0 +1,48 @@
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 };
@@ -0,0 +1,2 @@
1
+ export { block } from './block';
2
+ export { element } from './element';
@@ -0,0 +1,2 @@
1
+ export { block } from './block.js';
2
+ export { element } from './element.js';
@@ -0,0 +1,43 @@
1
+ import { ColorVariant, ColorWithVariants } from '@lumx/core/js/constants';
2
+ /**
3
+ * Generates a Lumx color class name for the given type, color and variant.
4
+ * This is the base function used by font() and background() utilities.
5
+ *
6
+ * @param type - The color class type ('font' or 'background')
7
+ * @param propColor - The color palette name (e.g., 'primary', 'dark') with optional variant suffix (e.g., 'primary-L2')
8
+ * @param propColorVariant - Optional color variant override (e.g., 'L1', 'L2', 'D1', 'N')
9
+ * @returns The Lumx color class name or undefined if no color is provided
10
+ *
11
+ * @example
12
+ * color('font', 'dark', 'L2'); // 'lumx-color-font-dark-L2'
13
+ * color('background', 'primary'); // 'lumx-color-background-primary-N'
14
+ * color('font', 'primary-L2'); // 'lumx-color-font-primary-L2'
15
+ * color('font', undefined); // undefined
16
+ */
17
+ export declare function color(type: 'font' | 'background', propColor: ColorWithVariants, propColorVariant?: ColorVariant): string;
18
+ /**
19
+ * Generates a Lumx background color class name for the given color and variant.
20
+ *
21
+ * @param propColor - The color palette name (e.g., 'primary', 'dark', 'light')
22
+ * @param propColorVariant - The color variant (e.g., 'L1', 'L2', 'D1', 'N')
23
+ * @returns The Lumx background color class name
24
+ *
25
+ * @example
26
+ * background('dark', 'L2'); // 'lumx-color-background-dark-L2'
27
+ * background('primary', 'N'); // 'lumx-color-background-primary-N'
28
+ */
29
+ export declare const background: (propColor: ColorWithVariants, propColorVariant?: ColorVariant) => string;
30
+ /**
31
+ * Generates a Lumx font color class name for the given color and variant.
32
+ *
33
+ * @param propColor - The color palette name (e.g., 'primary', 'dark') with optional variant suffix (e.g., 'primary-L2')
34
+ * @param propColorVariant - Optional color variant override (e.g., 'L1', 'L2', 'D1', 'N')
35
+ * @returns The Lumx font color class name or undefined if no color is provided
36
+ *
37
+ * @example
38
+ * font('dark', 'L2'); // 'lumx-color-font-dark-L2'
39
+ * font('primary-L2'); // 'lumx-color-font-primary-L2'
40
+ * font('primary'); // 'lumx-color-font-primary-N'
41
+ * font(undefined); // undefined
42
+ */
43
+ export declare const font: (propColor: ColorWithVariants, propColorVariant?: ColorVariant) => string;
@@ -0,0 +1,50 @@
1
+ import { ColorVariant } from '../../../constants/enums/index.js';
2
+ import { resolveColorWithVariants } from '../../../../_internal/DPnPEC08.js';
3
+
4
+ /**
5
+ * Generates a Lumx color class name for the given type, color and variant.
6
+ * This is the base function used by font() and background() utilities.
7
+ *
8
+ * @param type - The color class type ('font' or 'background')
9
+ * @param propColor - The color palette name (e.g., 'primary', 'dark') with optional variant suffix (e.g., 'primary-L2')
10
+ * @param propColorVariant - Optional color variant override (e.g., 'L1', 'L2', 'D1', 'N')
11
+ * @returns The Lumx color class name or undefined if no color is provided
12
+ *
13
+ * @example
14
+ * color('font', 'dark', 'L2'); // 'lumx-color-font-dark-L2'
15
+ * color('background', 'primary'); // 'lumx-color-background-primary-N'
16
+ * color('font', 'primary-L2'); // 'lumx-color-font-primary-L2'
17
+ * color('font', undefined); // undefined
18
+ */
19
+ function color(type, propColor, propColorVariant) {
20
+ const [cColor, cColorVariant = ColorVariant.N] = resolveColorWithVariants(propColor, propColorVariant);
21
+ return `lumx-color-${type}-${cColor}-${cColorVariant}`;
22
+ }
23
+ /**
24
+ * Generates a Lumx background color class name for the given color and variant.
25
+ *
26
+ * @param propColor - The color palette name (e.g., 'primary', 'dark', 'light')
27
+ * @param propColorVariant - The color variant (e.g., 'L1', 'L2', 'D1', 'N')
28
+ * @returns The Lumx background color class name
29
+ *
30
+ * @example
31
+ * background('dark', 'L2'); // 'lumx-color-background-dark-L2'
32
+ * background('primary', 'N'); // 'lumx-color-background-primary-N'
33
+ */
34
+ const background = (propColor, propColorVariant) => color('background', propColor, propColorVariant);
35
+ /**
36
+ * Generates a Lumx font color class name for the given color and variant.
37
+ *
38
+ * @param propColor - The color palette name (e.g., 'primary', 'dark') with optional variant suffix (e.g., 'primary-L2')
39
+ * @param propColorVariant - Optional color variant override (e.g., 'L1', 'L2', 'D1', 'N')
40
+ * @returns The Lumx font color class name or undefined if no color is provided
41
+ *
42
+ * @example
43
+ * font('dark', 'L2'); // 'lumx-color-font-dark-L2'
44
+ * font('primary-L2'); // 'lumx-color-font-primary-L2'
45
+ * font('primary'); // 'lumx-color-font-primary-N'
46
+ * font(undefined); // undefined
47
+ */
48
+ const font = (propColor, propColorVariant) => color('font', propColor, propColorVariant);
49
+
50
+ export { background, color, font };
@@ -0,0 +1,6 @@
1
+ export { default as join } from 'classnames';
2
+ export * from './color';
3
+ export * from './typography';
4
+ export * from './spacing';
5
+ export * from './visually-hidden';
6
+ export * as bem from './bem';
@@ -0,0 +1,7 @@
1
+ export { default as join } from 'classnames';
2
+ export { background, color, font } from './color/index.js';
3
+ export { typography } from './typography/index.js';
4
+ export { margin, margins, padding, paddings, spacing, spacings } from './spacing/index.js';
5
+ export { visuallyHidden } from './visually-hidden/index.js';
6
+ import * as index from './bem/index.js';
7
+ export { index as bem };
@@ -0,0 +1,70 @@
1
+ import type { Direction, Spacing } from '@lumx/core/js/types';
2
+ import type { Size } from '@lumx/core/js/constants';
3
+ /**
4
+ * Returns a lumx classname for the given type, direction and size. For example, for
5
+ * arguments type='padding', direction='right', size='regular' it returns lumx-spacing-padding-right-regular
6
+ * @param type - margin or padding
7
+ * @param direction - Direction
8
+ * @param size - Size
9
+ * @returns string
10
+ */
11
+ export declare function spacing(type: Spacing, direction?: Direction, size?: Size | null): string;
12
+ /**
13
+ * Returns a list of lumx classnames for the given types, directions and sizes. For example, for
14
+ * arguments [
15
+ * { type: 'padding', direction: 'right', size: 'regular'},
16
+ * { type: 'margin', direction: 'left', size: 'big'},
17
+ * ]
18
+ * it returns lumx-spacing-padding-right-regular lumx-spacing-margin-left-big
19
+ * @param spacingConfigs - Array of spacing configurations with direction and size
20
+ * @returns string
21
+ */
22
+ export declare const spacings: (spacingConfigs: {
23
+ type: Spacing;
24
+ direction?: Direction;
25
+ size?: Size | null;
26
+ }[]) => string;
27
+ /**
28
+ * Returns a lumx margin classname for the given direction and size. For example, for
29
+ * arguments direction='right', size='regular' it returns lumx-spacing-margin-right-regular
30
+ * @param direction - Direction
31
+ * @param size - Size
32
+ * @returns string
33
+ */
34
+ export declare const margin: (direction?: Direction, size?: Size | null) => string;
35
+ /**
36
+ * Returns a list of lumx margin classnames for the given directions and sizes. For example, for
37
+ * arguments [
38
+ * { direction: 'right', size: 'regular'},
39
+ * { direction: 'left', size: 'big'},
40
+ * ]
41
+ * it returns lumx-spacing-margin-right-regular lumx-spacing-margin-left-big
42
+ * @param marginConfigs - Array of padding configurations with direction and size
43
+ * @returns string
44
+ */
45
+ export declare const margins: (marginConfigs: {
46
+ direction?: Direction;
47
+ size?: Size | null;
48
+ }[]) => string;
49
+ /**
50
+ * Returns a lumx padding classname for the given direction and size. For example, for
51
+ * arguments direction='right', size='regular' it returns lumx-spacing-padding-right-regular
52
+ * @param direction - Direction
53
+ * @param size - Size
54
+ * @returns string
55
+ */
56
+ export declare const padding: (direction?: Direction, size?: Size | null) => string;
57
+ /**
58
+ * Returns a list of lumx padding classnames for the given directions and sizes. For example, for
59
+ * arguments [
60
+ * { direction: 'right', size: 'regular'},
61
+ * { direction: 'left', size: 'big'},
62
+ * ]
63
+ * it returns lumx-spacing-padding-right-regular lumx-spacing-padding-left-big
64
+ * @param paddingConfigs - Array of padding configurations with direction and size
65
+ * @returns Combined padding classnames as a string
66
+ */
67
+ export declare const paddings: (paddingConfigs: {
68
+ direction?: Direction;
69
+ size?: Size | null;
70
+ }[]) => string;
@@ -0,0 +1,74 @@
1
+ import classnames from 'classnames';
2
+
3
+ /**
4
+ * Returns a lumx classname for the given type, direction and size. For example, for
5
+ * arguments type='padding', direction='right', size='regular' it returns lumx-spacing-padding-right-regular
6
+ * @param type - margin or padding
7
+ * @param direction - Direction
8
+ * @param size - Size
9
+ * @returns string
10
+ */
11
+ function spacing(type, direction, size) {
12
+ let baseClass = `lumx-spacing-${type}`;
13
+ if (direction && direction !== 'all') {
14
+ baseClass = `${baseClass}-${direction}`;
15
+ }
16
+ if (size) {
17
+ baseClass = `${baseClass}-${size}`;
18
+ }
19
+ else if (size === null) {
20
+ baseClass = `${baseClass}-none`;
21
+ }
22
+ return baseClass;
23
+ }
24
+ /**
25
+ * Returns a list of lumx classnames for the given types, directions and sizes. For example, for
26
+ * arguments [
27
+ * { type: 'padding', direction: 'right', size: 'regular'},
28
+ * { type: 'margin', direction: 'left', size: 'big'},
29
+ * ]
30
+ * it returns lumx-spacing-padding-right-regular lumx-spacing-margin-left-big
31
+ * @param spacingConfigs - Array of spacing configurations with direction and size
32
+ * @returns string
33
+ */
34
+ const spacings = (spacingConfigs) => classnames(spacingConfigs.map((spa) => spacing(spa.type, spa.direction, spa.size)));
35
+ /**
36
+ * Returns a lumx margin classname for the given direction and size. For example, for
37
+ * arguments direction='right', size='regular' it returns lumx-spacing-margin-right-regular
38
+ * @param direction - Direction
39
+ * @param size - Size
40
+ * @returns string
41
+ */
42
+ const margin = (direction, size) => spacing('margin', direction, size);
43
+ /**
44
+ * Returns a list of lumx margin classnames for the given directions and sizes. For example, for
45
+ * arguments [
46
+ * { direction: 'right', size: 'regular'},
47
+ * { direction: 'left', size: 'big'},
48
+ * ]
49
+ * it returns lumx-spacing-margin-right-regular lumx-spacing-margin-left-big
50
+ * @param marginConfigs - Array of padding configurations with direction and size
51
+ * @returns string
52
+ */
53
+ const margins = (marginConfigs) => spacings(marginConfigs.map(({ direction, size }) => ({ type: 'margin', direction, size })));
54
+ /**
55
+ * Returns a lumx padding classname for the given direction and size. For example, for
56
+ * arguments direction='right', size='regular' it returns lumx-spacing-padding-right-regular
57
+ * @param direction - Direction
58
+ * @param size - Size
59
+ * @returns string
60
+ */
61
+ const padding = (direction, size) => spacing('padding', direction, size);
62
+ /**
63
+ * Returns a list of lumx padding classnames for the given directions and sizes. For example, for
64
+ * arguments [
65
+ * { direction: 'right', size: 'regular'},
66
+ * { direction: 'left', size: 'big'},
67
+ * ]
68
+ * it returns lumx-spacing-padding-right-regular lumx-spacing-padding-left-big
69
+ * @param paddingConfigs - Array of padding configurations with direction and size
70
+ * @returns Combined padding classnames as a string
71
+ */
72
+ const paddings = (paddingConfigs) => spacings(paddingConfigs.map(({ direction, size }) => ({ type: 'padding', direction, size })));
73
+
74
+ export { margin, margins, padding, paddings, spacing, spacings };
@@ -0,0 +1,6 @@
1
+ import type { Typography } from '@lumx/core/js/constants';
2
+ /**
3
+ * Returns the classname associated to the given typography. For example, for Typography.title it returns
4
+ * lumx-typography-title
5
+ */
6
+ export declare function typography(typo: Typography): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns the classname associated to the given typography. For example, for Typography.title it returns
3
+ * lumx-typography-title
4
+ */
5
+ function typography(typo) {
6
+ return `lumx-typography-${typo}`;
7
+ }
8
+
9
+ export { typography };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Visually hidden class name.
3
+ * Used to hide elements from view but keep them readable from screen readers
4
+ */
5
+ export declare const visuallyHidden: () => string;
@@ -0,0 +1,10 @@
1
+ import '../../../constants/enums/index.js';
2
+ import { VISUALLY_HIDDEN } from '../../../constants/className/index.js';
3
+
4
+ /**
5
+ * Visually hidden class name.
6
+ * Used to hide elements from view but keep them readable from screen readers
7
+ */
8
+ const visuallyHidden = () => VISUALLY_HIDDEN;
9
+
10
+ export { visuallyHidden };
@@ -0,0 +1,2 @@
1
+ export * from './keyboard';
2
+ export * from './swipe';
@@ -0,0 +1,2 @@
1
+ export { onButtonPressed, onEnterPressed, onEscapePressed } from './keyboard.js';
2
+ export { detectHorizontalSwipe } from './swipe.js';
@@ -0,0 +1,24 @@
1
+ import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
2
+ type KeyboardEventHandler<E extends KeyboardEvent | ReactKeyboardEvent> = (event: E) => void;
3
+ /**
4
+ * Make sure the pressed key is the enter key before calling the callback.
5
+ *
6
+ * @param handler The handler to call on enter/return press.
7
+ * @return The decorated function.
8
+ */
9
+ export declare function onEnterPressed<E extends KeyboardEvent | ReactKeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
10
+ /**
11
+ * Make sure the pressed key is the escape key before calling the callback.
12
+ *
13
+ * @param handler The handler to call on enter/return press.
14
+ * @return The decorated function.
15
+ */
16
+ export declare function onEscapePressed<E extends KeyboardEvent | ReactKeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
17
+ /**
18
+ * Handle button key pressed (Enter + Space).
19
+ *
20
+ * @param handler The handler to call.
21
+ * @return The decorated function.
22
+ */
23
+ export declare function onButtonPressed<E extends KeyboardEvent | ReactKeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
24
+ export {};