From d34852a3779ac6daea9003123e488828c983e73a Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Mon, 13 May 2024 12:39:54 -0400 Subject: [PATCH] Add mitt package to desktop for global event bus. ListView will be rewritten. ListView will be rewritten. Using Radix's Listbox has too much restrictions, I can't control which row to highlight programmatically. --- apps/desktop/components/AppList.vue | 11 +++++- apps/desktop/components/SearchBar.vue | 21 ++++++++++-- .../components/interface/list/ListItem.vue | 2 +- .../components/interface/list/ListView.vue | 8 +++++ apps/desktop/components/ui/input/Input.vue | 34 ++++++++++++------- apps/desktop/lib/globalEvents.ts | 3 ++ apps/desktop/package.json | 1 + apps/desktop/pages/index.vue | 10 +----- pnpm-lock.yaml | 3 ++ 9 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 apps/desktop/lib/globalEvents.ts diff --git a/apps/desktop/components/AppList.vue b/apps/desktop/components/AppList.vue index be19f5f3..4fe6ef5b 100644 --- a/apps/desktop/components/AppList.vue +++ b/apps/desktop/components/AppList.vue @@ -5,6 +5,7 @@ import { computedAsync } from "@vueuse/core"; import { open } from "@tauri-apps/api/shell"; import { cn } from "@/lib/utils"; import type { HTMLAttributes } from "vue"; +import { GlobalEventBus } from "~/lib/globalEvents"; const props = defineProps<{ class?: HTMLAttributes["class"]; @@ -13,10 +14,18 @@ const appStore = useAppsStore(); const foundApps = computedAsync(() => { return appStore.searchApps(appStore.searchTerm); }, []); + +GlobalEventBus.on("searchbar:keydown", (key) => { + console.log("searchbar:keydown", key); +}); +const selected = ref(""); +watch(foundApps, () => { + selected.value = foundApps.value[0]?.app_desktop_path ?? ""; +});