Skip to content

Commit 56dd44d

Browse files
added forwardRef to py-splashscreen
1 parent 92f64f6 commit 56dd44d

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

source/library/components/py-splashscreen/py-splashscreen.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import propTypes from "prop-types";
2+
import { forwardRef, type ForwardedRef } from "react";
23
import type {
34
PySplashscreenProperties,
45
PySplashscreenTag,
56
} from "./py-splashscreen.types";
67

7-
const PySplashscreen: PySplashscreenTag = <T extends object>({
8-
...rest
9-
}: PySplashscreenProperties<T>): JSX.Element => {
10-
return <py-splashscreen {...rest} />;
11-
};
8+
const PySplashscreen: PySplashscreenTag = forwardRef(
9+
<OptionalProperties extends object>(
10+
properties: PySplashscreenProperties<OptionalProperties>,
11+
reference: ForwardedRef<HTMLElement> | undefined,
12+
// eslint-disable-next-line max-params
13+
): JSX.Element => {
14+
return <py-splashscreen ref={reference} {...properties} />;
15+
},
16+
) as PySplashscreenTag;
17+
18+
PySplashscreen.displayName = "PySplashscreen";
1219

1320
PySplashscreen.propTypes = {
1421
enabled: propTypes.bool,

source/library/components/py-splashscreen/py-splashscreen.types.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ export type PySplashscreenPropertiesBase = Omit<
1515
autoclose?: boolean;
1616
};
1717

18-
export type PySplashscreenProperties<T> = T extends infer T
19-
? T & PySplashscreenPropertiesBase
20-
: PySplashscreenPropertiesBase;
18+
export type PySplashscreenProperties<OptionalProperties> =
19+
OptionalProperties extends infer OptionalProperties
20+
? OptionalProperties & PySplashscreenPropertiesBase
21+
: PySplashscreenPropertiesBase;
2122

22-
export type PySplashscreenProps<T> = PySplashscreenProperties<T>;
23+
export type PySplashscreenProps<OptionalProperties> =
24+
PySplashscreenProperties<OptionalProperties>;
2325

2426
export type PySplashscreenTag = {
25-
<T extends object>(properties: PySplashscreenProperties<T>): JSX.Element;
26-
propTypes: WeakValidationMap<PySplashscreenPropertiesBase>;
27+
<OptionalProperties extends object>(
28+
properties: PySplashscreenProperties<OptionalProperties>,
29+
): JSX.Element;
30+
displayName?: string;
31+
defaultProps?: Partial<PySplashscreenPropertiesBase>;
32+
propTypes?: WeakValidationMap<PySplashscreenPropertiesBase>;
2733
};

source/library/components/py-terminal/py-terminal.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import propTypes from "prop-types";
2-
import { forwardRef } from "react";
2+
import { ForwardedRef, forwardRef } from "react";
3+
34
import type { PyTerminalProperties, PyTerminalTag } from "./py-terminal.types";
45

56
const PyTerminal: PyTerminalTag = forwardRef(
67
<OptionalProperties extends object>(
78
properties: PyTerminalProperties<OptionalProperties>,
9+
reference: ForwardedRef<HTMLElement> | undefined,
10+
// eslint-disable-next-line max-params
811
): JSX.Element => {
9-
return <py-terminal {...properties} />;
12+
return <py-terminal ref={reference} {...properties} />;
1013
},
1114
) as PyTerminalTag;
1215

0 commit comments

Comments
 (0)