Sha256: 5c4004c701e294799e6f9c15691af973bad036453b048b9ebc96724de3366b2b
Contents?: true
Size: 743 Bytes
Versions: 147
Compression:
Stored size: 743 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static values = { label: String, labelAlternate: String, useAlternate: Boolean, } connect() { this.updateLabel() } toggle(event) { if (undefined !== event?.detail?.useAlternate) { this.useAlternateValue = event.detail.useAlternate } else { this.useAlternateValue = !this.useAlternateValue } } useAlternateValueChanged() { this.updateLabel() } updateLabel() { if (!this.hasLabelValue || !this.hasLabelAlternateValue || !this.hasUseAlternateValue) { return } this.element.textContent = this.useAlternateValue === true ? this.labelAlternateValue : this.labelValue } }
Version data entries
147 entries across 147 versions & 1 rubygems