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