From 8c2577703f1a44c4799b48cbc4d12fbfeedd8af7 Mon Sep 17 00:00:00 2001 From: Sam Jeeves Date: Sat, 16 Dec 2023 14:55:13 +0100 Subject: [PATCH 1/2] Allow more derived State classes to provide a generic type --- packages/react-canvas-core/src/states/DragCanvasState.ts | 3 ++- packages/react-canvas-core/src/states/SelectingState.ts | 3 ++- packages/react-canvas-core/src/states/SelectionBoxState.ts | 3 ++- .../react-diagrams-core/src/states/DragDiagramItemsState.ts | 2 +- packages/react-diagrams-core/src/states/DragNewLinkState.ts | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/react-canvas-core/src/states/DragCanvasState.ts b/packages/react-canvas-core/src/states/DragCanvasState.ts index 0d15c3e54..1a2fe073b 100644 --- a/packages/react-canvas-core/src/states/DragCanvasState.ts +++ b/packages/react-canvas-core/src/states/DragCanvasState.ts @@ -1,3 +1,4 @@ +import { CanvasEngine } from '../CanvasEngine'; import { AbstractDisplacementState, AbstractDisplacementStateEvent } from '../core-state/AbstractDisplacementState'; import { State } from '../core-state/State'; @@ -8,7 +9,7 @@ export interface DragCanvasStateOptions { allowDrag?: boolean; } -export class DragCanvasState extends AbstractDisplacementState { +export class DragCanvasState extends AbstractDisplacementState { // store this as we drag the canvas initialCanvasX: number; initialCanvasY: number; diff --git a/packages/react-canvas-core/src/states/SelectingState.ts b/packages/react-canvas-core/src/states/SelectingState.ts index 8a5c781f3..5c8f2e24d 100644 --- a/packages/react-canvas-core/src/states/SelectingState.ts +++ b/packages/react-canvas-core/src/states/SelectingState.ts @@ -2,8 +2,9 @@ import { State } from '../core-state/State'; import { Action, ActionEvent, InputType } from '../core-actions/Action'; import { SelectionBoxState } from './SelectionBoxState'; import { MouseEvent } from 'react'; +import { CanvasEngine } from '../CanvasEngine'; -export class SelectingState extends State { +export class SelectingState extends State { constructor() { super({ name: 'selecting' diff --git a/packages/react-canvas-core/src/states/SelectionBoxState.ts b/packages/react-canvas-core/src/states/SelectionBoxState.ts index d26c43495..642cbad1b 100644 --- a/packages/react-canvas-core/src/states/SelectionBoxState.ts +++ b/packages/react-canvas-core/src/states/SelectionBoxState.ts @@ -4,6 +4,7 @@ import { SelectionLayerModel } from '../entities/selection/SelectionLayerModel'; import { Point, Rectangle } from '@projectstorm/geometry'; import { BasePositionModel } from '../core-models/BasePositionModel'; import { ModelGeometryInterface } from '../core/ModelGeometryInterface'; +import { CanvasEngine } from '../CanvasEngine'; export interface SimpleClientRect { left: number; @@ -14,7 +15,7 @@ export interface SimpleClientRect { bottom: number; } -export class SelectionBoxState extends AbstractDisplacementState { +export class SelectionBoxState extends AbstractDisplacementState { layer: SelectionLayerModel; constructor() { diff --git a/packages/react-diagrams-core/src/states/DragDiagramItemsState.ts b/packages/react-diagrams-core/src/states/DragDiagramItemsState.ts index 86a56affa..11c9b3343 100644 --- a/packages/react-diagrams-core/src/states/DragDiagramItemsState.ts +++ b/packages/react-diagrams-core/src/states/DragDiagramItemsState.ts @@ -6,7 +6,7 @@ import { PortModel } from '../entities/port/PortModel'; import { MouseEvent } from 'react'; import { LinkModel } from '../entities/link/LinkModel'; -export class DragDiagramItemsState extends MoveItemsState { +export class DragDiagramItemsState extends MoveItemsState { constructor() { super(); this.registerAction( diff --git a/packages/react-diagrams-core/src/states/DragNewLinkState.ts b/packages/react-diagrams-core/src/states/DragNewLinkState.ts index 24823f7aa..8b444c0ef 100644 --- a/packages/react-diagrams-core/src/states/DragNewLinkState.ts +++ b/packages/react-diagrams-core/src/states/DragNewLinkState.ts @@ -22,7 +22,7 @@ export interface DragNewLinkStateOptions { allowLinksFromLockedPorts?: boolean; } -export class DragNewLinkState extends AbstractDisplacementState { +export class DragNewLinkState extends AbstractDisplacementState { port: PortModel; link: LinkModel; config: DragNewLinkStateOptions; From 09ed60ff64c670730dc5579412b1122261bc3718 Mon Sep 17 00:00:00 2001 From: Sam Jeeves Date: Sat, 16 Dec 2023 15:00:41 +0100 Subject: [PATCH 2/2] changeset --- .changeset/curly-doors-remain.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/curly-doors-remain.md diff --git a/.changeset/curly-doors-remain.md b/.changeset/curly-doors-remain.md new file mode 100644 index 000000000..258f263e1 --- /dev/null +++ b/.changeset/curly-doors-remain.md @@ -0,0 +1,6 @@ +--- +'@projectstorm/react-canvas-core': patch +'@projectstorm/react-diagrams-core': patch +--- + +Allow more derived State classes to provide a generic type