@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/types.d.ts CHANGED
@@ -1,29 +1,35 @@
1
- import React from "react";
2
- export declare type GenericHook<TParams = any, TReturn = any> = (...args: TParams[]) => TReturn;
3
- export declare type GenericComponent<T = any> = React.FunctionComponent<T>;
4
- export declare type ComposedFunction = GenericHook;
5
- export declare type Decorator<T> = (decoratee: T) => T;
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 declare type ComposableFC<T> = T & {
15
+ export type ComposableFC<T> = T & {
10
16
  displayName?: string;
11
17
  original: T;
12
18
  originalName: string;
13
19
  };
14
- export declare type Enumerable<T> = T extends Array<infer D> ? Array<D> : never;
15
- export declare type ComposeWith = Decorator<GenericComponent> | Decorator<GenericComponent>[] | Decorator<GenericHook> | Decorator<GenericHook>[];
16
- export declare type DecoratableHook<T extends GenericHook = GenericHook> = T & {
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 declare type DecoratableComponent<T = GenericComponent> = T & {
26
+ export type DecoratableComponent<T = GenericComponent> = T & {
21
27
  original: T;
22
28
  originalName: string;
23
29
  displayName: string;
24
30
  };
25
- export declare type Decoratable = DecoratableComponent | DecoratableHook;
31
+ export type Decoratable = DecoratableComponent | DecoratableHook;
26
32
  /**
27
33
  * @internal Add `null` to the ReturnType of the given function.
28
34
  */
29
- export declare type CanReturnNull<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => ReturnType<T> | null : never;
35
+ export type CanReturnNullOrElement<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => JSX.Element | null : never;
package/types.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
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 CanReturnNull<T> = T extends (...args: any) => any\n ? (...args: Parameters<T>) => ReturnType<T> | null\n : never;\n"],"mappings":"","ignoreList":[]}
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":[]}