From 576827f4ed24e7d28e016334743d14bb55bed47c Mon Sep 17 00:00:00 2001 From: Alex Abenoja Date: Thu, 7 May 2015 14:33:48 -0600 Subject: [PATCH] [changed] Introducing ButtonInput Encapsulating types "button", "reset" and "submit" into a single component. Usage of these types with Input is now deprecated. Please use ButtonInput instead. --- src/ButtonInput.js | 40 +++++++ src/Input.js | 240 ++-------------------------------------- src/InputBase.js | 226 +++++++++++++++++++++++++++++++++++++ test/ButtonInputSpec.js | 82 ++++++++++++++ test/InputSpec.js | 22 ++-- 5 files changed, 368 insertions(+), 242 deletions(-) create mode 100644 src/ButtonInput.js create mode 100644 src/InputBase.js create mode 100644 test/ButtonInputSpec.js diff --git a/src/ButtonInput.js b/src/ButtonInput.js new file mode 100644 index 0000000000..846d577ed4 --- /dev/null +++ b/src/ButtonInput.js @@ -0,0 +1,40 @@ +import React from 'react'; +import Button from './Button'; +import FormGroup from './FormGroup'; +import InputBase from './InputBase'; + +function valueValidation({children, value}, propName, componentName) { + if (children && value) { + return new Error('Both value and children cannot be passed to ButtonInput'); + } + return React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]).call(null, {children, value}, propName, componentName); +} + +class ButtonInput extends InputBase { + renderFormGroup(children) { + let {bsStyle, value, ...other} = this.props; /* eslint no-unused-vars: 0 object-shorthand: 0 */ + return {children}; + } + + renderInput() { + let {children, value, ...other} = this.props; + let val = children ? children : value; + return