react-spring-carousel 3.0.0-beta068 → 3.0.0-beta071

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.
Files changed (45) hide show
  1. package/dist/{types → declarations}/index.d.ts +3 -3
  2. package/dist/declarations/modules/index.d.ts +1 -0
  3. package/dist/declarations/modules/useEventsModule.d.ts +5 -0
  4. package/dist/{types → declarations}/modules/useFullscreenModule.d.ts +6 -12
  5. package/dist/{types → declarations}/modules/useThumbsModule.d.ts +14 -14
  6. package/dist/{types → declarations}/types/common.d.ts +34 -34
  7. package/dist/{types → declarations}/types/index.d.ts +3 -4
  8. package/dist/{types/modules/useEventsModule.d.ts → declarations/types/useEventsModule.types.d.ts} +46 -51
  9. package/dist/declarations/types/useFullscreenModule.types.d.ts +6 -0
  10. package/dist/{types → declarations}/types/useSpringCarousel.types.d.ts +102 -102
  11. package/dist/{types → declarations}/types/useTransitionCarousel.types.d.ts +33 -33
  12. package/dist/{types → declarations}/useSpringCarousel.d.ts +18 -18
  13. package/dist/{types → declarations}/useTransitionCarousel.d.ts +5 -5
  14. package/dist/index.cjs +1 -0
  15. package/dist/index.js +15 -0
  16. package/dist/index2.cjs +1 -0
  17. package/dist/index2.js +6 -0
  18. package/dist/useEventsModule-0feadbf7.cjs +1 -0
  19. package/dist/useEventsModule-538b90c9.js +33 -0
  20. package/dist/useSpringCarousel.cjs +1 -0
  21. package/dist/useSpringCarousel.js +665 -0
  22. package/dist/useThumbsModule-57ac2128.cjs +27 -0
  23. package/dist/useThumbsModule-f5b73ecb.js +723 -0
  24. package/dist/useTransitionCarousel.cjs +1 -0
  25. package/dist/useTransitionCarousel.js +255 -0
  26. package/package.json +37 -48
  27. package/README.md +0 -54
  28. package/dist/cjs/index.js +0 -2
  29. package/dist/cjs/index.js.map +0 -1
  30. package/dist/esm/index.js +0 -2
  31. package/dist/esm/index.js.map +0 -1
  32. package/dist/esm/index2.js +0 -2
  33. package/dist/esm/index2.js.map +0 -1
  34. package/dist/esm/useFullscreenModule-519d337d.js +0 -2
  35. package/dist/esm/useFullscreenModule-519d337d.js.map +0 -1
  36. package/dist/esm/useSpringCarousel.js +0 -2
  37. package/dist/esm/useSpringCarousel.js.map +0 -1
  38. package/dist/esm/useThumbsModule-faa196f9.js +0 -2
  39. package/dist/esm/useThumbsModule-faa196f9.js.map +0 -1
  40. package/dist/esm/useTransitionCarousel.js +0 -2
  41. package/dist/esm/useTransitionCarousel.js.map +0 -1
  42. package/dist/types/mockedItems.d.ts +0 -2
  43. package/dist/types/modules/index.d.ts +0 -3
  44. package/dist/umd/index.js +0 -2
  45. package/dist/umd/index.js.map +0 -1
@@ -0,0 +1,665 @@
1
+ import { u as De, j as P } from "./useThumbsModule-f5b73ecb.js";
2
+ import { useSpring as qe, config as X, useIsomorphicLayoutEffect as Be } from "@react-spring/web";
3
+ import { useRef as m, useEffect as N, createContext as He, useCallback as Oe, useContext as ze } from "react";
4
+ import { u as Xe } from "./useEventsModule-538b90c9.js";
5
+ import { useDrag as Ye } from "@use-gesture/react";
6
+ import Je from "resize-observer-polyfill";
7
+ import $ from "screenfull";
8
+ function Ke({
9
+ mainCarouselWrapperRef: n,
10
+ onFullScreenChange: v,
11
+ handleResize: E
12
+ }) {
13
+ const Y = m(!1);
14
+ N(() => {
15
+ function h() {
16
+ document.fullscreenElement && (O(!0), v(!0), E && E()), document.fullscreenElement || (O(!1), v(!1), E && E());
17
+ }
18
+ if ($.isEnabled)
19
+ return $.on("change", h), () => {
20
+ $.isEnabled && $.off("change", h);
21
+ };
22
+ }, []);
23
+ function O(h) {
24
+ Y.current = h;
25
+ }
26
+ function b() {
27
+ return Y.current;
28
+ }
29
+ function k(h) {
30
+ $.isEnabled && $.request(h || n.current);
31
+ }
32
+ function u() {
33
+ $.isEnabled && $.exit();
34
+ }
35
+ return {
36
+ enterFullscreen: k,
37
+ exitFullscreen: u,
38
+ getIsFullscreen: b
39
+ };
40
+ }
41
+ function rt({
42
+ items: n,
43
+ init: v = !0,
44
+ withThumbs: E,
45
+ thumbsSlideAxis: Y = "x",
46
+ itemsPerSlide: O = 1,
47
+ slideType: b = "fixed",
48
+ gutter: k = 0,
49
+ withLoop: u = !1,
50
+ startEndGutter: h = 0,
51
+ carouselSlideAxis: i = "x",
52
+ disableGestures: de = !1,
53
+ draggingSlideTreshold: L,
54
+ slideWhenThresholdIsReached: me = !1,
55
+ freeScroll: c,
56
+ enableFreeScrollDrag: xe,
57
+ initialStartingPosition: A,
58
+ prepareThumbsData: ye,
59
+ initialActiveItem: M = 0,
60
+ animateWhenActiveItemChange: Ie = !0,
61
+ getControllerRef: S
62
+ }) {
63
+ const w = O > n.length ? n.length : O, J = m(!1), K = m(L ?? 0), C = m("initial"), ee = m("initial"), te = m("initial"), p = m(M), s = m(M === 0), l = m(b === "fixed" && M === n.length - 1), f = m(null), x = m(null), re = m(!0), ne = m(0), ce = m(0), a = m(0), Te = m(u), be = m(b), Me = m(c), R = m(!1), Q = Oe(() => u ? [
64
+ ...n.map((e) => ({
65
+ ...e,
66
+ id: `prev-repeated-item-${e.id}`
67
+ })),
68
+ ...n,
69
+ ...n.map((e) => ({
70
+ ...e,
71
+ id: `next-repeated-item-${e.id}`
72
+ }))
73
+ ] : [...n], [n, u])(), [W, y] = qe(
74
+ () => ({
75
+ val: 0,
76
+ pause: !v,
77
+ onChange: ({ value: e }) => {
78
+ c && f.current ? (i === "x" ? f.current.scrollLeft = Math.abs(e.val) : f.current.scrollTop = Math.abs(e.val), G()) : x.current && (i === "x" ? x.current.style.transform = `translate3d(${e.val}px, 0px,0px)` : x.current.style.transform = `translate3d(0px,${e.val}px,0px)`);
79
+ }
80
+ }),
81
+ [c]
82
+ ), { emitEvent: U, useListenToCustomEvent: Z } = Xe(), { thumbsFragment: we, handleScroll: Ce } = De({
83
+ withThumbs: !!E,
84
+ thumbsSlideAxis: Y,
85
+ prepareThumbsData: ye,
86
+ items: n,
87
+ renderThumbFnProps: {
88
+ getIsActiveItem: fe,
89
+ getIsPrevItem: se,
90
+ useListenToCustomEvent: Z,
91
+ getIsNextItem: le
92
+ }
93
+ }), { enterFullscreen: ge, exitFullscreen: ve, getIsFullscreen: he } = Ke({
94
+ mainCarouselWrapperRef: f,
95
+ handleResize: () => _(),
96
+ onFullScreenChange: (e) => {
97
+ U({
98
+ eventName: "onFullscreenChange",
99
+ isFullscreen: e
100
+ });
101
+ }
102
+ });
103
+ function Fe(e) {
104
+ return b === "fixed" && !c ? {
105
+ marginRight: `${e ? 0 : k}px`,
106
+ flex: `1 0 calc(100% / ${w} - ${k * (w - 1) / w}px)`
107
+ } : {
108
+ marginRight: `${e ? 0 : k}px`
109
+ };
110
+ }
111
+ function d() {
112
+ var r;
113
+ const e = (r = f.current) == null ? void 0 : r.querySelector(".use-spring-carousel-item");
114
+ if (!e)
115
+ throw Error("No carousel items available!");
116
+ return e.getBoundingClientRect()[i === "x" ? "width" : "height"] + k;
117
+ }
118
+ function j({ from: e, to: r, nextActiveItem: t, immediate: o = !1, slideMode: T }) {
119
+ ee.current = T, typeof t == "number" && (c || (p.current = t), U({
120
+ eventName: "onSlideStartChange",
121
+ slideActionType: C.current,
122
+ slideMode: ee.current,
123
+ nextItem: {
124
+ startReached: s.current,
125
+ endReached: l.current,
126
+ index: c ? -1 : p.current,
127
+ id: c ? "" : n[p.current].id
128
+ }
129
+ })), a.current = r, y.start({
130
+ immediate: o,
131
+ from: {
132
+ val: e
133
+ },
134
+ to: {
135
+ val: r
136
+ },
137
+ config: {
138
+ ...X.default,
139
+ velocity: W.val.velocity
140
+ },
141
+ onRest(B) {
142
+ !o && B.finished && U({
143
+ eventName: "onSlideChange",
144
+ slideActionType: C.current,
145
+ slideMode: ee.current,
146
+ currentItem: {
147
+ startReached: s.current,
148
+ endReached: l.current,
149
+ index: c ? -1 : p.current,
150
+ id: c ? "" : n[p.current].id
151
+ }
152
+ });
153
+ }
154
+ }), E && !o && Ce(p.current);
155
+ }
156
+ function g() {
157
+ var e;
158
+ return u ? d() * n.length : Math.round(
159
+ Number(
160
+ (e = x.current) == null ? void 0 : e[i === "x" ? "scrollWidth" : "scrollHeight"]
161
+ ) - x.current.getBoundingClientRect()[i === "x" ? "width" : "height"] - h * 2
162
+ );
163
+ }
164
+ function ke() {
165
+ const e = `calc(100% - ${h * 2}px)`;
166
+ return {
167
+ width: i === "x" ? e : "100%",
168
+ height: i === "y" ? e : "100%"
169
+ };
170
+ }
171
+ function ue() {
172
+ var r;
173
+ const e = (r = x.current) == null ? void 0 : r.querySelector(".use-spring-carousel-item");
174
+ if (!e)
175
+ throw Error("No carousel items available!");
176
+ return e.getBoundingClientRect()[i === "x" ? "width" : "height"] + k;
177
+ }
178
+ function ie(e) {
179
+ const r = i === "x" ? "left" : "top", t = x.current;
180
+ t && (u ? (t.style.top = "0px", t.style.left = "0px", t.style[r] = `-${e - h}px`, s.current = !1, l.current = !1) : (t.style.left = "0px", t.style.top = "0px"));
181
+ }
182
+ function _(e = !1) {
183
+ if (x.current && e && (x.current.style.transform = "translate3d(0px, 0px,0px)", x.current.style.left = "0", x.current.style.top = "0"), b === "fixed" && ie(
184
+ A === "center" ? ue() * n.length - d() * Math.round((w - 1) / 2) : A === "end" ? ue() * n.length - d() * Math.round(w - 1) : ue() * n.length
185
+ ), b === "fluid") {
186
+ if (l.current && g() !== Math.abs(a.current) && !u) {
187
+ const r = -g();
188
+ a.current = r, y.start({
189
+ immediate: !0,
190
+ val: a.current
191
+ });
192
+ return;
193
+ }
194
+ if (Math.abs(a.current) > 0 && g() !== Math.abs(a.current) && !u && !c && te.current === "backward") {
195
+ const r = ne.current - g(), t = a.current + r;
196
+ return y.start({
197
+ immediate: !0,
198
+ val: t
199
+ }), () => {
200
+ a.current = t;
201
+ };
202
+ }
203
+ return;
204
+ }
205
+ if (!c && b === "fixed") {
206
+ const r = -(d() * p.current);
207
+ if (Math.abs(r) > g() && !u) {
208
+ const t = -g();
209
+ l.current = !0, a.current = t, y.start({
210
+ immediate: !0,
211
+ val: a.current
212
+ });
213
+ } else
214
+ a.current = r, y.start({
215
+ immediate: !0,
216
+ val: r
217
+ });
218
+ setTimeout(() => {
219
+ J.current = !1;
220
+ }, 0);
221
+ }
222
+ }
223
+ function F() {
224
+ return c && f.current ? f.current[i === "x" ? "scrollLeft" : "scrollTop"] : W.val.get();
225
+ }
226
+ function z(e, r) {
227
+ if (c && e === "next") {
228
+ const t = a.current + d();
229
+ return t > g() ? g() : t;
230
+ }
231
+ if (c && e === "prev") {
232
+ const t = a.current - d();
233
+ return t < 0 ? 0 : t;
234
+ }
235
+ return e === "next" ? typeof r == "number" ? -(r * d()) : a.current - d() : typeof r == "number" ? -(r * d()) : a.current + d();
236
+ }
237
+ function V({ type: e, index: r, immediate: t }) {
238
+ if (!v || R.current || s.current && !u)
239
+ return;
240
+ l.current && (te.current = "backward"), C.current = "prev", l.current = !1;
241
+ const o = typeof r == "number" ? r : p.current - 1;
242
+ if (c && G(), !u) {
243
+ const T = c ? z("prev", r) - d() / 3 < 0 : z("prev", r) + d() / 3 > 0;
244
+ if (s.current)
245
+ return;
246
+ if (T) {
247
+ s.current = !0, l.current = !1, j({
248
+ slideMode: e,
249
+ from: F(),
250
+ to: 0,
251
+ nextActiveItem: 0,
252
+ immediate: t
253
+ });
254
+ return;
255
+ }
256
+ }
257
+ if (u && (s.current || o < 0)) {
258
+ s.current = !1, l.current = !0, j({
259
+ slideMode: e,
260
+ from: F() - d() * n.length,
261
+ to: -(d() * n.length) + d(),
262
+ nextActiveItem: n.length - 1,
263
+ immediate: t
264
+ });
265
+ return;
266
+ }
267
+ o === 0 && (s.current = !0), (o === n.length - 1 || o === -1) && (l.current = !0), j({
268
+ slideMode: e,
269
+ from: F(),
270
+ to: z("prev", r),
271
+ nextActiveItem: o,
272
+ immediate: t
273
+ });
274
+ }
275
+ function D({ type: e, index: r, immediate: t }) {
276
+ if (!v || R.current || l.current && !u)
277
+ return;
278
+ s.current && (te.current = "forward"), C.current = "next", s.current = !1;
279
+ const o = r || p.current + 1;
280
+ if (c && G(), !u) {
281
+ const T = Math.abs(z("next", r)) > g() - d() / 3;
282
+ if (l.current)
283
+ return;
284
+ if (T) {
285
+ s.current = !1, l.current = !0, j({
286
+ slideMode: e,
287
+ from: F(),
288
+ to: c ? g() : -g(),
289
+ nextActiveItem: o,
290
+ immediate: t
291
+ });
292
+ return;
293
+ }
294
+ }
295
+ if (u && (l.current || o > n.length - 1)) {
296
+ l.current = !1, s.current = !0, j({
297
+ slideMode: e,
298
+ from: F() + d() * n.length,
299
+ to: 0,
300
+ nextActiveItem: 0,
301
+ immediate: t
302
+ });
303
+ return;
304
+ }
305
+ o === 0 && (s.current = !0), o === n.length - 1 && (l.current = !0), j({
306
+ slideMode: e,
307
+ from: F(),
308
+ to: z("next", r),
309
+ nextActiveItem: o,
310
+ immediate: t
311
+ });
312
+ }
313
+ function $e() {
314
+ L ? K.current = L : K.current = Math.floor(d() / 2 / 2);
315
+ }
316
+ function pe() {
317
+ !re.current && x.current && (ne.current = g(), Te.current = u, be.current = b, Me.current = c, ce.current = window.innerWidth, a.current = 0, oe({ id: 0, immediate: !0, shouldReset: !0 }), $e(), _());
318
+ }
319
+ const Ne = Ye(
320
+ (e) => {
321
+ const r = e.dragging, t = e.offset[i === "x" ? 0 : 1], o = e.movement[i === "x" ? 0 : 1], T = e.direction[i === "x" ? 0 : 1], B = o > K.current, H = o < -K.current, Ve = g();
322
+ if (r) {
323
+ if (T > 0 ? C.current = "prev" : C.current = "next", U({
324
+ ...e,
325
+ eventName: "onDrag",
326
+ slideActionType: C.current
327
+ }), c) {
328
+ if (t > 0) {
329
+ y.start({
330
+ from: {
331
+ val: F()
332
+ },
333
+ to: {
334
+ val: 0
335
+ },
336
+ config: {
337
+ velocity: e.velocity,
338
+ friction: 50,
339
+ tension: 1e3
340
+ }
341
+ }), e.cancel();
342
+ return;
343
+ }
344
+ y.start({
345
+ from: {
346
+ val: F()
347
+ },
348
+ to: {
349
+ val: -t
350
+ },
351
+ config: {
352
+ velocity: e.velocity,
353
+ friction: 50,
354
+ tension: 1e3
355
+ }
356
+ });
357
+ return;
358
+ }
359
+ y.start({
360
+ val: t,
361
+ config: {
362
+ velocity: e.velocity,
363
+ friction: 50,
364
+ tension: 1e3
365
+ }
366
+ }), me && H ? (D({ type: "drag" }), e.cancel()) : me && B && (V({ type: "drag" }), e.cancel()), Ve - Math.abs(t) < -(d() * 2) && e.cancel();
367
+ return;
368
+ }
369
+ if (e.last && c && t > 0) {
370
+ y.start({
371
+ from: {
372
+ val: F()
373
+ },
374
+ to: {
375
+ val: 0
376
+ },
377
+ config: {
378
+ velocity: e.velocity,
379
+ friction: 50,
380
+ tension: 1e3
381
+ }
382
+ });
383
+ return;
384
+ }
385
+ e.last && !e.canceled && c && (C.current === "prev" && V({ type: "drag" }), C.current === "next" && D({ type: "drag" })), e.last && !e.canceled && !c && (H ? !u && l.current ? y.start({
386
+ val: -g(),
387
+ config: {
388
+ ...X.default,
389
+ velocity: e.velocity
390
+ }
391
+ }) : D({ type: "drag" }) : B ? !u && s.current ? y.start({
392
+ val: 0,
393
+ config: {
394
+ ...X.default,
395
+ velocity: e.velocity
396
+ }
397
+ }) : V({ type: "drag" }) : y.start({
398
+ val: a.current,
399
+ config: {
400
+ ...X.default,
401
+ velocity: e.velocity
402
+ }
403
+ })), e.last && e.canceled && y.start({
404
+ val: a.current,
405
+ config: {
406
+ ...X.default,
407
+ velocity: e.velocity
408
+ }
409
+ });
410
+ },
411
+ {
412
+ enabled: v && !de && !c || !!c && !!xe,
413
+ axis: i,
414
+ from: () => c && f.current ? [
415
+ -f.current.scrollLeft,
416
+ -f.current.scrollTop
417
+ ] : i === "x" ? [W.val.get(), W.val.get()] : [W.val.get(), W.val.get()]
418
+ }
419
+ );
420
+ function Ee() {
421
+ return c ? i === "x" ? {
422
+ overflowX: "auto"
423
+ } : {
424
+ overflowY: "auto"
425
+ } : {};
426
+ }
427
+ function G() {
428
+ f.current && (a.current = f.current[i === "x" ? "scrollLeft" : "scrollTop"], f.current[i === "x" ? "scrollLeft" : "scrollTop"] === 0 && (s.current = !0, l.current = !1), f.current[i === "x" ? "scrollLeft" : "scrollTop"] > 0 && f.current[i === "x" ? "scrollLeft" : "scrollTop"] < g() && (s.current = !1, l.current = !1), f.current[i === "x" ? "scrollLeft" : "scrollTop"] === g() && (s.current = !1, l.current = !0));
429
+ }
430
+ function We() {
431
+ return c ? {
432
+ onWheel() {
433
+ W.val.stop(), G();
434
+ }
435
+ } : {};
436
+ }
437
+ function q(e, r) {
438
+ let t = 0;
439
+ if (typeof e == "string" ? t = n.findIndex((o) => o.id === e) : t = e, t < 0 || t >= n.length) {
440
+ if (r)
441
+ throw new Error(r);
442
+ console.error(`The item doesn't exist; check that the id provided - ${e} - is correct.`), t = -1;
443
+ }
444
+ return t;
445
+ }
446
+ function oe({ id: e, immediate: r, shouldReset: t, type: o }) {
447
+ if (!v || R.current)
448
+ return;
449
+ s.current = !1, l.current = !1;
450
+ const T = q(
451
+ e,
452
+ "The item you want to slide to doesn't exist; check the provided id."
453
+ );
454
+ if (T === p.current && !t)
455
+ return;
456
+ const B = q(n[p.current].id), H = q(n[T].id);
457
+ H > B ? D({
458
+ type: o || t ? "initial" : "click",
459
+ index: H,
460
+ immediate: r
461
+ }) : V({
462
+ type: o || t ? "initial" : "click",
463
+ index: H,
464
+ immediate: r
465
+ });
466
+ }
467
+ function le(e) {
468
+ const r = q(e, "The item doesn't exist; check the provided id."), t = p.current;
469
+ return u && t === n.length - 1 ? r === 0 : r === t + 1;
470
+ }
471
+ function se(e) {
472
+ const r = q(e, "The item doesn't exist; check the provided id."), t = p.current;
473
+ return u && t === 0 ? r === n.length - 1 : r === t - 1;
474
+ }
475
+ function fe(e) {
476
+ return q(e, "The item you want to check doesn't exist; check the provided id.") === p.current;
477
+ }
478
+ function Pe() {
479
+ return de ? "unset" : i === "x" ? "pan-y" : "pan-x";
480
+ }
481
+ const I = c ? {
482
+ useListenToCustomEvent: Z,
483
+ enterFullscreen: ge,
484
+ exitFullscreen: ve,
485
+ getIsFullscreen: he,
486
+ slideToPrevItem: (e = !0) => {
487
+ V({
488
+ type: "click",
489
+ immediate: !e
490
+ });
491
+ },
492
+ slideToNextItem: (e = !0) => {
493
+ D({
494
+ type: "click",
495
+ immediate: !e
496
+ });
497
+ }
498
+ } : {
499
+ useListenToCustomEvent: Z,
500
+ enterFullscreen: ge,
501
+ exitFullscreen: ve,
502
+ getIsFullscreen: he,
503
+ slideToPrevItem: (e = !0) => {
504
+ V({
505
+ type: "click",
506
+ immediate: !e
507
+ });
508
+ },
509
+ slideToNextItem: (e = !0) => {
510
+ D({
511
+ type: "click",
512
+ immediate: !e
513
+ });
514
+ },
515
+ slideToItem: (e, r = !0) => {
516
+ oe({ id: e, immediate: !r });
517
+ },
518
+ getIsNextItem: le,
519
+ getIsPrevItem: se,
520
+ getIsActiveItem: fe
521
+ };
522
+ Be(() => {
523
+ x.current && v && (J.current = !0, pe());
524
+ }, [v]), N(() => {
525
+ p.current !== M && oe({
526
+ id: M,
527
+ immediate: !Ie
528
+ });
529
+ }, [M]), N(() => {
530
+ if (v) {
531
+ if (M > n.length - 1)
532
+ throw new Error(
533
+ `initialActiveItem (${M}) is greater than the total quantity available items (${n.length}).`
534
+ );
535
+ w > n.length && console.warn(
536
+ `itemsPerSlide (${w}) is greater than the total quantity available items (${n.length}). Fallback to ${n.length})`
537
+ );
538
+ }
539
+ }, [M, n.length, w, v]), N(() => {
540
+ ce.current = window.innerWidth;
541
+ }, []), N(() => {
542
+ v && (J.current = !0, pe());
543
+ }, [A, w, h, k, v, u]), N(() => {
544
+ if (!v)
545
+ return;
546
+ function e() {
547
+ document.hidden ? R.current = !0 : R.current = !1;
548
+ }
549
+ return document.addEventListener("visibilitychange", e), () => {
550
+ document.removeEventListener("visibilitychange", e);
551
+ };
552
+ }, [v]), N(() => {
553
+ if (f.current) {
554
+ let e;
555
+ const r = new Je(() => {
556
+ if (re.current) {
557
+ re.current = !1;
558
+ return;
559
+ }
560
+ if (!R.current && !J.current) {
561
+ ce.current = window.innerWidth;
562
+ const t = _();
563
+ window.clearTimeout(e), e = setTimeout(() => {
564
+ ne.current = g(), typeof t == "function" && t();
565
+ }, 100);
566
+ }
567
+ });
568
+ return r.observe(f.current), () => {
569
+ r.disconnect();
570
+ };
571
+ }
572
+ }, [_, g]), N(() => {
573
+ S && S({
574
+ slideToNextItem: I.slideToNextItem,
575
+ slideToPrevItem: I.slideToPrevItem,
576
+ slideToItem: I == null ? void 0 : I.slideToItem
577
+ });
578
+ }, [S, I.slideToItem, I.slideToNextItem, I.slideToPrevItem]);
579
+ const Re = /* @__PURE__ */ P.jsx(ae.Provider, { value: I, children: we }), je = /* @__PURE__ */ P.jsx(ae.Provider, { value: I, children: /* @__PURE__ */ P.jsx(
580
+ "div",
581
+ {
582
+ className: "use-spring-carousel-main-wrapper",
583
+ ref: f,
584
+ ...We(),
585
+ style: {
586
+ display: "flex",
587
+ position: "relative",
588
+ width: "100%",
589
+ height: "100%",
590
+ ...Ee()
591
+ },
592
+ children: /* @__PURE__ */ P.jsxs(
593
+ "div",
594
+ {
595
+ className: "use-spring-carousel-track-wrapper",
596
+ ref: x,
597
+ ...Ne(),
598
+ style: {
599
+ position: "relative",
600
+ display: "flex",
601
+ flexDirection: i === "x" ? "row" : "column",
602
+ touchAction: Pe(),
603
+ ...ke()
604
+ },
605
+ children: [
606
+ (c || !u) && h ? /* @__PURE__ */ P.jsx(
607
+ "div",
608
+ {
609
+ style: {
610
+ flexShrink: 0,
611
+ width: h
612
+ }
613
+ }
614
+ ) : null,
615
+ Q.map((e, r) => /* @__PURE__ */ P.jsx(
616
+ "div",
617
+ {
618
+ className: "use-spring-carousel-item",
619
+ "data-testid": "use-spring-carousel-item-wrapper",
620
+ style: {
621
+ display: "flex",
622
+ position: "relative",
623
+ flex: "1",
624
+ ...Fe(
625
+ r === Q.findIndex(
626
+ (t) => t.id === Q[Q.length - 1].id
627
+ )
628
+ )
629
+ },
630
+ children: typeof e.renderItem == "function" ? e.renderItem({
631
+ getIsActiveItem: fe,
632
+ getIsNextItem: le,
633
+ getIsPrevItem: se,
634
+ useListenToCustomEvent: Z
635
+ }) : e.renderItem
636
+ },
637
+ `${e.id}-${r}`
638
+ )),
639
+ (c || !u) && h ? /* @__PURE__ */ P.jsx(
640
+ "div",
641
+ {
642
+ style: {
643
+ flexShrink: 0,
644
+ width: h
645
+ }
646
+ }
647
+ ) : null
648
+ ]
649
+ }
650
+ )
651
+ }
652
+ ) });
653
+ return { ...I, carouselFragment: je, thumbsFragment: Re };
654
+ }
655
+ const ae = He(void 0);
656
+ function nt() {
657
+ const n = ze(ae);
658
+ if (!n)
659
+ throw new Error("useSpringCarouselContext must be used within the carousel.");
660
+ return n;
661
+ }
662
+ export {
663
+ rt as useSpringCarousel,
664
+ nt as useSpringCarouselContext
665
+ };