infinity-ui-elements 1.8.43 → 1.8.44

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,68 @@ 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
+ // Width configurations
3828
+ const widthConfig = {
3829
+ small: "w-80",
3830
+ medium: "w-96",
3831
+ large: "w-[32rem]",
3832
+ xlarge: "w-[40rem]",
3833
+ };
3834
+ // Position-based classes
3835
+ const positionClasses = {
3836
+ left: {
3837
+ container: "justify-start",
3838
+ panel: isOpen ? "animate-slide-in-left" : "animate-slide-out-left",
3839
+ },
3840
+ right: {
3841
+ container: "justify-end",
3842
+ panel: isOpen ? "animate-slide-in-right" : "animate-slide-out-right",
3843
+ },
3844
+ };
3845
+ // Handle escape key
3846
+ React__namespace.useEffect(() => {
3847
+ if (!isOpen || !closeOnEscape || !onClose)
3848
+ return;
3849
+ const handleEscape = (e) => {
3850
+ if (e.key === "Escape") {
3851
+ onClose();
3852
+ }
3853
+ };
3854
+ document.addEventListener("keydown", handleEscape);
3855
+ return () => document.removeEventListener("keydown", handleEscape);
3856
+ }, [isOpen, closeOnEscape, onClose]);
3857
+ // Prevent body scroll when side panel is open
3858
+ React__namespace.useEffect(() => {
3859
+ if (isOpen) {
3860
+ document.body.style.overflow = "hidden";
3861
+ }
3862
+ else {
3863
+ document.body.style.overflow = "";
3864
+ }
3865
+ return () => {
3866
+ document.body.style.overflow = "";
3867
+ };
3868
+ }, [isOpen]);
3869
+ // Handle overlay click
3870
+ const handleOverlayClick = (e) => {
3871
+ if (closeOnOverlayClick && e.target === e.currentTarget && onClose) {
3872
+ onClose();
3873
+ }
3874
+ };
3875
+ // Don't render if not open
3876
+ if (!isOpen)
3877
+ return null;
3878
+ const hasHeader = title || description;
3879
+ const widthClass = width in widthConfig
3880
+ ? widthConfig[width]
3881
+ : width;
3882
+ return (jsxRuntime.jsxs("div", { className: cn("fixed inset-0 z-10000 flex items-stretch", 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", isOpen ? "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", "flex flex-col h-full max-w-full", 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
+ });
3884
+ SidePanel.displayName = "SidePanel";
3885
+
3824
3886
  const variantDefaults = {
3825
3887
  rect: { height: 16, className: "w-full rounded-large" },
3826
3888
  text: { height: 12, className: "w-full rounded-large" },
@@ -5056,6 +5118,7 @@ exports.RadioGroup = RadioGroup;
5056
5118
  exports.SearchableDropdown = SearchableDropdown;
5057
5119
  exports.Select = Select;
5058
5120
  exports.SelectTextField = SelectTextField;
5121
+ exports.SidePanel = SidePanel;
5059
5122
  exports.Skeleton = Skeleton;
5060
5123
  exports.SlotCell = SlotCell;
5061
5124
  exports.SpacerCell = SpacerCell;