react-autowhatever
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -80,3 +80,3 @@ 'use strict'; | ||
if (focusedItem !== null) { | ||
this.focusedItem = focusedItem; | ||
this.focusedItem = focusedItem.item; | ||
} | ||
@@ -124,14 +124,16 @@ } | ||
var itemPropsObj = isItemPropsFunction ? itemProps({ sectionIndex: sectionIndex, itemIndex: itemIndex }) : itemProps; | ||
var newItemProps = _extends({ | ||
id: _this2.getItemId(sectionIndex, itemIndex), | ||
ref: isFocused ? _this2.storeFocusedItemReference : null | ||
var allItemProps = _extends({ | ||
id: _this2.getItemId(sectionIndex, itemIndex) | ||
}, theme(itemKey, 'item', isFocused && 'itemFocused'), itemPropsObj); | ||
return _react2.default.createElement(_Item2.default, { | ||
if (isFocused) { | ||
allItemProps.ref = _this2.storeFocusedItemReference; | ||
} | ||
return _react2.default.createElement(_Item2.default, _extends({}, allItemProps, { | ||
sectionIndex: sectionIndex, | ||
itemIndex: itemIndex, | ||
item: item, | ||
itemProps: newItemProps, | ||
renderItem: renderItem, | ||
key: itemKey }); | ||
key: itemKey })); | ||
}); | ||
@@ -209,4 +211,5 @@ } | ||
var id = this.props; | ||
var id = this.props.id; | ||
return _react2.default.createElement( | ||
@@ -213,0 +216,0 @@ 'ul', |
@@ -33,2 +33,3 @@ 'use strict'; | ||
_this.storeItemReference = _this.storeItemReference.bind(_this); | ||
_this.onMouseEnter = _this.onMouseEnter.bind(_this); | ||
@@ -42,2 +43,20 @@ _this.onMouseLeave = _this.onMouseLeave.bind(_this); | ||
_createClass(Item, [{ | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(nextProps) { | ||
for (var key in nextProps) { | ||
if (nextProps[key] !== this.props[key]) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
}, { | ||
key: 'storeItemReference', | ||
value: function storeItemReference(item) { | ||
if (item !== null) { | ||
this.item = item; | ||
} | ||
} | ||
}, { | ||
key: 'onMouseEnter', | ||
@@ -48,6 +67,5 @@ value: function onMouseEnter(event) { | ||
var itemIndex = _props.itemIndex; | ||
var itemProps = _props.itemProps; | ||
itemProps.onMouseEnter(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
this.props.onMouseEnter(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
} | ||
@@ -60,6 +78,5 @@ }, { | ||
var itemIndex = _props2.itemIndex; | ||
var itemProps = _props2.itemProps; | ||
itemProps.onMouseLeave(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
this.props.onMouseLeave(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
} | ||
@@ -72,6 +89,5 @@ }, { | ||
var itemIndex = _props3.itemIndex; | ||
var itemProps = _props3.itemProps; | ||
itemProps.onMouseDown(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
this.props.onMouseDown(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
} | ||
@@ -84,6 +100,5 @@ }, { | ||
var itemIndex = _props4.itemIndex; | ||
var itemProps = _props4.itemProps; | ||
itemProps.onClick(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
this.props.onClick(event, { sectionIndex: sectionIndex, itemIndex: itemIndex }); | ||
} | ||
@@ -96,5 +111,4 @@ }, { | ||
var renderItem = _props5.renderItem; | ||
var itemProps = _props5.itemProps; | ||
var restProps = _objectWithoutProperties(_props5, ['item', 'renderItem', 'itemProps']); | ||
var restProps = _objectWithoutProperties(_props5, ['item', 'renderItem']); | ||
@@ -104,18 +118,16 @@ delete restProps.sectionIndex; | ||
var liProps = _extends({}, itemProps); | ||
if (typeof itemProps.onMouseEnter === 'function') { | ||
liProps.onMouseEnter = this.onMouseEnter; | ||
if (typeof restProps.onMouseEnter === 'function') { | ||
restProps.onMouseEnter = this.onMouseEnter; | ||
} | ||
if (typeof itemProps.onMouseLeave === 'function') { | ||
liProps.onMouseLeave = this.onMouseLeave; | ||
if (typeof restProps.onMouseLeave === 'function') { | ||
restProps.onMouseLeave = this.onMouseLeave; | ||
} | ||
if (typeof itemProps.onMouseDown === 'function') { | ||
liProps.onMouseDown = this.onMouseDown; | ||
if (typeof restProps.onMouseDown === 'function') { | ||
restProps.onMouseDown = this.onMouseDown; | ||
} | ||
if (typeof itemProps.onClick === 'function') { | ||
liProps.onClick = this.onClick; | ||
if (typeof restProps.onClick === 'function') { | ||
restProps.onClick = this.onClick; | ||
} | ||
@@ -125,3 +137,3 @@ | ||
'li', | ||
_extends({ role: 'option' }, restProps, liProps), | ||
_extends({ role: 'option' }, restProps, { ref: this.storeItemReference }), | ||
renderItem(item) | ||
@@ -140,4 +152,7 @@ ); | ||
renderItem: _react.PropTypes.func.isRequired, | ||
itemProps: _react.PropTypes.object.isRequired | ||
onMouseEnter: _react.PropTypes.func, | ||
onMouseLeave: _react.PropTypes.func, | ||
onMouseDown: _react.PropTypes.func, | ||
onClick: _react.PropTypes.func | ||
}; | ||
exports.default = Item; |
{ | ||
"name": "react-autowhatever", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Accessible rendering layer for Autosuggest and Autocomplete components", | ||
@@ -13,4 +13,4 @@ "main": "dist/Autowhatever.js", | ||
"start": "mkdir -p demo/dist && npm run copy-static-files && node server", | ||
"lint": "eslint demo/src src server.js webpack.dev.config.js webpack.gh-pages.config.js", | ||
"test": "mocha test/index.js --compilers js:babel-register", | ||
"lint": "eslint src test demo/src server.js webpack.dev.config.js webpack.gh-pages.config.js", | ||
"test": "mocha 'test/*.test.js' --compilers js:babel-register --require test/setup.js", | ||
"copy-static-files": "cp demo/src/index.html demo/dist/", | ||
@@ -48,2 +48,3 @@ "dist": "rm -rf dist && mkdir dist && babel src -d dist", | ||
"extract-text-webpack-plugin": "^1.0.1", | ||
"jsdom": "^9.4.1", | ||
"less": "^2.7.1", | ||
@@ -54,2 +55,3 @@ "less-loader": "^2.2.3", | ||
"react": "^15.2.1", | ||
"react-addons-test-utils": "^15.2.1", | ||
"react-dom": "^15.2.1", | ||
@@ -59,2 +61,4 @@ "react-hot-loader": "^1.3.0", | ||
"redux": "^3.5.2", | ||
"sinon": "^1.17.4", | ||
"sinon-chai": "^2.8.0", | ||
"style-loader": "^0.13.1", | ||
@@ -61,0 +65,0 @@ "webpack": "^1.13.0", |
25319
440
30