@underverse-ui/underverse 0.2.18 → 0.2.19
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/dist/index.cjs +30 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2406,29 +2406,28 @@ var useToast = () => {
|
|
|
2406
2406
|
}
|
|
2407
2407
|
return context;
|
|
2408
2408
|
};
|
|
2409
|
-
var ToastProvider = ({
|
|
2410
|
-
children,
|
|
2411
|
-
position = "top-right",
|
|
2412
|
-
maxToasts = 5
|
|
2413
|
-
}) => {
|
|
2409
|
+
var ToastProvider = ({ children, position = "top-right", maxToasts = 5 }) => {
|
|
2414
2410
|
const [toasts, setToasts] = (0, import_react7.useState)([]);
|
|
2415
2411
|
const idRef = (0, import_react7.useRef)(0);
|
|
2416
2412
|
const removeToast = (0, import_react7.useCallback)((id) => {
|
|
2417
2413
|
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
2418
2414
|
}, []);
|
|
2419
|
-
const addToast = (0, import_react7.useCallback)(
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2415
|
+
const addToast = (0, import_react7.useCallback)(
|
|
2416
|
+
(toast) => {
|
|
2417
|
+
const id = `toast-${++idRef.current}`;
|
|
2418
|
+
const newToast = { ...toast, id };
|
|
2419
|
+
setToasts((prev) => {
|
|
2420
|
+
const updated = [newToast, ...prev];
|
|
2421
|
+
return updated.slice(0, maxToasts);
|
|
2422
|
+
});
|
|
2423
|
+
if (toast.duration !== 0) {
|
|
2424
|
+
setTimeout(() => {
|
|
2425
|
+
removeToast(id);
|
|
2426
|
+
}, toast.duration || 5e3);
|
|
2427
|
+
}
|
|
2428
|
+
},
|
|
2429
|
+
[maxToasts, removeToast]
|
|
2430
|
+
);
|
|
2432
2431
|
const positionClasses = {
|
|
2433
2432
|
"top-right": "top-4 right-4",
|
|
2434
2433
|
"top-left": "top-4 left-4",
|
|
@@ -2439,7 +2438,7 @@ var ToastProvider = ({
|
|
|
2439
2438
|
};
|
|
2440
2439
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(ToastContext.Provider, { value: { addToast, removeToast, toasts }, children: [
|
|
2441
2440
|
children,
|
|
2442
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cn("fixed z-
|
|
2441
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cn("fixed z-[99999] flex flex-col gap-2 pointer-events-none", positionClasses[position]), "aria-live": "polite", "aria-atomic": true, children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ToastComponent, { toast, onRemove: removeToast }, toast.id)) })
|
|
2443
2442
|
] });
|
|
2444
2443
|
};
|
|
2445
2444
|
var ToastComponent = ({ toast, onRemove }) => {
|
|
@@ -3880,36 +3879,34 @@ var DropdownMenu = ({
|
|
|
3880
3879
|
if (open && triggerRef.current && contentRef.current) {
|
|
3881
3880
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
3882
3881
|
const menuRect = contentRef.current.getBoundingClientRect();
|
|
3883
|
-
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
3884
|
-
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
3885
3882
|
const viewportHeight = window.innerHeight;
|
|
3886
|
-
let top = rect.bottom +
|
|
3887
|
-
let left = rect.left
|
|
3883
|
+
let top = rect.bottom + 4;
|
|
3884
|
+
let left = rect.left;
|
|
3888
3885
|
if (rect.bottom + menuRect.height > viewportHeight && rect.top > menuRect.height) {
|
|
3889
|
-
top = rect.top
|
|
3886
|
+
top = rect.top - menuRect.height - 4;
|
|
3890
3887
|
}
|
|
3891
3888
|
switch (placement) {
|
|
3892
3889
|
case "top":
|
|
3893
3890
|
case "top-start":
|
|
3894
|
-
top = rect.top
|
|
3891
|
+
top = rect.top - menuRect.height - 4;
|
|
3895
3892
|
break;
|
|
3896
3893
|
case "top-end":
|
|
3897
|
-
top = rect.top
|
|
3898
|
-
left = rect.right
|
|
3894
|
+
top = rect.top - menuRect.height - 4;
|
|
3895
|
+
left = rect.right - menuRect.width;
|
|
3899
3896
|
break;
|
|
3900
3897
|
case "bottom":
|
|
3901
3898
|
case "bottom-start":
|
|
3902
3899
|
break;
|
|
3903
3900
|
case "bottom-end":
|
|
3904
|
-
left = rect.right
|
|
3901
|
+
left = rect.right - menuRect.width;
|
|
3905
3902
|
break;
|
|
3906
3903
|
case "left":
|
|
3907
|
-
top = rect.top
|
|
3908
|
-
left = rect.left
|
|
3904
|
+
top = rect.top;
|
|
3905
|
+
left = rect.left - menuRect.width - 4;
|
|
3909
3906
|
break;
|
|
3910
3907
|
case "right":
|
|
3911
|
-
top = rect.top
|
|
3912
|
-
left = rect.right +
|
|
3908
|
+
top = rect.top;
|
|
3909
|
+
left = rect.right + 4;
|
|
3913
3910
|
break;
|
|
3914
3911
|
}
|
|
3915
3912
|
setPosition({ top, left });
|
|
@@ -3983,7 +3980,7 @@ var DropdownMenu = ({
|
|
|
3983
3980
|
"data-combobox-dropdown": true,
|
|
3984
3981
|
ref: contentRef,
|
|
3985
3982
|
style: {
|
|
3986
|
-
position: "
|
|
3983
|
+
position: "fixed",
|
|
3987
3984
|
top: position?.top ?? -9999,
|
|
3988
3985
|
left: position?.left ?? -9999,
|
|
3989
3986
|
zIndex: 9999,
|