okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
fa6367a98
main
1import { useEffect , useState } from 'react' ; 2import { tr } from '../lib/i18n' ; 3import { useFolderPrompt } from '../lib/folder-pick' ; 4import { Btn , Dialog } from './ui' ; 5 6/** The fallback for a system without a folder chooser: say so in plain words and take the folder's path as text. */ 7export function FolderPathDialog () { 8const prompt = useFolderPrompt (); 9const [ path , setPath ] = useState ( '' ); 10useEffect (() => { if ( prompt ) setPath ( '' ); }, [ prompt ]); 11const submit = () => { const text = path . trim (); if ( text ) prompt ?. resolve ( text ); }; 12return < Dialog open = { !! prompt } compact title = { tr ( "Type the folder path" )} onClose = {() => prompt ?. resolve ( null )} 13actions = {<>< Btn onClick = {() => prompt ?. resolve ( null )}>{ tr ( "Cancel" )}</ Btn >< Btn variant = "primary" disabled = { ! path . trim ()} onClick = { submit }>{ tr ( "Use this folder" )}</ Btn ></>}> 14< form className = "stack" onSubmit = { event => { event . preventDefault (); submit (); }}> 15< p className = "small" role = "status" >{ tr ( prompt ?. message ?? '' )}</ p > 16< label className = "input-field" >< span >{ tr ( "Folder path" )}</ span > 17< input className = "st-input" autoFocus value = { path } onChange = { event => setPath ( event . target . value )} placeholder = { tr ( "/home/you/Documents" )} spellCheck = { false } aria-label = { tr ( "Folder path" )}/> 18</ label > 19</ form > 20</ Dialog >; 21}