Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cpr-select

Package Overview
Dependencies
Maintainers
8
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpr-select - npm Package Compare versions

Comparing version 2.5.4 to 2.5.5

4

build/cpr-select.js

@@ -6,3 +6,3 @@ /*!

* license: MIT
* version: 2.5.2
*/!function(e){var t={};function n(o){if(t[o])return t[o].exports;var l=t[o]={i:o,l:!1,exports:{}};return e[o].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)n.d(o,l,function(t){return e[t]}.bind(null,l));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=function(e){return e&&e.__esModule?e:{default:e}}(n(1)),r=n(2);function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var i="",s=void 0;var c=function(e){function t(){var e,n,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var c=arguments.length,u=Array(c),d=0;d<c;d++)u[d]=arguments[d];return n=o=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),o.state={dialogDisplayed:!1,top:0,focused:!1,close:function(e){(function e(t,n){return!!t&&(t===n||e(t.parentElement,n))})(e.target,o.el)||o.setState({dialogDisplayed:!1,focused:!1})}},o.displayDialog=function(e){o.disabled()||o.setState({dialogDisplayed:!0})},o.getIndex=function(e){return(0,r.findIndex)(o.props.options,{key:e})},o.onKeyDown=function(e){if(!o.disabled()){var t=e.which,n=o.state.selectedIndex;9!==t&&e.preventDefault(),13===t?o.selectItem(n):38===t?n<=0?o.setState({dialogDisplayed:!0}):o.setState({dialogDisplayed:!0,selectedIndex:n-1}):40===t?n===o.props.options.length-1?o.setState({dialogDisplayed:!0}):o.setState({dialogDisplayed:!0,selectedIndex:n+1}):27===t?o.setState({dialogDisplayed:!1}):o.highlightByText(e.which)}},o.triggerItemChange=function(){o.props.onChange&&o.props.onChange.call(null,o.props.options[o.state.selectedIndex].key,o.props.options[o.state.selectedIndex],o.state.selectedIndex)},o.selectItem=function(e,t){o.disabled()||setTimeout(function(){o.setState({selectedIndex:e,focused:!0,dialogDisplayed:!1}),setTimeout(o.triggerItemChange)})},o.positionDialogAndGetTop=function(e,t,n){var l=e.length-t,r=Math.floor(n/36),a=Math.floor((r-1)/2);return t>a&&l<a+1?e.length<r?36*t*-1-10-2+"px":(o.positionDialog(t,n),n/-2-15-36*(a-l)+"px"):t>a?(o.positionDialog(t,n),n/-2-.0075*n):36*t*-1-10-1+"px"},o.positionDialog=function(e,t){setTimeout(function(){var n=o.el.querySelector(".cp-select__menu");if(n){var l=t/2-8;n.scrollTop=36*e-l}})},o.focusSelect=function(){o.state.focused||o.setState({focused:!0})},o.onBlur=function(){o.setState({focused:!1},function(){o.props.onBlur&&o.props.onBlur.call(null,o.props.options[o.state.selectedIndex].key,o.props.options[o.state.selectedIndex],o.state.selectedIndex)})},o.highlightByText=function(e){i+=String.fromCharCode(e);var t=o.getIndexFromString(i);t>-1&&o.selectItem(t),clearTimeout(s),s=setTimeout(function(){i=""},1e3)},o.getIndexFromString=function(e){return e=e.toLowerCase(),(0,r.findIndex)(o.props.options,function(t){return null!==o.getViewValue(t)&&0===o.getViewValue(t).toLowerCase().indexOf(e)})},o.getViewValue=function(e){return null===e.value||void 0===e.value?null:e.value||e},o.getDialog=function(e,t,n){if(e){var r=o.state.selectedIndex,a=t.map(function(e,t){return e.separator?l.default.createElement("li",{key:"separator"+t,className:"separator"}):l.default.createElement("li",{key:e.key,className:r===t?"+selected":"",onMouseDown:o.selectItem.bind(o,t)},l.default.createElement("a",{style:null!==e.value?{}:{color:"rgba(0,0,0,0)"}},null!==e.value?e.value:"null"))});setTimeout(function(){try{o.el.querySelector(".cp-select__hidden-input").focus()}catch(e){if(-1===e.message.indexOf("Invariant Violation"))throw new Error(e.message)}},100);var i=o.props.maxHeight||400,s=o.props.zIndex||1e3;return l.default.createElement("div",null,l.default.createElement("ul",{className:"cp-select__menu cps-dropdown-menu "+(n||""),style:{top:o.positionDialogAndGetTop(t,r,i),maxHeight:i+"px",zIndex:s}},a))}},o.disabled=function(){return!o.props.options||0===o.props.options.length||o.props.disabled},o.render=function(){var e=o.props,t=e.options,n=void 0===t?[]:t,r=e.selected,a=e.outerClass,i=e.selectClass,s=e.placeholder,c=e.dropdownClass;console.log("dropdownClass",c);var u="cp-select",d=n[o.getIndex(r)],p=o;return o.disabled()&&(u+=" +disabled"),o.state.focused&&(u+=" +focus"),l.default.createElement("div",{ref:function(e){e&&(p.el=e)},className:"cp-select-outer "+(a||""),role:"select"},l.default.createElement("input",{className:"cp-select__hidden-input",onFocus:o.focusSelect,onBlur:o.onBlur,onKeyDown:o.onKeyDown}),l.default.createElement("div",{className:u+" "+(i||""),onClick:o.displayDialog},d?l.default.createElement("div",{className:"cp-select__selected"},d.value):l.default.createElement("div",{className:"cp-select__selected",style:{color:"#afafaf"}},s),n.length>0&&l.default.createElement("div",{className:"cp-select__icon"})),o.getDialog(o.state.dialogDisplayed,n,c))},a(o,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,l.default.Component),o(t,[{key:"componentWillUnmount",value:function(){document.body.removeEventListener("click",this.state.close)}},{key:"componentDidMount",value:function(){document.body.addEventListener("click",this.state.close);var e=this.getIndex(this.props.selected);this.setState(function(){return{selectedIndex:-1===e?0:e}})}}]),t}();t.default=c,"undefined"!=typeof window&&window&&!window.CanopySelect&&(window.CanopySelect=c)},function(e,t){e.exports=React},function(e,t){e.exports=_}]);
* version: 2.5.1
*/!function(e){var t={};function n(o){if(t[o])return t[o].exports;var l=t[o]={i:o,l:!1,exports:{}};return e[o].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)n.d(o,l,function(t){return e[t]}.bind(null,l));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=_},function(e,t){e.exports=React},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o,l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=n(1),a=(o=r)&&o.__esModule?o:{default:o},i=n(0);function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var c="",u=void 0;var d=function(e){function t(){var e,n,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var l=arguments.length,r=Array(l),d=0;d<l;d++)r[d]=arguments[d];return n=o=s(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(r))),o.state={dialogDisplayed:!1,top:0,focused:!1,close:function(e){(function e(t,n){return!!t&&(t===n||e(t.parentElement,n))})(e.target,o.el)||o.setState({dialogDisplayed:!1,focused:!1})}},o.displayDialog=function(e){o.disabled()||o.setState({dialogDisplayed:!0})},o.getIndex=function(e){return(0,i.findIndex)(o.props.options,{key:e})},o.onKeyDown=function(e){if(!o.disabled()){var t=e.which,n=o.state.selectedIndex;9!==t&&e.preventDefault(),13===t?o.selectItem(n):38===t?n<=0?o.setState({dialogDisplayed:!0}):o.setState({dialogDisplayed:!0,selectedIndex:n-1}):40===t?n===o.props.options.length-1?o.setState({dialogDisplayed:!0}):o.setState({dialogDisplayed:!0,selectedIndex:n+1}):27===t?o.setState({dialogDisplayed:!1}):o.highlightByText(e.which)}},o.triggerItemChange=function(){o.props.onChange&&o.props.onChange.call(null,o.props.options[o.state.selectedIndex].key,o.props.options[o.state.selectedIndex],o.state.selectedIndex)},o.selectItem=function(e,t){o.disabled()||setTimeout(function(){o.setState({selectedIndex:e,focused:!0,dialogDisplayed:!1}),setTimeout(o.triggerItemChange)})},o.positionDialogAndGetTop=function(e,t,n){var l=e.length-t,r=Math.floor(n/36),a=Math.floor((r-1)/2);return t>a&&l<a+1?e.length<r?36*t*-1-10-2+"px":(o.positionDialog(t,n),n/-2-15-36*(a-l)+"px"):t>a?(o.positionDialog(t,n),n/-2-.0075*n):36*t*-1-10-1+"px"},o.positionDialog=function(e,t){setTimeout(function(){var n=o.el.querySelector(".cp-select__menu");if(n){var l=t/2-8;n.scrollTop=36*e-l}})},o.focusSelect=function(){o.state.focused||o.setState({focused:!0})},o.onBlur=function(){o.setState({focused:!1,dialogDisplayed:!1},function(){o.props.onBlur&&o.props.onBlur.call(null,o.props.options[o.state.selectedIndex].key,o.props.options[o.state.selectedIndex],o.state.selectedIndex)})},o.highlightByText=function(e){c+=String.fromCharCode(e);var t=o.getIndexFromString(c);t>-1&&o.selectItem(t),clearTimeout(u),u=setTimeout(function(){c=""},1e3)},o.getIndexFromString=function(e){return e=e.toLowerCase(),(0,i.findIndex)(o.props.options,function(t){return null!==o.getViewValue(t)&&0===o.getViewValue(t).toLowerCase().indexOf(e)})},o.getViewValue=function(e){return null===e.value||void 0===e.value?null:e.value||e},o.getDialog=function(e,t){if(e){var n=o.state.selectedIndex,l=t.map(function(e,t){return e.separator?a.default.createElement("li",{key:"separator"+t,className:"separator"}):a.default.createElement("li",{key:e.key,className:n===t?"+selected":"",onMouseDown:o.selectItem.bind(o,t)},a.default.createElement("a",{style:null!==e.value?{}:{color:"rgba(0,0,0,0)"}},null!==e.value?e.value:"null"))});setTimeout(function(){try{o.el.querySelector(".cp-select__hidden-input").focus()}catch(e){if(-1===e.message.indexOf("Invariant Violation"))throw new Error(e.message)}},100);var r=o.props.maxHeight||400,i=o.props.zIndex||1e3;return a.default.createElement("div",null,a.default.createElement("ul",{className:"cp-select__menu cps-dropdown-menu",style:{top:o.positionDialogAndGetTop(t,n,r),maxHeight:r+"px",zIndex:i}},l))}},o.disabled=function(){return!o.props.options||0===o.props.options.length||o.props.disabled},o.render=function(){var e=o.props,t=e.options,n=void 0===t?[]:t,l=e.selected,r=e.outerClass,i=e.selectClass,s=e.placeholder,c="cp-select",u=n[o.getIndex(l)],d=o;return o.disabled()&&(c+=" +disabled"),o.state.focused&&(c+=" +focus"),a.default.createElement("div",{ref:function(e){e&&(d.el=e)},className:"cp-select-outer "+(r||""),role:"select"},a.default.createElement("input",{className:"cp-select__hidden-input",onFocus:o.focusSelect,onBlur:o.onBlur,onKeyDown:o.onKeyDown}),a.default.createElement("div",{className:c+" "+(i||""),onClick:o.displayDialog},u?a.default.createElement("div",{className:"cp-select__selected"},u.value):a.default.createElement("div",{className:"cp-select__selected",style:{color:"#afafaf"}},s),n.length>0&&a.default.createElement("div",{className:"cp-select__icon"})),o.getDialog(o.state.dialogDisplayed,n))},s(o,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default.Component),l(t,[{key:"componentWillUnmount",value:function(){document.body.removeEventListener("click",this.state.close)}},{key:"componentDidMount",value:function(){document.body.addEventListener("click",this.state.close);var e=this.getIndex(this.props.selected);this.setState(function(){return{selectedIndex:-1===e?0:e}})}}]),t}();t.default=d,"undefined"!=typeof window&&window&&!window.CanopySelect&&(window.CanopySelect=d)}]);

@@ -170,3 +170,5 @@ 'use strict';

_this.setState({
focused: false
focused: false,
dialogDisplayed: false
}, function () {

@@ -173,0 +175,0 @@ if (_this.props.onBlur) {

{
"name": "cpr-select",
"version": "2.5.4",
"version": "2.5.5",
"description": "A consistently styled cross-browser and keyboard friendly select component",

@@ -5,0 +5,0 @@ "main": "lib/select.js",

@@ -58,7 +58,7 @@ import React from 'react';

if(key !== 9) { // tab key
if(key !== 9) { // tab key
e.preventDefault();
}
if(key === 13) { // enter key
if(key === 13) { // enter key
this.selectItem(selectedIndex)

@@ -93,3 +93,3 @@ } else if(key === 38) { // up key

});
} else { // all other keys
} else { // all other keys
this.highlightByText(e.which);

@@ -170,3 +170,5 @@ }

this.setState({
focused: false
focused: false,
dialogDisplayed: false
}, () => {

@@ -173,0 +175,0 @@ if (this.props.onBlur) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc