Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test-results * cleanup * improve types * fix some stuff
- Loading branch information
Showing
14 changed files
with
625 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { FocusScope } from 'react-aria'; | ||
import { Button, Input } from 'react-aria-components'; | ||
|
||
export const EditableInput = ({ | ||
value, | ||
ariaLabel, | ||
name, | ||
onChange, | ||
}: { | ||
value: string; | ||
ariaLabel?: string; | ||
name?: string; | ||
onChange: (value: string) => void; | ||
}) => { | ||
const [isEditable, setIsEditable] = useState(false); | ||
|
||
useEffect(() => { | ||
if (!isEditable) { | ||
return; | ||
} | ||
|
||
const keysToLock = [ | ||
'ArrowLeft', | ||
'ArrowRight', | ||
'ArrowUp', | ||
'ArrowDown', | ||
'Tab', | ||
' ', | ||
]; | ||
|
||
function lockKeyDownToInput(e: KeyboardEvent) { | ||
if (keysToLock.includes(e.key)) { | ||
e.stopPropagation(); | ||
} | ||
} | ||
|
||
window.addEventListener('keydown', lockKeyDownToInput, { capture: true }); | ||
|
||
return () => { | ||
window.removeEventListener('keydown', lockKeyDownToInput, { | ||
capture: true, | ||
}); | ||
}; | ||
}, [isEditable]); | ||
|
||
return ( | ||
<> | ||
<Button | ||
className={`items-center truncate justify-center px-2 data-[pressed]:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all ${ | ||
isEditable ? 'hidden' : '' | ||
}`} | ||
onPress={() => { | ||
setIsEditable(true); | ||
}} | ||
name={name} | ||
aria-label={ariaLabel} | ||
value={value} | ||
> | ||
<span className="truncate">{value}</span> | ||
</Button> | ||
{isEditable && ( | ||
<FocusScope contain restoreFocus autoFocus> | ||
<Input | ||
className="px-2 truncate" | ||
name={name} | ||
aria-label={ariaLabel} | ||
defaultValue={value} | ||
onKeyDown={e => { | ||
const value = e.currentTarget.value; | ||
if (e.key === 'Enter') { | ||
e.stopPropagation(); | ||
onChange(value); | ||
setIsEditable(false); | ||
} | ||
|
||
if (e.key === 'Escape') { | ||
e.stopPropagation(); | ||
setIsEditable(false); | ||
} | ||
}} | ||
onBlur={e => { | ||
const value = e.currentTarget.value; | ||
onChange(value); | ||
setIsEditable(false); | ||
}} | ||
/> | ||
</FocusScope> | ||
)} | ||
</> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
packages/insomnia/src/ui/components/list-group/list-group-item.tsx
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
packages/insomnia/src/ui/components/list-group/list-group.tsx
This file was deleted.
Oops, something went wrong.
118 changes: 0 additions & 118 deletions
118
packages/insomnia/src/ui/components/list-group/unit-test-item.tsx
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
packages/insomnia/src/ui/components/list-group/unit-test-request-selector.tsx
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
packages/insomnia/src/ui/components/list-group/unit-test-result-badge.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.