@lumx/core 3.10.1-alpha.7 → 3.11.0
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 +64 -64
- 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 +354 -340
- package/js/custom-colors.min.js +1 -1
- package/js/custom-colors.min.js.map +1 -1
- package/js/date-picker.js +1550 -763
- 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 +2493 -1825
- package/js/utils.min.js +1 -1
- package/js/utils.min.js.map +1 -1
- package/js/utils.ts +35 -29
- 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
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
import React from 'react';
|
|
2
4
|
|
|
3
|
-
import
|
|
5
|
+
import isBoolean from 'lodash/isBoolean';
|
|
6
|
+
import isEmpty from 'lodash/isEmpty';
|
|
7
|
+
import kebabCase from 'lodash/kebabCase';
|
|
8
|
+
import noop from 'lodash/noop';
|
|
4
9
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Enhance isEmpty method to also works with numbers.
|
|
12
|
+
*
|
|
13
|
+
* @param value The value to check.
|
|
14
|
+
* @return Whether the input value is empty or != 0.
|
|
15
|
+
*/
|
|
16
|
+
const _isEmpty = (value: any) => {
|
|
17
|
+
if (typeof value === 'number') {
|
|
18
|
+
return value === 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return isEmpty(value);
|
|
22
|
+
};
|
|
9
23
|
|
|
10
24
|
/**
|
|
11
25
|
* Get the basic CSS class for the given type.
|
|
@@ -22,9 +36,9 @@ export function getBasicClass({
|
|
|
22
36
|
}: {
|
|
23
37
|
prefix: string;
|
|
24
38
|
type: string;
|
|
25
|
-
value: string | number | boolean | undefined
|
|
39
|
+
value: string | number | boolean | undefined;
|
|
26
40
|
}): string {
|
|
27
|
-
if (
|
|
41
|
+
if (isBoolean(value)) {
|
|
28
42
|
if (!value) {
|
|
29
43
|
// False value should not return a class.
|
|
30
44
|
return '';
|
|
@@ -32,13 +46,13 @@ export function getBasicClass({
|
|
|
32
46
|
const booleanPrefixes = ['has', 'is'];
|
|
33
47
|
|
|
34
48
|
if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {
|
|
35
|
-
return `${prefix}--${
|
|
49
|
+
return `${prefix}--${kebabCase(type)}`;
|
|
36
50
|
}
|
|
37
51
|
|
|
38
|
-
return `${prefix}--is-${
|
|
52
|
+
return `${prefix}--is-${kebabCase(type)}`;
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
return `${prefix}--${
|
|
55
|
+
return `${prefix}--${kebabCase(type)}-${value}`;
|
|
42
56
|
}
|
|
43
57
|
|
|
44
58
|
/**
|
|
@@ -52,22 +66,14 @@ export function getBasicClass({
|
|
|
52
66
|
* be used in the classname to represent the value of the given prop.
|
|
53
67
|
* @return All LumX basic CSS classes.
|
|
54
68
|
*/
|
|
55
|
-
export function handleBasicClasses({
|
|
56
|
-
prefix,
|
|
57
|
-
...props
|
|
58
|
-
}: {
|
|
59
|
-
prefix: string;
|
|
60
|
-
[prop: string]: string | number | boolean | null | undefined;
|
|
61
|
-
}): string {
|
|
69
|
+
export function handleBasicClasses({ prefix, ...props }: { prefix: string; [prop: string]: any }): string {
|
|
62
70
|
const otherClasses: any = {};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
+
if (!isEmpty(props)) {
|
|
72
|
+
Object.keys(props).forEach((prop) => {
|
|
73
|
+
otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])
|
|
74
|
+
? props[prop]
|
|
75
|
+
: !_isEmpty(props[prop]);
|
|
76
|
+
});
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
return classNames(prefix, otherClasses);
|
|
@@ -84,7 +90,7 @@ declare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';
|
|
|
84
90
|
* @param handleSwipe Callback function.
|
|
85
91
|
* @return Function to remove listeners.
|
|
86
92
|
*/
|
|
87
|
-
export function detectSwipe(touchSurface: Element, handleSwipe
|
|
93
|
+
export function detectSwipe(touchSurface: Element, handleSwipe: (direction: SwipeDirection) => void = noop) {
|
|
88
94
|
let distX: number;
|
|
89
95
|
let distY: number;
|
|
90
96
|
let startX: number;
|
|
@@ -135,7 +141,7 @@ export function detectSwipe(touchSurface: Element, handleSwipe?: (direction: Swi
|
|
|
135
141
|
direction = distY < 0 ? 'up' : 'down';
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
|
-
handleSwipe
|
|
144
|
+
handleSwipe(direction);
|
|
139
145
|
evt.preventDefault();
|
|
140
146
|
};
|
|
141
147
|
|
|
@@ -162,8 +168,8 @@ function isPassiveEventAvailable() {
|
|
|
162
168
|
supportsPassiveOption = true;
|
|
163
169
|
},
|
|
164
170
|
});
|
|
165
|
-
window.addEventListener('testPassiveEventSupport',
|
|
166
|
-
window.removeEventListener('testPassiveEventSupport',
|
|
171
|
+
window.addEventListener('testPassiveEventSupport', noop, opts);
|
|
172
|
+
window.removeEventListener('testPassiveEventSupport', noop, opts);
|
|
167
173
|
} catch (e) {
|
|
168
174
|
// ignored
|
|
169
175
|
}
|