import { useState } from 'react'; import { useArk } from '@libs/ark'; import { CancelIcon, EditIcon, EnterIcon } from '@shared/icons'; import { User } from '@shared/user'; import { cropText } from '@utils/formater'; import { useWidget } from '@utils/hooks/useWidget'; export function TitleBar({ id, title: aTitle, isLive, }: { id?: string; title?: string; isLive?: boolean; }) { const { ark } = useArk(); const [title, setTitle] = useState(aTitle); const [editing, setEditing] = useState(false); const { removeWidget, renameWidget } = useWidget(); const submitTitleChange = () => { renameWidget.mutate({ id, title }); setEditing(false); }; return (
{isLive ? (

Live

) : null}
{id === '9999' ? (
{ark.account.contacts ?.slice(0, 8) .map((item) => )} {ark.account.contacts?.length > 8 ? (
+{ark.account.contacts?.length - 8}
) : null}
) : !editing ? (

{cropText(title)}

) : ( setTitle(e.target.value)} onKeyUp={(event) => { if (event.key === 'Enter') { submitTitleChange(); } if (event.key === 'Escape') { setTitle(aTitle); setEditing(false); } }} type="text" spellCheck={false} autoFocus={editing} autoComplete="off" autoCorrect="off" autoCapitalize="off" placeholder="type here..." value={title} className="dark:transparent max-h-6 border-transparent bg-transparent px-3 text-sm placeholder:text-neutral-500 focus:border-blue-500 focus:ring focus:ring-blue-200 dark:placeholder:text-neutral-400 dark:focus:ring-blue-800" > )}
{id !== '9999' && id !== '9998' ? (
) : null}
); }