zakeke-configurator-react 0.0.137 → 0.0.138

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.
Files changed (2) hide show
  1. package/dist/index.js +58 -50
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25259,13 +25259,13 @@ class ZakekeEnvironment {
25259
25259
  });
25260
25260
  // Create quote for composition
25261
25261
  this.createQuote = (formData) => __awaiter(this, void 0, void 0, function* () {
25262
- var _c, _d;
25262
+ var _c, _e;
25263
25263
  let quote = new _models__WEBPACK_IMPORTED_MODULE_11__.Quote();
25264
25264
  quote.formData = JSON.stringify(formData);
25265
25265
  quote.quantity = this.quantity;
25266
25266
  quote.compositionDocID = this.composition.get('docID');
25267
25267
  quote.modelPrice = (_c = yield this.integration.getPrice(this.composition, this.zkCurrentTemplate, this.zkProduct, this.platformAttributesSelection, 0, 1)) !== null && _c !== void 0 ? _c : 0;
25268
- quote.variantName = (_d = this.product.name) !== null && _d !== void 0 ? _d : "";
25268
+ quote.variantName = (_e = this.product.name) !== null && _e !== void 0 ? _e : "";
25269
25269
  const quoteCreated = (yield _api__WEBPACK_IMPORTED_MODULE_4__.axiosApi.post(Zakeke.config.baseApiUrl + "quotes", quote)).data;
25270
25270
  return quoteCreated;
25271
25271
  });
@@ -25280,7 +25280,7 @@ class ZakekeEnvironment {
25280
25280
  dataType: "json"
25281
25281
  });
25282
25282
  if (response != null) {
25283
- console.log(`getTranslations response is OK: ${JSON.stringify(response)}`);
25283
+ // console.log(`getTranslations response is OK: ${JSON.stringify(response)}`);
25284
25284
  return response;
25285
25285
  }
25286
25286
  else {
@@ -25319,7 +25319,7 @@ class ZakekeEnvironment {
25319
25319
  return window.localStorage.getItem(this.copyrightMessageLocalStorageKey) ? true : false;
25320
25320
  };
25321
25321
  this.boot = (parameters) => __awaiter(this, void 0, void 0, function* () {
25322
- var _e, _f;
25322
+ var _f, _g;
25323
25323
  this.parseParameters(parameters);
25324
25324
  (0,_api__WEBPACK_IMPORTED_MODULE_4__.setupApi)(this.culture, this.token);
25325
25325
  yield this.loadLocalization();
@@ -25334,6 +25334,7 @@ class ZakekeEnvironment {
25334
25334
  statics: staticTranslations,
25335
25335
  dynamics: dynamicTranslations
25336
25336
  };
25337
+ _helpers__WEBPACK_IMPORTED_MODULE_7__.T.translations = this.publicTranslations;
25337
25338
  this.trigger("change");
25338
25339
  const composerModels = yield this.getComposerModels();
25339
25340
  this.zkScene = composerModels.get('scene');
@@ -25352,7 +25353,7 @@ class ZakekeEnvironment {
25352
25353
  this.trigger("change");
25353
25354
  this.zkTemplates = yield this.getTemplates();
25354
25355
  this.templates = this.zkTemplates.map(zkTemplate => _models__WEBPACK_IMPORTED_MODULE_11__.Template.fromTemplate(zkTemplate));
25355
- this.cameras = (_f = (_e = this.zkScene) === null || _e === void 0 ? void 0 : _e.get('cameraLocations').map(x => _models__WEBPACK_IMPORTED_MODULE_11__.Camera.fromZkCamera(x))) !== null && _f !== void 0 ? _f : [];
25356
+ this.cameras = (_g = (_f = this.zkScene) === null || _f === void 0 ? void 0 : _f.get('cameraLocations').map(x => _models__WEBPACK_IMPORTED_MODULE_11__.Camera.fromZkCamera(x))) !== null && _g !== void 0 ? _g : [];
25356
25357
  this.trigger("change");
25357
25358
  this.viewer = yield _3D_src__WEBPACK_IMPORTED_MODULE_2__.SceneViewer.createSceneViewerAsync();
25358
25359
  this.viewer.isHologramSource = true;
@@ -25439,39 +25440,22 @@ class ZakekeEnvironment {
25439
25440
  const currentOption = currentAttr.get("options").find(opt => opt.get("optionID") == item.optionID);
25440
25441
  const currentGroup = storeGroups.find(group => group.get("groupID") == currentAttr.get('groupID'));
25441
25442
  const currentStep = storeSteps.find(step => step.get("stepID") == currentAttr.get('stepID'));
25442
- let groupName = "";
25443
+ let label = "";
25443
25444
  let isOptionEnabled = false;
25444
25445
  this.selection.get("groups").each(group => {
25445
25446
  group.get("attributes").each(attr => {
25446
- var _a, _b, _c, _d, _e, _f, _g, _h;
25447
+ var _a, _b, _c, _e;
25447
25448
  const option = attr.get("options").find(x => x.get('optionID') == currentOption.get("optionID"));
25448
25449
  if (option && attr.get("enabled")) {
25449
25450
  isOptionEnabled = this.isOptionEnabled(currentOption.get("optionID"));
25450
- groupName = group.get("name");
25451
- if (isOptionEnabled) {
25452
- if (!recapProps[(currentAttr.get("name"))]) {
25453
- recapProps[(currentAttr.get("name"))] = {
25454
- groupDisplayOrder: (_a = currentGroup === null || currentGroup === void 0 ? void 0 : currentGroup.get('displayOrder')) !== null && _a !== void 0 ? _a : 0,
25455
- stepDisplayOrder: (_b = currentStep === null || currentStep === void 0 ? void 0 : currentStep.get('displayOrder')) !== null && _b !== void 0 ? _b : 0,
25456
- attributeDisplayOrder: (_c = currentAttr === null || currentAttr === void 0 ? void 0 : currentAttr.get('displayOrder')) !== null && _c !== void 0 ? _c : 0,
25457
- optionDisplayOrder: (_d = currentOption === null || currentOption === void 0 ? void 0 : currentOption.get('displayOrder')) !== null && _d !== void 0 ? _d : 0,
25458
- value: currentOption.get("name"),
25459
- groupName,
25460
- showGroup: false,
25461
- };
25462
- }
25463
- else {
25464
- recapProps[(currentAttr.get("name"))].showGroup = true;
25465
- recapProps[`${groupName} ${currentAttr.get("name")}`] = {
25466
- groupDisplayOrder: (_e = currentGroup === null || currentGroup === void 0 ? void 0 : currentGroup.get('displayOrder')) !== null && _e !== void 0 ? _e : 0,
25467
- stepDisplayOrder: (_f = currentStep === null || currentStep === void 0 ? void 0 : currentStep.get('displayOrder')) !== null && _f !== void 0 ? _f : 0,
25468
- attributeDisplayOrder: (_g = currentAttr === null || currentAttr === void 0 ? void 0 : currentAttr.get('displayOrder')) !== null && _g !== void 0 ? _g : 0,
25469
- optionDisplayOrder: (_h = currentOption === null || currentOption === void 0 ? void 0 : currentOption.get('displayOrder')) !== null && _h !== void 0 ? _h : 0,
25470
- value: currentOption.get("name"),
25471
- showGroup: false,
25472
- };
25473
- }
25474
- }
25451
+ label = group.get("groupID") !== -1 ? (_helpers__WEBPACK_IMPORTED_MODULE_7__.T._d(group.get("name")) + " " + _helpers__WEBPACK_IMPORTED_MODULE_7__.T._d(currentAttr.get("name"))) : _helpers__WEBPACK_IMPORTED_MODULE_7__.T._d(currentAttr.get("name"));
25452
+ recapProps[`${label}`] = {
25453
+ groupDisplayOrder: (_a = currentGroup === null || currentGroup === void 0 ? void 0 : currentGroup.get('displayOrder')) !== null && _a !== void 0 ? _a : 0,
25454
+ stepDisplayOrder: (_b = currentStep === null || currentStep === void 0 ? void 0 : currentStep.get('displayOrder')) !== null && _b !== void 0 ? _b : 0,
25455
+ attributeDisplayOrder: (_c = currentAttr === null || currentAttr === void 0 ? void 0 : currentAttr.get('displayOrder')) !== null && _c !== void 0 ? _c : 0,
25456
+ optionDisplayOrder: (_e = currentOption === null || currentOption === void 0 ? void 0 : currentOption.get('displayOrder')) !== null && _e !== void 0 ? _e : 0,
25457
+ value: _helpers__WEBPACK_IMPORTED_MODULE_7__.T._d(currentOption.get("name")),
25458
+ };
25475
25459
  }
25476
25460
  });
25477
25461
  });
@@ -26069,7 +26053,7 @@ class ZakekeEnvironment {
26069
26053
  this.renderDesign();
26070
26054
  };
26071
26055
  this.getTemplateUploadRestrictictions = (templateId, areaId) => {
26072
- var _a, _b, _c, _d, _e, _f, _g;
26056
+ var _a, _b, _c, _e, _f, _g, _h;
26073
26057
  const design = this.zkTemplates.find(x => x.get("templateDesignID") == templateId);
26074
26058
  if (!design)
26075
26059
  throw "Template does not exists with id " + templateId;
@@ -26089,10 +26073,10 @@ class ZakekeEnvironment {
26089
26073
  isUserImageAllowed: (_a = getUploadRestriction("isUserImageAllowed")) !== null && _a !== void 0 ? _a : true,
26090
26074
  isJpgAllowed: (_b = getUploadRestriction("isJpgAllowed")) !== null && _b !== void 0 ? _b : true,
26091
26075
  isPngAllowed: (_c = getUploadRestriction("isPngAllowed")) !== null && _c !== void 0 ? _c : true,
26092
- isSvgAllowed: (_d = getUploadRestriction("isSvgAllowed")) !== null && _d !== void 0 ? _d : true,
26093
- isPdfAllowed: ((_e = getUploadRestriction("isPdfAllowed")) !== null && _e !== void 0 ? _e : true) && !!pdfAddonEnabled,
26094
- isEpsAllowed: ((_f = getUploadRestriction("isEpsAllowed")) !== null && _f !== void 0 ? _f : true) && !!epsAddonEnabled,
26095
- isPdfWithRasterAllowed: ((_g = getUploadRestriction("isPdfWithRasterAllowed")) !== null && _g !== void 0 ? _g : true) && !!pdfAddonEnabled
26076
+ isSvgAllowed: (_e = getUploadRestriction("isSvgAllowed")) !== null && _e !== void 0 ? _e : true,
26077
+ isPdfAllowed: ((_f = getUploadRestriction("isPdfAllowed")) !== null && _f !== void 0 ? _f : true) && !!pdfAddonEnabled,
26078
+ isEpsAllowed: ((_g = getUploadRestriction("isEpsAllowed")) !== null && _g !== void 0 ? _g : true) && !!epsAddonEnabled,
26079
+ isPdfWithRasterAllowed: ((_h = getUploadRestriction("isPdfWithRasterAllowed")) !== null && _h !== void 0 ? _h : true) && !!pdfAddonEnabled
26096
26080
  };
26097
26081
  };
26098
26082
  // Get template
@@ -26180,12 +26164,12 @@ class ZakekeEnvironment {
26180
26164
  return new File([u8arr], filename, { type: mime });
26181
26165
  };
26182
26166
  this.addToCart = (additionalProperties, onBeforeSendDataToParent, legacyScreenshot) => __awaiter(this, void 0, void 0, function* () {
26183
- var _g;
26167
+ var _h;
26184
26168
  yield this.setExplodedMode(false);
26185
26169
  this.composition.set("compositionClientPreviews", []);
26186
26170
  const compositionClientPreviews = [];
26187
26171
  let sortedBuyScreenshotCameras = [];
26188
- const buyScreenshotCameras = (_g = this.zkScene) === null || _g === void 0 ? void 0 : _g.get("cameraLocations").filter(x => { var _a; return ((_a = x.get("name")) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf("buy_screenshot_camera_")) !== -1; });
26172
+ const buyScreenshotCameras = (_h = this.zkScene) === null || _h === void 0 ? void 0 : _h.get("cameraLocations").filter(x => { var _a; return ((_a = x.get("name")) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf("buy_screenshot_camera_")) !== -1; });
26189
26173
  if (buyScreenshotCameras)
26190
26174
  sortedBuyScreenshotCameras = lodash__WEBPACK_IMPORTED_MODULE_0___default().sortBy(buyScreenshotCameras, a => { return a.get("name"); });
26191
26175
  if (sortedBuyScreenshotCameras && sortedBuyScreenshotCameras.length > 0) {
@@ -26491,10 +26475,10 @@ class ZakekeEnvironment {
26491
26475
  })).data;
26492
26476
  });
26493
26477
  this.getPDF = () => __awaiter(this, void 0, void 0, function* () {
26494
- var _h;
26478
+ var _j;
26495
26479
  const data = yield this.getScreenshot(2048, 2048);
26496
26480
  const items = this.getDesignItemsInfo();
26497
- const areas = (_h = this.product) === null || _h === void 0 ? void 0 : _h.areas.filter(x => this.isAreaVisible(x.id)).map(x => ({
26481
+ const areas = (_j = this.product) === null || _j === void 0 ? void 0 : _j.areas.filter(x => this.isAreaVisible(x.id)).map(x => ({
26498
26482
  name: x.name,
26499
26483
  textItems: items.filter(i => i.areaId == x.id && i.type === ___WEBPACK_IMPORTED_MODULE_1__.ItemType.Text)
26500
26484
  })).filter(x => x.textItems.length > 0);
@@ -26535,8 +26519,8 @@ class ZakekeEnvironment {
26535
26519
  this.getShareCompositionUrl = () => __awaiter(this, void 0, void 0, function* () {
26536
26520
  // salvo (e riassegno dopo la creazione dello share url) l'id , per evitare problemi in caso di add to cart e edit
26537
26521
  // in questo modo ogni composizione condivisa è sempre diversa da quella di partenza
26538
- var _j;
26539
- const isDraft = (_j = this.composition.get("isDraft")) !== null && _j !== void 0 ? _j : false;
26522
+ var _k;
26523
+ const isDraft = (_k = this.composition.get("isDraft")) !== null && _k !== void 0 ? _k : false;
26540
26524
  this.composition.set("isDraft", false);
26541
26525
  const docID = yield this.saveCompositionCopy();
26542
26526
  this.composition.set("isDraft", isDraft);
@@ -26859,14 +26843,14 @@ class ZakekeEnvironment {
26859
26843
  }
26860
26844
  };
26861
26845
  this.saveComposition = (customPreviewSize, legacyScreenshot) => __awaiter(this, void 0, void 0, function* () {
26862
- var _k, _l, _m;
26846
+ var _l, _m, _o;
26863
26847
  console.log("Saving...");
26864
- const buyScreenshotCamera = (_k = this.zkScene) === null || _k === void 0 ? void 0 : _k.get("cameraLocations").find(x => { var _a; return ((_a = x.get("name")) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "buy_screenshot_camera"; });
26848
+ const buyScreenshotCamera = (_l = this.zkScene) === null || _l === void 0 ? void 0 : _l.get("cameraLocations").find(x => { var _a; return ((_a = x.get("name")) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "buy_screenshot_camera"; });
26865
26849
  if (!buyScreenshotCamera)
26866
26850
  this.viewer.restoreCameraState();
26867
26851
  yield (0,_helpers__WEBPACK_IMPORTED_MODULE_7__.sleep)(1);
26868
26852
  // Save image
26869
- const data = yield this.viewer.getSceneContentScreenshotAsync((_l = customPreviewSize === null || customPreviewSize === void 0 ? void 0 : customPreviewSize.customCartPreviewHeight) !== null && _l !== void 0 ? _l : this.previewWidth, (_m = customPreviewSize === null || customPreviewSize === void 0 ? void 0 : customPreviewSize.customCartPreviewWidth) !== null && _m !== void 0 ? _m : this.previewHeight, 0, this.zkCurrentTemplate, legacyScreenshot, buyScreenshotCamera);
26853
+ const data = yield this.viewer.getSceneContentScreenshotAsync((_m = customPreviewSize === null || customPreviewSize === void 0 ? void 0 : customPreviewSize.customCartPreviewHeight) !== null && _m !== void 0 ? _m : this.previewWidth, (_o = customPreviewSize === null || customPreviewSize === void 0 ? void 0 : customPreviewSize.customCartPreviewWidth) !== null && _o !== void 0 ? _o : this.previewHeight, 0, this.zkCurrentTemplate, legacyScreenshot, buyScreenshotCamera);
26870
26854
  this.composition.set("previewImageData", data);
26871
26855
  // Save composition
26872
26856
  yield this.saveDesignBackbone();
@@ -26888,8 +26872,8 @@ class ZakekeEnvironment {
26888
26872
  this.currentCompositionInfo.compositionTags = this.composition.get("tags");
26889
26873
  });
26890
26874
  this.loadSavedComposition = (docID) => __awaiter(this, void 0, void 0, function* () {
26891
- var _o;
26892
- const composition = (_o = this.savedCompositions) === null || _o === void 0 ? void 0 : _o.find(x => x.docID == docID);
26875
+ var _p;
26876
+ const composition = (_p = this.savedCompositions) === null || _p === void 0 ? void 0 : _p.find(x => x.docID == docID);
26893
26877
  if (composition)
26894
26878
  yield this.bootstrapComposition(new MPlaza.Composition(composition));
26895
26879
  });
@@ -27241,10 +27225,34 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
27241
27225
  });
27242
27226
  };
27243
27227
  class T {
27244
- static _(str, domain = "Composer") {
27245
- return window.gt.dgettext(domain, str);
27228
+ static _(str, domain) {
27229
+ var _a, _b;
27230
+ if ((_a = this.translations) === null || _a === void 0 ? void 0 : _a.statics) {
27231
+ const keys = Array.from((_b = this.translations) === null || _b === void 0 ? void 0 : _b.statics.keys());
27232
+ for (let key of keys) {
27233
+ if (key.toLowerCase() === str.toLowerCase())
27234
+ return this.translations.statics.get(key);
27235
+ }
27236
+ }
27237
+ let gt = window.gt;
27238
+ return gt ? gt.dgettext(domain, str) : str;
27239
+ }
27240
+ static _d(str) {
27241
+ var _a, _b;
27242
+ let string = str;
27243
+ if ((_a = this.translations) === null || _a === void 0 ? void 0 : _a.dynamics) {
27244
+ const keys = Array.from((_b = this.translations) === null || _b === void 0 ? void 0 : _b.dynamics.keys());
27245
+ for (let key of keys) {
27246
+ if (key.toLowerCase() === str.toLowerCase()) {
27247
+ if (this.translations.dynamics.get(key))
27248
+ string = this.translations.dynamics.get(key);
27249
+ }
27250
+ }
27251
+ }
27252
+ return string;
27246
27253
  }
27247
27254
  }
27255
+ T.translations = null;
27248
27256
  function dataURLtoFile(dataurl, filename) {
27249
27257
  var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
27250
27258
  while (n--) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zakeke-configurator-react",
3
- "version": "0.0.137",
3
+ "version": "0.0.138",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/declarations/composer/Module/src/index.d.ts",