mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
* 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
34 lines
1.4 KiB
JavaScript
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}
|
|
/>
|
|
);
|
|
};
|