UNPKG

react-dadata-suggestions

Version:

Just another one react component for dadata suggestions

8 lines 34.3 kB
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=require("react")},function(e,t,n){function r(e){if(i[e])return i[e].exports;var t=i[e]={exports:{},id:e,loaded:!1};return o[e].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}var o,i;e.exports=(i={},r.m=o=[function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=(r=n(2))&&r.__esModule?r:{default:r};t.default=o.default,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=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};function o(e){return e&&e.__esModule?e:{default:e}}t.default=c;var i=n(3),u=o(n(4)),a=n(14),s=o(n(15));function c(e){var t=e.activeClassName,n=void 0===t?"":t,o=e.activeIndex,u=void 0===o?-1:o,c=e.activeStyle,l=e.autoEscape,f=e.caseSensitive,p=void 0!==f&&f,h=e.className,d=e.findChunks,g=e.highlightClassName,y=void 0===g?"":g,v=e.highlightStyle,b=void 0===v?{}:v,m=e.highlightTag,O=void 0===m?"mark":m,w=e.sanitize,S=e.searchWords,E=e.textToHighlight,j=e.unhighlightClassName,x=void 0===j?"":j,T=e.unhighlightStyle,_=function(e,t){var n={};for(var r in e)0<=t.indexOf(r)||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["activeClassName","activeIndex","activeStyle","autoEscape","caseSensitive","className","findChunks","highlightClassName","highlightStyle","highlightTag","sanitize","searchWords","textToHighlight","unhighlightClassName","unhighlightStyle"]),P=(0,i.findAll)({autoEscape:l,caseSensitive:p,findChunks:d,sanitize:w,searchWords:S,textToHighlight:E}),k=O,N=-1,C="",R=void 0,D=(0,s.default)((function(e){var t={};for(var n in e)t[n.toLowerCase()]=e[n];return t}));return(0,a.createElement)("span",r({className:h},_,{children:P.map((function(e,t){var r=E.substr(e.start,e.end-e.start);if(e.highlight){N++;var o;o="object"==typeof y?p?y[r]:(y=D(y))[r.toLowerCase()]:y;var i=N===+u;C=o+" "+(i?n:""),R=1==i&&null!=c?Object.assign({},b,c):b;var s={children:r,className:C,key:t,style:R};return"string"!=typeof k&&(s.highlightIndex=N),(0,a.createElement)(k,s)}return(0,a.createElement)("span",{children:r,className:x,key:t,style:T})}))}))}c.propTypes={activeClassName:u.default.string,activeIndex:u.default.number,activeStyle:u.default.object,autoEscape:u.default.bool,className:u.default.string,findChunks:u.default.func,highlightClassName:u.default.oneOfType([u.default.object,u.default.string]),highlightStyle:u.default.object,highlightTag:u.default.oneOfType([u.default.node,u.default.func,u.default.string]),sanitize:u.default.func,searchWords:u.default.arrayOf(u.default.oneOfType([u.default.string,u.default.instanceOf(RegExp)])).isRequired,textToHighlight:u.default.string.isRequired,unhighlightClassName:u.default.string,unhighlightStyle:u.default.object},e.exports=t.default},function(e,t){function n(e){if(o[e])return o[e].exports;var t=o[e]={exports:{},id:e,loaded:!1};return r[e].call(t.exports,t,t.exports,n),t.loaded=!0,t.exports}var r,o;e.exports=(o={},n.m=r=[function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2);Object.defineProperty(t,"combineChunks",{enumerable:!0,get:function(){return r.combineChunks}}),Object.defineProperty(t,"fillInChunks",{enumerable:!0,get:function(){return r.fillInChunks}}),Object.defineProperty(t,"findAll",{enumerable:!0,get:function(){return r.findAll}}),Object.defineProperty(t,"findChunks",{enumerable:!0,get:function(){return r.findChunks}})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findAll=function(e){var t=e.autoEscape,i=e.caseSensitive,u=void 0!==i&&i,a=e.findChunks,s=void 0===a?r:a,c=e.sanitize,l=e.searchWords,f=e.textToHighlight;return o({chunksToHighlight:n({chunks:s({autoEscape:t,caseSensitive:u,sanitize:c,searchWords:l,textToHighlight:f})}),totalLength:f?f.length:0})};var n=t.combineChunks=function(e){var t=e.chunks;return t.sort((function(e,t){return e.start-t.start})).reduce((function(e,t){if(0===e.length)return[t];var n=e.pop();if(t.start<=n.end){var r=Math.max(n.end,t.end);e.push({start:n.start,end:r})}else e.push(n,t);return e}),[])},r=function(e){var t=e.autoEscape,n=e.caseSensitive,r=e.sanitize,o=void 0===r?i:r,u=e.searchWords,a=e.textToHighlight;return a=o(a),u.filter((function(e){return e})).reduce((function(e,r){r=o(r),t&&(r=r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"));for(var i=new RegExp(r,n?"g":"gi"),u=void 0;u=i.exec(a);){var s=u.index,c=i.lastIndex;s<c&&e.push({start:s,end:c}),u.index==i.lastIndex&&i.lastIndex++}return e}),[])};t.findChunks=r;var o=t.fillInChunks=function(e){function t(e,t,n){0<t-e&&o.push({start:e,end:t,highlight:n})}var n=e.chunksToHighlight,r=e.totalLength,o=[];if(0===n.length)t(0,r,!1);else{var i=0;n.forEach((function(e){t(i,e.start,!1),t(e.start,e.end,!0),i=e.end})),t(i,r,!1)}return o};function i(e){return e}}],n.c=o,n.p="",n(0))},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=n(6)((function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}),!0)}else e.exports=n(13)()}).call(t,n(5))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var s,c=[],l=!1,f=-1;function p(){l&&s&&(l=!1,s.length?c=s.concat(c):f=-1,c.length&&h())}function h(){if(!l){var e=a(p);l=!0;for(var t=c.length;t;){for(s=c,c=[];++f<t;)s&&s[f].run();f=-1,t=c.length}s=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new d(e,t)),1!==c.length||l||a(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){(function(t){"use strict";var r=n(7),o=n(8),i=n(9),u=n(10),a=n(11),s=n(12);e.exports=function(e,n){var c="function"==typeof Symbol&&Symbol.iterator,l="<<anonymous>>",f={array:g("array"),bool:g("boolean"),func:g("function"),number:g("number"),object:g("object"),string:g("string"),symbol:g("symbol"),any:d(r.thatReturnsNull),arrayOf:function(e){return d((function(t,n,r,o,i){if("function"!=typeof e)return new h("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=t[n];if(!Array.isArray(u))return new h("Invalid "+o+" `"+i+"` of type `"+v(u)+"` supplied to `"+r+"`, expected an array.");for(var s=0;s<u.length;s++){var c=e(u,s,r,o,i+"["+s+"]",a);if(c instanceof Error)return c}return null}))},element:d((function(t,n,r,o,i){var u=t[n];return e(u)?null:new h("Invalid "+o+" `"+i+"` of type `"+v(u)+"` supplied to `"+r+"`, expected a single ReactElement.")})),instanceOf:function(e){return d((function(t,n,r,o,i){if(t[n]instanceof e)return null;var u,a=e.name||l;return new h("Invalid "+o+" `"+i+"` of type `"+((u=t[n]).constructor&&u.constructor.name?u.constructor.name:l)+"` supplied to `"+r+"`, expected instance of `"+a+"`.")}))},node:d((function(e,t,n,r,o){return y(e[t])?null:new h("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return d((function(t,n,r,o,i){if("function"!=typeof e)return new h("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var u=t[n],s=v(u);if("object"!==s)return new h("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected an object.");for(var c in u)if(u.hasOwnProperty(c)){var l=e(u,c,r,o,i+"."+c,a);if(l instanceof Error)return l}return null}))},oneOf:function(e){return Array.isArray(e)?d((function(t,n,r,o,i){for(var u=t[n],a=0;a<e.length;a++)if(p(u,e[a]))return null;return new h("Invalid "+o+" `"+i+"` of value `"+u+"` supplied to `"+r+"`, expected one of "+JSON.stringify(e)+".")})):("production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOf, expected an instance of array."),r.thatReturnsNull)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull;for(var n=0;n<e.length;n++){var o=e[n];if("function"!=typeof o)return i(!1,"Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.",m(o),n),r.thatReturnsNull}return d((function(t,n,r,o,i){for(var u=0;u<e.length;u++)if(null==(0,e[u])(t,n,r,o,i,a))return null;return new h("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")}))},shape:function(e){return d((function(t,n,r,o,i){var u=t[n],s=v(u);if("object"!==s)return new h("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");for(var c in e){var l=e[c];if(l){var f=l(u,c,r,o,i+"."+c,a);if(f)return f}}return null}))},exact:function(e){return d((function(t,n,r,o,i){var s=t[n],c=v(s);if("object"!==c)return new h("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected `object`.");var l=u({},t[n],e);for(var f in l){var p=e[f];if(!p)return new h("Invalid "+o+" `"+i+"` key `"+f+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(t[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var d=p(s,f,r,o,i+"."+f,a);if(d)return d}return null}))}};function p(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function h(e){this.message=e,this.stack=""}function d(e){if("production"!==t.env.NODE_ENV)var r={},u=0;function s(s,c,f,p,d,g,y){if(p=p||l,g=g||f,y!==a)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var v=p+":"+f;!r[v]&&u<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",g,p),r[v]=!0,u++)}return null==c[f]?s?null===c[f]?new h("The "+d+" `"+g+"` is marked as required in `"+p+"`, but its value is `null`."):new h("The "+d+" `"+g+"` is marked as required in `"+p+"`, but its value is `undefined`."):null:e(c,f,p,d,g)}var c=s.bind(null,!1);return c.isRequired=s.bind(null,!0),c}function g(e){return d((function(t,n,r,o,i,u){var a=t[n];return v(a)===e?null:new h("Invalid "+o+" `"+i+"` of type `"+b(a)+"` supplied to `"+r+"`, expected `"+e+"`.")}))}function y(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(y);if(null===t||e(t))return!0;var n=function(e){var t=e&&(c&&e[c]||e["@@iterator"]);if("function"==typeof t)return t}(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!y(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!y(i[1]))return!1}return!0;default:return!1}}function v(e){var t,n=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":(t=e,"symbol"===n||"Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol?"symbol":n)}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function m(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return h.prototype=Error.prototype,f.checkPropTypes=s,f.PropTypes=f}}).call(t,n(5))},function(e,t){"use strict";function n(e){return function(){return e}}function r(){}r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){(function(t){"use strict";var n=function(){};"production"!==t.env.NODE_ENV&&(n=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=function(e,t,r,o,i,u,a,s){if(n(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[r,o,i,u,a,s],f=0;(c=new Error(t.replace(/%s/g,(function(){return l[f++]})))).name="Invariant Violation"}throw c.framesToPop=1,c}}}).call(t,n(5))},function(e,t,n){(function(t){"use strict";var r=n(7);"production"!==t.env.NODE_ENV&&(r=function(e,t){if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!e){for(var n=arguments.length,r=Array(2<n?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];(function(e){for(var t=arguments.length,n=Array(1<t?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,(function(){return n[o++]}));"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}}).apply(void 0,[t].concat(r))}}),e.exports=r}).call(t,n(5))},function(e,t){ /* object-assign (c) Sindre Sorhus @license MIT */ "use strict";var n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},r)).join("")?void 0:1}catch(e){return}}()?Object.assign:function(e,t){for(var i,u,a=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),s=1;s<arguments.length;s++){for(var c in i=Object(arguments[s]))r.call(i,c)&&(a[c]=i[c]);if(n){u=n(i);for(var l=0;l<u.length;l++)o.call(i,u[l])&&(a[u[l]]=i[u[l]])}}return a}},function(e,t){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){(function(t){"use strict";if("production"!==t.env.NODE_ENV)var r=n(8),o=n(9),i=n(11),u={};e.exports=function(e,n,a,s,c){if("production"!==t.env.NODE_ENV)for(var l in e)if(e.hasOwnProperty(l)){var f;try{r("function"==typeof e[l],"%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.",s||"React class",a,l,typeof e[l]),f=e[l](n,l,s,a,null,i)}catch(e){f=e}if(o(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",a,l,typeof f),f instanceof Error&&!(f.message in u)){u[f.message]=!0;var p=c?c():"";o(!1,"Failed %s type: %s%s",a,f.message,null!=p?p:"")}}}}).call(t,n(5))},function(e,t,n){"use strict";var r=n(7),o=n(8),i=n(11);e.exports=function(){function e(e,t,n,r,u,a){a!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}var n={array:e.isRequired=e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=r,n.PropTypes=n}},function(e,t){e.exports=n(0)},function(e,t){"use strict";function n(e,t){return e===t}e.exports=function(e){function t(e,t){return r(e,i[t])}var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:n,o=void 0,i=[],u=void 0,a=!1;return function(){for(var n=arguments.length,r=Array(n),s=0;s<n;s++)r[s]=arguments[s];return a&&o===this&&r.length===i.length&&r.every(t)?u:(a=!0,o=this,i=r,u=e.apply(this,r))}}}],r.c=i,r.p="",r(0))},function(e,t,n){e.exports=n(4)},function(e,t,n){},function(e,t,n){"use strict";function r(e){var t=e.highlighting,n=e.searchWords,r=e.value,o=e.status;return i.a.createElement("span",{className:"suggestions-value","data-suggestion-status":o},t?i.a.createElement(a.a,{highlightClassName:"suggestions-highlighting",searchWords:n,autoEscape:!0,textToHighlight:r}):r)}n.r(t);var o=n(0),i=n.n(o),u=(n(3),n(1)),a=n.n(u);function s(e){var t=e.children;return t?i.a.createElement("div",{className:"suggestions-subtext"},t):null}r.defaultProps={highlighting:!0};var c=r;s.defaultProps={};var l=s;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(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 h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=function(){!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&&g(e,t)}(r,o.Component);var e,t,n=function(e){return function(){var t,n,r,o=d(e);if(function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),1}catch(e){return}}}()){var i=d(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return n=this,!(r=t)||"object"!==f(r)&&"function"!=typeof r?h(n):r}}(r);function r(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);for(var t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];return y(h(e=n.call.apply(n,[this].concat(o))),"state",{hover:!1}),y(h(e),"handleHover",(function(){return e.setHover(!0)})),y(h(e),"handleBlur",(function(){return e.setHover(!1)})),y(h(e),"setHover",(function(t){e.setState({hover:t})})),e}return e=r,(t=[{key:"render",value:function(){var e=this.props,t=e.selected,n=e.highlighting,r=e.searchWords,o=e.subtext,u=e.value,a=e.status,s=t||this.state.hover?" suggestions-selected":"";return i.a.createElement("div",{className:"suggestions-suggestion".concat(s),onMouseEnter:this.handleHover,onMouseLeave:this.handleBlur,onMouseDown:this.props.onSelect},i.a.createElement(c,{highlighting:n,searchWords:r,value:u,status:a}),i.a.createElement(l,null,o))}}])&&p(e.prototype,t),r}();function b(e){return e&&"function"==typeof e}function m(e){return["data","state","status"].reduce((function(e,t){return e&&e[t]?e[t]:null}),e)}function O(e){var t=e.suggestions,n=e.visible,r=e.selected;return t.length&&n?i.a.createElement("div",{className:"suggestions-wrapper"},i.a.createElement("div",{className:"suggestions-suggestions"},i.a.createElement("div",{className:"suggestions-hint"},e.hint),t.map((function(t,n){return i.a.createElement(w,{key:n,index:n,selected:n===r,onSelect:e.onSelect(n),searchWords:e.highlighting?e.searchWords():[],highlighting:e.highlighting,value:e.suggestionsFormatter(t),subtext:e.subtextFormatter(t),status:m(t)})})))):null}v.defaultProps={};var w=v;function S(e){var t=e.name,n=e.loading,r=e.placeholder,o=e.query,u=e.disabled,a=e.readOnly,s=e.onChange,c=e.onMouseDown,l=e.onKeyPress,f=e.onBlur,p=e.onFocus,h="suggestions-input".concat(n?" loading":"");return i.a.createElement("input",{type:"text",className:h,autoComplete:"off",name:t,placeholder:r,value:o,disabled:u,readOnly:a,onChange:s,onMouseDown:c,onKeyPress:l,onKeyDown:l,onBlur:f,onFocus:p})}O.defaultProps={};var E=O;S.defaultProps={loading:!1,placeholder:""};var j=S,x=function(e){e.shiftKey||e.ctrlKey||e.altKey||[new k(e,this),new N(e,this),new _(e,this),new T(e,this),new P(e,this)].map((function(t){t.KEY_CODE===e.which&&t.handle()}))},T=function(e,t){return{KEY_CODE:9,handle:function(){t.state.showSuggestions&&new _(e,t).handle()}}},_=function(e,t){return{KEY_CODE:13,handle:function(){var n=t.state,r=n.selected,o=n.suggestions;if(e.preventDefault(),-1!==r)t.handleSelect(r)();else if(o.length){var i=t.state.query.trim(),u=o.findIndex((function(e){return e.value===i}));-1!==u&&t.handleSelect(u)()}}}},P=function(e,t){return{KEY_CODE:27,handle:function(){e.preventDefault(),t.makeListInvisible()}}},k=function(e,t){return{KEY_CODE:38,handle:function(){e.preventDefault();var n=t.state,r=n.selected,o=n.suggestions;if(n.showSuggestions){var i=o.length-1,u=0<r?r-1:i;t.selectSuggestion(u)}}}},N=function(e,t){return{KEY_CODE:40,handle:function(){e.preventDefault();var n=t.state,r=n.selected,o=n.suggestions,i=n.showSuggestions;if(i||!o.length){if(i){var u=r<o.length-1?r+1:0;t.selectSuggestion(u)}}else t.makeListVisible()}}};function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,R),this.locations_boost=[],this.token=e}C(R,"apiUrl","https://suggestions.dadata.ru/suggestions/api/4_1/rs"),C(R,"FIO","fio"),C(R,"ADDRESS","address"),C(R,"ORGANISATION","party"),C(R,"BANK","bank"),C(R,"EMAIL","email");var D=R,I=function(e){return new Headers({"Content-Type":"application/json",Accept:"application/json",Authorization:"Token ".concat(e)})},A=function(e){return function(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,o={endpoint:t,method:n,headers:e};return r&&(o.body=JSON.stringify(r)),new Request(t,o)}};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 q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){return(M="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 L(e){return function(e){if(Array.isArray(e))return W(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return W(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?W(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function W(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function H(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function B(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var U=function(){!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)}(t,D);var e=function(e){return function(){var t,n,r,o=K(e);if(function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),1}catch(e){return}}}()){var i=K(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return n=this,!(r=t)||"object"!==M(r)&&"function"!=typeof r?H(n):r}}(t);function t(n,r){var o,i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),B(H(o=e.call(this,n)),"detectAddress",(function(){var e="".concat(D.apiUrl,"/detectAddressByIp"),t=o.requestFactory(e,"GET");fetch(t).then((function(e){return e.json()})).then((function(e){return e.location.data})).then((function(e){return e?e.kladr_id:null})).then((function(e){e&&(o.locations_boost=[].concat(L(o.locations_boost),[{kladr_id:e}]))})).catch((function(){return null}))})),B(H(o),"suggestions",(function(e){o.locations_boost.length&&(e.locations_boost=o.locations_boost);var t=o.requestFactory(o.endpoint,"POST",e);return fetch(t).then((function(e){if(!e.ok)throw Error(e.statusText);return e.json()})).then((function(e){return e.suggestions}))})),o.headers=I(n),o.requestFactory=A(o.headers),o.endpoint="".concat(D.apiUrl,"/suggest/").concat(r),i&&r.toLowerCase()===D.ADDRESS&&o.detectAddress(),o}return t}(),Y=["аобл","респ","вл","г","гск","д","двлд","днп","дор","дп","жт","им","к","кв","кв-л","км","комн","кп","лпх","м","мкр","наб","нп","обл","оф","п","пгт","пер","пл","платф","рзд","рп","р-н","с","сл","снт","ст","стр","тер","туп","ул","х","ш"];function z(e){return(z="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 J(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 $(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function G(e){return(G=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=function(){!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&&Q(e,t)}(r,o.Component);var e,t,n=function(e){return function(){var t,n,r,o=G(e);if(function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),1}catch(e){return}}}()){var i=G(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return n=this,!(r=t)||"object"!==z(r)&&"function"!=typeof r?$(n):r}}(r);function r(e){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),X($(t=n.call(this,e)),"state",{query:"",suggestions:[],selected:-1,loading:!1,success:!1,error:!1,showSuggestions:!1}),X($(t),"clearFetchTimeout",(function(){t.fetchTimeoutId&&clearTimeout(t.fetchTimeoutId)})),X($(t),"fetchData",(function(e){t._isMounted&&t.setState({loading:!0,success:!1});var n=function(e,t){var n=t.count,r=t.specialRequestOptions;return 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){q(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}({query:e,count:n},void 0===r?{}:r)}(e,t.props);t.api.suggestions(n).then((function(e){t._isMounted&&t.setState({suggestions:e,loading:!1,error:!1,success:!0,showSuggestions:!0})})).catch((function(e){return t.handleError(e)}))})),X($(t),"searchWords",(function(){var e=t.state.query.split(/[^-А-Яа-яЁё\d\w]+/);return t.props.service===U.ADDRESS?e.filter((function(e){return!Y.includes(e)})):e})),X($(t),"handleChange",(function(e){var n=t.props.deferRequestBy;t.clearFetchTimeout(),t._isMounted&&t.setState({query:e,selected:-1});var r=t.props.minChars;e.length>=r?t.fetchTimeoutId=setTimeout((function(){t.fetchData(e)}),n):t._isMounted&&t.setState({suggestions:[],showSuggestions:!1,success:!1});var o=t.props.onChange;o&&o(e)})),X($(t),"handleBlur",(function(e){t.makeListInvisible();var n=t.props.onBlur;b(n)&&n(e)})),X($(t),"handleError",(function(e){t._isMounted&&t.setState({error:!0,loading:!1,success:!1});var n=t.props.onError;n&&n(e)})),X($(t),"selectSuggestion",(function(e){t.setState((function(n){var r=n.suggestions[e],o=t.selectedSuggestionFormatter(r);return{selected:e,query:o}})),t.selectEventFired=!0})),X($(t),"handleSelect",(function(e){return function(){var n=t.state.selected;e!==n&&t.selectSuggestion(e),t.makeListInvisible();var r=t.state.suggestions[e];(0,t.props.onSelect)(r)}})),X($(t),"formatter",(function(e,n){var r=t.props[n];return r?r(e):e.value})),X($(t),"suggestionsFormatter",(function(e){return t.formatter(e,"suggestionsFormatter")})),X($(t),"selectedSuggestionFormatter",(function(e){return t.formatter(e,"selectedSuggestionFormatter")})),X($(t),"subtextFormatter",(function(e){return"party"===t.props.service?"ИНН ".concat(e.data.inn):null})),X($(t),"makeListVisible",(function(){t.props.readOnly||t.state.showSuggestions||t.setState({showSuggestions:!0})})),X($(t),"handleFocus",(function(e){if(!t.props.readOnly){var n=t.state,r=n.query,o=n.success,i=n.suggestions,u=n.selected,a=n.error,s=t.props.minChars;i.length&&-1===u?t.makeListVisible():r.length>=s&&!o&&!a&&t.fetchData(r);var c=t.props.onFocus;b(c)&&c(e)}})),X($(t),"makeListInvisible",(function(){t.state.showSuggestions&&t.setState({showSuggestions:!1})}));var o=e.token,i=e.service,u=e.geolocation;return t.api=new U(o,i,u),t.handleKeyPress=x.bind($(t)),t.fetchTimeoutId=null,t.selectEventFired=!1,t}return e=r,(t=[{key:"UNSAFE_componentWillMount",value:function(){var e=this.props.query;this.setState({query:e})}},{key:"componentDidMount",value:function(){this._isMounted=!0}},{key:"UNSAFE_componentWillReceiveProps",value:function(e){var t,n,r=e.query,o=e.value,i=this.props.value,u=this.state.query;if(o&&(t=o,n=i,JSON.stringify(t)!==JSON.stringify(n)))return this.setState({suggestions:[o]}),void this.selectSuggestion(0);this.selectEventFired?this.selectEventFired=!1:r!==u&&this.handleChange(r)}},{key:"componentWillUnmount",value:function(){this.clearFetchTimeout(),this._isMounted=!1}},{key:"render",value:function(){var e=this,t=this.state,n=t.loading,r=t.query,o=t.showSuggestions,u=t.suggestions,a=t.selected,s=this.props,c=s.name,l=s.placeholder,f=s.disabled,p=s.readOnly,h=s.hint,d=s.highlighting;return i.a.createElement("div",{className:"suggestions-container"},i.a.createElement(j,{name:c,placeholder:l,disabled:f,readOnly:p,loading:n,query:r,onMouseDown:this.makeListVisible,onKeyPress:this.handleKeyPress,onBlur:this.handleBlur,onFocus:this.handleFocus,onChange:function(t){return e.handleChange(t.target.value)}}),i.a.createElement(E,{hint:h,highlighting:d,suggestions:u,selected:a,visible:o,onSelect:this.handleSelect,suggestionsFormatter:this.suggestionsFormatter,searchWords:this.searchWords,subtextFormatter:this.subtextFormatter}))}}])&&J(e.prototype,t),r}();X(Z,"defaultProps",{name:null,token:"",count:10,deferRequestBy:300,minChars:3,geolocation:!0,hint:"Выберите вариант ниже или продолжите ввод",query:"",service:"address",highlighting:!0}),t.default=Z}]); //# sourceMappingURL=index.js.map