Skip to content

Commit

Permalink
[fixed] updated React to v0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thealjey committed Oct 13, 2015
1 parent b5aca18 commit 9cdeb94
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 83 deletions.
40 changes: 23 additions & 17 deletions build/Combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var _react = require('react');
var _reactLibReactWithAddons = require('react/lib/ReactWithAddons');

var _react2 = _interopRequireDefault(_react);
var _reactLibReactWithAddons2 = _interopRequireDefault(_reactLibReactWithAddons);

var _reactDom = require('react-dom');

var _reactDom2 = _interopRequireDefault(_reactDom);

var _reactBootstrap = require('react-bootstrap');

Expand All @@ -34,6 +38,8 @@ var _lodashFunctionDebounce = require('lodash/function/debounce');

var _lodashFunctionDebounce2 = _interopRequireDefault(_lodashFunctionDebounce);

var caret = _reactLibReactWithAddons2['default'].createElement('span', { className: 'caret' });

var uid = 0;

/**
Expand All @@ -44,7 +50,7 @@ var uid = 0;
* @example
* import {Combo} from 'react-bootstrap-combobox';
*
* React.render(<Combo items={{
* ReactDOM.render(<Combo items={{
* // keys must be unique
* a: {label: 'first item', header: true}, // any combination of props supported by MenuItem
* b: 'second item', // same as {label: 'second item'}
Expand Down Expand Up @@ -116,7 +122,7 @@ var Combo = (function (_React$Component) {
_createClass(Combo, [{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(props, state) {
return props.onChange !== this.props.onChange || props.items !== this.props.items || props.value !== this.props.value || state.maxHeight !== this.state.maxHeight;
return _reactLibReactWithAddons2['default'].addons.shallowCompare(this, props, state);
}

/**
Expand Down Expand Up @@ -166,7 +172,7 @@ var Combo = (function (_React$Component) {
}
this.viewportHeight = height;

this.setState({ maxHeight: height - _react2['default'].findDOMNode(this).getBoundingClientRect().bottom - 5 });
this.setState({ maxHeight: height - _reactDom2['default'].findDOMNode(this).getBoundingClientRect().bottom - 5 });
}

/**
Expand Down Expand Up @@ -213,14 +219,14 @@ var Combo = (function (_React$Component) {
}, {
key: 'renderButton',
value: function renderButton() {
return _react2['default'].createElement(
return _reactLibReactWithAddons2['default'].createElement(
_reactBootstrap.Button,
{ block: true, bsRole: 'toggle', className: 'dropdown-toggle' },
_react2['default'].createElement(
_reactLibReactWithAddons2['default'].createElement(
'div',
null,
this.getLabel(),
_react2['default'].createElement('span', { className: 'caret' })
caret
)
);
}
Expand All @@ -241,12 +247,12 @@ var Combo = (function (_React$Component) {
value: function renderMenuItem(item, i) {
item = this.normalize(item);
if (item.divider) {
return _react2['default'].createElement(_reactBootstrap.MenuItem, { key: i, divider: true });
return _reactLibReactWithAddons2['default'].createElement(_reactBootstrap.MenuItem, { key: i, divider: true });
}
return _react2['default'].createElement(
return _reactLibReactWithAddons2['default'].createElement(
_reactBootstrap.MenuItem,
_extends({ key: i, eventKey: i, active: i === this.props.value }, item),
_react2['default'].createElement(
_reactLibReactWithAddons2['default'].createElement(
'div',
null,
item.label
Expand All @@ -266,7 +272,7 @@ var Combo = (function (_React$Component) {
}, {
key: 'renderMenu',
value: function renderMenu() {
return _react2['default'].createElement(
return _reactLibReactWithAddons2['default'].createElement(
_reactBootstrap.Dropdown.Menu,
{ style: this.state },
(0, _lodashCollectionMap2['default'])(this.props.items, this.renderMenuItem, this)
Expand All @@ -285,7 +291,7 @@ var Combo = (function (_React$Component) {
}, {
key: 'render',
value: function render() {
return _react2['default'].createElement(
return _reactLibReactWithAddons2['default'].createElement(
_reactBootstrap.Dropdown,
{ className: 'al-combo', id: this.id, onSelect: this.props.onChange },
this.renderButton(),
Expand All @@ -295,14 +301,14 @@ var Combo = (function (_React$Component) {
}]);

return Combo;
})(_react2['default'].Component);
})(_reactLibReactWithAddons2['default'].Component);

exports['default'] = Combo;

Combo.propTypes = {
onChange: _react2['default'].PropTypes.func,
items: _react2['default'].PropTypes.object.isRequired,
value: _react2['default'].PropTypes.string.isRequired
onChange: _reactLibReactWithAddons2['default'].PropTypes.func,
items: _reactLibReactWithAddons2['default'].PropTypes.object.isRequired,
value: _reactLibReactWithAddons2['default'].PropTypes.string.isRequired
};
Combo.defaultProps = { onChange: Function.prototype };
module.exports = exports['default'];
3 changes: 2 additions & 1 deletion development/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* @flow */

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

React.render(<App />, document.getElementById('app'));
ReactDOM.render(<App />, document.getElementById('app'));
2 changes: 1 addition & 1 deletion docs/Combo.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ <h5>Example</h5>

<pre class="prettyprint"><code>import {Combo} from 'react-bootstrap-combobox';

React.render(&lt;Combo items={{
ReactDOM.render(&lt;Combo items={{
// keys must be unique
a: {label: 'first item', header: true}, // any combination of props supported by MenuItem
b: 'second item', // same as {label: 'second item'}
Expand Down
16 changes: 9 additions & 7 deletions lib/Combo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/* @flow */

import React from 'react';
import React from 'react/lib/ReactWithAddons';
import ReactDOM from 'react-dom';
import {Button, Dropdown, MenuItem} from 'react-bootstrap';
import map from 'lodash/collection/map';
import isString from 'lodash/lang/isString';
import debounce from 'lodash/function/debounce';

const caret = <span className="caret" />;

let uid = 0;

/**
Expand All @@ -16,7 +19,7 @@ let uid = 0;
* @example
* import {Combo} from 'react-bootstrap-combobox';
*
* React.render(<Combo items={{
* ReactDOM.render(<Combo items={{
* // keys must be unique
* a: {label: 'first item', header: true}, // any combination of props supported by MenuItem
* b: 'second item', // same as {label: 'second item'}
Expand Down Expand Up @@ -94,9 +97,8 @@ export default class Combo extends React.Component {
* @param {Object} state - A new component state
* @return {boolean} true if the component needs to be re-rendered
*/
shouldComponentUpdate(props: Object, state: Object): bool {
return props.onChange !== this.props.onChange || props.items !== this.props.items ||
props.value !== this.props.value || state.maxHeight !== this.state.maxHeight;
shouldComponentUpdate(props: Object, state: Object): boolean {
return React.addons.shallowCompare(this, props, state);
}

/**
Expand Down Expand Up @@ -140,7 +142,7 @@ export default class Combo extends React.Component {
}
this.viewportHeight = height;

this.setState({maxHeight: height - React.findDOMNode(this).getBoundingClientRect().bottom - 5});
this.setState({maxHeight: height - ReactDOM.findDOMNode(this).getBoundingClientRect().bottom - 5});
}

/**
Expand Down Expand Up @@ -183,7 +185,7 @@ export default class Combo extends React.Component {
renderButton(): any {
return (
<Button block bsRole="toggle" className="dropdown-toggle">
<div>{this.getLabel()}<span className="caret" /></div>
<div>{this.getLabel()}{caret}</div>
</Button>
);
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
"dependencies": {
"babel-runtime": "^5.8.19",
"lodash": "^3.10.1",
"react": "^0.13.3",
"react-bootstrap": "^0.26.1"
"react": "^0.14.0",
"react-bootstrap": "^0.27.1",
"react-dom": "^0.14.0"
},
"devDependencies": {
"babel": "^5.8.21",
Expand All @@ -46,7 +47,6 @@
"proxyquire": "^1.7.3",
"react-hot-loader": "^1.2.8",
"release-script": "^0.5.3",
"webcompiler": "^1.5.4",
"webpack-dev-server": "^1.10.1"
"webcompiler": "^2.0.4"
}
}
Loading

0 comments on commit 9cdeb94

Please sign in to comment.