jenosize-ui 0.2.1 → 0.3.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/README.md +183 -63
- package/THIRD-PARTY-NOTICES.md +15 -0
- package/dist/GradientPicker-CQm3GT7F.d.ts +144 -0
- package/dist/{PaymentInput-Dn5WVQVy.d.ts → PaymentInput-Cz5jFB3p.d.ts} +1 -1
- package/dist/{Select-Dt5ARIH8.d.ts → Select-CXOAMlk7.d.ts} +15 -1
- package/dist/{TagInput-BaBeve6L.d.ts → TagInput-CzIrONr-.d.ts} +1 -1
- package/dist/area-chart.d.ts +2 -2
- package/dist/area-chart.js +7 -6
- package/dist/at-least-one-BZ2dsck-.d.ts +18 -0
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.js +12 -11
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +6 -6
- package/dist/bar-chart.d.ts +2 -2
- package/dist/bar-chart.js +7 -6
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +4 -4
- package/dist/button.d.ts +1 -1
- package/dist/button.js +11 -10
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +16 -15
- package/dist/callout.d.ts +4 -2
- package/dist/callout.js +12 -11
- package/dist/card.d.ts +59 -3
- package/dist/card.js +4 -4
- package/dist/carousel.d.ts +169 -0
- package/dist/carousel.js +9 -0
- package/dist/catalog.json +11180 -0
- package/dist/checkbox.js +8 -7
- package/dist/{chunk-MVG5MABV.js → chunk-26XQU3TC.js} +8 -8
- package/dist/{chunk-X2X7Q7NW.js → chunk-2R3QWWOT.js} +3 -3
- package/dist/{chunk-AIARANKE.js → chunk-3JQKVC2K.js} +4 -4
- package/dist/chunk-3P3QZPHV.js +109 -0
- package/dist/{chunk-GLKFFA7N.js → chunk-44AWXIQK.js} +5 -5
- package/dist/{chunk-FWRHBMWT.js → chunk-4Y32RIC7.js} +5 -19
- package/dist/{chunk-5XPMY2LF.js → chunk-5ECTNYKU.js} +5 -5
- package/dist/{chunk-6B6BWTXC.js → chunk-5GBA6X6A.js} +5 -5
- package/dist/{chunk-UGKELBNC.js → chunk-5SGF47TZ.js} +9 -9
- package/dist/{chunk-POQTE7JI.js → chunk-5XSR757T.js} +7 -7
- package/dist/{chunk-GZMDZF2V.js → chunk-6FGLABYH.js} +3 -3
- package/dist/{chunk-MCQG4H6T.js → chunk-6T3QAO5K.js} +12 -4
- package/dist/{chunk-SKRR3ZMP.js → chunk-737A4YNC.js} +3 -3
- package/dist/{chunk-AFYXSZGW.js → chunk-7LSUUEAF.js} +7 -5
- package/dist/{chunk-7VLYQR4D.js → chunk-7OFGPDYJ.js} +3 -3
- package/dist/{chunk-54SIZR63.js → chunk-7UCKFULR.js} +7 -7
- package/dist/{chunk-LQURV7HQ.js → chunk-7ZA3QZRP.js} +4 -4
- package/dist/{chunk-X2VMIBK5.js → chunk-A4YPUS6C.js} +4 -4
- package/dist/{chunk-5ZEUTSCV.js → chunk-B4OVIE2X.js} +6 -6
- package/dist/{chunk-P6CON2R2.js → chunk-BH32X25C.js} +3 -3
- package/dist/{chunk-667ZHY3T.js → chunk-BJHLW25G.js} +85 -538
- package/dist/{chunk-ULGCGKOE.js → chunk-BKBINQJZ.js} +4 -4
- package/dist/{chunk-CFFWYXDW.js → chunk-BXQFBFT7.js} +5 -5
- package/dist/{chunk-I6WMNXC7.js → chunk-CQGMOPLG.js} +6 -6
- package/dist/{chunk-FNQJJO63.js → chunk-CUONE6LA.js} +4 -4
- package/dist/{chunk-FFMTYQXE.js → chunk-CVCS5G3E.js} +43 -21
- package/dist/{chunk-33TOK7ES.js → chunk-DCKVNHV5.js} +5 -5
- package/dist/{chunk-A323V6AI.js → chunk-DYRGHXT5.js} +3 -3
- package/dist/{chunk-T4ZFZTY6.js → chunk-EHML2DLR.js} +4 -4
- package/dist/{chunk-N3RVMBPX.js → chunk-EJKQGUUM.js} +4 -4
- package/dist/{chunk-E2YZ7IMT.js → chunk-ESDSTS5N.js} +6 -6
- package/dist/{chunk-LCG34A5T.js → chunk-EVINS473.js} +5 -3
- package/dist/chunk-EXRVOGJ5.js +325 -0
- package/dist/{chunk-YHBI52P2.js → chunk-GDW6NFYN.js} +3 -3
- package/dist/chunk-GOCO45FF.js +619 -0
- package/dist/{chunk-7ZM7SNCZ.js → chunk-GPHGPY6T.js} +3 -3
- package/dist/{chunk-PO2TYK3C.js → chunk-GWYDOZGQ.js} +3 -3
- package/dist/{chunk-LO22VQL5.js → chunk-HNNNJP3A.js} +4 -4
- package/dist/{chunk-ZZSNTCCL.js → chunk-IESEBPYA.js} +4 -4
- package/dist/{chunk-3H444OJA.js → chunk-JZ4HGFWK.js} +3 -3
- package/dist/chunk-KBQJIVUB.js +33 -0
- package/dist/{chunk-CKMWBVRR.js → chunk-KCM4KEZ2.js} +4 -4
- package/dist/{chunk-3QXLIZIX.js → chunk-KNGJ3CSB.js} +3 -3
- package/dist/{chunk-FH7Z7SGQ.js → chunk-KNW3IUWX.js} +12 -11
- package/dist/{chunk-KZP6B6B3.js → chunk-KTWTYK5U.js} +16 -5
- package/dist/{chunk-LYXPJERB.js → chunk-L7Z6XGBU.js} +5 -5
- package/dist/{chunk-ZHAT2XZ4.js → chunk-LLUWBQK6.js} +10 -10
- package/dist/{chunk-QHH6AUR3.js → chunk-MDKVYC6R.js} +7 -7
- package/dist/{chunk-22M75A3N.js → chunk-MS6DY4CE.js} +14 -11
- package/dist/{chunk-LLPWQDF7.js → chunk-MTOTPAYZ.js} +3 -3
- package/dist/{chunk-AZ7DKRBY.js → chunk-MVF7FA4D.js} +5 -5
- package/dist/{chunk-AIGYMTCU.js → chunk-MVUNB43J.js} +3 -3
- package/dist/{chunk-ZMFY7WAY.js → chunk-O24HHIQG.js} +41 -39
- package/dist/{chunk-NKG4N6HA.js → chunk-O5EHNNPS.js} +4 -4
- package/dist/{chunk-5DP7W5HX.js → chunk-OIPFTJS6.js} +3 -3
- package/dist/{chunk-U4WSJAYK.js → chunk-OXNIEIOY.js} +20 -20
- package/dist/chunk-P2BGR77C.js +344 -0
- package/dist/{chunk-CGHYXWTT.js → chunk-PFAFTLN3.js} +4 -4
- package/dist/{chunk-4RBIWI2Q.js → chunk-Q2KR7PSX.js} +3 -3
- package/dist/{chunk-7GUPNTAH.js → chunk-QSOLK2I2.js} +7 -7
- package/dist/chunk-QTWRR7IS.js +1129 -0
- package/dist/{chunk-OLLD2BZN.js → chunk-QZHAL4BL.js} +3 -3
- package/dist/{chunk-OACWA4TC.js → chunk-R25NHHYT.js} +6 -6
- package/dist/{chunk-QDKETK7D.js → chunk-S55JKMG7.js} +5 -5
- package/dist/{chunk-S5TEWPWW.js → chunk-S5LLA36K.js} +10 -10
- package/dist/{chunk-QDYE5LVT.js → chunk-SF3HCW4G.js} +45 -4
- package/dist/{chunk-KHGW72BM.js → chunk-SGMVB7HD.js} +3 -3
- package/dist/{chunk-FKVPAEJ6.js → chunk-SKJC2KYD.js} +4 -3
- package/dist/chunk-SKPKL47Y.js +5671 -0
- package/dist/{chunk-6MMBQVRO.js → chunk-TCTTZHUS.js} +9 -9
- package/dist/chunk-U5X3MLM5.js +67 -0
- package/dist/chunk-UHSGD4CD.js +364 -0
- package/dist/chunk-UJ4WEQHR.js +525 -0
- package/dist/{chunk-6H4LNWQ7.js → chunk-VDFWWWLL.js} +9 -4
- package/dist/{chunk-5KSD4WKN.js → chunk-VIKV25VP.js} +5 -5
- package/dist/chunk-WJB5GWAZ.js +20 -0
- package/dist/{chunk-HHYEAFCL.js → chunk-XAQQ4LYL.js} +11 -11
- package/dist/{chunk-4VGEJG4M.js → chunk-XCFFM2C7.js} +9 -9
- package/dist/chunk-XKTD3X6Z.js +183 -0
- package/dist/{chunk-GQRSABRN.js → chunk-XWXXKEG6.js} +4 -4
- package/dist/chunk-YGFTNICV.js +110 -0
- package/dist/{chunk-T5574MXM.js → chunk-YGJL7QS7.js} +8 -8
- package/dist/{chunk-SB3DG572.js → chunk-YKPTUANT.js} +6 -6
- package/dist/{chunk-YQYVGWIC.js → chunk-YQAYAJ2T.js} +33 -11
- package/dist/chunk-YXYZW6WU.js +998 -0
- package/dist/{chunk-IQNVSQRK.js → chunk-Z6NSOC6T.js} +5 -5
- package/dist/{chunk-BBKE4W3B.js → chunk-ZAWGG4H2.js} +7 -7
- package/dist/{chunk-BFVJHH7S.js → chunk-ZF362B2X.js} +5 -5
- package/dist/{chunk-RJTVCA62.js → chunk-ZJIY642R.js} +3 -3
- package/dist/color-input.d.ts +93 -0
- package/dist/color-input.js +35 -0
- package/dist/color-picker.d.ts +268 -0
- package/dist/color-picker.js +28 -0
- package/dist/color-value-DYzChVOW.d.ts +129 -0
- package/dist/combobox.d.ts +1 -1
- package/dist/combobox.js +13 -12
- package/dist/date-calendar.d.ts +49 -0
- package/dist/date-calendar.js +12 -0
- package/dist/date-input.d.ts +1 -1
- package/dist/date-input.js +11 -10
- package/dist/date-picker.d.ts +15 -131
- package/dist/date-picker.js +26 -22
- package/dist/date-types-DrDdF6WJ.d.ts +100 -0
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +10 -10
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +9 -9
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/dropdown-menu.js +6 -6
- package/dist/dropzone.d.ts +3 -3
- package/dist/dropzone.js +17 -16
- package/dist/form.d.ts +15 -5
- package/dist/form.js +75 -36
- package/dist/header-navigation.d.ts +2 -2
- package/dist/header-navigation.js +21 -20
- package/dist/helper.d.ts +1 -1
- package/dist/index.d.ts +25 -11
- package/dist/index.js +92 -79
- package/dist/indicator.js +4 -4
- package/dist/inline-banner.d.ts +68 -0
- package/dist/inline-banner.js +20 -0
- package/dist/input.d.ts +1 -1
- package/dist/input.js +10 -9
- package/dist/kanban-board.d.ts +2 -2
- package/dist/kanban-board.js +16 -15
- package/dist/labels-C992bt7G.d.ts +1160 -0
- package/dist/line-chart.d.ts +2 -2
- package/dist/line-chart.js +7 -6
- package/dist/mcp.js +231 -0
- package/dist/number-input.d.ts +1 -1
- package/dist/number-input.js +10 -9
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +14 -13
- package/dist/{card-D56VxyAe.d.ts → panel-CUGm_Mxy.d.ts} +9 -57
- package/dist/payment-input.d.ts +3 -3
- package/dist/payment-input.js +10 -9
- package/dist/picker-draft-BPV3MUPY.d.ts +9 -0
- package/dist/pie-chart.d.ts +2 -2
- package/dist/pie-chart.js +7 -6
- package/dist/popover.d.ts +65 -4
- package/dist/popover.js +9 -9
- package/dist/progress-steps.js +4 -4
- package/dist/progress.js +3 -3
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +3 -3
- package/dist/qr-code.d.ts +227 -0
- package/dist/qr-code.js +19 -0
- package/dist/radar-chart.d.ts +2 -2
- package/dist/radar-chart.js +7 -6
- package/dist/radial-chart.d.ts +2 -2
- package/dist/radial-chart.js +7 -6
- package/dist/radio.js +8 -7
- package/dist/rich-text-editor.d.ts +624 -0
- package/dist/rich-text-editor.js +51 -0
- package/dist/rich-text-highlight.d.ts +11 -0
- package/dist/rich-text-highlight.js +65 -0
- package/dist/rich-text-sanitize.d.ts +17 -0
- package/dist/rich-text-sanitize.js +176 -0
- package/dist/scroll-area.js +2 -2
- package/dist/select.d.ts +2 -2
- package/dist/select.js +17 -16
- package/dist/separator.js +2 -2
- package/dist/shared-CGf2D8ZX.d.ts +20 -0
- package/dist/sidebar-navigation.d.ts +76 -27
- package/dist/sidebar-navigation.js +16 -15
- package/dist/sidebar-state.d.ts +76 -0
- package/dist/sidebar-state.js +27 -0
- package/dist/skeleton.js +2 -2
- package/dist/slider.d.ts +321 -0
- package/dist/slider.js +13 -0
- package/dist/styles.css +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +2 -2
- package/dist/table.d.ts +3 -19
- package/dist/table.js +34 -33
- package/dist/tabs.js +2 -2
- package/dist/tag-input.d.ts +3 -3
- package/dist/tag-input.js +13 -12
- package/dist/tag.d.ts +1 -1
- package/dist/tag.js +4 -4
- package/dist/textarea.js +8 -7
- package/dist/theme.css +965 -0
- package/dist/theme.js +12 -11
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +12 -11
- package/dist/tooltip.js +4 -3
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +6 -6
- package/dist/{types-DR9rAEy1.d.ts → types-DYFl0CEB.d.ts} +1 -1
- package/dist/{use-uploads-KaPqDklo.d.ts → use-uploads-2E7n0PWT.d.ts} +1 -1
- package/dist/verification-code-input.js +10 -9
- package/package.json +92 -8
- package/dist/chunk-BLIZ3CL3.js +0 -49
- package/dist/labels-DPrh0se9.d.ts +0 -627
- package/dist/panel-El4oI68p.d.ts +0 -9
- package/dist/shared-BYXJPnsN.d.ts +0 -11
|
@@ -0,0 +1,998 @@
|
|
|
1
|
+
import { useControllable } from './chunk-WJB5GWAZ.js';
|
|
2
|
+
import { useIsomorphicLayoutEffect } from './chunk-EDSK6FEH.js';
|
|
3
|
+
import { PauseIcon, PlayIcon, ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, ChevronLeftIcon } from './chunk-YGFTNICV.js';
|
|
4
|
+
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
5
|
+
import { useLabels } from './chunk-ZJIY642R.js';
|
|
6
|
+
import { warnNeedsName, warnPositiveInt, devWarn } from './chunk-SF3HCW4G.js';
|
|
7
|
+
import * as React3 from 'react';
|
|
8
|
+
import Fade from 'embla-carousel-fade';
|
|
9
|
+
import default2 from 'embla-carousel-react';
|
|
10
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
var QUERY = "(prefers-reduced-motion: reduce)";
|
|
13
|
+
function useReducedMotion() {
|
|
14
|
+
const [reduced, setReduced] = React3.useState(false);
|
|
15
|
+
React3.useEffect(() => {
|
|
16
|
+
if (typeof window === "undefined" || typeof globalThis.matchMedia !== "function") return;
|
|
17
|
+
const mq = globalThis.matchMedia(QUERY);
|
|
18
|
+
setReduced(mq.matches);
|
|
19
|
+
const onChange = (event) => setReduced(event.matches);
|
|
20
|
+
mq.addEventListener("change", onChange);
|
|
21
|
+
return () => mq.removeEventListener("change", onChange);
|
|
22
|
+
}, []);
|
|
23
|
+
return reduced;
|
|
24
|
+
}
|
|
25
|
+
var DURATION = 25;
|
|
26
|
+
function toEngineOptions(config) {
|
|
27
|
+
return {
|
|
28
|
+
axis: config.orientation === "vertical" ? "y" : "x",
|
|
29
|
+
align: config.align,
|
|
30
|
+
loop: config.loop,
|
|
31
|
+
dragFree: config.drag === "free",
|
|
32
|
+
watchDrag: config.drag !== "none",
|
|
33
|
+
slidesToScroll: Math.max(1, Math.round(config.slides.step)),
|
|
34
|
+
startIndex: config.startIndex,
|
|
35
|
+
containScroll: "trimSnaps",
|
|
36
|
+
duration: config.reducedMotion ? 0 : DURATION
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function toEnginePlugins(effect) {
|
|
40
|
+
return effect === "fade" ? [Fade()] : [];
|
|
41
|
+
}
|
|
42
|
+
function readSnapRegistry(api) {
|
|
43
|
+
const identity = () => Array.from({ length: api.slideNodes().length }, (_, index) => [index]);
|
|
44
|
+
const registry = api.internalEngine().slideRegistry;
|
|
45
|
+
if (!Array.isArray(registry) || registry.length === 0) return identity();
|
|
46
|
+
if (registry.some((group) => !Array.isArray(group) || group.length === 0)) return identity();
|
|
47
|
+
return registry;
|
|
48
|
+
}
|
|
49
|
+
function identitySnapRegistry(total) {
|
|
50
|
+
return Array.from({ length: Math.max(0, total) }, (_, index) => [index]);
|
|
51
|
+
}
|
|
52
|
+
function snapForIndex(registry, index) {
|
|
53
|
+
const found = registry.findIndex((group) => group.includes(index));
|
|
54
|
+
if (found !== -1) return found;
|
|
55
|
+
return index <= 0 ? 0 : Math.max(0, registry.length - 1);
|
|
56
|
+
}
|
|
57
|
+
function indexForSnap(registry, snap) {
|
|
58
|
+
const bounded = Math.min(Math.max(snap, 0), Math.max(0, registry.length - 1));
|
|
59
|
+
return registry[bounded]?.[0] ?? 0;
|
|
60
|
+
}
|
|
61
|
+
function visibleIndexes(config) {
|
|
62
|
+
const { registry, snap, perView, total, loop = false } = config;
|
|
63
|
+
if (total <= 0) return [];
|
|
64
|
+
const raw = indexForSnap(registry, snap);
|
|
65
|
+
if (loop) return Array.from({ length: Math.min(perView, total) }, (_, offset) => (raw + offset) % total);
|
|
66
|
+
const lead = Math.max(0, Math.min(raw, total - perView));
|
|
67
|
+
return Array.from({ length: perView }, (_, offset) => lead + offset).filter((index) => index < total);
|
|
68
|
+
}
|
|
69
|
+
function estimateSnapForIndex(config) {
|
|
70
|
+
const { index, step, snapCount } = config;
|
|
71
|
+
const page = Math.floor(index / Math.max(1, step));
|
|
72
|
+
const last = Math.max(0, snapCount - 1);
|
|
73
|
+
return Math.min(Math.max(0, page), last);
|
|
74
|
+
}
|
|
75
|
+
function estimateSnapCount(config) {
|
|
76
|
+
const { total, perView, step, loop } = config;
|
|
77
|
+
if (total <= 0) return 0;
|
|
78
|
+
const groups = Math.ceil(total / step);
|
|
79
|
+
if (loop) return groups;
|
|
80
|
+
return Math.max(1, Math.min(groups, Math.ceil((total - perView) / step) + 1));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/components/carousel/indicator.ts
|
|
84
|
+
var STRIP = "flex h-max items-center";
|
|
85
|
+
var STRIP_Y = "flex w-max flex-col items-center";
|
|
86
|
+
var STRIP_GAP = {
|
|
87
|
+
sm: "gap-2",
|
|
88
|
+
md: "gap-3",
|
|
89
|
+
lg: "gap-4"
|
|
90
|
+
};
|
|
91
|
+
var STRIP_GAP_LINE = {
|
|
92
|
+
sm: "gap-1.5",
|
|
93
|
+
md: "gap-2",
|
|
94
|
+
lg: "gap-3"
|
|
95
|
+
};
|
|
96
|
+
var STRIP_FRAMED = "rounded-full bg-on-color backdrop-blur";
|
|
97
|
+
var STRIP_FRAMED_PAD = {
|
|
98
|
+
sm: "p-1.5",
|
|
99
|
+
md: "p-2",
|
|
100
|
+
lg: "p-3"
|
|
101
|
+
};
|
|
102
|
+
var STRIP_FRAMED_LINE_W = {
|
|
103
|
+
sm: "w-36",
|
|
104
|
+
md: "w-40",
|
|
105
|
+
lg: "w-44"
|
|
106
|
+
};
|
|
107
|
+
var STRIP_FRAMED_LINE_H = {
|
|
108
|
+
sm: "h-36",
|
|
109
|
+
md: "h-40",
|
|
110
|
+
lg: "h-44"
|
|
111
|
+
};
|
|
112
|
+
var PIP = "relative cursor-pointer rounded-full transition-colors duration-100 ease-linear after:absolute outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2";
|
|
113
|
+
var DOT_SIZE = {
|
|
114
|
+
sm: "size-1.5 after:-inset-x-2 after:-inset-y-2.5",
|
|
115
|
+
md: "size-2 after:-inset-x-1.5 after:-inset-y-2",
|
|
116
|
+
lg: "size-2.5 after:-inset-x-2 after:-inset-y-3"
|
|
117
|
+
};
|
|
118
|
+
var BAR_SIZE = {
|
|
119
|
+
sm: "h-1 flex-1 after:-inset-x-1 after:-inset-y-2.5",
|
|
120
|
+
md: "h-1.5 flex-1 after:-inset-x-1.5 after:-inset-y-2",
|
|
121
|
+
lg: "h-2 flex-1 after:-inset-x-2 after:-inset-y-3"
|
|
122
|
+
};
|
|
123
|
+
var BAR_SIZE_Y = {
|
|
124
|
+
sm: "w-1 flex-1 after:-inset-y-1 after:-inset-x-2.5",
|
|
125
|
+
md: "w-1.5 flex-1 after:-inset-y-1.5 after:-inset-x-2",
|
|
126
|
+
lg: "w-2 flex-1 after:-inset-y-2 after:-inset-x-3"
|
|
127
|
+
};
|
|
128
|
+
var PIP_IDLE = "bg-quaternary hover:bg-fg-quaternary_hover";
|
|
129
|
+
var PIP_ACTIVE = "bg-fg-brand-primary_alt";
|
|
130
|
+
var ARROW_CHIP = "flex shrink-0 cursor-pointer items-center justify-center rounded-full bg-on-color text-fg-secondary backdrop-blur-xs outline-focus-ring transition duration-100 ease-linear focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-50";
|
|
131
|
+
var ARROW_BOX = "flex shrink-0 cursor-pointer items-center justify-center rounded-full bg-primary text-fg-secondary shadow-skeuomorphic ring-1 ring-inset ring-primary outline-focus-ring transition duration-100 ease-linear hover:bg-secondary hover:text-fg-secondary_hover focus-visible:outline-2 focus-visible:outline-offset-2 disabled:pointer-events-none disabled:text-fg-disabled disabled:shadow-xs";
|
|
132
|
+
var ARROW_SIZE = {
|
|
133
|
+
sm: "size-8 [&>svg]:size-4",
|
|
134
|
+
md: "size-9 [&>svg]:size-5",
|
|
135
|
+
lg: "size-11 [&>svg]:size-6"
|
|
136
|
+
};
|
|
137
|
+
var ARROW_INSET = {
|
|
138
|
+
sm: "px-3",
|
|
139
|
+
md: "px-4",
|
|
140
|
+
lg: "px-5"
|
|
141
|
+
};
|
|
142
|
+
var ARROW_INSET_Y = {
|
|
143
|
+
sm: "py-3",
|
|
144
|
+
md: "py-4",
|
|
145
|
+
lg: "py-5"
|
|
146
|
+
};
|
|
147
|
+
var ARROW_GLYPH = "[&>svg]:shrink-0 [&>svg]:pointer-events-none";
|
|
148
|
+
|
|
149
|
+
// src/components/carousel/labels.ts
|
|
150
|
+
var CAROUSEL_LABELS = {
|
|
151
|
+
/** The region's `aria-roledescription`. A screen reader reads it after the name, so a site that
|
|
152
|
+
* ships a Thai UI says "แกลเลอรี" rather than the English word. */
|
|
153
|
+
roleDescription: "carousel",
|
|
154
|
+
/** Each slide's `aria-roledescription`. */
|
|
155
|
+
slideRoleDescription: "slide",
|
|
156
|
+
previous: "Previous slide",
|
|
157
|
+
next: "Next slide",
|
|
158
|
+
/**
|
|
159
|
+
* The live region's text, and each slide's fallback accessible name.
|
|
160
|
+
*
|
|
161
|
+
* `index` is 1-based and `total` is the slide count — both already decided by the component, which
|
|
162
|
+
* is what a ctx carries: formatted display values, never an engine index. A language that puts the
|
|
163
|
+
* total first overrides the whole function rather than fighting the word order.
|
|
164
|
+
*/
|
|
165
|
+
slideOf: (ctx) => `${ctx.index} of ${ctx.total}`,
|
|
166
|
+
/** Each indicator button, and each thumbnail. Deliberately not just "Slide 3" — the position is the
|
|
167
|
+
* whole information a dot carries, and "3" alone does not say how far there is to go. */
|
|
168
|
+
goToSlide: (ctx) => `Go to slide ${ctx.index} of ${ctx.total}`,
|
|
169
|
+
/**
|
|
170
|
+
* Each indicator button once one press moves SEVERAL slides — `slides.perView > 1` or `step > 1`.
|
|
171
|
+
*
|
|
172
|
+
* A second key rather than a re-numbered `goToSlide`, because the component now has two countable
|
|
173
|
+
* things and they do not agree: the pips count PAGES (four items three-per-view is two pages, and
|
|
174
|
+
* `containScroll: "trimSnaps"` is what drops the third), while the thumbnail strip stays one thumb
|
|
175
|
+
* per SLIDE — a picture of slide 3 is not a picture of page 2. `goToSlide` keeps the strip and every
|
|
176
|
+
* ungrouped carousel's pips, so the default English of a one-slide-per-view carousel is unchanged.
|
|
177
|
+
*/
|
|
178
|
+
goToPage: (ctx) => `Go to page ${ctx.index} of ${ctx.total}`,
|
|
179
|
+
/** The indicator strip's group name. */
|
|
180
|
+
slides: "Slides",
|
|
181
|
+
/** The thumbnail strip's group name. */
|
|
182
|
+
thumbnails: "Slide thumbnails",
|
|
183
|
+
/** The autoplay toggle, whose LABEL is the state (there is no `aria-pressed` — a toggle that
|
|
184
|
+
* changes both announces twice). */
|
|
185
|
+
pause: "Pause",
|
|
186
|
+
play: "Play",
|
|
187
|
+
/** Announced when the toggle is used. */
|
|
188
|
+
paused: "Autoplay paused",
|
|
189
|
+
playing: "Autoplay resumed"
|
|
190
|
+
};
|
|
191
|
+
var THUMB_ASPECT = {
|
|
192
|
+
square: "aspect-square",
|
|
193
|
+
video: "aspect-video",
|
|
194
|
+
banner: "aspect-[8/5]",
|
|
195
|
+
wide: "aspect-[21/9]",
|
|
196
|
+
portrait: "aspect-[3/4]"
|
|
197
|
+
};
|
|
198
|
+
var THUMB_GAP = { sm: "gap-1.5", md: "gap-2", lg: "gap-3" };
|
|
199
|
+
var THUMB = "relative shrink-0 grow-0 cursor-pointer overflow-hidden rounded-lg ring-2 ring-inset ring-transparent transition-[--tw-ring-color] duration-100 ease-linear outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2 [&_img]:size-full [&_img]:object-cover";
|
|
200
|
+
var THUMB_ACTIVE = "ring-brand";
|
|
201
|
+
function CarouselThumbnailStrip(props) {
|
|
202
|
+
const { items, activeIndex, perView, aspect, size, groupLabel, slideLabel, onSelect } = props;
|
|
203
|
+
const [viewportRef, engine] = default2(
|
|
204
|
+
toEngineOptions({
|
|
205
|
+
orientation: "horizontal",
|
|
206
|
+
align: "start",
|
|
207
|
+
loop: false,
|
|
208
|
+
/* Free drag, because a thumb strip is a scroller rather than a set of destinations — snapping
|
|
209
|
+
* it would fight the finger and would fight the auto-scroll below. */
|
|
210
|
+
drag: "free",
|
|
211
|
+
slides: { perView, step: 1 },
|
|
212
|
+
startIndex: activeIndex,
|
|
213
|
+
reducedMotion: false
|
|
214
|
+
})
|
|
215
|
+
);
|
|
216
|
+
const [api, setApi] = React3.useState(null);
|
|
217
|
+
React3.useEffect(() => setApi(engine ?? null), [engine]);
|
|
218
|
+
React3.useEffect(() => {
|
|
219
|
+
if (!api) return;
|
|
220
|
+
api.scrollTo(activeIndex);
|
|
221
|
+
}, [api, activeIndex]);
|
|
222
|
+
const basis = `${100 / perView}%`;
|
|
223
|
+
return /* @__PURE__ */ jsx("div", { ref: viewportRef, className: "mt-3 overflow-hidden", children: /* @__PURE__ */ jsx("div", { role: "group", "aria-label": groupLabel, className: cn("flex", THUMB_GAP[size]), style: { ["--carousel-thumb-basis"]: basis }, children: items.map((item, index) => /* @__PURE__ */ jsx(
|
|
224
|
+
"button",
|
|
225
|
+
{
|
|
226
|
+
type: "button",
|
|
227
|
+
"data-carousel-control": "",
|
|
228
|
+
"aria-label": slideLabel(index + 1),
|
|
229
|
+
"aria-current": index === activeIndex ? "true" : void 0,
|
|
230
|
+
onClick: () => onSelect(index),
|
|
231
|
+
className: cn(THUMB, THUMB_ASPECT[aspect], "basis-[var(--carousel-thumb-basis)]", index === activeIndex && THUMB_ACTIVE),
|
|
232
|
+
children: item.thumb
|
|
233
|
+
},
|
|
234
|
+
item.value
|
|
235
|
+
)) }) });
|
|
236
|
+
}
|
|
237
|
+
CarouselThumbnailStrip.displayName = "CarouselThumbnailStrip";
|
|
238
|
+
var ASPECT = {
|
|
239
|
+
square: "aspect-square",
|
|
240
|
+
video: "aspect-video",
|
|
241
|
+
/* 8/5 = 1.6, the frame Untitled UI's own carousel demos use (`aspect-[1.6]`). It is a demo frame
|
|
242
|
+
there rather than a named variant, so the NAME is ours; the ratio is theirs. */
|
|
243
|
+
banner: "aspect-[8/5]",
|
|
244
|
+
wide: "aspect-[21/9]",
|
|
245
|
+
portrait: "aspect-[3/4]"
|
|
246
|
+
};
|
|
247
|
+
var GAP_X = {
|
|
248
|
+
none: "",
|
|
249
|
+
sm: "-mx-1",
|
|
250
|
+
md: "-mx-2",
|
|
251
|
+
lg: "-mx-3"
|
|
252
|
+
};
|
|
253
|
+
var GAP_Y = {
|
|
254
|
+
none: "h-full",
|
|
255
|
+
sm: "-my-1 h-[calc(100%+0.5rem)]",
|
|
256
|
+
md: "-my-2 h-[calc(100%+1rem)]",
|
|
257
|
+
lg: "-my-3 h-[calc(100%+1.5rem)]"
|
|
258
|
+
};
|
|
259
|
+
var PAD_X = {
|
|
260
|
+
none: "",
|
|
261
|
+
sm: "px-1",
|
|
262
|
+
md: "px-2",
|
|
263
|
+
lg: "px-3"
|
|
264
|
+
};
|
|
265
|
+
var PAD_Y = {
|
|
266
|
+
none: "",
|
|
267
|
+
sm: "py-1",
|
|
268
|
+
md: "py-2",
|
|
269
|
+
lg: "py-3"
|
|
270
|
+
};
|
|
271
|
+
var SLIDE_BOX = "h-full overflow-hidden rounded-xl";
|
|
272
|
+
var STRIP_MARGIN = { sm: "mt-3", md: "mt-4", lg: "mt-5" };
|
|
273
|
+
var STRIP_MARGIN_X = { sm: "ml-3", md: "ml-4", lg: "ml-5" };
|
|
274
|
+
var OUTSIDE_PAD = { sm: "px-10", md: "px-12", lg: "px-14" };
|
|
275
|
+
var OUTSIDE_PAD_Y = { sm: "py-10", md: "py-12", lg: "py-14" };
|
|
276
|
+
var RAMP = 0.8;
|
|
277
|
+
var REST_EPSILON = 5e-3;
|
|
278
|
+
var PEEK_FACTOR = 0.88;
|
|
279
|
+
function resolveSlides(slides, effect) {
|
|
280
|
+
const o = slides === false || slides === void 0 ? {} : slides;
|
|
281
|
+
const fade = effect === "fade";
|
|
282
|
+
const perView = Math.max(1, Math.round(o.perView ?? 1));
|
|
283
|
+
return {
|
|
284
|
+
perView,
|
|
285
|
+
step: fade ? perView : Math.max(1, Math.round(o.step ?? perView)),
|
|
286
|
+
peek: fade ? false : o.peek ?? false,
|
|
287
|
+
gap: o.gap ?? "sm"
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function resolveAutoplay(autoplay) {
|
|
291
|
+
if (autoplay === false || autoplay === void 0) return null;
|
|
292
|
+
return {
|
|
293
|
+
delay: autoplay.delay ?? 5e3,
|
|
294
|
+
pauseOnHover: autoplay.pauseOnHover ?? true,
|
|
295
|
+
pauseOnFocus: autoplay.pauseOnFocus ?? true,
|
|
296
|
+
stopOnInteraction: autoplay.stopOnInteraction ?? false,
|
|
297
|
+
control: autoplay.control ?? "button"
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function resolveThumbnails(thumbnails) {
|
|
301
|
+
if (thumbnails === false || thumbnails === void 0) return null;
|
|
302
|
+
return { perView: Math.max(1, Math.round(thumbnails.perView ?? 6)), aspect: thumbnails.aspect ?? "video" };
|
|
303
|
+
}
|
|
304
|
+
function Carousel(props) {
|
|
305
|
+
const {
|
|
306
|
+
items,
|
|
307
|
+
value: valueProp,
|
|
308
|
+
defaultValue,
|
|
309
|
+
onValueChange,
|
|
310
|
+
arrows = "overlay",
|
|
311
|
+
indicator = "dot",
|
|
312
|
+
indicatorPlacement = "outside",
|
|
313
|
+
autoplay: autoplayProp,
|
|
314
|
+
slides: slidesProp,
|
|
315
|
+
thumbnails: thumbnailsProp,
|
|
316
|
+
orientation = "horizontal",
|
|
317
|
+
align = "start",
|
|
318
|
+
loop = false,
|
|
319
|
+
drag = "snap",
|
|
320
|
+
aspect = "auto",
|
|
321
|
+
effect = "none",
|
|
322
|
+
size = "md",
|
|
323
|
+
keepMounted = false,
|
|
324
|
+
onReachEnd,
|
|
325
|
+
labels,
|
|
326
|
+
className
|
|
327
|
+
} = props;
|
|
328
|
+
const t = useLabels("carousel", CAROUSEL_LABELS, labels);
|
|
329
|
+
const reducedMotion = useReducedMotion();
|
|
330
|
+
const slides = resolveSlides(slidesProp, effect);
|
|
331
|
+
const autoplay = resolveAutoplay(autoplayProp);
|
|
332
|
+
const thumbs = resolveThumbnails(thumbnailsProp);
|
|
333
|
+
const vertical = orientation === "vertical";
|
|
334
|
+
const total = items.length;
|
|
335
|
+
const firstValue = items[0]?.value;
|
|
336
|
+
const [value, setValueRaw] = useControllable(valueProp, defaultValue ?? firstValue, void 0);
|
|
337
|
+
const activeIndex = Math.max(
|
|
338
|
+
0,
|
|
339
|
+
items.findIndex((i) => i.value === value)
|
|
340
|
+
);
|
|
341
|
+
const reasonRef = React3.useRef(null);
|
|
342
|
+
const onValueChangeRef = React3.useRef(onValueChange);
|
|
343
|
+
onValueChangeRef.current = onValueChange;
|
|
344
|
+
const commit = React3.useCallback(
|
|
345
|
+
(next, reason) => {
|
|
346
|
+
setValueRaw(next);
|
|
347
|
+
onValueChangeRef.current?.(next, reason);
|
|
348
|
+
},
|
|
349
|
+
[setValueRaw]
|
|
350
|
+
);
|
|
351
|
+
const [api, setApi] = React3.useState(null);
|
|
352
|
+
const startIndexRef = React3.useRef(
|
|
353
|
+
estimateSnapForIndex({
|
|
354
|
+
index: activeIndex,
|
|
355
|
+
step: slides.step,
|
|
356
|
+
snapCount: estimateSnapCount({ total, perView: slides.perView, step: slides.step, loop })
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
const [viewportRef, engine] = default2(
|
|
360
|
+
toEngineOptions({
|
|
361
|
+
orientation,
|
|
362
|
+
align,
|
|
363
|
+
loop,
|
|
364
|
+
drag,
|
|
365
|
+
slides: { perView: slides.perView, step: slides.step },
|
|
366
|
+
startIndex: startIndexRef.current,
|
|
367
|
+
reducedMotion
|
|
368
|
+
}),
|
|
369
|
+
toEnginePlugins(effect)
|
|
370
|
+
);
|
|
371
|
+
React3.useEffect(() => setApi(engine ?? null), [engine]);
|
|
372
|
+
const itemsRef = React3.useRef(items);
|
|
373
|
+
itemsRef.current = items;
|
|
374
|
+
const activeIndexRef = React3.useRef(activeIndex);
|
|
375
|
+
activeIndexRef.current = activeIndex;
|
|
376
|
+
const perViewRef = React3.useRef(slides.perView);
|
|
377
|
+
perViewRef.current = slides.perView;
|
|
378
|
+
const commitRef = React3.useRef(commit);
|
|
379
|
+
commitRef.current = commit;
|
|
380
|
+
const [bounds, setBounds] = React3.useState({ prev: false, next: false });
|
|
381
|
+
const [snaps, setSnaps] = React3.useState(null);
|
|
382
|
+
React3.useEffect(() => {
|
|
383
|
+
if (!api) return;
|
|
384
|
+
const onSelect = () => {
|
|
385
|
+
const registry2 = readSnapRegistry(api);
|
|
386
|
+
const snap = api.selectedScrollSnap();
|
|
387
|
+
setBounds({ prev: api.canScrollPrev(), next: api.canScrollNext() });
|
|
388
|
+
const reason = reasonRef.current ?? "drag";
|
|
389
|
+
reasonRef.current = null;
|
|
390
|
+
if (snapForIndex(registry2, activeIndexRef.current) === snap) return;
|
|
391
|
+
const next = itemsRef.current[indexForSnap(registry2, snap)];
|
|
392
|
+
if (!next) return;
|
|
393
|
+
commitRef.current(next.value, reason);
|
|
394
|
+
};
|
|
395
|
+
const onReInit = () => {
|
|
396
|
+
setBounds({ prev: api.canScrollPrev(), next: api.canScrollNext() });
|
|
397
|
+
setSnaps({ count: api.scrollSnapList().length, registry: readSnapRegistry(api) });
|
|
398
|
+
};
|
|
399
|
+
onReInit();
|
|
400
|
+
api.on("select", onSelect).on("reInit", onReInit);
|
|
401
|
+
return () => {
|
|
402
|
+
api.off("select", onSelect).off("reInit", onReInit);
|
|
403
|
+
};
|
|
404
|
+
}, [api]);
|
|
405
|
+
const registry = snaps?.registry ?? identitySnapRegistry(total);
|
|
406
|
+
const snapCount = snaps?.count ?? estimateSnapCount({ total, perView: slides.perView, step: slides.step, loop });
|
|
407
|
+
const activeSnap = Math.min(snapForIndex(registry, activeIndex), Math.max(0, snapCount - 1));
|
|
408
|
+
React3.useEffect(() => {
|
|
409
|
+
if (!api) return;
|
|
410
|
+
const target = snapForIndex(readSnapRegistry(api), activeIndex);
|
|
411
|
+
if (api.selectedScrollSnap() === target) return;
|
|
412
|
+
reasonRef.current ??= "api";
|
|
413
|
+
api.scrollTo(target);
|
|
414
|
+
}, [api, activeIndex]);
|
|
415
|
+
const [inView, setInView] = React3.useState([0]);
|
|
416
|
+
const seenRef = React3.useRef(/* @__PURE__ */ new Set([0]));
|
|
417
|
+
const [, forceSeen] = React3.useReducer((n) => n + 1, 0);
|
|
418
|
+
React3.useEffect(() => {
|
|
419
|
+
if (!api) return;
|
|
420
|
+
const read = () => {
|
|
421
|
+
const reported = api.slidesInView();
|
|
422
|
+
const derived = visibleIndexes({
|
|
423
|
+
registry: readSnapRegistry(api),
|
|
424
|
+
snap: api.selectedScrollSnap(),
|
|
425
|
+
perView: perViewRef.current,
|
|
426
|
+
total: itemsRef.current.length,
|
|
427
|
+
loop
|
|
428
|
+
});
|
|
429
|
+
const visible = reported.length > 0 ? reported : derived;
|
|
430
|
+
setInView(visible);
|
|
431
|
+
let grew = false;
|
|
432
|
+
const withBuffer = visible.flatMap((index) => [index - 1, index, index + 1]);
|
|
433
|
+
for (const near of withBuffer) {
|
|
434
|
+
if (near < 0 || seenRef.current.has(near)) continue;
|
|
435
|
+
seenRef.current.add(near);
|
|
436
|
+
grew = true;
|
|
437
|
+
}
|
|
438
|
+
if (grew) forceSeen();
|
|
439
|
+
};
|
|
440
|
+
read();
|
|
441
|
+
api.on("slidesInView", read).on("reInit", read).on("select", read);
|
|
442
|
+
return () => {
|
|
443
|
+
api.off("slidesInView", read).off("reInit", read).off("select", read);
|
|
444
|
+
};
|
|
445
|
+
}, [api, loop]);
|
|
446
|
+
const onReachEndRef = React3.useRef(onReachEnd);
|
|
447
|
+
onReachEndRef.current = onReachEnd;
|
|
448
|
+
const reachedRef = React3.useRef(-1);
|
|
449
|
+
React3.useEffect(() => {
|
|
450
|
+
if (!onReachEndRef.current || total === 0) return;
|
|
451
|
+
if (!inView.includes(total - 1)) return;
|
|
452
|
+
if (reachedRef.current === total) return;
|
|
453
|
+
reachedRef.current = total;
|
|
454
|
+
onReachEndRef.current();
|
|
455
|
+
}, [inView, total]);
|
|
456
|
+
const [wanted, setWanted] = React3.useState(false);
|
|
457
|
+
const [hovered, setHovered] = React3.useState(false);
|
|
458
|
+
const [focused, setFocused] = React3.useState(false);
|
|
459
|
+
const [hidden, setHidden] = React3.useState(false);
|
|
460
|
+
useIsomorphicLayoutEffect(() => {
|
|
461
|
+
setWanted(autoplay !== null && !reducedMotion);
|
|
462
|
+
}, [autoplay !== null, reducedMotion]);
|
|
463
|
+
React3.useEffect(() => {
|
|
464
|
+
if (typeof document === "undefined") return;
|
|
465
|
+
const onVisibility = () => setHidden(document.visibilityState === "hidden");
|
|
466
|
+
onVisibility();
|
|
467
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
468
|
+
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
469
|
+
}, []);
|
|
470
|
+
const suspended = autoplay?.pauseOnHover !== false && hovered || autoplay?.pauseOnFocus !== false && focused || hidden;
|
|
471
|
+
const playing = autoplay !== null && wanted && !suspended && !reducedMotion;
|
|
472
|
+
React3.useEffect(() => {
|
|
473
|
+
if (!api || !playing || !autoplay || total < 2) return;
|
|
474
|
+
const id = globalThis.setTimeout(() => {
|
|
475
|
+
reasonRef.current = "autoplay";
|
|
476
|
+
if (api.canScrollNext()) api.scrollNext();
|
|
477
|
+
else api.scrollTo(0);
|
|
478
|
+
}, autoplay.delay);
|
|
479
|
+
return () => globalThis.clearTimeout(id);
|
|
480
|
+
}, [api, playing, autoplay?.delay, activeIndex, total]);
|
|
481
|
+
const [autoHeight, setAutoHeight] = React3.useState(null);
|
|
482
|
+
useIsomorphicLayoutEffect(() => {
|
|
483
|
+
if (!api || aspect !== "auto") return;
|
|
484
|
+
const nodes = api.slideNodes();
|
|
485
|
+
const node = nodes[activeIndex];
|
|
486
|
+
if (!node || typeof ResizeObserver === "undefined") return;
|
|
487
|
+
let frame = 0;
|
|
488
|
+
const measure = () => {
|
|
489
|
+
cancelAnimationFrame(frame);
|
|
490
|
+
frame = requestAnimationFrame(() => setAutoHeight(node.offsetHeight));
|
|
491
|
+
};
|
|
492
|
+
measure();
|
|
493
|
+
const ro = new ResizeObserver(measure);
|
|
494
|
+
ro.observe(node);
|
|
495
|
+
return () => {
|
|
496
|
+
cancelAnimationFrame(frame);
|
|
497
|
+
ro.disconnect();
|
|
498
|
+
};
|
|
499
|
+
}, [api, aspect, activeIndex, inView]);
|
|
500
|
+
const perView = slides.perView;
|
|
501
|
+
React3.useEffect(() => {
|
|
502
|
+
if (!api || effect !== "fade" || perView < 2 || loop) return;
|
|
503
|
+
let windows = [];
|
|
504
|
+
let offsets = [];
|
|
505
|
+
let natural = [];
|
|
506
|
+
let boxes = [];
|
|
507
|
+
const axis = vertical ? "Y" : "X";
|
|
508
|
+
const root = api.rootNode();
|
|
509
|
+
const layer = document.createElement("div");
|
|
510
|
+
layer.dataset.carousel = "fade-layer";
|
|
511
|
+
layer.setAttribute("aria-hidden", "true");
|
|
512
|
+
layer.setAttribute("inert", "");
|
|
513
|
+
layer.style.cssText = "position:absolute;inset:0;pointer-events:none;";
|
|
514
|
+
const ghosts = /* @__PURE__ */ new Map();
|
|
515
|
+
let pair = "";
|
|
516
|
+
const clearGhosts = () => {
|
|
517
|
+
for (const ghost of ghosts.values()) ghost.remove();
|
|
518
|
+
ghosts.clear();
|
|
519
|
+
layer.remove();
|
|
520
|
+
pair = "";
|
|
521
|
+
};
|
|
522
|
+
const measure = () => {
|
|
523
|
+
const registry2 = readSnapRegistry(api);
|
|
524
|
+
const nodes = api.slideNodes();
|
|
525
|
+
const total2 = nodes.length;
|
|
526
|
+
boxes = nodes.map((node) => {
|
|
527
|
+
const rect = node.getBoundingClientRect();
|
|
528
|
+
return vertical ? { main: rect.height, cross: rect.width } : { main: rect.width, cross: rect.height };
|
|
529
|
+
});
|
|
530
|
+
natural = boxes.map((_, index) => boxes.slice(0, index).reduce((sum, box) => sum + box.main, 0));
|
|
531
|
+
windows = api.scrollSnapList().map((_, snap) => new Set(visibleIndexes({ registry: registry2, snap, perView, total: total2, loop: false })));
|
|
532
|
+
offsets = windows.map((shown) => -(natural[[...shown][0] ?? 0] ?? 0));
|
|
533
|
+
};
|
|
534
|
+
const buildGhost = (index, snap) => {
|
|
535
|
+
const source = api.slideNodes()[index];
|
|
536
|
+
const box = boxes[index];
|
|
537
|
+
if (!source || !box) return null;
|
|
538
|
+
const ghost = source.cloneNode(true);
|
|
539
|
+
ghost.dataset.carousel = "slide-ghost";
|
|
540
|
+
for (const name of ["role", "aria-roledescription", "aria-label", "inert", "id"]) ghost.removeAttribute(name);
|
|
541
|
+
for (const owner of ghost.querySelectorAll("[id]")) owner.removeAttribute("id");
|
|
542
|
+
const sources = source.querySelectorAll("canvas");
|
|
543
|
+
for (const [i, canvas] of [...ghost.querySelectorAll("canvas")].entries()) {
|
|
544
|
+
const original = sources[i];
|
|
545
|
+
if (!original || original.width === 0 || original.height === 0) continue;
|
|
546
|
+
try {
|
|
547
|
+
canvas.getContext("2d")?.drawImage(original, 0, 0);
|
|
548
|
+
} catch {
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const position = (natural[index] ?? 0) + (offsets[snap] ?? 0);
|
|
552
|
+
ghost.style.position = "absolute";
|
|
553
|
+
ghost.style.left = "0";
|
|
554
|
+
ghost.style.top = "0";
|
|
555
|
+
ghost.style.width = `${vertical ? box.cross : box.main}px`;
|
|
556
|
+
ghost.style.height = `${vertical ? box.main : box.cross}px`;
|
|
557
|
+
ghost.style.transform = `translate${axis}(${Math.round(position * 100) / 100}px)`;
|
|
558
|
+
ghost.style.opacity = "0";
|
|
559
|
+
ghost.style.mixBlendMode = "plus-lighter";
|
|
560
|
+
ghost.style.pointerEvents = "none";
|
|
561
|
+
return ghost;
|
|
562
|
+
};
|
|
563
|
+
const write = (node, opacity, offset, additive) => {
|
|
564
|
+
node.style.opacity = String(Math.round(opacity * 100) / 100);
|
|
565
|
+
node.style.transform = `translate${axis}(${Math.round(offset * 100) / 100}px)`;
|
|
566
|
+
node.style.pointerEvents = opacity > 0.5 ? "auto" : "none";
|
|
567
|
+
node.style.mixBlendMode = additive ? "plus-lighter" : "";
|
|
568
|
+
};
|
|
569
|
+
const paint = () => {
|
|
570
|
+
const pages = windows.length;
|
|
571
|
+
if (pages === 0) return;
|
|
572
|
+
const at = Math.min(Math.max(api.scrollProgress() * Math.max(1, pages - 1), 0), pages - 1);
|
|
573
|
+
const from = Math.floor(at);
|
|
574
|
+
const to = Math.min(from + 1, pages - 1);
|
|
575
|
+
const raw = at - from;
|
|
576
|
+
const ratio = raw < REST_EPSILON ? 0 : raw > 1 - REST_EPSILON ? 1 : raw;
|
|
577
|
+
const turning = ratio > 0 && ratio < 1;
|
|
578
|
+
const settledOn = ratio === 1 ? to : from;
|
|
579
|
+
if (!turning) clearGhosts();
|
|
580
|
+
else {
|
|
581
|
+
const key = `${from}>${to}`;
|
|
582
|
+
if (key !== pair) {
|
|
583
|
+
clearGhosts();
|
|
584
|
+
pair = key;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
root.style.isolation = turning ? "isolate" : "";
|
|
588
|
+
for (const [index, node] of api.slideNodes().entries()) {
|
|
589
|
+
if (!turning) node.style.mixBlendMode = "";
|
|
590
|
+
const leaving = windows[from]?.has(index) ?? false;
|
|
591
|
+
const arriving = windows[to]?.has(index) ?? false;
|
|
592
|
+
if (!leaving && !arriving) continue;
|
|
593
|
+
if (!turning) {
|
|
594
|
+
const shown = windows[settledOn]?.has(index) ?? false;
|
|
595
|
+
write(node, shown ? 1 : 0, offsets[shown ? settledOn : leaving ? from : to] ?? 0, false);
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
if (leaving && arriving) {
|
|
599
|
+
let ghost = ghosts.get(index);
|
|
600
|
+
if (!ghost) {
|
|
601
|
+
ghost = buildGhost(index, to) ?? void 0;
|
|
602
|
+
if (ghost) {
|
|
603
|
+
ghosts.set(index, ghost);
|
|
604
|
+
if (!layer.isConnected) root.append(layer);
|
|
605
|
+
layer.append(ghost);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (ghost) ghost.style.opacity = String(Math.round(ratio * 100) / 100);
|
|
609
|
+
}
|
|
610
|
+
write(node, leaving ? 1 - ratio : ratio, offsets[leaving ? from : to] ?? 0, true);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
const relayout = () => {
|
|
614
|
+
clearGhosts();
|
|
615
|
+
measure();
|
|
616
|
+
paint();
|
|
617
|
+
};
|
|
618
|
+
relayout();
|
|
619
|
+
api.on("scroll", paint).on("select", paint).on("settle", paint).on("reInit", relayout);
|
|
620
|
+
return () => {
|
|
621
|
+
api.off("scroll", paint).off("select", paint).off("settle", paint).off("reInit", relayout);
|
|
622
|
+
clearGhosts();
|
|
623
|
+
root.style.isolation = "";
|
|
624
|
+
for (const node of api.slideNodes()) {
|
|
625
|
+
node.style.opacity = "";
|
|
626
|
+
node.style.transform = "";
|
|
627
|
+
node.style.pointerEvents = "";
|
|
628
|
+
node.style.mixBlendMode = "";
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
}, [api, effect, loop, perView, vertical]);
|
|
632
|
+
React3.useEffect(() => {
|
|
633
|
+
if (!api || effect !== "scale") return;
|
|
634
|
+
let arcs = [];
|
|
635
|
+
let rate = 1;
|
|
636
|
+
const measure = () => {
|
|
637
|
+
const snaps2 = api.scrollSnapList();
|
|
638
|
+
const registry2 = readSnapRegistry(api);
|
|
639
|
+
const total2 = api.slideNodes().length;
|
|
640
|
+
rate = Math.max(1, snaps2.length - 1) / RAMP;
|
|
641
|
+
const showing = Array.from({ length: total2 }, () => []);
|
|
642
|
+
for (const [snap, at] of snaps2.entries()) {
|
|
643
|
+
const shown = visibleIndexes({ registry: registry2, snap, perView, total: total2, loop });
|
|
644
|
+
for (const index of shown) showing[index]?.push(at);
|
|
645
|
+
}
|
|
646
|
+
arcs = showing.map((pages, index) => {
|
|
647
|
+
const at = pages.length > 0 ? [...pages].sort((a, b) => a - b) : [snaps2[snapForIndex(registry2, index)] ?? 0];
|
|
648
|
+
const first = at[0] ?? 0;
|
|
649
|
+
const last = at.at(-1) ?? first;
|
|
650
|
+
if (!loop) return [first, last - first];
|
|
651
|
+
if (at.length >= snaps2.length) return [0, 1];
|
|
652
|
+
let gapAt = 0;
|
|
653
|
+
let widest = first + 1 - last;
|
|
654
|
+
for (const [i, value2] of at.entries()) {
|
|
655
|
+
const previous = at[i - 1];
|
|
656
|
+
if (previous !== void 0 && value2 - previous > widest) {
|
|
657
|
+
widest = value2 - previous;
|
|
658
|
+
gapAt = i;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
const from = at[gapAt] ?? first;
|
|
662
|
+
return [from, 1 - widest];
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
const paint = () => {
|
|
666
|
+
const progress = api.scrollProgress();
|
|
667
|
+
for (const [index, node] of api.slideNodes().entries()) {
|
|
668
|
+
const [from, span] = arcs[index] ?? [0, 0];
|
|
669
|
+
const r = loop ? progress - from - Math.floor(progress - from) : progress - from;
|
|
670
|
+
let delta = 0;
|
|
671
|
+
if (r < 0) delta = -r;
|
|
672
|
+
else if (r > span) delta = loop ? Math.min(r - span, 1 - r) : r - span;
|
|
673
|
+
const distance = Math.min(1, delta * rate);
|
|
674
|
+
node.style.setProperty("--carousel-scale", String(1 - distance * 0.08));
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
const relayout = () => {
|
|
678
|
+
measure();
|
|
679
|
+
paint();
|
|
680
|
+
};
|
|
681
|
+
relayout();
|
|
682
|
+
api.on("scroll", paint).on("select", paint).on("reInit", relayout);
|
|
683
|
+
return () => {
|
|
684
|
+
api.off("scroll", paint).off("select", paint).off("reInit", relayout);
|
|
685
|
+
};
|
|
686
|
+
}, [api, effect, loop, perView]);
|
|
687
|
+
const rootRef = React3.useRef(null);
|
|
688
|
+
const viewportElRef = React3.useRef(null);
|
|
689
|
+
const setViewport = React3.useCallback(
|
|
690
|
+
(node) => {
|
|
691
|
+
viewportElRef.current = node;
|
|
692
|
+
viewportRef(node);
|
|
693
|
+
},
|
|
694
|
+
[viewportRef]
|
|
695
|
+
);
|
|
696
|
+
const step = React3.useCallback(
|
|
697
|
+
(direction, reason) => {
|
|
698
|
+
if (!api) return;
|
|
699
|
+
reasonRef.current = reason;
|
|
700
|
+
if (direction === 1) api.scrollNext();
|
|
701
|
+
else api.scrollPrev();
|
|
702
|
+
if (autoplay?.stopOnInteraction) setWanted(false);
|
|
703
|
+
},
|
|
704
|
+
[api, autoplay?.stopOnInteraction]
|
|
705
|
+
);
|
|
706
|
+
const onKeyDown = (event) => {
|
|
707
|
+
const target = event.target;
|
|
708
|
+
if (!target) return;
|
|
709
|
+
const owned = target === viewportElRef.current || target.closest("[data-carousel-control]") !== null;
|
|
710
|
+
if (!owned) return;
|
|
711
|
+
const prevKey = vertical ? "ArrowUp" : "ArrowLeft";
|
|
712
|
+
const nextKey = vertical ? "ArrowDown" : "ArrowRight";
|
|
713
|
+
switch (event.key) {
|
|
714
|
+
case prevKey: {
|
|
715
|
+
event.preventDefault();
|
|
716
|
+
step(-1, "keyboard");
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
case nextKey: {
|
|
720
|
+
event.preventDefault();
|
|
721
|
+
step(1, "keyboard");
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
case "Home": {
|
|
725
|
+
event.preventDefault();
|
|
726
|
+
reasonRef.current = "keyboard";
|
|
727
|
+
api?.scrollTo(0);
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
case "End": {
|
|
731
|
+
event.preventDefault();
|
|
732
|
+
reasonRef.current = "keyboard";
|
|
733
|
+
api?.scrollTo(snapCount - 1);
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
const hasName = Boolean(props["aria-label"] ?? props["aria-labelledby"]);
|
|
739
|
+
warnNeedsName("Carousel", hasName, "`aria-label` or `aria-labelledby`");
|
|
740
|
+
warnPositiveInt("Carousel", "slides.perView", slidesProp === false ? void 0 : slidesProp?.perView);
|
|
741
|
+
warnPositiveInt("Carousel", "slides.step", slidesProp === false ? void 0 : slidesProp?.step);
|
|
742
|
+
warnPositiveInt("Carousel", "thumbnails.perView", thumbnailsProp === false ? void 0 : thumbnailsProp?.perView);
|
|
743
|
+
if (process.env.NODE_ENV !== "production") {
|
|
744
|
+
const asked = slidesProp === false || slidesProp === void 0 ? null : slidesProp;
|
|
745
|
+
if (effect === "fade" && asked !== null && (asked.peek === true || asked.step !== void 0 && Math.round(asked.step) !== slides.perView)) {
|
|
746
|
+
devWarn(
|
|
747
|
+
'Carousel: `effect="fade"` cross-fades a whole PAGE, so a page must be whole \u2014 `slides.step` is pinned to `slides.perView` and `slides.peek` is ignored. A rail itself is fine.'
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
if (effect === "fade" && loop && slides.perView > 1 && total % slides.perView !== 0) {
|
|
751
|
+
devWarn(
|
|
752
|
+
'Carousel: `effect="fade"` with `loop` and `slides.perView > 1` shows a PARTIAL last page when `items.length` is not a multiple of `slides.perView` \u2014 the wrapped window is the plugin\'s to paint, not ours. Drop `loop`, or make the count divide.'
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
if (autoplay && autoplay.control === "none") {
|
|
756
|
+
devWarn(
|
|
757
|
+
'Carousel: `autoplay.control="none"` removes the pause button. WCAG 2.2.2 requires a pause mechanism for content that moves for more than 5s, so render your own \u2014 hover and focus pausing do not discharge it.'
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
if (thumbs && items.every((i) => i.thumb === void 0)) {
|
|
761
|
+
devWarn("Carousel: `thumbnails` is set but no item carries a `thumb`, so the strip renders nothing.");
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (total === 0) return null;
|
|
765
|
+
const single = snapCount <= 1;
|
|
766
|
+
const showArrows = arrows !== "none" && !single;
|
|
767
|
+
const showIndicator = indicator !== "none" && !single;
|
|
768
|
+
const grouped = snapCount !== total;
|
|
769
|
+
const canPrev = api ? bounds.prev : loop || activeSnap > 0;
|
|
770
|
+
const canNext = api ? bounds.next : loop || activeSnap < snapCount - 1;
|
|
771
|
+
const basis = `${100 / slides.perView * (slides.peek ? PEEK_FACTOR : 1)}%`;
|
|
772
|
+
const PrevIcon = vertical ? ChevronUpIcon : ChevronLeftIcon;
|
|
773
|
+
const NextIcon = vertical ? ChevronDownIcon : ChevronRightIcon;
|
|
774
|
+
const overlayIndicator = indicatorPlacement === "overlay";
|
|
775
|
+
const railed = vertical && overlayIndicator;
|
|
776
|
+
const onMedia = arrows === "overlay";
|
|
777
|
+
const arrowBox = onMedia ? ARROW_CHIP : ARROW_BOX;
|
|
778
|
+
const arrowButton = (direction) => {
|
|
779
|
+
const isNext = direction === 1;
|
|
780
|
+
return /* @__PURE__ */ jsx(
|
|
781
|
+
"button",
|
|
782
|
+
{
|
|
783
|
+
type: "button",
|
|
784
|
+
"data-carousel-control": "",
|
|
785
|
+
"aria-label": isNext ? t.next : t.previous,
|
|
786
|
+
disabled: isNext ? !canNext : !canPrev,
|
|
787
|
+
onClick: () => step(direction, "arrow"),
|
|
788
|
+
className: cn(arrowBox, ARROW_SIZE[size], ARROW_GLYPH),
|
|
789
|
+
children: isNext ? /* @__PURE__ */ jsx(NextIcon, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(PrevIcon, { "aria-hidden": "true" })
|
|
790
|
+
}
|
|
791
|
+
);
|
|
792
|
+
};
|
|
793
|
+
const indicatorStrip = /* @__PURE__ */ jsx(
|
|
794
|
+
"div",
|
|
795
|
+
{
|
|
796
|
+
role: "group",
|
|
797
|
+
"aria-label": t.slides,
|
|
798
|
+
className: cn(
|
|
799
|
+
/* The strip mirrors the axis it reports on, at BOTH placements — a dot row read left to right
|
|
800
|
+
under a track that travels top to bottom describes the wrong journey, and `line`'s bars are
|
|
801
|
+
worse than wrong: a bar NAMES the axis it divides, so horizontal ones under a vertical
|
|
802
|
+
carousel divide a width nothing scrolls along. Where the column then SITS is
|
|
803
|
+
`indicatorPlacement`'s business and nothing else's. */
|
|
804
|
+
vertical ? STRIP_Y : STRIP,
|
|
805
|
+
indicator === "line" ? STRIP_GAP_LINE[size] : STRIP_GAP[size],
|
|
806
|
+
/* A bar strip divides its host evenly, so BELOW it takes the media's full width. Framed it
|
|
807
|
+
must not: `w-full` made the pill paint edge-to-edge and `line + overlay` read as `line +
|
|
808
|
+
below`. Bounded, it floats — which is UUI's construction and the fix for the defect the
|
|
809
|
+
owner reported. */
|
|
810
|
+
indicator === "line" && (vertical ? overlayIndicator ? STRIP_FRAMED_LINE_H[size] : "h-full" : overlayIndicator ? STRIP_FRAMED_LINE_W[size] : "w-full"),
|
|
811
|
+
overlayIndicator && [STRIP_FRAMED, STRIP_FRAMED_PAD[size]]
|
|
812
|
+
),
|
|
813
|
+
children: Array.from({ length: snapCount }, (_, snap) => {
|
|
814
|
+
const lead = indexForSnap(registry, snap);
|
|
815
|
+
return /* @__PURE__ */ jsx(
|
|
816
|
+
"button",
|
|
817
|
+
{
|
|
818
|
+
type: "button",
|
|
819
|
+
"data-carousel-control": "",
|
|
820
|
+
"aria-label": grouped ? t.goToPage({ index: snap + 1, total: snapCount }) : t.goToSlide({ index: snap + 1, total }),
|
|
821
|
+
"aria-current": snap === activeSnap ? "true" : void 0,
|
|
822
|
+
onClick: () => {
|
|
823
|
+
reasonRef.current = "indicator";
|
|
824
|
+
api?.scrollTo(snap);
|
|
825
|
+
if (autoplay?.stopOnInteraction) setWanted(false);
|
|
826
|
+
},
|
|
827
|
+
className: cn(
|
|
828
|
+
PIP,
|
|
829
|
+
indicator === "line" ? vertical ? BAR_SIZE_Y[size] : BAR_SIZE[size] : DOT_SIZE[size],
|
|
830
|
+
snap === activeSnap ? PIP_ACTIVE : PIP_IDLE
|
|
831
|
+
)
|
|
832
|
+
},
|
|
833
|
+
items[lead]?.value ?? snap
|
|
834
|
+
);
|
|
835
|
+
})
|
|
836
|
+
}
|
|
837
|
+
);
|
|
838
|
+
const floatingArrows = showArrows && (arrows === "overlay" || arrows === "outside");
|
|
839
|
+
const inlineArrows = showArrows && arrows === "below";
|
|
840
|
+
const footerRow = inlineArrows || showIndicator && !overlayIndicator;
|
|
841
|
+
const pager = footerRow ? /* @__PURE__ */ jsxs("div", { className: cn("flex justify-center gap-4", vertical ? ["flex-col items-center", STRIP_MARGIN_X[size]] : ["items-center", STRIP_MARGIN[size]]), children: [
|
|
842
|
+
inlineArrows && arrowButton(-1),
|
|
843
|
+
showIndicator && !overlayIndicator && indicatorStrip,
|
|
844
|
+
inlineArrows && arrowButton(1)
|
|
845
|
+
] }) : null;
|
|
846
|
+
const sideBySide = vertical && pager !== null;
|
|
847
|
+
return /* @__PURE__ */ jsxs(
|
|
848
|
+
"section",
|
|
849
|
+
{
|
|
850
|
+
ref: rootRef,
|
|
851
|
+
"aria-roledescription": t.roleDescription,
|
|
852
|
+
"aria-label": props["aria-label"],
|
|
853
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
854
|
+
onKeyDown,
|
|
855
|
+
onPointerEnter: () => setHovered(true),
|
|
856
|
+
onPointerLeave: () => setHovered(false),
|
|
857
|
+
onFocus: () => setFocused(true),
|
|
858
|
+
onBlur: (event) => {
|
|
859
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);
|
|
860
|
+
},
|
|
861
|
+
className: cn("relative w-full", className),
|
|
862
|
+
children: [
|
|
863
|
+
/* @__PURE__ */ jsx("div", { "aria-live": playing ? "off" : "polite", "aria-atomic": "true", className: "sr-only", children: t.slideOf({ index: activeIndex + 1, total }) }),
|
|
864
|
+
/* @__PURE__ */ jsxs("div", { className: cn(sideBySide && "flex items-stretch"), children: [
|
|
865
|
+
/* @__PURE__ */ jsxs(
|
|
866
|
+
"div",
|
|
867
|
+
{
|
|
868
|
+
className: cn("relative", sideBySide && "min-w-0 flex-1", arrows === "outside" && !single && (vertical ? OUTSIDE_PAD_Y[size] : OUTSIDE_PAD[size])),
|
|
869
|
+
children: [
|
|
870
|
+
floatingArrows && /* @__PURE__ */ jsxs(
|
|
871
|
+
"div",
|
|
872
|
+
{
|
|
873
|
+
className: cn(
|
|
874
|
+
"pointer-events-none absolute inset-0 z-1 flex items-center justify-between [&>*]:pointer-events-auto",
|
|
875
|
+
vertical && "flex-col",
|
|
876
|
+
arrows === "overlay" && (vertical ? ARROW_INSET_Y[size] : ARROW_INSET[size])
|
|
877
|
+
),
|
|
878
|
+
children: [
|
|
879
|
+
arrowButton(-1),
|
|
880
|
+
arrowButton(1)
|
|
881
|
+
]
|
|
882
|
+
}
|
|
883
|
+
),
|
|
884
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
885
|
+
autoplay?.control === "button" && /* @__PURE__ */ jsx(
|
|
886
|
+
"button",
|
|
887
|
+
{
|
|
888
|
+
type: "button",
|
|
889
|
+
"data-carousel-control": "",
|
|
890
|
+
"aria-label": playing ? t.pause : t.play,
|
|
891
|
+
onClick: () => setWanted((w) => !w),
|
|
892
|
+
className: cn(arrowBox, ARROW_SIZE[size], ARROW_GLYPH, "absolute top-3 right-3 z-2"),
|
|
893
|
+
children: playing ? /* @__PURE__ */ jsx(PauseIcon, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(PlayIcon, { "aria-hidden": "true" })
|
|
894
|
+
}
|
|
895
|
+
),
|
|
896
|
+
/* @__PURE__ */ jsx(
|
|
897
|
+
"div",
|
|
898
|
+
{
|
|
899
|
+
ref: setViewport,
|
|
900
|
+
"data-carousel": "viewport",
|
|
901
|
+
tabIndex: 0,
|
|
902
|
+
className: cn(
|
|
903
|
+
/* `overflow-hidden` only — the CORNER lives on the slide BOX now. Untitled UI rounds each
|
|
904
|
+
`Carousel.Item`, not the window: with a gap between slides that is the difference
|
|
905
|
+
between four rounded cards and one rounded window full of square ones.
|
|
906
|
+
|
|
907
|
+
`relative` is not layout: it is the containing block a fading rail's stand-in overlay
|
|
908
|
+
(§ effect: "fade") is positioned against, and the group `plus-lighter` adds into. With
|
|
909
|
+
no offsets of its own and no `z-index`, it creates no stacking context, so the arrows
|
|
910
|
+
and the indicator — siblings OUTSIDE this box, at `z-1`/`z-2` — still paint over it. */
|
|
911
|
+
"relative overflow-hidden outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
912
|
+
vertical ? "touch-pan-x" : "touch-pan-y",
|
|
913
|
+
aspect !== "auto" && ASPECT[aspect]
|
|
914
|
+
),
|
|
915
|
+
style: aspect === "auto" && autoHeight !== null ? { height: autoHeight } : void 0,
|
|
916
|
+
children: /* @__PURE__ */ jsx(
|
|
917
|
+
"div",
|
|
918
|
+
{
|
|
919
|
+
"data-carousel": "container",
|
|
920
|
+
className: cn("flex", vertical ? ["flex-col", GAP_Y[slides.gap]] : ["h-full", GAP_X[slides.gap]], aspect === "auto" && "items-start"),
|
|
921
|
+
style: { ["--carousel-basis"]: basis },
|
|
922
|
+
children: items.map((item, index) => {
|
|
923
|
+
const mounted = keepMounted || item.keepMounted || seenRef.current.has(index);
|
|
924
|
+
const visible = inView.includes(index);
|
|
925
|
+
return /* @__PURE__ */ jsx(
|
|
926
|
+
"div",
|
|
927
|
+
{
|
|
928
|
+
"data-carousel": "slide",
|
|
929
|
+
role: "group",
|
|
930
|
+
"aria-roledescription": t.slideRoleDescription,
|
|
931
|
+
"aria-label": item.ariaLabel ?? t.slideOf({ index: index + 1, total }),
|
|
932
|
+
inert: !visible ? true : void 0,
|
|
933
|
+
className: cn(
|
|
934
|
+
"min-h-0 min-w-0 shrink-0 grow-0 basis-[var(--carousel-basis)]",
|
|
935
|
+
vertical ? PAD_Y[slides.gap] : PAD_X[slides.gap],
|
|
936
|
+
item.className
|
|
937
|
+
),
|
|
938
|
+
children: /* @__PURE__ */ jsx(
|
|
939
|
+
"div",
|
|
940
|
+
{
|
|
941
|
+
"data-carousel": "slide-box",
|
|
942
|
+
className: cn(SLIDE_BOX, effect === "scale" && "scale-[var(--carousel-scale,1)] transition-transform duration-100 ease-linear"),
|
|
943
|
+
children: mounted ? typeof item.content === "function" ? item.content() : item.content : null
|
|
944
|
+
}
|
|
945
|
+
)
|
|
946
|
+
},
|
|
947
|
+
item.value
|
|
948
|
+
);
|
|
949
|
+
})
|
|
950
|
+
}
|
|
951
|
+
)
|
|
952
|
+
}
|
|
953
|
+
),
|
|
954
|
+
showIndicator && overlayIndicator && /* @__PURE__ */ jsx(
|
|
955
|
+
"div",
|
|
956
|
+
{
|
|
957
|
+
className: cn(
|
|
958
|
+
"pointer-events-none absolute z-1 flex justify-center [&>*]:pointer-events-auto",
|
|
959
|
+
/* Railed, the strip is centred DOWN the right edge; otherwise it is centred across the
|
|
960
|
+
bottom, which is where it has always sat. */
|
|
961
|
+
railed ? "inset-y-0 right-4 flex-col" : "inset-x-0 bottom-4"
|
|
962
|
+
),
|
|
963
|
+
children: indicatorStrip
|
|
964
|
+
}
|
|
965
|
+
)
|
|
966
|
+
] })
|
|
967
|
+
]
|
|
968
|
+
}
|
|
969
|
+
),
|
|
970
|
+
sideBySide && pager
|
|
971
|
+
] }),
|
|
972
|
+
thumbs && items.some((i) => i.thumb !== void 0) && /* @__PURE__ */ jsx(
|
|
973
|
+
CarouselThumbnailStrip,
|
|
974
|
+
{
|
|
975
|
+
items,
|
|
976
|
+
activeIndex,
|
|
977
|
+
perView: thumbs.perView,
|
|
978
|
+
aspect: thumbs.aspect,
|
|
979
|
+
size,
|
|
980
|
+
groupLabel: t.thumbnails,
|
|
981
|
+
slideLabel: (index) => t.goToSlide({ index, total }),
|
|
982
|
+
onSelect: (index) => {
|
|
983
|
+
reasonRef.current = "indicator";
|
|
984
|
+
api?.scrollTo(snapForIndex(registry, index));
|
|
985
|
+
if (autoplay?.stopOnInteraction) setWanted(false);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
),
|
|
989
|
+
!sideBySide && pager
|
|
990
|
+
]
|
|
991
|
+
}
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
Carousel.displayName = "Carousel";
|
|
995
|
+
|
|
996
|
+
export { Carousel };
|
|
997
|
+
//# sourceMappingURL=chunk-YXYZW6WU.js.map
|
|
998
|
+
//# sourceMappingURL=chunk-YXYZW6WU.js.map
|