@threekit-tools/treble 0.0.57 → 0.0.60-next.1
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 +9 -7
- package/dist/Treble/Treble.js +26 -6
- 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/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/useSingleAnimation/index.d.ts +17 -0
- package/dist/hooks/useSingleAnimation/index.js +264 -0
- package/dist/hooks/useWishlist/index.d.ts +10 -7
- package/dist/hooks/useWishlist/index.js +17 -25
- 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 +3 -1
- package/dist/index.js +6 -1
- package/dist/store/attributes.d.ts +14 -1
- package/dist/store/attributes.js +6 -45
- package/dist/store/price.js +2 -2
- 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/store/wishlist.d.ts +3 -2
- package/dist/threekit.d.ts +20 -2
- package/dist/utils.d.ts +9 -11
- package/dist/utils.js +83 -27
- package/package.json +17 -2
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = require("react");
|
|
54
|
+
var useThreekitInitStatus_1 = __importDefault(require("../useThreekitInitStatus"));
|
|
55
|
+
var utils_1 = require("../../utils");
|
|
56
|
+
var prepAnimateConfig = function (config) {
|
|
57
|
+
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var totalDuration, player, assetId, nodesRaw, nodes;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
totalDuration = config.duration * 1000 || 0;
|
|
63
|
+
player = window.threekit.player.enableApi('player');
|
|
64
|
+
return [4 /*yield*/, player.getAssetInstance(window.threekit.player.scene.find({
|
|
65
|
+
id: window.threekit.player.instanceId,
|
|
66
|
+
plug: 'Proxy',
|
|
67
|
+
property: 'asset',
|
|
68
|
+
}))];
|
|
69
|
+
case 1:
|
|
70
|
+
assetId = _a.sent();
|
|
71
|
+
nodesRaw = Object.entries(config.nodes).reduce(function (output, _a) {
|
|
72
|
+
var _b;
|
|
73
|
+
var name = _a[0], nodeData = _a[1];
|
|
74
|
+
var nodeId = window.threekit.player.scene.get({
|
|
75
|
+
from: assetId,
|
|
76
|
+
name: name,
|
|
77
|
+
}).id;
|
|
78
|
+
var node = Object.assign({ nodeId: nodeId }, { duration: (nodeData.duration || config.duration || 0) * 1000 }, { paddingStart: (nodeData.delay || 0) * 1000 }, 'translation' in nodeData
|
|
79
|
+
? {
|
|
80
|
+
translation: [
|
|
81
|
+
window.threekit.player.scene.get({
|
|
82
|
+
from: assetId,
|
|
83
|
+
id: nodeId,
|
|
84
|
+
plug: 'Transform',
|
|
85
|
+
property: 'translation',
|
|
86
|
+
}),
|
|
87
|
+
Object.assign({ x: 0, y: 0, z: 0 }, nodeData.translation),
|
|
88
|
+
],
|
|
89
|
+
}
|
|
90
|
+
: {}, 'rotation' in nodeData
|
|
91
|
+
? {
|
|
92
|
+
rotation: [
|
|
93
|
+
window.threekit.player.scene.get({
|
|
94
|
+
from: assetId,
|
|
95
|
+
id: nodeId,
|
|
96
|
+
plug: 'Transform',
|
|
97
|
+
property: 'rotation',
|
|
98
|
+
}),
|
|
99
|
+
Object.assign({ x: 0, y: 0, z: 0 }, nodeData.rotation),
|
|
100
|
+
],
|
|
101
|
+
}
|
|
102
|
+
: {}, 'scale' in nodeData
|
|
103
|
+
? {
|
|
104
|
+
scale: [
|
|
105
|
+
window.threekit.player.scene.get({
|
|
106
|
+
from: assetId,
|
|
107
|
+
id: nodeId,
|
|
108
|
+
plug: 'Transform',
|
|
109
|
+
property: 'scale',
|
|
110
|
+
}),
|
|
111
|
+
Object.assign({ x: 0, y: 0, z: 0 }, nodeData.scale),
|
|
112
|
+
],
|
|
113
|
+
}
|
|
114
|
+
: {});
|
|
115
|
+
var duration = node.duration + node.paddingStart;
|
|
116
|
+
if (duration > totalDuration)
|
|
117
|
+
totalDuration = duration;
|
|
118
|
+
return Object.assign(output, (_b = {}, _b[name] = node, _b));
|
|
119
|
+
}, {});
|
|
120
|
+
nodes = Object.entries(nodesRaw).reduce(function (output, _a) {
|
|
121
|
+
var _b;
|
|
122
|
+
var nodeName = _a[0], nodeData = _a[1];
|
|
123
|
+
var paddingEnd = 0;
|
|
124
|
+
if (totalDuration !== nodeData.duration + nodeData.paddingStart)
|
|
125
|
+
paddingEnd =
|
|
126
|
+
totalDuration - (nodeData.duration + nodeData.paddingStart);
|
|
127
|
+
return Object.assign(output, (_b = {},
|
|
128
|
+
_b[nodeName] = __assign(__assign({}, nodeData), { paddingEnd: paddingEnd }),
|
|
129
|
+
_b));
|
|
130
|
+
}, {});
|
|
131
|
+
resolve([assetId, totalDuration, nodes]);
|
|
132
|
+
return [2 /*return*/];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}); });
|
|
136
|
+
};
|
|
137
|
+
var useAnimation = function (animationConfig) {
|
|
138
|
+
var _a = (0, react_1.useState)(false), animationInProgress = _a[0], setAnimationInProgress = _a[1];
|
|
139
|
+
var ref = (0, react_1.useRef)({
|
|
140
|
+
assetId: undefined,
|
|
141
|
+
startTime: 0,
|
|
142
|
+
totalDuration: 0,
|
|
143
|
+
nodes: {},
|
|
144
|
+
isTransformed: false,
|
|
145
|
+
});
|
|
146
|
+
var isLoaded = (0, useThreekitInitStatus_1.default)();
|
|
147
|
+
if (!isLoaded)
|
|
148
|
+
return [undefined, undefined];
|
|
149
|
+
var animateFrame = function (timestamp) {
|
|
150
|
+
// if (startTime.current === undefined) startTime.current = timestamp;
|
|
151
|
+
// const elapsed = timestamp - startTime.current;
|
|
152
|
+
if (ref.current.startTime === undefined)
|
|
153
|
+
ref.current.startTime = timestamp;
|
|
154
|
+
var elapsed = timestamp - ref.current.startTime;
|
|
155
|
+
Object.values(ref.current.nodes).forEach(function (nodeConfig) {
|
|
156
|
+
if (!ref.current.isTransformed) {
|
|
157
|
+
// If its too early we don't animate
|
|
158
|
+
if (elapsed < nodeConfig.paddingStart)
|
|
159
|
+
return;
|
|
160
|
+
// If its too early we don't animate
|
|
161
|
+
if (elapsed > nodeConfig.duration + nodeConfig.paddingStart)
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
else if (ref.current.isTransformed) {
|
|
165
|
+
// If its too early we don't animate
|
|
166
|
+
if (elapsed < nodeConfig.paddingEnd)
|
|
167
|
+
return;
|
|
168
|
+
// If its too early we don't animate
|
|
169
|
+
if (elapsed > nodeConfig.duration + nodeConfig.paddingEnd)
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
var progressTime = !ref.current.isTransformed
|
|
173
|
+
? elapsed - nodeConfig.paddingStart
|
|
174
|
+
: elapsed - nodeConfig.paddingEnd;
|
|
175
|
+
var animationPercent = (0, utils_1.easeInOutCubic)(progressTime / nodeConfig.duration);
|
|
176
|
+
var translation;
|
|
177
|
+
var rotation;
|
|
178
|
+
var scale;
|
|
179
|
+
if ('translation' in nodeConfig) {
|
|
180
|
+
translation = Object.keys(nodeConfig.translation[1]).reduce(function (output, axis) {
|
|
181
|
+
var _a;
|
|
182
|
+
var value = !ref.current.isTransformed
|
|
183
|
+
? nodeConfig.translation[0][axis] +
|
|
184
|
+
nodeConfig.translation[1][axis] * animationPercent
|
|
185
|
+
: nodeConfig.translation[1][axis] +
|
|
186
|
+
nodeConfig.translation[0][axis] -
|
|
187
|
+
nodeConfig.translation[1][axis] * animationPercent;
|
|
188
|
+
return Object.assign(output, (_a = {}, _a[axis] = value, _a));
|
|
189
|
+
}, {});
|
|
190
|
+
window.threekit.player.scene.set({
|
|
191
|
+
from: ref.current.assetId,
|
|
192
|
+
id: nodeConfig.nodeId,
|
|
193
|
+
plug: 'Transform',
|
|
194
|
+
property: 'translation',
|
|
195
|
+
}, translation);
|
|
196
|
+
}
|
|
197
|
+
if ('rotation' in nodeConfig) {
|
|
198
|
+
rotation = Object.keys(nodeConfig.rotation[1]).reduce(function (output, axis) {
|
|
199
|
+
var _a;
|
|
200
|
+
var value = !ref.current.isTransformed
|
|
201
|
+
? nodeConfig.rotation[0][axis] +
|
|
202
|
+
nodeConfig.rotation[1][axis] * animationPercent
|
|
203
|
+
: nodeConfig.rotation[1][axis] +
|
|
204
|
+
nodeConfig.rotation[0][axis] -
|
|
205
|
+
nodeConfig.rotation[1][axis] * animationPercent;
|
|
206
|
+
return Object.assign(output, (_a = {}, _a[axis] = value, _a));
|
|
207
|
+
}, {});
|
|
208
|
+
window.threekit.player.scene.set({
|
|
209
|
+
from: ref.current.assetId,
|
|
210
|
+
id: nodeConfig.nodeId,
|
|
211
|
+
plug: 'Transform',
|
|
212
|
+
property: 'rotation',
|
|
213
|
+
}, rotation);
|
|
214
|
+
}
|
|
215
|
+
if ('scale' in nodeConfig) {
|
|
216
|
+
scale = Object.keys(nodeConfig.scale[1]).reduce(function (output, axis) {
|
|
217
|
+
var _a;
|
|
218
|
+
var value = !ref.current.isTransformed
|
|
219
|
+
? nodeConfig.scale[0][axis] +
|
|
220
|
+
nodeConfig.scale[1][axis] * animationPercent
|
|
221
|
+
: nodeConfig.scale[1][axis] +
|
|
222
|
+
nodeConfig.scale[0][axis] -
|
|
223
|
+
nodeConfig.scale[1][axis] * animationPercent;
|
|
224
|
+
return Object.assign(output, (_a = {}, _a[axis] = value, _a));
|
|
225
|
+
}, {});
|
|
226
|
+
window.threekit.player.scene.set({
|
|
227
|
+
from: ref.current.assetId,
|
|
228
|
+
id: nodeConfig.nodeId,
|
|
229
|
+
plug: 'Transform',
|
|
230
|
+
property: 'scale',
|
|
231
|
+
}, scale);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
if (elapsed < ref.current.totalDuration) {
|
|
235
|
+
window.requestAnimationFrame(animateFrame);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
setAnimationInProgress(false);
|
|
239
|
+
ref.current.startTime = undefined;
|
|
240
|
+
ref.current.isTransformed = !ref.current.isTransformed;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
var handleClickAnimate = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
244
|
+
var _a;
|
|
245
|
+
return __generator(this, function (_b) {
|
|
246
|
+
switch (_b.label) {
|
|
247
|
+
case 0:
|
|
248
|
+
ref.current.startTime = undefined;
|
|
249
|
+
if (!!ref.current.nodes) return [3 /*break*/, 2];
|
|
250
|
+
return [4 /*yield*/, prepAnimateConfig(animationConfig)];
|
|
251
|
+
case 1:
|
|
252
|
+
_a = _b.sent(), ref.current.assetId = _a[0], ref.current.totalDuration = _a[1], ref.current.nodes = _a[2];
|
|
253
|
+
ref.current.isTransformed = false;
|
|
254
|
+
_b.label = 2;
|
|
255
|
+
case 2:
|
|
256
|
+
setAnimationInProgress(true);
|
|
257
|
+
window.requestAnimationFrame(animateFrame);
|
|
258
|
+
return [2 /*return*/];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}); };
|
|
262
|
+
return [animationInProgress, handleClickAnimate];
|
|
263
|
+
};
|
|
264
|
+
exports.default = useAnimation;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IConfigurationResponse } from '../../http/configurations';
|
|
2
|
+
import { ISaveConfiguration } from '../../api/configurations';
|
|
3
|
+
interface HydratedWishlistItem extends IConfigurationResponse {
|
|
4
|
+
handleSelect: () => void;
|
|
5
|
+
handleRemove: () => void;
|
|
6
|
+
handleShare: () => void;
|
|
7
|
+
}
|
|
2
8
|
declare type UseWishlistHook = [
|
|
3
|
-
|
|
4
|
-
(config?:
|
|
5
|
-
(idx: number) => void,
|
|
6
|
-
(idx: number) => void,
|
|
7
|
-
(idx: number) => void,
|
|
9
|
+
Array<HydratedWishlistItem>,
|
|
10
|
+
(config?: Omit<ISaveConfiguration, 'configurator'>) => void,
|
|
8
11
|
() => void
|
|
9
|
-
] | [undefined, undefined, undefined
|
|
12
|
+
] | [undefined, undefined, undefined];
|
|
10
13
|
declare const useWishlist: () => UseWishlistHook;
|
|
11
14
|
export default useWishlist;
|
|
@@ -11,34 +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
|
|
17
|
-
var handleAddToWishlist = function (config) {
|
|
18
|
-
return dispatch((0, wishlist_1.addToWishlist)(config));
|
|
19
|
-
};
|
|
20
|
-
var handleRemoveFromWishlist = function (idx) {
|
|
21
|
-
dispatch((0, wishlist_1.removeFromWishlist)(idx));
|
|
22
|
-
message_1.default.info('Item removed from wishlist');
|
|
23
|
-
};
|
|
24
|
-
var handleResumeItem = function (idx) {
|
|
25
|
-
dispatch((0, wishlist_1.resumeFromWishlist)(idx));
|
|
26
|
-
};
|
|
27
|
-
var handleShareItem = function (idx) {
|
|
28
|
-
var url = (0, utils_1.getResumableUrl)(wishlist[idx].shortId);
|
|
29
|
-
(0, utils_1.copyToClipboard)(url);
|
|
30
|
-
message_1.default.info('Link copied!');
|
|
31
|
-
};
|
|
16
|
+
return [undefined, undefined, undefined];
|
|
17
|
+
var handleAddToWishlist = function (config) { return dispatch((0, wishlist_1.addToWishlist)(config)); };
|
|
32
18
|
var handleClearWishlist = function () {
|
|
33
19
|
dispatch(wishlist_1.clearWishlist);
|
|
34
20
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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];
|
|
43
35
|
};
|
|
44
36
|
exports.default = useWishlist;
|
|
@@ -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,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;
|
|
@@ -39,6 +39,11 @@ 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;
|
|
45
|
+
var useNestedConfigurator_1 = __importDefault(require("./hooks/useNestedConfigurator"));
|
|
46
|
+
exports.useNestedConfigurator = useNestedConfigurator_1.default;
|
|
42
47
|
// Components
|
|
43
48
|
var ThreekitProvider_1 = __importDefault(require("./components/ThreekitProvider"));
|
|
44
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/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,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;
|