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