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(() => {
const container = containerRef.current
if (container) {
container.addEventListener('scroll', handleScroll)
return () => container.removeEventListener('scroll', handleScroll)
}
}, [])
return (
)
}
export default Table