handsontable 0.0.0-next-fd8b2aa-20240614 → 0.0.0-next-7b70e9b-20240614

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

package/helpers/mixed.js CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
134
134
  function _injectProductInfo(key, element) {
135
135
  const hasValidType = !isEmpty(key);
136
136
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
137
- const hotVersion = "0.0.0-next-fd8b2aa-20240614";
137
+ const hotVersion = "0.0.0-next-7b70e9b-20240614";
138
138
  let keyValidityDate;
139
139
  let consoleMessageState = 'invalid';
140
140
  let domMessageState = 'invalid';
package/helpers/mixed.mjs CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
124
124
  export function _injectProductInfo(key, element) {
125
125
  const hasValidType = !isEmpty(key);
126
126
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
127
- const hotVersion = "0.0.0-next-fd8b2aa-20240614";
127
+ const hotVersion = "0.0.0-next-7b70e9b-20240614";
128
128
  let keyValidityDate;
129
129
  let consoleMessageState = 'invalid';
130
130
  let domMessageState = 'invalid';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/handsontable/handsontable/issues"
11
11
  },
12
12
  "author": "Handsoncode <hello@handsontable.com>",
13
- "version": "0.0.0-next-fd8b2aa-20240614",
13
+ "version": "0.0.0-next-7b70e9b-20240614",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
@@ -1,13 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- require("core-js/modules/esnext.set.difference.v2.js");
5
- require("core-js/modules/esnext.set.intersection.v2.js");
6
- require("core-js/modules/esnext.set.is-disjoint-from.v2.js");
7
- require("core-js/modules/esnext.set.is-subset-of.v2.js");
8
- require("core-js/modules/esnext.set.is-superset-of.v2.js");
9
- require("core-js/modules/esnext.set.symmetric-difference.v2.js");
10
- require("core-js/modules/esnext.set.union.v2.js");
11
4
  // This file handles key-name discrepancies between browsers.
12
5
  // For the list of discrepancies, go to: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values.
13
6
  const mappings = new Map([[' ', 'space'],
@@ -42,36 +35,34 @@ exports.normalizeKeys = normalizeKeys;
42
35
  const getKeysList = normalizedKeys => {
43
36
  return normalizedKeys.split('+');
44
37
  };
45
-
46
- /**
47
- * The regex tests if the event.code matches to the pattern and it's used to extract letters and digits from
48
- * the string.
49
- */
50
38
  exports.getKeysList = getKeysList;
51
- const codeToKeyRegExp = new RegExp('^(?:Key|Digit)([A-Z0-9])$');
52
- const keyCodeNames = new Set(['Backquote', 'Minus', 'Equal', 'BracketLeft', 'BracketRight', 'Backslash', 'Semicolon', 'Quote', 'Comma', 'Period', 'Slash']);
39
+ const specialCharactersSet = new Map([[186, 'semicolon'], [187, 'equal'], [188, 'comma'], [189, 'minus'], [190, 'period'], [191, 'slash'], [192, 'backquote'], [219, 'bracketleft'], [220, 'backslash'], [221, 'bracketright'], [222, 'quote']]);
53
40
 
54
41
  /**
55
- * Normalizes a keyboard event key value to a key before its modification. When the keyboard event
56
- * is triggered with Alt, Control or Shift keys the `key` property contains modified key e.g. for Alt+L
57
- * it will be `ł`. But that value is only valid for polish keyboard layout. To fix that limitations, for
58
- * letters and digits the value is taken from the `code` property which holds original value before
59
- * transformation.
42
+ * Normalizes a keyboard event key value to a key before its modification.
43
+ *
44
+ * Keep in mind that there is difference between `key` and `code` properties of the KeyboardEvent object.
45
+ * The `key` property represents the logical key on the keyboard (after applying modifiers and taking
46
+ * the keyboard layout into account), where the `code` property represents the physical key
47
+ * (regardless of what is printed on the key). Using the `keyCode` for alphanumeric keys,
48
+ * solves the problem and allows to get the correct key value. The value that takes the keyboard layout
49
+ * into account but is not modified by the modifiers (e.g. Alt + L would give polish "ł" we want "l").
60
50
  *
61
51
  * @param {Event} event The KeyboardEvent object.
62
52
  * @returns {string}
63
53
  */
64
54
  const normalizeEventKey = _ref => {
65
55
  let {
66
- key,
67
- code
56
+ which,
57
+ key
68
58
  } = _ref;
69
- let normalizedKey = key;
70
- if (codeToKeyRegExp.test(code)) {
71
- normalizedKey = code.replace(codeToKeyRegExp, '$1');
72
- } else if (keyCodeNames.has(code)) {
73
- normalizedKey = code;
59
+ if (specialCharactersSet.has(which)) {
60
+ return specialCharactersSet.get(which);
61
+ }
62
+ const normalizedKey = String.fromCharCode(which).toLowerCase();
63
+ if (/^[a-z0-9]$/.test(normalizedKey)) {
64
+ return normalizedKey;
74
65
  }
75
- return normalizedKey.toLowerCase();
66
+ return key.toLowerCase();
76
67
  };
77
68
  exports.normalizeEventKey = normalizeEventKey;
@@ -1,10 +1,3 @@
1
- import "core-js/modules/esnext.set.difference.v2.js";
2
- import "core-js/modules/esnext.set.intersection.v2.js";
3
- import "core-js/modules/esnext.set.is-disjoint-from.v2.js";
4
- import "core-js/modules/esnext.set.is-subset-of.v2.js";
5
- import "core-js/modules/esnext.set.is-superset-of.v2.js";
6
- import "core-js/modules/esnext.set.symmetric-difference.v2.js";
7
- import "core-js/modules/esnext.set.union.v2.js";
8
1
  // This file handles key-name discrepancies between browsers.
9
2
  // For the list of discrepancies, go to: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values.
10
3
  const mappings = new Map([[' ', 'space'],
@@ -38,34 +31,32 @@ export const normalizeKeys = keys => {
38
31
  export const getKeysList = normalizedKeys => {
39
32
  return normalizedKeys.split('+');
40
33
  };
34
+ const specialCharactersSet = new Map([[186, 'semicolon'], [187, 'equal'], [188, 'comma'], [189, 'minus'], [190, 'period'], [191, 'slash'], [192, 'backquote'], [219, 'bracketleft'], [220, 'backslash'], [221, 'bracketright'], [222, 'quote']]);
41
35
 
42
36
  /**
43
- * The regex tests if the event.code matches to the pattern and it's used to extract letters and digits from
44
- * the string.
45
- */
46
- const codeToKeyRegExp = new RegExp('^(?:Key|Digit)([A-Z0-9])$');
47
- const keyCodeNames = new Set(['Backquote', 'Minus', 'Equal', 'BracketLeft', 'BracketRight', 'Backslash', 'Semicolon', 'Quote', 'Comma', 'Period', 'Slash']);
48
-
49
- /**
50
- * Normalizes a keyboard event key value to a key before its modification. When the keyboard event
51
- * is triggered with Alt, Control or Shift keys the `key` property contains modified key e.g. for Alt+L
52
- * it will be `ł`. But that value is only valid for polish keyboard layout. To fix that limitations, for
53
- * letters and digits the value is taken from the `code` property which holds original value before
54
- * transformation.
37
+ * Normalizes a keyboard event key value to a key before its modification.
38
+ *
39
+ * Keep in mind that there is difference between `key` and `code` properties of the KeyboardEvent object.
40
+ * The `key` property represents the logical key on the keyboard (after applying modifiers and taking
41
+ * the keyboard layout into account), where the `code` property represents the physical key
42
+ * (regardless of what is printed on the key). Using the `keyCode` for alphanumeric keys,
43
+ * solves the problem and allows to get the correct key value. The value that takes the keyboard layout
44
+ * into account but is not modified by the modifiers (e.g. Alt + L would give polish "ł" we want "l").
55
45
  *
56
46
  * @param {Event} event The KeyboardEvent object.
57
47
  * @returns {string}
58
48
  */
59
49
  export const normalizeEventKey = _ref => {
60
50
  let {
61
- key,
62
- code
51
+ which,
52
+ key
63
53
  } = _ref;
64
- let normalizedKey = key;
65
- if (codeToKeyRegExp.test(code)) {
66
- normalizedKey = code.replace(codeToKeyRegExp, '$1');
67
- } else if (keyCodeNames.has(code)) {
68
- normalizedKey = code;
54
+ if (specialCharactersSet.has(which)) {
55
+ return specialCharactersSet.get(which);
56
+ }
57
+ const normalizedKey = String.fromCharCode(which).toLowerCase();
58
+ if (/^[a-z0-9]$/.test(normalizedKey)) {
59
+ return normalizedKey;
69
60
  }
70
- return normalizedKey.toLowerCase();
61
+ return key.toLowerCase();
71
62
  };