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 11import propTypes from "prop-types" ;
2+ import { forwardRef , type ForwardedRef } from "react" ;
23import type { PyReplProperties , PyReplTag } from "./py-repl.types" ;
34
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" ;
1524
1625PyRepl . propTypes = {
1726 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" ;
27import ReactElementProps from "~types/react-element-properties/react-element-properties" ;
38
49export type PyReplPropertiesBase = Omit <
@@ -11,11 +16,17 @@ export type PyReplPropertiesBase = Omit<
1116 children ?: string ;
1217} ;
1318
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 ;
1723
1824export 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 > ;
2132} ;
You can’t perform that action at this time.
0 commit comments