Sha256: 40afee733969544a888a8752b7a6ca584b0a23964b7091c2a9ac2222c2d13f67
Contents?: true
Size: 846 Bytes
Versions: 1
Compression:
Stored size: 846 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = [ "item" ] static values = { index: Number } connect() { this.#updateTabstops() } prev() { if (this.indexValue > 0) { this.indexValue-- this.#updateTabstops() this.#focusCurrentItem() } } next() { if (this.indexValue < this.#lastIndex) { this.indexValue++ this.#updateTabstops() this.#focusCurrentItem() } } reset() { this.indexValue = 0 this.#updateTabstops() } #updateTabstops() { this.itemTargets.forEach((element, index) => { element.tabIndex = index === this.indexValue ? 0 : -1 }) } #focusCurrentItem() { this.itemTargets[this.indexValue].focus() } get #lastIndex() { return this.itemTargets.length -1 } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
css-zero-0.0.50 | lib/generators/css_zero/add/templates/app/javascript/controllers/menu_controller.js |