fix selection command
This commit is contained in:
parent
ce7a300f48
commit
96d04a6094
3 changed files with 11 additions and 4 deletions
|
@ -23,7 +23,7 @@ export interface TableApi<T extends Record<string, any>> {
|
||||||
readonly rows: Accessor<DataSet<T>>;
|
readonly rows: Accessor<DataSet<T>>;
|
||||||
readonly columns: Accessor<Column<T>[]>;
|
readonly columns: Accessor<Column<T>[]>;
|
||||||
selectAll(): void;
|
selectAll(): void;
|
||||||
clear(): void;
|
clearSelection(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TableContextType<T extends Record<string, any>> {
|
interface TableContextType<T extends Record<string, any>> {
|
||||||
|
@ -123,7 +123,7 @@ function Api<T extends Record<string, any>>(props: { api: undefined | ((api: Tab
|
||||||
selectAll() {
|
selectAll() {
|
||||||
selectionContext.selectAll();
|
selectionContext.selectAll();
|
||||||
},
|
},
|
||||||
clear() {
|
clearSelection() {
|
||||||
selectionContext.clear();
|
selectionContext.clear();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,8 @@ export interface GridApi {
|
||||||
readonly selection: Accessor<SelectionItem<number, Entry>[]>;
|
readonly selection: Accessor<SelectionItem<number, Entry>[]>;
|
||||||
remove(indices: number[]): void;
|
remove(indices: number[]): void;
|
||||||
addKey(key: string): void;
|
addKey(key: string): void;
|
||||||
// addLocale(locale: string): void;
|
selectAll(): void;
|
||||||
|
clearSelection(): void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const groupBy = (rows: DataSetRowNode<number, Entry>[]) => {
|
const groupBy = (rows: DataSetRowNode<number, Entry>[]) => {
|
||||||
|
@ -68,6 +69,12 @@ export function Grid(props: { class?: string, rows: Entry[], locales: string[],
|
||||||
addKey(key) {
|
addKey(key) {
|
||||||
r.insert({ key, ...Object.fromEntries(locales().map(l => [l, ''])) });
|
r.insert({ key, ...Object.fromEntries(locales().map(l => [l, ''])) });
|
||||||
},
|
},
|
||||||
|
selectAll() {
|
||||||
|
api()?.selectAll();
|
||||||
|
},
|
||||||
|
clearSelection() {
|
||||||
|
api()?.clearSelection();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
|
||||||
api()?.selectAll();
|
api()?.selectAll();
|
||||||
}, { key: 'a', modifier: Modifier.Control }),
|
}, { key: 'a', modifier: Modifier.Control }),
|
||||||
clearSelection: createCommand('clear selection', () => {
|
clearSelection: createCommand('clear selection', () => {
|
||||||
api()?.clear();
|
api()?.clearSelection();
|
||||||
}),
|
}),
|
||||||
delete: createCommand('delete selected items', () => {
|
delete: createCommand('delete selected items', () => {
|
||||||
const { selection, remove } = api() ?? {};
|
const { selection, remove } = api() ?? {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue