anki/ts/deckoptions/index.ts

35 lines
1.0 KiB
TypeScript
Raw Normal View History

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
2021-04-25 10:40:02 +02:00
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
import { setupI18n, ModuleName } from "lib/i18n";
import { checkNightMode } from "lib/nightmode";
2021-04-25 10:40:02 +02:00
import DeckOptionsPage from "./DeckOptionsPage.svelte";
import SpinBox from "./SpinBox.svelte";
import SpinBoxFloat from "./SpinBoxFloat.svelte";
import EnumSelector from "./EnumSelector.svelte";
import CheckBox from "./CheckBox.svelte";
2021-04-25 10:40:02 +02:00
export async function deckOptions(
target: HTMLDivElement,
deckId: number
2021-04-25 10:40:02 +02:00
): Promise<DeckOptionsPage> {
checkNightMode();
await setupI18n({
modules: [ModuleName.SCHEDULING, ModuleName.ACTIONS, ModuleName.DECK_CONFIG],
});
2021-04-25 10:40:02 +02:00
const info = await getDeckOptionsInfo(deckId);
const state = new DeckOptionsState(deckId, info);
return new DeckOptionsPage({
target,
props: { state },
});
}
export const deckConfigComponents = {
SpinBox,
SpinBoxFloat,
EnumSelector,
CheckBox,
};