New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yaireo/tagify

Package Overview
Dependencies
Maintainers
1
Versions
270
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yaireo/tagify - npm Package Compare versions

Comparing version 2.27.0 to 2.28.0

4

dist/jQuery.tagify.min.js
/**
* Tagify (v 2.27.0)- tags input component
* Tagify (v 2.28.0)- tags input component
* By Yair Even-Or

@@ -7,2 +7,2 @@ * Don't sell this code. (c)

*/
"use strict";function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(i,!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(i).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}!function(o){function n(t,e){if(!t)return console.warn("Tagify: ","invalid input element ",t),this;this.applySettings(t,e),this.state={},this.value=[],this.listeners={},this.DOM={},this.extend(this,new this.EventDispatcher(this)),this.build(t),this.loadOriginalValues(),this.events.customBinding.call(this),this.events.binding.call(this),t.autofocus&&this.DOM.input.focus()}o.fn.tagify=function(){var i=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.each(function(){var t,e=o(this);if(e.data("tagify"))return this;i.isJQueryPlugin=!0,t=new n(e[0],i),e.data("tagify",t)})},n.prototype={isIE:window.document.documentMode,TEXTS:{empty:"empty",exceed:"number of tags exceeded",pattern:"pattern mismatch",duplicate:"already exists",notAllowed:"not allowed"},DEFAULTS:{delimiters:",",pattern:null,maxTags:1/0,callbacks:{},addTagOnBlur:!0,duplicates:!1,whitelist:[],blacklist:[],enforceWhitelist:!1,keepInvalidTags:!1,autoComplete:!0,mixTagsAllowedAfter:/,|\.|\:|\s/,mixTagsInterpolator:["[[","]]"],backspace:!0,skipInvalid:!1,transformTag:function(){},dropdown:{classname:"",enabled:2,maxItems:10,itemTemplate:"",fuzzySearch:!0}},templates:{wrapper:function(t,e){return'<tags class="tagify '.concat(e.mode?"tagify--mix":""," ").concat(t.className,'"\n ').concat(e.readonly?'readonly aria-readonly="true"':'aria-haspopup="true" aria-expanded="false"','\n role="tagslist">\n <span contenteditable data-placeholder="').concat(t.placeholder||"&#8203;",'" aria-placeholder="').concat(t.placeholder||"",'"\n class="tagify__input"\n role="textbox"\n aria-multiline="false"></span>\n </tags>')},tag:function(t,e){return"<tag title='".concat(e.title||t,"'\n contenteditable='false'\n spellcheck='false'\n class='tagify__tag ").concat(e.class?e.class:"","'\n ").concat(this.getAttributes(e),">\n <x title='' class='tagify__tag__removeBtn' role='button' aria-label='remove tag'></x>\n <div>\n <span class='tagify__tag-text'>").concat(t,"</span>\n </div>\n </tag>")},dropdownItem:function(t){var e=(t.value||t).replace(/`|'/g,"&#39;");return"<div ".concat(this.getAttributes(t),"\n class='tagify__dropdown__item ").concat(t.class?t.class:"",'\'\n tabindex="0"\n role="menuitem"\n aria-labelledby="dropdown-label">').concat(e,"</div>")}},customEventsList:["click","add","remove","invalid","input","edit"],applySettings:function(t,e){var i=t.getAttribute("data-whitelist"),n=t.getAttribute("data-blacklist");if(this.DEFAULTS.templates=this.templates,this.DEFAULTS.dropdown.itemTemplate=this.templates.dropdownItem,this.settings=this.extend({},this.DEFAULTS,e),this.settings.readonly=t.hasAttribute("readonly"),this.isIE&&(this.settings.autoComplete=!1),n&&(n=n.split(this.settings.delimiters))instanceof Array&&(this.settings.blacklist=n),i&&(i=i.split(this.settings.delimiters))instanceof Array&&(this.settings.whitelist=i),t.pattern)try{this.settings.pattern=new RegExp(t.pattern)}catch(t){}if(this.settings&&this.settings.delimiters)try{this.settings.delimiters=new RegExp(this.settings.delimiters,"g")}catch(t){}},parseHTML:function(t){return(new DOMParser).parseFromString(t.trim(),"text/html").body.firstElementChild},escapeHTML:function(t){var e=document.createTextNode(t),i=document.createElement("p");return i.appendChild(e),i.innerHTML},build:function(t){var e=this.DOM,i=this.settings.templates.wrapper(t,this.settings);e.originalInput=t,e.scope=this.parseHTML(i),e.input=e.scope.querySelector("[contenteditable]"),t.parentNode.insertBefore(e.scope,t),0<=this.settings.dropdown.enabled&&this.dropdown.init.call(this)},destroy:function(){this.DOM.scope.parentNode.removeChild(this.DOM.scope),this.dropdown.hide.call(this,!0)},loadOriginalValues:function(t){var e=0<arguments.length&&void 0!==t?t:this.DOM.originalInput.value;if(e){this.removeAllTags();try{e=JSON.parse(e)}catch(t){}"mix"==this.settings.mode?this.parseMixTags(e):this.addTags(e).forEach(function(t){return t&&t.classList.add("tagify--noAnim")})}},extend:function(t,e,i){function n(t){var e=Object.prototype.toString.call(t).split(" ")[1].slice(0,-1);return t===Object(t)&&"Array"!=e&&"Function"!=e&&"RegExp"!=e&&"HTMLUnknownElement"!=e}function s(t,e){for(var i in e)e.hasOwnProperty(i)&&(n(e[i])?n(t[i])?s(t[i],e[i]):t[i]=Object.assign({},e[i]):t[i]=e[i])}return t instanceof Object||(t={}),s(t,e),i&&s(t,i),t},EventDispatcher:function(n){var s=document.createTextNode("");this.off=function(t,e){return e&&s.removeEventListener.call(s,t,e),this},this.on=function(t,e){return e&&s.addEventListener.call(s,t,e),this},this.trigger=function(t,e){var i;if(t)if(n.settings.isJQueryPlugin)o(n.DOM.originalInput).triggerHandler(t,[e]);else{try{i=new CustomEvent(t,{detail:e})}catch(t){console.warn(t)}s.dispatchEvent(i)}}},events:{customBinding:function(){var e=this;this.customEventsList.forEach(function(t){e.on(t,e.settings.callbacks[t])})},binding:function(t){var e,i=!(0<arguments.length&&void 0!==t)||t,n=this.events.callbacks,s=i?"addEventListener":"removeEventListener";for(var a in i&&!this.listeners.main&&(this.DOM.input.addEventListener(this.isIE?"keydown":"input",n[this.isIE?"onInputIE":"onInput"].bind(this)),this.settings.isJQueryPlugin&&o(this.DOM.originalInput).on("tagify.removeAllTags",this.removeAllTags.bind(this))),e=this.listeners.main=this.listeners.main||{paste:["input",n.onPaste.bind(this)],focus:["input",n.onFocusBlur.bind(this)],blur:["input",n.onFocusBlur.bind(this)],keydown:["input",n.onKeydown.bind(this)],click:["scope",n.onClickScope.bind(this)],dblclick:["scope",n.onDoubleClickScope.bind(this)]})this.DOM[e[a][0]][s](a,e[a][1])},callbacks:{onFocusBlur:function(t){var e=t.target.textContent.trim();"mix"!=this.settings.mode&&("focus"==t.type?(this.DOM.scope.classList.add("tagify--focus"),0===this.settings.dropdown.enabled&&this.dropdown.show.call(this)):"blur"==t.type?(this.DOM.scope.classList.remove("tagify--focus"),e&&this.settings.addTagOnBlur&&this.addTags(e,!0).length):(this.DOM.input.removeAttribute("style"),this.dropdown.hide.call(this)))},onKeydown:function(t){var e,i=this,n=t.target.textContent.trim();if("mix"==this.settings.mode){switch(t.key){case"Delete":case"Backspace":var s=[];e=this.DOM.input.children,setTimeout(function(){[].forEach.call(e,function(t){return s.push(t.getAttribute("value"))}),i.value=i.value.filter(function(t){return-1!=s.indexOf(t.value)})},20);break;case"Enter":t.preventDefault()}return!0}switch(t.key){case"Backspace":""!=n&&8203!=n.charCodeAt(0)||(!0===this.settings.backspace?this.removeTag():"edit"==this.settings.backspace&&this.editTag());break;case"Esc":case"Escape":this.input.set.call(this),t.target.blur();break;case"ArrowRight":case"Tab":if(!n)return!0;case"Enter":t.preventDefault(),this.addTags(n,!0)}},onInput:function(t){var e=this.input.normalize.call(this),i=e.length>=this.settings.dropdown.enabled,n={value:e,inputElm:this.DOM.input};if("mix"==this.settings.mode)return this.events.callbacks.onMixTagsInput.call(this,t);e?this.input.value!=e&&(n.isValid=this.validateTag.call(this,e),this.input.set.call(this,e,!1),this.trigger("input",n),-1!=e.search(this.settings.delimiters)?this.addTags(e).length&&this.input.set.call(this):0<=this.settings.dropdown.enabled&&this.dropdown[i?"show":"hide"].call(this,e)):this.input.set.call(this,"")},onMixTagsInput:function(t){var e,i,n,s,a;if(this.maxTagsReached())return!0;window.getSelection&&0<(e=window.getSelection()).rangeCount&&((i=e.getRangeAt(0).cloneRange()).collapse(!0),i.setStart(window.getSelection().focusNode,0),(s=(n=i.toString().split(this.settings.mixTagsAllowedAfter))[n.length-1].match(this.settings.pattern))&&(this.state.tag={prefix:s[0],value:s.input.split(s[0])[1]},s=this.state.tag,a=this.state.tag.value.length>=this.settings.dropdown.enabled)),this.update(),this.trigger("input",this.extend({},this.state.tag,{textContent:this.DOM.input.textContent})),this.state.tag&&this.dropdown[a?"show":"hide"].call(this,this.state.tag.value)},onInputIE:function(t){var e=this;setTimeout(function(){e.events.callbacks.onInput.call(e,t)})},onPaste:function(t){},onClickScope:function(t){var e,i=t.target.closest("tag");"TAGS"==t.target.tagName?this.DOM.input.focus():"X"==t.target.tagName?this.removeTag(t.target.parentNode):i&&(e=this.getNodeIndex(i),this.trigger("click",{tag:i,index:e,data:this.value[e]}))},onEditTagInput:function(t){var e=t.closest("tag"),i=this.getNodeIndex(e),n=this.input.normalize(t),s=n.toLowerCase()==t.originalValue.toLowerCase()||this.validateTag(n);e.classList.toggle("tagify--invalid",!0!==s),e.isValid=s,this.trigger("input",{tag:e,index:i,data:this.extend({},this.value[i],{newValue:n})})},onEditTagBlur:function(t){var e,i=t.closest("tag"),n=this.getNodeIndex(i),s=this.input.normalize(t),a=s||t.originalValue,o=this.input.normalize(t)!=t.originalValue,r=i.isValid,l=_objectSpread({},this.value[n],{value:a});s?(o&&(this.settings.transformTag.call(this,l),r=this.validateTag(l.value)),void 0!==r&&!0!==r||(t.textContent=l.value,this.value[n].value=l.value,this.update(),(e=t.cloneNode(!0)).removeAttribute("contenteditable"),i.title=l.value,i.classList.remove("tagify--editable"),t.parentNode.replaceChild(e,t),this.trigger("edit",{tag:i,index:n,data:this.value[n]}))):this.removeTag(i)},onEditTagkeydown:function(t){switch(t.key){case"Esc":case"Escape":t.target.textContent=t.target.originalValue;case"Enter":case"Tab":t.preventDefault(),t.target.blur()}},onDoubleClickScope:function(t){var e,i,n=t.target.closest("tag"),s=this.settings;n&&(e=n.classList.contains("tagify--editable"),i=n.hasAttribute("readonly"),"mix"==s.mode||s.readonly||s.enforceWhitelist||e||i||this.editTag(n))}}},editTag:function(t){var e=this,i=0<arguments.length&&void 0!==t?t:this.getLastTag(),n=i.querySelector(".tagify__tag-text"),s=this.events.callbacks;n?(i.classList.add("tagify--editable"),n.originalValue=n.textContent,n.setAttribute("contenteditable",!0),n.addEventListener("blur",s.onEditTagBlur.bind(this,n)),n.addEventListener("input",s.onEditTagInput.bind(this,n)),n.addEventListener("keydown",function(t){return s.onEditTagkeydown.call(e,t)}),n.focus()):console.warn("Cannot find element in Tag template: ",".tagify__tag-text")},input:{value:"",set:function(t,e){var i=0<arguments.length&&void 0!==t?t:"",n=!(1<arguments.length&&void 0!==e)||e;this.input.value=i,n&&(this.DOM.input.innerHTML=i),i||this.dropdown.hide.call(this),i.length<2&&this.input.autocomplete.suggest.call(this,""),this.input.validate.call(this)},setRangeAtStartEnd:function(t,e){var i,n,s=0<arguments.length&&void 0!==t&&t,a=1<arguments.length?e:void 0;document.createRange&&((i=document.createRange()).selectNodeContents(a||this.DOM.input),i.collapse(s),(n=window.getSelection()).removeAllRanges(),n.addRange(i))},validate:function(){var t=!this.input.value||this.validateTag.call(this,this.input.value);this.DOM.input.classList.toggle("tagify__input--invalid",!0!==t)},normalize:function(t){var e=(0<arguments.length&&void 0!==t?t:this.DOM.input).innerText;return"settings"in this&&this.settings.delimiters&&(e=e.replace(/(?:\r\n|\r|\n)/g,this.settings.delimiters.source.charAt(1))),e=e.replace(/\s/g," ").replace(/^\s+/,"")},autocomplete:{suggest:function(t){t&&this.input.value?this.DOM.input.setAttribute("data-suggest",t.substring(this.input.value.length)):this.DOM.input.removeAttribute("data-suggest")},set:function(t){var e=this.DOM.input.getAttribute("data-suggest"),i=t||(e?this.input.value+e:null);return!!i&&(this.input.set.call(this,i),this.input.autocomplete.suggest.call(this,""),this.dropdown.hide.call(this),this.input.setRangeAtStartEnd.call(this),!0)}}},getNodeIndex:function(t){var e=0;if(t)for(;t=t.previousElementSibling;)e++;return e},getTagElms:function(){return this.DOM.scope.querySelectorAll("tag")},getLastTag:function(){var t=this.DOM.scope.querySelectorAll("tag:not(.tagify--hide):not([readonly])");return t[t.length-1]},isTagDuplicate:function(e){return this.value.findIndex(function(t){return e.trim().toLowerCase()===t.value.toLowerCase()})},getTagIndexByValue:function(i){var n=[];return this.getTagElms().forEach(function(t,e){t.textContent.trim().toLowerCase()==i.toLowerCase()&&n.push(e)}),n},getTagElmByValue:function(t){var e=this.getTagIndexByValue(t)[0];return this.getTagElms()[e]},markTagByValue:function(t,e){return!!(e=e||this.getTagElmByValue(t))&&(e.classList.add("tagify--mark"),e)},isTagBlacklisted:function(e){return e=e.toLowerCase().trim(),this.settings.blacklist.filter(function(t){return e==t.toLowerCase()}).length},isTagWhitelisted:function(e){return this.settings.whitelist.some(function(t){if((t.value||t).toLowerCase()===e.toLowerCase())return!0})},validateTag:function(t){var e=t.trim(),i=!0;return e?this.settings.pattern&&!this.settings.pattern.test(e)?i=this.TEXTS.pattern:this.settings.duplicates||-1===this.isTagDuplicate(e)?(this.isTagBlacklisted(e)||this.settings.enforceWhitelist&&!this.isTagWhitelisted(e))&&(i=this.TEXTS.notAllowed):i=this.TEXTS.duplicate:i=this.TEXTS.empty,i},maxTagsReached:function(){return this.value.length>=this.settings.maxTags&&this.TEXTS.exceed},normalizeTags:function(t){function i(t){return t.split(a).filter(function(t){return t}).map(function(t){return{value:t.trim()}})}var e,n=this.settings,s=n.whitelist,a=n.delimiters,o=n.mode,r=!!s&&s[0]instanceof Object,l=t instanceof Array&&t[0]instanceof Object&&"value"in t[0],d=[];if(l)return t=(e=[]).concat.apply(e,_toConsumableArray(t.map(function(e){return i(e.value).map(function(t){return _objectSpread({},e,{},t)})})));if("number"==typeof t&&(t=t.toString()),"string"==typeof t){if(!t.trim())return[];t=i(t)}else if(!l&&t instanceof Array){var c;t=(c=[]).concat.apply(c,_toConsumableArray(t.map(function(t){return i(t)})))}return r&&(t.forEach(function(e){var t=s.filter(function(t){return t.value.toLowerCase()==e.value.toLowerCase()});t[0]?d.push(t[0]):"mix"!=o&&d.push(e)}),t=d),t},parseMixTags:function(t){var n,s=this,e=this.settings,a=e.mixTagsInterpolator,o=e.duplicates;return t=t.split(a[0]).map(function(t){var e,i=t.split(a[1]);return 1<i.length&&s.isTagWhitelisted(i[0])&&(o||-1===s.isTagDuplicate(i[0]))&&(n=s.normalizeTags(i[0])[0],e=s.createTagElem(n),i[0]=e.outerHTML+"&#8288;",s.value.push(n)),i.join("")}).join(""),this.DOM.input.innerHTML=t,this.update(),t},addMixTag:function(t){if(t&&this.state.tag){for(var e,i,n,s,a=this.state.tag.prefix+this.state.tag.value,o=document.createNodeIterator(this.DOM.input,NodeFilter.SHOW_TEXT),r=100;(e=o.nextNode())&&r--;)if(e.nodeType===Node.TEXT_NODE){if(-1==(n=e.nodeValue.indexOf(a)))continue;s=e.splitText(n),this.settings.transformTag.call(this,t),i=this.createTagElem(t),s.nodeValue=s.nodeValue.replace(a,""),e.parentNode.insertBefore(i,s),i.insertAdjacentHTML("afterend","&#8288;")}i&&(this.value.push(t),this.update(),this.trigger("add",this.extend({},{index:this.value.length,tag:i},t))),this.state.tag=null}},addTags:function(t,e,i){var s=this,a=2<arguments.length&&void 0!==i?i:this.settings.skipInvalid,o=[];if(!t||!t.length)return o;if(t=this.normalizeTags.call(this,t),"mix"==this.settings.mode)return this.addMixTag(t[0]);return this.DOM.input.removeAttribute("style"),t.forEach(function(t){var e,i,n={};if(t=Object.assign({},t),s.settings.transformTag.call(s,t),!0!==(e=s.maxTagsReached()||s.validateTag.call(s,t.value))){if(a)return;n["aria-invalid"]=!0,n.class=(t.class||"")+" tagify--notAllowed",n.title=e,s.markTagByValue(t.value),s.trigger("invalid",{data:t,index:s.value.length,message:e})}n.role="tag",t.readonly&&(n["aria-readonly"]=!0),i=s.createTagElem(s.extend({},t,n)),o.push(i),function(t){var e=this.DOM.scope.lastElementChild;e===this.DOM.input?this.DOM.scope.insertBefore(t,e):this.DOM.scope.appendChild(t)}.call(s,i),!0===e?(s.value.push(t),s.update(),s.trigger("add",{tag:i,index:s.value.length-1,data:t})):s.settings.keepInvalidTags||setTimeout(function(){s.removeTag(i,!0)},1e3)}),t.length&&e&&this.input.set.call(this),o},minify:function(t){return t.replace(new RegExp(">[\r\n ]+<","g"),"><")},createTagElem:function(t){var e=this.escapeHTML(t.value),i=this.settings.templates.tag.call(this,e,t);return this.settings.readonly&&(t.readonly=!0),i=this.minify(i),this.parseHTML(i)},removeTag:function(t,e,i){var n=this,s=0<arguments.length&&void 0!==t?t:this.getLastTag(),a=1<arguments.length?e:void 0,o=2<arguments.length&&void 0!==i?i:250;if("string"==typeof s&&(s=this.getTagElmByValue(s)),s instanceof HTMLElement){var r,l=this.getNodeIndex(s),d=function(){s.parentNode&&(s.parentNode.removeChild(s),a||(r=n.value.splice(l,1)[0],n.update(),n.trigger("remove",{tag:s,index:l,data:r}),n.dropdown.render.call(n)))};o&&10<o?(s.style.width=parseFloat(window.getComputedStyle(s).width)+"px",document.body.clientTop,s.classList.add("tagify--hide"),setTimeout(d,400)):d()}},removeAllTags:function(){this.value=[],this.update(),Array.prototype.slice.call(this.getTagElms()).forEach(function(t){return t.parentNode.removeChild(t)})},getAttributes:function(t){if("[object Object]"!=Object.prototype.toString.call(t))return"";var e,i,n=Object.keys(t),s="";for(i=n.length;i--;)"class"!=(e=n[i])&&t.hasOwnProperty(e)&&t[e]&&(s+=" "+e+(t[e]?'="'.concat(t[e],'"'):""));return s},preUpdate:function(){this.DOM.scope.classList.toggle("hasMaxTags",this.value.length>=this.settings.maxTags)},update:function(){this.preUpdate(),this.DOM.originalInput.value="mix"==this.settings.mode?this.getMixedTagsAsString():this.value.length?JSON.stringify(this.value):""},getMixedTagsAsString:function(){var i="";return this.DOM.input.childNodes.forEach(function(t,e){1==t.nodeType?t.classList.contains("tagify__tag")&&(i+="[["+t.getAttribute("value")+"]]"):i+=t.textContent}),i},dropdown:{init:function(){this.DOM.dropdown=this.dropdown.build.call(this)},build:function(){var t=this.settings.dropdown,e=t.position,i=t.classname,n="".concat("manual"==e?"":"tagify__dropdown"," ").concat(i).trim(),s='<div class="'.concat(n,'" role="menu"></div>');return this.parseHTML(s)},show:function(t){var e,i="manual"==this.settings.dropdown.position;if(this.settings.whitelist.length){if(this.suggestedListItems=this.dropdown.filterListItems.call(this,t),!this.suggestedListItems.length)return this.input.autocomplete.suggest.call(this),void this.dropdown.hide.call(this);e=this.dropdown.createListHTML.call(this,this.suggestedListItems),this.DOM.dropdown.innerHTML=this.minify(e),this.settings.enforceWhitelist&&!i&&this.dropdown.highlightOption.call(this,this.DOM.dropdown.querySelector(".tagify__dropdown__item")),this.DOM.scope.setAttribute("aria-expanded",!0),this.trigger("dropdown:show",this.DOM.dropdown),document.body.contains(this.DOM.dropdown)||(i||(this.dropdown.position.call(this),document.body.appendChild(this.DOM.dropdown),this.events.binding.call(this,!1)),this.dropdown.events.binding.call(this))}},hide:function(t){var e=this.DOM,i=e.scope,n=e.dropdown,s="manual"==this.settings.dropdown.position&&!t;n&&document.body.contains(n)&&!s&&(window.removeEventListener("resize",this.dropdown.position),this.dropdown.events.binding.call(this,!1),this.events.binding.call(this),i.setAttribute("aria-expanded",!1),n.parentNode.removeChild(n),this.trigger("dropdown:hide",n))},render:function(){this.suggestedListItems=this.dropdown.filterListItems.call(this,"");var t=this.dropdown.createListHTML.call(this,this.suggestedListItems);this.DOM.dropdown.innerHTML=this.minify(t)},position:function(){var t=this.DOM.scope.getBoundingClientRect();this.DOM.dropdown.style.cssText="left: "+(t.left+window.pageXOffset)+"px; top: "+(t.top+t.height-1+window.pageYOffset)+"px; width: "+t.width+"px"},events:{binding:function(t){var e=!(0<arguments.length&&void 0!==t)||t,i=this.listeners.dropdown=this.listeners.dropdown||{position:this.dropdown.position.bind(this),onKeyDown:this.dropdown.events.callbacks.onKeyDown.bind(this),onMouseOver:this.dropdown.events.callbacks.onMouseOver.bind(this),onClick:this.dropdown.events.callbacks.onClick.bind(this)},n=e?"addEventListener":"removeEventListener";"manual"!=this.settings.dropdown.position&&(window[n]("resize",i.position),window[n]("keydown",i.onKeyDown)),window[n]("mousedown",i.onClick),this.DOM.dropdown[n]("mouseover",i.onMouseOver)},callbacks:{onKeyDown:function(t){var e=this,i=this.DOM.dropdown.querySelector("[class$='--active']"),n=i||this.DOM.dropdown.children[0],s="";switch(t.key){case"ArrowDown":case"ArrowUp":case"Down":case"Up":t.preventDefault(),n=(n=n&&n[("ArrowUp"==t.key||"Up"==t.key?"previous":"next")+"ElementSibling"])||this.DOM.dropdown.children["ArrowUp"==t.key||"Up"==t.key?this.DOM.dropdown.children.length-1:0],this.dropdown.highlightOption.call(this,n,!0);break;case"Escape":case"Esc":this.dropdown.hide.call(this);break;case"ArrowRight":case"Tab":if(t.preventDefault(),!this.input.autocomplete.set.call(this,n?n.textContent:null))return!1;case"Enter":if(t.preventDefault(),i)return s=this.suggestedListItems[this.getNodeIndex(i)]||this.input.value,this.addTags([s],!0),this.dropdown.hide.call(this),setTimeout(function(){return e.DOM.input.focus()},100),!1;this.addTags(this.input.value,!0)}},onMouseOver:function(t){t.target.className.includes("__item")&&this.dropdown.highlightOption.call(this,t.target)},onClick:function(t){var e,i,n=this;if(0==t.button&&t.target!=this.DOM.dropdown){if(i=t.target.closest(".tagify__dropdown__item")){if(i.parentNode!==this.DOM.dropdown)return;e=this.suggestedListItems[this.getNodeIndex(i)]||this.input.value,this.addTags([e],!0),setTimeout(function(){return n.DOM.input.focus()},100)}this.dropdown.hide.call(this)}}}},highlightOption:function(t,e){if(t){var i,n="tagify__dropdown__item--active";this.DOM.dropdown.querySelectorAll("[class$='--active']").forEach(function(t){t.classList.remove(n),t.removeAttribute("aria-selected")}),t.classList.add(n),t.setAttribute("aria-selected",!0),e&&(t.parentNode.scrollTop=t.clientHeight+t.offsetTop-t.parentNode.clientHeight),this.settings.autoComplete&&!this.settings.dropdown.fuzzySearch&&(i=this.suggestedListItems[this.getNodeIndex(t)].value||this.input.value,this.input.autocomplete.suggest.call(this,i))}},filterListItems:function(t){var e,i,n,s,a=this,o=[],r=this.settings.whitelist,l=this.settings.dropdown.maxItems||1/0,d=0;if(!t)return r.filter(function(t){return-1==a.isTagDuplicate(t.value||t)}).slice(0,l);for(;d<r.length&&(n=(((e=r[d]instanceof Object?r[d]:{value:r[d]}).searchBy||"")+" "+e.value).toLowerCase().indexOf(t.toLowerCase()),i=this.settings.dropdown.fuzzySearch?0<=n:0==n,s=!this.settings.duplicates&&-1<this.isTagDuplicate(e.value),i&&!s&&l--&&o.push(e),0!=l);d++);return o},createListHTML:function(t){var e=this.settings.templates.dropdownItem.bind(this);return t.map(e).join("")}}}}(jQuery);
"use strict";function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(i,!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(i).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}!function(o){function n(t,e){if(!t)return console.warn("Tagify: ","invalid input element ",t),this;this.applySettings(t,e),this.state={},this.value=[],this.listeners={},this.DOM={},this.extend(this,new this.EventDispatcher(this)),this.build(t),this.loadOriginalValues(),this.events.customBinding.call(this),this.events.binding.call(this),t.autofocus&&this.DOM.input.focus()}o.fn.tagify=function(){var i=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.each(function(){var t,e=o(this);if(e.data("tagify"))return this;i.isJQueryPlugin=!0,t=new n(e[0],i),e.data("tagify",t)})},n.prototype={isIE:window.document.documentMode,TEXTS:{empty:"empty",exceed:"number of tags exceeded",pattern:"pattern mismatch",duplicate:"already exists",notAllowed:"not allowed"},DEFAULTS:{delimiters:",",pattern:null,maxTags:1/0,callbacks:{},addTagOnBlur:!0,duplicates:!1,whitelist:[],blacklist:[],enforceWhitelist:!1,keepInvalidTags:!1,autoComplete:!0,mixTagsAllowedAfter:/,|\.|\:|\s/,mixTagsInterpolator:["[[","]]"],backspace:!0,skipInvalid:!1,transformTag:function(){},dropdown:{classname:"",enabled:2,maxItems:10,itemTemplate:"",fuzzySearch:!0}},templates:{wrapper:function(t,e){return'<tags class="tagify '.concat(e.mode?"tagify--mix":""," ").concat(t.className,'"\n ').concat(e.readonly?'readonly aria-readonly="true"':'aria-haspopup="true" aria-expanded="false"','\n role="tagslist">\n <span contenteditable data-placeholder="').concat(t.placeholder||"&#8203;",'" aria-placeholder="').concat(t.placeholder||"",'"\n class="tagify__input"\n role="textbox"\n aria-multiline="false"></span>\n </tags>')},tag:function(t,e){return"<tag title='".concat(e.title||t,"'\n contenteditable='false'\n spellcheck='false'\n class='tagify__tag ").concat(e.class?e.class:"","'\n ").concat(this.getAttributes(e),">\n <x title='' class='tagify__tag__removeBtn' role='button' aria-label='remove tag'></x>\n <div>\n <span class='tagify__tag-text'>").concat(t,"</span>\n </div>\n </tag>")},dropdownItem:function(t){var e=(t.value||t).replace(/`|'/g,"&#39;");return"<div ".concat(this.getAttributes(t),"\n class='tagify__dropdown__item ").concat(t.class?t.class:"",'\'\n tabindex="0"\n role="menuitem"\n aria-labelledby="dropdown-label">').concat(e,"</div>")}},customEventsList:["click","add","remove","invalid","input","edit"],applySettings:function(t,e){var i=t.getAttribute("data-whitelist"),n=t.getAttribute("data-blacklist");if(this.DEFAULTS.templates=this.templates,this.DEFAULTS.dropdown.itemTemplate=this.templates.dropdownItem,this.settings=this.extend({},this.DEFAULTS,e),this.settings.readonly=t.hasAttribute("readonly"),this.isIE&&(this.settings.autoComplete=!1),n&&(n=n.split(this.settings.delimiters))instanceof Array&&(this.settings.blacklist=n),i&&(i=i.split(this.settings.delimiters))instanceof Array&&(this.settings.whitelist=i),t.pattern)try{this.settings.pattern=new RegExp(t.pattern)}catch(t){}if(this.settings&&this.settings.delimiters)try{this.settings.delimiters=new RegExp(this.settings.delimiters,"g")}catch(t){}},parseHTML:function(t){return(new DOMParser).parseFromString(t.trim(),"text/html").body.firstElementChild},escapeHTML:function(t){var e=document.createTextNode(t),i=document.createElement("p");return i.appendChild(e),i.innerHTML},build:function(t){var e=this.DOM,i=this.settings.templates.wrapper(t,this.settings);e.originalInput=t,e.scope=this.parseHTML(i),e.input=e.scope.querySelector("[contenteditable]"),t.parentNode.insertBefore(e.scope,t),0<=this.settings.dropdown.enabled&&this.dropdown.init.call(this)},destroy:function(){this.DOM.scope.parentNode.removeChild(this.DOM.scope),this.dropdown.hide.call(this,!0)},loadOriginalValues:function(t){var e=0<arguments.length&&void 0!==t?t:this.DOM.originalInput.value;if(e){this.removeAllTags();try{e=JSON.parse(e)}catch(t){}"mix"==this.settings.mode?this.parseMixTags(e):this.addTags(e).forEach(function(t){return t&&t.classList.add("tagify--noAnim")})}},extend:function(t,e,i){function n(t){var e=Object.prototype.toString.call(t).split(" ")[1].slice(0,-1);return t===Object(t)&&"Array"!=e&&"Function"!=e&&"RegExp"!=e&&"HTMLUnknownElement"!=e}function s(t,e){for(var i in e)e.hasOwnProperty(i)&&(n(e[i])?n(t[i])?s(t[i],e[i]):t[i]=Object.assign({},e[i]):t[i]=e[i])}return t instanceof Object||(t={}),s(t,e),i&&s(t,i),t},EventDispatcher:function(n){var s=document.createTextNode("");this.off=function(t,e){return e&&s.removeEventListener.call(s,t,e),this},this.on=function(t,e){return e&&s.addEventListener.call(s,t,e),this},this.trigger=function(t,e){var i;if(t)if(n.settings.isJQueryPlugin)o(n.DOM.originalInput).triggerHandler(t,[e]);else{try{i=new CustomEvent(t,{detail:e})}catch(t){console.warn(t)}s.dispatchEvent(i)}}},events:{customBinding:function(){var e=this;this.customEventsList.forEach(function(t){e.on(t,e.settings.callbacks[t])})},binding:function(t){var e,i=!(0<arguments.length&&void 0!==t)||t,n=this.events.callbacks,s=i?"addEventListener":"removeEventListener";for(var a in i&&!this.listeners.main&&(this.DOM.input.addEventListener(this.isIE?"keydown":"input",n[this.isIE?"onInputIE":"onInput"].bind(this)),this.settings.isJQueryPlugin&&o(this.DOM.originalInput).on("tagify.removeAllTags",this.removeAllTags.bind(this))),e=this.listeners.main=this.listeners.main||{paste:["input",n.onPaste.bind(this)],focus:["input",n.onFocusBlur.bind(this)],blur:["input",n.onFocusBlur.bind(this)],keydown:["input",n.onKeydown.bind(this)],click:["scope",n.onClickScope.bind(this)],dblclick:["scope",n.onDoubleClickScope.bind(this)]})this.DOM[e[a][0]][s](a,e[a][1])},callbacks:{onFocusBlur:function(t){var e=t.target.textContent.trim();"mix"!=this.settings.mode&&("focus"==t.type?(this.DOM.scope.classList.add("tagify--focus"),0===this.settings.dropdown.enabled&&this.dropdown.show.call(this)):"blur"==t.type?(this.DOM.scope.classList.remove("tagify--focus"),e&&this.settings.addTagOnBlur&&this.addTags(e,!0).length):(this.DOM.input.removeAttribute("style"),this.dropdown.hide.call(this)))},onKeydown:function(t){var e,i=this,n=t.target.textContent.trim();if("mix"==this.settings.mode){switch(t.key){case"Delete":case"Backspace":var s=[];e=this.DOM.input.children,setTimeout(function(){[].forEach.call(e,function(t){return s.push(t.getAttribute("value"))}),i.value=i.value.filter(function(t){return-1!=s.indexOf(t.value)})},20);break;case"Enter":t.preventDefault()}return!0}switch(t.key){case"Backspace":""!=n&&8203!=n.charCodeAt(0)||(!0===this.settings.backspace?this.removeTag():"edit"==this.settings.backspace&&this.editTag());break;case"Esc":case"Escape":this.input.set.call(this),t.target.blur();break;case"ArrowRight":case"Tab":if(!n)return!0;case"Enter":t.preventDefault(),this.addTags(n,!0)}},onInput:function(t){var e=this.input.normalize.call(this),i=e.length>=this.settings.dropdown.enabled,n={value:e,inputElm:this.DOM.input};if("mix"==this.settings.mode)return this.events.callbacks.onMixTagsInput.call(this,t);e?this.input.value!=e&&(n.isValid=this.validateTag.call(this,e),this.input.set.call(this,e,!1),this.trigger("input",n),-1!=e.search(this.settings.delimiters)?this.addTags(e).length&&this.input.set.call(this):0<=this.settings.dropdown.enabled&&this.dropdown[i?"show":"hide"].call(this,e)):this.input.set.call(this,"")},onMixTagsInput:function(t){var e,i,n,s,a;if(this.maxTagsReached())return!0;window.getSelection&&0<(e=window.getSelection()).rangeCount&&((i=e.getRangeAt(0).cloneRange()).collapse(!0),i.setStart(window.getSelection().focusNode,0),(s=(n=i.toString().split(this.settings.mixTagsAllowedAfter))[n.length-1].match(this.settings.pattern))&&(this.state.tag={prefix:s[0],value:s.input.split(s[0])[1]},s=this.state.tag,a=this.state.tag.value.length>=this.settings.dropdown.enabled)),this.update(),this.trigger("input",this.extend({},this.state.tag,{textContent:this.DOM.input.textContent})),this.state.tag&&this.dropdown[a?"show":"hide"].call(this,this.state.tag.value)},onInputIE:function(t){var e=this;setTimeout(function(){e.events.callbacks.onInput.call(e,t)})},onPaste:function(t){},onClickScope:function(t){var e,i=t.target.closest("tag");"TAGS"==t.target.tagName?this.DOM.input.focus():"X"==t.target.tagName?this.removeTag(t.target.parentNode):i&&(e=this.getNodeIndex(i),this.trigger("click",{tag:i,index:e,data:this.value[e]}))},onEditTagInput:function(t){var e=t.closest("tag"),i=this.getNodeIndex(e),n=this.input.normalize(t),s=n.toLowerCase()==t.originalValue.toLowerCase()||this.validateTag(n);e.classList.toggle("tagify--invalid",!0!==s),e.isValid=s,this.trigger("input",{tag:e,index:i,data:this.extend({},this.value[i],{newValue:n})})},onEditTagBlur:function(t){var e,i=t.closest("tag"),n=this.getNodeIndex(i),s=this.input.normalize(t),a=s||t.originalValue,o=this.input.normalize(t)!=t.originalValue,r=i.isValid,l=_objectSpread({},this.value[n],{value:a});s?(o&&(this.settings.transformTag.call(this,l),r=this.validateTag(l.value)),void 0!==r&&!0!==r||(t.textContent=l.value,this.value[n].value=l.value,this.update(),(e=t.cloneNode(!0)).removeAttribute("contenteditable"),i.title=l.value,i.classList.remove("tagify--editable"),t.parentNode.replaceChild(e,t),this.trigger("edit",{tag:i,index:n,data:this.value[n]}))):this.removeTag(i)},onEditTagkeydown:function(t){switch(t.key){case"Esc":case"Escape":t.target.textContent=t.target.originalValue;case"Enter":case"Tab":t.preventDefault(),t.target.blur()}},onDoubleClickScope:function(t){var e,i,n=t.target.closest("tag"),s=this.settings;n&&(e=n.classList.contains("tagify--editable"),i=n.hasAttribute("readonly"),"mix"==s.mode||s.readonly||s.enforceWhitelist||e||i||this.editTag(n))}}},editTag:function(t){var e=this,i=0<arguments.length&&void 0!==t?t:this.getLastTag(),n=i.querySelector(".tagify__tag-text"),s=this.events.callbacks;if(n)return i.classList.add("tagify--editable"),n.originalValue=n.textContent,n.setAttribute("contenteditable",!0),n.addEventListener("blur",s.onEditTagBlur.bind(this,n)),n.addEventListener("input",s.onEditTagInput.bind(this,n)),n.addEventListener("keydown",function(t){return s.onEditTagkeydown.call(e,t)}),n.focus(),this;console.warn("Cannot find element in Tag template: ",".tagify__tag-text")},input:{value:"",set:function(t,e){var i=0<arguments.length&&void 0!==t?t:"",n=!(1<arguments.length&&void 0!==e)||e;this.input.value=i,n&&(this.DOM.input.innerHTML=i),i||this.dropdown.hide.call(this),i.length<2&&this.input.autocomplete.suggest.call(this,""),this.input.validate.call(this)},setRangeAtStartEnd:function(t,e){var i,n,s=0<arguments.length&&void 0!==t&&t,a=1<arguments.length?e:void 0;document.createRange&&((i=document.createRange()).selectNodeContents(a||this.DOM.input),i.collapse(s),(n=window.getSelection()).removeAllRanges(),n.addRange(i))},validate:function(){var t=!this.input.value||this.validateTag.call(this,this.input.value);this.DOM.input.classList.toggle("tagify__input--invalid",!0!==t)},normalize:function(t){var e=(0<arguments.length&&void 0!==t?t:this.DOM.input).innerText;return"settings"in this&&this.settings.delimiters&&(e=e.replace(/(?:\r\n|\r|\n)/g,this.settings.delimiters.source.charAt(1))),e=e.replace(/\s/g," ").replace(/^\s+/,"")},autocomplete:{suggest:function(t){t&&this.input.value?this.DOM.input.setAttribute("data-suggest",t.substring(this.input.value.length)):this.DOM.input.removeAttribute("data-suggest")},set:function(t){var e=this.DOM.input.getAttribute("data-suggest"),i=t||(e?this.input.value+e:null);return!!i&&(this.input.set.call(this,i),this.input.autocomplete.suggest.call(this,""),this.dropdown.hide.call(this),this.input.setRangeAtStartEnd.call(this),!0)}}},getNodeIndex:function(t){var e=0;if(t)for(;t=t.previousElementSibling;)e++;return e},getTagElms:function(){return this.DOM.scope.querySelectorAll("tag")},getLastTag:function(){var t=this.DOM.scope.querySelectorAll("tag:not(.tagify--hide):not([readonly])");return t[t.length-1]},isTagDuplicate:function(e){return this.value.some(function(t){return"string"==typeof e?e.trim().toLowerCase()===t.value.toLowerCase():JSON.stringify(t).toLowerCase()===JSON.stringify(e).toLowerCase()})},getTagIndexByValue:function(i){var n=[];return this.getTagElms().forEach(function(t,e){t.textContent.trim().toLowerCase()==i.toLowerCase()&&n.push(e)}),n},getTagElmByValue:function(t){var e=this.getTagIndexByValue(t)[0];return this.getTagElms()[e]},markTagByValue:function(t,e){return!!(e=e||this.getTagElmByValue(t))&&(e.classList.add("tagify--mark"),e)},isTagBlacklisted:function(e){return e=e.toLowerCase().trim(),this.settings.blacklist.filter(function(t){return e==t.toLowerCase()}).length},isTagWhitelisted:function(e){return this.settings.whitelist.some(function(t){if((t.value||t).toLowerCase()===e.toLowerCase())return!0})},validateTag:function(t){var e=t.trim(),i=!0;return e?this.settings.pattern&&!this.settings.pattern.test(e)?i=this.TEXTS.pattern:!this.settings.duplicates&&this.isTagDuplicate(e)?i=this.TEXTS.duplicate:(this.isTagBlacklisted(e)||this.settings.enforceWhitelist&&!this.isTagWhitelisted(e))&&(i=this.TEXTS.notAllowed):i=this.TEXTS.empty,i},maxTagsReached:function(){return this.value.length>=this.settings.maxTags&&this.TEXTS.exceed},normalizeTags:function(t){function i(t){return t.split(a).filter(function(t){return t}).map(function(t){return{value:t.trim()}})}var e,n=this.settings,s=n.whitelist,a=n.delimiters,o=n.mode,r=!!s&&s[0]instanceof Object,l=t instanceof Array&&t[0]instanceof Object&&"value"in t[0],d=[];if(l)return t=(e=[]).concat.apply(e,_toConsumableArray(t.map(function(e){return i(e.value).map(function(t){return _objectSpread({},e,{},t)})})));if("number"==typeof t&&(t=t.toString()),"string"==typeof t){if(!t.trim())return[];t=i(t)}else if(!l&&t instanceof Array){var c;t=(c=[]).concat.apply(c,_toConsumableArray(t.map(function(t){return i(t)})))}return r&&(t.forEach(function(e){var t=s.filter(function(t){return t.value.toLowerCase()==e.value.toLowerCase()});t[0]?d.push(t[0]):"mix"!=o&&d.push(e)}),t=d),t},parseMixTags:function(t){var a=this,e=this.settings,o=e.mixTagsInterpolator,r=e.duplicates,l=e.transformTag;return t=t.split(o[0]).map(function(t){var e,i,n=t.split(o[1]),s=n[0];try{e=JSON.parse(s)}catch(t){e=a.normalizeTags(s)[0]}return 1<n.length&&a.isTagWhitelisted(e.value)&&(r||!a.isTagDuplicate(e.value))&&(l.call(a,e),i=a.createTagElem(e),n[0]=i.outerHTML+"&#8288;",a.value.push(e)),n.join("")}).join(""),this.DOM.input.innerHTML=t,this.update(),t},addMixTag:function(t){if(t&&this.state.tag){for(var e,i,n,s,a=this.state.tag.prefix+this.state.tag.value,o=document.createNodeIterator(this.DOM.input,NodeFilter.SHOW_TEXT,null,!1),r=100;(e=o.nextNode())&&r--;)if(e.nodeType===Node.TEXT_NODE){if(-1==(n=e.nodeValue.indexOf(a)))continue;s=e.splitText(n),this.settings.transformTag.call(this,t),i=this.createTagElem(t),s.nodeValue=s.nodeValue.replace(a,""),e.parentNode.insertBefore(i,s),i.insertAdjacentHTML("afterend","&#8288;")}i&&(this.value.push(t),this.update(),this.trigger("add",this.extend({},{index:this.value.length,tag:i},t))),this.state.tag=null}},addEmptyTag:function(){var t={value:""},e=this.createTagElem(t);this.appendTag.call(this,e),this.value.push(t),this.update(),this.editTag(e)},addTags:function(t,e,i){var s=this,a=2<arguments.length&&void 0!==i?i:this.settings.skipInvalid,o=[];return t&&t.length?(t=this.normalizeTags.call(this,t),"mix"==this.settings.mode?this.addMixTag(t[0]):(this.DOM.input.removeAttribute("style"),t.forEach(function(t){var e,i,n={};if(t=Object.assign({},t),s.settings.transformTag.call(s,t),!0!==(e=s.maxTagsReached()||s.validateTag.call(s,t.value))){if(a)return;n["aria-invalid"]=!0,n.class=(t.class||"")+" tagify--notAllowed",n.title=e,s.markTagByValue(t.value),s.trigger("invalid",{data:t,index:s.value.length,message:e})}n.role="tag",t.readonly&&(n["aria-readonly"]=!0),i=s.createTagElem(s.extend({},t,n)),o.push(i),s.appendTag(i),!0===e?(s.value.push(t),s.update(),s.trigger("add",{tag:i,index:s.value.length-1,data:t})):s.settings.keepInvalidTags||setTimeout(function(){s.removeTag(i,!0)},1e3)}),t.length&&e&&this.input.set.call(this),o)):o},appendTag:function(t){var e=this.DOM.scope.lastElementChild;e===this.DOM.input?this.DOM.scope.insertBefore(t,e):this.DOM.scope.appendChild(t)},minify:function(t){return t.replace(new RegExp(">[\r\n ]+<","g"),"><")},createTagElem:function(t){var e=this.escapeHTML(t.value),i=this.settings.templates.tag.call(this,e,t);return this.settings.readonly&&(t.readonly=!0),i=this.minify(i),this.parseHTML(i)},removeTag:function(t,e,i){var n=this,s=0<arguments.length&&void 0!==t?t:this.getLastTag(),a=1<arguments.length?e:void 0,o=2<arguments.length&&void 0!==i?i:250;if("string"==typeof s&&(s=this.getTagElmByValue(s)),s instanceof HTMLElement){var r,l=this.getNodeIndex(s),d=function(){s.parentNode&&(s.parentNode.removeChild(s),a||(r=n.value.splice(l,1)[0],n.update(),n.trigger("remove",{tag:s,index:l,data:r}),n.dropdown.render.call(n)))};o&&10<o?(s.style.width=parseFloat(window.getComputedStyle(s).width)+"px",document.body.clientTop,s.classList.add("tagify--hide"),setTimeout(d,400)):d()}},removeAllTags:function(){this.value=[],this.update(),Array.prototype.slice.call(this.getTagElms()).forEach(function(t){return t.parentNode.removeChild(t)})},getAttributes:function(t){if("[object Object]"!=Object.prototype.toString.call(t))return"";var e,i,n=Object.keys(t),s="";for(i=n.length;i--;)"class"!=(e=n[i])&&t.hasOwnProperty(e)&&t[e]&&(s+=" "+e+(t[e]?'="'.concat(t[e],'"'):""));return s},preUpdate:function(){this.DOM.scope.classList.toggle("hasMaxTags",this.value.length>=this.settings.maxTags)},update:function(){this.preUpdate(),this.DOM.originalInput.value="mix"==this.settings.mode?this.getMixedTagsAsString():this.value.length?JSON.stringify(this.value):""},getMixedTagsAsString:function(){var e=this,i="",n=0,s=this.settings.mixTagsInterpolator;return this.DOM.input.childNodes.forEach(function(t){1==t.nodeType&&t.classList.contains("tagify__tag")?i+=s[0]+JSON.stringify(e.value[n++])+s[1]:i+=t.textContent}),i},dropdown:{init:function(){this.DOM.dropdown=this.dropdown.build.call(this)},build:function(){var t=this.settings.dropdown,e=t.position,i=t.classname,n="".concat("manual"==e?"":"tagify__dropdown"," ").concat(i).trim(),s='<div class="'.concat(n,'" role="menu"></div>');return this.parseHTML(s)},show:function(t){var e,i="manual"==this.settings.dropdown.position;if(this.settings.whitelist.length){if(this.suggestedListItems=this.dropdown.filterListItems.call(this,t),!this.suggestedListItems.length)return this.input.autocomplete.suggest.call(this),void this.dropdown.hide.call(this);e=this.dropdown.createListHTML.call(this,this.suggestedListItems),this.DOM.dropdown.innerHTML=this.minify(e),this.settings.enforceWhitelist&&!i&&this.dropdown.highlightOption.call(this,this.DOM.dropdown.children[0]),this.DOM.scope.setAttribute("aria-expanded",!0),this.trigger("dropdown:show",this.DOM.dropdown),document.body.contains(this.DOM.dropdown)||(i||(this.dropdown.position.call(this),document.body.appendChild(this.DOM.dropdown),this.events.binding.call(this,!1)),this.dropdown.events.binding.call(this))}},hide:function(t){var e=this.DOM,i=e.scope,n=e.dropdown,s="manual"==this.settings.dropdown.position&&!t;n&&document.body.contains(n)&&!s&&(window.removeEventListener("resize",this.dropdown.position),this.dropdown.events.binding.call(this,!1),this.events.binding.call(this),i.setAttribute("aria-expanded",!1),n.parentNode.removeChild(n),this.trigger("dropdown:hide",n))},render:function(){this.suggestedListItems=this.dropdown.filterListItems.call(this,"");var t=this.dropdown.createListHTML.call(this,this.suggestedListItems);this.DOM.dropdown.innerHTML=this.minify(t)},position:function(){var t=this.DOM.scope.getBoundingClientRect();this.DOM.dropdown.style.cssText="left: "+(t.left+window.pageXOffset)+"px; top: "+(t.top+t.height-1+window.pageYOffset)+"px; width: "+t.width+"px"},events:{binding:function(t){var e=!(0<arguments.length&&void 0!==t)||t,i=this.dropdown.events.callbacks,n=this.listeners.dropdown=this.listeners.dropdown||{position:this.dropdown.position.bind(this),onKeyDown:i.onKeyDown.bind(this),onMouseOver:i.onMouseOver.bind(this),onClick:i.onClick.bind(this)},s=e?"addEventListener":"removeEventListener";"manual"!=this.settings.dropdown.position&&(window[s]("resize",n.position),window[s]("keydown",n.onKeyDown)),window[s]("mousedown",n.onClick),this.DOM.dropdown[s]("mouseover",n.onMouseOver)},callbacks:{onKeyDown:function(t){var e=this.DOM.dropdown.querySelector("[class$='--active']"),i=e,n="";switch(t.key){case"ArrowDown":case"ArrowUp":case"Down":case"Up":t.preventDefault(),i=(i=i&&i[("ArrowUp"==t.key||"Up"==t.key?"previous":"next")+"ElementSibling"])||this.DOM.dropdown.children["ArrowUp"==t.key||"Up"==t.key?this.DOM.dropdown.children.length-1:0],this.dropdown.highlightOption.call(this,i,!0);break;case"Escape":case"Esc":this.dropdown.hide.call(this);break;case"ArrowRight":case"Tab":if(!e||!this.input.autocomplete.set.call(this,i?i.textContent:null))return!1;case"Enter":if(t.preventDefault(),e)return n=this.suggestedListItems[this.getNodeIndex(e)]||this.input.value,this.addTags([n],!0),this.dropdown.hide.call(this),0===this.settings.dropdown.enabled&&this.dropdown.show.call(this),!1;this.addTags(this.input.value,!0)}},onMouseOver:function(t){t.target.className.includes("__item")&&this.dropdown.highlightOption.call(this,t.target)},onClick:function(t){var e,i,n=this;if(0==t.button&&t.target!=this.DOM.dropdown){if(i=t.target.closest(".tagify__dropdown__item")){if(i.parentNode!==this.DOM.dropdown)return;e=this.suggestedListItems[this.getNodeIndex(i)]||this.input.value,this.addTags([e],!0),setTimeout(function(){return n.DOM.input.focus()},100)}this.dropdown.hide.call(this)}}}},highlightOption:function(t,e){if(t){var i,n="tagify__dropdown__item--active";this.DOM.dropdown.querySelectorAll("[class$='--active']").forEach(function(t){t.classList.remove(n),t.removeAttribute("aria-selected")}),t.classList.add(n),t.setAttribute("aria-selected",!0),e&&(t.parentNode.scrollTop=t.clientHeight+t.offsetTop-t.parentNode.clientHeight),this.settings.autoComplete&&!this.settings.dropdown.fuzzySearch&&(i=this.suggestedListItems[this.getNodeIndex(t)].value||this.input.value,this.input.autocomplete.suggest.call(this,i))}},filterListItems:function(t){var e,i,n,s,a=this,o=[],r=this.settings.whitelist,l=this.settings.dropdown.maxItems||1/0,d=0;if(!t)return r.filter(function(t){return!a.isTagDuplicate(t.value||t)}).slice(0,l);for(;d<r.length&&(n=(((e=r[d]instanceof Object?r[d]:{value:r[d]}).searchBy||"")+" "+e.value).toLowerCase().indexOf(t.toLowerCase()),i=this.settings.dropdown.fuzzySearch?0<=n:0==n,s=!this.settings.duplicates&&this.isTagDuplicate(e.value),i&&!s&&l--&&o.push(e),0!=l);d++);return o},createListHTML:function(t){var e=this.settings.templates.dropdownItem.bind(this);return t.map(e).join("")}}}}(jQuery);
/**
* Tagify (v 2.27.0)- tags input component
* Tagify (v 2.28.0)- tags input component
* By Yair Even-Or

@@ -581,2 +581,6 @@ * Don't sell this code. (c)

},
/**
* @param {Node} tagElm the tag element to edit. if nothing specified, use last last
*/
editTag: function editTag() {

@@ -603,2 +607,3 @@ var _this4 = this;

editableElm.focus();
return this;
},

@@ -699,9 +704,10 @@

* Searches if any tag with a certain value already exis
* @param {String} s [text value to search for]
* @return {int} [Position index of the tag. -1 is returned if tag is not found.]
* @param {String/Object} v [text value / tag data object]
* @return {Boolean}
*/
isTagDuplicate: function isTagDuplicate(s) {
return this.value.findIndex(function (item) {
return s.trim().toLowerCase() === item.value.toLowerCase();
}); // return this.value.some(item => s.toLowerCase() === item.value.toLowerCase());
isTagDuplicate: function isTagDuplicate(v) {
// change to Array.Some
return this.value.some(function (item) {
return typeof v == 'string' ? v.trim().toLowerCase() === item.value.toLowerCase() : JSON.stringify(item).toLowerCase() === JSON.stringify(v).toLowerCase();
});
},

@@ -769,3 +775,3 @@ getTagIndexByValue: function getTagIndexByValue(value) {

else if (this.settings.pattern && !this.settings.pattern.test(value)) result = this.TEXTS.pattern; // if duplicates are not allowed and there is a duplicate
else if (!this.settings.duplicates && this.isTagDuplicate(value) !== -1) result = this.TEXTS.duplicate;else if (this.isTagBlacklisted(value) || this.settings.enforceWhitelist && !this.isTagWhitelisted(value)) result = this.TEXTS.notAllowed;
else if (!this.settings.duplicates && this.isTagDuplicate(value)) result = this.TEXTS.duplicate;else if (this.isTagBlacklisted(value) || this.settings.enforceWhitelist && !this.isTagWhitelisted(value)) result = this.TEXTS.notAllowed;
return result;

@@ -854,9 +860,18 @@ },

mixTagsInterpolator = _this$settings2.mixTagsInterpolator,
duplicates = _this$settings2.duplicates;
duplicates = _this$settings2.duplicates,
transformTag = _this$settings2.transformTag;
s = s.split(mixTagsInterpolator[0]).map(function (s1) {
var s2 = s1.split(mixTagsInterpolator[1]),
preInterpolated = s2[0],
tagData,
tagElm;
if (s2.length > 1 && _this5.isTagWhitelisted(s2[0]) && (duplicates || _this5.isTagDuplicate(s2[0]) === -1)) {
tagData = _this5.normalizeTags(s2[0])[0];
try {
tagData = JSON.parse(preInterpolated);
} catch (err) {
tagData = _this5.normalizeTags(preInterpolated)[0]; //{value:preInterpolated}
}
if (s2.length > 1 && _this5.isTagWhitelisted(tagData.value) && (duplicates || !_this5.isTagDuplicate(tagData.value))) {
transformTag.call(_this5, tagData);
tagElm = _this5.createTagElem(tagData);

@@ -881,3 +896,3 @@ s2[0] = tagElm.outerHTML + "&#8288;"; // put a zero-space at the end so the caret so it won't jump back to the start (when the last input's child element is a tag)

var tag = this.state.tag.prefix + this.state.tag.value,
iter = document.createNodeIterator(this.DOM.input, NodeFilter.SHOW_TEXT),
iter = document.createNodeIterator(this.DOM.input, NodeFilter.SHOW_TEXT, null, false),
textnode,

@@ -919,2 +934,17 @@ tagElm,

/**
* add an empty "tag" element in an editable state
*/
addEmptyTag: function addEmptyTag() {
var tagData = {
value: ""
},
tagElm = this.createTagElem(tagData); // add the tag to the component's DOM
this.appendTag.call(this, tagElm);
this.value.push(tagData);
this.update();
this.editTag(tagElm);
},
/**
* add a "tag" element to the "tags" component

@@ -976,3 +1006,3 @@ * @param {String/Array} tagsItems [A string (single or multiple values with a delimiter), or an Array of Objects or just Array of Strings]

appendTag.call(_this6, tagElm);
_this6.appendTag(tagElm);

@@ -1001,15 +1031,14 @@ if (tagValidation === true) {

}
/**
* appened (validated) tag to the component's DOM scope
* @return {[type]} [description]
*/
function appendTag(tagElm) {
var insertBeforeNode = this.DOM.scope.lastElementChild;
if (insertBeforeNode === this.DOM.input) this.DOM.scope.insertBefore(tagElm, insertBeforeNode);else this.DOM.scope.appendChild(tagElm);
}
return tagElems;
},
/**
* appened (validated) tag to the component's DOM scope
* @return {[type]} [description]
*/
appendTag: function appendTag(tagElm) {
var insertBeforeNode = this.DOM.scope.lastElementChild;
if (insertBeforeNode === this.DOM.input) this.DOM.scope.insertBefore(tagElm, insertBeforeNode);else this.DOM.scope.appendChild(tagElm);
},
minify: function minify(html) {

@@ -1117,7 +1146,9 @@ return html.replace(new RegExp("\>[\r\n ]+\<", "g"), "><");

getMixedTagsAsString: function getMixedTagsAsString() {
var result = "";
this.DOM.input.childNodes.forEach(function (node, i) {
if (node.nodeType == 1) {
if (node.classList.contains("tagify__tag")) result += "[[" + node.getAttribute("value") + "]]";
} else result += node.textContent;
var _this8 = this;
var result = "",
i = 0,
_interpolator = this.settings.mixTagsInterpolator;
this.DOM.input.childNodes.forEach(function (node) {
if (node.nodeType == 1 && node.classList.contains("tagify__tag")) result += _interpolator[0] + JSON.stringify(_this8.value[i++]) + _interpolator[1];else result += node.textContent;
});

@@ -1162,3 +1193,3 @@ return result;

this.settings.enforceWhitelist && !isManual && this.dropdown.highlightOption.call(this, this.DOM.dropdown.querySelector('.tagify__dropdown__item'));
this.settings.enforceWhitelist && !isManual && this.dropdown.highlightOption.call(this, this.DOM.dropdown.children[0]);
this.DOM.scope.setAttribute("aria-expanded", true);

@@ -1222,7 +1253,8 @@ this.trigger("dropdown:show", this.DOM.dropdown); // if the dropdown has yet to be appended to the document,

// references to the ".bind()" methods must be saved so they could be unbinded later
var _CBR = this.listeners.dropdown = this.listeners.dropdown || {
var _CB = this.dropdown.events.callbacks,
_CBR = this.listeners.dropdown = this.listeners.dropdown || {
position: this.dropdown.position.bind(this),
onKeyDown: this.dropdown.events.callbacks.onKeyDown.bind(this),
onMouseOver: this.dropdown.events.callbacks.onMouseOver.bind(this),
onClick: this.dropdown.events.callbacks.onClick.bind(this)
onKeyDown: _CB.onKeyDown.bind(this),
onMouseOver: _CB.onMouseOver.bind(this),
onClick: _CB.onClick.bind(this)
},

@@ -1241,7 +1273,5 @@ action = bindUnbind ? 'addEventListener' : 'removeEventListener';

onKeyDown: function onKeyDown(e) {
var _this8 = this;
// get the "active" element, and if there was none (yet) active, use first child
var activeListElm = this.DOM.dropdown.querySelector("[class$='--active']"),
selectedElm = activeListElm || this.DOM.dropdown.children[0],
selectedElm = activeListElm,
newValue = "";

@@ -1271,4 +1301,4 @@

case 'Tab':
e.preventDefault();
if (!this.input.autocomplete.set.call(this, selectedElm ? selectedElm.textContent : null)) return false;
// e.preventDefault();
if (!activeListElm || !this.input.autocomplete.set.call(this, selectedElm ? selectedElm.textContent : null)) return false;

@@ -1282,5 +1312,7 @@ case 'Enter':

this.dropdown.hide.call(this);
setTimeout(function () {
return _this8.DOM.input.focus();
}, 100);
if (this.settings.dropdown.enabled === 0) {
this.dropdown.show.call(this);
}
return false;

@@ -1360,3 +1392,3 @@ } else {

return whitelist.filter(function (item) {
return _this10.isTagDuplicate(item.value || item) == -1;
return !_this10.isTagDuplicate(item.value || item);
}) // don't include tags which have already been added.

@@ -1374,3 +1406,3 @@ .slice(0, suggestionsCount); // respect "maxItems" dropdown setting

valueIsInWhitelist = this.settings.dropdown.fuzzySearch ? whitelistItemValueIndex >= 0 : whitelistItemValueIndex == 0;
isDuplicate = !this.settings.duplicates && this.isTagDuplicate(whitelistItem.value) > -1; // match for the value within each "whitelist" item
isDuplicate = !this.settings.duplicates && this.isTagDuplicate(whitelistItem.value); // match for the value within each "whitelist" item

@@ -1377,0 +1409,0 @@ if (valueIsInWhitelist && !isDuplicate && suggestionsCount--) list.push(whitelistItem);

/**
* Tagify (v 2.27.0)- tags input component
* Tagify (v 2.28.0)- tags input component
* By Yair Even-Or

@@ -7,2 +7,2 @@ * Don't sell this code. (c)

*/
!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.Tagify=e()}(this,function(){"use strict";function h(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function n(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function u(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(i,!0).forEach(function(t){s(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function s(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function t(t,e){if(!t)return console.warn("Tagify: ","invalid input element ",t),this;this.applySettings(t,e),this.state={},this.value=[],this.listeners={},this.DOM={},this.extend(this,new this.EventDispatcher(this)),this.build(t),this.loadOriginalValues(),this.events.customBinding.call(this),this.events.binding.call(this),t.autofocus&&this.DOM.input.focus()}return t.prototype={isIE:window.document.documentMode,TEXTS:{empty:"empty",exceed:"number of tags exceeded",pattern:"pattern mismatch",duplicate:"already exists",notAllowed:"not allowed"},DEFAULTS:{delimiters:",",pattern:null,maxTags:1/0,callbacks:{},addTagOnBlur:!0,duplicates:!1,whitelist:[],blacklist:[],enforceWhitelist:!1,keepInvalidTags:!1,autoComplete:!0,mixTagsAllowedAfter:/,|\.|\:|\s/,mixTagsInterpolator:["[[","]]"],backspace:!0,skipInvalid:!1,transformTag:function(){},dropdown:{classname:"",enabled:2,maxItems:10,itemTemplate:"",fuzzySearch:!0}},templates:{wrapper:function(t,e){return'<tags class="tagify '.concat(e.mode?"tagify--mix":""," ").concat(t.className,'"\n ').concat(e.readonly?'readonly aria-readonly="true"':'aria-haspopup="true" aria-expanded="false"','\n role="tagslist">\n <span contenteditable data-placeholder="').concat(t.placeholder||"&#8203;",'" aria-placeholder="').concat(t.placeholder||"",'"\n class="tagify__input"\n role="textbox"\n aria-multiline="false"></span>\n </tags>')},tag:function(t,e){return"<tag title='".concat(e.title||t,"'\n contenteditable='false'\n spellcheck='false'\n class='tagify__tag ").concat(e.class?e.class:"","'\n ").concat(this.getAttributes(e),">\n <x title='' class='tagify__tag__removeBtn' role='button' aria-label='remove tag'></x>\n <div>\n <span class='tagify__tag-text'>").concat(t,"</span>\n </div>\n </tag>")},dropdownItem:function(t){var e=(t.value||t).replace(/`|'/g,"&#39;");return"<div ".concat(this.getAttributes(t),"\n class='tagify__dropdown__item ").concat(t.class?t.class:"",'\'\n tabindex="0"\n role="menuitem"\n aria-labelledby="dropdown-label">').concat(e,"</div>")}},customEventsList:["click","add","remove","invalid","input","edit"],applySettings:function(t,e){var i=t.getAttribute("data-whitelist"),n=t.getAttribute("data-blacklist");if(this.DEFAULTS.templates=this.templates,this.DEFAULTS.dropdown.itemTemplate=this.templates.dropdownItem,this.settings=this.extend({},this.DEFAULTS,e),this.settings.readonly=t.hasAttribute("readonly"),this.isIE&&(this.settings.autoComplete=!1),n&&(n=n.split(this.settings.delimiters))instanceof Array&&(this.settings.blacklist=n),i&&(i=i.split(this.settings.delimiters))instanceof Array&&(this.settings.whitelist=i),t.pattern)try{this.settings.pattern=new RegExp(t.pattern)}catch(t){}if(this.settings&&this.settings.delimiters)try{this.settings.delimiters=new RegExp(this.settings.delimiters,"g")}catch(t){}},parseHTML:function(t){return(new DOMParser).parseFromString(t.trim(),"text/html").body.firstElementChild},escapeHTML:function(t){var e=document.createTextNode(t),i=document.createElement("p");return i.appendChild(e),i.innerHTML},build:function(t){var e=this.DOM,i=this.settings.templates.wrapper(t,this.settings);e.originalInput=t,e.scope=this.parseHTML(i),e.input=e.scope.querySelector("[contenteditable]"),t.parentNode.insertBefore(e.scope,t),0<=this.settings.dropdown.enabled&&this.dropdown.init.call(this)},destroy:function(){this.DOM.scope.parentNode.removeChild(this.DOM.scope),this.dropdown.hide.call(this,!0)},loadOriginalValues:function(t){var e=0<arguments.length&&void 0!==t?t:this.DOM.originalInput.value;if(e){this.removeAllTags();try{e=JSON.parse(e)}catch(t){}"mix"==this.settings.mode?this.parseMixTags(e):this.addTags(e).forEach(function(t){return t&&t.classList.add("tagify--noAnim")})}},extend:function(t,e,i){function n(t){var e=Object.prototype.toString.call(t).split(" ")[1].slice(0,-1);return t===Object(t)&&"Array"!=e&&"Function"!=e&&"RegExp"!=e&&"HTMLUnknownElement"!=e}function s(t,e){for(var i in e)e.hasOwnProperty(i)&&(n(e[i])?n(t[i])?s(t[i],e[i]):t[i]=Object.assign({},e[i]):t[i]=e[i])}return t instanceof Object||(t={}),s(t,e),i&&s(t,i),t},EventDispatcher:function(n){var s=document.createTextNode("");this.off=function(t,e){return e&&s.removeEventListener.call(s,t,e),this},this.on=function(t,e){return e&&s.addEventListener.call(s,t,e),this},this.trigger=function(t,e){var i;if(t)if(n.settings.isJQueryPlugin)$(n.DOM.originalInput).triggerHandler(t,[e]);else{try{i=new CustomEvent(t,{detail:e})}catch(t){console.warn(t)}s.dispatchEvent(i)}}},events:{customBinding:function(){var e=this;this.customEventsList.forEach(function(t){e.on(t,e.settings.callbacks[t])})},binding:function(t){var e,i=!(0<arguments.length&&void 0!==t)||t,n=this.events.callbacks,s=i?"addEventListener":"removeEventListener";for(var a in i&&!this.listeners.main&&(this.DOM.input.addEventListener(this.isIE?"keydown":"input",n[this.isIE?"onInputIE":"onInput"].bind(this)),this.settings.isJQueryPlugin&&$(this.DOM.originalInput).on("tagify.removeAllTags",this.removeAllTags.bind(this))),e=this.listeners.main=this.listeners.main||{paste:["input",n.onPaste.bind(this)],focus:["input",n.onFocusBlur.bind(this)],blur:["input",n.onFocusBlur.bind(this)],keydown:["input",n.onKeydown.bind(this)],click:["scope",n.onClickScope.bind(this)],dblclick:["scope",n.onDoubleClickScope.bind(this)]})this.DOM[e[a][0]][s](a,e[a][1])},callbacks:{onFocusBlur:function(t){var e=t.target.textContent.trim();"mix"!=this.settings.mode&&("focus"==t.type?(this.DOM.scope.classList.add("tagify--focus"),0===this.settings.dropdown.enabled&&this.dropdown.show.call(this)):"blur"==t.type?(this.DOM.scope.classList.remove("tagify--focus"),e&&this.settings.addTagOnBlur&&this.addTags(e,!0).length):(this.DOM.input.removeAttribute("style"),this.dropdown.hide.call(this)))},onKeydown:function(t){var e,i=this,n=t.target.textContent.trim();if("mix"==this.settings.mode){switch(t.key){case"Delete":case"Backspace":var s=[];e=this.DOM.input.children,setTimeout(function(){[].forEach.call(e,function(t){return s.push(t.getAttribute("value"))}),i.value=i.value.filter(function(t){return-1!=s.indexOf(t.value)})},20);break;case"Enter":t.preventDefault()}return!0}switch(t.key){case"Backspace":""!=n&&8203!=n.charCodeAt(0)||(!0===this.settings.backspace?this.removeTag():"edit"==this.settings.backspace&&this.editTag());break;case"Esc":case"Escape":this.input.set.call(this),t.target.blur();break;case"ArrowRight":case"Tab":if(!n)return!0;case"Enter":t.preventDefault(),this.addTags(n,!0)}},onInput:function(t){var e=this.input.normalize.call(this),i=e.length>=this.settings.dropdown.enabled,n={value:e,inputElm:this.DOM.input};if("mix"==this.settings.mode)return this.events.callbacks.onMixTagsInput.call(this,t);e?this.input.value!=e&&(n.isValid=this.validateTag.call(this,e),this.input.set.call(this,e,!1),this.trigger("input",n),-1!=e.search(this.settings.delimiters)?this.addTags(e).length&&this.input.set.call(this):0<=this.settings.dropdown.enabled&&this.dropdown[i?"show":"hide"].call(this,e)):this.input.set.call(this,"")},onMixTagsInput:function(t){var e,i,n,s,a;if(this.maxTagsReached())return!0;window.getSelection&&0<(e=window.getSelection()).rangeCount&&((i=e.getRangeAt(0).cloneRange()).collapse(!0),i.setStart(window.getSelection().focusNode,0),(s=(n=i.toString().split(this.settings.mixTagsAllowedAfter))[n.length-1].match(this.settings.pattern))&&(this.state.tag={prefix:s[0],value:s.input.split(s[0])[1]},s=this.state.tag,a=this.state.tag.value.length>=this.settings.dropdown.enabled)),this.update(),this.trigger("input",this.extend({},this.state.tag,{textContent:this.DOM.input.textContent})),this.state.tag&&this.dropdown[a?"show":"hide"].call(this,this.state.tag.value)},onInputIE:function(t){var e=this;setTimeout(function(){e.events.callbacks.onInput.call(e,t)})},onPaste:function(t){},onClickScope:function(t){var e,i=t.target.closest("tag");"TAGS"==t.target.tagName?this.DOM.input.focus():"X"==t.target.tagName?this.removeTag(t.target.parentNode):i&&(e=this.getNodeIndex(i),this.trigger("click",{tag:i,index:e,data:this.value[e]}))},onEditTagInput:function(t){var e=t.closest("tag"),i=this.getNodeIndex(e),n=this.input.normalize(t),s=n.toLowerCase()==t.originalValue.toLowerCase()||this.validateTag(n);e.classList.toggle("tagify--invalid",!0!==s),e.isValid=s,this.trigger("input",{tag:e,index:i,data:this.extend({},this.value[i],{newValue:n})})},onEditTagBlur:function(t){var e,i=t.closest("tag"),n=this.getNodeIndex(i),s=this.input.normalize(t),a=s||t.originalValue,o=this.input.normalize(t)!=t.originalValue,r=i.isValid,l=u({},this.value[n],{value:a});s?(o&&(this.settings.transformTag.call(this,l),r=this.validateTag(l.value)),void 0!==r&&!0!==r||(t.textContent=l.value,this.value[n].value=l.value,this.update(),(e=t.cloneNode(!0)).removeAttribute("contenteditable"),i.title=l.value,i.classList.remove("tagify--editable"),t.parentNode.replaceChild(e,t),this.trigger("edit",{tag:i,index:n,data:this.value[n]}))):this.removeTag(i)},onEditTagkeydown:function(t){switch(t.key){case"Esc":case"Escape":t.target.textContent=t.target.originalValue;case"Enter":case"Tab":t.preventDefault(),t.target.blur()}},onDoubleClickScope:function(t){var e,i,n=t.target.closest("tag"),s=this.settings;n&&(e=n.classList.contains("tagify--editable"),i=n.hasAttribute("readonly"),"mix"==s.mode||s.readonly||s.enforceWhitelist||e||i||this.editTag(n))}}},editTag:function(t){var e=this,i=0<arguments.length&&void 0!==t?t:this.getLastTag(),n=i.querySelector(".tagify__tag-text"),s=this.events.callbacks;n?(i.classList.add("tagify--editable"),n.originalValue=n.textContent,n.setAttribute("contenteditable",!0),n.addEventListener("blur",s.onEditTagBlur.bind(this,n)),n.addEventListener("input",s.onEditTagInput.bind(this,n)),n.addEventListener("keydown",function(t){return s.onEditTagkeydown.call(e,t)}),n.focus()):console.warn("Cannot find element in Tag template: ",".tagify__tag-text")},input:{value:"",set:function(t,e){var i=0<arguments.length&&void 0!==t?t:"",n=!(1<arguments.length&&void 0!==e)||e;this.input.value=i,n&&(this.DOM.input.innerHTML=i),i||this.dropdown.hide.call(this),i.length<2&&this.input.autocomplete.suggest.call(this,""),this.input.validate.call(this)},setRangeAtStartEnd:function(t,e){var i,n,s=0<arguments.length&&void 0!==t&&t,a=1<arguments.length?e:void 0;document.createRange&&((i=document.createRange()).selectNodeContents(a||this.DOM.input),i.collapse(s),(n=window.getSelection()).removeAllRanges(),n.addRange(i))},validate:function(){var t=!this.input.value||this.validateTag.call(this,this.input.value);this.DOM.input.classList.toggle("tagify__input--invalid",!0!==t)},normalize:function(t){var e=(0<arguments.length&&void 0!==t?t:this.DOM.input).innerText;return"settings"in this&&this.settings.delimiters&&(e=e.replace(/(?:\r\n|\r|\n)/g,this.settings.delimiters.source.charAt(1))),e=e.replace(/\s/g," ").replace(/^\s+/,"")},autocomplete:{suggest:function(t){t&&this.input.value?this.DOM.input.setAttribute("data-suggest",t.substring(this.input.value.length)):this.DOM.input.removeAttribute("data-suggest")},set:function(t){var e=this.DOM.input.getAttribute("data-suggest"),i=t||(e?this.input.value+e:null);return!!i&&(this.input.set.call(this,i),this.input.autocomplete.suggest.call(this,""),this.dropdown.hide.call(this),this.input.setRangeAtStartEnd.call(this),!0)}}},getNodeIndex:function(t){var e=0;if(t)for(;t=t.previousElementSibling;)e++;return e},getTagElms:function(){return this.DOM.scope.querySelectorAll("tag")},getLastTag:function(){var t=this.DOM.scope.querySelectorAll("tag:not(.tagify--hide):not([readonly])");return t[t.length-1]},isTagDuplicate:function(e){return this.value.findIndex(function(t){return e.trim().toLowerCase()===t.value.toLowerCase()})},getTagIndexByValue:function(i){var n=[];return this.getTagElms().forEach(function(t,e){t.textContent.trim().toLowerCase()==i.toLowerCase()&&n.push(e)}),n},getTagElmByValue:function(t){var e=this.getTagIndexByValue(t)[0];return this.getTagElms()[e]},markTagByValue:function(t,e){return!!(e=e||this.getTagElmByValue(t))&&(e.classList.add("tagify--mark"),e)},isTagBlacklisted:function(e){return e=e.toLowerCase().trim(),this.settings.blacklist.filter(function(t){return e==t.toLowerCase()}).length},isTagWhitelisted:function(e){return this.settings.whitelist.some(function(t){if((t.value||t).toLowerCase()===e.toLowerCase())return!0})},validateTag:function(t){var e=t.trim(),i=!0;return e?this.settings.pattern&&!this.settings.pattern.test(e)?i=this.TEXTS.pattern:this.settings.duplicates||-1===this.isTagDuplicate(e)?(this.isTagBlacklisted(e)||this.settings.enforceWhitelist&&!this.isTagWhitelisted(e))&&(i=this.TEXTS.notAllowed):i=this.TEXTS.duplicate:i=this.TEXTS.empty,i},maxTagsReached:function(){return this.value.length>=this.settings.maxTags&&this.TEXTS.exceed},normalizeTags:function(t){function i(t){return t.split(a).filter(function(t){return t}).map(function(t){return{value:t.trim()}})}var e,n=this.settings,s=n.whitelist,a=n.delimiters,o=n.mode,r=!!s&&s[0]instanceof Object,l=t instanceof Array&&t[0]instanceof Object&&"value"in t[0],c=[];if(l)return t=(e=[]).concat.apply(e,h(t.map(function(e){return i(e.value).map(function(t){return u({},e,{},t)})})));if("number"==typeof t&&(t=t.toString()),"string"==typeof t){if(!t.trim())return[];t=i(t)}else if(!l&&t instanceof Array){var d;t=(d=[]).concat.apply(d,h(t.map(function(t){return i(t)})))}return r&&(t.forEach(function(e){var t=s.filter(function(t){return t.value.toLowerCase()==e.value.toLowerCase()});t[0]?c.push(t[0]):"mix"!=o&&c.push(e)}),t=c),t},parseMixTags:function(t){var n,s=this,e=this.settings,a=e.mixTagsInterpolator,o=e.duplicates;return t=t.split(a[0]).map(function(t){var e,i=t.split(a[1]);return 1<i.length&&s.isTagWhitelisted(i[0])&&(o||-1===s.isTagDuplicate(i[0]))&&(n=s.normalizeTags(i[0])[0],e=s.createTagElem(n),i[0]=e.outerHTML+"&#8288;",s.value.push(n)),i.join("")}).join(""),this.DOM.input.innerHTML=t,this.update(),t},addMixTag:function(t){if(t&&this.state.tag){for(var e,i,n,s,a=this.state.tag.prefix+this.state.tag.value,o=document.createNodeIterator(this.DOM.input,NodeFilter.SHOW_TEXT),r=100;(e=o.nextNode())&&r--;)if(e.nodeType===Node.TEXT_NODE){if(-1==(n=e.nodeValue.indexOf(a)))continue;s=e.splitText(n),this.settings.transformTag.call(this,t),i=this.createTagElem(t),s.nodeValue=s.nodeValue.replace(a,""),e.parentNode.insertBefore(i,s),i.insertAdjacentHTML("afterend","&#8288;")}i&&(this.value.push(t),this.update(),this.trigger("add",this.extend({},{index:this.value.length,tag:i},t))),this.state.tag=null}},addTags:function(t,e,i){var s=this,a=2<arguments.length&&void 0!==i?i:this.settings.skipInvalid,o=[];if(!t||!t.length)return o;if(t=this.normalizeTags.call(this,t),"mix"==this.settings.mode)return this.addMixTag(t[0]);return this.DOM.input.removeAttribute("style"),t.forEach(function(t){var e,i,n={};if(t=Object.assign({},t),s.settings.transformTag.call(s,t),!0!==(e=s.maxTagsReached()||s.validateTag.call(s,t.value))){if(a)return;n["aria-invalid"]=!0,n.class=(t.class||"")+" tagify--notAllowed",n.title=e,s.markTagByValue(t.value),s.trigger("invalid",{data:t,index:s.value.length,message:e})}n.role="tag",t.readonly&&(n["aria-readonly"]=!0),i=s.createTagElem(s.extend({},t,n)),o.push(i),function(t){var e=this.DOM.scope.lastElementChild;e===this.DOM.input?this.DOM.scope.insertBefore(t,e):this.DOM.scope.appendChild(t)}.call(s,i),!0===e?(s.value.push(t),s.update(),s.trigger("add",{tag:i,index:s.value.length-1,data:t})):s.settings.keepInvalidTags||setTimeout(function(){s.removeTag(i,!0)},1e3)}),t.length&&e&&this.input.set.call(this),o},minify:function(t){return t.replace(new RegExp(">[\r\n ]+<","g"),"><")},createTagElem:function(t){var e=this.escapeHTML(t.value),i=this.settings.templates.tag.call(this,e,t);return this.settings.readonly&&(t.readonly=!0),i=this.minify(i),this.parseHTML(i)},removeTag:function(t,e,i){var n=this,s=0<arguments.length&&void 0!==t?t:this.getLastTag(),a=1<arguments.length?e:void 0,o=2<arguments.length&&void 0!==i?i:250;if("string"==typeof s&&(s=this.getTagElmByValue(s)),s instanceof HTMLElement){var r,l=this.getNodeIndex(s),c=function(){s.parentNode&&(s.parentNode.removeChild(s),a||(r=n.value.splice(l,1)[0],n.update(),n.trigger("remove",{tag:s,index:l,data:r}),n.dropdown.render.call(n)))};o&&10<o?(s.style.width=parseFloat(window.getComputedStyle(s).width)+"px",document.body.clientTop,s.classList.add("tagify--hide"),setTimeout(c,400)):c()}},removeAllTags:function(){this.value=[],this.update(),Array.prototype.slice.call(this.getTagElms()).forEach(function(t){return t.parentNode.removeChild(t)})},getAttributes:function(t){if("[object Object]"!=Object.prototype.toString.call(t))return"";var e,i,n=Object.keys(t),s="";for(i=n.length;i--;)"class"!=(e=n[i])&&t.hasOwnProperty(e)&&t[e]&&(s+=" "+e+(t[e]?'="'.concat(t[e],'"'):""));return s},preUpdate:function(){this.DOM.scope.classList.toggle("hasMaxTags",this.value.length>=this.settings.maxTags)},update:function(){this.preUpdate(),this.DOM.originalInput.value="mix"==this.settings.mode?this.getMixedTagsAsString():this.value.length?JSON.stringify(this.value):""},getMixedTagsAsString:function(){var i="";return this.DOM.input.childNodes.forEach(function(t,e){1==t.nodeType?t.classList.contains("tagify__tag")&&(i+="[["+t.getAttribute("value")+"]]"):i+=t.textContent}),i},dropdown:{init:function(){this.DOM.dropdown=this.dropdown.build.call(this)},build:function(){var t=this.settings.dropdown,e=t.position,i=t.classname,n="".concat("manual"==e?"":"tagify__dropdown"," ").concat(i).trim(),s='<div class="'.concat(n,'" role="menu"></div>');return this.parseHTML(s)},show:function(t){var e,i="manual"==this.settings.dropdown.position;if(this.settings.whitelist.length){if(this.suggestedListItems=this.dropdown.filterListItems.call(this,t),!this.suggestedListItems.length)return this.input.autocomplete.suggest.call(this),void this.dropdown.hide.call(this);e=this.dropdown.createListHTML.call(this,this.suggestedListItems),this.DOM.dropdown.innerHTML=this.minify(e),this.settings.enforceWhitelist&&!i&&this.dropdown.highlightOption.call(this,this.DOM.dropdown.querySelector(".tagify__dropdown__item")),this.DOM.scope.setAttribute("aria-expanded",!0),this.trigger("dropdown:show",this.DOM.dropdown),document.body.contains(this.DOM.dropdown)||(i||(this.dropdown.position.call(this),document.body.appendChild(this.DOM.dropdown),this.events.binding.call(this,!1)),this.dropdown.events.binding.call(this))}},hide:function(t){var e=this.DOM,i=e.scope,n=e.dropdown,s="manual"==this.settings.dropdown.position&&!t;n&&document.body.contains(n)&&!s&&(window.removeEventListener("resize",this.dropdown.position),this.dropdown.events.binding.call(this,!1),this.events.binding.call(this),i.setAttribute("aria-expanded",!1),n.parentNode.removeChild(n),this.trigger("dropdown:hide",n))},render:function(){this.suggestedListItems=this.dropdown.filterListItems.call(this,"");var t=this.dropdown.createListHTML.call(this,this.suggestedListItems);this.DOM.dropdown.innerHTML=this.minify(t)},position:function(){var t=this.DOM.scope.getBoundingClientRect();this.DOM.dropdown.style.cssText="left: "+(t.left+window.pageXOffset)+"px; top: "+(t.top+t.height-1+window.pageYOffset)+"px; width: "+t.width+"px"},events:{binding:function(t){var e=!(0<arguments.length&&void 0!==t)||t,i=this.listeners.dropdown=this.listeners.dropdown||{position:this.dropdown.position.bind(this),onKeyDown:this.dropdown.events.callbacks.onKeyDown.bind(this),onMouseOver:this.dropdown.events.callbacks.onMouseOver.bind(this),onClick:this.dropdown.events.callbacks.onClick.bind(this)},n=e?"addEventListener":"removeEventListener";"manual"!=this.settings.dropdown.position&&(window[n]("resize",i.position),window[n]("keydown",i.onKeyDown)),window[n]("mousedown",i.onClick),this.DOM.dropdown[n]("mouseover",i.onMouseOver)},callbacks:{onKeyDown:function(t){var e=this,i=this.DOM.dropdown.querySelector("[class$='--active']"),n=i||this.DOM.dropdown.children[0],s="";switch(t.key){case"ArrowDown":case"ArrowUp":case"Down":case"Up":t.preventDefault(),n=(n=n&&n[("ArrowUp"==t.key||"Up"==t.key?"previous":"next")+"ElementSibling"])||this.DOM.dropdown.children["ArrowUp"==t.key||"Up"==t.key?this.DOM.dropdown.children.length-1:0],this.dropdown.highlightOption.call(this,n,!0);break;case"Escape":case"Esc":this.dropdown.hide.call(this);break;case"ArrowRight":case"Tab":if(t.preventDefault(),!this.input.autocomplete.set.call(this,n?n.textContent:null))return!1;case"Enter":if(t.preventDefault(),i)return s=this.suggestedListItems[this.getNodeIndex(i)]||this.input.value,this.addTags([s],!0),this.dropdown.hide.call(this),setTimeout(function(){return e.DOM.input.focus()},100),!1;this.addTags(this.input.value,!0)}},onMouseOver:function(t){t.target.className.includes("__item")&&this.dropdown.highlightOption.call(this,t.target)},onClick:function(t){var e,i,n=this;if(0==t.button&&t.target!=this.DOM.dropdown){if(i=t.target.closest(".tagify__dropdown__item")){if(i.parentNode!==this.DOM.dropdown)return;e=this.suggestedListItems[this.getNodeIndex(i)]||this.input.value,this.addTags([e],!0),setTimeout(function(){return n.DOM.input.focus()},100)}this.dropdown.hide.call(this)}}}},highlightOption:function(t,e){if(t){var i,n="tagify__dropdown__item--active";this.DOM.dropdown.querySelectorAll("[class$='--active']").forEach(function(t){t.classList.remove(n),t.removeAttribute("aria-selected")}),t.classList.add(n),t.setAttribute("aria-selected",!0),e&&(t.parentNode.scrollTop=t.clientHeight+t.offsetTop-t.parentNode.clientHeight),this.settings.autoComplete&&!this.settings.dropdown.fuzzySearch&&(i=this.suggestedListItems[this.getNodeIndex(t)].value||this.input.value,this.input.autocomplete.suggest.call(this,i))}},filterListItems:function(t){var e,i,n,s,a=this,o=[],r=this.settings.whitelist,l=this.settings.dropdown.maxItems||1/0,c=0;if(!t)return r.filter(function(t){return-1==a.isTagDuplicate(t.value||t)}).slice(0,l);for(;c<r.length&&(n=(((e=r[c]instanceof Object?r[c]:{value:r[c]}).searchBy||"")+" "+e.value).toLowerCase().indexOf(t.toLowerCase()),i=this.settings.dropdown.fuzzySearch?0<=n:0==n,s=!this.settings.duplicates&&-1<this.isTagDuplicate(e.value),i&&!s&&l--&&o.push(e),0!=l);c++);return o},createListHTML:function(t){var e=this.settings.templates.dropdownItem.bind(this);return t.map(e).join("")}}},t});
!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.Tagify=e()}(this,function(){"use strict";function h(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function n(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function u(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?n(i,!0).forEach(function(t){s(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):n(i).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function s(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function t(t,e){if(!t)return console.warn("Tagify: ","invalid input element ",t),this;this.applySettings(t,e),this.state={},this.value=[],this.listeners={},this.DOM={},this.extend(this,new this.EventDispatcher(this)),this.build(t),this.loadOriginalValues(),this.events.customBinding.call(this),this.events.binding.call(this),t.autofocus&&this.DOM.input.focus()}return t.prototype={isIE:window.document.documentMode,TEXTS:{empty:"empty",exceed:"number of tags exceeded",pattern:"pattern mismatch",duplicate:"already exists",notAllowed:"not allowed"},DEFAULTS:{delimiters:",",pattern:null,maxTags:1/0,callbacks:{},addTagOnBlur:!0,duplicates:!1,whitelist:[],blacklist:[],enforceWhitelist:!1,keepInvalidTags:!1,autoComplete:!0,mixTagsAllowedAfter:/,|\.|\:|\s/,mixTagsInterpolator:["[[","]]"],backspace:!0,skipInvalid:!1,transformTag:function(){},dropdown:{classname:"",enabled:2,maxItems:10,itemTemplate:"",fuzzySearch:!0}},templates:{wrapper:function(t,e){return'<tags class="tagify '.concat(e.mode?"tagify--mix":""," ").concat(t.className,'"\n ').concat(e.readonly?'readonly aria-readonly="true"':'aria-haspopup="true" aria-expanded="false"','\n role="tagslist">\n <span contenteditable data-placeholder="').concat(t.placeholder||"&#8203;",'" aria-placeholder="').concat(t.placeholder||"",'"\n class="tagify__input"\n role="textbox"\n aria-multiline="false"></span>\n </tags>')},tag:function(t,e){return"<tag title='".concat(e.title||t,"'\n contenteditable='false'\n spellcheck='false'\n class='tagify__tag ").concat(e.class?e.class:"","'\n ").concat(this.getAttributes(e),">\n <x title='' class='tagify__tag__removeBtn' role='button' aria-label='remove tag'></x>\n <div>\n <span class='tagify__tag-text'>").concat(t,"</span>\n </div>\n </tag>")},dropdownItem:function(t){var e=(t.value||t).replace(/`|'/g,"&#39;");return"<div ".concat(this.getAttributes(t),"\n class='tagify__dropdown__item ").concat(t.class?t.class:"",'\'\n tabindex="0"\n role="menuitem"\n aria-labelledby="dropdown-label">').concat(e,"</div>")}},customEventsList:["click","add","remove","invalid","input","edit"],applySettings:function(t,e){var i=t.getAttribute("data-whitelist"),n=t.getAttribute("data-blacklist");if(this.DEFAULTS.templates=this.templates,this.DEFAULTS.dropdown.itemTemplate=this.templates.dropdownItem,this.settings=this.extend({},this.DEFAULTS,e),this.settings.readonly=t.hasAttribute("readonly"),this.isIE&&(this.settings.autoComplete=!1),n&&(n=n.split(this.settings.delimiters))instanceof Array&&(this.settings.blacklist=n),i&&(i=i.split(this.settings.delimiters))instanceof Array&&(this.settings.whitelist=i),t.pattern)try{this.settings.pattern=new RegExp(t.pattern)}catch(t){}if(this.settings&&this.settings.delimiters)try{this.settings.delimiters=new RegExp(this.settings.delimiters,"g")}catch(t){}},parseHTML:function(t){return(new DOMParser).parseFromString(t.trim(),"text/html").body.firstElementChild},escapeHTML:function(t){var e=document.createTextNode(t),i=document.createElement("p");return i.appendChild(e),i.innerHTML},build:function(t){var e=this.DOM,i=this.settings.templates.wrapper(t,this.settings);e.originalInput=t,e.scope=this.parseHTML(i),e.input=e.scope.querySelector("[contenteditable]"),t.parentNode.insertBefore(e.scope,t),0<=this.settings.dropdown.enabled&&this.dropdown.init.call(this)},destroy:function(){this.DOM.scope.parentNode.removeChild(this.DOM.scope),this.dropdown.hide.call(this,!0)},loadOriginalValues:function(t){var e=0<arguments.length&&void 0!==t?t:this.DOM.originalInput.value;if(e){this.removeAllTags();try{e=JSON.parse(e)}catch(t){}"mix"==this.settings.mode?this.parseMixTags(e):this.addTags(e).forEach(function(t){return t&&t.classList.add("tagify--noAnim")})}},extend:function(t,e,i){function n(t){var e=Object.prototype.toString.call(t).split(" ")[1].slice(0,-1);return t===Object(t)&&"Array"!=e&&"Function"!=e&&"RegExp"!=e&&"HTMLUnknownElement"!=e}function s(t,e){for(var i in e)e.hasOwnProperty(i)&&(n(e[i])?n(t[i])?s(t[i],e[i]):t[i]=Object.assign({},e[i]):t[i]=e[i])}return t instanceof Object||(t={}),s(t,e),i&&s(t,i),t},EventDispatcher:function(n){var s=document.createTextNode("");this.off=function(t,e){return e&&s.removeEventListener.call(s,t,e),this},this.on=function(t,e){return e&&s.addEventListener.call(s,t,e),this},this.trigger=function(t,e){var i;if(t)if(n.settings.isJQueryPlugin)$(n.DOM.originalInput).triggerHandler(t,[e]);else{try{i=new CustomEvent(t,{detail:e})}catch(t){console.warn(t)}s.dispatchEvent(i)}}},events:{customBinding:function(){var e=this;this.customEventsList.forEach(function(t){e.on(t,e.settings.callbacks[t])})},binding:function(t){var e,i=!(0<arguments.length&&void 0!==t)||t,n=this.events.callbacks,s=i?"addEventListener":"removeEventListener";for(var a in i&&!this.listeners.main&&(this.DOM.input.addEventListener(this.isIE?"keydown":"input",n[this.isIE?"onInputIE":"onInput"].bind(this)),this.settings.isJQueryPlugin&&$(this.DOM.originalInput).on("tagify.removeAllTags",this.removeAllTags.bind(this))),e=this.listeners.main=this.listeners.main||{paste:["input",n.onPaste.bind(this)],focus:["input",n.onFocusBlur.bind(this)],blur:["input",n.onFocusBlur.bind(this)],keydown:["input",n.onKeydown.bind(this)],click:["scope",n.onClickScope.bind(this)],dblclick:["scope",n.onDoubleClickScope.bind(this)]})this.DOM[e[a][0]][s](a,e[a][1])},callbacks:{onFocusBlur:function(t){var e=t.target.textContent.trim();"mix"!=this.settings.mode&&("focus"==t.type?(this.DOM.scope.classList.add("tagify--focus"),0===this.settings.dropdown.enabled&&this.dropdown.show.call(this)):"blur"==t.type?(this.DOM.scope.classList.remove("tagify--focus"),e&&this.settings.addTagOnBlur&&this.addTags(e,!0).length):(this.DOM.input.removeAttribute("style"),this.dropdown.hide.call(this)))},onKeydown:function(t){var e,i=this,n=t.target.textContent.trim();if("mix"==this.settings.mode){switch(t.key){case"Delete":case"Backspace":var s=[];e=this.DOM.input.children,setTimeout(function(){[].forEach.call(e,function(t){return s.push(t.getAttribute("value"))}),i.value=i.value.filter(function(t){return-1!=s.indexOf(t.value)})},20);break;case"Enter":t.preventDefault()}return!0}switch(t.key){case"Backspace":""!=n&&8203!=n.charCodeAt(0)||(!0===this.settings.backspace?this.removeTag():"edit"==this.settings.backspace&&this.editTag());break;case"Esc":case"Escape":this.input.set.call(this),t.target.blur();break;case"ArrowRight":case"Tab":if(!n)return!0;case"Enter":t.preventDefault(),this.addTags(n,!0)}},onInput:function(t){var e=this.input.normalize.call(this),i=e.length>=this.settings.dropdown.enabled,n={value:e,inputElm:this.DOM.input};if("mix"==this.settings.mode)return this.events.callbacks.onMixTagsInput.call(this,t);e?this.input.value!=e&&(n.isValid=this.validateTag.call(this,e),this.input.set.call(this,e,!1),this.trigger("input",n),-1!=e.search(this.settings.delimiters)?this.addTags(e).length&&this.input.set.call(this):0<=this.settings.dropdown.enabled&&this.dropdown[i?"show":"hide"].call(this,e)):this.input.set.call(this,"")},onMixTagsInput:function(t){var e,i,n,s,a;if(this.maxTagsReached())return!0;window.getSelection&&0<(e=window.getSelection()).rangeCount&&((i=e.getRangeAt(0).cloneRange()).collapse(!0),i.setStart(window.getSelection().focusNode,0),(s=(n=i.toString().split(this.settings.mixTagsAllowedAfter))[n.length-1].match(this.settings.pattern))&&(this.state.tag={prefix:s[0],value:s.input.split(s[0])[1]},s=this.state.tag,a=this.state.tag.value.length>=this.settings.dropdown.enabled)),this.update(),this.trigger("input",this.extend({},this.state.tag,{textContent:this.DOM.input.textContent})),this.state.tag&&this.dropdown[a?"show":"hide"].call(this,this.state.tag.value)},onInputIE:function(t){var e=this;setTimeout(function(){e.events.callbacks.onInput.call(e,t)})},onPaste:function(t){},onClickScope:function(t){var e,i=t.target.closest("tag");"TAGS"==t.target.tagName?this.DOM.input.focus():"X"==t.target.tagName?this.removeTag(t.target.parentNode):i&&(e=this.getNodeIndex(i),this.trigger("click",{tag:i,index:e,data:this.value[e]}))},onEditTagInput:function(t){var e=t.closest("tag"),i=this.getNodeIndex(e),n=this.input.normalize(t),s=n.toLowerCase()==t.originalValue.toLowerCase()||this.validateTag(n);e.classList.toggle("tagify--invalid",!0!==s),e.isValid=s,this.trigger("input",{tag:e,index:i,data:this.extend({},this.value[i],{newValue:n})})},onEditTagBlur:function(t){var e,i=t.closest("tag"),n=this.getNodeIndex(i),s=this.input.normalize(t),a=s||t.originalValue,o=this.input.normalize(t)!=t.originalValue,r=i.isValid,l=u({},this.value[n],{value:a});s?(o&&(this.settings.transformTag.call(this,l),r=this.validateTag(l.value)),void 0!==r&&!0!==r||(t.textContent=l.value,this.value[n].value=l.value,this.update(),(e=t.cloneNode(!0)).removeAttribute("contenteditable"),i.title=l.value,i.classList.remove("tagify--editable"),t.parentNode.replaceChild(e,t),this.trigger("edit",{tag:i,index:n,data:this.value[n]}))):this.removeTag(i)},onEditTagkeydown:function(t){switch(t.key){case"Esc":case"Escape":t.target.textContent=t.target.originalValue;case"Enter":case"Tab":t.preventDefault(),t.target.blur()}},onDoubleClickScope:function(t){var e,i,n=t.target.closest("tag"),s=this.settings;n&&(e=n.classList.contains("tagify--editable"),i=n.hasAttribute("readonly"),"mix"==s.mode||s.readonly||s.enforceWhitelist||e||i||this.editTag(n))}}},editTag:function(t){var e=this,i=0<arguments.length&&void 0!==t?t:this.getLastTag(),n=i.querySelector(".tagify__tag-text"),s=this.events.callbacks;if(n)return i.classList.add("tagify--editable"),n.originalValue=n.textContent,n.setAttribute("contenteditable",!0),n.addEventListener("blur",s.onEditTagBlur.bind(this,n)),n.addEventListener("input",s.onEditTagInput.bind(this,n)),n.addEventListener("keydown",function(t){return s.onEditTagkeydown.call(e,t)}),n.focus(),this;console.warn("Cannot find element in Tag template: ",".tagify__tag-text")},input:{value:"",set:function(t,e){var i=0<arguments.length&&void 0!==t?t:"",n=!(1<arguments.length&&void 0!==e)||e;this.input.value=i,n&&(this.DOM.input.innerHTML=i),i||this.dropdown.hide.call(this),i.length<2&&this.input.autocomplete.suggest.call(this,""),this.input.validate.call(this)},setRangeAtStartEnd:function(t,e){var i,n,s=0<arguments.length&&void 0!==t&&t,a=1<arguments.length?e:void 0;document.createRange&&((i=document.createRange()).selectNodeContents(a||this.DOM.input),i.collapse(s),(n=window.getSelection()).removeAllRanges(),n.addRange(i))},validate:function(){var t=!this.input.value||this.validateTag.call(this,this.input.value);this.DOM.input.classList.toggle("tagify__input--invalid",!0!==t)},normalize:function(t){var e=(0<arguments.length&&void 0!==t?t:this.DOM.input).innerText;return"settings"in this&&this.settings.delimiters&&(e=e.replace(/(?:\r\n|\r|\n)/g,this.settings.delimiters.source.charAt(1))),e=e.replace(/\s/g," ").replace(/^\s+/,"")},autocomplete:{suggest:function(t){t&&this.input.value?this.DOM.input.setAttribute("data-suggest",t.substring(this.input.value.length)):this.DOM.input.removeAttribute("data-suggest")},set:function(t){var e=this.DOM.input.getAttribute("data-suggest"),i=t||(e?this.input.value+e:null);return!!i&&(this.input.set.call(this,i),this.input.autocomplete.suggest.call(this,""),this.dropdown.hide.call(this),this.input.setRangeAtStartEnd.call(this),!0)}}},getNodeIndex:function(t){var e=0;if(t)for(;t=t.previousElementSibling;)e++;return e},getTagElms:function(){return this.DOM.scope.querySelectorAll("tag")},getLastTag:function(){var t=this.DOM.scope.querySelectorAll("tag:not(.tagify--hide):not([readonly])");return t[t.length-1]},isTagDuplicate:function(e){return this.value.some(function(t){return"string"==typeof e?e.trim().toLowerCase()===t.value.toLowerCase():JSON.stringify(t).toLowerCase()===JSON.stringify(e).toLowerCase()})},getTagIndexByValue:function(i){var n=[];return this.getTagElms().forEach(function(t,e){t.textContent.trim().toLowerCase()==i.toLowerCase()&&n.push(e)}),n},getTagElmByValue:function(t){var e=this.getTagIndexByValue(t)[0];return this.getTagElms()[e]},markTagByValue:function(t,e){return!!(e=e||this.getTagElmByValue(t))&&(e.classList.add("tagify--mark"),e)},isTagBlacklisted:function(e){return e=e.toLowerCase().trim(),this.settings.blacklist.filter(function(t){return e==t.toLowerCase()}).length},isTagWhitelisted:function(e){return this.settings.whitelist.some(function(t){if((t.value||t).toLowerCase()===e.toLowerCase())return!0})},validateTag:function(t){var e=t.trim(),i=!0;return e?this.settings.pattern&&!this.settings.pattern.test(e)?i=this.TEXTS.pattern:!this.settings.duplicates&&this.isTagDuplicate(e)?i=this.TEXTS.duplicate:(this.isTagBlacklisted(e)||this.settings.enforceWhitelist&&!this.isTagWhitelisted(e))&&(i=this.TEXTS.notAllowed):i=this.TEXTS.empty,i},maxTagsReached:function(){return this.value.length>=this.settings.maxTags&&this.TEXTS.exceed},normalizeTags:function(t){function i(t){return t.split(a).filter(function(t){return t}).map(function(t){return{value:t.trim()}})}var e,n=this.settings,s=n.whitelist,a=n.delimiters,o=n.mode,r=!!s&&s[0]instanceof Object,l=t instanceof Array&&t[0]instanceof Object&&"value"in t[0],d=[];if(l)return t=(e=[]).concat.apply(e,h(t.map(function(e){return i(e.value).map(function(t){return u({},e,{},t)})})));if("number"==typeof t&&(t=t.toString()),"string"==typeof t){if(!t.trim())return[];t=i(t)}else if(!l&&t instanceof Array){var c;t=(c=[]).concat.apply(c,h(t.map(function(t){return i(t)})))}return r&&(t.forEach(function(e){var t=s.filter(function(t){return t.value.toLowerCase()==e.value.toLowerCase()});t[0]?d.push(t[0]):"mix"!=o&&d.push(e)}),t=d),t},parseMixTags:function(t){var a=this,e=this.settings,o=e.mixTagsInterpolator,r=e.duplicates,l=e.transformTag;return t=t.split(o[0]).map(function(t){var e,i,n=t.split(o[1]),s=n[0];try{e=JSON.parse(s)}catch(t){e=a.normalizeTags(s)[0]}return 1<n.length&&a.isTagWhitelisted(e.value)&&(r||!a.isTagDuplicate(e.value))&&(l.call(a,e),i=a.createTagElem(e),n[0]=i.outerHTML+"&#8288;",a.value.push(e)),n.join("")}).join(""),this.DOM.input.innerHTML=t,this.update(),t},addMixTag:function(t){if(t&&this.state.tag){for(var e,i,n,s,a=this.state.tag.prefix+this.state.tag.value,o=document.createNodeIterator(this.DOM.input,NodeFilter.SHOW_TEXT,null,!1),r=100;(e=o.nextNode())&&r--;)if(e.nodeType===Node.TEXT_NODE){if(-1==(n=e.nodeValue.indexOf(a)))continue;s=e.splitText(n),this.settings.transformTag.call(this,t),i=this.createTagElem(t),s.nodeValue=s.nodeValue.replace(a,""),e.parentNode.insertBefore(i,s),i.insertAdjacentHTML("afterend","&#8288;")}i&&(this.value.push(t),this.update(),this.trigger("add",this.extend({},{index:this.value.length,tag:i},t))),this.state.tag=null}},addEmptyTag:function(){var t={value:""},e=this.createTagElem(t);this.appendTag.call(this,e),this.value.push(t),this.update(),this.editTag(e)},addTags:function(t,e,i){var s=this,a=2<arguments.length&&void 0!==i?i:this.settings.skipInvalid,o=[];return t&&t.length?(t=this.normalizeTags.call(this,t),"mix"==this.settings.mode?this.addMixTag(t[0]):(this.DOM.input.removeAttribute("style"),t.forEach(function(t){var e,i,n={};if(t=Object.assign({},t),s.settings.transformTag.call(s,t),!0!==(e=s.maxTagsReached()||s.validateTag.call(s,t.value))){if(a)return;n["aria-invalid"]=!0,n.class=(t.class||"")+" tagify--notAllowed",n.title=e,s.markTagByValue(t.value),s.trigger("invalid",{data:t,index:s.value.length,message:e})}n.role="tag",t.readonly&&(n["aria-readonly"]=!0),i=s.createTagElem(s.extend({},t,n)),o.push(i),s.appendTag(i),!0===e?(s.value.push(t),s.update(),s.trigger("add",{tag:i,index:s.value.length-1,data:t})):s.settings.keepInvalidTags||setTimeout(function(){s.removeTag(i,!0)},1e3)}),t.length&&e&&this.input.set.call(this),o)):o},appendTag:function(t){var e=this.DOM.scope.lastElementChild;e===this.DOM.input?this.DOM.scope.insertBefore(t,e):this.DOM.scope.appendChild(t)},minify:function(t){return t.replace(new RegExp(">[\r\n ]+<","g"),"><")},createTagElem:function(t){var e=this.escapeHTML(t.value),i=this.settings.templates.tag.call(this,e,t);return this.settings.readonly&&(t.readonly=!0),i=this.minify(i),this.parseHTML(i)},removeTag:function(t,e,i){var n=this,s=0<arguments.length&&void 0!==t?t:this.getLastTag(),a=1<arguments.length?e:void 0,o=2<arguments.length&&void 0!==i?i:250;if("string"==typeof s&&(s=this.getTagElmByValue(s)),s instanceof HTMLElement){var r,l=this.getNodeIndex(s),d=function(){s.parentNode&&(s.parentNode.removeChild(s),a||(r=n.value.splice(l,1)[0],n.update(),n.trigger("remove",{tag:s,index:l,data:r}),n.dropdown.render.call(n)))};o&&10<o?(s.style.width=parseFloat(window.getComputedStyle(s).width)+"px",document.body.clientTop,s.classList.add("tagify--hide"),setTimeout(d,400)):d()}},removeAllTags:function(){this.value=[],this.update(),Array.prototype.slice.call(this.getTagElms()).forEach(function(t){return t.parentNode.removeChild(t)})},getAttributes:function(t){if("[object Object]"!=Object.prototype.toString.call(t))return"";var e,i,n=Object.keys(t),s="";for(i=n.length;i--;)"class"!=(e=n[i])&&t.hasOwnProperty(e)&&t[e]&&(s+=" "+e+(t[e]?'="'.concat(t[e],'"'):""));return s},preUpdate:function(){this.DOM.scope.classList.toggle("hasMaxTags",this.value.length>=this.settings.maxTags)},update:function(){this.preUpdate(),this.DOM.originalInput.value="mix"==this.settings.mode?this.getMixedTagsAsString():this.value.length?JSON.stringify(this.value):""},getMixedTagsAsString:function(){var e=this,i="",n=0,s=this.settings.mixTagsInterpolator;return this.DOM.input.childNodes.forEach(function(t){1==t.nodeType&&t.classList.contains("tagify__tag")?i+=s[0]+JSON.stringify(e.value[n++])+s[1]:i+=t.textContent}),i},dropdown:{init:function(){this.DOM.dropdown=this.dropdown.build.call(this)},build:function(){var t=this.settings.dropdown,e=t.position,i=t.classname,n="".concat("manual"==e?"":"tagify__dropdown"," ").concat(i).trim(),s='<div class="'.concat(n,'" role="menu"></div>');return this.parseHTML(s)},show:function(t){var e,i="manual"==this.settings.dropdown.position;if(this.settings.whitelist.length){if(this.suggestedListItems=this.dropdown.filterListItems.call(this,t),!this.suggestedListItems.length)return this.input.autocomplete.suggest.call(this),void this.dropdown.hide.call(this);e=this.dropdown.createListHTML.call(this,this.suggestedListItems),this.DOM.dropdown.innerHTML=this.minify(e),this.settings.enforceWhitelist&&!i&&this.dropdown.highlightOption.call(this,this.DOM.dropdown.children[0]),this.DOM.scope.setAttribute("aria-expanded",!0),this.trigger("dropdown:show",this.DOM.dropdown),document.body.contains(this.DOM.dropdown)||(i||(this.dropdown.position.call(this),document.body.appendChild(this.DOM.dropdown),this.events.binding.call(this,!1)),this.dropdown.events.binding.call(this))}},hide:function(t){var e=this.DOM,i=e.scope,n=e.dropdown,s="manual"==this.settings.dropdown.position&&!t;n&&document.body.contains(n)&&!s&&(window.removeEventListener("resize",this.dropdown.position),this.dropdown.events.binding.call(this,!1),this.events.binding.call(this),i.setAttribute("aria-expanded",!1),n.parentNode.removeChild(n),this.trigger("dropdown:hide",n))},render:function(){this.suggestedListItems=this.dropdown.filterListItems.call(this,"");var t=this.dropdown.createListHTML.call(this,this.suggestedListItems);this.DOM.dropdown.innerHTML=this.minify(t)},position:function(){var t=this.DOM.scope.getBoundingClientRect();this.DOM.dropdown.style.cssText="left: "+(t.left+window.pageXOffset)+"px; top: "+(t.top+t.height-1+window.pageYOffset)+"px; width: "+t.width+"px"},events:{binding:function(t){var e=!(0<arguments.length&&void 0!==t)||t,i=this.dropdown.events.callbacks,n=this.listeners.dropdown=this.listeners.dropdown||{position:this.dropdown.position.bind(this),onKeyDown:i.onKeyDown.bind(this),onMouseOver:i.onMouseOver.bind(this),onClick:i.onClick.bind(this)},s=e?"addEventListener":"removeEventListener";"manual"!=this.settings.dropdown.position&&(window[s]("resize",n.position),window[s]("keydown",n.onKeyDown)),window[s]("mousedown",n.onClick),this.DOM.dropdown[s]("mouseover",n.onMouseOver)},callbacks:{onKeyDown:function(t){var e=this.DOM.dropdown.querySelector("[class$='--active']"),i=e,n="";switch(t.key){case"ArrowDown":case"ArrowUp":case"Down":case"Up":t.preventDefault(),i=(i=i&&i[("ArrowUp"==t.key||"Up"==t.key?"previous":"next")+"ElementSibling"])||this.DOM.dropdown.children["ArrowUp"==t.key||"Up"==t.key?this.DOM.dropdown.children.length-1:0],this.dropdown.highlightOption.call(this,i,!0);break;case"Escape":case"Esc":this.dropdown.hide.call(this);break;case"ArrowRight":case"Tab":if(!e||!this.input.autocomplete.set.call(this,i?i.textContent:null))return!1;case"Enter":if(t.preventDefault(),e)return n=this.suggestedListItems[this.getNodeIndex(e)]||this.input.value,this.addTags([n],!0),this.dropdown.hide.call(this),0===this.settings.dropdown.enabled&&this.dropdown.show.call(this),!1;this.addTags(this.input.value,!0)}},onMouseOver:function(t){t.target.className.includes("__item")&&this.dropdown.highlightOption.call(this,t.target)},onClick:function(t){var e,i,n=this;if(0==t.button&&t.target!=this.DOM.dropdown){if(i=t.target.closest(".tagify__dropdown__item")){if(i.parentNode!==this.DOM.dropdown)return;e=this.suggestedListItems[this.getNodeIndex(i)]||this.input.value,this.addTags([e],!0),setTimeout(function(){return n.DOM.input.focus()},100)}this.dropdown.hide.call(this)}}}},highlightOption:function(t,e){if(t){var i,n="tagify__dropdown__item--active";this.DOM.dropdown.querySelectorAll("[class$='--active']").forEach(function(t){t.classList.remove(n),t.removeAttribute("aria-selected")}),t.classList.add(n),t.setAttribute("aria-selected",!0),e&&(t.parentNode.scrollTop=t.clientHeight+t.offsetTop-t.parentNode.clientHeight),this.settings.autoComplete&&!this.settings.dropdown.fuzzySearch&&(i=this.suggestedListItems[this.getNodeIndex(t)].value||this.input.value,this.input.autocomplete.suggest.call(this,i))}},filterListItems:function(t){var e,i,n,s,a=this,o=[],r=this.settings.whitelist,l=this.settings.dropdown.maxItems||1/0,d=0;if(!t)return r.filter(function(t){return!a.isTagDuplicate(t.value||t)}).slice(0,l);for(;d<r.length&&(n=(((e=r[d]instanceof Object?r[d]:{value:r[d]}).searchBy||"")+" "+e.value).toLowerCase().indexOf(t.toLowerCase()),i=this.settings.dropdown.fuzzySearch?0<=n:0==n,s=!this.settings.duplicates&&this.isTagDuplicate(e.value),i&&!s&&l--&&o.push(e),0!=l);d++);return o},createListHTML:function(t){var e=this.settings.templates.dropdownItem.bind(this);return t.map(e).join("")}}},t});
{
"name": "@yaireo/tagify",
"version": "2.27.0",
"version": "2.28.0",
"homepage": "https://github.com/yairEO/tagify",

@@ -5,0 +5,0 @@ "description": "lightweight, efficient Tags input component in Vanilla JS / React / Angular [super customizable, tiny size & top performance]",

@@ -350,12 +350,14 @@ <a href='https://www.npmjs.com/package/@yaireo/tagify'>

Name | Info
------------------- | --------------------------------------------------------------------------
destroy | Reverts the input element back as it was before Tagify was applied
removeAllTags | Removes all tags and resets the original input tag's value property
addTags | Accepts a String (word, single or multiple with a delimiter), an Array of Objects (see above) or Strings
removeTag | Removes a specific tag. Argument is the tag DOM element to be removed. When nothing passed, removes last tag (see source code)
loadOriginalValues | Converts the input's value into tags. This method gets called automatically when instansiating Tagify
getTagIndexByValue |
getTagElmByValue |
parseMixTags | Converts a String argument (`[[foo]]⁠ and [[bar]]⁠ are..`) into HTML with mixed tags & texts
Name | Parameters | Info
------------------- | ---------------------------------- | --------------------------------------------------------------------------
destroy | | Reverts the input element back as it was before Tagify was applied
removeAllTags | | Removes all tags and resets the original input tag's value property
addTags | tagsItems, clearInput, skipInvalid | Accepts a String (word, single or multiple with a delimiter), an Array of Objects (see above) or Strings
removeTag | Node/String | Removes a specific tag. Argument is the tag DOM element to be removed, or value. When nothing passed, removes last tag (see source code)
loadOriginalValues | String/Array | Converts the input's value into tags. This method gets called automatically when instansiating Tagify. Also works for mixed-tags
getTagIndexByValue | String | Returns the index of a specific tag, by value
parseMixTags | String | Converts a String argument (`[[foo]]⁠ and [[bar]]⁠ are..`) into HTML with mixed tags & texts
getTagElms | | Returns a DOM nodes list of all the tags
getTagElmByValue | String | Returns a specific tag DOM node by value
editTag | Node | Goes to edit-mode in a specific tag

@@ -362,0 +364,0 @@

@@ -579,2 +579,5 @@ function Tagify( input, settings ){

/**
* @param {Node} tagElm the tag element to edit. if nothing specified, use last last
*/
editTag( tagElm = this.getLastTag() ){

@@ -591,2 +594,3 @@ var editableElm = tagElm.querySelector('.tagify__tag-text'),

editableElm.originalValue = editableElm.textContent;
editableElm.setAttribute('contenteditable', true);

@@ -599,2 +603,3 @@

editableElm.focus();
return this;
},

@@ -708,8 +713,12 @@

* Searches if any tag with a certain value already exis
* @param {String} s [text value to search for]
* @return {int} [Position index of the tag. -1 is returned if tag is not found.]
* @param {String/Object} v [text value / tag data object]
* @return {Boolean}
*/
isTagDuplicate( s ){
return this.value.findIndex(item => s.trim().toLowerCase() === item.value.toLowerCase());
// return this.value.some(item => s.toLowerCase() === item.value.toLowerCase());
isTagDuplicate( v ){
// change to Array.Some
return this.value.some(item =>
typeof v == 'string'
? v.trim().toLowerCase() === item.value.toLowerCase()
: JSON.stringify(item).toLowerCase() === JSON.stringify(v).toLowerCase()
)
},

@@ -787,3 +796,3 @@

// if duplicates are not allowed and there is a duplicate
else if( !this.settings.duplicates && this.isTagDuplicate(value) !== -1 )
else if( !this.settings.duplicates && this.isTagDuplicate(value) )
result = this.TEXTS.duplicate;

@@ -861,10 +870,18 @@

var tagData,
{mixTagsInterpolator, duplicates} = this.settings;
{mixTagsInterpolator, duplicates, transformTag} = this.settings;
s = s.split(mixTagsInterpolator[0]).map(s1 => {
var s2 = s1.split(mixTagsInterpolator[1]),
preInterpolated = s2[0],
tagData,
tagElm;
if( s2.length > 1 && this.isTagWhitelisted(s2[0]) && (duplicates || this.isTagDuplicate(s2[0]) === -1) ){
tagData = this.normalizeTags(s2[0])[0];
try{
tagData = JSON.parse(preInterpolated)
} catch(err){
tagData = this.normalizeTags(preInterpolated)[0] //{value:preInterpolated}
}
if( s2.length > 1 && this.isTagWhitelisted(tagData.value) && (duplicates || !this.isTagDuplicate(tagData.value)) ){
transformTag.call(this, tagData);
tagElm = this.createTagElem(tagData);

@@ -889,3 +906,3 @@ s2[0] = tagElm.outerHTML + "&#8288;" // put a zero-space at the end so the caret so it won't jump back to the start (when the last input's child element is a tag)

var tag = this.state.tag.prefix + this.state.tag.value,
iter = document.createNodeIterator(this.DOM.input, NodeFilter.SHOW_TEXT),
iter = document.createNodeIterator(this.DOM.input, NodeFilter.SHOW_TEXT, null, false),
textnode,

@@ -925,2 +942,16 @@ tagElm,

/**
* add an empty "tag" element in an editable state
*/
addEmptyTag(){
var tagData = {value:""},
tagElm = this.createTagElem(tagData)
// add the tag to the component's DOM
this.appendTag.call(this, tagElm)
this.value.push(tagData)
this.update()
this.editTag(tagElm)
},
/**
* add a "tag" element to the "tags" component

@@ -981,6 +1012,6 @@ * @param {String/Array} tagsItems [A string (single or multiple values with a delimiter), or an Array of Objects or just Array of Strings]

tagElm = this.createTagElem( this.extend({}, tagData, tagElmParams) );
tagElems.push(tagElm);
tagElems.push(tagElm)
// add the tag to the component's DOM
appendTag.call(this, tagElm);
this.appendTag(tagElm)

@@ -1003,14 +1034,3 @@ if( tagValidation === true ){

/**
* appened (validated) tag to the component's DOM scope
* @return {[type]} [description]
*/
function appendTag(tagElm){
var insertBeforeNode = this.DOM.scope.lastElementChild;
if( insertBeforeNode === this.DOM.input )
this.DOM.scope.insertBefore(tagElm, insertBeforeNode);
else
this.DOM.scope.appendChild(tagElm);
}

@@ -1020,2 +1040,15 @@ return tagElems

/**
* appened (validated) tag to the component's DOM scope
* @return {[type]} [description]
*/
appendTag(tagElm){
var insertBeforeNode = this.DOM.scope.lastElementChild;
if( insertBeforeNode === this.DOM.input )
this.DOM.scope.insertBefore(tagElm, insertBeforeNode);
else
this.DOM.scope.appendChild(tagElm);
},
minify( html ){

@@ -1128,13 +1161,12 @@ return html.replace( new RegExp( "\>[\r\n ]+\<" , "g" ) , "><" );

getMixedTagsAsString(){
var result = "";
var result = "",
i = 0,
_interpolator = this.settings.mixTagsInterpolator;
this.DOM.input.childNodes.forEach((node, i) => {
if( node.nodeType == 1 ){
if( node.classList.contains("tagify__tag") )
result += "[[" + node.getAttribute("value") + "]]"
}
this.DOM.input.childNodes.forEach((node) => {
if( node.nodeType == 1 && node.classList.contains("tagify__tag") )
result += _interpolator[0] + JSON.stringify(this.value[i++]) + _interpolator[1]
else
result += node.textContent;
})
return result;

@@ -1181,3 +1213,3 @@ },

// if "enforceWhitelist" is "true", highlight the first suggested item
this.settings.enforceWhitelist && !isManual && this.dropdown.highlightOption.call(this, this.DOM.dropdown.querySelector('.tagify__dropdown__item'));
this.settings.enforceWhitelist && !isManual && this.dropdown.highlightOption.call(this, this.DOM.dropdown.children[0]);
this.DOM.scope.setAttribute("aria-expanded", true)

@@ -1238,3 +1270,2 @@

events : {
/**

@@ -1247,7 +1278,8 @@ * Events should only be binded when the dropdown is rendered and removed when isn't

// references to the ".bind()" methods must be saved so they could be unbinded later
var _CBR = (this.listeners.dropdown = this.listeners.dropdown || {
var _CB = this.dropdown.events.callbacks,
_CBR = (this.listeners.dropdown = this.listeners.dropdown || {
position : this.dropdown.position.bind(this),
onKeyDown : this.dropdown.events.callbacks.onKeyDown.bind(this),
onMouseOver : this.dropdown.events.callbacks.onMouseOver.bind(this),
onClick : this.dropdown.events.callbacks.onClick.bind(this)
onKeyDown : _CB.onKeyDown.bind(this),
onMouseOver : _CB.onMouseOver.bind(this),
onClick : _CB.onClick.bind(this)
}),

@@ -1271,3 +1303,3 @@ action = bindUnbind ? 'addEventListener' : 'removeEventListener';

var activeListElm = this.DOM.dropdown.querySelector("[class$='--active']"),
selectedElm = activeListElm || this.DOM.dropdown.children[0],
selectedElm = activeListElm,
newValue = "";

@@ -1298,4 +1330,4 @@

case 'Tab' :
e.preventDefault();
if( !this.input.autocomplete.set.call(this, selectedElm ? selectedElm.textContent : null) )
// e.preventDefault();
if( !activeListElm || !this.input.autocomplete.set.call(this, selectedElm ? selectedElm.textContent : null) )
return false;

@@ -1308,3 +1340,6 @@ case 'Enter' :

this.dropdown.hide.call(this);
setTimeout(() => this.DOM.input.focus(), 100);
if( this.settings.dropdown.enabled === 0 ){
this.dropdown.show.call(this);
}
return false;

@@ -1332,3 +1367,2 @@ }

if( listItemElm ){

@@ -1397,3 +1431,3 @@ // make sure the list item belongs to this context of the Tagify instance (and not some other instance's manual suggestions list)

return whitelist
.filter(item => this.isTagDuplicate(item.value || item) == -1 ) // don't include tags which have already been added.
.filter(item => !this.isTagDuplicate(item.value || item)) // don't include tags which have already been added.
.slice(0, suggestionsCount); // respect "maxItems" dropdown setting

@@ -1411,3 +1445,3 @@ }

isDuplicate = !this.settings.duplicates && this.isTagDuplicate(whitelistItem.value) > -1;
isDuplicate = !this.settings.duplicates && this.isTagDuplicate(whitelistItem.value);

@@ -1414,0 +1448,0 @@ // match for the value within each "whitelist" item

Sorry, the diff of this file is not supported yet

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