Skip to content

Commit

Permalink
0.0.5 lib build
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansfdc committed Sep 25, 2015
1 parent 0d5d660 commit 6b5f522
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
26 changes: 17 additions & 9 deletions lib/SLDSPicklistBase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ module.exports = _react2['default'].createClass({
modal: false,
className: '',
listClassName: '',
onClick: function onClick() {
console.log('onClick should be defined');
},
onClick: function onClick() {},
onSelect: function onSelect(value) {
console.log('onItemSelect should be defined');
},
Expand Down Expand Up @@ -107,14 +105,21 @@ module.exports = _react2['default'].createClass({
},

handleClick: function handleClick(event) {
event.preventDefault();
event.stopPropagation();
this.setState({ isOpen: true });
if (this.props.onClick) {
this.props.onClick();
_utils.EventUtil.trap(event);
if (!this.state.isOpen) {
this.setState({ isOpen: true });
if (this.props.onClick) {
this.props.onClick();
}
} else {
this.handleClose();
}
},

handleMouseDown: function handleMouseDown(event) {
_utils.EventUtil.trapImmediate(event);
},

handleBlur: function handleBlur(e) {
this.setState({ isFocused: false });
},
Expand All @@ -135,6 +140,7 @@ module.exports = _react2['default'].createClass({
if (event.keyCode) {
if (event.keyCode === _utils.KEYS.ENTER || event.keyCode === _utils.KEYS.SPACE || event.keyCode === _utils.KEYS.DOWN || event.keyCode === _utils.KEYS.UP) {
_utils.EventUtil.trapEvent(event);

this.setState({
isOpen: true,
highlightedIndex: 0
Expand Down Expand Up @@ -210,7 +216,7 @@ module.exports = _react2['default'].createClass({
var className = this.state.currentSelectedItem ? 'slds-input--bare slds-hide' : 'slds-input--bare';
return _react2['default'].createElement(
'div',
{ className: "slds-form-element ignore-react-onclickoutside slds-theme--" + this.props.theme },
{ className: "slds-form-element slds-theme--" + this.props.theme },
_react2['default'].createElement(
'div',
{ className: "slds-picklist slds-theme--" + this.props.theme },
Expand All @@ -227,6 +233,7 @@ module.exports = _react2['default'].createClass({
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onClick: this.handleClick,
onMouseDown: this.handleMouseDown,
tabIndex: this.state.isOpen ? -1 : 0,
onKeyDown: this.handleKeyDown },
_react2['default'].createElement(
Expand All @@ -243,6 +250,7 @@ module.exports = _react2['default'].createClass({
},

componentDidUpdate: function componentDidUpdate(prevProps, prevState) {

if (this.state.lastBlurredTimeStamp !== prevState.lastBlurredTimeStamp) {
if (this.state.lastBlurredIndex === this.state.highlightedIndex) {
this.handleClose();
Expand Down
7 changes: 6 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ var _SLDSSettings = require('./SLDSSettings');

var _SLDSSettings2 = _interopRequireDefault(_SLDSSettings);

var _SLDSButton = require('./SLDSButton');

var _SLDSButton2 = _interopRequireDefault(_SLDSButton);

module.exports = {
SLDSPicklistBase: _SLDSPicklistBase2['default'],
SLDSSettings: _SLDSSettings2['default']
SLDSSettings: _SLDSSettings2['default'],
SLDSButton: _SLDSButton2['default']
};
7 changes: 7 additions & 0 deletions lib/utils/EventUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ var EventUtil = {

trap: function trap(event) {
return EventUtil.trapEvent(event);
},

trapImmediate: function trapImmediate(event) {
if (event.nativeEvent) {
event.nativeEvent.stopImmediatePropagation();
}
EventUtil.trap(event);
}

};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "design-system-react",
"version": "0.0.4",
"version": "0.0.5",
"description": "Salesforce Lightning Design System React components",
"scripts": {
"start": "node server.js",
Expand Down

0 comments on commit 6b5f522

Please sign in to comment.