infinity-ui-elements 1.8.44 → 1.8.45
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/components/SidePanel/SidePanel.d.ts.map +1 -1
- package/dist/index.esm.js +25 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3824,6 +3824,8 @@ SearchableDropdown.displayName = "SearchableDropdown";
|
|
|
3824
3824
|
const SidePanel = React__namespace.forwardRef(({ isOpen, onClose, title, titleIcon, description, footer, children, position = "right", width = "medium", showCloseButton = true, headerActions, closeOnOverlayClick = true, closeOnEscape = true, className, contentClassName, headerClassName, bodyClassName, footerClassName, overlayClassName, ariaLabel, ariaDescribedBy, }, ref) => {
|
|
3825
3825
|
const panelRef = React__namespace.useRef(null);
|
|
3826
3826
|
const contentRef = ref || panelRef;
|
|
3827
|
+
const [isVisible, setIsVisible] = React__namespace.useState(false);
|
|
3828
|
+
const [shouldRender, setShouldRender] = React__namespace.useState(false);
|
|
3827
3829
|
// Width configurations
|
|
3828
3830
|
const widthConfig = {
|
|
3829
3831
|
small: "w-80",
|
|
@@ -3831,15 +3833,33 @@ const SidePanel = React__namespace.forwardRef(({ isOpen, onClose, title, titleIc
|
|
|
3831
3833
|
large: "w-[32rem]",
|
|
3832
3834
|
xlarge: "w-[40rem]",
|
|
3833
3835
|
};
|
|
3836
|
+
// Handle mounting and unmounting with animation
|
|
3837
|
+
React__namespace.useEffect(() => {
|
|
3838
|
+
if (isOpen) {
|
|
3839
|
+
setShouldRender(true);
|
|
3840
|
+
// Small delay to trigger animation
|
|
3841
|
+
requestAnimationFrame(() => {
|
|
3842
|
+
setIsVisible(true);
|
|
3843
|
+
});
|
|
3844
|
+
}
|
|
3845
|
+
else {
|
|
3846
|
+
setIsVisible(false);
|
|
3847
|
+
// Wait for animation to complete before unmounting
|
|
3848
|
+
const timer = setTimeout(() => {
|
|
3849
|
+
setShouldRender(false);
|
|
3850
|
+
}, 300); // Match animation duration
|
|
3851
|
+
return () => clearTimeout(timer);
|
|
3852
|
+
}
|
|
3853
|
+
}, [isOpen]);
|
|
3834
3854
|
// Position-based classes
|
|
3835
3855
|
const positionClasses = {
|
|
3836
3856
|
left: {
|
|
3837
3857
|
container: "justify-start",
|
|
3838
|
-
panel:
|
|
3858
|
+
panel: isVisible ? "animate-slide-in-left" : "animate-slide-out-left",
|
|
3839
3859
|
},
|
|
3840
3860
|
right: {
|
|
3841
3861
|
container: "justify-end",
|
|
3842
|
-
panel:
|
|
3862
|
+
panel: isVisible ? "animate-slide-in-right" : "animate-slide-out-right",
|
|
3843
3863
|
},
|
|
3844
3864
|
};
|
|
3845
3865
|
// Handle escape key
|
|
@@ -3872,14 +3892,14 @@ const SidePanel = React__namespace.forwardRef(({ isOpen, onClose, title, titleIc
|
|
|
3872
3892
|
onClose();
|
|
3873
3893
|
}
|
|
3874
3894
|
};
|
|
3875
|
-
// Don't render if not open
|
|
3876
|
-
if (!
|
|
3895
|
+
// Don't render if not open and animation is complete
|
|
3896
|
+
if (!shouldRender)
|
|
3877
3897
|
return null;
|
|
3878
3898
|
const hasHeader = title || description;
|
|
3879
3899
|
const widthClass = width in widthConfig
|
|
3880
3900
|
? widthConfig[width]
|
|
3881
3901
|
: width;
|
|
3882
|
-
return (jsxRuntime.jsxs("div", { className: cn("fixed inset-0 z-10000 flex
|
|
3902
|
+
return (jsxRuntime.jsxs("div", { className: cn("fixed inset-0 z-10000 flex p-4", positionClasses[position].container, className), role: "dialog", "aria-modal": "true", "aria-label": ariaLabel || title, "aria-describedby": ariaDescribedBy, children: [jsxRuntime.jsx("div", { className: cn("absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity duration-300", isVisible ? "opacity-100" : "opacity-0", overlayClassName), onClick: handleOverlayClick, "aria-hidden": "true" }), jsxRuntime.jsxs("div", { ref: contentRef, className: cn("relative bg-white shadow-2xl transition-transform duration-300 ease-out rounded-large", "flex flex-col max-w-full h-full overflow-hidden", widthClass, positionClasses[position].panel, contentClassName), children: [hasHeader && (jsxRuntime.jsxs("div", { className: cn("flex items-center justify-between gap-4 px-7 py-5 shrink-0 border-b border-surface-outline-neutral-subtle", headerClassName), children: [jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-1 min-w-0", children: [titleIcon && (jsxRuntime.jsx("div", { className: "flex items-center justify-center shrink-0", children: typeof titleIcon === "string" ? (jsxRuntime.jsx(Icon, { name: titleIcon, size: 20 })) : (titleIcon) })), jsxRuntime.jsxs("div", { className: "flex flex-col flex-1 min-w-0", children: [title && (jsxRuntime.jsx(Text, { as: "h2", variant: "body", size: "large", weight: "semibold", color: "default", className: "truncate", children: title })), description && (jsxRuntime.jsx(Text, { as: "p", variant: "body", size: "small", weight: "regular", color: "subtle", className: "mt-0.5", children: description }))] })] }), jsxRuntime.jsxs("div", { className: "flex items-center gap-2 shrink-0", children: [headerActions, showCloseButton && onClose && (jsxRuntime.jsx(IconButton, { icon: "close", onClick: onClose, color: "neutral", size: "small", "aria-label": "Close side panel" }))] })] })), !hasHeader && showCloseButton && onClose && (jsxRuntime.jsx("div", { className: "absolute top-4 right-4 z-10", children: jsxRuntime.jsx(IconButton, { icon: "close", onClick: onClose, color: "neutral", size: "small", "aria-label": "Close side panel" }) })), jsxRuntime.jsx("div", { className: cn("flex-1 overflow-y-auto px-6", hasHeader ? "py-6" : "pt-6 pb-4", !footer && "pb-6", bodyClassName), children: children }), footer && (jsxRuntime.jsxs("div", { className: "flex flex-col shrink-0", children: [jsxRuntime.jsx(Divider, { thickness: "thin", variant: "muted" }), jsxRuntime.jsx("div", { className: cn("flex items-center justify-end gap-3 px-6 py-4", footerClassName), children: footer })] }))] })] }));
|
|
3883
3903
|
});
|
|
3884
3904
|
SidePanel.displayName = "SidePanel";
|
|
3885
3905
|
|