@y14e/menu 1.5.5 → 1.5.7
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/README.md +5 -5
- package/dist/index.cjs +15 -33
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,16 +10,16 @@ npm i @y14e/menu
|
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
// npm
|
|
13
|
-
import Menu from '@y14e/menu@1.5.
|
|
13
|
+
import Menu from '@y14e/menu@1.5.7';
|
|
14
14
|
// with middleware
|
|
15
|
-
import Menu, { flip, offset, shift } from '@y14e/menu@1.5.
|
|
15
|
+
import Menu, { flip, offset, shift } from '@y14e/menu@1.5.7';
|
|
16
16
|
|
|
17
17
|
// CDNs
|
|
18
|
-
import Menu from 'https://esm.sh/@y14e/menu@1.5.
|
|
18
|
+
import Menu from 'https://esm.sh/@y14e/menu@1.5.7';
|
|
19
19
|
// or
|
|
20
|
-
import Menu from 'https://cdn.jsdelivr.net/npm/@y14e/menu@1.5.
|
|
20
|
+
import Menu from 'https://cdn.jsdelivr.net/npm/@y14e/menu@1.5.7/+esm';
|
|
21
21
|
// or
|
|
22
|
-
import Menu from 'https://esm.unpkg.com/@y14e/menu@1.5.
|
|
22
|
+
import Menu from 'https://esm.unpkg.com/@y14e/menu@1.5.7';
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Usage
|
package/dist/index.cjs
CHANGED
|
@@ -2927,40 +2927,29 @@ var Menu = class _Menu {
|
|
|
2927
2927
|
requestAnimationFrame(() => this.#focusTrigger());
|
|
2928
2928
|
return;
|
|
2929
2929
|
}
|
|
2930
|
-
if (![
|
|
2931
|
-
"Enter",
|
|
2932
|
-
"Escape",
|
|
2933
|
-
" ",
|
|
2934
|
-
"ArrowLeft",
|
|
2935
|
-
...this.#isMenubar ? ["ArrowRight"] : []
|
|
2936
|
-
].includes(key)) {
|
|
2930
|
+
if (!["Enter", "Escape", " ", "ArrowLeft", "ArrowRight"].includes(key)) {
|
|
2937
2931
|
return;
|
|
2938
2932
|
}
|
|
2939
2933
|
event.preventDefault();
|
|
2940
2934
|
event.stopPropagation();
|
|
2935
|
+
if (key === "Escape" || key === "ArrowLeft" && this.#isSubmenu) {
|
|
2936
|
+
this.close();
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2941
2939
|
const active = getActiveElement4();
|
|
2942
2940
|
if (!(active instanceof HTMLElement)) {
|
|
2943
2941
|
return;
|
|
2944
2942
|
}
|
|
2945
2943
|
switch (key) {
|
|
2946
|
-
case "Tab":
|
|
2947
|
-
case "Escape":
|
|
2948
|
-
this.close();
|
|
2949
|
-
return;
|
|
2950
|
-
case "ArrowLeft":
|
|
2951
|
-
if (this.#isMenubar) {
|
|
2952
|
-
this.#closeAndMoveFocus("previous");
|
|
2953
|
-
} else if (this.#isSubmenu && this.#triggerElement) {
|
|
2954
|
-
this.close();
|
|
2955
|
-
}
|
|
2956
|
-
return;
|
|
2957
|
-
case "ArrowRight":
|
|
2958
|
-
this.#closeAndMoveFocus("next");
|
|
2959
|
-
return;
|
|
2960
2944
|
case "Enter":
|
|
2961
2945
|
case " ":
|
|
2962
2946
|
active.click();
|
|
2963
|
-
|
|
2947
|
+
break;
|
|
2948
|
+
case "ArrowLeft":
|
|
2949
|
+
case "ArrowRight":
|
|
2950
|
+
this.#isMenubar && this.close();
|
|
2951
|
+
this.#dispatchTriggerKeyDown(key);
|
|
2952
|
+
break;
|
|
2964
2953
|
}
|
|
2965
2954
|
};
|
|
2966
2955
|
#onItemPointerEnter = (event) => {
|
|
@@ -3090,19 +3079,12 @@ var Menu = class _Menu {
|
|
|
3090
3079
|
this.#submenuTimer = void 0;
|
|
3091
3080
|
}
|
|
3092
3081
|
}
|
|
3093
|
-
#closeAndMoveFocus(direction) {
|
|
3094
|
-
this.close();
|
|
3095
|
-
requestAnimationFrame(
|
|
3096
|
-
() => this.#getTrigger()?.dispatchEvent(
|
|
3097
|
-
new KeyboardEvent("keydown", {
|
|
3098
|
-
key: direction === "previous" ? "ArrowLeft" : "ArrowRight"
|
|
3099
|
-
})
|
|
3100
|
-
)
|
|
3101
|
-
);
|
|
3102
|
-
}
|
|
3103
3082
|
#containsRoot(element) {
|
|
3104
3083
|
return this.#rootElement.contains(element) || !!this.#listElement?.contains(element);
|
|
3105
3084
|
}
|
|
3085
|
+
#dispatchTriggerKeyDown(key) {
|
|
3086
|
+
this.#getTrigger()?.dispatchEvent(new KeyboardEvent("keydown", { key }));
|
|
3087
|
+
}
|
|
3106
3088
|
#focusTrigger() {
|
|
3107
3089
|
const active = getActiveElement4();
|
|
3108
3090
|
if (!(active instanceof HTMLElement)) {
|
|
@@ -3266,7 +3248,7 @@ function isFocusable3(element) {
|
|
|
3266
3248
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3267
3249
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3268
3250
|
*
|
|
3269
|
-
* @version 1.5.
|
|
3251
|
+
* @version 1.5.7
|
|
3270
3252
|
* @author Yusuke Kamiyamane
|
|
3271
3253
|
* @license MIT
|
|
3272
3254
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ export { flip, offset, shift } from '@floating-ui/dom';
|
|
|
6
6
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
7
7
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
8
8
|
*
|
|
9
|
-
* @version 1.5.
|
|
9
|
+
* @version 1.5.7
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { flip, offset, shift } from '@floating-ui/dom';
|
|
|
6
6
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
7
7
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
8
8
|
*
|
|
9
|
-
* @version 1.5.
|
|
9
|
+
* @version 1.5.7
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -2923,40 +2923,29 @@ var Menu = class _Menu {
|
|
|
2923
2923
|
requestAnimationFrame(() => this.#focusTrigger());
|
|
2924
2924
|
return;
|
|
2925
2925
|
}
|
|
2926
|
-
if (![
|
|
2927
|
-
"Enter",
|
|
2928
|
-
"Escape",
|
|
2929
|
-
" ",
|
|
2930
|
-
"ArrowLeft",
|
|
2931
|
-
...this.#isMenubar ? ["ArrowRight"] : []
|
|
2932
|
-
].includes(key)) {
|
|
2926
|
+
if (!["Enter", "Escape", " ", "ArrowLeft", "ArrowRight"].includes(key)) {
|
|
2933
2927
|
return;
|
|
2934
2928
|
}
|
|
2935
2929
|
event.preventDefault();
|
|
2936
2930
|
event.stopPropagation();
|
|
2931
|
+
if (key === "Escape" || key === "ArrowLeft" && this.#isSubmenu) {
|
|
2932
|
+
this.close();
|
|
2933
|
+
return;
|
|
2934
|
+
}
|
|
2937
2935
|
const active = getActiveElement4();
|
|
2938
2936
|
if (!(active instanceof HTMLElement)) {
|
|
2939
2937
|
return;
|
|
2940
2938
|
}
|
|
2941
2939
|
switch (key) {
|
|
2942
|
-
case "Tab":
|
|
2943
|
-
case "Escape":
|
|
2944
|
-
this.close();
|
|
2945
|
-
return;
|
|
2946
|
-
case "ArrowLeft":
|
|
2947
|
-
if (this.#isMenubar) {
|
|
2948
|
-
this.#closeAndMoveFocus("previous");
|
|
2949
|
-
} else if (this.#isSubmenu && this.#triggerElement) {
|
|
2950
|
-
this.close();
|
|
2951
|
-
}
|
|
2952
|
-
return;
|
|
2953
|
-
case "ArrowRight":
|
|
2954
|
-
this.#closeAndMoveFocus("next");
|
|
2955
|
-
return;
|
|
2956
2940
|
case "Enter":
|
|
2957
2941
|
case " ":
|
|
2958
2942
|
active.click();
|
|
2959
|
-
|
|
2943
|
+
break;
|
|
2944
|
+
case "ArrowLeft":
|
|
2945
|
+
case "ArrowRight":
|
|
2946
|
+
this.#isMenubar && this.close();
|
|
2947
|
+
this.#dispatchTriggerKeyDown(key);
|
|
2948
|
+
break;
|
|
2960
2949
|
}
|
|
2961
2950
|
};
|
|
2962
2951
|
#onItemPointerEnter = (event) => {
|
|
@@ -3086,19 +3075,12 @@ var Menu = class _Menu {
|
|
|
3086
3075
|
this.#submenuTimer = void 0;
|
|
3087
3076
|
}
|
|
3088
3077
|
}
|
|
3089
|
-
#closeAndMoveFocus(direction) {
|
|
3090
|
-
this.close();
|
|
3091
|
-
requestAnimationFrame(
|
|
3092
|
-
() => this.#getTrigger()?.dispatchEvent(
|
|
3093
|
-
new KeyboardEvent("keydown", {
|
|
3094
|
-
key: direction === "previous" ? "ArrowLeft" : "ArrowRight"
|
|
3095
|
-
})
|
|
3096
|
-
)
|
|
3097
|
-
);
|
|
3098
|
-
}
|
|
3099
3078
|
#containsRoot(element) {
|
|
3100
3079
|
return this.#rootElement.contains(element) || !!this.#listElement?.contains(element);
|
|
3101
3080
|
}
|
|
3081
|
+
#dispatchTriggerKeyDown(key) {
|
|
3082
|
+
this.#getTrigger()?.dispatchEvent(new KeyboardEvent("keydown", { key }));
|
|
3083
|
+
}
|
|
3102
3084
|
#focusTrigger() {
|
|
3103
3085
|
const active = getActiveElement4();
|
|
3104
3086
|
if (!(active instanceof HTMLElement)) {
|
|
@@ -3262,7 +3244,7 @@ function isFocusable3(element) {
|
|
|
3262
3244
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3263
3245
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3264
3246
|
*
|
|
3265
|
-
* @version 1.5.
|
|
3247
|
+
* @version 1.5.7
|
|
3266
3248
|
* @author Yusuke Kamiyamane
|
|
3267
3249
|
* @license MIT
|
|
3268
3250
|
* @copyright Copyright (c) Yusuke Kamiyamane
|