Skip to content

The VS Code of video editing, built for agents.

TypeScript

feat: implement multi-project deletion and selection functionality

konstantin-paulusbd11bc6b051a
diff --git a/apps/web/src/components/dashboard/delete-project-dialog.tsx b/apps/web/src/components/dashboard/delete-project-dialog.tsx
index d71df389..15eabde6 100644
--- a/apps/web/src/components/dashboard/delete-project-dialog.tsx
+++ b/apps/web/src/components/dashboard/delete-project-dialog.tsx
@@ -19,35 +19,40 @@ import type { ProjectInfo } from "@/projects";
type DeleteProjectDialogProps = {
- /** The project being deleted; `null` while the dialog is closed. */
- project: ProjectInfo | null;
+ /** The projects being deleted; empty while the dialog is closed. */
+ projects: ProjectInfo[];
/** Asked for whenever the dialog should close, confirmed or not. */
onClose(): void;
- /** The project is in the Trash — for the list that showed it to catch up. */
- onDeleted(project: ProjectInfo): void;
+ /** The projects are in the Trash — for the list that showed them to catch up. */
+ onDeleted(projects: ProjectInfo[]): void;
};
/**
- * The confirmation a project's deletion goes through. The view holds which
- * project is pending and renders this on it; the delete itself, and being
+ * The confirmation a deletion of projects goes through. The view holds which
+ * projects are pending and renders this on them; the delete itself, and being
* unclosable while it runs, are the dialog's own.
*/
export function DeleteProjectDialog(props: DeleteProjectDialogProps) {
const [deleting, setDeleting] = createSignal(false);
+ const multiple = () => props.projects.length > 1;
const confirm = async () => {
- const project = props.project;
- if (!project || deleting()) return;
+ const projects = props.projects;
+ if (projects.length === 0 || deleting()) return;
setDeleting(true);
+ const deleted: ProjectInfo[] = [];
try {
- await trashProject(project);
- props.onDeleted(project);
+ for (const project of projects) {
+ await trashProject(project);
+ deleted.push(project);
+ }
} catch (e) {
toast.error("Failed to delete project", {
description: (e as Error).message,
});
} finally {
+ if (deleted.length > 0) props.onDeleted(deleted);
setDeleting(false);
props.onClose();
}
@@ -55,17 +60,18 @@ export function DeleteProjectDialog(props: DeleteProjectDialogProps) {
return (
<AlertDialog
- open={props.project !== null}
+ open={props.projects.length > 0}
onOpenChange={(open) => {
if (!open && !deleting()) props.onClose();
}}
>
<AlertDialogContent>
<AlertDialogHeader>
- <AlertDialogTitle>Delete project</AlertDialogTitle>
+ <AlertDialogTitle>{multiple() ? `Delete ${props.projects.length} projects` : "Delete project"}</AlertDialogTitle>
<AlertDialogDescription>
- {`"${props.project?.displayName ?? ""}" will be moved to the Trash. `}
- You can restore it from there until the Trash is emptied.
+ {multiple()
+ ? `${props.projects.length} projects will be moved to the Trash. You can restore them from there until the Trash is emptied.`
+ : `"${props.projects[0]?.displayName ?? ""}" will be moved to the Trash. You can restore it from there until the Trash is emptied.`}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
diff --git a/apps/web/src/components/dashboard/home-view.tsx b/apps/web/src/components/dashboard/home-view.tsx
index 9b587510..d0739df7 100644
--- a/apps/web/src/components/dashboard/home-view.tsx
+++ b/apps/web/src/components/dashboard/home-view.tsx
@@ -55,6 +55,7 @@ import {
import { DeleteProjectDialog } from "./delete-project-dialog";
import { DashboardProjectCard } from "./project-card";
+import { createProjectSelection } from "./selection";
import {
DashboardCardButton,
DashboardCardMeta,
@@ -80,8 +81,8 @@ type PromptTarget =
*/
const RECENT_CARD_WIDTH_PX = 180;
const RECENT_MIN_COLUMNS = 2;
-/** The grid's `gap-x-0.5`. */
-const RECENT_GAP_PX = 2;
+/** The grid's `gap-x-1.5`. */
+const RECENT_GAP_PX = 6;
/** Recent projects the target menu offers before it gets unwieldy. */
const MENU_PROJECTS = 8;
@@ -105,9 +106,6 @@ export function DashboardHomeView() {
const [prompt, setPrompt] = createSignal("");
const [target, setTarget] = createSignal<PromptTarget>({ kind: "new" });
- const [selectedProject, setSelectedProject] = createSignal<string | null>(
- null,
- );
const [busy, setBusy] = createSignal(false);
const [attachments, setAttachments] = createSignal<Attachment[]>([]);
@@ -153,6 +151,8 @@ export function DashboardHomeView() {
(a, b) => parseTimestamp(b.modifiedAt) - parseTimestamp(a.modifiedAt),
),
);
+ /** The recents that fit the row, beside the new-project card. */
+ const visibleRecents = createMemo(() => recentProjects().slice(0, recentColumns() - 1));
const targetLabel = () => {
const current = target();
@@ -233,16 +233,20 @@ export function DashboardHomeView() {
void handleSubmit();
};
+ const [pendingDelete, setPendingDelete] = createSignal<ProjectInfo[]>([]);
+
+ const selection = createProjectSelection({
+ projects: visibleRecents,
+ grid: recentGrid,
+ onDelete: setPendingDelete,
+ });
+
// Anything outside a card clears the selection — the grid's gaps, the space
// around it, and the composer above it. A click on a card is that card's.
- const clearSelection = createBackgroundClickHandler(() =>
- setSelectedProject(null),
- );
-
- const [pendingDelete, setPendingDelete] = createSignal<ProjectInfo | null>(null);
+ const clearSelection = createBackgroundClickHandler(selection.clear);
- const handleDeleted = (project: ProjectInfo) => {
- setSelectedProject((current) => (current === project.dir ? null : current));
+ const handleDeleted = () => {
+ selection.clear();
refetchProjects();
};
@@ -260,7 +264,7 @@ export function DashboardHomeView() {
try {
const project = await createNewProject();
if (!project) return;
- setSelectedProject(null);
+ selection.clear();
refetchProjects();
openProject(project);
} catch (e) {
@@ -425,7 +429,7 @@ export function DashboardHomeView() {
<div
ref={setRecentGrid}
data-slot="card-grid"
- class="grid items-start gap-x-0.5 gap-y-3"
+ class="grid items-start gap-x-1.5 gap-y-3"
style={{ "grid-template-columns": `repeat(${recentColumns()}, minmax(0, 1fr))` }}
>
<DashboardCardButton onClick={handleCreateProject}>
@@ -437,15 +441,16 @@ export function DashboardHomeView() {
</DashboardCardPreview>
<DashboardCardMeta title="New project" />
</DashboardCardButton>
- <For each={recentProjects().slice(0, recentColumns() - 1)}>
+ <For each={visibleRecents()}>
{(project) => (
<DashboardProjectCard
project={project}
- active={selectedProject() === project.dir}
- onSelect={() => setSelectedProject(project.dir)}
- onDeselect={() => setSelectedProject(null)}
+ active={selection.isSelected(project)}
+ targets={selection.targets(project)}
+ onSelect={(event) => selection.click(project, event)}
+ onContextMenu={() => selection.contextMenu(project)}
onOpen={() => openProject(project)}
- onDelete={() => setPendingDelete(project)}
+ onDelete={() => setPendingDelete(selection.targets(project))}
onChanged={refetchProjects}
/>
)}
@@ -456,8 +461,8 @@ export function DashboardHomeView() {
</div>
<DeleteProjectDialog
- project={pendingDelete()}
- onClose={() => setPendingDelete(null)}
+ projects={pendingDelete()}
+ onClose={() => setPendingDelete([])}
onDeleted={handleDeleted}
/>
</>
diff --git a/apps/web/src/components/dashboard/project-card.tsx b/apps/web/src/components/dashboard/project-card.tsx
index 52b6e5c1..08efb3d7 100644
--- a/apps/web/src/components/dashboard/project-card.tsx
+++ b/apps/web/src/components/dashboard/project-card.tsx
@@ -23,15 +23,17 @@ import { formatEditedAt } from "./utils";
type DashboardProjectCardProps = {
project: ProjectRecord;
- /** Whether the card is the selected one in its grid. */
+ /** Whether the card is selected in its grid. */
active: boolean;
- /** A single click, or a right-click, landed on the card. */
- onSelect: () => void;
- /** Escape was pressed on the card. */
- onDeselect: () => void;
+ /** What the menu acts on: the selection the card is in, or the card alone. */
+ targets: ProjectRecord[];
+ /** A click, with its modifiers, or Space, without, landed on the card. */
+ onSelect: (event?: MouseEvent) => void;
+ /** A right-click landed on the card. */
+ onContextMenu: () => void;
/** The card was double-clicked, or Open chosen from the menu. */
onOpen: () => void;
- /** Delete was pressed on the card, or chosen from the menu. */
+ /** Delete was chosen from the menu, for the targets. */
onDelete: () => void;
/** A rename or duplicate changed the projects on disk; the owner refetches its list. */
onChanged: () => void;
@@ -42,12 +44,14 @@ type DashboardProjectCardProps = {
* the context menu that opens it (here, in the file manager, or in a code
* editor), renames, duplicates, and deletes it. Rename
* happens inline, in place of the name, and lives here so every grid that
- * shows projects gets the same menu.
+ * shows projects gets the same menu. With more than one project selected,
+ * the menu only duplicates and deletes them all.
*/
export function DashboardProjectCard(props: DashboardProjectCardProps) {
const [renaming, setRenaming] = createSignal(false);
const [renameDraft, setRenameDraft] = createSignal("");
const [editors] = createResource(listEditors, { initialValue: [] });
+ const multiple = () => props.targets.length > 1;
const startRenaming = () => {
batch(() => {
@@ -86,11 +90,14 @@ export function DashboardProjectCard(props: DashboardProjectCardProps) {
const handleDuplicate = async () => {
try {
- await duplicateProject(props.project.dir);
- track("project_duplicated");
- props.onChanged();
+ for (const project of props.targets) {
+ await duplicateProject(project.dir);
+ track("project_duplicated");
+ }
} catch (e) {
toast.error("Failed to duplicate project", { description: (e as Error).message });
+ } finally {
+ props.onChanged();
}
};
@@ -145,7 +152,7 @@ export function DashboardProjectCard(props: DashboardProjectCardProps) {
<ContextMenu
modal={false}
onOpenChange={(open) => {
- if (open) props.onSelect();
+ if (open) props.onContextMenu();
}}
>
<ContextMenuTrigger as="div" class="contents">
@@ -153,8 +160,6 @@ export function DashboardProjectCard(props: DashboardProjectCardProps) {
active={props.active}
onClick={props.onSelect}
onDoubleClick={handleOpen}
- onEscape={props.onDeselect}
- onDelete={props.onDelete}
>
<DashboardCardPreview>
<DashboardProjectThumbnail cover={props.project.cover} />
@@ -193,21 +198,32 @@ export function DashboardProjectCard(props: DashboardProjectCardProps) {
</ContextMenuTrigger>
<ContextMenuPortal>
<ContextMenuContent class="w-45 gap-0">
- <ContextMenuItem onSelect={handleOpen}>Open</ContextMenuItem>
- <ContextMenuSeparator class="my-2" />
- <ContextMenuItem onSelect={handleReveal}>
- {isWindowsDesktop() ? "Show in Explorer" : "Show in Finder"}
- </ContextMenuItem>
- <For each={editors()}>
- {(editor) => (
- <ContextMenuItem onSelect={() => handleOpenInEditor(editor)}>Open in {editor.label}</ContextMenuItem>
- )}
- </For>
- <ContextMenuSeparator class="my-2" />
- <ContextMenuItem onSelect={startRenaming}>Rename</ContextMenuItem>
- <ContextMenuItem onSelect={handleDuplicate}>Duplicate</ContextMenuItem>
- <ContextMenuSeparator class="my-2" />
- <ContextMenuItem onSelect={props.onDelete}>Delete</ContextMenuItem>
+ <Show
+ when={!multiple()}
+ fallback={
+ <>
+ <ContextMenuItem onSelect={handleDuplicate}>Duplicate {props.targets.length} projects</ContextMenuItem>
+ <ContextMenuSeparator class="my-2" />
+ <ContextMenuItem onSelect={props.onDelete}>Delete {props.targets.length} projects</ContextMenuItem>
+ </>
+ }
+ >
+ <ContextMenuItem onSelect={handleOpen}>Open</ContextMenuItem>
+ <ContextMenuSeparator class="my-2" />
+ <ContextMenuItem onSelect={handleReveal}>
+ {isWindowsDesktop() ? "Show in Explorer" : "Show in Finder"}
+ </ContextMenuItem>
+ <For each={editors()}>
+ {(editor) => (
+ <ContextMenuItem onSelect={() => handleOpenInEditor(editor)}>Open in {editor.label}</ContextMenuItem>
+ )}
+ </For>
+ <ContextMenuSeparator class="my-2" />
+ <ContextMenuItem onSelect={startRenaming}>Rename</ContextMenuItem>
+ <ContextMenuItem onSelect={handleDuplicate}>Duplicate</ContextMenuItem>
+ <ContextMenuSeparator class="my-2" />
+ <ContextMenuItem onSelect={props.onDelete}>Delete</ContextMenuItem>
+ </Show>
</ContextMenuContent>
</ContextMenuPortal>
</ContextMenu>
diff --git a/apps/web/src/components/dashboard/projects-view.tsx b/apps/web/src/components/dashboard/projects-view.tsx
index cdb39826..c6ec42eb 100644
--- a/apps/web/src/components/dashboard/projects-view.tsx
+++ b/apps/web/src/components/dashboard/projects-view.tsx
@@ -24,6 +24,7 @@ import {
} from "./shared";
import { DeleteProjectDialog } from "./delete-project-dialog";
import { DashboardProjectCard } from "./project-card";
+import { createProjectSelection } from "./selection";
import { parseTimestamp } from "./utils";
import { DashboardSearchPanel } from "./search-bar";
import { projectRoute, useReturnHere } from "@/hooks/use-project-route";
@@ -44,9 +45,9 @@ export function DashboardProjectsView() {
const [search, setSearch] = createSignal("");
const [sort, setSort] = createSignal<ProjectSortOption>("last-viewed");
const [projects, { refetch: refetchProjects }] = createResource(projectsRevision, () => listProjects());
- const [selectedProject, setSelectedProject] = createSignal<string | null>(null);
const [creating, setCreating] = createSignal(false);
- const [pendingDelete, setPendingDelete] = createSignal<ProjectInfo | null>(null);
+ const [pendingDelete, setPendingDelete] = createSignal<ProjectInfo[]>([]);
+ const [grid, setGrid] = createSignal<HTMLDivElement>();
const selectedSortOption = () =>
SORT_OPTIONS.find((option) => option.id === sort()) ?? SORT_OPTIONS[0];
@@ -79,6 +80,12 @@ export function DashboardProjectsView() {
return entries;
});
+ const selection = createProjectSelection({
+ projects: sortedProjects,
+ grid,
+ onDelete: setPendingDelete,
+ });
+
const openProject = async (project: ProjectInfo) => {
const found = await openProjectFromList(project);
if (!found) return;
@@ -86,8 +93,8 @@ export function DashboardProjectsView() {
navigate(projectRoute(projectKey(found)), { state: returnHere() });
};
- const handleDeleted = (project: ProjectInfo) => {
- setSelectedProject((current) => (current === project.dir ? null : current));
+ const handleDeleted = () => {
+ selection.clear();
refetchProjects();
};
@@ -119,7 +126,8 @@ export function DashboardProjectsView() {
<DashboardViewSection
class="pb-4"
title="Recent projects"
- onBackgroundClick={() => setSelectedProject(null)}
+ onBackgroundClick={selection.clear}
+ gridRef={setGrid}
controls={
<>
<Select<(typeof SORT_OPTIONS)[number]>
@@ -159,11 +167,12 @@ export function DashboardProjectsView() {
{(project) => (
<DashboardProjectCard
project={project}
- active={selectedProject() === project.dir}
- onSelect={() => setSelectedProject(project.dir)}
- onDeselect={() => setSelectedProject(null)}
+ active={selection.isSelected(project)}
+ targets={selection.targets(project)}
+ onSelect={(event) => selection.click(project, event)}
+ onContextMenu={() => selection.contextMenu(project)}
onOpen={() => openProject(project)}
- onDelete={() => setPendingDelete(project)}
+ onDelete={() => setPendingDelete(selection.targets(project))}
onChanged={refetchProjects}
/>
)}
@@ -171,8 +180,8 @@ export function DashboardProjectsView() {
</DashboardViewSection>
<DeleteProjectDialog
- project={pendingDelete()}
- onClose={() => setPendingDelete(null)}
+ projects={pendingDelete()}
+ onClose={() => setPendingDelete([])}
onDeleted={handleDeleted}
/>
</DashboardSearchPanel>
diff --git a/apps/web/src/components/dashboard/selection.ts b/apps/web/src/components/dashboard/selection.ts
new file mode 100644
index 00000000..dd8f10b8
--- /dev/null
+++ b/apps/web/src/components/dashboard/selection.ts
@@ -0,0 +1,177 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { createMemo, createSignal, onCleanup, onMount } from "solid-js";
+
+import { isInputTarget } from "@/utils/browser";
+
+import type { ProjectInfo } from "@/projects";
+
+type ProjectSelectionOptions<T extends ProjectInfo> = {
+ /** The projects the grid shows, in the order it shows them. */
+ projects: () => T[];
+ /** The grid itself: its columns, and the cards arrows move focus to. */
+ grid: () => HTMLElement | undefined;
+ /** Delete or Backspace with projects selected. */
+ onDelete: (projects: T[]) => void;
+};
+
+/**
+ * Finder's selection, over a grid of project cards: a click selects one card,
+ * ⌘/Ctrl-click adds or removes one, Shift-click selects the run from the last
+ * card clicked, ⌘/Ctrl-A selects them all, the arrows move the selection
+ * (Shift extends it), Escape clears it, and Delete (or ⌘⌫) asks to delete it.
+ *
+ * The keys are heard on the window, while focus is on the page itself or in
+ * the grid — not in a field, a menu, or a dialog. The grid's first cell is
+ * the New project card, which is never selected.
+ */
+export function createProjectSelection<T extends ProjectInfo>(options: ProjectSelectionOptions<T>) {
+ const [dirs, setDirs] = createSignal<ReadonlySet<string>>(new Set());
+ // Where a Shift range starts, where Shift-arrows move from, and what was
+ // selected before the range — the range is added to that.
+ let anchor: string | null = null;
+ let lead: string | null = null;
+ let base: ReadonlySet<string> = new Set();
+
+ /** What is selected and still on the grid, in grid order. */
+ const selected = createMemo(() => options.projects().filter((project) => dirs().has(project.dir)));
+
+ const isSelected = (project: T) => dirs().has(project.dir);
+
+ const selectOnly = (dir: string) => {
+ setDirs(new Set([dir]));
+ anchor = lead = dir;
+ base = new Set();
+ };
+
+ /** Selects anchor through `dir` on top of `base`, or just `dir` when the anchor is off the grid. */
+ const selectRangeTo = (dir: string) => {
+ const projects = options.projects();
+ const from = projects.findIndex((project) => project.dir === anchor);
+ const to = projects.findIndex((project) => project.dir === dir);
+ if (from < 0 || to < 0) return selectOnly(dir);
+
+ const next = new Set(base);
+ for (let i = Math.min(from, to); i <= Math.max(from, to); i++) next.add(projects[i].dir);
+ setDirs(next);
+ lead = dir;
+ };
+
+ /** A click on a card; a Space press on one, with no event, is a plain click. */
+ const click = (project: T, event?: MouseEvent) => {
+ if (event?.shiftKey) return selectRangeTo(project.dir);
+
+ if (event?.metaKey || event?.ctrlKey) {
+ const next = new Set(dirs());
+ if (!next.delete(project.dir)) next.add(project.dir);
+ setDirs(next);
+ anchor = lead = project.dir;
+ base = new Set([...next].filter((dir) => dir !== project.dir));
+ return;
+ }
+
+ selectOnly(project.dir);
+ };
+
+ /** A right-click keeps the selection it lands in, and replaces any other. */
+ const contextMenu = (project: T) => {
+ if (!isSelected(project)) selectOnly(project.dir);
+ };
+
+ /** What a card's menu acts on: the selection when the card is in it, else the card alone. */
+ const targets = (project: T) => (isSelected(project) ? selected() : [project]);
+
+ const clear = () => {
+ setDirs(new Set<string>());
+ anchor = lead = null;
+ base = new Set();
+ };
+
+ const selectAll = () => {
+ const projects = options.projects();
+ setDirs(new Set(projects.map((project) => project.dir)));
+ anchor = projects[0]?.dir ?? null;
+ lead = projects.at(-1)?.dir ?? null;
+ base = new Set();
+ };
+
+ /** Moves the lead a cell over, or a row up or down, as Finder's icon view does. */
+ const move = (key: string, extend: boolean) => {
+ const projects = options.projects();
+ const grid = options.grid();
+ if (projects.length === 0 || !grid) return;
+
+ // Cells count the New project card at 0, so project i sits in cell i + 1.
+ const columns = Math.max(1, getComputedStyle(grid).gridTemplateColumns.split(" ").length);
+ const count = projects.length;
+ const from = projects.findIndex((project) => project.dir === lead);
+
+ let cell: number;
+ if (from < 0) {
+ cell = 1;
+ } else {
+ const current = from + 1;
+ if (key === "ArrowLeft") cell = current - 1;
+ else if (key === "ArrowRight") cell = current + 1;
+ else if (key === "ArrowUp") cell = current - columns;
+ // Down from a row above a short last row lands on its last card.
+ else if (current + columns <= count) cell = current + columns;
+ else if (Math.floor(current / columns) < Math.floor(count / columns)) cell = count;
+ else return;
+
+ if (cell < 1 || cell > count) return;
+ }
+
+ const dir = projects[cell - 1].dir;
+ if (extend && anchor !== null) selectRangeTo(dir);
+ else selectOnly(dir);
+
+ grid.querySelectorAll<HTMLElement>('[data-slot="card-button"]')[cell]?.focus();
+ };
+
+ const handleKeyDown = (event: KeyboardEvent) => {
+ if (event.defaultPrevented || isInputTarget(event)) return;
+ const target = event.target as Node;
+ if (target !== document.body && !options.grid()?.contains(target)) return;
+
+ const mod = event.metaKey || event.ctrlKey;
+
+ if (mod && !event.shiftKey && !event.altKey && event.key.toLowerCase() === "a") {
+ event.preventDefault();
+ selectAll();
+ return;
+ }
+
+ // ⌘⌫ is Finder's Move to Trash; the bare keys are kept from before.
+ if ((event.key === "Backspace" || event.key === "Delete") && !event.shiftKey && !event.altKey) {
+ const projects = selected();
+ if (projects.length === 0) return;
+ event.preventDefault();
+ options.onDelete(projects);
+ return;
+ }
+
+ if (mod || event.altKey) return;
+
+ if (event.key === "Escape") {
+ if (dirs().size === 0) return;
+ event.preventDefault();
+ clear();
+ return;
+ }
+
+ if (event.key.startsWith("Arrow")) {
+ event.preventDefault();
+ move(event.key, event.shiftKey);
+ }
+ };
+
+ onMount(() => {
+ window.addEventListener("keydown", handleKeyDown);
+ onCleanup(() => window.removeEventListener("keydown", handleKeyDown));
+ });
+
+ return { selected, isSelected, click, contextMenu, targets, clear };
+}
diff --git a/apps/web/src/components/dashboard/shared.tsx b/apps/web/src/components/dashboard/shared.tsx
index ea53dd7c..b1154122 100644
--- a/apps/web/src/components/dashboard/shared.tsx
+++ b/apps/web/src/components/dashboard/shared.tsx
@@ -445,10 +445,9 @@ export function DashboardInfoActionRow(props: DashboardInfoActionRowProps) {
type DashboardCardButtonProps = {
active?: boolean;
- onClick?(): void;
+ /** A click, or Space — which has no mouse event to pass. */
+ onClick?(event?: MouseEvent): void;
onDoubleClick?(): void;
- onEscape?(): void;
- onDelete?(): void;
children: JSX.Element;
class?: string;
};
@@ -470,22 +469,6 @@ export function DashboardCardButton(props: DashboardCardButtonProps) {
event.preventDefault();
props.onClick();
- return;
- }
-
- if (event.key === "Escape") {
- if (!props.onEscape) return;
-
- event.preventDefault();
- props.onEscape();
- return;
- }
-
- if (event.key === "Backspace" || event.key === "Delete") {
- if (!props.onDelete) return;
-
- event.preventDefault();
- props.onDelete();
}
};
@@ -494,11 +477,11 @@ export function DashboardCardButton(props: DashboardCardButtonProps) {
data-slot="card-button"
role="button"
tabIndex={0}
- onClick={props.onClick}
+ onClick={(event) => props.onClick?.(event)}
onDblClick={props.onDoubleClick}
onKeyDown={handleKeyDown}
class={cx(
- "flex min-w-0 flex-col gap-3 rounded-xl px-2 pt-2 pb-3 text-left outline-none transition-colors hover:bg-accent/50 group",
+ "flex min-w-0 flex-col gap-3 rounded-xl px-1.5 pt-1.5 pb-3 text-left outline-none transition-colors select-none hover:bg-accent/50 group",
props.active && "bg-primary/15 hover:bg-primary/15 ring-1 ring-inset ring-primary",
props.class,
)}
@@ -633,6 +616,7 @@ type DashboardViewSectionProps = {
children: JSX.Element;
class?: string;
onBackgroundClick?(): void;
+ gridRef?(el: HTMLDivElement): void;
};
export function DashboardViewSection(props: DashboardViewSectionProps) {
@@ -651,8 +635,9 @@ export function DashboardViewSection(props: DashboardViewSectionProps) {
<div class="min-h-0 flex-1 overflow-y-auto px-4" onClick={handleClick}>
<div
+ ref={props.gridRef}
data-slot="card-grid"
- class="grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] content-start items-start gap-x-0.5 gap-y-3"
+ class="grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] content-start items-start gap-x-1.5 gap-y-3"
>
{props.children}
</div>