From 3c9b3423a9da38baa0ec5507c398ec2bf1286c79 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Wed, 14 Aug 2024 19:43:25 -0700 Subject: [PATCH] update type defs --- frontend/layout/lib/TileLayout.tsx | 10 ++++++++-- frontend/layout/lib/layoutModel.ts | 18 ++---------------- frontend/layout/lib/layoutModelHooks.ts | 4 ++-- frontend/layout/lib/types.ts | 19 ++++++++++++++++++- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/frontend/layout/lib/TileLayout.tsx b/frontend/layout/lib/TileLayout.tsx index 4e47498d..96d041fd 100644 --- a/frontend/layout/lib/TileLayout.tsx +++ b/frontend/layout/lib/TileLayout.tsx @@ -18,10 +18,16 @@ import React, { import { DropTargetMonitor, XYCoord, useDrag, useDragLayer, useDrop } from "react-dnd"; import { debounce, throttle } from "throttle-debounce"; import { useDevicePixelRatio } from "use-device-pixel-ratio"; -import { LayoutModel, ResizeHandleProps } from "./layoutModel"; +import { LayoutModel } from "./layoutModel"; import { useLayoutNode, useTileLayout } from "./layoutModelHooks"; import "./tilelayout.less"; -import { LayoutNode, LayoutTreeActionType, LayoutTreeComputeMoveNodeAction, TileLayoutContents } from "./types"; +import { + LayoutNode, + LayoutTreeActionType, + LayoutTreeComputeMoveNodeAction, + ResizeHandleProps, + TileLayoutContents, +} from "./types"; import { determineDropDirection } from "./utils"; export interface TileLayoutProps { diff --git a/frontend/layout/lib/layoutModel.ts b/frontend/layout/lib/layoutModel.ts index 783a33f9..daf0ec05 100644 --- a/frontend/layout/lib/layoutModel.ts +++ b/frontend/layout/lib/layoutModel.ts @@ -17,6 +17,7 @@ import { import { ContentRenderer, LayoutNode, + LayoutNodeAdditionalProps, LayoutTreeAction, LayoutTreeActionType, LayoutTreeComputeMoveNodeAction, @@ -30,27 +31,12 @@ import { LayoutTreeState, LayoutTreeSwapNodeAction, PreviewRenderer, + ResizeHandleProps, TileLayoutContents, WritableLayoutTreeStateAtom, } from "./types"; import { Dimensions, FlexDirection, setTransform } from "./utils"; -export interface ResizeHandleProps { - id: string; - parentNodeId: string; - parentIndex: number; - centerPx: number; - transform: CSSProperties; - flexDirection: FlexDirection; -} - -export interface LayoutNodeAdditionalProps { - transform?: CSSProperties; - rect?: Dimensions; - pixelToSizeRatio?: number; - resizeHandles?: ResizeHandleProps[]; -} - interface ResizeContext { handleId: string; pixelToSizeRatio: number; diff --git a/frontend/layout/lib/layoutModelHooks.ts b/frontend/layout/lib/layoutModelHooks.ts index b9a60aa6..aba99307 100644 --- a/frontend/layout/lib/layoutModelHooks.ts +++ b/frontend/layout/lib/layoutModelHooks.ts @@ -3,8 +3,8 @@ import useResizeObserver from "@react-hook/resize-observer"; import { atom, Atom, useAtomValue } from "jotai"; import { useEffect, useState } from "react"; import { withLayoutTreeStateAtomFromTab } from "./layoutAtom"; -import { LayoutModel, LayoutNodeAdditionalProps } from "./layoutModel"; -import { LayoutNode, TileLayoutContents } from "./types"; +import { LayoutModel } from "./layoutModel"; +import { LayoutNode, LayoutNodeAdditionalProps, TileLayoutContents } from "./types"; const layoutModelMap: Map = new Map(); diff --git a/frontend/layout/lib/types.ts b/frontend/layout/lib/types.ts index a36ae6cc..046ffca1 100644 --- a/frontend/layout/lib/types.ts +++ b/frontend/layout/lib/types.ts @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 import { WritableAtom } from "jotai"; -import { DropDirection, FlexDirection } from "./utils.js"; +import { CSSProperties } from "react"; +import { Dimensions, DropDirection, FlexDirection } from "./utils.js"; /** * Represents an operation to insert a node into a tree. @@ -258,3 +259,19 @@ export interface TileLayoutContents { */ tabId?: string; } + +export interface ResizeHandleProps { + id: string; + parentNodeId: string; + parentIndex: number; + centerPx: number; + transform: CSSProperties; + flexDirection: FlexDirection; +} + +export interface LayoutNodeAdditionalProps { + transform?: CSSProperties; + rect?: Dimensions; + pixelToSizeRatio?: number; + resizeHandles?: ResizeHandleProps[]; +}