chore(react/collections): move files around for ease of development

This commit is contained in:
Elian Doran
2025-08-30 14:29:54 +03:00
parent bb55544f25
commit ffb90c2b4b
7 changed files with 34 additions and 26 deletions

View File

@@ -0,0 +1,7 @@
interface NoteListProps {
displayOnlyCollections?: boolean;
}
export default function NoteList({ }: NoteListProps) {
return <p>Hi</p>
}

View File

@@ -1,8 +1,8 @@
import NoteContextAwareWidget from "./note_context_aware_widget.js";
import NoteListRenderer from "../services/note_list_renderer.js";
import type FNote from "../entities/fnote.js";
import type { CommandListener, CommandListenerData, CommandMappings, CommandNames, EventData, EventNames } from "../components/app_context.js";
import type ViewMode from "./view_widgets/view_mode.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js";
import NoteListRenderer from "./note_list_renderer.ts.bak/index.js";
import type FNote from "../../entities/fnote.js";
import type { CommandListener, CommandListenerData, CommandMappings, CommandNames, EventData, EventNames } from "../../components/app_context.js";
import type ViewMode from "../view_widgets/view_mode.js";
const TPL = /*html*/`
<div class="note-list-widget">

View File

@@ -0,0 +1,71 @@
import type FNote from "../../entities/fnote.js";
import BoardView from "../view_widgets/board_view/index.js";
import CalendarView from "../view_widgets/calendar_view.js";
import GeoView from "../view_widgets/geo_view/index.js";
import ListOrGridView from "../view_widgets/list_or_grid_view.js";
import TableView from "../view_widgets/table_view/index.js";
import type { ViewModeArgs } from "../view_widgets/view_mode.js";
import type ViewMode from "../view_widgets/view_mode.js";
const allViewTypes = ["list", "grid", "calendar", "table", "geoMap", "board"] as const;
export type ArgsWithoutNoteId = Omit<ViewModeArgs, "noteIds">;
export type ViewTypeOptions = typeof allViewTypes[number];
export default class NoteListRenderer {
private viewType: ViewTypeOptions;
private args: ArgsWithoutNoteId;
public viewMode?: ViewMode<any>;
constructor(args: ArgsWithoutNoteId) {
this.args = args;
this.viewType = this.#getViewType(args.parentNote);
}
#getViewType(parentNote: FNote): ViewTypeOptions {
const viewType = parentNote.getLabelValue("viewType");
if (!(allViewTypes as readonly string[]).includes(viewType || "")) {
// when not explicitly set, decide based on the note type
return parentNote.type === "search" ? "list" : "grid";
} else {
return viewType as ViewTypeOptions;
}
}
get isFullHeight() {
switch (this.viewType) {
case "list":
case "grid":
return false;
default:
return true;
}
}
async renderList() {
const args = this.args;
const viewMode = this.#buildViewMode(args);
this.viewMode = viewMode;
await viewMode.beforeRender();
return await viewMode.renderList();
}
#buildViewMode(args: ViewModeArgs) {
switch (this.viewType) {
case "calendar":
return new CalendarView(args);
case "table":
return new TableView(args);
case "geoMap":
return new GeoView(args);
case "board":
return new BoardView(args);
case "list":
case "grid":
default:
return new ListOrGridView(this.viewType, args);
}
}
}

View File

@@ -3,7 +3,7 @@ import { t } from "../services/i18n";
import Alert from "./react/Alert";
import { useNoteContext, useNoteProperty, useTriliumEvent } from "./react/hooks";
import "./search_result.css";
import NoteListRenderer from "../services/note_list_renderer";
// import NoteListRenderer from "../services/note_list_renderer";
enum SearchResultState {
NO_RESULTS,
@@ -28,12 +28,13 @@ export default function SearchResult() {
} else if (searchContainerRef.current) {
setState(SearchResultState.GOT_RESULTS);
const noteListRenderer = new NoteListRenderer({
$parent: $(searchContainerRef.current),
parentNote: note,
showNotePath: true
});
noteListRenderer.renderList();
// TODO: Fix me.
// const noteListRenderer = new NoteListRenderer({
// $parent: $(searchContainerRef.current),
// parentNote: note,
// showNotePath: true
// });
// noteListRenderer.renderList();
}
}