ublo-lib 1.47.84 → 1.47.86
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infinite-carousel.d.ts","sourceRoot":"","sources":["../../../../src/common/components/infinite-carousel/infinite-carousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"infinite-carousel.d.ts","sourceRoot":"","sources":["../../../../src/common/components/infinite-carousel/infinite-carousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,KAAK,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzC,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACP,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,SAAS,EACT,QAAQ,EACR,OAAiB,EACjB,OAAY,EACZ,WAAW,GACZ,EAAE,KAAK,2CAwSP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { useUbloContext } from "ublo/with-ublo";
|
|
@@ -15,6 +15,7 @@ export default function InfiniteCarousel({ className, children, variant = "wheel
|
|
|
15
15
|
const [items, setItems] = React.useState([]);
|
|
16
16
|
const [currentIndex, setCurrentIndex] = React.useState(0);
|
|
17
17
|
const [isTransitioning, setIsTransitioning] = React.useState(false);
|
|
18
|
+
const isEditing = cmsMode === "editing";
|
|
18
19
|
const { wheel_items_gap = 100, scale_items_gap = 10, hide_wheel_items = false, scale_number = 0.75, rotate_number = 25, translateY_number = 80, transition_duration = 500, } = options;
|
|
19
20
|
const cloneCount = React.useMemo(() => {
|
|
20
21
|
if (cloneNumber !== undefined)
|
|
@@ -29,7 +30,7 @@ export default function InfiniteCarousel({ className, children, variant = "wheel
|
|
|
29
30
|
return sections;
|
|
30
31
|
}, []);
|
|
31
32
|
React.useEffect(() => {
|
|
32
|
-
if (
|
|
33
|
+
if (isEditing)
|
|
33
34
|
return;
|
|
34
35
|
const foundItems = extractItems();
|
|
35
36
|
if (foundItems.length > 0) {
|
|
@@ -40,9 +41,9 @@ export default function InfiniteCarousel({ className, children, variant = "wheel
|
|
|
40
41
|
itemHeight.current = foundItems[0].offsetHeight;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
}, [extractItems,
|
|
44
|
+
}, [extractItems, isEditing, cloneCount]);
|
|
44
45
|
React.useEffect(() => {
|
|
45
|
-
if (!zoneRef.current ||
|
|
46
|
+
if (!zoneRef.current || isEditing)
|
|
46
47
|
return;
|
|
47
48
|
const observer = new MutationObserver(() => {
|
|
48
49
|
const foundItems = extractItems();
|
|
@@ -56,7 +57,7 @@ export default function InfiniteCarousel({ className, children, variant = "wheel
|
|
|
56
57
|
subtree: true,
|
|
57
58
|
});
|
|
58
59
|
return () => observer.disconnect();
|
|
59
|
-
}, [extractItems, items,
|
|
60
|
+
}, [extractItems, items, isEditing]);
|
|
60
61
|
const infiniteItems = React.useMemo(() => {
|
|
61
62
|
if (items.length === 0)
|
|
62
63
|
return [];
|
|
@@ -174,15 +175,18 @@ export default function InfiniteCarousel({ className, children, variant = "wheel
|
|
|
174
175
|
}
|
|
175
176
|
};
|
|
176
177
|
const classes = classNames(css.carousel, css[`carousel--${variant}`], className);
|
|
177
|
-
if (items.length === 0 ||
|
|
178
|
-
return (_jsx(
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
if (items.length === 0 || items.length < 3 || isEditing) {
|
|
179
|
+
return (_jsx(_Fragment, { children: React.cloneElement(children, {
|
|
180
|
+
ref: zoneRef,
|
|
181
|
+
}) }));
|
|
181
182
|
}
|
|
182
183
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classes, style: {
|
|
183
184
|
"--carousel-item-width": `${itemWidth.current}px`,
|
|
184
185
|
"--carousel-item-height": `${itemHeight.current}px`,
|
|
185
|
-
}, children: [_jsxs("div", { className: css.controls, children: [_jsx(Button, { className: css.control, variant: "link", onClick: () => slideTo("prev"), "data-control": "prev", children: _jsx(ChevronLeftIcon, { className: css.controlIcon }) }), _jsx(Button, { className: css.control, variant: "link", onClick: () => slideTo("next"), "data-control": "next", children: _jsx(ChevronRightIcon, { className: css.controlIcon }) })] }), _jsx("div", { className: css.viewport, children: _jsx("div", { className: css.track, children: infiniteItems.map((item, index) =>
|
|
186
|
+
}, children: [_jsxs("div", { className: css.controls, children: [_jsx(Button, { className: css.control, variant: "link", onClick: () => slideTo("prev"), "data-control": "prev", children: _jsx(ChevronLeftIcon, { className: css.controlIcon }) }), _jsx(Button, { className: css.control, variant: "link", onClick: () => slideTo("next"), "data-control": "next", children: _jsx(ChevronRightIcon, { className: css.controlIcon }) })] }), _jsx("div", { className: css.viewport, children: _jsx("div", { className: css.track, children: infiniteItems.map((item, index) => {
|
|
187
|
+
const current = index === currentIndex;
|
|
188
|
+
return (_jsx("div", { "data-current-item": current, className: css.item, style: getItemStyle(index), dangerouslySetInnerHTML: { __html: item.outerHTML } }, `item-${index}`));
|
|
189
|
+
}) }) }), _jsx("div", { style: { display: "none" }, children: React.cloneElement(children, {
|
|
186
190
|
ref: zoneRef,
|
|
187
191
|
}) })] }), _jsx(ScrollbarSize, {})] }));
|
|
188
192
|
}
|