import { Controller } from '@hotwired/stimulus'; export default class extends Controller { static targets = ['select', 'display']; connect() { if (!this.hasSelectTarget) return; const selectedOption = this.selectTarget.selectedOptions[0]; const displayText = selectedOption?.dataset?.displayText; if (displayText !== undefined) { this.displayTarget.innerHTML = displayText; } } handle(event) { if (!this.hasSelectTarget) return; const selectedOption = event.target.selectedOptions[0]; const displayText = selectedOption.dataset.displayText; if (displayText !== undefined) { this.displayTarget.innerHTML = displayText; } } }