import React, { TableHTMLAttributes, useEffect, useRef, useState } from 'react'
import { cn } from 'ui'
type TableProps = TableHTMLAttributes
const Table = ({ children, ...props }: TableProps) => {
const containerRef = useRef(null)
const [showShadow, setShowShadow] = useState(true)
const handleScroll = () => {
const container = containerRef.current
if (container) {
const { scrollWidth, scrollLeft, offsetWidth } = container
const isAtEnd = scrollWidth - scrollLeft - 2 < offsetWidth
setShowShadow(!isAtEnd)
}
}
useEffect(() => {
containerRef?.current?.addEventListener('scroll', handleScroll)
return () => containerRef?.current?.removeEventListener('scroll', handleScroll)
}, [])
return (
)
}
export default Table