import React from 'react'; import type { IView, ViewData } from '../../typing'; import { ResizeHandleHorizontal, ResizeHandleVertical } from '../Resize'; import './index.less'; export type ComponentProps = { view: IView; rootView: IView; activeViewKey: string; }; interface Props extends ComponentProps { renderComponent: (props: ComponentProps) => JSX.Element; } const SplitView = (props: Props) => { const { rootView, view = rootView, activeViewKey, renderComponent } = props; const { v: vertical = [], h: horizontal = [] } = view; if (vertical.length === 0 && horizontal.length === 0) { return renderComponent({ view, rootView, activeViewKey }); } let defaultChildrentyle = {}; const children: React.ReactNode[] = []; if (vertical.length !== 0) { defaultChildrentyle = { width: 100 / vertical.length + '%' }; vertical.forEach((g, index) => { if (index !== 0) { children.push( ); } const child = ( ); const cls = `view-view-horizontal-child ${index === 0 ? 'first' : ''}`; if (child) { children.push(
{child}
); } }); } if (horizontal.length !== 0) { defaultChildrentyle = { height: 100 / horizontal.length + '%' }; horizontal.forEach((g, index) => { if (index !== 0) { children.push( ); } const child = ( ); const cls = `view-view-vertical-child ${index === 0 ? 'first' : ''}`; if (child) { children.push(
{child}
); } }); } if (children.length === 0) { return
Empty
; } const cls = `${horizontal.length > 0 ? 'view-view-vertical' : ''} ${ vertical.length > 0 ? 'view-view-horizontal' : '' }`; return
{children}
; }; export default SplitView;