Skip to content

Commit af80770

Browse files
committed
Merge branch 'refs/heads/main' into forman-multiple_panels
2 parents eab60ad + 08e4e08 commit af80770

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

dashi/src/lib/DashiContainer.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
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

612
export interface DashiContainerProps extends Omit<ContainerModel, "type"> {
713
onEvent: EventHandler;
@@ -10,30 +16,23 @@ export interface DashiContainerProps extends Omit<ContainerModel, "type"> {
1016
function 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

Comments
 (0)