({ selectedNodes, onConfirm }: { selectedNodes: ColumnViewNode[], onConfirm: (newPath: string) => void; })
| 48 | } |
| 49 | |
| 50 | export function PathBarText({ selectedNodes, onConfirm }: { selectedNodes: ColumnViewNode[], onConfirm: (newPath: string) => void; }) { |
| 51 | const [path, setPath] = useState(''); |
| 52 | const ref = useRef<HTMLInputElement>(null); |
| 53 | |
| 54 | useEffect(() => { |
| 55 | setPath(selectedNodes.at(-1)?.id || ''); |
| 56 | }, [selectedNodes]); |
| 57 | |
| 58 | useEffect(() => { |
| 59 | if (ref.current) { |
| 60 | ref.current.focus(); |
| 61 | } |
| 62 | }, [ref]); |
| 63 | |
| 64 | return ( |
| 65 | <form |
| 66 | onSubmit={(e) => { |
| 67 | onConfirm(path); |
| 68 | e.preventDefault(); |
| 69 | }} |
| 70 | // onBlur={() => onConfirm(path)} |
| 71 | className="flex overflow-x-hidden items-center bg-slate-300 dark:bg-slate-700 rounded-sm" |
| 72 | > |
| 73 | <label className="grow"> |
| 74 | <input |
| 75 | ref={ref} |
| 76 | className={ |
| 77 | "w-full border-none outline-none text-ellipsis text-base px-2 py-0 rounded-sm bg-transparent dark:text-slate-200" |
| 78 | } |
| 79 | style={{ boxShadow: 'none' }} |
| 80 | type="text" |
| 81 | name="title" |
| 82 | spellCheck="false" |
| 83 | placeholder="Name your JSON file" |
| 84 | value={path} |
| 85 | onChange={(e) => setPath(e.target.value)} |
| 86 | /> |
| 87 | </label> |
| 88 | <button type="submit" className="flex ml-auto justify-center items-center w-[26px] h-[26px] hover:bg-slate-400 dark:text-slate-400 dark:hover:bg-white dark:hover:bg-opacity-[10%]"> |
| 89 | <CheckIcon className='h-5' /> |
| 90 | </button> |
| 91 | </form> |
| 92 | ); |
| 93 | } |
| 94 | |
| 95 | export type PathBarLinkProps = { |
| 96 | selectedNodes: ColumnViewNode[]; |
nothing calls this directly
no outgoing calls
no test coverage detected