@crystaldesign/widget-image-carousel 25.11.0-beta.9 → 25.11.0-rc.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/build/esm/index.js +330 -84
- package/build/types/widget-image-carousel/src/components/ImageList/index.d.ts +2 -3
- package/build/types/widget-image-carousel/src/components/ImageList/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/components/InfoElement/index.d.ts +9 -0
- package/build/types/widget-image-carousel/src/components/InfoElement/index.d.ts.map +1 -0
- package/build/types/widget-image-carousel/src/components/OpenConfiguratorButton/index.d.ts +13 -0
- package/build/types/widget-image-carousel/src/components/OpenConfiguratorButton/index.d.ts.map +1 -0
- package/build/types/widget-image-carousel/src/components/Swiper/index.d.ts +4 -3
- package/build/types/widget-image-carousel/src/components/Swiper/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/components/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/stories/SimilarProducts/default.stories.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-prod.stories.d.ts +8 -0
- package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-prod.stories.d.ts.map +1 -0
- package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-test.stories.d.ts +8 -0
- package/build/types/widget-image-carousel/src/stories/SimpleProductList/kirchner-test.stories.d.ts.map +1 -0
- package/build/types/widget-image-carousel/src/types/index.d.ts +31 -4
- package/build/types/widget-image-carousel/src/types/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/useImageCarousel.d.ts +3 -8
- package/build/types/widget-image-carousel/src/useImageCarousel.d.ts.map +1 -1
- package/build/umd/report.html +1 -1
- package/build/umd/widget-image-carousel.umd.min.js +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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, replaceTemplatesInObject, 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';
|
|
8
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
8
9
|
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
9
10
|
import { Navigation } from 'swiper/modules';
|
|
10
11
|
import classNames from 'classnames';
|
|
11
12
|
import 'swiper/css';
|
|
12
13
|
import 'swiper/css/navigation';
|
|
13
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
14
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
14
15
|
|
|
15
16
|
(function() {
|
|
16
17
|
const env = {"STAGE":"production"};
|
|
@@ -28,7 +29,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
28
29
|
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
30
|
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
31
|
function useImageCarousel(_ref) {
|
|
31
|
-
var
|
|
32
|
+
var productIds = _ref.productIds,
|
|
32
33
|
settings = _ref.settings;
|
|
33
34
|
var _useState = useState([]),
|
|
34
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -42,45 +43,63 @@ function useImageCarousel(_ref) {
|
|
|
42
43
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
44
|
error = _useState6[0],
|
|
44
45
|
setError = _useState6[1];
|
|
46
|
+
var _useDivaCore = useDivaCore(),
|
|
47
|
+
openComponent = _useDivaCore.actions.openComponent;
|
|
48
|
+
var _useTranslation = useTranslation(),
|
|
49
|
+
i18n = _useTranslation.i18n;
|
|
45
50
|
useCss(settings);
|
|
46
51
|
var _useProductData = useProductData({
|
|
47
|
-
productIds:
|
|
48
|
-
widgetType: 'IMAGECAROUSEL'
|
|
52
|
+
productIds: productIds,
|
|
53
|
+
widgetType: 'IMAGECAROUSEL',
|
|
54
|
+
standaloneWidget: settings.type === 'SIMPLE_PRODUCT_LIST'
|
|
49
55
|
}),
|
|
50
56
|
getProductsByDivaNrs = _useProductData.getProductsByDivaNrs,
|
|
51
57
|
getProductByDivaNrAndVariantId = _useProductData.getProductByDivaNrAndVariantId,
|
|
52
58
|
setSelectedProductId = _useProductData.setSelectedProductId,
|
|
53
59
|
selectedProduct = _useProductData.selectedProduct,
|
|
54
|
-
setProductCache = _useProductData.setProductCache
|
|
60
|
+
setProductCache = _useProductData.setProductCache,
|
|
61
|
+
getSimpleProductListByIds = _useProductData.getSimpleProductListByIds,
|
|
62
|
+
productVariants = _useProductData.productVariants;
|
|
55
63
|
var onClickProduct = useCallback(function (productId) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
behavior: 'smooth'
|
|
64
|
+
if (settings.openComponent) {
|
|
65
|
+
var clonedSettings = cloneDeep(settings);
|
|
66
|
+
var product = productVariants.find(function (p) {
|
|
67
|
+
return p._id === productId;
|
|
61
68
|
});
|
|
69
|
+
if (product) {
|
|
70
|
+
var action = replaceTemplatesInObject(clonedSettings.openComponent, product, i18n.language);
|
|
71
|
+
openComponent(action);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
setSelectedProductId(productId);
|
|
75
|
+
if (!settings.disableScrollToTop) {
|
|
76
|
+
window.scrollTo({
|
|
77
|
+
top: 0,
|
|
78
|
+
behavior: 'smooth'
|
|
79
|
+
});
|
|
80
|
+
}
|
|
62
81
|
}
|
|
63
|
-
}, [setSelectedProductId]);
|
|
82
|
+
}, [setSelectedProductId, settings.openComponent, productVariants]);
|
|
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
|
-
|
|
74
|
-
|
|
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.
|
|
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 =
|
|
127
|
+
_context.next = 29;
|
|
109
128
|
break;
|
|
110
129
|
case 21:
|
|
111
|
-
|
|
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
|
|
116
|
-
_context.prev =
|
|
153
|
+
case 35:
|
|
154
|
+
_context.prev = 35;
|
|
117
155
|
setLoading(false);
|
|
118
|
-
return _context.finish(
|
|
119
|
-
case
|
|
156
|
+
return _context.finish(35);
|
|
157
|
+
case 38:
|
|
120
158
|
case "end":
|
|
121
159
|
return _context.stop();
|
|
122
160
|
}
|
|
123
|
-
}, _callee, null, [[0,
|
|
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 &&
|
|
167
|
+
if (selectedProduct || productIds !== null && productIds !== void 0 && productIds.length && settings.type === 'SIMPLE_PRODUCT_LIST') {
|
|
130
168
|
loadMockups();
|
|
131
169
|
}
|
|
132
|
-
}, [selectedProduct,
|
|
170
|
+
}, [selectedProduct, productIds]);
|
|
133
171
|
return {
|
|
134
172
|
media: media,
|
|
135
173
|
error: error,
|
|
136
174
|
loading: loading,
|
|
137
|
-
|
|
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(
|
|
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,
|
|
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
|
|
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 (
|
|
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
|
-
|
|
426
|
+
infoElements: infoElements ? addInfoElements(infoElements, similarProduct) : undefined,
|
|
391
427
|
productId: similarProduct._id
|
|
392
428
|
});
|
|
393
429
|
}
|
|
@@ -401,14 +437,172 @@ 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
|
+
}
|
|
404
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("span", {
|
|
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
|
+
});
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function styleInject(css, ref) {
|
|
568
|
+
if ( ref === void 0 ) ref = {};
|
|
569
|
+
var insertAt = ref.insertAt;
|
|
570
|
+
|
|
571
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
572
|
+
|
|
573
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
574
|
+
var style = document.createElement('style');
|
|
575
|
+
style.type = 'text/css';
|
|
576
|
+
|
|
577
|
+
if (insertAt === 'top') {
|
|
578
|
+
if (head.firstChild) {
|
|
579
|
+
head.insertBefore(style, head.firstChild);
|
|
580
|
+
} else {
|
|
581
|
+
head.appendChild(style);
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
head.appendChild(style);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (style.styleSheet) {
|
|
588
|
+
style.styleSheet.cssText = css;
|
|
589
|
+
} else {
|
|
590
|
+
style.appendChild(document.createTextNode(css));
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
var slideInfoElement = "slideInfoElement-hvOw3";
|
|
595
|
+
var css_248z = ".imageCarouselContainer-5xR1Z {\n width: 100%;\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 20px;\n}\n\n.imageCarousel-doGe7 {\n height: 100%;\n width: 100%;\n}\n\n.slide-kzTjO {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n}\n\n.slideImage-25uCG {\n max-height: 100%;\n max-width: 100%;\n -o-object-fit: contain;\n object-fit: contain;\n cursor: pointer;\n}\n\n.slideDescriptionImage-qebF3 {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 100%;\n}\n\n.slideDescriptionImage-qebF3 img {\n cursor: pointer;\n display: block;\n width: 100%;\n max-height: 75%;\n height: auto;\n -o-object-fit: contain;\n object-fit: contain;\n}\n\n.slideDescription-UOsb1 {\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 25%;\n background: lightgrey;\n color: black;\n text-align: center;\n}\n\n.slideDescription-UOsb1 span {\n font-size: 26px;\n}\n\n.slideInfoElement-hvOw3 {\n display: flex;\n flex-direction: column;\n}\n";
|
|
596
|
+
styleInject(css_248z);
|
|
405
597
|
|
|
406
598
|
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
599
|
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
600
|
var SwiperComponent = function SwiperComponent(_ref) {
|
|
601
|
+
var _settings$sliderProp;
|
|
409
602
|
var media = _ref.media,
|
|
410
603
|
settings = _ref.settings,
|
|
411
|
-
|
|
604
|
+
onClickProduct = _ref.onClickProduct,
|
|
605
|
+
isMobile = _ref.isMobile;
|
|
412
606
|
return /*#__PURE__*/jsx("div", {
|
|
413
607
|
className: classNames(['diva-widget-image-carousel-container']),
|
|
414
608
|
children: /*#__PURE__*/jsx(Swiper, _objectSpread$1(_objectSpread$1({
|
|
@@ -416,13 +610,18 @@ var SwiperComponent = function SwiperComponent(_ref) {
|
|
|
416
610
|
navigation: true,
|
|
417
611
|
className: classNames(['diva-widget-image-carousel-swiper'])
|
|
418
612
|
}, settings.sliderProp), {}, {
|
|
613
|
+
loop: ((_settings$sliderProp = settings.sliderProp) === null || _settings$sliderProp === void 0 ? void 0 : _settings$sliderProp.loop) && media.length > 1,
|
|
419
614
|
children: media.map(function (m, i) {
|
|
615
|
+
var _settings$infoElement, _settings$openConfigu, _settings$openConfigu2, _settings$infoElement2, _settings$openConfigu3, _settings$openConfigu4;
|
|
420
616
|
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
421
617
|
className: classNames(['diva-widget-image-carousel-slide']),
|
|
422
|
-
|
|
618
|
+
onClick: function onClick() {
|
|
619
|
+
return onClickProduct(m.productId);
|
|
620
|
+
},
|
|
621
|
+
children: (_settings$infoElement = settings.infoElements) !== null && _settings$infoElement !== void 0 && _settings$infoElement.length ? /*#__PURE__*/jsxs("div", {
|
|
423
622
|
className: classNames(['diva-widget-image-carousel-slide-description-image']),
|
|
424
623
|
onClick: function onClick() {
|
|
425
|
-
return
|
|
624
|
+
return onClickProduct(m.productId);
|
|
426
625
|
},
|
|
427
626
|
children: [/*#__PURE__*/jsx(MediaItem, {
|
|
428
627
|
mediaUrl: m.url,
|
|
@@ -430,24 +629,51 @@ var SwiperComponent = function SwiperComponent(_ref) {
|
|
|
430
629
|
config: {
|
|
431
630
|
disableSirv: false,
|
|
432
631
|
sirvProps: settings.sirvProps
|
|
632
|
+
},
|
|
633
|
+
overlay: !isMobile && (_settings$openConfigu = settings.openConfiguratorCta) !== null && _settings$openConfigu !== void 0 && _settings$openConfigu.enabled ? /*#__PURE__*/jsx(OpenConfiguratorButton, {
|
|
634
|
+
settings: settings.openConfiguratorCta,
|
|
635
|
+
onClick: function onClick() {
|
|
636
|
+
return onClickProduct(m.productId);
|
|
637
|
+
}
|
|
638
|
+
}) : undefined
|
|
639
|
+
}), ((_settings$openConfigu2 = settings.openConfiguratorCta) === null || _settings$openConfigu2 === void 0 ? void 0 : _settings$openConfigu2.enabled) && isMobile && /*#__PURE__*/jsx(OpenConfiguratorButton, {
|
|
640
|
+
settings: settings.openConfiguratorCta,
|
|
641
|
+
onClick: function onClick() {
|
|
642
|
+
return onClickProduct(m.productId);
|
|
433
643
|
}
|
|
434
644
|
}), /*#__PURE__*/jsx("div", {
|
|
435
|
-
className: classNames(['diva-widget-image-carousel-slide-
|
|
436
|
-
children:
|
|
437
|
-
|
|
645
|
+
className: classNames([slideInfoElement, 'diva-widget-image-carousel-slide-info']),
|
|
646
|
+
children: (_settings$infoElement2 = settings.infoElements) === null || _settings$infoElement2 === void 0 ? void 0 : _settings$infoElement2.map(function (infoElement) {
|
|
647
|
+
return /*#__PURE__*/jsx(InfoElementComponent, {
|
|
648
|
+
infoElement: infoElement,
|
|
649
|
+
media: m
|
|
650
|
+
});
|
|
438
651
|
})
|
|
439
652
|
})]
|
|
440
|
-
}) : /*#__PURE__*/
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
653
|
+
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
654
|
+
children: [/*#__PURE__*/jsx(MediaItem, {
|
|
655
|
+
mediaUrl: m.url,
|
|
656
|
+
isCurrentlyVisible: true,
|
|
657
|
+
config: {
|
|
658
|
+
disableSirv: false,
|
|
659
|
+
sirvProps: settings.sirvProps
|
|
660
|
+
},
|
|
661
|
+
className: classNames(['diva-widget-image-carousel-slide-image']),
|
|
662
|
+
onClick: function onClick() {
|
|
663
|
+
return onClickProduct(m.productId);
|
|
664
|
+
},
|
|
665
|
+
overlay: !isMobile && (_settings$openConfigu3 = settings.openConfiguratorCta) !== null && _settings$openConfigu3 !== void 0 && _settings$openConfigu3.enabled ? /*#__PURE__*/jsx(OpenConfiguratorButton, {
|
|
666
|
+
settings: settings.openConfiguratorCta,
|
|
667
|
+
onClick: function onClick() {
|
|
668
|
+
return onClickProduct(m.productId);
|
|
669
|
+
}
|
|
670
|
+
}) : undefined
|
|
671
|
+
}), ((_settings$openConfigu4 = settings.openConfiguratorCta) === null || _settings$openConfigu4 === void 0 ? void 0 : _settings$openConfigu4.enabled) && isMobile && /*#__PURE__*/jsx(OpenConfiguratorButton, {
|
|
672
|
+
settings: settings.openConfiguratorCta,
|
|
673
|
+
onClick: function onClick() {
|
|
674
|
+
return onClickProduct(m.productId);
|
|
675
|
+
}
|
|
676
|
+
})]
|
|
451
677
|
})
|
|
452
678
|
}, i);
|
|
453
679
|
})
|
|
@@ -458,16 +684,17 @@ var SwiperComponent = function SwiperComponent(_ref) {
|
|
|
458
684
|
var ImageList = function ImageList(_ref) {
|
|
459
685
|
var media = _ref.media,
|
|
460
686
|
settings = _ref.settings,
|
|
461
|
-
|
|
687
|
+
onClickProduct = _ref.onClickProduct;
|
|
462
688
|
return /*#__PURE__*/jsx("div", {
|
|
463
689
|
className: classNames(['diva-widget-image-list']),
|
|
464
690
|
children: media.map(function (m, i) {
|
|
691
|
+
var _settings$infoElement, _settings$openConfigu, _settings$infoElement2, _settings$openConfigu2;
|
|
465
692
|
return /*#__PURE__*/jsx("div", {
|
|
466
693
|
className: classNames(['diva-widget-image-list-item']),
|
|
467
|
-
children: settings.
|
|
694
|
+
children: (_settings$infoElement = settings.infoElements) !== null && _settings$infoElement !== void 0 && _settings$infoElement.length ? /*#__PURE__*/jsxs("div", {
|
|
468
695
|
className: classNames(['diva-widget-image-list-item-description-image']),
|
|
469
696
|
onClick: function onClick() {
|
|
470
|
-
return
|
|
697
|
+
return onClickProduct(m.productId);
|
|
471
698
|
},
|
|
472
699
|
children: [/*#__PURE__*/jsx(MediaItem, {
|
|
473
700
|
mediaUrl: m.url,
|
|
@@ -476,23 +703,38 @@ var ImageList = function ImageList(_ref) {
|
|
|
476
703
|
disableSirv: false,
|
|
477
704
|
sirvProps: settings.sirvProps
|
|
478
705
|
}
|
|
706
|
+
}), ((_settings$openConfigu = settings.openConfiguratorCta) === null || _settings$openConfigu === void 0 ? void 0 : _settings$openConfigu.enabled) && /*#__PURE__*/jsx(OpenConfiguratorButton, {
|
|
707
|
+
settings: settings.openConfiguratorCta,
|
|
708
|
+
onClick: function onClick() {
|
|
709
|
+
return onClickProduct(m.productId);
|
|
710
|
+
}
|
|
479
711
|
}), /*#__PURE__*/jsx("div", {
|
|
480
|
-
className: classNames(['diva-widget-image-list-item-
|
|
481
|
-
children:
|
|
482
|
-
|
|
712
|
+
className: classNames(['diva-widget-image-list-item-info']),
|
|
713
|
+
children: (_settings$infoElement2 = settings.infoElements) === null || _settings$infoElement2 === void 0 ? void 0 : _settings$infoElement2.map(function (infoElement) {
|
|
714
|
+
return /*#__PURE__*/jsx(InfoElementComponent, {
|
|
715
|
+
infoElement: infoElement,
|
|
716
|
+
media: m
|
|
717
|
+
});
|
|
483
718
|
})
|
|
484
719
|
})]
|
|
485
|
-
}) : /*#__PURE__*/
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
720
|
+
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
721
|
+
children: [/*#__PURE__*/jsx(MediaItem, {
|
|
722
|
+
mediaUrl: m.url,
|
|
723
|
+
isCurrentlyVisible: true,
|
|
724
|
+
config: {
|
|
725
|
+
disableSirv: false,
|
|
726
|
+
sirvProps: settings.sirvProps
|
|
727
|
+
},
|
|
728
|
+
className: classNames(['diva-widget-image-list-item-image']),
|
|
729
|
+
onClick: function onClick() {
|
|
730
|
+
return onClickProduct(m.productId);
|
|
731
|
+
}
|
|
732
|
+
}), ((_settings$openConfigu2 = settings.openConfiguratorCta) === null || _settings$openConfigu2 === void 0 ? void 0 : _settings$openConfigu2.enabled) && /*#__PURE__*/jsx(OpenConfiguratorButton, {
|
|
733
|
+
settings: settings.openConfiguratorCta,
|
|
734
|
+
onClick: function onClick() {
|
|
735
|
+
return onClickProduct(m.productId);
|
|
736
|
+
}
|
|
737
|
+
})]
|
|
496
738
|
})
|
|
497
739
|
}, i);
|
|
498
740
|
})
|
|
@@ -504,35 +746,39 @@ function MainComponent(props) {
|
|
|
504
746
|
media = _useImageCarousel.media,
|
|
505
747
|
error = _useImageCarousel.error;
|
|
506
748
|
_useImageCarousel.loading;
|
|
507
|
-
var
|
|
749
|
+
var onClickProduct = _useImageCarousel.onClickProduct;
|
|
508
750
|
var _useDivaCore = useDivaCore(),
|
|
509
751
|
isMobile = _useDivaCore.state.isMobile;
|
|
510
752
|
if (error) return /*#__PURE__*/jsx("div", {
|
|
511
753
|
children: "Error"
|
|
512
754
|
});
|
|
513
|
-
if (isMobile &&
|
|
755
|
+
if (isMobile && props.settings.avoidUsingSwiperOnMobile) {
|
|
514
756
|
return /*#__PURE__*/jsx(ImageList, {
|
|
515
757
|
media: media,
|
|
516
758
|
settings: props.settings,
|
|
517
|
-
|
|
759
|
+
onClickProduct: onClickProduct
|
|
518
760
|
});
|
|
519
761
|
}
|
|
520
762
|
return /*#__PURE__*/jsx(SwiperComponent, {
|
|
521
763
|
media: media,
|
|
522
764
|
settings: props.settings,
|
|
523
|
-
|
|
765
|
+
onClickProduct: onClickProduct,
|
|
766
|
+
isMobile: isMobile
|
|
524
767
|
});
|
|
525
768
|
}
|
|
526
769
|
|
|
527
770
|
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
771
|
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
772
|
var Main = function Main(_ref) {
|
|
530
|
-
var _parameters$productId;
|
|
531
773
|
var settings = _ref.settings,
|
|
532
774
|
parameters = _ref.parameters;
|
|
775
|
+
var productIds = useMemo(function () {
|
|
776
|
+
var _parameters$productId, _parameters$productId2;
|
|
777
|
+
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 : [];
|
|
778
|
+
}, [parameters === null || parameters === void 0 ? void 0 : parameters.productIds]);
|
|
533
779
|
return /*#__PURE__*/jsx(ImageCarouselComponent, {
|
|
534
780
|
settings: settings,
|
|
535
|
-
|
|
781
|
+
productIds: productIds
|
|
536
782
|
});
|
|
537
783
|
};
|
|
538
784
|
var ImageCarouselComponent = function ImageCarouselComponent(props) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Media } from '@crystaldesign/widget-image-carousel/
|
|
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
|
-
|
|
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,
|
|
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
|