1- import { Component , ComponentType , NamedExoticComponent } from 'react' ;
1+ import {
2+ Component ,
3+ ComponentType ,
4+ ForwardRefExoticComponent ,
5+ PropsWithoutRef ,
6+ RefAttributes ,
7+ } from 'react' ;
28import { ConnectedComponent } from 'react-redux' ;
39import GoldenLayout from '@deephaven/golden-layout' ;
410import type {
@@ -8,10 +14,33 @@ import type {
814} from '@deephaven/golden-layout' ;
915import PanelManager from './PanelManager' ;
1016
11- export type PanelFunctionComponentType < P > = NamedExoticComponent < P > & {
17+ /**
18+ * Alias for the return type of React.forwardRef()
19+ */
20+ export type ForwardRefComponentType < P , R > = ForwardRefExoticComponent <
21+ PropsWithoutRef < P > & RefAttributes < R >
22+ > ;
23+
24+ /**
25+ * Panel components can provide static props that provide meta data about the
26+ * panel.
27+ */
28+ export interface PanelStaticMetaData {
29+ /**
30+ * Should be set to the same name as the component type.
31+ * @deprecated Use `displayName` instead.
32+ */
1233 COMPONENT ?: string ;
34+
35+ /** Title of the panel. */
1336 TITLE ?: string ;
14- } ;
37+ }
38+
39+ /**
40+ * Panels defined as functional components have to use React.forwardRef.
41+ */
42+ export type PanelFunctionComponentType < P , R > = ForwardRefComponentType < P , R > &
43+ PanelStaticMetaData ;
1544
1645export type WrappedComponentType <
1746 P extends PanelProps ,
@@ -24,8 +53,9 @@ export type PanelComponentType<
2453> = (
2554 | ComponentType < P >
2655 | WrappedComponentType < P , C >
27- | PanelFunctionComponentType < P >
28- ) & { COMPONENT ?: string ; TITLE ?: string } ;
56+ | PanelFunctionComponentType < P , unknown >
57+ ) &
58+ PanelStaticMetaData ;
2959
3060export function isWrappedComponent <
3161 P extends PanelProps ,
0 commit comments