From 605554ba0891b7c2c28f55a018d6ceb3a7512ec9 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 16 Dec 2025 16:25:10 +0400 Subject: [PATCH] Update Block events callback types --- packages/core/src/block_manager/types.ts | 19 +++++++++++++------ packages/core/src/common/index.ts | 6 ++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/core/src/block_manager/types.ts b/packages/core/src/block_manager/types.ts index d08793f9b..0126c70a1 100644 --- a/packages/core/src/block_manager/types.ts +++ b/packages/core/src/block_manager/types.ts @@ -1,6 +1,13 @@ import BlockManager from '.'; import Category, { CategoryProperties, ItemsByCategory } from '../abstract/ModuleCategory'; -import { AddOptions, Model, ObjectAny, RemoveOptions } from '../common'; +import { + AddOptions, + EventCallbackAdd, + EventCallbackAll, + EventCallbackRemove, + EventCallbackRemoveBefore, + EventCallbackUpdate, +} from '../common'; import Component from '../dom_components/model/Component'; import Block from './model/Block'; @@ -92,16 +99,16 @@ export enum BlocksEvents { /**{END_EVENTS}*/ export interface BlocksEventCallback { - [BlocksEvents.add]: [Block, AddOptions]; - [BlocksEvents.remove]: [Block, RemoveOptions]; - [BlocksEvents.removeBefore]: [Block, () => void, RemoveOptions]; - [BlocksEvents.update]: [Block, AddOptions]; + [BlocksEvents.add]: EventCallbackAdd; + [BlocksEvents.remove]: EventCallbackRemove; + [BlocksEvents.removeBefore]: EventCallbackRemoveBefore; + [BlocksEvents.update]: EventCallbackUpdate; [BlocksEvents.dragStart]: [Block, DragEvent?]; [BlocksEvents.drag]: [Block, DragEvent?]; [BlocksEvents.dragEnd]: [Component | undefined, Block]; [BlocksEvents.categoryUpdate]: [{ category: Category; changes: Partial; options: AddOptions }]; [BlocksEvents.custom]: [BlocksCustomData]; - [BlocksEvents.all]: [{ event: BlockEvent; model?: Model; options: ObjectAny }]; + [BlocksEvents.all]: EventCallbackAll; } // need this to avoid the TS documentation generator to break diff --git a/packages/core/src/common/index.ts b/packages/core/src/common/index.ts index 3757c8ddb..e0d152632 100644 --- a/packages/core/src/common/index.ts +++ b/packages/core/src/common/index.ts @@ -105,3 +105,9 @@ export const DEFAULT_BOXRECT: BoxRect = { }; export type PrevToNewIdMap = Record; + +export type EventCallbackAdd = [M, AddOptions]; +export type EventCallbackUpdate = [M, AddOptions]; +export type EventCallbackRemove = [M, RemoveOptions]; +export type EventCallbackRemoveBefore = [M, RemoveFn: () => void, RemoveOptions]; +export type EventCallbackAll = [{ event: E; model?: M; options: ObjectAny }];