@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.
- package/js/constants/design-tokens.js +5389 -2294
- package/js/constants/index.js +107 -134
- package/js/constants/keycodes.js +9 -13
- package/js/custom-colors.js +17 -22
- package/js/types/Callback.js +0 -1
- package/js/types/Falsy.js +0 -1
- package/js/types/GenericProps.js +0 -1
- package/js/types/HasAriaLabelOrLabelledBy.js +0 -1
- package/js/types/HasClassName.js +0 -1
- package/js/types/HasCloseMode.js +0 -1
- package/js/types/HasTheme.js +0 -1
- package/js/types/HeadingElement.js +0 -1
- package/js/types/Point.js +0 -1
- package/js/types/Predicate.js +0 -1
- package/js/types/RectSize.js +0 -1
- package/js/types/TextElement.js +0 -1
- package/js/types/ValueOf.js +0 -1
- package/js/types/index.js +0 -1
- package/js/utils/className/fontColorClass.js +7 -12
- package/js/utils/className/fontColorClass.test.js +14 -16
- package/js/utils/className/getBasicClass.js +19 -24
- package/js/utils/className/getBasicClass.test.js +55 -19
- package/js/utils/className/getRootClassName.js +10 -17
- package/js/utils/className/getRootClassName.test.js +11 -13
- package/js/utils/className/getTypographyClassName.js +3 -7
- package/js/utils/className/getTypographyClassName.test.js +5 -7
- package/js/utils/className/handleBasicClasses.js +27 -31
- package/js/utils/className/handleBasicClasses.test.js +30 -32
- package/js/utils/className/index.js +12 -25
- package/js/utils/className/resolveColorWithVariants.js +4 -9
- package/js/utils/className/resolveColorWithVariants.test.js +26 -28
- package/js/utils/index.js +161 -174
- package/package.json +1 -3
- package/js/constants/design-tokens.min.js +0 -1
- package/js/constants/index.min.js +0 -1
- package/js/constants/keycodes.min.js +0 -1
- package/js/custom-colors.min.js +0 -1
- package/js/types/Callback.min.js +0 -1
- package/js/types/Falsy.min.js +0 -1
- package/js/types/GenericProps.min.js +0 -1
- package/js/types/HasAriaLabelOrLabelledBy.min.js +0 -1
- package/js/types/HasClassName.min.js +0 -1
- package/js/types/HasCloseMode.min.js +0 -1
- package/js/types/HasTheme.min.js +0 -1
- package/js/types/HeadingElement.min.js +0 -1
- package/js/types/Point.min.js +0 -1
- package/js/types/Predicate.min.js +0 -1
- package/js/types/RectSize.min.js +0 -1
- package/js/types/TextElement.min.js +0 -1
- package/js/types/ValueOf.min.js +0 -1
- package/js/types/index.min.js +0 -1
- package/js/utils/className/fontColorClass.min.js +0 -1
- package/js/utils/className/fontColorClass.test.min.js +0 -1
- package/js/utils/className/getBasicClass.min.js +0 -1
- package/js/utils/className/getBasicClass.test.min.js +0 -1
- package/js/utils/className/getRootClassName.min.js +0 -1
- package/js/utils/className/getRootClassName.test.min.js +0 -1
- package/js/utils/className/getTypographyClassName.min.js +0 -1
- package/js/utils/className/getTypographyClassName.test.min.js +0 -1
- package/js/utils/className/handleBasicClasses.min.js +0 -1
- package/js/utils/className/handleBasicClasses.test.min.js +0 -1
- package/js/utils/className/index.min.js +0 -1
- package/js/utils/className/resolveColorWithVariants.min.js +0 -1
- package/js/utils/className/resolveColorWithVariants.test.min.js +0 -1
- package/js/utils/index.min.js +0 -1
- package/lumx.min.css +0 -1
|
@@ -1,22 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
import { getBasicClass } from './getBasicClass.js';
|
|
2
|
+
import 'lodash/isBoolean';
|
|
3
|
+
import 'lodash/kebabCase';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
26
|
+
export { getRootClassName };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { getRootClassName } from './getRootClassName.js';
|
|
2
|
+
import 'lodash/kebabCase';
|
|
3
|
+
import '../../constants/index.js';
|
|
4
|
+
import '../../constants/keycodes.js';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 =
|
|
10
|
-
|
|
5
|
+
const getTypographyClassName = typography => {
|
|
6
|
+
return `lumx-typography-${typography}`;
|
|
11
7
|
};
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
export { getTypographyClassName };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { getTypographyClassName } from './getTypographyClassName.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
48
|
+
export { handleBasicClasses };
|
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
8
|
+
export { resolveColorWithVariants };
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import { resolveColorWithVariants } from './resolveColorWithVariants.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
});
|