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

select2-react-component

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

select2-react-component - npm Package Compare versions

Comparing version 5.5.1 to 5.6.0

README.md

2

dist/select2-react-component.min.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t(e.Select2={},e.React,e.ReactDOM)}(this,function(e,s,r){"use strict";var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function d(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var i=[{l:"a",s:/[ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ]/gi},{l:"aa",s:/ꜳ/gi},{l:"ae",s:/[æǽǣ]/gi},{l:"ao",s:/ꜵ/gi},{l:"au",s:/ꜷ/gi},{l:"av",s:/[ꜹꜻ]/gi},{l:"ay",s:/ꜽ/gi},{l:"b",s:/[ⓑbḃḅḇƀƃɓ]/gi},{l:"c",s:/[ⓒcćĉċčçḉƈȼꜿↄ]/gi},{l:"d",s:/[ⓓdḋďḍḑḓḏđƌɖɗꝺ]/gi},{l:"dz",s:/[dzdž]/gi},{l:"e",s:/[ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ]/gi},{l:"f",s:/[ⓕfḟƒꝼ]/gi},{l:"g",s:/[ⓖgǵĝḡğġǧģǥɠꞡᵹꝿ]/gi},{l:"h",s:/[ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ]/gi},{l:"hv",s:/ƕ/gi},{l:"i",s:/[ⓘiìíîĩīĭİïḯỉǐȉȋịįḭɨı]/gi},{l:"j",s:/[ⓙjĵǰɉ]/gi},{l:"k",s:/[ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ]/gi},{l:"l",s:/[ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇꝆ]/gi},{l:"lj",s:/lj/gi},{l:"m",s:/[ⓜmḿṁṃɱɯ]/gi},{l:"n",s:/[ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ]/gi},{l:"nj",s:/nj/gi},{l:"o",s:/[ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔƟꝋꝍɵ]/gi},{l:"oi",s:/ƣ/gi},{l:"oe",s:/œ/gi},{l:"oo",s:/ꝏ/gi},{l:"ou",s:/ȣ/gi},{l:"p",s:/[ⓟpṕṗƥᵽꝑꝓꝕ]/gi},{l:"q",s:/[ⓠqɋꝗꝙ]/gi},{l:"r",s:/[ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ]/gi},{l:"s",s:/[ⓢsßẞśṥŝṡšṧṣṩșşȿꞩꞅẛ]/gi},{l:"t",s:/[ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ]/gi},{l:"tz",s:/ꜩ/gi},{l:"u",s:/[ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ]/gi},{l:"v",s:/[ⓥvṽṿʋꝟʌ]/gi},{l:"vy",s:/ꝡ/gi},{l:"w",s:/[ⓦwẁẃŵẇẅẘẉⱳ]/gi},{l:"x",s:/[ⓧxẋẍ]/gi},{l:"y",s:/[ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ]/gi},{l:"z",s:/[ⓩzźẑżžẓẕƶȥɀⱬꝣ]/gi}];function c(e,t){var r,n,o,l;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var a=s.value,u=a.options;if(u)try{for(var c=d(u),p=c.next();!p.done;p=c.next()){var h=p.value;if(h.value===t)return h}}catch(e){o={error:e}}finally{try{p&&!p.done&&(l=c.return)&&l.call(c)}finally{if(o)throw o.error}}else if(a.value===t)return a}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return null}function o(e,t,r){var n,o;if(r){var l=Array.isArray(t)?t:[],i=[];try{for(var s=d(l),a=s.next();!a.done;a=s.next()){var u=c(e,a.value);u&&i.push(u)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return i}return c(e,t)}function l(e){var t,r,n,o;try{for(var l=d(e),i=l.next();!i.done;i=l.next()){var s=i.value,a=s.options;if(a)try{for(var u=d(a),c=u.next();!c.done;c=u.next()){var p;if(!(p=c.value).disabled)return p.value}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}else if(!(p=s).disabled)return p.value}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}return null}function a(e,t){var r,n,o,l;if(v(t))return!0;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var a=s.value,u=a.options;if(u)try{for(var c=d(u),p=c.next();!p.done;p=c.next()){if(p.value.value===t)return!1}}catch(e){o={error:e}}finally{try{p&&!p.done&&(l=c.return)&&l.call(c)}finally{if(o)throw o.error}}else if(a.value===t)return!1}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0}function u(e,t){for(var r=v(t),n=e.length-1;0<=n;n--){var o=e[n],l=o.options;if(l)for(var i=l.length-1;0<=i;i--){var s=l[i];if(r&&!s.disabled)return s.value;r=s.value===t}else{s=o;if(r&&!s.disabled)return s.value;r=s.value===t}}return r?t:null}function p(e,t){var r,n,o,l,i=v(t);try{for(var s=d(e),a=s.next();!a.done;a=s.next()){var u=a.value,c=u.options;if(c)try{for(var p=d(c),h=p.next();!h.done;h=p.next()){var f=h.value;if(i){if(!f.disabled)return f.value}else i=f.value===t}}catch(e){o={error:e}}finally{try{h&&!h.done&&(l=p.return)&&l.call(p)}finally{if(o)throw o.error}}else{f=u;if(i){if(!f.disabled)return f.value}else i=f.value===t}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i?t:null}function v(e){return null==e}function h(e,t,r,n){if(v(e))return t.scrollTop=0;var o,l=function(e,t){var r,n,o=0;try{for(var l=d(e),i=l.next();!i.done;i=l.next()){var s=i.value,a=s.options;if(a){o++;var u=a.findIndex(function(e){return e.value===t});if(-1!==u)return o+u;o+=a.length}else{if(s.value===t)return o;o++}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return 0}(r,e);return 5<l-n?(n+=l-n-5,(o=t.querySelectorAll("li").item(l))&&(t.scrollTop=o.offsetTop-t.offsetHeight),n):0<n-l?(n-=n-l,(o=t.querySelectorAll("li").item(n-1))&&(t.scrollTop=o.offsetTop),n):null}function f(e,t,r){return!t||null!==y(e).match(new RegExp(function(e,t){e=y((r=e,r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"))),t&&"function"==typeof t&&(e=t(e));var r;return e}(t,r),"i"))}function y(e){var t,r;try{for(var n=d(i),o=n.next();!o.done;o=n.next()){var l=o.value;e=e.replace(l.s,l.l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return e}function m(e,t,r){var n,o;if(t){var l=[];try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var a=s.value,u=a.options;if(u){if(u.some(function(e){return f(e.label,t,r)})){var c=u.filter(function(e){return f(e.label,t,r)});l.push({label:a.label,options:c})}}else f(a.label,t,r)&&l.push(a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}return l}return e}function g(e,t){return e===t?"select2-results__option select2-results__option--highlighted":"select2-results__option"}function S(e){return e?"select2-container select2-container--default select2-container-dropdown select2-container--open":"select2-container select2-container--default select2-container-dropdown"}function x(e,t){return"select2 select2-container select2-container--default "+(e?"select2-container--disabled":"")+" "+(t?"select2-container--open":"")+" select2-container--below select2-container--focus"}function b(e){return"select2-selection select2-selection--"+(e?"multiple":"single")}function E(e,t){return"number"!=typeof t&&(t=6),function(e){var t,r,n=0;try{for(var o=d(e),l=o.next();!l.done;l=o.next()){var i=l.value.options;i?n+=i.length:n++}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n}(e)<t}function T(e){return e?"select2-search select2-search--dropdown select2-search--hide":"select2-search select2-search--dropdown"}function _(e,t,r){return r?e&&e.some(function(e){return e.value===t.value})?"true":"false":e&&t.value===e.value?"true":"false"}function O(e,t){for(var r=0;r<e.length;r++)if(e[r].value===t.value)return void e.splice(r,1)}var t=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.hoveringValue=null,t.option=null,t.isOpen=!1,t.innerSearchText="",t.lastScrollTopIndex=0,t.onChange=function(e){t.searchText=e.currentTarget.value,t.setState({searchText:t.searchText})},t}return function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),Object.defineProperty(t.prototype,"searchText",{get:function(){return this.innerSearchText},set:function(e){this.props.customSearchEnabled&&this.props.search&&this.props.search(e),this.innerSearchText=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropdownStyle",{get:function(){return S(this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"containerStyle",{get:function(){return x(this.props.disabled,this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectionStyle",{get:function(){return b(this.props.multiple)},enumerable:!0,configurable:!0}),t.prototype.componentWillMount=function(){var e=o(this.props.data,this.props.value,this.props.multiple);null!==e&&(this.option=e,this.setState({option:this.option})),Array.isArray(e)||(this.hoveringValue=this.props.value),this.setState({hoveringValue:this.hoveringValue}),this.isSearchboxHidden=!this.props.customSearchEnabled&&E(this.props.data,this.props.minCountForSearch),this.searchStyle=T(this.isSearchboxHidden)},t.prototype.componentDidMount=function(){var e=r.findDOMNode(this);this.searchInputElement=e.childNodes[1].childNodes[0].childNodes[0].childNodes[0],this.resultsElement=e.childNodes[1].childNodes[0].childNodes[1].childNodes[0]},t.prototype.render=function(){var t=this,e=this.renderResult(),r=this.renderSelection();return s.createElement("div",{className:this.containerStyle},s.createElement("div",{className:"selection",onClick:function(){return t.toggleOpenAndClose()}},s.createElement("div",{className:this.selectionStyle,role:"combobox"},r)),s.createElement("div",{className:this.dropdownStyle},s.createElement("div",{className:"select2-dropdown select2-dropdown--below"},s.createElement("div",{className:this.searchStyle},s.createElement("input",{value:this.searchText,onChange:this.onChange,onKeyDown:function(e){return t.keyDown(e)},onBlur:function(){return t.focusout()},className:"select2-search__field",type:"search",role:"textbox",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})),s.createElement("div",{className:"select2-results"},s.createElement("ul",{className:"select2-results__options",role:"tree",tabIndex:-1,onKeyDown:function(e){return t.keyDown(e)},onBlur:function(){return t.focusout()}},e)))))},t.prototype.renderSelection=function(){var r=this;if(this.props.multiple){var e=this.option.map(function(t,e){return s.createElement("li",{className:"select2-selection__choice",title:t.label,key:e},s.createElement("span",{onClick:function(e){return r.removeSelection(e,t)},className:"select2-selection__choice__remove",role:"presentation"},"×"),t.label)});return s.createElement("ul",{className:"select2-selection__rendered"},e)}var t=this.option,n=t?t.component?s.createElement(t.component,{option:t}):t.label:s.createElement("span",{className:"select2-selection__placeholder"},this.props.placeholder);return[s.createElement("span",{key:"label",className:"select2-selection__rendered",title:t?t.label:""},n),s.createElement("span",{key:"arrow",className:"select2-selection__arrow",role:"presentation"},s.createElement("b",{role:"presentation"}))]},t.prototype.renderResult=function(){var i=this;return this.getFilteredData(!1).map(function(e,t){var r=e.options;if(r){var n=r.map(function(e,t){var r=e.component?s.createElement(e.component,{option:e}):e.label;return s.createElement("li",{className:i.getOptionStyle(e.value),key:t,role:"treeitem","aria-selected":i.isSelected(e),"aria-disabled":i.isDisabled(e),onMouseEnter:function(){return i.mouseenter(e)},onClick:function(){return i.click(e)}},r)});return s.createElement("li",{className:"select2-results__option",role:"group",key:t},s.createElement("strong",{className:"select2-results__group"},e.label),s.createElement("ul",{className:"select2-results__options select2-results__options--nested"},n))}var o=e,l=o.component?s.createElement(o.component,{option:o}):o.label;return s.createElement("li",{className:i.getOptionStyle(o.value),key:t,role:"treeitem","aria-selected":i.isSelected(o),"aria-disabled":i.isDisabled(o),onMouseEnter:function(){return i.mouseenter(o)},onClick:function(){return i.click(o)}},l)})},t.prototype.getFilteredData=function(e){var t=this.props.customSearchEnabled?this.props.data:m(this.props.data,this.searchText);if(a(t,this.hoveringValue)&&(this.hoveringValue=l(t),e&&this.setState({hoveringValue:this.hoveringValue}),this.resultsElement)){var r=h(this.hoveringValue,this.resultsElement,t,this.lastScrollTopIndex);null!==r&&(this.lastScrollTopIndex=r,e&&this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}return t},t.prototype.getOptionStyle=function(e){return g(e,this.hoveringValue)},t.prototype.mouseenter=function(e){e.disabled||(this.hoveringValue=e.value,this.setState({hoveringValue:this.hoveringValue}))},t.prototype.click=function(e){e.disabled||this.select(e),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},t.prototype.toggleOpenAndClose=function(){var t=this;this.props.disabled||(this.isOpen=!this.isOpen,this.setState({isOpen:this.isOpen}),this.isOpen&&(this.innerSearchText="",this.setState({searchText:this.searchText},function(){if(t.focusSearchboxOrResultsElement(),t.resultsElement){var e=h(t.hoveringValue,t.resultsElement,t.props.data,t.lastScrollTopIndex);null!==e&&(t.lastScrollTopIndex=e)}}),this.props.open&&this.props.open()),this.focusoutTimer&&clearTimeout(this.focusoutTimer))},t.prototype.focusout=function(){var e=this;this.focusoutTimer=setTimeout(function(){e.isOpen=!1,e.setState({isOpen:e.isOpen}),e.focusoutTimer=void 0},200)},t.prototype.moveUp=function(){if(this.hoveringValue=u(this.getFilteredData(!0),this.hoveringValue),this.setState({hoveringValue:this.hoveringValue}),this.resultsElement){var e=h(this.hoveringValue,this.resultsElement,this.getFilteredData(!0),this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e,this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}},t.prototype.moveDown=function(){if(this.hoveringValue=p(this.getFilteredData(!0),this.hoveringValue),this.setState({hoveringValue:this.hoveringValue}),this.resultsElement){var e=h(this.hoveringValue,this.resultsElement,this.getFilteredData(!0),this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e,this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}},t.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},t.prototype.select=function(t){if(null!==t)if(this.props.multiple){var e=this.option,r=e.findIndex(function(e){return e.value===t.value});-1===r?e.push(t):e.splice(r,1),this.setState({option:this.option})}else this.option=t,this.isOpen=!1,this.setState({option:this.option,isOpen:this.isOpen});this.props.update&&this.props.update(this.props.multiple?this.option.map(function(e){return e.value}):this.option.value)},t.prototype.keyDown=function(e){40===e.keyCode?(this.moveDown(),e.preventDefault()):38===e.keyCode?(this.moveUp(),e.preventDefault()):13===e.keyCode&&(this.selectByEnter(),e.preventDefault())},t.prototype.isSelected=function(e){return _(this.option,e,this.props.multiple)},t.prototype.isDisabled=function(e){return e.disabled?"true":"false"},t.prototype.focusSearchboxOrResultsElement=function(){this.isSearchboxHidden?this.resultsElement&&this.resultsElement.focus():this.searchInputElement&&this.searchInputElement.focus()},t.prototype.removeSelection=function(e,t){var r=this;O(this.option,t),this.props.update&&this.props.update(this.option.map(function(e){return e.value})),e.preventDefault(),e.stopPropagation(),this.isOpen&&this.setState({option:this.option},function(){r.focusSearchboxOrResultsElement()}),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},t}(s.PureComponent);e.Select2=t,e.timeout=200,e.getOptionByValue=c,e.getOptionsByValue=o,e.getFirstAvailableOption=l,e.valueIsNotInFilteredData=a,e.getPreviousOption=u,e.getNextOption=p,e.getLastScrollTopIndex=h,e.getFilteredData=m,e.getOptionStyle=g,e.getDropdownStyle=S,e.getContainerStyle=x,e.getSelectionStyle=b,e.isSearchboxHiddex=E,e.getSearchStyle=T,e.isSelected=_,e.removeSelection=O,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e=e||self).Select2={},e.React,e.ReactDOM)}(this,function(e,s,t){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function d(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var i=[{l:"a",s:/[ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ]/gi},{l:"aa",s:/ꜳ/gi},{l:"ae",s:/[æǽǣ]/gi},{l:"ao",s:/ꜵ/gi},{l:"au",s:/ꜷ/gi},{l:"av",s:/[ꜹꜻ]/gi},{l:"ay",s:/ꜽ/gi},{l:"b",s:/[ⓑbḃḅḇƀƃɓ]/gi},{l:"c",s:/[ⓒcćĉċčçḉƈȼꜿↄ]/gi},{l:"d",s:/[ⓓdḋďḍḑḓḏđƌɖɗꝺ]/gi},{l:"dz",s:/[dzdž]/gi},{l:"e",s:/[ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ]/gi},{l:"f",s:/[ⓕfḟƒꝼ]/gi},{l:"g",s:/[ⓖgǵĝḡğġǧģǥɠꞡᵹꝿ]/gi},{l:"h",s:/[ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ]/gi},{l:"hv",s:/ƕ/gi},{l:"i",s:/[ⓘiìíîĩīĭİïḯỉǐȉȋịįḭɨı]/gi},{l:"j",s:/[ⓙjĵǰɉ]/gi},{l:"k",s:/[ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ]/gi},{l:"l",s:/[ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇꝆ]/gi},{l:"lj",s:/lj/gi},{l:"m",s:/[ⓜmḿṁṃɱɯ]/gi},{l:"n",s:/[ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ]/gi},{l:"nj",s:/nj/gi},{l:"o",s:/[ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔƟꝋꝍɵ]/gi},{l:"oi",s:/ƣ/gi},{l:"oe",s:/œ/gi},{l:"oo",s:/ꝏ/gi},{l:"ou",s:/ȣ/gi},{l:"p",s:/[ⓟpṕṗƥᵽꝑꝓꝕ]/gi},{l:"q",s:/[ⓠqɋꝗꝙ]/gi},{l:"r",s:/[ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ]/gi},{l:"s",s:/[ⓢsßẞśṥŝṡšṧṣṩșşȿꞩꞅẛ]/gi},{l:"t",s:/[ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ]/gi},{l:"tz",s:/ꜩ/gi},{l:"u",s:/[ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ]/gi},{l:"v",s:/[ⓥvṽṿʋꝟʌ]/gi},{l:"vy",s:/ꝡ/gi},{l:"w",s:/[ⓦwẁẃŵẇẅẘẉⱳ]/gi},{l:"x",s:/[ⓧxẋẍ]/gi},{l:"y",s:/[ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ]/gi},{l:"z",s:/[ⓩzźẑżžẓẕƶȥɀⱬꝣ]/gi}];function c(e,t){var r,n,o,l;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var a=s.value,u=a.options;if(u)try{for(var c=d(u),p=c.next();!p.done;p=c.next()){var h=p.value;if(h.value===t)return h}}catch(e){o={error:e}}finally{try{p&&!p.done&&(l=c.return)&&l.call(c)}finally{if(o)throw o.error}}else if(a.value===t)return a}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return null}function n(e,t,r){var n,o;if(r){var l=Array.isArray(t)?t:[],i=[];try{for(var s=d(l),a=s.next();!a.done;a=s.next()){var u=c(e,a.value);u&&i.push(u)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return i}return c(e,t)}function o(e){var t,r,n,o;try{for(var l=d(e),i=l.next();!i.done;i=l.next()){var s=i.value,a=s.options;if(a)try{for(var u=d(a),c=u.next();!c.done;c=u.next()){var p;if(!(p=c.value).disabled)return p.value}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}else if(!(p=s).disabled)return p.value}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}return null}function l(e,t){var r,n,o,l;if(v(t))return!0;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var a=s.value,u=a.options;if(u)try{for(var c=d(u),p=c.next();!p.done;p=c.next()){if(p.value.value===t)return!1}}catch(e){o={error:e}}finally{try{p&&!p.done&&(l=c.return)&&l.call(c)}finally{if(o)throw o.error}}else if(a.value===t)return!1}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0}function a(e,t){for(var r=v(t),n=e.length-1;0<=n;n--){var o=e[n],l=o.options;if(l)for(var i=l.length-1;0<=i;i--){var s=l[i];if(r&&!s.disabled)return s.value;r=s.value===t}else{s=o;if(r&&!s.disabled)return s.value;r=s.value===t}}return r?t:null}function u(e,t){var r,n,o,l,i=v(t);try{for(var s=d(e),a=s.next();!a.done;a=s.next()){var u=a.value,c=u.options;if(c)try{for(var p=d(c),h=p.next();!h.done;h=p.next()){var f=h.value;if(i){if(!f.disabled)return f.value}else i=f.value===t}}catch(e){o={error:e}}finally{try{h&&!h.done&&(l=p.return)&&l.call(p)}finally{if(o)throw o.error}}else{f=u;if(i){if(!f.disabled)return f.value}else i=f.value===t}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i?t:null}function v(e){return null==e}function p(e,t,r,n){if(v(e))return t.scrollTop=0;var o,l=function(e,t){var r,n,o=0;try{for(var l=d(e),i=l.next();!i.done;i=l.next()){var s=i.value,a=s.options;if(a){o++;var u=a.findIndex(function(e){return e.value===t});if(-1!==u)return o+u;o+=a.length}else{if(s.value===t)return o;o++}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return 0}(r,e);return 5<l-n?(n+=l-n-5,(o=t.querySelectorAll("li").item(l))&&(t.scrollTop=o.offsetTop-t.offsetHeight),n):0<n-l?(n-=n-l,(o=t.querySelectorAll("li").item(n-1))&&(t.scrollTop=o.offsetTop),n):null}function h(e,t,r){return!t||null!==f(e).match(new RegExp(function(e,t){e=f(function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(e)),t&&"function"==typeof t&&(e=t(e));return e}(t,r),"i"))}function f(e){var t,r;try{for(var n=d(i),o=n.next();!o.done;o=n.next()){var l=o.value;e=e.replace(l.s,l.l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return e}function y(e,t,r){var n,o;if(t){var l=[];try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var a=s.value,u=a.options;if(u){if(u.some(function(e){return h(e.label,t,r)})){var c=u.filter(function(e){return h(e.label,t,r)});l.push({label:a.label,options:c})}}else h(a.label,t,r)&&l.push(a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}return l}return e}function m(e,t){return e===t?"select2-results__option select2-results__option--highlighted":"select2-results__option"}function g(e){return e?"select2-container select2-container--default select2-container-dropdown select2-container--open":"select2-container select2-container--default select2-container-dropdown"}function S(e,t){return void 0===e&&(e=void 0),"select2 select2-container select2-container--default "+(e?"select2-container--disabled":"")+" "+(t?"select2-container--open":"")+" select2-container--below select2-container--focus"}function x(e){return void 0===e&&(e=void 0),"select2-selection select2-selection--"+(e?"multiple":"single")}function b(e,t){return"number"!=typeof t&&(t=6),function(e){var t,r,n=0;try{for(var o=d(e),l=o.next();!l.done;l=o.next()){var i=l.value.options;i?n+=i.length:n++}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n}(e)<t}function E(e){return e?"select2-search select2-search--dropdown select2-search--hide":"select2-search select2-search--dropdown"}function T(e,t,r){return r?e&&e.some(function(e){return e.value===t.value})?"true":"false":e&&t.value===e.value?"true":"false"}function _(e,t){for(var r=0;r<e.length;r++)if(e[r].value===t.value)return void e.splice(r,1)}var O,w,N,V=(N=s.PureComponent,r(O=I,w=N),void(O.prototype=null===w?Object.create(w):(D.prototype=w.prototype,new D)),Object.defineProperty(I.prototype,"searchText",{get:function(){return this.innerSearchText},set:function(e){this.props.customSearchEnabled&&this.props.search&&this.props.search(e),this.innerSearchText=e},enumerable:!0,configurable:!0}),Object.defineProperty(I.prototype,"dropdownStyle",{get:function(){return g(this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(I.prototype,"containerStyle",{get:function(){return S(this.props.disabled,this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(I.prototype,"selectionStyle",{get:function(){return x(this.props.multiple)},enumerable:!0,configurable:!0}),I.prototype.componentWillMount=function(){var e=n(this.props.data,this.props.value,this.props.multiple);null!==e&&(this.option=e,this.setState({option:this.option})),Array.isArray(e)||(this.hoveringValue=this.props.value),this.setState({hoveringValue:this.hoveringValue}),this.isSearchboxHidden=!this.props.customSearchEnabled&&b(this.props.data,this.props.minCountForSearch),this.searchStyle=E(this.isSearchboxHidden)},I.prototype.componentDidMount=function(){var e=t.findDOMNode(this);this.searchInputElement=e.childNodes[1].childNodes[0].childNodes[0].childNodes[0],this.resultsElement=e.childNodes[1].childNodes[0].childNodes[1].childNodes[0]},I.prototype.render=function(){var t=this,e=this.renderResult(),r=this.renderSelection();return s.createElement("div",{className:this.containerStyle},s.createElement("div",{className:"selection",onClick:function(){return t.toggleOpenAndClose()}},s.createElement("div",{className:this.selectionStyle,role:"combobox"},r)),s.createElement("div",{className:this.dropdownStyle},s.createElement("div",{className:"select2-dropdown select2-dropdown--below"},s.createElement("div",{className:this.searchStyle},s.createElement("input",{value:this.searchText,onChange:this.onChange,onKeyDown:function(e){return t.keyDown(e)},onBlur:function(){return t.focusout()},className:"select2-search__field",type:"search",role:"textbox",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})),s.createElement("div",{className:"select2-results"},s.createElement("ul",{className:"select2-results__options",role:"tree",tabIndex:-1,onKeyDown:function(e){return t.keyDown(e)},onBlur:function(){return t.focusout()}},e)))))},I.prototype.renderSelection=function(){var r=this;if(this.props.multiple){var e=this.option.map(function(t,e){return s.createElement("li",{className:"select2-selection__choice",title:t.label,key:e},s.createElement("span",{onClick:function(e){return r.removeSelection(e,t)},className:"select2-selection__choice__remove",role:"presentation"},"×"),t.label)});return s.createElement("ul",{className:"select2-selection__rendered"},e)}var t=this.option,n=t?t.component?s.createElement(t.component,{option:t}):t.label:s.createElement("span",{className:"select2-selection__placeholder"},this.props.placeholder);return[s.createElement("span",{key:"label",className:"select2-selection__rendered",title:t?t.label:""},n),s.createElement("span",{key:"arrow",className:"select2-selection__arrow",role:"presentation"},s.createElement("b",{role:"presentation"}))]},I.prototype.renderResult=function(){var i=this;return this.getFilteredData(!1).map(function(e,t){var r=e.options;if(r){var n=r.map(function(e,t){var r=e.component?s.createElement(e.component,{option:e}):e.label;return s.createElement("li",{className:i.getOptionStyle(e.value),key:t,role:"treeitem","aria-selected":i.isSelected(e),"aria-disabled":i.isDisabled(e),onMouseEnter:function(){return i.mouseenter(e)},onClick:function(){return i.click(e)}},r)});return s.createElement("li",{className:"select2-results__option",role:"group",key:t},s.createElement("strong",{className:"select2-results__group"},e.label),s.createElement("ul",{className:"select2-results__options select2-results__options--nested"},n))}var o=e,l=o.component?s.createElement(o.component,{option:o}):o.label;return s.createElement("li",{className:i.getOptionStyle(o.value),key:t,role:"treeitem","aria-selected":i.isSelected(o),"aria-disabled":i.isDisabled(o),onMouseEnter:function(){return i.mouseenter(o)},onClick:function(){return i.click(o)}},l)})},I.prototype.getFilteredData=function(e){var t=this.props.customSearchEnabled?this.props.data:y(this.props.data,this.searchText);if(l(t,this.hoveringValue)&&(this.hoveringValue=o(t),e&&this.setState({hoveringValue:this.hoveringValue}),this.resultsElement)){var r=p(this.hoveringValue,this.resultsElement,t,this.lastScrollTopIndex);null!==r&&(this.lastScrollTopIndex=r,e&&this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}return t},I.prototype.getOptionStyle=function(e){return m(e,this.hoveringValue)},I.prototype.mouseenter=function(e){e.disabled||(this.hoveringValue=e.value,this.setState({hoveringValue:this.hoveringValue}))},I.prototype.click=function(e){e.disabled||this.select(e),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},I.prototype.toggleOpenAndClose=function(){var t=this;this.props.disabled||(this.isOpen=!this.isOpen,this.setState({isOpen:this.isOpen}),this.isOpen&&(this.innerSearchText="",this.setState({searchText:this.searchText},function(){if(t.focusSearchboxOrResultsElement(),t.resultsElement){var e=p(t.hoveringValue,t.resultsElement,t.props.data,t.lastScrollTopIndex);null!==e&&(t.lastScrollTopIndex=e)}}),this.props.open&&this.props.open()),this.focusoutTimer&&clearTimeout(this.focusoutTimer))},I.prototype.focusout=function(){var e=this;this.focusoutTimer=setTimeout(function(){e.isOpen=!1,e.setState({isOpen:e.isOpen}),e.focusoutTimer=void 0},200)},I.prototype.moveUp=function(){if(this.hoveringValue=a(this.getFilteredData(!0),this.hoveringValue),this.setState({hoveringValue:this.hoveringValue}),this.resultsElement){var e=p(this.hoveringValue,this.resultsElement,this.getFilteredData(!0),this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e,this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}},I.prototype.moveDown=function(){if(this.hoveringValue=u(this.getFilteredData(!0),this.hoveringValue),this.setState({hoveringValue:this.hoveringValue}),this.resultsElement){var e=p(this.hoveringValue,this.resultsElement,this.getFilteredData(!0),this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e,this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}},I.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},I.prototype.select=function(t){if(null!==t)if(this.props.multiple){var e=this.option,r=e.findIndex(function(e){return e.value===t.value});-1===r?e.push(t):e.splice(r,1),this.setState({option:this.option})}else this.option=t,this.isOpen=!1,this.setState({option:this.option,isOpen:this.isOpen});this.props.update&&this.props.update(this.props.multiple?this.option.map(function(e){return e.value}):this.option.value)},I.prototype.keyDown=function(e){40===e.keyCode?(this.moveDown(),e.preventDefault()):38===e.keyCode?(this.moveUp(),e.preventDefault()):13===e.keyCode&&(this.selectByEnter(),e.preventDefault())},I.prototype.isSelected=function(e){return T(this.option,e,this.props.multiple)},I.prototype.isDisabled=function(e){return e.disabled?"true":"false"},I.prototype.focusSearchboxOrResultsElement=function(){this.isSearchboxHidden?this.resultsElement&&this.resultsElement.focus():this.searchInputElement&&this.searchInputElement.focus()},I.prototype.removeSelection=function(e,t){var r=this;_(this.option,t),this.props.update&&this.props.update(this.option.map(function(e){return e.value})),e.preventDefault(),e.stopPropagation(),this.isOpen&&this.setState({option:this.option},function(){r.focusSearchboxOrResultsElement()}),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},I);function D(){this.constructor=O}function I(){var t=null!==N&&N.apply(this,arguments)||this;return t.hoveringValue=null,t.option=null,t.isOpen=!1,t.innerSearchText="",t.lastScrollTopIndex=0,t.onChange=function(e){t.searchText=e.currentTarget.value,t.setState({searchText:t.searchText})},t}e.Select2=V,e.getContainerStyle=S,e.getDropdownStyle=g,e.getFilteredData=y,e.getFirstAvailableOption=o,e.getLastScrollTopIndex=p,e.getNextOption=u,e.getOptionByValue=c,e.getOptionStyle=m,e.getOptionsByValue=n,e.getPreviousOption=a,e.getSearchStyle=E,e.getSelectionStyle=x,e.isSearchboxHiddex=b,e.isSelected=T,e.removeSelection=_,e.timeout=200,e.valueIsNotInFilteredData=l,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "select2-react-component",
"version": "5.5.1",
"version": "5.6.0",
"description": "A reactjs select component.",

@@ -27,9 +27,9 @@ "main": "dist/index.js",

"react-dom": "16",
"select2-component": "^5.5.1"
"select2-component": "^5.6.0"
},
"devDependencies": {
"@types/react": "16.4.18",
"@types/react-dom": "16.0.9"
"@types/react": "16.8.19",
"@types/react-dom": "16.8.4"
},
"gitHead": "1ad4e802ca62ba9a8f466c3db58f3ef3e3be35dc"
"gitHead": "a29960cb6fca13ec077b3bd784dada8985d782b7"
}
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