@isograph/react 0.0.0-main-9977b173 → 0.0.0-main-adb0955b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,12 +2,14 @@ import * as React from 'react';
|
|
|
2
2
|
import { ExtractReadFromStore, IsographEntrypoint } from '../core/entrypoint';
|
|
3
3
|
import { FragmentReference } from '../core/FragmentReference';
|
|
4
4
|
import { NetworkRequestReaderOptions } from '../core/read';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type IsExactlyIntrinsicAttributes<T> = T extends JSX.IntrinsicAttributes ? JSX.IntrinsicAttributes extends T ? true : false : false;
|
|
6
|
+
export declare function FragmentReader<TProps extends Record<any, any>, TEntrypoint extends IsographEntrypoint<any, React.FC<TProps>>>(props: IsExactlyIntrinsicAttributes<TProps> extends true ? {
|
|
7
|
+
fragmentReference: FragmentReference<ExtractReadFromStore<TEntrypoint>, React.FC<TProps>>;
|
|
8
|
+
additionalProps?: Record<PropertyKey, never>;
|
|
8
9
|
networkRequestOptions?: Partial<NetworkRequestReaderOptions>;
|
|
9
10
|
} : {
|
|
10
11
|
fragmentReference: FragmentReference<ExtractReadFromStore<TEntrypoint>, React.FC<TProps>>;
|
|
11
|
-
additionalProps: TProps
|
|
12
|
+
additionalProps: Omit<TProps, keyof JSX.IntrinsicAttributes>;
|
|
12
13
|
networkRequestOptions?: Partial<NetworkRequestReaderOptions>;
|
|
13
14
|
}): React.ReactNode;
|
|
15
|
+
export {};
|
|
@@ -28,5 +28,8 @@ const React = __importStar(require("react"));
|
|
|
28
28
|
const useResult_1 = require("./useResult");
|
|
29
29
|
function FragmentReader(props) {
|
|
30
30
|
const Component = (0, useResult_1.useResult)(props.fragmentReference, props.networkRequestOptions);
|
|
31
|
+
// TypeScript is not understanding that if additionalProps is Record<PropertyKey, never>,
|
|
32
|
+
// it means that TProps === JSX.IntrinsicAttributes.
|
|
33
|
+
// @ts-expect-error
|
|
31
34
|
return React.createElement(Component, Object.assign({}, props.additionalProps));
|
|
32
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isograph/react",
|
|
3
|
-
"version": "0.0.0-main-
|
|
3
|
+
"version": "0.0.0-main-adb0955b",
|
|
4
4
|
"description": "Use Isograph with React",
|
|
5
5
|
"homepage": "https://isograph.dev",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"tsc": "tsc"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@isograph/disposable-types": "0.0.0-main-
|
|
21
|
-
"@isograph/react-disposable-state": "0.0.0-main-
|
|
22
|
-
"@isograph/reference-counted-pointer": "0.0.0-main-
|
|
20
|
+
"@isograph/disposable-types": "0.0.0-main-adb0955b",
|
|
21
|
+
"@isograph/react-disposable-state": "0.0.0-main-adb0955b",
|
|
22
|
+
"@isograph/reference-counted-pointer": "0.0.0-main-adb0955b"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": "18.3.1"
|
|
@@ -4,17 +4,23 @@ import { FragmentReference } from '../core/FragmentReference';
|
|
|
4
4
|
import { useResult } from './useResult';
|
|
5
5
|
import { NetworkRequestReaderOptions } from '../core/read';
|
|
6
6
|
|
|
7
|
+
type IsExactlyIntrinsicAttributes<T> = T extends JSX.IntrinsicAttributes
|
|
8
|
+
? JSX.IntrinsicAttributes extends T
|
|
9
|
+
? true
|
|
10
|
+
: false
|
|
11
|
+
: false;
|
|
12
|
+
|
|
7
13
|
export function FragmentReader<
|
|
8
14
|
TProps extends Record<any, any>,
|
|
9
15
|
TEntrypoint extends IsographEntrypoint<any, React.FC<TProps>>,
|
|
10
16
|
>(
|
|
11
|
-
props: TProps extends
|
|
17
|
+
props: IsExactlyIntrinsicAttributes<TProps> extends true
|
|
12
18
|
? {
|
|
13
19
|
fragmentReference: FragmentReference<
|
|
14
20
|
ExtractReadFromStore<TEntrypoint>,
|
|
15
|
-
React.FC<
|
|
21
|
+
React.FC<TProps>
|
|
16
22
|
>;
|
|
17
|
-
additionalProps?:
|
|
23
|
+
additionalProps?: Record<PropertyKey, never>;
|
|
18
24
|
networkRequestOptions?: Partial<NetworkRequestReaderOptions>;
|
|
19
25
|
}
|
|
20
26
|
: {
|
|
@@ -22,7 +28,7 @@ export function FragmentReader<
|
|
|
22
28
|
ExtractReadFromStore<TEntrypoint>,
|
|
23
29
|
React.FC<TProps>
|
|
24
30
|
>;
|
|
25
|
-
additionalProps: TProps
|
|
31
|
+
additionalProps: Omit<TProps, keyof JSX.IntrinsicAttributes>;
|
|
26
32
|
networkRequestOptions?: Partial<NetworkRequestReaderOptions>;
|
|
27
33
|
},
|
|
28
34
|
): React.ReactNode {
|
|
@@ -30,5 +36,8 @@ export function FragmentReader<
|
|
|
30
36
|
props.fragmentReference,
|
|
31
37
|
props.networkRequestOptions,
|
|
32
38
|
);
|
|
39
|
+
// TypeScript is not understanding that if additionalProps is Record<PropertyKey, never>,
|
|
40
|
+
// it means that TProps === JSX.IntrinsicAttributes.
|
|
41
|
+
// @ts-expect-error
|
|
33
42
|
return <Component {...props.additionalProps} />;
|
|
34
43
|
}
|