@@ -61,14 +61,14 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
6161 } ;
6262 } , [ schema . refreshInterval , onRefresh , handleRefresh ] ) ;
6363
64- const renderWidget = ( widget : DashboardWidgetSchema ) => {
64+ const renderWidget = ( widget : DashboardWidgetSchema , index : number ) => {
6565 const getComponentSchema = ( ) => {
6666 if ( widget . component ) return widget . component ;
6767
6868 // Handle Shorthand Registry Mappings
69- const widgetType = ( widget as any ) . type ;
69+ const widgetType = widget . type ;
70+ const options = ( widget . options || { } ) as Record < string , any > ;
7071 if ( widgetType === 'bar' || widgetType === 'line' || widgetType === 'area' || widgetType === 'pie' || widgetType === 'donut' ) {
71- const options = ( widget as any ) . options || { } ;
7272 // Support data at widget level or nested inside options
7373 const widgetData = ( widget as any ) . data || options . data ;
7474 const dataItems = Array . isArray ( widgetData ) ? widgetData : widgetData ?. items || [ ] ;
@@ -87,7 +87,6 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
8787 }
8888
8989 if ( widgetType === 'table' ) {
90- const options = ( widget as any ) . options || { } ;
9190 // Support data at widget level or nested inside options
9291 const widgetData = ( widget as any ) . data || options . data ;
9392 return {
@@ -102,17 +101,18 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
102101
103102 return {
104103 ...widget ,
105- ...( ( widget as any ) . options || { } )
104+ ...options
106105 } ;
107106 } ;
108107
109108 const componentSchema = getComponentSchema ( ) ;
110- const isSelfContained = ( widget as any ) . type === 'metric' ;
109+ const isSelfContained = widget . type === 'metric' ;
110+ const widgetKey = widget . id || widget . title || `widget-${ index } ` ;
111111
112112 if ( isSelfContained ) {
113113 return (
114114 < div
115- key = { widget . id || widget . title }
115+ key = { widgetKey }
116116 className = { cn ( "h-full w-full" , isMobile && "w-[85vw] shrink-0 snap-center" ) }
117117 style = { ! isMobile && widget . layout ? {
118118 gridColumn : `span ${ widget . layout . w } ` ,
@@ -126,7 +126,7 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
126126
127127 return (
128128 < Card
129- key = { widget . id || widget . title }
129+ key = { widgetKey }
130130 className = { cn (
131131 "overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md" ,
132132 "bg-card/50 backdrop-blur-sm" ,
@@ -176,7 +176,7 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
176176 className = "flex overflow-x-auto snap-x snap-mandatory gap-3 pb-4 [-webkit-overflow-scrolling:touch]"
177177 style = { { scrollPaddingLeft : '0.75rem' } }
178178 >
179- { schema . widgets ?. map ( ( widget : DashboardWidgetSchema ) => renderWidget ( widget ) ) }
179+ { schema . widgets ?. map ( ( widget : DashboardWidgetSchema , index : number ) => renderWidget ( widget , index ) ) }
180180 </ div >
181181 </ div >
182182 ) ;
@@ -197,7 +197,7 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
197197 { ...props }
198198 >
199199 { refreshButton }
200- { schema . widgets ?. map ( ( widget : DashboardWidgetSchema ) => renderWidget ( widget ) ) }
200+ { schema . widgets ?. map ( ( widget : DashboardWidgetSchema , index : number ) => renderWidget ( widget , index ) ) }
201201 </ div >
202202 ) ;
203203 }
0 commit comments