@lumx/core 3.20.1-alpha.11 → 3.20.1-alpha.13

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 (66) hide show
  1. package/js/constants/design-tokens.js +5389 -2294
  2. package/js/constants/index.js +107 -134
  3. package/js/constants/keycodes.js +9 -13
  4. package/js/custom-colors.js +17 -22
  5. package/js/types/Callback.js +0 -1
  6. package/js/types/Falsy.js +0 -1
  7. package/js/types/GenericProps.js +0 -1
  8. package/js/types/HasAriaLabelOrLabelledBy.js +0 -1
  9. package/js/types/HasClassName.js +0 -1
  10. package/js/types/HasCloseMode.js +0 -1
  11. package/js/types/HasTheme.js +0 -1
  12. package/js/types/HeadingElement.js +0 -1
  13. package/js/types/Point.js +0 -1
  14. package/js/types/Predicate.js +0 -1
  15. package/js/types/RectSize.js +0 -1
  16. package/js/types/TextElement.js +0 -1
  17. package/js/types/ValueOf.js +0 -1
  18. package/js/types/index.js +0 -1
  19. package/js/utils/className/fontColorClass.js +7 -12
  20. package/js/utils/className/fontColorClass.test.js +14 -16
  21. package/js/utils/className/getBasicClass.js +19 -24
  22. package/js/utils/className/getBasicClass.test.js +55 -19
  23. package/js/utils/className/getRootClassName.js +10 -17
  24. package/js/utils/className/getRootClassName.test.js +11 -13
  25. package/js/utils/className/getTypographyClassName.js +3 -7
  26. package/js/utils/className/getTypographyClassName.test.js +5 -7
  27. package/js/utils/className/handleBasicClasses.js +27 -31
  28. package/js/utils/className/handleBasicClasses.test.js +30 -32
  29. package/js/utils/className/index.js +12 -25
  30. package/js/utils/className/resolveColorWithVariants.js +4 -9
  31. package/js/utils/className/resolveColorWithVariants.test.js +26 -28
  32. package/js/utils/index.js +161 -174
  33. package/package.json +1 -3
  34. package/js/constants/design-tokens.min.js +0 -1
  35. package/js/constants/index.min.js +0 -1
  36. package/js/constants/keycodes.min.js +0 -1
  37. package/js/custom-colors.min.js +0 -1
  38. package/js/types/Callback.min.js +0 -1
  39. package/js/types/Falsy.min.js +0 -1
  40. package/js/types/GenericProps.min.js +0 -1
  41. package/js/types/HasAriaLabelOrLabelledBy.min.js +0 -1
  42. package/js/types/HasClassName.min.js +0 -1
  43. package/js/types/HasCloseMode.min.js +0 -1
  44. package/js/types/HasTheme.min.js +0 -1
  45. package/js/types/HeadingElement.min.js +0 -1
  46. package/js/types/Point.min.js +0 -1
  47. package/js/types/Predicate.min.js +0 -1
  48. package/js/types/RectSize.min.js +0 -1
  49. package/js/types/TextElement.min.js +0 -1
  50. package/js/types/ValueOf.min.js +0 -1
  51. package/js/types/index.min.js +0 -1
  52. package/js/utils/className/fontColorClass.min.js +0 -1
  53. package/js/utils/className/fontColorClass.test.min.js +0 -1
  54. package/js/utils/className/getBasicClass.min.js +0 -1
  55. package/js/utils/className/getBasicClass.test.min.js +0 -1
  56. package/js/utils/className/getRootClassName.min.js +0 -1
  57. package/js/utils/className/getRootClassName.test.min.js +0 -1
  58. package/js/utils/className/getTypographyClassName.min.js +0 -1
  59. package/js/utils/className/getTypographyClassName.test.min.js +0 -1
  60. package/js/utils/className/handleBasicClasses.min.js +0 -1
  61. package/js/utils/className/handleBasicClasses.test.min.js +0 -1
  62. package/js/utils/className/index.min.js +0 -1
  63. package/js/utils/className/resolveColorWithVariants.min.js +0 -1
  64. package/js/utils/className/resolveColorWithVariants.test.min.js +0 -1
  65. package/js/utils/index.min.js +0 -1
  66. package/lumx.min.css +0 -1
@@ -1,22 +1,58 @@
1
- 'use strict';
1
+ import { getBasicClass } from './getBasicClass.js';
2
+ import 'lodash/isBoolean';
3
+ import 'lodash/kebabCase';
2
4
 
3
- var js_utils_className_getBasicClass = require('./getBasicClass.js');
4
- require('lodash/isBoolean');
5
- require('lodash/kebabCase');
5
+ describe(getBasicClass, () => {
6
+ it('should return correct basic CSS class for different types and values', () => {
7
+ // Test cases with different inputs
8
+ expect(getBasicClass({
9
+ prefix: 'test',
10
+ type: 'color',
11
+ value: 'primary'
12
+ })).toBe('test--color-primary');
13
+ expect(getBasicClass({
14
+ prefix: 'test',
15
+ type: 'variant',
16
+ value: 'button'
17
+ })).toBe('test--variant-button');
18
+ expect(getBasicClass({
19
+ prefix: 'test',
20
+ type: 'isDark',
21
+ value: true
22
+ })).toBe('test--is-dark');
23
+ expect(getBasicClass({
24
+ prefix: 'test',
25
+ type: 'dark',
26
+ value: true
27
+ })).toBe('test--is-dark');
28
+ expect(getBasicClass({
29
+ prefix: 'test',
30
+ type: 'hasDark',
31
+ value: true
32
+ })).toBe('test--has-dark');
33
+ expect(getBasicClass({
34
+ prefix: 'test',
35
+ type: 'isActive',
36
+ value: false
37
+ })).toBe('');
6
38
 
7
- describe(js_utils_className_getBasicClass.getBasicClass, () => {
8
- it('should return correct basic CSS class for different types and values', () => {
9
- // Test cases with different inputs
10
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'color', value: 'primary' })).toBe('test--color-primary');
11
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'variant', value: 'button' })).toBe('test--variant-button');
12
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'isDark', value: true })).toBe('test--is-dark');
13
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'dark', value: true })).toBe('test--is-dark');
14
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'hasDark', value: true })).toBe('test--has-dark');
15
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'isActive', value: false })).toBe('');
16
- // Additional tests for boolean types
17
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'hasBorder', value: true })).toBe('test--has-border');
18
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'isVisible', value: false })).toBe('');
19
- // Tests for undefined
20
- expect(js_utils_className_getBasicClass.getBasicClass({ prefix: 'test', type: 'variant', value: undefined })).toBe('test--variant-undefined');
21
- });
39
+ // Additional tests for boolean types
40
+ expect(getBasicClass({
41
+ prefix: 'test',
42
+ type: 'hasBorder',
43
+ value: true
44
+ })).toBe('test--has-border');
45
+ expect(getBasicClass({
46
+ prefix: 'test',
47
+ type: 'isVisible',
48
+ value: false
49
+ })).toBe('');
50
+
51
+ // Tests for undefined
52
+ expect(getBasicClass({
53
+ prefix: 'test',
54
+ type: 'variant',
55
+ value: undefined
56
+ })).toBe('test--variant-undefined');
57
+ });
22
58
  });
@@ -1,17 +1,10 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var kebabCase = require('lodash/kebabCase');
6
- var js_constants_index = require('../../constants/index.js');
7
- require('../../constants/keycodes.js');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var kebabCase__default = /*#__PURE__*/_interopDefaultLegacy(kebabCase);
1
+ import kebabCase from 'lodash/kebabCase';
2
+ import { CSS_PREFIX } from '../../constants/index.js';
3
+ import '../../constants/keycodes.js';
12
4
 
13
5
  // See https://regex101.com/r/YjS1uI/3
14
6
  const LAST_PART_CLASSNAME = /^(.*)-(.+)$/gi;
7
+
15
8
  /**
16
9
  * Get the name of the root CSS class of a component based on its name.
17
10
  *
@@ -23,11 +16,11 @@ const LAST_PART_CLASSNAME = /^(.*)-(.+)$/gi;
23
16
  * lower-snake-case.
24
17
  */
25
18
  function getRootClassName(componentName, subComponent) {
26
- const formattedClassName = `${js_constants_index.CSS_PREFIX}-${kebabCase__default["default"](componentName)}`;
27
- if (subComponent) {
28
- return formattedClassName.replace(LAST_PART_CLASSNAME, '$1__$2');
29
- }
30
- return formattedClassName;
19
+ const formattedClassName = `${CSS_PREFIX}-${kebabCase(componentName)}`;
20
+ if (subComponent) {
21
+ return formattedClassName.replace(LAST_PART_CLASSNAME, '$1__$2');
22
+ }
23
+ return formattedClassName;
31
24
  }
32
25
 
33
- exports.getRootClassName = getRootClassName;
26
+ export { getRootClassName };
@@ -1,15 +1,13 @@
1
- 'use strict';
1
+ import { getRootClassName } from './getRootClassName.js';
2
+ import 'lodash/kebabCase';
3
+ import '../../constants/index.js';
4
+ import '../../constants/keycodes.js';
2
5
 
3
- var js_utils_className_getRootClassName = require('./getRootClassName.js');
4
- require('lodash/kebabCase');
5
- require('../../constants/index.js');
6
- require('../../constants/keycodes.js');
7
-
8
- describe(js_utils_className_getRootClassName.getRootClassName, () => {
9
- it('should transform the component name into a lumx class', () => {
10
- expect(js_utils_className_getRootClassName.getRootClassName('Table')).toBe('lumx-table');
11
- });
12
- it('should transform the sub component name into a lumx class', () => {
13
- expect(js_utils_className_getRootClassName.getRootClassName('TableBody', true)).toBe('lumx-table__body');
14
- });
6
+ describe(getRootClassName, () => {
7
+ it('should transform the component name into a lumx class', () => {
8
+ expect(getRootClassName('Table')).toBe('lumx-table');
9
+ });
10
+ it('should transform the sub component name into a lumx class', () => {
11
+ expect(getRootClassName('TableBody', true)).toBe('lumx-table__body');
12
+ });
15
13
  });
@@ -1,13 +1,9 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
1
  /**
6
2
  * Returns the classname associated to the given typography.
7
3
  * For example, for `Typography.title` it returns `lumx-typography-title`
8
4
  */
9
- const getTypographyClassName = (typography) => {
10
- return `lumx-typography-${typography}`;
5
+ const getTypographyClassName = typography => {
6
+ return `lumx-typography-${typography}`;
11
7
  };
12
8
 
13
- exports.getTypographyClassName = getTypographyClassName;
9
+ export { getTypographyClassName };
@@ -1,9 +1,7 @@
1
- 'use strict';
1
+ import { getTypographyClassName } from './getTypographyClassName.js';
2
2
 
3
- var js_utils_className_getTypographyClassName = require('./getTypographyClassName.js');
4
-
5
- describe(js_utils_className_getTypographyClassName.getTypographyClassName, () => {
6
- it('should generate lumx typography class', () => {
7
- expect(js_utils_className_getTypographyClassName.getTypographyClassName('title')).toBe('lumx-typography-title');
8
- });
3
+ describe(getTypographyClassName, () => {
4
+ it('should generate lumx typography class', () => {
5
+ expect(getTypographyClassName('title')).toBe('lumx-typography-title');
6
+ });
9
7
  });
@@ -1,18 +1,8 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var classNames = require('classnames');
6
- var isBoolean = require('lodash/isBoolean');
7
- var isEmpty = require('lodash/isEmpty');
8
- var js_utils_className_getBasicClass = require('./getBasicClass.js');
9
- require('lodash/kebabCase');
10
-
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
-
13
- var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
14
- var isBoolean__default = /*#__PURE__*/_interopDefaultLegacy(isBoolean);
15
- var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
1
+ import classNames from 'classnames';
2
+ import isBoolean from 'lodash/isBoolean';
3
+ import isEmpty from 'lodash/isEmpty';
4
+ import { getBasicClass } from './getBasicClass.js';
5
+ import 'lodash/kebabCase';
16
6
 
17
7
  /**
18
8
  * Enhance isEmpty method to also works with numbers.
@@ -20,12 +10,13 @@ var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
20
10
  * @param value The value to check.
21
11
  * @return Whether the input value is empty or != 0.
22
12
  */
23
- const _isEmpty = (value) => {
24
- if (typeof value === 'number') {
25
- return value === 0;
26
- }
27
- return isEmpty__default["default"](value);
13
+ const _isEmpty = value => {
14
+ if (typeof value === 'number') {
15
+ return value === 0;
16
+ }
17
+ return isEmpty(value);
28
18
  };
19
+
29
20
  /**
30
21
  * Return all basic LumX CSS classes which are available for every components.
31
22
  *
@@ -37,16 +28,21 @@ const _isEmpty = (value) => {
37
28
  * be used in the classname to represent the value of the given prop.
38
29
  * @return All LumX basic CSS classes.
39
30
  */
40
- function handleBasicClasses({ prefix, ...props }) {
41
- const otherClasses = {};
42
- if (!isEmpty__default["default"](props)) {
43
- Object.keys(props).forEach((prop) => {
44
- otherClasses[js_utils_className_getBasicClass.getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean__default["default"](props[prop])
45
- ? props[prop]
46
- : !_isEmpty(props[prop]);
47
- });
48
- }
49
- return classNames__default["default"](prefix, otherClasses);
31
+ function handleBasicClasses({
32
+ prefix,
33
+ ...props
34
+ }) {
35
+ const otherClasses = {};
36
+ if (!isEmpty(props)) {
37
+ Object.keys(props).forEach(prop => {
38
+ otherClasses[getBasicClass({
39
+ prefix,
40
+ type: prop,
41
+ value: props[prop]
42
+ })] = isBoolean(props[prop]) ? props[prop] : !_isEmpty(props[prop]);
43
+ });
44
+ }
45
+ return classNames(prefix, otherClasses);
50
46
  }
51
47
 
52
- exports.handleBasicClasses = handleBasicClasses;
48
+ export { handleBasicClasses };
@@ -1,35 +1,33 @@
1
- 'use strict';
1
+ import { handleBasicClasses } from './handleBasicClasses.js';
2
+ import 'classnames';
3
+ import 'lodash/isBoolean';
4
+ import 'lodash/isEmpty';
5
+ import './getBasicClass.js';
6
+ import 'lodash/kebabCase';
2
7
 
3
- var js_utils_className_handleBasicClasses = require('./handleBasicClasses.js');
4
- require('classnames');
5
- require('lodash/isBoolean');
6
- require('lodash/isEmpty');
7
- require('./getBasicClass.js');
8
- require('lodash/kebabCase');
9
-
10
- describe(js_utils_className_handleBasicClasses.handleBasicClasses, () => {
11
- it('should return correct combined CSS classes based on props', () => {
12
- const className = js_utils_className_handleBasicClasses.handleBasicClasses({
13
- prefix: 'test',
14
- // Undefined
15
- undefined,
16
- // Null
17
- null: null,
18
- // Empty string
19
- emptyString: '',
20
- // Empty array
21
- emptyArray: [],
22
- // Empty object
23
- emptyObject: {},
24
- // String
25
- color: 'red',
26
- // False property
27
- isDisabled: false,
28
- // Boolean without a prefix (is or has)
29
- visible: true,
30
- // Has prefix
31
- hasButton: true,
32
- });
33
- expect(className).toBe('test test--color-red test--is-visible test--has-button');
8
+ describe(handleBasicClasses, () => {
9
+ it('should return correct combined CSS classes based on props', () => {
10
+ const className = handleBasicClasses({
11
+ prefix: 'test',
12
+ // Undefined
13
+ undefined,
14
+ // Null
15
+ null: null,
16
+ // Empty string
17
+ emptyString: '',
18
+ // Empty array
19
+ emptyArray: [],
20
+ // Empty object
21
+ emptyObject: {},
22
+ // String
23
+ color: 'red',
24
+ // False property
25
+ isDisabled: false,
26
+ // Boolean without a prefix (is or has)
27
+ visible: true,
28
+ // Has prefix
29
+ hasButton: true
34
30
  });
31
+ expect(className).toBe('test test--color-red test--is-visible test--has-button');
32
+ });
35
33
  });
@@ -1,25 +1,12 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var js_utils_className_handleBasicClasses = require('./handleBasicClasses.js');
6
- var js_utils_className_getBasicClass = require('./getBasicClass.js');
7
- var js_utils_className_getRootClassName = require('./getRootClassName.js');
8
- var js_utils_className_getTypographyClassName = require('./getTypographyClassName.js');
9
- var js_utils_className_fontColorClass = require('./fontColorClass.js');
10
- var js_utils_className_resolveColorWithVariants = require('./resolveColorWithVariants.js');
11
- require('classnames');
12
- require('lodash/isBoolean');
13
- require('lodash/isEmpty');
14
- require('lodash/kebabCase');
15
- require('../../constants/index.js');
16
- require('../../constants/keycodes.js');
17
-
18
-
19
-
20
- exports.handleBasicClasses = js_utils_className_handleBasicClasses.handleBasicClasses;
21
- exports.getBasicClass = js_utils_className_getBasicClass.getBasicClass;
22
- exports.getRootClassName = js_utils_className_getRootClassName.getRootClassName;
23
- exports.getTypographyClassName = js_utils_className_getTypographyClassName.getTypographyClassName;
24
- exports.fontColorClass = js_utils_className_fontColorClass.fontColorClass;
25
- exports.resolveColorWithVariants = js_utils_className_resolveColorWithVariants.resolveColorWithVariants;
1
+ export { handleBasicClasses } from './handleBasicClasses.js';
2
+ export { getBasicClass } from './getBasicClass.js';
3
+ export { getRootClassName } from './getRootClassName.js';
4
+ export { getTypographyClassName } from './getTypographyClassName.js';
5
+ export { fontColorClass } from './fontColorClass.js';
6
+ export { resolveColorWithVariants } from './resolveColorWithVariants.js';
7
+ import 'classnames';
8
+ import 'lodash/isBoolean';
9
+ import 'lodash/isEmpty';
10
+ import 'lodash/kebabCase';
11
+ import '../../constants/index.js';
12
+ import '../../constants/keycodes.js';
@@ -1,13 +1,8 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
1
  /** Resolve color & color variant from a `ColorWithVariants` and optionally a `ColorVariant`. */
6
2
  function resolveColorWithVariants(colorWithVariants, colorVariant) {
7
- if (!colorWithVariants)
8
- return [undefined, colorVariant];
9
- const [color, baseColorVariant] = colorWithVariants.split('-');
10
- return [color, (colorVariant || baseColorVariant)];
3
+ if (!colorWithVariants) return [undefined, colorVariant];
4
+ const [color, baseColorVariant] = colorWithVariants.split('-');
5
+ return [color, colorVariant || baseColorVariant];
11
6
  }
12
7
 
13
- exports.resolveColorWithVariants = resolveColorWithVariants;
8
+ export { resolveColorWithVariants };
@@ -1,30 +1,28 @@
1
- 'use strict';
1
+ import { resolveColorWithVariants } from './resolveColorWithVariants.js';
2
2
 
3
- var js_utils_className_resolveColorWithVariants = require('./resolveColorWithVariants.js');
4
-
5
- describe(js_utils_className_resolveColorWithVariants.resolveColorWithVariants, () => {
6
- it('should handle undefined color', () => {
7
- const result = js_utils_className_resolveColorWithVariants.resolveColorWithVariants(undefined);
8
- expect(result).toEqual([undefined, undefined]);
9
- });
10
- it('should handle undefined color with variant', () => {
11
- const result = js_utils_className_resolveColorWithVariants.resolveColorWithVariants(undefined, 'L2');
12
- expect(result).toEqual([undefined, 'L2']);
13
- });
14
- it('should handle color with undefined variant', () => {
15
- const result = js_utils_className_resolveColorWithVariants.resolveColorWithVariants('primary');
16
- expect(result).toEqual(['primary', undefined]);
17
- });
18
- it('should handle color & variant separated', () => {
19
- const result = js_utils_className_resolveColorWithVariants.resolveColorWithVariants('primary', 'L2');
20
- expect(result).toEqual(['primary', 'L2']);
21
- });
22
- it('should handle color with variant all in one', () => {
23
- const result = js_utils_className_resolveColorWithVariants.resolveColorWithVariants('primary-L2');
24
- expect(result).toEqual(['primary', 'L2']);
25
- });
26
- it('should override color variant with the given color variant', () => {
27
- const result = js_utils_className_resolveColorWithVariants.resolveColorWithVariants('primary-L2', 'D2');
28
- expect(result).toEqual(['primary', 'D2']);
29
- });
3
+ describe(resolveColorWithVariants, () => {
4
+ it('should handle undefined color', () => {
5
+ const result = resolveColorWithVariants(undefined);
6
+ expect(result).toEqual([undefined, undefined]);
7
+ });
8
+ it('should handle undefined color with variant', () => {
9
+ const result = resolveColorWithVariants(undefined, 'L2');
10
+ expect(result).toEqual([undefined, 'L2']);
11
+ });
12
+ it('should handle color with undefined variant', () => {
13
+ const result = resolveColorWithVariants('primary');
14
+ expect(result).toEqual(['primary', undefined]);
15
+ });
16
+ it('should handle color & variant separated', () => {
17
+ const result = resolveColorWithVariants('primary', 'L2');
18
+ expect(result).toEqual(['primary', 'L2']);
19
+ });
20
+ it('should handle color with variant all in one', () => {
21
+ const result = resolveColorWithVariants('primary-L2');
22
+ expect(result).toEqual(['primary', 'L2']);
23
+ });
24
+ it('should override color variant with the given color variant', () => {
25
+ const result = resolveColorWithVariants('primary-L2', 'D2');
26
+ expect(result).toEqual(['primary', 'D2']);
27
+ });
30
28
  });