1import { Controller } from "@hotwired/stimulus" 2import { get } from "@rails/request.js" 3 4export default class extends Controller { 5 static targets = ["query", "placeId", "results"] 6 static values = { 7 url: String, 8 delay: { type: Number, default: 300 } 9 } 10 11 search() { 12 clearTimeout(this.timeout) 13 this.placeIdTarget.value = "" 14 15 this.timeout = setTimeout(() => this.fetchResults(), this.delayValue) 16 } 17 18 select({ params: { placeId, address } }) { 19 this.placeIdTarget.value = placeId 20 this.queryTarget.value = address 21 this.resultsTarget.replaceChildren() 22 } 23 24 async fetchResults() { 25 const q = this.queryTarget.value.trim() 26 27 if (!q) { 28 this.resultsTarget.replaceChildren() 29 return 30 } 31 32 await get(this.urlValue, { 33 query: { q }, 34 responseKind: "turbo-stream" 35 }) 36 } 37}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.