@webiny/react-composition 6.0.0-beta.0 → 6.0.0-rc.1

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.
@@ -1,66 +1,51 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createVoidComponent = createVoidComponent;
9
- exports.makeDecoratable = makeDecoratable;
10
- exports.makeDecoratableHook = makeDecoratableHook;
11
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _Context = require("./Context");
14
- var _decorators = require("./decorators");
15
- var ComposableContext = /*#__PURE__*/(0, _react.createContext)([]);
1
+ import React, { createContext, useContext, useMemo } from "react";
2
+ import { useComponent } from "./Context.js";
3
+ import { withDecoratorFactory, withHookDecoratorFactory } from "./decorators.js";
4
+ const ComposableContext = /*#__PURE__*/createContext([]);
16
5
  ComposableContext.displayName = "ComposableContext";
17
6
  function useComposableParents() {
18
- var context = (0, _react.useContext)(ComposableContext);
7
+ const context = useContext(ComposableContext);
19
8
  if (!context) {
20
9
  return [];
21
10
  }
22
11
  return context;
23
12
  }
24
- var nullRenderer = function nullRenderer() {
25
- return null;
26
- };
27
-
28
- // Maybe there's a better way to mark props as non-existent, but for now I left it as `any`.
29
-
30
- function makeDecoratableComponent(name) {
31
- var Component = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : nullRenderer;
32
- var Decoratable = function Decoratable(props) {
33
- var parents = useComposableParents();
34
- var ComposedComponent = (0, _Context.useComponent)(Component);
35
- var context = (0, _react.useMemo)(function () {
36
- return [].concat((0, _toConsumableArray2.default)(parents), [name]);
37
- }, [parents, name]);
38
- return /*#__PURE__*/_react.default.createElement(ComposableContext.Provider, {
13
+ const nullRenderer = () => null;
14
+ function makeDecoratableComponent(name, Component = nullRenderer) {
15
+ const Decoratable = props => {
16
+ const parents = useComposableParents();
17
+ const ComposedComponent = useComponent(Component);
18
+ const context = useMemo(() => [...parents, name], [parents, name]);
19
+ return /*#__PURE__*/React.createElement(ComposableContext.Provider, {
39
20
  value: context
40
- }, /*#__PURE__*/_react.default.createElement(ComposedComponent, props, props.children));
21
+ }, /*#__PURE__*/React.createElement(ComposedComponent, props, props.children));
22
+ };
23
+ const staticProps = {
24
+ original: Component,
25
+ originalName: name,
26
+ displayName: `Decoratable<${name}>`
41
27
  };
42
- Decoratable.original = Component;
43
- Decoratable.originalName = name;
44
- Decoratable.displayName = "Decoratable<".concat(name, ">");
45
- return (0, _decorators.withDecoratorFactory)()(Decoratable);
28
+ return withDecoratorFactory()(Object.assign(Decoratable, staticProps));
46
29
  }
47
- function makeDecoratableHook(hook) {
48
- var decoratableHook = function decoratableHook(params) {
49
- var composedHook = (0, _Context.useComponent)(hook);
30
+ export function makeDecoratableHook(hook) {
31
+ const decoratableHook = params => {
32
+ const composedHook = useComponent(hook);
50
33
  return composedHook(params);
51
34
  };
52
35
  decoratableHook.original = hook;
53
- return (0, _decorators.withHookDecoratorFactory)()(decoratableHook);
36
+ return withHookDecoratorFactory()(decoratableHook);
54
37
  }
55
- function createVoidComponent() {
38
+ export function createVoidComponent() {
56
39
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
- return function (props) {
40
+ return props => {
58
41
  return null;
59
42
  };
60
43
  }
61
- function makeDecoratable(hookOrName, Component) {
44
+ export function makeDecoratable(hookOrName, Component) {
62
45
  if (Component) {
63
- return makeDecoratableComponent(hookOrName, /*#__PURE__*/_react.default.memo(Component));
46
+ const component = makeDecoratableComponent(hookOrName, /*#__PURE__*/React.memo(Component));
47
+ component.original.displayName = hookOrName;
48
+ return component;
64
49
  }
65
50
  return makeDecoratableHook(hookOrName);
66
51
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_Context","_decorators","ComposableContext","createContext","displayName","useComposableParents","context","useContext","nullRenderer","makeDecoratableComponent","name","Component","arguments","length","undefined","Decoratable","props","parents","ComposedComponent","useComponent","useMemo","concat","_toConsumableArray2","default","createElement","Provider","value","children","original","originalName","withDecoratorFactory","makeDecoratableHook","hook","decoratableHook","params","composedHook","withHookDecoratorFactory","createVoidComponent","makeDecoratable","hookOrName","React","memo"],"sources":["makeDecoratable.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { useComponent } from \"./Context\";\nimport { DecoratableComponent, DecoratableHook, GenericComponent, GenericHook } from \"~/types\";\nimport { withDecoratorFactory, withHookDecoratorFactory } from \"~/decorators\";\n\nconst ComposableContext = createContext<string[]>([]);\nComposableContext.displayName = \"ComposableContext\";\n\nfunction useComposableParents() {\n const context = useContext(ComposableContext);\n if (!context) {\n return [];\n }\n\n return context;\n}\n\nconst nullRenderer = () => null;\n\n// Maybe there's a better way to mark props as non-existent, but for now I left it as `any`.\ntype NoProps = any;\n\ntype GetProps<T extends (...args: any) => any> = Parameters<T> extends [infer First]\n ? undefined extends First\n ? NoProps\n : First\n : NoProps;\n\nfunction makeDecoratableComponent<T extends GenericComponent>(\n name: string,\n Component: T = nullRenderer as unknown as T\n) {\n const Decoratable = (props: GetProps<T>): JSX.Element | null => {\n const parents = useComposableParents();\n const ComposedComponent = useComponent(Component);\n\n const context = useMemo(() => [...parents, name], [parents, name]);\n\n return (\n <ComposableContext.Provider value={context}>\n <ComposedComponent {...props}>{props.children}</ComposedComponent>\n </ComposableContext.Provider>\n );\n };\n\n Decoratable.original = Component;\n Decoratable.originalName = name;\n Decoratable.displayName = `Decoratable<${name}>`;\n\n return withDecoratorFactory()(Decoratable as DecoratableComponent<typeof Decoratable>);\n}\n\nexport function makeDecoratableHook<T extends GenericHook>(hook: T) {\n const decoratableHook = (params: Parameters<T>) => {\n const composedHook = useComponent(hook);\n\n return composedHook(params) as DecoratableHook<T>;\n };\n\n decoratableHook.original = hook;\n\n return withHookDecoratorFactory()(decoratableHook as DecoratableHook<T>);\n}\n\nexport function createVoidComponent<T>() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return (props: T): JSX.Element | null => {\n return null;\n };\n}\n\nexport function makeDecoratable<T extends GenericHook>(\n hook: T\n): ReturnType<typeof makeDecoratableHook<T>>;\nexport function makeDecoratable<T extends GenericComponent>(\n name: string,\n Component: T\n): ReturnType<typeof makeDecoratableComponent<T>>;\nexport function makeDecoratable(hookOrName: any, Component?: any) {\n if (Component) {\n return makeDecoratableComponent(hookOrName, React.memo(Component));\n }\n\n return makeDecoratableHook(hookOrName);\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAMG,iBAAiB,gBAAG,IAAAC,oBAAa,EAAW,EAAE,CAAC;AACrDD,iBAAiB,CAACE,WAAW,GAAG,mBAAmB;AAEnD,SAASC,oBAAoBA,CAAA,EAAG;EAC5B,IAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACL,iBAAiB,CAAC;EAC7C,IAAI,CAACI,OAAO,EAAE;IACV,OAAO,EAAE;EACb;EAEA,OAAOA,OAAO;AAClB;AAEA,IAAME,YAAY,GAAG,SAAfA,YAAYA,CAAA;EAAA,OAAS,IAAI;AAAA;;AAE/B;;AASA,SAASC,wBAAwBA,CAC7BC,IAAY,EAEd;EAAA,IADEC,SAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGJ,YAAY;EAE3B,IAAMO,WAAW,GAAG,SAAdA,WAAWA,CAAIC,KAAkB,EAAyB;IAC5D,IAAMC,OAAO,GAAGZ,oBAAoB,CAAC,CAAC;IACtC,IAAMa,iBAAiB,GAAG,IAAAC,qBAAY,EAACR,SAAS,CAAC;IAEjD,IAAML,OAAO,GAAG,IAAAc,cAAO,EAAC;MAAA,UAAAC,MAAA,KAAAC,mBAAA,CAAAC,OAAA,EAAUN,OAAO,IAAEP,IAAI;IAAA,CAAC,EAAE,CAACO,OAAO,EAAEP,IAAI,CAAC,CAAC;IAElE,oBACIb,MAAA,CAAA0B,OAAA,CAAAC,aAAA,CAACtB,iBAAiB,CAACuB,QAAQ;MAACC,KAAK,EAAEpB;IAAQ,gBACvCT,MAAA,CAAA0B,OAAA,CAAAC,aAAA,CAACN,iBAAiB,EAAKF,KAAK,EAAGA,KAAK,CAACW,QAA4B,CACzC,CAAC;EAErC,CAAC;EAEDZ,WAAW,CAACa,QAAQ,GAAGjB,SAAS;EAChCI,WAAW,CAACc,YAAY,GAAGnB,IAAI;EAC/BK,WAAW,CAACX,WAAW,kBAAAiB,MAAA,CAAkBX,IAAI,MAAG;EAEhD,OAAO,IAAAoB,gCAAoB,EAAC,CAAC,CAACf,WAAuD,CAAC;AAC1F;AAEO,SAASgB,mBAAmBA,CAAwBC,IAAO,EAAE;EAChE,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,MAAqB,EAAK;IAC/C,IAAMC,YAAY,GAAG,IAAAhB,qBAAY,EAACa,IAAI,CAAC;IAEvC,OAAOG,YAAY,CAACD,MAAM,CAAC;EAC/B,CAAC;EAEDD,eAAe,CAACL,QAAQ,GAAGI,IAAI;EAE/B,OAAO,IAAAI,oCAAwB,EAAC,CAAC,CAACH,eAAqC,CAAC;AAC5E;AAEO,SAASI,mBAAmBA,CAAA,EAAM;EACrC;EACA,OAAO,UAACrB,KAAQ,EAAyB;IACrC,OAAO,IAAI;EACf,CAAC;AACL;AASO,SAASsB,eAAeA,CAACC,UAAe,EAAE5B,SAAe,EAAE;EAC9D,IAAIA,SAAS,EAAE;IACX,OAAOF,wBAAwB,CAAC8B,UAAU,eAAEC,cAAK,CAACC,IAAI,CAAC9B,SAAS,CAAC,CAAC;EACtE;EAEA,OAAOoB,mBAAmB,CAACQ,UAAU,CAAC;AAC1C","ignoreList":[]}
1
+ {"version":3,"names":["React","createContext","useContext","useMemo","useComponent","withDecoratorFactory","withHookDecoratorFactory","ComposableContext","displayName","useComposableParents","context","nullRenderer","makeDecoratableComponent","name","Component","Decoratable","props","parents","ComposedComponent","createElement","Provider","value","children","staticProps","original","originalName","Object","assign","makeDecoratableHook","hook","decoratableHook","params","composedHook","createVoidComponent","makeDecoratable","hookOrName","component","memo"],"sources":["makeDecoratable.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { useComponent } from \"./Context.js\";\nimport type {\n DecoratableComponent,\n DecoratableHook,\n GenericComponent,\n GenericHook\n} from \"~/types.js\";\nimport { withDecoratorFactory, withHookDecoratorFactory } from \"~/decorators.js\";\n\nconst ComposableContext = createContext<string[]>([]);\nComposableContext.displayName = \"ComposableContext\";\n\nfunction useComposableParents() {\n const context = useContext(ComposableContext);\n if (!context) {\n return [];\n }\n\n return context;\n}\n\nconst nullRenderer = () => null;\n\nfunction makeDecoratableComponent<T extends GenericComponent>(\n name: string,\n Component: T = nullRenderer as unknown as T\n) {\n const Decoratable = (props: React.ComponentProps<T>): JSX.Element | null => {\n const parents = useComposableParents();\n const ComposedComponent = useComponent(Component) as GenericComponent<\n React.ComponentProps<T>\n >;\n\n const context = useMemo(() => [...parents, name], [parents, name]);\n\n return (\n <ComposableContext.Provider value={context}>\n <ComposedComponent {...props}>{props.children}</ComposedComponent>\n </ComposableContext.Provider>\n );\n };\n\n const staticProps = {\n original: Component,\n originalName: name,\n displayName: `Decoratable<${name}>`\n };\n\n return withDecoratorFactory()(\n Object.assign(Decoratable, staticProps) as DecoratableComponent<\n typeof Component & typeof staticProps\n >\n );\n}\n\nexport function makeDecoratableHook<T extends GenericHook>(hook: T) {\n const decoratableHook = (params: Parameters<T>) => {\n const composedHook = useComponent(hook);\n\n return composedHook(params) as DecoratableHook<T>;\n };\n\n decoratableHook.original = hook;\n\n return withHookDecoratorFactory()(decoratableHook as DecoratableHook<T>);\n}\n\nexport function createVoidComponent<T>() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return (props: T): JSX.Element | null => {\n return null;\n };\n}\n\nexport function makeDecoratable<T extends GenericHook>(\n hook: T\n): ReturnType<typeof makeDecoratableHook<T>>;\nexport function makeDecoratable<T extends GenericComponent>(\n name: string,\n Component: T\n): ReturnType<typeof makeDecoratableComponent<T>>;\nexport function makeDecoratable(hookOrName: any, Component?: any) {\n if (Component) {\n const component = makeDecoratableComponent(hookOrName, React.memo(Component));\n component.original.displayName = hookOrName;\n return component;\n }\n\n return makeDecoratableHook(hookOrName);\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AACjE,SAASC,YAAY;AAOrB,SAASC,oBAAoB,EAAEC,wBAAwB;AAEvD,MAAMC,iBAAiB,gBAAGN,aAAa,CAAW,EAAE,CAAC;AACrDM,iBAAiB,CAACC,WAAW,GAAG,mBAAmB;AAEnD,SAASC,oBAAoBA,CAAA,EAAG;EAC5B,MAAMC,OAAO,GAAGR,UAAU,CAACK,iBAAiB,CAAC;EAC7C,IAAI,CAACG,OAAO,EAAE;IACV,OAAO,EAAE;EACb;EAEA,OAAOA,OAAO;AAClB;AAEA,MAAMC,YAAY,GAAGA,CAAA,KAAM,IAAI;AAE/B,SAASC,wBAAwBA,CAC7BC,IAAY,EACZC,SAAY,GAAGH,YAA4B,EAC7C;EACE,MAAMI,WAAW,GAAIC,KAA8B,IAAyB;IACxE,MAAMC,OAAO,GAAGR,oBAAoB,CAAC,CAAC;IACtC,MAAMS,iBAAiB,GAAGd,YAAY,CAACU,SAAS,CAE/C;IAED,MAAMJ,OAAO,GAAGP,OAAO,CAAC,MAAM,CAAC,GAAGc,OAAO,EAAEJ,IAAI,CAAC,EAAE,CAACI,OAAO,EAAEJ,IAAI,CAAC,CAAC;IAElE,oBACIb,KAAA,CAAAmB,aAAA,CAACZ,iBAAiB,CAACa,QAAQ;MAACC,KAAK,EAAEX;IAAQ,gBACvCV,KAAA,CAAAmB,aAAA,CAACD,iBAAiB,EAAKF,KAAK,EAAGA,KAAK,CAACM,QAA4B,CACzC,CAAC;EAErC,CAAC;EAED,MAAMC,WAAW,GAAG;IAChBC,QAAQ,EAAEV,SAAS;IACnBW,YAAY,EAAEZ,IAAI;IAClBL,WAAW,EAAE,eAAeK,IAAI;EACpC,CAAC;EAED,OAAOR,oBAAoB,CAAC,CAAC,CACzBqB,MAAM,CAACC,MAAM,CAACZ,WAAW,EAAEQ,WAAW,CAG1C,CAAC;AACL;AAEA,OAAO,SAASK,mBAAmBA,CAAwBC,IAAO,EAAE;EAChE,MAAMC,eAAe,GAAIC,MAAqB,IAAK;IAC/C,MAAMC,YAAY,GAAG5B,YAAY,CAACyB,IAAI,CAAC;IAEvC,OAAOG,YAAY,CAACD,MAAM,CAAC;EAC/B,CAAC;EAEDD,eAAe,CAACN,QAAQ,GAAGK,IAAI;EAE/B,OAAOvB,wBAAwB,CAAC,CAAC,CAACwB,eAAqC,CAAC;AAC5E;AAEA,OAAO,SAASG,mBAAmBA,CAAA,EAAM;EACrC;EACA,OAAQjB,KAAQ,IAAyB;IACrC,OAAO,IAAI;EACf,CAAC;AACL;AASA,OAAO,SAASkB,eAAeA,CAACC,UAAe,EAAErB,SAAe,EAAE;EAC9D,IAAIA,SAAS,EAAE;IACX,MAAMsB,SAAS,GAAGxB,wBAAwB,CAACuB,UAAU,eAAEnC,KAAK,CAACqC,IAAI,CAACvB,SAAS,CAAC,CAAC;IAC7EsB,SAAS,CAACZ,QAAQ,CAAChB,WAAW,GAAG2B,UAAU;IAC3C,OAAOC,SAAS;EACpB;EAEA,OAAOR,mBAAmB,CAACO,UAAU,CAAC;AAC1C","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/react-composition",
3
- "version": "6.0.0-beta.0",
3
+ "version": "6.0.0-rc.1",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -14,29 +15,19 @@
14
15
  ],
15
16
  "license": "MIT",
16
17
  "dependencies": {
17
- "@babel/runtime": "7.24.1",
18
18
  "@types/react": "18.2.79",
19
19
  "react": "18.2.0",
20
20
  "react-dom": "18.2.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@babel/cli": "7.24.1",
24
- "@babel/core": "7.24.3",
25
- "@babel/preset-env": "7.24.3",
26
- "@babel/preset-typescript": "7.24.1",
27
23
  "@testing-library/react": "15.0.7",
28
- "@webiny/cli": "6.0.0-beta.0",
29
- "@webiny/project-utils": "6.0.0-beta.0",
30
- "ttypescript": "1.5.15",
31
- "typescript": "4.7.4"
24
+ "@webiny/build-tools": "6.0.0-rc.1",
25
+ "typescript": "5.9.3",
26
+ "vitest": "4.0.18"
32
27
  },
33
28
  "publishConfig": {
34
29
  "access": "public",
35
30
  "directory": "dist"
36
31
  },
37
- "scripts": {
38
- "build": "yarn webiny run build",
39
- "watch": "yarn webiny run watch"
40
- },
41
- "gitHead": "aa8dbfbbd5ad13ec271adba6f2431e02991a300f"
32
+ "gitHead": "36d702721ff9ed39fb21d6f5fe7922a2a8716e63"
42
33
  }
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":[]}