react-autocomplete-input
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -0,1 +1,4 @@ | ||
### 9th March 2021 - 1.0.16 | ||
- Props to LazaroHurtado, now library supports several sets of triggers and options simultaneously (https://github.com/yury-dymov/react-autocomplete-input/pull/54) | ||
### 2nd December 2020 - 1.0.15 | ||
@@ -2,0 +5,0 @@ - Introduced new `onSelect` callback — (https://github.com/yury-dymov/react-autocomplete-input/pull/53) |
@@ -1,1 +0,1 @@ | ||
module.exports=(()=>{"use strict";var e={353:(e,t,n)=>{n.r(t),n.d(t,{default:()=>w});const r=require("react");var o=n.n(r);const i=require("prop-types");var a=n.n(i);const s=require("textarea-caret");var l=n.n(s);const u=require("get-input-selection");var c=n.n(u);function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function b(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){return!t||"object"!==g(t)&&"function"!=typeof t?y(e):t}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var O={Component:a().oneOfType([a().string,a().elementType]),defaultValue:a().string,disabled:a().bool,maxOptions:a().number,onBlur:a().func,onChange:a().func,onKeyDown:a().func,onRequestOptions:a().func,onSelect:a().func,options:a().arrayOf(a().string),regex:a().string,matchAny:a().bool,minChars:a().number,requestOnlyIfNoOptions:a().bool,spaceRemovers:a().arrayOf(a().string),spacer:a().string,trigger:a().string,value:a().string,offsetX:a().number,offsetY:a().number,passThroughEnter:a().bool},S=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(O,e);var t,n,i,a,s=(i=O,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=m(i);if(a){var n=m(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return d(this,e)});function O(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,O),(t=s.call(this,e)).isTrigger=t.isTrigger.bind(y(t)),t.getMatch=t.getMatch.bind(y(t)),t.handleChange=t.handleChange.bind(y(t)),t.handleKeyDown=t.handleKeyDown.bind(y(t)),t.handleResize=t.handleResize.bind(y(t)),t.handleSelection=t.handleSelection.bind(y(t)),t.updateCaretPosition=t.updateCaretPosition.bind(y(t)),t.updateHelper=t.updateHelper.bind(y(t)),t.resetHelper=t.resetHelper.bind(y(t)),t.renderAutocompleteList=t.renderAutocompleteList.bind(y(t)),t.state={helperVisible:!1,left:0,matchLength:0,matchStart:0,options:[],selection:0,top:0,value:null},t.recentValue=e.defaultValue,t.enableSpaceRemovers=!1,t.refInput=(0,r.createRef)(),t}return t=O,(n=[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function(e){var t=this.props.options,n=this.state.caret;t.length!==e.options.length&&this.updateHelper(this.recentValue,n,t)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize)}},{key:"getMatch",value:function(e,t,n){for(var r=this.props,o=r.trigger,i=r.matchAny,a=r.regex,s=new RegExp(a),l=o.length,u=o.match(s),c=t-1;c>=0;--c){var p=e.substring(c,t).match(s),f=-1;if(l>0){var h=u?c:c-l+1;if(h<0)return null;if(this.isTrigger(e,h)&&(f=h+l),!p&&f<0)return null}else{if(p&&c>0)continue;if(t-(f=0===c&&p?0:c+1)==0)return null}if(f>=0){var b=function(){var r=e.substring(f,t),o=n.filter((function(e){var t=e.toLowerCase().indexOf(r.toLowerCase());return-1!==t&&(i||0===t)})),a=r.length;return{v:{matchStart:f,matchLength:a,options:o}}}();if("object"===g(b))return b.v}}return null}},{key:"isTrigger",value:function(e,t){var n=this.props.trigger;return!n||!n.length||e.substr(t,n.length)===n}},{key:"handleChange",value:function(e){var t=this.props,n=t.onChange,r=t.options,o=t.spaceRemovers,i=t.spacer,a=t.value,s=this.recentValue,l=e.target.value,u=c()(e.target).end;if(l.length||this.setState({helperVisible:!1}),this.recentValue=l,this.setState({caret:u,value:e.target.value}),!l.length||!u)return n(e.target.value);if(this.enableSpaceRemovers&&o.length&&l.length>2&&i.length){for(var p=0;p<Math.max(s.length,l.length);++p)if(s[p]!==l[p]){if(p>=2&&l[p-1]===i&&-1===o.indexOf(l[p-2])&&-1!==o.indexOf(l[p])&&this.getMatch(l.substring(0,p-2),u-3,r)){var f="".concat(l.slice(0,p-1)).concat(l.slice(p,p+1)).concat(l.slice(p-1,p)).concat(l.slice(p+1));return this.updateCaretPosition(p+1),this.refInput.current.value=f,a||this.setState({value:f}),n(f)}break}this.enableSpaceRemovers=!1}return this.updateHelper(l,u,r),a||this.setState({value:e.target.value}),n(e.target.value)}},{key:"handleKeyDown",value:function(e){var t=this.state,n=t.helperVisible,r=t.options,o=t.selection,i=this.props,a=i.onKeyDown,s=i.passThroughEnter;if(n)switch(e.keyCode){case 27:e.preventDefault(),this.resetHelper();break;case 38:e.preventDefault(),this.setState({selection:(r.length+o-1)%r.length});break;case 40:e.preventDefault(),this.setState({selection:(o+1)%r.length});break;case 14:case 13:s||e.preventDefault(),this.handleSelection(o);break;case 9:this.handleSelection(o);break;default:a(e)}else a(e)}},{key:"handleResize",value:function(){this.setState({helperVisible:!1})}},{key:"handleSelection",value:function(e){var t=this.state,n=t.matchStart,r=t.matchLength,o=t.options,i=this.props,a=i.spacer,s=i.onSelect,l=o[e],u=this.recentValue,c=u.substring(0,n),p=u.substring(n+r),f={target:this.refInput.current};f.target.value="".concat(c).concat(l).concat(a).concat(p),this.handleChange(f),s(f.target.value),this.resetHelper(),this.updateCaretPosition(c.length+l.length+1),this.enableSpaceRemovers=!0}},{key:"updateCaretPosition",value:function(e){var t=this;this.setState({caret:e},(function(){return(0,u.setCaretPosition)(t.refInput.current,e)}))}},{key:"updateHelper",value:function(e,t,n){var r=this.refInput.current,o=this.getMatch(e,t,n);if(o){var i=l()(r,t),a=r.getBoundingClientRect(),s=i.top+r.offsetTop,u=Math.min(i.left+r.offsetLeft-10,r.offsetLeft+a.width-100),c=this.props,p=c.minChars,g=c.onRequestOptions,b=c.requestOnlyIfNoOptions;o.matchLength>=p&&(o.options.length>1||1===o.options.length&&o.options[0].length!==o.matchLength)?this.setState(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({helperVisible:!0,top:s,left:u},o)):(b&&o.options.length||g(e.substr(o.matchStart,o.matchLength)),this.resetHelper())}else this.resetHelper()}},{key:"resetHelper",value:function(){this.setState({helperVisible:!1,selection:0})}},{key:"renderAutocompleteList",value:function(){var e=this,t=this.state,n=t.helperVisible,r=t.left,i=t.matchStart,a=t.matchLength,s=t.options,l=t.selection,u=t.top,c=t.value;if(!n)return null;var p=this.props,f=p.maxOptions,h=p.offsetX,g=p.offsetY;if(0===s.length)return null;if(l>=s.length)return this.setState({selection:0}),null;var b=0===f?s.length:f,v=s.slice(0,b).map((function(t,n){var r=t.toLowerCase().indexOf(c.substr(i,a).toLowerCase());return o().createElement("li",{className:n===l?"active":null,key:t,onClick:function(){e.handleSelection(n)},onMouseEnter:function(){e.setState({selection:n})}},t.slice(0,r),o().createElement("strong",null,t.substr(r,a)),t.slice(r+a))}));return o().createElement("ul",{className:"react-autocomplete-input",style:{left:r+h,top:u+g}},v)}},{key:"render",value:function(){var e=this.props,t=e.Component,n=e.defaultValue,r=e.disabled,i=e.onBlur,a=e.value,s=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,["Component","defaultValue","disabled","onBlur","value"]),l=this.state.value,u=Object.assign({},s);Object.keys(this.constructor.propTypes).forEach((function(e){delete u[e]}));var c="";return null!=a?c=a:l?c=l:n&&(c=n),o().createElement("span",null,o().createElement(t,p({disabled:r,onBlur:i,onChange:this.handleChange,onKeyDown:this.handleKeyDown,ref:this.refInput,value:c},u)),this.renderAutocompleteList())}}])&&b(t.prototype,n),O}(o().Component);S.propTypes=O,S.defaultProps={Component:"textarea",defaultValue:"",disabled:!1,maxOptions:6,onBlur:function(){},onChange:function(){},onKeyDown:function(){},onRequestOptions:function(){},onSelect:function(){},options:[],regex:"^[A-Za-z0-9\\-_]+$",matchAny:!1,minChars:0,requestOnlyIfNoOptions:!0,spaceRemovers:[",",".","!","?"],spacer:" ",trigger:"@",offsetX:0,offsetY:0,value:null,passThroughEnter:!1};const w=S}},t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(353)})(); | ||
module.exports=function(){"use strict";var e={405:function(e,t,r){r.r(t),r.d(t,{default:function(){return w}}),require("core-js/modules/es.array.concat"),require("core-js/modules/es.array.filter"),require("core-js/modules/es.array.for-each"),require("core-js/modules/es.array.index-of"),require("core-js/modules/es.array.map"),require("core-js/modules/es.array.slice"),require("core-js/modules/es.array.sort"),require("core-js/modules/es.object.assign"),require("core-js/modules/es.object.get-prototype-of"),require("core-js/modules/es.object.keys"),require("core-js/modules/es.object.to-string"),require("core-js/modules/es.reflect.construct"),require("core-js/modules/es.regexp.constructor"),require("core-js/modules/es.regexp.exec"),require("core-js/modules/es.regexp.to-string"),require("core-js/modules/es.string.match"),require("core-js/modules/web.dom-collections.for-each");var n=require("react"),o=r.n(n),i=require("prop-types"),a=r.n(i),s=require("textarea-caret"),u=r.n(s),l=require("get-input-selection"),c=r.n(l);function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e,t){return!t||"object"!==f(t)&&"function"!=typeof t?v(e):t}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var j={Component:a().oneOfType([a().string,a().elementType]),defaultValue:a().string,disabled:a().bool,maxOptions:a().number,onBlur:a().func,onChange:a().func,onKeyDown:a().func,onRequestOptions:a().func,onSelect:a().func,options:a().oneOfType([a().object,a().arrayOf(a().string)]),regex:a().string,matchAny:a().bool,minChars:a().number,requestOnlyIfNoOptions:a().bool,spaceRemovers:a().arrayOf(a().string),spacer:a().string,trigger:a().oneOfType([a().string,a().arrayOf(a().string)]),value:a().string,offsetX:a().number,offsetY:a().number,passThroughEnter:a().bool},S=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(f,e);var t,r,i,a,s=(i=f,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=O(i);if(a){var r=O(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return m(this,e)});function f(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,f),(t=s.call(this,e)).isTrigger=t.isTrigger.bind(v(t)),t.arrayTriggerMatch=t.arrayTriggerMatch.bind(v(t)),t.getMatch=t.getMatch.bind(v(t)),t.handleChange=t.handleChange.bind(v(t)),t.handleKeyDown=t.handleKeyDown.bind(v(t)),t.handleResize=t.handleResize.bind(v(t)),t.handleSelection=t.handleSelection.bind(v(t)),t.updateCaretPosition=t.updateCaretPosition.bind(v(t)),t.updateHelper=t.updateHelper.bind(v(t)),t.resetHelper=t.resetHelper.bind(v(t)),t.renderAutocompleteList=t.renderAutocompleteList.bind(v(t)),t.state={helperVisible:!1,left:0,matchLength:0,matchStart:0,options:[],selection:0,top:0,value:null},t.recentValue=e.defaultValue,t.enableSpaceRemovers=!1,t.refInput=(0,n.createRef)(),t}return t=f,(r=[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function(e){var t=this.props.options,r=this.state.caret;t.length!==e.options.length&&this.updateHelper(this.recentValue,r,t)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize)}},{key:"getMatch",value:function(e,t,r){var n=this.props,o=n.trigger,i=n.matchAny,a=n.regex,s=new RegExp(a),u=o;Array.isArray(u)||(u=new Array(o)),u.sort();var l=r;Array.isArray(r)&&u.forEach((function(e){l[e]=r}));for(var c=this.arrayTriggerMatch(u,s),f=null,p=0;p<c.length;p++)for(var h=c[p],d=h.triggerStr,y=h.triggerMatch,b=h.triggerLength,m=t-1;m>=0;--m){var v=e.substring(m,t).match(s),O=-1;if(b>0){var j=y?m:m-b+1;if(j<0)break;if(this.isTrigger(d,e,j)&&(O=j+b),!v&&O<0)break}else{if(v&&m>0)continue;if(t-(O=0===m&&v?0:m+1)==0)break}O>=0&&function(){var r=l[d];if(null==r)return"continue";var n=e.substring(O,t),o=r.filter((function(e){var t=e.toLowerCase().indexOf(n.toLowerCase());return-1!==t&&(i||0===t)})),a=n.length;f=null===f?{matchStart:O,matchLength:a,options:o}:g(g({},f),{},{matchStart:O,matchLength:a,options:o})}()}return f}},{key:"arrayTriggerMatch",value:function(e,t){return e.map((function(e){return{triggerStr:e,triggerMatch:e.match(t),triggerLength:e.length}}))}},{key:"isTrigger",value:function(e,t,r){return!e||!e.length||t.substr(r,e.length)===e}},{key:"handleChange",value:function(e){var t=this.props,r=t.onChange,n=t.options,o=t.spaceRemovers,i=t.spacer,a=t.value,s=this.recentValue,u=e.target.value,l=c()(e.target).end;if(u.length||this.setState({helperVisible:!1}),this.recentValue=u,this.setState({caret:l,value:e.target.value}),!u.length||!l)return r(e.target.value);if(this.enableSpaceRemovers&&o.length&&u.length>2&&i.length){for(var f=0;f<Math.max(s.length,u.length);++f)if(s[f]!==u[f]){if(f>=2&&u[f-1]===i&&-1===o.indexOf(u[f-2])&&-1!==o.indexOf(u[f])&&this.getMatch(u.substring(0,f-2),l-3,n)){var p="".concat(u.slice(0,f-1)).concat(u.slice(f,f+1)).concat(u.slice(f-1,f)).concat(u.slice(f+1));return this.updateCaretPosition(f+1),this.refInput.current.value=p,a||this.setState({value:p}),r(p)}break}this.enableSpaceRemovers=!1}return this.updateHelper(u,l,n),a||this.setState({value:e.target.value}),r(e.target.value)}},{key:"handleKeyDown",value:function(e){var t=this.state,r=t.helperVisible,n=t.options,o=t.selection,i=this.props,a=i.onKeyDown,s=i.passThroughEnter;if(r)switch(e.keyCode){case 27:e.preventDefault(),this.resetHelper();break;case 38:e.preventDefault(),this.setState({selection:(n.length+o-1)%n.length});break;case 40:e.preventDefault(),this.setState({selection:(o+1)%n.length});break;case 14:case 13:s||e.preventDefault(),this.handleSelection(o);break;case 9:this.handleSelection(o);break;default:a(e)}else a(e)}},{key:"handleResize",value:function(){this.setState({helperVisible:!1})}},{key:"handleSelection",value:function(e){var t=this.state,r=t.matchStart,n=t.matchLength,o=t.options,i=this.props,a=i.spacer,s=i.onSelect,u=o[e],l=this.recentValue,c=l.substring(0,r),f=l.substring(r+n),p={target:this.refInput.current};p.target.value="".concat(c).concat(u).concat(a).concat(f),this.handleChange(p),s(p.target.value),this.resetHelper(),this.updateCaretPosition(c.length+u.length+1),this.enableSpaceRemovers=!0}},{key:"updateCaretPosition",value:function(e){var t=this;this.setState({caret:e},(function(){return(0,l.setCaretPosition)(t.refInput.current,e)}))}},{key:"updateHelper",value:function(e,t,r){var n=this.refInput.current,o=this.getMatch(e,t,r);if(o){var i=u()(n,t),a=n.getBoundingClientRect(),s=i.top+n.offsetTop,l=Math.min(i.left+n.offsetLeft-10,n.offsetLeft+a.width-100),c=this.props,f=c.minChars,p=c.onRequestOptions,h=c.requestOnlyIfNoOptions;o.matchLength>=f&&(o.options.length>1||1===o.options.length&&o.options[0].length!==o.matchLength)?this.setState(g({helperVisible:!0,top:s,left:l},o)):(h&&o.options.length||p(e.substr(o.matchStart,o.matchLength)),this.resetHelper())}else this.resetHelper()}},{key:"resetHelper",value:function(){this.setState({helperVisible:!1,selection:0})}},{key:"renderAutocompleteList",value:function(){var e=this,t=this.state,r=t.helperVisible,n=t.left,i=t.matchStart,a=t.matchLength,s=t.options,u=t.selection,l=t.top,c=t.value;if(!r)return null;var f=this.props,p=f.maxOptions,h=f.offsetX,g=f.offsetY;if(0===s.length)return null;if(u>=s.length)return this.setState({selection:0}),null;var d=0===p?s.length:p,y=s.slice(0,d).map((function(t,r){var n=t.toLowerCase().indexOf(c.substr(i,a).toLowerCase());return o().createElement("li",{className:r===u?"active":null,key:t,onClick:function(){e.handleSelection(r)},onMouseEnter:function(){e.setState({selection:r})}},t.slice(0,n),o().createElement("strong",null,t.substr(n,a)),t.slice(n+a))}));return o().createElement("ul",{className:"react-autocomplete-input",style:{left:n+h,top:l+g}},y)}},{key:"render",value:function(){var e=this.props,t=e.Component,r=e.defaultValue,n=e.disabled,i=e.onBlur,a=e.value,s=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["Component","defaultValue","disabled","onBlur","value"]),u=this.state.value,l=Object.assign({},s);Object.keys(j).forEach((function(e){delete l[e]}));var c="";return null!=a?c=a:u?c=u:r&&(c=r),o().createElement("span",null,o().createElement(t,p({disabled:n,onBlur:i,onChange:this.handleChange,onKeyDown:this.handleKeyDown,ref:this.refInput,value:c},l)),this.renderAutocompleteList())}}])&&y(t.prototype,r),f}(o().Component);S.propTypes=j,S.defaultProps={Component:"textarea",defaultValue:"",disabled:!1,maxOptions:6,onBlur:function(){},onChange:function(){},onKeyDown:function(){},onRequestOptions:function(){},onSelect:function(){},options:[],regex:"^[A-Za-z0-9\\-_]+$",matchAny:!1,minChars:0,requestOnlyIfNoOptions:!0,spaceRemovers:[",",".","!","?"],spacer:" ",trigger:"@",offsetX:0,offsetY:0,value:null,passThroughEnter:!1};var w=S}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}return r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(405)}(); |
{ | ||
"name": "react-autocomplete-input", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "Autocomplete input field for React", | ||
@@ -39,2 +39,3 @@ "main": "dist/bundle.js", | ||
"cheerio": "^0.22.0", | ||
"core-js": "3", | ||
"css-loader": "^2.1.0", | ||
@@ -61,3 +62,3 @@ "enzyme": "^3.8.0", | ||
"webpack-cli": "^4.2.0", | ||
"webpack-node-externals": "^1.7.2" | ||
"webpack-node-externals": "^2.5.2" | ||
}, | ||
@@ -72,3 +73,11 @@ "dependencies": { | ||
"react-dom": "*" | ||
} | ||
}, | ||
"browserslist": [ | ||
"edge 16", | ||
"safari 9", | ||
"firefox 57", | ||
"ie 11", | ||
"ios 9", | ||
"chrome 49" | ||
] | ||
} |
@@ -22,2 +22,11 @@ # react-autocomplete-input | ||
# Multiple Triggers and Options Example | ||
```JavaScript | ||
import TextInput from 'react-autocomplete-input'; | ||
import 'react-autocomplete-input/dist/bundle.css'; | ||
<TextField trigger={["@", "@@"]} options={{"@": ["aa", "ab", "abc", "abcd"], "@@": ["az", "ar"]}} /> | ||
``` | ||
Here for trigger `@` first set of options will resolve and for `@@` — second set. | ||
# Features | ||
@@ -24,0 +33,0 @@ * Supports both keyboard and mouse for option selection |
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
87020
151
32