import type { ScrollValues } from 'rc-scrollbars'; import { Scrollbars } from 'rc-scrollbars'; import type { MutableRefObject, CSSProperties, ReactNode, ReactElement } from 'react'; import React, { useMemo, memo, forwardRef } from 'react'; const styleDefault: CSSProperties = { width: '100%', height: '100%', flexGrow: 1, willChange: 'transform', overflowY: 'hidden', }; export type CustomScrollbarsProps = { overflowX?: boolean; style?: CSSProperties; children?: ReactNode; onScroll?: (values: ScrollValues) => void; renderView?: typeof Scrollbars.defaultProps.renderView; renderTrackHorizontal?: typeof Scrollbars.defaultProps.renderTrackHorizontal; autoHide?: boolean; }; const ScrollableContentWrapper = forwardRef(function ScrollableContentWrapper( { children, style, onScroll, overflowX, renderView, ...props }, ref, ) { const scrollbarsStyle = useMemo((): CSSProperties => ({ ...style, ...styleDefault }), [style]); return (
} renderThumbVertical={({ style, ...props }): JSX.Element => (
)} children={children} ref={(sRef): void => { if (ref && sRef) { if (typeof ref === 'function') { ref(sRef.view ?? null); return; } (ref as MutableRefObject).current = sRef.view; } }} /> ); }); export default memo(ScrollableContentWrapper);