diff --git a/lib/command/CommandHandler.ts b/lib/command/CommandHandler.ts index 6571ac320..e50ee54b5 100644 --- a/lib/command/CommandHandler.ts +++ b/lib/command/CommandHandler.ts @@ -1,12 +1,11 @@ -import { ElementLike } from "../core/Types"; -import { CommandContext } from "./CommandStack"; +import type { ElementLike } from '../core/Types'; +import type { CommandContext } from './CommandStack'; /** * A command handler that may be registered via * {@link CommandStack#registerHandler}. */ export default interface CommandHandler { - /** * Execute changes described in the passed action context. * @@ -49,4 +48,4 @@ export default interface CommandHandler { * @param context The execution context. */ postExecute?(context: CommandContext): void; -} \ No newline at end of file +} diff --git a/lib/draw/DefaultRenderer.spec.ts b/lib/draw/DefaultRenderer.spec.ts index b344c158f..8de80bcc4 100644 --- a/lib/draw/DefaultRenderer.spec.ts +++ b/lib/draw/DefaultRenderer.spec.ts @@ -1,9 +1,9 @@ -import Diagram from "../Diagram"; +import Diagram from '../Diagram'; -import DefaultRenderer from "./DefaultRenderer"; +import DefaultRenderer from './DefaultRenderer'; -import ElementFactory from "../core/ElementFactory"; -import GraphicsFactory from "../core/GraphicsFactory"; +import ElementFactory from '../core/ElementFactory'; +import GraphicsFactory from '../core/GraphicsFactory'; const diagram = new Diagram(); diff --git a/lib/features/context-pad/ContextPadProvider.ts b/lib/features/context-pad/ContextPadProvider.ts index 4736eb398..974e4ae6d 100644 --- a/lib/features/context-pad/ContextPadProvider.ts +++ b/lib/features/context-pad/ContextPadProvider.ts @@ -1,11 +1,17 @@ -import { Element } from '../../model/Types'; +import type { Element } from '../../model/Types'; -import { ContextPadTarget } from './ContextPad'; +import type { ContextPadTarget } from './ContextPad'; -export type ContextPadEntryAction = (event: Event, target: ContextPadTarget, autoActivate: boolean) => any; +export type ContextPadEntryAction = ( + event: Event, + target: ContextPadTarget, + autoActivate: boolean +) => any; export type ContextPadEntry = { - action: Record> | ContextPadEntryAction; + action: + | Record> + | ContextPadEntryAction; className?: string; group?: string; html?: string; @@ -13,15 +19,21 @@ export type ContextPadEntry = { title?: string; }; -export type ContextPadEntries = Record>; +export type ContextPadEntries = Record< + string, + ContextPadEntry +>; -export type ContextPadEntriesCallback = (entries: ContextPadEntries) => ContextPadEntries; +export type ContextPadEntriesCallback = ( + entries: ContextPadEntries +) => ContextPadEntries; /** * An interface to be implemented by a context menu provider. */ -export default interface ContextPadProvider { - +export default interface ContextPadProvider< + ElementType extends Element = Element +> { /** * Returns a map of entries or a function that receives, modifies and returns * a map of entries for one element. @@ -50,7 +62,9 @@ export default interface ContextPadProvider ContextPadEntriesCallback | ContextPadEntries; + getContextPadEntries?: ( + element: ElementType + ) => ContextPadEntriesCallback | ContextPadEntries; /** * Returns a map of entries or a function that receives, modifies and returns @@ -79,5 +93,7 @@ export default interface ContextPadProvider ContextPadEntriesCallback | ContextPadEntries; -} \ No newline at end of file + getMultiElementContextPadEntries?: ( + elements: ElementType[] + ) => ContextPadEntriesCallback | ContextPadEntries; +} diff --git a/lib/features/outline/OutlineProvider.ts b/lib/features/outline/OutlineProvider.ts index 76a6fa2a2..2e57ca5cc 100644 --- a/lib/features/outline/OutlineProvider.ts +++ b/lib/features/outline/OutlineProvider.ts @@ -1,4 +1,4 @@ -import { Element } from '../../model/Types'; +import type { Element } from '../../model/Types'; export type Outline = SVGSVGElement | SVGCircleElement | SVGRectElement; @@ -6,7 +6,6 @@ export type Outline = SVGSVGElement | SVGCircleElement | SVGRectElement; * An interface to be implemented by an outline provider. */ export default interface OutlineProvider { - /** * Returns outline shape for given element. * @@ -49,13 +48,13 @@ export default interface OutlineProvider { * } else if (element.type === 'Bar') { * return true; * } - * + * * return false; * } * ``` - * + * * @param element * @param outline - */ + */ updateOutline: (element: Element, outline: Outline) => boolean; } diff --git a/lib/features/popup-menu/PopupMenuProvider.ts b/lib/features/popup-menu/PopupMenuProvider.ts index 0af523850..f36a6f75e 100644 --- a/lib/features/popup-menu/PopupMenuProvider.ts +++ b/lib/features/popup-menu/PopupMenuProvider.ts @@ -1,8 +1,12 @@ -import { VNode } from '@bpmn-io/diagram-js-ui'; +import type { VNode } from '@bpmn-io/diagram-js-ui'; -import { PopupMenuTarget } from './PopupMenu'; +import type { PopupMenuTarget } from './PopupMenu'; -export type PopupMenuEntryAction = (event: Event, entry: PopupMenuEntry, action?: string) => any; +export type PopupMenuEntryAction = ( + event: Event, + entry: PopupMenuEntry, + action?: string +) => any; export type PopupMenuEntry = { action: PopupMenuEntryAction; @@ -15,9 +19,15 @@ export type PopupMenuEntry = { export type PopupMenuEntries = Record; -export type PopupMenuEntriesProvider = (entries: PopupMenuEntries) => PopupMenuEntries; +export type PopupMenuEntriesProvider = ( + entries: PopupMenuEntries +) => PopupMenuEntries; -export type PopupMenuHeaderEntryAction = (event: Event, entry: PopupMenuHeaderEntry, action?: string) => any; +export type PopupMenuHeaderEntryAction = ( + event: Event, + entry: PopupMenuHeaderEntry, + action?: string +) => any; export type PopupMenuHeaderEntry = { action: PopupMenuHeaderEntryAction; @@ -33,17 +43,20 @@ export type PopupMenuHeaderEntry = { export type PopupMenuHeaderEntries = PopupMenuHeaderEntry[]; -export type PopupMenuProviderHeaderEntriesProvider = (entries: PopupMenuHeaderEntries) => PopupMenuHeaderEntries; +export type PopupMenuProviderHeaderEntriesProvider = ( + entries: PopupMenuHeaderEntries +) => PopupMenuHeaderEntries; export type PopupMenuEmptyPlaceholder = VNode; -export type PopupMenuEmptyPlaceholderProvider = (search: string) => PopupMenuEmptyPlaceholder; +export type PopupMenuEmptyPlaceholderProvider = ( + search: string +) => PopupMenuEmptyPlaceholder; /** * An interface to be implemented by a popup menu provider. */ export default interface PopupMenuProvider { - /** * Returns a map of entries or a function that receives, modifies and returns * a map of entries. @@ -72,7 +85,9 @@ export default interface PopupMenuProvider { * * @param target */ - getPopupMenuEntries(target: PopupMenuTarget): PopupMenuEntriesProvider | PopupMenuEntries; + getPopupMenuEntries( + target: PopupMenuTarget + ): PopupMenuEntriesProvider | PopupMenuEntries; /** * Returns a list of header entries or a function that receives, modifies and @@ -104,7 +119,9 @@ export default interface PopupMenuProvider { * * @param target */ - getHeaderEntries?(target: PopupMenuTarget): PopupMenuProviderHeaderEntriesProvider | PopupMenuHeaderEntries; + getHeaderEntries?( + target: PopupMenuTarget + ): PopupMenuProviderHeaderEntriesProvider | PopupMenuHeaderEntries; /** * Returns a component to be displayed when no popup menu entries @@ -120,5 +137,7 @@ export default interface PopupMenuProvider { * } * ``` */ - getEmptyPlaceholder?(): PopupMenuEmptyPlaceholderProvider | PopupMenuEmptyPlaceholder; -} \ No newline at end of file + getEmptyPlaceholder?(): + | PopupMenuEmptyPlaceholderProvider + | PopupMenuEmptyPlaceholder; +} diff --git a/lib/features/search-pad/SearchPadProvider.ts b/lib/features/search-pad/SearchPadProvider.ts index 65eec51ae..082f96527 100644 --- a/lib/features/search-pad/SearchPadProvider.ts +++ b/lib/features/search-pad/SearchPadProvider.ts @@ -1,4 +1,4 @@ -import { Element } from '../../model/Types'; +import type { Element } from '../../model/Types'; export type Token = { matched: string; @@ -13,4 +13,4 @@ export type SearchResult = { export default interface SearchPadProvider { find(pattern: string): SearchResult[]; -} \ No newline at end of file +}