@yaireo/tagify
Version:
lightweight, efficient Tags input component in Vanilla JS / React / Angular [super customizable, tiny size & top performance]
1 lines • 6.1 kB
JavaScript
!function(){if(String.prototype.includes||(String.prototype.includes=function(e,t){return"number"!=typeof t&&(t=0),!(t+e.length>this.length)&&-1!==this.indexOf(e,t)}),"function"==typeof window.CustomEvent)return;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e,"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),r=1;r<arguments.length;r++){var o=arguments[r];if(null!=o)for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])}return n},writable:!0,configurable:!0}),window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var r=arguments[1],o=0;o<n;){var i=t[o];if(e.call(r,i,o,t))return o;o++}return-1},configurable:!0,writable:!0}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;if(!document.documentElement.contains(t))return null;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),document.execCommand("AutoUrlDetect",!1,!1),"".trim||(String.prototype.trim=function(){return this.replace(/^[\s]+|[\s]+$/g,"")}),function(e){e.DOMException||((DOMException=function(e){this.message=e}).prototype=new Error);function c(e,t){if(""===t)throw new DOMException("Failed to execute '"+e+"' on 'DOMTokenList': The token provided must not be empty.");if(-1!==(r=t.search(y)))throw new DOMException("Failed to execute '"+e+"' on 'DOMTokenList': The token provided ('"+t[r]+"') contains HTML space characters, which are not valid in tokens.")}var t,n,y=/[\11\12\14\15\40]/,r=0;"function"!=typeof DOMTokenList&&function(f){var t=f.document,e=f.Object,n=e.prototype.hasOwnProperty,v=e.defineProperty,s=0,d=0;function a(){if(!s)throw TypeError("Illegal constructor")}function p(){var e=f.event,t=e.propertyName;if(!d&&("className"===t||"classList"===t&&!v)){var n=e.srcElement,r=n[" uCLp"],o=""+n[t],i=o.trim().split(y),s=n["classList"===t?" uCL":"classList"],a=r.length;e:for(var l=0,c=r.length=i.length,u=0;l!==c;++l){for(var p=0;p!==l;++p)if(i[p]===i[l]){u++;continue e}s[l-u]=i[l]}for(var h=c-u;h<a;++h)delete s[h];if("classList"!==t)return;d=1,n.classList=s,n.className=o,d=0,s.length=i.length-u}}function r(l){if(!(l&&"innerHTML"in l))throw TypeError("Illegal invocation");l.detachEvent("onpropertychange",p),s=1;try{function e(){}e.prototype=new a}finally{s=0}var c=e.prototype,u=new e;e:for(var t=l.className.trim().split(y),n=0,r=t.length,o=0;n!==r;++n){for(var i=0;i!==n;++i)if(t[i]===t[n]){o++;continue e}this[n-o]=t[n]}c.length=r-o,c.value=l.className,c[" uCL"]=l,v?(v(l,"classList",{enumerable:1,get:function(){return u},configurable:0,set:function(e){d=1,l.className=c.value=e+="",d=0;var t=e.trim().split(y),n=c.length;e:for(var r=0,o=c.length=t.length,i=0;r!==o;++r){for(var s=0;s!==r;++s)if(t[s]===t[r]){i++;continue e}u[r-i]=t[r]}for(var a=o-i;a<n;++a)delete u[a]}}),v(l," uCLp",{enumerable:0,configurable:0,writeable:0,value:e.prototype}),v(c," uCL",{enumerable:0,configurable:0,writeable:0,value:l})):(l.classList=u,l[" uCL"]=u,l[" uCLp"]=e.prototype),l.attachEvent("onpropertychange",p)}a.prototype.toString=a.prototype.toLocaleString=function(){return this.value},a.prototype.add=function(){e:for(var e=0,t=arguments.length,n="",r=this[" uCL"],o=r[" uCLp"];e!==t;++e){c("add",n=arguments[e]+"");for(var i=0,s=o.length,a=n;i!==s;++i){if(this[i]===n)continue e;a+=" "+this[i]}this[s]=n,o.length+=1,o.value=a}d=1,r.className=o.value,d=0},a.prototype.remove=function(){for(var e=0,t=arguments.length,n="",r=this[" uCL"],o=r[" uCLp"];e!==t;++e){c("remove",n=arguments[e]+"");for(var i=0,s=o.length,a="",l=0;i!==s;++i)l?this[i-1]=this[i]:this[i]!==n?a+=this[i]+" ":l=1;l&&(delete this[s],o.length-=1,o.value=a)}d=1,r.className=o.value,d=0},f.DOMTokenList=a;try{f.Object.defineProperty(f.Element.prototype,"classList",{enumerable:1,get:function(e){return n.call(this,"classList")||r(this),this.classList},configurable:0,set:function(e){this.className=e}})}catch(e){f[" uCL"]=r,t.documentElement.firstChild.appendChild(t.createElement("style")).styleSheet.cssText='_*{x-uCLp:expression(!this.hasOwnProperty("classList")&&window[" uCL"](this))}[class]{x-uCLp/**/:expression(!this.hasOwnProperty("classList")&&window[" uCL"](this))}'}}(e),t=e.DOMTokenList.prototype,n=e.document.createElement("div").classList,t.item||(t.item=function(e){return void 0===(t=this[e])?null:t;var t}),t.toggle&&!1===n.toggle("a",0)||(t.toggle=function(e){if(1<arguments.length)return this[arguments[1]?"add":"remove"](e),!!arguments[1];var t=this.value;return this.remove(t),t===this.value&&(this.add(e),!0)}),t.replace&&"boolean"==typeof n.replace("a","b")||(t.replace=function(e,t){c("replace",e),c("replace",t);var n=this.value;return this.remove(e),this.value!==n&&(this.add(t),!0)}),t.contains||(t.contains=function(e){for(var t=0,n=this.length;t!==n;++t)if(this[t]===e)return!0;return!1}),t.forEach||(t.forEach=function(e){if(1===arguments.length)for(var t=0,n=this.length;t!==n;++t)e(this[t],t,this);else{t=0,n=this.length;for(var r=arguments[1];t!==n;++t)e.call(r,this[t],t,this)}}),t.entries||(t.entries=function(){var e=this;return{next:function(){return 0<e.length?{value:[0,e[0]],done:!1}:{done:!0}}}}),t.values||(t.values=function(){var e=this;return{next:function(){return 0<e.length?{value:e[0],done:!1}:{done:!0}}}}),t.keys||(t.keys=function(){var e=this;return{next:function(){return 0<e.length?{value:0,done:!1}:{done:!0}}}})}(window)}();