ToolJet/frontend/src/Editor/Components/NumberInput.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.4 KiB
JavaScript

import React, { useEffect } from 'react';
export const NumberInput = function NumberInput({ height, properties, exposedVariables, styles, setExposedVariable }) {
useEffect(() => {
setExposedVariable('value', properties.value);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [properties.value]);
const { visibility, borderRadius } = styles;
return (
<input
disabled={styles.disabledState}
onChange={(e) => {
if (
!isNaN(parseInt(properties.minValue)) &&
!isNaN(parseInt(properties.maxValue)) &&
parseInt(properties.minValue) > parseInt(properties.maxValue)
) {
setExposedVariable('value', parseInt(properties.maxValue));
} else if (!isNaN(parseInt(properties.maxValue)) && parseInt(e.target.value) > parseInt(properties.maxValue)) {
setExposedVariable('value', parseInt(properties.maxValue));
} else if (!isNaN(parseInt(properties.minValue)) && parseInt(e.target.value) < parseInt(properties.minValue)) {
setExposedVariable('value', parseInt(properties.minValue));
} else {
setExposedVariable('value', parseInt(e.target.value));
}
}}
type="number"
className="form-control"
placeholder={properties.placeholder}
style={{ height, display: visibility ? '' : 'none', borderRadius: `${borderRadius}px` }}
value={exposedVariables.value}
/>
);
};