@crystaldesign/widget-library 25.9.0-beta.4 → 25.9.0-beta.40
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 +138 -64
- package/build/types/widget-library/src/components/Gallery/ArActionIcon/index.d.ts.map +1 -1
- package/build/types/widget-library/src/hooks/useGlobalCache.d.ts +6 -1
- package/build/types/widget-library/src/hooks/useGlobalCache.d.ts.map +1 -1
- package/build/types/widget-library/src/hooks/useProductData.d.ts +6 -1
- 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,9 +100,14 @@ if (typeof window !== 'undefined' && !window.__divaWidgetCache) {
|
|
|
99
100
|
*/
|
|
100
101
|
function useGlobalCache(_ref) {
|
|
101
102
|
var uniqueWidgetId = _ref.uniqueWidgetId,
|
|
102
|
-
widgetType = _ref.widgetType
|
|
103
|
+
widgetType = _ref.widgetType,
|
|
104
|
+
noGlobalCache = _ref.noGlobalCache;
|
|
103
105
|
var getOrFetch = useCallback(function (key, fetcher) {
|
|
104
106
|
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] getOrFetch called for key: ").concat(key));
|
|
107
|
+
if (noGlobalCache) {
|
|
108
|
+
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] Global cache disabled, fetching directly for key: ").concat(key));
|
|
109
|
+
return fetcher();
|
|
110
|
+
}
|
|
105
111
|
if (typeof window === 'undefined' || !window.__divaWidgetCache) {
|
|
106
112
|
LOG$2.debug("[".concat(widgetType, ":").concat(uniqueWidgetId, "] No global cache available, fetching directly for key: ").concat(key));
|
|
107
113
|
return fetcher();
|
|
@@ -259,7 +265,8 @@ var generateWidgetId = function generateWidgetId() {
|
|
|
259
265
|
function useProductData(_ref) {
|
|
260
266
|
var productIds = _ref.productIds,
|
|
261
267
|
variants = _ref.variants,
|
|
262
|
-
widgetType = _ref.widgetType
|
|
268
|
+
widgetType = _ref.widgetType,
|
|
269
|
+
noGlobalCache = _ref.noGlobalCache;
|
|
263
270
|
// Generate stable widget ID that persists for the lifetime of this hook instance
|
|
264
271
|
// Function to handle selectedProduct changes
|
|
265
272
|
|
|
@@ -270,7 +277,8 @@ function useProductData(_ref) {
|
|
|
270
277
|
handler = _useDivaCore.handler;
|
|
271
278
|
var _useGlobalCache = useGlobalCache({
|
|
272
279
|
uniqueWidgetId: widgetId,
|
|
273
|
-
widgetType: widgetType
|
|
280
|
+
widgetType: widgetType,
|
|
281
|
+
noGlobalCache: noGlobalCache
|
|
274
282
|
}),
|
|
275
283
|
getOrFetch = _useGlobalCache.getOrFetch,
|
|
276
284
|
setCache = _useGlobalCache.setCache;
|
|
@@ -290,6 +298,10 @@ function useProductData(_ref) {
|
|
|
290
298
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
291
299
|
error = _useState8[0],
|
|
292
300
|
setError = _useState8[1];
|
|
301
|
+
var _useState9 = useState(true),
|
|
302
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
303
|
+
initialProduct = _useState10[0],
|
|
304
|
+
setInitialProduct = _useState10[1];
|
|
293
305
|
var fetchProducts = useCallback(/*#__PURE__*/function () {
|
|
294
306
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ids) {
|
|
295
307
|
var productPromises, results, flattenedResults;
|
|
@@ -416,15 +428,39 @@ function useProductData(_ref) {
|
|
|
416
428
|
}
|
|
417
429
|
setError(false);
|
|
418
430
|
setLoading(true);
|
|
419
|
-
fetchProducts(normalizedProductIds).then(function (
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
431
|
+
fetchProducts(normalizedProductIds).then(/*#__PURE__*/function () {
|
|
432
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(variants) {
|
|
433
|
+
var variantToUse, _variantToUse$catCode;
|
|
434
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
435
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
436
|
+
case 0:
|
|
437
|
+
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Successfully loaded ").concat(variants.length, " product variants"));
|
|
438
|
+
setProductVariants(variants);
|
|
439
|
+
variantToUse = variants.find(function (v) {
|
|
440
|
+
return v._id === normalizedProductIds[0];
|
|
441
|
+
});
|
|
442
|
+
setSelectedProduct(variantToUse !== null && variantToUse !== void 0 ? variantToUse : variants[0]);
|
|
443
|
+
setLoading(false);
|
|
444
|
+
if (!initialProduct) {
|
|
445
|
+
_context4.next = 10;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
DivaUtils.businessMetrics.setConfiguratorSessionId(undefined, true);
|
|
449
|
+
setInitialProduct(false);
|
|
450
|
+
_context4.next = 10;
|
|
451
|
+
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) {
|
|
452
|
+
return set.SupplierGUID;
|
|
453
|
+
}), 'onWidgetInitialProduct');
|
|
454
|
+
case 10:
|
|
455
|
+
case "end":
|
|
456
|
+
return _context4.stop();
|
|
457
|
+
}
|
|
458
|
+
}, _callee4);
|
|
459
|
+
}));
|
|
460
|
+
return function (_x4) {
|
|
461
|
+
return _ref5.apply(this, arguments);
|
|
462
|
+
};
|
|
463
|
+
}())["catch"](function (error) {
|
|
428
464
|
LOG.error(new DivaError("[".concat(widgetType, ":").concat(widgetId, "] Error loading products"), {
|
|
429
465
|
cause: error
|
|
430
466
|
}));
|
|
@@ -434,17 +470,17 @@ function useProductData(_ref) {
|
|
|
434
470
|
});
|
|
435
471
|
}, [normalizedProductIds]);
|
|
436
472
|
var setSelectedProductId = useCallback(/*#__PURE__*/function () {
|
|
437
|
-
var
|
|
438
|
-
var product, _variants2, _product;
|
|
439
|
-
return _regeneratorRuntime.wrap(function
|
|
440
|
-
while (1) switch (
|
|
473
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(productId) {
|
|
474
|
+
var product, _product$catCodex, _variants2, _product, _product$catCodex2;
|
|
475
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
476
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
441
477
|
case 0:
|
|
442
478
|
if (!((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct._id) === productId)) {
|
|
443
|
-
|
|
479
|
+
_context5.next = 3;
|
|
444
480
|
break;
|
|
445
481
|
}
|
|
446
482
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " already selected, skipping"));
|
|
447
|
-
return
|
|
483
|
+
return _context5.abrupt("return");
|
|
448
484
|
case 3:
|
|
449
485
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] setSelectedProductId called with productId: ").concat(productId));
|
|
450
486
|
|
|
@@ -454,74 +490,84 @@ function useProductData(_ref) {
|
|
|
454
490
|
return p._id === productId;
|
|
455
491
|
});
|
|
456
492
|
if (!product) {
|
|
457
|
-
|
|
493
|
+
_context5.next = 12;
|
|
458
494
|
break;
|
|
459
495
|
}
|
|
460
496
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " found in current variants, setting as selected"));
|
|
461
497
|
setSelectedProduct(product);
|
|
462
498
|
notifyProductChanged(product);
|
|
463
|
-
|
|
464
|
-
|
|
499
|
+
_context5.next = 11;
|
|
500
|
+
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) {
|
|
501
|
+
return set.SupplierGUID;
|
|
502
|
+
}) : undefined);
|
|
503
|
+
case 11:
|
|
504
|
+
return _context5.abrupt("return");
|
|
505
|
+
case 12:
|
|
465
506
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " not found in current variants, fetching variants for it"));
|
|
466
|
-
|
|
507
|
+
_context5.prev = 13;
|
|
467
508
|
setError(false);
|
|
468
509
|
setLoading(true);
|
|
469
|
-
|
|
510
|
+
_context5.next = 18;
|
|
470
511
|
return fetchProducts([productId]);
|
|
471
|
-
case
|
|
472
|
-
_variants2 =
|
|
512
|
+
case 18:
|
|
513
|
+
_variants2 = _context5.sent;
|
|
473
514
|
setProductVariants(_variants2);
|
|
474
515
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] New ").concat(_variants2.length, " variants to productVariants"));
|
|
475
516
|
_product = _variants2.find(function (p) {
|
|
476
517
|
return p._id === productId;
|
|
477
518
|
});
|
|
478
519
|
if (!_product) {
|
|
479
|
-
|
|
520
|
+
_context5.next = 30;
|
|
480
521
|
break;
|
|
481
522
|
}
|
|
482
523
|
LOG.debug("[".concat(widgetType, ":").concat(widgetId, "] Setting product ").concat(productId, " as selected after fetching"));
|
|
483
524
|
setSelectedProduct(_product);
|
|
484
525
|
notifyProductChanged(_product);
|
|
485
|
-
|
|
526
|
+
_context5.next = 28;
|
|
527
|
+
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) {
|
|
528
|
+
return set.SupplierGUID;
|
|
529
|
+
}));
|
|
530
|
+
case 28:
|
|
531
|
+
_context5.next = 31;
|
|
486
532
|
break;
|
|
487
|
-
case
|
|
533
|
+
case 30:
|
|
488
534
|
throw new DivaError("[".concat(widgetType, ":").concat(widgetId, "] Product ").concat(productId, " not found"));
|
|
489
|
-
case
|
|
490
|
-
|
|
535
|
+
case 31:
|
|
536
|
+
_context5.next = 37;
|
|
491
537
|
break;
|
|
492
|
-
case
|
|
493
|
-
|
|
494
|
-
|
|
538
|
+
case 33:
|
|
539
|
+
_context5.prev = 33;
|
|
540
|
+
_context5.t0 = _context5["catch"](13);
|
|
495
541
|
LOG.error(new DivaError("[".concat(widgetType, ":").concat(widgetId, "] Error loading product"), {
|
|
496
|
-
cause:
|
|
542
|
+
cause: _context5.t0
|
|
497
543
|
}));
|
|
498
544
|
setError(true);
|
|
499
|
-
case
|
|
500
|
-
|
|
545
|
+
case 37:
|
|
546
|
+
_context5.prev = 37;
|
|
501
547
|
setLoading(false);
|
|
502
|
-
return
|
|
503
|
-
case
|
|
548
|
+
return _context5.finish(37);
|
|
549
|
+
case 40:
|
|
504
550
|
case "end":
|
|
505
|
-
return
|
|
551
|
+
return _context5.stop();
|
|
506
552
|
}
|
|
507
|
-
},
|
|
553
|
+
}, _callee5, null, [[13, 33, 37, 40]]);
|
|
508
554
|
}));
|
|
509
|
-
return function (
|
|
510
|
-
return
|
|
555
|
+
return function (_x5) {
|
|
556
|
+
return _ref6.apply(this, arguments);
|
|
511
557
|
};
|
|
512
558
|
}(), [selectedProduct, productVariants, fetchProducts, setSelectedProduct, widgetId, widgetType]);
|
|
513
|
-
function getProductsByDivaNrs(
|
|
559
|
+
function getProductsByDivaNrs(_x6) {
|
|
514
560
|
return _getProductsByDivaNrs.apply(this, arguments);
|
|
515
561
|
}
|
|
516
562
|
function _getProductsByDivaNrs() {
|
|
517
|
-
_getProductsByDivaNrs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
563
|
+
_getProductsByDivaNrs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(divaNrs) {
|
|
518
564
|
var products;
|
|
519
|
-
return _regeneratorRuntime.wrap(function
|
|
520
|
-
while (1) switch (
|
|
565
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
566
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
521
567
|
case 0:
|
|
522
568
|
// Sort divaNrs array to ensure consistent cache keys
|
|
523
569
|
divaNrs.sort();
|
|
524
|
-
|
|
570
|
+
_context6.next = 3;
|
|
525
571
|
return getOrFetch('divaNrs' + divaNrs.join(','), function () {
|
|
526
572
|
return handler.productHandler.apiGetProductByQuery([{
|
|
527
573
|
id: 'divaNr',
|
|
@@ -534,24 +580,24 @@ function useProductData(_ref) {
|
|
|
534
580
|
}], 1000, false);
|
|
535
581
|
});
|
|
536
582
|
case 3:
|
|
537
|
-
products =
|
|
538
|
-
return
|
|
583
|
+
products = _context6.sent;
|
|
584
|
+
return _context6.abrupt("return", products);
|
|
539
585
|
case 5:
|
|
540
586
|
case "end":
|
|
541
|
-
return
|
|
587
|
+
return _context6.stop();
|
|
542
588
|
}
|
|
543
|
-
},
|
|
589
|
+
}, _callee6);
|
|
544
590
|
}));
|
|
545
591
|
return _getProductsByDivaNrs.apply(this, arguments);
|
|
546
592
|
}
|
|
547
|
-
function getProductByDivaNrAndVariantId(
|
|
593
|
+
function getProductByDivaNrAndVariantId(_x7, _x8) {
|
|
548
594
|
return _getProductByDivaNrAndVariantId.apply(this, arguments);
|
|
549
595
|
}
|
|
550
596
|
function _getProductByDivaNrAndVariantId() {
|
|
551
|
-
_getProductByDivaNrAndVariantId = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
597
|
+
_getProductByDivaNrAndVariantId = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(divaNr, variantId) {
|
|
552
598
|
var filter, product;
|
|
553
|
-
return _regeneratorRuntime.wrap(function
|
|
554
|
-
while (1) switch (
|
|
599
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
600
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
555
601
|
case 0:
|
|
556
602
|
filter = [{
|
|
557
603
|
id: 'divaNr',
|
|
@@ -569,18 +615,18 @@ function useProductData(_ref) {
|
|
|
569
615
|
value: parseInt(variantId)
|
|
570
616
|
});
|
|
571
617
|
}
|
|
572
|
-
|
|
618
|
+
_context7.next = 4;
|
|
573
619
|
return getOrFetch('divaNr' + divaNr + 'variantId' + variantId, function () {
|
|
574
620
|
return handler.productHandler.apiGetProductByQuery(filter, 1, false);
|
|
575
621
|
});
|
|
576
622
|
case 4:
|
|
577
|
-
product =
|
|
578
|
-
return
|
|
623
|
+
product = _context7.sent;
|
|
624
|
+
return _context7.abrupt("return", product);
|
|
579
625
|
case 6:
|
|
580
626
|
case "end":
|
|
581
|
-
return
|
|
627
|
+
return _context7.stop();
|
|
582
628
|
}
|
|
583
|
-
},
|
|
629
|
+
}, _callee7);
|
|
584
630
|
}));
|
|
585
631
|
return _getProductByDivaNrAndVariantId.apply(this, arguments);
|
|
586
632
|
}
|
|
@@ -590,6 +636,33 @@ function useProductData(_ref) {
|
|
|
590
636
|
timestamp: Date.now()
|
|
591
637
|
});
|
|
592
638
|
}
|
|
639
|
+
function logSelectedProduct(_x9, _x10, _x11, _x12, _x13, _x14) {
|
|
640
|
+
return _logSelectedProduct.apply(this, arguments);
|
|
641
|
+
}
|
|
642
|
+
function _logSelectedProduct() {
|
|
643
|
+
_logSelectedProduct = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(productId, widgetType, variantId, catalogName, catalogCodex, supplierId) {
|
|
644
|
+
var event,
|
|
645
|
+
_args8 = arguments;
|
|
646
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
647
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
648
|
+
case 0:
|
|
649
|
+
event = _args8.length > 6 && _args8[6] !== undefined ? _args8[6] : 'onWidgetProductSelected';
|
|
650
|
+
LOG.businessEvent(event, 'DivaWidget', "Product ".concat(productId, " selected in widget ").concat(widgetType), {
|
|
651
|
+
productId: productId,
|
|
652
|
+
variantId: variantId,
|
|
653
|
+
widgetType: widgetType,
|
|
654
|
+
catalogName: catalogName,
|
|
655
|
+
catalogCodex: catalogCodex,
|
|
656
|
+
supplierId: supplierId
|
|
657
|
+
});
|
|
658
|
+
case 2:
|
|
659
|
+
case "end":
|
|
660
|
+
return _context8.stop();
|
|
661
|
+
}
|
|
662
|
+
}, _callee8);
|
|
663
|
+
}));
|
|
664
|
+
return _logSelectedProduct.apply(this, arguments);
|
|
665
|
+
}
|
|
593
666
|
return {
|
|
594
667
|
productVariants: productVariants,
|
|
595
668
|
error: error,
|
|
@@ -746,13 +819,13 @@ function useGallery(_ref) {
|
|
|
746
819
|
var _swiper$params;
|
|
747
820
|
setCurrentMediaIndex(mediaIndex);
|
|
748
821
|
if (swiper !== null && swiper !== void 0 && (_swiper$params = swiper.params) !== null && _swiper$params !== void 0 && _swiper$params.loop) {
|
|
749
|
-
swiper === null || swiper === void 0 || swiper.slideToLoop(mediaIndex);
|
|
822
|
+
swiper === null || swiper === void 0 || swiper.slideToLoop(mediaIndex, 0);
|
|
750
823
|
} else {
|
|
751
|
-
swiper === null || swiper === void 0 || swiper.slideTo(mediaIndex);
|
|
824
|
+
swiper === null || swiper === void 0 || swiper.slideTo(mediaIndex, 0);
|
|
752
825
|
}
|
|
753
826
|
}
|
|
754
827
|
}
|
|
755
|
-
}, [currentProductId]);
|
|
828
|
+
}, [currentProductId, swiper]);
|
|
756
829
|
var hasSirvMedia = useMemo(function () {
|
|
757
830
|
var _loop = function _loop(i) {
|
|
758
831
|
if (medias.find(function (m) {
|
|
@@ -1085,7 +1158,8 @@ var ArActionIcon = function ArActionIcon(_ref) {
|
|
|
1085
1158
|
if (element !== null && element !== void 0 && element.style) element.style.display = 'none';
|
|
1086
1159
|
}, []);
|
|
1087
1160
|
if (!url || !arViewerBaseUrl) return /*#__PURE__*/jsx(Fragment, {});
|
|
1088
|
-
var
|
|
1161
|
+
var apllyConfiguratorSessionId = DivaUtils.ConfigurationId ? '&configurationId=' + DivaUtils.ConfigurationId : '';
|
|
1162
|
+
var finalURL = arViewerBaseUrl + '/arViewer?arMedia=' + url + '&divaSessionId=' + DivaUtils.SessionId + apllyConfiguratorSessionId;
|
|
1089
1163
|
var arText = typeof (config === null || config === void 0 ? void 0 : config.text) === 'string' ? config.text : (config === null || config === void 0 ? void 0 : config.text) !== false ? t('widget.gallery.arActionIcon.text') : '';
|
|
1090
1164
|
return /*#__PURE__*/jsx("div", _objectSpread$1(_objectSpread$1({}, triggerProps), {}, {
|
|
1091
1165
|
onClick: function onClick() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Gallery/ArActionIcon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Gallery/ArActionIcon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,aAAa,EAAE,mBAAmB,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,QAAA,MAAM,YAAY,mCAAoC,iBAAiB,sBAoDtE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -51,6 +51,11 @@ 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;
|
|
54
59
|
}
|
|
55
60
|
declare global {
|
|
56
61
|
interface Window {
|
|
@@ -63,6 +68,6 @@ declare global {
|
|
|
63
68
|
* Global cache for shared data between widgets of a website
|
|
64
69
|
* Simple implementation with request deduplication
|
|
65
70
|
*/
|
|
66
|
-
export declare function useGlobalCache({ uniqueWidgetId, widgetType }: UseGlobalCacheProps): DivaWidgetCache;
|
|
71
|
+
export declare function useGlobalCache({ uniqueWidgetId, widgetType, noGlobalCache }: UseGlobalCacheProps): DivaWidgetCache;
|
|
67
72
|
export {};
|
|
68
73
|
//# 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,IAAI,CAAC;IAC7B;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,eAAe;IACvB;;;;;;;OAOG;IACH,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1E;;;OAGG;IACH,KAAK,EAAE,CAAC,GAAG,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;
|
|
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,IAAI,CAAC;IAC7B;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,eAAe;IACvB;;;;;;;OAOG;IACH,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1E;;;OAGG;IACH,KAAK,EAAE,CAAC,GAAG,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;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;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,aAAa,EAAE,EAAE,mBAAmB,GAAG,eAAe,CAuGlH"}
|
|
@@ -6,8 +6,13 @@ 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;
|
|
9
14
|
}
|
|
10
|
-
export declare function useProductData({ productIds, variants, widgetType }: UseProductDataProps): {
|
|
15
|
+
export declare function useProductData({ productIds, variants, widgetType, noGlobalCache }: UseProductDataProps): {
|
|
11
16
|
productVariants: ProductData[];
|
|
12
17
|
error: boolean;
|
|
13
18
|
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;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAKD,wBAAgB,cAAc,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,mBAAmB;;;;oCAyLxD,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.9.0-beta.
|
|
3
|
+
"version": "25.9.0-beta.40",
|
|
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": "aaab08373082b3c6a37b0a3646f399b0925d387c"
|
|
40
40
|
}
|