@y14e/menu 1.5.3 → 1.5.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/README.md +5 -5
- package/dist/index.cjs +10 -7
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +10 -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.5';
|
|
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.5';
|
|
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.5';
|
|
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.5/+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.5';
|
|
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
|
);
|
|
@@ -3010,7 +3012,9 @@ var Menu = class _Menu {
|
|
|
3010
3012
|
if (!this.#isPortal || !this.#isSubmenu && this.#triggerElement) {
|
|
3011
3013
|
const style2 = this.#listElement.style;
|
|
3012
3014
|
style2.setProperty("position", "fixed");
|
|
3013
|
-
|
|
3015
|
+
if (!this.#cleanupPortal) {
|
|
3016
|
+
this.#cleanupPortal = createPortal(this.#listElement);
|
|
3017
|
+
}
|
|
3014
3018
|
requestAnimationFrame(() => style2.removeProperty("position"));
|
|
3015
3019
|
}
|
|
3016
3020
|
requestAnimationFrame(
|
|
@@ -3162,15 +3166,15 @@ var Menu = class _Menu {
|
|
|
3162
3166
|
}
|
|
3163
3167
|
}
|
|
3164
3168
|
#updatePopover() {
|
|
3165
|
-
if (!this.#
|
|
3169
|
+
if (!this.#popoverRef) {
|
|
3166
3170
|
return;
|
|
3167
3171
|
}
|
|
3168
3172
|
const compute = () => {
|
|
3169
|
-
if (!this.#
|
|
3173
|
+
if (!this.#popoverRef || !this.#listElement) {
|
|
3170
3174
|
return;
|
|
3171
3175
|
}
|
|
3172
3176
|
const options = this.#settings.popover[this.#isSubmenu ? "submenu" : "menu"];
|
|
3173
|
-
computePosition2(this.#
|
|
3177
|
+
computePosition2(this.#popoverRef, this.#listElement, {
|
|
3174
3178
|
...options,
|
|
3175
3179
|
placement: options.placement
|
|
3176
3180
|
}).then(
|
|
@@ -3238,10 +3242,9 @@ var Menu = class _Menu {
|
|
|
3238
3242
|
}
|
|
3239
3243
|
);
|
|
3240
3244
|
};
|
|
3241
|
-
compute();
|
|
3242
3245
|
if (!this.#cleanupPopover) {
|
|
3243
3246
|
this.#cleanupPopover = autoUpdate(
|
|
3244
|
-
this.#
|
|
3247
|
+
this.#popoverRef,
|
|
3245
3248
|
this.#listElement,
|
|
3246
3249
|
compute
|
|
3247
3250
|
);
|
|
@@ -3263,7 +3266,7 @@ function isFocusable3(element) {
|
|
|
3263
3266
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3264
3267
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3265
3268
|
*
|
|
3266
|
-
* @version 1.5.
|
|
3269
|
+
* @version 1.5.5
|
|
3267
3270
|
* @author Yusuke Kamiyamane
|
|
3268
3271
|
* @license MIT
|
|
3269
3272
|
* @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.5
|
|
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.5
|
|
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
|
);
|
|
@@ -3006,7 +3008,9 @@ var Menu = class _Menu {
|
|
|
3006
3008
|
if (!this.#isPortal || !this.#isSubmenu && this.#triggerElement) {
|
|
3007
3009
|
const style2 = this.#listElement.style;
|
|
3008
3010
|
style2.setProperty("position", "fixed");
|
|
3009
|
-
|
|
3011
|
+
if (!this.#cleanupPortal) {
|
|
3012
|
+
this.#cleanupPortal = createPortal(this.#listElement);
|
|
3013
|
+
}
|
|
3010
3014
|
requestAnimationFrame(() => style2.removeProperty("position"));
|
|
3011
3015
|
}
|
|
3012
3016
|
requestAnimationFrame(
|
|
@@ -3158,15 +3162,15 @@ var Menu = class _Menu {
|
|
|
3158
3162
|
}
|
|
3159
3163
|
}
|
|
3160
3164
|
#updatePopover() {
|
|
3161
|
-
if (!this.#
|
|
3165
|
+
if (!this.#popoverRef) {
|
|
3162
3166
|
return;
|
|
3163
3167
|
}
|
|
3164
3168
|
const compute = () => {
|
|
3165
|
-
if (!this.#
|
|
3169
|
+
if (!this.#popoverRef || !this.#listElement) {
|
|
3166
3170
|
return;
|
|
3167
3171
|
}
|
|
3168
3172
|
const options = this.#settings.popover[this.#isSubmenu ? "submenu" : "menu"];
|
|
3169
|
-
computePosition2(this.#
|
|
3173
|
+
computePosition2(this.#popoverRef, this.#listElement, {
|
|
3170
3174
|
...options,
|
|
3171
3175
|
placement: options.placement
|
|
3172
3176
|
}).then(
|
|
@@ -3234,10 +3238,9 @@ var Menu = class _Menu {
|
|
|
3234
3238
|
}
|
|
3235
3239
|
);
|
|
3236
3240
|
};
|
|
3237
|
-
compute();
|
|
3238
3241
|
if (!this.#cleanupPopover) {
|
|
3239
3242
|
this.#cleanupPopover = autoUpdate(
|
|
3240
|
-
this.#
|
|
3243
|
+
this.#popoverRef,
|
|
3241
3244
|
this.#listElement,
|
|
3242
3245
|
compute
|
|
3243
3246
|
);
|
|
@@ -3259,7 +3262,7 @@ function isFocusable3(element) {
|
|
|
3259
3262
|
* WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
|
|
3260
3263
|
* Supports checkbox item, radio item, and infinitely nested menus.
|
|
3261
3264
|
*
|
|
3262
|
-
* @version 1.5.
|
|
3265
|
+
* @version 1.5.5
|
|
3263
3266
|
* @author Yusuke Kamiyamane
|
|
3264
3267
|
* @license MIT
|
|
3265
3268
|
* @copyright Copyright (c) Yusuke Kamiyamane
|