Sha256: b11275c25008747adc186cbaa329c75bb37ee63b1886b3c8196e989e430cf3ec
Contents?: true
Size: 581 Bytes
Versions: 10
Compression:
Stored size: 581 Bytes
Contents
import { Controller } from "@hotwired/stimulus"; export default class UIFilter extends Controller { static targets = ["source", "item"]; connect() {} filter(event) { let lowerCaseFilterTerm = this.sourceTarget.value.toLowerCase(); let regex = new RegExp("^" + lowerCaseFilterTerm); if (this.hasItemTarget) { this.itemTargets.forEach((el, i) => { let filterableKey = el.innerText.toLowerCase(); // Check for consecutive characters match using regex el.classList.toggle("hidden", !regex.test(filterableKey)); }); } } }
Version data entries
10 entries across 10 versions & 1 rubygems