@w3ux/factories 1.0.0-alpha.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/cjs/index.d.ts +1 -0
- package/cjs/index.js +21 -0
- package/cjs/index.js.map +1 -0
- package/cjs/withProviders.d.ts +3 -0
- package/cjs/withProviders.js +17 -0
- package/cjs/withProviders.js.map +1 -0
- package/mjs/index.d.ts +1 -0
- package/mjs/index.js +5 -0
- package/mjs/index.js.map +1 -0
- package/mjs/withProviders.d.ts +3 -0
- package/mjs/withProviders.js +13 -0
- package/mjs/withProviders.js.map +1 -0
- package/package.json +16 -0
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./withProviders";
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./withProviders"), exports);
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,kDAAgC","file":"index.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nexport * from \"./withProviders\";\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withProviders = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const withProviders = (providers, Wrapped) => providers.reduceRight((acc, prov) => {
|
|
6
|
+
if (Array.isArray(prov)) {
|
|
7
|
+
const Provider = prov[0];
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(Provider, Object.assign({}, prov[1], { children: acc }));
|
|
9
|
+
}
|
|
10
|
+
const Provider = prov;
|
|
11
|
+
return (0, jsx_runtime_1.jsx)(Provider, { children: acc });
|
|
12
|
+
}, (0, jsx_runtime_1.jsx)(Wrapped, {}));
|
|
13
|
+
exports.withProviders = withProviders;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=withProviders.js.map
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=withProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/withProviders.tsx"],"names":[],"mappings":";;;;AAUO,MAAM,aAAa,GAAG,CAAC,SAAqB,EAAE,OAAW,EAAE,EAAE,CAClE,SAAS,CAAC,WAAW,CACnB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACZ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,OAAO,uBAAC,QAAQ,oBAAK,IAAI,CAAC,CAAC,CAAC,cAAG,GAAG,IAAY,CAAC;IACjD,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC;IACtB,OAAO,uBAAC,QAAQ,cAAE,GAAG,GAAY,CAAC;AACpC,CAAC,EACD,uBAAC,OAAO,KAAG,CACZ,CAAC;AAXS,QAAA,aAAa,iBAWtB","file":"withProviders.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport type { FC } from \"react\";\n\n// `providers` accepts standalone functional components or an array of a functional component and its props.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Provider = FC<any> | [FC<any>, any];\n\n// A pure function that applies an arbitrary amount of context providers to a wrapped component.\nexport const withProviders = (providers: Provider[], Wrapped: FC) =>\n providers.reduceRight(\n (acc, prov) => {\n if (Array.isArray(prov)) {\n const Provider = prov[0];\n return <Provider {...prov[1]}>{acc}</Provider>;\n }\n const Provider = prov;\n return <Provider>{acc}</Provider>;\n },\n <Wrapped />\n );\n"]}
|
package/mjs/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./withProviders";
|
package/mjs/index.js
ADDED
package/mjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAC","file":"index.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nexport * from \"./withProviders\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const withProviders = (providers, Wrapped) => providers.reduceRight((acc, prov) => {
|
|
3
|
+
if (Array.isArray(prov)) {
|
|
4
|
+
const Provider = prov[0];
|
|
5
|
+
return _jsx(Provider, { ...prov[1], children: acc });
|
|
6
|
+
}
|
|
7
|
+
const Provider = prov;
|
|
8
|
+
return _jsx(Provider, { children: acc });
|
|
9
|
+
}, _jsx(Wrapped, {}));
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=withProviders.js.map
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=withProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/withProviders.tsx"],"names":[],"mappings":";AAUA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAqB,EAAE,OAAW,EAAE,EAAE,CAClE,SAAS,CAAC,WAAW,CACnB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACZ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,OAAO,KAAC,QAAQ,OAAK,IAAI,CAAC,CAAC,CAAC,YAAG,GAAG,GAAY,CAAC;IACjD,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC;IACtB,OAAO,KAAC,QAAQ,cAAE,GAAG,GAAY,CAAC;AACpC,CAAC,EACD,KAAC,OAAO,KAAG,CACZ,CAAC","file":"withProviders.js","sourcesContent":["/* @license Copyright 2024 w3ux authors & contributors\nSPDX-License-Identifier: GPL-3.0-only */\n\nimport type { FC } from \"react\";\n\n// `providers` accepts standalone functional components or an array of a functional component and its props.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Provider = FC<any> | [FC<any>, any];\n\n// A pure function that applies an arbitrary amount of context providers to a wrapped component.\nexport const withProviders = (providers: Provider[], Wrapped: FC) =>\n providers.reduceRight(\n (acc, prov) => {\n if (Array.isArray(prov)) {\n const Provider = prov[0];\n return <Provider {...prov[1]}>{acc}</Provider>;\n }\n const Provider = prov;\n return <Provider>{acc}</Provider>;\n },\n <Wrapped />\n );\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@w3ux/factories",
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
|
+
"license": "GPL-3.0-only",
|
|
5
|
+
"main": "cjs/index.js",
|
|
6
|
+
"module": "mjs/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./mjs/index.js",
|
|
10
|
+
"require": "./cjs/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"react": "^18"
|
|
15
|
+
}
|
|
16
|
+
}
|