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/components/SidePanel/SidePanel.d.ts +91 -0
- package/dist/components/SidePanel/SidePanel.d.ts.map +1 -0
- package/dist/components/SidePanel/SidePanel.stories.d.ts +20 -0
- package/dist/components/SidePanel/SidePanel.stories.d.ts.map +1 -0
- package/dist/components/SidePanel/index.d.ts +3 -0
- package/dist/components/SidePanel/index.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +83 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3800,6 +3800,88 @@ const SearchableDropdown = React.forwardRef(({ className, items = [], sectionHea
|
|
|
3800
3800
|
});
|
|
3801
3801
|
SearchableDropdown.displayName = "SearchableDropdown";
|
|
3802
3802
|
|
|
3803
|
+
const SidePanel = React.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) => {
|
|
3804
|
+
const panelRef = React.useRef(null);
|
|
3805
|
+
const contentRef = ref || panelRef;
|
|
3806
|
+
const [isVisible, setIsVisible] = React.useState(false);
|
|
3807
|
+
const [shouldRender, setShouldRender] = React.useState(false);
|
|
3808
|
+
// Width configurations
|
|
3809
|
+
const widthConfig = {
|
|
3810
|
+
small: "w-80",
|
|
3811
|
+
medium: "w-96",
|
|
3812
|
+
large: "w-[32rem]",
|
|
3813
|
+
xlarge: "w-[40rem]",
|
|
3814
|
+
};
|
|
3815
|
+
// Handle mounting and unmounting with animation
|
|
3816
|
+
React.useEffect(() => {
|
|
3817
|
+
if (isOpen) {
|
|
3818
|
+
setShouldRender(true);
|
|
3819
|
+
// Small delay to trigger animation
|
|
3820
|
+
requestAnimationFrame(() => {
|
|
3821
|
+
setIsVisible(true);
|
|
3822
|
+
});
|
|
3823
|
+
}
|
|
3824
|
+
else {
|
|
3825
|
+
setIsVisible(false);
|
|
3826
|
+
// Wait for animation to complete before unmounting
|
|
3827
|
+
const timer = setTimeout(() => {
|
|
3828
|
+
setShouldRender(false);
|
|
3829
|
+
}, 300); // Match animation duration
|
|
3830
|
+
return () => clearTimeout(timer);
|
|
3831
|
+
}
|
|
3832
|
+
}, [isOpen]);
|
|
3833
|
+
// Position-based classes
|
|
3834
|
+
const positionClasses = {
|
|
3835
|
+
left: {
|
|
3836
|
+
container: "justify-start",
|
|
3837
|
+
panel: isVisible ? "animate-slide-in-left" : "animate-slide-out-left",
|
|
3838
|
+
},
|
|
3839
|
+
right: {
|
|
3840
|
+
container: "justify-end",
|
|
3841
|
+
panel: isVisible ? "animate-slide-in-right" : "animate-slide-out-right",
|
|
3842
|
+
},
|
|
3843
|
+
};
|
|
3844
|
+
// Handle escape key
|
|
3845
|
+
React.useEffect(() => {
|
|
3846
|
+
if (!isOpen || !closeOnEscape || !onClose)
|
|
3847
|
+
return;
|
|
3848
|
+
const handleEscape = (e) => {
|
|
3849
|
+
if (e.key === "Escape") {
|
|
3850
|
+
onClose();
|
|
3851
|
+
}
|
|
3852
|
+
};
|
|
3853
|
+
document.addEventListener("keydown", handleEscape);
|
|
3854
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
3855
|
+
}, [isOpen, closeOnEscape, onClose]);
|
|
3856
|
+
// Prevent body scroll when side panel is open
|
|
3857
|
+
React.useEffect(() => {
|
|
3858
|
+
if (isOpen) {
|
|
3859
|
+
document.body.style.overflow = "hidden";
|
|
3860
|
+
}
|
|
3861
|
+
else {
|
|
3862
|
+
document.body.style.overflow = "";
|
|
3863
|
+
}
|
|
3864
|
+
return () => {
|
|
3865
|
+
document.body.style.overflow = "";
|
|
3866
|
+
};
|
|
3867
|
+
}, [isOpen]);
|
|
3868
|
+
// Handle overlay click
|
|
3869
|
+
const handleOverlayClick = (e) => {
|
|
3870
|
+
if (closeOnOverlayClick && e.target === e.currentTarget && onClose) {
|
|
3871
|
+
onClose();
|
|
3872
|
+
}
|
|
3873
|
+
};
|
|
3874
|
+
// Don't render if not open and animation is complete
|
|
3875
|
+
if (!shouldRender)
|
|
3876
|
+
return null;
|
|
3877
|
+
const hasHeader = title || description;
|
|
3878
|
+
const widthClass = width in widthConfig
|
|
3879
|
+
? widthConfig[width]
|
|
3880
|
+
: width;
|
|
3881
|
+
return (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: [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" }), 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 && (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: [jsxs("div", { className: "flex items-center gap-3 flex-1 min-w-0", children: [titleIcon && (jsx("div", { className: "flex items-center justify-center shrink-0", children: typeof titleIcon === "string" ? (jsx(Icon, { name: titleIcon, size: 20 })) : (titleIcon) })), jsxs("div", { className: "flex flex-col flex-1 min-w-0", children: [title && (jsx(Text, { as: "h2", variant: "body", size: "large", weight: "semibold", color: "default", className: "truncate", children: title })), description && (jsx(Text, { as: "p", variant: "body", size: "small", weight: "regular", color: "subtle", className: "mt-0.5", children: description }))] })] }), jsxs("div", { className: "flex items-center gap-2 shrink-0", children: [headerActions, showCloseButton && onClose && (jsx(IconButton, { icon: "close", onClick: onClose, color: "neutral", size: "small", "aria-label": "Close side panel" }))] })] })), !hasHeader && showCloseButton && onClose && (jsx("div", { className: "absolute top-4 right-4 z-10", children: jsx(IconButton, { icon: "close", onClick: onClose, color: "neutral", size: "small", "aria-label": "Close side panel" }) })), 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 && (jsxs("div", { className: "flex flex-col shrink-0", children: [jsx(Divider, { thickness: "thin", variant: "muted" }), jsx("div", { className: cn("flex items-center justify-end gap-3 px-6 py-4", footerClassName), children: footer })] }))] })] }));
|
|
3882
|
+
});
|
|
3883
|
+
SidePanel.displayName = "SidePanel";
|
|
3884
|
+
|
|
3803
3885
|
const variantDefaults = {
|
|
3804
3886
|
rect: { height: 16, className: "w-full rounded-large" },
|
|
3805
3887
|
text: { height: 12, className: "w-full rounded-large" },
|
|
@@ -5007,5 +5089,5 @@ const UploadBox = React.forwardRef(({ label, helperText, errorText, successText,
|
|
|
5007
5089
|
});
|
|
5008
5090
|
UploadBox.displayName = "UploadBox";
|
|
5009
5091
|
|
|
5010
|
-
export { Alert, Amount, Avatar, AvatarCell, Badge, Button, ButtonGroup, Checkbox, Counter, DatePicker, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, IconButton, IconCell, Link, ListItem, Modal, NumberCell, Pagination, Radio, RadioGroup, SearchableDropdown, Select, SelectTextField, Skeleton, SlotCell, SpacerCell, Switch, TabItem, Table, TableDetailPanel, Tabs, Text, TextArea, TextField, Tooltip, UploadBox, alertVariants, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, datePickerVariants, dropdownVariants, getAvailableIcons, hasIcon, iconButtonVariants, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectTriggerVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants, uploadBoxVariants };
|
|
5092
|
+
export { Alert, Amount, Avatar, AvatarCell, Badge, Button, ButtonGroup, Checkbox, Counter, DatePicker, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, IconButton, IconCell, Link, ListItem, Modal, NumberCell, Pagination, Radio, RadioGroup, SearchableDropdown, Select, SelectTextField, SidePanel, Skeleton, SlotCell, SpacerCell, Switch, TabItem, Table, TableDetailPanel, Tabs, Text, TextArea, TextField, Tooltip, UploadBox, alertVariants, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, datePickerVariants, dropdownVariants, getAvailableIcons, hasIcon, iconButtonVariants, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectTriggerVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants, uploadBoxVariants };
|
|
5011
5093
|
//# sourceMappingURL=index.esm.js.map
|