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 11import 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" ;
34
45/**
56 * @param root0
67 * @param root0.children
78 * @deprecated
89 */
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" ;
1525
1626PyTitle . propTypes = {
1727 children : propTypes . string . isRequired ,
Original file line number Diff line number Diff line change 11import type {
22 DetailedHTMLProps ,
3+ ForwardedRef ,
34 HTMLAttributes ,
45 WeakValidationMap ,
56} from "react" ;
@@ -14,13 +15,20 @@ export type PyTitlePropertiesBase = Omit<
1415 children : string ;
1516} ;
1617
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 ;
2022
21- export type PyTitleProps < T > = PyTitleProperties < T > ;
23+ export type PyTitleProps < OptionalProperties > =
24+ PyTitleProperties < OptionalProperties > ;
2225
2326export 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 > ;
2634} ;
You can’t perform that action at this time.
0 commit comments