ublo-lib 1.7.2 → 1.7.4

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.
@@ -58,13 +58,14 @@ const Thumbnails = ({
58
58
  carouselRef,
59
59
  count,
60
60
  current,
61
- setCurrent
61
+ setCurrent,
62
+ targets
62
63
  }) => {
63
64
  const [thumbnails, setThumbnails] = React.useState([]);
64
65
  React.useEffect(() => {
65
66
  const carousel = carouselRef.current;
66
67
  if (carousel) {
67
- const sections = carousel.querySelectorAll("section[data-class]");
68
+ const sections = carousel.querySelectorAll(targets);
68
69
  if (sections.length) {
69
70
  const images = Array.from(sections).reduce((acc, section) => {
70
71
  const image = section.querySelector("img");
@@ -74,7 +75,7 @@ const Thumbnails = ({
74
75
  setThumbnails(images);
75
76
  }
76
77
  }
77
- }, [carouselRef, count]);
78
+ }, [carouselRef, count, targets]);
78
79
  if (!count || !thumbnails.length) return null;
79
80
  return _jsx("div", {
80
81
  className: "carousel__thumbnails",
@@ -115,6 +116,7 @@ const Carousel = ({
115
116
  const [dragging, setDragging] = React.useState(0);
116
117
  const editing = cmsMode === "editing";
117
118
  const draggingAllowed = !editing && allowDragOnDesktop;
119
+ const targets = editing ? "section" : "section:not([data-hidden])";
118
120
  const showNextArrow = current < count - 1;
119
121
  const showPrevArrow = current !== 0;
120
122
  const next = React.useCallback(e => {
@@ -218,9 +220,9 @@ const Carousel = ({
218
220
  };
219
221
  const updateSectionCount = React.useCallback(() => {
220
222
  const carousel = carouselRef.current;
221
- const sections = carousel.querySelectorAll("section");
223
+ const sections = carousel.querySelectorAll(targets);
222
224
  setCount(sections?.length || 0);
223
- }, []);
225
+ }, [targets]);
224
226
  React.useEffect(() => {
225
227
  const zone = carouselRef.current?.querySelector(".cms");
226
228
  if (zone) {
@@ -231,7 +233,7 @@ const Carousel = ({
231
233
  React.useEffect(() => {
232
234
  const carousel = carouselRef.current;
233
235
  const inner = carousel.firstElementChild;
234
- const sections = Array.from(carousel.querySelectorAll("section"));
236
+ const sections = Array.from(carousel.querySelectorAll(targets));
235
237
  const undraggableElements = Array.from(carousel.querySelectorAll(UNDRAGGABLE_TAGS));
236
238
  setCount(sections.length);
237
239
  if (!editing) {
@@ -271,7 +273,7 @@ const Carousel = ({
271
273
  });
272
274
  if (fade) inner.style.removeProperty("transform");
273
275
  }
274
- }, [children, current, editing, fade, count]);
276
+ }, [current, editing, fade, targets]);
275
277
  const onUndraggableElementClick = React.useCallback(e => {
276
278
  e.preventDefault();
277
279
  e.stopPropagation();
@@ -324,11 +326,12 @@ const Carousel = ({
324
326
  count: count,
325
327
  current: current,
326
328
  setCurrent: setCurrent
327
- }), thumbnails && _jsx(Thumbnails, {
329
+ }), thumbnails && count > 1 && _jsx(Thumbnails, {
328
330
  carouselRef: carouselRef,
329
331
  count: count,
330
332
  current: current,
331
- setCurrent: setCurrent
333
+ setCurrent: setCurrent,
334
+ targets: targets
332
335
  })]
333
336
  });
334
337
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^2.1.0",
6
6
  "next": "^12.0.0",