"use client"

import { ComponentProps, Dispatch, SetStateAction } from "react"

export function TableInputContainer({ isActive, setIsActive, children }: ComponentProps<"div"> & { isActive: boolean, setIsActive: Dispatch<SetStateAction<boolean>> }) {
  return (
    <div
      onDoubleClick={() => setIsActive(prev => !prev)}
      className="w-full h-fit flex items-center justify-center"
      tabIndex={0}
      onKeyDown={e => {
        if (e.code === "Enter" && !isActive) {
          setIsActive(true)
        }
      }}
    >
      {children}
    </div>
  )
}
