11import type { CSSProperties , ReactElement } from "react" ;
22import CircularProgress from "@mui/material/CircularProgress" ;
3-
4- import {
5- type ComponentChangeHandler ,
6- type ContributionState ,
7- Component ,
8- } from "@/lib" ;
3+ import { Component } from "@/lib" ;
4+ import type { ComponentState , ComponentChangeHandler } from "@/lib" ;
95import type { PanelState } from "@/demo/types" ;
106
117const panelContainerStyle : CSSProperties = {
@@ -32,39 +28,43 @@ const panelContentStyle: CSSProperties = {
3228 padding : 2 ,
3329} ;
3430
35- interface PanelProps extends ContributionState < PanelState > {
31+ interface PanelProps extends PanelState {
32+ componentProps ?: ComponentState ;
33+ componentStatus ?: string ;
34+ componentError ?: { message : string } ;
3635 onChange : ComponentChangeHandler ;
3736}
3837
3938function Panel ( {
40- name,
41- state,
42- component,
43- componentResult,
39+ title,
40+ visible,
41+ componentProps,
42+ componentStatus,
43+ componentError,
4444 onChange,
4545} : PanelProps ) {
46- if ( ! state . visible ) {
46+ if ( ! visible ) {
4747 return null ;
4848 }
4949 let panelElement : ReactElement | null = null ;
50- if ( component ) {
51- panelElement = < Component { ...component } onChange = { onChange } /> ;
52- } else if ( componentResult . error ) {
50+ if ( componentProps ) {
51+ panelElement = < Component { ...componentProps } onChange = { onChange } /> ;
52+ } else if ( componentError ) {
5353 panelElement = (
5454 < span >
55- Error loading { name } : { componentResult . error . message }
55+ Error loading panel { title } : { componentError . message }
5656 </ span >
5757 ) ;
58- } else if ( componentResult . status === "pending" ) {
58+ } else if ( componentStatus === "pending" ) {
5959 panelElement = (
6060 < span >
61- < CircularProgress size = { 30 } color = "secondary" /> Loading { name } ...
61+ < CircularProgress size = { 30 } color = "secondary" /> Loading { title } ...
6262 </ span >
6363 ) ;
6464 }
6565 return (
6666 < div style = { panelContainerStyle } >
67- < div style = { panelHeaderStyle } > { state . title } </ div >
67+ < div style = { panelHeaderStyle } > { title } </ div >
6868 < div style = { panelContentStyle } > { panelElement } </ div >
6969 </ div >
7070 ) ;
0 commit comments