@threekit-tools/treble 0.0.58 → 0.0.60-next.2
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 +8 -2
- package/dist/Treble/Treble.js +23 -2
- 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/ThreekitProvider/index.d.ts +1 -0
- package/dist/components/ThreekitProvider/index.js +10 -3
- package/dist/components/Tiles/index.js +3 -4
- package/dist/components/TilesGroup/index.js +3 -4
- package/dist/components/TrebleApp/index.d.ts +1 -0
- package/dist/components/TrebleApp/index.js +16 -6
- package/dist/components/Wishlist/index.js +6 -11
- package/dist/components/containers/formInputContainer.d.ts +9 -5
- package/dist/components/containers/formInputContainer.js +14 -19
- 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 +6 -5
- package/dist/hooks/useConfigurator/index.d.ts +2 -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 +22 -0
- package/dist/hooks/useProductCache/index.js +28 -0
- package/dist/hooks/useWishlist/index.d.ts +8 -6
- package/dist/hooks/useWishlist/index.js +16 -22
- 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 +3 -1
- package/dist/index.js +5 -1
- package/dist/store/attributes.d.ts +14 -1
- package/dist/store/attributes.js +6 -45
- package/dist/store/product.d.ts +47 -2
- package/dist/store/product.js +267 -12
- package/dist/store/translations.d.ts +4 -2
- package/dist/store/translations.js +4 -12
- package/dist/store/treble.d.ts +36 -2
- package/dist/store/treble.js +214 -52
- package/dist/threekit.d.ts +16 -1
- package/dist/utils.d.ts +7 -10
- package/dist/utils.js +22 -23
- package/package.json +1 -1
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
|
@@ -42,26 +42,27 @@ 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"));
|
|
46
|
+
var utils_2 = require("../../utils");
|
|
47
47
|
var useAttribute = function (attributeName) {
|
|
48
|
+
var _a;
|
|
48
49
|
if (!attributeName)
|
|
49
50
|
return [undefined, undefined];
|
|
50
51
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
51
|
-
var
|
|
52
|
+
var _b = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), attributes = _b[0], translations = _b[1], language = _b[2];
|
|
52
53
|
if (!attributeName || !attributes)
|
|
53
54
|
return [undefined, undefined];
|
|
54
55
|
var attribute = attributes[attributeName];
|
|
55
56
|
if (!attribute)
|
|
56
57
|
return [undefined, undefined];
|
|
58
|
+
var preppedAttributes = (0, utils_2.hydrateAttribute)([(_a = {}, _a[attributeName] = attribute, _a), translations, language], function (config) { return dispatch((0, attributes_1.setConfiguration)(config)); });
|
|
57
59
|
var handleChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
60
|
var preppedValue, assetId;
|
|
59
61
|
var _a;
|
|
60
62
|
return __generator(this, function (_b) {
|
|
61
63
|
switch (_b.label) {
|
|
62
64
|
case 0:
|
|
63
|
-
if (!(attribute.type === 'Asset' &&
|
|
64
|
-
attribute.assetType === constants_1.ASSET_TYPES.upload)) return [3 /*break*/, 4];
|
|
65
|
+
if (!(attribute.type === 'Asset' && attribute.assetType === 'upload')) return [3 /*break*/, 4];
|
|
65
66
|
if (!!value) return [3 /*break*/, 1];
|
|
66
67
|
preppedValue = (0, utils_1.selectionToConfiguration)('', attribute.type);
|
|
67
68
|
return [3 /*break*/, 3];
|
|
@@ -83,6 +84,6 @@ var useAttribute = function (attributeName) {
|
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
}); };
|
|
86
|
-
return [
|
|
87
|
+
return [preppedAttributes[attributeName], handleChange];
|
|
87
88
|
};
|
|
88
89
|
exports.default = useAttribute;
|
|
@@ -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;
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var attributes_1 = require("../../store/attributes");
|
|
4
4
|
var store_1 = require("../../store");
|
|
5
|
+
var utils_1 = require("../../utils");
|
|
5
6
|
var useConfigurator = function () {
|
|
6
7
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
|
-
var
|
|
8
|
-
if (!
|
|
8
|
+
var hydrationData = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData);
|
|
9
|
+
if (!hydrationData)
|
|
9
10
|
return [undefined, undefined];
|
|
11
|
+
var preppedAttributes = (0, utils_1.hydrateAttribute)(hydrationData, function (config) {
|
|
12
|
+
return dispatch((0, attributes_1.setConfiguration)(config));
|
|
13
|
+
});
|
|
10
14
|
var handleChange = function (configuration) {
|
|
11
15
|
return dispatch((0, attributes_1.setConfiguration)(configuration));
|
|
12
16
|
};
|
|
13
|
-
return [
|
|
17
|
+
return [preppedAttributes, handleChange];
|
|
14
18
|
};
|
|
15
19
|
exports.default = useConfigurator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IHydratedAttribute, ISetConfiguration } from '../../threekit';
|
|
2
|
+
declare type UseNestedConfiguratorError = [undefined, undefined];
|
|
3
|
+
declare type UseNestedConfiguratorSuccess = [
|
|
4
|
+
Record<string, IHydratedAttribute>,
|
|
5
|
+
(val: ISetConfiguration) => Promise<void>
|
|
6
|
+
];
|
|
7
|
+
declare const useNestedConfigurator: (address: string | Array<string>) => UseNestedConfiguratorError | UseNestedConfiguratorSuccess;
|
|
8
|
+
export default useNestedConfigurator;
|
|
@@ -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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CachedProduct } from '../../store/product';
|
|
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
|
+
}
|
|
13
|
+
interface CacheData {
|
|
14
|
+
cache: Array<HydratedCacheProduct>;
|
|
15
|
+
products: Array<ISelectableProduct>;
|
|
16
|
+
}
|
|
17
|
+
declare type UseProductCache = [
|
|
18
|
+
CacheData,
|
|
19
|
+
(config?: string | IReloadConfig) => Promise<void>
|
|
20
|
+
];
|
|
21
|
+
declare const useProductCache: () => UseProductCache;
|
|
22
|
+
export default useProductCache;
|
|
@@ -0,0 +1,28 @@
|
|
|
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.getActiveCacheIdx);
|
|
9
|
+
var handleLoadNewProduct = function (config) {
|
|
10
|
+
return dispatch((0, product_1.loadNewProduct)(config));
|
|
11
|
+
};
|
|
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];
|
|
27
|
+
};
|
|
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/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,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';
|
|
@@ -41,4 +43,4 @@ import icons from './icons';
|
|
|
41
43
|
export * from './icons';
|
|
42
44
|
import TrebleApp from './components/TrebleApp';
|
|
43
45
|
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, };
|
|
46
|
+
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, 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.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,6 +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
|
+
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;
|
|
43
47
|
// Components
|
|
44
48
|
var ThreekitProvider_1 = __importDefault(require("./components/ThreekitProvider"));
|
|
45
49
|
exports.ThreekitProvider = ThreekitProvider_1.default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
2
|
import { ISetConfiguration, IThreekitDisplayAttribute } 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 getHydrationData: ((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, IThreekitDisplayAttribute>, ITranslationMap | undefined, string | undefined]) & import("reselect").OutputSelectorFields<(args_0: AttributesState, args_1: string | undefined) => [Record<string, IThreekitDisplayAttribute>, ITranslationMap | undefined, string | undefined] & {
|
|
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.getHydrationData = 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,51 +77,11 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
76
77
|
/*****************************************************
|
|
77
78
|
* Standard Selectors
|
|
78
79
|
****************************************************/
|
|
79
|
-
|
|
80
|
-
var getAttributes = function (state) {
|
|
81
|
-
var attributes = state.attributes;
|
|
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;
|
|
88
|
-
var hasTranslation = !!language && !!translations;
|
|
89
|
-
return Object.values(attributes).reduce(function (output, attribute) {
|
|
90
|
-
var _a;
|
|
91
|
-
var _b;
|
|
92
|
-
return Object.assign(output, (_a = {},
|
|
93
|
-
_a[attribute.name] = Object.assign({}, attribute, {
|
|
94
|
-
label: hasTranslation
|
|
95
|
-
? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
|
|
96
|
-
: attribute.name,
|
|
97
|
-
}, attribute.type === 'String'
|
|
98
|
-
? {
|
|
99
|
-
values: attribute.values.map(function (el) {
|
|
100
|
-
var _a;
|
|
101
|
-
return Object.assign({}, el, {
|
|
102
|
-
label: hasTranslation
|
|
103
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
104
|
-
: el.label,
|
|
105
|
-
});
|
|
106
|
-
}),
|
|
107
|
-
}
|
|
108
|
-
: attribute.type === 'Asset'
|
|
109
|
-
? {
|
|
110
|
-
values: attribute.values.map(function (el) {
|
|
111
|
-
var _a;
|
|
112
|
-
return Object.assign({}, el, {
|
|
113
|
-
label: hasTranslation
|
|
114
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
115
|
-
: el.name,
|
|
116
|
-
});
|
|
117
|
-
}),
|
|
118
|
-
}
|
|
119
|
-
: undefined),
|
|
120
|
-
_a));
|
|
121
|
-
}, {});
|
|
122
|
-
};
|
|
80
|
+
var getAttributes = function (state) { return state.attributes; };
|
|
123
81
|
exports.getAttributes = getAttributes;
|
|
82
|
+
exports.getHydrationData = (0, toolkit_1.createSelector)(exports.getAttributes, translations_1.getLanguage, function (attributes, language) {
|
|
83
|
+
return [attributes, translations_1.TRANSLATIONS, language];
|
|
84
|
+
});
|
|
124
85
|
// Configurator
|
|
125
86
|
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
87
|
return __generator(this, function (_a) {
|
package/dist/store/product.d.ts
CHANGED
|
@@ -1,22 +1,67 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import { IMetadata } from '../threekit';
|
|
2
|
+
import { IMetadata, IConfiguration, IProduct } 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
|
+
id: undefined | string;
|
|
10
|
+
name?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
thumbnail?: string;
|
|
13
|
+
connection: IConnectionConfig;
|
|
14
|
+
configuration: IConfiguration;
|
|
15
|
+
}
|
|
16
|
+
export interface CachedProductState extends Pick<CachedProduct, 'id' | 'name' | 'label' | 'thumbnail'> {
|
|
17
|
+
data: string;
|
|
18
|
+
}
|
|
19
|
+
interface IEnvConfig extends Record<string, Partial<IProduct>> {
|
|
20
|
+
}
|
|
21
|
+
export interface IHydratedProducts extends Record<string, IEnvConfig> {
|
|
22
|
+
}
|
|
6
23
|
export interface ProductState {
|
|
24
|
+
id: undefined | string;
|
|
7
25
|
name: undefined | string;
|
|
8
26
|
metadata: undefined | IMetadata;
|
|
27
|
+
cache: Array<CachedProductState>;
|
|
28
|
+
activeCacheIdx: number;
|
|
9
29
|
}
|
|
30
|
+
/*****************************************************
|
|
31
|
+
* Constants
|
|
32
|
+
****************************************************/
|
|
33
|
+
export declare let PRODUCTS: IHydratedProducts;
|
|
10
34
|
/*****************************************************
|
|
11
35
|
* Actions
|
|
12
36
|
****************************************************/
|
|
37
|
+
export declare const setProductId: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>;
|
|
13
38
|
export declare const setName: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
14
39
|
export declare const setMetadata: import("@reduxjs/toolkit").ActionCreatorWithPayload<IMetadata, string>;
|
|
15
|
-
export declare const
|
|
40
|
+
export declare const appendToCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
41
|
+
export declare const updateActiveProductCache: import("@reduxjs/toolkit").ActionCreatorWithPayload<CachedProductState, string>;
|
|
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>;
|
|
16
46
|
declare const reducer: import("redux").Reducer<ProductState, import("redux").AnyAction>;
|
|
17
47
|
/*****************************************************
|
|
18
48
|
* Standard Selectors
|
|
19
49
|
****************************************************/
|
|
50
|
+
export declare const getProductId: (state: RootState) => undefined | string;
|
|
20
51
|
export declare const getName: (state: RootState) => undefined | string;
|
|
21
52
|
export declare const getMetadata: (state: RootState) => undefined | IMetadata;
|
|
53
|
+
export declare const getActiveCacheIdx: (state: RootState) => number;
|
|
54
|
+
export declare const getProductCache: (state: RootState) => Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
55
|
+
/*****************************************************
|
|
56
|
+
* Complex Actions
|
|
57
|
+
****************************************************/
|
|
58
|
+
export declare const initProduct: (prods?: IHydratedProducts | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
59
|
+
export declare const cacheActiveProduct: (config?: Pick<IReloadConfig, "label" | "thumbnail"> | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => {
|
|
60
|
+
payload: CachedProductState;
|
|
61
|
+
type: string;
|
|
62
|
+
};
|
|
63
|
+
export declare const loadProduct: (id: string) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
64
|
+
export declare const loadNewProduct: (config: undefined | string | IReloadConfig) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
65
|
+
export declare const changeActiveCacheIdx: (idx: number) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
66
|
+
export declare const removeProductIdx: (idx?: number | undefined) => (dispatch: ThreekitDispatch, getState: () => RootState) => Promise<void>;
|
|
22
67
|
export default reducer;
|