Sha256: dc413924a728bd6602ba83c6c54a4bd485b1c18f78d8b96866f05764e214be20
Contents?: true
Size: 1003 Bytes
Versions: 36
Compression:
Stored size: 1003 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = ['condition', 'category'] filterConditions(event) { const query = event.currentTarget.value.toLowerCase() const visibleCategories = new Set() // hide / show condition links that match the query and note which // categories should be visible this.conditionTargets.forEach(conditionNode => { const conditionName = conditionNode.innerHTML.toLowerCase() if (conditionName.includes(query)) { conditionNode.hidden = false visibleCategories.add(conditionNode.dataset.category) } else { conditionNode.hidden = true } }) // hide / show category headers that have this.categoryTargets.forEach(categoryNode => { const categoryName = categoryNode.innerHTML if (visibleCategories.has(categoryName)) { categoryNode.hidden = false } else { categoryNode.hidden = true } }) } }
Version data entries
36 entries across 36 versions & 1 rubygems