import * as React from 'react'; import { ReactSVGPanZoom, Tool, Value, TOOL_PAN } from 'react-svg-pan-zoom'; import { Container } from './Elements/Container'; import { ContainerModel } from '../../Interfaces/ContainerModel'; import { Selector } from './Elements/Selector'; interface ISVGProps { width: number, height: number, children: ContainerModel | ContainerModel[] | null, selected: ContainerModel | null } interface ISVGState { value: Value, tool: Tool } export class SVG extends React.PureComponent { public state: ISVGState; public svg: React.RefObject; constructor(props: ISVGProps) { super(props); this.state = { value: { viewerWidth: window.innerWidth, viewerHeight: window.innerHeight } as Value, tool: TOOL_PAN }; this.svg = React.createRef(); } render() { const xmlns = ''; const properties = { width: this.props.width, height: this.props.height, xmlns }; let children: React.ReactNode | React.ReactNode[] = []; if (Array.isArray(this.props.children)) { children = this.props.children.map(child => ); } else if (this.props.children !== null) { children = ; } return ( this.setState({ value })} tool={this.state.tool} onChangeTool={tool => this.setState({ tool })} miniatureProps={{ position: 'left', background: '#616264', width: window.innerWidth - 12, height: 120 }} > { children } ); }; }