1- import { ContainerModel , EventHandler } from "./model" ;
2- import DashiPlot , { DashiPlotProps } from "./DashiPlot" ;
3- import DashiButton , { DashiButtonProps } from "./DashiButton" ;
4- import DashiBox , { DashiBoxProps } from "./DashiBox" ;
1+ import {
2+ BoxModel ,
3+ ButtonModel ,
4+ ContainerModel ,
5+ EventHandler ,
6+ PlotModel ,
7+ } from "./model" ;
8+ import DashiPlot from "./DashiPlot" ;
9+ import DashiButton from "./DashiButton" ;
10+ import DashiBox from "./DashiBox" ;
511
612export interface DashiContainerProps extends Omit < ContainerModel , "type" > {
713 onEvent : EventHandler ;
@@ -10,31 +16,23 @@ export interface DashiContainerProps extends Omit<ContainerModel, "type"> {
1016function DashiContainer ( { components, onEvent } : DashiContainerProps ) {
1117 return (
1218 < >
13- { components . map ( ( { type : componentType , ...props } , index ) => {
14- const key = props . id || index ;
15- if ( componentType === "plot" ) {
19+ { components . map ( ( { type, ...model } , index ) => {
20+ const key = model . id || index ;
21+ if ( type === "plot" ) {
1622 return (
17- < DashiPlot
18- key = { key }
19- { ...( props as DashiPlotProps ) }
20- onEvent = { onEvent }
21- />
23+ < DashiPlot key = { key } { ...( model as PlotModel ) } onEvent = { onEvent } />
2224 ) ;
23- } else if ( componentType === "button" ) {
25+ } else if ( type === "button" ) {
2426 return (
2527 < DashiButton
2628 key = { key }
27- { ...( props as DashiButtonProps ) }
29+ { ...( model as ButtonModel ) }
2830 onEvent = { onEvent }
2931 />
3032 ) ;
31- } else if ( componentType === "box" ) {
33+ } else if ( type === "box" ) {
3234 return (
33- < DashiBox
34- key = { key }
35- { ...( props as DashiBoxProps ) }
36- onEvent = { onEvent }
37- />
35+ < DashiBox key = { key } { ...( model as BoxModel ) } onEvent = { onEvent } />
3836 ) ;
3937 }
4038 } ) }
0 commit comments