@webiny/react-composition 0.0.0-unstable.ecd8734205 → 0.0.0-unstable.f6dc066313
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 +90 -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/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/react-composition",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.f6dc066313",
|
|
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
|
-
"@
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"react": "17.0.2",
|
|
21
|
-
"react-dom": "17.0.2"
|
|
18
|
+
"@types/react": "18.2.79",
|
|
19
|
+
"react": "18.2.0",
|
|
20
|
+
"react-dom": "18.2.0"
|
|
22
21
|
},
|
|
23
22
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"@webiny/cli": "^0.0.0-unstable.ecd8734205",
|
|
29
|
-
"@webiny/project-utils": "^0.0.0-unstable.ecd8734205",
|
|
30
|
-
"ttypescript": "^1.5.13",
|
|
31
|
-
"typescript": "4.7.4"
|
|
23
|
+
"@testing-library/react": "15.0.7",
|
|
24
|
+
"@webiny/build-tools": "0.0.0-unstable.f6dc066313",
|
|
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
|
-
"
|
|
38
|
-
"build": "yarn webiny run build",
|
|
39
|
-
"watch": "yarn webiny run watch"
|
|
40
|
-
},
|
|
41
|
-
"gitHead": "ecd8734205e0e21ae04076c28ff9806dad07a730"
|
|
32
|
+
"gitHead": "f6dc066313ddce5339d2aacec3aa84e61232689b"
|
|
42
33
|
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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>;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
15
|
+
export type ComposableFC<T> = T & {
|
|
16
|
+
displayName?: string;
|
|
17
|
+
original: T;
|
|
18
|
+
originalName: string;
|
|
19
|
+
};
|
|
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 & {
|
|
23
|
+
original: T;
|
|
24
|
+
originalName: string;
|
|
25
|
+
};
|
|
26
|
+
export type DecoratableComponent<T = GenericComponent> = T & {
|
|
27
|
+
original: T;
|
|
28
|
+
originalName: string;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
31
|
+
export type Decoratable = DecoratableComponent | DecoratableHook;
|
|
32
|
+
/**
|
|
33
|
+
* @internal Add `null` to the ReturnType of the given function.
|
|
34
|
+
*/
|
|
35
|
+
export type CanReturnNullOrElement<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => JSX.Element | null : never;
|
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"}
|