Sha256: 1c3dac1ef568324d8e7d6bb0e15ac099ac62f2ab976b05ae52947e414fbbb9fa
Contents?: true
Size: 997 Bytes
Versions: 2
Compression:
Stored size: 997 Bytes
Contents
import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { FormGroup, TextInput, ValidatedOptions } from '@patternfly/react-core'; import { translate as __ } from 'foremanReact/common/I18n'; export const NumberInput = ({ formProps, inputProps }) => { const [validated, setValidated] = useState(); const name = inputProps.id.replace(/-/g, ' '); return ( <FormGroup {...formProps} helperTextInvalid={__('Has to be a number')} validated={validated} > <TextInput aria-label={name} type="text" {...inputProps} onChange={newValue => { setValidated( /^\d+$/.test(newValue) || newValue === '' ? ValidatedOptions.noval : ValidatedOptions.error ); inputProps.onChange(newValue); }} /> </FormGroup> ); }; NumberInput.propTypes = { formProps: PropTypes.object.isRequired, inputProps: PropTypes.object.isRequired, };
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_remote_execution-4.8.0 | webpack/JobWizard/steps/form/NumberInput.js |
foreman_remote_execution-4.5.6 | webpack/JobWizard/steps/form/NumberInput.js |