From 96d04a60943a8d30706e94ba96dc4c1d83b9811c Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Mon, 6 Jan 2025 15:49:37 +0100 Subject: [PATCH] fix selection command --- src/components/table/table.tsx | 4 ++-- src/features/file/grid.tsx | 9 ++++++++- src/routes/(editor)/edit.tsx | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/table/table.tsx b/src/components/table/table.tsx index 1a4ad48..bde47a7 100644 --- a/src/components/table/table.tsx +++ b/src/components/table/table.tsx @@ -23,7 +23,7 @@ export interface TableApi> { readonly rows: Accessor>; readonly columns: Accessor[]>; selectAll(): void; - clear(): void; + clearSelection(): void; } interface TableContextType> { @@ -123,7 +123,7 @@ function Api>(props: { api: undefined | ((api: Tab selectAll() { selectionContext.selectAll(); }, - clear() { + clearSelection() { selectionContext.clear(); }, }; diff --git a/src/features/file/grid.tsx b/src/features/file/grid.tsx index 4d8ec7e..b98b2a1 100644 --- a/src/features/file/grid.tsx +++ b/src/features/file/grid.tsx @@ -11,7 +11,8 @@ export interface GridApi { readonly selection: Accessor[]>; remove(indices: number[]): void; addKey(key: string): void; - // addLocale(locale: string): void; + selectAll(): void; + clearSelection(): void; }; const groupBy = (rows: DataSetRowNode[]) => { @@ -68,6 +69,12 @@ export function Grid(props: { class?: string, rows: Entry[], locales: string[], addKey(key) { r.insert({ key, ...Object.fromEntries(locales().map(l => [l, ''])) }); }, + selectAll() { + api()?.selectAll(); + }, + clearSelection() { + api()?.clearSelection(); + }, }); }); diff --git a/src/routes/(editor)/edit.tsx b/src/routes/(editor)/edit.tsx index 661d234..f54b183 100644 --- a/src/routes/(editor)/edit.tsx +++ b/src/routes/(editor)/edit.tsx @@ -275,7 +275,7 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => { api()?.selectAll(); }, { key: 'a', modifier: Modifier.Control }), clearSelection: createCommand('clear selection', () => { - api()?.clear(); + api()?.clearSelection(); }), delete: createCommand('delete selected items', () => { const { selection, remove } = api() ?? {};