import React, { HTMLAttributes, useState, useRef, useEffect } from 'react'; import classNames from 'classnames'; import { FaPlay, FaPause, FaStepForward, FaStepBackward } from 'react-icons/fa'; interface NowPlayingProps extends HTMLAttributes { songName: string; fileName: string; isPlaying: boolean; onPlayPause: () => void; onStepForward: () => void; onStepBackward: () => void; } const NowPlaying: React.FC = (props) => { return ( {props.songName} {props.fileName} {props.isPlaying ? : } ); }; const SongTable: React.FC = () => { const songs = Array.from({ length: 20 }, (_, index) => `Song ${index + 1}`); const SongRow: React.FC<{ song: string }> = ({ song }) => { const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); const buttonRef = useRef(null); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (buttonRef.current && !buttonRef.current.contains(event.target as Node)) { setShowDeleteConfirm(false); } }; if (showDeleteConfirm) { document.addEventListener('click', handleClickOutside); } return () => { document.removeEventListener('click', handleClickOutside); }; }, [showDeleteConfirm]); return ( {song} { e.stopPropagation(); if (showDeleteConfirm) { // Handle delete here console.log('Deleting:', song); } else { setShowDeleteConfirm(true); } }} > {showDeleteConfirm ? 'Delete' : '×'} ); }; return ( {songs.map((song, index) => ( ))} ); }; const App: React.FC = () => { const [isPlaying, setIsPlaying] = useState(false); const [songName, setSongName] = useState('Song Name'); const [fileName, setFileName] = useState('Song Name.mp3'); return ( setIsPlaying(!isPlaying)} onStepForward={() => {}} onStepBackward={() => {}} /> ); }; export default App;