Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@types): fixed custom data diagrams #42

Merged
merged 1 commit into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions @types/Diagram.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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