@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.
@@ -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 ? ['Enter', 'Space'] : _d;
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
- var key = event.key;
13
- if (checkKeys.includes(key)) {
13
+ if (checkKeys.includes(event.key)) {
14
14
  if (preventDefault)
15
15
  event.preventDefault();
16
16
  fn(event);
@@ -14,7 +14,7 @@ export var a11yKeyboardCode = {
14
14
  export var a11yKeyboard = {
15
15
  ArrowLeft: 'ArrowLeft',
16
16
  ArrowRight: 'ArrowRight',
17
- Space: 'Space',
17
+ Space: ' ',
18
18
  Escape: 'Escape',
19
19
  Enter: 'Enter',
20
20
  Tab: 'Tab',
@@ -11,9 +11,9 @@ export declare type useA11yKeyEventOptions = {
11
11
  */
12
12
  preventDefault?: boolean;
13
13
  /**
14
- * event check keys
14
+ * check point for `event.key`
15
15
  *
16
- * @default ['Enter', 'Space']
16
+ * @default ['Enter', ' ']
17
17
  */
18
18
  checkKeys?: string[];
19
19
  };
@@ -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 ? ['Enter', 'Space'] : _d;
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
- var key = event.key;
15
- if (checkKeys.includes(key)) {
15
+ if (checkKeys.includes(event.key)) {
16
16
  if (preventDefault)
17
17
  event.preventDefault();
18
18
  fn(event);
@@ -16,7 +16,7 @@ exports.a11yKeyboardCode = {
16
16
  exports.a11yKeyboard = {
17
17
  ArrowLeft: 'ArrowLeft',
18
18
  ArrowRight: 'ArrowRight',
19
- Space: 'Space',
19
+ Space: ' ',
20
20
  Escape: 'Escape',
21
21
  Enter: 'Enter',
22
22
  Tab: 'Tab',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "author": "RingCentral",
5
5
  "license": "MIT",
6
6
  "main": "./index.js",