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

react-autocomplete

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-autocomplete - npm Package Compare versions

Comparing version 1.5.3 to 1.5.4

9

build/lib/Autocomplete.js

@@ -194,2 +194,6 @@ 'use strict';

}
// Capture the input's focus as long as the ignoreBlur flag is set
if (this._ignoreBlur) {
this.refs.input.focus();
}
},

@@ -352,3 +356,2 @@ exposeAPI: function exposeAPI(el) {

var value = this.props.getItemValue(item);
this.setIgnoreBlur(false);
this.setState({

@@ -358,2 +361,5 @@ isOpen: false,

}, function () {
// Clear the ignoreBlur flag after the component has
// updated to release control over the input's focus
_this4.setIgnoreBlur(false);
_this4.props.onSelect(value, item);

@@ -403,3 +409,2 @@ });

if (this._ignoreBlur) {
this.refs.input.focus();
return;

@@ -406,0 +411,0 @@ }

@@ -7,2 +7,5 @@ # CHANGELOG

## [1.5.4] - 2017-05-25
### Fixed
- Delay re-focus until all actions have been processed (#240)

@@ -176,3 +179,4 @@ ## [1.5.3] - 2017-05-14

[Unreleased]: https://github.com/reactjs/react-autocomplete/compare/v1.5.3...HEAD
[Unreleased]: https://github.com/reactjs/react-autocomplete/compare/v1.5.4...HEAD
[1.5.4]: https://github.com/reactjs/react-autocomplete/compare/v1.5.3...v1.5.4
[1.5.3]: https://github.com/reactjs/react-autocomplete/compare/v1.5.2...v1.5.3

@@ -179,0 +183,0 @@ [1.5.2]: https://github.com/reactjs/react-autocomplete/compare/v1.5.1...v1.5.2

@@ -207,2 +207,6 @@ (function (g, factory) {

}
// Capture the input's focus as long as the ignoreBlur flag is set
if (this._ignoreBlur) {
this.refs.input.focus();
}
},

@@ -365,3 +369,2 @@ exposeAPI: function exposeAPI(el) {

var value = this.props.getItemValue(item);
this.setIgnoreBlur(false);
this.setState({

@@ -371,2 +374,5 @@ isOpen: false,

}, function () {
// Clear the ignoreBlur flag after the component has
// updated to release control over the input's focus
_this4.setIgnoreBlur(false);
_this4.props.onSelect(value, item);

@@ -416,3 +422,2 @@ });

if (this._ignoreBlur) {
this.refs.input.focus();
return;

@@ -419,0 +424,0 @@ }

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],e):t.ReactAutocomplete=e(t.React,t.ReactDOM)}(this,function(t,e){return function(t){return function e(n,o,i){function r(l,u){if(!o[l]){if(!n[l]){var p="function"==typeof t&&t;if(!u&&p)return p(l,!0);if(s)return s(l,!0);var f=new Error("Cannot find module '"+l+"'");throw f.code="MODULE_NOT_FOUND",f}var h=o[l]={exports:{}};n[l][0].call(h.exports,function(t){var e=n[l][1][t];return r(e?e:t)},h,h.exports,e,n,o,i)}return o[l].exports}for(var s="function"==typeof t&&t,l=0;l<i.length;l++)r(i[l]);return r}({1:[function(t,e,n){(function(n){"use strict";var o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},i=t("react"),r=i.PropTypes,s=t("react-dom"),l=s.findDOMNode,u=t("dom-scroll-into-view"),p=[],f=["blur","checkValidity","click","focus","select","setCustomValidity","setSelectionRange","setRangeText"],h=i.createClass({displayName:"Autocomplete",propTypes:{items:r.array.isRequired,value:r.any,onChange:r.func,onSelect:r.func,shouldItemRender:r.func,sortItems:r.func,getItemValue:r.func.isRequired,renderItem:r.func.isRequired,renderMenu:r.func,menuStyle:r.object,inputProps:r.object,wrapperProps:r.object,wrapperStyle:r.object,autoHighlight:r.bool,onMenuVisibilityChange:r.func,open:r.bool,debug:r.bool},getDefaultProps:function(){return{value:"",wrapperProps:{},wrapperStyle:{display:"inline-block"},inputProps:{},onChange:function(){},onSelect:function(){},renderMenu:function(t,e,n){return i.createElement("div",{style:o({},n,this.menuStyle),children:t})},menuStyle:{borderRadius:"3px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.9)",padding:"2px 0",fontSize:"90%",position:"fixed",overflow:"auto",maxHeight:"50%"},autoHighlight:!0,onMenuVisibilityChange:function(){}}},getInitialState:function(){return{isOpen:!1,highlightedIndex:null}},componentWillMount:function(){this.refs={},this._ignoreBlur=!1,this._performAutoCompleteOnUpdate=!1,this._performAutoCompleteOnKeyUp=!1},componentWillReceiveProps:function(t){this._performAutoCompleteOnUpdate=!0,(this.props.items!==t.items||this.state.highlightedIndex>=t.items.length)&&this.setState({highlightedIndex:null})},componentDidMount:function(){this.isOpen()&&this.setMenuPositions()},componentDidUpdate:function(t,e){(this.state.isOpen&&!e.isOpen||"open"in this.props&&this.props.open&&!t.open)&&this.setMenuPositions(),this.isOpen()&&this._performAutoCompleteOnUpdate&&(this._performAutoCompleteOnUpdate=!1,this.maybeAutoCompleteText()),this.maybeScrollItemIntoView(),e.isOpen!==this.state.isOpen&&this.props.onMenuVisibilityChange(this.state.isOpen)},exposeAPI:function(t){var e=this;this.refs.input=t,f.forEach(function(n){return e[n]=t&&t[n]&&t[n].bind(t)})},maybeScrollItemIntoView:function(){if(this.isOpen()&&null!==this.state.highlightedIndex){var t=this.refs["item-"+this.state.highlightedIndex],e=this.refs.menu;t&&u(l(t),l(e),{onlyScrollIfNeeded:!0})}},handleKeyDown:function(t){this.keyDownHandlers[t.key]?this.keyDownHandlers[t.key].call(this,t):this.isOpen()||this.setState({isOpen:!0})},handleChange:function(t){this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:null}),this.props.onChange(t,t.target.value)},handleKeyUp:function(){this._performAutoCompleteOnKeyUp&&(this._performAutoCompleteOnKeyUp=!1,this.maybeAutoCompleteText())},keyDownHandlers:{ArrowDown:function(t){t.preventDefault();var e=this.getFilteredItems().length;if(e){var n=this.state.highlightedIndex,o=null===n||n===e-1?0:n+1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:o,isOpen:!0})}},ArrowUp:function(t){t.preventDefault();var e=this.getFilteredItems().length;if(e){var n=this.state.highlightedIndex,o=0===n||null===n?e-1:n-1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:o,isOpen:!0})}},Enter:function(t){var e=this;if(this.isOpen())if(null==this.state.highlightedIndex)this.setState({isOpen:!1},function(){e.refs.input.select()});else{t.preventDefault();var n=this.getFilteredItems()[this.state.highlightedIndex],o=this.props.getItemValue(n);this.setState({isOpen:!1,highlightedIndex:null},function(){e.refs.input.setSelectionRange(o.length,o.length),e.props.onSelect(o,n)})}},Escape:function(){this.setIgnoreBlur(!1),this.setState({highlightedIndex:null,isOpen:!1})},Tab:function(){this.setIgnoreBlur(!1)}},getFilteredItems:function(){var t=this,e=this.props.items;return this.props.shouldItemRender&&(e=e.filter(function(e){return t.props.shouldItemRender(e,t.props.value)})),this.props.sortItems&&e.sort(function(e,n){return t.props.sortItems(e,n,t.props.value)}),e},maybeAutoCompleteText:function(){if(this.props.autoHighlight&&""!==this.props.value){var t=this.state.highlightedIndex,e=this.getFilteredItems();if(0!==e.length){var n=null!==t?e[t]:e[0],o=this.props.getItemValue(n),i=0===o.toLowerCase().indexOf(this.props.value.toLowerCase());i&&null===t&&this.setState({highlightedIndex:0})}}},setMenuPositions:function(){var t=this.refs.input,e=t.getBoundingClientRect(),o=n.window.getComputedStyle(t),i=parseInt(o.marginBottom,10)||0,r=parseInt(o.marginLeft,10)||0,s=parseInt(o.marginRight,10)||0;this.setState({menuTop:e.bottom+i,menuLeft:e.left+r,menuWidth:e.width+r+s})},highlightItemFromMouse:function(t){this.setState({highlightedIndex:t})},selectItemFromMouse:function(t){var e=this,n=this.props.getItemValue(t);this.setIgnoreBlur(!1),this.setState({isOpen:!1,highlightedIndex:null},function(){e.props.onSelect(n,t)})},setIgnoreBlur:function(t){this._ignoreBlur=t},renderMenu:function(){var t=this,e=this.getFilteredItems().map(function(e,n){var o=t.props.renderItem(e,t.state.highlightedIndex===n,{cursor:"default"});return i.cloneElement(o,{onMouseEnter:function(){return t.highlightItemFromMouse(n)},onClick:function(){return t.selectItemFromMouse(e)},ref:function(e){return t.refs["item-"+n]=e}})}),n={left:this.state.menuLeft,top:this.state.menuTop,minWidth:this.state.menuWidth},o=this.props.renderMenu(e,this.props.value,n);return i.cloneElement(o,{ref:function(e){return t.refs.menu=e},onMouseEnter:function(){return t.setIgnoreBlur(!0)},onMouseLeave:function(){return t.setIgnoreBlur(!1)}})},handleInputBlur:function(t){if(this._ignoreBlur)return void this.refs.input.focus();this.setState({isOpen:!1,highlightedIndex:null});var e=this.props.inputProps.onBlur;e&&e(t)},handleInputFocus:function(t){if(!this._ignoreBlur){this.setState({isOpen:!0});var e=this.props.inputProps.onFocus;e&&e(t)}},isInputFocused:function(){var t=this.refs.input;return t.ownerDocument&&t===t.ownerDocument.activeElement},handleInputClick:function(){this.isInputFocused()&&!this.isOpen()&&this.setState({isOpen:!0})},composeEventHandlers:function(t,e){return e?function(n){t(n),e(n)}:t},isOpen:function(){return"open"in this.props?this.props.open:this.state.isOpen},render:function(){this.props.debug&&p.push({id:p.length,state:this.state});var t=this.props.inputProps,e=this.isOpen();return i.createElement("div",o({style:o({},this.props.wrapperStyle)},this.props.wrapperProps),i.createElement("input",o({},t,{role:"combobox","aria-autocomplete":"list","aria-expanded":e,autoComplete:"off",ref:this.exposeAPI,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onChange:this.handleChange,onKeyDown:this.composeEventHandlers(this.handleKeyDown,t.onKeyDown),onKeyUp:this.composeEventHandlers(this.handleKeyUp,t.onKeyUp),onClick:this.composeEventHandlers(this.handleInputClick,t.onClick),value:this.props.value})),e&&this.renderMenu(),this.props.debug&&i.createElement("pre",{style:{marginLeft:300}},JSON.stringify(p.slice(p.length-5,p.length),null,2)))}});e.exports=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"dom-scroll-into-view":2,react:"react","react-dom":"react-dom"}],2:[function(t,e,n){e.exports=t("./lib/dom-scroll-into-view")},{"./lib/dom-scroll-into-view":3}],3:[function(t,e,n){function o(t,e,n){n=n||{},9===e.nodeType&&(e=i.getWindow(e));var o=n.allowHorizontalScroll,r=n.onlyScrollIfNeeded,s=n.alignWithTop,l=n.alignWithLeft;o=void 0===o||o;var u,p,f,h,a,c,d,m,g,v,y=i.isWindow(e),w=i.offset(t),I=i.outerHeight(t),b=i.outerWidth(t);y?(d=e,v=i.height(d),g=i.width(d),m={left:i.scrollLeft(d),top:i.scrollTop(d)},a={left:w.left-m.left,top:w.top-m.top},c={left:w.left+b-(m.left+g),top:w.top+I-(m.top+v)},h=m):(u=i.offset(e),p=e.clientHeight,f=e.clientWidth,h={left:e.scrollLeft,top:e.scrollTop},a={left:w.left-(u.left+(parseFloat(i.css(e,"borderLeftWidth"))||0)),top:w.top-(u.top+(parseFloat(i.css(e,"borderTopWidth"))||0))},c={left:w.left+b-(u.left+f+(parseFloat(i.css(e,"borderRightWidth"))||0)),top:w.top+I-(u.top+p+(parseFloat(i.css(e,"borderBottomWidth"))||0))}),a.top<0||c.top>0?s===!0?i.scrollTop(e,h.top+a.top):s===!1?i.scrollTop(e,h.top+c.top):a.top<0?i.scrollTop(e,h.top+a.top):i.scrollTop(e,h.top+c.top):r||(s=void 0===s||!!s,s?i.scrollTop(e,h.top+a.top):i.scrollTop(e,h.top+c.top)),o&&(a.left<0||c.left>0?l===!0?i.scrollLeft(e,h.left+a.left):l===!1?i.scrollLeft(e,h.left+c.left):a.left<0?i.scrollLeft(e,h.left+a.left):i.scrollLeft(e,h.left+c.left):r||(l=void 0===l||!!l,l?i.scrollLeft(e,h.left+a.left):i.scrollLeft(e,h.left+c.left)))}var i=t("./util");e.exports=o},{"./util":4}],4:[function(t,e,n){function o(t){var e,n,o,i=t.ownerDocument,r=i.body,s=i&&i.documentElement;return e=t.getBoundingClientRect(),n=e.left,o=e.top,n-=s.clientLeft||r.clientLeft||0,o-=s.clientTop||r.clientTop||0,{left:n,top:o}}function i(t,e){var n=t["page"+(e?"Y":"X")+"Offset"],o="scroll"+(e?"Top":"Left");if("number"!=typeof n){var i=t.document;n=i.documentElement[o],"number"!=typeof n&&(n=i.body[o])}return n}function r(t){return i(t)}function s(t){return i(t,!0)}function l(t){var e=o(t),n=t.ownerDocument,i=n.defaultView||n.parentWindow;return e.left+=r(i),e.top+=s(i),e}function u(t,e,n){var o="",i=t.ownerDocument;return(n=n||i.defaultView.getComputedStyle(t,null))&&(o=n.getPropertyValue(e)||n[e]),o}function p(t,e){var n=t[S]&&t[S][e];if(x.test(n)&&!O.test(e)){var o=t.style,i=o[T],r=t[C][T];t[C][T]=t[S][T],o[T]="fontSize"===e?"1em":n||0,n=o.pixelLeft+L,o[T]=i,t[C][T]=r}return""===n?"auto":n}function f(t,e){"static"===y(t,"position")&&(t.style.position="relative");var n,o,i=l(t),r={};for(o in e)n=parseFloat(y(t,o))||0,r[o]=n+e[o]-i[o];y(t,r)}function h(t,e){for(var n=0;n<t.length;n++)e(t[n])}function a(t){return"border-box"===I(t,"boxSizing")}function c(t,e,n){var o,i={},r=t.style;for(o in e)i[o]=r[o],r[o]=e[o];n.call(t);for(o in e)r[o]=i[o]}function d(t,e,n){var o,i,r,s=0;for(i=0;i<e.length;i++)if(o=e[i])for(r=0;r<n.length;r++){var l;l="border"===o?o+n[r]+"Width":o+n[r],s+=parseFloat(I(t,l))||0}return s}function m(t){return null!=t&&t==t.window}function g(t,e,n){if(m(t))return"width"===e?R.viewportWidth(t):R.viewportHeight(t);if(9===t.nodeType)return"width"===e?R.docWidth(t):R.docHeight(t);var o="width"===e?["Left","Right"]:["Top","Bottom"],i="width"===e?t.offsetWidth:t.offsetHeight,r=I(t),s=a(t,r),l=0;(null==i||i<=0)&&(i=void 0,l=I(t,e),(null==l||Number(l)<0)&&(l=t.style[e]||0),l=parseFloat(l)||0),void 0===n&&(n=s?W:E);var u=void 0!==i||s,p=i||l;return n===E?u?p-d(t,["border","padding"],o,r):l:u?p+(n===W?0:n===M?-d(t,["border"],o,r):d(t,["margin"],o,r)):l+d(t,D.slice(n),o,r)}function v(t){var e,n=arguments;return 0!==t.offsetWidth?e=g.apply(void 0,n):c(t,U,function(){e=g.apply(void 0,n)}),e}function y(t,e,n){if("object"!=typeof e)return"undefined"==typeof n?I(t,e):("number"==typeof n&&(n+="px"),void(t.style[e]=n));for(var o in e)y(t,o,e[o])}function w(t,e){for(var n in e)t[n]=e[n];return t}var I,b=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,x=new RegExp("^("+b+")(?!px)[a-z%]+$","i"),O=/^(top|right|bottom|left)$/,S="currentStyle",C="runtimeStyle",T="left",L="px";"undefined"!=typeof window&&(I=window.getComputedStyle?u:p);var D=["margin","border","padding"],E=-1,M=2,W=1,F=0,R={};h(["Width","Height"],function(t){R["doc"+t]=function(e){var n=e.document;return Math.max(n.documentElement["scroll"+t],n.body["scroll"+t],R["viewport"+t](n))},R["viewport"+t]=function(e){var n="client"+t,o=e.document,i=o.body,r=o.documentElement,s=r[n];return"CSS1Compat"===o.compatMode&&s||i&&i[n]||s}});var U={position:"absolute",visibility:"hidden",display:"block"};h(["width","height"],function(t){var e=t.charAt(0).toUpperCase()+t.slice(1);R["outer"+e]=function(e,n){return e&&v(e,t,n?F:W)};var n="width"===t?["Left","Right"]:["Top","Bottom"];R[t]=function(e,o){if(void 0===o)return e&&v(e,t,E);if(e){var i=I(e),r=a(e);return r&&(o+=d(e,["padding","border"],n,i)),y(e,t,o)}}});var A=e.exports={getWindow:function(t){var e=t.ownerDocument||t;return e.defaultView||e.parentWindow},offset:function(t,e){return"undefined"==typeof e?l(t):void f(t,e)},isWindow:m,each:h,css:y,clone:function(t){var e={};for(var n in t)e[n]=t[n];var o=t.overflow;if(o)for(n in t)e.overflow[n]=t.overflow[n];return e},mix:w,scrollLeft:function(t,e){if(m(t)){if(void 0===e)return r(t);window.scrollTo(e,s(t))}else{if(void 0===e)return t.scrollLeft;t.scrollLeft=e}},scrollTop:function(t,e){if(m(t)){if(void 0===e)return s(t);window.scrollTo(r(t),e)}else{if(void 0===e)return t.scrollTop;t.scrollTop=e}},merge:function(){for(var t={},e=0;e<arguments.length;e++)A.mix(t,arguments[e]);return t},viewportWidth:0,viewportHeight:0};w(A,R)},{}]},{},[1])(1)}(function(n){if("react"===n)return t;if("react-dom"===n)return e;if("undefined"!=typeof require)return require(n);var o=new Error("Cannot find module '"+n+"'");throw o.code="MODULE_NOT_FOUND",o})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],e):t.ReactAutocomplete=e(t.React,t.ReactDOM)}(this,function(t,e){return function(t){return function e(n,o,i){function r(l,u){if(!o[l]){if(!n[l]){var p="function"==typeof t&&t;if(!u&&p)return p(l,!0);if(s)return s(l,!0);var f=new Error("Cannot find module '"+l+"'");throw f.code="MODULE_NOT_FOUND",f}var h=o[l]={exports:{}};n[l][0].call(h.exports,function(t){var e=n[l][1][t];return r(e?e:t)},h,h.exports,e,n,o,i)}return o[l].exports}for(var s="function"==typeof t&&t,l=0;l<i.length;l++)r(i[l]);return r}({1:[function(t,e,n){(function(n){"use strict";var o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},i=t("react"),r=i.PropTypes,s=t("react-dom"),l=s.findDOMNode,u=t("dom-scroll-into-view"),p=[],f=["blur","checkValidity","click","focus","select","setCustomValidity","setSelectionRange","setRangeText"],h=i.createClass({displayName:"Autocomplete",propTypes:{items:r.array.isRequired,value:r.any,onChange:r.func,onSelect:r.func,shouldItemRender:r.func,sortItems:r.func,getItemValue:r.func.isRequired,renderItem:r.func.isRequired,renderMenu:r.func,menuStyle:r.object,inputProps:r.object,wrapperProps:r.object,wrapperStyle:r.object,autoHighlight:r.bool,onMenuVisibilityChange:r.func,open:r.bool,debug:r.bool},getDefaultProps:function(){return{value:"",wrapperProps:{},wrapperStyle:{display:"inline-block"},inputProps:{},onChange:function(){},onSelect:function(){},renderMenu:function(t,e,n){return i.createElement("div",{style:o({},n,this.menuStyle),children:t})},menuStyle:{borderRadius:"3px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.9)",padding:"2px 0",fontSize:"90%",position:"fixed",overflow:"auto",maxHeight:"50%"},autoHighlight:!0,onMenuVisibilityChange:function(){}}},getInitialState:function(){return{isOpen:!1,highlightedIndex:null}},componentWillMount:function(){this.refs={},this._ignoreBlur=!1,this._performAutoCompleteOnUpdate=!1,this._performAutoCompleteOnKeyUp=!1},componentWillReceiveProps:function(t){this._performAutoCompleteOnUpdate=!0,(this.props.items!==t.items||this.state.highlightedIndex>=t.items.length)&&this.setState({highlightedIndex:null})},componentDidMount:function(){this.isOpen()&&this.setMenuPositions()},componentDidUpdate:function(t,e){(this.state.isOpen&&!e.isOpen||"open"in this.props&&this.props.open&&!t.open)&&this.setMenuPositions(),this.isOpen()&&this._performAutoCompleteOnUpdate&&(this._performAutoCompleteOnUpdate=!1,this.maybeAutoCompleteText()),this.maybeScrollItemIntoView(),e.isOpen!==this.state.isOpen&&this.props.onMenuVisibilityChange(this.state.isOpen),this._ignoreBlur&&this.refs.input.focus()},exposeAPI:function(t){var e=this;this.refs.input=t,f.forEach(function(n){return e[n]=t&&t[n]&&t[n].bind(t)})},maybeScrollItemIntoView:function(){if(this.isOpen()&&null!==this.state.highlightedIndex){var t=this.refs["item-"+this.state.highlightedIndex],e=this.refs.menu;t&&u(l(t),l(e),{onlyScrollIfNeeded:!0})}},handleKeyDown:function(t){this.keyDownHandlers[t.key]?this.keyDownHandlers[t.key].call(this,t):this.isOpen()||this.setState({isOpen:!0})},handleChange:function(t){this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:null}),this.props.onChange(t,t.target.value)},handleKeyUp:function(){this._performAutoCompleteOnKeyUp&&(this._performAutoCompleteOnKeyUp=!1,this.maybeAutoCompleteText())},keyDownHandlers:{ArrowDown:function(t){t.preventDefault();var e=this.getFilteredItems().length;if(e){var n=this.state.highlightedIndex,o=null===n||n===e-1?0:n+1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:o,isOpen:!0})}},ArrowUp:function(t){t.preventDefault();var e=this.getFilteredItems().length;if(e){var n=this.state.highlightedIndex,o=0===n||null===n?e-1:n-1;this._performAutoCompleteOnKeyUp=!0,this.setState({highlightedIndex:o,isOpen:!0})}},Enter:function(t){var e=this;if(this.isOpen())if(null==this.state.highlightedIndex)this.setState({isOpen:!1},function(){e.refs.input.select()});else{t.preventDefault();var n=this.getFilteredItems()[this.state.highlightedIndex],o=this.props.getItemValue(n);this.setState({isOpen:!1,highlightedIndex:null},function(){e.refs.input.setSelectionRange(o.length,o.length),e.props.onSelect(o,n)})}},Escape:function(){this.setIgnoreBlur(!1),this.setState({highlightedIndex:null,isOpen:!1})},Tab:function(){this.setIgnoreBlur(!1)}},getFilteredItems:function(){var t=this,e=this.props.items;return this.props.shouldItemRender&&(e=e.filter(function(e){return t.props.shouldItemRender(e,t.props.value)})),this.props.sortItems&&e.sort(function(e,n){return t.props.sortItems(e,n,t.props.value)}),e},maybeAutoCompleteText:function(){if(this.props.autoHighlight&&""!==this.props.value){var t=this.state.highlightedIndex,e=this.getFilteredItems();if(0!==e.length){var n=null!==t?e[t]:e[0],o=this.props.getItemValue(n),i=0===o.toLowerCase().indexOf(this.props.value.toLowerCase());i&&null===t&&this.setState({highlightedIndex:0})}}},setMenuPositions:function(){var t=this.refs.input,e=t.getBoundingClientRect(),o=n.window.getComputedStyle(t),i=parseInt(o.marginBottom,10)||0,r=parseInt(o.marginLeft,10)||0,s=parseInt(o.marginRight,10)||0;this.setState({menuTop:e.bottom+i,menuLeft:e.left+r,menuWidth:e.width+r+s})},highlightItemFromMouse:function(t){this.setState({highlightedIndex:t})},selectItemFromMouse:function(t){var e=this,n=this.props.getItemValue(t);this.setState({isOpen:!1,highlightedIndex:null},function(){e.setIgnoreBlur(!1),e.props.onSelect(n,t)})},setIgnoreBlur:function(t){this._ignoreBlur=t},renderMenu:function(){var t=this,e=this.getFilteredItems().map(function(e,n){var o=t.props.renderItem(e,t.state.highlightedIndex===n,{cursor:"default"});return i.cloneElement(o,{onMouseEnter:function(){return t.highlightItemFromMouse(n)},onClick:function(){return t.selectItemFromMouse(e)},ref:function(e){return t.refs["item-"+n]=e}})}),n={left:this.state.menuLeft,top:this.state.menuTop,minWidth:this.state.menuWidth},o=this.props.renderMenu(e,this.props.value,n);return i.cloneElement(o,{ref:function(e){return t.refs.menu=e},onMouseEnter:function(){return t.setIgnoreBlur(!0)},onMouseLeave:function(){return t.setIgnoreBlur(!1)}})},handleInputBlur:function(t){if(!this._ignoreBlur){this.setState({isOpen:!1,highlightedIndex:null});var e=this.props.inputProps.onBlur;e&&e(t)}},handleInputFocus:function(t){if(!this._ignoreBlur){this.setState({isOpen:!0});var e=this.props.inputProps.onFocus;e&&e(t)}},isInputFocused:function(){var t=this.refs.input;return t.ownerDocument&&t===t.ownerDocument.activeElement},handleInputClick:function(){this.isInputFocused()&&!this.isOpen()&&this.setState({isOpen:!0})},composeEventHandlers:function(t,e){return e?function(n){t(n),e(n)}:t},isOpen:function(){return"open"in this.props?this.props.open:this.state.isOpen},render:function(){this.props.debug&&p.push({id:p.length,state:this.state});var t=this.props.inputProps,e=this.isOpen();return i.createElement("div",o({style:o({},this.props.wrapperStyle)},this.props.wrapperProps),i.createElement("input",o({},t,{role:"combobox","aria-autocomplete":"list","aria-expanded":e,autoComplete:"off",ref:this.exposeAPI,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onChange:this.handleChange,onKeyDown:this.composeEventHandlers(this.handleKeyDown,t.onKeyDown),onKeyUp:this.composeEventHandlers(this.handleKeyUp,t.onKeyUp),onClick:this.composeEventHandlers(this.handleInputClick,t.onClick),value:this.props.value})),e&&this.renderMenu(),this.props.debug&&i.createElement("pre",{style:{marginLeft:300}},JSON.stringify(p.slice(p.length-5,p.length),null,2)))}});e.exports=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"dom-scroll-into-view":2,react:"react","react-dom":"react-dom"}],2:[function(t,e,n){e.exports=t("./lib/dom-scroll-into-view")},{"./lib/dom-scroll-into-view":3}],3:[function(t,e,n){function o(t,e,n){n=n||{},9===e.nodeType&&(e=i.getWindow(e));var o=n.allowHorizontalScroll,r=n.onlyScrollIfNeeded,s=n.alignWithTop,l=n.alignWithLeft;o=void 0===o||o;var u,p,f,h,a,c,d,m,g,v,y=i.isWindow(e),w=i.offset(t),I=i.outerHeight(t),b=i.outerWidth(t);y?(d=e,v=i.height(d),g=i.width(d),m={left:i.scrollLeft(d),top:i.scrollTop(d)},a={left:w.left-m.left,top:w.top-m.top},c={left:w.left+b-(m.left+g),top:w.top+I-(m.top+v)},h=m):(u=i.offset(e),p=e.clientHeight,f=e.clientWidth,h={left:e.scrollLeft,top:e.scrollTop},a={left:w.left-(u.left+(parseFloat(i.css(e,"borderLeftWidth"))||0)),top:w.top-(u.top+(parseFloat(i.css(e,"borderTopWidth"))||0))},c={left:w.left+b-(u.left+f+(parseFloat(i.css(e,"borderRightWidth"))||0)),top:w.top+I-(u.top+p+(parseFloat(i.css(e,"borderBottomWidth"))||0))}),a.top<0||c.top>0?s===!0?i.scrollTop(e,h.top+a.top):s===!1?i.scrollTop(e,h.top+c.top):a.top<0?i.scrollTop(e,h.top+a.top):i.scrollTop(e,h.top+c.top):r||(s=void 0===s||!!s,s?i.scrollTop(e,h.top+a.top):i.scrollTop(e,h.top+c.top)),o&&(a.left<0||c.left>0?l===!0?i.scrollLeft(e,h.left+a.left):l===!1?i.scrollLeft(e,h.left+c.left):a.left<0?i.scrollLeft(e,h.left+a.left):i.scrollLeft(e,h.left+c.left):r||(l=void 0===l||!!l,l?i.scrollLeft(e,h.left+a.left):i.scrollLeft(e,h.left+c.left)))}var i=t("./util");e.exports=o},{"./util":4}],4:[function(t,e,n){function o(t){var e,n,o,i=t.ownerDocument,r=i.body,s=i&&i.documentElement;return e=t.getBoundingClientRect(),n=e.left,o=e.top,n-=s.clientLeft||r.clientLeft||0,o-=s.clientTop||r.clientTop||0,{left:n,top:o}}function i(t,e){var n=t["page"+(e?"Y":"X")+"Offset"],o="scroll"+(e?"Top":"Left");if("number"!=typeof n){var i=t.document;n=i.documentElement[o],"number"!=typeof n&&(n=i.body[o])}return n}function r(t){return i(t)}function s(t){return i(t,!0)}function l(t){var e=o(t),n=t.ownerDocument,i=n.defaultView||n.parentWindow;return e.left+=r(i),e.top+=s(i),e}function u(t,e,n){var o="",i=t.ownerDocument;return(n=n||i.defaultView.getComputedStyle(t,null))&&(o=n.getPropertyValue(e)||n[e]),o}function p(t,e){var n=t[S]&&t[S][e];if(x.test(n)&&!O.test(e)){var o=t.style,i=o[T],r=t[C][T];t[C][T]=t[S][T],o[T]="fontSize"===e?"1em":n||0,n=o.pixelLeft+L,o[T]=i,t[C][T]=r}return""===n?"auto":n}function f(t,e){"static"===y(t,"position")&&(t.style.position="relative");var n,o,i=l(t),r={};for(o in e)n=parseFloat(y(t,o))||0,r[o]=n+e[o]-i[o];y(t,r)}function h(t,e){for(var n=0;n<t.length;n++)e(t[n])}function a(t){return"border-box"===I(t,"boxSizing")}function c(t,e,n){var o,i={},r=t.style;for(o in e)i[o]=r[o],r[o]=e[o];n.call(t);for(o in e)r[o]=i[o]}function d(t,e,n){var o,i,r,s=0;for(i=0;i<e.length;i++)if(o=e[i])for(r=0;r<n.length;r++){var l;l="border"===o?o+n[r]+"Width":o+n[r],s+=parseFloat(I(t,l))||0}return s}function m(t){return null!=t&&t==t.window}function g(t,e,n){if(m(t))return"width"===e?B.viewportWidth(t):B.viewportHeight(t);if(9===t.nodeType)return"width"===e?B.docWidth(t):B.docHeight(t);var o="width"===e?["Left","Right"]:["Top","Bottom"],i="width"===e?t.offsetWidth:t.offsetHeight,r=I(t),s=a(t,r),l=0;(null==i||i<=0)&&(i=void 0,l=I(t,e),(null==l||Number(l)<0)&&(l=t.style[e]||0),l=parseFloat(l)||0),void 0===n&&(n=s?W:E);var u=void 0!==i||s,p=i||l;return n===E?u?p-d(t,["border","padding"],o,r):l:u?p+(n===W?0:n===M?-d(t,["border"],o,r):d(t,["margin"],o,r)):l+d(t,D.slice(n),o,r)}function v(t){var e,n=arguments;return 0!==t.offsetWidth?e=g.apply(void 0,n):c(t,R,function(){e=g.apply(void 0,n)}),e}function y(t,e,n){if("object"!=typeof e)return"undefined"==typeof n?I(t,e):("number"==typeof n&&(n+="px"),void(t.style[e]=n));for(var o in e)y(t,o,e[o])}function w(t,e){for(var n in e)t[n]=e[n];return t}var I,b=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,x=new RegExp("^("+b+")(?!px)[a-z%]+$","i"),O=/^(top|right|bottom|left)$/,S="currentStyle",C="runtimeStyle",T="left",L="px";"undefined"!=typeof window&&(I=window.getComputedStyle?u:p);var D=["margin","border","padding"],E=-1,M=2,W=1,F=0,B={};h(["Width","Height"],function(t){B["doc"+t]=function(e){var n=e.document;return Math.max(n.documentElement["scroll"+t],n.body["scroll"+t],B["viewport"+t](n))},B["viewport"+t]=function(e){var n="client"+t,o=e.document,i=o.body,r=o.documentElement,s=r[n];return"CSS1Compat"===o.compatMode&&s||i&&i[n]||s}});var R={position:"absolute",visibility:"hidden",display:"block"};h(["width","height"],function(t){var e=t.charAt(0).toUpperCase()+t.slice(1);B["outer"+e]=function(e,n){return e&&v(e,t,n?F:W)};var n="width"===t?["Left","Right"]:["Top","Bottom"];B[t]=function(e,o){if(void 0===o)return e&&v(e,t,E);if(e){var i=I(e),r=a(e);return r&&(o+=d(e,["padding","border"],n,i)),y(e,t,o)}}});var U=e.exports={getWindow:function(t){var e=t.ownerDocument||t;return e.defaultView||e.parentWindow},offset:function(t,e){return"undefined"==typeof e?l(t):void f(t,e)},isWindow:m,each:h,css:y,clone:function(t){var e={};for(var n in t)e[n]=t[n];var o=t.overflow;if(o)for(n in t)e.overflow[n]=t.overflow[n];return e},mix:w,scrollLeft:function(t,e){if(m(t)){if(void 0===e)return r(t);window.scrollTo(e,s(t))}else{if(void 0===e)return t.scrollLeft;t.scrollLeft=e}},scrollTop:function(t,e){if(m(t)){if(void 0===e)return s(t);window.scrollTo(r(t),e)}else{if(void 0===e)return t.scrollTop;t.scrollTop=e}},merge:function(){for(var t={},e=0;e<arguments.length;e++)U.mix(t,arguments[e]);return t},viewportWidth:0,viewportHeight:0};w(U,B)},{}]},{},[1])(1)}(function(n){if("react"===n)return t;if("react-dom"===n)return e;if("undefined"!=typeof require)return require(n);var o=new Error("Cannot find module '"+n+"'");throw o.code="MODULE_NOT_FOUND",o})});
//# sourceMappingURL=react-autocomplete.min.js.map
{
"name": "react-autocomplete",
"version": "1.5.3",
"version": "1.5.4",
"description": "Accessible, extensible, Autocomplete for React.js",

@@ -5,0 +5,0 @@ "main": "./build/lib/Autocomplete.js",

@@ -23,4 +23,4 @@ # React Autocomplete [![Travis build status](https://travis-ci.org/reactjs/react-autocomplete.svg?branch=master)](https://travis-ci.org/reactjs/react-autocomplete/)

* Development: [https://unpkg.com/react-autocomplete@1.5.2/dist/react-autocomplete.js](https://unpkg.com/react-autocomplete@1.5.2/dist/react-autocomplete.js)
* Production: [https://unpkg.com/react-autocomplete@1.5.2/dist/react-autocomplete.min.js](https://unpkg.com/react-autocomplete@1.5.2/dist/react-autocomplete.min.js)
* Development: [https://unpkg.com/react-autocomplete@1.5.3/dist/react-autocomplete.js](https://unpkg.com/react-autocomplete@1.5.3/dist/react-autocomplete.js)
* Production: [https://unpkg.com/react-autocomplete@1.5.3/dist/react-autocomplete.min.js](https://unpkg.com/react-autocomplete@1.5.3/dist/react-autocomplete.min.js)

@@ -27,0 +27,0 @@ ## API

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc