// assets/controllers/tom-select_controller.js import { Controller } from '@hotwired/stimulus'; import TomSelect from 'tom-select'; export default class extends Controller { connect() { new TomSelect(this.element, { plugins: ['remove_button'], placeholder: this.element.dataset.placeholder ?? 'Rechercher une dépendance...', maxOptions: null, wrapperClass: 'ts-wrapper form-tom-select', }); } disconnect() { if (this.element.tomselect) { this.element.tomselect.destroy(); } } }