@y14e/menu 1.5.0 → 1.5.1
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 +8 -7
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +8 -7
- 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.1';
|
|
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.1';
|
|
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.1';
|
|
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.1/+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.1';
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Usage
|
package/dist/index.cjs
CHANGED
|
@@ -2718,8 +2718,8 @@ var Menu = class _Menu {
|
|
|
2718
2718
|
}
|
|
2719
2719
|
this.#initialize();
|
|
2720
2720
|
}
|
|
2721
|
-
open(
|
|
2722
|
-
this.#toggle(true,
|
|
2721
|
+
open(_initialFocus = "first") {
|
|
2722
|
+
this.#toggle(true, { initialFocus: _initialFocus });
|
|
2723
2723
|
}
|
|
2724
2724
|
close() {
|
|
2725
2725
|
this.#toggle(false);
|
|
@@ -2919,7 +2919,7 @@ var Menu = class _Menu {
|
|
|
2919
2919
|
}
|
|
2920
2920
|
event.preventDefault();
|
|
2921
2921
|
event.stopPropagation();
|
|
2922
|
-
this.open(key === "
|
|
2922
|
+
this.open(key === "ArrowDown" ? "first" : "last");
|
|
2923
2923
|
};
|
|
2924
2924
|
#onListKeyDown = (event) => {
|
|
2925
2925
|
const { shiftKey, key } = event;
|
|
@@ -3000,7 +3000,7 @@ var Menu = class _Menu {
|
|
|
3000
3000
|
i.setAttribute("aria-checked", String(i === item));
|
|
3001
3001
|
});
|
|
3002
3002
|
};
|
|
3003
|
-
#toggle(isOpen,
|
|
3003
|
+
#toggle(isOpen, options = {}) {
|
|
3004
3004
|
if (this.#triggerElement?.ariaExpanded === String(isOpen)) {
|
|
3005
3005
|
return;
|
|
3006
3006
|
}
|
|
@@ -3025,7 +3025,8 @@ var Menu = class _Menu {
|
|
|
3025
3025
|
style.setProperty("display", "block");
|
|
3026
3026
|
style.setProperty("opacity", "0");
|
|
3027
3027
|
this.#triggerElement && this.#updatePopover();
|
|
3028
|
-
|
|
3028
|
+
const { initialFocus = "first" } = options;
|
|
3029
|
+
this.#itemElements.filter(isFocusable3).at(initialFocus === "first" ? 0 : -1)?.focus();
|
|
3029
3030
|
} else {
|
|
3030
3031
|
this.#clearSubmenuTimer();
|
|
3031
3032
|
this.#focusTrigger();
|
|
@@ -3101,7 +3102,7 @@ var Menu = class _Menu {
|
|
|
3101
3102
|
);
|
|
3102
3103
|
}
|
|
3103
3104
|
#containsRoot(element) {
|
|
3104
|
-
return this.#rootElement.contains(element) || this.#listElement?.contains(element);
|
|
3105
|
+
return this.#rootElement.contains(element) || !!this.#listElement?.contains(element);
|
|
3105
3106
|
}
|
|
3106
3107
|
#focusTrigger() {
|
|
3107
3108
|
const active = getActiveElement4();
|
|
@@ -3264,7 +3265,7 @@ function isFocusable3(element) {
|
|
|
3264
3265
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3265
3266
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3266
3267
|
*
|
|
3267
|
-
* @version 1.5.
|
|
3268
|
+
* @version 1.5.1
|
|
3268
3269
|
* @author Yusuke Kamiyamane
|
|
3269
3270
|
* @license MIT
|
|
3270
3271
|
* @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.1
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -51,7 +51,11 @@ declare class Menu {
|
|
|
51
51
|
* @internal Internal constructor
|
|
52
52
|
*/
|
|
53
53
|
constructor(root: HTMLElement, options?: MenuOptions, _internal?: InternalOptions);
|
|
54
|
-
open(
|
|
54
|
+
open(): void;
|
|
55
|
+
/**
|
|
56
|
+
* @internal Internal open
|
|
57
|
+
*/
|
|
58
|
+
open(_initialFocus?: 'first' | 'last'): void;
|
|
55
59
|
close(): void;
|
|
56
60
|
destroy(force?: boolean): Promise<void>;
|
|
57
61
|
}
|
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.1
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -51,7 +51,11 @@ declare class Menu {
|
|
|
51
51
|
* @internal Internal constructor
|
|
52
52
|
*/
|
|
53
53
|
constructor(root: HTMLElement, options?: MenuOptions, _internal?: InternalOptions);
|
|
54
|
-
open(
|
|
54
|
+
open(): void;
|
|
55
|
+
/**
|
|
56
|
+
* @internal Internal open
|
|
57
|
+
*/
|
|
58
|
+
open(_initialFocus?: 'first' | 'last'): void;
|
|
55
59
|
close(): void;
|
|
56
60
|
destroy(force?: boolean): Promise<void>;
|
|
57
61
|
}
|
package/dist/index.js
CHANGED
|
@@ -2714,8 +2714,8 @@ var Menu = class _Menu {
|
|
|
2714
2714
|
}
|
|
2715
2715
|
this.#initialize();
|
|
2716
2716
|
}
|
|
2717
|
-
open(
|
|
2718
|
-
this.#toggle(true,
|
|
2717
|
+
open(_initialFocus = "first") {
|
|
2718
|
+
this.#toggle(true, { initialFocus: _initialFocus });
|
|
2719
2719
|
}
|
|
2720
2720
|
close() {
|
|
2721
2721
|
this.#toggle(false);
|
|
@@ -2915,7 +2915,7 @@ var Menu = class _Menu {
|
|
|
2915
2915
|
}
|
|
2916
2916
|
event.preventDefault();
|
|
2917
2917
|
event.stopPropagation();
|
|
2918
|
-
this.open(key === "
|
|
2918
|
+
this.open(key === "ArrowDown" ? "first" : "last");
|
|
2919
2919
|
};
|
|
2920
2920
|
#onListKeyDown = (event) => {
|
|
2921
2921
|
const { shiftKey, key } = event;
|
|
@@ -2996,7 +2996,7 @@ var Menu = class _Menu {
|
|
|
2996
2996
|
i.setAttribute("aria-checked", String(i === item));
|
|
2997
2997
|
});
|
|
2998
2998
|
};
|
|
2999
|
-
#toggle(isOpen,
|
|
2999
|
+
#toggle(isOpen, options = {}) {
|
|
3000
3000
|
if (this.#triggerElement?.ariaExpanded === String(isOpen)) {
|
|
3001
3001
|
return;
|
|
3002
3002
|
}
|
|
@@ -3021,7 +3021,8 @@ var Menu = class _Menu {
|
|
|
3021
3021
|
style.setProperty("display", "block");
|
|
3022
3022
|
style.setProperty("opacity", "0");
|
|
3023
3023
|
this.#triggerElement && this.#updatePopover();
|
|
3024
|
-
|
|
3024
|
+
const { initialFocus = "first" } = options;
|
|
3025
|
+
this.#itemElements.filter(isFocusable3).at(initialFocus === "first" ? 0 : -1)?.focus();
|
|
3025
3026
|
} else {
|
|
3026
3027
|
this.#clearSubmenuTimer();
|
|
3027
3028
|
this.#focusTrigger();
|
|
@@ -3097,7 +3098,7 @@ var Menu = class _Menu {
|
|
|
3097
3098
|
);
|
|
3098
3099
|
}
|
|
3099
3100
|
#containsRoot(element) {
|
|
3100
|
-
return this.#rootElement.contains(element) || this.#listElement?.contains(element);
|
|
3101
|
+
return this.#rootElement.contains(element) || !!this.#listElement?.contains(element);
|
|
3101
3102
|
}
|
|
3102
3103
|
#focusTrigger() {
|
|
3103
3104
|
const active = getActiveElement4();
|
|
@@ -3260,7 +3261,7 @@ function isFocusable3(element) {
|
|
|
3260
3261
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3261
3262
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3262
3263
|
*
|
|
3263
|
-
* @version 1.5.
|
|
3264
|
+
* @version 1.5.1
|
|
3264
3265
|
* @author Yusuke Kamiyamane
|
|
3265
3266
|
* @license MIT
|
|
3266
3267
|
* @copyright Copyright (c) Yusuke Kamiyamane
|