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