This repository was archived by the owner on Jul 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update for compatibility with react-bootstrap 0.29+.
- Loading branch information
1 parent
1d07b4c
commit 0b031ab
Showing
3 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,49 @@ | ||
React = require('react') | ||
classNames = require('classnames') | ||
Input = require('react-bootstrap').Input | ||
MaskedInputField = require('react-maskedinput') | ||
{FormControl} = require('react-bootstrap') | ||
MaskedInputField = require('react-maskedinput') | ||
{bsClass, getClassSet} = require('react-bootstrap/lib/utils/bootstrapUtils') | ||
FormControlFeedback = require('react-bootstrap/lib/FormControlFeedback') | ||
FormControlStatic = require('react-bootstrap/lib/FormControlStatic') | ||
React = require('react') | ||
elementType = require('react-prop-types/lib/elementType') | ||
classNames = require('classnames') | ||
|
||
class MaskedInput extends Input | ||
renderInput: -> | ||
className = if @isCheckboxOrRadio() || @isFile() then '' else 'form-control' | ||
<MaskedInputField {...@props} className={classNames(@props.className, className)} ref='input' key='input' /> | ||
propTypes = | ||
componentClass: elementType | ||
# Only relevant if `componentClass` is `'input'`. | ||
type: React.PropTypes.string | ||
# Uses `controlId` from `<FormGroup>` if not explicitly specified. | ||
id: React.PropTypes.string | ||
|
||
module.exports = MaskedInput | ||
defaultProps = | ||
componentClass: 'input' | ||
|
||
contextTypes = | ||
$bs_formGroup: React.PropTypes.object | ||
|
||
class MaskedFormControl extends FormControl | ||
render: -> | ||
formGroup = @context.$bs_formGroup | ||
controlId = formGroup && formGroup.controlId | ||
|
||
{type, id, className} = @props | ||
id ||= controlId | ||
props = {} | ||
props[k] = v for k, v in @props when k not in ['componentClass', 'type', 'id', 'className', 'bsClass'] | ||
|
||
classes = getClassSet(@props) unless type is 'file' | ||
|
||
<MaskedInputField | ||
{...@props} | ||
type={type} | ||
id={id} | ||
className={classNames(className, classes)} | ||
/> | ||
|
||
MaskedFormControl.propTypes = propTypes | ||
MaskedFormControl.defaultProps = defaultProps | ||
MaskedFormControl.contextTypes = contextTypes | ||
|
||
MaskedFormControl.Feedback = FormControlFeedback | ||
MaskedFormControl.Static = FormControlStatic | ||
|
||
module.exports = bsClass('form-control', MaskedFormControl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters