select2-react-component
Advanced tools
Comparing version 5.8.2 to 5.8.3
@@ -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=e||self).Select2={},e.React,e.ReactDOM)}(this,function(e,l,t){"use strict";var o=function(e,t){return(o=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 r(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}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 s=[{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,o,n,i;try{for(var s=d(e),l=s.next();!l.done;l=s.next()){var a=l.value,u=a.options;if(u)try{for(var c=(n=void 0,d(u)),p=c.next();!p.done;p=c.next()){var h=p.value;if(h.value===t)return h}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}else if(a.value===t)return a}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}return null}function n(e,t,r){var o,n;if(r){var i=Array.isArray(t)?t:[],s=[];try{for(var l=d(i),a=l.next();!a.done;a=l.next()){var u=c(e,a.value);u&&s.push(u)}}catch(e){o={error:e}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}finally{if(o)throw o.error}}return s}return c(e,t)}function i(e){var t,r,o,n;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var l=s.value,a=l.options;if(a)try{for(var u=(o=void 0,d(a)),c=u.next();!c.done;c=u.next()){var p;if(!(p=c.value).disabled)return p.value}}catch(e){o={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(o)throw o.error}}else if(!(p=l).disabled)return p.value}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return null}function a(e,t){var r,o,n,i;if(v(t))return!0;try{for(var s=d(e),l=s.next();!l.done;l=s.next()){var a=l.value,u=a.options;if(u)try{for(var c=(n=void 0,d(u)),p=c.next();!p.done;p=c.next()){if(p.value.value===t)return!1}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}else if(a.value===t)return!1}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}return!0}function u(e,t){for(var r=v(t),o=e.length-1;0<=o;o--){var n=e[o],i=n.options;if(i)for(var s=i.length-1;0<=s;s--){var l=i[s];if(r&&!l.disabled)return l.value;r=l.value===t}else{l=n;if(r&&!l.disabled)return l.value;r=l.value===t}}return r?t:null}function p(e,t){var r,o,n,i,s=v(t);try{for(var l=d(e),a=l.next();!a.done;a=l.next()){var u=a.value,c=u.options;if(c)try{for(var p=(n=void 0,d(c)),h=p.next();!h.done;h=p.next()){var f=h.value;if(s){if(!f.disabled)return f.value}else s=f.value===t}}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}else{f=u;if(s){if(!f.disabled)return f.value}else s=f.value===t}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}return s?t:null}function v(e){return null==e}function h(e,t,r,o){if(v(e))return t.scrollTop=0;var n,i=function(e,t){var r,o,n=0;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var l=s.value,a=l.options;if(a){n++;var u=a.findIndex(function(e){return e.value===t});if(-1!==u)return n+u;n+=a.length}else{if(l.value===t)return n;n++}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return 0}(r,e);return 5<i-o?(o+=i-o-5,(n=t.querySelectorAll("li").item(i))&&(t.scrollTop=n.offsetTop-t.offsetHeight),o):0<o-i?(o-=o-i,(n=t.querySelectorAll("li").item(o-1))&&(t.scrollTop=n.offsetTop),o):null}function f(e,t,r){return!t||null!==y(e).match(new RegExp(function(e,t){e=y(function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(e)),t&&"function"==typeof t&&(e=t(e));return e}(t,r),"i"))}function y(e){var t,r;try{for(var o=d(s),n=o.next();!n.done;n=o.next()){var i=n.value;e=e.replace(i.s,i.l)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return e}function m(e,t,r){var o,n;if(t){var i=[];try{for(var s=d(e),l=s.next();!l.done;l=s.next()){var a=l.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)});i.push({label:a.label,options:c})}}else f(a.label,t,r)&&i.push(a)}}catch(e){o={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}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 b(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 E(e,t){return"number"!=typeof t&&(t=6),function(e){var t,r,o=0;try{for(var n=d(e),i=n.next();!i.done;i=n.next()){var s=i.value.options;s?o+=s.length:o++}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return o}(e)<t}function T(e){return e?"select2-search select2-search--dropdown select2-search--hide":"select2-search select2-search--dropdown"}function O(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 k(e,t){for(var r=0;r<e.length;r++)if(e[r].value===t.value)return void e.splice(r,1)}var _,N=(r(V,_=l.PureComponent),Object.defineProperty(V.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(V.prototype,"dropdownStyle",{get:function(){return S(this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"containerStyle",{get:function(){return b(this.props.disabled,this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"selectionStyle",{get:function(){return x(this.props.multiple)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"isSearchboxHidden",{get:function(){return!this.props.customSearchEnabled&&E(this.props.data,this.props.minCountForSearch)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"searchStyle",{get:function(){return T(this.isSearchboxHidden)},enumerable:!0,configurable:!0}),V.prototype.UNSAFE_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})},V.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]},V.prototype.render=function(){var t=this,e=this.renderResult(),r=this.renderSelection();return l.createElement("div",{className:this.containerStyle},l.createElement("div",{className:"selection",onClick:function(){return t.toggleOpenAndClose()}},l.createElement("div",{className:this.selectionStyle,role:"combobox"},r)),l.createElement("div",{className:this.dropdownStyle},l.createElement("div",{className:"select2-dropdown select2-dropdown--below"},l.createElement("div",{className:this.searchStyle},l.createElement("input",{value:this.searchText,onChange:this.onChange,onKeyDown:function(e){return t.keyDown(e)},onKeyUp:function(e){return t.keyUp(e)},onKeyPress:function(e){return t.keyPress(e)},onBlur:function(){return t.focusout()},className:"select2-search__field",type:"search",role:"textbox",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})),l.createElement("div",{className:"select2-results"},l.createElement("ul",{className:"select2-results__options",role:"tree",tabIndex:-1,onKeyDown:function(e){return t.keyDown(e)},onFocus:function(){return t.cancelFocusoutTimer()},onBlur:function(){return t.focusout()}},e)))))},V.prototype.renderSelection=function(){var r=this;if(this.props.multiple){var e=this.option.map(function(t,e){return l.createElement("li",{className:"select2-selection__choice",title:t.label,key:e},l.createElement("span",{onClick:function(e){return r.removeSelection(e,t)},className:"select2-selection__choice__remove",role:"presentation"},"×"),t.label)});return l.createElement("ul",{className:"select2-selection__rendered"},e)}var t=this.option,o=t?t.component?l.createElement(t.component,{option:t}):t.label:l.createElement("span",{className:"select2-selection__placeholder"},this.props.placeholder);return[l.createElement("span",{key:"label",className:"select2-selection__rendered",title:t?t.label:""},o),l.createElement("span",{key:"arrow",className:"select2-selection__arrow",role:"presentation"},l.createElement("b",{role:"presentation"}))]},V.prototype.renderResult=function(){var s=this;return this.getFilteredData(!1).map(function(e,t){var r=e.options;if(r){var o=r.map(function(e,t){var r=e.component?l.createElement(e.component,{option:e}):e.label;return l.createElement("li",{className:s.getOptionStyle(e.value),key:t,role:"treeitem","aria-selected":s.isSelected(e),"aria-disabled":s.isDisabled(e),onMouseEnter:function(){return s.mouseenter(e)},onClick:function(){return s.click(e)}},r)});return l.createElement("li",{className:"select2-results__option",role:"group",key:t},l.createElement("strong",{className:"select2-results__group"},e.label),l.createElement("ul",{className:"select2-results__options select2-results__options--nested"},o))}var n=e,i=n.component?l.createElement(n.component,{option:n}):n.label;return l.createElement("li",{className:s.getOptionStyle(n.value),key:t,role:"treeitem","aria-selected":s.isSelected(n),"aria-disabled":s.isDisabled(n),onMouseEnter:function(){return s.mouseenter(n)},onClick:function(){return s.click(n)}},i)})},V.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=i(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},V.prototype.getOptionStyle=function(e){return g(e,this.hoveringValue)},V.prototype.mouseenter=function(e){e.disabled||(this.hoveringValue=e.value,this.setState({hoveringValue:this.hoveringValue}))},V.prototype.click=function(e){e.disabled||this.select(e),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},V.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))},V.prototype.focusout=function(){var e=this;this.focusoutTimer=setTimeout(function(){e.isOpen=!1,e.setState({isOpen:e.isOpen}),e.focusoutTimer=void 0},200)},V.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}))}},V.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}))}},V.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},V.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)},V.prototype.keyDown=function(e){this.props.keydown&&this.props.keydown(e),40===e.keyCode?(this.moveDown(),e.preventDefault()):38===e.keyCode?(this.moveUp(),e.preventDefault()):13===e.keyCode&&(this.selectByEnter(),e.preventDefault())},V.prototype.keyUp=function(e){this.props.keyup&&this.props.keyup(e)},V.prototype.keyPress=function(e){this.props.keypress&&this.props.keypress(e)},V.prototype.isSelected=function(e){return O(this.option,e,this.props.multiple)},V.prototype.isDisabled=function(e){return e.disabled?"true":"false"},V.prototype.focusSearchboxOrResultsElement=function(){this.isSearchboxHidden?this.resultsElement&&this.resultsElement.focus():this.searchInputElement&&this.searchInputElement.focus()},V.prototype.removeSelection=function(e,t){var r=this;k(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)},V.prototype.cancelFocusoutTimer=function(){this.focusoutTimer&&clearTimeout(this.focusoutTimer)},V);function V(){var t=null!==_&&_.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}var w,D=(r(I,w=l.PureComponent),Object.defineProperty(I.prototype,"dropdownStyle",{get:function(){return S(this.isOpen&&0<this.props.data.length)},enumerable:!0,configurable:!0}),Object.defineProperty(I.prototype,"containerStyle",{get:function(){return b(!1,this.isOpen&&0<this.props.data.length)},enumerable:!0,configurable:!0}),I.prototype.UNSAFE_componentWillMount=function(){var e=n(this.props.data,this.props.value,!1);null!==e&&(this.option=e,this.setState({option:this.option})),Array.isArray(e)||(this.hoveringValue=this.props.value),this.setState({hoveringValue:this.hoveringValue})},I.prototype.componentDidMount=function(){var e=t.findDOMNode(this);this.searchInputElement=e.childNodes[0].childNodes[0].childNodes[0].childNodes[0],this.resultsElement=e.childNodes[1].childNodes[0].childNodes[0].childNodes[0]},I.prototype.render=function(){var t=this,e=this.renderResult();return l.createElement("div",{className:this.containerStyle},l.createElement("div",{className:"selection"},l.createElement("div",{className:"select2-search select2-search--dropdown"},l.createElement("input",{value:this.props.value,onChange:this.onChange,onKeyDown:function(e){return t.keyDown(e)},onKeyUp:function(e){return t.keyUp(e)},onKeyPress:function(e){return t.keyPress(e)},onBlur:function(){return t.focusout()},onClick:function(){return t.toggleOpenAndClose()},className:"select2-search__field",type:"search",role:"textbox",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}))),l.createElement("div",{className:this.dropdownStyle},l.createElement("div",{className:"select2-dropdown"},l.createElement("div",{className:"select2-results"},l.createElement("ul",{className:"select2-results__options",role:"tree",tabIndex:-1,onKeyDown:function(e){return t.keyDown(e)}},e)))))},I.prototype.renderResult=function(){var s=this;return this.getFilteredData(!1).map(function(e,t){var r=e.options;if(r){var o=r.map(function(e,t){var r=e.component?l.createElement(e.component,{option:e}):e.label;return l.createElement("li",{className:s.getOptionStyle(e.value),key:t,role:"treeitem","aria-selected":s.isSelected(e),"aria-disabled":s.isDisabled(e),onMouseEnter:function(){return s.mouseenter(e)},onClick:function(){return s.click(e)}},r)});return l.createElement("li",{className:"select2-results__option",role:"group",key:t},l.createElement("strong",{className:"select2-results__group"},e.label),l.createElement("ul",{className:"select2-results__options select2-results__options--nested"},o))}var n=e,i=n.component?l.createElement(n.component,{option:n}):n.label;return l.createElement("li",{className:s.getOptionStyle(n.value),key:t,role:"treeitem","aria-selected":s.isSelected(n),"aria-disabled":s.isDisabled(n),onMouseEnter:function(){return s.mouseenter(n)},onClick:function(){return s.click(n)}},i)})},I.prototype.getFilteredData=function(e){var t=this.props.data;if(a(t,this.hoveringValue)&&(this.hoveringValue=i(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},I.prototype.getOptionStyle=function(e){return g(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(){if(this.isOpen=!this.isOpen,this.setState({isOpen:this.isOpen}),this.isOpen&&(this.focusSearchboxOrResultsElement(),this.resultsElement)){var e=h(this.hoveringValue,this.resultsElement,this.props.data,this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e)}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=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}))}},I.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}))}},I.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},I.prototype.select=function(e){null!==e&&(this.option=e,this.isOpen=!1,this.setState({option:this.option,isOpen:this.isOpen})),this.props.select&&this.props.select(this.option.value),this.props.update&&this.props.update(this.option.value)},I.prototype.keyDown=function(e){this.props.keydown&&this.props.keydown(e),40===e.keyCode?(this.moveDown(),e.preventDefault()):38===e.keyCode?(this.moveUp(),e.preventDefault()):13===e.keyCode&&(this.selectByEnter(),e.preventDefault())},I.prototype.keyUp=function(e){this.props.keyup&&this.props.keyup(e)},I.prototype.keyPress=function(e){this.props.keypress&&this.props.keypress(e)},I.prototype.isSelected=function(e){return O(this.option,e,!1)},I.prototype.isDisabled=function(e){return e.disabled?"true":"false"},I.prototype.focusSearchboxOrResultsElement=function(){this.searchInputElement&&this.searchInputElement.focus()},I);function I(){var t=null!==w&&w.apply(this,arguments)||this;return t.hoveringValue=null,t.option=null,t.isOpen=!1,t.lastScrollTopIndex=0,t.onChange=function(e){t.props.search&&t.props.search(e.currentTarget.value),t.props.update&&t.props.update(e.currentTarget.value)},t}e.AutoComplete=D,e.Select2=N,e.getContainerStyle=b,e.getDropdownStyle=S,e.getFilteredData=m,e.getFirstAvailableOption=i,e.getLastScrollTopIndex=h,e.getNextOption=p,e.getOptionByValue=c,e.getOptionStyle=g,e.getOptionsByValue=n,e.getPreviousOption=u,e.getSearchStyle=T,e.getSelectionStyle=x,e.isSearchboxHiddex=E,e.isSelected=O,e.removeSelection=k,e.timeout=200,e.valueIsNotInFilteredData=a,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,l,t){"use strict";var o=function(e,t){return(o=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 r(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}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 s=[{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,o,n,i;try{for(var s=d(e),l=s.next();!l.done;l=s.next()){var a=l.value,u=a.options;if(u)try{for(var c=(n=void 0,d(u)),p=c.next();!p.done;p=c.next()){var h=p.value;if(h.value===t)return h}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}else if(a.value===t)return a}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}return null}function n(e,t,r){var o,n;if(r){var i=Array.isArray(t)?t:[],s=[];try{for(var l=d(i),a=l.next();!a.done;a=l.next()){var u=c(e,a.value);u&&s.push(u)}}catch(e){o={error:e}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}finally{if(o)throw o.error}}return s}return c(e,t)}function i(e){var t,r,o,n;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var l=s.value,a=l.options;if(a)try{for(var u=(o=void 0,d(a)),c=u.next();!c.done;c=u.next()){var p;if(!(p=c.value).disabled)return p.value}}catch(e){o={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(o)throw o.error}}else if(!(p=l).disabled)return p.value}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return null}function a(e,t){var r,o,n,i;if(v(t))return!0;try{for(var s=d(e),l=s.next();!l.done;l=s.next()){var a=l.value,u=a.options;if(u)try{for(var c=(n=void 0,d(u)),p=c.next();!p.done;p=c.next()){if(p.value.value===t)return!1}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}else if(a.value===t)return!1}}catch(e){r={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}return!0}function u(e,t){for(var r=v(t),o=e.length-1;0<=o;o--){var n=e[o],i=n.options;if(i)for(var s=i.length-1;0<=s;s--){var l=i[s];if(r&&!l.disabled)return l.value;r=l.value===t}else{l=n;if(r&&!l.disabled)return l.value;r=l.value===t}}return r?t:null}function p(e,t){var r,o,n,i,s=v(t);try{for(var l=d(e),a=l.next();!a.done;a=l.next()){var u=a.value,c=u.options;if(c)try{for(var p=(n=void 0,d(c)),h=p.next();!h.done;h=p.next()){var f=h.value;if(s){if(!f.disabled)return f.value}else s=f.value===t}}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}else{f=u;if(s){if(!f.disabled)return f.value}else s=f.value===t}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}return s?t:null}function v(e){return null==e}function h(e,t,r,o){if(v(e))return t.scrollTop=0;var n,i=function(e,t){var r,o,n=0;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var l=s.value,a=l.options;if(a){n++;var u=a.findIndex(function(e){return e.value===t});if(-1!==u)return n+u;n+=a.length}else{if(l.value===t)return n;n++}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return 0}(r,e);return 5<i-o?(o+=i-o-5,(n=t.querySelectorAll("li").item(i))&&(t.scrollTop=n.offsetTop-t.offsetHeight),o):0<o-i?(o-=o-i,(n=t.querySelectorAll("li").item(o-1))&&(t.scrollTop=n.offsetTop),o):null}function f(e,t,r){return!t||null!==y(e).match(new RegExp(function(e,t){e=y(function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(e)),t&&"function"==typeof t&&(e=t(e));return e}(t,r),"i"))}function y(e){var t,r;try{for(var o=d(s),n=o.next();!n.done;n=o.next()){var i=n.value;e=e.replace(i.s,i.l)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return e}function m(e,t,r){var o,n;if(t){var i=[];try{for(var s=d(e),l=s.next();!l.done;l=s.next()){var a=l.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)});i.push({label:a.label,options:c})}}else f(a.label,t,r)&&i.push(a)}}catch(e){o={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}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 b(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 E(e,t){return"number"!=typeof t&&(t=6),function(e){var t,r,o=0;try{for(var n=d(e),i=n.next();!i.done;i=n.next()){var s=i.value.options;s?o+=s.length:o++}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return o}(e)<t}function T(e){return e?"select2-search select2-search--dropdown select2-search--hide":"select2-search select2-search--dropdown"}function O(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 k(e,t){for(var r=0;r<e.length;r++)if(e[r].value===t.value)return void e.splice(r,1)}var _,N=(r(V,_=l.PureComponent),Object.defineProperty(V.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(V.prototype,"dropdownStyle",{get:function(){return S(this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"containerStyle",{get:function(){return b(this.props.disabled,this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"selectionStyle",{get:function(){return x(this.props.multiple)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"isSearchboxHidden",{get:function(){return!this.props.customSearchEnabled&&E(this.props.data,this.props.minCountForSearch)},enumerable:!0,configurable:!0}),Object.defineProperty(V.prototype,"searchStyle",{get:function(){return T(this.isSearchboxHidden)},enumerable:!0,configurable:!0}),V.prototype.UNSAFE_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})},V.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]},V.prototype.componentWillUnmount=function(){this.cancelFocusoutTimer()},V.prototype.render=function(){var t=this,e=this.renderResult(),r=this.renderSelection();return l.createElement("div",{className:this.containerStyle},l.createElement("div",{className:"selection",onClick:function(){return t.toggleOpenAndClose()}},l.createElement("div",{className:this.selectionStyle,role:"combobox"},r)),l.createElement("div",{className:this.dropdownStyle},l.createElement("div",{className:"select2-dropdown select2-dropdown--below"},l.createElement("div",{className:this.searchStyle},l.createElement("input",{value:this.searchText,onChange:this.onChange,onKeyDown:function(e){return t.keyDown(e)},onKeyUp:function(e){return t.keyUp(e)},onKeyPress:function(e){return t.keyPress(e)},onBlur:function(){return t.focusout()},className:"select2-search__field",type:"search",role:"textbox",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1})),l.createElement("div",{className:"select2-results"},l.createElement("ul",{className:"select2-results__options",role:"tree",tabIndex:-1,onKeyDown:function(e){return t.keyDown(e)},onFocus:function(){return t.cancelFocusoutTimer()},onBlur:function(){return t.focusout()}},e)))))},V.prototype.renderSelection=function(){var r=this;if(this.props.multiple){var e=this.option.map(function(t,e){return l.createElement("li",{className:"select2-selection__choice",title:t.label,key:e},l.createElement("span",{onClick:function(e){return r.removeSelection(e,t)},className:"select2-selection__choice__remove",role:"presentation"},"×"),t.label)});return l.createElement("ul",{className:"select2-selection__rendered"},e)}var t=this.option,o=t?t.component?l.createElement(t.component,{option:t}):t.label:l.createElement("span",{className:"select2-selection__placeholder"},this.props.placeholder);return[l.createElement("span",{key:"label",className:"select2-selection__rendered",title:t?t.label:""},o),l.createElement("span",{key:"arrow",className:"select2-selection__arrow",role:"presentation"},l.createElement("b",{role:"presentation"}))]},V.prototype.renderResult=function(){var s=this;return this.getFilteredData(!1).map(function(e,t){var r=e.options;if(r){var o=r.map(function(e,t){var r=e.component?l.createElement(e.component,{option:e}):e.label;return l.createElement("li",{className:s.getOptionStyle(e.value),key:t,role:"treeitem","aria-selected":s.isSelected(e),"aria-disabled":s.isDisabled(e),onMouseEnter:function(){return s.mouseenter(e)},onClick:function(){return s.click(e)}},r)});return l.createElement("li",{className:"select2-results__option",role:"group",key:t},l.createElement("strong",{className:"select2-results__group"},e.label),l.createElement("ul",{className:"select2-results__options select2-results__options--nested"},o))}var n=e,i=n.component?l.createElement(n.component,{option:n}):n.label;return l.createElement("li",{className:s.getOptionStyle(n.value),key:t,role:"treeitem","aria-selected":s.isSelected(n),"aria-disabled":s.isDisabled(n),onMouseEnter:function(){return s.mouseenter(n)},onClick:function(){return s.click(n)}},i)})},V.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=i(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},V.prototype.getOptionStyle=function(e){return g(e,this.hoveringValue)},V.prototype.mouseenter=function(e){e.disabled||(this.hoveringValue=e.value,this.setState({hoveringValue:this.hoveringValue}))},V.prototype.click=function(e){e.disabled||this.select(e),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},V.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))},V.prototype.focusout=function(){var e=this;this.focusoutTimer=setTimeout(function(){e.isOpen=!1,e.setState({isOpen:e.isOpen}),e.focusoutTimer=void 0},200)},V.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}))}},V.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}))}},V.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},V.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)},V.prototype.keyDown=function(e){this.props.keydown&&this.props.keydown(e),40===e.keyCode?(this.moveDown(),e.preventDefault()):38===e.keyCode?(this.moveUp(),e.preventDefault()):13===e.keyCode&&(this.selectByEnter(),e.preventDefault())},V.prototype.keyUp=function(e){this.props.keyup&&this.props.keyup(e)},V.prototype.keyPress=function(e){this.props.keypress&&this.props.keypress(e)},V.prototype.isSelected=function(e){return O(this.option,e,this.props.multiple)},V.prototype.isDisabled=function(e){return e.disabled?"true":"false"},V.prototype.focusSearchboxOrResultsElement=function(){this.isSearchboxHidden?this.resultsElement&&this.resultsElement.focus():this.searchInputElement&&this.searchInputElement.focus()},V.prototype.removeSelection=function(e,t){var r=this;k(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)},V.prototype.cancelFocusoutTimer=function(){this.focusoutTimer&&clearTimeout(this.focusoutTimer)},V);function V(){var t=null!==_&&_.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}var w,D=(r(I,w=l.PureComponent),Object.defineProperty(I.prototype,"dropdownStyle",{get:function(){return S(this.isOpen&&0<this.props.data.length)},enumerable:!0,configurable:!0}),Object.defineProperty(I.prototype,"containerStyle",{get:function(){return b(!1,this.isOpen&&0<this.props.data.length)},enumerable:!0,configurable:!0}),I.prototype.UNSAFE_componentWillMount=function(){var e=n(this.props.data,this.props.value,!1);null!==e&&(this.option=e,this.setState({option:this.option})),Array.isArray(e)||(this.hoveringValue=this.props.value),this.setState({hoveringValue:this.hoveringValue})},I.prototype.componentDidMount=function(){var e=t.findDOMNode(this);this.searchInputElement=e.childNodes[0].childNodes[0].childNodes[0].childNodes[0],this.resultsElement=e.childNodes[1].childNodes[0].childNodes[0].childNodes[0]},I.prototype.render=function(){var t=this,e=this.renderResult();return l.createElement("div",{className:this.containerStyle},l.createElement("div",{className:"selection"},l.createElement("div",{className:"select2-search select2-search--dropdown"},l.createElement("input",{value:this.props.value,onChange:this.onChange,onKeyDown:function(e){return t.keyDown(e)},onKeyUp:function(e){return t.keyUp(e)},onKeyPress:function(e){return t.keyPress(e)},onBlur:function(){return t.focusout()},onClick:function(){return t.toggleOpenAndClose()},className:"select2-search__field",type:"search",role:"textbox",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}))),l.createElement("div",{className:this.dropdownStyle},l.createElement("div",{className:"select2-dropdown"},l.createElement("div",{className:"select2-results"},l.createElement("ul",{className:"select2-results__options",role:"tree",tabIndex:-1,onKeyDown:function(e){return t.keyDown(e)}},e)))))},I.prototype.renderResult=function(){var s=this;return this.getFilteredData(!1).map(function(e,t){var r=e.options;if(r){var o=r.map(function(e,t){var r=e.component?l.createElement(e.component,{option:e}):e.label;return l.createElement("li",{className:s.getOptionStyle(e.value),key:t,role:"treeitem","aria-selected":s.isSelected(e),"aria-disabled":s.isDisabled(e),onMouseEnter:function(){return s.mouseenter(e)},onClick:function(){return s.click(e)}},r)});return l.createElement("li",{className:"select2-results__option",role:"group",key:t},l.createElement("strong",{className:"select2-results__group"},e.label),l.createElement("ul",{className:"select2-results__options select2-results__options--nested"},o))}var n=e,i=n.component?l.createElement(n.component,{option:n}):n.label;return l.createElement("li",{className:s.getOptionStyle(n.value),key:t,role:"treeitem","aria-selected":s.isSelected(n),"aria-disabled":s.isDisabled(n),onMouseEnter:function(){return s.mouseenter(n)},onClick:function(){return s.click(n)}},i)})},I.prototype.getFilteredData=function(e){var t=this.props.data;if(a(t,this.hoveringValue)&&(this.hoveringValue=i(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},I.prototype.getOptionStyle=function(e){return g(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(){if(this.isOpen=!this.isOpen,this.setState({isOpen:this.isOpen}),this.isOpen&&(this.focusSearchboxOrResultsElement(),this.resultsElement)){var e=h(this.hoveringValue,this.resultsElement,this.props.data,this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e)}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=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}))}},I.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}))}},I.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},I.prototype.select=function(e){null!==e&&(this.option=e,this.isOpen=!1,this.setState({option:this.option,isOpen:this.isOpen})),this.props.select&&this.props.select(this.option.value),this.props.update&&this.props.update(this.option.value)},I.prototype.keyDown=function(e){this.props.keydown&&this.props.keydown(e),40===e.keyCode?(this.moveDown(),e.preventDefault()):38===e.keyCode?(this.moveUp(),e.preventDefault()):13===e.keyCode&&(this.selectByEnter(),e.preventDefault())},I.prototype.keyUp=function(e){this.props.keyup&&this.props.keyup(e)},I.prototype.keyPress=function(e){this.props.keypress&&this.props.keypress(e)},I.prototype.isSelected=function(e){return O(this.option,e,!1)},I.prototype.isDisabled=function(e){return e.disabled?"true":"false"},I.prototype.focusSearchboxOrResultsElement=function(){this.searchInputElement&&this.searchInputElement.focus()},I);function I(){var t=null!==w&&w.apply(this,arguments)||this;return t.hoveringValue=null,t.option=null,t.isOpen=!1,t.lastScrollTopIndex=0,t.onChange=function(e){t.props.search&&t.props.search(e.currentTarget.value),t.props.update&&t.props.update(e.currentTarget.value)},t}e.AutoComplete=D,e.Select2=N,e.getContainerStyle=b,e.getDropdownStyle=S,e.getFilteredData=m,e.getFirstAvailableOption=i,e.getLastScrollTopIndex=h,e.getNextOption=p,e.getOptionByValue=c,e.getOptionStyle=g,e.getOptionsByValue=n,e.getPreviousOption=u,e.getSearchStyle=T,e.getSelectionStyle=x,e.isSearchboxHiddex=E,e.isSelected=O,e.removeSelection=k,e.timeout=200,e.valueIsNotInFilteredData=a,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -39,2 +39,3 @@ import * as React from 'react'; | ||
componentDidMount(): void; | ||
componentWillUnmount(): void; | ||
render(): JSX.Element; | ||
@@ -41,0 +42,0 @@ private renderSelection; |
@@ -90,2 +90,5 @@ import { __extends } from "tslib"; | ||
}; | ||
Select2.prototype.componentWillUnmount = function () { | ||
this.cancelFocusoutTimer(); | ||
}; | ||
Select2.prototype.render = function () { | ||
@@ -92,0 +95,0 @@ var _this = this; |
{ | ||
"name": "select2-react-component", | ||
"version": "5.8.2", | ||
"version": "5.8.3", | ||
"description": "A reactjs select component.", | ||
@@ -33,3 +33,3 @@ "main": "dist/select2-react-component.min.js", | ||
}, | ||
"gitHead": "f098b5f5969724816aa6945ad08f12ed14eda9f8" | ||
"gitHead": "251a7fba12e34f06877e0c309bfae048307dd384" | ||
} |
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
54626
792