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,30 +16,23 @@ export interface DashiContainerProps extends Omit<ContainerModel, "type"> {
1016function DashiContainer ( { components, onEvent } : DashiContainerProps ) {
1117 return (
1218 < >
13- { components . map ( ( { type : componentType , ...props } , key ) => {
14- if ( componentType === "plot" ) {
19+ { components . map ( ( { type, ...model } , index ) => {
20+ const key = model . id || index ;
21+ if ( type === "plot" ) {
1522 return (
16- < DashiPlot
17- key = { key }
18- { ...( props as DashiPlotProps ) }
19- onEvent = { onEvent }
20- />
23+ < DashiPlot key = { key } { ...( model as PlotModel ) } onEvent = { onEvent } />
2124 ) ;
22- } else if ( componentType === "button" ) {
25+ } else if ( type === "button" ) {
2326 return (
2427 < DashiButton
2528 key = { key }
26- { ...( props as DashiButtonProps ) }
29+ { ...( model as ButtonModel ) }
2730 onEvent = { onEvent }
2831 />
2932 ) ;
30- } else if ( componentType === "box" ) {
33+ } else if ( type === "box" ) {
3134 return (
32- < DashiBox
33- key = { key }
34- { ...( props as DashiBoxProps ) }
35- onEvent = { onEvent }
36- />
35+ < DashiBox key = { key } { ...( model as BoxModel ) } onEvent = { onEvent } />
3736 ) ;
3837 }
3938 } ) }
0 commit comments