2021-04-12 06:18:30 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2021-05-18 19:21:25 +02:00
|
|
|
/* eslint
|
|
|
|
@typescript-eslint/no-explicit-any: "off",
|
|
|
|
*/
|
|
|
|
|
2021-08-24 02:19:26 +02:00
|
|
|
import "sveltelib/export-runtime";
|
2021-08-23 23:45:50 +02:00
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
|
2021-04-22 19:55:26 +02:00
|
|
|
import { setupI18n, ModuleName } from "lib/i18n";
|
|
|
|
import { checkNightMode } from "lib/nightmode";
|
2021-04-25 10:40:02 +02:00
|
|
|
import DeckOptionsPage from "./DeckOptionsPage.svelte";
|
2021-06-30 19:55:56 +02:00
|
|
|
import { nightModeKey, touchDeviceKey, modalsKey } from "components/context-keys";
|
2021-05-18 16:32:29 +02:00
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
export async function deckOptions(
|
2021-04-12 06:18:30 +02:00
|
|
|
target: HTMLDivElement,
|
|
|
|
deckId: number
|
2021-04-25 10:40:02 +02:00
|
|
|
): Promise<DeckOptionsPage> {
|
2021-05-18 16:32:29 +02:00
|
|
|
const [info] = await Promise.all([
|
|
|
|
getDeckOptionsInfo(deckId),
|
|
|
|
setupI18n({
|
|
|
|
modules: [
|
|
|
|
ModuleName.SCHEDULING,
|
|
|
|
ModuleName.ACTIONS,
|
|
|
|
ModuleName.DECK_CONFIG,
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
]);
|
|
|
|
|
|
|
|
const context = new Map();
|
2021-06-12 17:48:53 +02:00
|
|
|
const nightMode = checkNightMode();
|
2021-05-18 16:32:29 +02:00
|
|
|
context.set(nightModeKey, nightMode);
|
|
|
|
|
2021-05-25 18:54:58 +02:00
|
|
|
const modals = new Map();
|
|
|
|
context.set(modalsKey, modals);
|
|
|
|
|
2021-06-12 17:48:53 +02:00
|
|
|
const touchDevice = "ontouchstart" in document.documentElement;
|
|
|
|
context.set(touchDeviceKey, touchDevice);
|
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
const state = new DeckOptionsState(deckId, info);
|
|
|
|
return new DeckOptionsPage({
|
2021-04-12 06:18:30 +02:00
|
|
|
target,
|
|
|
|
props: { state },
|
2021-05-18 16:32:29 +02:00
|
|
|
context,
|
|
|
|
} as any);
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
2021-04-25 11:24:19 +02:00
|
|
|
|
2021-07-06 03:36:02 +02:00
|
|
|
import TitledContainer from "./TitledContainer.svelte";
|
|
|
|
import SpinBoxRow from "./SpinBoxRow.svelte";
|
|
|
|
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
|
|
|
|
import EnumSelectorRow from "./EnumSelectorRow.svelte";
|
|
|
|
import SwitchRow from "./SwitchRow.svelte";
|
|
|
|
|
|
|
|
export const components = {
|
|
|
|
TitledContainer,
|
|
|
|
SpinBoxRow,
|
|
|
|
SpinBoxFloatRow,
|
|
|
|
EnumSelectorRow,
|
|
|
|
SwitchRow,
|
2021-04-25 11:24:19 +02:00
|
|
|
};
|