Skip to content

Commit

Permalink
chore: change typescript imports to use verbatim module syntax (#927)
Browse files Browse the repository at this point in the history
Closes #864
  • Loading branch information
LoaderB0T authored Aug 20, 2024
1 parent 5cfe484 commit e6559b2
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 38 deletions.
7 changes: 3 additions & 4 deletions lib/command/CommandHandler.ts
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -49,4 +48,4 @@ export default interface CommandHandler {
* @param context The execution context.
*/
postExecute?(context: CommandContext): void;
}
}
8 changes: 4 additions & 4 deletions lib/draw/DefaultRenderer.spec.ts
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
38 changes: 27 additions & 11 deletions lib/features/context-pad/ContextPadProvider.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
import { Element } from '../../model/Types';
import type { Element } from '../../model/Types';

import { ContextPadTarget } from './ContextPad';
import type { ContextPadTarget } from './ContextPad';

export type ContextPadEntryAction<ElementType extends Element = Element> = (event: Event, target: ContextPadTarget<ElementType>, autoActivate: boolean) => any;
export type ContextPadEntryAction<ElementType extends Element = Element> = (
event: Event,
target: ContextPadTarget<ElementType>,
autoActivate: boolean
) => any;

export type ContextPadEntry<ElementType extends Element = Element> = {
action: Record<string, ContextPadEntryAction<ElementType>> | ContextPadEntryAction<ElementType>;
action:
| Record<string, ContextPadEntryAction<ElementType>>
| ContextPadEntryAction<ElementType>;
className?: string;
group?: string;
html?: string;
imageUrl?: string;
title?: string;
};

export type ContextPadEntries<ElementType extends Element = Element> = Record<string, ContextPadEntry<ElementType>>;
export type ContextPadEntries<ElementType extends Element = Element> = Record<
string,
ContextPadEntry<ElementType>
>;

export type ContextPadEntriesCallback<ElementType extends Element = Element> = (entries: ContextPadEntries<ElementType>) => ContextPadEntries<ElementType>;
export type ContextPadEntriesCallback<ElementType extends Element = Element> = (
entries: ContextPadEntries<ElementType>
) => ContextPadEntries<ElementType>;

/**
* An interface to be implemented by a context menu provider.
*/
export default interface ContextPadProvider<ElementType extends Element = Element> {

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.
Expand Down Expand Up @@ -50,7 +62,9 @@ export default interface ContextPadProvider<ElementType extends Element = Elemen
*
* @param element
*/
getContextPadEntries?: (element: ElementType) => ContextPadEntriesCallback<ElementType> | ContextPadEntries<ElementType>;
getContextPadEntries?: (
element: ElementType
) => ContextPadEntriesCallback<ElementType> | ContextPadEntries<ElementType>;

/**
* Returns a map of entries or a function that receives, modifies and returns
Expand Down Expand Up @@ -79,5 +93,7 @@ export default interface ContextPadProvider<ElementType extends Element = Elemen
*
* @param elements
*/
getMultiElementContextPadEntries?: (elements: ElementType[]) => ContextPadEntriesCallback<ElementType> | ContextPadEntries<ElementType>;
}
getMultiElementContextPadEntries?: (
elements: ElementType[]
) => ContextPadEntriesCallback<ElementType> | ContextPadEntries<ElementType>;
}
9 changes: 4 additions & 5 deletions lib/features/outline/OutlineProvider.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Element } from '../../model/Types';
import type { Element } from '../../model/Types';

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.
*
Expand Down Expand Up @@ -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;
}
43 changes: 31 additions & 12 deletions lib/features/popup-menu/PopupMenuProvider.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,9 +19,15 @@ export type PopupMenuEntry = {

export type PopupMenuEntries = Record<string, PopupMenuEntry>;

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;
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -120,5 +137,7 @@ export default interface PopupMenuProvider {
* }
* ```
*/
getEmptyPlaceholder?(): PopupMenuEmptyPlaceholderProvider | PopupMenuEmptyPlaceholder;
}
getEmptyPlaceholder?():
| PopupMenuEmptyPlaceholderProvider
| PopupMenuEmptyPlaceholder;
}
4 changes: 2 additions & 2 deletions lib/features/search-pad/SearchPadProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Element } from '../../model/Types';
import type { Element } from '../../model/Types';

export type Token = {
matched: string;
Expand All @@ -13,4 +13,4 @@ export type SearchResult = {

export default interface SearchPadProvider {
find(pattern: string): SearchResult[];
}
}

0 comments on commit e6559b2

Please sign in to comment.