@astralui/core 0.1.13 → 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 +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +11 -1
- 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]);
|
|
@@ -763,7 +772,7 @@ function dateTimeToInputStr(d) {
|
|
|
763
772
|
if (!d || isNaN(d.getTime())) return "";
|
|
764
773
|
return `${dateToInputStr(d)}T${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
|
|
765
774
|
}
|
|
766
|
-
function DateInput({ type = "date", value, onChange, min, max, className, style, disabled, "aria-label": ariaLabel }) {
|
|
775
|
+
function DateInput({ type = "date", value, onChange, min, max, className, style, disabled, id, "aria-label": ariaLabel }) {
|
|
767
776
|
const isTime = type === "datetime-local";
|
|
768
777
|
const fmt = isTime ? dateTimeToInputStr : dateToInputStr;
|
|
769
778
|
const [s, setS] = react.useState(() => fmt(value));
|
|
@@ -792,6 +801,7 @@ function DateInput({ type = "date", value, onChange, min, max, className, style,
|
|
|
792
801
|
className,
|
|
793
802
|
style,
|
|
794
803
|
disabled,
|
|
804
|
+
id,
|
|
795
805
|
"aria-label": ariaLabel,
|
|
796
806
|
value: s,
|
|
797
807
|
min: min ? fmt(min) : void 0,
|