mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
26 lines
578 B
TypeScript
26 lines
578 B
TypeScript
import { Controller } from '@hotwired/stimulus'
|
|
|
|
import TomSelect from 'tom-select'
|
|
import type { TomInput } from 'tom-select/dist/cjs/types'
|
|
|
|
// Connects to data-controller="searchable-select"
|
|
export default class extends Controller {
|
|
tomSelect: TomSelect | null
|
|
|
|
connect (): void {
|
|
this.tomSelect = new TomSelect((this.element as TomInput), { // eslint-disable-line no-new
|
|
selectOnTab: true,
|
|
allowEmptyOption: true
|
|
})
|
|
}
|
|
|
|
disconnect (): void {
|
|
this.tomSelect?.destroy()
|
|
}
|
|
|
|
reconnect (): void {
|
|
this.disconnect()
|
|
this.connect()
|
|
}
|
|
}
|