@ikas/storefront 0.0.44 → 0.0.46

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/build/index.js CHANGED
@@ -11343,6 +11343,409 @@ var IkasCategoryListPropValueProvider = /** @class */ (function () {
11343
11343
  return IkasCategoryListPropValueProvider;
11344
11344
  }());
11345
11345
 
11346
+ var IkasCustomPropValueProvider = /** @class */ (function () {
11347
+ function IkasCustomPropValueProvider(value, customData, theme, pageType, pageSpecificData, pageParams) {
11348
+ this.value = value;
11349
+ this.customData = customData;
11350
+ this.theme = theme;
11351
+ this.pageType = pageType;
11352
+ this.pageSpecificData = pageSpecificData;
11353
+ this.pageParams = pageParams;
11354
+ }
11355
+ IkasCustomPropValueProvider.prototype.getValue = function () {
11356
+ return __awaiter(this, void 0, void 0, function () {
11357
+ var customDataValue, _a;
11358
+ return __generator(this, function (_b) {
11359
+ switch (_b.label) {
11360
+ case 0:
11361
+ if (this.value === undefined || this.value === null)
11362
+ return [2 /*return*/];
11363
+ _b.label = 1;
11364
+ case 1:
11365
+ _b.trys.push([1, 32, , 33]);
11366
+ _a = this.customData.type;
11367
+ switch (_a) {
11368
+ case exports.IkasThemeCustomDataType.TEXT: return [3 /*break*/, 2];
11369
+ case exports.IkasThemeCustomDataType.BOOLEAN: return [3 /*break*/, 4];
11370
+ case exports.IkasThemeCustomDataType.BRAND_LIST: return [3 /*break*/, 6];
11371
+ case exports.IkasThemeCustomDataType.BRAND: return [3 /*break*/, 8];
11372
+ case exports.IkasThemeCustomDataType.CATEGORY_LIST: return [3 /*break*/, 10];
11373
+ case exports.IkasThemeCustomDataType.CATEGORY: return [3 /*break*/, 12];
11374
+ case exports.IkasThemeCustomDataType.COLOR: return [3 /*break*/, 14];
11375
+ case exports.IkasThemeCustomDataType.IMAGE_LIST: return [3 /*break*/, 16];
11376
+ case exports.IkasThemeCustomDataType.IMAGE: return [3 /*break*/, 18];
11377
+ case exports.IkasThemeCustomDataType.LINK: return [3 /*break*/, 20];
11378
+ case exports.IkasThemeCustomDataType.LIST_OF_LINK: return [3 /*break*/, 20];
11379
+ case exports.IkasThemeCustomDataType.PRODUCT_DETAIL: return [3 /*break*/, 22];
11380
+ case exports.IkasThemeCustomDataType.PRODUCT_LIST: return [3 /*break*/, 24];
11381
+ case exports.IkasThemeCustomDataType.OBJECT: return [3 /*break*/, 26];
11382
+ case exports.IkasThemeCustomDataType.DYNAMIC_LIST: return [3 /*break*/, 28];
11383
+ case exports.IkasThemeCustomDataType.STATIC_LIST: return [3 /*break*/, 28];
11384
+ }
11385
+ return [3 /*break*/, 30];
11386
+ case 2: return [4 /*yield*/, this.getTextValue()];
11387
+ case 3:
11388
+ customDataValue = _b.sent();
11389
+ return [3 /*break*/, 31];
11390
+ case 4: return [4 /*yield*/, this.getBooleanValue()];
11391
+ case 5:
11392
+ customDataValue = _b.sent();
11393
+ return [3 /*break*/, 31];
11394
+ case 6: return [4 /*yield*/, this.getBrandListPropValue()];
11395
+ case 7:
11396
+ customDataValue = _b.sent();
11397
+ return [3 /*break*/, 31];
11398
+ case 8: return [4 /*yield*/, this.getBrandPropValue()];
11399
+ case 9:
11400
+ customDataValue = _b.sent();
11401
+ return [3 /*break*/, 31];
11402
+ case 10: return [4 /*yield*/, this.getCategoryListPropValue()];
11403
+ case 11:
11404
+ customDataValue = _b.sent();
11405
+ return [3 /*break*/, 31];
11406
+ case 12: return [4 /*yield*/, this.getCategoryPropValue()];
11407
+ case 13:
11408
+ customDataValue = _b.sent();
11409
+ return [3 /*break*/, 31];
11410
+ case 14: return [4 /*yield*/, this.getColorPropValue()];
11411
+ case 15:
11412
+ customDataValue = _b.sent();
11413
+ return [3 /*break*/, 31];
11414
+ case 16: return [4 /*yield*/, this.getImageListPropValue()];
11415
+ case 17:
11416
+ customDataValue = _b.sent();
11417
+ return [3 /*break*/, 31];
11418
+ case 18: return [4 /*yield*/, this.getImagePropValue()];
11419
+ case 19:
11420
+ customDataValue = _b.sent();
11421
+ return [3 /*break*/, 31];
11422
+ case 20: return [4 /*yield*/, this.getLinkPropValue()];
11423
+ case 21:
11424
+ customDataValue = _b.sent();
11425
+ return [3 /*break*/, 31];
11426
+ case 22: return [4 /*yield*/, this.getProductDetailPropValue()];
11427
+ case 23:
11428
+ customDataValue = _b.sent();
11429
+ return [3 /*break*/, 31];
11430
+ case 24: return [4 /*yield*/, this.getProductListPropValue()];
11431
+ case 25:
11432
+ customDataValue = _b.sent();
11433
+ return [3 /*break*/, 31];
11434
+ case 26: return [4 /*yield*/, this.getObjectValue()];
11435
+ case 27:
11436
+ customDataValue = _b.sent();
11437
+ return [3 /*break*/, 31];
11438
+ case 28: return [4 /*yield*/, this.getArrayValue()];
11439
+ case 29:
11440
+ customDataValue = _b.sent();
11441
+ return [3 /*break*/, 31];
11442
+ case 30: return [3 /*break*/, 31];
11443
+ case 31: return [3 /*break*/, 33];
11444
+ case 32:
11445
+ _b.sent();
11446
+ return [2 /*return*/];
11447
+ case 33: return [2 /*return*/, JSON.parse(JSON.stringify(customDataValue))];
11448
+ }
11449
+ });
11450
+ });
11451
+ };
11452
+ IkasCustomPropValueProvider.prototype.getBooleanValue = function () {
11453
+ return __awaiter(this, void 0, void 0, function () {
11454
+ var provider, value;
11455
+ return __generator(this, function (_a) {
11456
+ switch (_a.label) {
11457
+ case 0:
11458
+ provider = new IkasBooleanPropValueProvider(this.value);
11459
+ return [4 /*yield*/, provider.getValue()];
11460
+ case 1:
11461
+ value = _a.sent();
11462
+ return [2 /*return*/, {
11463
+ value: value,
11464
+ customData: this.customData,
11465
+ }];
11466
+ }
11467
+ });
11468
+ });
11469
+ };
11470
+ IkasCustomPropValueProvider.prototype.getBrandListPropValue = function () {
11471
+ return __awaiter(this, void 0, void 0, function () {
11472
+ var provider, value;
11473
+ return __generator(this, function (_a) {
11474
+ switch (_a.label) {
11475
+ case 0:
11476
+ provider = new IkasBrandListPropValueProvider(this.value);
11477
+ return [4 /*yield*/, provider.getValue()];
11478
+ case 1:
11479
+ value = _a.sent();
11480
+ return [2 /*return*/, {
11481
+ value: value,
11482
+ customData: this.customData,
11483
+ }];
11484
+ }
11485
+ });
11486
+ });
11487
+ };
11488
+ IkasCustomPropValueProvider.prototype.getBrandPropValue = function () {
11489
+ return __awaiter(this, void 0, void 0, function () {
11490
+ var provider, value;
11491
+ return __generator(this, function (_a) {
11492
+ switch (_a.label) {
11493
+ case 0:
11494
+ provider = new IkasBrandPropValueProvider(this.value, this.pageSpecificData);
11495
+ return [4 /*yield*/, provider.getValue()];
11496
+ case 1:
11497
+ value = _a.sent();
11498
+ return [2 /*return*/, {
11499
+ value: value,
11500
+ customData: this.customData,
11501
+ }];
11502
+ }
11503
+ });
11504
+ });
11505
+ };
11506
+ IkasCustomPropValueProvider.prototype.getCategoryListPropValue = function () {
11507
+ return __awaiter(this, void 0, void 0, function () {
11508
+ var provider, value;
11509
+ return __generator(this, function (_a) {
11510
+ switch (_a.label) {
11511
+ case 0:
11512
+ provider = new IkasCategoryListPropValueProvider(this.value);
11513
+ return [4 /*yield*/, provider.getValue()];
11514
+ case 1:
11515
+ value = _a.sent();
11516
+ return [2 /*return*/, {
11517
+ value: value,
11518
+ customData: this.customData,
11519
+ }];
11520
+ }
11521
+ });
11522
+ });
11523
+ };
11524
+ IkasCustomPropValueProvider.prototype.getCategoryPropValue = function () {
11525
+ return __awaiter(this, void 0, void 0, function () {
11526
+ var provider, value;
11527
+ return __generator(this, function (_a) {
11528
+ switch (_a.label) {
11529
+ case 0:
11530
+ provider = new IkasCategoryPropValueProvider(this.value, this.pageSpecificData);
11531
+ return [4 /*yield*/, provider.getValue()];
11532
+ case 1:
11533
+ value = _a.sent();
11534
+ return [2 /*return*/, {
11535
+ value: value,
11536
+ customData: this.customData,
11537
+ }];
11538
+ }
11539
+ });
11540
+ });
11541
+ };
11542
+ IkasCustomPropValueProvider.prototype.getColorPropValue = function () {
11543
+ return __awaiter(this, void 0, void 0, function () {
11544
+ var provider, value;
11545
+ return __generator(this, function (_a) {
11546
+ switch (_a.label) {
11547
+ case 0:
11548
+ provider = new IkasColorPropValueProvider(this.value);
11549
+ return [4 /*yield*/, provider.getValue()];
11550
+ case 1:
11551
+ value = _a.sent();
11552
+ return [2 /*return*/, {
11553
+ value: value,
11554
+ customData: this.customData,
11555
+ }];
11556
+ }
11557
+ });
11558
+ });
11559
+ };
11560
+ IkasCustomPropValueProvider.prototype.getImageListPropValue = function () {
11561
+ return __awaiter(this, void 0, void 0, function () {
11562
+ var provider, value;
11563
+ return __generator(this, function (_a) {
11564
+ switch (_a.label) {
11565
+ case 0:
11566
+ provider = new IkasImageListPropValueProvider(this.value);
11567
+ return [4 /*yield*/, provider.getValue()];
11568
+ case 1:
11569
+ value = _a.sent();
11570
+ return [2 /*return*/, {
11571
+ value: value,
11572
+ customData: this.customData,
11573
+ }];
11574
+ }
11575
+ });
11576
+ });
11577
+ };
11578
+ IkasCustomPropValueProvider.prototype.getImagePropValue = function () {
11579
+ return __awaiter(this, void 0, void 0, function () {
11580
+ var provider, value;
11581
+ return __generator(this, function (_a) {
11582
+ switch (_a.label) {
11583
+ case 0:
11584
+ provider = new IkasImagePropValueProvider(this.value);
11585
+ return [4 /*yield*/, provider.getValue()];
11586
+ case 1:
11587
+ value = _a.sent();
11588
+ return [2 /*return*/, {
11589
+ value: value,
11590
+ customData: this.customData,
11591
+ }];
11592
+ }
11593
+ });
11594
+ });
11595
+ };
11596
+ IkasCustomPropValueProvider.prototype.getLinkPropValue = function () {
11597
+ return __awaiter(this, void 0, void 0, function () {
11598
+ var provider, value;
11599
+ return __generator(this, function (_a) {
11600
+ switch (_a.label) {
11601
+ case 0:
11602
+ provider = new IkasLinkPropValueProvider(this.value, this.theme);
11603
+ return [4 /*yield*/, provider.getValue()];
11604
+ case 1:
11605
+ value = _a.sent();
11606
+ return [2 /*return*/, {
11607
+ value: value,
11608
+ customData: this.customData,
11609
+ }];
11610
+ }
11611
+ });
11612
+ });
11613
+ };
11614
+ IkasCustomPropValueProvider.prototype.getProductDetailPropValue = function () {
11615
+ return __awaiter(this, void 0, void 0, function () {
11616
+ var provider, value;
11617
+ return __generator(this, function (_a) {
11618
+ switch (_a.label) {
11619
+ case 0:
11620
+ provider = new IkasProductDetailPropValueProvider(this.value, this.pageSpecificData);
11621
+ return [4 /*yield*/, provider.getValue()];
11622
+ case 1:
11623
+ value = _a.sent();
11624
+ return [2 /*return*/, {
11625
+ value: value,
11626
+ customData: this.customData,
11627
+ }];
11628
+ }
11629
+ });
11630
+ });
11631
+ };
11632
+ IkasCustomPropValueProvider.prototype.getProductListPropValue = function () {
11633
+ return __awaiter(this, void 0, void 0, function () {
11634
+ var provider, value;
11635
+ return __generator(this, function (_a) {
11636
+ switch (_a.label) {
11637
+ case 0:
11638
+ provider = new IkasProductListPropValueProvider(this.pageType, this.value, this.pageParams || {}, this.pageSpecificData);
11639
+ return [4 /*yield*/, provider.getValue()];
11640
+ case 1:
11641
+ value = _a.sent();
11642
+ return [2 /*return*/, {
11643
+ value: value,
11644
+ customData: this.customData,
11645
+ }];
11646
+ }
11647
+ });
11648
+ });
11649
+ };
11650
+ IkasCustomPropValueProvider.prototype.getTextValue = function () {
11651
+ return __awaiter(this, void 0, void 0, function () {
11652
+ var provider, value;
11653
+ return __generator(this, function (_a) {
11654
+ switch (_a.label) {
11655
+ case 0:
11656
+ provider = new IkasTextPropValueProvider(this.value);
11657
+ return [4 /*yield*/, provider.getValue()];
11658
+ case 1:
11659
+ value = _a.sent();
11660
+ return [2 /*return*/, {
11661
+ value: value,
11662
+ customData: this.customData,
11663
+ }];
11664
+ }
11665
+ });
11666
+ });
11667
+ };
11668
+ IkasCustomPropValueProvider.prototype.getObjectValue = function () {
11669
+ return __awaiter(this, void 0, void 0, function () {
11670
+ var objectValue, _i, _a, nestedData, nestedValue, nestedProvider, _itemValue;
11671
+ return __generator(this, function (_b) {
11672
+ switch (_b.label) {
11673
+ case 0:
11674
+ objectValue = {};
11675
+ _i = 0, _a = this.customData.nestedData || [];
11676
+ _b.label = 1;
11677
+ case 1:
11678
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
11679
+ nestedData = _a[_i];
11680
+ if (!nestedData.key)
11681
+ return [3 /*break*/, 3];
11682
+ nestedValue = this.value[nestedData.key];
11683
+ if (nestedData.isRequired &&
11684
+ (nestedValue === undefined || nestedValue === null))
11685
+ throw new Error("Required data is missing");
11686
+ nestedProvider = new IkasCustomPropValueProvider(nestedValue, nestedData, this.theme, this.pageSpecificData);
11687
+ return [4 /*yield*/, nestedProvider.getValue()];
11688
+ case 2:
11689
+ _itemValue = _b.sent();
11690
+ if (nestedData.isRequired &&
11691
+ (_itemValue === null || _itemValue === undefined))
11692
+ throw new Error("Required data is missing");
11693
+ objectValue[nestedData.key] = _itemValue;
11694
+ _b.label = 3;
11695
+ case 3:
11696
+ _i++;
11697
+ return [3 /*break*/, 1];
11698
+ case 4: return [2 /*return*/, {
11699
+ value: objectValue,
11700
+ customData: this.customData,
11701
+ }];
11702
+ }
11703
+ });
11704
+ });
11705
+ };
11706
+ IkasCustomPropValueProvider.prototype.getArrayValue = function () {
11707
+ return __awaiter(this, void 0, void 0, function () {
11708
+ var value, nestedData, _i, _a, itemValue, provider, _itemValue;
11709
+ return __generator(this, function (_b) {
11710
+ switch (_b.label) {
11711
+ case 0:
11712
+ if (!this.value || !Array.isArray(this.value))
11713
+ throw new Error("Incorrect data!");
11714
+ value = [];
11715
+ nestedData = this.customData.nestedData[0];
11716
+ _i = 0, _a = this.value;
11717
+ _b.label = 1;
11718
+ case 1:
11719
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
11720
+ itemValue = _a[_i];
11721
+ if (nestedData.isRequired &&
11722
+ (itemValue === undefined || itemValue === null))
11723
+ throw new Error("Required data is missing");
11724
+ provider = new IkasCustomPropValueProvider(itemValue, nestedData, this.theme, this.pageSpecificData);
11725
+ return [4 /*yield*/, provider.getValue()];
11726
+ case 2:
11727
+ _itemValue = _b.sent();
11728
+ if (nestedData.isRequired &&
11729
+ (_itemValue === null || _itemValue === undefined)) {
11730
+ throw new Error("Required data is missing");
11731
+ }
11732
+ else
11733
+ value.push(_itemValue);
11734
+ _b.label = 3;
11735
+ case 3:
11736
+ _i++;
11737
+ return [3 /*break*/, 1];
11738
+ case 4: return [2 /*return*/, {
11739
+ value: value,
11740
+ customData: this.customData,
11741
+ }];
11742
+ }
11743
+ });
11744
+ });
11745
+ };
11746
+ return IkasCustomPropValueProvider;
11747
+ }());
11748
+
11346
11749
  var IkasPageDataProvider = /** @class */ (function () {
11347
11750
  function IkasPageDataProvider(theme, pageParams, pageType) {
11348
11751
  this.pageType = null;
@@ -11605,7 +12008,7 @@ var IkasPageDataProvider = /** @class */ (function () {
11605
12008
  };
11606
12009
  IkasPageDataProvider.prototype.getPageComponentPropValue = function (pageComponent, prop) {
11607
12010
  return __awaiter(this, void 0, void 0, function () {
11608
- var propValueProvider, propValue;
12011
+ var propValueProvider, propValue, customData;
11609
12012
  return __generator(this, function (_a) {
11610
12013
  switch (_a.label) {
11611
12014
  case 0:
@@ -11650,6 +12053,12 @@ var IkasPageDataProvider = /** @class */ (function () {
11650
12053
  case exports.IkasThemeComponentPropType.COLOR:
11651
12054
  propValueProvider = new IkasColorPropValueProvider(propValue);
11652
12055
  break;
12056
+ case exports.IkasThemeComponentPropType.CUSTOM:
12057
+ customData = this.theme.customData.find(function (cd) { return cd.id === prop.customDataId; });
12058
+ if (!customData)
12059
+ return [2 /*return*/];
12060
+ propValueProvider = new IkasCustomPropValueProvider(propValue, customData, this.theme, this.pageType, this.pageSpecificData, this.pageParams);
12061
+ break;
11653
12062
  }
11654
12063
  return [4 /*yield*/, (propValueProvider === null || propValueProvider === void 0 ? void 0 : propValueProvider.getValue())];
11655
12064
  case 1: return [2 /*return*/, _a.sent()];
@@ -11707,32 +12116,49 @@ var IkasPageDataProvider = /** @class */ (function () {
11707
12116
  case exports.IkasThemeComponentPropType.LIST_OF_LINK:
11708
12117
  IkasPageDataProvider.initLinkPropValue(prop, propValue, pageComponentPropValue);
11709
12118
  break;
12119
+ case exports.IkasThemeComponentPropType.CUSTOM:
12120
+ IkasPageDataProvider.initCustomDataPropValue(prop, propValue, pageComponentPropValue, router, isBrowser);
12121
+ break;
11710
12122
  }
11711
12123
  });
11712
12124
  });
11713
12125
  return pageComponentPropValues;
11714
12126
  };
11715
12127
  IkasPageDataProvider.initBrandPropValue = function (prop, propValue, pageComponentPropValue) {
11716
- var brand = new IkasBrand(propValue);
11717
- pageComponentPropValue.propValues[prop.name] = brand;
12128
+ pageComponentPropValue.propValues[prop.name] = IkasPageDataProvider._initBrandPropValue(propValue);
12129
+ };
12130
+ IkasPageDataProvider._initBrandPropValue = function (propValue) {
12131
+ return new IkasBrand(propValue);
11718
12132
  };
11719
12133
  IkasPageDataProvider.initBrandListPropValue = function (prop, propValue, pageComponentPropValue) {
11720
- var brandList = new IkasBrandList(propValue);
11721
- pageComponentPropValue.propValues[prop.name] = brandList;
12134
+ pageComponentPropValue.propValues[prop.name] = IkasPageDataProvider._initBrandListPropValue(propValue);
12135
+ };
12136
+ IkasPageDataProvider._initBrandListPropValue = function (propValue) {
12137
+ return new IkasBrandList(propValue);
11722
12138
  };
11723
12139
  IkasPageDataProvider.initCategoryPropValue = function (prop, propValue, pageComponentPropValue) {
11724
- var category = new IkasCategory(propValue);
11725
- pageComponentPropValue.propValues[prop.name] = category;
12140
+ pageComponentPropValue.propValues[prop.name] = IkasPageDataProvider._initCategoryPropValue(propValue);
12141
+ };
12142
+ IkasPageDataProvider._initCategoryPropValue = function (propValue) {
12143
+ return new IkasCategory(propValue);
11726
12144
  };
11727
12145
  IkasPageDataProvider.initCategoryListPropValue = function (prop, propValue, pageComponentPropValue) {
11728
12146
  var categoryList = new IkasCategoryList(propValue);
11729
12147
  pageComponentPropValue.propValues[prop.name] = categoryList;
11730
12148
  };
12149
+ IkasPageDataProvider._initCategoryListPropValue = function (propValue) {
12150
+ return new IkasCategoryList(propValue);
12151
+ };
11731
12152
  IkasPageDataProvider.initProductListPropValue = function (prop, propValue, pageComponentPropValue) {
11732
- var productList = new IkasProductList(propValue);
11733
- pageComponentPropValue.propValues[prop.name] = productList;
12153
+ pageComponentPropValue.propValues[prop.name] = this._initProductListPropValue(propValue);
12154
+ };
12155
+ IkasPageDataProvider._initProductListPropValue = function (propValue) {
12156
+ return new IkasProductList(propValue);
11734
12157
  };
11735
12158
  IkasPageDataProvider.initProductDetailPropValue = function (prop, propValue, pageComponentPropValue, router, isBrowser) {
12159
+ pageComponentPropValue.propValues[prop.name] = this._initProductDetailPropValue(propValue, router, isBrowser);
12160
+ };
12161
+ IkasPageDataProvider._initProductDetailPropValue = function (propValue, router, isBrowser) {
11736
12162
  var usePageData = propValue.usePageData;
11737
12163
  var _propValue = propValue;
11738
12164
  var productDetail = new IkasProductDetail(_propValue.product, _propValue.selectedVariantValues);
@@ -11746,23 +12172,92 @@ var IkasPageDataProvider = /** @class */ (function () {
11746
12172
  }
11747
12173
  }
11748
12174
  }
11749
- pageComponentPropValue.propValues[prop.name] = new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues, usePageData, router);
12175
+ return new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues, usePageData, router);
11750
12176
  };
11751
12177
  IkasPageDataProvider.initLinkPropValue = function (prop, propValue, pageComponentPropValue) {
12178
+ pageComponentPropValue.propValues[prop.name] = this._initLinkPropValue(propValue);
12179
+ };
12180
+ IkasPageDataProvider._initLinkPropValue = function (propValue) {
11752
12181
  if (Array.isArray(propValue)) {
11753
- pageComponentPropValue.propValues[prop.name] = propValue.map(function (p) {
12182
+ return propValue.map(function (p) {
11754
12183
  return new IkasNavigationLink(p.href, p.label, p.subLinks, p.isExternal || undefined);
11755
12184
  });
11756
12185
  }
11757
12186
  else if (propValue) {
11758
- pageComponentPropValue.propValues[prop.name] = new IkasNavigationLink(propValue.href, propValue.label, propValue.subLinks, propValue.isExternal);
12187
+ return new IkasNavigationLink(propValue.href, propValue.label, propValue.subLinks, propValue.isExternal);
11759
12188
  }
11760
12189
  };
11761
12190
  IkasPageDataProvider.initImagePropValue = function (prop, propValue, pageComponentPropValue) {
11762
- pageComponentPropValue.propValues[prop.name] = new IkasImage(propValue.id);
12191
+ pageComponentPropValue.propValues[prop.name] = this._initImagePropValue(propValue);
12192
+ };
12193
+ IkasPageDataProvider._initImagePropValue = function (propValue) {
12194
+ return new IkasImage(propValue.id);
11763
12195
  };
11764
12196
  IkasPageDataProvider.initImageListPropValue = function (prop, propValue, pageComponentPropValue) {
11765
- pageComponentPropValue.propValues[prop.name] = propValue.map(function (i) { return new IkasImage(i.id); });
12197
+ pageComponentPropValue.propValues[prop.name] = this._initImageListPropValue(propValue);
12198
+ };
12199
+ IkasPageDataProvider._initImageListPropValue = function (propValue) {
12200
+ return propValue.map(function (i) { return new IkasImage(i.id); });
12201
+ };
12202
+ IkasPageDataProvider.initCustomDataPropValue = function (prop, customDataValue, pageComponentPropValue, router, isBrowser) {
12203
+ if (!customDataValue ||
12204
+ !customDataValue.value ||
12205
+ !customDataValue.customData)
12206
+ return;
12207
+ pageComponentPropValue.propValues[prop.name] = this._initCustomDataPropValue(customDataValue, customDataValue.customData, router, isBrowser);
12208
+ };
12209
+ IkasPageDataProvider._initCustomDataPropValue = function (customDataValue, customData, router, isBrowser) {
12210
+ var _this = this;
12211
+ if (!customDataValue)
12212
+ return null;
12213
+ var propValue = customDataValue.value;
12214
+ if (propValue === null || propValue === undefined)
12215
+ return null;
12216
+ switch (customData.type) {
12217
+ case exports.IkasThemeCustomDataType.BRAND:
12218
+ return this._initBrandPropValue(propValue);
12219
+ case exports.IkasThemeCustomDataType.BRAND_LIST:
12220
+ return this._initBrandListPropValue(propValue);
12221
+ case exports.IkasThemeCustomDataType.CATEGORY_LIST:
12222
+ return this._initCategoryListPropValue(propValue);
12223
+ case exports.IkasThemeCustomDataType.CATEGORY:
12224
+ return this._initCategoryPropValue(propValue);
12225
+ case exports.IkasThemeCustomDataType.IMAGE_LIST:
12226
+ return this._initImageListPropValue(propValue);
12227
+ case exports.IkasThemeCustomDataType.IMAGE:
12228
+ return this._initImagePropValue(propValue);
12229
+ case exports.IkasThemeCustomDataType.LINK:
12230
+ return this._initLinkPropValue(propValue);
12231
+ case exports.IkasThemeCustomDataType.PRODUCT_DETAIL:
12232
+ return this._initProductDetailPropValue(propValue, router, isBrowser);
12233
+ case exports.IkasThemeCustomDataType.PRODUCT_LIST:
12234
+ return this._initProductListPropValue(propValue);
12235
+ case exports.IkasThemeCustomDataType.OBJECT:
12236
+ var objectValue = {};
12237
+ for (var _i = 0, _a = customData.nestedData || []; _i < _a.length; _i++) {
12238
+ var nestedCustomData = _a[_i];
12239
+ var value = propValue[nestedCustomData.key];
12240
+ objectValue[nestedCustomData.key] = this._initCustomDataPropValue(value, nestedCustomData, router, isBrowser);
12241
+ }
12242
+ return objectValue;
12243
+ case exports.IkasThemeCustomDataType.DYNAMIC_LIST:
12244
+ case exports.IkasThemeCustomDataType.STATIC_LIST:
12245
+ try {
12246
+ if (!propValue || !propValue.length)
12247
+ return null;
12248
+ var listValue_1 = [];
12249
+ var nestedCustomData_1 = customData.nestedData[0];
12250
+ propValue.forEach(function (itemValue) {
12251
+ listValue_1.push(_this._initCustomDataPropValue(itemValue, nestedCustomData_1, router, isBrowser));
12252
+ });
12253
+ return listValue_1;
12254
+ }
12255
+ catch (err) {
12256
+ return [];
12257
+ }
12258
+ default:
12259
+ return propValue;
12260
+ }
11766
12261
  };
11767
12262
  return IkasPageDataProvider;
11768
12263
  }());
@@ -11833,10 +12328,7 @@ var IkasImage = /** @class */ (function () {
11833
12328
  });
11834
12329
  Object.defineProperty(IkasImage.prototype, "src", {
11835
12330
  get: function () {
11836
- if (this.id.includes("/"))
11837
- return "" + process.env.NEXT_PUBLIC_IMG_BASE_URL + this.id + "/1920/1920/img.webp";
11838
- var merchantId = decodeBase64(this.editorApiKey || IkasStorefrontConfig.config.apiKey || "");
11839
- return "" + process.env.NEXT_PUBLIC_IMG_BASE_URL + merchantId + "/" + this.id + "/1920/1920/img.webp";
12331
+ return this.getSrc(1920);
11840
12332
  },
11841
12333
  enumerable: false,
11842
12334
  configurable: true
@@ -11851,6 +12343,12 @@ var IkasImage = /** @class */ (function () {
11851
12343
  enumerable: false,
11852
12344
  configurable: true
11853
12345
  });
12346
+ IkasImage.prototype.getSrc = function (size) {
12347
+ if (this.id.includes("/"))
12348
+ return "" + process.env.NEXT_PUBLIC_IMG_BASE_URL + this.id + "/" + size + "/" + size + "/img.webp";
12349
+ var merchantId = decodeBase64(this.editorApiKey || IkasStorefrontConfig.config.apiKey || "");
12350
+ return "" + process.env.NEXT_PUBLIC_IMG_BASE_URL + merchantId + "/" + this.id + "/" + size + "/" + size + "/img.webp";
12351
+ };
11854
12352
  return IkasImage;
11855
12353
  }());
11856
12354
 
@@ -12899,6 +13397,7 @@ var IkasThemeComponentProp = /** @class */ (function () {
12899
13397
  this.displayName = data.displayName || "";
12900
13398
  this.type = data.type || exports.IkasThemeComponentPropType.TEXT;
12901
13399
  this.isRequired = data.isRequired || false;
13400
+ this.customDataId = data.customDataId || null;
12902
13401
  mobx.makeAutoObservable(this);
12903
13402
  }
12904
13403
  return IkasThemeComponentProp;
@@ -12917,6 +13416,7 @@ var IkasThemeComponentProp = /** @class */ (function () {
12917
13416
  IkasThemeComponentPropType["CATEGORY"] = "CATEGORY";
12918
13417
  IkasThemeComponentPropType["CATEGORY_LIST"] = "CATEGORY_LIST";
12919
13418
  IkasThemeComponentPropType["COLOR"] = "COLOR";
13419
+ IkasThemeComponentPropType["CUSTOM"] = "CUSTOM";
12920
13420
  // TODO number
12921
13421
  // TODO productAttribute
12922
13422
  })(exports.IkasThemeComponentPropType || (exports.IkasThemeComponentPropType = {}));
@@ -12936,6 +13436,54 @@ var IkasThemeComponent = /** @class */ (function () {
12936
13436
  return IkasThemeComponent;
12937
13437
  }());
12938
13438
 
13439
+ var IkasThemeCustomData = /** @class */ (function () {
13440
+ function IkasThemeCustomData(data) {
13441
+ var _this = this;
13442
+ if (data === void 0) { data = {}; }
13443
+ this.id = data.id || "";
13444
+ this.name = data.name || null;
13445
+ this.type = data.type || exports.IkasThemeCustomDataType.TEXT;
13446
+ this.isRequired = data.isRequired !== undefined ? data.isRequired : true;
13447
+ this.key = data.key || null;
13448
+ this.parent = data.parent || null;
13449
+ this.itemCount = data.itemCount || null;
13450
+ this.isRoot = data.isRoot || false;
13451
+ this.nestedData = data.nestedData
13452
+ ? data.nestedData.map(function (nd) {
13453
+ return new IkasThemeCustomData(__assign(__assign({}, nd), { parent: _this }));
13454
+ })
13455
+ : null;
13456
+ if (this.type === exports.IkasThemeCustomDataType.STATIC_LIST && !this.itemCount)
13457
+ this.itemCount = 1;
13458
+ mobx.makeAutoObservable(this);
13459
+ }
13460
+ IkasThemeCustomData.prototype.toJSON = function () {
13461
+ var obj = __assign({}, this);
13462
+ delete obj.parent;
13463
+ return obj;
13464
+ };
13465
+ return IkasThemeCustomData;
13466
+ }());
13467
+ (function (IkasThemeCustomDataType) {
13468
+ IkasThemeCustomDataType["TEXT"] = "TEXT";
13469
+ IkasThemeCustomDataType["NUMBER"] = "NUMBER";
13470
+ IkasThemeCustomDataType["BOOLEAN"] = "BOOLEAN";
13471
+ IkasThemeCustomDataType["IMAGE"] = "IMAGE";
13472
+ IkasThemeCustomDataType["IMAGE_LIST"] = "IMAGE_LIST";
13473
+ IkasThemeCustomDataType["LINK"] = "LINK";
13474
+ IkasThemeCustomDataType["LIST_OF_LINK"] = "LIST_OF_LINK";
13475
+ IkasThemeCustomDataType["PRODUCT_DETAIL"] = "PRODUCT_DETAIL";
13476
+ IkasThemeCustomDataType["PRODUCT_LIST"] = "PRODUCT_LIST";
13477
+ IkasThemeCustomDataType["BRAND"] = "BRAND";
13478
+ IkasThemeCustomDataType["BRAND_LIST"] = "BRAND_LIST";
13479
+ IkasThemeCustomDataType["CATEGORY"] = "CATEGORY";
13480
+ IkasThemeCustomDataType["CATEGORY_LIST"] = "CATEGORY_LIST";
13481
+ IkasThemeCustomDataType["COLOR"] = "COLOR";
13482
+ IkasThemeCustomDataType["OBJECT"] = "OBJECT";
13483
+ IkasThemeCustomDataType["STATIC_LIST"] = "STATIC_LIST";
13484
+ IkasThemeCustomDataType["DYNAMIC_LIST"] = "DYNAMIC_LIST";
13485
+ })(exports.IkasThemeCustomDataType || (exports.IkasThemeCustomDataType = {}));
13486
+
12939
13487
  var IkasThemePageComponent = /** @class */ (function () {
12940
13488
  function IkasThemePageComponent(data) {
12941
13489
  this.id = data.id || "";
@@ -13003,6 +13551,7 @@ var IkasThemeSettings = /** @class */ (function () {
13003
13551
  var IkasTheme = /** @class */ (function () {
13004
13552
  function IkasTheme(data) {
13005
13553
  if (data === void 0) { data = {}; }
13554
+ var _a;
13006
13555
  this.name = data.name || "";
13007
13556
  this.components = data.components
13008
13557
  ? data.components.map(function (c) { return new IkasThemeComponent(c); })
@@ -13011,6 +13560,8 @@ var IkasTheme = /** @class */ (function () {
13011
13560
  this.settings = data.settings
13012
13561
  ? new IkasThemeSettings(data.settings)
13013
13562
  : new IkasThemeSettings();
13563
+ this.customData = data.customData
13564
+ ? (_a = data.customData) === null || _a === void 0 ? void 0 : _a.map(function (cd) { return new IkasThemeCustomData(cd); }) : [];
13014
13565
  mobx.makeAutoObservable(this);
13015
13566
  }
13016
13567
  Object.defineProperty(IkasTheme.prototype, "headerComponent", {
@@ -24853,8 +25404,12 @@ var PageViewModel = /** @class */ (function () {
24853
25404
  case 1:
24854
25405
  propValue = _d.sent();
24855
25406
  mobx.runInAction(function () {
24856
- if (pageComponentPropValues)
25407
+ if (pageComponentPropValues) {
24857
25408
  pageComponentPropValues.propValues[propName] = propValue;
25409
+ if (prop.type === exports.IkasThemeComponentPropType.CUSTOM) {
25410
+ IkasPageDataProvider.initCustomDataPropValue(prop, propValue, pageComponentPropValues, _this.router, true);
25411
+ }
25412
+ }
24858
25413
  });
24859
25414
  return [2 /*return*/];
24860
25415
  }
@@ -25717,6 +26272,7 @@ exports.IkasTheme = IkasTheme;
25717
26272
  exports.IkasThemeAPI = IkasThemeAPI;
25718
26273
  exports.IkasThemeComponent = IkasThemeComponent;
25719
26274
  exports.IkasThemeComponentProp = IkasThemeComponentProp;
26275
+ exports.IkasThemeCustomData = IkasThemeCustomData;
25720
26276
  exports.IkasThemePage = IkasThemePage;
25721
26277
  exports.IkasThemePageComponent = IkasThemePageComponent;
25722
26278
  exports.IkasThemeSettings = IkasThemeSettings;