Co-authored-by: Roman Zabaluev <rzabaluev@provectus.com> Co-authored-by: Oleg Shur <workshur@gmail.com>
This commit is contained in:
parent
77dca1594c
commit
91b86b5b78
1 changed files with 22 additions and 1 deletions
|
@ -17,6 +17,7 @@ const Input: React.FC<InputProps> = ({
|
||||||
hookFormOptions,
|
hookFormOptions,
|
||||||
search,
|
search,
|
||||||
inputSize = 'L',
|
inputSize = 'L',
|
||||||
|
type,
|
||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
const methods = useFormContext();
|
const methods = useFormContext();
|
||||||
|
@ -28,10 +29,30 @@ const Input: React.FC<InputProps> = ({
|
||||||
inputSize={inputSize}
|
inputSize={inputSize}
|
||||||
{...methods.register(name, { ...hookFormOptions })}
|
{...methods.register(name, { ...hookFormOptions })}
|
||||||
hasLeftIcon={!!search}
|
hasLeftIcon={!!search}
|
||||||
|
type={type}
|
||||||
{...rest}
|
{...rest}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (type === 'number') {
|
||||||
|
if (e.key === 'e') {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onPaste={(e) => {
|
||||||
|
if (type === 'number') {
|
||||||
|
e.preventDefault();
|
||||||
|
const value = e.clipboardData.getData('Text');
|
||||||
|
methods.setValue(name, value.replace(/[^\d.]/g, ''));
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<S.Input inputSize={inputSize} hasLeftIcon={!!search} {...rest} />
|
<S.Input
|
||||||
|
inputSize={inputSize}
|
||||||
|
hasLeftIcon={!!search}
|
||||||
|
type={type}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</S.Wrapper>
|
</S.Wrapper>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue