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

cpr-select

Package Overview
Dependencies
Maintainers
1
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 1.0.4 to 1.0.5

4

build/cpr-select.js

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

* license: MIT
* version: 1.0.4
* version: 1.0.5
*/
!function(e){function t(s){if(n[s])return n[s].exports;var i=n[s]={exports:{},id:s,loaded:!1};return e[s].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function s(e,t){for(var n,s=!0;s;){s=!1;var i=e,o=t;if(!i)return!1;if(n=i.className.indexOf(o)>-1)return n;e=i.parentElement,t=o,s=!0}}var i=function(e){return e&&e.__esModule?e["default"]:e},o=i(n(1)),r=n(2).findIndex;n(3);var a=void 0,l=void 0,c=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=r(this.props.options,{key:this.props.selected})),{selectedIndex:t,dialogDisplayed:!1,top:0,focused:!1,close:function(t){s(t.target,"cp-select-outer")||e.setState({dialogDisplayed:!1,focused:!1})}}},displayDialog:function(e){this.setState({dialogDisplayed:!0})},onKeyDown:function(e){var t=e.which,n=this.state.selectedIndex;9!==t&&e.preventDefault(),13===t?this.selectItem(n):38===t?this.setState({dialogDisplayed:!0,selectedIndex:n?n-1:0}):40===t?n===this.props.options.length-1?this.setState({dialogDisplayed:!0}):this.setState({dialogDisplayed:!0,selectedIndex:n?n+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 n=this;setTimeout(function(){n.setState({selectedIndex:e,focused:!0,dialogDisplayed:!1}),setTimeout(n.triggerItemChange)})},positionDialogAndGetTop:function(e,t){var n=e.length-t;return t>5&&6>n?e.length<11?-2+(36*t*-1-10)+"px":(this.positionDialog(t),-215-36*(5-n)+"px"):t>5?(this.positionDialog(t),"-203px"):-1+(36*t*-1-10)+"px"},positionDialog:function(e){var t=this;setTimeout(function(){var n=o.findDOMNode(t).querySelector(".cp-select__menu");n&&(n.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}),l=setTimeout(function(){a=""},1e3)},getIndexFromString:function(e){var t=this;return e=e.toLowerCase(),r(this.props.options,function(n){return 0===t.getViewValue(n).toLowerCase().indexOf(e)})},getViewValue:function(e){return e.value||e},getDialog:function(e,t){var n=this;if(e){var s=function(){var e=n.state.selectedIndex,s=t.map(function(t,s){return o.createElement("li",{key:t.key,className:e===s?"+selected":"",onMouseDown:n.selectItem.bind(n,s)},o.createElement("a",null,t.value))});return setTimeout(function(){o.findDOMNode(n).querySelector(".cp-select__hidden-input").focus()},100),{v:o.createElement("div",null,o.createElement("ul",{className:"cp-select__menu cps-dropdown-menu",style:{top:n.positionDialogAndGetTop(t,e)}},s))}}();if("object"==typeof s)return s.v}},render:function(){var e="cp-select",t=this.props.options[this.state.selectedIndex];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.CanopySelect||(window.CanopySelect=c),e.exports=c},function(e,t){e.exports=React},function(e,t){e.exports=_},function(e,t,n){var s=n(4);"string"==typeof s&&(s=[[e.id,s,""]]);n(6)(s,{})},function(e,t,n){t=e.exports=n(5)(),t.push([e.id,".cp-select-outer{position:relative;height:32px;font-size:12px}.cp-select{border-radius:2px;box-shadow:0 1px 4px 0 rgba(0,0,0,.26);display:inline-block;padding:8px 14px;min-width:140px;color:#AFAFAF;background-color:#fff;cursor:pointer;width:100%;height:32px}.cps-has-error .cp-select{box-shadow:0 1px 4px 0 #FE996C}.cp-select.\\+disabled{cursor:not-allowed;background-color:#F9F9F9;opacity:1;border:1px dashed #CFCFCF}.cp-select.\\+focus{box-shadow:0 0 0 2px rgba(76,175,80,.3)}.cp-select__selected{width:calc(100% - 15px);vertical-align:middle;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.cp-select__icon{display:inline-block;border-color:#AFAFAF transparent;border-style:solid;border-width:6px 6px 0 6px;height:0;width:0;float:right;position:relative;top:6px}.cp-select-outer .cp-select__menu{display:block;max-height:400px;overflow:auto;width:100%;position:absolute;font-size:12px}.cp-select-outer .cp-select__menu li{height:36px!important}.cp-select-outer .cp-select__menu li.\\+selected>a{color:#333;text-decoration:none;background-color:#f7f7f7}.cp-select__hidden-input{opacity:0;position:absolute;left:0;top:0;width:0;height:0}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t];n[2]?e.push("@media "+n[2]+"{"+n[1]+"}"):e.push(n[1])}return e.join("")},e}},function(e,t,n){function s(e,t){for(var n=0;n<e.length;n++){var s=e[n],i=p[s.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](s.parts[o]);for(;o<s.parts.length;o++)i.parts.push(r(s.parts[o],t))}else{for(var a=[],o=0;o<s.parts.length;o++)a.push(r(s.parts[o],t));p[s.id]={id:s.id,refs:1,parts:a}}}}function i(e){for(var t=[],n={},s=0;s<e.length;s++){var i=e[s],o=i[0],r=i[1],a=i[2],l=i[3],c={css:r,media:a,sourceMap:l};n[o]?n[o].parts.push(c):t.push(n[o]={id:o,parts:[c]})}return t}function o(){var e=document.createElement("style"),t=h();return e.type="text/css",t.appendChild(e),e}function r(e,t){var n,s,i;if(t.singleton){var r=g++;n=f||(f=o()),s=l.bind(null,n,r,!1),i=l.bind(null,n,r,!0)}else n=o(),s=c.bind(null,n),i=function(){n.parentNode.removeChild(n)};return s(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;s(e=t)}else i()}}function a(e,t,n){var s=["/** >>"+t+" **/","/** "+t+"<< **/"],i=e.lastIndexOf(s[0]),o=n?s[0]+n+s[1]:"";if(e.lastIndexOf(s[0])>=0){var r=e.lastIndexOf(s[1])+s[1].length;return e.slice(0,i)+o+e.slice(r)}return e+o}function l(e,t,n,s){var i=n?"":s.css;if(e.styleSheet)e.styleSheet.cssText=a(e.styleSheet.cssText,t,i);else{var o=document.createTextNode(i),r=e.childNodes;r[t]&&e.removeChild(r[t]),r.length?e.insertBefore(o,r[t]):e.appendChild(o)}}function c(e,t){var n=t.css,s=t.media,i=t.sourceMap;if(i&&"function"==typeof btoa)try{n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(JSON.stringify(i))+" */",n='@import url("data:text/css;base64,'+btoa(n)+'")'}catch(o){}if(s&&e.setAttribute("media",s),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var p={},d=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},u=d(function(){return/msie 9\b/.test(window.navigator.userAgent.toLowerCase())}),h=d(function(){return document.head||document.getElementsByTagName("head")[0]}),f=null,g=0;e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=u());var n=i(e);return s(n,t),function(e){for(var o=[],r=0;r<n.length;r++){var a=n[r],l=p[a.id];l.refs--,o.push(l)}if(e){var c=i(e);s(c,t)}for(var r=0;r<o.length;r++){var l=o[r];if(0===l.refs){for(var d=0;d<l.parts.length;d++)l.parts[d]();delete p[l.id]}}}}}]);
!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,c=void 0,a=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=l(this.props.options,{key:this.props.selected})),{selectedIndex:t,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})},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){c+=String.fromCharCode(e);var t=this.getIndexFromString(c);t>-1&&this.setState({selectedIndex:t}),a=setTimeout(function(){c=""},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(){o.findDOMNode(s).querySelector(".cp-select__hidden-input").focus()},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.state.selectedIndex];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.CanopySelect||(window.CanopySelect=r),e.exports=r},function(e,t){e.exports=React},function(e,t){e.exports=_}]);

@@ -15,4 +15,2 @@ 'use strict';

require('./select.css');
var searchString = undefined;

@@ -19,0 +17,0 @@ var keyTimeout = undefined;

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

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

import React from 'react';
import {findIndex} from 'lodash';
import './select.css';

@@ -5,0 +4,0 @@ let searchString;

Sorry, the diff of this file is not supported yet

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