Sha256: b0f509e059f8fa56334ca5a60e86fc7202bcc634966521d525290d9967f52858
Contents?: true
Size: 799 Bytes
Versions: 34
Compression:
Stored size: 799 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = [ "dependee", "dependant" ] connect() { this.#checkDependee() } check({ target }) { target === this.dependeeTarget ? this.#checkDependants() : this.#checkDependee() } #checkDependants() { this.dependantTargets.forEach(e => e.checked = this.dependeeTarget.checked) } #checkDependee() { this.dependeeTarget.checked = this.#allChecked this.dependeeTarget.indeterminate = this.#indeterminate } get #indeterminate() { return this.#atLeastOneChecked && !this.#allChecked; } get #atLeastOneChecked() { return this.dependantTargets.some(e => e.checked) } get #allChecked() { return this.dependantTargets.every(e => e.checked) } }
Version data entries
34 entries across 34 versions & 1 rubygems