@jsenv/dom 0.9.4 → 0.9.5
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/dist/jsenv_dom.js +25 -3
- package/package.json +7 -7
package/dist/jsenv_dom.js
CHANGED
|
@@ -3995,16 +3995,38 @@ const findFocusable = (element) => {
|
|
|
3995
3995
|
return focusableDescendant;
|
|
3996
3996
|
};
|
|
3997
3997
|
|
|
3998
|
+
// Input types where ArrowUp/Down natively change the value — don't intercept them
|
|
3999
|
+
const INPUT_TYPES_WITH_ARROW_MEANING = new Set([
|
|
4000
|
+
"number",
|
|
4001
|
+
"range",
|
|
4002
|
+
"date",
|
|
4003
|
+
"time",
|
|
4004
|
+
"datetime-local",
|
|
4005
|
+
"month",
|
|
4006
|
+
"week",
|
|
4007
|
+
]);
|
|
4008
|
+
const INPUT_ALLOWED_KEYS = new Set(["Home", "End", "Escape", "Enter"]);
|
|
4009
|
+
const INPUT_ARROW_KEYS = new Set(["ArrowDown", "ArrowUp"]);
|
|
4010
|
+
const TEXTAREA_ALLOWED_KEYS = new Set(["Escape"]);
|
|
4011
|
+
|
|
3998
4012
|
const canInterceptKeys = (event) => {
|
|
3999
4013
|
const target = event.target;
|
|
4000
|
-
//
|
|
4014
|
+
// Allow specific keys on input/textarea/contenteditable elements
|
|
4015
|
+
if (target.tagName === "INPUT") {
|
|
4016
|
+
if (INPUT_ALLOWED_KEYS.has(event.key)) {
|
|
4017
|
+
return true;
|
|
4018
|
+
}
|
|
4019
|
+
if (INPUT_ARROW_KEYS.has(event.key)) {
|
|
4020
|
+
return !INPUT_TYPES_WITH_ARROW_MEANING.has(target.type);
|
|
4021
|
+
}
|
|
4022
|
+
return false;
|
|
4023
|
+
}
|
|
4001
4024
|
if (
|
|
4002
|
-
target.tagName === "INPUT" ||
|
|
4003
4025
|
target.tagName === "TEXTAREA" ||
|
|
4004
4026
|
target.contentEditable === "true" ||
|
|
4005
4027
|
target.isContentEditable
|
|
4006
4028
|
) {
|
|
4007
|
-
return
|
|
4029
|
+
return TEXTAREA_ALLOWED_KEYS.has(event.key);
|
|
4008
4030
|
}
|
|
4009
4031
|
// Don't handle shortcuts when select dropdown is open
|
|
4010
4032
|
if (target.tagName === "SELECT") {
|
package/package.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/dom",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "DOM utilities for writing frontend code",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "https://github.com/jsenv/core",
|
|
8
9
|
"directory": "packages/frontend/dom"
|
|
9
10
|
},
|
|
10
|
-
"license": "MIT",
|
|
11
11
|
"author": {
|
|
12
12
|
"name": "dmail",
|
|
13
13
|
"email": "dmaillard06@gmail.com"
|
|
14
14
|
},
|
|
15
|
-
"
|
|
16
|
-
"./dist/jsenv_dom.js"
|
|
17
|
-
],
|
|
18
|
-
"type": "module",
|
|
15
|
+
"license": "MIT",
|
|
19
16
|
"exports": {
|
|
20
17
|
".": {
|
|
21
18
|
"node": {
|
|
@@ -47,5 +44,8 @@
|
|
|
47
44
|
},
|
|
48
45
|
"publishConfig": {
|
|
49
46
|
"access": "public"
|
|
50
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"sideEffects": [
|
|
49
|
+
"./dist/jsenv_dom.js"
|
|
50
|
+
]
|
|
51
51
|
}
|