Added isRequired opt to Input, Textarea

• Added:
- isRequired opt to Input, Textarea
This commit is contained in:
mgabdev 2020-09-02 17:54:36 -05:00
parent 9ca6b6a884
commit 8d07aa7564
2 changed files with 6 additions and 0 deletions

View File

@ -29,6 +29,7 @@ class Input extends React.PureComponent {
id, id,
hideLabel, hideLabel,
maxLength, maxLength,
isRequired,
} = this.props } = this.props
const inputClasses = CX({ const inputClasses = CX({
@ -93,6 +94,7 @@ class Input extends React.PureComponent {
onBlur={onBlur} onBlur={onBlur}
readOnly={readOnly} readOnly={readOnly}
maxLength={maxLength} maxLength={maxLength}
required={isRequired ? true : undefined}
/> />
{ {
@ -128,6 +130,7 @@ Input.propTypes = {
readOnly: PropTypes.string, readOnly: PropTypes.string,
inputRef: PropTypes.func, inputRef: PropTypes.func,
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
isRequired: PropTypes.bool,
hideLabel: PropTypes.bool, hideLabel: PropTypes.bool,
maxLength: PropTypes.number, maxLength: PropTypes.number,
} }

View File

@ -18,6 +18,7 @@ class Textarea extends React.PureComponent {
onFocus, onFocus,
onBlur, onBlur,
title, title,
isRequired,
} = this.props } = this.props
const inputClasses = CX({ const inputClasses = CX({
@ -57,6 +58,7 @@ class Textarea extends React.PureComponent {
onKeyUp={onKeyUp} onKeyUp={onKeyUp}
onFocus={onFocus} onFocus={onFocus}
onBlur={onBlur} onBlur={onBlur}
required={isRequired ? true : undefined}
/> />
</div> </div>
@ -74,6 +76,7 @@ Textarea.propTypes = {
onFocus: PropTypes.func, onFocus: PropTypes.func,
onBlur: PropTypes.func, onBlur: PropTypes.func,
title: PropTypes.string, title: PropTypes.string,
isRequired: PropTypes.bool,
} }
export default Textarea export default Textarea