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 1
1
import propTypes from "prop-types" ;
2
+ import { forwardRef , type ForwardedRef } from "react" ;
3
+
2
4
import type {
3
5
PyRegisterWidgetProperties ,
4
6
PyRegisterWidgetTag ,
@@ -11,16 +13,30 @@ import type {
11
13
* @param root0.pythonClass
12
14
* @deprecated
13
15
*/
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" ;
24
40
25
41
PyRegisterWidget . propTypes = {
26
42
name : propTypes . string ,
Original file line number Diff line number Diff line change 1
1
import type {
2
2
DetailedHTMLProps ,
3
+ ForwardedRef ,
3
4
HTMLAttributes ,
4
5
WeakValidationMap ,
5
6
} from "react" ;
@@ -16,11 +17,17 @@ export type PyRegisterWidgetPropertiesBase = Omit<
16
17
pythonClass ?: string ;
17
18
} ;
18
19
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 ;
22
24
23
25
export 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 > ;
26
33
} ;
You can’t perform that action at this time.
0 commit comments