@ringcentral/juno 2.3.5 → 2.3.6
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/es6/foundation/hooks/useA11yKeyEvent/useA11yKeyEvent.js +3 -3
- package/es6/foundation/utils/a11yKeyboardCode.js +1 -1
- package/foundation/hooks/useA11yKeyEvent/useA11yKeyEvent.d.ts +2 -2
- package/foundation/hooks/useA11yKeyEvent/useA11yKeyEvent.js +3 -3
- package/foundation/utils/a11yKeyboardCode.js +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useEventCallback } from '../useEventCallback';
|
|
2
|
+
var defaultCheckKeys = ['Enter', ' '];
|
|
2
3
|
/**
|
|
3
4
|
* bind event with a11y keyboard, `space`, `enter`, only trigger when key includes in `checkKeys`
|
|
4
5
|
*
|
|
5
6
|
* that will auto preventDefault by default, if you don't want that, set `false` with `preventDefault`
|
|
6
7
|
*/
|
|
7
8
|
export var useA11yKeyEvent = function (fn, _a) {
|
|
8
|
-
var _b = _a === void 0 ? {} : _a, onlyOnFocus = _b.onlyOnFocus, _c = _b.preventDefault, preventDefault = _c === void 0 ? true : _c, _d = _b.checkKeys, checkKeys = _d === void 0 ?
|
|
9
|
+
var _b = _a === void 0 ? {} : _a, onlyOnFocus = _b.onlyOnFocus, _c = _b.preventDefault, preventDefault = _c === void 0 ? true : _c, _d = _b.checkKeys, checkKeys = _d === void 0 ? defaultCheckKeys : _d;
|
|
9
10
|
return useEventCallback(function (event) {
|
|
10
11
|
if (!fn || (onlyOnFocus && event.target !== event.currentTarget))
|
|
11
12
|
return;
|
|
12
|
-
|
|
13
|
-
if (checkKeys.includes(key)) {
|
|
13
|
+
if (checkKeys.includes(event.key)) {
|
|
14
14
|
if (preventDefault)
|
|
15
15
|
event.preventDefault();
|
|
16
16
|
fn(event);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var useEventCallback_1 = require("../useEventCallback");
|
|
4
|
+
var defaultCheckKeys = ['Enter', ' '];
|
|
4
5
|
/**
|
|
5
6
|
* bind event with a11y keyboard, `space`, `enter`, only trigger when key includes in `checkKeys`
|
|
6
7
|
*
|
|
7
8
|
* that will auto preventDefault by default, if you don't want that, set `false` with `preventDefault`
|
|
8
9
|
*/
|
|
9
10
|
exports.useA11yKeyEvent = function (fn, _a) {
|
|
10
|
-
var _b = _a === void 0 ? {} : _a, onlyOnFocus = _b.onlyOnFocus, _c = _b.preventDefault, preventDefault = _c === void 0 ? true : _c, _d = _b.checkKeys, checkKeys = _d === void 0 ?
|
|
11
|
+
var _b = _a === void 0 ? {} : _a, onlyOnFocus = _b.onlyOnFocus, _c = _b.preventDefault, preventDefault = _c === void 0 ? true : _c, _d = _b.checkKeys, checkKeys = _d === void 0 ? defaultCheckKeys : _d;
|
|
11
12
|
return useEventCallback_1.useEventCallback(function (event) {
|
|
12
13
|
if (!fn || (onlyOnFocus && event.target !== event.currentTarget))
|
|
13
14
|
return;
|
|
14
|
-
|
|
15
|
-
if (checkKeys.includes(key)) {
|
|
15
|
+
if (checkKeys.includes(event.key)) {
|
|
16
16
|
if (preventDefault)
|
|
17
17
|
event.preventDefault();
|
|
18
18
|
fn(event);
|