cpr-select
Advanced tools
Comparing version 1.1.1 to 1.1.3
@@ -6,4 +6,4 @@ /*! | ||
* license: MIT | ||
* version: 1.1.0 | ||
* version: 1.1.3 | ||
*/ | ||
!function(e){function t(n){if(s[n])return s[n].exports;var i=s[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var s={};return t.m=e,t.c=s,t.p="",t(0)}([function(e,t,s){"use strict";function n(e,t){for(var s,n=!0;n;){n=!1;var i=e,o=t;if(!i)return!1;if(s=i.className.indexOf(o)>-1)return s;e=i.parentElement,t=o,n=!0}}var i=function(e){return e&&e.__esModule?e["default"]:e},o=i(s(1)),l=s(2).findIndex,a=void 0,c=void 0,r=o.createClass({displayName:"CanopySelect",componentWillMount:function(){document.body.addEventListener("click",this.state.close)},componentWillUnmount:function(){document.body.removeEventListener("click",this.state.close)},getInitialState:function(){var e=this,t=null;return this.props.selected&&(t=this.getIndex(this.props.selected)),{dialogDisplayed:!1,top:0,focused:!1,close:function(t){n(t.target,"cp-select-outer")||e.setState({dialogDisplayed:!1,focused:!1})}}},displayDialog:function(e){this.setState({dialogDisplayed:!0})},getIndex:function(e){return l(this.props.options,{key:e})},onKeyDown:function(e){var t=e.which,s=this.state.selectedIndex;9!==t&&e.preventDefault(),13===t?this.selectItem(s):38===t?this.setState({dialogDisplayed:!0,selectedIndex:s?s-1:0}):40===t?s===this.props.options.length-1?this.setState({dialogDisplayed:!0}):this.setState({dialogDisplayed:!0,selectedIndex:s?s+1:0}):27===t?this.setState({dialogDisplayed:!1}):this.highlightByText(e.which)},triggerItemChange:function(){this.props.onChange&&this.props.onChange.call(null,this.props.options[this.state.selectedIndex].key,this.props.options[this.state.selectedIndex],this.state.selectedIndex)},selectItem:function(e,t){var s=this;setTimeout(function(){s.setState({selectedIndex:e,focused:!0,dialogDisplayed:!1}),setTimeout(s.triggerItemChange)})},positionDialogAndGetTop:function(e,t){var s=e.length-t;return t>5&&6>s?e.length<11?-2+(36*t*-1-10)+"px":(this.positionDialog(t),-215-36*(5-s)+"px"):t>5?(this.positionDialog(t),"-203px"):-1+(36*t*-1-10)+"px"},positionDialog:function(e){var t=this;setTimeout(function(){var s=o.findDOMNode(t).querySelector(".cp-select__menu");s&&(s.scrollTop=36*e-192)})},focusSelect:function(){this.state.focused||this.setState({focused:!0})},onBlur:function(){this.setState({focused:!1})},highlightByText:function(e){a+=String.fromCharCode(e);var t=this.getIndexFromString(a);t>-1&&this.setState({selectedIndex:t}),c=setTimeout(function(){a=""},1e3)},getIndexFromString:function(e){var t=this;return e=e.toLowerCase(),l(this.props.options,function(s){return 0===t.getViewValue(s).toLowerCase().indexOf(e)})},getViewValue:function(e){return e.value||e},getDialog:function(e,t){var s=this;if(e){var n=function(){var e=s.state.selectedIndex,n=t.map(function(t,n){return o.createElement("li",{key:t.key,className:e===n?"+selected":"",onMouseDown:s.selectItem.bind(s,n)},o.createElement("a",null,t.value))});return setTimeout(function(){try{o.findDOMNode(s).querySelector(".cp-select__hidden-input").focus()}catch(e){if(-1===e.message.indexOf("Invariant Violation"))throw new Error(e.message)}},100),{v:o.createElement("div",null,o.createElement("ul",{className:"cp-select__menu cps-dropdown-menu",style:{top:s.positionDialogAndGetTop(t,e)}},n))}}();if("object"==typeof n)return n.v}},render:function(){var e="cp-select",t=this.props.options[this.getIndex(this.props.selected)];return this.props.disabled&&(e+=" +disabled"),this.state.focused&&(e+=" +focus"),o.createElement("div",{className:"cp-select-outer",role:"select"},o.createElement("input",{className:"cp-select__hidden-input",onFocus:this.focusSelect,onBlur:this.onBlur,onKeyDown:this.onKeyDown}),o.createElement("div",{className:e,onClick:this.displayDialog},o.createElement("div",{className:"cp-select__selected"},t?t.value:this.props.placeholder),o.createElement("div",{className:"cp-select__icon"})),this.getDialog(this.state.dialogDisplayed,this.props.options))}});window&&!window.CanopySelect&&(window.CanopySelect=r),e.exports=r},function(e,t){e.exports=React},function(e,t){e.exports=_}]); | ||
!function(e){function t(i){if(s[i])return s[i].exports;var n=s[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var s={};return t.m=e,t.c=s,t.p="",t(0)}([function(e,t,s){"use strict";function i(e,t){for(var s,i=!0;i;){i=!1;var n=e,o=t;if(!n)return!1;if(s=n.className.indexOf(o)>-1)return s;e=n.parentElement,t=o,i=!0}}var n=function(e){return e&&e.__esModule?e["default"]:e},o=n(s(1)),l=s(2).findIndex,a=void 0,c=void 0,r=o.createClass({displayName:"CanopySelect",componentWillMount:function(){document.body.addEventListener("click",this.state.close)},componentWillUnmount:function(){document.body.removeEventListener("click",this.state.close)},getInitialState:function(){var e=this,t=null;return this.props.selected&&(t=this.getIndex(this.props.selected)),{dialogDisplayed:!1,top:0,focused:!1,close:function(t){i(t.target,"cp-select-outer")||e.setState({dialogDisplayed:!1,focused:!1})}}},displayDialog:function(e){this.setState({dialogDisplayed:!0})},getIndex:function(e){return l(this.props.options,{key:e})},onKeyDown:function(e){var t=e.which,s=this.state.selectedIndex;9!==t&&e.preventDefault(),13===t?this.selectItem(s):38===t?this.setState({dialogDisplayed:!0,selectedIndex:void 0===s?0:s-1}):40===t?s===this.props.options.length-1?this.setState({dialogDisplayed:!0}):this.setState({dialogDisplayed:!0,selectedIndex:s?s+1:0}):27===t?this.setState({dialogDisplayed:!1}):this.highlightByText(e.which)},triggerItemChange:function(){this.props.onChange&&this.props.onChange.call(null,this.props.options[this.state.selectedIndex].key,this.props.options[this.state.selectedIndex],this.state.selectedIndex)},selectItem:function(e,t){var s=this;setTimeout(function(){s.setState({selectedIndex:e,focused:!0,dialogDisplayed:!1}),setTimeout(s.triggerItemChange)})},positionDialogAndGetTop:function(e,t){var s=e.length-t;return t>5&&6>s?e.length<11?-2+(36*t*-1-10)+"px":(this.positionDialog(t),-215-36*(5-s)+"px"):t>5?(this.positionDialog(t),"-203px"):-1+(36*t*-1-10)+"px"},positionDialog:function(e){var t=this;setTimeout(function(){var s=o.findDOMNode(t).querySelector(".cp-select__menu");s&&(s.scrollTop=36*e-192)})},focusSelect:function(){this.state.focused||this.setState({focused:!0})},onBlur:function(){this.setState({focused:!1})},highlightByText:function(e){a+=String.fromCharCode(e);var t=this.getIndexFromString(a);t>-1&&this.setState({selectedIndex:t}),c=setTimeout(function(){a=""},1e3)},getIndexFromString:function(e){var t=this;return e=e.toLowerCase(),l(this.props.options,function(s){return 0===t.getViewValue(s).toLowerCase().indexOf(e)})},getViewValue:function(e){return e.value||e},getDialog:function(e,t){var s=this;if(e){var i=function(){var e=s.state.selectedIndex,i=t.map(function(t,i){return o.createElement("li",{key:t.key,className:e===i?"+selected":"",onMouseDown:s.selectItem.bind(s,i)},o.createElement("a",null,t.value))});return setTimeout(function(){try{o.findDOMNode(s).querySelector(".cp-select__hidden-input").focus()}catch(e){if(-1===e.message.indexOf("Invariant Violation"))throw new Error(e.message)}},100),{v:o.createElement("div",null,o.createElement("ul",{className:"cp-select__menu cps-dropdown-menu",style:{top:s.positionDialogAndGetTop(t,e)}},i))}}();if("object"==typeof i)return i.v}},render:function(){var e="cp-select",t=this.props.options[this.getIndex(this.props.selected)];return this.props.disabled&&(e+=" +disabled"),this.state.focused&&(e+=" +focus"),o.createElement("div",{className:"cp-select-outer",role:"select"},o.createElement("input",{className:"cp-select__hidden-input",onFocus:this.focusSelect,onBlur:this.onBlur,onKeyDown:this.onKeyDown}),o.createElement("div",{className:e,onClick:this.displayDialog},o.createElement("div",{className:"cp-select__selected"},t?t.value:this.props.placeholder),o.createElement("div",{className:"cp-select__icon"})),this.getDialog(this.state.dialogDisplayed,this.props.options))}});window&&!window.CanopySelect&&(window.CanopySelect=r),e.exports=r},function(e,t,s){e.exports=React},function(e,t,s){e.exports=_}]); |
@@ -103,3 +103,3 @@ 'use strict'; | ||
dialogDisplayed: true, | ||
selectedIndex: !selectedIndex ? 0 : selectedIndex - 1 | ||
selectedIndex: selectedIndex === undefined ? 0 : selectedIndex - 1 | ||
}); | ||
@@ -109,25 +109,25 @@ | ||
} else if (key === 40) { | ||
// down key | ||
// down key | ||
if (selectedIndex === this.props.options.length - 1) { | ||
this.setState({ | ||
dialogDisplayed: true | ||
}); | ||
} else { | ||
this.setState({ | ||
dialogDisplayed: true, | ||
selectedIndex: !selectedIndex ? 0 : selectedIndex + 1 | ||
}); | ||
} | ||
if (selectedIndex === this.props.options.length - 1) { | ||
this.setState({ | ||
dialogDisplayed: true | ||
}); | ||
} else { | ||
this.setState({ | ||
dialogDisplayed: true, | ||
selectedIndex: !selectedIndex ? 0 : selectedIndex + 1 | ||
}); | ||
} | ||
//positionDialog(scope.collection[scope.selectedIndex]); | ||
} else if (key === 27) { | ||
// escape key | ||
this.setState({ | ||
dialogDisplayed: false | ||
}); | ||
} else { | ||
// all other keys | ||
this.highlightByText(e.which); | ||
} | ||
//positionDialog(scope.collection[scope.selectedIndex]); | ||
} else if (key === 27) { | ||
// escape key | ||
this.setState({ | ||
dialogDisplayed: false | ||
}); | ||
} else { | ||
// all other keys | ||
this.highlightByText(e.which); | ||
} | ||
}, | ||
@@ -161,7 +161,7 @@ | ||
// Dialog doesn't have a scroll | ||
return -2 + (36 * index * -1 - 10) + 'px'; | ||
return -2 + (36 * index * -1 - 10) + "px"; | ||
} else { | ||
// Dialog has a scroll | ||
this.positionDialog(index); | ||
return -215 - (5 - distanceFromEnd) * 36 + 'px'; | ||
return -215 - (5 - distanceFromEnd) * 36 + "px"; | ||
} | ||
@@ -174,3 +174,3 @@ } else if (index > 5) { | ||
// Top 5 | ||
return -1 + (36 * index * -1 - 10) + 'px'; | ||
return -1 + (36 * index * -1 - 10) + "px"; | ||
} | ||
@@ -183,3 +183,3 @@ }, | ||
setTimeout(function () { | ||
var menuDialog = _react2['default'].findDOMNode(_this3).querySelector('.cp-select__menu'); | ||
var menuDialog = _react2['default'].findDOMNode(_this3).querySelector(".cp-select__menu"); | ||
if (menuDialog) { | ||
@@ -215,4 +215,5 @@ menuDialog.scrollTop = 36 * index - 192; | ||
// dialogDisplayed: true | ||
keyTimeout = setTimeout(function () { | ||
searchString = ''; | ||
searchString = ""; | ||
}, 1000); | ||
@@ -311,3 +312,2 @@ }, | ||
exports['default'] = CanopySelect; | ||
module.exports = exports['default']; | ||
// dialogDisplayed: true | ||
module.exports = exports['default']; |
@@ -37,10 +37,10 @@ 'use strict'; | ||
var items = [{ | ||
'value': 'Alabama', | ||
'key': 'AL' | ||
"value": "Alabama", | ||
"key": "AL" | ||
}, { | ||
'value': 'Alaska', | ||
'key': 'AK' | ||
"value": "Alaska", | ||
"key": "AK" | ||
}, { | ||
'value': 'American Samoa', | ||
'key': 'AS' | ||
"value": "American Samoa", | ||
"key": "AS" | ||
}]; | ||
@@ -56,10 +56,10 @@ | ||
var items = [{ | ||
'value': 'Alabama', | ||
'key': 'AL' | ||
"value": "Alabama", | ||
"key": "AL" | ||
}, { | ||
'value': 'Alaska', | ||
'key': 'AK' | ||
"value": "Alaska", | ||
"key": "AK" | ||
}, { | ||
'value': 'American Samoa', | ||
'key': 'AS' | ||
"value": "American Samoa", | ||
"key": "AS" | ||
}]; | ||
@@ -79,10 +79,10 @@ | ||
var items = [{ | ||
'value': 'Alabama', | ||
'key': 'AL' | ||
"value": "Alabama", | ||
"key": "AL" | ||
}, { | ||
'value': 'Alaska', | ||
'key': 'AK' | ||
"value": "Alaska", | ||
"key": "AK" | ||
}, { | ||
'value': 'American Samoa', | ||
'key': 'AS' | ||
"value": "American Samoa", | ||
"key": "AS" | ||
}]; | ||
@@ -89,0 +89,0 @@ |
{ | ||
"name": "cpr-select", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"description": "A consistently styled cross-browser and keyboard friendly select component", | ||
@@ -9,3 +9,3 @@ "main": "lib/select.js", | ||
"dist": "webpack --optimize-minimize", | ||
"compile": "node node_modules/babel/bin/babel.js src --out-dir lib", | ||
"compile": "babel src --out-dir lib", | ||
"build": "npm run dist && npm run compile" | ||
@@ -24,24 +24,24 @@ }, | ||
"devDependencies": { | ||
"autoprefixer-loader": "^1.2.0", | ||
"babel": "^5.6.14", | ||
"babel-core": "^4.7.13", | ||
"babel-loader": "^4.2.0", | ||
"css-loader": "^0.9.1", | ||
"jasmine-core": "^2.1.3", | ||
"jsx-loader": "^0.13.2", | ||
"karma": "^0.12.31", | ||
"karma-chrome-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.3.4", | ||
"karma-phantomjs-launcher": "^0.2.0", | ||
"karma-sourcemap-loader": "^0.3.5", | ||
"karma-webpack": "^1.5.1", | ||
"ngmin": "^0.5.0", | ||
"ngmin-webpack-plugin": "^0.1.3", | ||
"autoprefixer-loader": "1.2.0", | ||
"babel": "5.6.14", | ||
"babel-core": "4.7.13", | ||
"babel-loader": "4.2.0", | ||
"css-loader": "0.9.1", | ||
"jasmine-core": "2.1.3", | ||
"jsx-loader": "0.13.2", | ||
"karma": "0.12.31", | ||
"karma-chrome-launcher": "0.1.7", | ||
"karma-jasmine": "0.3.4", | ||
"karma-phantomjs-launcher": "0.2.0", | ||
"karma-sourcemap-loader": "0.3.5", | ||
"karma-webpack": "1.5.1", | ||
"ngmin": "0.5.0", | ||
"ngmin-webpack-plugin": "0.1.3", | ||
"phantomjs-polyfill": "0.0.1", | ||
"style-loader": "^0.8.3", | ||
"webpack": "^1.4.15" | ||
"style-loader": "0.8.3", | ||
"webpack": "1.4.15" | ||
}, | ||
"dependencies": { | ||
"lodash": "^3.10.0", | ||
"react": "^0.13.3" | ||
"react": "^0.14.2" | ||
}, | ||
@@ -48,0 +48,0 @@ "optionalDependencies": { |
@@ -38,3 +38,3 @@ cpr-select [![Build Status](https://travis-ci.org/CanopyTax/cpr-select.png?branch=master)](https://travis-ci.org/CanopyTax/cpr-select) | ||
<CanopySelect items={items} onChange={itemsChanged} placeholder="Select a country" selected="AK"></CanopySelect> | ||
<CanopySelect options={items} onChange={itemsChanged} placeholder="Select a country" selected="AK"></CanopySelect> | ||
``` | ||
@@ -41,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
57884
0
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedfbjs@0.6.1(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedreact@0.14.10(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addedwhatwg-fetch@0.9.0(transitive)
- Removedreact@0.13.3(transitive)
Updatedreact@^0.14.2