@crystaldesign/widget-image-carousel 25.11.0-beta.3 → 25.11.0-beta.30

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 (23) hide show
  1. package/build/esm/index.js +297 -85
  2. package/build/types/widget-image-carousel/src/components/ImageList/index.d.ts +2 -3
  3. package/build/types/widget-image-carousel/src/components/ImageList/index.d.ts.map +1 -1
  4. package/build/types/widget-image-carousel/src/components/InfoElement/index.d.ts +9 -0
  5. package/build/types/widget-image-carousel/src/components/InfoElement/index.d.ts.map +1 -0
  6. package/build/types/widget-image-carousel/src/components/OpenConfiguratorButton/index.d.ts +13 -0
  7. package/build/types/widget-image-carousel/src/components/OpenConfiguratorButton/index.d.ts.map +1 -0
  8. package/build/types/widget-image-carousel/src/components/Swiper/index.d.ts +3 -3
  9. package/build/types/widget-image-carousel/src/components/Swiper/index.d.ts.map +1 -1
  10. package/build/types/widget-image-carousel/src/components/index.d.ts.map +1 -1
  11. package/build/types/widget-image-carousel/src/index.d.ts.map +1 -1
  12. package/build/types/widget-image-carousel/src/stories/SimilarProducts/default.stories.d.ts.map +1 -1
  13. package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-prod.stories.d.ts +8 -0
  14. package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-prod.stories.d.ts.map +1 -0
  15. package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-test.stories.d.ts +8 -0
  16. package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-test.stories.d.ts.map +1 -0
  17. package/build/types/widget-image-carousel/src/types/index.d.ts +23 -4
  18. package/build/types/widget-image-carousel/src/types/index.d.ts.map +1 -1
  19. package/build/types/widget-image-carousel/src/useImageCarousel.d.ts +3 -8
  20. package/build/types/widget-image-carousel/src/useImageCarousel.d.ts.map +1 -1
  21. package/build/umd/report.html +1 -1
  22. package/build/umd/widget-image-carousel.umd.min.js +1 -1
  23. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import { useState, useCallback, useEffect } from 'react';
3
- import { useCss, useProductData, MediaItem, useConfiguration } from '@crystaldesign/widget-library';
4
- import { useDivaCore } from '@crystaldesign/diva-core';
2
+ import { useState, useCallback, useEffect, useMemo } from 'react';
3
+ import { useCss, useProductData, ActionGroup, Action, MediaItem, useConfiguration } from '@crystaldesign/widget-library';
4
+ import { useDivaCore, useTranslation } from '@crystaldesign/diva-core';
5
5
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
6
6
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
7
7
  import _regeneratorRuntime from '@babel/runtime/regenerator';
@@ -10,7 +10,7 @@ import { Navigation } from 'swiper/modules';
10
10
  import classNames from 'classnames';
11
11
  import 'swiper/css';
12
12
  import 'swiper/css/navigation';
13
- import { jsx, jsxs } from 'react/jsx-runtime';
13
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
14
14
 
15
15
  (function() {
16
16
  const env = {"STAGE":"production"};
@@ -28,7 +28,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
28
28
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
29
29
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
30
30
  function useImageCarousel(_ref) {
31
- var productId = _ref.productId,
31
+ var productIds = _ref.productIds,
32
32
  settings = _ref.settings;
33
33
  var _useState = useState([]),
34
34
  _useState2 = _slicedToArray(_useState, 2),
@@ -42,45 +42,64 @@ function useImageCarousel(_ref) {
42
42
  _useState6 = _slicedToArray(_useState5, 2),
43
43
  error = _useState6[0],
44
44
  setError = _useState6[1];
45
+ var _useDivaCore = useDivaCore(),
46
+ openComponent = _useDivaCore.actions.openComponent;
45
47
  useCss(settings);
46
48
  var _useProductData = useProductData({
47
- productIds: productId,
48
- widgetType: 'IMAGECAROUSEL'
49
+ productIds: productIds,
50
+ widgetType: 'IMAGECAROUSEL',
51
+ standaloneWidget: settings.type === 'SIMPLE_PRODUCT_LIST'
49
52
  }),
50
53
  getProductsByDivaNrs = _useProductData.getProductsByDivaNrs,
51
54
  getProductByDivaNrAndVariantId = _useProductData.getProductByDivaNrAndVariantId,
52
55
  setSelectedProductId = _useProductData.setSelectedProductId,
53
56
  selectedProduct = _useProductData.selectedProduct,
54
- setProductCache = _useProductData.setProductCache;
57
+ setProductCache = _useProductData.setProductCache,
58
+ getSimpleProductListByIds = _useProductData.getSimpleProductListByIds;
55
59
  var onClickProduct = useCallback(function (productId) {
56
- setSelectedProductId(productId);
57
- if (!settings.disableScrollToTop) {
58
- window.scrollTo({
59
- top: 0,
60
- behavior: 'smooth'
61
- });
60
+ var _settings$openConfigu;
61
+ if ((_settings$openConfigu = settings.openConfiguratorCta) !== null && _settings$openConfigu !== void 0 && _settings$openConfigu.enabled) {
62
+ openConfigurator(productId);
63
+ } else {
64
+ setSelectedProductId(productId);
65
+ if (!settings.disableScrollToTop) {
66
+ window.scrollTo({
67
+ top: 0,
68
+ behavior: 'smooth'
69
+ });
70
+ }
62
71
  }
63
- }, [setSelectedProductId]);
72
+ }, [setSelectedProductId, settings.openConfiguratorCta]);
73
+ var openConfigurator = function openConfigurator(productId) {
74
+ openComponent({
75
+ type: 'DIVA_WEBPLANNER',
76
+ parameters: {
77
+ productId: productId
78
+ },
79
+ openInFullscreen: true,
80
+ absoluteFullscreen: true
81
+ });
82
+ };
64
83
  useEffect(function () {
65
84
  var loadMockups = /*#__PURE__*/function () {
66
85
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
67
- var _settings$mediaFuncti, mediaFunctionType, foundMedia, _foundMedia;
86
+ var _settings$mediaFuncti, mediaFunctionType, foundMedia, _foundMedia, _foundMedia2;
68
87
  return _regeneratorRuntime.wrap(function _callee$(_context) {
69
88
  while (1) switch (_context.prev = _context.next) {
70
89
  case 0:
71
90
  _context.prev = 0;
72
91
  setLoading(true);
73
- if (!selectedProduct) {
74
- _context.next = 19;
92
+ mediaFunctionType = (_settings$mediaFuncti = settings.mediaFunctionType) !== null && _settings$mediaFuncti !== void 0 ? _settings$mediaFuncti : 'SHO';
93
+ if (!(selectedProduct && settings.type !== 'SIMPLE_PRODUCT_LIST')) {
94
+ _context.next = 21;
75
95
  break;
76
96
  }
77
- mediaFunctionType = (_settings$mediaFuncti = settings.mediaFunctionType) !== null && _settings$mediaFuncti !== void 0 ? _settings$mediaFuncti : 'SHO';
78
97
  if (!(settings.type === 'WALL_MOCKUPS')) {
79
98
  _context.next = 11;
80
99
  break;
81
100
  }
82
101
  _context.next = 7;
83
- return getWallMockups(selectedProduct, mediaFunctionType);
102
+ return getWallMockups(selectedProduct, mediaFunctionType, settings.infoElements);
84
103
  case 7:
85
104
  foundMedia = _context.sent;
86
105
  if (foundMedia) {
@@ -94,7 +113,7 @@ function useImageCarousel(_ref) {
94
113
  break;
95
114
  }
96
115
  _context.next = 14;
97
- return getSimilarProductMedia(selectedProduct, mediaFunctionType, settings.description);
116
+ return getSimilarProductMedia(selectedProduct, mediaFunctionType, settings.infoElements);
98
117
  case 14:
99
118
  _foundMedia = _context.sent;
100
119
  if (_foundMedia) {
@@ -103,44 +122,63 @@ function useImageCarousel(_ref) {
103
122
  _context.next = 19;
104
123
  break;
105
124
  case 18:
106
- throw new Error('Invalid type');
125
+ throw new Error('Invalid type or invalid data');
107
126
  case 19:
108
- _context.next = 25;
127
+ _context.next = 29;
109
128
  break;
110
129
  case 21:
111
- _context.prev = 21;
130
+ if (!(productIds !== null && productIds !== void 0 && productIds.length && settings.type === 'SIMPLE_PRODUCT_LIST')) {
131
+ _context.next = 28;
132
+ break;
133
+ }
134
+ _context.next = 24;
135
+ return getSimpleProductList(productIds, mediaFunctionType, settings.infoElements);
136
+ case 24:
137
+ _foundMedia2 = _context.sent;
138
+ if (_foundMedia2) {
139
+ setMedia(_foundMedia2);
140
+ }
141
+ _context.next = 29;
142
+ break;
143
+ case 28:
144
+ throw new Error('Invalid type or invalid data');
145
+ case 29:
146
+ _context.next = 35;
147
+ break;
148
+ case 31:
149
+ _context.prev = 31;
112
150
  _context.t0 = _context["catch"](0);
113
151
  console.error(_context.t0);
114
152
  setError(_context.t0);
115
- case 25:
116
- _context.prev = 25;
153
+ case 35:
154
+ _context.prev = 35;
117
155
  setLoading(false);
118
- return _context.finish(25);
119
- case 28:
156
+ return _context.finish(35);
157
+ case 38:
120
158
  case "end":
121
159
  return _context.stop();
122
160
  }
123
- }, _callee, null, [[0, 21, 25, 28]]);
161
+ }, _callee, null, [[0, 31, 35, 38]]);
124
162
  }));
125
163
  return function loadMockups() {
126
164
  return _ref2.apply(this, arguments);
127
165
  };
128
166
  }();
129
- if (selectedProduct && productId) {
167
+ if (selectedProduct || productIds !== null && productIds !== void 0 && productIds.length && settings.type === 'SIMPLE_PRODUCT_LIST') {
130
168
  loadMockups();
131
169
  }
132
- }, [selectedProduct, productId]);
170
+ }, [selectedProduct, productIds]);
133
171
  return {
134
172
  media: media,
135
173
  error: error,
136
174
  loading: loading,
137
- setSelectedProductId: onClickProduct
175
+ onClickProduct: onClickProduct
138
176
  };
139
- function getWallMockups(_x, _x2) {
177
+ function getWallMockups(_x, _x2, _x3) {
140
178
  return _getWallMockups.apply(this, arguments);
141
179
  }
142
180
  function _getWallMockups() {
143
- _getWallMockups = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(product, wallMockupFunctionType) {
181
+ _getWallMockups = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(product, wallMockupFunctionType, infoElements) {
144
182
  var _product$customData, _product$customData2, _product$customData3;
145
183
  var wallMockupDivaNrs, wallMockupProducts, optCodex, opvMapping, optOpvPairsToSearch, media, _loop, i;
146
184
  return _regeneratorRuntime.wrap(function _callee2$(_context5) {
@@ -206,7 +244,8 @@ function useImageCarousel(_ref) {
206
244
  })) === null || _variant$media === void 0 ? void 0 : _variant$media.url;
207
245
  media.push({
208
246
  url: mediaUrl,
209
- productId: variant._id
247
+ productId: variant._id,
248
+ infoElements: infoElements ? addInfoElements(infoElements, variant) : undefined
210
249
  });
211
250
  return _context3.abrupt("return", 1);
212
251
  case 8:
@@ -266,7 +305,8 @@ function useImageCarousel(_ref) {
266
305
  })) === null || _targetProduct$media === void 0 ? void 0 : _targetProduct$media.url;
267
306
  media.push({
268
307
  url: mediaUrl,
269
- productId: targetProduct._id
308
+ productId: targetProduct._id,
309
+ infoElements: infoElements ? addInfoElements(infoElements, targetProduct) : undefined
270
310
  });
271
311
  }
272
312
  }
@@ -331,13 +371,13 @@ function useImageCarousel(_ref) {
331
371
  });
332
372
  });
333
373
  }
334
- function getSimilarProductMedia(_x3, _x4, _x5) {
374
+ function getSimilarProductMedia(_x4, _x5, _x6) {
335
375
  return _getSimilarProductMedia.apply(this, arguments);
336
376
  }
337
377
  function _getSimilarProductMedia() {
338
- _getSimilarProductMedia = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(product, mediaFunctionType, description) {
378
+ _getSimilarProductMedia = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(product, mediaFunctionType, infoElements) {
339
379
  var _product$customData4;
340
- var similarProductsDivaNr, similarProducts, media, i, _similarProduct$media, _similarProduct$media2, similarProduct, mediaUrl, desc, _similarProduct$descr;
380
+ var similarProductsDivaNr, similarProducts, media, i, _similarProduct$media, _similarProduct$media2, similarProduct, mediaUrl;
341
381
  return _regeneratorRuntime.wrap(function _callee4$(_context7) {
342
382
  while (1) switch (_context7.prev = _context7.next) {
343
383
  case 0:
@@ -367,7 +407,7 @@ function useImageCarousel(_ref) {
367
407
  }
368
408
  }, _callee3);
369
409
  }));
370
- return function (_x6) {
410
+ return function (_x10) {
371
411
  return _ref3.apply(this, arguments);
372
412
  };
373
413
  }()));
@@ -380,14 +420,10 @@ function useImageCarousel(_ref) {
380
420
  mediaUrl = (_similarProduct$media = similarProduct === null || similarProduct === void 0 || (_similarProduct$media2 = similarProduct.media) === null || _similarProduct$media2 === void 0 || (_similarProduct$media2 = _similarProduct$media2.find(function (m) {
381
421
  return m.functionType === mediaFunctionType;
382
422
  })) === null || _similarProduct$media2 === void 0 ? void 0 : _similarProduct$media2.url) !== null && _similarProduct$media !== void 0 ? _similarProduct$media : similarProduct.image;
383
- desc = undefined;
384
423
  if (mediaUrl) {
385
- if (description) {
386
- desc = (_similarProduct$descr = similarProduct[description]) !== null && _similarProduct$descr !== void 0 ? _similarProduct$descr : description;
387
- }
388
424
  media.push({
389
425
  url: mediaUrl,
390
- description: desc,
426
+ infoElements: infoElements ? addInfoElements(infoElements, similarProduct) : undefined,
391
427
  productId: similarProduct._id
392
428
  });
393
429
  }
@@ -401,14 +437,141 @@ function useImageCarousel(_ref) {
401
437
  }));
402
438
  return _getSimilarProductMedia.apply(this, arguments);
403
439
  }
440
+ function getSimpleProductList(_x7, _x8, _x9) {
441
+ return _getSimpleProductList.apply(this, arguments);
442
+ }
443
+ function _getSimpleProductList() {
444
+ _getSimpleProductList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(productIds, mediaFunctionType, infoElements) {
445
+ var productIdsArray, products, media, _iterator2, _step2, _p$media$find$url, _p$media, p, mediaUrl;
446
+ return _regeneratorRuntime.wrap(function _callee5$(_context8) {
447
+ while (1) switch (_context8.prev = _context8.next) {
448
+ case 0:
449
+ productIdsArray = Array.isArray(productIds) ? productIds : productIds.split(';');
450
+ _context8.next = 3;
451
+ return getSimpleProductListByIds(productIdsArray);
452
+ case 3:
453
+ products = _context8.sent;
454
+ media = [];
455
+ _iterator2 = _createForOfIteratorHelper(products.data);
456
+ try {
457
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
458
+ p = _step2.value;
459
+ mediaUrl = (_p$media$find$url = p === null || p === void 0 || (_p$media = p.media) === null || _p$media === void 0 || (_p$media = _p$media.find(function (m) {
460
+ return m.functionType === mediaFunctionType;
461
+ })) === null || _p$media === void 0 ? void 0 : _p$media.url) !== null && _p$media$find$url !== void 0 ? _p$media$find$url : p.image;
462
+ media.push({
463
+ url: mediaUrl,
464
+ productId: p._id,
465
+ infoElements: infoElements ? addInfoElements(infoElements, p) : undefined
466
+ });
467
+ }
468
+ } catch (err) {
469
+ _iterator2.e(err);
470
+ } finally {
471
+ _iterator2.f();
472
+ }
473
+ return _context8.abrupt("return", media);
474
+ case 8:
475
+ case "end":
476
+ return _context8.stop();
477
+ }
478
+ }, _callee5);
479
+ }));
480
+ return _getSimpleProductList.apply(this, arguments);
481
+ }
482
+ }
483
+ var addInfoElements = function addInfoElements(infoElements, product) {
484
+ var infoEl = {};
485
+ if (infoElements) {
486
+ var _iterator3 = _createForOfIteratorHelper(infoElements),
487
+ _step3;
488
+ try {
489
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
490
+ var infoElement = _step3.value;
491
+ if (infoElement.text) {
492
+ var _infoElement$text;
493
+ infoEl[infoElement.text] = (_infoElement$text = product[infoElement.text]) !== null && _infoElement$text !== void 0 ? _infoElement$text : infoElement.text;
494
+ }
495
+ }
496
+ } catch (err) {
497
+ _iterator3.e(err);
498
+ } finally {
499
+ _iterator3.f();
500
+ }
501
+ }
502
+ return infoEl;
503
+ };
504
+
505
+ var OpenConfiguratorButton = function OpenConfiguratorButton(_ref) {
506
+ var _settings$ctaText;
507
+ var settings = _ref.settings,
508
+ onClick = _ref.onClick;
509
+ var _useTranslation = useTranslation(),
510
+ t = _useTranslation.t;
511
+ if (!settings.enabled) return /*#__PURE__*/jsx(Fragment, {});
512
+ return /*#__PURE__*/jsx("button", {
513
+ className: classNames('widget-image-carousel-open-configurator-button', settings.className),
514
+ onClick: onClick,
515
+ children: /*#__PURE__*/jsxs("div", {
516
+ style: {
517
+ display: 'flex',
518
+ alignItems: 'center',
519
+ justifyContent: 'center'
520
+ },
521
+ children: [/*#__PURE__*/jsx("span", {
522
+ className: "widget-image-carousel-open-configurator-text",
523
+ children: (_settings$ctaText = settings.ctaText) !== null && _settings$ctaText !== void 0 ? _settings$ctaText : t('configurator.CONFIGURE_NOW')
524
+ }), settings.ctaIcon && /*#__PURE__*/jsx("img", {
525
+ src: settings.ctaIcon,
526
+ alt: "Configurator Icon",
527
+ className: "widget-image-carousel-open-configurator-icon"
528
+ })]
529
+ })
530
+ });
531
+ };
532
+
533
+ var InfoElementComponent = function InfoElementComponent(_ref) {
534
+ var _media$infoElements, _infoElement$text;
535
+ var infoElement = _ref.infoElement,
536
+ media = _ref.media;
537
+ switch (infoElement.type) {
538
+ case 'text':
539
+ return /*#__PURE__*/jsx("p", {
540
+ className: infoElement.className,
541
+ children: (_media$infoElements = media.infoElements) === null || _media$infoElements === void 0 ? void 0 : _media$infoElements[(_infoElement$text = infoElement.text) !== null && _infoElement$text !== void 0 ? _infoElement$text : '']
542
+ });
543
+ case 'cta':
544
+ {
545
+ return /*#__PURE__*/jsx(CallToAction, {
546
+ config: infoElement.action
547
+ });
548
+ }
549
+ default:
550
+ return /*#__PURE__*/jsx("span", {
551
+ children: "Invalid InfoElement - Check Config"
552
+ });
553
+ }
554
+ };
555
+ function CallToAction(_ref2) {
556
+ var config = _ref2.config;
557
+ if ('actions' in config) {
558
+ return /*#__PURE__*/jsx(ActionGroup, {
559
+ config: config
560
+ });
561
+ }
562
+ return /*#__PURE__*/jsx(Action, {
563
+ config: config
564
+ });
404
565
  }
405
566
 
406
567
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
407
568
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
408
569
  var SwiperComponent = function SwiperComponent(_ref) {
570
+ var _settings$sliderProp;
409
571
  var media = _ref.media,
410
572
  settings = _ref.settings,
411
- setSelectedProductId = _ref.setSelectedProductId;
573
+ onClickProduct = _ref.onClickProduct,
574
+ isMobile = _ref.isMobile;
412
575
  return /*#__PURE__*/jsx("div", {
413
576
  className: classNames(['diva-widget-image-carousel-container']),
414
577
  children: /*#__PURE__*/jsx(Swiper, _objectSpread$1(_objectSpread$1({
@@ -416,13 +579,15 @@ var SwiperComponent = function SwiperComponent(_ref) {
416
579
  navigation: true,
417
580
  className: classNames(['diva-widget-image-carousel-swiper'])
418
581
  }, settings.sliderProp), {}, {
582
+ loop: ((_settings$sliderProp = settings.sliderProp) === null || _settings$sliderProp === void 0 ? void 0 : _settings$sliderProp.loop) && media.length > 1,
419
583
  children: media.map(function (m, i) {
584
+ var _settings$infoElement, _settings$openConfigu, _settings$openConfigu2, _settings$infoElement2, _settings$openConfigu3, _settings$openConfigu4;
420
585
  return /*#__PURE__*/jsx(SwiperSlide, {
421
586
  className: classNames(['diva-widget-image-carousel-slide']),
422
- children: settings.description ? /*#__PURE__*/jsxs("div", {
587
+ children: (_settings$infoElement = settings.infoElements) !== null && _settings$infoElement !== void 0 && _settings$infoElement.length ? /*#__PURE__*/jsxs("div", {
423
588
  className: classNames(['diva-widget-image-carousel-slide-description-image']),
424
589
  onClick: function onClick() {
425
- return setSelectedProductId(m.productId);
590
+ return onClickProduct(m.productId);
426
591
  },
427
592
  children: [/*#__PURE__*/jsx(MediaItem, {
428
593
  mediaUrl: m.url,
@@ -430,24 +595,51 @@ var SwiperComponent = function SwiperComponent(_ref) {
430
595
  config: {
431
596
  disableSirv: false,
432
597
  sirvProps: settings.sirvProps
598
+ },
599
+ overlay: !isMobile && (_settings$openConfigu = settings.openConfiguratorCta) !== null && _settings$openConfigu !== void 0 && _settings$openConfigu.enabled ? /*#__PURE__*/jsx(OpenConfiguratorButton, {
600
+ settings: settings.openConfiguratorCta,
601
+ onClick: function onClick() {
602
+ return onClickProduct(m.productId);
603
+ }
604
+ }) : undefined
605
+ }), ((_settings$openConfigu2 = settings.openConfiguratorCta) === null || _settings$openConfigu2 === void 0 ? void 0 : _settings$openConfigu2.enabled) && isMobile && /*#__PURE__*/jsx(OpenConfiguratorButton, {
606
+ settings: settings.openConfiguratorCta,
607
+ onClick: function onClick() {
608
+ return onClickProduct(m.productId);
433
609
  }
434
610
  }), /*#__PURE__*/jsx("div", {
435
- className: classNames(['diva-widget-image-carousel-slide-description']),
436
- children: /*#__PURE__*/jsx("span", {
437
- children: m.description
611
+ className: classNames(['diva-widget-image-carousel-slide-info']),
612
+ children: (_settings$infoElement2 = settings.infoElements) === null || _settings$infoElement2 === void 0 ? void 0 : _settings$infoElement2.map(function (infoElement) {
613
+ return /*#__PURE__*/jsx(InfoElementComponent, {
614
+ infoElement: infoElement,
615
+ media: m
616
+ });
438
617
  })
439
618
  })]
440
- }) : /*#__PURE__*/jsx(MediaItem, {
441
- mediaUrl: m.url,
442
- isCurrentlyVisible: true,
443
- config: {
444
- disableSirv: false,
445
- sirvProps: settings.sirvProps
446
- },
447
- className: classNames(['diva-widget-image-carousel-slide-image']),
448
- onClick: function onClick() {
449
- return setSelectedProductId(m.productId);
450
- }
619
+ }) : /*#__PURE__*/jsxs(Fragment, {
620
+ children: [/*#__PURE__*/jsx(MediaItem, {
621
+ mediaUrl: m.url,
622
+ isCurrentlyVisible: true,
623
+ config: {
624
+ disableSirv: false,
625
+ sirvProps: settings.sirvProps
626
+ },
627
+ className: classNames(['diva-widget-image-carousel-slide-image']),
628
+ onClick: function onClick() {
629
+ return onClickProduct(m.productId);
630
+ },
631
+ overlay: !isMobile && (_settings$openConfigu3 = settings.openConfiguratorCta) !== null && _settings$openConfigu3 !== void 0 && _settings$openConfigu3.enabled ? /*#__PURE__*/jsx(OpenConfiguratorButton, {
632
+ settings: settings.openConfiguratorCta,
633
+ onClick: function onClick() {
634
+ return onClickProduct(m.productId);
635
+ }
636
+ }) : undefined
637
+ }), ((_settings$openConfigu4 = settings.openConfiguratorCta) === null || _settings$openConfigu4 === void 0 ? void 0 : _settings$openConfigu4.enabled) && isMobile && /*#__PURE__*/jsx(OpenConfiguratorButton, {
638
+ settings: settings.openConfiguratorCta,
639
+ onClick: function onClick() {
640
+ return onClickProduct(m.productId);
641
+ }
642
+ })]
451
643
  })
452
644
  }, i);
453
645
  })
@@ -458,16 +650,17 @@ var SwiperComponent = function SwiperComponent(_ref) {
458
650
  var ImageList = function ImageList(_ref) {
459
651
  var media = _ref.media,
460
652
  settings = _ref.settings,
461
- setSelectedProductId = _ref.setSelectedProductId;
653
+ onClickProduct = _ref.onClickProduct;
462
654
  return /*#__PURE__*/jsx("div", {
463
655
  className: classNames(['diva-widget-image-list']),
464
656
  children: media.map(function (m, i) {
657
+ var _settings$infoElement, _settings$openConfigu, _settings$infoElement2, _settings$openConfigu2;
465
658
  return /*#__PURE__*/jsx("div", {
466
659
  className: classNames(['diva-widget-image-list-item']),
467
- children: settings.description ? /*#__PURE__*/jsxs("div", {
660
+ children: (_settings$infoElement = settings.infoElements) !== null && _settings$infoElement !== void 0 && _settings$infoElement.length ? /*#__PURE__*/jsxs("div", {
468
661
  className: classNames(['diva-widget-image-list-item-description-image']),
469
662
  onClick: function onClick() {
470
- return setSelectedProductId(m.productId);
663
+ return onClickProduct(m.productId);
471
664
  },
472
665
  children: [/*#__PURE__*/jsx(MediaItem, {
473
666
  mediaUrl: m.url,
@@ -476,23 +669,38 @@ var ImageList = function ImageList(_ref) {
476
669
  disableSirv: false,
477
670
  sirvProps: settings.sirvProps
478
671
  }
672
+ }), ((_settings$openConfigu = settings.openConfiguratorCta) === null || _settings$openConfigu === void 0 ? void 0 : _settings$openConfigu.enabled) && /*#__PURE__*/jsx(OpenConfiguratorButton, {
673
+ settings: settings.openConfiguratorCta,
674
+ onClick: function onClick() {
675
+ return onClickProduct(m.productId);
676
+ }
479
677
  }), /*#__PURE__*/jsx("div", {
480
- className: classNames(['diva-widget-image-list-item-description']),
481
- children: /*#__PURE__*/jsx("span", {
482
- children: m.description
678
+ className: classNames(['diva-widget-image-list-item-info']),
679
+ children: (_settings$infoElement2 = settings.infoElements) === null || _settings$infoElement2 === void 0 ? void 0 : _settings$infoElement2.map(function (infoElement) {
680
+ return /*#__PURE__*/jsx(InfoElementComponent, {
681
+ infoElement: infoElement,
682
+ media: m
683
+ });
483
684
  })
484
685
  })]
485
- }) : /*#__PURE__*/jsx(MediaItem, {
486
- mediaUrl: m.url,
487
- isCurrentlyVisible: true,
488
- config: {
489
- disableSirv: false,
490
- sirvProps: settings.sirvProps
491
- },
492
- className: classNames(['diva-widget-image-list-item-image']),
493
- onClick: function onClick() {
494
- return setSelectedProductId(m.productId);
495
- }
686
+ }) : /*#__PURE__*/jsxs(Fragment, {
687
+ children: [/*#__PURE__*/jsx(MediaItem, {
688
+ mediaUrl: m.url,
689
+ isCurrentlyVisible: true,
690
+ config: {
691
+ disableSirv: false,
692
+ sirvProps: settings.sirvProps
693
+ },
694
+ className: classNames(['diva-widget-image-list-item-image']),
695
+ onClick: function onClick() {
696
+ return onClickProduct(m.productId);
697
+ }
698
+ }), ((_settings$openConfigu2 = settings.openConfiguratorCta) === null || _settings$openConfigu2 === void 0 ? void 0 : _settings$openConfigu2.enabled) && /*#__PURE__*/jsx(OpenConfiguratorButton, {
699
+ settings: settings.openConfiguratorCta,
700
+ onClick: function onClick() {
701
+ return onClickProduct(m.productId);
702
+ }
703
+ })]
496
704
  })
497
705
  }, i);
498
706
  })
@@ -504,35 +712,39 @@ function MainComponent(props) {
504
712
  media = _useImageCarousel.media,
505
713
  error = _useImageCarousel.error;
506
714
  _useImageCarousel.loading;
507
- var setSelectedProductId = _useImageCarousel.setSelectedProductId;
715
+ var onClickProduct = _useImageCarousel.onClickProduct;
508
716
  var _useDivaCore = useDivaCore(),
509
717
  isMobile = _useDivaCore.state.isMobile;
510
718
  if (error) return /*#__PURE__*/jsx("div", {
511
719
  children: "Error"
512
720
  });
513
- if (isMobile && !props.settings.avoidUsingSwiperOnMobile) {
721
+ if (isMobile && props.settings.avoidUsingSwiperOnMobile) {
514
722
  return /*#__PURE__*/jsx(ImageList, {
515
723
  media: media,
516
724
  settings: props.settings,
517
- setSelectedProductId: setSelectedProductId
725
+ onClickProduct: onClickProduct
518
726
  });
519
727
  }
520
728
  return /*#__PURE__*/jsx(SwiperComponent, {
521
729
  media: media,
522
730
  settings: props.settings,
523
- setSelectedProductId: setSelectedProductId
731
+ onClickProduct: onClickProduct,
732
+ isMobile: isMobile
524
733
  });
525
734
  }
526
735
 
527
736
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
528
737
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
529
738
  var Main = function Main(_ref) {
530
- var _parameters$productId;
531
739
  var settings = _ref.settings,
532
740
  parameters = _ref.parameters;
741
+ var productIds = useMemo(function () {
742
+ var _parameters$productId, _parameters$productId2;
743
+ return (_parameters$productId = parameters === null || parameters === void 0 || (_parameters$productId2 = parameters.productIds) === null || _parameters$productId2 === void 0 ? void 0 : _parameters$productId2.split(';')) !== null && _parameters$productId !== void 0 ? _parameters$productId : [];
744
+ }, [parameters === null || parameters === void 0 ? void 0 : parameters.productIds]);
533
745
  return /*#__PURE__*/jsx(ImageCarouselComponent, {
534
746
  settings: settings,
535
- productId: (_parameters$productId = parameters === null || parameters === void 0 ? void 0 : parameters.productId) !== null && _parameters$productId !== void 0 ? _parameters$productId : ''
747
+ productIds: productIds
536
748
  });
537
749
  };
538
750
  var ImageCarouselComponent = function ImageCarouselComponent(props) {
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
- import { Media } from '@crystaldesign/widget-image-carousel/useImageCarousel';
3
- import { Configuration } from '@crystaldesign/widget-image-carousel/types';
2
+ import { Configuration, Media } from '@crystaldesign/widget-image-carousel/types';
4
3
  interface ImageListProps {
5
4
  media: Media[];
6
5
  settings: Configuration;
7
- setSelectedProductId: (id: string) => void;
6
+ onClickProduct: (id: string) => void;
8
7
  }
9
8
  export declare const ImageList: React.FC<ImageListProps>;
10
9
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ImageList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,KAAK,EAAE,MAAM,uDAAuD,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAE3E,UAAU,cAAc;IACtB,KAAK,EAAE,KAAK,EAAE,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,oBAAoB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyB9C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ImageList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAe,MAAM,4CAA4C,CAAC;AAI/F,UAAU,cAAc;IACtB,KAAK,EAAE,KAAK,EAAE,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAiC9C,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { InfoElement, Media } from '../../types';
3
+ interface InfoElementComponentProps {
4
+ infoElement: InfoElement;
5
+ media: Media;
6
+ }
7
+ export declare const InfoElementComponent: React.FC<InfoElementComponentProps>;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/InfoElement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEjD,UAAU,yBAAyB;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAUpE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface OpenConfiguratorButtonProps {
3
+ settings: {
4
+ enabled: boolean;
5
+ className: string;
6
+ ctaText?: string;
7
+ ctaIcon?: string;
8
+ };
9
+ onClick: () => void;
10
+ }
11
+ export declare const OpenConfiguratorButton: React.FC<OpenConfiguratorButtonProps>;
12
+ export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/OpenConfiguratorButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,2BAA2B;IACnC,QAAQ,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtF,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAWxE,CAAC"}