import { Controller } from '@hotwired/stimulus' export default class extends Controller { static targets = [ 'field' ] toggle() { let type = this.fieldTarget.getAttribute('type') === 'password' ? 'text' : 'password' this.fieldTarget.setAttribute('type', type) } }