import useOverlayScroller from '@/hooks/use-overlay-scroller'; import React from 'react'; import './style.less'; import { WrapperContext } from './use-wrapper-context'; interface ColumnWrapperProps { children: React.ReactNode; footer?: React.ReactNode; maxHeight?: string | number; paddingBottom?: number; styles?: { wrapper?: React.CSSProperties; container?: React.CSSProperties; }; } const ColumnWrapper: React.FC = ({ children, footer, maxHeight, styles = {} }) => { const scroller = React.useRef(null); const footerRef = React.useRef(null); const contentRef = React.useRef(null); const { initialize, instance, scrollEventElement, scrollToBottom, scrollToTarget, getScrollElementScrollableHeight } = useOverlayScroller({ options: { scrollbars: { autoHide: 'move' } } }); React.useEffect(() => { if (scroller.current) { initialize(scroller.current); } }, []); React.useLayoutEffect(() => { if (!scroller.current || !footerRef.current || !contentRef.current) return; const updatePadding = () => { const height = footerRef.current!.getBoundingClientRect().height; contentRef.current!.style.paddingBottom = `${height - 22}px`; }; updatePadding(); const observer = new ResizeObserver(updatePadding); observer.observe(footerRef.current); return () => observer.disconnect(); }, []); return (
{children}
{footer && (
{footer}
)}
); }; export default ColumnWrapper;