Skip to content

Commit

Permalink
Merge pull request #42 from caddijp/feature/types
Browse files Browse the repository at this point in the history
fix(@types): fixed custom data diagrams
  • Loading branch information
antonioru committed Nov 6, 2020
2 parents 43c5cf8 + dc0931e commit 4c1cf03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions @types/Diagram.ts
@@ -1,11 +1,11 @@
import { FunctionComponent, MemoExoticComponent } from 'react';
import { memo } from 'react';
import { DiagramSchema } from './DiagramSchema';

export type DiagramProps<P = unknown> = {
export type DiagramProps<P> = {
schema?: DiagramSchema<P>;
onChange?: (schema: DiagramSchema<P>) => unknown;
};

declare const Diagram: MemoExoticComponent<FunctionComponent<DiagramProps>>;
declare const Diagram: <P = unknown>(props: DiagramProps<P>) => JSX.Element;

export default Diagram;
export default memo(Diagram);
9 changes: 4 additions & 5 deletions index-tests.tsx
Expand Up @@ -25,18 +25,17 @@ export const UncontrolledDiagram1 = () => {
);
};

type CustomData = {
onDoubleClick: () => void;
};

export const UncontrolledDiagram2 = () => {
const [schema, { onChange, addNode, removeNode }] = useSchema<CustomData>({
const [schema, { onChange, addNode, removeNode }] = useSchema({
nodes: [
{
id: 'node-1',
content: 'Node 1',
coordinates: [150, 60],
outputs: [{ id: 'port-1', alignment: 'right' }],
data: {
onDoubleClick: () => console.warn('hello'),
}
},
],
});
Expand Down
8 changes: 4 additions & 4 deletions index.d.ts
@@ -1,14 +1,14 @@
import Diagram from './@types/Diagram';
import useSchema from './@types/useSchema';
import createSchema from './@types/createSchema';
import Diagram from "./@types/Diagram";
import useSchema from "./@types/useSchema";
import createSchema from "./@types/createSchema";
import {
validateSchema,
validatePort,
validateLink,
validateNodes,
validateNode,
validateLinks,
} from './@types/validators';
} from "./@types/validators";

export {
Diagram,
Expand Down

0 comments on commit 4c1cf03

Please sign in to comment.