@lumx/core 3.21.1 → 3.21.2-alpha.1
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/CONTRIBUTING.md +1 -5
- package/js/constants/components/index.d.ts +24 -0
- package/js/constants/components/index.js +26 -0
- package/js/constants/enums/index.d.ts +200 -0
- package/js/constants/enums/index.js +155 -0
- package/js/constants/index.d.ts +3 -0
- package/js/constants/index.js +3 -218
- package/js/constants/keycodes/index.d.ts +36 -0
- package/js/constants/{keycodes.js → keycodes/index.js} +1 -13
- package/js/types/{GenericProps.ts → GenericProps.d.ts} +0 -1
- package/js/types/HasAriaLabelOrLabelledBy.d.ts +17 -0
- package/js/types/{HasTheme.ts → HasTheme.d.ts} +0 -1
- package/js/types/KebabCase.d.ts +2 -0
- package/js/types/LumxClassName.d.ts +3 -0
- package/js/types/Point.d.ts +7 -0
- package/js/types/RectSize.d.ts +7 -0
- package/js/types/{TextElement.ts → TextElement.d.ts} +0 -1
- package/js/types/{index.ts → index.d.ts} +1 -0
- package/js/types/index.js +0 -1
- package/js/utils/events/index.d.ts +2 -0
- package/js/utils/events/index.js +2 -0
- package/js/utils/events/keyboard.d.ts +24 -0
- package/js/utils/events/keyboard.js +44 -0
- package/js/utils/events/swipe.d.ts +6 -0
- package/js/utils/events/swipe.js +79 -0
- package/js/utils/index.d.ts +1 -0
- package/js/utils/index.js +2 -223
- package/lumx.css +7 -6
- package/package.json +11 -11
- package/scss/components/list/_index.scss +10 -4
- package/js/constants/design-tokens.js +0 -2329
- package/js/constants/design-tokens.min.js +0 -1
- package/js/constants/design-tokens.ts +0 -2324
- package/js/constants/index.min.js +0 -1
- package/js/constants/index.ts +0 -231
- package/js/constants/keycodes.min.js +0 -1
- package/js/constants/keycodes.ts +0 -44
- package/js/custom-colors.js +0 -48
- package/js/custom-colors.min.js +0 -1
- package/js/custom-colors.ts +0 -56
- package/js/date-picker.js +0 -71
- package/js/date-picker.min.js +0 -1
- package/js/date-picker.ts +0 -77
- package/js/types/Callback.js +0 -2
- package/js/types/Callback.min.js +0 -1
- package/js/types/Falsy.js +0 -2
- package/js/types/Falsy.min.js +0 -1
- package/js/types/GenericProps.js +0 -2
- package/js/types/GenericProps.min.js +0 -1
- package/js/types/HasAriaLabelOrLabelledBy.js +0 -2
- package/js/types/HasAriaLabelOrLabelledBy.min.js +0 -1
- package/js/types/HasAriaLabelOrLabelledBy.ts +0 -19
- package/js/types/HasClassName.js +0 -2
- package/js/types/HasClassName.min.js +0 -1
- package/js/types/HasCloseMode.js +0 -2
- package/js/types/HasCloseMode.min.js +0 -1
- package/js/types/HasTheme.js +0 -2
- package/js/types/HasTheme.min.js +0 -1
- package/js/types/HeadingElement.js +0 -2
- package/js/types/HeadingElement.min.js +0 -1
- package/js/types/Point.js +0 -2
- package/js/types/Point.min.js +0 -1
- package/js/types/Point.ts +0 -4
- package/js/types/Predicate.js +0 -2
- package/js/types/Predicate.min.js +0 -1
- package/js/types/RectSize.js +0 -2
- package/js/types/RectSize.min.js +0 -1
- package/js/types/RectSize.ts +0 -4
- package/js/types/TextElement.js +0 -2
- package/js/types/TextElement.min.js +0 -1
- package/js/types/ValueOf.js +0 -2
- package/js/types/ValueOf.min.js +0 -1
- package/js/types/index.min.js +0 -1
- package/js/utils/className/fontColorClass.js +0 -20
- package/js/utils/className/fontColorClass.min.js +0 -1
- package/js/utils/className/fontColorClass.test.js +0 -18
- package/js/utils/className/fontColorClass.test.min.js +0 -1
- package/js/utils/className/fontColorClass.test.ts +0 -15
- package/js/utils/className/fontColorClass.ts +0 -12
- package/js/utils/className/getBasicClass.js +0 -36
- package/js/utils/className/getBasicClass.min.js +0 -1
- package/js/utils/className/getBasicClass.test.js +0 -22
- package/js/utils/className/getBasicClass.test.min.js +0 -1
- package/js/utils/className/getBasicClass.test.ts +0 -20
- package/js/utils/className/getBasicClass.ts +0 -36
- package/js/utils/className/getRootClassName.js +0 -33
- package/js/utils/className/getRootClassName.min.js +0 -1
- package/js/utils/className/getRootClassName.test.js +0 -15
- package/js/utils/className/getRootClassName.test.min.js +0 -1
- package/js/utils/className/getRootClassName.test.ts +0 -11
- package/js/utils/className/getRootClassName.ts +0 -25
- package/js/utils/className/getTypographyClassName.js +0 -13
- package/js/utils/className/getTypographyClassName.min.js +0 -1
- package/js/utils/className/getTypographyClassName.test.js +0 -9
- package/js/utils/className/getTypographyClassName.test.min.js +0 -1
- package/js/utils/className/getTypographyClassName.test.ts +0 -7
- package/js/utils/className/getTypographyClassName.ts +0 -9
- package/js/utils/className/handleBasicClasses.js +0 -52
- package/js/utils/className/handleBasicClasses.min.js +0 -1
- package/js/utils/className/handleBasicClasses.test.js +0 -35
- package/js/utils/className/handleBasicClasses.test.min.js +0 -1
- package/js/utils/className/handleBasicClasses.test.ts +0 -28
- package/js/utils/className/handleBasicClasses.ts +0 -44
- package/js/utils/className/index.js +0 -25
- package/js/utils/className/index.min.js +0 -1
- package/js/utils/className/index.ts +0 -6
- package/js/utils/className/resolveColorWithVariants.js +0 -13
- package/js/utils/className/resolveColorWithVariants.min.js +0 -1
- package/js/utils/className/resolveColorWithVariants.test.js +0 -30
- package/js/utils/className/resolveColorWithVariants.test.min.js +0 -1
- package/js/utils/className/resolveColorWithVariants.test.ts +0 -33
- package/js/utils/className/resolveColorWithVariants.ts +0 -11
- package/js/utils/index.min.js +0 -1
- package/js/utils/index.ts +0 -221
- package/lumx.min.css +0 -1
- /package/js/types/{Callback.ts → Callback.d.ts} +0 -0
- /package/js/types/{Falsy.ts → Falsy.d.ts} +0 -0
- /package/js/types/{HasClassName.ts → HasClassName.d.ts} +0 -0
- /package/js/types/{HasCloseMode.ts → HasCloseMode.d.ts} +0 -0
- /package/js/types/{HeadingElement.ts → HeadingElement.d.ts} +0 -0
- /package/js/types/{Predicate.ts → Predicate.d.ts} +0 -0
- /package/js/types/{ValueOf.ts → ValueOf.d.ts} +0 -0
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* The down key code.
|
|
7
3
|
*/
|
|
@@ -39,12 +35,4 @@ const UP_KEY_CODE = 38;
|
|
|
39
35
|
*/
|
|
40
36
|
const BACKSPACE_KEY_CODE = 8;
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
exports.DOWN_KEY_CODE = DOWN_KEY_CODE;
|
|
44
|
-
exports.ENTER_KEY_CODE = ENTER_KEY_CODE;
|
|
45
|
-
exports.ESCAPE_KEY_CODE = ESCAPE_KEY_CODE;
|
|
46
|
-
exports.LEFT_KEY_CODE = LEFT_KEY_CODE;
|
|
47
|
-
exports.RIGHT_KEY_CODE = RIGHT_KEY_CODE;
|
|
48
|
-
exports.SPACE_KEY_CODE = SPACE_KEY_CODE;
|
|
49
|
-
exports.TAB_KEY_CODE = TAB_KEY_CODE;
|
|
50
|
-
exports.UP_KEY_CODE = UP_KEY_CODE;
|
|
38
|
+
export { BACKSPACE_KEY_CODE, DOWN_KEY_CODE, ENTER_KEY_CODE, ESCAPE_KEY_CODE, LEFT_KEY_CODE, RIGHT_KEY_CODE, SPACE_KEY_CODE, TAB_KEY_CODE, UP_KEY_CODE };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Require either `aria-label` or `arial-labelledby` prop.
|
|
3
|
+
* If none are set, the order will prioritize `aria-labelledby` over `aria-label` as it
|
|
4
|
+
* needs a visible element.
|
|
5
|
+
*/
|
|
6
|
+
export type HasAriaLabelOrLabelledBy<T = string | undefined> = T extends string ? {
|
|
7
|
+
/**
|
|
8
|
+
* The id of the element to use as title of the dialog. Can be within or out of the dialog.
|
|
9
|
+
* Although it is not recommended, aria-label can be used instead if no visible element is available.
|
|
10
|
+
*/
|
|
11
|
+
'aria-labelledby': T;
|
|
12
|
+
/** The label of the dialog. */
|
|
13
|
+
'aria-label'?: undefined;
|
|
14
|
+
} : {
|
|
15
|
+
'aria-label': string;
|
|
16
|
+
'aria-labelledby'?: undefined;
|
|
17
|
+
};
|
package/js/types/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
2
|
+
type KeyboardEventHandler<E extends KeyboardEvent | ReactKeyboardEvent> = (event: E) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Make sure the pressed key is the enter key before calling the callback.
|
|
5
|
+
*
|
|
6
|
+
* @param handler The handler to call on enter/return press.
|
|
7
|
+
* @return The decorated function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function onEnterPressed<E extends KeyboardEvent | ReactKeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
|
|
10
|
+
/**
|
|
11
|
+
* Make sure the pressed key is the escape key before calling the callback.
|
|
12
|
+
*
|
|
13
|
+
* @param handler The handler to call on enter/return press.
|
|
14
|
+
* @return The decorated function.
|
|
15
|
+
*/
|
|
16
|
+
export declare function onEscapePressed<E extends KeyboardEvent | ReactKeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
|
|
17
|
+
/**
|
|
18
|
+
* Handle button key pressed (Enter + Space).
|
|
19
|
+
*
|
|
20
|
+
* @param handler The handler to call.
|
|
21
|
+
* @return The decorated function.
|
|
22
|
+
*/
|
|
23
|
+
export declare function onButtonPressed<E extends KeyboardEvent | ReactKeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make sure the pressed key is the enter key before calling the callback.
|
|
3
|
+
*
|
|
4
|
+
* @param handler The handler to call on enter/return press.
|
|
5
|
+
* @return The decorated function.
|
|
6
|
+
*/
|
|
7
|
+
function onEnterPressed(handler) {
|
|
8
|
+
return (evt) => {
|
|
9
|
+
if (evt.key !== 'Enter') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
handler(evt);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Make sure the pressed key is the escape key before calling the callback.
|
|
17
|
+
*
|
|
18
|
+
* @param handler The handler to call on enter/return press.
|
|
19
|
+
* @return The decorated function.
|
|
20
|
+
*/
|
|
21
|
+
function onEscapePressed(handler) {
|
|
22
|
+
return (evt) => {
|
|
23
|
+
if (evt.key !== 'Escape') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
handler(evt);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Handle button key pressed (Enter + Space).
|
|
31
|
+
*
|
|
32
|
+
* @param handler The handler to call.
|
|
33
|
+
* @return The decorated function.
|
|
34
|
+
*/
|
|
35
|
+
function onButtonPressed(handler) {
|
|
36
|
+
return (evt) => {
|
|
37
|
+
if (evt.key !== 'Enter' && evt.key !== ' ') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
handler(evt);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { onButtonPressed, onEnterPressed, onEscapePressed };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects horizontal swipe direction without blocking the browser scroll using passive event.
|
|
3
|
+
* @see http://javascriptkit.com/javatutors/touchevents2.shtml
|
|
4
|
+
* @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
|
|
5
|
+
*/
|
|
6
|
+
export declare function detectHorizontalSwipe(touchSurface: Element, handleSwipe: (direction: 'right' | 'left') => void): () => void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the browser support passive events.
|
|
3
|
+
* @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js
|
|
4
|
+
*/
|
|
5
|
+
function isPassiveEventAvailable() {
|
|
6
|
+
let supportsPassiveOption = false;
|
|
7
|
+
try {
|
|
8
|
+
const opts = Object.defineProperty({}, 'passive', {
|
|
9
|
+
get() {
|
|
10
|
+
supportsPassiveOption = true;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
window.addEventListener('testPassiveEventSupport', () => { }, opts);
|
|
14
|
+
window.removeEventListener('testPassiveEventSupport', () => { }, opts);
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
// ignored
|
|
18
|
+
}
|
|
19
|
+
return supportsPassiveOption;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Detects horizontal swipe direction without blocking the browser scroll using passive event.
|
|
23
|
+
* @see http://javascriptkit.com/javatutors/touchevents2.shtml
|
|
24
|
+
* @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
|
|
25
|
+
*/
|
|
26
|
+
function detectHorizontalSwipe(touchSurface, handleSwipe) {
|
|
27
|
+
let startX;
|
|
28
|
+
let startY;
|
|
29
|
+
// Required min distance traveled to be considered swipe.
|
|
30
|
+
const threshold = 150;
|
|
31
|
+
// Maximum distance allowed at the same time in perpendicular direction.
|
|
32
|
+
const restraint = 150;
|
|
33
|
+
// Maximum time allowed to travel that distance.
|
|
34
|
+
const allowedTime = 300;
|
|
35
|
+
let elapsedTime;
|
|
36
|
+
let startTime;
|
|
37
|
+
let finished;
|
|
38
|
+
const onTouchStart = (evt) => {
|
|
39
|
+
const [touch] = Array.from(evt.changedTouches);
|
|
40
|
+
startX = touch.pageX;
|
|
41
|
+
startY = touch.pageY;
|
|
42
|
+
// Record time when finger first makes contact with surface.
|
|
43
|
+
startTime = new Date().getTime();
|
|
44
|
+
finished = false;
|
|
45
|
+
};
|
|
46
|
+
const onTouchMove = (evt) => {
|
|
47
|
+
if (finished) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
elapsedTime = new Date().getTime() - startTime;
|
|
51
|
+
if (elapsedTime > allowedTime) {
|
|
52
|
+
// Touch swipe too long to be considered.
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const [touch] = Array.from(evt.changedTouches);
|
|
56
|
+
// Get horizontal dist traveled by finger while in contact with surface.
|
|
57
|
+
const distX = touch.pageX - startX;
|
|
58
|
+
// Get vertical dist traveled by finger while in contact with surface.
|
|
59
|
+
const distY = touch.pageY - startY;
|
|
60
|
+
if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {
|
|
61
|
+
// Swipe is not horizontal.
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// Swipe direction.
|
|
65
|
+
const direction = distX < 0 ? 'left' : 'right';
|
|
66
|
+
handleSwipe(direction);
|
|
67
|
+
finished = true;
|
|
68
|
+
};
|
|
69
|
+
// Activate passive event if possible for better scrolling performance.
|
|
70
|
+
const eventOptions = isPassiveEventAvailable() ? { passive: true } : false;
|
|
71
|
+
touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);
|
|
72
|
+
touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);
|
|
73
|
+
return () => {
|
|
74
|
+
touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);
|
|
75
|
+
touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { detectHorizontalSwipe };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './events';
|
package/js/utils/index.js
CHANGED
|
@@ -1,223 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var noop = require('lodash/noop');
|
|
6
|
-
var js_utils_className_handleBasicClasses = require('./className/handleBasicClasses.js');
|
|
7
|
-
var js_utils_className_getBasicClass = require('./className/getBasicClass.js');
|
|
8
|
-
var js_utils_className_getRootClassName = require('./className/getRootClassName.js');
|
|
9
|
-
var js_utils_className_getTypographyClassName = require('./className/getTypographyClassName.js');
|
|
10
|
-
var js_utils_className_fontColorClass = require('./className/fontColorClass.js');
|
|
11
|
-
var js_utils_className_resolveColorWithVariants = require('./className/resolveColorWithVariants.js');
|
|
12
|
-
require('classnames');
|
|
13
|
-
require('lodash/isBoolean');
|
|
14
|
-
require('lodash/isEmpty');
|
|
15
|
-
require('lodash/kebabCase');
|
|
16
|
-
require('../constants/index.js');
|
|
17
|
-
require('../constants/keycodes.js');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Make sure the pressed key is the enter key before calling the callback.
|
|
25
|
-
*
|
|
26
|
-
* @param handler The handler to call on enter/return press.
|
|
27
|
-
* @return The decorated function.
|
|
28
|
-
*/
|
|
29
|
-
function onEnterPressed(handler) {
|
|
30
|
-
return (evt) => {
|
|
31
|
-
if (evt.key !== 'Enter') {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
handler(evt);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Make sure the pressed key is the escape key before calling the callback.
|
|
39
|
-
*
|
|
40
|
-
* @param handler The handler to call on enter/return press.
|
|
41
|
-
* @return The decorated function.
|
|
42
|
-
*/
|
|
43
|
-
function onEscapePressed(handler) {
|
|
44
|
-
return (evt) => {
|
|
45
|
-
if (evt.key !== 'Escape') {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
handler(evt);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Handle button key pressed (Enter + Space).
|
|
53
|
-
*
|
|
54
|
-
* @param handler The handler to call.
|
|
55
|
-
* @return The decorated function.
|
|
56
|
-
*/
|
|
57
|
-
function onButtonPressed(handler) {
|
|
58
|
-
return (evt) => {
|
|
59
|
-
if (evt.key !== 'Enter' && evt.key !== ' ') {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
handler(evt);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Detects swipe direction.
|
|
67
|
-
* Credits: http://javascriptkit.com/javatutors/touchevents2.shtml.
|
|
68
|
-
*
|
|
69
|
-
* @deprecated use `detectHorizontalSwipe` instead if possible (better performance and does not block scroll)
|
|
70
|
-
* @param touchSurface Element that will hold touch events.
|
|
71
|
-
* @param handleSwipe Callback function.
|
|
72
|
-
* @return Function to remove listeners.
|
|
73
|
-
*/
|
|
74
|
-
function detectSwipe(touchSurface, handleSwipe = noop__default["default"]) {
|
|
75
|
-
let distX;
|
|
76
|
-
let distY;
|
|
77
|
-
let startX;
|
|
78
|
-
let startY;
|
|
79
|
-
let direction;
|
|
80
|
-
// Required min distance traveled to be considered swipe.
|
|
81
|
-
const threshold = 150;
|
|
82
|
-
// Maximum distance allowed at the same time in perpendicular direction.
|
|
83
|
-
const restraint = 100;
|
|
84
|
-
// Maximum time allowed to travel that distance.
|
|
85
|
-
const allowedTime = 300;
|
|
86
|
-
let elapsedTime;
|
|
87
|
-
let startTime;
|
|
88
|
-
const onTouchStart = (evt) => {
|
|
89
|
-
const [touch] = Array.from(evt.changedTouches);
|
|
90
|
-
direction = 'none';
|
|
91
|
-
// Const dist = 0;
|
|
92
|
-
startX = touch.pageX;
|
|
93
|
-
startY = touch.pageY;
|
|
94
|
-
// Record time when finger first makes contact with surface.
|
|
95
|
-
startTime = new Date().getTime();
|
|
96
|
-
evt.preventDefault();
|
|
97
|
-
};
|
|
98
|
-
const onTouchMove = (evt) => {
|
|
99
|
-
// Prevent scrolling when inside DIV.
|
|
100
|
-
evt.preventDefault();
|
|
101
|
-
};
|
|
102
|
-
const onTouchEnd = (evt) => {
|
|
103
|
-
const [touch] = Array.from(evt.changedTouches);
|
|
104
|
-
// Get horizontal dist traveled by finger while in contact with surface.
|
|
105
|
-
distX = touch.pageX - startX;
|
|
106
|
-
// Get vertical dist traveled by finger while in contact with surface.
|
|
107
|
-
distY = touch.pageY - startY;
|
|
108
|
-
// Get time elapsed.
|
|
109
|
-
elapsedTime = new Date().getTime() - startTime;
|
|
110
|
-
if (elapsedTime <= allowedTime) {
|
|
111
|
-
// First condition for awipe met.
|
|
112
|
-
if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {
|
|
113
|
-
// 2nd condition for horizontal swipe met.
|
|
114
|
-
// If dist traveled is negative, it indicates left swipe.
|
|
115
|
-
direction = distX < 0 ? 'left' : 'right';
|
|
116
|
-
}
|
|
117
|
-
else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {
|
|
118
|
-
// 2nd condition for vertical swipe met.
|
|
119
|
-
// If dist traveled is negative, it indicates up swipe.
|
|
120
|
-
direction = distY < 0 ? 'up' : 'down';
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
handleSwipe(direction);
|
|
124
|
-
evt.preventDefault();
|
|
125
|
-
};
|
|
126
|
-
touchSurface.addEventListener('touchstart', onTouchStart, false);
|
|
127
|
-
touchSurface.addEventListener('touchmove', onTouchMove, false);
|
|
128
|
-
touchSurface.addEventListener('touchend', onTouchEnd, false);
|
|
129
|
-
return () => {
|
|
130
|
-
touchSurface.removeEventListener('touchstart', onTouchStart, false);
|
|
131
|
-
touchSurface.removeEventListener('touchmove', onTouchMove, false);
|
|
132
|
-
touchSurface.removeEventListener('touchend', onTouchEnd, false);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Checks whether or not the browser support passive events.
|
|
137
|
-
* @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js
|
|
138
|
-
*/
|
|
139
|
-
function isPassiveEventAvailable() {
|
|
140
|
-
let supportsPassiveOption = false;
|
|
141
|
-
try {
|
|
142
|
-
const opts = Object.defineProperty({}, 'passive', {
|
|
143
|
-
get() {
|
|
144
|
-
supportsPassiveOption = true;
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
window.addEventListener('testPassiveEventSupport', noop__default["default"], opts);
|
|
148
|
-
window.removeEventListener('testPassiveEventSupport', noop__default["default"], opts);
|
|
149
|
-
}
|
|
150
|
-
catch (e) {
|
|
151
|
-
// ignored
|
|
152
|
-
}
|
|
153
|
-
return supportsPassiveOption;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Detects horizontal swipe direction without blocking the browser scroll using passive event.
|
|
157
|
-
* @see http://javascriptkit.com/javatutors/touchevents2.shtml
|
|
158
|
-
* @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
|
|
159
|
-
*/
|
|
160
|
-
function detectHorizontalSwipe(touchSurface, handleSwipe) {
|
|
161
|
-
let startX;
|
|
162
|
-
let startY;
|
|
163
|
-
// Required min distance traveled to be considered swipe.
|
|
164
|
-
const threshold = 150;
|
|
165
|
-
// Maximum distance allowed at the same time in perpendicular direction.
|
|
166
|
-
const restraint = 150;
|
|
167
|
-
// Maximum time allowed to travel that distance.
|
|
168
|
-
const allowedTime = 300;
|
|
169
|
-
let elapsedTime;
|
|
170
|
-
let startTime;
|
|
171
|
-
let finished;
|
|
172
|
-
const onTouchStart = (evt) => {
|
|
173
|
-
const [touch] = Array.from(evt.changedTouches);
|
|
174
|
-
startX = touch.pageX;
|
|
175
|
-
startY = touch.pageY;
|
|
176
|
-
// Record time when finger first makes contact with surface.
|
|
177
|
-
startTime = new Date().getTime();
|
|
178
|
-
finished = false;
|
|
179
|
-
};
|
|
180
|
-
const onTouchMove = (evt) => {
|
|
181
|
-
if (finished) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
elapsedTime = new Date().getTime() - startTime;
|
|
185
|
-
if (elapsedTime > allowedTime) {
|
|
186
|
-
// Touch swipe too long to be considered.
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
const [touch] = Array.from(evt.changedTouches);
|
|
190
|
-
// Get horizontal dist traveled by finger while in contact with surface.
|
|
191
|
-
const distX = touch.pageX - startX;
|
|
192
|
-
// Get vertical dist traveled by finger while in contact with surface.
|
|
193
|
-
const distY = touch.pageY - startY;
|
|
194
|
-
if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {
|
|
195
|
-
// Swipe is not horizontal.
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
// Swipe direction.
|
|
199
|
-
const direction = distX < 0 ? 'left' : 'right';
|
|
200
|
-
handleSwipe(direction);
|
|
201
|
-
finished = true;
|
|
202
|
-
};
|
|
203
|
-
// Activate passive event if possible for better scrolling performance.
|
|
204
|
-
const eventOptions = isPassiveEventAvailable() ? { passive: true } : false;
|
|
205
|
-
touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);
|
|
206
|
-
touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);
|
|
207
|
-
return () => {
|
|
208
|
-
touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);
|
|
209
|
-
touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
exports.handleBasicClasses = js_utils_className_handleBasicClasses.handleBasicClasses;
|
|
214
|
-
exports.getBasicClass = js_utils_className_getBasicClass.getBasicClass;
|
|
215
|
-
exports.getRootClassName = js_utils_className_getRootClassName.getRootClassName;
|
|
216
|
-
exports.getTypographyClassName = js_utils_className_getTypographyClassName.getTypographyClassName;
|
|
217
|
-
exports.fontColorClass = js_utils_className_fontColorClass.fontColorClass;
|
|
218
|
-
exports.resolveColorWithVariants = js_utils_className_resolveColorWithVariants.resolveColorWithVariants;
|
|
219
|
-
exports.detectHorizontalSwipe = detectHorizontalSwipe;
|
|
220
|
-
exports.detectSwipe = detectSwipe;
|
|
221
|
-
exports.onButtonPressed = onButtonPressed;
|
|
222
|
-
exports.onEnterPressed = onEnterPressed;
|
|
223
|
-
exports.onEscapePressed = onEscapePressed;
|
|
1
|
+
export { onButtonPressed, onEnterPressed, onEscapePressed } from './events/keyboard.js';
|
|
2
|
+
export { detectHorizontalSwipe } from './events/swipe.js';
|
package/lumx.css
CHANGED
|
@@ -8733,13 +8733,14 @@ table {
|
|
|
8733
8733
|
|
|
8734
8734
|
/* Item spacing
|
|
8735
8735
|
========================================================================== */
|
|
8736
|
-
.lumx-list--item-padding-big .lumx-list-item__link,
|
|
8737
|
-
.lumx-list
|
|
8736
|
+
.lumx-list:has(.lumx-list-item__link) .lumx-list-item__link, .lumx-list.lumx-list--item-padding-big .lumx-list-item__link,
|
|
8737
|
+
.lumx-list:has(.lumx-list-item__link) .lumx-list-item__wrapper,
|
|
8738
|
+
.lumx-list.lumx-list--item-padding-big .lumx-list-item__wrapper {
|
|
8738
8739
|
padding-right: 16px;
|
|
8739
8740
|
padding-left: 16px;
|
|
8740
8741
|
}
|
|
8741
|
-
.lumx-list--item-padding-huge .lumx-list-item__link,
|
|
8742
|
-
.lumx-list--item-padding-huge .lumx-list-item__wrapper {
|
|
8742
|
+
.lumx-list.lumx-list--item-padding-huge .lumx-list-item__link,
|
|
8743
|
+
.lumx-list.lumx-list--item-padding-huge .lumx-list-item__wrapper {
|
|
8743
8744
|
padding-right: 24px;
|
|
8744
8745
|
padding-left: 24px;
|
|
8745
8746
|
}
|
|
@@ -8772,11 +8773,11 @@ table {
|
|
|
8772
8773
|
line-height: 14px;
|
|
8773
8774
|
margin-right: 8px;
|
|
8774
8775
|
}
|
|
8775
|
-
.lumx-list--item-padding-big .lumx-list-subheader {
|
|
8776
|
+
.lumx-list:has(.lumx-list-item__link) .lumx-list-subheader, .lumx-list.lumx-list--item-padding-big .lumx-list-subheader {
|
|
8776
8777
|
padding-right: 16px;
|
|
8777
8778
|
padding-left: 16px;
|
|
8778
8779
|
}
|
|
8779
|
-
.lumx-list--item-padding-huge .lumx-list-subheader {
|
|
8780
|
+
.lumx-list.lumx-list--item-padding-huge .lumx-list-subheader {
|
|
8780
8781
|
padding-right: 24px;
|
|
8781
8782
|
padding-left: 24px;
|
|
8782
8783
|
}
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"LumX"
|
|
20
20
|
],
|
|
21
21
|
"license": "MIT",
|
|
22
|
+
"type": "module",
|
|
22
23
|
"name": "@lumx/core",
|
|
23
24
|
"publishConfig": {
|
|
24
25
|
"directory": "dist"
|
|
@@ -28,30 +29,29 @@
|
|
|
28
29
|
"url": "git+https://github.com/lumapps/design-system.git"
|
|
29
30
|
},
|
|
30
31
|
"scripts": {
|
|
31
|
-
"generate:design-tokens": "yarn node style-dictionary",
|
|
32
|
+
"generate:design-tokens": "yarn node style-dictionary/index.cjs",
|
|
32
33
|
"build": "rollup -c",
|
|
34
|
+
"test": "vitest run",
|
|
33
35
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
34
36
|
},
|
|
35
37
|
"sideEffects": false,
|
|
36
|
-
"version": "3.21.1",
|
|
38
|
+
"version": "3.21.2-alpha.1",
|
|
37
39
|
"devDependencies": {
|
|
38
|
-
"@rollup/plugin-
|
|
39
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
40
|
-
"@rollup/plugin-typescript": "^12.1.4",
|
|
40
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
41
41
|
"@types/react": "^17.0.2",
|
|
42
42
|
"autoprefixer": "^9.7.4",
|
|
43
43
|
"glob": "^7.1.6",
|
|
44
44
|
"postcss": "^8.5.6",
|
|
45
|
-
"rollup": "^
|
|
45
|
+
"rollup": "^4.53.3",
|
|
46
46
|
"rollup-plugin-cleaner": "^1.0.0",
|
|
47
47
|
"rollup-plugin-copy": "^3.5.0",
|
|
48
48
|
"sass": "^1.54.0",
|
|
49
49
|
"style-dictionary": "^3.9.0",
|
|
50
50
|
"tinycolor2": "^1.4.1",
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
51
|
+
"typescript": "^5.4.3",
|
|
52
|
+
"version-changelog": "^3.1.1",
|
|
53
|
+
"vite": "^6.3.5",
|
|
54
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
55
|
+
"vitest": "^3.0.0"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -52,11 +52,14 @@
|
|
|
52
52
|
|
|
53
53
|
.#{$lumx-base-prefix}-list-item__link,
|
|
54
54
|
.#{$lumx-base-prefix}-list-item__wrapper {
|
|
55
|
-
|
|
55
|
+
// Padding big (defaults when list contain clickable item)
|
|
56
|
+
.#{$lumx-base-prefix}-list:has(.#{$lumx-base-prefix}-list-item__link) &,
|
|
57
|
+
.#{$lumx-base-prefix}-list.#{$lumx-base-prefix}-list--item-padding-big & {
|
|
56
58
|
@include lumx-list-item-padding("big");
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
// Padding huge
|
|
62
|
+
.#{$lumx-base-prefix}-list.#{$lumx-base-prefix}-list--item-padding-huge & {
|
|
60
63
|
@include lumx-list-item-padding("huge");
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -78,11 +81,14 @@
|
|
|
78
81
|
@include lumx-list-subheader-icon;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
// Padding big (defaults when list contain clickable item)
|
|
85
|
+
.#{$lumx-base-prefix}-list:has(.#{$lumx-base-prefix}-list-item__link) &,
|
|
86
|
+
.#{$lumx-base-prefix}-list.#{$lumx-base-prefix}-list--item-padding-big & {
|
|
82
87
|
@include lumx-list-item-padding("big");
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
// Padding huge
|
|
91
|
+
.#{$lumx-base-prefix}-list.#{$lumx-base-prefix}-list--item-padding-huge & {
|
|
86
92
|
@include lumx-list-item-padding("huge");
|
|
87
93
|
}
|
|
88
94
|
}
|