ToolJet/frontend/src/Editor/Components/TextInput.jsx
Kiran Ashok c836d861cf
Border radius style for input widgets (#1972)
* updating File picker
Text input
Text area
DateRangePicker
Datepicker
PasswordInput
NumberInput
TextInput
codeEditor, to include border radius style option

* change to number input

* theme file updated to remove override for border radius

* change to number input

* text input updated with border radius style

* updated with border radius

* date range picker border radius removed

* removing overiding class
2022-01-29 07:06:08 +05:30

34 lines
1.2 KiB
JavaScript

import React, { useEffect, useState } from 'react';
export const TextInput = function TextInput({ height, validate, properties, styles, setExposedVariable, fireEvent }) {
const [value, setValue] = useState(properties.value);
const { isValid, validationError } = validate(value);
useEffect(() => {
setExposedVariable('isValid', isValid);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isValid]);
useEffect(() => {
setValue(properties.value);
setExposedVariable('value', properties.value);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [properties.value]);
return (
<div className="text-input">
<input
disabled={styles.disabledState}
onChange={(e) => {
setValue(e.target.value);
setExposedVariable('value', e.target.value);
fireEvent('onChange');
}}
type="text"
className={`form-control ${!isValid ? 'is-invalid' : ''} validation-without-icon`}
placeholder={properties.placeholder}
style={{ height, display: styles.visibility ? '' : 'none', borderRadius: `${styles.borderRadius}px` }}
value={value}
/>
<div className="invalid-feedback">{validationError}</div>
</div>
);
};