ublo-lib 1.7.3 → 1.7.5
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(
|
|
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",
|
|
@@ -225,8 +226,14 @@ const Carousel = ({
|
|
|
225
226
|
React.useEffect(() => {
|
|
226
227
|
const zone = carouselRef.current?.querySelector(".cms");
|
|
227
228
|
if (zone) {
|
|
228
|
-
zone.addEventListener("
|
|
229
|
-
|
|
229
|
+
zone.addEventListener("ublo-section-created", updateSectionCount);
|
|
230
|
+
zone.addEventListener("ublo-section-pasted", updateSectionCount);
|
|
231
|
+
zone.addEventListener("ublo-section-removed", updateSectionCount);
|
|
232
|
+
return () => {
|
|
233
|
+
zone.removeEventListener("ublo-section-removed", updateSectionCount);
|
|
234
|
+
zone.removeEventListener("ublo-section-pasted", updateSectionCount);
|
|
235
|
+
zone.removeEventListener("ublo-section-created", updateSectionCount);
|
|
236
|
+
};
|
|
230
237
|
}
|
|
231
238
|
}, [updateSectionCount]);
|
|
232
239
|
React.useEffect(() => {
|
|
@@ -272,7 +279,7 @@ const Carousel = ({
|
|
|
272
279
|
});
|
|
273
280
|
if (fade) inner.style.removeProperty("transform");
|
|
274
281
|
}
|
|
275
|
-
}, [current, editing, fade, targets]);
|
|
282
|
+
}, [count, current, editing, fade, targets]);
|
|
276
283
|
const onUndraggableElementClick = React.useCallback(e => {
|
|
277
284
|
e.preventDefault();
|
|
278
285
|
e.stopPropagation();
|
|
@@ -329,7 +336,8 @@ const Carousel = ({
|
|
|
329
336
|
carouselRef: carouselRef,
|
|
330
337
|
count: count,
|
|
331
338
|
current: current,
|
|
332
|
-
setCurrent: setCurrent
|
|
339
|
+
setCurrent: setCurrent,
|
|
340
|
+
targets: targets
|
|
333
341
|
})]
|
|
334
342
|
});
|
|
335
343
|
};
|
|
@@ -95,12 +95,12 @@ const usePackages = (defaultPopupContent, setPopupContent, cartUrl, selector = "
|
|
|
95
95
|
}, [selector, toggleEditButton]);
|
|
96
96
|
const init = React.useCallback(section => {
|
|
97
97
|
const zone = section.closest(".cms");
|
|
98
|
-
zone.addEventListener("
|
|
98
|
+
zone.addEventListener("ublo-section-created", callback);
|
|
99
99
|
section.addEventListener("click", onPackageClick);
|
|
100
100
|
}, [callback, onPackageClick]);
|
|
101
101
|
const cleanup = React.useCallback(section => {
|
|
102
102
|
const zone = section.closest(".cms");
|
|
103
|
-
zone.removeEventListener("
|
|
103
|
+
zone.removeEventListener("ublo-section-created", callback);
|
|
104
104
|
section.removeEventListener("click", onPackageClick);
|
|
105
105
|
}, [callback, onPackageClick]);
|
|
106
106
|
React.useEffect(() => {
|
|
@@ -40,13 +40,13 @@ const useZoneSync = (zoneRef, twinZoneParentSelector) => {
|
|
|
40
40
|
attributes: true
|
|
41
41
|
});
|
|
42
42
|
} else {
|
|
43
|
-
zone.addEventListener("
|
|
43
|
+
zone.addEventListener("ublo-section-created", init);
|
|
44
44
|
}
|
|
45
45
|
}, [twinZoneParentSelector, zoneRef]);
|
|
46
46
|
const cleanup = useCallback(() => {
|
|
47
47
|
const zone = zoneRef.current;
|
|
48
48
|
if (!zone) return;
|
|
49
|
-
zone.removeEventListener("
|
|
49
|
+
zone.removeEventListener("ublo-section-created", init);
|
|
50
50
|
}, [init, zoneRef]);
|
|
51
51
|
useEffect(() => {
|
|
52
52
|
if (cmsMode) {
|