@threekit-tools/treble 0.0.20 → 0.0.21
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/dist/components/ProductLayout/index.d.ts +6 -0
- package/dist/components/ProductLayout/index.js +10 -0
- package/dist/components/ProductLoader/index.d.ts +12 -0
- package/dist/components/ProductLoader/index.js +82 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -1
- package/package.json +2 -1
- package/tailwind-presets.js +1 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var ProductLayout = function (props) {
|
|
8
|
+
return react_1.default.createElement(react_1.default.Fragment, null, props.children);
|
|
9
|
+
};
|
|
10
|
+
exports.default = ProductLayout;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="webpack-env" />
|
|
3
|
+
import { ThreekitProviderProps } from '../ThreekitProvider';
|
|
4
|
+
interface IProducts {
|
|
5
|
+
ctx: __WebpackModuleApi.RequireContext;
|
|
6
|
+
}
|
|
7
|
+
interface ProductLoaderProps extends Omit<ThreekitProviderProps, 'children'> {
|
|
8
|
+
productId: string;
|
|
9
|
+
products: IProducts;
|
|
10
|
+
}
|
|
11
|
+
export default function ProductLoader(props: ProductLoaderProps): JSX.Element | null;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
var react_1 = __importStar(require("react"));
|
|
26
|
+
var ThreekitProvider_1 = __importDefault(require("../ThreekitProvider"));
|
|
27
|
+
var productAssetId = {};
|
|
28
|
+
var productComponents = [];
|
|
29
|
+
var productToComponentMap = {};
|
|
30
|
+
function ProductLoader(props) {
|
|
31
|
+
var productId = props.productId, products = props.products, credentials = props.credentials, playerConfig = props.playerConfig, theme = props.theme, threekitEnv = props.threekitEnv;
|
|
32
|
+
if (!productId || !products)
|
|
33
|
+
return null;
|
|
34
|
+
if (!productComponents.length) {
|
|
35
|
+
products.ctx.keys().forEach(function (fileName) {
|
|
36
|
+
if (!fileName.includes('product.js'))
|
|
37
|
+
return;
|
|
38
|
+
if (fileName.includes('].product.js'))
|
|
39
|
+
return;
|
|
40
|
+
productComponents.push(products.ctx(fileName).default);
|
|
41
|
+
});
|
|
42
|
+
react_1.Children.forEach(Object.values(productComponents).map(function (el) { return el({}); }), function (jsx, i) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (!jsx)
|
|
45
|
+
return;
|
|
46
|
+
if (jsx.type.name !== 'ProductLayout')
|
|
47
|
+
return;
|
|
48
|
+
if (!jsx.props.products)
|
|
49
|
+
return;
|
|
50
|
+
var products;
|
|
51
|
+
if (Array.isArray(jsx.props.products))
|
|
52
|
+
products = jsx.props.products.reduce(function (output, id) {
|
|
53
|
+
var _a;
|
|
54
|
+
return Object.assign(output, (_a = {}, _a[id] = id, _a));
|
|
55
|
+
}, {});
|
|
56
|
+
else if (typeof jsx.props.products === 'string') {
|
|
57
|
+
var prdStr = jsx.props.products;
|
|
58
|
+
products = (_a = {}, _a[prdStr] = prdStr, _a);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
products = jsx.props.products;
|
|
62
|
+
}
|
|
63
|
+
Object.entries(products).forEach(function (_a) {
|
|
64
|
+
var key = _a[0], assetId = _a[1];
|
|
65
|
+
productAssetId[key] = assetId;
|
|
66
|
+
productToComponentMap[key] = i;
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
var Product = productComponents[productToComponentMap[props.productId]];
|
|
71
|
+
if (!Product)
|
|
72
|
+
return null;
|
|
73
|
+
var assetId = productAssetId[props.productId];
|
|
74
|
+
var env = threekitEnv || 'preview';
|
|
75
|
+
var preppedCredentials = Object.assign({}, credentials);
|
|
76
|
+
preppedCredentials[env] = Object.assign(preppedCredentials[env], {
|
|
77
|
+
assetId: assetId,
|
|
78
|
+
});
|
|
79
|
+
return (react_1.default.createElement(ThreekitProvider_1.default, { credentials: preppedCredentials, playerConfig: Object.assign({}, playerConfig), theme: theme },
|
|
80
|
+
react_1.default.createElement(Product, null)));
|
|
81
|
+
}
|
|
82
|
+
exports.default = ProductLoader;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,4 +37,6 @@ import Wishlist from './components/Wishlist';
|
|
|
37
37
|
import Share from './components/Share';
|
|
38
38
|
import icons from './icons';
|
|
39
39
|
export * from './icons';
|
|
40
|
-
|
|
40
|
+
import ProductLoader from './components/ProductLoader';
|
|
41
|
+
import ProductLayout from './components/ProductLayout';
|
|
42
|
+
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, ProductLoader, ProductLayout, };
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurator = exports.useAttribute = void 0;
|
|
16
|
+
exports.ProductLayout = exports.ProductLoader = exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurator = exports.useAttribute = void 0;
|
|
17
17
|
// Hooks
|
|
18
18
|
var useAttribute_1 = __importDefault(require("./hooks/useAttribute"));
|
|
19
19
|
exports.useAttribute = useAttribute_1.default;
|
|
@@ -101,3 +101,8 @@ exports.Share = Share_1.default;
|
|
|
101
101
|
var icons_1 = __importDefault(require("./icons"));
|
|
102
102
|
exports.icons = icons_1.default;
|
|
103
103
|
__exportStar(require("./icons"), exports);
|
|
104
|
+
// Products - Multi-configurtors
|
|
105
|
+
var ProductLoader_1 = __importDefault(require("./components/ProductLoader"));
|
|
106
|
+
exports.ProductLoader = ProductLoader_1.default;
|
|
107
|
+
var ProductLayout_1 = __importDefault(require("./components/ProductLayout"));
|
|
108
|
+
exports.ProductLayout = ProductLayout_1.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threekit-tools/treble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"author": "Amaan Saeed",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"@types/react-dom": ">=17.0.9",
|
|
45
45
|
"@types/redux-logger": "^3.0.9",
|
|
46
46
|
"@types/styled-components": "^5.1.15",
|
|
47
|
+
"@types/webpack-env": "^1.16.3",
|
|
47
48
|
"babel-loader": "^8.2.2",
|
|
48
49
|
"react": ">=17.0.2",
|
|
49
50
|
"react-dom": ">=17.0.2",
|
package/tailwind-presets.js
CHANGED