diff --git a/packages/excalidraw/components/Stats/Angle.tsx b/packages/excalidraw/components/Stats/Angle.tsx index 58d393e1a..4ef20a645 100644 --- a/packages/excalidraw/components/Stats/Angle.tsx +++ b/packages/excalidraw/components/Stats/Angle.tsx @@ -11,13 +11,8 @@ import type Scene from "@excalidraw/element/Scene"; import { angleIcon } from "../icons"; -import DragInput from "./DragInput"; -import { - type DragInputCallbackType, - getStepSizedValue, - isPropertyEditable, - updateBindings, -} from "./utils"; +import DragInput, { type DragInputCallbackType } from "./DragInput"; +import { getStepSizedValue, isPropertyEditable, updateBindings } from "./utils"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/Stats/Dimension.tsx b/packages/excalidraw/components/Stats/Dimension.tsx index 2b5659bf5..dbd942c9a 100644 --- a/packages/excalidraw/components/Stats/Dimension.tsx +++ b/packages/excalidraw/components/Stats/Dimension.tsx @@ -12,12 +12,8 @@ import type { ExcalidrawElement } from "@excalidraw/element/types"; import type Scene from "@excalidraw/element/Scene"; -import DragInput from "./DragInput"; -import { - type DragInputCallbackType, - getStepSizedValue, - isPropertyEditable, -} from "./utils"; +import DragInput, { type DragInputCallbackType } from "./DragInput"; +import { getStepSizedValue, isPropertyEditable } from "./utils"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/Stats/DragInput.tsx b/packages/excalidraw/components/Stats/DragInput.tsx index 730f4f312..6fdf909b2 100644 --- a/packages/excalidraw/components/Stats/DragInput.tsx +++ b/packages/excalidraw/components/Stats/DragInput.tsx @@ -13,13 +13,30 @@ import { CaptureUpdateAction } from "../../store"; import { useApp } from "../App"; import { InlineIcon } from "../InlineIcon"; -import { type DragInputCallbackType, SMALLEST_DELTA } from "./utils"; +import { SMALLEST_DELTA } from "./utils"; import "./DragInput.scss"; import type { StatsInputProperty } from "./utils"; import type { AppState } from "../../types"; +export type DragInputCallbackType< + P extends StatsInputProperty, + E = ExcalidrawElement, +> = (props: { + accumulatedChange: number; + instantChange: number; + originalElements: readonly E[]; + originalElementsMap: ElementsMap; + shouldKeepAspectRatio: boolean; + shouldChangeByStepSize: boolean; + scene: Scene; + nextValue?: number; + property: P; + originalAppState: AppState; + setInputValue: (value: number) => void; +}) => void; + interface StatsDragInputProps< T extends StatsInputProperty, E = ExcalidrawElement, diff --git a/packages/excalidraw/components/Stats/FontSize.tsx b/packages/excalidraw/components/Stats/FontSize.tsx index 3a4c80fb4..ac2e323a6 100644 --- a/packages/excalidraw/components/Stats/FontSize.tsx +++ b/packages/excalidraw/components/Stats/FontSize.tsx @@ -16,8 +16,8 @@ import type Scene from "@excalidraw/element/Scene"; import { fontSizeIcon } from "../icons"; -import StatsDragInput from "./DragInput"; -import { type DragInputCallbackType, getStepSizedValue } from "./utils"; +import StatsDragInput, { type DragInputCallbackType } from "./DragInput"; +import { getStepSizedValue } from "./utils"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/Stats/MultiAngle.tsx b/packages/excalidraw/components/Stats/MultiAngle.tsx index 2ef43c994..5e429dada 100644 --- a/packages/excalidraw/components/Stats/MultiAngle.tsx +++ b/packages/excalidraw/components/Stats/MultiAngle.tsx @@ -13,12 +13,8 @@ import type Scene from "@excalidraw/element/Scene"; import { angleIcon } from "../icons"; -import DragInput from "./DragInput"; -import { - type DragInputCallbackType, - getStepSizedValue, - isPropertyEditable, -} from "./utils"; +import DragInput, { type DragInputCallbackType } from "./DragInput"; +import { getStepSizedValue, isPropertyEditable } from "./utils"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/Stats/MultiDimension.tsx b/packages/excalidraw/components/Stats/MultiDimension.tsx index 711589582..3a008feae 100644 --- a/packages/excalidraw/components/Stats/MultiDimension.tsx +++ b/packages/excalidraw/components/Stats/MultiDimension.tsx @@ -24,9 +24,9 @@ import type { import type Scene from "@excalidraw/element/Scene"; -import DragInput from "./DragInput"; +import DragInput, { type DragInputCallbackType } from "./DragInput"; import { getAtomicUnits, getStepSizedValue, isPropertyEditable } from "./utils"; -import { type DragInputCallbackType, getElementsInAtomicUnit } from "./utils"; +import { getElementsInAtomicUnit } from "./utils"; import type { AtomicUnit } from "./utils"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/Stats/MultiFontSize.tsx b/packages/excalidraw/components/Stats/MultiFontSize.tsx index 9e9c94fbc..d1c7dcdfc 100644 --- a/packages/excalidraw/components/Stats/MultiFontSize.tsx +++ b/packages/excalidraw/components/Stats/MultiFontSize.tsx @@ -19,8 +19,8 @@ import type Scene from "@excalidraw/element/Scene"; import { fontSizeIcon } from "../icons"; -import StatsDragInput from "./DragInput"; -import { DragInputCallbackType, getStepSizedValue } from "./utils"; +import StatsDragInput, { type DragInputCallbackType } from "./DragInput"; +import { getStepSizedValue } from "./utils"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/Stats/utils.ts b/packages/excalidraw/components/Stats/utils.ts index 8e383046e..ef8a663e3 100644 --- a/packages/excalidraw/components/Stats/utils.ts +++ b/packages/excalidraw/components/Stats/utils.ts @@ -31,6 +31,7 @@ import type { import type Scene from "@excalidraw/element/Scene"; import type { AppState } from "../../types"; +import type { DragInputCallbackType } from "./DragInput"; export type StatsInputProperty = | "x" @@ -41,23 +42,6 @@ export type StatsInputProperty = | "fontSize" | "gridStep"; -export type DragInputCallbackType< - P extends StatsInputProperty, - E = ExcalidrawElement, -> = (props: { - accumulatedChange: number; - instantChange: number; - originalElements: readonly E[]; - originalElementsMap: ElementsMap; - shouldKeepAspectRatio: boolean; - shouldChangeByStepSize: boolean; - scene: Scene; - nextValue?: number; - property: P; - originalAppState: AppState; - setInputValue: (value: number) => void; -}) => void; - export const SMALLEST_DELTA = 0.01; export const isPropertyEditable = (