@webiny/react-composition 6.0.0-beta.0 → 6.0.0-rc.0
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.
- package/Compose.d.ts +2 -2
- package/Compose.js +19 -18
- package/Compose.js.map +1 -1
- package/CompositionScope.d.ts +9 -3
- package/CompositionScope.js +18 -19
- package/CompositionScope.js.map +1 -1
- package/Context.d.ts +15 -12
- package/Context.js +71 -80
- package/Context.js.map +1 -1
- package/README.md +9 -6
- package/createDecorator.d.ts +6 -6
- package/createDecorator.js +9 -19
- package/createDecorator.js.map +1 -1
- package/decorators.d.ts +7 -14
- package/decorators.js +22 -33
- package/decorators.js.map +1 -1
- package/index.d.ts +8 -8
- package/index.js +7 -93
- package/index.js.map +1 -1
- package/makeComposable.d.ts +30 -14
- package/makeComposable.js +6 -14
- package/makeComposable.js.map +1 -1
- package/makeDecoratable.d.ts +10 -15
- package/makeDecoratable.js +29 -44
- package/makeDecoratable.js.map +1 -1
- package/package.json +6 -15
- package/types.d.ts +18 -12
- package/types.js +1 -5
- package/types.js.map +1 -1
package/types.d.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export type GenericHook<TParams = any, TReturn = any> = (...args: TParams[]) => TReturn;
|
|
3
|
+
export type GenericComponent<T = any> = React.FunctionComponent<T>;
|
|
4
|
+
export type ComposedFunction = GenericHook;
|
|
5
|
+
export type Decorator<T> = (decoratee: T) => T;
|
|
6
|
+
/**
|
|
7
|
+
* Some decoratable components will always return `null`, by design.
|
|
8
|
+
* To allow you to decorate these components, we must tell TS that the decorator is allowed to return not just `null`
|
|
9
|
+
* (which is inferred from the component type), but also a JSX.Element.
|
|
10
|
+
*/
|
|
11
|
+
export type ComponentDecorator<T> = (decoratee: T) => CanReturnNullOrElement<T>;
|
|
6
12
|
/**
|
|
7
13
|
* @deprecated
|
|
8
14
|
*/
|
|
9
|
-
export
|
|
15
|
+
export type ComposableFC<T> = T & {
|
|
10
16
|
displayName?: string;
|
|
11
17
|
original: T;
|
|
12
18
|
originalName: string;
|
|
13
19
|
};
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
20
|
+
export type Enumerable<T> = T extends Array<infer D> ? Array<D> : never;
|
|
21
|
+
export type ComposeWith = Decorator<GenericComponent> | Decorator<GenericComponent>[] | Decorator<GenericHook> | Decorator<GenericHook>[];
|
|
22
|
+
export type DecoratableHook<T extends GenericHook = GenericHook> = T & {
|
|
17
23
|
original: T;
|
|
18
24
|
originalName: string;
|
|
19
25
|
};
|
|
20
|
-
export
|
|
26
|
+
export type DecoratableComponent<T = GenericComponent> = T & {
|
|
21
27
|
original: T;
|
|
22
28
|
originalName: string;
|
|
23
29
|
displayName: string;
|
|
24
30
|
};
|
|
25
|
-
export
|
|
31
|
+
export type Decoratable = DecoratableComponent | DecoratableHook;
|
|
26
32
|
/**
|
|
27
33
|
* @internal Add `null` to the ReturnType of the given function.
|
|
28
34
|
*/
|
|
29
|
-
export
|
|
35
|
+
export type CanReturnNullOrElement<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => JSX.Element | null : never;
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import React from \"react\";\n\nexport type GenericHook<TParams = any, TReturn = any> = (...args: TParams[]) => TReturn;\n\nexport type GenericComponent<T = any> = React.FunctionComponent<T>;\n\nexport type ComposedFunction = GenericHook;\n\nexport type Decorator<T> = (decoratee: T) => T;\n\n/**\n * @deprecated\n */\nexport type ComposableFC<T> = T & {\n displayName?: string;\n original: T;\n originalName: string;\n};\n\nexport type Enumerable<T> = T extends Array<infer D> ? Array<D> : never;\n\nexport type ComposeWith =\n | Decorator<GenericComponent>\n | Decorator<GenericComponent>[]\n | Decorator<GenericHook>\n | Decorator<GenericHook>[];\n\nexport type DecoratableHook<T extends GenericHook = GenericHook> = T & {\n original: T;\n originalName: string;\n};\n\nexport type DecoratableComponent<T = GenericComponent> = T & {\n original: T;\n originalName: string;\n displayName: string;\n};\n\nexport type Decoratable = DecoratableComponent | DecoratableHook;\n\n/**\n * @internal Add `null` to the ReturnType of the given function.\n */\nexport type
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type React from \"react\";\n\nexport type GenericHook<TParams = any, TReturn = any> = (...args: TParams[]) => TReturn;\n\nexport type GenericComponent<T = any> = React.FunctionComponent<T>;\n\nexport type ComposedFunction = GenericHook;\n\nexport type Decorator<T> = (decoratee: T) => T;\n\n/**\n * Some decoratable components will always return `null`, by design.\n * To allow you to decorate these components, we must tell TS that the decorator is allowed to return not just `null`\n * (which is inferred from the component type), but also a JSX.Element.\n */\nexport type ComponentDecorator<T> = (decoratee: T) => CanReturnNullOrElement<T>;\n\n/**\n * @deprecated\n */\nexport type ComposableFC<T> = T & {\n displayName?: string;\n original: T;\n originalName: string;\n};\n\nexport type Enumerable<T> = T extends Array<infer D> ? Array<D> : never;\n\nexport type ComposeWith =\n | Decorator<GenericComponent>\n | Decorator<GenericComponent>[]\n | Decorator<GenericHook>\n | Decorator<GenericHook>[];\n\nexport type DecoratableHook<T extends GenericHook = GenericHook> = T & {\n original: T;\n originalName: string;\n};\n\nexport type DecoratableComponent<T = GenericComponent> = T & {\n original: T;\n originalName: string;\n displayName: string;\n};\n\nexport type Decoratable = DecoratableComponent | DecoratableHook;\n\n/**\n * @internal Add `null` to the ReturnType of the given function.\n */\nexport type CanReturnNullOrElement<T> = T extends (...args: any) => any\n ? (...args: Parameters<T>) => JSX.Element | null\n : never;\n"],"mappings":"","ignoreList":[]}
|