public/be-assets/node_modules/@yaireo/tagify/dist/tagify.esm.js
/**
   * Removes a tag
   * @param  {Array|Node|String}  tagElms         [DOM element(s) or a String value. if undefined or null, remove last added tag]
   * @param  {Boolean}            silent          [A flag, which when turned on, does not remove any value and does not update the original input value but simply removes the tag from tagify]
   * @param  {Number}             tranDuration    [Transition duration in MS]
   * TODO: Allow multiple tags to be removed at-once
   */
Removes a tag
@param  {Array|Node|String}  tagElms         [DOM element(s) or a String value. if undefined or null, remove last added tag]
@param  {Boolean}            silent          [A flag, which when turned on, does not remove any value and does not update the original input value but simply removes the tag from tagify]
@param  {Number}             tranDuration    [Transition duration in MS]
TODO: Allow multiple tags to be removed at-once
Removes a tag @param { Array|Node|String } tagElms [ DOM element ( s ) or a String value . if undefined or null remove last added tag ] @param { Boolean } silent [ A flag which when turned on does not remove any value and does not update the original input value but simply removes the tag from tagify ] @param { Number } tranDuration [ Transition duration in MS ] TODO : Allow multiple tags to be removed at - once
removeTags(tagElms, silent, tranDuration) {
    var tagsToRemove;
    tagElms = tagElms && tagElms instanceof HTMLElement ? [tagElms] : tagElms instanceof Array ? tagElms : tagElms ? [tagElms] : [this.getLastTag()]; 
    tagsToRemove = tagElms.reduce((elms, tagElm) => {
      if (tagElm && typeof tagElm == 'string') tagElm = this.getTagElmByValue(tagElm);
      var tagData = this.tagData(tagElm);
      if (tagElm && tagData && !tagData.readonly) 
        elms.push({
          node: tagElm,
          idx: this.getTagIdx(tagData),
          data: this.tagData(tagElm, {
            '__removed': true
          })
        });
      return elms;
    }, []);
    tranDuration = typeof tranDuration == "number" ? tranDuration : this.CSSVars.tagHideTransition;
    if (this.settings.mode == 'select') {
      tranDuration = 0;
      this.input.set.call(this);
    } 
    if (tagsToRemove.length == 1) {
      if (tagsToRemove[0].node.classList.contains(this.settings.classNames.tagNotAllowed)) silent = true;
    }
    if (!tagsToRemove.length) return;
    this.settings.hooks.beforeRemoveTag(tagsToRemove, {
      tagify: this
    }).then(() => {
      function removeNode(tag) {
        if (!tag.node.parentNode) return;
        tag.node.parentNode.removeChild(tag.node);
        if (!silent) {
          this.trigger('remove', {
            tag: tag.node,
            index: tag.idx,
            data: tag.data
          });
          this.dropdown.refilter();
          this.dropdown.position();
          this.DOM.input.normalize(); 
          if (this.settings.keepInvalidTags) this.reCheckInvalidTags();
        } else if (this.settings.keepInvalidTags) this.trigger('remove', {
          tag: tag.node,
          index: tag.idx
        });
      }
      function animation(tag) {
        tag.node.style.width = parseFloat(window.getComputedStyle(tag.node).width) + 'px';
        document.body.clientTop; 
        tag.node.classList.add(this.settings.classNames.tagHide); 
        setTimeout(removeNode.bind(this), tranDuration, tag);
      }
      if (tranDuration && tranDuration > 10 && tagsToRemove.length == 1) animation.call(this, tagsToRemove[0]);else tagsToRemove.forEach(removeNode.bind(this)); 
      if (!silent) {
        this.removeTagsFromValue(tagsToRemove.map(tag => tag.node));
        this.update(); 
        if (this.settings.mode == 'select') this.DOM.input.setAttribute('contenteditable', true);
      }
    }).catch(reason => {});
  }
removeTags ( tagElms , silent , tranDuration ) { var tagsToRemove ; tagElms = tagElms && tagElms instanceof HTMLElement ? [ tagElms ] : tagElms instanceof Array ? tagElms : tagElms ? [ tagElms ] : [ this . getLastTag ( ) ] ; tagsToRemove = tagElms . reduce ( ( elms , tagElm ) => { if ( tagElm && typeof tagElm == 'string' ) tagElm = this . getTagElmByValue ( tagElm ) ; var tagData = this . tagData ( tagElm ) ; if ( tagElm && tagData && ! tagData . readonly ) elms . push ( { node : tagElm , idx : this . getTagIdx ( tagData ) , data : this . tagData ( tagElm , { '__removed' : true } ) } ) ; return elms ; } , [ ] ) ; tranDuration = typeof tranDuration == "number" ? tranDuration : this . CSSVars . tagHideTransition ; if ( this . settings . mode == 'select' ) { tranDuration = 0 ; this . input . set . call ( this ) ; } if ( tagsToRemove . length == 1 ) { if ( tagsToRemove [ 0 ] . node . classList . contains ( this . settings . classNames . tagNotAllowed ) ) silent = true ; } if ( ! tagsToRemove . length ) return ; this . settings . hooks . beforeRemoveTag ( tagsToRemove , { tagify : this } ) . then ( ( ) => { function removeNode ( tag ) { if ( ! tag . node . parentNode ) return ; tag . node . parentNode . removeChild ( tag . node ) ; if ( ! silent ) { this . trigger ( 'remove' , { tag : tag . node , index : tag . idx , data : tag . data } ) ; this . dropdown . refilter ( ) ; this . dropdown . position ( ) ; this . DOM . input . normalize ( ) ; if ( this . settings . keepInvalidTags ) this . reCheckInvalidTags ( ) ; } else if ( this . settings . keepInvalidTags ) this . trigger ( 'remove' , { tag : tag . node , index : tag . idx } ) ; } function animation ( tag ) { tag . node . style . width = parseFloat ( window . getComputedStyle ( tag . node ) . width ) + 'px' ; document . body . clientTop ; tag . node . classList . add ( this . settings . classNames . tagHide ) ; setTimeout ( removeNode . bind ( this ) , tranDuration , tag ) ; } if ( tranDuration && tranDuration > 10 && tagsToRemove . length == 1 ) animation . call ( this , tagsToRemove [ 0 ] ) ; else tagsToRemove . forEach ( removeNode . bind ( this ) ) ; if ( ! silent ) { this . removeTagsFromValue ( tagsToRemove . map ( tag => tag . node ) ) ; this . update ( ) ; if ( this . settings . mode == 'select' ) this . DOM . input . setAttribute ( 'contenteditable' , true ) ; } } ) . catch ( reason => { } ) ; }
Removes a tag
 @param  {Array|Node|String}  tagElms         [DOM element(s) or a String value.
Removes a tag @param { Array|Node|String } tagElms [ DOM element ( s ) or a String value .
// normalize tagElms array values: // 1. removing invalid items // 2, if an item is String try to get the matching Tag HTML node // 3. get the tag data // 4. return a collection of Objects // make sure it's a tag and not some other node // because the DOM node might be removed by async animation, the state will be updated while // the node might still be in the DOM, so the "update" method should know which nodes to ignore // this.getNodeIndex(tagElm); // this.getTagIndexByValue(tagElm.textContent) // if only a single tag is to be removed // this.removeValueById(tagData.__uid) // best-practice when in mix-mode (safe to do always anyways) // check if any of the current tags which might have been marked as "duplicate" should be un-marked // force repaint for the width to take affect before the "hide" class below // manual timeout (hack, since transitionend cannot be used because of hover) // update state regardless of animation // update the original input with the current value