69 lines
1.2 KiB
React
69 lines
1.2 KiB
React
|
|
import React, { useEffect, useState } from "react";
|
||
|
|
import { Input } from "antd";
|
||
|
|
import FloatLabel from "./FloatLabel/index.jsx";
|
||
|
|
import "./main.scss";
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
export const VersionUpdateInputField = ({ fieldState, fieldApi, ...props }) => {
|
||
|
|
|
||
|
|
const { value } = fieldState;
|
||
|
|
|
||
|
|
const [inpValue, setInputValue] = useState('')
|
||
|
|
|
||
|
|
|
||
|
|
const {
|
||
|
|
field,
|
||
|
|
onChange,
|
||
|
|
isOnChange,
|
||
|
|
onBlur,
|
||
|
|
label,
|
||
|
|
forwardedRef,
|
||
|
|
required,
|
||
|
|
valueData,
|
||
|
|
...rest
|
||
|
|
} = props;
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
if (!valueData) {
|
||
|
|
setInputValue(false)
|
||
|
|
}
|
||
|
|
}, [valueData])
|
||
|
|
|
||
|
|
return (
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<div className="example">
|
||
|
|
<FloatLabel
|
||
|
|
label={label}
|
||
|
|
value={inpValue}
|
||
|
|
isOnChange={isOnChange}
|
||
|
|
>
|
||
|
|
<Input
|
||
|
|
{...rest}
|
||
|
|
id={field}
|
||
|
|
ref={forwardedRef}
|
||
|
|
defaultValue={value?.toString()}
|
||
|
|
required={required}
|
||
|
|
onChange={(e) => {
|
||
|
|
setInputValue(e?.target?.value)
|
||
|
|
if (onChange) {
|
||
|
|
onChange(e);
|
||
|
|
}
|
||
|
|
|
||
|
|
}}
|
||
|
|
onBlur={(e) => {
|
||
|
|
if (onBlur) {
|
||
|
|
onBlur(e);
|
||
|
|
}
|
||
|
|
}}
|
||
|
|
|
||
|
|
/>
|
||
|
|
</FloatLabel>
|
||
|
|
|
||
|
|
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
};
|