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