@@ -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,22 @@ const TOOLBAR_HEIGHT = 48; // Pixels
114115/**
115116 * PanelDisplay displays the panels in a specific location.
116117 */
117- export function PanelDisplay < L extends string > (
118+ export function PanelDisplay (
118119 props : {
119- location : L ;
120- coordinator : PanelsCoordinator < L > ;
120+ location : ReflexedPanelLocation ;
121+ coordinator : PanelsCoordinator ;
121122 datastore : DataStore ;
122123 services : Services ;
123- } & {
124124 dimensions ?: { width : number ; height : number } ;
125- } ,
125+ }
126126) {
127127 const classes = useStyles ( ) ;
128128 const coordinator = props . coordinator ;
129129
130130 const currentTabName = coordinator . getActivePanel ( props . location ) ?. id || "" ;
131131
132132 const handleChangeTab = useCallback (
133- ( _event : React . ChangeEvent < object > , selectedPanelId : string ) => {
133+ ( _event : object , selectedPanelId : string ) => {
134134 coordinator . setActivePanel ( selectedPanelId , props . location ) ;
135135 } ,
136136 [ coordinator , props . location ] ,
@@ -159,14 +159,13 @@ export function PanelDisplay<L extends string>(
159159 aria-label = "Tabs"
160160 variant = "fullWidth"
161161 >
162- { panels . map ( ( panel : Panel < L > ) => {
162+ { panels . map ( ( { id , Summary } : Panel ) => {
163163 // NOTE: Using this as a tag here is important for React's state system. Otherwise,
164164 // it'll run hooks outside of the normal flow, which breaks things.
165- const Summary = panel . summary ;
166165 return (
167166 < Tab
168- key = { `tab- ${ panel . id } ` }
169- value = { panel . id }
167+ key = { id }
168+ value = { id }
170169 label = { < Summary { ...props } /> }
171170 />
172171 ) ;
@@ -175,7 +174,7 @@ export function PanelDisplay<L extends string>(
175174
176175 < span >
177176 { currentTabName &&
178- coordinator . listLocations ( ) . map ( ( locData : LocationData < L > ) => {
177+ coordinator . listLocations ( ) . map ( ( locData : LocationData ) => {
179178 if ( locData . location === props . location ) {
180179 return < div key = { locData . location } /> ;
181180 }
@@ -215,27 +214,26 @@ export function PanelDisplay<L extends string>(
215214 </ Toolbar >
216215 </ AppBar >
217216
218- { panels . map ( ( panel : Panel < L > ) => {
217+ { panels . map ( ( { id , Content } : Panel ) => {
219218 // NOTE: Using this as a tag here is important for React's state system. Otherwise,
220219 // it'll run hooks outside of the normal flow, which breaks things.
221- const Content = panel . content ;
222220 const height =
223221 ( props . dimensions ?. height ?? 0 >= 48 )
224222 ? ( props . dimensions ?. height ?? 0 ) - 48
225223 : "auto" ;
226224
227225 return (
228226 < TabPanel
229- key = { `panel- ${ panel . id } ` }
230- index = { panel . id }
227+ key = { id }
228+ index = { id }
231229 value = { currentTabName }
232230 style = { {
233231 overflow : "auto" ,
234232 height : height || "auto" ,
235233 position : "relative" ,
236234 } }
237235 >
238- { currentTabName === panel . id && < Content { ...contentProps } /> }
236+ { currentTabName === id && < Content { ...contentProps } /> }
239237 </ TabPanel >
240238 ) ;
241239 } ) }
0 commit comments