@crystaldesign/widget-image-carousel 25.10.0-rc.1 → 25.10.0-rc.2
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 +20 -18
- package/build/types/widget-image-carousel/src/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/types/index.d.ts +1 -2
- package/build/types/widget-image-carousel/src/types/index.d.ts.map +1 -1
- package/build/types/widget-image-carousel/src/useImageCarousel.d.ts +1 -1
- 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,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
3
3
|
import { useCss, useProductData, MediaItem, useConfiguration } from '@crystaldesign/widget-library';
|
|
4
4
|
import { useDivaCore, useTranslation } from '@crystaldesign/diva-core';
|
|
5
5
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
@@ -28,9 +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
|
|
32
|
-
var productId = _ref.productId,
|
|
33
|
-
productIds = _ref.productIds,
|
|
31
|
+
var productIds = _ref.productIds,
|
|
34
32
|
settings = _ref.settings;
|
|
35
33
|
var _useState = useState([]),
|
|
36
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -48,7 +46,7 @@ function useImageCarousel(_ref) {
|
|
|
48
46
|
openComponent = _useDivaCore.actions.openComponent;
|
|
49
47
|
useCss(settings);
|
|
50
48
|
var _useProductData = useProductData({
|
|
51
|
-
productIds:
|
|
49
|
+
productIds: productIds,
|
|
52
50
|
widgetType: 'IMAGECAROUSEL'
|
|
53
51
|
}),
|
|
54
52
|
getProductsByDivaNrs = _useProductData.getProductsByDivaNrs,
|
|
@@ -83,7 +81,7 @@ function useImageCarousel(_ref) {
|
|
|
83
81
|
};
|
|
84
82
|
useEffect(function () {
|
|
85
83
|
var loadMockups = /*#__PURE__*/function () {
|
|
86
|
-
var
|
|
84
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
87
85
|
var _settings$mediaFuncti, mediaFunctionType, foundMedia, _foundMedia, _foundMedia2;
|
|
88
86
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
89
87
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -157,13 +155,13 @@ function useImageCarousel(_ref) {
|
|
|
157
155
|
}, _callee, null, [[0, 28, 32, 35]]);
|
|
158
156
|
}));
|
|
159
157
|
return function loadMockups() {
|
|
160
|
-
return
|
|
158
|
+
return _ref2.apply(this, arguments);
|
|
161
159
|
};
|
|
162
160
|
}();
|
|
163
|
-
if (selectedProduct &&
|
|
161
|
+
if (selectedProduct && productIds !== null && productIds !== void 0 && productIds.length) {
|
|
164
162
|
loadMockups();
|
|
165
163
|
}
|
|
166
|
-
}, [selectedProduct,
|
|
164
|
+
}, [selectedProduct, productIds]);
|
|
167
165
|
return {
|
|
168
166
|
media: media,
|
|
169
167
|
error: error,
|
|
@@ -384,7 +382,7 @@ function useImageCarousel(_ref) {
|
|
|
384
382
|
case 3:
|
|
385
383
|
_context7.next = 5;
|
|
386
384
|
return Promise.all(similarProductsDivaNr.map(/*#__PURE__*/function () {
|
|
387
|
-
var
|
|
385
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(divaNr) {
|
|
388
386
|
var _divaNrParts$;
|
|
389
387
|
var divaNrParts;
|
|
390
388
|
return _regeneratorRuntime.wrap(function _callee3$(_context6) {
|
|
@@ -402,7 +400,7 @@ function useImageCarousel(_ref) {
|
|
|
402
400
|
}, _callee3);
|
|
403
401
|
}));
|
|
404
402
|
return function (_x9) {
|
|
405
|
-
return
|
|
403
|
+
return _ref3.apply(this, arguments);
|
|
406
404
|
};
|
|
407
405
|
}()));
|
|
408
406
|
case 5:
|
|
@@ -440,13 +438,14 @@ function useImageCarousel(_ref) {
|
|
|
440
438
|
}
|
|
441
439
|
function _getSimpleProductList() {
|
|
442
440
|
_getSimpleProductList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(productIds, mediaFunctionType, description) {
|
|
443
|
-
var products;
|
|
441
|
+
var productIdsArray, products;
|
|
444
442
|
return _regeneratorRuntime.wrap(function _callee5$(_context8) {
|
|
445
443
|
while (1) switch (_context8.prev = _context8.next) {
|
|
446
444
|
case 0:
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
445
|
+
productIdsArray = Array.isArray(productIds) ? productIds : productIds.split(';');
|
|
446
|
+
_context8.next = 3;
|
|
447
|
+
return getSimpleProductListByIds(productIdsArray);
|
|
448
|
+
case 3:
|
|
450
449
|
products = _context8.sent;
|
|
451
450
|
return _context8.abrupt("return", products.data.map(function (p) {
|
|
452
451
|
var _p$media$find$url, _p$media, _p$description;
|
|
@@ -458,7 +457,7 @@ function useImageCarousel(_ref) {
|
|
|
458
457
|
description: description ? (_p$description = p[description]) !== null && _p$description !== void 0 ? _p$description : description : undefined
|
|
459
458
|
};
|
|
460
459
|
}));
|
|
461
|
-
case
|
|
460
|
+
case 5:
|
|
462
461
|
case "end":
|
|
463
462
|
return _context8.stop();
|
|
464
463
|
}
|
|
@@ -660,12 +659,15 @@ function MainComponent(props) {
|
|
|
660
659
|
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; }
|
|
661
660
|
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; }
|
|
662
661
|
var Main = function Main(_ref) {
|
|
663
|
-
var _parameters$productId;
|
|
664
662
|
var settings = _ref.settings,
|
|
665
663
|
parameters = _ref.parameters;
|
|
664
|
+
var productIds = useMemo(function () {
|
|
665
|
+
var _parameters$productId, _parameters$productId2;
|
|
666
|
+
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 : [];
|
|
667
|
+
}, [parameters === null || parameters === void 0 ? void 0 : parameters.productIds]);
|
|
666
668
|
return /*#__PURE__*/jsx(ImageCarouselComponent, {
|
|
667
669
|
settings: settings,
|
|
668
|
-
|
|
670
|
+
productIds: productIds
|
|
669
671
|
});
|
|
670
672
|
};
|
|
671
673
|
var ImageCarouselComponent = function ImageCarouselComponent(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAkB,MAAM,0BAA0B,CAAC;AAG/E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAO5D,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAG/D,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,mBAAmB,CAAC,aAAa,CAGrD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -2,8 +2,7 @@ import { BaseConfiguration } from '@crystaldesign/widget-library';
|
|
|
2
2
|
import { SwiperProps } from 'swiper/react';
|
|
3
3
|
export interface ImageCarouselProps {
|
|
4
4
|
settings: Configuration;
|
|
5
|
-
|
|
6
|
-
productIds?: string[];
|
|
5
|
+
productIds: string | string[];
|
|
7
6
|
}
|
|
8
7
|
export interface Configuration extends BaseConfiguration {
|
|
9
8
|
type: 'WALL_MOCKUPS' | 'SIMILAR_PRODUCTS' | 'SIMPLE_PRODUCT_LIST';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,IAAI,EAAE,cAAc,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,mBAAmB,CAAC,EAAE;QACpB,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImageCarouselProps, Media } from './types';
|
|
2
|
-
export declare function useImageCarousel({
|
|
2
|
+
export declare function useImageCarousel({ productIds, settings }: ImageCarouselProps): {
|
|
3
3
|
media: Media[];
|
|
4
4
|
error: Error | undefined;
|
|
5
5
|
loading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImageCarousel.d.ts","sourceRoot":"","sources":["../../../../src/useImageCarousel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKpD,wBAAgB,gBAAgB,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"useImageCarousel.d.ts","sourceRoot":"","sources":["../../../../src/useImageCarousel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKpD,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,kBAAkB;;;;gCAiB7D,MAAM;EA2LrB"}
|