select2-react-component
Advanced tools
Comparing version 5.9.0 to 5.10.0
@@ -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){var r=e.classes?" "+e.classes:"";return e.value===t?"select2-results__option select2-results__option--highlighted"+r:"select2-results__option"+r}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],this.mounted=!0},V.prototype.componentWillUnmount=function(){this.mounted=!1,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),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),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.mounted&&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),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),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 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 r(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function d(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}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,n,o,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=(o=void 0,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&&(i=c.return)&&i.call(c)}finally{if(o)throw o.error}}else if(a.value===t)return a}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return null}function o(e,t,r){var n,o;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){n={error:e}}finally{try{a&&!a.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}return s}return c(e,t)}function i(e){var t,r,n,o;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=(n=void 0,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=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,n,o,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=(o=void 0,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&&(i=c.return)&&i.call(c)}finally{if(o)throw o.error}}else if(a.value===t)return!1}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}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],i=o.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=o;if(r&&!l.disabled)return l.value;r=l.value===t}}return r?t:null}function p(e,t){var r,n,o,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=(o=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){o={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(o)throw o.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&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return s?t:null}function v(e){return null==e}function h(e,t,r,n){if(v(e))return t.scrollTop=0;var o,i=function(e,t){var r,n,o=0;try{for(var i=d(e),s=i.next();!s.done;s=i.next()){var l=s.value,a=l.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(l.value===t)return o;o++}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return 0}(r,e);return 5<i-n?(n+=i-n-5,(o=t.querySelectorAll("li").item(i))&&(t.scrollTop=o.offsetTop-t.offsetHeight),n):0<n-i?(n-=n-i,(o=t.querySelectorAll("li").item(n-1))&&(t.scrollTop=o.offsetTop),n):null}function f(e,t,r){return!t||null!==m(e).match(new RegExp(function(e,t){e=m(function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(e)),t&&"function"==typeof t&&(e=t(e));return e}(t,r),"i"))}function m(e){var t,r;try{for(var n=d(s),o=n.next();!o.done;o=n.next()){var i=o.value;e=e.replace(i.s,i.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 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){n={error:e}}finally{try{l&&!l.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return i}return e}function g(e,t){var r=e.classes?" "+e.classes:"";return e.value===t?"select2-results__option select2-results__option--highlighted"+r:"select2-results__option"+r}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,n=0;try{for(var o=d(e),i=o.next();!i.done;i=o.next()){var s=i.value.options;s?n+=s.length:n++}}catch(e){t={error:e}}finally{try{i&&!i.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 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(w,_=l.PureComponent),Object.defineProperty(w.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(w.prototype,"dropdownStyle",{get:function(){return S(this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"containerStyle",{get:function(){return b(this.props.disabled,this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"selectionStyle",{get:function(){return x(this.props.multiple)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"isSearchboxHidden",{get:function(){return!this.props.customSearchEnabled&&E(this.props.data,this.props.minCountForSearch)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"searchStyle",{get:function(){return T(this.isSearchboxHidden)},enumerable:!0,configurable:!0}),w.prototype.UNSAFE_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})},w.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],this.mounted=!0},w.prototype.componentWillUnmount=function(){this.mounted=!1,this.cancelFocusoutTimer()},w.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",maxLength:this.props.maximumInputLength,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)))))},w.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,n=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:""},n),l.createElement("span",{key:"arrow",className:"select2-selection__arrow",role:"presentation"},l.createElement("b",{role:"presentation"}))]},w.prototype.renderResult=function(){var s=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?l.createElement(e.component,{option:e}):e.label;return l.createElement("li",{className:s.getOptionStyle(e),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"},n))}var o=e,i=o.component?l.createElement(o.component,{option:o}):o.label;return l.createElement("li",{className:s.getOptionStyle(o),key:t,role:"treeitem","aria-selected":s.isSelected(o),"aria-disabled":s.isDisabled(o),onMouseEnter:function(){return s.mouseenter(o)},onClick:function(){return s.click(o)}},i)})},w.prototype.getFilteredData=function(e){var t=this.props.customSearchEnabled||this.props.minimumInputLength&&this.props.minimumInputLength>this.searchText.length?this.props.data:y(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},w.prototype.getOptionStyle=function(e){return g(e,this.hoveringValue)},w.prototype.mouseenter=function(e){e.disabled||(this.hoveringValue=e.value,this.setState({hoveringValue:this.hoveringValue}))},w.prototype.click=function(e){e.disabled||this.select(e),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},w.prototype.toggleOpenAndClose=function(){var t=this;this.props.disabled||(this.isOpen=!this.isOpen,this.setState({isOpen:this.isOpen}),this.isOpen&&(this.props.keepSearchText||(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))},w.prototype.focusout=function(){var e=this;this.focusoutTimer=setTimeout(function(){e.isOpen=!1,e.mounted&&e.setState({isOpen:e.isOpen}),e.focusoutTimer=void 0},200)},w.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}))}},w.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}))}},w.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},w.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)},w.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())},w.prototype.keyUp=function(e){this.props.keyup&&this.props.keyup(e)},w.prototype.keyPress=function(e){this.props.keypress&&this.props.keypress(e)},w.prototype.isSelected=function(e){return O(this.option,e,this.props.multiple)},w.prototype.isDisabled=function(e){return e.disabled?"true":"false"},w.prototype.focusSearchboxOrResultsElement=function(){this.isSearchboxHidden?this.resultsElement&&this.resultsElement.focus():this.searchInputElement&&this.searchInputElement.focus()},w.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)},w.prototype.cancelFocusoutTimer=function(){this.focusoutTimer&&clearTimeout(this.focusoutTimer)},w);function w(){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 V,D=(r(I,V=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=o(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 n=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),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"},n))}var o=e,i=o.component?l.createElement(o.component,{option:o}):o.label;return l.createElement("li",{className:s.getOptionStyle(o),key:t,role:"treeitem","aria-selected":s.isSelected(o),"aria-disabled":s.isDisabled(o),onMouseEnter:function(){return s.mouseenter(o)},onClick:function(){return s.click(o)}},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!==V&&V.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=y,e.getFirstAvailableOption=i,e.getLastScrollTopIndex=h,e.getNextOption=p,e.getOptionByValue=c,e.getOptionStyle=g,e.getOptionsByValue=o,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})}); |
@@ -21,2 +21,5 @@ import * as React from 'react'; | ||
keypress?: (e: React.KeyboardEvent) => void; | ||
minimumInputLength?: number; | ||
maximumInputLength?: number; | ||
keepSearchText?: boolean; | ||
}, {}> { | ||
@@ -23,0 +26,0 @@ private hoveringValue?; |
@@ -105,3 +105,3 @@ import { __extends } from "tslib"; | ||
React.createElement("div", { className: this.searchStyle }, | ||
React.createElement("input", { value: this.searchText, onChange: this.onChange, onKeyDown: function (e) { return _this.keyDown(e); }, onKeyUp: function (e) { return _this.keyUp(e); }, onKeyPress: function (e) { return _this.keyPress(e); }, onBlur: function () { return _this.focusout(); }, className: 'select2-search__field', type: 'search', role: 'textbox', autoComplete: 'off', autoCorrect: 'off', autoCapitalize: 'off', spellCheck: false })), | ||
React.createElement("input", { value: this.searchText, onChange: this.onChange, onKeyDown: function (e) { return _this.keyDown(e); }, onKeyUp: function (e) { return _this.keyUp(e); }, onKeyPress: function (e) { return _this.keyPress(e); }, onBlur: function () { return _this.focusout(); }, className: 'select2-search__field', type: 'search', role: 'textbox', autoComplete: 'off', autoCorrect: 'off', autoCapitalize: 'off', maxLength: this.props.maximumInputLength, spellCheck: false })), | ||
React.createElement("div", { className: 'select2-results' }, | ||
@@ -156,2 +156,3 @@ React.createElement("ul", { className: 'select2-results__options', role: 'tree', tabIndex: -1, onKeyDown: function (e) { return _this.keyDown(e); }, onFocus: function () { return _this.cancelFocusoutTimer(); }, onBlur: function () { return _this.focusout(); } }, results)))))); | ||
var result = this.props.customSearchEnabled | ||
|| (this.props.minimumInputLength && this.props.minimumInputLength > this.searchText.length) | ||
? this.props.data | ||
@@ -201,3 +202,5 @@ : common.getFilteredData(this.props.data, this.searchText); | ||
if (this.isOpen) { | ||
this.innerSearchText = ''; | ||
if (!this.props.keepSearchText) { | ||
this.innerSearchText = ''; | ||
} | ||
this.setState({ searchText: this.searchText }, function () { | ||
@@ -204,0 +207,0 @@ _this.focusSearchboxOrResultsElement(); |
{ | ||
"name": "select2-react-component", | ||
"version": "5.9.0", | ||
"version": "5.10.0", | ||
"description": "A reactjs select component.", | ||
@@ -33,3 +33,3 @@ "main": "dist/select2-react-component.min.js", | ||
}, | ||
"gitHead": "2a843a374b480efd01990ad42f9b79888b80c029" | ||
"gitHead": "84b371bbe41999d8027f0cb962369a2c85d2e555" | ||
} |
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
55393
805