select2-react-component
Advanced tools
Comparing version 5.7.0 to 5.8.0
@@ -1,59 +0,2 @@ | ||
import * as React from 'react'; | ||
import * as common from 'select2-component'; | ||
export * from 'select2-component'; | ||
/** | ||
* @public | ||
*/ | ||
export declare class Select2 extends React.PureComponent<{ | ||
data: common.Select2Data; | ||
value?: common.Select2UpdateValue; | ||
disabled?: boolean; | ||
minCountForSearch?: number; | ||
placeholder?: string; | ||
customSearchEnabled?: boolean; | ||
multiple?: boolean; | ||
update?: (value: common.Select2UpdateValue) => void; | ||
open?: () => void; | ||
search?: (text: string) => void; | ||
keydown?: (e: React.KeyboardEvent) => void; | ||
keyup?: (e: React.KeyboardEvent) => void; | ||
keypress?: (e: React.KeyboardEvent) => void; | ||
}, {}> { | ||
private hoveringValue?; | ||
private option; | ||
private isOpen; | ||
private focusoutTimer?; | ||
private innerSearchText; | ||
private lastScrollTopIndex; | ||
private isSearchboxHidden; | ||
private searchStyle; | ||
private searchInputElement; | ||
private resultsElement; | ||
private searchText; | ||
private readonly dropdownStyle; | ||
private readonly containerStyle; | ||
private readonly selectionStyle; | ||
componentWillMount(): void; | ||
componentDidMount(): void; | ||
render(): JSX.Element; | ||
private renderSelection; | ||
private renderResult; | ||
private getFilteredData; | ||
private getOptionStyle; | ||
private mouseenter; | ||
private click; | ||
private toggleOpenAndClose; | ||
private focusout; | ||
private moveUp; | ||
private moveDown; | ||
private selectByEnter; | ||
private select; | ||
private keyDown; | ||
private keyUp; | ||
private keyPress; | ||
private onChange; | ||
private isSelected; | ||
private isDisabled; | ||
private focusSearchboxOrResultsElement; | ||
private removeSelection; | ||
} | ||
export * from './select2'; | ||
export * from './auto-complete'; |
@@ -1,328 +0,2 @@ | ||
import * as tslib_1 from "tslib"; | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import * as common from 'select2-component'; | ||
export * from 'select2-component'; | ||
/** | ||
* @public | ||
*/ | ||
var Select2 = /** @class */ (function (_super) { | ||
tslib_1.__extends(Select2, _super); | ||
function Select2() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.hoveringValue = null; | ||
_this.option = null; | ||
_this.isOpen = false; | ||
_this.innerSearchText = ''; | ||
_this.lastScrollTopIndex = 0; | ||
_this.onChange = function (e) { | ||
_this.searchText = e.currentTarget.value; | ||
_this.setState({ searchText: _this.searchText }); | ||
}; | ||
return _this; | ||
} | ||
Object.defineProperty(Select2.prototype, "searchText", { | ||
get: function () { | ||
return this.innerSearchText; | ||
}, | ||
set: function (text) { | ||
if (this.props.customSearchEnabled && this.props.search) { | ||
this.props.search(text); | ||
} | ||
this.innerSearchText = text; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Select2.prototype, "dropdownStyle", { | ||
get: function () { | ||
return common.getDropdownStyle(this.isOpen); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Select2.prototype, "containerStyle", { | ||
get: function () { | ||
return common.getContainerStyle(this.props.disabled, this.isOpen); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Select2.prototype, "selectionStyle", { | ||
get: function () { | ||
return common.getSelectionStyle(this.props.multiple); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Select2.prototype.componentWillMount = function () { | ||
var option = common.getOptionsByValue(this.props.data, this.props.value, this.props.multiple); | ||
if (option !== null) { | ||
this.option = option; | ||
this.setState({ option: this.option }); | ||
} | ||
if (!Array.isArray(option)) { | ||
this.hoveringValue = this.props.value; | ||
} | ||
this.setState({ hoveringValue: this.hoveringValue }); | ||
this.isSearchboxHidden = this.props.customSearchEnabled | ||
? false | ||
: common.isSearchboxHiddex(this.props.data, this.props.minCountForSearch); | ||
this.searchStyle = common.getSearchStyle(this.isSearchboxHidden); | ||
}; | ||
Select2.prototype.componentDidMount = function () { | ||
var theElement = ReactDOM.findDOMNode(this); | ||
this.searchInputElement = theElement.childNodes[1].childNodes[0].childNodes[0].childNodes[0]; | ||
this.resultsElement = theElement.childNodes[1].childNodes[0].childNodes[1].childNodes[0]; | ||
}; | ||
Select2.prototype.render = function () { | ||
var _this = this; | ||
var results = this.renderResult(); | ||
var selection = this.renderSelection(); | ||
return (React.createElement("div", { className: this.containerStyle }, | ||
React.createElement("div", { className: 'selection', onClick: function () { return _this.toggleOpenAndClose(); } }, | ||
React.createElement("div", { className: this.selectionStyle, role: 'combobox' }, selection)), | ||
React.createElement("div", { className: this.dropdownStyle }, | ||
React.createElement("div", { className: 'select2-dropdown select2-dropdown--below' }, | ||
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("div", { className: 'select2-results' }, | ||
React.createElement("ul", { className: 'select2-results__options', role: 'tree', tabIndex: -1, onKeyDown: function (e) { return _this.keyDown(e); }, onBlur: function () { return _this.focusout(); } }, results)))))); | ||
}; | ||
Select2.prototype.renderSelection = function () { | ||
var _this = this; | ||
if (this.props.multiple) { | ||
var items = this.option.map(function (op, i) { return (React.createElement("li", { className: 'select2-selection__choice', title: op.label, key: i }, | ||
React.createElement("span", { onClick: function (e) { return _this.removeSelection(e, op); }, className: 'select2-selection__choice__remove', role: 'presentation' }, "\u00D7"), | ||
op.label)); }); | ||
return (React.createElement("ul", { className: 'select2-selection__rendered' }, items)); | ||
} | ||
else { | ||
var option = this.option; | ||
var label = option | ||
? (option.component ? React.createElement(option.component, { option: option }) : option.label) | ||
: React.createElement("span", { className: 'select2-selection__placeholder' }, this.props.placeholder); | ||
return [ | ||
React.createElement("span", { key: 'label', className: 'select2-selection__rendered', title: option ? option.label : '' }, label), | ||
React.createElement("span", { key: 'arrow', className: 'select2-selection__arrow', role: 'presentation' }, | ||
React.createElement("b", { role: 'presentation' })) | ||
]; | ||
} | ||
}; | ||
Select2.prototype.renderResult = function () { | ||
var _this = this; | ||
return this.getFilteredData(false).map(function (groupOrOption, i) { | ||
var options = groupOrOption.options; | ||
if (options) { | ||
var optionsElements = options.map(function (option, j) { | ||
var optionElement = option.component | ||
? React.createElement(option.component, { option: option }) | ||
: option.label; | ||
return (React.createElement("li", { className: _this.getOptionStyle(option.value), key: j, role: 'treeitem', "aria-selected": _this.isSelected(option), "aria-disabled": _this.isDisabled(option), onMouseEnter: function () { return _this.mouseenter(option); }, onClick: function () { return _this.click(option); } }, optionElement)); | ||
}); | ||
return (React.createElement("li", { className: 'select2-results__option', role: 'group', key: i }, | ||
React.createElement("strong", { className: 'select2-results__group' }, groupOrOption.label), | ||
React.createElement("ul", { className: 'select2-results__options select2-results__options--nested' }, optionsElements))); | ||
} | ||
else { | ||
var option_1 = groupOrOption; | ||
var optionElement = option_1.component | ||
? React.createElement(option_1.component, { option: option_1 }) | ||
: option_1.label; | ||
return (React.createElement("li", { className: _this.getOptionStyle(option_1.value), key: i, role: 'treeitem', "aria-selected": _this.isSelected(option_1), "aria-disabled": _this.isDisabled(option_1), onMouseEnter: function () { return _this.mouseenter(option_1); }, onClick: function () { return _this.click(option_1); } }, optionElement)); | ||
} | ||
}); | ||
}; | ||
Select2.prototype.getFilteredData = function (canSetState) { | ||
var result = this.props.customSearchEnabled | ||
? this.props.data | ||
: common.getFilteredData(this.props.data, this.searchText); | ||
if (common.valueIsNotInFilteredData(result, this.hoveringValue)) { | ||
this.hoveringValue = common.getFirstAvailableOption(result); | ||
if (canSetState) { | ||
this.setState({ hoveringValue: this.hoveringValue }); | ||
} | ||
if (this.resultsElement) { | ||
var lastScrollTopIndex = common.getLastScrollTopIndex(this.hoveringValue, this.resultsElement, result, this.lastScrollTopIndex); | ||
if (lastScrollTopIndex !== null) { | ||
this.lastScrollTopIndex = lastScrollTopIndex; | ||
if (canSetState) { | ||
this.setState({ lastScrollTopIndex: this.lastScrollTopIndex }); | ||
} | ||
} | ||
} | ||
} | ||
return result; | ||
}; | ||
Select2.prototype.getOptionStyle = function (value) { | ||
return common.getOptionStyle(value, this.hoveringValue); | ||
}; | ||
Select2.prototype.mouseenter = function (option) { | ||
if (!option.disabled) { | ||
this.hoveringValue = option.value; | ||
this.setState({ hoveringValue: this.hoveringValue }); | ||
} | ||
}; | ||
Select2.prototype.click = function (option) { | ||
if (!option.disabled) { | ||
this.select(option); | ||
} | ||
if (this.focusoutTimer) { | ||
clearTimeout(this.focusoutTimer); | ||
} | ||
}; | ||
Select2.prototype.toggleOpenAndClose = function () { | ||
var _this = this; | ||
if (this.props.disabled) { | ||
return; | ||
} | ||
this.isOpen = !this.isOpen; | ||
this.setState({ isOpen: this.isOpen }); | ||
if (this.isOpen) { | ||
this.innerSearchText = ''; | ||
this.setState({ searchText: this.searchText }, function () { | ||
_this.focusSearchboxOrResultsElement(); | ||
if (_this.resultsElement) { | ||
var lastScrollTopIndex = common.getLastScrollTopIndex(_this.hoveringValue, _this.resultsElement, _this.props.data, _this.lastScrollTopIndex); | ||
if (lastScrollTopIndex !== null) { | ||
_this.lastScrollTopIndex = lastScrollTopIndex; | ||
} | ||
} | ||
}); | ||
if (this.props.open) { | ||
this.props.open(); | ||
} | ||
} | ||
if (this.focusoutTimer) { | ||
clearTimeout(this.focusoutTimer); | ||
} | ||
}; | ||
Select2.prototype.focusout = function () { | ||
var _this = this; | ||
this.focusoutTimer = setTimeout(function () { | ||
_this.isOpen = false; | ||
_this.setState({ isOpen: _this.isOpen }); | ||
_this.focusoutTimer = undefined; | ||
}, common.timeout); | ||
}; | ||
Select2.prototype.moveUp = function () { | ||
this.hoveringValue = common.getPreviousOption(this.getFilteredData(true), this.hoveringValue); | ||
this.setState({ hoveringValue: this.hoveringValue }); | ||
if (this.resultsElement) { | ||
var lastScrollTopIndex = common.getLastScrollTopIndex(this.hoveringValue, this.resultsElement, this.getFilteredData(true), this.lastScrollTopIndex); | ||
if (lastScrollTopIndex !== null) { | ||
this.lastScrollTopIndex = lastScrollTopIndex; | ||
this.setState({ lastScrollTopIndex: this.lastScrollTopIndex }); | ||
} | ||
} | ||
}; | ||
Select2.prototype.moveDown = function () { | ||
this.hoveringValue = common.getNextOption(this.getFilteredData(true), this.hoveringValue); | ||
this.setState({ hoveringValue: this.hoveringValue }); | ||
if (this.resultsElement) { | ||
var lastScrollTopIndex = common.getLastScrollTopIndex(this.hoveringValue, this.resultsElement, this.getFilteredData(true), this.lastScrollTopIndex); | ||
if (lastScrollTopIndex !== null) { | ||
this.lastScrollTopIndex = lastScrollTopIndex; | ||
this.setState({ lastScrollTopIndex: this.lastScrollTopIndex }); | ||
} | ||
} | ||
}; | ||
Select2.prototype.selectByEnter = function () { | ||
if (this.hoveringValue) { | ||
var option = common.getOptionByValue(this.props.data, this.hoveringValue); | ||
this.select(option); | ||
} | ||
}; | ||
Select2.prototype.select = function (option) { | ||
if (option !== null) { | ||
if (this.props.multiple) { | ||
var options = this.option; | ||
var index = options.findIndex(function (op) { return op.value === option.value; }); | ||
if (index === -1) { | ||
options.push(option); | ||
} | ||
else { | ||
options.splice(index, 1); | ||
} | ||
this.setState({ | ||
option: this.option | ||
}); | ||
} | ||
else { | ||
this.option = option; | ||
this.isOpen = false; | ||
this.setState({ | ||
option: this.option, | ||
isOpen: this.isOpen | ||
}); | ||
} | ||
} | ||
if (this.props.update) { | ||
this.props.update(this.props.multiple ? this.option.map(function (op) { return op.value; }) : this.option.value); | ||
} | ||
}; | ||
Select2.prototype.keyDown = function (e) { | ||
if (this.props.keydown) { | ||
this.props.keydown(e); | ||
} | ||
if (e.keyCode === 40) { | ||
this.moveDown(); | ||
e.preventDefault(); | ||
} | ||
else if (e.keyCode === 38) { | ||
this.moveUp(); | ||
e.preventDefault(); | ||
} | ||
else if (e.keyCode === 13) { | ||
this.selectByEnter(); | ||
e.preventDefault(); | ||
} | ||
}; | ||
Select2.prototype.keyUp = function (e) { | ||
if (this.props.keyup) { | ||
this.props.keyup(e); | ||
} | ||
}; | ||
Select2.prototype.keyPress = function (e) { | ||
if (this.props.keypress) { | ||
this.props.keypress(e); | ||
} | ||
}; | ||
Select2.prototype.isSelected = function (option) { | ||
return common.isSelected(this.option, option, this.props.multiple); | ||
}; | ||
Select2.prototype.isDisabled = function (option) { | ||
return option.disabled ? 'true' : 'false'; | ||
}; | ||
Select2.prototype.focusSearchboxOrResultsElement = function () { | ||
if (!this.isSearchboxHidden) { | ||
if (this.searchInputElement) { | ||
this.searchInputElement.focus(); | ||
} | ||
} | ||
else { | ||
if (this.resultsElement) { | ||
this.resultsElement.focus(); | ||
} | ||
} | ||
}; | ||
Select2.prototype.removeSelection = function (e, option) { | ||
var _this = this; | ||
common.removeSelection(this.option, option); | ||
if (this.props.update) { | ||
this.props.update(this.option.map(function (op) { return op.value; })); | ||
} | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
if (this.isOpen) { | ||
this.setState({ option: this.option }, function () { | ||
_this.focusSearchboxOrResultsElement(); | ||
}); | ||
} | ||
if (this.focusoutTimer) { | ||
clearTimeout(this.focusoutTimer); | ||
} | ||
}; | ||
return Select2; | ||
}(React.PureComponent)); | ||
export { Select2 }; | ||
export * from './select2'; | ||
export * from './auto-complete'; |
@@ -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,s,t){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function d(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var l=[{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 l=d(e),s=l.next();!s.done;s=l.next()){var a=s.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{s&&!s.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return null}function n(e,t,r){var n,o;if(r){var i=Array.isArray(t)?t:[],l=[];try{for(var s=d(i),a=s.next();!a.done;a=s.next()){var u=c(e,a.value);u&&l.push(u)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return l}return c(e,t)}function o(e){var t,r,n,o;try{for(var i=d(e),l=i.next();!l.done;l=i.next()){var s=l.value,a=s.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=s).disabled)return p.value}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return null}function i(e,t){var r,n,o,i;if(v(t))return!0;try{for(var l=d(e),s=l.next();!s.done;s=l.next()){var a=s.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{s&&!s.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return!0}function a(e,t){for(var r=v(t),n=e.length-1;0<=n;n--){var o=e[n],i=o.options;if(i)for(var l=i.length-1;0<=l;l--){var s=i[l];if(r&&!s.disabled)return s.value;r=s.value===t}else{s=o;if(r&&!s.disabled)return s.value;r=s.value===t}}return r?t:null}function u(e,t){var r,n,o,i,l=v(t);try{for(var s=d(e),a=s.next();!a.done;a=s.next()){var u=a.value,c=u.options;if(c)try{for(var p=(o=void 0,d(c)),h=p.next();!h.done;h=p.next()){var f=h.value;if(l){if(!f.disabled)return f.value}else l=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(l){if(!f.disabled)return f.value}else l=f.value===t}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return l?t:null}function v(e){return null==e}function p(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),l=i.next();!l.done;l=i.next()){var s=l.value,a=s.options;if(a){o++;var u=a.findIndex(function(e){return e.value===t});if(-1!==u)return o+u;o+=a.length}else{if(s.value===t)return o;o++}}}catch(e){r={error:e}}finally{try{l&&!l.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 h(e,t,r){return!t||null!==f(e).match(new RegExp(function(e,t){e=f(function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}(e)),t&&"function"==typeof t&&(e=t(e));return e}(t,r),"i"))}function f(e){var t,r;try{for(var n=d(l),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 l=d(e),s=l.next();!s.done;s=l.next()){var a=s.value,u=a.options;if(u){if(u.some(function(e){return h(e.label,t,r)})){var c=u.filter(function(e){return h(e.label,t,r)});i.push({label:a.label,options:c})}}else h(a.label,t,r)&&i.push(a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}return i}return e}function m(e,t){return e===t?"select2-results__option select2-results__option--highlighted":"select2-results__option"}function g(e){return e?"select2-container select2-container--default select2-container-dropdown select2-container--open":"select2-container select2-container--default select2-container-dropdown"}function S(e,t){return void 0===e&&(e=void 0),"select2 select2-container select2-container--default "+(e?"select2-container--disabled":"")+" "+(t?"select2-container--open":"")+" select2-container--below select2-container--focus"}function x(e){return void 0===e&&(e=void 0),"select2-selection select2-selection--"+(e?"multiple":"single")}function b(e,t){return"number"!=typeof t&&(t=6),function(e){var t,r,n=0;try{for(var o=d(e),i=o.next();!i.done;i=o.next()){var l=i.value.options;l?n+=l.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 E(e){return e?"select2-search select2-search--dropdown select2-search--hide":"select2-search select2-search--dropdown"}function T(e,t,r){return r?e&&e.some(function(e){return e.value===t.value})?"true":"false":e&&t.value===e.value?"true":"false"}function _(e,t){for(var r=0;r<e.length;r++)if(e[r].value===t.value)return void e.splice(r,1)}var O,w,k,N=(k=s.PureComponent,r(O=D,w=k),void(O.prototype=null===w?Object.create(w):(V.prototype=w.prototype,new V)),Object.defineProperty(D.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(D.prototype,"dropdownStyle",{get:function(){return g(this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(D.prototype,"containerStyle",{get:function(){return S(this.props.disabled,this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(D.prototype,"selectionStyle",{get:function(){return x(this.props.multiple)},enumerable:!0,configurable:!0}),D.prototype.componentWillMount=function(){var e=n(this.props.data,this.props.value,this.props.multiple);null!==e&&(this.option=e,this.setState({option:this.option})),Array.isArray(e)||(this.hoveringValue=this.props.value),this.setState({hoveringValue:this.hoveringValue}),this.isSearchboxHidden=!this.props.customSearchEnabled&&b(this.props.data,this.props.minCountForSearch),this.searchStyle=E(this.isSearchboxHidden)},D.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]},D.prototype.render=function(){var t=this,e=this.renderResult(),r=this.renderSelection();return s.createElement("div",{className:this.containerStyle},s.createElement("div",{className:"selection",onClick:function(){return t.toggleOpenAndClose()}},s.createElement("div",{className:this.selectionStyle,role:"combobox"},r)),s.createElement("div",{className:this.dropdownStyle},s.createElement("div",{className:"select2-dropdown select2-dropdown--below"},s.createElement("div",{className:this.searchStyle},s.createElement("input",{value:this.searchText,onChange:this.onChange,onKeyDown:function(e){return t.keyDown(e)},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})),s.createElement("div",{className:"select2-results"},s.createElement("ul",{className:"select2-results__options",role:"tree",tabIndex:-1,onKeyDown:function(e){return t.keyDown(e)},onBlur:function(){return t.focusout()}},e)))))},D.prototype.renderSelection=function(){var r=this;if(this.props.multiple){var e=this.option.map(function(t,e){return s.createElement("li",{className:"select2-selection__choice",title:t.label,key:e},s.createElement("span",{onClick:function(e){return r.removeSelection(e,t)},className:"select2-selection__choice__remove",role:"presentation"},"×"),t.label)});return s.createElement("ul",{className:"select2-selection__rendered"},e)}var t=this.option,n=t?t.component?s.createElement(t.component,{option:t}):t.label:s.createElement("span",{className:"select2-selection__placeholder"},this.props.placeholder);return[s.createElement("span",{key:"label",className:"select2-selection__rendered",title:t?t.label:""},n),s.createElement("span",{key:"arrow",className:"select2-selection__arrow",role:"presentation"},s.createElement("b",{role:"presentation"}))]},D.prototype.renderResult=function(){var l=this;return this.getFilteredData(!1).map(function(e,t){var r=e.options;if(r){var n=r.map(function(e,t){var r=e.component?s.createElement(e.component,{option:e}):e.label;return s.createElement("li",{className:l.getOptionStyle(e.value),key:t,role:"treeitem","aria-selected":l.isSelected(e),"aria-disabled":l.isDisabled(e),onMouseEnter:function(){return l.mouseenter(e)},onClick:function(){return l.click(e)}},r)});return s.createElement("li",{className:"select2-results__option",role:"group",key:t},s.createElement("strong",{className:"select2-results__group"},e.label),s.createElement("ul",{className:"select2-results__options select2-results__options--nested"},n))}var o=e,i=o.component?s.createElement(o.component,{option:o}):o.label;return s.createElement("li",{className:l.getOptionStyle(o.value),key:t,role:"treeitem","aria-selected":l.isSelected(o),"aria-disabled":l.isDisabled(o),onMouseEnter:function(){return l.mouseenter(o)},onClick:function(){return l.click(o)}},i)})},D.prototype.getFilteredData=function(e){var t=this.props.customSearchEnabled?this.props.data:y(this.props.data,this.searchText);if(i(t,this.hoveringValue)&&(this.hoveringValue=o(t),e&&this.setState({hoveringValue:this.hoveringValue}),this.resultsElement)){var r=p(this.hoveringValue,this.resultsElement,t,this.lastScrollTopIndex);null!==r&&(this.lastScrollTopIndex=r,e&&this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}return t},D.prototype.getOptionStyle=function(e){return m(e,this.hoveringValue)},D.prototype.mouseenter=function(e){e.disabled||(this.hoveringValue=e.value,this.setState({hoveringValue:this.hoveringValue}))},D.prototype.click=function(e){e.disabled||this.select(e),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},D.prototype.toggleOpenAndClose=function(){var t=this;this.props.disabled||(this.isOpen=!this.isOpen,this.setState({isOpen:this.isOpen}),this.isOpen&&(this.innerSearchText="",this.setState({searchText:this.searchText},function(){if(t.focusSearchboxOrResultsElement(),t.resultsElement){var e=p(t.hoveringValue,t.resultsElement,t.props.data,t.lastScrollTopIndex);null!==e&&(t.lastScrollTopIndex=e)}}),this.props.open&&this.props.open()),this.focusoutTimer&&clearTimeout(this.focusoutTimer))},D.prototype.focusout=function(){var e=this;this.focusoutTimer=setTimeout(function(){e.isOpen=!1,e.setState({isOpen:e.isOpen}),e.focusoutTimer=void 0},200)},D.prototype.moveUp=function(){if(this.hoveringValue=a(this.getFilteredData(!0),this.hoveringValue),this.setState({hoveringValue:this.hoveringValue}),this.resultsElement){var e=p(this.hoveringValue,this.resultsElement,this.getFilteredData(!0),this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e,this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}},D.prototype.moveDown=function(){if(this.hoveringValue=u(this.getFilteredData(!0),this.hoveringValue),this.setState({hoveringValue:this.hoveringValue}),this.resultsElement){var e=p(this.hoveringValue,this.resultsElement,this.getFilteredData(!0),this.lastScrollTopIndex);null!==e&&(this.lastScrollTopIndex=e,this.setState({lastScrollTopIndex:this.lastScrollTopIndex}))}},D.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},D.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)},D.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())},D.prototype.keyUp=function(e){this.props.keyup&&this.props.keyup(e)},D.prototype.keyPress=function(e){this.props.keypress&&this.props.keypress(e)},D.prototype.isSelected=function(e){return T(this.option,e,this.props.multiple)},D.prototype.isDisabled=function(e){return e.disabled?"true":"false"},D.prototype.focusSearchboxOrResultsElement=function(){this.isSearchboxHidden?this.resultsElement&&this.resultsElement.focus():this.searchInputElement&&this.searchInputElement.focus()},D.prototype.removeSelection=function(e,t){var r=this;_(this.option,t),this.props.update&&this.props.update(this.option.map(function(e){return e.value})),e.preventDefault(),e.stopPropagation(),this.isOpen&&this.setState({option:this.option},function(){r.focusSearchboxOrResultsElement()}),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},D);function V(){this.constructor=O}function D(){var t=null!==k&&k.apply(this,arguments)||this;return t.hoveringValue=null,t.option=null,t.isOpen=!1,t.innerSearchText="",t.lastScrollTopIndex=0,t.onChange=function(e){t.searchText=e.currentTarget.value,t.setState({searchText:t.searchText})},t}e.Select2=N,e.getContainerStyle=S,e.getDropdownStyle=g,e.getFilteredData=y,e.getFirstAvailableOption=o,e.getLastScrollTopIndex=p,e.getNextOption=u,e.getOptionByValue=c,e.getOptionStyle=m,e.getOptionsByValue=n,e.getPreviousOption=a,e.getSearchStyle=E,e.getSelectionStyle=x,e.isSearchboxHiddex=b,e.isSelected=T,e.removeSelection=_,e.timeout=200,e.valueIsNotInFilteredData=i,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&&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,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!==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 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 m(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){return e===t?"select2-results__option select2-results__option--highlighted":"select2-results__option"}function S(e){return e?"select2-container select2-container--default select2-container-dropdown select2-container--open":"select2-container select2-container--default select2-container-dropdown"}function x(e,t){return 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 b(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 V,_=(r(N,V=l.PureComponent),Object.defineProperty(N.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(N.prototype,"dropdownStyle",{get:function(){return S(this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(N.prototype,"containerStyle",{get:function(){return x(this.props.disabled,this.isOpen)},enumerable:!0,configurable:!0}),Object.defineProperty(N.prototype,"selectionStyle",{get:function(){return b(this.props.multiple)},enumerable:!0,configurable:!0}),N.prototype.componentWillMount=function(){var e=o(this.props.data,this.props.value,this.props.multiple);null!==e&&(this.option=e,this.setState({option:this.option})),Array.isArray(e)||(this.hoveringValue=this.props.value),this.setState({hoveringValue:this.hoveringValue}),this.isSearchboxHidden=!this.props.customSearchEnabled&&E(this.props.data,this.props.minCountForSearch),this.searchStyle=T(this.isSearchboxHidden)},N.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]},N.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)},onBlur:function(){return t.focusout()}},e)))))},N.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"}))]},N.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.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"},n))}var o=e,i=o.component?l.createElement(o.component,{option:o}):o.label;return l.createElement("li",{className:s.getOptionStyle(o.value),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)})},N.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},N.prototype.getOptionStyle=function(e){return g(e,this.hoveringValue)},N.prototype.mouseenter=function(e){e.disabled||(this.hoveringValue=e.value,this.setState({hoveringValue:this.hoveringValue}))},N.prototype.click=function(e){e.disabled||this.select(e),this.focusoutTimer&&clearTimeout(this.focusoutTimer)},N.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))},N.prototype.focusout=function(){var e=this;this.focusoutTimer=setTimeout(function(){e.isOpen=!1,e.setState({isOpen:e.isOpen}),e.focusoutTimer=void 0},200)},N.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}))}},N.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}))}},N.prototype.selectByEnter=function(){if(this.hoveringValue){var e=c(this.props.data,this.hoveringValue);this.select(e)}},N.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)},N.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())},N.prototype.keyUp=function(e){this.props.keyup&&this.props.keyup(e)},N.prototype.keyPress=function(e){this.props.keypress&&this.props.keypress(e)},N.prototype.isSelected=function(e){return O(this.option,e,this.props.multiple)},N.prototype.isDisabled=function(e){return e.disabled?"true":"false"},N.prototype.focusSearchboxOrResultsElement=function(){this.isSearchboxHidden?this.resultsElement&&this.resultsElement.focus():this.searchInputElement&&this.searchInputElement.focus()},N.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)},N);function N(){var t=null!==V&&V.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 x(!1,this.isOpen&&0<this.props.data.length)},enumerable:!0,configurable:!0}),I.prototype.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.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"},n))}var o=e,i=o.component?l.createElement(o.component,{option:o}):o.label;return l.createElement("li",{className:s.getOptionStyle(o.value),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!==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=_,e.getContainerStyle=x,e.getDropdownStyle=S,e.getFilteredData=m,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=b,e.isSearchboxHiddex=E,e.isSelected=O,e.removeSelection=k,e.timeout=200,e.valueIsNotInFilteredData=a,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "select2-react-component", | ||
"version": "5.7.0", | ||
"version": "5.8.0", | ||
"description": "A reactjs select component.", | ||
@@ -33,3 +33,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "f9e9bce50e32f9ab021993e428c47a46c56f69e9" | ||
"gitHead": "ec774cd7b38632506599200f49540395c60b3fd3" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53445
10
768
1