@webiny/react-composition 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.dbdf5d6258
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 +6 -12
- package/Compose.js +61 -21
- package/Compose.js.map +1 -1
- package/CompositionScope.d.ts +17 -0
- package/CompositionScope.js +27 -0
- package/CompositionScope.js.map +1 -0
- package/Context.d.ts +24 -27
- package/Context.js +75 -110
- package/Context.js.map +1 -1
- package/README.md +9 -6
- package/createDecorator.d.ts +19 -0
- package/createDecorator.js +29 -0
- package/createDecorator.js.map +1 -0
- package/decorators.d.ts +15 -0
- package/decorators.js +71 -0
- package/decorators.js.map +1 -0
- package/domain/CompositionStore.d.ts +15 -0
- package/domain/CompositionStore.js +102 -0
- package/domain/CompositionStore.js.map +1 -0
- package/index.d.ts +9 -4
- package/index.js +10 -57
- package/index.js.map +1 -1
- package/makeComposable.d.ts +43 -3
- package/makeComposable.js +10 -68
- package/makeComposable.js.map +1 -1
- package/makeDecoratable.d.ts +31 -0
- package/makeDecoratable.js +53 -0
- package/makeDecoratable.js.map +1 -0
- package/package.json +10 -19
- package/types.d.ts +35 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/createComponentPlugin.d.ts +0 -8
- package/createComponentPlugin.js +0 -29
- package/createComponentPlugin.js.map +0 -1
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React, { ComponentProps } from "react";
|
|
2
|
-
import { ComposableFC, HigherOrderComponent } from "./index";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a component which, when mounted, registers a Higher Order Component for the given base component.
|
|
5
|
-
* This is particularly useful for decorating (wrapping) existing composable components.
|
|
6
|
-
* For more information, visit https://www.webiny.com/docs/admin-area/basics/framework.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createComponentPlugin<T extends ComposableFC<ComponentProps<T>>>(Base: T, hoc: HigherOrderComponent<ComponentProps<T>>): React.FC;
|
package/createComponentPlugin.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createComponentPlugin = createComponentPlugin;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var _index = require("./index");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Creates a component which, when mounted, registers a Higher Order Component for the given base component.
|
|
16
|
-
* This is particularly useful for decorating (wrapping) existing composable components.
|
|
17
|
-
* For more information, visit https://www.webiny.com/docs/admin-area/basics/framework.
|
|
18
|
-
*/
|
|
19
|
-
function createComponentPlugin(Base, hoc) {
|
|
20
|
-
var ComponentPlugin = function ComponentPlugin() {
|
|
21
|
-
return /*#__PURE__*/_react.default.createElement(_index.Compose, {
|
|
22
|
-
component: Base,
|
|
23
|
-
with: hoc
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
ComponentPlugin.displayName = Base.displayName;
|
|
28
|
-
return ComponentPlugin;
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createComponentPlugin","Base","hoc","ComponentPlugin","displayName"],"sources":["createComponentPlugin.tsx"],"sourcesContent":["import React, { ComponentProps } from \"react\";\nimport { ComposableFC, Compose, HigherOrderComponent } from \"./index\";\n\n/**\n * Creates a component which, when mounted, registers a Higher Order Component for the given base component.\n * This is particularly useful for decorating (wrapping) existing composable components.\n * For more information, visit https://www.webiny.com/docs/admin-area/basics/framework.\n */\nexport function createComponentPlugin<T extends ComposableFC<ComponentProps<T>>>(\n Base: T,\n hoc: HigherOrderComponent<ComponentProps<T>>\n): React.FC {\n const ComponentPlugin = () => <Compose component={Base} with={hoc} />;\n ComponentPlugin.displayName = Base.displayName;\n return ComponentPlugin;\n}\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAT,CACHC,IADG,EAEHC,GAFG,EAGK;EACR,IAAMC,eAAe,GAAG,SAAlBA,eAAkB;IAAA,oBAAM,6BAAC,cAAD;MAAS,SAAS,EAAEF,IAApB;MAA0B,IAAI,EAAEC;IAAhC,EAAN;EAAA,CAAxB;;EACAC,eAAe,CAACC,WAAhB,GAA8BH,IAAI,CAACG,WAAnC;EACA,OAAOD,eAAP;AACH"}
|