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} {onChange}
items={decks} items={decks}
icon={mdiBookOutline} 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 Modal from "./Modal.svelte";
import type { IconData } from "./types"; import type { IconData } from "./types";
import * as tr from "@generated/ftl"; import * as tr from "@generated/ftl";
import Shortcut from "./Shortcut.svelte";
interface Props { interface Props {
title: string; title: string;
selectedItem?: Item | null; selectedItem?: Item | null;
items: Item[]; items: Item[];
icon: IconData; icon: IconData;
keyCombination: string;
onChange?: (item: Item) => void; 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 modal: Modal | null = $state(null);
let searchQuery = $state(""); let searchQuery = $state("");
@ -54,6 +56,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
{selectedItem?.name ?? "…"} {selectedItem?.name ?? "…"}
</LabelButton> </LabelButton>
<Shortcut keyCombination={keyCombination} on:action={() => modal?.toggle()} />
<Modal bind:this={modal} dialogClass="modal-lg"> <Modal bind:this={modal} dialogClass="modal-lg">
<div slot="header" class="modal-header"> <div slot="header" class="modal-header">
<IconConstrain iconSize={90}> <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(); modal.hide();
} }
export function toggle(): void {
modal.toggle();
}
export { onOkClicked_ as acceptHandler, onCancelClicked_ as cancelHandler }; export { onOkClicked_ as acceptHandler, onCancelClicked_ as cancelHandler };
const { set: setModalOpen, remove: removeModalClosingHandler } = 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} {onChange}
items={notetypes} items={notetypes}
icon={mdiNewspaper} icon={mdiNewspaper}
keyCombination="Control+N"
/> />