Browse Source

Update Block events callback types

fix-improve-data-coll-up
Artur Arseniev 10 months ago
parent
commit
605554ba08
  1. 19
      packages/core/src/block_manager/types.ts
  2. 6
      packages/core/src/common/index.ts

19
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<Block>;
[BlocksEvents.remove]: EventCallbackRemove<Block>;
[BlocksEvents.removeBefore]: EventCallbackRemoveBefore<Block>;
[BlocksEvents.update]: EventCallbackUpdate<Block>;
[BlocksEvents.dragStart]: [Block, DragEvent?];
[BlocksEvents.drag]: [Block, DragEvent?];
[BlocksEvents.dragEnd]: [Component | undefined, Block];
[BlocksEvents.categoryUpdate]: [{ category: Category; changes: Partial<CategoryProperties>; options: AddOptions }];
[BlocksEvents.custom]: [BlocksCustomData];
[BlocksEvents.all]: [{ event: BlockEvent; model?: Model; options: ObjectAny }];
[BlocksEvents.all]: EventCallbackAll<BlockEvent, Block>;
}
// need this to avoid the TS documentation generator to break

6
packages/core/src/common/index.ts

@ -105,3 +105,9 @@ export const DEFAULT_BOXRECT: BoxRect = {
};
export type PrevToNewIdMap = Record<string, string>;
export type EventCallbackAdd<M> = [M, AddOptions];
export type EventCallbackUpdate<M> = [M, AddOptions];
export type EventCallbackRemove<M> = [M, RemoveOptions];
export type EventCallbackRemoveBefore<M> = [M, RemoveFn: () => void, RemoveOptions];
export type EventCallbackAll<E, M> = [{ event: E; model?: M; options: ObjectAny }];

Loading…
Cancel
Save