Comments (14)
Hmm. That's a good start, but there's a fair bit going on in the Boostrap component. It's confusing though, because the docs are a bit scattered (as usual):
http://getbootstrap.com/css/#forms
http://getbootstrap.com/components/#input-groups
Here's how my current Input component works. It doesn't use all of the functionality either.
<Form callback={this.submit}>
<Input name="email" type="email" placeholder="Email" required={true}/>
<Input name="password" type="password" placeholder="Password"/>
<Input name="password" type="password" placeholder="Re-enter Password"/>
<Button bsStyle="success" bsSize="large">
Submit
</Button>
<Button bsStyle="danger" bsSize="large">
Cancel
</Button>
</Form>
Here's my implementation of Input. It does some validation; I'm not sure if this is a great idea.
var Input = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
type: React.PropTypes.oneOf(INPUT_TYPES).isRequired,
placeholder: React.PropTypes.string,
label: React.PropTypes.string,
required: React.PropTypes.bool,
oneOf: React.PropTypes.array,
minLength: React.PropTypes.int
},
getInitialState: function() { return {}; },
getValue: function() {
return this.refs.input.getDOMNode().value;
},
renderInput: function(){
var className = "form-control input-md";
return <input type={this.props.type} className={className}
placeholder={this.props.placeholder} ref="input"/>;
},
renderLabel: function(){
return this.props.label ? <label>{this.props.label}</label> : undefined;
},
render: function(){
var className = "form-group";
if (this.state.error)
className += ' has-error';
return this.transferPropsTo(
<div className={className} onBlur={this.onBlur} onFocus={this.onFocus}>
{this.renderInput()}
{this.renderLabel()}
</div>
);
},
onBlur: function(e){
var value = this.getValue();
var error;
if (this.props.required && !value)
error = 'required';
else if (this.props.oneOf && !(value in this.props.oneOf))
error = 'oneOf';
else if (this.props.minLength && value.length < this.props.minLength)
error = 'minLength';
this.setState({error: error});
},
onFocus: function(e) {
this.setState({error: false});
e.stopPropagation();
}
});
from react-bootstrap.
I'd like to leave validation out of the component at least for now. Just add the relevant error/warning class from some prop like bsStyle
in my example. What other functionality can you see missing from my initial example?
from react-bootstrap.
I missed that "before" and "after" would do the input-group parts, so that's covered.
Where does placeholder text go?
from react-bootstrap.
oh, yeah, forgot placeholder - I'll add that.
On Tue, Feb 11, 2014 at 3:03 PM, syllog1sm [email protected] wrote:
I missed that "before" and "after" would do the input-group parts, so
that's covered.Where does placeholder text go?
Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-34762245
.
from react-bootstrap.
What would be really cool is to have Input with optional autocompletion
Thanks !
from react-bootstrap.
That would be great. Id like a pure React Selectize https://github.com/brianreavis/selectize.js . It's not going to happen in this project I'm afraid.
from react-bootstrap.
Answering my own comment: https://github.com/chenglou/react-chosen
For those looking )
from react-bootstrap.
Is there any work in progress? I may have some time to spend on it.
I agree that validation should stay out for now.
from react-bootstrap.
That would be fantastic! I don't think it's been started.@pieterv ?
from react-bootstrap.
@liamcmitchell sounds good! I haven't made any progress on this.
For validation it would be nice if we can make sure HTML5 validation properties can still be set on the input, required
being the main one.
from react-bootstrap.
Work in progress here: #89
from react-bootstrap.
Just note that there is wrapper around selectize.js
https://github.com/ggarek/react-selectize
from react-bootstrap.
@PetrSnobelt Did you so that library's announcement that it is no longer maintained? What are you looking for?
from react-bootstrap.
I know, but it is only wrapper...
I'm looking for great autocomplete/suggestion component (like selectize) for react-bootstrap
from react-bootstrap.
Related Issues (20)
- null is not an object (evaluating 'ye.scrollHeight') HOT 1
- Feature Select component with search HOT 1
- Bug - Page Not Found for Tabs Doc Site HOT 3
- Dropdown should overlay the parent container HOT 1
- Alignment of button text in grid changes if href tag is set HOT 1
- Feature Request: Custom Anchor element for PageItem
- Button is not responsive inside the MODAL HOT 3
- defaultActiveKey and alwaysOpen not working properly at the same time HOT 1
- Error using components HOT 1
- NextJS <Link> giving error with react-bootstrap <Navbar.Link> HOT 1
- Docs - Components props tables are missing
- Tabs Component doesn't pass id attribute to underlying element HOT 1
- aria-label for DropdownButton HOT 2
- React Bootstrap doesn't let me set background color HOT 1
- Bug: OverlayTrigger doesn't hide after modal close. HOT 5
- Rendering children (Accordion) HOT 1
- Modal component stop working when closed HOT 6
- Keyboard input Tab + Shift escapes Modal's focus HOT 3
- ESC and Up/Down in Dropdown doesn't work when using the native Bootstrap HOT 2
- Suggest adding 'use clientโ for all the react-bootstrap component HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-bootstrap.