From 1c4a1c6b99adcff90b0e8d2421271a2a675f61f4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 20 Dec 2024 11:50:28 +0100 Subject: [PATCH] initial ts conversion --- .../grid/stores/{columns.js => columns.ts} | 28 +++++++++++++++---- .../grid/stores/{index.js => index.ts} | 8 ++++++ 2 files changed, 31 insertions(+), 5 deletions(-) rename packages/frontend-core/src/components/grid/stores/{columns.js => columns.ts} (90%) rename packages/frontend-core/src/components/grid/stores/{index.js => index.ts} (92%) diff --git a/packages/frontend-core/src/components/grid/stores/columns.js b/packages/frontend-core/src/components/grid/stores/columns.ts similarity index 90% rename from packages/frontend-core/src/components/grid/stores/columns.js rename to packages/frontend-core/src/components/grid/stores/columns.ts index 5f2800ba7a..44f9039de5 100644 --- a/packages/frontend-core/src/components/grid/stores/columns.js +++ b/packages/frontend-core/src/components/grid/stores/columns.ts @@ -1,7 +1,25 @@ -import { derived, get, writable } from "svelte/store" +import { derived, get, Writable, writable } from "svelte/store" import { DefaultColumnWidth, GutterWidth } from "../lib/constants" +import { FieldSchema } from "@budibase/types" +import { StoreContext } from "." -export const createStores = () => { +export interface Store { + columns: Writable +} + +type Column = FieldSchema & { + related?: { + field: string + subField: string + } + primaryDisplay: boolean + + schema?: { + autocolumn: boolean + } +} + +export const createStores = (): Store => { const columns = writable([]) // Enrich columns with metadata about their display position @@ -30,7 +48,7 @@ export const createStores = () => { } } -export const deriveStores = context => { +export const deriveStores = (context: Store) => { const { columns } = context // Derive a lookup map for all columns by name @@ -78,7 +96,7 @@ export const deriveStores = context => { } } -export const createActions = context => { +export const createActions = (context: StoreContext) => { const { columns, datasource } = context // Updates the width of all columns @@ -125,7 +143,7 @@ export const createActions = context => { } } -export const initialise = context => { +export const initialise = (context: StoreContext) => { const { definition, columns, displayColumn, enrichedSchema } = context // Merge new schema fields with existing schema in order to preserve widths diff --git a/packages/frontend-core/src/components/grid/stores/index.js b/packages/frontend-core/src/components/grid/stores/index.ts similarity index 92% rename from packages/frontend-core/src/components/grid/stores/index.js rename to packages/frontend-core/src/components/grid/stores/index.ts index 6671cc729c..80898713e5 100644 --- a/packages/frontend-core/src/components/grid/stores/index.js +++ b/packages/frontend-core/src/components/grid/stores/index.ts @@ -71,3 +71,11 @@ export const attachStores = context => { return context } + +export interface StoreContext { + columns: Columns.Store["columns"] + datasource: any + definition: any + displayColumn: any + enrichedSchema: any +}