infinity-ui-elements 1.8.43 → 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/index.js CHANGED
@@ -3821,6 +3821,88 @@ const SearchableDropdown = React__namespace.forwardRef(({ className, items = [],
3821
3821
  });
3822
3822
  SearchableDropdown.displayName = "SearchableDropdown";
3823
3823
 
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
+ const panelRef = React__namespace.useRef(null);
3826
+ const contentRef = ref || panelRef;
3827
+ const [isVisible, setIsVisible] = React__namespace.useState(false);
3828
+ const [shouldRender, setShouldRender] = React__namespace.useState(false);
3829
+ // Width configurations
3830
+ const widthConfig = {
3831
+ small: "w-80",
3832
+ medium: "w-96",
3833
+ large: "w-[32rem]",
3834
+ xlarge: "w-[40rem]",
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]);
3854
+ // Position-based classes
3855
+ const positionClasses = {
3856
+ left: {
3857
+ container: "justify-start",
3858
+ panel: isVisible ? "animate-slide-in-left" : "animate-slide-out-left",
3859
+ },
3860
+ right: {
3861
+ container: "justify-end",
3862
+ panel: isVisible ? "animate-slide-in-right" : "animate-slide-out-right",
3863
+ },
3864
+ };
3865
+ // Handle escape key
3866
+ React__namespace.useEffect(() => {
3867
+ if (!isOpen || !closeOnEscape || !onClose)
3868
+ return;
3869
+ const handleEscape = (e) => {
3870
+ if (e.key === "Escape") {
3871
+ onClose();
3872
+ }
3873
+ };
3874
+ document.addEventListener("keydown", handleEscape);
3875
+ return () => document.removeEventListener("keydown", handleEscape);
3876
+ }, [isOpen, closeOnEscape, onClose]);
3877
+ // Prevent body scroll when side panel is open
3878
+ React__namespace.useEffect(() => {
3879
+ if (isOpen) {
3880
+ document.body.style.overflow = "hidden";
3881
+ }
3882
+ else {
3883
+ document.body.style.overflow = "";
3884
+ }
3885
+ return () => {
3886
+ document.body.style.overflow = "";
3887
+ };
3888
+ }, [isOpen]);
3889
+ // Handle overlay click
3890
+ const handleOverlayClick = (e) => {
3891
+ if (closeOnOverlayClick && e.target === e.currentTarget && onClose) {
3892
+ onClose();
3893
+ }
3894
+ };
3895
+ // Don't render if not open and animation is complete
3896
+ if (!shouldRender)
3897
+ return null;
3898
+ const hasHeader = title || description;
3899
+ const widthClass = width in widthConfig
3900
+ ? widthConfig[width]
3901
+ : width;
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 })] }))] })] }));
3903
+ });
3904
+ SidePanel.displayName = "SidePanel";
3905
+
3824
3906
  const variantDefaults = {
3825
3907
  rect: { height: 16, className: "w-full rounded-large" },
3826
3908
  text: { height: 12, className: "w-full rounded-large" },
@@ -5056,6 +5138,7 @@ exports.RadioGroup = RadioGroup;
5056
5138
  exports.SearchableDropdown = SearchableDropdown;
5057
5139
  exports.Select = Select;
5058
5140
  exports.SelectTextField = SelectTextField;
5141
+ exports.SidePanel = SidePanel;
5059
5142
  exports.Skeleton = Skeleton;
5060
5143
  exports.SlotCell = SlotCell;
5061
5144
  exports.SpacerCell = SpacerCell;