@astralui/core 0.1.14 → 0.1.15
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 +1 -1
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ notifications.update({ id: 'x', message: 'Done', color: 'green', loading: false,
|
|
|
90
90
|
|---|---|
|
|
91
91
|
| `AstralModal` / `AstralDrawer` | Portalled, centered modal / right drawer (escape + click-outside). |
|
|
92
92
|
| `AstralSelect` | Single-select combobox (searchable / clearable / creatable). |
|
|
93
|
-
| `AstralMenu` | Anchored dropdown menu (items array). |
|
|
93
|
+
| `AstralMenu` | Anchored dropdown menu (items array). Closes on an outside click or Escape; inside a dialog, Escape closes the menu only. |
|
|
94
94
|
| `AstralPinInput` | Code/OTP input. |
|
|
95
95
|
| `DateInput` | Freeze-proof native date / datetime-local input. |
|
|
96
96
|
| `Spinner` | Theme-aware loading spinner. |
|
package/dist/index.cjs
CHANGED
|
@@ -616,12 +616,21 @@ function AstralMenu({ trigger, items, align = "end", width = 220 }) {
|
|
|
616
616
|
if (menuRef.current?.contains(e.target)) return;
|
|
617
617
|
setOpen(false);
|
|
618
618
|
};
|
|
619
|
+
const onKey = (e) => {
|
|
620
|
+
if (e.key !== "Escape") return;
|
|
621
|
+
e.preventDefault();
|
|
622
|
+
e.stopPropagation();
|
|
623
|
+
setOpen(false);
|
|
624
|
+
anchorRef.current?.querySelector(FOCUSABLE)?.focus();
|
|
625
|
+
};
|
|
619
626
|
window.addEventListener("scroll", onScroll, true);
|
|
620
627
|
window.addEventListener("resize", onResize);
|
|
628
|
+
window.addEventListener("keydown", onKey, true);
|
|
621
629
|
document.addEventListener("mousedown", onDoc, true);
|
|
622
630
|
return () => {
|
|
623
631
|
window.removeEventListener("scroll", onScroll, true);
|
|
624
632
|
window.removeEventListener("resize", onResize);
|
|
633
|
+
window.removeEventListener("keydown", onKey, true);
|
|
625
634
|
document.removeEventListener("mousedown", onDoc, true);
|
|
626
635
|
};
|
|
627
636
|
}, [open, reposition]);
|