Skip to content
Merged

deps #2152

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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:
skip: ["eslint"]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.5
rev: v0.14.8
hooks:
- id: ruff-check
args: ["--fix"]
Expand All @@ -16,7 +16,7 @@ repos:
additional_dependencies:
- mdformat-gfm
- repo: https://github.com/biomejs/pre-commit
rev: v2.3.5
rev: v2.3.8
hooks:
- id: biome-check
args: ["--error-on-warnings"]
Expand All @@ -29,17 +29,17 @@ repos:
types_or: ["svelte", "yaml"]
require_serial: true
additional_dependencies:
- "prettier@3.6.2"
- "prettier@3.7.4"
- "[email protected]"
- "svelte@5.43.8"
- "svelte@5.45.6"
- id: stylelint
name: stylelint
language: node
entry: stylelint --fix
types_or: ["css", "svelte"]
require_serial: true
additional_dependencies:
- "stylelint@16.25.0"
- "stylelint@16.26.1"
- "[email protected]"
- "[email protected]"
- "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.5/schema.json",
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
"files": {
"includes": ["**", "!docs/templates/**/*.html", "!src/fava/**/*.html"]
},
Expand Down
682 changes: 381 additions & 301 deletions frontend/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@types/d3-time-format": "^4.0.0",
"@types/jsdom": "^27.0.0",
"@types/node": "^22.1.0",
"chokidar": "^4.0.0",
"chokidar": "^5.0.0",
"esbuild": "^0.27.0",
"esbuild-svelte": "^0.9.0",
"eslint": "^9.27.0",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/charts/SelectCombobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
/** Whether the list of options in the Combobox popup is hidden. */
let hidden = $state(true);
/** The index of the option that is currently focused */
// Use the initial index in options (options does not change).
// svelte-ignore state_referenced_locally
let index = $state(options.indexOf(value));
/** The popup list element. */
let ul: HTMLUListElement | undefined = $state();
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/charts/Sunburst.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

$effect.pre(() => {
// if-expression to run on each change of chart
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
data;
void data;
untrack(() => {
current = null;
});
Expand Down
144 changes: 79 additions & 65 deletions frontend/src/codemirror/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from "@codemirror/language";
import { lintGutter, lintKeymap } from "@codemirror/lint";
import { highlightSelectionMatches, searchKeymap } from "@codemirror/search";
import type { Extension } from "@codemirror/state";
import { EditorState } from "@codemirror/state";
import type { KeyBinding } from "@codemirror/view";
import {
Expand Down Expand Up @@ -81,22 +80,14 @@ interface EditorAndAttachment {
renderEditor: Attachment<HTMLDivElement | HTMLPreElement>;
}

function setup(
value: string | undefined,
extensions: Extension[],
): EditorAndAttachment {
const view = new EditorView({
state: EditorState.create(
value !== undefined ? { doc: value, extensions } : { extensions },
),
});
function editor_attachment(editor: EditorView): EditorAndAttachment {
return {
editor: view,
editor,
renderEditor: (el) => {
el.appendChild(view.dom);
el.appendChild(editor.dom);

return () => {
el.removeChild(view.dom);
el.removeChild(editor.dom);
};
},
};
Expand All @@ -105,12 +96,16 @@ function setup(
/**
* A basic readonly editor for an asynchronously loaded document.
*/
export function initDocumentPreviewEditor(value: string): EditorAndAttachment {
return setup(value, [
baseExtensions,
EditorState.readOnly.of(true),
placeholder("Loading..."),
]);
export function initDocumentPreviewEditor(): EditorAndAttachment {
return editor_attachment(
new EditorView({
extensions: [
baseExtensions,
EditorState.readOnly.of(true),
placeholder("Loading..."),
],
}),
);
}

/**
Expand All @@ -121,11 +116,14 @@ export class BeancountTextarea extends HTMLTextAreaElement {
super();
getBeancountLanguageSupport()
.then((beancount) => {
const { editor } = setup(this.value, [
beancount,
syntaxHighlighting(defaultHighlightStyle),
EditorView.editable.of(false),
]);
const editor = new EditorView({
doc: this.value,
extensions: [
beancount,
syntaxHighlighting(defaultHighlightStyle),
EditorView.editable.of(false),
],
});
this.parentNode?.insertBefore(editor.dom, this);
this.style.display = "none";
})
Expand All @@ -140,64 +138,80 @@ export function initBeancountEditor(
value: string,
onDocChanges: (s: EditorState) => void,
commands: KeyBinding[],
beancount: LanguageSupport,
beancount: () => LanguageSupport,
): EditorAndAttachment {
const $indent = store_get(indent);
const $currency_column = store_get(currency_column);
return setup(value, [
beancount,
indentUnit.of(" ".repeat($indent)),
...($currency_column ? [rulerPlugin($currency_column - 1)] : []),
keymap.of(commands),
EditorView.updateListener.of((update) => {
if (update.docChanged) {
onDocChanges(update.state);
}
return editor_attachment(
new EditorView({
doc: value,
extensions: [
beancount(),
indentUnit.of(" ".repeat($indent)),
...($currency_column ? [rulerPlugin($currency_column - 1)] : []),
keymap.of(commands),
EditorView.updateListener.of((update) => {
if (update.docChanged) {
onDocChanges(update.state);
}
}),
baseExtensions,
syntaxHighlighting(beancountEditorHighlight),
],
}),
baseExtensions,
syntaxHighlighting(beancountEditorHighlight),
]);
);
}

/**
* A basic readonly BQL editor that only does syntax highlighting.
*/
export function initReadonlyQueryEditor(value: string): EditorAndAttachment {
return setup(value, [
bql,
syntaxHighlighting(beancountQueryHighlight),
EditorView.editable.of(false),
]);
return editor_attachment(
new EditorView({
doc: value,
extensions: [
bql,
syntaxHighlighting(beancountQueryHighlight),
EditorView.editable.of(false),
],
}),
);
}

/**
* The main BQL editor.
*/
export function initQueryEditor(
value: string | undefined,
value: string,
onDocChanges: (s: EditorState) => void,
_placeholder: string,
submit: () => void,
placeholder_value: string,
get_submit: () => () => void,
): EditorAndAttachment {
return setup(value, [
bql,
EditorView.updateListener.of((update) => {
if (update.docChanged) {
onDocChanges(update.state);
}
return editor_attachment(
new EditorView({
doc: value,
extensions: [
bql,
EditorView.updateListener.of((update) => {
if (update.docChanged) {
onDocChanges(update.state);
}
}),
keymap.of([
{
key: "Control-Enter",
mac: "Meta-Enter",
run: () => {
const submit = get_submit();
submit();
return true;
},
},
]),
placeholder(placeholder_value),
baseExtensions,
syntaxHighlighting(beancountQueryHighlight),
],
}),
keymap.of([
{
key: "Control-Enter",
mac: "Meta-Enter",
run: () => {
submit();
return true;
},
},
]),
placeholder(_placeholder),
baseExtensions,
syntaxHighlighting(beancountQueryHighlight),
]);
);
}
2 changes: 1 addition & 1 deletion frontend/src/editor/DocumentPreviewEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

let { url }: Props = $props();

const { editor, renderEditor } = initDocumentPreviewEditor("");
const { editor, renderEditor } = initDocumentPreviewEditor();

const set_editor_content = (value: string) => {
if (value !== editor.state.sliceDoc()) {
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/editor/SliceEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
sha256sum = $bindable(),
}: Props = $props();

let currentSlice = $state(slice);
let changed = $derived(currentSlice !== slice);
// Keep the initital slice value to check for changes.
// svelte-ignore state_referenced_locally
const initial_slice = slice;

let currentSlice = $state(initial_slice);
let changed = $derived(currentSlice !== initial_slice);

let saving = $state(false);
let deleting = $state(false);
Expand Down Expand Up @@ -67,7 +71,7 @@
}

const { renderEditor } = initBeancountEditor(
slice,
initial_slice,
(state) => {
currentSlice = state.sliceDoc();
},
Expand All @@ -83,7 +87,7 @@
},
},
],
beancount_language_support,
() => beancount_language_support,
);
</script>

Expand Down
5 changes: 2 additions & 3 deletions frontend/src/reports/editor/Editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@
},
},
],
beancount_language_support,
() => beancount_language_support,
);

$effect(() => {
// update editor contents if source changes
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
source;
void source;
untrack(() => {
editor.dispatch(replaceContents(editor.state, source.source));
sha256sum = source.sha256sum;
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/reports/import/Import.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@

let { files }: ImportReportProps = $props();

/** Whether the `<details>` for the "other files" is open. */
let show_other_files = $state.raw(
// initially show the other files if no importable files are present
files.every((file) => !file.identified_by_importers),
// initially show the other files if no importable files are present
// svelte-ignore state_referenced_locally
const show_other_files_initially = files.every(
(file) => !file.identified_by_importers,
);

/** Whether the `<details>` for the "other files" is open. */
let show_other_files = $state.raw(show_other_files_initially);

/** The array of entries to show the modal for. */
let entries: Entry[] = $state([]);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/reports/query/QueryEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
value = state.sliceDoc();
},
_("...enter a BQL query. 'help' to list available commands."),
submit,
() => submit,
);

$effect(() => {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/reports/query/ReadonlyQueryEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

let { value, error = false }: Props = $props();

// This component is not used with updating values
// svelte-ignore state_referenced_locally
const { renderEditor } = initReadonlyQueryEditor(value);
</script>

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/tree-table/IntervalTreeTableNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import { getTreeTableNotShownContext } from "./helpers.ts";
import IntervalTreeTableNode from "./IntervalTreeTableNode.svelte";

type Nodes = NonEmptyArray<AccountTreeNode>;

interface Props {
/** The account nodes to show. */
nodes: NonEmptyArray<AccountTreeNode>;
nodes: Nodes;
/** The budgets (per account a list per date range). */
budgets: Record<string, AccountBudget[]>;
}
Expand Down Expand Up @@ -70,9 +72,7 @@
{#each children as child, index (child.account)}
{#if !$not_shown.has(child.account)}
<IntervalTreeTableNode
nodes={nodes.map(
(n) => n.children[index],
) as unknown as NonEmptyArray<AccountTreeNode>}
nodes={nodes.map((n) => n.children[index]) as unknown as Nodes}
{budgets}
/>
{/if}
Expand Down
Loading