search bar

This commit is contained in:
2026-02-20 17:38:29 -05:00
parent 089af5e299
commit 402789e763
10 changed files with 566 additions and 29 deletions
@@ -0,0 +1,54 @@
import type { ReactiveController, ReactiveControllerHost } from 'lit';
import { searchStore } from '../search-store';
/**
* SearchController connects a Lit component to the SearchStore.
*
* Usage in a component:
*
* private search = new SearchController(this);
*
* render() {
* const term = this.search.term;
* ...
* }
*/
export class SearchController implements ReactiveController {
private host: ReactiveControllerHost;
private unsubscribe?: () => void;
constructor(host: ReactiveControllerHost) {
this.host = host;
host.addController(this);
}
// ===================================================================
// LIFECYCLE HOOKS
// ===================================================================
hostConnected(): void {
this.unsubscribe = searchStore.subscribe(() => {
this.host.requestUpdate();
});
}
hostDisconnected(): void {
this.unsubscribe?.();
}
// ===================================================================
// DATA ACCESS
// ===================================================================
get term(): string {
return searchStore.getTerm();
}
set term(value: string) {
searchStore.setTerm(value);
}
get isSearchableView(): boolean {
return searchStore.isSearchableView();
}
}