Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
"prettier.useEditorConfig": true,
"prettier.embeddedLanguageFormatting": "off",
"stylelint.configBasedir": "./panel",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
6 changes: 5 additions & 1 deletion panel/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default defineConfig([
ignores: ["*.min.js"],
rules: {
"arrow-body-style": ["error", "as-needed"],
curly: ["error", "all"],
eqeqeq: ["error", "always"],
"no-console": ["warn"],
"no-else-return": ["error"],
Expand Down Expand Up @@ -68,4 +67,9 @@ export default defineConfig([
},
},
eslintConfigPrettier,
{
rules: {
curly: ["error", "all"],
},
},
]);
6 changes: 3 additions & 3 deletions panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"stylelint-config-standard-scss": "^17.0.0",
"stylelint-order": "^8.1.1",
"stylelint-scss": "^7.0.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.58.0"
"typescript": "^6.0.3",
"typescript-eslint": "^8.59.4"
},
"packageManager": "pnpm@10.30.2+sha512.36cdc707e7b7940a988c9c1ecf88d084f8514b5c3f085f53a2e244c2921d3b2545bc20dd4ebe1fc245feec463bb298aecea7a63ed1f7680b877dc6379d8d0cb4"
"packageManager": "pnpm@11.2.2+sha512.36e6621fad506178936455e70247b8808ef4ec25797a9f437a93281a020484e2607f6a469a22e982987c3dbb8866e3071514ab10a4a1749e06edcd1ec118436f"
}
214 changes: 107 additions & 107 deletions panel/pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions panel/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allowBuilds:
'@parcel/watcher': false
esbuild: false
35 changes: 21 additions & 14 deletions panel/src/ts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,34 @@ import { Tooltips } from "./components/tooltips";

import { Backups } from "./components/views/backups";
import { Dashboard } from "./components/views/dashboard";
import type { DateInputOptions } from "./components/inputs/date-input";
import type { DurationInputOptions } from "./components/inputs/duration-input";
import type { EditorInputOptions } from "./components/inputs/editor-input";
import { Login } from "./components/views/login";
import { Pages } from "./components/views/pages";
import { Plugins } from "./components/views/plugins";
import type { SelectInputOptions } from "./components/inputs/select-input";
import { Statistics } from "./components/views/statistics";
import type { TagsInputOptions } from "./components/inputs/tags-input";
import { Updates } from "./components/views/updates";

interface BackupsConfig {
labels: {
now: string;
};
}

interface AppConfig {
siteUri: string;
baseUri: string;
csrfToken?: string;
csrfToken: string;
colorScheme?: string;
DateInput?: any;
DurationInput?: any;
EditorInput?: any;
SelectInput?: any;
TagsInput?: any;
Backups?: any;
DateInput?: DateInputOptions;
DurationInput?: DurationInputOptions;
EditorInput?: EditorInputOptions;
SelectInput?: SelectInputOptions;
TagsInput?: TagsInputOptions;
Comment on lines +36 to +40
Backups?: BackupsConfig;
}

interface Component {
Expand All @@ -42,6 +53,7 @@ class App {
config: AppConfig = {
siteUri: "/",
baseUri: "/",
csrfToken: "",
};

modals: Modals = {};
Expand Down Expand Up @@ -80,15 +92,10 @@ class App {
}

loadConfig(config: AppConfig) {
Object.assign(this.config, config);
this.config = { ...this.config, ...config };
}

loadComponent(
component: Component,
options: ComponentConfig = {
globalAlias: undefined,
},
) {
loadComponent(component: Component, options: ComponentConfig = {}) {
const instance = new component(this);
const { globalAlias } = options;
if (globalAlias) {
Expand Down
6 changes: 4 additions & 2 deletions panel/src/ts/components/color-scheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class ColorScheme {
document.documentElement.classList.add(`color-scheme-${colorScheme}`);
};

const darkColorSchemeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");

const setPreferredColorScheme = (change = false) => {
const cookies = getCookies();
const cookieName = "formwork_preferred_color_scheme";
Expand All @@ -30,7 +32,7 @@ export class ColorScheme {

if (window.matchMedia("(prefers-color-scheme: light)").matches) {
colorScheme = "light";
} else if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
} else if (darkColorSchemeMediaQuery.matches) {
colorScheme = "dark";
}

Expand All @@ -49,7 +51,7 @@ export class ColorScheme {

window.addEventListener("beforeunload", () => setPreferredColorScheme());
window.addEventListener("pagehide", () => setPreferredColorScheme());
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => setPreferredColorScheme(true));
darkColorSchemeMediaQuery.addEventListener("change", () => setPreferredColorScheme(true));

if (getSupportedColorSchemes() === "light dark") {
setPreferredColorScheme(true);
Expand Down
2 changes: 1 addition & 1 deletion panel/src/ts/components/dropdowns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class Dropdowns {
const button = (event.target as HTMLDivElement).closest(".dropdown-button") as HTMLButtonElement;

if (button) {
const dropdown = document.getElementById(button.dataset.dropdown as string) as HTMLElement;
const dropdown = document.getElementById(button.dataset.dropdown ?? "") as HTMLElement;
const isVisible = getComputedStyle(dropdown).display !== "none";
event.preventDefault();

Expand Down
8 changes: 4 additions & 4 deletions panel/src/ts/components/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Files {
renameFileModal.onOpen((modal, trigger) => {
if (trigger) {
const input = $('[id="renameFileModal.filename"]', modal.element) as HTMLInputElement;
input.value = trigger.dataset.filename as string;
input.value = trigger.dataset.filename ?? "";
input.setSelectionRange(0, input.value.lastIndexOf("."));
}
});
Expand All @@ -38,19 +38,19 @@ export class Files {
replaceFileCommand.addEventListener("click", () => {
const form = document.createElement("form");
form.hidden = true;
form.action = replaceFileCommand.dataset.action as string;
form.action = replaceFileCommand.dataset.action ?? "";
form.method = "post";
form.enctype = "multipart/form-data";

const fileInput = document.createElement("input");
fileInput.name = "file";
fileInput.type = "file";
fileInput.accept = replaceFileCommand.dataset.extension as string;
fileInput.accept = replaceFileCommand.dataset.extension ?? "";
form.appendChild(fileInput);

const csrfInput = document.createElement("input");
csrfInput.name = "csrf-token";
csrfInput.value = app.config.csrfToken as string;
csrfInput.value = app.config.csrfToken;
form.appendChild(csrfInput);

fileInput.click();
Expand Down
Loading
Loading