@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
package/dist/Treble/Snapshots.js
CHANGED
|
@@ -129,53 +129,12 @@ var Snapshots = /** @class */ (function () {
|
|
|
129
129
|
}, Promise.resolve(snapshots));
|
|
130
130
|
};
|
|
131
131
|
this.takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
switch (_a.label) {
|
|
137
|
-
case 0:
|
|
138
|
-
files = (0, utils_1.dataURItoFile)(snapshot, filename);
|
|
139
|
-
return [4 /*yield*/, api_1.default.configurations.save({
|
|
140
|
-
assetId: window.threekit.player.assetId,
|
|
141
|
-
configuration: window.threekit.configurator.getConfiguration(),
|
|
142
|
-
files: files,
|
|
143
|
-
})];
|
|
144
|
-
case 1:
|
|
145
|
-
response = _a.sent();
|
|
146
|
-
return [2 /*return*/, "".concat(threekitDomain, "/api/files/hash/").concat(response.data.thumbnail)];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
function downloadSnapshot(snapshot, filename) {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
-
var blob, blobUrl, link, clickHandler;
|
|
154
|
-
return __generator(this, function (_a) {
|
|
155
|
-
blob = (0, utils_1.dataURItoBlob)(snapshot);
|
|
156
|
-
blobUrl = URL.createObjectURL(blob);
|
|
157
|
-
link = document.createElement('a');
|
|
158
|
-
link.href = blobUrl;
|
|
159
|
-
link.download = filename;
|
|
160
|
-
clickHandler = function () {
|
|
161
|
-
setTimeout(function () {
|
|
162
|
-
URL.revokeObjectURL(blobUrl);
|
|
163
|
-
link.removeEventListener('click', clickHandler);
|
|
164
|
-
}, 150);
|
|
165
|
-
};
|
|
166
|
-
link.addEventListener('click', clickHandler);
|
|
167
|
-
document.body.appendChild(link);
|
|
168
|
-
link.click();
|
|
169
|
-
return [2 /*return*/];
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
var threekitDomain, filename, size, format, attributeName, output, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition, _a, savedSnapshots, snapshotBlobs, snapshotFiles;
|
|
174
|
-
var _b;
|
|
175
|
-
return __generator(this, function (_c) {
|
|
176
|
-
switch (_c.label) {
|
|
132
|
+
var _a, threekitDomain, orgId, filename, size, format, attributeName, output, cameras, snapshotsRaw, snapshotData, camerasMap_1, currentCamera, cameraPosition, _b, attachments, response_1, urlsArray, snapshotBlobs, snapshotFiles;
|
|
133
|
+
var _c;
|
|
134
|
+
return __generator(this, function (_d) {
|
|
135
|
+
switch (_d.label) {
|
|
177
136
|
case 0:
|
|
178
|
-
|
|
137
|
+
_a = connection_1.default.getConnection(), threekitDomain = _a.threekitDomain, orgId = _a.orgId;
|
|
179
138
|
filename = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.filename) || DEFAULT_CAMERA_CONFIG.filename;
|
|
180
139
|
size = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.size) || DEFAULT_CAMERA_CONFIG.size;
|
|
181
140
|
format = (snapshotsConfig === null || snapshotsConfig === void 0 ? void 0 : snapshotsConfig.format) || DEFAULT_CAMERA_CONFIG.format;
|
|
@@ -185,7 +144,7 @@ var Snapshots = /** @class */ (function () {
|
|
|
185
144
|
if (!(cameras.length === 1 && cameras[0] === undefined)) return [3 /*break*/, 2];
|
|
186
145
|
return [4 /*yield*/, this.getSnapshot({ size: size, format: format })];
|
|
187
146
|
case 1:
|
|
188
|
-
snapshotData =
|
|
147
|
+
snapshotData = _d.sent();
|
|
189
148
|
snapshotsRaw = [snapshotData];
|
|
190
149
|
return [3 /*break*/, 5];
|
|
191
150
|
case 2:
|
|
@@ -197,17 +156,17 @@ var Snapshots = /** @class */ (function () {
|
|
|
197
156
|
cameraPosition = (0, utils_1.getCameraPosition)(window.threekit.player.camera);
|
|
198
157
|
return [4 /*yield*/, this.getSnapshots(cameras, camerasMap_1)];
|
|
199
158
|
case 3:
|
|
200
|
-
snapshotsRaw =
|
|
201
|
-
return [4 /*yield*/, window.threekit.configurator.setConfiguration((
|
|
202
|
-
|
|
203
|
-
|
|
159
|
+
snapshotsRaw = _d.sent();
|
|
160
|
+
return [4 /*yield*/, window.threekit.configurator.setConfiguration((_c = {},
|
|
161
|
+
_c[attributeName] = currentCamera,
|
|
162
|
+
_c))];
|
|
204
163
|
case 4:
|
|
205
|
-
|
|
164
|
+
_d.sent();
|
|
206
165
|
(0, utils_1.setCameraPosition)(window.threekit.player.camera, cameraPosition);
|
|
207
|
-
|
|
166
|
+
_d.label = 5;
|
|
208
167
|
case 5:
|
|
209
|
-
|
|
210
|
-
switch (
|
|
168
|
+
_b = output;
|
|
169
|
+
switch (_b) {
|
|
211
170
|
case constants_1.SNAPSHOT_OUTPUTS.url: return [3 /*break*/, 6];
|
|
212
171
|
case constants_1.SNAPSHOT_OUTPUTS.download: return [3 /*break*/, 8];
|
|
213
172
|
case constants_1.SNAPSHOT_OUTPUTS.blob: return [3 /*break*/, 9];
|
|
@@ -215,21 +174,32 @@ var Snapshots = /** @class */ (function () {
|
|
|
215
174
|
case constants_1.SNAPSHOT_OUTPUTS.dataUrl: return [3 /*break*/, 11];
|
|
216
175
|
}
|
|
217
176
|
return [3 /*break*/, 11];
|
|
218
|
-
case 6:
|
|
177
|
+
case 6:
|
|
178
|
+
attachments = snapshotsRaw.reduce(function (output, el, idx) {
|
|
179
|
+
var _a;
|
|
219
180
|
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
220
|
-
?
|
|
181
|
+
? (0, utils_1.regularToKebabCase)(camerasList[idx] || 'default')
|
|
221
182
|
: '';
|
|
222
|
-
|
|
223
|
-
|
|
183
|
+
var file = (0, utils_1.dataURItoFile)(el, "".concat(filename, "-").concat(cameraName, ".").concat(format));
|
|
184
|
+
return Object.assign(output, (_a = {}, _a[cameraName] = file, _a));
|
|
185
|
+
}, {});
|
|
186
|
+
return [4 /*yield*/, api_1.default.configurations.save({
|
|
187
|
+
assetId: window.threekit.player.assetId,
|
|
188
|
+
configuration: window.threekit.configurator.getConfiguration(),
|
|
189
|
+
attachments: attachments,
|
|
190
|
+
})];
|
|
224
191
|
case 7:
|
|
225
|
-
|
|
226
|
-
|
|
192
|
+
response_1 = _d.sent();
|
|
193
|
+
urlsArray = Object.keys(response_1.data.attachments).map(function (key) {
|
|
194
|
+
return "".concat(threekitDomain, "/api/configurations/").concat(response_1.data.shortId, "/files/").concat(key, "?orgId=").concat(orgId);
|
|
195
|
+
});
|
|
196
|
+
return [2 /*return*/, Promise.resolve(urlsArray)];
|
|
227
197
|
case 8:
|
|
228
198
|
snapshotsRaw.forEach(function (snapshotBlob, idx) {
|
|
229
199
|
var cameraName = (camerasList === null || camerasList === void 0 ? void 0 : camerasList[idx])
|
|
230
200
|
? "-".concat((0, utils_1.regularToKebabCase)(camerasList[idx] || 'default'))
|
|
231
201
|
: '';
|
|
232
|
-
downloadSnapshot(snapshotBlob, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
202
|
+
(0, utils_1.downloadSnapshot)(snapshotBlob, "".concat(filename).concat(cameraName, ".").concat(format));
|
|
233
203
|
});
|
|
234
204
|
return [2 /*return*/, Promise.resolve()];
|
|
235
205
|
case 9:
|
|
@@ -244,7 +214,6 @@ var Snapshots = /** @class */ (function () {
|
|
|
244
214
|
});
|
|
245
215
|
return [2 /*return*/, Promise.resolve(snapshotFiles)];
|
|
246
216
|
case 11: return [2 /*return*/, Promise.resolve(snapshotsRaw)];
|
|
247
|
-
case 12: return [2 /*return*/];
|
|
248
217
|
}
|
|
249
218
|
});
|
|
250
219
|
}); };
|
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import threekitAPI from '../api';
|
|
2
|
-
import { IThreekitPlayer,
|
|
2
|
+
import { IThreekitPlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../threekit';
|
|
3
3
|
import { IWishlist } from './Wishlist';
|
|
4
4
|
import Snapshots from './Snapshots';
|
|
5
|
+
import { ISaveConfiguration } from '../api/configurations';
|
|
5
6
|
interface ITreble {
|
|
6
7
|
player: IThreekitPlayer;
|
|
7
8
|
orgId: string;
|
|
8
9
|
initialConfiguration: IConfiguration;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
interface IEmailShareCredentials {
|
|
12
|
+
to: string;
|
|
13
|
+
from: string;
|
|
14
|
+
templateId: string;
|
|
14
15
|
}
|
|
15
16
|
declare class Treble {
|
|
16
17
|
_api: typeof threekitAPI;
|
|
@@ -20,12 +21,13 @@ declare class Treble {
|
|
|
20
21
|
private _snapshots;
|
|
21
22
|
takeSnapshots: Snapshots['takeSnapshots'];
|
|
22
23
|
constructor({ player, orgId, initialConfiguration }: ITreble);
|
|
23
|
-
saveConfiguration: (config?:
|
|
24
|
+
saveConfiguration: (config?: Omit<ISaveConfiguration, "configuration"> | undefined) => Promise<{
|
|
24
25
|
resumableUrl: string;
|
|
25
26
|
} & import("../http/configurations").IConfigurationResponse & {
|
|
26
27
|
thumbnail: string;
|
|
27
28
|
}>;
|
|
28
|
-
getNestedConfigurator: (address: string | Array<string>) =>
|
|
29
|
+
getNestedConfigurator: (address: string | Array<string>) => undefined | IThreekitPrivateConfigurator;
|
|
29
30
|
resetConfiguration: (configuration?: ISetConfiguration | undefined) => void;
|
|
31
|
+
sendEmail: (credentials: IEmailShareCredentials, templateData: Record<string, any>) => Promise<import("../http/server").IPostEmailResponse>;
|
|
30
32
|
}
|
|
31
33
|
export default Treble;
|
package/dist/Treble/Treble.js
CHANGED
|
@@ -50,22 +50,21 @@ var Treble = /** @class */ (function () {
|
|
|
50
50
|
var _this = this;
|
|
51
51
|
var player = _a.player, orgId = _a.orgId, initialConfiguration = _a.initialConfiguration;
|
|
52
52
|
this.saveConfiguration = function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
53
|
-
var threekitDomain, _a, customerId, metadata, productVersion,
|
|
53
|
+
var threekitDomain, _a, customerId, metadata, productVersion, attachments, response, params, url;
|
|
54
54
|
var _b;
|
|
55
55
|
var _c;
|
|
56
56
|
return __generator(this, function (_d) {
|
|
57
57
|
switch (_d.label) {
|
|
58
58
|
case 0:
|
|
59
59
|
threekitDomain = connection_1.default.getConnection().threekitDomain;
|
|
60
|
-
_a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, productVersion = _a.productVersion;
|
|
61
|
-
files = undefined;
|
|
60
|
+
_a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, productVersion = _a.productVersion, attachments = _a.attachments;
|
|
62
61
|
return [4 /*yield*/, api_1.default.configurations.save({
|
|
63
62
|
assetId: window.threekit.player.assetId,
|
|
64
63
|
configuration: window.threekit.configurator.getConfiguration(),
|
|
65
64
|
customerId: customerId,
|
|
66
65
|
metadata: metadata,
|
|
67
66
|
productVersion: productVersion,
|
|
68
|
-
|
|
67
|
+
attachments: attachments,
|
|
69
68
|
})];
|
|
70
69
|
case 1:
|
|
71
70
|
response = _d.sent();
|
|
@@ -84,14 +83,19 @@ var Treble = /** @class */ (function () {
|
|
|
84
83
|
});
|
|
85
84
|
}); };
|
|
86
85
|
this.getNestedConfigurator = function (address) {
|
|
86
|
+
if (!address)
|
|
87
|
+
return undefined;
|
|
87
88
|
var player = window.threekit.player.enableApi('player');
|
|
88
89
|
var addressArr = Array.isArray(address) ? address : [address];
|
|
89
90
|
return addressArr.reduce(function (configurator, attributeName) {
|
|
91
|
+
var _a;
|
|
92
|
+
if (!configurator)
|
|
93
|
+
return undefined;
|
|
90
94
|
var itemId = configurator.getAppliedConfiguration(attributeName);
|
|
91
|
-
return window.threekit.player.scene.get({
|
|
95
|
+
return (_a = window.threekit.player.scene.get({
|
|
92
96
|
id: itemId,
|
|
93
97
|
evalNode: true,
|
|
94
|
-
}).configurator;
|
|
98
|
+
})) === null || _a === void 0 ? void 0 : _a.configurator;
|
|
95
99
|
}, player.getConfigurator());
|
|
96
100
|
};
|
|
97
101
|
this.resetConfiguration = function (configuration) {
|
|
@@ -99,6 +103,22 @@ var Treble = /** @class */ (function () {
|
|
|
99
103
|
var updateConfiguration = Object.assign(initialConfiguration, configuration);
|
|
100
104
|
window.threekit.configurator.setConfiguration(updateConfiguration);
|
|
101
105
|
};
|
|
106
|
+
this.sendEmail = function (credentials, templateData) {
|
|
107
|
+
if (!credentials)
|
|
108
|
+
throw new Error('sendEmail is missing credentials object');
|
|
109
|
+
if (!credentials.from.length)
|
|
110
|
+
throw new Error('sendEmail is missing sender email - "From"');
|
|
111
|
+
if (!credentials.to.length)
|
|
112
|
+
throw new Error('sendEmail is missing receivers email - "To"');
|
|
113
|
+
if (!credentials.templateId.length)
|
|
114
|
+
throw new Error('sendEmail is missing the templateId to use - "TemplateId"');
|
|
115
|
+
var data = Object.assign({
|
|
116
|
+
To: credentials.to,
|
|
117
|
+
From: credentials.from,
|
|
118
|
+
TemplateId: credentials.templateId,
|
|
119
|
+
}, { TemplateModel: templateData });
|
|
120
|
+
return api_1.default.server.sendEmail(data);
|
|
121
|
+
};
|
|
102
122
|
// Threekit API
|
|
103
123
|
this._api = api_1.default;
|
|
104
124
|
this._player = player;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IConfigurationResponse } from '../http/configurations';
|
|
2
|
-
import {
|
|
2
|
+
import { ISaveConfiguration } from '../api/configurations';
|
|
3
3
|
export declare type WishlistArray = Array<IConfigurationResponse>;
|
|
4
4
|
export interface IWishlist {
|
|
5
5
|
getWishlist(): Promise<Array<IConfigurationResponse>>;
|
|
6
|
-
addItem(config?:
|
|
6
|
+
addItem(config?: Omit<ISaveConfiguration, 'configurator'>): Promise<Array<IConfigurationResponse>>;
|
|
7
7
|
removeItemByIdx(idx: number): Array<IConfigurationResponse>;
|
|
8
8
|
clearWishlist(): Array<IConfigurationResponse>;
|
|
9
9
|
}
|
|
@@ -11,7 +11,7 @@ declare class Wishlist implements IWishlist {
|
|
|
11
11
|
_wishlistKey: string;
|
|
12
12
|
constructor(orgId: string);
|
|
13
13
|
getWishlist: () => Promise<WishlistArray>;
|
|
14
|
-
addItem: (config?:
|
|
14
|
+
addItem: (config?: Omit<ISaveConfiguration, "configurator"> | undefined) => Promise<WishlistArray>;
|
|
15
15
|
removeItemByIdx: (idx: number) => WishlistArray;
|
|
16
16
|
clearWishlist: () => WishlistArray;
|
|
17
17
|
}
|
package/dist/Treble/Wishlist.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { IConfigurationResponse } from '../http/configurations';
|
|
2
2
|
import { IConfiguration, IMetadata } from '../threekit';
|
|
3
|
-
interface ISaveConfiguration {
|
|
3
|
+
export interface ISaveConfiguration {
|
|
4
4
|
assetId: string;
|
|
5
5
|
customerId?: string;
|
|
6
6
|
configuration: IConfiguration;
|
|
7
7
|
metadata?: IMetadata;
|
|
8
8
|
productVersion?: string;
|
|
9
|
-
|
|
9
|
+
attachments?: Record<string, File>;
|
|
10
10
|
}
|
|
11
11
|
export declare const save: (saveConfig: ISaveConfiguration) => Promise<import("axios").AxiosResponse<IConfigurationResponse>>;
|
|
12
12
|
export declare const fetch: (configurationId: string) => Promise<import("axios").AxiosResponse<IConfigurationResponse>>;
|
|
13
13
|
export declare const fetchAll: () => Promise<IConfigurationResponse[]>;
|
|
14
|
-
export {};
|
|
@@ -42,30 +42,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.fetchAll = exports.fetch = exports.save = void 0;
|
|
43
43
|
var http_1 = __importDefault(require("../http"));
|
|
44
44
|
var save = function (saveConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var assetId, customerId, configuration, metadata, productVersion,
|
|
45
|
+
var assetId, customerId, configuration, metadata, productVersion, attachments, error, fd, attachmentsPrepped_1;
|
|
46
46
|
return __generator(this, function (_a) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
assetId = saveConfig.assetId, customerId = saveConfig.customerId, configuration = saveConfig.configuration, metadata = saveConfig.metadata, productVersion = saveConfig.productVersion, attachments = saveConfig.attachments;
|
|
48
|
+
if (!assetId)
|
|
49
|
+
error = 'Requires Asset Id';
|
|
50
|
+
if (!configuration)
|
|
51
|
+
error = 'Requires a configuration';
|
|
52
|
+
if (error)
|
|
53
|
+
throw new Error(error);
|
|
54
|
+
fd = new FormData();
|
|
55
|
+
fd.append('productId', assetId);
|
|
56
|
+
fd.append('variant', JSON.stringify(configuration));
|
|
57
|
+
fd.append('productVersion', productVersion || 'v1');
|
|
58
|
+
if (metadata && Object.keys(metadata))
|
|
59
|
+
fd.append('metadata', JSON.stringify(metadata));
|
|
60
|
+
if (customerId)
|
|
61
|
+
fd.append('customerId', customerId);
|
|
62
|
+
if (attachments && Object.keys(attachments).length) {
|
|
63
|
+
attachmentsPrepped_1 = {};
|
|
64
|
+
Object.entries(attachments).forEach(function (_a) {
|
|
65
|
+
var _b;
|
|
66
|
+
var key = _a[0], file = _a[1];
|
|
67
|
+
fd.append('files', file);
|
|
68
|
+
attachmentsPrepped_1 = Object.assign({}, attachmentsPrepped_1, (_b = {},
|
|
69
|
+
_b[key] = file.name,
|
|
70
|
+
_b));
|
|
71
|
+
});
|
|
72
|
+
fd.append('attachments', JSON.stringify(attachmentsPrepped_1));
|
|
68
73
|
}
|
|
74
|
+
return [2 /*return*/, http_1.default.configurations.postConfiguration(fd)];
|
|
69
75
|
});
|
|
70
76
|
}); };
|
|
71
77
|
exports.save = save;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import * as configurations from './configurations';
|
|
|
3
3
|
import * as price from './price';
|
|
4
4
|
import * as orders from './orders';
|
|
5
5
|
import * as catalog from './catalog';
|
|
6
|
+
import * as server from './server';
|
|
6
7
|
declare const _default: {
|
|
7
8
|
products: typeof products;
|
|
8
9
|
configurations: typeof configurations;
|
|
9
10
|
price: typeof price;
|
|
10
11
|
orders: typeof orders;
|
|
11
12
|
catalog: typeof catalog;
|
|
13
|
+
server: typeof server;
|
|
12
14
|
};
|
|
13
15
|
export default _default;
|
package/dist/api/index.js
CHANGED
|
@@ -24,10 +24,12 @@ var configurations = __importStar(require("./configurations"));
|
|
|
24
24
|
var price = __importStar(require("./price"));
|
|
25
25
|
var orders = __importStar(require("./orders"));
|
|
26
26
|
var catalog = __importStar(require("./catalog"));
|
|
27
|
+
var server = __importStar(require("./server"));
|
|
27
28
|
exports.default = {
|
|
28
29
|
products: products,
|
|
29
30
|
configurations: configurations,
|
|
30
31
|
price: price,
|
|
31
32
|
orders: orders,
|
|
32
33
|
catalog: catalog,
|
|
34
|
+
server: server,
|
|
33
35
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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.sendEmail = void 0;
|
|
7
|
+
var http_1 = __importDefault(require("../http"));
|
|
8
|
+
var sendEmail = function (data) {
|
|
9
|
+
return http_1.default.server.postEmail(data);
|
|
10
|
+
};
|
|
11
|
+
exports.sendEmail = sendEmail;
|
|
@@ -38,7 +38,7 @@ var Price = function (props) {
|
|
|
38
38
|
return react_1.default.createElement(cards_styles_1.CardPrice, { className: "".concat(className, " option-price") }, price);
|
|
39
39
|
};
|
|
40
40
|
var Cards = function (props) {
|
|
41
|
-
var title = props.title, description = props.description, options = props.options,
|
|
41
|
+
var title = props.title, description = props.description, options = props.options, customClassName = props.className, showThumbnail = props.showThumbnail, showPrice = props.showPrice, showDescription = props.showDescription;
|
|
42
42
|
var cls = (0, utils_1.generateInputClassName)('cards', customClassName, title);
|
|
43
43
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
44
44
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
@@ -50,10 +50,9 @@ var Cards = function (props) {
|
|
|
50
50
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
51
51
|
price: !showPrice ? undefined : el.price,
|
|
52
52
|
description: !showDescription ? undefined : el.description,
|
|
53
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
54
|
-
var selected = value === optionValue;
|
|
53
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
55
54
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
56
|
-
return (react_1.default.createElement(cards_styles_1.CardWrapper, { key: i, onClick:
|
|
55
|
+
return (react_1.default.createElement(cards_styles_1.CardWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt },
|
|
57
56
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, name: name, className: clsOpt }),
|
|
58
57
|
react_1.default.createElement("div", null,
|
|
59
58
|
react_1.default.createElement(Title, { name: name, className: clsOpt }),
|
|
@@ -57,7 +57,7 @@ var Price = function (props) {
|
|
|
57
57
|
return (react_1.default.createElement(dropdown_styles_1.OptionPrice, { className: "".concat(className, " option-price") }, price));
|
|
58
58
|
};
|
|
59
59
|
var Dropdown = function (props) {
|
|
60
|
-
var title = props.title, description = props.description, options = props.options, value = props.value,
|
|
60
|
+
var title = props.title, description = props.description, options = props.options, value = props.value, customClassName = props.className, showThumbnail = props.showThumbnail, showPrice = props.showPrice, showDescription = props.showDescription, dropdownMaxHeight = props.dropdownMaxHeight;
|
|
61
61
|
var _a = (0, react_1.useState)(true), hide = _a[0], setHide = _a[1];
|
|
62
62
|
var ref = (0, react_1.useRef)(null);
|
|
63
63
|
(0, react_1.useEffect)(function () {
|
|
@@ -73,12 +73,6 @@ var Dropdown = function (props) {
|
|
|
73
73
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
74
74
|
};
|
|
75
75
|
}, [hide, ref]);
|
|
76
|
-
var handleClick = function (value) {
|
|
77
|
-
if (!onClick)
|
|
78
|
-
return;
|
|
79
|
-
onClick(value);
|
|
80
|
-
setHide(true);
|
|
81
|
-
};
|
|
82
76
|
var cls = (0, utils_1.generateInputClassName)('dropdown', customClassName, title);
|
|
83
77
|
var selectedOpt = options === null || options === void 0 ? void 0 : options.find(function (el) { return el.value === value; });
|
|
84
78
|
return (react_1.default.createElement("div", { className: cls },
|
|
@@ -105,10 +99,12 @@ var Dropdown = function (props) {
|
|
|
105
99
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
106
100
|
price: !showPrice ? undefined : el.price,
|
|
107
101
|
description: !showDescription ? undefined : el.description,
|
|
108
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
109
|
-
var selected = value === optionValue;
|
|
102
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
110
103
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue);
|
|
111
|
-
return (react_1.default.createElement(dropdown_styles_1.OptionWrapper, { key: i, onClick: function () {
|
|
104
|
+
return (react_1.default.createElement(dropdown_styles_1.OptionWrapper, { key: i, onClick: function () {
|
|
105
|
+
handleSelect();
|
|
106
|
+
setHide(true);
|
|
107
|
+
}, className: clsOpt, selected: selected },
|
|
112
108
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, name: name, className: clsOpt }),
|
|
113
109
|
react_1.default.createElement("div", null,
|
|
114
110
|
react_1.default.createElement(Title, { name: name, className: clsOpt }),
|
|
@@ -38,7 +38,7 @@ var Price = function (props) {
|
|
|
38
38
|
return (react_1.default.createElement(strips_styles_1.StripPrice, { className: "".concat(className, " option-price") }, price));
|
|
39
39
|
};
|
|
40
40
|
var Strips = function (props) {
|
|
41
|
-
var title = props.title, description = props.description, options = props.options,
|
|
41
|
+
var title = props.title, description = props.description, options = props.options, customClassName = props.className, showThumbnail = props.showThumbnail, showPrice = props.showPrice, showDescription = props.showDescription;
|
|
42
42
|
var cls = (0, utils_1.generateInputClassName)('strips', customClassName, title);
|
|
43
43
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
44
44
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
@@ -50,10 +50,9 @@ var Strips = function (props) {
|
|
|
50
50
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
51
51
|
price: !showPrice ? undefined : el.price,
|
|
52
52
|
description: !showDescription ? undefined : el.description,
|
|
53
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
54
|
-
var selected = value === optionValue;
|
|
53
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
55
54
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
56
|
-
return (react_1.default.createElement(strips_styles_1.StripWrapper, { key: i, onClick:
|
|
55
|
+
return (react_1.default.createElement(strips_styles_1.StripWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt },
|
|
57
56
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, name: name, className: clsOpt }),
|
|
58
57
|
react_1.default.createElement("div", null,
|
|
59
58
|
react_1.default.createElement(Title, { name: name, className: clsOpt }),
|
|
@@ -30,7 +30,7 @@ var Thumbnail = function (props) {
|
|
|
30
30
|
return (react_1.default.createElement(swatch_styles_1.OptionThumbnail, { className: "".concat(className, " option-thumbnail"), color: color, shape: shape, size: size }, imageUrl ? react_1.default.createElement("img", { src: imageUrl, alt: name || '' }) : react_1.default.createElement("span", null)));
|
|
31
31
|
};
|
|
32
32
|
var Swatch = function (props) {
|
|
33
|
-
var _a = Object.assign({ shape: 'round', size: '60px' }, props), title = _a.title, shape = _a.shape, description = _a.description, options = _a.options,
|
|
33
|
+
var _a = Object.assign({ shape: 'round', size: '60px' }, props), title = _a.title, shape = _a.shape, description = _a.description, options = _a.options, customClassName = _a.className, showThumbnail = _a.showThumbnail, showPrice = _a.showPrice, showDescription = _a.showDescription, size = _a.size;
|
|
34
34
|
var cls = (0, utils_1.generateInputClassName)('swatch', customClassName, title);
|
|
35
35
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
36
36
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
@@ -42,10 +42,9 @@ var Swatch = function (props) {
|
|
|
42
42
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
43
43
|
price: !showPrice ? undefined : el.price,
|
|
44
44
|
description: !showDescription ? undefined : el.description,
|
|
45
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
46
|
-
var selected = value === optionValue;
|
|
45
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
47
46
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
48
|
-
return (react_1.default.createElement(swatch_styles_1.OptionWrapper, { key: i, onClick:
|
|
47
|
+
return (react_1.default.createElement(swatch_styles_1.OptionWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt, shape: shape, size: size },
|
|
49
48
|
react_1.default.createElement("div", null,
|
|
50
49
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, shape: shape, className: clsOpt, size: size })),
|
|
51
50
|
react_1.default.createElement(SwatchInfo, { title: name, price: price, description: description })));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IFormComponentProps } from '../containers/formInputContainer';
|
|
3
3
|
export interface ITextInput extends IFormComponentProps<undefined> {
|
|
4
|
+
maxLength?: number;
|
|
4
5
|
}
|
|
5
6
|
export declare const TextInput: {
|
|
6
7
|
(props: ITextInput): JSX.Element;
|
|
@@ -14,12 +14,12 @@ var utils_1 = require("../../utils");
|
|
|
14
14
|
var constants_1 = require("../../constants");
|
|
15
15
|
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
16
16
|
var TextInput = function (props) {
|
|
17
|
-
var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
|
|
17
|
+
var title = props.title, description = props.description, value = props.value, onChange = props.onChange, maxLength = props.maxLength, customClassName = props.className;
|
|
18
18
|
var cls = (0, utils_1.generateInputClassName)('text-input', customClassName, title);
|
|
19
19
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
20
20
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
21
21
|
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
22
|
-
react_1.default.createElement(textInput_styles_1.Input, { type: "text", value: value, onChange: function (e) { return onChange && onChange(e.target.value); }, className: cls })));
|
|
22
|
+
react_1.default.createElement(textInput_styles_1.Input, { type: "text", maxLength: maxLength, value: value, onChange: function (e) { return onChange && onChange(e.target.value); }, className: cls })));
|
|
23
23
|
};
|
|
24
24
|
exports.TextInput = TextInput;
|
|
25
25
|
exports.TextInput.componentName = 'text-input';
|
|
@@ -9,5 +9,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.Input = void 0;
|
|
11
11
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
-
exports.Input = styled_components_1.default.input(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n margin: 0;\n padding:
|
|
12
|
+
exports.Input = styled_components_1.default.input(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n margin: 0;\n padding: 8px 7px;\n background: #fff;\n border: 1px solid #d9d9d9;\n color: ", ";\n outline: none;\n border-radius: 2px;\n font-size: 14px;\n transition: all 0.3s;\n font-family: ", ";\n\n &:hover {\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n"], ["\n width: 100%;\n margin: 0;\n padding: 8px 7px;\n background: #fff;\n border: 1px solid #d9d9d9;\n color: ", ";\n outline: none;\n border-radius: 2px;\n font-size: 14px;\n transition: all 0.3s;\n font-family: ", ";\n\n &:hover {\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n"])), function (props) { return props.theme.textColor; }, function (props) { return props.theme.fontFamily; }, function (props) { return props.theme.primaryColor; }, function (props) { return props.theme.primaryColor; }, function (props) { return "".concat(props.theme.primaryColor, "33"); });
|
|
13
13
|
var templateObject_1;
|
|
@@ -31,10 +31,17 @@ var theme_1 = __importDefault(require("../../theme"));
|
|
|
31
31
|
var GlobalStyles_styles_1 = __importDefault(require("./GlobalStyles.styles"));
|
|
32
32
|
var App = function (props) {
|
|
33
33
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
34
|
+
var playerConfig = props.playerConfig, productId = props.productId, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
|
|
34
35
|
(0, react_1.useEffect)(function () {
|
|
35
36
|
var init = function () {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
dispatch((0, treble_1.launch)({
|
|
38
|
+
playerConfig: playerConfig,
|
|
39
|
+
productId: productId,
|
|
40
|
+
project: project,
|
|
41
|
+
locale: locale,
|
|
42
|
+
threekitEnv: threekitEnv,
|
|
43
|
+
eventHandlers: eventHandlers,
|
|
44
|
+
}));
|
|
38
45
|
};
|
|
39
46
|
init();
|
|
40
47
|
return;
|
|
@@ -45,6 +52,6 @@ var ThreekitProvider = function (props) {
|
|
|
45
52
|
return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
|
|
46
53
|
react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
|
|
47
54
|
react_1.default.createElement(GlobalStyles_styles_1.default, null),
|
|
48
|
-
react_1.default.createElement(App, { locale: props.locale, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children))));
|
|
55
|
+
react_1.default.createElement(App, { locale: props.locale, productId: props.productId, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children))));
|
|
49
56
|
};
|
|
50
57
|
exports.default = ThreekitProvider;
|
|
@@ -14,16 +14,15 @@ var utils_1 = require("../../utils");
|
|
|
14
14
|
var constants_1 = require("../../constants");
|
|
15
15
|
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
16
16
|
var Tiles = function (props) {
|
|
17
|
-
var _a = Object.assign({ columns: 2 }, props), title = _a.title, description = _a.description, options = _a.options,
|
|
17
|
+
var _a = Object.assign({ columns: 2 }, props), title = _a.title, description = _a.description, options = _a.options, customClassName = _a.className, columns = _a.columns;
|
|
18
18
|
var cls = (0, utils_1.generateInputClassName)('tiles', customClassName, title);
|
|
19
19
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
20
20
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
21
21
|
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
22
22
|
react_1.default.createElement(tiles_styles_1.TilesWrapper, { columns: columns }, options === null || options === void 0 ? void 0 : options.map(function (el, i) {
|
|
23
|
-
var name = el.name, optionValue = el.value;
|
|
24
|
-
var selected = value === optionValue;
|
|
23
|
+
var name = el.name, optionValue = el.value, selected = el.selected, handleSelect = el.handleSelect;
|
|
25
24
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
26
|
-
return (react_1.default.createElement(tiles_styles_1.TileWrapper, { key: i, onClick:
|
|
25
|
+
return (react_1.default.createElement(tiles_styles_1.TileWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt },
|
|
27
26
|
react_1.default.createElement("div", null, name)));
|
|
28
27
|
}))));
|
|
29
28
|
};
|