@lumx/core 3.19.0 → 3.19.1-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/js/constants/index.js +167 -0
- package/js/constants/index.min.js +1 -1
- package/js/constants/index.ts +195 -0
- package/js/types/Callback.js +2 -0
- package/js/types/Callback.min.js +1 -0
- package/js/types/Callback.ts +4 -0
- package/js/types/Falsy.js +2 -0
- package/js/types/Falsy.min.js +1 -0
- package/js/types/Falsy.ts +5 -0
- package/js/types/GenericProps.js +2 -0
- package/js/types/GenericProps.min.js +1 -0
- package/js/types/GenericProps.ts +11 -0
- package/js/types/HasAriaLabelOrLabelledBy.js +2 -0
- package/js/types/HasAriaLabelOrLabelledBy.min.js +1 -0
- package/js/types/HasAriaLabelOrLabelledBy.ts +19 -0
- package/js/types/HasClassName.js +2 -0
- package/js/types/HasClassName.min.js +1 -0
- package/js/types/HasClassName.ts +6 -0
- package/js/types/HasCloseMode.js +2 -0
- package/js/types/HasCloseMode.min.js +1 -0
- package/js/types/HasCloseMode.ts +7 -0
- package/js/types/HasTheme.js +2 -0
- package/js/types/HasTheme.min.js +1 -0
- package/js/types/HasTheme.ts +8 -0
- package/js/types/HeadingElement.js +2 -0
- package/js/types/HeadingElement.min.js +1 -0
- package/js/types/HeadingElement.ts +2 -0
- package/js/types/Point.js +2 -0
- package/js/types/Point.min.js +1 -0
- package/js/types/Point.ts +4 -0
- package/js/types/Predicate.js +2 -0
- package/js/types/Predicate.min.js +1 -0
- package/js/types/Predicate.ts +2 -0
- package/js/types/RectSize.js +2 -0
- package/js/types/RectSize.min.js +1 -0
- package/js/types/RectSize.ts +4 -0
- package/js/types/TextElement.js +2 -0
- package/js/types/TextElement.min.js +1 -0
- package/js/types/TextElement.ts +4 -0
- package/js/types/ValueOf.js +2 -0
- package/js/types/ValueOf.min.js +1 -0
- package/js/types/ValueOf.ts +2 -0
- package/js/types/index.js +2 -0
- package/js/types/index.min.js +1 -0
- package/js/types/index.ts +13 -0
- package/js/utils/className/fontColorClass.js +20 -0
- package/js/utils/className/fontColorClass.min.js +1 -0
- package/js/utils/className/fontColorClass.test.js +18 -0
- package/js/utils/className/fontColorClass.test.min.js +1 -0
- package/js/utils/className/fontColorClass.test.ts +15 -0
- package/js/utils/className/fontColorClass.ts +12 -0
- package/js/utils/className/getBasicClass.js +36 -0
- package/js/utils/className/getBasicClass.min.js +1 -0
- package/js/utils/className/getBasicClass.test.js +22 -0
- package/js/utils/className/getBasicClass.test.min.js +1 -0
- package/js/utils/className/getBasicClass.test.ts +20 -0
- package/js/utils/className/getBasicClass.ts +36 -0
- package/js/utils/className/getRootClassName.js +33 -0
- package/js/utils/className/getRootClassName.min.js +1 -0
- package/js/utils/className/getRootClassName.test.js +15 -0
- package/js/utils/className/getRootClassName.test.min.js +1 -0
- package/js/utils/className/getRootClassName.test.ts +11 -0
- package/js/utils/className/getRootClassName.ts +25 -0
- package/js/utils/className/getTypographyClassName.js +13 -0
- package/js/utils/className/getTypographyClassName.min.js +1 -0
- package/js/utils/className/getTypographyClassName.test.js +9 -0
- package/js/utils/className/getTypographyClassName.test.min.js +1 -0
- package/js/utils/className/getTypographyClassName.test.ts +7 -0
- package/js/utils/className/getTypographyClassName.ts +9 -0
- package/js/utils/className/handleBasicClasses.js +52 -0
- package/js/utils/className/handleBasicClasses.min.js +1 -0
- package/js/utils/className/handleBasicClasses.test.js +35 -0
- package/js/utils/className/handleBasicClasses.test.min.js +1 -0
- package/js/utils/className/handleBasicClasses.test.ts +28 -0
- package/js/utils/className/handleBasicClasses.ts +44 -0
- package/js/utils/className/index.js +25 -0
- package/js/utils/className/index.min.js +1 -0
- package/js/utils/className/index.ts +6 -0
- package/js/utils/className/resolveColorWithVariants.js +13 -0
- package/js/utils/className/resolveColorWithVariants.min.js +1 -0
- package/js/utils/className/resolveColorWithVariants.test.js +30 -0
- package/js/utils/className/resolveColorWithVariants.test.min.js +1 -0
- package/js/utils/className/resolveColorWithVariants.test.ts +33 -0
- package/js/utils/className/resolveColorWithVariants.ts +11 -0
- package/js/{utils.js → utils/index.js} +48 -96
- package/js/utils/index.min.js +1 -0
- package/js/{utils.ts → utils/index.ts} +41 -116
- package/package.json +2 -1
- package/js/utils.min.js +0 -1
|
@@ -2,75 +2,65 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var classNames = require('classnames');
|
|
6
|
-
var isBoolean = require('lodash/isBoolean');
|
|
7
|
-
var isEmpty = require('lodash/isEmpty');
|
|
8
|
-
var kebabCase = require('lodash/kebabCase');
|
|
9
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');
|
|
10
18
|
|
|
11
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
20
|
|
|
13
|
-
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
14
|
-
var isBoolean__default = /*#__PURE__*/_interopDefaultLegacy(isBoolean);
|
|
15
|
-
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
16
|
-
var kebabCase__default = /*#__PURE__*/_interopDefaultLegacy(kebabCase);
|
|
17
21
|
var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
24
|
+
* Make sure the pressed key is the enter key before calling the callback.
|
|
21
25
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @return
|
|
26
|
+
* @param handler The handler to call on enter/return press.
|
|
27
|
+
* @return The decorated function.
|
|
24
28
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
function onEnterPressed(handler) {
|
|
30
|
+
return (evt) => {
|
|
31
|
+
if (evt.key !== 'Enter') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
handler(evt);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
31
37
|
/**
|
|
32
|
-
*
|
|
38
|
+
* Make sure the pressed key is the escape key before calling the callback.
|
|
33
39
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @
|
|
36
|
-
* @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).
|
|
37
|
-
* @return The basic CSS class.
|
|
40
|
+
* @param handler The handler to call on enter/return press.
|
|
41
|
+
* @return The decorated function.
|
|
38
42
|
*/
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
return '';
|
|
44
|
-
}
|
|
45
|
-
const booleanPrefixes = ['has', 'is'];
|
|
46
|
-
if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {
|
|
47
|
-
return `${prefix}--${kebabCase__default["default"](type)}`;
|
|
43
|
+
function onEscapePressed(handler) {
|
|
44
|
+
return (evt) => {
|
|
45
|
+
if (evt.key !== 'Escape') {
|
|
46
|
+
return;
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
return `${prefix}--${kebabCase__default["default"](type)}-${value}`;
|
|
48
|
+
handler(evt);
|
|
49
|
+
};
|
|
52
50
|
}
|
|
53
51
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @see {@link /src/components/index.d.ts} for the possible values of each parameter.
|
|
52
|
+
* Handle button key pressed (Enter + Space).
|
|
57
53
|
*
|
|
58
|
-
* @param
|
|
59
|
-
* @
|
|
60
|
-
* The rule of thumb: the key is the name of the prop in the class, the value a string that will
|
|
61
|
-
* be used in the classname to represent the value of the given prop.
|
|
62
|
-
* @return All LumX basic CSS classes.
|
|
54
|
+
* @param handler The handler to call.
|
|
55
|
+
* @return The decorated function.
|
|
63
56
|
*/
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return classNames__default["default"](prefix, otherClasses);
|
|
57
|
+
function onButtonPressed(handler) {
|
|
58
|
+
return (evt) => {
|
|
59
|
+
if (evt.key !== 'Enter' && evt.key !== ' ') {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
handler(evt);
|
|
63
|
+
};
|
|
74
64
|
}
|
|
75
65
|
/**
|
|
76
66
|
* Detects swipe direction.
|
|
@@ -219,53 +209,15 @@ function detectHorizontalSwipe(touchSurface, handleSwipe) {
|
|
|
219
209
|
touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);
|
|
220
210
|
};
|
|
221
211
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Make sure the pressed key is the enter key before calling the callback.
|
|
224
|
-
*
|
|
225
|
-
* @param handler The handler to call on enter/return press.
|
|
226
|
-
* @return The decorated function.
|
|
227
|
-
*/
|
|
228
|
-
function onEnterPressed(handler) {
|
|
229
|
-
return (evt) => {
|
|
230
|
-
if (evt.key !== 'Enter') {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
handler(evt);
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Make sure the pressed key is the escape key before calling the callback.
|
|
238
|
-
*
|
|
239
|
-
* @param handler The handler to call on enter/return press.
|
|
240
|
-
* @return The decorated function.
|
|
241
|
-
*/
|
|
242
|
-
function onEscapePressed(handler) {
|
|
243
|
-
return (evt) => {
|
|
244
|
-
if (evt.key !== 'Escape') {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
handler(evt);
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Handle button key pressed (Enter + Space).
|
|
252
|
-
*
|
|
253
|
-
* @param handler The handler to call.
|
|
254
|
-
* @return The decorated function.
|
|
255
|
-
*/
|
|
256
|
-
function onButtonPressed(handler) {
|
|
257
|
-
return (evt) => {
|
|
258
|
-
if (evt.key !== 'Enter' && evt.key !== ' ') {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
handler(evt);
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
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;
|
|
265
219
|
exports.detectHorizontalSwipe = detectHorizontalSwipe;
|
|
266
220
|
exports.detectSwipe = detectSwipe;
|
|
267
|
-
exports.getBasicClass = getBasicClass;
|
|
268
|
-
exports.handleBasicClasses = handleBasicClasses;
|
|
269
221
|
exports.onButtonPressed = onButtonPressed;
|
|
270
222
|
exports.onEnterPressed = onEnterPressed;
|
|
271
223
|
exports.onEscapePressed = onEscapePressed;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/noop"),t=require("./className/handleBasicClasses.min.js"),s=require("./className/getBasicClass.min.js"),r=require("./className/getRootClassName.min.js"),a=require("./className/getTypographyClassName.min.js"),n=require("./className/fontColorClass.min.js"),o=require("./className/resolveColorWithVariants.min.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("classnames"),require("lodash/isBoolean"),require("lodash/isEmpty"),require("lodash/kebabCase"),require("../constants/index.min.js"),require("../constants/keycodes.min.js");var u=i(e);exports.handleBasicClasses=t.handleBasicClasses,exports.getBasicClass=s.getBasicClass,exports.getRootClassName=r.getRootClassName,exports.getTypographyClassName=a.getTypographyClassName,exports.fontColorClass=n.fontColorClass,exports.resolveColorWithVariants=o.resolveColorWithVariants,exports.detectHorizontalSwipe=function(e,t){let s,r,a,n,o;const i=e=>{const[t]=Array.from(e.changedTouches);s=t.pageX,r=t.pageY,n=(new Date).getTime(),o=!1},c=e=>{if(o)return;if(a=(new Date).getTime()-n,a>300)return;const[i]=Array.from(e.changedTouches),u=i.pageX-s,c=i.pageY-r;if(!(Math.abs(u)>=150&&Math.abs(c)<=150))return;t(u<0?"left":"right"),o=!0},l=!!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get(){e=!0}});window.addEventListener("testPassiveEventSupport",u.default,t),window.removeEventListener("testPassiveEventSupport",u.default,t)}catch(e){}return e}()&&{passive:!0};return e.addEventListener("touchstart",i,l),e.addEventListener("touchmove",c,l),()=>{e.removeEventListener("touchstart",i,l),e.removeEventListener("touchmove",c,l)}},exports.detectSwipe=function(e,t=u.default){let s,r,a,n,o,i,c;const l=e=>{const[t]=Array.from(e.changedTouches);o="none",a=t.pageX,n=t.pageY,c=(new Date).getTime(),e.preventDefault()},p=e=>{e.preventDefault()},d=e=>{const[u]=Array.from(e.changedTouches);s=u.pageX-a,r=u.pageY-n,i=(new Date).getTime()-c,i<=300&&(Math.abs(s)>=150&&Math.abs(r)<=100?o=s<0?"left":"right":Math.abs(r)>=150&&Math.abs(s)<=100&&(o=r<0?"up":"down")),t(o),e.preventDefault()};return e.addEventListener("touchstart",l,!1),e.addEventListener("touchmove",p,!1),e.addEventListener("touchend",d,!1),()=>{e.removeEventListener("touchstart",l,!1),e.removeEventListener("touchmove",p,!1),e.removeEventListener("touchend",d,!1)}},exports.onButtonPressed=function(e){return t=>{"Enter"!==t.key&&" "!==t.key||e(t)}},exports.onEnterPressed=function(e){return t=>{"Enter"===t.key&&e(t)}},exports.onEscapePressed=function(e){return t=>{"Escape"===t.key&&e(t)}};
|
|
@@ -1,82 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
-
import React from 'react';
|
|
1
|
+
import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
4
2
|
|
|
5
|
-
import isBoolean from 'lodash/isBoolean';
|
|
6
|
-
import isEmpty from 'lodash/isEmpty';
|
|
7
|
-
import kebabCase from 'lodash/kebabCase';
|
|
8
3
|
import noop from 'lodash/noop';
|
|
9
4
|
|
|
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
|
-
}
|
|
5
|
+
export * from './className';
|
|
20
6
|
|
|
21
|
-
|
|
22
|
-
};
|
|
7
|
+
type KeyboardEventHandler<E extends KeyboardEvent | ReactKeyboardEvent> = (event: E) => void;
|
|
23
8
|
|
|
24
9
|
/**
|
|
25
|
-
*
|
|
10
|
+
* Make sure the pressed key is the enter key before calling the callback.
|
|
26
11
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @
|
|
29
|
-
* @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).
|
|
30
|
-
* @return The basic CSS class.
|
|
12
|
+
* @param handler The handler to call on enter/return press.
|
|
13
|
+
* @return The decorated function.
|
|
31
14
|
*/
|
|
32
|
-
export function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
type: string;
|
|
39
|
-
value: string | number | boolean | undefined;
|
|
40
|
-
}): string {
|
|
41
|
-
if (isBoolean(value)) {
|
|
42
|
-
if (!value) {
|
|
43
|
-
// False value should not return a class.
|
|
44
|
-
return '';
|
|
15
|
+
export function onEnterPressed<E extends KeyboardEvent | ReactKeyboardEvent>(
|
|
16
|
+
handler: KeyboardEventHandler<E>,
|
|
17
|
+
): KeyboardEventHandler<E> {
|
|
18
|
+
return (evt) => {
|
|
19
|
+
if (evt.key !== 'Enter') {
|
|
20
|
+
return;
|
|
45
21
|
}
|
|
46
|
-
|
|
22
|
+
handler(evt);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
47
25
|
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Make sure the pressed key is the escape key before calling the callback.
|
|
28
|
+
*
|
|
29
|
+
* @param handler The handler to call on enter/return press.
|
|
30
|
+
* @return The decorated function.
|
|
31
|
+
*/
|
|
32
|
+
export function onEscapePressed<E extends KeyboardEvent | ReactKeyboardEvent>(
|
|
33
|
+
handler: KeyboardEventHandler<E>,
|
|
34
|
+
): KeyboardEventHandler<E> {
|
|
35
|
+
return (evt) => {
|
|
36
|
+
if (evt.key !== 'Escape') {
|
|
37
|
+
return;
|
|
50
38
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return `${prefix}--${kebabCase(type)}-${value}`;
|
|
39
|
+
handler(evt);
|
|
40
|
+
};
|
|
56
41
|
}
|
|
57
42
|
|
|
58
43
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @see {@link /src/components/index.d.ts} for the possible values of each parameter.
|
|
44
|
+
* Handle button key pressed (Enter + Space).
|
|
62
45
|
*
|
|
63
|
-
* @param
|
|
64
|
-
* @
|
|
65
|
-
* The rule of thumb: the key is the name of the prop in the class, the value a string that will
|
|
66
|
-
* be used in the classname to represent the value of the given prop.
|
|
67
|
-
* @return All LumX basic CSS classes.
|
|
46
|
+
* @param handler The handler to call.
|
|
47
|
+
* @return The decorated function.
|
|
68
48
|
*/
|
|
69
|
-
export function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return classNames(prefix, otherClasses);
|
|
49
|
+
export function onButtonPressed<E extends KeyboardEvent | ReactKeyboardEvent>(
|
|
50
|
+
handler: KeyboardEventHandler<E>,
|
|
51
|
+
): KeyboardEventHandler<E> {
|
|
52
|
+
return (evt) => {
|
|
53
|
+
if (evt.key !== 'Enter' && evt.key !== ' ') {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
handler(evt);
|
|
57
|
+
};
|
|
80
58
|
}
|
|
81
59
|
|
|
82
60
|
declare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';
|
|
@@ -241,56 +219,3 @@ export function detectHorizontalSwipe(touchSurface: Element, handleSwipe: (direc
|
|
|
241
219
|
touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);
|
|
242
220
|
};
|
|
243
221
|
}
|
|
244
|
-
|
|
245
|
-
type KeyboardEventHandler<E extends KeyboardEvent | React.KeyboardEvent> = (event: E) => void;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Make sure the pressed key is the enter key before calling the callback.
|
|
249
|
-
*
|
|
250
|
-
* @param handler The handler to call on enter/return press.
|
|
251
|
-
* @return The decorated function.
|
|
252
|
-
*/
|
|
253
|
-
export function onEnterPressed<E extends KeyboardEvent | React.KeyboardEvent>(
|
|
254
|
-
handler: KeyboardEventHandler<E>,
|
|
255
|
-
): KeyboardEventHandler<E> {
|
|
256
|
-
return (evt) => {
|
|
257
|
-
if (evt.key !== 'Enter') {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
handler(evt);
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Make sure the pressed key is the escape key before calling the callback.
|
|
266
|
-
*
|
|
267
|
-
* @param handler The handler to call on enter/return press.
|
|
268
|
-
* @return The decorated function.
|
|
269
|
-
*/
|
|
270
|
-
export function onEscapePressed<E extends KeyboardEvent | React.KeyboardEvent>(
|
|
271
|
-
handler: KeyboardEventHandler<E>,
|
|
272
|
-
): KeyboardEventHandler<E> {
|
|
273
|
-
return (evt) => {
|
|
274
|
-
if (evt.key !== 'Escape') {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
handler(evt);
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Handle button key pressed (Enter + Space).
|
|
283
|
-
*
|
|
284
|
-
* @param handler The handler to call.
|
|
285
|
-
* @return The decorated function.
|
|
286
|
-
*/
|
|
287
|
-
export function onButtonPressed<E extends KeyboardEvent | React.KeyboardEvent>(
|
|
288
|
-
handler: KeyboardEventHandler<E>,
|
|
289
|
-
): KeyboardEventHandler<E> {
|
|
290
|
-
return (evt) => {
|
|
291
|
-
if (evt.key !== 'Enter' && evt.key !== ' ') {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
handler(evt);
|
|
295
|
-
};
|
|
296
|
-
}
|
package/package.json
CHANGED
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
34
34
|
},
|
|
35
35
|
"sideEffects": false,
|
|
36
|
-
"version": "3.19.
|
|
36
|
+
"version": "3.19.1-alpha.1",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@rollup/plugin-commonjs": "^19.0.2",
|
|
39
39
|
"@rollup/plugin-terser": "^0.4.4",
|
|
40
40
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
41
|
+
"@types/react": "^17.0.2",
|
|
41
42
|
"autoprefixer": "^9.7.4",
|
|
42
43
|
"glob": "^7.1.6",
|
|
43
44
|
"postcss": "^8.5.6",
|
package/js/utils.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("classnames"),t=require("lodash/isBoolean"),r=require("lodash/isEmpty"),n=require("lodash/kebabCase"),a=require("lodash/noop");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e),u=s(t),i=s(r),c=s(n),d=s(a);function f({prefix:e,type:t,value:r}){if(u.default(r)){if(!r)return"";return["has","is"].some(e=>t.toString().startsWith(e))?`${e}--${c.default(t)}`:`${e}--is-${c.default(t)}`}return`${e}--${c.default(t)}-${r}`}exports.detectHorizontalSwipe=function(e,t){let r,n,a,s,o;const u=e=>{const[t]=Array.from(e.changedTouches);r=t.pageX,n=t.pageY,s=(new Date).getTime(),o=!1},i=e=>{if(o)return;if(a=(new Date).getTime()-s,a>300)return;const[u]=Array.from(e.changedTouches),i=u.pageX-r,c=u.pageY-n;if(!(Math.abs(i)>=150&&Math.abs(c)<=150))return;t(i<0?"left":"right"),o=!0},c=!!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get(){e=!0}});window.addEventListener("testPassiveEventSupport",d.default,t),window.removeEventListener("testPassiveEventSupport",d.default,t)}catch(e){}return e}()&&{passive:!0};return e.addEventListener("touchstart",u,c),e.addEventListener("touchmove",i,c),()=>{e.removeEventListener("touchstart",u,c),e.removeEventListener("touchmove",i,c)}},exports.detectSwipe=function(e,t=d.default){let r,n,a,s,o,u,i;const c=e=>{const[t]=Array.from(e.changedTouches);o="none",a=t.pageX,s=t.pageY,i=(new Date).getTime(),e.preventDefault()},f=e=>{e.preventDefault()},p=e=>{const[c]=Array.from(e.changedTouches);r=c.pageX-a,n=c.pageY-s,u=(new Date).getTime()-i,u<=300&&(Math.abs(r)>=150&&Math.abs(n)<=100?o=r<0?"left":"right":Math.abs(n)>=150&&Math.abs(r)<=100&&(o=n<0?"up":"down")),t(o),e.preventDefault()};return e.addEventListener("touchstart",c,!1),e.addEventListener("touchmove",f,!1),e.addEventListener("touchend",p,!1),()=>{e.removeEventListener("touchstart",c,!1),e.removeEventListener("touchmove",f,!1),e.removeEventListener("touchend",p,!1)}},exports.getBasicClass=f,exports.handleBasicClasses=function({prefix:e,...t}){const r={};return i.default(t)||Object.keys(t).forEach(n=>{var a;r[f({prefix:e,type:n,value:t[n]})]=u.default(t[n])?t[n]:!("number"==typeof(a=t[n])?0===a:i.default(a))}),o.default(e,r)},exports.onButtonPressed=function(e){return t=>{"Enter"!==t.key&&" "!==t.key||e(t)}},exports.onEnterPressed=function(e){return t=>{"Enter"===t.key&&e(t)}},exports.onEscapePressed=function(e){return t=>{"Escape"===t.key&&e(t)}};
|