From 0c937e0827688313ea479249fd45a56d54f5f58b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 30 Dec 2024 13:44:43 +0100 Subject: [PATCH] Type bounds --- .../src/components/grid/stores/bounds.ts | 17 +++++++++++++++-- .../src/components/grid/stores/index.ts | 8 +++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/bounds.ts b/packages/frontend-core/src/components/grid/stores/bounds.ts index c0939f7389..0050555f96 100644 --- a/packages/frontend-core/src/components/grid/stores/bounds.ts +++ b/packages/frontend-core/src/components/grid/stores/bounds.ts @@ -1,6 +1,19 @@ -import { derived, writable } from "svelte/store" +import { derived, Readable, Writable, writable } from "svelte/store" -export const createStores = () => { +interface BoundsStore { + bounds: Writable<{ + left: number + top: number + width: number + height: number + }> + height: Readable + width: Readable +} + +export type Store = BoundsStore + +export const createStores = (): BoundsStore => { const bounds = writable({ left: 0, top: 0, diff --git a/packages/frontend-core/src/components/grid/stores/index.ts b/packages/frontend-core/src/components/grid/stores/index.ts index 8a4d40976d..1b5e2a48c1 100644 --- a/packages/frontend-core/src/components/grid/stores/index.ts +++ b/packages/frontend-core/src/components/grid/stores/index.ts @@ -1,4 +1,4 @@ -import { Readable, Writable } from "svelte/store" +import { Writable } from "svelte/store" import type { APIClient } from "../../../api/types" import * as Bounds from "./bounds" @@ -97,9 +97,6 @@ export type Store = BaseStore & // TODO while typing the rest of stores subscribe: any dispatch: (event: string, data: any) => any - width: Writable - bounds: Readable - height: Readable } & Rows.Store & Reorder.Store & Resize.Store & @@ -108,7 +105,8 @@ export type Store = BaseStore & Cache.Store & Viewport.Store & Notifications.Store & - Sort.Store + Sort.Store & + Bounds.Store export const attachStores = (context: Store): Store => { // Atomic store creation