feat: cv2

This commit is contained in:
2026-01-09 14:42:33 +01:00
parent 82dd08f2a2
commit 4bc84b5399
17 changed files with 1178 additions and 633 deletions

View File

@@ -19,13 +19,17 @@
let {
currentAction = undefined,
nextAction = undefined,
queryFilter = undefined,
ignoreIcon,
autofocus = false,
onselect,
onclose,
}: {
currentAction?: number;
queryFilter?: string;
nextAction?: number;
autofocus?: boolean;
ignoreIcon?: boolean;
onselect?: (id: number) => void;
onclose?: () => void;
} = $props();
@@ -43,6 +47,14 @@
createIndex($KEYMAP_CODES);
});
let didClear = true;
$effect(() => {
if (queryFilter !== undefined || !didClear) {
searchBox.value = queryFilter ?? "";
search();
}
});
async function createIndex(codes: Map<number, KeyInfo>) {
for (const [, action] of codes) {
await index?.addAsync(
@@ -60,6 +72,7 @@
(category) => [category, []] as [KeymapCategory, KeyInfo[]],
),
);
didClear = searchBox.value === "";
const result =
searchBox.value === ""
? Array.from($KEYMAP_CODES.keys())
@@ -167,7 +180,7 @@
<li>Action code is out of range</li>
{/if}
{/if}
{#each results as [category, actions] (category)}
{#each results as [category, actions] (actions)}
{#if actions.length > 0}
<div class="category">
<h3>{category.name}</h3>
@@ -191,7 +204,7 @@
}
: undefined}
>
<Action {action} display="verbose"></Action>
<Action {action} display="verbose" {ignoreIcon}></Action>
</button>
{/each}
</ul>