mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
const emailRegexp = /([^@;,<>\s]+@[^@;,<>\s]+)/g
|
|
|
|
export default class extends HTMLElement {
|
|
connectedCallback () {
|
|
if (this.dataset.limit) {
|
|
this.textarea.addEventListener('input', () => {
|
|
const emails = this.textarea.value.match(emailRegexp) || []
|
|
|
|
this.updateCounter(emails.length)
|
|
})
|
|
}
|
|
}
|
|
|
|
updateCounter (count) {
|
|
let counter = document.getElementById('emails_counter')
|
|
let bulkMessage = document.getElementById('bulk_message')
|
|
|
|
if (count < 2) {
|
|
counter?.remove()
|
|
|
|
return
|
|
}
|
|
|
|
if ((count + 10) > this.dataset.limit) {
|
|
if (!counter) {
|
|
counter = document.createElement('span')
|
|
|
|
counter.id = 'emails_counter'
|
|
counter.classList.add('text-xs', 'right-0', 'absolute')
|
|
counter.style.bottom = '-15px'
|
|
|
|
this.textarea.parentNode.append(counter)
|
|
}
|
|
|
|
counter.innerText = `${count} / ${this.dataset.limit}`
|
|
}
|
|
|
|
// Bulk send pro feature removed
|
|
}
|
|
|
|
get textarea () {
|
|
return this.querySelector('textarea')
|
|
}
|
|
}
|