@crystaldesign/widget-library 25.8.0-rc.9 → 25.9.0-beta.10
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 +187 -85
- package/build/types/widget-library/src/components/Gallery/index.d.ts.map +1 -1
- package/build/types/widget-library/src/components/Gallery/types.d.ts +1 -0
- package/build/types/widget-library/src/components/Gallery/types.d.ts.map +1 -1
- package/build/types/widget-library/src/components/Gallery/useGallery.d.ts.map +1 -1
- package/build/types/widget-library/src/components/MediaItem/index.d.ts +1 -1
- package/build/types/widget-library/src/components/MediaItem/index.d.ts.map +1 -1
- package/build/types/widget-library/src/hooks/useGlobalCache.d.ts +1 -6
- package/build/types/widget-library/src/hooks/useGlobalCache.d.ts.map +1 -1
- package/build/types/widget-library/src/hooks/useProductData.d.ts +1 -6
- package/build/types/widget-library/src/hooks/useProductData.d.ts.map +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useDivaCore, getLogger, DivaError, useTranslation } from '@crystaldesig
|
|
|
3
3
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
5
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
6
|
+
import DivaUtils from '@crystaldesign/diva-utils';
|
|
6
7
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
7
8
|
import { Navigation, Thumbs, Pagination } from 'swiper/modules';
|
|
8
9
|
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
@@ -99,14 +100,9 @@ if (typeof window !== 'undefined' && !window.__divaWidgetCache) {
|
|
|
99
100
|
*/
|
|
100
101
|
function useGlobalCache(_ref) {
|
|
101
102
|
var uniqueWidgetId = _ref.uniqueWidgetId,
|
|
102
|
-
widgetType = _ref.widgetType
|
|
103
|
-
noGlobalCache = _ref.noGlobalCache;
|
|
103
|
+
widgetType = _ref.widgetType;
|
|
104
104
|
var getOrFetch = useCallback(function (key, fetcher) {
|
|
105
105
|
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] getOrFetch called for key: ").concat(key));
|
|
106
|
-
if (noGlobalCache) {
|
|
107
|
-
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] Global cache disabled, fetching directly for key: ").concat(key));
|
|
108
|
-
return fetcher();
|
|
109
|
-
}
|
|
110
106
|
if (typeof window === 'undefined' || !window.__divaWidgetCache) {
|
|
111
107
|
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] No global cache available, fetching directly for key: ").concat(key));
|
|
112
108
|
return fetcher();
|
|
@@ -264,8 +260,7 @@ var generateWidgetId = function generateWidgetId() {
|
|
|
264
260
|
function useProductData(_ref) {
|
|
265
261
|
var productIds = _ref.productIds,
|
|
266
262
|
variants = _ref.variants,
|
|
267
|
-
widgetType = _ref.widgetType
|
|
268
|
-
noGlobalCache = _ref.noGlobalCache;
|
|
263
|
+
widgetType = _ref.widgetType;
|
|
269
264
|
// Generate stable widget ID that persists for the lifetime of this hook instance
|
|
270
265
|
// Function to handle selectedProduct changes
|
|
271
266
|
|
|
@@ -276,8 +271,7 @@ function useProductData(_ref) {
|
|
|
276
271
|
handler = _useDivaCore.handler;
|
|
277
272
|
var _useGlobalCache = useGlobalCache({
|
|
278
273
|
uniqueWidgetId: widgetId,
|
|
279
|
-
widgetType: widgetType
|
|
280
|
-
noGlobalCache: noGlobalCache
|
|
274
|
+
widgetType: widgetType
|
|
281
275
|
}),
|
|
282
276
|
getOrFetch = _useGlobalCache.getOrFetch,
|
|
283
277
|
setCache = _useGlobalCache.setCache;
|
|
@@ -297,6 +291,10 @@ function useProductData(_ref) {
|
|
|
297
291
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
298
292
|
error = _useState8[0],
|
|
299
293
|
setError = _useState8[1];
|
|
294
|
+
var _useState9 = useState(true),
|
|
295
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
296
|
+
initialProduct = _useState10[0],
|
|
297
|
+
setInitialProduct = _useState10[1];
|
|
300
298
|
var fetchProducts = useCallback(/*#__PURE__*/function () {
|
|
301
299
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ids) {
|
|
302
300
|
var productPromises, results, flattenedResults;
|
|
@@ -423,15 +421,39 @@ function useProductData(_ref) {
|
|
|
423
421
|
}
|
|
424
422
|
setError(false);
|
|
425
423
|
setLoading(true);
|
|
426
|
-
fetchProducts(normalizedProductIds).then(function (
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
424
|
+
fetchProducts(normalizedProductIds).then(/*#__PURE__*/function () {
|
|
425
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(variants) {
|
|
426
|
+
var variantToUse, _variantToUse$catCode;
|
|
427
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
428
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
429
|
+
case 0:
|
|
430
|
+
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Successfully loaded ").concat(variants.length, " product variants"));
|
|
431
|
+
setProductVariants(variants);
|
|
432
|
+
variantToUse = variants.find(function (v) {
|
|
433
|
+
return v._id === normalizedProductIds[0];
|
|
434
|
+
});
|
|
435
|
+
setSelectedProduct(variantToUse !== null && variantToUse !== void 0 ? variantToUse : variants[0]);
|
|
436
|
+
setLoading(false);
|
|
437
|
+
if (!initialProduct) {
|
|
438
|
+
_context4.next = 10;
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
DivaUtils.businessMetrics.setConfiguratorSessionId(undefined, true);
|
|
442
|
+
setInitialProduct(false);
|
|
443
|
+
_context4.next = 10;
|
|
444
|
+
return logSelectedProduct(normalizedProductIds[0], widgetType, variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.variantId, variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.modelName, variantToUse === null || variantToUse === void 0 || (_variantToUse$catCode = variantToUse.catCodex) === null || _variantToUse$catCode === void 0 ? void 0 : _variantToUse$catCode.toString(), variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.configuration.OrderSets.map(function (set) {
|
|
445
|
+
return set.SupplierGUID;
|
|
446
|
+
}), 'onWidgetInitialProduct');
|
|
447
|
+
case 10:
|
|
448
|
+
case "end":
|
|
449
|
+
return _context4.stop();
|
|
450
|
+
}
|
|
451
|
+
}, _callee4);
|
|
452
|
+
}));
|
|
453
|
+
return function (_x4) {
|
|
454
|
+
return _ref5.apply(this, arguments);
|
|
455
|
+
};
|
|
456
|
+
}())["catch"](function (error) {
|
|
435
457
|
LOG.error(new DivaError("[".concat(widgetType, ":").concat(widgetId, "] Error loading products"), {
|
|
436
458
|
cause: error
|
|
437
459
|
}));
|
|
@@ -441,17 +463,17 @@ function useProductData(_ref) {
|
|
|
441
463
|
});
|
|
442
464
|
}, [normalizedProductIds]);
|
|
443
465
|
var setSelectedProductId = useCallback(/*#__PURE__*/function () {
|
|
444
|
-
var
|
|
445
|
-
var product, _variants2, _product;
|
|
446
|
-
return _regeneratorRuntime.wrap(function
|
|
447
|
-
while (1) switch (
|
|
466
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(productId) {
|
|
467
|
+
var product, _product$catCodex, _variants2, _product, _product$catCodex2;
|
|
468
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
469
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
448
470
|
case 0:
|
|
449
471
|
if (!((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct._id) === productId)) {
|
|
450
|
-
|
|
472
|
+
_context5.next = 3;
|
|
451
473
|
break;
|
|
452
474
|
}
|
|
453
475
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " already selected, skipping"));
|
|
454
|
-
return
|
|
476
|
+
return _context5.abrupt("return");
|
|
455
477
|
case 3:
|
|
456
478
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] setSelectedProductId called with productId: ").concat(productId));
|
|
457
479
|
|
|
@@ -461,74 +483,84 @@ function useProductData(_ref) {
|
|
|
461
483
|
return p._id === productId;
|
|
462
484
|
});
|
|
463
485
|
if (!product) {
|
|
464
|
-
|
|
486
|
+
_context5.next = 12;
|
|
465
487
|
break;
|
|
466
488
|
}
|
|
467
489
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " found in current variants, setting as selected"));
|
|
468
490
|
setSelectedProduct(product);
|
|
469
491
|
notifyProductChanged(product);
|
|
470
|
-
|
|
471
|
-
|
|
492
|
+
_context5.next = 11;
|
|
493
|
+
return logSelectedProduct(productId, widgetType, product.variantId, product.modelName, (_product$catCodex = product.catCodex) === null || _product$catCodex === void 0 ? void 0 : _product$catCodex.toString(), product.configuration ? product.configuration.OrderSets.map(function (set) {
|
|
494
|
+
return set.SupplierGUID;
|
|
495
|
+
}) : undefined);
|
|
496
|
+
case 11:
|
|
497
|
+
return _context5.abrupt("return");
|
|
498
|
+
case 12:
|
|
472
499
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " not found in current variants, fetching variants for it"));
|
|
473
|
-
|
|
500
|
+
_context5.prev = 13;
|
|
474
501
|
setError(false);
|
|
475
502
|
setLoading(true);
|
|
476
|
-
|
|
503
|
+
_context5.next = 18;
|
|
477
504
|
return fetchProducts([productId]);
|
|
478
|
-
case
|
|
479
|
-
_variants2 =
|
|
505
|
+
case 18:
|
|
506
|
+
_variants2 = _context5.sent;
|
|
480
507
|
setProductVariants(_variants2);
|
|
481
508
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] New ").concat(_variants2.length, " variants to productVariants"));
|
|
482
509
|
_product = _variants2.find(function (p) {
|
|
483
510
|
return p._id === productId;
|
|
484
511
|
});
|
|
485
512
|
if (!_product) {
|
|
486
|
-
|
|
513
|
+
_context5.next = 30;
|
|
487
514
|
break;
|
|
488
515
|
}
|
|
489
516
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Setting product ").concat(productId, " as selected after fetching"));
|
|
490
517
|
setSelectedProduct(_product);
|
|
491
518
|
notifyProductChanged(_product);
|
|
492
|
-
|
|
519
|
+
_context5.next = 28;
|
|
520
|
+
return logSelectedProduct(productId, widgetType, _product.variantId, _product.modelName, (_product$catCodex2 = _product.catCodex) === null || _product$catCodex2 === void 0 ? void 0 : _product$catCodex2.toString(), _product.configuration.OrderSets.map(function (set) {
|
|
521
|
+
return set.SupplierGUID;
|
|
522
|
+
}));
|
|
523
|
+
case 28:
|
|
524
|
+
_context5.next = 31;
|
|
493
525
|
break;
|
|
494
|
-
case
|
|
526
|
+
case 30:
|
|
495
527
|
throw new DivaError("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " not found"));
|
|
496
|
-
case
|
|
497
|
-
|
|
528
|
+
case 31:
|
|
529
|
+
_context5.next = 37;
|
|
498
530
|
break;
|
|
499
|
-
case
|
|
500
|
-
|
|
501
|
-
|
|
531
|
+
case 33:
|
|
532
|
+
_context5.prev = 33;
|
|
533
|
+
_context5.t0 = _context5["catch"](13);
|
|
502
534
|
LOG.error(new DivaError("[".concat(widgetType, ":").concat(widgetId, "] Error loading product"), {
|
|
503
|
-
cause:
|
|
535
|
+
cause: _context5.t0
|
|
504
536
|
}));
|
|
505
537
|
setError(true);
|
|
506
|
-
case
|
|
507
|
-
|
|
538
|
+
case 37:
|
|
539
|
+
_context5.prev = 37;
|
|
508
540
|
setLoading(false);
|
|
509
|
-
return
|
|
510
|
-
case
|
|
541
|
+
return _context5.finish(37);
|
|
542
|
+
case 40:
|
|
511
543
|
case "end":
|
|
512
|
-
return
|
|
544
|
+
return _context5.stop();
|
|
513
545
|
}
|
|
514
|
-
},
|
|
546
|
+
}, _callee5, null, [[13, 33, 37, 40]]);
|
|
515
547
|
}));
|
|
516
|
-
return function (
|
|
517
|
-
return
|
|
548
|
+
return function (_x5) {
|
|
549
|
+
return _ref6.apply(this, arguments);
|
|
518
550
|
};
|
|
519
551
|
}(), [selectedProduct, productVariants, fetchProducts, setSelectedProduct, widgetId, widgetType]);
|
|
520
|
-
function getProductsByDivaNrs(
|
|
552
|
+
function getProductsByDivaNrs(_x6) {
|
|
521
553
|
return _getProductsByDivaNrs.apply(this, arguments);
|
|
522
554
|
}
|
|
523
555
|
function _getProductsByDivaNrs() {
|
|
524
|
-
_getProductsByDivaNrs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
556
|
+
_getProductsByDivaNrs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(divaNrs) {
|
|
525
557
|
var products;
|
|
526
|
-
return _regeneratorRuntime.wrap(function
|
|
527
|
-
while (1) switch (
|
|
558
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
559
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
528
560
|
case 0:
|
|
529
561
|
// Sort divaNrs array to ensure consistent cache keys
|
|
530
562
|
divaNrs.sort();
|
|
531
|
-
|
|
563
|
+
_context6.next = 3;
|
|
532
564
|
return getOrFetch('divaNrs' + divaNrs.join(','), function () {
|
|
533
565
|
return handler.productHandler.apiGetProductByQuery([{
|
|
534
566
|
id: 'divaNr',
|
|
@@ -541,24 +573,24 @@ function useProductData(_ref) {
|
|
|
541
573
|
}], 1000, false);
|
|
542
574
|
});
|
|
543
575
|
case 3:
|
|
544
|
-
products =
|
|
545
|
-
return
|
|
576
|
+
products = _context6.sent;
|
|
577
|
+
return _context6.abrupt("return", products);
|
|
546
578
|
case 5:
|
|
547
579
|
case "end":
|
|
548
|
-
return
|
|
580
|
+
return _context6.stop();
|
|
549
581
|
}
|
|
550
|
-
},
|
|
582
|
+
}, _callee6);
|
|
551
583
|
}));
|
|
552
584
|
return _getProductsByDivaNrs.apply(this, arguments);
|
|
553
585
|
}
|
|
554
|
-
function getProductByDivaNrAndVariantId(
|
|
586
|
+
function getProductByDivaNrAndVariantId(_x7, _x8) {
|
|
555
587
|
return _getProductByDivaNrAndVariantId.apply(this, arguments);
|
|
556
588
|
}
|
|
557
589
|
function _getProductByDivaNrAndVariantId() {
|
|
558
|
-
_getProductByDivaNrAndVariantId = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
590
|
+
_getProductByDivaNrAndVariantId = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(divaNr, variantId) {
|
|
559
591
|
var filter, product;
|
|
560
|
-
return _regeneratorRuntime.wrap(function
|
|
561
|
-
while (1) switch (
|
|
592
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
593
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
562
594
|
case 0:
|
|
563
595
|
filter = [{
|
|
564
596
|
id: 'divaNr',
|
|
@@ -576,18 +608,18 @@ function useProductData(_ref) {
|
|
|
576
608
|
value: parseInt(variantId)
|
|
577
609
|
});
|
|
578
610
|
}
|
|
579
|
-
|
|
611
|
+
_context7.next = 4;
|
|
580
612
|
return getOrFetch('divaNr' + divaNr + 'variantId' + variantId, function () {
|
|
581
613
|
return handler.productHandler.apiGetProductByQuery(filter, 1, false);
|
|
582
614
|
});
|
|
583
615
|
case 4:
|
|
584
|
-
product =
|
|
585
|
-
return
|
|
616
|
+
product = _context7.sent;
|
|
617
|
+
return _context7.abrupt("return", product);
|
|
586
618
|
case 6:
|
|
587
619
|
case "end":
|
|
588
|
-
return
|
|
620
|
+
return _context7.stop();
|
|
589
621
|
}
|
|
590
|
-
},
|
|
622
|
+
}, _callee7);
|
|
591
623
|
}));
|
|
592
624
|
return _getProductByDivaNrAndVariantId.apply(this, arguments);
|
|
593
625
|
}
|
|
@@ -597,6 +629,33 @@ function useProductData(_ref) {
|
|
|
597
629
|
timestamp: Date.now()
|
|
598
630
|
});
|
|
599
631
|
}
|
|
632
|
+
function logSelectedProduct(_x9, _x10, _x11, _x12, _x13, _x14) {
|
|
633
|
+
return _logSelectedProduct.apply(this, arguments);
|
|
634
|
+
}
|
|
635
|
+
function _logSelectedProduct() {
|
|
636
|
+
_logSelectedProduct = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(productId, widgetType, variantId, catalogName, catalogCodex, supplierId) {
|
|
637
|
+
var event,
|
|
638
|
+
_args8 = arguments;
|
|
639
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
640
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
641
|
+
case 0:
|
|
642
|
+
event = _args8.length > 6 && _args8[6] !== undefined ? _args8[6] : 'onWidgetProductSelected';
|
|
643
|
+
LOG.businessEvent(event, 'DivaWidget', "Product ".concat(productId, " selected in widget ").concat(widgetType), {
|
|
644
|
+
productId: productId,
|
|
645
|
+
variantId: variantId,
|
|
646
|
+
widgetType: widgetType,
|
|
647
|
+
catalogName: catalogName,
|
|
648
|
+
catalogCodex: catalogCodex,
|
|
649
|
+
supplierId: supplierId
|
|
650
|
+
});
|
|
651
|
+
case 2:
|
|
652
|
+
case "end":
|
|
653
|
+
return _context8.stop();
|
|
654
|
+
}
|
|
655
|
+
}, _callee8);
|
|
656
|
+
}));
|
|
657
|
+
return _logSelectedProduct.apply(this, arguments);
|
|
658
|
+
}
|
|
600
659
|
return {
|
|
601
660
|
productVariants: productVariants,
|
|
602
661
|
error: error,
|
|
@@ -789,6 +848,7 @@ function useGallery(_ref) {
|
|
|
789
848
|
setSwiperIsInitialized(true);
|
|
790
849
|
return;
|
|
791
850
|
}
|
|
851
|
+
if (swiper.isBeginning) return;
|
|
792
852
|
var newMediaIndex = swiper.realIndex;
|
|
793
853
|
var media = medias[newMediaIndex];
|
|
794
854
|
setCurrentMediaIndex(newMediaIndex);
|
|
@@ -913,18 +973,55 @@ var MediaItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
913
973
|
var _media$url;
|
|
914
974
|
var media = _ref.media,
|
|
915
975
|
mediaUrl = _ref.mediaUrl,
|
|
916
|
-
|
|
917
|
-
config = _ref.config
|
|
918
|
-
_ref.isCurrentlyVisible
|
|
919
|
-
|
|
976
|
+
videoAutoplay = _ref.videoAutoplay,
|
|
977
|
+
config = _ref.config,
|
|
978
|
+
isCurrentlyVisible = _ref.isCurrentlyVisible,
|
|
979
|
+
onClick = _ref.onClick;
|
|
920
980
|
var useSirv = false;
|
|
921
981
|
var _useDivaCore = useDivaCore(),
|
|
922
982
|
baseSirvUrls = _useDivaCore.state.apiConfig.baseSirvUrls;
|
|
983
|
+
var videoRef = useRef(null);
|
|
984
|
+
useEffect(function () {
|
|
985
|
+
if (videoAutoplay && (media === null || media === void 0 ? void 0 : media.mediaType) === 'VID' && videoRef.current && isCurrentlyVisible) {
|
|
986
|
+
var video = videoRef.current;
|
|
987
|
+
|
|
988
|
+
// Set muted before attempting to play (required for autoplay)
|
|
989
|
+
video.muted = true;
|
|
990
|
+
// Add autoplay attributes
|
|
991
|
+
video.autoplay = true;
|
|
992
|
+
video.playsInline = true;
|
|
993
|
+
video.loop = true;
|
|
994
|
+
|
|
995
|
+
// Ensure video is loaded before attempting to play
|
|
996
|
+
if (video.readyState >= 2) {
|
|
997
|
+
var playPromise = video.play();
|
|
998
|
+
if (playPromise !== undefined) {
|
|
999
|
+
playPromise["catch"](function (error) {
|
|
1000
|
+
console.warn('Autoplay was blocked by browser:', error);
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
} else {
|
|
1004
|
+
// If video is not loaded yet, wait for it to load
|
|
1005
|
+
var _handleCanPlay = function handleCanPlay() {
|
|
1006
|
+
video.removeEventListener('canplay', _handleCanPlay);
|
|
1007
|
+
var playPromise = video.play();
|
|
1008
|
+
if (playPromise !== undefined) {
|
|
1009
|
+
playPromise["catch"](function (error) {
|
|
1010
|
+
console.warn('Autoplay was blocked by browser:', error);
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
video.addEventListener('canplay', _handleCanPlay);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}, [isCurrentlyVisible, videoAutoplay, media === null || media === void 0 ? void 0 : media.mediaType]);
|
|
923
1018
|
if (!media && !mediaUrl) return /*#__PURE__*/jsx(Fragment, {});
|
|
924
1019
|
var url = (_media$url = media === null || media === void 0 ? void 0 : media.url) !== null && _media$url !== void 0 ? _media$url : mediaUrl;
|
|
925
1020
|
if (!config.disableSirv && url && baseSirvUrls !== null && baseSirvUrls !== void 0 && baseSirvUrls.find(function (base) {
|
|
926
1021
|
return url === null || url === void 0 ? void 0 : url.includes(base);
|
|
927
|
-
}))
|
|
1022
|
+
})) {
|
|
1023
|
+
useSirv = true;
|
|
1024
|
+
}
|
|
928
1025
|
if (media && useSirv) return /*#__PURE__*/jsx(SirvMediaItem, {
|
|
929
1026
|
media: media,
|
|
930
1027
|
config: config
|
|
@@ -933,18 +1030,21 @@ var MediaItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
933
1030
|
ref: ref,
|
|
934
1031
|
media: media
|
|
935
1032
|
});
|
|
936
|
-
if (media && media.mediaType == 'VID')
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1033
|
+
if (media && media.mediaType == 'VID') {
|
|
1034
|
+
var _media$url2;
|
|
1035
|
+
return /*#__PURE__*/jsx("video", {
|
|
1036
|
+
ref: videoRef,
|
|
1037
|
+
className: "diva-widget-mediaitem",
|
|
1038
|
+
autoPlay: videoAutoplay,
|
|
1039
|
+
muted: videoAutoplay,
|
|
1040
|
+
playsInline: videoAutoplay,
|
|
1041
|
+
loop: videoAutoplay,
|
|
1042
|
+
children: /*#__PURE__*/jsx("source", {
|
|
1043
|
+
src: media.url,
|
|
1044
|
+
type: media !== null && media !== void 0 && (_media$url2 = media.url) !== null && _media$url2 !== void 0 && _media$url2.includes('.mp4') ? 'video/mp4' : 'video/webm'
|
|
1045
|
+
})
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
948
1048
|
return /*#__PURE__*/jsx("img", {
|
|
949
1049
|
className: "diva-widget-mediaitem",
|
|
950
1050
|
src: url,
|
|
@@ -1139,11 +1239,13 @@ var Gallery = function Gallery(props) {
|
|
|
1139
1239
|
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
1140
1240
|
id: 'gallery media index ' + i,
|
|
1141
1241
|
"data-product-id": media.productId,
|
|
1242
|
+
"data-visible": i === (swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex),
|
|
1142
1243
|
children: /*#__PURE__*/jsx(MediaItem, {
|
|
1143
1244
|
media: media,
|
|
1144
1245
|
config: props.config,
|
|
1145
1246
|
isCurrentlyVisible: i === (swiper === null || swiper === void 0 ? void 0 : swiper.activeIndex),
|
|
1146
|
-
ref: htmlArElement
|
|
1247
|
+
ref: htmlArElement,
|
|
1248
|
+
videoAutoplay: props.config.videoAutoplay
|
|
1147
1249
|
})
|
|
1148
1250
|
}, media.ref);
|
|
1149
1251
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Gallery/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC,cAAc,SAAS,CAAC;AAKxB,eAAO,MAAM,OAAO,UAAW,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Gallery/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC,cAAc,SAAS,CAAC;AAKxB,eAAO,MAAM,OAAO,UAAW,YAAY,sBA8D1C,CAAC"}
|
|
@@ -10,6 +10,7 @@ export interface GalleryConfig extends BaseElementConfig, MediaItemConfig {
|
|
|
10
10
|
sliderProp?: SwiperProps;
|
|
11
11
|
thumbSliderProp?: SwiperProps;
|
|
12
12
|
arIconProps?: ArActionIconConfig;
|
|
13
|
+
videoAutoplay?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export interface ArActionIconConfig extends BaseElementConfig {
|
|
15
16
|
text?: string | boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Gallery/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,aAAc,SAAQ,iBAAiB,EAAE,eAAe;IACvE,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,WAAW,CAAC,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Gallery/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,aAAc,SAA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,EACR,MAAM,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,EAC3D,gBAAgB,EAChB,mBAAmB,GACpB,EAAE,YAAY;;;;;;;;4BAsCkB,WAAW;
|
|
1
|
+
{"version":3,"file":"useGallery.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Gallery/useGallery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,MAAM,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,EAC3D,gBAAgB,EAChB,mBAAmB,GACpB,EAAE,YAAY;;;;;;;;4BAsCkB,WAAW;EAiC3C"}
|
|
@@ -7,7 +7,7 @@ type Props = {
|
|
|
7
7
|
mediaUrl?: string;
|
|
8
8
|
config: MediaItemConfig;
|
|
9
9
|
isCurrentlyVisible: boolean;
|
|
10
|
-
|
|
10
|
+
videoAutoplay?: boolean;
|
|
11
11
|
onClick?: () => void;
|
|
12
12
|
};
|
|
13
13
|
export declare const MediaItem: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLArViewerElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/MediaItem/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/MediaItem/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEzD,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,SAAS,mFA0EpB,CAAC"}
|
|
@@ -51,11 +51,6 @@ interface UseGlobalCacheProps {
|
|
|
51
51
|
* Widget type, used for events and logging
|
|
52
52
|
*/
|
|
53
53
|
widgetType: string;
|
|
54
|
-
/**
|
|
55
|
-
* If true, the global cache will not be used
|
|
56
|
-
* This is used in the product list, where we always want to fetch the latest data
|
|
57
|
-
*/
|
|
58
|
-
noGlobalCache?: boolean;
|
|
59
54
|
}
|
|
60
55
|
declare global {
|
|
61
56
|
interface Window {
|
|
@@ -68,6 +63,6 @@ declare global {
|
|
|
68
63
|
* Global cache for shared data between widgets of a website
|
|
69
64
|
* Simple implementation with request deduplication
|
|
70
65
|
*/
|
|
71
|
-
export declare function useGlobalCache({ uniqueWidgetId, widgetType
|
|
66
|
+
export declare function useGlobalCache({ uniqueWidgetId, widgetType }: UseGlobalCacheProps): DivaWidgetCache;
|
|
72
67
|
export {};
|
|
73
68
|
//# sourceMappingURL=useGlobalCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalCache.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useGlobalCache.ts"],"names":[],"mappings":"AAKA,UAAU,UAAU,CAAC,CAAC;IACpB;;OAEG;IACH,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IACjB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,IA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G,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5C;AAED,UAAU,mBAAmB;IAC3B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,iBAAiB,EAAE;YACjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;SACrC,CAAC;KACH;CACF;AASD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,mBAAmB,GAAG,eAAe,CAkGnG"}
|
|
@@ -6,13 +6,8 @@ export interface UseProductDataProps {
|
|
|
6
6
|
* Widget type, used for logging
|
|
7
7
|
*/
|
|
8
8
|
widgetType: string;
|
|
9
|
-
/**
|
|
10
|
-
* If true, the global cache will not be used
|
|
11
|
-
* This is used in the product list, where we always want to fetch the latest data
|
|
12
|
-
*/
|
|
13
|
-
noGlobalCache?: boolean;
|
|
14
9
|
}
|
|
15
|
-
export declare function useProductData({ productIds, variants, widgetType
|
|
10
|
+
export declare function useProductData({ productIds, variants, widgetType }: UseProductDataProps): {
|
|
16
11
|
productVariants: ProductData[];
|
|
17
12
|
error: boolean;
|
|
18
13
|
loading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductData.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useProductData.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,WAAW,EAA0B,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"useProductData.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useProductData.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,WAAW,EAA0B,MAAM,0BAA0B,CAAC;AAQ1F,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAKD,wBAAgB,cAAc,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,mBAAmB;;;;oCAyLzC,MAAM,EAAE,KAAG,OAAO,CAAC,GAAG,CAAC;6CAyBd,MAAM,cAAc,MAAM,KAAG,OAAO,CAAC,GAAG,CAAC;;sCAxF3E,MAAM;2BAmHI,MAAM,QAAQ,GAAG;EAoChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crystaldesign/widget-library",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.9.0-beta.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"storybook": "storybook dev -p 6006",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"suiteName": "widget-library",
|
|
37
37
|
"outputDirectory": "./test-reports"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "21fe41b81e2815f4d2a5de0a1ce97b88a5c34926"
|
|
40
40
|
}
|