11import propTypes from "prop-types" ;
2- import { useMemo , type WeakValidationMap } from "react" ;
2+ import { ForwardedRef , WeakValidationMap , forwardRef , useMemo } from "react" ;
3+
34import type {
45 PyEnvChildrenAsObject ,
56 PyEnvProperties ,
@@ -12,41 +13,50 @@ import type {
1213 * @param root0.children
1314 * @deprecated
1415 */
15- const PyEnv : PyEnvTag = < T extends object > ( {
16- children,
17- ...rest
18- } : PyEnvProperties < T > ) : JSX . Element => {
19- const fixedChildren : string = useMemo ( ( ) : string => {
20- const { paths, items } : PyEnvChildrenAsObject = Object ( children ) ;
21- if ( paths || items ) {
22- const fixedItems : string =
23- [ ...( items || [ ] ) ]
24- ?. map ( ( element : string ) : string => {
25- return `- ${ element } ` ;
26- } )
27- . join ( "\n" ) || "" ;
28- const fixedPaths : string =
29- [ ...( paths || [ ] ) ]
30- ?. map ( ( element : string ) : string => {
31- return `\t- ${ element } ` ;
32- } )
33- . join ( "\n" ) || "" ;
34- const fixedPathsWithCondition : string = fixedPaths
35- ? `\n- paths:\n${ fixedPaths } `
36- : "" ;
37- return `${ fixedItems } ${ fixedPathsWithCondition } ` ;
38- } else {
39- return Array . isArray ( children )
40- ? children
41- . map ( ( element : string ) : string => {
16+ const PyEnv : PyEnvTag = forwardRef (
17+ < OptionalProperties extends object > (
18+ { children, ...rest } : PyEnvProperties < OptionalProperties > ,
19+ reference : ForwardedRef < HTMLElement > | undefined ,
20+ // eslint-disable-next-line max-params
21+ ) : JSX . Element => {
22+ const fixedChildren : string = useMemo ( ( ) : string => {
23+ const { paths, items } : PyEnvChildrenAsObject = Object ( children ) ;
24+ if ( paths || items ) {
25+ const fixedItems : string =
26+ [ ...( items || [ ] ) ]
27+ ?. map ( ( element : string ) : string => {
4228 return `- ${ element } ` ;
4329 } )
44- . join ( "\n" )
45- : ( children as string ) ;
46- }
47- } , [ children ] ) ;
48- return < py-env { ...rest } > { fixedChildren } </ py-env > ;
49- } ;
30+ . join ( "\n" ) || "" ;
31+ const fixedPaths : string =
32+ [ ...( paths || [ ] ) ]
33+ ?. map ( ( element : string ) : string => {
34+ return `\t- ${ element } ` ;
35+ } )
36+ . join ( "\n" ) || "" ;
37+ const fixedPathsWithCondition : string = fixedPaths
38+ ? `\n- paths:\n${ fixedPaths } `
39+ : "" ;
40+ return `${ fixedItems } ${ fixedPathsWithCondition } ` ;
41+ } else {
42+ return Array . isArray ( children )
43+ ? children
44+ . map ( ( element : string ) : string => {
45+ return `- ${ element } ` ;
46+ } )
47+ . join ( "\n" )
48+ : ( children as string ) ;
49+ }
50+ } , [ children ] ) ;
51+ return (
52+ < py-env ref = { reference } { ...rest } >
53+ { fixedChildren }
54+ </ py-env >
55+ ) ;
56+ } ,
57+ ) as PyEnvTag ;
58+
59+ PyEnv . displayName = "PyEnv" ;
5060
5161PyEnv . propTypes = {
5262 children : propTypes . oneOfType ( [
0 commit comments