-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add format parser #53
Conversation
src/mixin.js
Outdated
if (this.props.parser) { | ||
input = this.props.parser(input); | ||
} else { | ||
input = input.replace(/[^\w\.-]*/g, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe set defaultProps.parser
is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much~ (^^)
0c6ee4d
to
e88e192
Compare
README.md
Outdated
<tr> | ||
<td>parser</td> | ||
<td>Function</td> | ||
<td></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser default value should be show in document
always, it's better to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a parser
may make thing complex and would be confused with formatter
.
I will check it later.
using defaultProps for parser README add default parser
3ad82a0
to
7cf58bc
Compare
|
Since function formatter(value, direction) { // direction will be 'format' or 'parse'
if (direction === 'parse') {
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
} else {
return `$ ${this.numberWithCommas(value)} boeing737`;
}
} |
maybe like this props.transform = {
formatter: value => value, // default maybe
parse: value => value
} |
Add parser to extract value from format.
Default parser will be:
fix ant-design/ant-design#5178
Thanks so much
Jiramew