File tree Expand file tree Collapse file tree 2 files changed +38
-15
lines changed
source/library/components/py-register-widget Expand file tree Collapse file tree 2 files changed +38
-15
lines changed Original file line number Diff line number Diff line change 11import propTypes from "prop-types" ;
2+ import { forwardRef , type ForwardedRef } from "react" ;
3+
24import type {
35 PyRegisterWidgetProperties ,
46 PyRegisterWidgetTag ,
@@ -11,16 +13,30 @@ import type {
1113 * @param root0.pythonClass
1214 * @deprecated
1315 */
14- const PyRegisterWidget : PyRegisterWidgetTag = < T extends object > ( {
15- name,
16- src,
17- pythonClass,
18- ...rest
19- } : PyRegisterWidgetProperties < T > ) : JSX . Element => {
20- return (
21- < py-register-widget { ...rest } src = { src } name = { name } klass = { pythonClass } />
22- ) ;
23- } ;
16+ const PyRegisterWidget : PyRegisterWidgetTag = forwardRef (
17+ < OptionalProperties extends object > (
18+ {
19+ name,
20+ src,
21+ pythonClass,
22+ ...rest
23+ } : PyRegisterWidgetProperties < OptionalProperties > ,
24+ reference : ForwardedRef < HTMLElement > | undefined ,
25+ // eslint-disable-next-line max-params
26+ ) : JSX . Element => {
27+ return (
28+ < py-register-widget
29+ ref = { reference }
30+ { ...rest }
31+ src = { src }
32+ name = { name }
33+ klass = { pythonClass }
34+ />
35+ ) ;
36+ } ,
37+ ) as PyRegisterWidgetTag ;
38+
39+ PyRegisterWidget . displayName = "PyRegisterWidget" ;
2440
2541PyRegisterWidget . propTypes = {
2642 name : propTypes . string ,
Original file line number Diff line number Diff line change 11import type {
22 DetailedHTMLProps ,
3+ ForwardedRef ,
34 HTMLAttributes ,
45 WeakValidationMap ,
56} from "react" ;
@@ -16,11 +17,17 @@ export type PyRegisterWidgetPropertiesBase = Omit<
1617 pythonClass ?: string ;
1718} ;
1819
19- export type PyRegisterWidgetProperties < T > = T extends infer T
20- ? T & PyRegisterWidgetPropertiesBase
21- : PyRegisterWidgetPropertiesBase ;
20+ export type PyRegisterWidgetProperties < OptionalProperties > =
21+ OptionalProperties extends infer OptionalProperties
22+ ? OptionalProperties & PyRegisterWidgetPropertiesBase
23+ : PyRegisterWidgetPropertiesBase ;
2224
2325export type PyRegisterWidgetTag = {
24- < T extends object > ( properties : PyRegisterWidgetProperties < T > ) : JSX . Element ;
25- propTypes : WeakValidationMap < PyRegisterWidgetPropertiesBase > ;
26+ < OptionalProperties extends object > (
27+ properties : PyRegisterWidgetProperties < OptionalProperties > ,
28+ reference ?: ForwardedRef < HTMLElement > ,
29+ ) : JSX . Element ;
30+ displayName ?: string ;
31+ defaultProps ?: Partial < PyRegisterWidgetPropertiesBase > ;
32+ propTypes ?: WeakValidationMap < PyRegisterWidgetPropertiesBase > ;
2633} ;
You can’t perform that action at this time.
0 commit comments