diff --git a/packages/frontend-core/src/components/grid/stores/columns.ts b/packages/frontend-core/src/components/grid/stores/columns.ts index b201cc7f7b..18ef8f55c2 100644 --- a/packages/frontend-core/src/components/grid/stores/columns.ts +++ b/packages/frontend-core/src/components/grid/stores/columns.ts @@ -180,6 +180,7 @@ export const initialise = (context: StoreContext) => { conditions: fieldSchema.conditions, related: fieldSchema.related, calculationType: fieldSchema.calculationType, + __left: undefined as any, // TODO } // Override a few properties for primary display if (field === primaryDisplay) { diff --git a/packages/frontend-core/src/components/grid/stores/index.ts b/packages/frontend-core/src/components/grid/stores/index.ts index b5676ca241..2a68e30d25 100644 --- a/packages/frontend-core/src/components/grid/stores/index.ts +++ b/packages/frontend-core/src/components/grid/stores/index.ts @@ -66,7 +66,8 @@ export type Store = BaseStore & Menu.Store & Filter.Store & UI.Store & - Clipboard.Store & { + Clipboard.Store & + Scroll.Store & { // TODO while typing the rest of stores fetch: Writable sort: Writable @@ -85,6 +86,8 @@ export type Store = BaseStore & width: Writable fixedRowHeight: Writable rowChangeCache: Readable + bounds: Readable + height: Readable } export const attachStores = (context: Store): Store => { diff --git a/packages/frontend-core/src/components/grid/stores/scroll.js b/packages/frontend-core/src/components/grid/stores/scroll.ts similarity index 86% rename from packages/frontend-core/src/components/grid/stores/scroll.js rename to packages/frontend-core/src/components/grid/stores/scroll.ts index 9411cb93f1..0be8fa4a77 100644 --- a/packages/frontend-core/src/components/grid/stores/scroll.js +++ b/packages/frontend-core/src/components/grid/stores/scroll.ts @@ -1,4 +1,4 @@ -import { writable, derived, get } from "svelte/store" +import { writable, derived, get, Writable, Readable } from "svelte/store" import { tick } from "svelte" import { GutterWidth, @@ -8,8 +8,31 @@ import { VPadding, } from "../lib/constants" import { parseCellID } from "../lib/utils" +import { Store as StoreContext } from "." -export const createStores = () => { +interface ScrollStore { + scroll: Writable<{ + left: number + top: number + }> + scrollTop: Readable + scrollLeft: Readable +} + +interface ScrollDerivedStore { + stickyWidth: Readable + contentHeight: Readable + contentWidth: Readable + screenWidth: Readable + maxScrollTop: Readable + maxScrollLeft: Readable + showHScrollbar: Readable + showVScrollbar: Readable +} + +export type Store = ScrollStore & ScrollDerivedStore + +export const createStores = (): ScrollStore => { const scroll = writable({ left: 0, top: 0, @@ -26,7 +49,7 @@ export const createStores = () => { } } -export const deriveStores = context => { +export const deriveStores = (context: StoreContext) => { const { rows, visibleColumns, @@ -107,7 +130,7 @@ export const deriveStores = context => { } } -export const initialise = context => { +export const initialise = (context: StoreContext) => { const { focusedCellId, focusedRow, @@ -189,7 +212,7 @@ export const initialise = context => { // Ensure horizontal position is viewable // Check horizontal position of columns next const { field } = parseCellID($focusedCellId) - const column = get(columnLookupMap)[field] + const column = get(columnLookupMap)[field!] if (!column || column.primaryDisplay) { return } diff --git a/packages/frontend-core/src/components/grid/stores/ui.ts b/packages/frontend-core/src/components/grid/stores/ui.ts index 7d6c6dcac9..31f2dc3ea0 100644 --- a/packages/frontend-core/src/components/grid/stores/ui.ts +++ b/packages/frontend-core/src/components/grid/stores/ui.ts @@ -8,6 +8,7 @@ import { } from "../lib/constants" import { getCellID, parseCellID } from "../lib/utils" import { Store as StoreContext } from "." +import { Row } from "@budibase/types" export interface UIStore { focusedCellId: Writable @@ -34,7 +35,7 @@ export interface UIStore { export interface UIDerivedStore { focusedRowId: Readable - focusedRow: Readable + focusedRow: Readable contentLines: Readable<3 | 2 | 1> compact: Readable selectedRowCount: Readable diff --git a/packages/types/src/ui/stores/grid/columns.ts b/packages/types/src/ui/stores/grid/columns.ts index 5f02efa8cb..56442a871f 100644 --- a/packages/types/src/ui/stores/grid/columns.ts +++ b/packages/types/src/ui/stores/grid/columns.ts @@ -17,5 +17,6 @@ export type UIColumn = FieldSchema & { } calculationType: CalculationType __idx?: number - __left?: number + __left: number + width: number }