@lumx/core 3.20.1-alpha.37 → 3.20.1-alpha.39

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.
Files changed (116) hide show
  1. package/js/constants/design-tokens.d.ts +5421 -0
  2. package/js/constants/design-tokens.js +1 -3
  3. package/js/constants/index.d.ts +232 -0
  4. package/js/constants/index.js +2 -33
  5. package/js/constants/keycodes.d.ts +36 -0
  6. package/js/constants/keycodes.js +1 -11
  7. package/js/custom-colors.d.ts +25 -0
  8. package/js/custom-colors.js +1 -4
  9. package/js/types/Callback.js +0 -1
  10. package/js/types/Falsy.js +0 -1
  11. package/js/types/{GenericProps.ts → GenericProps.d.ts} +0 -1
  12. package/js/types/GenericProps.js +0 -1
  13. package/js/types/HasAriaLabelOrLabelledBy.d.ts +17 -0
  14. package/js/types/HasAriaLabelOrLabelledBy.js +0 -1
  15. package/js/types/HasClassName.js +0 -1
  16. package/js/types/HasCloseMode.js +0 -1
  17. package/js/types/{HasTheme.ts → HasTheme.d.ts} +0 -1
  18. package/js/types/HasTheme.js +0 -1
  19. package/js/types/HeadingElement.js +0 -1
  20. package/js/types/Point.d.ts +7 -0
  21. package/js/types/Point.js +0 -1
  22. package/js/types/Predicate.js +0 -1
  23. package/js/types/RectSize.d.ts +7 -0
  24. package/js/types/RectSize.js +0 -1
  25. package/js/types/{TextElement.ts → TextElement.d.ts} +0 -1
  26. package/js/types/TextElement.js +0 -1
  27. package/js/types/ValueOf.js +0 -1
  28. package/js/types/index.js +0 -1
  29. package/js/utils/className/fontColorClass.d.ts +6 -0
  30. package/js/utils/className/fontColorClass.js +4 -7
  31. package/js/utils/className/getBasicClass.d.ts +13 -0
  32. package/js/utils/className/getBasicClass.js +3 -5
  33. package/js/utils/className/{getRootClassName.ts → getRootClassName.d.ts} +1 -15
  34. package/js/utils/className/getRootClassName.js +4 -7
  35. package/js/utils/className/{getTypographyClassName.ts → getTypographyClassName.d.ts} +1 -4
  36. package/js/utils/className/getTypographyClassName.js +1 -3
  37. package/js/utils/className/handleBasicClasses.d.ts +15 -0
  38. package/js/utils/className/handleBasicClasses.js +6 -9
  39. package/js/utils/className/index.js +6 -23
  40. package/js/utils/className/resolveColorWithVariants.d.ts +3 -0
  41. package/js/utils/className/resolveColorWithVariants.js +1 -3
  42. package/js/utils/events/index.d.ts +2 -0
  43. package/js/utils/events/index.js +2 -0
  44. package/js/utils/events/keyboard.d.ts +24 -0
  45. package/js/utils/events/keyboard.js +44 -0
  46. package/js/utils/events/swipe.d.ts +6 -0
  47. package/js/utils/events/swipe.js +79 -0
  48. package/js/utils/index.d.ts +2 -0
  49. package/js/utils/index.js +8 -217
  50. package/package.json +4 -5
  51. package/js/constants/design-tokens.min.js +0 -1
  52. package/js/constants/design-tokens.ts +0 -2324
  53. package/js/constants/index.min.js +0 -1
  54. package/js/constants/index.ts +0 -231
  55. package/js/constants/keycodes.min.js +0 -1
  56. package/js/constants/keycodes.ts +0 -44
  57. package/js/custom-colors.min.js +0 -1
  58. package/js/custom-colors.ts +0 -56
  59. package/js/types/Callback.min.js +0 -1
  60. package/js/types/Falsy.min.js +0 -1
  61. package/js/types/GenericProps.min.js +0 -1
  62. package/js/types/HasAriaLabelOrLabelledBy.min.js +0 -1
  63. package/js/types/HasAriaLabelOrLabelledBy.ts +0 -19
  64. package/js/types/HasClassName.min.js +0 -1
  65. package/js/types/HasCloseMode.min.js +0 -1
  66. package/js/types/HasTheme.min.js +0 -1
  67. package/js/types/HeadingElement.min.js +0 -1
  68. package/js/types/Point.min.js +0 -1
  69. package/js/types/Point.ts +0 -4
  70. package/js/types/Predicate.min.js +0 -1
  71. package/js/types/RectSize.min.js +0 -1
  72. package/js/types/RectSize.ts +0 -4
  73. package/js/types/TextElement.min.js +0 -1
  74. package/js/types/ValueOf.min.js +0 -1
  75. package/js/types/index.min.js +0 -1
  76. package/js/utils/className/fontColorClass.min.js +0 -1
  77. package/js/utils/className/fontColorClass.test.js +0 -18
  78. package/js/utils/className/fontColorClass.test.min.js +0 -1
  79. package/js/utils/className/fontColorClass.test.ts +0 -15
  80. package/js/utils/className/fontColorClass.ts +0 -12
  81. package/js/utils/className/getBasicClass.min.js +0 -1
  82. package/js/utils/className/getBasicClass.test.js +0 -22
  83. package/js/utils/className/getBasicClass.test.min.js +0 -1
  84. package/js/utils/className/getBasicClass.test.ts +0 -20
  85. package/js/utils/className/getBasicClass.ts +0 -36
  86. package/js/utils/className/getRootClassName.min.js +0 -1
  87. package/js/utils/className/getRootClassName.test.js +0 -15
  88. package/js/utils/className/getRootClassName.test.min.js +0 -1
  89. package/js/utils/className/getRootClassName.test.ts +0 -11
  90. package/js/utils/className/getTypographyClassName.min.js +0 -1
  91. package/js/utils/className/getTypographyClassName.test.js +0 -9
  92. package/js/utils/className/getTypographyClassName.test.min.js +0 -1
  93. package/js/utils/className/getTypographyClassName.test.ts +0 -7
  94. package/js/utils/className/handleBasicClasses.min.js +0 -1
  95. package/js/utils/className/handleBasicClasses.test.js +0 -35
  96. package/js/utils/className/handleBasicClasses.test.min.js +0 -1
  97. package/js/utils/className/handleBasicClasses.test.ts +0 -28
  98. package/js/utils/className/handleBasicClasses.ts +0 -44
  99. package/js/utils/className/index.min.js +0 -1
  100. package/js/utils/className/resolveColorWithVariants.min.js +0 -1
  101. package/js/utils/className/resolveColorWithVariants.test.js +0 -30
  102. package/js/utils/className/resolveColorWithVariants.test.min.js +0 -1
  103. package/js/utils/className/resolveColorWithVariants.test.ts +0 -33
  104. package/js/utils/className/resolveColorWithVariants.ts +0 -11
  105. package/js/utils/index.min.js +0 -1
  106. package/js/utils/index.ts +0 -221
  107. package/lumx.min.css +0 -1
  108. /package/js/types/{Callback.ts → Callback.d.ts} +0 -0
  109. /package/js/types/{Falsy.ts → Falsy.d.ts} +0 -0
  110. /package/js/types/{HasClassName.ts → HasClassName.d.ts} +0 -0
  111. /package/js/types/{HasCloseMode.ts → HasCloseMode.d.ts} +0 -0
  112. /package/js/types/{HeadingElement.ts → HeadingElement.d.ts} +0 -0
  113. /package/js/types/{Predicate.ts → Predicate.d.ts} +0 -0
  114. /package/js/types/{ValueOf.ts → ValueOf.d.ts} +0 -0
  115. /package/js/types/{index.ts → index.d.ts} +0 -0
  116. /package/js/utils/className/{index.ts → index.d.ts} +0 -0
@@ -1,10 +1,7 @@
1
- 'use strict';
2
-
3
- var classNames = require('classnames');
4
- var isBoolean = require('lodash/isBoolean');
5
- var isEmpty = require('lodash/isEmpty');
6
- var js_utils_className_getBasicClass = require('./getBasicClass.js');
7
- require('lodash/kebabCase');
1
+ import classNames from 'classnames';
2
+ import isBoolean from 'lodash/isBoolean';
3
+ import isEmpty from 'lodash/isEmpty';
4
+ import { getBasicClass } from './getBasicClass.js';
8
5
 
9
6
  /**
10
7
  * Enhance isEmpty method to also works with numbers.
@@ -33,7 +30,7 @@ function handleBasicClasses({ prefix, ...props }) {
33
30
  const otherClasses = {};
34
31
  if (!isEmpty(props)) {
35
32
  Object.keys(props).forEach((prop) => {
36
- otherClasses[js_utils_className_getBasicClass.getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])
33
+ otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])
37
34
  ? props[prop]
38
35
  : !_isEmpty(props[prop]);
39
36
  });
@@ -41,4 +38,4 @@ function handleBasicClasses({ prefix, ...props }) {
41
38
  return classNames(prefix, otherClasses);
42
39
  }
43
40
 
44
- exports.handleBasicClasses = handleBasicClasses;
41
+ export { handleBasicClasses };
@@ -1,23 +1,6 @@
1
- 'use strict';
2
-
3
- var js_utils_className_handleBasicClasses = require('./handleBasicClasses.js');
4
- var js_utils_className_getBasicClass = require('./getBasicClass.js');
5
- var js_utils_className_getRootClassName = require('./getRootClassName.js');
6
- var js_utils_className_getTypographyClassName = require('./getTypographyClassName.js');
7
- var js_utils_className_fontColorClass = require('./fontColorClass.js');
8
- var js_utils_className_resolveColorWithVariants = require('./resolveColorWithVariants.js');
9
- require('classnames');
10
- require('lodash/isBoolean');
11
- require('lodash/isEmpty');
12
- require('lodash/kebabCase');
13
- require('../../constants/index.js');
14
- require('../../constants/keycodes.js');
15
-
16
-
17
-
18
- exports.handleBasicClasses = js_utils_className_handleBasicClasses.handleBasicClasses;
19
- exports.getBasicClass = js_utils_className_getBasicClass.getBasicClass;
20
- exports.getRootClassName = js_utils_className_getRootClassName.getRootClassName;
21
- exports.getTypographyClassName = js_utils_className_getTypographyClassName.getTypographyClassName;
22
- exports.fontColorClass = js_utils_className_fontColorClass.fontColorClass;
23
- 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';
@@ -0,0 +1,3 @@
1
+ import { ColorPalette, ColorVariant, ColorWithVariants } from '../../constants';
2
+ /** Resolve color & color variant from a `ColorWithVariants` and optionally a `ColorVariant`. */
3
+ export declare function resolveColorWithVariants(colorWithVariants?: ColorWithVariants, colorVariant?: ColorVariant): [color?: ColorPalette, colorVariant?: ColorVariant];
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  /** Resolve color & color variant from a `ColorWithVariants` and optionally a `ColorVariant`. */
4
2
  function resolveColorWithVariants(colorWithVariants, colorVariant) {
5
3
  if (!colorWithVariants)
@@ -8,4 +6,4 @@ function resolveColorWithVariants(colorWithVariants, colorVariant) {
8
6
  return [color, (colorVariant || baseColorVariant)];
9
7
  }
10
8
 
11
- exports.resolveColorWithVariants = resolveColorWithVariants;
9
+ export { resolveColorWithVariants };
@@ -0,0 +1,2 @@
1
+ export * from './keyboard';
2
+ export * from './swipe';
@@ -0,0 +1,2 @@
1
+ export { onButtonPressed, onEnterPressed, onEscapePressed } from './keyboard.js';
2
+ export { detectHorizontalSwipe } from './swipe.js';
@@ -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,2 @@
1
+ export * from './className';
2
+ export * from './events';
package/js/utils/index.js CHANGED
@@ -1,217 +1,8 @@
1
- 'use strict';
2
-
3
- var noop = require('lodash/noop');
4
- var js_utils_className_handleBasicClasses = require('./className/handleBasicClasses.js');
5
- var js_utils_className_getBasicClass = require('./className/getBasicClass.js');
6
- var js_utils_className_getRootClassName = require('./className/getRootClassName.js');
7
- var js_utils_className_getTypographyClassName = require('./className/getTypographyClassName.js');
8
- var js_utils_className_fontColorClass = require('./className/fontColorClass.js');
9
- var js_utils_className_resolveColorWithVariants = require('./className/resolveColorWithVariants.js');
10
- require('classnames');
11
- require('lodash/isBoolean');
12
- require('lodash/isEmpty');
13
- require('lodash/kebabCase');
14
- require('../constants/index.js');
15
- require('../constants/keycodes.js');
16
-
17
- /**
18
- * Make sure the pressed key is the enter key before calling the callback.
19
- *
20
- * @param handler The handler to call on enter/return press.
21
- * @return The decorated function.
22
- */
23
- function onEnterPressed(handler) {
24
- return (evt) => {
25
- if (evt.key !== 'Enter') {
26
- return;
27
- }
28
- handler(evt);
29
- };
30
- }
31
- /**
32
- * Make sure the pressed key is the escape key before calling the callback.
33
- *
34
- * @param handler The handler to call on enter/return press.
35
- * @return The decorated function.
36
- */
37
- function onEscapePressed(handler) {
38
- return (evt) => {
39
- if (evt.key !== 'Escape') {
40
- return;
41
- }
42
- handler(evt);
43
- };
44
- }
45
- /**
46
- * Handle button key pressed (Enter + Space).
47
- *
48
- * @param handler The handler to call.
49
- * @return The decorated function.
50
- */
51
- function onButtonPressed(handler) {
52
- return (evt) => {
53
- if (evt.key !== 'Enter' && evt.key !== ' ') {
54
- return;
55
- }
56
- handler(evt);
57
- };
58
- }
59
- /**
60
- * Detects swipe direction.
61
- * Credits: http://javascriptkit.com/javatutors/touchevents2.shtml.
62
- *
63
- * @deprecated use `detectHorizontalSwipe` instead if possible (better performance and does not block scroll)
64
- * @param touchSurface Element that will hold touch events.
65
- * @param handleSwipe Callback function.
66
- * @return Function to remove listeners.
67
- */
68
- function detectSwipe(touchSurface, handleSwipe = noop) {
69
- let distX;
70
- let distY;
71
- let startX;
72
- let startY;
73
- let direction;
74
- // Required min distance traveled to be considered swipe.
75
- const threshold = 150;
76
- // Maximum distance allowed at the same time in perpendicular direction.
77
- const restraint = 100;
78
- // Maximum time allowed to travel that distance.
79
- const allowedTime = 300;
80
- let elapsedTime;
81
- let startTime;
82
- const onTouchStart = (evt) => {
83
- const [touch] = Array.from(evt.changedTouches);
84
- direction = 'none';
85
- // Const dist = 0;
86
- startX = touch.pageX;
87
- startY = touch.pageY;
88
- // Record time when finger first makes contact with surface.
89
- startTime = new Date().getTime();
90
- evt.preventDefault();
91
- };
92
- const onTouchMove = (evt) => {
93
- // Prevent scrolling when inside DIV.
94
- evt.preventDefault();
95
- };
96
- const onTouchEnd = (evt) => {
97
- const [touch] = Array.from(evt.changedTouches);
98
- // Get horizontal dist traveled by finger while in contact with surface.
99
- distX = touch.pageX - startX;
100
- // Get vertical dist traveled by finger while in contact with surface.
101
- distY = touch.pageY - startY;
102
- // Get time elapsed.
103
- elapsedTime = new Date().getTime() - startTime;
104
- if (elapsedTime <= allowedTime) {
105
- // First condition for awipe met.
106
- if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {
107
- // 2nd condition for horizontal swipe met.
108
- // If dist traveled is negative, it indicates left swipe.
109
- direction = distX < 0 ? 'left' : 'right';
110
- }
111
- else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {
112
- // 2nd condition for vertical swipe met.
113
- // If dist traveled is negative, it indicates up swipe.
114
- direction = distY < 0 ? 'up' : 'down';
115
- }
116
- }
117
- handleSwipe(direction);
118
- evt.preventDefault();
119
- };
120
- touchSurface.addEventListener('touchstart', onTouchStart, false);
121
- touchSurface.addEventListener('touchmove', onTouchMove, false);
122
- touchSurface.addEventListener('touchend', onTouchEnd, false);
123
- return () => {
124
- touchSurface.removeEventListener('touchstart', onTouchStart, false);
125
- touchSurface.removeEventListener('touchmove', onTouchMove, false);
126
- touchSurface.removeEventListener('touchend', onTouchEnd, false);
127
- };
128
- }
129
- /**
130
- * Checks whether or not the browser support passive events.
131
- * @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js
132
- */
133
- function isPassiveEventAvailable() {
134
- let supportsPassiveOption = false;
135
- try {
136
- const opts = Object.defineProperty({}, 'passive', {
137
- get() {
138
- supportsPassiveOption = true;
139
- },
140
- });
141
- window.addEventListener('testPassiveEventSupport', noop, opts);
142
- window.removeEventListener('testPassiveEventSupport', noop, opts);
143
- }
144
- catch (e) {
145
- // ignored
146
- }
147
- return supportsPassiveOption;
148
- }
149
- /**
150
- * Detects horizontal swipe direction without blocking the browser scroll using passive event.
151
- * @see http://javascriptkit.com/javatutors/touchevents2.shtml
152
- * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
153
- */
154
- function detectHorizontalSwipe(touchSurface, handleSwipe) {
155
- let startX;
156
- let startY;
157
- // Required min distance traveled to be considered swipe.
158
- const threshold = 150;
159
- // Maximum distance allowed at the same time in perpendicular direction.
160
- const restraint = 150;
161
- // Maximum time allowed to travel that distance.
162
- const allowedTime = 300;
163
- let elapsedTime;
164
- let startTime;
165
- let finished;
166
- const onTouchStart = (evt) => {
167
- const [touch] = Array.from(evt.changedTouches);
168
- startX = touch.pageX;
169
- startY = touch.pageY;
170
- // Record time when finger first makes contact with surface.
171
- startTime = new Date().getTime();
172
- finished = false;
173
- };
174
- const onTouchMove = (evt) => {
175
- if (finished) {
176
- return;
177
- }
178
- elapsedTime = new Date().getTime() - startTime;
179
- if (elapsedTime > allowedTime) {
180
- // Touch swipe too long to be considered.
181
- return;
182
- }
183
- const [touch] = Array.from(evt.changedTouches);
184
- // Get horizontal dist traveled by finger while in contact with surface.
185
- const distX = touch.pageX - startX;
186
- // Get vertical dist traveled by finger while in contact with surface.
187
- const distY = touch.pageY - startY;
188
- if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {
189
- // Swipe is not horizontal.
190
- return;
191
- }
192
- // Swipe direction.
193
- const direction = distX < 0 ? 'left' : 'right';
194
- handleSwipe(direction);
195
- finished = true;
196
- };
197
- // Activate passive event if possible for better scrolling performance.
198
- const eventOptions = isPassiveEventAvailable() ? { passive: true } : false;
199
- touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);
200
- touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);
201
- return () => {
202
- touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);
203
- touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);
204
- };
205
- }
206
-
207
- exports.handleBasicClasses = js_utils_className_handleBasicClasses.handleBasicClasses;
208
- exports.getBasicClass = js_utils_className_getBasicClass.getBasicClass;
209
- exports.getRootClassName = js_utils_className_getRootClassName.getRootClassName;
210
- exports.getTypographyClassName = js_utils_className_getTypographyClassName.getTypographyClassName;
211
- exports.fontColorClass = js_utils_className_fontColorClass.fontColorClass;
212
- exports.resolveColorWithVariants = js_utils_className_resolveColorWithVariants.resolveColorWithVariants;
213
- exports.detectHorizontalSwipe = detectHorizontalSwipe;
214
- exports.detectSwipe = detectSwipe;
215
- exports.onButtonPressed = onButtonPressed;
216
- exports.onEnterPressed = onEnterPressed;
217
- exports.onEscapePressed = onEscapePressed;
1
+ export { handleBasicClasses } from './className/handleBasicClasses.js';
2
+ export { getBasicClass } from './className/getBasicClass.js';
3
+ export { getRootClassName } from './className/getRootClassName.js';
4
+ export { getTypographyClassName } from './className/getTypographyClassName.js';
5
+ export { fontColorClass } from './className/fontColorClass.js';
6
+ export { resolveColorWithVariants } from './className/resolveColorWithVariants.js';
7
+ export { onButtonPressed, onEnterPressed, onEscapePressed } from './events/keyboard.js';
8
+ export { detectHorizontalSwipe } from './events/swipe.js';
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"
@@ -34,16 +35,14 @@
34
35
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
35
36
  },
36
37
  "sideEffects": false,
37
- "version": "3.20.1-alpha.37",
38
+ "version": "3.20.1-alpha.39",
38
39
  "devDependencies": {
39
- "@rollup/plugin-commonjs": "^29.0.0",
40
- "@rollup/plugin-terser": "^0.4.4",
41
- "@rollup/plugin-typescript": "^12.1.4",
40
+ "@rollup/plugin-typescript": "^12.3.0",
42
41
  "@types/react": "^17.0.2",
43
42
  "autoprefixer": "^9.7.4",
44
43
  "glob": "^7.1.6",
45
44
  "postcss": "^8.5.6",
46
- "rollup": "3.29.5",
45
+ "rollup": "^4.53.3",
47
46
  "rollup-plugin-cleaner": "^1.0.0",
48
47
  "rollup-plugin-copy": "^3.5.0",
49
48
  "sass": "^1.54.0",