-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
618682c
commit 779797f
Showing
18 changed files
with
178 additions
and
197 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
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
import { InputHTMLAttributes, forwardRef, useState } from 'react' | ||
import { Input } from './input' | ||
import { useIntl } from 'react-intl' | ||
|
||
interface Props { | ||
value: string[] | ||
onChange: (value: string[]) => void | ||
dataTest?: string | ||
} | ||
export const InputList = forwardRef< | ||
HTMLInputElement, | ||
InputHTMLAttributes<HTMLInputElement> & Props | ||
>(({ value, onChange, dataTest }, ref) => { | ||
const intl = useIntl() | ||
const [inputValue, setInputValue] = useState('') | ||
const addTags = (event) => { | ||
if (event.key === 'Enter' && event.target.value !== '') { | ||
onChange([...value, event.target.value]) | ||
setInputValue('') | ||
} | ||
} | ||
|
||
return ( | ||
<div className="control"> | ||
<div className="tags"> | ||
{value.map((tag, index) => ( | ||
<div | ||
key={`input_list_${tag}_${index}`} | ||
className="tag is-info is-medium" | ||
> | ||
{tag} | ||
<button | ||
className="delete is-small" | ||
onClick={() => | ||
onChange([ | ||
...value.filter((tag) => value.indexOf(tag) !== index), | ||
]) | ||
} | ||
></button> | ||
</div> | ||
))} | ||
</div> | ||
<Input | ||
type="text" | ||
placeholder={intl.formatMessage({ | ||
id: 'press_enter_to_add_value', | ||
defaultMessage: 'Press enter to add value', | ||
})} | ||
onKeyUp={(event) => addTags(event)} | ||
value={inputValue} | ||
ref={ref} | ||
dataTest={dataTest} | ||
onChange={(value) => { | ||
setInputValue(value) | ||
}} | ||
/> | ||
</div> | ||
) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
import { InputHTMLAttributes } from 'react' | ||
import { Input } from './input' | ||
|
||
interface Props { | ||
value: string | ||
dataTest: string | ||
onChange: (value: string) => void | ||
} | ||
|
||
export const PasswordInput = ({ | ||
value, | ||
dataTest, | ||
onChange, | ||
}: Props & InputHTMLAttributes<HTMLInputElement>) => { | ||
return ( | ||
<Input | ||
value={value} | ||
type="password" | ||
dataTest={dataTest} | ||
onChange={onChange} | ||
/> | ||
) | ||
} |
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
Oops, something went wrong.