45 lines
956 B
JavaScript
45 lines
956 B
JavaScript
import { Input as AntInput } from 'antd';
|
|
import { useStatus } from 'client/hooks/useStatus';
|
|
import { useStoreValue } from 'client/hooks/useStoreValue';
|
|
import { Status } from 'core/types/elements';
|
|
import { observer } from 'mobx-react';
|
|
import React from 'react';
|
|
|
|
const Input = ({
|
|
name,
|
|
readonly,
|
|
type,
|
|
pattern,
|
|
prefix,
|
|
suffix,
|
|
placeholder,
|
|
addonBefore,
|
|
addonAfter,
|
|
valueName,
|
|
computedValue,
|
|
}) => {
|
|
const { value, setCurrentValue } = useStoreValue({
|
|
computedValue,
|
|
valueName,
|
|
});
|
|
const { status } = useStatus(name);
|
|
|
|
return (
|
|
<AntInput
|
|
prefix={prefix}
|
|
suffix={suffix}
|
|
disabled={status === Status.Disabled}
|
|
readOnly={readonly}
|
|
type={type}
|
|
placeholder={placeholder}
|
|
pattern={pattern}
|
|
addonBefore={addonBefore}
|
|
addonAfter={addonAfter}
|
|
value={value}
|
|
onChange={(e) => setCurrentValue(e.target.value)}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default observer(Input);
|