Develop (#35)
* refactor(ts): add ReactFlowProps * Refactor/grid.tsx (#24) * chore(deps-dev): bump start-server-and-test from 1.10.4 to 1.10.5 Bumps [start-server-and-test](https://github.com/bahmutov/start-server-and-test) from 1.10.4 to 1.10.5. - [Release notes](https://github.com/bahmutov/start-server-and-test/releases) - [Commits](https://github.com/bahmutov/start-server-and-test/compare/v1.10.4...v1.10.5) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps-dev): bump typescript from 3.6.3 to 3.6.4 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.6.3 to 3.6.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v3.6.3...v3.6.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * refactor: grid.js -> grid.tsx * refactor(bg): remove unused renderer * refactor(connectionline): use ts * refactor(ts): edges * chore(build): update * Refactor/typescript (WIP) (#25) * refactor(store): use ts * refactor(edgewrapper): use ts * fix(handle): provide onConnect default func * refactor(nodeselection): use ts * refactor(userselction): use ts * refactor(plugins): use ts * refactor(hooks): use ts * refactor(nodes): use ts * refactor(edgerenderer): use ts * refactor(graphview): use ts * refactor(utils): rename js to ts * refactor(app): fix ts errors * fix(ts): errors * fix(app): ts errors * refactor(app): ts erros * refactor(app): ts errors * fix(utils): removeElements * feat(example): add empty renderer closes #34 * fix(connect): dont drag node on connect * chore(build): update
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
import { CSSProperties, SVGAttributes } from 'react';
|
||||
|
||||
export type ElementId = string;
|
||||
|
||||
export type Elements = Array<Node | Edge>;
|
||||
|
||||
export type Transform = [number, number, number];
|
||||
|
||||
export type Position = 'left' | 'top' | 'right' | 'bottom';
|
||||
|
||||
export type XYPosition = {
|
||||
x: number,
|
||||
y: number
|
||||
};
|
||||
|
||||
export enum GridType {
|
||||
Lines = 'lines',
|
||||
Dots = 'dots',
|
||||
};
|
||||
|
||||
export type HandleType = 'source' | 'target';
|
||||
|
||||
export type NodeTypesType = { [key: string]: React.ReactNode };
|
||||
|
||||
export type EdgeTypesType = NodeTypesType;
|
||||
|
||||
export interface Dimensions {
|
||||
width: number,
|
||||
height: number
|
||||
}
|
||||
|
||||
export interface Rect extends Dimensions {
|
||||
x: number,
|
||||
y: number
|
||||
};
|
||||
|
||||
export interface SelectionRect extends Rect {
|
||||
startX: number;
|
||||
startY: number;
|
||||
draw: boolean
|
||||
};
|
||||
|
||||
export interface Node {
|
||||
id: ElementId,
|
||||
position?: XYPosition,
|
||||
type?: string,
|
||||
__rg?: any,
|
||||
data?: any,
|
||||
style?: CSSProperties
|
||||
};
|
||||
|
||||
export interface Edge {
|
||||
id: ElementId,
|
||||
type?: string,
|
||||
source: ElementId,
|
||||
target: ElementId,
|
||||
style?: SVGAttributes<{}>
|
||||
animated?: boolean
|
||||
};
|
||||
|
||||
export interface EdgeProps {
|
||||
sourceX: number,
|
||||
sourceY: number,
|
||||
targetX: number,
|
||||
targetY: number,
|
||||
style?: SVGAttributes<{}>
|
||||
};
|
||||
|
||||
export interface EdgeBezierProps extends EdgeProps{
|
||||
sourcePosition: Position,
|
||||
targetPosition: Position
|
||||
};
|
||||
|
||||
export interface NodeProps {
|
||||
id: ElementId,
|
||||
type: string,
|
||||
data: any;
|
||||
selected: boolean;
|
||||
style?: CSSProperties;
|
||||
};
|
||||
|
||||
export interface NodeComponentProps {
|
||||
id: ElementId,
|
||||
type: string;
|
||||
data: any;
|
||||
selected?: boolean;
|
||||
transform?: Transform;
|
||||
xPos?: number;
|
||||
yPos?: number;
|
||||
onClick?: () => any;
|
||||
onNodeDragStop?: () => any;
|
||||
style?: CSSProperties;
|
||||
};
|
||||
|
||||
export type FitViewParams = {
|
||||
padding: number
|
||||
};
|
||||
export type FitViewFunc = (fitViewOptions: FitViewParams) => void;
|
||||
|
||||
type OnLoadParams = {
|
||||
zoomIn: () => void;
|
||||
zoomOut: () => void;
|
||||
fitView: FitViewFunc
|
||||
};
|
||||
|
||||
export type OnLoadFunc = (params: OnLoadParams) => void;
|
||||
|
||||
export type OnConnectParams = {
|
||||
source: ElementId;
|
||||
target: ElementId;
|
||||
};
|
||||
|
||||
export type OnConnectFunc = (params: OnConnectParams) => void;
|
||||
|
||||
export type Connection = {
|
||||
source: ElementId;
|
||||
target: ElementId;
|
||||
};
|
||||
|
||||
export interface HandleElement {
|
||||
id?: ElementId;
|
||||
position: Position;
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
export interface EdgeWrapperProps {
|
||||
id: ElementId,
|
||||
source: ElementId,
|
||||
target: ElementId,
|
||||
type: any,
|
||||
onClick?: (edge: Edge) => void
|
||||
animated?: boolean,
|
||||
selected?: boolean,
|
||||
};
|
||||
Reference in New Issue
Block a user