Sha256: e0563cf9115cd13767545a72cf3b37021d2eb861293b6d28c2ff1a0a6d1a5bb2
Contents?: true
Size: 790 Bytes
Versions: 6
Compression:
Stored size: 790 Bytes
Contents
import { Controller } from '@hotwired/stimulus' export default class extends Controller { static get targets () { return ['textarea', 'count'] } connect () { this.update() } update () { this.resize() this.updateCount() } resize () { this.textareaTarget.style.height = 'auto' this.textareaTarget.setAttribute('style', 'height:' + (this.textareaTarget.scrollHeight) + 'px;overflow-y:hidden;') } updateCount () { if (this.textareaTarget.getAttribute('maxlength')) { this.updateCountLength() } } updateCountLength () { const currentLength = this.textareaTarget.value.length const maximumLength = this.textareaTarget.getAttribute('maxlength') this.countTarget.textContent = `${currentLength}/${maximumLength}` } }
Version data entries
6 entries across 6 versions & 1 rubygems