Skip to content

Commit

Permalink
Merge pull request #76 from jeff-phillips-18/type-updates
Browse files Browse the repository at this point in the history
fix(componentFactory): Update component factory return type
  • Loading branch information
jeff-phillips-18 authored Jul 6, 2023
2 parents f233856 + a3029ba commit 5c4cad6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/module/src/Visualization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class Visualization extends Stateful implements Controller {
return undefined;
}

getComponent(kind: ModelKind, type: string): ComponentType<{ element: GraphElement }> {
getComponent(kind: ModelKind, type: string): ComponentType<{ element: GraphElement | Graph | Node | Edge }> {
for (const factory of this.componentFactories) {
const component = factory(kind, type);
if (component) {
Expand Down
4 changes: 2 additions & 2 deletions packages/module/src/components/ElementWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import * as React from 'react';
import { observer } from 'mobx-react';
import { computed } from 'mobx';
import ElementContext from '../utils/ElementContext';
import { GraphElement, isGraph, isEdge, isNode, Node } from '../types';
import { Edge, Graph, isGraph, isEdge, isNode, Node } from '../types';
import { ATTR_DATA_ID, ATTR_DATA_KIND, ATTR_DATA_TYPE } from '../const';
import ComputeElementDimensions from './ComputeElementDimensions';
import { useDndManager } from '../behavior/useDndManager';

interface ElementWrapperProps {
element: GraphElement;
element: Graph | Edge | Node;
}

const NodeElementComponent: React.FunctionComponent<{ element: Node }> = observer(({ element }) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/module/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export interface WithState {

export type LayoutFactory = (type: string, graph: Graph) => Layout | undefined;

export type ComponentFactory = (kind: ModelKind, type: string) => ComponentType<{ element: GraphElement }> | undefined;
export type ComponentFactory = (kind: ModelKind, type: string) => ComponentType<{ element: GraphElement | Graph | Edge | Node }> | undefined;

export type ElementFactory = (kind: ModelKind, type: string) => GraphElement | undefined;

Expand All @@ -320,7 +320,7 @@ export interface Controller extends WithState {
getEdgeById(id: string): Edge | undefined;
addElement(element: GraphElement): void;
removeElement(element: GraphElement): void;
getComponent(kind: ModelKind, type: string): ComponentType<{ element: GraphElement }>;
getComponent(kind: ModelKind, type: string): ComponentType<{ element: GraphElement | Graph | Edge | Node }>;
registerLayoutFactory(factory: LayoutFactory): void;
registerComponentFactory(factory: ComponentFactory): void;
registerElementFactory(factory: ElementFactory): void;
Expand Down

0 comments on commit 5c4cad6

Please sign in to comment.