@@ -13,15 +13,16 @@ import { DataStore } from "../../../services/datastore";
1313import { Services } from "../../../services/services" ;
1414import { Panel , useSummaryStyles } from "./common" ;
1515import { LocationData , PanelsCoordinator } from "./coordinator" ;
16+ import { ReflexedPanelLocation } from "../types" ;
1617
1718export const SUMMARY_BAR_HEIGHT = 48 ; // Pixels
1819
1920/**
2021 * PanelSummaryBar is the summary bar displayed when a panel display is closed.
2122 */
22- export function PanelSummaryBar < L extends string > ( props : {
23- location : L ;
24- coordinator : PanelsCoordinator < L > ;
23+ export function PanelSummaryBar ( props : {
24+ location : ReflexedPanelLocation ;
25+ coordinator : PanelsCoordinator ;
2526 services : Services ;
2627 disabled ?: boolean | undefined ;
2728 overrideSummaryDisplay ?: ReactNode ;
@@ -45,10 +46,10 @@ export function PanelSummaryBar<L extends string>(props: {
4546 >
4647 { props . overrideSummaryDisplay !== undefined &&
4748 props . overrideSummaryDisplay }
48- { panels . map ( ( panel : Panel < L > ) => {
49+ { panels . map ( ( panel : Panel ) => {
4950 // NOTE: Using this as a tag here is important for React's state system. Otherwise,
5051 // it'll run hooks outside of the normal flow, which breaks things.
51- const Summary = panel . summary ;
52+ const Summary = panel . Summary ;
5253 return (
5354 < Button
5455 key = { panel . id }
@@ -114,23 +115,20 @@ const TOOLBAR_HEIGHT = 48; // Pixels
114115/**
115116 * PanelDisplay displays the panels in a specific location.
116117 */
117- export function PanelDisplay < L extends string > (
118- props : {
119- location : L ;
120- coordinator : PanelsCoordinator < L > ;
121- datastore : DataStore ;
122- services : Services ;
123- } & {
124- dimensions ?: { width : number ; height : number } ;
125- } ,
126- ) {
118+ export function PanelDisplay ( props : {
119+ location : ReflexedPanelLocation ;
120+ coordinator : PanelsCoordinator ;
121+ datastore : DataStore ;
122+ services : Services ;
123+ dimensions ?: { width : number ; height : number } ;
124+ } ) {
127125 const classes = useStyles ( ) ;
128126 const coordinator = props . coordinator ;
129127
130128 const currentTabName = coordinator . getActivePanel ( props . location ) ?. id || "" ;
131129
132130 const handleChangeTab = useCallback (
133- ( _event : React . ChangeEvent < object > , selectedPanelId : string ) => {
131+ ( _event : object , selectedPanelId : string ) => {
134132 coordinator . setActivePanel ( selectedPanelId , props . location ) ;
135133 } ,
136134 [ coordinator , props . location ] ,
@@ -159,23 +157,16 @@ export function PanelDisplay<L extends string>(
159157 aria-label = "Tabs"
160158 variant = "fullWidth"
161159 >
162- { panels . map ( ( panel : Panel < L > ) => {
160+ { panels . map ( ( { id , Summary } : Panel ) => {
163161 // NOTE: Using this as a tag here is important for React's state system. Otherwise,
164162 // it'll run hooks outside of the normal flow, which breaks things.
165- const Summary = panel . summary ;
166- return (
167- < Tab
168- key = { `tab-${ panel . id } ` }
169- value = { panel . id }
170- label = { < Summary { ...props } /> }
171- />
172- ) ;
163+ return < Tab key = { id } value = { id } label = { < Summary { ...props } /> } /> ;
173164 } ) }
174165 </ Tabs >
175166
176167 < span >
177168 { currentTabName &&
178- coordinator . listLocations ( ) . map ( ( locData : LocationData < L > ) => {
169+ coordinator . listLocations ( ) . map ( ( locData : LocationData ) => {
179170 if ( locData . location === props . location ) {
180171 return < div key = { locData . location } /> ;
181172 }
@@ -215,27 +206,26 @@ export function PanelDisplay<L extends string>(
215206 </ Toolbar >
216207 </ AppBar >
217208
218- { panels . map ( ( panel : Panel < L > ) => {
209+ { panels . map ( ( { id , Content } : Panel ) => {
219210 // NOTE: Using this as a tag here is important for React's state system. Otherwise,
220211 // it'll run hooks outside of the normal flow, which breaks things.
221- const Content = panel . content ;
222212 const height =
223213 ( props . dimensions ?. height ?? 0 >= 48 )
224214 ? ( props . dimensions ?. height ?? 0 ) - 48
225215 : "auto" ;
226216
227217 return (
228218 < TabPanel
229- key = { `panel- ${ panel . id } ` }
230- index = { panel . id }
219+ key = { id }
220+ index = { id }
231221 value = { currentTabName }
232222 style = { {
233223 overflow : "auto" ,
234224 height : height || "auto" ,
235225 position : "relative" ,
236226 } }
237227 >
238- { currentTabName === panel . id && < Content { ...contentProps } /> }
228+ { currentTabName === id && < Content { ...contentProps } /> }
239229 </ TabPanel >
240230 ) ;
241231 } ) }
0 commit comments