@planetaexo/design-system 0.71.0 → 0.72.0
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/dist/index.cjs +106 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +106 -48
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12702,65 +12702,114 @@ function CarouselGallery({
|
|
|
12702
12702
|
onOpen,
|
|
12703
12703
|
className
|
|
12704
12704
|
}) {
|
|
12705
|
-
var _a;
|
|
12706
12705
|
const total = photos.length;
|
|
12707
|
-
const
|
|
12708
|
-
const prev = () =>
|
|
12709
|
-
const next = () =>
|
|
12710
|
-
const
|
|
12711
|
-
const
|
|
12712
|
-
const
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12706
|
+
const go = (i) => onIndexChange(Math.max(0, Math.min(total - 1, i)));
|
|
12707
|
+
const prev = () => go(index - 1);
|
|
12708
|
+
const next = () => go(index + 1);
|
|
12709
|
+
const containerRef = React20__namespace.useRef(null);
|
|
12710
|
+
const [drag, setDrag] = React20__namespace.useState(0);
|
|
12711
|
+
const [dragging, setDragging] = React20__namespace.useState(false);
|
|
12712
|
+
const gesture = React20__namespace.useRef(null);
|
|
12713
|
+
const movedRef = React20__namespace.useRef(false);
|
|
12714
|
+
const onPointerDown = (e) => {
|
|
12715
|
+
var _a, _b;
|
|
12716
|
+
if (total <= 1) return;
|
|
12717
|
+
movedRef.current = false;
|
|
12718
|
+
gesture.current = {
|
|
12719
|
+
x: e.clientX,
|
|
12720
|
+
y: e.clientY,
|
|
12721
|
+
w: (_b = (_a = containerRef.current) == null ? void 0 : _a.clientWidth) != null ? _b : 1,
|
|
12722
|
+
axis: null,
|
|
12723
|
+
id: e.pointerId
|
|
12724
|
+
};
|
|
12716
12725
|
};
|
|
12717
|
-
const
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
if (!
|
|
12721
|
-
const
|
|
12722
|
-
const
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12726
|
+
const onPointerMove = (e) => {
|
|
12727
|
+
var _a;
|
|
12728
|
+
const g = gesture.current;
|
|
12729
|
+
if (!g || e.pointerId !== g.id) return;
|
|
12730
|
+
const dx = e.clientX - g.x;
|
|
12731
|
+
const dy = e.clientY - g.y;
|
|
12732
|
+
if (g.axis === null) {
|
|
12733
|
+
if (Math.abs(dx) > 8 && Math.abs(dx) > Math.abs(dy)) {
|
|
12734
|
+
g.axis = "x";
|
|
12735
|
+
setDragging(true);
|
|
12736
|
+
(_a = containerRef.current) == null ? void 0 : _a.setPointerCapture(g.id);
|
|
12737
|
+
} else if (Math.abs(dy) > 8) {
|
|
12738
|
+
gesture.current = null;
|
|
12739
|
+
return;
|
|
12740
|
+
} else {
|
|
12741
|
+
return;
|
|
12742
|
+
}
|
|
12728
12743
|
}
|
|
12744
|
+
if (g.axis !== "x") return;
|
|
12745
|
+
movedRef.current = true;
|
|
12746
|
+
let d = dx;
|
|
12747
|
+
if (index === 0 && d > 0 || index === total - 1 && d < 0) d *= 0.35;
|
|
12748
|
+
setDrag(d);
|
|
12749
|
+
};
|
|
12750
|
+
const endGesture = (e) => {
|
|
12751
|
+
const g = gesture.current;
|
|
12752
|
+
gesture.current = null;
|
|
12753
|
+
setDragging(false);
|
|
12754
|
+
setDrag(0);
|
|
12755
|
+
if (!g || g.axis !== "x") return;
|
|
12756
|
+
const dx = e.clientX - g.x;
|
|
12757
|
+
const threshold = Math.min(110, g.w * 0.18);
|
|
12758
|
+
if (dx <= -threshold) next();
|
|
12759
|
+
else if (dx >= threshold) prev();
|
|
12729
12760
|
};
|
|
12730
12761
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12731
12762
|
"div",
|
|
12732
12763
|
{
|
|
12733
|
-
|
|
12734
|
-
|
|
12764
|
+
ref: containerRef,
|
|
12765
|
+
onPointerDown,
|
|
12766
|
+
onPointerMove,
|
|
12767
|
+
onPointerUp: endGesture,
|
|
12768
|
+
onPointerCancel: endGesture,
|
|
12769
|
+
onClick: () => {
|
|
12770
|
+
if (movedRef.current) {
|
|
12771
|
+
movedRef.current = false;
|
|
12772
|
+
return;
|
|
12773
|
+
}
|
|
12774
|
+
onOpen(index);
|
|
12775
|
+
},
|
|
12776
|
+
onKeyDown: (e) => {
|
|
12777
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
12778
|
+
e.preventDefault();
|
|
12779
|
+
onOpen(index);
|
|
12780
|
+
}
|
|
12781
|
+
},
|
|
12782
|
+
role: "button",
|
|
12783
|
+
tabIndex: 0,
|
|
12784
|
+
"aria-label": `Open photo ${index + 1} fullscreen`,
|
|
12735
12785
|
className: cn(
|
|
12736
|
-
"relative w-full aspect-[4/3] sm:aspect-[16/10] overflow-hidden bg-muted
|
|
12786
|
+
"relative w-full aspect-[4/3] sm:aspect-[16/10] overflow-hidden bg-muted",
|
|
12787
|
+
"touch-pan-y select-none cursor-zoom-in",
|
|
12788
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
12737
12789
|
className
|
|
12738
12790
|
),
|
|
12739
12791
|
children: [
|
|
12740
12792
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12741
|
-
"
|
|
12793
|
+
"div",
|
|
12742
12794
|
{
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
return;
|
|
12748
|
-
}
|
|
12749
|
-
onOpen(index);
|
|
12795
|
+
className: "flex h-full w-full",
|
|
12796
|
+
style: {
|
|
12797
|
+
transform: `translateX(calc(${-index * 100}% + ${drag}px))`,
|
|
12798
|
+
transition: dragging ? "none" : "transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1)"
|
|
12750
12799
|
},
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
)
|
|
12800
|
+
children: photos.map((p, i) => {
|
|
12801
|
+
var _a;
|
|
12802
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-full shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12803
|
+
Picture,
|
|
12804
|
+
{
|
|
12805
|
+
src: p.src,
|
|
12806
|
+
alt: (_a = p.alt) != null ? _a : `Photo ${i + 1}`,
|
|
12807
|
+
title: p.caption,
|
|
12808
|
+
className: "pointer-events-none h-full w-full object-cover",
|
|
12809
|
+
rootMargin: "400px"
|
|
12810
|
+
}
|
|
12811
|
+
) }, i);
|
|
12812
|
+
})
|
|
12764
12813
|
}
|
|
12765
12814
|
),
|
|
12766
12815
|
total > 1 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -12768,7 +12817,10 @@ function CarouselGallery({
|
|
|
12768
12817
|
"button",
|
|
12769
12818
|
{
|
|
12770
12819
|
type: "button",
|
|
12771
|
-
onClick:
|
|
12820
|
+
onClick: (e) => {
|
|
12821
|
+
e.stopPropagation();
|
|
12822
|
+
prev();
|
|
12823
|
+
},
|
|
12772
12824
|
"aria-label": "Previous photo",
|
|
12773
12825
|
className: cn(
|
|
12774
12826
|
"absolute left-3 sm:left-4 top-1/2 -translate-y-1/2 z-10",
|
|
@@ -12784,7 +12836,10 @@ function CarouselGallery({
|
|
|
12784
12836
|
"button",
|
|
12785
12837
|
{
|
|
12786
12838
|
type: "button",
|
|
12787
|
-
onClick:
|
|
12839
|
+
onClick: (e) => {
|
|
12840
|
+
e.stopPropagation();
|
|
12841
|
+
next();
|
|
12842
|
+
},
|
|
12788
12843
|
"aria-label": "Next photo",
|
|
12789
12844
|
className: cn(
|
|
12790
12845
|
"absolute right-3 sm:right-4 top-1/2 -translate-y-1/2 z-10",
|
|
@@ -12801,7 +12856,10 @@ function CarouselGallery({
|
|
|
12801
12856
|
"button",
|
|
12802
12857
|
{
|
|
12803
12858
|
type: "button",
|
|
12804
|
-
onClick: () =>
|
|
12859
|
+
onClick: (e) => {
|
|
12860
|
+
e.stopPropagation();
|
|
12861
|
+
onIndexChange(i);
|
|
12862
|
+
},
|
|
12805
12863
|
"aria-label": `Go to photo ${i + 1}`,
|
|
12806
12864
|
className: cn(
|
|
12807
12865
|
"h-1.5 rounded-full transition-all duration-300",
|