import React, { useEffect, useState } from 'react'; import { cn } from '@/lib/utils'; const baseInput = 'w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 py-0.5 text-sm text-slate-800 ' + 'hover:border-slate-200 focus:border-violet-300 focus:bg-white focus:outline-none focus:ring-1 focus:ring-violet-200'; /** * Inline text / email / number field: blur or Enter commits if the value changed. */ export function EditableCell({ value, onCommit, className = '', inputClassName = '', type = 'text', multiline = false, disabled = false, }) { const str = value == null || value === undefined ? '' : String(value); const [local, setLocal] = useState(str); useEffect(() => { setLocal(str); }, [str]); const commit = () => { if (disabled) return; const next = multiline ? local : local.trim(); const prev = multiline ? str : str.trim(); if (next !== prev) onCommit(next); }; const stop = (e) => e.stopPropagation(); if (multiline) { return (