pds-dev-kit-web-test 2.7.543 → 2.7.545

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.
@@ -5103,9 +5103,9 @@
5103
5103
  "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_DATAFILTER": "NONE",
5104
5104
  "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_DATAOFFSET": 0,
5105
5105
  "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_DATASORTING": "PAPPQUERY_SORTING_ITEM_ID_ASC",
5106
- "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_DISPLAYCOUNTS": 4,
5106
+ "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_DISPLAYCOUNTS": 3,
5107
5107
  "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_EDITCOMMONITEM": null,
5108
- "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_ITEMCOUNTS": 2,
5108
+ "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_ITEMCOUNTS": 4,
5109
5109
  "CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_MANUALITEMS": [
5110
5110
  {
5111
5111
  "order": 1,
@@ -26,6 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  var jsx_runtime_1 = require("react/jsx-runtime");
29
+ /* eslint-disable no-loop-func */
30
+ /* eslint-disable no-plusplus */
29
31
  var react_1 = require("react");
30
32
  var swiper_1 = require("swiper");
31
33
  require("swiper/modules/navigation/navigation.min.css");
@@ -44,39 +46,51 @@ function (_a, ref) {
44
46
  }, [children]);
45
47
  var finalSlidesPerView = props.effect === 'cards' ? 1 : slidesPerView;
46
48
  var useAutoplay = !!styles.useAutoplay && childrenArray.length > 1;
47
- // 2. (수정) 루프와 slidesPerView 문제를 해결하기 위한 배열
48
- var loopedChildren = (0, react_1.useMemo)(function () {
49
- // 루프가 아니거나, slidesPerView가 1이하이면 원본 반환
50
- console.log('loopedChildren calculation', {
51
- loop: loop,
52
- slidesPerView: slidesPerView,
53
- originalChildrenLength: originalChildren.length
54
- });
49
+ // 2. loop를 위한 슬라이드 배열 key 생성
50
+ var _b = (0, react_1.useMemo)(function () {
55
51
  if (!loop || typeof slidesPerView !== 'number' || slidesPerView <= 1) {
56
- return originalChildren;
52
+ return {
53
+ slides: originalChildren.map(function (child, idx) { return ({ child: child, key: "original-".concat(idx) }); }),
54
+ shouldEnableLoop: loop
55
+ };
57
56
  }
58
- // 3. (핵심) 루프가 필요한데 슬라이드 수가 충분하지 않은 경우
59
- // Swiper loop는 최소 slidesPerView * 2개 이상 필요
60
- var minSlidesRequired = slidesPerView * 2;
61
- console.log('minSlidesRequired', minSlidesRequired);
62
- console.log('originalChildren.length', originalChildren.length);
63
- if (originalChildren.length > 0 && originalChildren.length < minSlidesRequired) {
64
- // 필요한 개수만큼만 정확히 복제
65
- var duplicatedChildren = [];
66
- while (duplicatedChildren.length < minSlidesRequired) {
67
- duplicatedChildren.push.apply(duplicatedChildren, originalChildren);
57
+ // loop를 위한 최소 슬라이드 계산 (Swiper 내부 복제를 위한 공간 확보)
58
+ var minSlidesForLoop = slidesPerView * 2;
59
+ // 슬라이드가 충분하면 원본 그대로 + loop 활성화
60
+ if (originalChildren.length >= minSlidesForLoop) {
61
+ return {
62
+ slides: originalChildren.map(function (child, idx) { return ({ child: child, key: "original-".concat(idx) }); }),
63
+ shouldEnableLoop: true
64
+ };
65
+ }
66
+ // 슬라이드가 부족하면 충분한 개수까지 복제 + loop 활성화
67
+ if (originalChildren.length > 0) {
68
+ var duplicatedSlides_1 = [];
69
+ var copyCount_1 = 0;
70
+ // Swiper loop가 제대로 작동하려면 충분히 많이 복제
71
+ // minSlidesForLoop * 3 = 18개 정도면 무한 루프가 자연스럽게 작동
72
+ while (duplicatedSlides_1.length < minSlidesForLoop * 3) {
73
+ originalChildren.forEach(function (child, idx) {
74
+ duplicatedSlides_1.push({ child: child, key: "copy-".concat(copyCount_1, "-").concat(idx) });
75
+ });
76
+ copyCount_1++;
68
77
  }
69
- return duplicatedChildren.slice(0, minSlidesRequired);
78
+ return {
79
+ slides: duplicatedSlides_1,
80
+ shouldEnableLoop: true // 충분히 복제했으므로 loop 활성화
81
+ };
70
82
  }
71
- // 슬라이드 수가 충분하면 원본 반환
72
- return originalChildren;
73
- }, [originalChildren, loop, slidesPerView]);
74
- // Swiper에 loopedSlides 옵션 추가
83
+ return {
84
+ slides: originalChildren.map(function (child, idx) { return ({ child: child, key: "original-".concat(idx) }); }),
85
+ shouldEnableLoop: false
86
+ };
87
+ }, [originalChildren, loop, slidesPerView]), slides = _b.slides, shouldEnableLoop = _b.shouldEnableLoop;
88
+ // loopedSlides는 loop가 실제로 활성화될 때만 설정
75
89
  var loopedSlidesCount = (0, react_1.useMemo)(function () {
76
- if (!loop || typeof slidesPerView !== 'number')
90
+ if (!shouldEnableLoop || typeof slidesPerView !== 'number')
77
91
  return undefined;
78
- return Math.max(slidesPerView, originalChildren.length);
79
- }, [loop, slidesPerView, originalChildren.length]);
92
+ return slidesPerView;
93
+ }, [shouldEnableLoop, slidesPerView]);
80
94
  return ((0, jsx_runtime_1.jsx)(StyledSwiper_1.default, __assign({ id: "styled-swiper-wrapper" }, { children: (0, jsx_runtime_1.jsx)(react_2.Swiper, __assign({ ref: ref, style: {
81
95
  width: '100%',
82
96
  height: '100%'
@@ -91,7 +105,10 @@ function (_a, ref) {
91
105
  swiper_1.EffectCards,
92
106
  swiper_1.EffectCoverflow,
93
107
  swiper_1.EffectFlip
94
- ], loopedSlides: loopedSlidesCount, slidesPerView: finalSlidesPerView, scrollbar: styles.scrollbar, slidesPerGroup: styles.slidesPerGroup, spaceBetween: styles.spaceBetween, freeMode: styles.freeMode, autoplay: useAutoplay ? styles.autoplay : false, loop: loop, allowTouchMove: allowTouchMove, observer: true, observeParents: true }, props, { children: loopedChildren.map(function (slide, index) { return ((0, jsx_runtime_1.jsx)(react_2.SwiperSlide, __assign({ style: { pointerEvents: allowTouchMove ? 'auto' : 'none' } }, { children: slide || (0, jsx_runtime_1.jsx)("div", { className: "swiper-slide-empty" }) }), index)); }) })) })));
108
+ ], loopedSlides: loopedSlidesCount, slidesPerView: finalSlidesPerView, scrollbar: styles.scrollbar, slidesPerGroup: styles.slidesPerGroup, spaceBetween: styles.spaceBetween, freeMode: styles.freeMode, autoplay: useAutoplay ? styles.autoplay : false, loop: shouldEnableLoop, allowTouchMove: allowTouchMove, observer: true, observeParents: true }, props, { children: slides.map(function (_a) {
109
+ var child = _a.child, key = _a.key;
110
+ return ((0, jsx_runtime_1.jsx)(react_2.SwiperSlide, __assign({ style: { pointerEvents: allowTouchMove ? 'auto' : 'none' } }, { children: child || (0, jsx_runtime_1.jsx)("div", { className: "swiper-slide-empty" }) }), key));
111
+ }) })) })));
95
112
  });
96
113
  ContentsCarouselCore.displayName = 'ContentsCarouselCore';
97
114
  exports.default = ContentsCarouselCore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "2.7.543",
3
+ "version": "2.7.545",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",