@lumx/core 3.10.1-alpha.6 → 3.10.1-alpha.8
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 +2 -2
- package/js/constants/design-tokens.min.js +1 -1
- package/js/constants/design-tokens.min.js.map +1 -1
- package/js/constants/index.js +4 -4
- package/js/constants/index.min.js +1 -1
- package/js/constants/index.min.js.map +1 -1
- package/js/constants/keycodes.js +2 -2
- package/js/constants/keycodes.min.js +1 -1
- package/js/constants/keycodes.min.js.map +1 -1
- package/js/custom-colors.js +218 -211
- package/js/custom-colors.min.js +1 -1
- package/js/custom-colors.min.js.map +1 -1
- package/js/date-picker.js +1139 -362
- package/js/date-picker.min.js +1 -1
- package/js/date-picker.min.js.map +1 -1
- package/js/date-picker.ts +2 -1
- package/js/utils.js +1419 -1264
- package/js/utils.min.js +1 -1
- package/js/utils.min.js.map +1 -1
- package/js/utils.ts +14 -15
- package/lumx.css +1 -1
- package/lumx.min.css +1 -1
- package/package.json +1 -1
- package/scss/components/popover/_index.scss +1 -0
package/js/utils.ts
CHANGED
|
@@ -2,12 +2,10 @@ import classNames from 'classnames';
|
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
|
+
import isBoolean from 'lodash/isBoolean';
|
|
5
6
|
import isEmpty from 'lodash/isEmpty';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function camelToKebabCase(str: string): string {
|
|
9
|
-
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
10
|
-
}
|
|
7
|
+
import kebabCase from 'lodash/kebabCase';
|
|
8
|
+
import noop from 'lodash/noop';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Enhance isEmpty method to also works with numbers.
|
|
@@ -40,7 +38,7 @@ export function getBasicClass({
|
|
|
40
38
|
type: string;
|
|
41
39
|
value: string | number | boolean | undefined;
|
|
42
40
|
}): string {
|
|
43
|
-
if (
|
|
41
|
+
if (isBoolean(value)) {
|
|
44
42
|
if (!value) {
|
|
45
43
|
// False value should not return a class.
|
|
46
44
|
return '';
|
|
@@ -48,13 +46,13 @@ export function getBasicClass({
|
|
|
48
46
|
const booleanPrefixes = ['has', 'is'];
|
|
49
47
|
|
|
50
48
|
if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {
|
|
51
|
-
return `${prefix}--${
|
|
49
|
+
return `${prefix}--${kebabCase(type)}`;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
return `${prefix}--is-${
|
|
52
|
+
return `${prefix}--is-${kebabCase(type)}`;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
return `${prefix}--${
|
|
55
|
+
return `${prefix}--${kebabCase(type)}-${value}`;
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
/**
|
|
@@ -72,8 +70,9 @@ export function handleBasicClasses({ prefix, ...props }: { prefix: string; [prop
|
|
|
72
70
|
const otherClasses: any = {};
|
|
73
71
|
if (!isEmpty(props)) {
|
|
74
72
|
Object.keys(props).forEach((prop) => {
|
|
75
|
-
otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] =
|
|
76
|
-
|
|
73
|
+
otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])
|
|
74
|
+
? props[prop]
|
|
75
|
+
: !_isEmpty(props[prop]);
|
|
77
76
|
});
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -91,7 +90,7 @@ declare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';
|
|
|
91
90
|
* @param handleSwipe Callback function.
|
|
92
91
|
* @return Function to remove listeners.
|
|
93
92
|
*/
|
|
94
|
-
export function detectSwipe(touchSurface: Element, handleSwipe
|
|
93
|
+
export function detectSwipe(touchSurface: Element, handleSwipe: (direction: SwipeDirection) => void = noop) {
|
|
95
94
|
let distX: number;
|
|
96
95
|
let distY: number;
|
|
97
96
|
let startX: number;
|
|
@@ -142,7 +141,7 @@ export function detectSwipe(touchSurface: Element, handleSwipe?: (direction: Swi
|
|
|
142
141
|
direction = distY < 0 ? 'up' : 'down';
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
|
-
handleSwipe
|
|
144
|
+
handleSwipe(direction);
|
|
146
145
|
evt.preventDefault();
|
|
147
146
|
};
|
|
148
147
|
|
|
@@ -169,8 +168,8 @@ function isPassiveEventAvailable() {
|
|
|
169
168
|
supportsPassiveOption = true;
|
|
170
169
|
},
|
|
171
170
|
});
|
|
172
|
-
window.addEventListener('testPassiveEventSupport',
|
|
173
|
-
window.removeEventListener('testPassiveEventSupport',
|
|
171
|
+
window.addEventListener('testPassiveEventSupport', noop, opts);
|
|
172
|
+
window.removeEventListener('testPassiveEventSupport', noop, opts);
|
|
174
173
|
} catch (e) {
|
|
175
174
|
// ignored
|
|
176
175
|
}
|