From e7920aeb34e14e0dae66f9bea1bf8e7b6ff848dd Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 27 Dec 2024 18:15:33 +0100 Subject: [PATCH] Fix ui actions usage --- .../src/components/grid/stores/ui.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/ui.ts b/packages/frontend-core/src/components/grid/stores/ui.ts index 45baebe4fe..3cde73207e 100644 --- a/packages/frontend-core/src/components/grid/stores/ui.ts +++ b/packages/frontend-core/src/components/grid/stores/ui.ts @@ -40,12 +40,21 @@ export interface UIDerivedStore { compact: Readable selectedRowCount: Readable isSelectingCells: Readable - selectedCells: Readable & { actions: any } + selectedCells: Readable selectedCellMap: Readable> selectedCellCount: Readable } -export type Store = UIStore & UIDerivedStore +interface UIActionStore { + selectedCells: UIDerivedStore["selectedCells"] & { + actions: { + clear: () => void + selectRange: (source: string | null, target: string | null) => void + } + } +} + +export type Store = UIStore & UIDerivedStore & UIActionStore export const createStores = (context: StoreContext): UIStore => { const { props } = context @@ -82,7 +91,7 @@ export const createStores = (context: StoreContext): UIStore => { } } -export const deriveStores = (context: StoreContext) => { +export const deriveStores = (context: StoreContext): UIDerivedStore => { const { focusedCellId, rows, @@ -97,14 +106,14 @@ export const deriveStores = (context: StoreContext) => { // Derive the current focused row ID const focusedRowId = derived(focusedCellId, $focusedCellId => { - return parseCellID($focusedCellId).rowId + return parseCellID($focusedCellId).rowId ?? null }) // Derive the row that contains the selected cell const focusedRow = derived( [focusedRowId, rowLookupMap], ([$focusedRowId, $rowLookupMap]) => { - if ($focusedRowId === undefined) { + if ($focusedRowId === null) { return }