1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Input } from '@material-ui/core';
7 import { InputProps } from '@material-ui/core/Input';
9 export class IntInput extends React.Component<InputProps> {
10 handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
11 const { onChange = () => { return; } } = this.props;
12 const parsedValue = parseInt(event.target.value, 10);
13 event.target.value = parsedValue.toString();
18 const parsedValue = parseInt(typeof this.props.value === 'string' ? this.props.value : '', 10);
19 const value = isNaN(parsedValue) ? '' : parsedValue.toString();
23 onChange: this.handleChange,
25 return <Input {...props} />;