@y14e/menu 1.5.3 → 1.5.4
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 +7 -6
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -6
- 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.4';
|
|
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.4';
|
|
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.4';
|
|
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.4/+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.4';
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Usage
|
package/dist/index.cjs
CHANGED
|
@@ -2627,6 +2627,7 @@ var Menu = class _Menu {
|
|
|
2627
2627
|
#isMenubar;
|
|
2628
2628
|
#isPortal;
|
|
2629
2629
|
#isSubmenu;
|
|
2630
|
+
#popoverRef;
|
|
2630
2631
|
#triggerElement;
|
|
2631
2632
|
#listElement;
|
|
2632
2633
|
#itemElements;
|
|
@@ -2669,6 +2670,7 @@ var Menu = class _Menu {
|
|
|
2669
2670
|
this.#triggerElement = this.#rootElement.querySelector(
|
|
2670
2671
|
selector[this.#isSubmenu ? "item" : "trigger"]
|
|
2671
2672
|
);
|
|
2673
|
+
this.#popoverRef = _internal.popoverRef ?? this.#triggerElement;
|
|
2672
2674
|
this.#listElement = this.#rootElement.querySelector(
|
|
2673
2675
|
selector.list
|
|
2674
2676
|
);
|
|
@@ -3162,15 +3164,15 @@ var Menu = class _Menu {
|
|
|
3162
3164
|
}
|
|
3163
3165
|
}
|
|
3164
3166
|
#updatePopover() {
|
|
3165
|
-
if (!this.#
|
|
3167
|
+
if (!this.#popoverRef) {
|
|
3166
3168
|
return;
|
|
3167
3169
|
}
|
|
3168
3170
|
const compute = () => {
|
|
3169
|
-
if (!this.#
|
|
3171
|
+
if (!this.#popoverRef || !this.#listElement) {
|
|
3170
3172
|
return;
|
|
3171
3173
|
}
|
|
3172
3174
|
const options = this.#settings.popover[this.#isSubmenu ? "submenu" : "menu"];
|
|
3173
|
-
computePosition2(this.#
|
|
3175
|
+
computePosition2(this.#popoverRef, this.#listElement, {
|
|
3174
3176
|
...options,
|
|
3175
3177
|
placement: options.placement
|
|
3176
3178
|
}).then(
|
|
@@ -3238,10 +3240,9 @@ var Menu = class _Menu {
|
|
|
3238
3240
|
}
|
|
3239
3241
|
);
|
|
3240
3242
|
};
|
|
3241
|
-
compute();
|
|
3242
3243
|
if (!this.#cleanupPopover) {
|
|
3243
3244
|
this.#cleanupPopover = autoUpdate(
|
|
3244
|
-
this.#
|
|
3245
|
+
this.#popoverRef,
|
|
3245
3246
|
this.#listElement,
|
|
3246
3247
|
compute
|
|
3247
3248
|
);
|
|
@@ -3263,7 +3264,7 @@ function isFocusable3(element) {
|
|
|
3263
3264
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3264
3265
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3265
3266
|
*
|
|
3266
|
-
* @version 1.5.
|
|
3267
|
+
* @version 1.5.4
|
|
3267
3268
|
* @author Yusuke Kamiyamane
|
|
3268
3269
|
* @license MIT
|
|
3269
3270
|
* @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.4
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -42,6 +42,7 @@ interface InternalOptions {
|
|
|
42
42
|
readonly isMenubar?: boolean;
|
|
43
43
|
readonly isPortal?: boolean;
|
|
44
44
|
readonly isSubmenu?: boolean;
|
|
45
|
+
readonly popoverRef?: HTMLElement | null;
|
|
45
46
|
}
|
|
46
47
|
declare class Menu {
|
|
47
48
|
#private;
|
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.4
|
|
10
10
|
* @author Yusuke Kamiyamane
|
|
11
11
|
* @license MIT
|
|
12
12
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
|
@@ -42,6 +42,7 @@ interface InternalOptions {
|
|
|
42
42
|
readonly isMenubar?: boolean;
|
|
43
43
|
readonly isPortal?: boolean;
|
|
44
44
|
readonly isSubmenu?: boolean;
|
|
45
|
+
readonly popoverRef?: HTMLElement | null;
|
|
45
46
|
}
|
|
46
47
|
declare class Menu {
|
|
47
48
|
#private;
|
package/dist/index.js
CHANGED
|
@@ -2623,6 +2623,7 @@ var Menu = class _Menu {
|
|
|
2623
2623
|
#isMenubar;
|
|
2624
2624
|
#isPortal;
|
|
2625
2625
|
#isSubmenu;
|
|
2626
|
+
#popoverRef;
|
|
2626
2627
|
#triggerElement;
|
|
2627
2628
|
#listElement;
|
|
2628
2629
|
#itemElements;
|
|
@@ -2665,6 +2666,7 @@ var Menu = class _Menu {
|
|
|
2665
2666
|
this.#triggerElement = this.#rootElement.querySelector(
|
|
2666
2667
|
selector[this.#isSubmenu ? "item" : "trigger"]
|
|
2667
2668
|
);
|
|
2669
|
+
this.#popoverRef = _internal.popoverRef ?? this.#triggerElement;
|
|
2668
2670
|
this.#listElement = this.#rootElement.querySelector(
|
|
2669
2671
|
selector.list
|
|
2670
2672
|
);
|
|
@@ -3158,15 +3160,15 @@ var Menu = class _Menu {
|
|
|
3158
3160
|
}
|
|
3159
3161
|
}
|
|
3160
3162
|
#updatePopover() {
|
|
3161
|
-
if (!this.#
|
|
3163
|
+
if (!this.#popoverRef) {
|
|
3162
3164
|
return;
|
|
3163
3165
|
}
|
|
3164
3166
|
const compute = () => {
|
|
3165
|
-
if (!this.#
|
|
3167
|
+
if (!this.#popoverRef || !this.#listElement) {
|
|
3166
3168
|
return;
|
|
3167
3169
|
}
|
|
3168
3170
|
const options = this.#settings.popover[this.#isSubmenu ? "submenu" : "menu"];
|
|
3169
|
-
computePosition2(this.#
|
|
3171
|
+
computePosition2(this.#popoverRef, this.#listElement, {
|
|
3170
3172
|
...options,
|
|
3171
3173
|
placement: options.placement
|
|
3172
3174
|
}).then(
|
|
@@ -3234,10 +3236,9 @@ var Menu = class _Menu {
|
|
|
3234
3236
|
}
|
|
3235
3237
|
);
|
|
3236
3238
|
};
|
|
3237
|
-
compute();
|
|
3238
3239
|
if (!this.#cleanupPopover) {
|
|
3239
3240
|
this.#cleanupPopover = autoUpdate(
|
|
3240
|
-
this.#
|
|
3241
|
+
this.#popoverRef,
|
|
3241
3242
|
this.#listElement,
|
|
3242
3243
|
compute
|
|
3243
3244
|
);
|
|
@@ -3259,7 +3260,7 @@ function isFocusable3(element) {
|
|
|
3259
3260
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3260
3261
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3261
3262
|
*
|
|
3262
|
-
* @version 1.5.
|
|
3263
|
+
* @version 1.5.4
|
|
3263
3264
|
* @author Yusuke Kamiyamane
|
|
3264
3265
|
* @license MIT
|
|
3265
3266
|
* @copyright Copyright (c) Yusuke Kamiyamane
|