File tree Expand file tree Collapse file tree 2 files changed +37
-17
lines changed
source/library/components/py-repl Expand file tree Collapse file tree 2 files changed +37
-17
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" ;
2
3
import type { PyReplProperties , PyReplTag } from "./py-repl.types" ;
3
4
4
- const PyRepl : PyReplTag = < T extends object > ( {
5
- autoGenerate = false ,
6
- children,
7
- ...rest
8
- } : PyReplProperties < T > ) : JSX . Element => {
9
- return (
10
- < py-repl { ...rest } auto-generate = { autoGenerate } >
11
- { children }
12
- </ py-repl >
13
- ) ;
14
- } ;
5
+ const PyRepl : PyReplTag = forwardRef (
6
+ < OptionalProperties extends object > (
7
+ {
8
+ autoGenerate = false ,
9
+ children,
10
+ ...rest
11
+ } : PyReplProperties < OptionalProperties > ,
12
+ reference : ForwardedRef < HTMLElement > | undefined ,
13
+ // eslint-disable-next-line max-params
14
+ ) : JSX . Element => {
15
+ return (
16
+ < py-repl ref = { reference } { ...rest } auto-generate = { autoGenerate } >
17
+ { children }
18
+ </ py-repl >
19
+ ) ;
20
+ } ,
21
+ ) as PyReplTag ;
22
+
23
+ PyRepl . displayName = "PyRepl" ;
15
24
16
25
PyRepl . propTypes = {
17
26
children : propTypes . string ,
Original file line number Diff line number Diff line change 1
- import { DetailedHTMLProps , HTMLAttributes , WeakValidationMap } from "react" ;
1
+ import type {
2
+ DetailedHTMLProps ,
3
+ ForwardedRef ,
4
+ HTMLAttributes ,
5
+ WeakValidationMap ,
6
+ } from "react" ;
2
7
import ReactElementProps from "~types/react-element-properties/react-element-properties" ;
3
8
4
9
export type PyReplPropertiesBase = Omit <
@@ -11,11 +16,17 @@ export type PyReplPropertiesBase = Omit<
11
16
children ?: string ;
12
17
} ;
13
18
14
- export type PyReplProperties < T > = T extends infer T
15
- ? T & PyReplPropertiesBase
16
- : PyReplPropertiesBase ;
19
+ export type PyReplProperties < OptionalProperties > =
20
+ OptionalProperties extends infer OptionalProperties
21
+ ? OptionalProperties & PyReplPropertiesBase
22
+ : PyReplPropertiesBase ;
17
23
18
24
export type PyReplTag = {
19
- < T extends object > ( properties : PyReplProperties < T > ) : JSX . Element ;
20
- propTypes : WeakValidationMap < PyReplPropertiesBase > ;
25
+ < OptionalProperties extends object > (
26
+ properties : PyReplProperties < OptionalProperties > ,
27
+ reference ?: ForwardedRef < HTMLElement > ,
28
+ ) : JSX . Element ;
29
+ displayName ?: string ;
30
+ defaultProps ?: Partial < PyReplPropertiesBase > ;
31
+ propTypes ?: WeakValidationMap < PyReplPropertiesBase > ;
21
32
} ;
You can’t perform that action at this time.
0 commit comments