import { Controller } from '@hotwired/stimulus'; export default class extends Controller { static values = { hideRule: String, showRule: String }; static targets = ['checkBox', 'togglable']; connect() { this.handle(); } handle() { if (!this.hasCheckBoxTarget || !this.checkBoxTarget.checked) { this.togglableTargets.forEach((togglable) => { togglable.classList.add('hidden'); }); } else { this.togglableTargets.forEach((togglable) => { togglable.classList.remove('hidden'); }); } } }