@crystaldesign/widget-library 25.10.0-beta.9 → 25.11.0-beta.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 +41 -20
- 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 +1 -0
- package/build/types/widget-library/src/components/Gallery/useGallery.d.ts.map +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -810,21 +810,22 @@ function useGallery(_ref) {
|
|
|
810
810
|
useEffect(function () {
|
|
811
811
|
var _medias$currentMediaI;
|
|
812
812
|
if (currentProductId !== undefined && ((_medias$currentMediaI = medias[currentMediaIndex]) === null || _medias$currentMediaI === void 0 ? void 0 : _medias$currentMediaI.productId) !== currentProductId) {
|
|
813
|
-
// Find the first media index that corresponds to this product index
|
|
814
813
|
var mediaIndex = medias.findIndex(function (media) {
|
|
815
814
|
return media.productId === currentProductId;
|
|
816
815
|
});
|
|
817
|
-
if (mediaIndex !== -1 && mediaIndex !== currentMediaIndex) {
|
|
818
|
-
var _swiper$params;
|
|
816
|
+
if (mediaIndex !== -1 && mediaIndex !== currentMediaIndex && swiper) {
|
|
819
817
|
setCurrentMediaIndex(mediaIndex);
|
|
820
|
-
if (swiper
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
818
|
+
if (swiper.realIndex !== mediaIndex) {
|
|
819
|
+
var _swiper$params;
|
|
820
|
+
if ((_swiper$params = swiper.params) !== null && _swiper$params !== void 0 && _swiper$params.loop) {
|
|
821
|
+
swiper.slideToLoop(mediaIndex, 0);
|
|
822
|
+
} else {
|
|
823
|
+
swiper.slideTo(mediaIndex, 0);
|
|
824
|
+
}
|
|
824
825
|
}
|
|
825
826
|
}
|
|
826
827
|
}
|
|
827
|
-
}, [currentProductId]);
|
|
828
|
+
}, [currentProductId, swiper]);
|
|
828
829
|
var hasSirvMedia = useMemo(function () {
|
|
829
830
|
var _loop = function _loop(i) {
|
|
830
831
|
if (medias.find(function (m) {
|
|
@@ -848,22 +849,37 @@ function useGallery(_ref) {
|
|
|
848
849
|
sirvLoaded = _useSirv.sirvLoaded;
|
|
849
850
|
var onSlideChange = function onSlideChange(swiper) {
|
|
850
851
|
if (swiper.el.classList.contains('gallery-main-nested-swiper')) return;
|
|
851
|
-
|
|
852
|
-
|
|
852
|
+
var newMediaIndex = swiper.realIndex;
|
|
853
|
+
var media = medias[newMediaIndex];
|
|
853
854
|
if (!swiperIsInitialized) {
|
|
854
855
|
setSwiperIsInitialized(true);
|
|
855
856
|
return;
|
|
856
857
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
858
|
+
if (newMediaIndex !== currentMediaIndex) {
|
|
859
|
+
setCurrentMediaIndex(newMediaIndex);
|
|
860
|
+
if (setCurrentProductId && (media === null || media === void 0 ? void 0 : media.productId) !== currentProductId) {
|
|
861
|
+
setCurrentProductId(media.productId);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
onThumbSlideChange(swiper.realIndex);
|
|
865
|
+
};
|
|
866
|
+
var onThumbSlideChange = function onThumbSlideChange(clickedIndex) {
|
|
867
|
+
if (!(thumbsSwiper !== null && thumbsSwiper !== void 0 && thumbsSwiper.slides)) return;
|
|
868
|
+
if (clickedIndex == null || clickedIndex < 0) return;
|
|
869
|
+
var visibleSlides = Array.from(thumbsSwiper.slides).filter(function (slide) {
|
|
870
|
+
return slide.classList.contains('swiper-slide-visible');
|
|
871
|
+
});
|
|
872
|
+
if (visibleSlides.length === 0) return;
|
|
873
|
+
var firstVisibleIndex = visibleSlides[0].swiperSlideIndex;
|
|
874
|
+
var lastVisibleIndex = visibleSlides[visibleSlides.length - 1].swiperSlideIndex;
|
|
875
|
+
|
|
876
|
+
// if the first or last visible slide is clicked, slide to the previous or next slide
|
|
877
|
+
if (clickedIndex === firstVisibleIndex) {
|
|
878
|
+
thumbsSwiper.slideTo(Math.max(clickedIndex - 1, 0));
|
|
879
|
+
} else if (clickedIndex === lastVisibleIndex) {
|
|
880
|
+
thumbsSwiper.slideTo(Math.min(clickedIndex + 1, thumbsSwiper.slides.length - 1));
|
|
862
881
|
}
|
|
863
882
|
};
|
|
864
|
-
|
|
865
|
-
// Get the current product index based on the current media index
|
|
866
|
-
medias[currentMediaIndex];
|
|
867
883
|
return {
|
|
868
884
|
medias: medias,
|
|
869
885
|
sirvLoaded: sirvLoaded,
|
|
@@ -872,7 +888,8 @@ function useGallery(_ref) {
|
|
|
872
888
|
currentIndex: currentMediaIndex,
|
|
873
889
|
setThumbsSwiper: setThumbsSwiper,
|
|
874
890
|
setSwiper: setSwiper,
|
|
875
|
-
onSlideChange: onSlideChange
|
|
891
|
+
onSlideChange: onSlideChange,
|
|
892
|
+
onThumbSlideChange: onThumbSlideChange
|
|
876
893
|
};
|
|
877
894
|
}
|
|
878
895
|
|
|
@@ -1308,7 +1325,8 @@ var Gallery = function Gallery(props) {
|
|
|
1308
1325
|
onSlideChange = _useGallery.onSlideChange,
|
|
1309
1326
|
setThumbsSwiper = _useGallery.setThumbsSwiper,
|
|
1310
1327
|
setSwiper = _useGallery.setSwiper,
|
|
1311
|
-
currentIndex = _useGallery.currentIndex
|
|
1328
|
+
currentIndex = _useGallery.currentIndex,
|
|
1329
|
+
onThumbSlideChange = _useGallery.onThumbSlideChange;
|
|
1312
1330
|
useEffect(function () {
|
|
1313
1331
|
if (props.setCurrentMedia) {
|
|
1314
1332
|
props.setCurrentMedia(medias[currentIndex]);
|
|
@@ -1367,6 +1385,9 @@ var Gallery = function Gallery(props) {
|
|
|
1367
1385
|
var _media$url;
|
|
1368
1386
|
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
1369
1387
|
id: 'thumb media index ' + i,
|
|
1388
|
+
onClick: function onClick() {
|
|
1389
|
+
return onThumbSlideChange(i);
|
|
1390
|
+
},
|
|
1370
1391
|
children: /*#__PURE__*/jsx(Thumb, {
|
|
1371
1392
|
media: media,
|
|
1372
1393
|
medias: medias
|
|
@@ -11,6 +11,7 @@ export interface GalleryConfig extends BaseElementConfig, MediaItemConfig {
|
|
|
11
11
|
thumbSliderProp?: SwiperProps;
|
|
12
12
|
arIconProps?: ArActionIconConfig;
|
|
13
13
|
videoAutoplay?: boolean;
|
|
14
|
+
showOnlyReadyForSlider?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export interface ArActionIconConfig extends BaseElementConfig {
|
|
16
17
|
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;IACjC,aAAa,CAAC,EAAE,OAAO,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,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;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACrD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAsB,SAAQ,KAAK;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -9,5 +9,6 @@ export default function useGallery({ products, config: { functionTypes, add2DIma
|
|
|
9
9
|
setThumbsSwiper: import("react").Dispatch<import("react").SetStateAction<SwiperClass | null>>;
|
|
10
10
|
setSwiper: import("react").Dispatch<import("react").SetStateAction<SwiperClass | null>>;
|
|
11
11
|
onSlideChange: (swiper: SwiperClass) => void;
|
|
12
|
+
onThumbSlideChange: (clickedIndex: any) => void;
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=useGallery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;;;;;;;;
|
|
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;;;;;;;;4BAuCkB,WAAW;uCAoBA,GAAG;EA8B9C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crystaldesign/widget-library",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.11.0-beta.1",
|
|
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": "e1e57cd62c8d95fb8269c8a39dd3edfb32ed90d1"
|
|
40
40
|
}
|