Add selector shortcuts

This commit is contained in:
Abdo 2025-08-14 08:57:03 +03:00
parent 0137ca6c27
commit 4444942b46
4 changed files with 10 additions and 1 deletions

View file

@ -31,4 +31,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{onChange}
items={decks}
icon={mdiBookOutline}
keyCombination="Control+D"
/>

View file

@ -10,16 +10,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import Modal from "./Modal.svelte";
import type { IconData } from "./types";
import * as tr from "@generated/ftl";
import Shortcut from "./Shortcut.svelte";
interface Props {
title: string;
selectedItem?: Item | null;
items: Item[];
icon: IconData;
keyCombination: string;
onChange?: (item: Item) => void;
}
let { title, onChange, icon, items, selectedItem = $bindable(null) }: Props = $props();
let { title, onChange, icon, items, selectedItem = $bindable(null), keyCombination }: Props = $props();
let modal: Modal | null = $state(null);
let searchQuery = $state("");
@ -54,6 +56,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{selectedItem?.name ?? "…"}
</LabelButton>
<Shortcut keyCombination={keyCombination} on:action={() => modal?.toggle()} />
<Modal bind:this={modal} dialogClass="modal-lg">
<div slot="header" class="modal-header">
<IconConstrain iconSize={90}>

View file

@ -40,6 +40,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
modal.hide();
}
export function toggle(): void {
modal.toggle();
}
export { onOkClicked_ as acceptHandler, onCancelClicked_ as cancelHandler };
const { set: setModalOpen, remove: removeModalClosingHandler } =

View file

@ -30,4 +30,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{onChange}
items={notetypes}
icon={mdiNewspaper}
keyCombination="Control+N"
/>