Skip to content

Commit

Permalink
CHG: emailInput修改
Browse files Browse the repository at this point in the history
  • Loading branch information
Ak2hol authored and yangin committed Jul 21, 2021
1 parent 9bd129a commit 724b4cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
25 changes: 14 additions & 11 deletions components/emailInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,26 @@ export default class InputEmail extends PureComponent {

isActive: false,
isValid: true,
isFinishedTyping: checkFinishedTyping(this.props.value),
isFinishedTyping: checkFinishedTyping(this.props.value)
}

static propTypes = {
size: PropTypes.oneOf(['regular', 'small']),
theme: PropTypes.oneOf(['core', 'plain']),
size: PropTypes.oneOf([ 'regular', 'small' ]),
theme: PropTypes.oneOf([ 'core', 'plain' ]),
unstyled: PropTypes.bool,

value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
value: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
placeholder: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),

isDisabled: PropTypes.bool,
disabled: PropTypes.bool,
readOnly: PropTypes.bool,
isAutoFocus: PropTypes.bool,

onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func,

className: PropTypes.string,
className: PropTypes.string
}

static defaultProps = {
Expand All @@ -52,8 +53,9 @@ export default class InputEmail extends PureComponent {
isDisabled: false,
disabled: false,
readOnly: false,
isAutoFocus: false,

onChange: () => null,
onChange: () => null
}

static getDerivedStateFromProps (props, { prevProps, value }) {
Expand All @@ -69,13 +71,13 @@ export default class InputEmail extends PureComponent {
this.setState(
{
value,
isFinishedTyping: checkFinishedTyping(value),
isFinishedTyping: checkFinishedTyping(value)
},
() => {
const { onChange } = this.props
this.checkValidity()
onChange(value.trim(), e)
},
}
)
}

Expand Down Expand Up @@ -108,6 +110,7 @@ export default class InputEmail extends PureComponent {
readOnly, placeholder,

onFocus,
isAutoFocus
} = this.props

const { value, isActive, isValid } = this.state
Expand All @@ -122,7 +125,7 @@ export default class InputEmail extends PureComponent {
isActive && !isDisabled && !readOnly && 'is-active',
isDisabled && 'is-disabled',
readOnly && 'is-readonly',
isValid ? 'is-valid' : 'isnt-valid',
isValid ? 'is-valid' : 'isnt-valid'
])

return (
Expand All @@ -134,9 +137,9 @@ export default class InputEmail extends PureComponent {
type="email"
value={value}
placeholder={placeholder}

disabled={isDisabled}
readOnly={readOnly}
autoFocus={isAutoFocus}

onChange={this.onChange}
onFocus={onFocus}
Expand Down
22 changes: 13 additions & 9 deletions components/input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ export default function Input ({
value,
type,
onChange,
isAutoFocus,
...others
}) {
const klass = trimList([
theme === 'core' ? 'CoreInput' : 'Input',
size,
unstyled && 'unstyled',
isInvalid && 'is-invalid',
className,
className
])

return (
Expand All @@ -33,6 +34,7 @@ export default function Input ({
type={type}
value={value}
onChange={createOnChangeHandler(onChange)}
autoFocus={isAutoFocus}
{...others}
/>
</StyledInputLabel>
Expand All @@ -41,20 +43,22 @@ export default function Input ({

Input.propTypes = {
type: PropTypes.string,
size: PropTypes.oneOf(['regular', 'small']),
theme: PropTypes.oneOf(['core', 'plain']),
size: PropTypes.oneOf([ 'regular', 'small' ]),
theme: PropTypes.oneOf([ 'core', 'plain' ]),
unstyled: PropTypes.bool,
isInvalid: PropTypes.bool,
className: PropTypes.string,
value: PropTypes.string,
onChange: PropTypes.func,
isAutoFocus: PropTypes.bool
}

Input.defaultProps = {
type: 'text',
size: 'regular',
theme: 'plain',
onChange: () => null,
isAutoFocus: false,
onChange: () => null
}

/**
Expand All @@ -71,7 +75,7 @@ export function Textarea ({
theme === 'core' ? 'CoreTextarea' : 'Textarea',
size,
unstyled && 'unstyled',
className,
className
])

return (
Expand All @@ -87,15 +91,15 @@ export function Textarea ({

Textarea.propTypes = {
className: PropTypes.string,
size: PropTypes.oneOf(['regular', 'small']),
theme: PropTypes.oneOf(['core', 'plain']),
size: PropTypes.oneOf([ 'regular', 'small' ]),
theme: PropTypes.oneOf([ 'core', 'plain' ]),
unstyled: PropTypes.bool,
value: PropTypes.string,
onChange: PropTypes.func,
onChange: PropTypes.func
}

Textarea.defaultProps = {
size: 'regular',
theme: 'plain',
onChange: () => null,
onChange: () => null
}

0 comments on commit 724b4cb

Please sign in to comment.