Type derivedStore

This commit is contained in:
Adria Navarro 2024-12-20 12:23:50 +01:00
parent 675e195708
commit 624df90eda
1 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { derived, get, Writable, writable } from "svelte/store"
import { derived, get, Readable, Writable, writable } from "svelte/store"
import { DefaultColumnWidth, GutterWidth } from "../lib/constants"
import { CalculationType, FieldSchema } from "@budibase/types"
import { StoreContext } from "."
@ -7,6 +7,15 @@ export interface Store {
columns: Writable<Column[]>
}
export interface DerivedStore {
tableColumns: Readable<Column[]>
displayColumn: Readable<Column>
columnLookupMap: Readable<Record<string, Column>>
visibleColumns: Readable<Column[]>
scrollableColumns: Readable<Column[]>
hasNonAutoColumn: Readable<boolean>
}
type Column = FieldSchema & {
label: string
readonly: boolean
@ -51,7 +60,7 @@ export const createStores = (): Store => {
}
}
export const deriveStores = (context: Store) => {
export const deriveStores = (context: Store): DerivedStore => {
const { columns } = context
// Derive a lookup map for all columns by name