@xwadex/fesd-next 0.3.3 → 0.3.4-10
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 +1 -26
- package/dist/components/index.d.ts +186 -1
- package/dist/components/index.js +1211 -1
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.d.ts +68 -1
- package/dist/hooks/index.js +891 -1
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +55 -4
- package/dist/index.js +5036 -4
- package/dist/index.js.map +1 -0
- package/dist/shadcns/index.d.ts +490 -0
- package/dist/shadcns/index.js +3864 -0
- package/dist/shadcns/index.js.map +1 -0
- package/dist/types/index.d.ts +16 -3
- package/dist/types/index.js +3 -1
- package/dist/types/index.js.map +1 -0
- package/dist/useAnchors-BzgJT2J9.d.ts +78 -0
- package/dist/utils/index.d.ts +15 -1
- package/dist/utils/index.js +63 -1
- package/dist/utils/index.js.map +1 -0
- package/package.json +60 -47
- package/dist/components/myComponents/MyComponent.d.ts +0 -2
- package/dist/components/myComponents/MyComponent.js +0 -4
- package/dist/components/myComponents/MyComponent.module.scss +0 -3
- package/dist/components/myComponents/index.d.ts +0 -1
- package/dist/components/myComponents/index.js +0 -1
- package/dist/hooks/useHooks.d.ts +0 -1
- package/dist/hooks/useHooks.js +0 -3
- package/dist/utils/someUtil.d.ts +0 -1
- package/dist/utils/someUtil.js +0 -3
package/dist/components/index.js
CHANGED
|
@@ -1 +1,1211 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React2 from 'react';
|
|
2
|
+
import React2__default, { memo, useRef, useEffectEvent, useEffect, useState, useLayoutEffect, createContext, useMemo, useCallback, use } from 'react';
|
|
3
|
+
import 'js-cookie';
|
|
4
|
+
import { useAnimate, motionValue } from 'motion/react';
|
|
5
|
+
import { create } from 'zustand';
|
|
6
|
+
import Lenis from 'lenis';
|
|
7
|
+
import '@radix-ui/react-accordion';
|
|
8
|
+
import { ArrowLeft } from 'lucide-react';
|
|
9
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
10
|
+
import '@radix-ui/react-alert-dialog';
|
|
11
|
+
import { cva } from 'class-variance-authority';
|
|
12
|
+
import '@radix-ui/react-aspect-ratio';
|
|
13
|
+
import '@radix-ui/react-avatar';
|
|
14
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
15
|
+
import 'react-day-picker';
|
|
16
|
+
import useEmblaCarousel from 'embla-carousel-react';
|
|
17
|
+
import 'recharts';
|
|
18
|
+
import '@radix-ui/react-checkbox';
|
|
19
|
+
import '@radix-ui/react-collapsible';
|
|
20
|
+
import 'cmdk';
|
|
21
|
+
import '@radix-ui/react-context-menu';
|
|
22
|
+
import '@radix-ui/react-dialog';
|
|
23
|
+
import 'vaul';
|
|
24
|
+
import '@radix-ui/react-dropdown-menu';
|
|
25
|
+
import 'react-hook-form';
|
|
26
|
+
import '@radix-ui/react-hover-card';
|
|
27
|
+
import 'input-otp';
|
|
28
|
+
import '@radix-ui/react-label';
|
|
29
|
+
import '@radix-ui/react-menubar';
|
|
30
|
+
import '@radix-ui/react-navigation-menu';
|
|
31
|
+
import '@radix-ui/react-popover';
|
|
32
|
+
import '@radix-ui/react-progress';
|
|
33
|
+
import '@radix-ui/react-radio-group';
|
|
34
|
+
import 'react-resizable-panels';
|
|
35
|
+
import '@radix-ui/react-scroll-area';
|
|
36
|
+
import '@radix-ui/react-select';
|
|
37
|
+
import '@radix-ui/react-separator';
|
|
38
|
+
import '@radix-ui/react-slider';
|
|
39
|
+
import 'next-themes';
|
|
40
|
+
import 'sonner';
|
|
41
|
+
import '@radix-ui/react-switch';
|
|
42
|
+
import '@radix-ui/react-tabs';
|
|
43
|
+
import '@radix-ui/react-toggle-group';
|
|
44
|
+
import '@radix-ui/react-toggle';
|
|
45
|
+
import '@radix-ui/react-tooltip';
|
|
46
|
+
import { clsx } from 'clsx';
|
|
47
|
+
import { twMerge } from 'tailwind-merge';
|
|
48
|
+
import { useLenis, ReactLenis } from 'lenis/react';
|
|
49
|
+
import { WheelGesturesPlugin } from 'embla-carousel-wheel-gestures';
|
|
50
|
+
import Autoplay from 'embla-carousel-autoplay';
|
|
51
|
+
import AutoScroll from 'embla-carousel-auto-scroll';
|
|
52
|
+
import AutoHeight from 'embla-carousel-auto-height';
|
|
53
|
+
import ClassNames from 'embla-carousel-class-names';
|
|
54
|
+
import Fade from 'embla-carousel-fade';
|
|
55
|
+
|
|
56
|
+
// src/hooks/useDebounce.tsx
|
|
57
|
+
var ANCHOR_ATTRIBUTE = "data-anchor";
|
|
58
|
+
var OFFSETER_ATTRIBUTE = "data-anchor-offseter";
|
|
59
|
+
function useAnchors() {
|
|
60
|
+
const [_, animate] = useAnimate();
|
|
61
|
+
const controllerRef = useRef(/* @__PURE__ */ new Map());
|
|
62
|
+
const scrollAnimations = useCallback(({
|
|
63
|
+
controllerKey,
|
|
64
|
+
containerDom,
|
|
65
|
+
anchorScrollValue,
|
|
66
|
+
containerScrollValue,
|
|
67
|
+
direction = "y",
|
|
68
|
+
duration = 1,
|
|
69
|
+
delay = 0,
|
|
70
|
+
ease = [0, 1, 0.5, 0.99],
|
|
71
|
+
onScroll: onPlay,
|
|
72
|
+
onScrolled,
|
|
73
|
+
onScrolling,
|
|
74
|
+
...props
|
|
75
|
+
}) => {
|
|
76
|
+
if (direction !== "y" && direction !== "x") {
|
|
77
|
+
console.error(`Scroll Direction isn't 'x' or 'y' `);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const { left: scrollLeft, top: scrollTop } = containerScrollValue;
|
|
81
|
+
const { left: anchorLeft, top: anchorTop } = anchorScrollValue;
|
|
82
|
+
const isScrollX = direction === "x";
|
|
83
|
+
const isScrollY = direction === "y";
|
|
84
|
+
const startValue = isScrollX ? scrollLeft : scrollTop;
|
|
85
|
+
const endValue = isScrollX ? anchorLeft : anchorTop;
|
|
86
|
+
if (startValue == endValue) {
|
|
87
|
+
controllerRef.current.delete(controllerKey);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const motionStartValue = motionValue(startValue);
|
|
91
|
+
const onUpdate = (value) => {
|
|
92
|
+
const left = isScrollX ? value : void 0;
|
|
93
|
+
const top = isScrollY ? value : void 0;
|
|
94
|
+
containerDom.scrollTo({ left, top });
|
|
95
|
+
onScrolling?.(value);
|
|
96
|
+
};
|
|
97
|
+
const onComplete = () => {
|
|
98
|
+
controllerRef.current.delete(controllerKey);
|
|
99
|
+
onScrolled?.();
|
|
100
|
+
};
|
|
101
|
+
const options = {
|
|
102
|
+
duration,
|
|
103
|
+
ease,
|
|
104
|
+
delay,
|
|
105
|
+
onPlay,
|
|
106
|
+
onUpdate,
|
|
107
|
+
onComplete,
|
|
108
|
+
...props
|
|
109
|
+
};
|
|
110
|
+
controllerRef.current.set(
|
|
111
|
+
controllerKey,
|
|
112
|
+
animate(motionStartValue, endValue, options)
|
|
113
|
+
);
|
|
114
|
+
}, []);
|
|
115
|
+
const scrollToAnchor = useCallback((anchorOptions) => {
|
|
116
|
+
const {
|
|
117
|
+
anchor: anchorName,
|
|
118
|
+
container: containerName,
|
|
119
|
+
offseters,
|
|
120
|
+
align,
|
|
121
|
+
offset = 0,
|
|
122
|
+
direction = "y",
|
|
123
|
+
...options
|
|
124
|
+
} = anchorOptions;
|
|
125
|
+
const anchorsStores = getAnchorsStores();
|
|
126
|
+
const scrollContainersStores = getScrollContainerStores();
|
|
127
|
+
const isScrolltoAnchor = anchorName !== "#";
|
|
128
|
+
const isScrollContainer = containerName && containerName !== "window";
|
|
129
|
+
const controllerKey = containerName ?? "window";
|
|
130
|
+
if (controllerRef.current.has(controllerKey)) {
|
|
131
|
+
controllerRef.current.get(controllerKey)?.stop();
|
|
132
|
+
controllerRef.current.delete(controllerKey);
|
|
133
|
+
}
|
|
134
|
+
const anchorDom = isScrolltoAnchor ? anchorsStores.anchors.get(anchorName) : void 0;
|
|
135
|
+
if (isScrolltoAnchor && !(anchorDom instanceof HTMLElement)) return;
|
|
136
|
+
const containerDom = isScrollContainer ? scrollContainersStores.containers.get(containerName) : window;
|
|
137
|
+
if (!containerDom) return;
|
|
138
|
+
const getOffseterDomClient = (offseters2) => {
|
|
139
|
+
const offseterDom = anchorsStores.offseters.get(offseters2);
|
|
140
|
+
const { clientWidth, clientHeight } = offseterDom || {};
|
|
141
|
+
return { width: clientWidth ?? 0, height: clientHeight ?? 0 };
|
|
142
|
+
};
|
|
143
|
+
const offsets = Array.isArray(offseters) ? offseters.reduce((init, offseter) => {
|
|
144
|
+
const { width, height } = getOffseterDomClient(offseter);
|
|
145
|
+
return {
|
|
146
|
+
width: (init.width ?? 0) + width,
|
|
147
|
+
height: (init.height ?? 0) + height
|
|
148
|
+
};
|
|
149
|
+
}, {}) : typeof offseters == "string" ? getOffseterDomClient(offseters) : { width: 0, height: 0 };
|
|
150
|
+
const offsetValue = {
|
|
151
|
+
width: direction === "x" ? offsets.width + offset : 0,
|
|
152
|
+
height: direction === "y" ? offsets.height + offset : 0
|
|
153
|
+
};
|
|
154
|
+
const isLenisScroll = containerDom == window && window.document.documentElement.classList.contains("lenis") || containerDom instanceof Lenis;
|
|
155
|
+
if (isLenisScroll) {
|
|
156
|
+
const lenis = isScrollContainer ? containerDom : getRootLenis()?.root;
|
|
157
|
+
if (!lenis) return;
|
|
158
|
+
const directionOffset = direction === "x" ? offsetValue.width + offset : offsetValue.height + offset;
|
|
159
|
+
lenis.scrollTo(
|
|
160
|
+
anchorDom ?? 0,
|
|
161
|
+
{
|
|
162
|
+
offset: directionOffset * -1,
|
|
163
|
+
onStart: (lenis2) => options?.onScroll?.(lenis2),
|
|
164
|
+
onComplete: (lenis2) => options?.onScrolled?.(lenis2)
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const containerScrollValue = {
|
|
170
|
+
top: Math.round(isScrollContainer ? containerDom.scrollTop : containerDom.pageYOffset),
|
|
171
|
+
left: Math.round(isScrollContainer ? containerDom.scrollLeft : pageXOffset)
|
|
172
|
+
};
|
|
173
|
+
const containerRect = isScrollContainer ? containerDom.getBoundingClientRect() : { top: 0, left: 0 };
|
|
174
|
+
const containerOffsetValue = {
|
|
175
|
+
left: containerScrollValue.left - (isScrollContainer ? containerRect.left : 0),
|
|
176
|
+
top: containerScrollValue.top - (isScrollContainer ? containerRect.top : 0)
|
|
177
|
+
};
|
|
178
|
+
const anchorRect = anchorDom ? anchorDom.getBoundingClientRect() : { left: 0, top: 0 };
|
|
179
|
+
const anchorScrollValue = {
|
|
180
|
+
left: isScrolltoAnchor ? Math.round(anchorRect.left + containerOffsetValue.left - offsetValue.width) : offsetValue.width,
|
|
181
|
+
top: isScrolltoAnchor ? Math.round(anchorRect.top + containerOffsetValue.top - offsetValue.height) : offsetValue.height
|
|
182
|
+
};
|
|
183
|
+
scrollAnimations({
|
|
184
|
+
controllerKey,
|
|
185
|
+
containerDom,
|
|
186
|
+
containerScrollValue,
|
|
187
|
+
anchorScrollValue,
|
|
188
|
+
direction,
|
|
189
|
+
...options
|
|
190
|
+
});
|
|
191
|
+
}, []);
|
|
192
|
+
const returnsMemo = useMemo(() => ({
|
|
193
|
+
registerAnchors,
|
|
194
|
+
registerOffseters,
|
|
195
|
+
setStores: setAnchorsStore,
|
|
196
|
+
getStores: getAnchorsStores,
|
|
197
|
+
scrollToAnchor
|
|
198
|
+
}), [scrollToAnchor]);
|
|
199
|
+
return returnsMemo;
|
|
200
|
+
}
|
|
201
|
+
function useRegistration({ key, name }) {
|
|
202
|
+
const ref = useRef(null);
|
|
203
|
+
const attribute = key == "anchors" ? ANCHOR_ATTRIBUTE : OFFSETER_ATTRIBUTE;
|
|
204
|
+
useLayoutEffect(() => {
|
|
205
|
+
setAnchorsStore({ key, action: "add", node: ref.current, name });
|
|
206
|
+
return () => {
|
|
207
|
+
setAnchorsStore({ key, action: "remove", node: ref.current, name });
|
|
208
|
+
};
|
|
209
|
+
}, []);
|
|
210
|
+
return { ref, [attribute]: name };
|
|
211
|
+
}
|
|
212
|
+
function registerAnchors(name) {
|
|
213
|
+
return useRegistration({ key: "anchors", name });
|
|
214
|
+
}
|
|
215
|
+
function registerOffseters(name) {
|
|
216
|
+
return useRegistration({ key: "offseters", name });
|
|
217
|
+
}
|
|
218
|
+
var useAnchorsStores = create()(() => ({
|
|
219
|
+
anchors: /* @__PURE__ */ new Map(),
|
|
220
|
+
offseters: /* @__PURE__ */ new Map()
|
|
221
|
+
}));
|
|
222
|
+
var getAnchorsStores = () => useAnchorsStores.getState();
|
|
223
|
+
var setAnchorsStore = (options) => {
|
|
224
|
+
const { key, action, name, node } = options;
|
|
225
|
+
useAnchorsStores.setState((stores) => {
|
|
226
|
+
switch (key) {
|
|
227
|
+
case "anchors":
|
|
228
|
+
const anchorDom = stores.anchors?.get(name);
|
|
229
|
+
if (action == "add" && node instanceof HTMLElement) {
|
|
230
|
+
if (anchorDom == node) return stores;
|
|
231
|
+
stores.anchors?.set(name, node);
|
|
232
|
+
} else if (action == "remove" && anchorDom) {
|
|
233
|
+
stores.anchors?.delete(name);
|
|
234
|
+
}
|
|
235
|
+
return { anchors: stores.anchors };
|
|
236
|
+
case "offseters":
|
|
237
|
+
const offseterDom = stores.offseters?.get(name);
|
|
238
|
+
if (action == "add" && node instanceof HTMLElement) {
|
|
239
|
+
if (offseterDom == node) return stores;
|
|
240
|
+
stores.offseters?.set(name, node);
|
|
241
|
+
} else if (action == "remove" && offseterDom) {
|
|
242
|
+
stores.offseters?.delete(name);
|
|
243
|
+
}
|
|
244
|
+
return { offseters: stores.offseters };
|
|
245
|
+
default:
|
|
246
|
+
return stores;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
cva(
|
|
251
|
+
"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
|
252
|
+
{
|
|
253
|
+
variants: {
|
|
254
|
+
variant: {
|
|
255
|
+
default: "bg-card text-card-foreground",
|
|
256
|
+
destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
defaultVariants: {
|
|
260
|
+
variant: "default"
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
cva(
|
|
265
|
+
"inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
|
266
|
+
{
|
|
267
|
+
variants: {
|
|
268
|
+
variant: {
|
|
269
|
+
default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
270
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
271
|
+
destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
272
|
+
outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
defaultVariants: {
|
|
276
|
+
variant: "default"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
var buttonVariants = cva(
|
|
281
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
282
|
+
{
|
|
283
|
+
variants: {
|
|
284
|
+
variant: {
|
|
285
|
+
default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
286
|
+
destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
287
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
288
|
+
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
289
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
290
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
291
|
+
},
|
|
292
|
+
size: {
|
|
293
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
294
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
295
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
296
|
+
icon: "size-9"
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
defaultVariants: {
|
|
300
|
+
variant: "default",
|
|
301
|
+
size: "default"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
function Button({
|
|
306
|
+
className,
|
|
307
|
+
variant,
|
|
308
|
+
size,
|
|
309
|
+
asChild = false,
|
|
310
|
+
...props
|
|
311
|
+
}) {
|
|
312
|
+
const Comp = asChild ? Slot : "button";
|
|
313
|
+
return /* @__PURE__ */ jsx(
|
|
314
|
+
Comp,
|
|
315
|
+
{
|
|
316
|
+
"data-slot": "button",
|
|
317
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
318
|
+
...props
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
var CarouselContext = React2.createContext(null);
|
|
323
|
+
function useCarousel() {
|
|
324
|
+
const context = React2.useContext(CarouselContext);
|
|
325
|
+
if (!context) {
|
|
326
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
327
|
+
}
|
|
328
|
+
return context;
|
|
329
|
+
}
|
|
330
|
+
function Carousel({
|
|
331
|
+
orientation = "horizontal",
|
|
332
|
+
opts,
|
|
333
|
+
setApi,
|
|
334
|
+
plugins,
|
|
335
|
+
className,
|
|
336
|
+
children,
|
|
337
|
+
...props
|
|
338
|
+
}) {
|
|
339
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
340
|
+
{
|
|
341
|
+
...opts,
|
|
342
|
+
axis: orientation === "horizontal" ? "x" : "y"
|
|
343
|
+
},
|
|
344
|
+
plugins
|
|
345
|
+
);
|
|
346
|
+
const [canScrollPrev, setCanScrollPrev] = React2.useState(false);
|
|
347
|
+
const [canScrollNext, setCanScrollNext] = React2.useState(false);
|
|
348
|
+
const onSelect = React2.useCallback((api2) => {
|
|
349
|
+
if (!api2) return;
|
|
350
|
+
setCanScrollPrev(api2.canScrollPrev());
|
|
351
|
+
setCanScrollNext(api2.canScrollNext());
|
|
352
|
+
}, []);
|
|
353
|
+
const scrollPrev = React2.useCallback(() => {
|
|
354
|
+
api?.scrollPrev();
|
|
355
|
+
}, [api]);
|
|
356
|
+
const scrollNext = React2.useCallback(() => {
|
|
357
|
+
api?.scrollNext();
|
|
358
|
+
}, [api]);
|
|
359
|
+
const handleKeyDown = React2.useCallback(
|
|
360
|
+
(event) => {
|
|
361
|
+
if (event.key === "ArrowLeft") {
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
scrollPrev();
|
|
364
|
+
} else if (event.key === "ArrowRight") {
|
|
365
|
+
event.preventDefault();
|
|
366
|
+
scrollNext();
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
[scrollPrev, scrollNext]
|
|
370
|
+
);
|
|
371
|
+
React2.useEffect(() => {
|
|
372
|
+
if (!api || !setApi) return;
|
|
373
|
+
setApi(api);
|
|
374
|
+
}, [api, setApi]);
|
|
375
|
+
React2.useEffect(() => {
|
|
376
|
+
if (!api) return;
|
|
377
|
+
onSelect(api);
|
|
378
|
+
api.on("reInit", onSelect);
|
|
379
|
+
api.on("select", onSelect);
|
|
380
|
+
return () => {
|
|
381
|
+
api?.off("select", onSelect);
|
|
382
|
+
};
|
|
383
|
+
}, [api, onSelect]);
|
|
384
|
+
return /* @__PURE__ */ jsx(
|
|
385
|
+
CarouselContext.Provider,
|
|
386
|
+
{
|
|
387
|
+
value: {
|
|
388
|
+
carouselRef,
|
|
389
|
+
api,
|
|
390
|
+
opts,
|
|
391
|
+
orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
392
|
+
scrollPrev,
|
|
393
|
+
scrollNext,
|
|
394
|
+
canScrollPrev,
|
|
395
|
+
canScrollNext
|
|
396
|
+
},
|
|
397
|
+
children: /* @__PURE__ */ jsx(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
onKeyDownCapture: handleKeyDown,
|
|
401
|
+
className: cn("relative", className),
|
|
402
|
+
role: "region",
|
|
403
|
+
"aria-roledescription": "carousel",
|
|
404
|
+
"data-slot": "carousel",
|
|
405
|
+
...props,
|
|
406
|
+
children
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
function CarouselPrevious({
|
|
413
|
+
className,
|
|
414
|
+
variant = "outline",
|
|
415
|
+
size = "icon",
|
|
416
|
+
...props
|
|
417
|
+
}) {
|
|
418
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
419
|
+
return /* @__PURE__ */ jsxs(
|
|
420
|
+
Button,
|
|
421
|
+
{
|
|
422
|
+
"data-slot": "carousel-previous",
|
|
423
|
+
variant,
|
|
424
|
+
size,
|
|
425
|
+
className: cn(
|
|
426
|
+
"absolute size-8 rounded-full",
|
|
427
|
+
orientation === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
428
|
+
className
|
|
429
|
+
),
|
|
430
|
+
disabled: !canScrollPrev,
|
|
431
|
+
onClick: scrollPrev,
|
|
432
|
+
...props,
|
|
433
|
+
children: [
|
|
434
|
+
/* @__PURE__ */ jsx(ArrowLeft, {}),
|
|
435
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Previous slide" })
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
React2.createContext(null);
|
|
441
|
+
React2.createContext({});
|
|
442
|
+
React2.createContext({});
|
|
443
|
+
cva(
|
|
444
|
+
"group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1"
|
|
445
|
+
);
|
|
446
|
+
React2.createContext(null);
|
|
447
|
+
cva(
|
|
448
|
+
"peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
|
449
|
+
{
|
|
450
|
+
variants: {
|
|
451
|
+
variant: {
|
|
452
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
453
|
+
outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
|
|
454
|
+
},
|
|
455
|
+
size: {
|
|
456
|
+
default: "h-8 text-sm",
|
|
457
|
+
sm: "h-7 text-xs",
|
|
458
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
defaultVariants: {
|
|
462
|
+
variant: "default",
|
|
463
|
+
size: "default"
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
);
|
|
467
|
+
React2.createContext({
|
|
468
|
+
size: "default",
|
|
469
|
+
variant: "default"
|
|
470
|
+
});
|
|
471
|
+
cva(
|
|
472
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
|
473
|
+
{
|
|
474
|
+
variants: {
|
|
475
|
+
variant: {
|
|
476
|
+
default: "bg-transparent",
|
|
477
|
+
outline: "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"
|
|
478
|
+
},
|
|
479
|
+
size: {
|
|
480
|
+
default: "h-9 px-2 min-w-9",
|
|
481
|
+
sm: "h-8 px-1.5 min-w-8",
|
|
482
|
+
lg: "h-10 px-2.5 min-w-10"
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
defaultVariants: {
|
|
486
|
+
variant: "default",
|
|
487
|
+
size: "default"
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
function cn(...inputs) {
|
|
492
|
+
return twMerge(clsx(...inputs));
|
|
493
|
+
}
|
|
494
|
+
var AnchorTarget = ({ name, ...props }) => {
|
|
495
|
+
const { registerAnchors: registerAnchors2 } = useAnchors();
|
|
496
|
+
return /* @__PURE__ */ jsx(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
...props,
|
|
500
|
+
...registerAnchors2(name)
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
};
|
|
504
|
+
var AnchorOffseter = ({ name, ...props }) => {
|
|
505
|
+
const { registerOffseters: registerOffseters2 } = useAnchors();
|
|
506
|
+
return /* @__PURE__ */ jsx(
|
|
507
|
+
"div",
|
|
508
|
+
{
|
|
509
|
+
...props,
|
|
510
|
+
...registerOffseters2(name)
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
};
|
|
514
|
+
var AnchorTrigger = ({
|
|
515
|
+
children,
|
|
516
|
+
className,
|
|
517
|
+
...options
|
|
518
|
+
}) => {
|
|
519
|
+
const { scrollToAnchor } = useAnchors();
|
|
520
|
+
return /* @__PURE__ */ jsx(
|
|
521
|
+
"div",
|
|
522
|
+
{
|
|
523
|
+
className: cn(className),
|
|
524
|
+
onClick: () => scrollToAnchor(options),
|
|
525
|
+
children
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
};
|
|
529
|
+
var Anchors = {
|
|
530
|
+
Trigger: AnchorTrigger,
|
|
531
|
+
Target: AnchorTarget,
|
|
532
|
+
Offseter: AnchorOffseter
|
|
533
|
+
};
|
|
534
|
+
var LenisScroll = memo((props) => {
|
|
535
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
536
|
+
props?.root == true ? /* @__PURE__ */ jsx(LenisRootScroll, { ...props }) : /* @__PURE__ */ jsx(LenisContainerScroll, { ...props }),
|
|
537
|
+
" "
|
|
538
|
+
] });
|
|
539
|
+
});
|
|
540
|
+
var LenisRootScroll = memo(({
|
|
541
|
+
root,
|
|
542
|
+
options
|
|
543
|
+
}) => {
|
|
544
|
+
const lenis = useLenis();
|
|
545
|
+
const lenisRef = useRef(null);
|
|
546
|
+
const registerRootLenis = useEffectEvent(() => {
|
|
547
|
+
if (!root == true || !lenis) return;
|
|
548
|
+
setRootLenis(lenis);
|
|
549
|
+
});
|
|
550
|
+
useEffect(() => {
|
|
551
|
+
registerRootLenis();
|
|
552
|
+
}, [lenis]);
|
|
553
|
+
return /* @__PURE__ */ jsx(
|
|
554
|
+
ReactLenis,
|
|
555
|
+
{
|
|
556
|
+
ref: lenisRef,
|
|
557
|
+
root,
|
|
558
|
+
options: {
|
|
559
|
+
autoRaf: true,
|
|
560
|
+
lerp: 5e-4,
|
|
561
|
+
duration: 1.5,
|
|
562
|
+
smoothWheel: true,
|
|
563
|
+
...options
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
});
|
|
568
|
+
var LenisContainerScroll = memo(({
|
|
569
|
+
name,
|
|
570
|
+
className,
|
|
571
|
+
children,
|
|
572
|
+
options,
|
|
573
|
+
...restProps
|
|
574
|
+
}) => {
|
|
575
|
+
const [containerRef, setContainerRef] = useState();
|
|
576
|
+
const wrapperRef = useRef(null);
|
|
577
|
+
const contentRef = useRef(null);
|
|
578
|
+
const initLenis = useEffectEvent(() => {
|
|
579
|
+
if (!wrapperRef.current || !contentRef.current || !name) return;
|
|
580
|
+
const lenis = new Lenis({
|
|
581
|
+
wrapper: wrapperRef.current,
|
|
582
|
+
content: contentRef.current,
|
|
583
|
+
autoRaf: true,
|
|
584
|
+
...options
|
|
585
|
+
});
|
|
586
|
+
setContainerRef(contentRef);
|
|
587
|
+
setScrollContainerStore({ name, action: "add", node: lenis });
|
|
588
|
+
return () => {
|
|
589
|
+
setScrollContainerStore({ name, action: "remove" });
|
|
590
|
+
lenis?.destroy?.();
|
|
591
|
+
};
|
|
592
|
+
});
|
|
593
|
+
useLayoutEffect(() => {
|
|
594
|
+
const effect = initLenis();
|
|
595
|
+
return effect;
|
|
596
|
+
}, [name, options]);
|
|
597
|
+
return /* @__PURE__ */ jsx(
|
|
598
|
+
"div",
|
|
599
|
+
{
|
|
600
|
+
ref: wrapperRef,
|
|
601
|
+
"data-lenis-scroll": name,
|
|
602
|
+
className: cn("group overflow-hidden", className),
|
|
603
|
+
...restProps,
|
|
604
|
+
children: /* @__PURE__ */ jsx(
|
|
605
|
+
"div",
|
|
606
|
+
{
|
|
607
|
+
ref: contentRef,
|
|
608
|
+
className: cn("h-full", "relative", "will-change-transform overscroll-contain"),
|
|
609
|
+
children: /* @__PURE__ */ jsx(ScrollContainerContext, { value: { containerRef }, children })
|
|
610
|
+
}
|
|
611
|
+
)
|
|
612
|
+
}
|
|
613
|
+
);
|
|
614
|
+
});
|
|
615
|
+
var useLenisStores = create()(() => ({
|
|
616
|
+
root: null
|
|
617
|
+
}));
|
|
618
|
+
var setRootLenis = (lenis) => useLenisStores.setState(() => {
|
|
619
|
+
return { root: lenis };
|
|
620
|
+
});
|
|
621
|
+
var getRootLenis = () => useLenisStores.getState();
|
|
622
|
+
var ScrollContainer = ({
|
|
623
|
+
name,
|
|
624
|
+
lenis = false,
|
|
625
|
+
...props
|
|
626
|
+
}) => {
|
|
627
|
+
return /* @__PURE__ */ jsx(Fragment, { children: lenis ? /* @__PURE__ */ jsx(LenisScroll, { name, ...props }) : /* @__PURE__ */ jsx(NativeScroll, { name, ...props }) });
|
|
628
|
+
};
|
|
629
|
+
var ScrollContainerContext = createContext(null);
|
|
630
|
+
var useScrollContainerContext = () => {
|
|
631
|
+
const context = use(ScrollContainerContext);
|
|
632
|
+
if (!context) throw new Error("useScrollContainerContext must be used inside ScrollContainerProvider");
|
|
633
|
+
return context;
|
|
634
|
+
};
|
|
635
|
+
var useScrollContainersStores = create()(() => ({
|
|
636
|
+
containers: /* @__PURE__ */ new Map()
|
|
637
|
+
}));
|
|
638
|
+
var getScrollContainer = (name) => {
|
|
639
|
+
const stores = useScrollContainersStores.getState();
|
|
640
|
+
return stores.containers?.get(name);
|
|
641
|
+
};
|
|
642
|
+
var getScrollContainerStores = () => useScrollContainersStores.getState();
|
|
643
|
+
var setScrollContainerStore = (options) => {
|
|
644
|
+
const { action, name, node } = options;
|
|
645
|
+
useScrollContainersStores.setState((stores) => {
|
|
646
|
+
const containerDom = stores.containers?.get(name);
|
|
647
|
+
const isContainerNode = node instanceof Lenis || node instanceof HTMLDivElement;
|
|
648
|
+
if (action == "add" && isContainerNode) {
|
|
649
|
+
if (containerDom == node) return stores;
|
|
650
|
+
stores.containers?.set(name, node);
|
|
651
|
+
} else if (action == "remove" && containerDom) {
|
|
652
|
+
stores.containers?.delete(name);
|
|
653
|
+
}
|
|
654
|
+
return { containers: stores.containers };
|
|
655
|
+
});
|
|
656
|
+
};
|
|
657
|
+
var NativeScroll = memo(({
|
|
658
|
+
tag: Component = "div",
|
|
659
|
+
name,
|
|
660
|
+
className,
|
|
661
|
+
...restProps
|
|
662
|
+
}) => {
|
|
663
|
+
const componentRef = useRef(null);
|
|
664
|
+
const [containerRef, setContainerRef] = useState();
|
|
665
|
+
const nativeEffect = useEffectEvent(() => {
|
|
666
|
+
if (!componentRef.current) return;
|
|
667
|
+
setContainerRef(componentRef);
|
|
668
|
+
setScrollContainerStore({ name, action: "add", node: componentRef.current });
|
|
669
|
+
return () => {
|
|
670
|
+
setScrollContainerStore({ name, action: "remove" });
|
|
671
|
+
};
|
|
672
|
+
});
|
|
673
|
+
useEffect(() => {
|
|
674
|
+
const effect = nativeEffect();
|
|
675
|
+
return effect;
|
|
676
|
+
}, [componentRef?.current]);
|
|
677
|
+
return /* @__PURE__ */ jsx(ScrollContainerContext, { value: { containerRef }, children: /* @__PURE__ */ jsx(
|
|
678
|
+
Component,
|
|
679
|
+
{
|
|
680
|
+
ref: componentRef,
|
|
681
|
+
"data-native-scroll": name,
|
|
682
|
+
className: cn(
|
|
683
|
+
"overflow-auto",
|
|
684
|
+
"will-change-transform",
|
|
685
|
+
className
|
|
686
|
+
),
|
|
687
|
+
...restProps
|
|
688
|
+
}
|
|
689
|
+
) });
|
|
690
|
+
});
|
|
691
|
+
function emblaCarouselsHooks({
|
|
692
|
+
options,
|
|
693
|
+
autoplay,
|
|
694
|
+
autoScroll,
|
|
695
|
+
classNames,
|
|
696
|
+
autoHeight,
|
|
697
|
+
fade,
|
|
698
|
+
wheel,
|
|
699
|
+
setApi
|
|
700
|
+
}) {
|
|
701
|
+
const orientation = options?.axis ?? "x";
|
|
702
|
+
const plugins = useMemo(() => [
|
|
703
|
+
autoplay && Autoplay(typeof autoplay == "boolean" ? void 0 : autoplay),
|
|
704
|
+
autoScroll && AutoScroll(typeof autoScroll == "boolean" ? void 0 : autoScroll),
|
|
705
|
+
autoHeight && AutoHeight(typeof autoHeight == "boolean" ? void 0 : autoHeight),
|
|
706
|
+
classNames && ClassNames(typeof classNames == "boolean" ? void 0 : classNames),
|
|
707
|
+
fade && Fade(typeof fade == "boolean" ? void 0 : fade),
|
|
708
|
+
wheel && WheelGesturesPlugin(typeof wheel == "boolean" ? void 0 : wheel)
|
|
709
|
+
].filter(
|
|
710
|
+
(plugin) => plugin
|
|
711
|
+
), [
|
|
712
|
+
autoplay,
|
|
713
|
+
autoScroll,
|
|
714
|
+
classNames,
|
|
715
|
+
fade,
|
|
716
|
+
wheel,
|
|
717
|
+
autoHeight
|
|
718
|
+
]);
|
|
719
|
+
const [emblaRef, emblaApi] = useEmblaCarousel(options, plugins);
|
|
720
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
721
|
+
const [isScrollPrev, setIsScrollPrev] = useState(false);
|
|
722
|
+
const [isScrollNext, setIsScrollNext] = useState(false);
|
|
723
|
+
const scrollPrev = useCallback(() => {
|
|
724
|
+
emblaApi?.scrollPrev();
|
|
725
|
+
}, [emblaApi]);
|
|
726
|
+
const scrollNext = useCallback(() => {
|
|
727
|
+
emblaApi?.scrollNext();
|
|
728
|
+
}, [emblaApi]);
|
|
729
|
+
const onKeyDownCapture = useCallback((event) => {
|
|
730
|
+
console.log("key...");
|
|
731
|
+
if (event.key === "ArrowLeft") {
|
|
732
|
+
event.preventDefault();
|
|
733
|
+
scrollPrev();
|
|
734
|
+
} else if (event.key === "ArrowRight") {
|
|
735
|
+
event.preventDefault();
|
|
736
|
+
scrollNext();
|
|
737
|
+
}
|
|
738
|
+
}, [scrollPrev, scrollNext]);
|
|
739
|
+
const onSelect = useCallback((api) => {
|
|
740
|
+
if (!api) return;
|
|
741
|
+
setCurrentIndex(api?.selectedScrollSnap());
|
|
742
|
+
setIsScrollPrev(api.canScrollPrev());
|
|
743
|
+
setIsScrollNext(api.canScrollNext());
|
|
744
|
+
}, []);
|
|
745
|
+
const initalEffect = useEffectEvent(() => {
|
|
746
|
+
if (!emblaApi || !setApi) return;
|
|
747
|
+
setApi?.(emblaApi);
|
|
748
|
+
onSelect(emblaApi);
|
|
749
|
+
emblaApi.on("reInit", onSelect);
|
|
750
|
+
emblaApi.on("select", onSelect);
|
|
751
|
+
return () => {
|
|
752
|
+
emblaApi?.off("select", onSelect);
|
|
753
|
+
};
|
|
754
|
+
});
|
|
755
|
+
useEffect(() => {
|
|
756
|
+
const events = initalEffect();
|
|
757
|
+
return () => {
|
|
758
|
+
events?.();
|
|
759
|
+
};
|
|
760
|
+
}, [emblaApi]);
|
|
761
|
+
return {
|
|
762
|
+
emblaRef,
|
|
763
|
+
emblaApi,
|
|
764
|
+
orientation,
|
|
765
|
+
currentIndex,
|
|
766
|
+
isScrollPrev,
|
|
767
|
+
isScrollNext,
|
|
768
|
+
scrollPrev,
|
|
769
|
+
scrollNext,
|
|
770
|
+
onKeyDownCapture
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
var CarouselsContext = createContext(null);
|
|
774
|
+
var useCarouselsContext = () => {
|
|
775
|
+
const context = use(CarouselsContext);
|
|
776
|
+
if (!context) throw new Error("useCarousel must be used within a <Carousel />");
|
|
777
|
+
return context;
|
|
778
|
+
};
|
|
779
|
+
var EmblaCarouselsRoots = memo(({
|
|
780
|
+
children,
|
|
781
|
+
className,
|
|
782
|
+
setApi,
|
|
783
|
+
options,
|
|
784
|
+
autoplay,
|
|
785
|
+
autoScroll,
|
|
786
|
+
classNames,
|
|
787
|
+
autoHeight,
|
|
788
|
+
fade,
|
|
789
|
+
wheel,
|
|
790
|
+
...props
|
|
791
|
+
}) => {
|
|
792
|
+
const {
|
|
793
|
+
emblaRef,
|
|
794
|
+
emblaApi,
|
|
795
|
+
orientation,
|
|
796
|
+
currentIndex,
|
|
797
|
+
isScrollPrev,
|
|
798
|
+
isScrollNext,
|
|
799
|
+
scrollPrev,
|
|
800
|
+
scrollNext,
|
|
801
|
+
onKeyDownCapture
|
|
802
|
+
} = emblaCarouselsHooks({
|
|
803
|
+
setApi,
|
|
804
|
+
options,
|
|
805
|
+
autoplay,
|
|
806
|
+
autoScroll,
|
|
807
|
+
classNames,
|
|
808
|
+
autoHeight,
|
|
809
|
+
fade,
|
|
810
|
+
wheel
|
|
811
|
+
});
|
|
812
|
+
const contextValue = useMemo(() => ({
|
|
813
|
+
emblaRef,
|
|
814
|
+
emblaApi,
|
|
815
|
+
orientation,
|
|
816
|
+
currentIndex,
|
|
817
|
+
isScrollPrev,
|
|
818
|
+
isScrollNext,
|
|
819
|
+
scrollPrev,
|
|
820
|
+
scrollNext
|
|
821
|
+
}), [
|
|
822
|
+
emblaRef,
|
|
823
|
+
emblaApi,
|
|
824
|
+
orientation,
|
|
825
|
+
currentIndex,
|
|
826
|
+
isScrollPrev,
|
|
827
|
+
isScrollNext,
|
|
828
|
+
scrollPrev,
|
|
829
|
+
scrollNext
|
|
830
|
+
]);
|
|
831
|
+
return /* @__PURE__ */ jsx(CarouselsContext, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
832
|
+
"div",
|
|
833
|
+
{
|
|
834
|
+
"data-component": "embla-carousels",
|
|
835
|
+
onKeyDownCapture,
|
|
836
|
+
className: cn("relative overflow-hidden", className),
|
|
837
|
+
"aria-roledescription": "embla-carousels",
|
|
838
|
+
role: "region",
|
|
839
|
+
...props,
|
|
840
|
+
children
|
|
841
|
+
}
|
|
842
|
+
) });
|
|
843
|
+
});
|
|
844
|
+
var EmblaCarouselsContents = memo(({ className, ...props }) => {
|
|
845
|
+
const { emblaRef, orientation } = useCarouselsContext();
|
|
846
|
+
return /* @__PURE__ */ jsx(
|
|
847
|
+
"div",
|
|
848
|
+
{
|
|
849
|
+
ref: emblaRef,
|
|
850
|
+
className: "overflow-hidden",
|
|
851
|
+
"data-component": "embla-carousels-contents",
|
|
852
|
+
children: /* @__PURE__ */ jsx(
|
|
853
|
+
"div",
|
|
854
|
+
{
|
|
855
|
+
className: cn(
|
|
856
|
+
"flex",
|
|
857
|
+
orientation === "x" ? "flex-row" : "flex-col",
|
|
858
|
+
className
|
|
859
|
+
),
|
|
860
|
+
...props
|
|
861
|
+
}
|
|
862
|
+
)
|
|
863
|
+
}
|
|
864
|
+
);
|
|
865
|
+
});
|
|
866
|
+
var EmblaCarouselsSlides = memo(({ className, ...props }) => {
|
|
867
|
+
return /* @__PURE__ */ jsx(
|
|
868
|
+
"div",
|
|
869
|
+
{
|
|
870
|
+
role: "group",
|
|
871
|
+
"aria-roledescription": "slide",
|
|
872
|
+
"data-component": "embla-carousels-slides",
|
|
873
|
+
className: cn(
|
|
874
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
875
|
+
className
|
|
876
|
+
),
|
|
877
|
+
...props
|
|
878
|
+
}
|
|
879
|
+
);
|
|
880
|
+
});
|
|
881
|
+
var EmblaCarousels = {
|
|
882
|
+
Roots: EmblaCarouselsRoots,
|
|
883
|
+
Contents: EmblaCarouselsContents,
|
|
884
|
+
Slides: EmblaCarouselsSlides
|
|
885
|
+
};
|
|
886
|
+
var CarouselContext2 = createContext(null);
|
|
887
|
+
var CarouselContextProvider = (props) => {
|
|
888
|
+
return /* @__PURE__ */ jsx(CarouselContext2, { ...props });
|
|
889
|
+
};
|
|
890
|
+
var useCarouselContext = () => {
|
|
891
|
+
const context = use(CarouselContext2);
|
|
892
|
+
if (!context) throw new Error("useCMSData must be used inside CMSProvider");
|
|
893
|
+
return context;
|
|
894
|
+
};
|
|
895
|
+
var Embla = ({
|
|
896
|
+
children,
|
|
897
|
+
className,
|
|
898
|
+
options,
|
|
899
|
+
datas,
|
|
900
|
+
autoplayEnabled = true,
|
|
901
|
+
autoplayOptions,
|
|
902
|
+
setApi,
|
|
903
|
+
setMethods,
|
|
904
|
+
setRef,
|
|
905
|
+
style,
|
|
906
|
+
controls,
|
|
907
|
+
onScrolled
|
|
908
|
+
}) => {
|
|
909
|
+
const { loop, duration = 40 } = options || {};
|
|
910
|
+
const autoplaySetting = useMemo(() => {
|
|
911
|
+
if (!autoplayEnabled) return;
|
|
912
|
+
return [Autoplay({ playOnInit: true, delay: 5e3, stopOnInteraction: false, ...autoplayOptions })];
|
|
913
|
+
}, [autoplayEnabled, autoplayOptions]);
|
|
914
|
+
const [emblaRef, emblaApi] = useEmblaCarousel({ ...options, loop, duration }, autoplaySetting);
|
|
915
|
+
const [selectIndex, setSelectIndex] = useState(0);
|
|
916
|
+
const [scrollSnaps, setScrollSnaps] = useState([]);
|
|
917
|
+
const nextScroll = useCallback(() => {
|
|
918
|
+
if (!emblaApi) return;
|
|
919
|
+
const { canScrollNext, scrollNext } = emblaApi;
|
|
920
|
+
canScrollNext() && scrollNext() && autoPlayReset();
|
|
921
|
+
}, [emblaApi]);
|
|
922
|
+
const prevScroll = useCallback(() => {
|
|
923
|
+
if (!emblaApi) return;
|
|
924
|
+
const { canScrollPrev, scrollPrev } = emblaApi;
|
|
925
|
+
canScrollPrev() && scrollPrev() && autoPlayReset();
|
|
926
|
+
}, [emblaApi]);
|
|
927
|
+
const scrollToIndex = useCallback((index) => {
|
|
928
|
+
if (!emblaApi || typeof index !== "number") return;
|
|
929
|
+
emblaApi.scrollTo(index);
|
|
930
|
+
}, [emblaApi]);
|
|
931
|
+
const autoPlayReset = useCallback(() => {
|
|
932
|
+
if (!emblaApi) return;
|
|
933
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
934
|
+
autoplay && autoplay.reset();
|
|
935
|
+
}, [emblaApi]);
|
|
936
|
+
const autoPlayPlay = useCallback(() => {
|
|
937
|
+
if (!emblaApi) return;
|
|
938
|
+
if (!emblaApi.canScrollNext()) return;
|
|
939
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
940
|
+
autoplay && autoplay.play();
|
|
941
|
+
}, [emblaApi]);
|
|
942
|
+
const autoPlayStop = useCallback(() => {
|
|
943
|
+
if (!emblaApi) return;
|
|
944
|
+
const autoplay = emblaApi?.plugins()?.autoplay;
|
|
945
|
+
autoplay && autoplay.stop();
|
|
946
|
+
}, [emblaApi]);
|
|
947
|
+
const contextValue = useMemo(() => ({
|
|
948
|
+
datas,
|
|
949
|
+
emblaRef,
|
|
950
|
+
emblaApi,
|
|
951
|
+
selectIndex,
|
|
952
|
+
scrollSnaps,
|
|
953
|
+
nextScroll,
|
|
954
|
+
prevScroll,
|
|
955
|
+
scrollToIndex,
|
|
956
|
+
autoPlayReset,
|
|
957
|
+
autoPlayStop,
|
|
958
|
+
autoPlayPlay
|
|
959
|
+
}), [
|
|
960
|
+
datas,
|
|
961
|
+
emblaRef,
|
|
962
|
+
emblaApi,
|
|
963
|
+
selectIndex,
|
|
964
|
+
scrollSnaps,
|
|
965
|
+
nextScroll,
|
|
966
|
+
prevScroll,
|
|
967
|
+
scrollToIndex,
|
|
968
|
+
autoPlayReset,
|
|
969
|
+
autoPlayStop,
|
|
970
|
+
autoPlayPlay
|
|
971
|
+
]);
|
|
972
|
+
const onInit = useCallback((emblaApi2) => {
|
|
973
|
+
const snapList = emblaApi2.scrollSnapList();
|
|
974
|
+
setScrollSnaps(snapList);
|
|
975
|
+
}, []);
|
|
976
|
+
const onSelectEvent = (emblaApi2) => {
|
|
977
|
+
emblaApi2.on("select", () => {
|
|
978
|
+
onScrolled?.(emblaApi2.selectedScrollSnap());
|
|
979
|
+
setSelectIndex(emblaApi2.selectedScrollSnap());
|
|
980
|
+
});
|
|
981
|
+
};
|
|
982
|
+
useEffect(() => {
|
|
983
|
+
if (!emblaApi) return;
|
|
984
|
+
setRef?.(emblaRef);
|
|
985
|
+
setApi?.(emblaApi);
|
|
986
|
+
setMethods?.({});
|
|
987
|
+
onInit(emblaApi);
|
|
988
|
+
onSelectEvent(emblaApi);
|
|
989
|
+
}, [emblaApi]);
|
|
990
|
+
return /* @__PURE__ */ jsx(CarouselContextProvider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
991
|
+
"div",
|
|
992
|
+
{
|
|
993
|
+
"data-component": "embla-root",
|
|
994
|
+
className: cn("relative w-full"),
|
|
995
|
+
children: [
|
|
996
|
+
/* @__PURE__ */ jsx(
|
|
997
|
+
"div",
|
|
998
|
+
{
|
|
999
|
+
className: cn(
|
|
1000
|
+
"overflow-hidden",
|
|
1001
|
+
"w-full",
|
|
1002
|
+
className
|
|
1003
|
+
),
|
|
1004
|
+
ref: emblaRef,
|
|
1005
|
+
style,
|
|
1006
|
+
children
|
|
1007
|
+
}
|
|
1008
|
+
),
|
|
1009
|
+
Array.isArray(controls) ? controls.map((ctrl, i) => /* @__PURE__ */ jsx(React2__default.Fragment, { children: ctrl }, i)) : controls
|
|
1010
|
+
]
|
|
1011
|
+
}
|
|
1012
|
+
) });
|
|
1013
|
+
};
|
|
1014
|
+
Embla.displayName = "Embla";
|
|
1015
|
+
var embla_default = Embla;
|
|
1016
|
+
var EmblaContainer = ({
|
|
1017
|
+
slide: SlideComponent,
|
|
1018
|
+
className,
|
|
1019
|
+
children,
|
|
1020
|
+
style,
|
|
1021
|
+
...props
|
|
1022
|
+
}) => {
|
|
1023
|
+
const { datas, emblaApi } = useCarouselContext();
|
|
1024
|
+
const cantSlide = !emblaApi?.canScrollNext() && !emblaApi?.canScrollPrev();
|
|
1025
|
+
return /* @__PURE__ */ jsxs(
|
|
1026
|
+
"div",
|
|
1027
|
+
{
|
|
1028
|
+
"data-component": "embla-container",
|
|
1029
|
+
className: cn(
|
|
1030
|
+
"flex",
|
|
1031
|
+
className,
|
|
1032
|
+
cantSlide && [
|
|
1033
|
+
"transform-[unset!important]"
|
|
1034
|
+
]
|
|
1035
|
+
),
|
|
1036
|
+
style: { ...style },
|
|
1037
|
+
children: [
|
|
1038
|
+
SlideComponent && datas?.map((item, index) => /* @__PURE__ */ jsx(
|
|
1039
|
+
SlideComponent,
|
|
1040
|
+
{
|
|
1041
|
+
...item,
|
|
1042
|
+
index,
|
|
1043
|
+
...props
|
|
1044
|
+
},
|
|
1045
|
+
item?.multipurpose?.key ?? item?.id ?? index
|
|
1046
|
+
)),
|
|
1047
|
+
children
|
|
1048
|
+
]
|
|
1049
|
+
}
|
|
1050
|
+
);
|
|
1051
|
+
};
|
|
1052
|
+
EmblaContainer.displayName = "EmblaContainer";
|
|
1053
|
+
var embla_container_default = EmblaContainer;
|
|
1054
|
+
var EmblaPagination = ({
|
|
1055
|
+
color = "black",
|
|
1056
|
+
align,
|
|
1057
|
+
className,
|
|
1058
|
+
maxDots = 5,
|
|
1059
|
+
dynamic = true,
|
|
1060
|
+
swiperNumber = true
|
|
1061
|
+
}) => {
|
|
1062
|
+
const { selectIndex, scrollToIndex, scrollSnaps, autoPlayReset, emblaApi } = useCarouselContext();
|
|
1063
|
+
const total = scrollSnaps?.length ?? 0;
|
|
1064
|
+
const active = Math.max(0, Math.min(selectIndex ?? 0, Math.max(0, total - 1)));
|
|
1065
|
+
const paginationNumber = `${Number(active + 1) < 10 ? "0" + Number(active + 1) : Number(active + 1)}`;
|
|
1066
|
+
const isWhite = color === "white";
|
|
1067
|
+
const clickEvent = (index) => {
|
|
1068
|
+
scrollToIndex(index);
|
|
1069
|
+
autoPlayReset();
|
|
1070
|
+
};
|
|
1071
|
+
const isSelected = (index) => {
|
|
1072
|
+
return index === selectIndex;
|
|
1073
|
+
};
|
|
1074
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
1075
|
+
const [slideCount, setSlideCount] = useState(0);
|
|
1076
|
+
useEffect(() => {
|
|
1077
|
+
if (!emblaApi || !dynamic) return;
|
|
1078
|
+
const update = () => {
|
|
1079
|
+
setSelectedIndex(emblaApi.selectedScrollSnap());
|
|
1080
|
+
setSlideCount(emblaApi.scrollSnapList().length);
|
|
1081
|
+
};
|
|
1082
|
+
emblaApi.on("select", update);
|
|
1083
|
+
emblaApi.on("reInit", update);
|
|
1084
|
+
update();
|
|
1085
|
+
return () => {
|
|
1086
|
+
emblaApi.off("select", update);
|
|
1087
|
+
emblaApi.off("reInit", update);
|
|
1088
|
+
};
|
|
1089
|
+
}, [emblaApi, dynamic]);
|
|
1090
|
+
const getVisibleBullets = () => {
|
|
1091
|
+
const total2 = slideCount ?? 0;
|
|
1092
|
+
if (total2 === 0) return [];
|
|
1093
|
+
const limit = Math.max(1, Number(maxDots));
|
|
1094
|
+
const windowSize = Math.min(total2, limit);
|
|
1095
|
+
const left = Math.floor((windowSize - 1) / 2);
|
|
1096
|
+
const right = windowSize - left - 1;
|
|
1097
|
+
let start = selectedIndex - left;
|
|
1098
|
+
let end = selectedIndex + right;
|
|
1099
|
+
if (start < 0) {
|
|
1100
|
+
end = Math.min(end - start, total2 - 1);
|
|
1101
|
+
start = 0;
|
|
1102
|
+
}
|
|
1103
|
+
if (end > total2 - 1) {
|
|
1104
|
+
start = Math.max(0, start - (end - (total2 - 1)));
|
|
1105
|
+
end = total2 - 1;
|
|
1106
|
+
}
|
|
1107
|
+
return Array.from({ length: end - start + 1 }, (_, i) => start + i);
|
|
1108
|
+
};
|
|
1109
|
+
const visibleRange = getVisibleBullets();
|
|
1110
|
+
const dots = dynamic ? visibleRange : scrollSnaps?.map((_, i) => i) ?? [];
|
|
1111
|
+
const swiperSnap = [
|
|
1112
|
+
"text-[16px]",
|
|
1113
|
+
"font-semibold",
|
|
1114
|
+
" leading-[1.4]"
|
|
1115
|
+
];
|
|
1116
|
+
const paginationColorStyle = {
|
|
1117
|
+
"black": "#000",
|
|
1118
|
+
"white": "#fff"
|
|
1119
|
+
}[color] || `${color}`;
|
|
1120
|
+
const paginationColorStyle2 = {
|
|
1121
|
+
"--pagination-color": paginationColorStyle
|
|
1122
|
+
};
|
|
1123
|
+
return /* @__PURE__ */ jsxs(
|
|
1124
|
+
"div",
|
|
1125
|
+
{
|
|
1126
|
+
"data-compoents": "emblas-pagination",
|
|
1127
|
+
className: cn(
|
|
1128
|
+
"flex",
|
|
1129
|
+
"items-center",
|
|
1130
|
+
"gap-7.25",
|
|
1131
|
+
align === "center" && [
|
|
1132
|
+
"justify-center"
|
|
1133
|
+
],
|
|
1134
|
+
className
|
|
1135
|
+
),
|
|
1136
|
+
style: paginationColorStyle2,
|
|
1137
|
+
children: [
|
|
1138
|
+
swiperNumber && /* @__PURE__ */ jsx(
|
|
1139
|
+
"div",
|
|
1140
|
+
{
|
|
1141
|
+
className: cn(
|
|
1142
|
+
swiperSnap,
|
|
1143
|
+
"relative",
|
|
1144
|
+
"after:absolute",
|
|
1145
|
+
"after:top-1/2",
|
|
1146
|
+
"after:right-[-15px]",
|
|
1147
|
+
"after:-translate-y-1/2",
|
|
1148
|
+
"after:block",
|
|
1149
|
+
// "after:bg-black",
|
|
1150
|
+
"after:bg-(--pagination-color)",
|
|
1151
|
+
"after:w-0.5",
|
|
1152
|
+
"after:h-3.75",
|
|
1153
|
+
"after:opacity-20",
|
|
1154
|
+
isWhite && [
|
|
1155
|
+
"after:bg-white"
|
|
1156
|
+
]
|
|
1157
|
+
),
|
|
1158
|
+
children: paginationNumber
|
|
1159
|
+
}
|
|
1160
|
+
),
|
|
1161
|
+
/* @__PURE__ */ jsx(
|
|
1162
|
+
"div",
|
|
1163
|
+
{
|
|
1164
|
+
className: cn(
|
|
1165
|
+
"flex",
|
|
1166
|
+
"flex-wrap",
|
|
1167
|
+
"justify-end",
|
|
1168
|
+
"items-center",
|
|
1169
|
+
"gap-y-0",
|
|
1170
|
+
"gap-x-2.5",
|
|
1171
|
+
"**:data-[component='emblas-pagination-dots']:bg-(--pagination-color)",
|
|
1172
|
+
isWhite && [
|
|
1173
|
+
"**:data-[component='emblas-pagination-dots']:bg-white"
|
|
1174
|
+
]
|
|
1175
|
+
),
|
|
1176
|
+
children: dots.map((index) => /* @__PURE__ */ jsx(
|
|
1177
|
+
"div",
|
|
1178
|
+
{
|
|
1179
|
+
"data-component": "emblas-pagination-dots",
|
|
1180
|
+
onClick: () => clickEvent(index),
|
|
1181
|
+
className: cn(
|
|
1182
|
+
"w-1.5",
|
|
1183
|
+
"h-1.5",
|
|
1184
|
+
"rounded-full",
|
|
1185
|
+
"cursor-pointer",
|
|
1186
|
+
"opacity-30",
|
|
1187
|
+
isSelected(index) && "opacity-100"
|
|
1188
|
+
)
|
|
1189
|
+
},
|
|
1190
|
+
index
|
|
1191
|
+
))
|
|
1192
|
+
}
|
|
1193
|
+
)
|
|
1194
|
+
]
|
|
1195
|
+
}
|
|
1196
|
+
);
|
|
1197
|
+
};
|
|
1198
|
+
EmblaPagination.displayName = "EmblaPagination";
|
|
1199
|
+
var emblas_pagination_default = EmblaPagination;
|
|
1200
|
+
var Tests = () => {
|
|
1201
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1202
|
+
/* @__PURE__ */ jsx(Carousel, { children: /* @__PURE__ */ jsx(CarouselPrevious, {}) }),
|
|
1203
|
+
/* @__PURE__ */ jsx(Button, { children: "test123133232" })
|
|
1204
|
+
] });
|
|
1205
|
+
};
|
|
1206
|
+
Tests.displayName = "Tests";
|
|
1207
|
+
var tests_default = Tests;
|
|
1208
|
+
|
|
1209
|
+
export { AnchorOffseter, AnchorTarget, AnchorTrigger, Anchors, CarouselContextProvider, embla_default as Embla, EmblaCarousels, EmblaCarouselsContents, EmblaCarouselsRoots, EmblaCarouselsSlides, embla_container_default as EmblaContainer, emblas_pagination_default as EmblaPagination, LenisContainerScroll, LenisRootScroll, LenisScroll, NativeScroll, ScrollContainer, ScrollContainerContext, tests_default as Tests, emblaCarouselsHooks, getRootLenis, getScrollContainer, getScrollContainerStores, setRootLenis, setScrollContainerStore, useCarouselContext, useCarouselsContext, useLenisStores, useScrollContainerContext, useScrollContainersStores };
|
|
1210
|
+
//# sourceMappingURL=index.js.map
|
|
1211
|
+
//# sourceMappingURL=index.js.map
|