Sha256: 0ccef2c031b0522618767a66cff434af8651266c99417266d31b871019a88695

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

export function tagTemplate(tagData) {
  const suggestions = this.settings.whitelist || []

  const possibleSuggestion = suggestions.find(
    // eslint-disable-next-line eqeqeq
    (item) => item.value == tagData.value,
  )
  const possibleLabel = possibleSuggestion && 'label' in possibleSuggestion
    ? possibleSuggestion.label
    : tagData.value

  return `
<tag title="${tagData.value}"
  contenteditable='false'
  spellcheck='false'
  tabIndex="-1"
  class="tagify__tag ${tagData.class ? tagData.class : ''}"
  ${this.getAttributes(tagData)}
>
  <x title='' class='tagify__tag__removeBtn' role='button' aria-label='remove tag'></x>
  <div>
      <span class='tagify__tag-text'>${possibleLabel}</span>
  </div>
</tag>
`
}

export function suggestionItemTemplate(tagData) {
  return `
<div ${this.getAttributes(tagData)}
  class='tagify__dropdown__item flex items-center ${
  tagData.class ? tagData.class : ''
}'
  tabindex="0"
  role="option">
  ${
  tagData.avatar
    ? `
  <div class='rounded w-8 h-8 block mr-2'>
      <img onerror="this.style.visibility='hidden'" class="w-full" src="${tagData.avatar}">
  </div>`
    : ''
}
  <span>${tagData.label}</span>
</div>
`
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
avo-3.15.1 app/javascript/js/controllers/fields/tags_field_helpers.js
avo-3.15.0 app/javascript/js/controllers/fields/tags_field_helpers.js
avo-3.14.5 app/javascript/js/controllers/fields/tags_field_helpers.js
avo-3.14.4 app/javascript/js/controllers/fields/tags_field_helpers.js
avo-3.14.3 app/javascript/js/controllers/fields/tags_field_helpers.js
avo-3.14.2 app/javascript/js/controllers/fields/tags_field_helpers.js
avo-3.14.1 app/javascript/js/controllers/fields/tags_field_helpers.js
avo-3.14.0 app/javascript/js/controllers/fields/tags_field_helpers.js