alaska-field-number
Advanced tools
Comparing version 0.4.1 to 0.8.0
108
lib/view.js
@@ -15,4 +15,2 @@ 'use strict'; | ||
var _reactBootstrap = require('react-bootstrap'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -53,3 +51,3 @@ | ||
var value = _this.state.display; | ||
var unfomarted = undefined; | ||
var unfomarted = void 0; | ||
if (field.format) { | ||
@@ -111,28 +109,86 @@ unfomarted = numeral().unformat(value); | ||
var disabled = _props.disabled; | ||
var value = _props.value; | ||
var errorText = _props.errorText; | ||
var help = field.help; | ||
var style = undefined; | ||
var className = 'form-group'; | ||
if (errorText) { | ||
style = 'error'; | ||
className += ' has-error'; | ||
help = errorText; | ||
} | ||
var display = this.state.display; | ||
var helpElement = help ? _react2.default.createElement( | ||
'p', | ||
{ className: 'help-block' }, | ||
help | ||
) : null; | ||
var inputElement = void 0; | ||
if (field.static) { | ||
inputElement = _react2.default.createElement( | ||
'p', | ||
{ className: 'form-control-static' }, | ||
value | ||
); | ||
} else { | ||
inputElement = _react2.default.createElement('input', { | ||
type: 'text', | ||
className: 'form-control', | ||
onChange: this.handleChange, | ||
onFocus: this.handleFocus, | ||
onBlur: this.handleBlur, | ||
value: this.state.display, | ||
disabled: disabled | ||
}); | ||
var addonAfter = field.addonAfter ? _react2.default.createElement( | ||
'span', | ||
{ className: 'input-group-addon' }, | ||
field.addonAfter | ||
) : null; | ||
var addonBefore = field.addonBefore ? _react2.default.createElement( | ||
'span', | ||
{ className: 'input-group-addon' }, | ||
field.addonBefore | ||
) : null; | ||
if (addonAfter || addonBefore) { | ||
inputElement = _react2.default.createElement( | ||
'div', | ||
{ className: 'input-group' }, | ||
addonBefore, | ||
inputElement, | ||
addonAfter | ||
); | ||
} | ||
} | ||
return _react2.default.createElement(_reactBootstrap.Input, { | ||
type: 'text', | ||
bsStyle: style, | ||
value: display, | ||
label: field.label, | ||
onChange: this.handleChange, | ||
disabled: disabled, | ||
onFocus: this.handleFocus, | ||
onBlur: this.handleBlur, | ||
labelClassName: 'col-xs-2', | ||
wrapperClassName: 'col-xs-10', | ||
help: help, | ||
addonAfter: field.addonAfter, | ||
addonBefore: field.addonBefore | ||
}); | ||
var label = field.nolabel ? '' : field.label; | ||
if (field.fullWidth) { | ||
var labelElement = label ? _react2.default.createElement( | ||
'label', | ||
{ className: 'control-label' }, | ||
label | ||
) : null; | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: className }, | ||
labelElement, | ||
inputElement, | ||
helpElement | ||
); | ||
} | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: className }, | ||
_react2.default.createElement( | ||
'label', | ||
{ className: 'col-sm-2 control-label' }, | ||
label | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'col-sm-10' }, | ||
inputElement, | ||
helpElement | ||
) | ||
); | ||
} | ||
@@ -145,4 +201,10 @@ }]); | ||
NumberFieldView.propTypes = { | ||
children: _react2.default.PropTypes.node | ||
value: _react2.default.PropTypes.any, | ||
model: _react2.default.PropTypes.object, | ||
data: _react2.default.PropTypes.object, | ||
field: _react2.default.PropTypes.object, | ||
disabled: _react2.default.PropTypes.bool, | ||
errorText: _react2.default.PropTypes.string, | ||
onChange: _react2.default.PropTypes.func | ||
}; | ||
exports.default = NumberFieldView; |
{ | ||
"name": "alaska-field-number", | ||
"version": "0.4.1", | ||
"version": "0.8.0", | ||
"description": "Alaska number field", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18892
307