@threekit-tools/treble 0.0.57-animation → 0.0.59
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/Snapshots.js +32 -63
- package/dist/Treble/Treble.d.ts +8 -6
- package/dist/Treble/Treble.js +19 -4
- package/dist/Treble/Wishlist.d.ts +3 -3
- package/dist/Treble/Wishlist.js +1 -0
- package/dist/api/configurations.d.ts +2 -3
- package/dist/api/configurations.js +28 -22
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/server.d.ts +2 -0
- package/dist/api/server.js +11 -0
- package/dist/components/Cards/index.js +3 -4
- package/dist/components/Dropdown/index.js +6 -10
- package/dist/components/Strips/index.js +3 -4
- package/dist/components/Swatch/index.js +3 -4
- package/dist/components/TextInput/index.d.ts +1 -0
- package/dist/components/TextInput/index.js +2 -2
- package/dist/components/TextInput/textInput.styles.js +1 -1
- package/dist/components/Tiles/index.js +3 -4
- package/dist/components/TilesGroup/index.js +3 -4
- package/dist/components/containers/formInputContainer.d.ts +8 -4
- package/dist/components/containers/formInputContainer.js +10 -15
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +4 -0
- package/dist/hooks/useAttribute/index.d.ts +2 -2
- package/dist/hooks/useAttribute/index.js +2 -4
- package/dist/hooks/useConfigurator/index.d.ts +2 -2
- package/dist/hooks/useConfigurator/index.js +1 -1
- package/dist/hooks/useProductCache/index.d.ts +14 -0
- package/dist/hooks/useProductCache/index.js +35 -0
- package/dist/hooks/useWishlist/index.d.ts +3 -2
- package/dist/hooks/useWishlist/index.js +1 -3
- package/dist/http/configurations.d.ts +1 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/http/server.d.ts +14 -0
- package/dist/http/server.js +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/store/attributes.d.ts +15 -2
- package/dist/store/attributes.js +20 -12
- package/dist/store/price.js +2 -2
- package/dist/store/product.d.ts +38 -2
- package/dist/store/product.js +221 -10
- package/dist/store/translations.d.ts +1 -0
- package/dist/store/translations.js +3 -1
- package/dist/store/treble.d.ts +32 -2
- package/dist/store/treble.js +157 -34
- package/dist/store/wishlist.d.ts +3 -2
- package/dist/threekit.d.ts +16 -1
- package/dist/utils.d.ts +1 -9
- package/dist/utils.js +58 -54
- package/package.json +1 -1
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
|
@@ -29,15 +29,13 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
29
29
|
var descriptionKey = metadataKeyDescription || constants_1.METADATA_RESERVED.description;
|
|
30
30
|
var options;
|
|
31
31
|
var selected = attribute.value;
|
|
32
|
-
if (attribute.type ===
|
|
33
|
-
|
|
34
|
-
options = stringAttribute.values.map(function (el) { return (__assign(__assign({}, el), { name: el.label })); });
|
|
32
|
+
if (attribute.type === 'String') {
|
|
33
|
+
options = attribute.values.map(function (el) { return (__assign(__assign({}, el), { name: el.label })); });
|
|
35
34
|
}
|
|
36
|
-
else if (attribute.type ===
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? assetAttribute.values
|
|
35
|
+
else if (attribute.type === 'Asset') {
|
|
36
|
+
selected = (_a = attribute.value) === null || _a === void 0 ? void 0 : _a.assetId;
|
|
37
|
+
options = attribute.values
|
|
38
|
+
? attribute.values
|
|
41
39
|
.map(function (el) { return prepCatalogItem(el); })
|
|
42
40
|
.sort(function (a, b) {
|
|
43
41
|
if (!sort || !Object.keys(constants_1.SORT_OPTIONS).includes(sort))
|
|
@@ -50,9 +48,8 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
50
48
|
})
|
|
51
49
|
: [];
|
|
52
50
|
}
|
|
53
|
-
else if (attribute.type ===
|
|
54
|
-
|
|
55
|
-
selected = (0, utils_1.inflateRgb)(colorAttribute.value);
|
|
51
|
+
else if (attribute.type === 'Color') {
|
|
52
|
+
selected = (0, utils_1.inflateRgb)(attribute.value);
|
|
56
53
|
}
|
|
57
54
|
function prepCatalogItem(item) {
|
|
58
55
|
var _a, _b;
|
|
@@ -80,9 +77,7 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
80
77
|
return { selected: selected, options: options };
|
|
81
78
|
};
|
|
82
79
|
exports.prepAttributeForComponent = prepAttributeForComponent;
|
|
83
|
-
function formComponentContainer(FormComponent
|
|
84
|
-
// FormComponent: IFormComponent<P>
|
|
85
|
-
) {
|
|
80
|
+
function formComponentContainer(FormComponent) {
|
|
86
81
|
return function (props) {
|
|
87
82
|
var attribute = props.attribute, metadataKeyThumbnail = props.metadataKeyThumbnail, metadataKeyDescription = props.metadataKeyDescription, metadataKeyPrice = props.metadataKeyPrice, hideAttributeTitle = props.hideAttributeTitle, sort = props.sort;
|
|
88
83
|
var isLoading = (0, usePlayerLoadingStatus_1.default)();
|
|
@@ -104,7 +99,7 @@ function formComponentContainer(FormComponent
|
|
|
104
99
|
sort: sort,
|
|
105
100
|
}), selected = _b.selected, options = _b.options;
|
|
106
101
|
var handleSetAttribute = function (value) {
|
|
107
|
-
return setAttribute
|
|
102
|
+
return setAttribute === null || setAttribute === void 0 ? void 0 : setAttribute(value);
|
|
108
103
|
};
|
|
109
104
|
var preppedProps = __assign({}, props);
|
|
110
105
|
if (!hideAttributeTitle && !preppedProps.title)
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
interface IConnectionConfig {
|
|
1
|
+
export interface IConnectionConfig {
|
|
2
2
|
authToken?: string;
|
|
3
3
|
orgId?: string;
|
|
4
4
|
assetId?: string;
|
|
5
5
|
threekitDomain?: string;
|
|
6
|
+
serverUrl?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare class ThreekitConnection {
|
|
8
9
|
_authToken: string;
|
|
9
10
|
_orgId: string;
|
|
10
11
|
_assetId: string;
|
|
11
12
|
_threekitDomain: string;
|
|
13
|
+
_serverUrl: string;
|
|
12
14
|
constructor();
|
|
13
15
|
connect(config: IConnectionConfig): Promise<void>;
|
|
14
16
|
getConnection(): {
|
|
@@ -16,6 +18,7 @@ export declare class ThreekitConnection {
|
|
|
16
18
|
orgId: string;
|
|
17
19
|
assetId: string;
|
|
18
20
|
threekitDomain: string;
|
|
21
|
+
serverUrl: string;
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
declare const _default: ThreekitConnection;
|
package/dist/connection.js
CHANGED
|
@@ -42,6 +42,7 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
42
42
|
this._authToken = '';
|
|
43
43
|
this._orgId = '';
|
|
44
44
|
this._assetId = '';
|
|
45
|
+
this._serverUrl = '';
|
|
45
46
|
this._threekitDomain = 'https://admin-fts.threekit.com';
|
|
46
47
|
}
|
|
47
48
|
ThreekitConnection.prototype.connect = function (config) {
|
|
@@ -53,6 +54,8 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
53
54
|
this._orgId = config.orgId;
|
|
54
55
|
if (config.assetId)
|
|
55
56
|
this._assetId = config.assetId;
|
|
57
|
+
if (config.serverUrl)
|
|
58
|
+
this._serverUrl = config.serverUrl;
|
|
56
59
|
if (config.threekitDomain)
|
|
57
60
|
this._threekitDomain = "https://".concat(config.threekitDomain);
|
|
58
61
|
return [2 /*return*/];
|
|
@@ -68,6 +71,7 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
68
71
|
orgId: this._orgId,
|
|
69
72
|
assetId: this._assetId,
|
|
70
73
|
threekitDomain: this._threekitDomain,
|
|
74
|
+
serverUrl: this._serverUrl,
|
|
71
75
|
};
|
|
72
76
|
};
|
|
73
77
|
return ThreekitConnection;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IHydratedAttribute, IConfigurationColor } from '../../threekit';
|
|
2
2
|
export declare type RawAttributeValue = string | number | boolean | IConfigurationColor | File | undefined;
|
|
3
3
|
declare type UseAttributeError = [undefined, undefined];
|
|
4
4
|
declare type UseAttributeSuccess = [
|
|
5
|
-
|
|
5
|
+
IHydratedAttribute,
|
|
6
6
|
(val: RawAttributeValue) => Promise<void>
|
|
7
7
|
];
|
|
8
8
|
declare type UseAttributeHook = UseAttributeError | UseAttributeSuccess;
|
|
@@ -42,13 +42,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
var store_1 = require("../../store");
|
|
43
43
|
var attributes_1 = require("../../store/attributes");
|
|
44
44
|
var utils_1 = require("../../utils");
|
|
45
|
-
var constants_1 = require("../../constants");
|
|
46
45
|
var api_1 = __importDefault(require("../../api"));
|
|
47
46
|
var useAttribute = function (attributeName) {
|
|
48
47
|
if (!attributeName)
|
|
49
48
|
return [undefined, undefined];
|
|
50
49
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
51
|
-
var attributes = (0, store_1.useThreekitSelector)(attributes_1.
|
|
50
|
+
var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
|
|
52
51
|
if (!attributeName || !attributes)
|
|
53
52
|
return [undefined, undefined];
|
|
54
53
|
var attribute = attributes[attributeName];
|
|
@@ -60,8 +59,7 @@ var useAttribute = function (attributeName) {
|
|
|
60
59
|
return __generator(this, function (_b) {
|
|
61
60
|
switch (_b.label) {
|
|
62
61
|
case 0:
|
|
63
|
-
if (!(attribute.type === 'Asset' &&
|
|
64
|
-
attribute.assetType === constants_1.ASSET_TYPES.upload)) return [3 /*break*/, 4];
|
|
62
|
+
if (!(attribute.type === 'Asset' && attribute.assetType === 'upload')) return [3 /*break*/, 4];
|
|
65
63
|
if (!!value) return [3 /*break*/, 1];
|
|
66
64
|
preppedValue = (0, utils_1.selectionToConfiguration)('', attribute.type);
|
|
67
65
|
return [3 /*break*/, 3];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ISetConfiguration,
|
|
1
|
+
import { ISetConfiguration, IHydratedAttribute } from '../../threekit';
|
|
2
2
|
declare type UseConfiguratorError = [undefined, undefined];
|
|
3
3
|
declare type UseConfiguratorSuccess = [
|
|
4
|
-
Record<string,
|
|
4
|
+
Record<string, IHydratedAttribute>,
|
|
5
5
|
(configuration: ISetConfiguration) => void
|
|
6
6
|
];
|
|
7
7
|
declare type UseConfiguratorHook = UseConfiguratorError | UseConfiguratorSuccess;
|
|
@@ -4,7 +4,7 @@ var attributes_1 = require("../../store/attributes");
|
|
|
4
4
|
var store_1 = require("../../store");
|
|
5
5
|
var useConfigurator = function () {
|
|
6
6
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
|
-
var attributes = (0, store_1.useThreekitSelector)(attributes_1.
|
|
7
|
+
var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
|
|
8
8
|
if (!attributes)
|
|
9
9
|
return [undefined, undefined];
|
|
10
10
|
var handleChange = function (configuration) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CachedProduct } from '../../store/product';
|
|
2
|
+
import { IReloadConfig } from '../../store/treble';
|
|
3
|
+
interface CacheData {
|
|
4
|
+
activeProductIdx: number;
|
|
5
|
+
cache: Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
6
|
+
}
|
|
7
|
+
declare type UseProductCache = [
|
|
8
|
+
CacheData,
|
|
9
|
+
(config?: string | IReloadConfig) => Promise<void>,
|
|
10
|
+
(idx: number) => Promise<void>,
|
|
11
|
+
(idx: number) => Promise<void>
|
|
12
|
+
];
|
|
13
|
+
declare const useProductCache: () => UseProductCache;
|
|
14
|
+
export default useProductCache;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var product_1 = require("../../store/product");
|
|
4
|
+
var store_1 = require("../../store");
|
|
5
|
+
var useProductCache = function () {
|
|
6
|
+
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
|
+
var cache = (0, store_1.useThreekitSelector)(product_1.getProductCache);
|
|
8
|
+
var activeProductIdx = (0, store_1.useThreekitSelector)(product_1.getActiveProductIdx);
|
|
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
|
+
};
|
|
22
|
+
var handleLoadNewProduct = function (config) {
|
|
23
|
+
return dispatch((0, product_1.loadNewProduct)(config));
|
|
24
|
+
};
|
|
25
|
+
var handleRemoveProduct = function (idx) {
|
|
26
|
+
return dispatch((0, product_1.removeProductIdx)(idx));
|
|
27
|
+
};
|
|
28
|
+
return [
|
|
29
|
+
data,
|
|
30
|
+
handleLoadNewProduct,
|
|
31
|
+
handleChangeActiveProduct,
|
|
32
|
+
handleRemoveProduct,
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
exports.default = useProductCache;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WishlistArray } from '../../Treble';
|
|
2
|
+
import { ISaveConfiguration } from '../../api/configurations';
|
|
2
3
|
declare type UseWishlistHook = [
|
|
3
4
|
WishlistArray,
|
|
4
|
-
(config?:
|
|
5
|
+
(config?: Omit<ISaveConfiguration, 'configurator'>) => void,
|
|
5
6
|
(idx: number) => void,
|
|
6
7
|
(idx: number) => void,
|
|
7
8
|
(idx: number) => void,
|
|
@@ -14,9 +14,7 @@ var useWishlist = function () {
|
|
|
14
14
|
var wishlist = (0, store_1.useThreekitSelector)(wishlist_1.getWishlist);
|
|
15
15
|
if (!isLoaded)
|
|
16
16
|
return [undefined, undefined, undefined, undefined, undefined, undefined];
|
|
17
|
-
var handleAddToWishlist = function (config) {
|
|
18
|
-
return dispatch((0, wishlist_1.addToWishlist)(config));
|
|
19
|
-
};
|
|
17
|
+
var handleAddToWishlist = function (config) { return dispatch((0, wishlist_1.addToWishlist)(config)); };
|
|
20
18
|
var handleRemoveFromWishlist = function (idx) {
|
|
21
19
|
dispatch((0, wishlist_1.removeFromWishlist)(idx));
|
|
22
20
|
message_1.default.info('Item removed from wishlist');
|
|
@@ -13,6 +13,7 @@ export interface IConfigurationResponse {
|
|
|
13
13
|
shortId: string;
|
|
14
14
|
thumbnail: null | string;
|
|
15
15
|
variant: IConfiguration;
|
|
16
|
+
attachments: Record<string, string>;
|
|
16
17
|
}
|
|
17
18
|
interface IConfigurationsResponse extends IMultiPageResponse {
|
|
18
19
|
configurations: Array<IConfigurationResponse>;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import * as products from './products';
|
|
|
3
3
|
import * as configurations from './configurations';
|
|
4
4
|
import * as pricebook from './pricebook';
|
|
5
5
|
import * as catalog from './catalog';
|
|
6
|
+
import * as server from './server';
|
|
6
7
|
declare const _default: {
|
|
7
8
|
orders: typeof orders;
|
|
8
9
|
products: typeof products;
|
|
9
10
|
configurations: typeof configurations;
|
|
10
11
|
pricebook: typeof pricebook;
|
|
11
12
|
catalog: typeof catalog;
|
|
13
|
+
server: typeof server;
|
|
12
14
|
};
|
|
13
15
|
export default _default;
|
package/dist/http/index.js
CHANGED
|
@@ -24,10 +24,12 @@ var products = __importStar(require("./products"));
|
|
|
24
24
|
var configurations = __importStar(require("./configurations"));
|
|
25
25
|
var pricebook = __importStar(require("./pricebook"));
|
|
26
26
|
var catalog = __importStar(require("./catalog"));
|
|
27
|
+
var server = __importStar(require("./server"));
|
|
27
28
|
exports.default = {
|
|
28
29
|
orders: orders,
|
|
29
30
|
products: products,
|
|
30
31
|
configurations: configurations,
|
|
31
32
|
pricebook: pricebook,
|
|
32
33
|
catalog: catalog,
|
|
34
|
+
server: server,
|
|
33
35
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IPostEmailRequest {
|
|
2
|
+
From: string;
|
|
3
|
+
To: string;
|
|
4
|
+
TemplateId: string;
|
|
5
|
+
TemplateModel: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface IPostEmailResponse {
|
|
8
|
+
To: string;
|
|
9
|
+
SubmittedAt: string;
|
|
10
|
+
MessageID: string;
|
|
11
|
+
ErrorCode: 0;
|
|
12
|
+
Message: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const postEmail: (data: IPostEmailRequest) => Promise<IPostEmailResponse>;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
exports.postEmail = void 0;
|
|
7
|
+
var axios_1 = __importDefault(require("axios"));
|
|
8
|
+
var connection_1 = __importDefault(require("../connection"));
|
|
9
|
+
var postEmail = function (data) {
|
|
10
|
+
if (!data)
|
|
11
|
+
throw new Error('data missing');
|
|
12
|
+
var serverUrl = connection_1.default.getConnection().serverUrl;
|
|
13
|
+
if (!serverUrl)
|
|
14
|
+
throw new Error('missing server-url');
|
|
15
|
+
return axios_1.default.post("".concat(serverUrl, "/api/email"), data);
|
|
16
|
+
};
|
|
17
|
+
exports.postEmail = postEmail;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ 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';
|
|
13
14
|
import ThreekitProvider from './components/ThreekitProvider';
|
|
14
15
|
import Player from './components/Player';
|
|
15
16
|
import Button from './components/Button';
|
|
@@ -41,4 +42,4 @@ import icons from './icons';
|
|
|
41
42
|
export * from './icons';
|
|
42
43
|
import TrebleApp from './components/TrebleApp';
|
|
43
44
|
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, };
|
|
45
|
+
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, 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, };
|
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.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = 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;
|
|
@@ -39,6 +39,9 @@ var useShare_1 = __importDefault(require("./hooks/useShare"));
|
|
|
39
39
|
exports.useShare = useShare_1.default;
|
|
40
40
|
var usePlayerPortal_1 = __importDefault(require("./hooks/usePlayerPortal"));
|
|
41
41
|
exports.usePlayerPortal = usePlayerPortal_1.default;
|
|
42
|
+
// import useSingleAnimation from './hooks/useSingleAnimation';
|
|
43
|
+
var useProductCache_1 = __importDefault(require("./hooks/useProductCache"));
|
|
44
|
+
exports.useProductCache = useProductCache_1.default;
|
|
42
45
|
// Components
|
|
43
46
|
var ThreekitProvider_1 = __importDefault(require("./components/ThreekitProvider"));
|
|
44
47
|
exports.ThreekitProvider = ThreekitProvider_1.default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import { ISetConfiguration, IThreekitDisplayAttribute } from '../threekit';
|
|
2
|
+
import { ISetConfiguration, IThreekitDisplayAttribute, IHydratedAttribute } from '../threekit';
|
|
3
|
+
import { ITranslationMap } from '../api/products';
|
|
3
4
|
/*****************************************************
|
|
4
5
|
* Types and Interfaces
|
|
5
6
|
****************************************************/
|
|
@@ -15,6 +16,18 @@ declare const reducer: import("redux").Reducer<AttributesState, import("redux").
|
|
|
15
16
|
/*****************************************************
|
|
16
17
|
* Standard Selectors
|
|
17
18
|
****************************************************/
|
|
18
|
-
export declare const getAttributes: (state: RootState) =>
|
|
19
|
+
export declare const getAttributes: (state: RootState) => AttributesState;
|
|
20
|
+
export declare const getHydratedAttributes: ((state: {
|
|
21
|
+
treble: import("./treble").TrebleState;
|
|
22
|
+
product: import("./product").ProductState;
|
|
23
|
+
attributes: AttributesState;
|
|
24
|
+
translations: import("./translations").TranslationsState;
|
|
25
|
+
wishlist: import("../Treble").WishlistArray;
|
|
26
|
+
price: import("./price").PriceState;
|
|
27
|
+
}) => Record<string, IHydratedAttribute>) & import("reselect").OutputSelectorFields<(args_0: AttributesState, args_1: ITranslationMap | undefined, args_2: string | undefined) => Record<string, IHydratedAttribute> & {
|
|
28
|
+
clearCache: () => void;
|
|
29
|
+
}> & {
|
|
30
|
+
clearCache: () => void;
|
|
31
|
+
};
|
|
19
32
|
export declare const setConfiguration: (config: ISetConfiguration) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
20
33
|
export default reducer;
|
package/dist/store/attributes.js
CHANGED
|
@@ -36,9 +36,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.setConfiguration = exports.getAttributes = exports.setAttributes = void 0;
|
|
39
|
+
exports.setConfiguration = exports.getHydratedAttributes = exports.getAttributes = exports.setAttributes = void 0;
|
|
40
40
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
41
41
|
var treble_1 = require("./treble");
|
|
42
|
+
var translations_1 = require("./translations");
|
|
42
43
|
/*****************************************************
|
|
43
44
|
* Actions
|
|
44
45
|
****************************************************/
|
|
@@ -76,15 +77,9 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
76
77
|
/*****************************************************
|
|
77
78
|
* Standard Selectors
|
|
78
79
|
****************************************************/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var isThreekitInitialized = state.treble.isThreekitInitialized;
|
|
83
|
-
var _a = state.translations, language = _a.language, translations = _a.translations;
|
|
84
|
-
if (!isThreekitInitialized)
|
|
85
|
-
return undefined;
|
|
86
|
-
if (!attributes)
|
|
87
|
-
return undefined;
|
|
80
|
+
var getAttributes = function (state) { return state.attributes; };
|
|
81
|
+
exports.getAttributes = getAttributes;
|
|
82
|
+
exports.getHydratedAttributes = (0, toolkit_1.createSelector)(exports.getAttributes, translations_1.getTranslations, translations_1.getLanguage, function (attributes, translations, language) {
|
|
88
83
|
var hasTranslation = !!language && !!translations;
|
|
89
84
|
return Object.values(attributes).reduce(function (output, attribute) {
|
|
90
85
|
var _a;
|
|
@@ -102,6 +97,13 @@ var getAttributes = function (state) {
|
|
|
102
97
|
label: hasTranslation
|
|
103
98
|
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
104
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,
|
|
105
107
|
});
|
|
106
108
|
}),
|
|
107
109
|
}
|
|
@@ -113,14 +115,20 @@ var getAttributes = function (state) {
|
|
|
113
115
|
label: hasTranslation
|
|
114
116
|
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
115
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,
|
|
116
125
|
});
|
|
117
126
|
}),
|
|
118
127
|
}
|
|
119
128
|
: undefined),
|
|
120
129
|
_a));
|
|
121
130
|
}, {});
|
|
122
|
-
};
|
|
123
|
-
exports.getAttributes = getAttributes;
|
|
131
|
+
});
|
|
124
132
|
// Configurator
|
|
125
133
|
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
134
|
return __generator(this, function (_a) {
|
package/dist/store/price.js
CHANGED
|
@@ -55,9 +55,9 @@ var initPrice = function () { return function (dispatch) { return __awaiter(void
|
|
|
55
55
|
case 0: return [4 /*yield*/, api_1.default.price.getPricebooksList()];
|
|
56
56
|
case 1:
|
|
57
57
|
pricebook = _a.sent();
|
|
58
|
-
id = pricebook[0].id;
|
|
59
|
-
currency = pricebook[0].currencies[0];
|
|
60
58
|
if (pricebook.length) {
|
|
59
|
+
id = pricebook[0].id;
|
|
60
|
+
currency = pricebook[0].currencies[0];
|
|
61
61
|
dispatch((0, exports.setPriceConfig)({ id: id, currency: currency }));
|
|
62
62
|
price = window.threekit.configurator.getPrice(id, currency);
|
|
63
63
|
dispatch((0, exports.setPrice)(price));
|
package/dist/store/product.d.ts
CHANGED
|
@@ -1,22 +1,58 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import { IMetadata } from '../threekit';
|
|
2
|
+
import { IMetadata, IConfiguration, IProducts } from '../threekit';
|
|
3
|
+
import { IConnectionConfig } from '../connection';
|
|
4
|
+
import { IReloadConfig } from './treble';
|
|
3
5
|
/*****************************************************
|
|
4
6
|
* Types and Interfaces
|
|
5
7
|
****************************************************/
|
|
8
|
+
export interface CachedProduct {
|
|
9
|
+
name?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
thumbnail?: string;
|
|
12
|
+
connection: IConnectionConfig;
|
|
13
|
+
configuration: IConfiguration;
|
|
14
|
+
}
|
|
15
|
+
export interface CachedProductState extends Pick<CachedProduct, 'name' | 'label' | 'thumbnail'> {
|
|
16
|
+
data: string;
|
|
17
|
+
}
|
|
6
18
|
export interface ProductState {
|
|
7
19
|
name: undefined | string;
|
|
8
20
|
metadata: undefined | IMetadata;
|
|
21
|
+
cachedProducts: Array<CachedProductState>;
|
|
22
|
+
activeProductIdx: number;
|
|
9
23
|
}
|
|
24
|
+
/*****************************************************
|
|
25
|
+
* Constants
|
|
26
|
+
****************************************************/
|
|
27
|
+
export declare let PRODUCTS: IProducts;
|
|
10
28
|
/*****************************************************
|
|
11
29
|
* Actions
|
|
12
30
|
****************************************************/
|
|
13
31
|
export declare const setName: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
14
32
|
export declare const setMetadata: import("@reduxjs/toolkit").ActionCreatorWithPayload<IMetadata, string>;
|
|
15
|
-
export declare const
|
|
33
|
+
export declare const addProductToCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
34
|
+
export declare const updateActiveProductCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
35
|
+
export declare const removeProductFromCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
36
|
+
export declare const setActiveProductIdx: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
37
|
+
export declare const incrementActiveProductIdx: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<undefined, string>;
|
|
38
|
+
export declare const decrementActiveProductIdx: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<undefined, string>;
|
|
16
39
|
declare const reducer: import("redux").Reducer<ProductState, import("redux").AnyAction>;
|
|
17
40
|
/*****************************************************
|
|
18
41
|
* Standard Selectors
|
|
19
42
|
****************************************************/
|
|
20
43
|
export declare const getName: (state: RootState) => undefined | string;
|
|
21
44
|
export declare const getMetadata: (state: RootState) => undefined | IMetadata;
|
|
45
|
+
export declare const getActiveProductIdx: (state: RootState) => number;
|
|
46
|
+
export declare const getProductCache: (state: RootState) => Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
47
|
+
/*****************************************************
|
|
48
|
+
* Complex Actions
|
|
49
|
+
****************************************************/
|
|
50
|
+
export declare const initProduct: (prods?: IProducts | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
51
|
+
export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, "label" | "thumbnail"> | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => {
|
|
52
|
+
payload: CachedProductState;
|
|
53
|
+
type: string;
|
|
54
|
+
};
|
|
55
|
+
export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
56
|
+
export declare const changeActiveProductIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
57
|
+
export declare const removeProductIdx: (idx?: number | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
22
58
|
export default reducer;
|