Reverse refactor

This commit is contained in:
Mark Tolmacs 2025-05-02 14:12:12 +02:00
parent 2605c3f962
commit 9ab7e55377
No known key found for this signature in database
8 changed files with 31 additions and 43 deletions

View file

@ -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";

View file

@ -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";

View file

@ -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,

View file

@ -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";

View file

@ -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";

View file

@ -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";

View file

@ -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";

View file

@ -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 = (