@threekit-tools/treble 0.0.60 → 0.0.63
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/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +7 -2
- package/dist/components/Switch/index.d.ts +66 -0
- package/dist/components/Switch/index.js +86 -0
- package/dist/components/Switch/switch.styles.d.ts +4 -0
- package/dist/components/Switch/switch.styles.js +16 -0
- package/dist/components/TextInput/index.js +2 -0
- package/dist/components/ThreekitProvider/index.d.ts +1 -0
- package/dist/components/ThreekitProvider/index.js +10 -3
- package/dist/components/TrebleApp/index.d.ts +1 -0
- package/dist/components/TrebleApp/index.js +16 -6
- package/dist/components/Upload/index.js +5 -4
- package/dist/components/UploadArea/index.js +4 -3
- package/dist/components/Wishlist/index.js +6 -11
- package/dist/components/containers/formInputContainer.d.ts +4 -4
- package/dist/components/containers/formInputContainer.js +4 -4
- package/dist/components/formComponents.js +5 -1
- package/dist/hooks/useAttribute/index.js +5 -2
- package/dist/hooks/useConfigurator/index.js +7 -3
- package/dist/hooks/useNestedConfigurator/index.d.ts +8 -0
- package/dist/hooks/useNestedConfigurator/index.js +93 -0
- package/dist/hooks/useProductCache/index.d.ts +13 -5
- package/dist/hooks/useProductCache/index.js +16 -23
- package/dist/hooks/useWishlist/index.d.ts +8 -6
- package/dist/hooks/useWishlist/index.js +16 -22
- package/dist/index.d.ts +4 -1
- package/dist/index.js +7 -2
- package/dist/store/attributes.d.ts +3 -3
- package/dist/store/attributes.js +3 -50
- package/dist/store/product.d.ts +22 -13
- package/dist/store/product.js +98 -54
- package/dist/store/translations.d.ts +4 -3
- package/dist/store/translations.js +4 -14
- package/dist/store/treble.d.ts +4 -0
- package/dist/store/treble.js +69 -30
- package/dist/threekit.d.ts +9 -5
- package/dist/utils.d.ts +7 -1
- package/dist/utils.js +53 -1
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var react_1 = require("react");
|
|
40
|
+
var store_1 = require("../../store");
|
|
41
|
+
var treble_1 = require("../../store/treble");
|
|
42
|
+
var utils_1 = require("../../utils");
|
|
43
|
+
var attributes_1 = require("../../store/attributes");
|
|
44
|
+
var useNestedConfigurator = function (address) {
|
|
45
|
+
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
46
|
+
var hasInitialized = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
|
|
47
|
+
var playerLoading = (0, store_1.useThreekitSelector)(treble_1.isPlayerLoading);
|
|
48
|
+
var _a = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), _ = _a[0], translations = _a[1], language = _a[2];
|
|
49
|
+
var _b = (0, react_1.useState)(), attributes = _b[0], setAttributes = _b[1];
|
|
50
|
+
var configurator = (0, react_1.useRef)();
|
|
51
|
+
(0, react_1.useEffect)(function () {
|
|
52
|
+
(function () {
|
|
53
|
+
var _a;
|
|
54
|
+
if (!hasInitialized)
|
|
55
|
+
return;
|
|
56
|
+
if (playerLoading)
|
|
57
|
+
return;
|
|
58
|
+
configurator.current =
|
|
59
|
+
window.threekit.treble.getNestedConfigurator(address);
|
|
60
|
+
if (!configurator.current)
|
|
61
|
+
return;
|
|
62
|
+
var updatedAttrs = (_a = configurator.current) === null || _a === void 0 ? void 0 : _a.getDisplayAttributes();
|
|
63
|
+
setAttributes(updatedAttrs);
|
|
64
|
+
})();
|
|
65
|
+
}, [hasInitialized, address, playerLoading]);
|
|
66
|
+
if (!hasInitialized || !configurator.current || !attributes)
|
|
67
|
+
return [undefined, undefined];
|
|
68
|
+
var handleSelect = function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var updatedAttrs;
|
|
70
|
+
var _a, _b;
|
|
71
|
+
return __generator(this, function (_c) {
|
|
72
|
+
switch (_c.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
dispatch((0, treble_1.setPlayerLoading)(true));
|
|
75
|
+
return [4 /*yield*/, ((_a = configurator.current) === null || _a === void 0 ? void 0 : _a.setConfiguration(config))];
|
|
76
|
+
case 1:
|
|
77
|
+
_c.sent();
|
|
78
|
+
dispatch((0, treble_1.setPlayerLoading)(false));
|
|
79
|
+
updatedAttrs = (_b = configurator.current) === null || _b === void 0 ? void 0 : _b.getDisplayAttributes();
|
|
80
|
+
if (updatedAttrs)
|
|
81
|
+
setAttributes(updatedAttrs);
|
|
82
|
+
return [2 /*return*/];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}); };
|
|
86
|
+
var attributeObj = attributes.reduce(function (output, attr) {
|
|
87
|
+
var _a;
|
|
88
|
+
return Object.assign(output, (_a = {}, _a[attr.name] = attr, _a));
|
|
89
|
+
}, {});
|
|
90
|
+
var preppedAttributes = (0, utils_1.hydrateAttribute)([attributeObj, translations, language], handleSelect);
|
|
91
|
+
return [preppedAttributes, handleSelect];
|
|
92
|
+
};
|
|
93
|
+
exports.default = useNestedConfigurator;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { CachedProduct } from '../../store/product';
|
|
2
2
|
import { IReloadConfig } from '../../store/treble';
|
|
3
|
+
interface HydratedCacheProduct extends Pick<CachedProduct, 'name' | 'label' | 'thumbnail'> {
|
|
4
|
+
selected: boolean;
|
|
5
|
+
handleSelect: () => Promise<void>;
|
|
6
|
+
handleRemove: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
interface ISelectableProduct {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
handleSelect: () => void;
|
|
12
|
+
}
|
|
3
13
|
interface CacheData {
|
|
4
|
-
|
|
5
|
-
|
|
14
|
+
cache: Array<HydratedCacheProduct>;
|
|
15
|
+
products: Array<ISelectableProduct>;
|
|
6
16
|
}
|
|
7
17
|
declare type UseProductCache = [
|
|
8
18
|
CacheData,
|
|
9
|
-
(config?: string | IReloadConfig) => Promise<void
|
|
10
|
-
(idx: number) => Promise<void>,
|
|
11
|
-
(idx: number) => Promise<void>
|
|
19
|
+
(config?: string | IReloadConfig) => Promise<void>
|
|
12
20
|
];
|
|
13
21
|
declare const useProductCache: () => UseProductCache;
|
|
14
22
|
export default useProductCache;
|
|
@@ -5,31 +5,24 @@ var store_1 = require("../../store");
|
|
|
5
5
|
var useProductCache = function () {
|
|
6
6
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
7
|
var cache = (0, store_1.useThreekitSelector)(product_1.getProductCache);
|
|
8
|
-
var activeProductIdx = (0, store_1.useThreekitSelector)(product_1.
|
|
9
|
-
var data = {
|
|
10
|
-
cache: cache,
|
|
11
|
-
activeProductIdx: activeProductIdx,
|
|
12
|
-
};
|
|
13
|
-
var handleChangeActiveProduct = function (idx) {
|
|
14
|
-
if (idx === undefined)
|
|
15
|
-
return Promise.resolve();
|
|
16
|
-
if (idx === activeProductIdx)
|
|
17
|
-
return Promise.resolve();
|
|
18
|
-
if (!cache || idx >= (cache === null || cache === void 0 ? void 0 : cache.length))
|
|
19
|
-
return Promise.resolve();
|
|
20
|
-
return dispatch((0, product_1.changeActiveProductIdx)(idx));
|
|
21
|
-
};
|
|
8
|
+
var activeProductIdx = (0, store_1.useThreekitSelector)(product_1.getActiveCacheIdx);
|
|
22
9
|
var handleLoadNewProduct = function (config) {
|
|
23
10
|
return dispatch((0, product_1.loadNewProduct)(config));
|
|
24
11
|
};
|
|
25
|
-
var
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
12
|
+
var hydratedCache = cache.map(function (el, i) {
|
|
13
|
+
return Object.assign({}, el, {
|
|
14
|
+
selected: activeProductIdx === i,
|
|
15
|
+
handleRemove: function () { return dispatch((0, product_1.removeProductIdx)(i)); },
|
|
16
|
+
handleSelect: activeProductIdx === i
|
|
17
|
+
? function () { return Promise.resolve(); }
|
|
18
|
+
: function () { return dispatch((0, product_1.changeActiveCacheIdx)(i)); },
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
var products = Object.keys(product_1.PRODUCTS).map(function (prod) { return ({
|
|
22
|
+
id: prod,
|
|
23
|
+
label: prod,
|
|
24
|
+
handleSelect: function () { return dispatch((0, product_1.loadProduct)(prod)); },
|
|
25
|
+
}); });
|
|
26
|
+
return [{ cache: hydratedCache, products: products }, handleLoadNewProduct];
|
|
34
27
|
};
|
|
35
28
|
exports.default = useProductCache;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IConfigurationResponse } from '../../http/configurations';
|
|
2
2
|
import { ISaveConfiguration } from '../../api/configurations';
|
|
3
|
+
interface HydratedWishlistItem extends IConfigurationResponse {
|
|
4
|
+
handleSelect: () => void;
|
|
5
|
+
handleRemove: () => void;
|
|
6
|
+
handleShare: () => void;
|
|
7
|
+
}
|
|
3
8
|
declare type UseWishlistHook = [
|
|
4
|
-
|
|
9
|
+
Array<HydratedWishlistItem>,
|
|
5
10
|
(config?: Omit<ISaveConfiguration, 'configurator'>) => void,
|
|
6
|
-
(idx: number) => void,
|
|
7
|
-
(idx: number) => void,
|
|
8
|
-
(idx: number) => void,
|
|
9
11
|
() => void
|
|
10
|
-
] | [undefined, undefined, undefined
|
|
12
|
+
] | [undefined, undefined, undefined];
|
|
11
13
|
declare const useWishlist: () => UseWishlistHook;
|
|
12
14
|
export default useWishlist;
|
|
@@ -11,32 +11,26 @@ var message_1 = __importDefault(require("../../components/message"));
|
|
|
11
11
|
var useWishlist = function () {
|
|
12
12
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
13
13
|
var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
|
|
14
|
-
var
|
|
14
|
+
var wishlistData = (0, store_1.useThreekitSelector)(wishlist_1.getWishlist);
|
|
15
15
|
if (!isLoaded)
|
|
16
|
-
return [undefined, undefined, undefined
|
|
16
|
+
return [undefined, undefined, undefined];
|
|
17
17
|
var handleAddToWishlist = function (config) { return dispatch((0, wishlist_1.addToWishlist)(config)); };
|
|
18
|
-
var handleRemoveFromWishlist = function (idx) {
|
|
19
|
-
dispatch((0, wishlist_1.removeFromWishlist)(idx));
|
|
20
|
-
message_1.default.info('Item removed from wishlist');
|
|
21
|
-
};
|
|
22
|
-
var handleResumeItem = function (idx) {
|
|
23
|
-
dispatch((0, wishlist_1.resumeFromWishlist)(idx));
|
|
24
|
-
};
|
|
25
|
-
var handleShareItem = function (idx) {
|
|
26
|
-
var url = (0, utils_1.getResumableUrl)(wishlist[idx].shortId);
|
|
27
|
-
(0, utils_1.copyToClipboard)(url);
|
|
28
|
-
message_1.default.info('Link copied!');
|
|
29
|
-
};
|
|
30
18
|
var handleClearWishlist = function () {
|
|
31
19
|
dispatch(wishlist_1.clearWishlist);
|
|
32
20
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
var wishlist = wishlistData.map(function (el, i) {
|
|
22
|
+
return Object.assign({}, el, {
|
|
23
|
+
handleSelect: function () { return dispatch((0, wishlist_1.resumeFromWishlist)(i)); },
|
|
24
|
+
handleRemove: function () {
|
|
25
|
+
dispatch((0, wishlist_1.removeFromWishlist)(i));
|
|
26
|
+
message_1.default.info('Item removed from wishlist');
|
|
27
|
+
},
|
|
28
|
+
handleShare: function () {
|
|
29
|
+
(0, utils_1.copyToClipboard)((0, utils_1.getResumableUrl)(el.shortId));
|
|
30
|
+
message_1.default.info('Link copied!');
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return [wishlist, handleAddToWishlist, handleClearWishlist];
|
|
41
35
|
};
|
|
42
36
|
exports.default = useWishlist;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ import useSnapshot from './hooks/useSnapshot';
|
|
|
10
10
|
import useWishlist from './hooks/useWishlist';
|
|
11
11
|
import useShare from './hooks/useShare';
|
|
12
12
|
import usePlayerPortal from './hooks/usePlayerPortal';
|
|
13
|
+
import useProductCache from './hooks/useProductCache';
|
|
14
|
+
import useNestedConfigurator from './hooks/useNestedConfigurator';
|
|
13
15
|
import ThreekitProvider from './components/ThreekitProvider';
|
|
14
16
|
import Player from './components/Player';
|
|
15
17
|
import Button from './components/Button';
|
|
@@ -20,6 +22,7 @@ import Swatch from './components/Swatch';
|
|
|
20
22
|
import Tiles from './components/Tiles';
|
|
21
23
|
import TilesGroup from './components/TilesGroup';
|
|
22
24
|
import Upload from './components/Upload';
|
|
25
|
+
import Switch from './components/Switch';
|
|
23
26
|
import ProductName from './components/ProductName';
|
|
24
27
|
import ProductDescription from './components/ProductDescription';
|
|
25
28
|
import AttributeTitle from './components/AttributeTitle';
|
|
@@ -41,4 +44,4 @@ import icons from './icons';
|
|
|
41
44
|
export * from './icons';
|
|
42
45
|
import TrebleApp from './components/TrebleApp';
|
|
43
46
|
import ProductLayout from './components/ProductLayout';
|
|
44
|
-
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
|
|
47
|
+
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, useNestedConfigurator, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, Switch, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, 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.ProductLayout = exports.TrebleApp = 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.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.usePlayerPortal = 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.TrebleApp = 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.Switch = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.useNestedConfigurator = exports.useProductCache = exports.usePlayerPortal = 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;
|
|
@@ -40,7 +40,10 @@ exports.useShare = useShare_1.default;
|
|
|
40
40
|
var usePlayerPortal_1 = __importDefault(require("./hooks/usePlayerPortal"));
|
|
41
41
|
exports.usePlayerPortal = usePlayerPortal_1.default;
|
|
42
42
|
// import useSingleAnimation from './hooks/useSingleAnimation';
|
|
43
|
-
|
|
43
|
+
var useProductCache_1 = __importDefault(require("./hooks/useProductCache"));
|
|
44
|
+
exports.useProductCache = useProductCache_1.default;
|
|
45
|
+
var useNestedConfigurator_1 = __importDefault(require("./hooks/useNestedConfigurator"));
|
|
46
|
+
exports.useNestedConfigurator = useNestedConfigurator_1.default;
|
|
44
47
|
// Components
|
|
45
48
|
var ThreekitProvider_1 = __importDefault(require("./components/ThreekitProvider"));
|
|
46
49
|
exports.ThreekitProvider = ThreekitProvider_1.default;
|
|
@@ -63,6 +66,8 @@ var TilesGroup_1 = __importDefault(require("./components/TilesGroup"));
|
|
|
63
66
|
exports.TilesGroup = TilesGroup_1.default;
|
|
64
67
|
var Upload_1 = __importDefault(require("./components/Upload"));
|
|
65
68
|
exports.Upload = Upload_1.default;
|
|
69
|
+
var Switch_1 = __importDefault(require("./components/Switch"));
|
|
70
|
+
exports.Switch = Switch_1.default;
|
|
66
71
|
// Display
|
|
67
72
|
var ProductName_1 = __importDefault(require("./components/ProductName"));
|
|
68
73
|
exports.ProductName = ProductName_1.default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import { ISetConfiguration, IThreekitDisplayAttribute
|
|
2
|
+
import { ISetConfiguration, IThreekitDisplayAttribute } from '../threekit';
|
|
3
3
|
import { ITranslationMap } from '../api/products';
|
|
4
4
|
/*****************************************************
|
|
5
5
|
* Types and Interfaces
|
|
@@ -17,14 +17,14 @@ declare const reducer: import("redux").Reducer<AttributesState, import("redux").
|
|
|
17
17
|
* Standard Selectors
|
|
18
18
|
****************************************************/
|
|
19
19
|
export declare const getAttributes: (state: RootState) => AttributesState;
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const getHydrationData: ((state: {
|
|
21
21
|
treble: import("./treble").TrebleState;
|
|
22
22
|
product: import("./product").ProductState;
|
|
23
23
|
attributes: AttributesState;
|
|
24
24
|
translations: import("./translations").TranslationsState;
|
|
25
25
|
wishlist: import("../Treble").WishlistArray;
|
|
26
26
|
price: import("./price").PriceState;
|
|
27
|
-
}) => Record<string,
|
|
27
|
+
}) => [Record<string, IThreekitDisplayAttribute>, ITranslationMap | undefined, string | undefined]) & import("reselect").OutputSelectorFields<(args_0: AttributesState, args_1: string | undefined) => [Record<string, IThreekitDisplayAttribute>, ITranslationMap | undefined, string | undefined] & {
|
|
28
28
|
clearCache: () => void;
|
|
29
29
|
}> & {
|
|
30
30
|
clearCache: () => void;
|
package/dist/store/attributes.js
CHANGED
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.setConfiguration = exports.
|
|
39
|
+
exports.setConfiguration = exports.getHydrationData = exports.getAttributes = exports.setAttributes = void 0;
|
|
40
40
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
41
41
|
var treble_1 = require("./treble");
|
|
42
42
|
var translations_1 = require("./translations");
|
|
@@ -79,55 +79,8 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
79
79
|
****************************************************/
|
|
80
80
|
var getAttributes = function (state) { return state.attributes; };
|
|
81
81
|
exports.getAttributes = getAttributes;
|
|
82
|
-
exports.
|
|
83
|
-
|
|
84
|
-
return Object.values(attributes).reduce(function (output, attribute) {
|
|
85
|
-
var _a;
|
|
86
|
-
var _b;
|
|
87
|
-
return Object.assign(output, (_a = {},
|
|
88
|
-
_a[attribute.name] = Object.assign({}, attribute, {
|
|
89
|
-
label: hasTranslation
|
|
90
|
-
? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
|
|
91
|
-
: attribute.name,
|
|
92
|
-
}, attribute.type === 'String'
|
|
93
|
-
? {
|
|
94
|
-
values: attribute.values.map(function (el) {
|
|
95
|
-
var _a;
|
|
96
|
-
return Object.assign({}, el, {
|
|
97
|
-
label: hasTranslation
|
|
98
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
99
|
-
: el.label,
|
|
100
|
-
handleSelect: function () {
|
|
101
|
-
var _a;
|
|
102
|
-
return window.threekit.configurator.setConfiguration((_a = {},
|
|
103
|
-
_a[attribute.name] = el.value,
|
|
104
|
-
_a));
|
|
105
|
-
},
|
|
106
|
-
selected: attribute.value === el.value,
|
|
107
|
-
});
|
|
108
|
-
}),
|
|
109
|
-
}
|
|
110
|
-
: attribute.type === 'Asset'
|
|
111
|
-
? {
|
|
112
|
-
values: attribute.values.map(function (el) {
|
|
113
|
-
var _a;
|
|
114
|
-
return Object.assign({}, el, {
|
|
115
|
-
label: hasTranslation
|
|
116
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
117
|
-
: el.name,
|
|
118
|
-
handleSelect: function () {
|
|
119
|
-
var _a;
|
|
120
|
-
return window.threekit.configurator.setConfiguration((_a = {},
|
|
121
|
-
_a[attribute.name] = el.assetId,
|
|
122
|
-
_a));
|
|
123
|
-
},
|
|
124
|
-
selected: attribute.value.assetId === el.assetId,
|
|
125
|
-
});
|
|
126
|
-
}),
|
|
127
|
-
}
|
|
128
|
-
: undefined),
|
|
129
|
-
_a));
|
|
130
|
-
}, {});
|
|
82
|
+
exports.getHydrationData = (0, toolkit_1.createSelector)(exports.getAttributes, translations_1.getLanguage, function (attributes, language) {
|
|
83
|
+
return [attributes, translations_1.TRANSLATIONS, language];
|
|
131
84
|
});
|
|
132
85
|
// Configurator
|
|
133
86
|
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
package/dist/store/product.d.ts
CHANGED
|
@@ -1,58 +1,67 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import { IMetadata, IConfiguration,
|
|
2
|
+
import { IMetadata, IConfiguration, IProduct } from '../threekit';
|
|
3
3
|
import { IConnectionConfig } from '../connection';
|
|
4
4
|
import { IReloadConfig } from './treble';
|
|
5
5
|
/*****************************************************
|
|
6
6
|
* Types and Interfaces
|
|
7
7
|
****************************************************/
|
|
8
8
|
export interface CachedProduct {
|
|
9
|
+
id: undefined | string;
|
|
9
10
|
name?: string;
|
|
10
11
|
label?: string;
|
|
11
12
|
thumbnail?: string;
|
|
12
13
|
connection: IConnectionConfig;
|
|
13
14
|
configuration: IConfiguration;
|
|
14
15
|
}
|
|
15
|
-
export interface CachedProductState extends Pick<CachedProduct, 'name' | 'label' | 'thumbnail'> {
|
|
16
|
+
export interface CachedProductState extends Pick<CachedProduct, 'id' | 'name' | 'label' | 'thumbnail'> {
|
|
16
17
|
data: string;
|
|
17
18
|
}
|
|
19
|
+
interface IEnvConfig extends Record<string, Partial<IProduct>> {
|
|
20
|
+
}
|
|
21
|
+
export interface IHydratedProducts extends Record<string, IEnvConfig> {
|
|
22
|
+
}
|
|
18
23
|
export interface ProductState {
|
|
24
|
+
id: undefined | string;
|
|
19
25
|
name: undefined | string;
|
|
20
26
|
metadata: undefined | IMetadata;
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
cache: Array<CachedProductState>;
|
|
28
|
+
activeCacheIdx: number;
|
|
23
29
|
}
|
|
24
30
|
/*****************************************************
|
|
25
31
|
* Constants
|
|
26
32
|
****************************************************/
|
|
27
|
-
export declare let PRODUCTS:
|
|
33
|
+
export declare let PRODUCTS: IHydratedProducts;
|
|
28
34
|
/*****************************************************
|
|
29
35
|
* Actions
|
|
30
36
|
****************************************************/
|
|
37
|
+
export declare const setProductId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>;
|
|
31
38
|
export declare const setName: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
32
39
|
export declare const setMetadata: import("@reduxjs/toolkit").ActionCreatorWithPayload<IMetadata, string>;
|
|
33
|
-
export declare const
|
|
40
|
+
export declare const appendToCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
34
41
|
export declare const updateActiveProductCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
35
|
-
export declare const
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const
|
|
38
|
-
export declare const
|
|
42
|
+
export declare const removeFromCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
43
|
+
export declare const setActiveCacheIdx: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
44
|
+
export declare const incrementActiveCacheIdx: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<undefined, string>;
|
|
45
|
+
export declare const decrementActiveCacheIdx: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<undefined, string>;
|
|
39
46
|
declare const reducer: import("redux").Reducer<ProductState, import("redux").AnyAction>;
|
|
40
47
|
/*****************************************************
|
|
41
48
|
* Standard Selectors
|
|
42
49
|
****************************************************/
|
|
50
|
+
export declare const getProductId: (state: RootState) => undefined | string;
|
|
43
51
|
export declare const getName: (state: RootState) => undefined | string;
|
|
44
52
|
export declare const getMetadata: (state: RootState) => undefined | IMetadata;
|
|
45
|
-
export declare const
|
|
53
|
+
export declare const getActiveCacheIdx: (state: RootState) => number;
|
|
46
54
|
export declare const getProductCache: (state: RootState) => Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
47
55
|
/*****************************************************
|
|
48
56
|
* Complex Actions
|
|
49
57
|
****************************************************/
|
|
50
|
-
export declare const initProduct: (prods?:
|
|
58
|
+
export declare const initProduct: (prods?: IHydratedProducts | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
51
59
|
export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, "label" | "thumbnail"> | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => {
|
|
52
60
|
payload: CachedProductState;
|
|
53
61
|
type: string;
|
|
54
62
|
};
|
|
63
|
+
export declare const loadProduct: (id: string) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
55
64
|
export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
56
|
-
export declare const
|
|
65
|
+
export declare const changeActiveCacheIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
57
66
|
export declare const removeProductIdx: (idx?: number | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
58
67
|
export default reducer;
|