@ankhorage/zora 28.5.1 → 28.5.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 28.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 88218a7: Load only the active Carousel slide initially, preload its next slide after image readiness, and preserve transition layers without restarting fade animations on layout changes.
8
+
9
+ ## 28.5.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 3634b1a: Allow published web artifacts to consume React 19.3 alongside the Expo 57 native React baseline.
14
+ - 77d4362: Update dependencies: `@ankhorage/surface`, `react-native-enriched-html`.
15
+
3
16
  ## 28.5.1
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # ZORA
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v28.5.1](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: configured](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v28.5.3](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: configured](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
7
7
 
8
8
  Provides opinionated React Native and React Native Web UI components, theme primitives, registries, and reader surfaces built on @ankhorage/surface.
9
9
 
@@ -50,7 +50,11 @@ Open `./paradox/index.html` locally in your browser to browse the complete docum
50
50
 
51
51
  ## Contributors
52
52
 
53
+ <a href="https://github.com/ankhorage-renovate-sync%5Bbot%5D"><img src="https://avatars.githubusercontent.com/u/323340348?s=64" width="40" height="40" alt="ankhorage-renovate-sync%5Bbot%5D" /></a>
53
54
  <a href="https://github.com/artiphishle"><img src="https://avatars.githubusercontent.com/u/137318798?s=64" width="40" height="40" alt="artiphishle" /></a>
55
+ <a href="https://github.com/github-actions%5Bbot%5D"><img src="https://avatars.githubusercontent.com/u/41898282?s=64" width="40" height="40" alt="github-actions%5Bbot%5D" /></a>
56
+ <a href="https://github.com/renovate%5Bbot%5D"><img src="https://avatars.githubusercontent.com/u/29139614?s=64" width="40" height="40" alt="renovate%5Bbot%5D" /></a>
57
+ <a href="https://github.com/Copilot"><img src="https://avatars.githubusercontent.com/u/198982749?s=64" width="40" height="40" alt="Copilot" /></a>
54
58
  <a href="https://github.com/faeb187"><img src="https://avatars.githubusercontent.com/u/389333?s=64" width="40" height="40" alt="faeb187" /></a>
55
59
  <a href="https://github.com/artiphishle-agent"><img src="https://avatars.githubusercontent.com/u/341682830?s=64" width="40" height="40" alt="artiphishle-agent" /></a>
56
60
 
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../src/features/carousel/Carousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,sBAAsB,CAAC;AAI7F;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,KAAK,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,UAAU,EACV,UAAmB,EACnB,eAAsB,EACtB,cAAoB,EACpB,YAAmB,EACnB,cAAsB,EACtB,aAAa,EACb,YAAmB,EACnB,cAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,UAAkB,EAClB,cAAsB,EACtB,aAAgC,EAChC,SAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,UAAoB,EACpB,UAAU,EACV,KAAK,EACL,WAAW,EACX,MAAM,GACP,EAAE,aAAa,4BA6Ff"}
1
+ {"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../src/features/carousel/Carousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,sBAAsB,CAAC;AAI7F;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,KAAK,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,UAAU,EACV,UAAmB,EACnB,eAAsB,EACtB,cAAoB,EACpB,YAAmB,EACnB,cAAsB,EACtB,aAAa,EACb,YAAmB,EACnB,cAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,UAAkB,EAClB,cAAsB,EACtB,aAAgC,EAChC,SAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,UAAoB,EACpB,UAAU,EACV,KAAK,EACL,WAAW,EACX,MAAM,GACP,EAAE,aAAa,4BAkJf"}
@@ -9,6 +9,10 @@ import { useCarouselPlayback } from './useCarouselPlayback';
9
9
  export function Carousel({ slides, index, defaultIndex, onIndexChange, autoPlay, paused, loop, intervalMs, transition = 'fade', enterDurationMs = 1200, exitDurationMs = 800, initialScale = 1.06, animateOnMount = false, reducedMotion, showProgress = true, progressHeight = 4, progressTrackColor, progressIndicatorColor, progressTrackStyle, progressIndicatorStyle, showArrows = false, showIndicators = false, previousLabel = 'Previous slide', nextLabel = 'Next slide', controlColor, controlBackgroundColor, controlsStyle, activeIndicatorColor, inactiveIndicatorColor, indicatorsStyle, resizeMode = 'cover', imageStyle, style, renderImage, testID, }) {
10
10
  const { theme } = useZoraTheme();
11
11
  const [width, setWidth] = React.useState(0);
12
+ const initialIndex = normalizeSlideIndex(index ?? defaultIndex ?? 0, slides.length);
13
+ const initialSlide = slides.at(initialIndex);
14
+ const [mountedSlideKeys, setMountedSlideKeys] = React.useState(() => initialSlide ? new Set([initialSlide.key]) : new Set());
15
+ const [readySlideKeys, setReadySlideKeys] = React.useState(() => new Set());
12
16
  const { activeIndex, controlledWithoutHandler, direction, loop: enabledLoop, navigate, progress, shouldReduceMotion, } = useCarouselPlayback({
13
17
  slides,
14
18
  index,
@@ -20,6 +24,26 @@ export function Carousel({ slides, index, defaultIndex, onIndexChange, autoPlay,
20
24
  intervalMs,
21
25
  reducedMotion,
22
26
  });
27
+ const activeSlide = slides.at(activeIndex);
28
+ const nextIndex = getNextSlideIndex(activeIndex, slides.length, enabledLoop);
29
+ const nextSlide = nextIndex === undefined ? undefined : slides.at(nextIndex);
30
+ const activeSlideKey = activeSlide?.key;
31
+ const nextSlideKey = nextSlide?.key;
32
+ const mountedKeys = ensureMountedSlide(ensureMountedSlide(mountedSlideKeys, activeSlideKey), getPreloadedSlideKey(activeSlideKey, nextSlideKey, readySlideKeys));
33
+ const markSlideLoaded = React.useCallback((slideKey) => {
34
+ setReadySlideKeys((current) => ensureMountedSlide(current, slideKey));
35
+ if (slideKey === activeSlideKey) {
36
+ setMountedSlideKeys((current) => ensureMountedSlide(current, nextSlideKey));
37
+ }
38
+ }, [activeSlideKey, nextSlideKey]);
39
+ const completeTransition = React.useCallback((completedSlideKey) => {
40
+ if (!activeSlideKey || completedSlideKey !== activeSlideKey)
41
+ return;
42
+ const transitionRetentionKeys = [activeSlideKey, nextSlideKey].filter((slideKey) => slideKey !== undefined);
43
+ setMountedSlideKeys((current) => new Set(transitionRetentionKeys.filter((slideKey) => slideKey === activeSlideKey ||
44
+ current.has(slideKey) ||
45
+ readySlideKeys.has(activeSlideKey))));
46
+ }, [activeSlideKey, nextSlideKey, readySlideKeys]);
23
47
  if (slides.length === 0)
24
48
  return null;
25
49
  const canPrevious = enabledLoop || activeIndex > 0;
@@ -27,18 +51,26 @@ export function Carousel({ slides, index, defaultIndex, onIndexChange, autoPlay,
27
51
  const markerColor = activeIndicatorColor ?? theme.colors.primary;
28
52
  const idleMarkerColor = inactiveIndicatorColor ?? theme.semantics.neutral.divider;
29
53
  return (<View onLayout={(event) => setWidth(event.nativeEvent.layout.width)} testID={testID} style={[{ position: 'relative', overflow: 'hidden', width: '100%', height: '100%' }, style]}>
30
- {slides.map((slide, slideIndex) => (<CarouselLayer key={slide.key} active={activeIndex === slideIndex} animate={slides.length > 1} animateOnMount={animateOnMount} direction={direction} enterDurationMs={enterDurationMs} exitDurationMs={exitDurationMs} imageStyle={imageStyle} initialScale={initialScale} reducedMotion={shouldReduceMotion} renderImage={renderImage} resizeMode={resizeMode} slide={slide} slideIndex={slideIndex} transition={transition} width={width}/>))}
54
+ {slides.flatMap((slide, slideIndex) => mountedKeys.has(slide.key)
55
+ ? [
56
+ <CarouselLayer key={slide.key} active={activeIndex === slideIndex} animate={slides.length > 1} animateOnMount={animateOnMount || activeIndex !== initialIndex} direction={direction} enterDurationMs={enterDurationMs} exitDurationMs={exitDurationMs} imageStyle={imageStyle} initialScale={initialScale} onImageLoad={() => markSlideLoaded(slide.key)} onTransitionComplete={completeTransition} reducedMotion={shouldReduceMotion} renderImage={renderImage} resizeMode={resizeMode} slide={slide} slideIndex={slideIndex} transition={transition} width={width}/>,
57
+ ]
58
+ : [])}
31
59
  <CarouselControls activeIndex={activeIndex} canNext={canNext} canPrevious={canPrevious} controlBackgroundColor={controlBackgroundColor ?? theme.semantics.surface.raised} controlColor={controlColor ?? theme.semantics.content.default} controlledWithoutHandler={controlledWithoutHandler} controlsStyle={controlsStyle} navigate={navigate} nextLabel={nextLabel} previousLabel={previousLabel} show={showArrows && slides.length > 1} testID={testID}/>
32
60
  <CarouselIndicators activeIndex={activeIndex} activeColor={markerColor} controlledWithoutHandler={controlledWithoutHandler} idleColor={idleMarkerColor} indicatorsStyle={indicatorsStyle} navigate={navigate} show={showIndicators && slides.length > 1} slides={slides} testID={testID}/>
33
61
  <CarouselProgress height={progressHeight} indicatorColor={progressIndicatorColor ?? theme.colors.primary} indicatorStyle={progressIndicatorStyle} progress={progress} show={showProgress && slides.length > 1} testID={testID} trackColor={progressTrackColor ?? theme.semantics.neutral.divider} trackStyle={progressTrackStyle}/>
34
62
  </View>);
35
63
  }
36
64
  /*** Keep departing slides mounted for an animated overlap without unmounting content. */
37
- function CarouselLayer({ slide, slideIndex, active, animate, animateOnMount, direction, enterDurationMs = 1200, exitDurationMs = 800, initialScale = 1.06, reducedMotion, renderImage, resizeMode, imageStyle, transition, width, }) {
65
+ function CarouselLayer({ slide, slideIndex, active, animate, animateOnMount, direction, enterDurationMs = 1200, exitDurationMs = 800, initialScale = 1.06, onImageLoad, onTransitionComplete, reducedMotion, renderImage, resizeMode, imageStyle, transition, width, }) {
38
66
  const [opacity] = React.useState(() => new Animated.Value(active && !animateOnMount ? 1 : 0));
39
67
  const [scale] = React.useState(() => new Animated.Value(active && animateOnMount ? initialScale : 1));
40
68
  const [offset] = React.useState(() => new Animated.Value(0));
41
69
  const hasMounted = React.useRef(false);
70
+ const widthRef = React.useRef(width);
71
+ React.useEffect(() => {
72
+ widthRef.current = width;
73
+ }, [width]);
42
74
  React.useEffect(() => {
43
75
  const firstRender = !hasMounted.current;
44
76
  hasMounted.current = true;
@@ -51,17 +83,19 @@ function CarouselLayer({ slide, slideIndex, active, animate, animateOnMount, dir
51
83
  opacity.setValue(active ? 1 : 0);
52
84
  scale.setValue(1);
53
85
  offset.setValue(0);
86
+ if (active)
87
+ onTransitionComplete(slide.key);
54
88
  return;
55
89
  }
56
90
  if (transition === 'slide') {
57
91
  scale.setValue(1);
58
92
  if (active) {
59
- offset.setValue(direction * width);
93
+ offset.setValue(direction * widthRef.current);
60
94
  opacity.setValue(1);
61
95
  }
62
96
  Animated.parallel([
63
97
  Animated.timing(offset, {
64
- toValue: active ? 0 : -direction * width,
98
+ toValue: active ? 0 : -direction * widthRef.current,
65
99
  duration: Math.max(0, active ? enterDurationMs : exitDurationMs),
66
100
  easing: Easing.bezier(0.4, 0, 0.2, 1),
67
101
  useNativeDriver: true,
@@ -72,7 +106,10 @@ function CarouselLayer({ slide, slideIndex, active, animate, animateOnMount, dir
72
106
  easing: Easing.linear,
73
107
  useNativeDriver: true,
74
108
  }),
75
- ]).start();
109
+ ]).start(({ finished }) => {
110
+ if (active && finished)
111
+ onTransitionComplete(slide.key);
112
+ });
76
113
  }
77
114
  else if (active) {
78
115
  opacity.setValue(0);
@@ -90,7 +127,10 @@ function CarouselLayer({ slide, slideIndex, active, animate, animateOnMount, dir
90
127
  easing: Easing.bezier(0.4, 0, 0.2, 1),
91
128
  useNativeDriver: true,
92
129
  }),
93
- ]).start();
130
+ ]).start(({ finished }) => {
131
+ if (finished)
132
+ onTransitionComplete(slide.key);
133
+ });
94
134
  }
95
135
  else {
96
136
  Animated.timing(opacity, {
@@ -118,13 +158,50 @@ function CarouselLayer({ slide, slideIndex, active, animate, animateOnMount, dir
118
158
  reducedMotion,
119
159
  scale,
120
160
  transition,
121
- width,
161
+ onTransitionComplete,
162
+ slide.key,
122
163
  ]);
123
164
  return (<Animated.View accessibilityElementsHidden={!active} importantForAccessibility={active ? 'auto' : 'no-hide-descendants'} pointerEvents={active ? 'auto' : 'none'} style={[StyleSheet.absoluteFill, { opacity, transform: [{ scale }, { translateX: offset }] }]}>
124
- {slide.source !== undefined ? (renderImage ? (renderImage(slide, slideIndex)) : (<Image accessibilityLabel={slide.alt} accessible={Boolean(slide.alt)} resizeMode={resizeMode} source={typeof slide.source === 'string' ? { uri: slide.source } : slide.source} style={[StyleSheet.absoluteFill, imageStyle]}/>)) : null}
165
+ {slide.source !== undefined ? (renderImage ? (renderCarouselImage(renderImage(slide, slideIndex), onImageLoad)) : (<Image accessibilityLabel={slide.alt} accessible={Boolean(slide.alt)} resizeMode={resizeMode} source={typeof slide.source === 'string' ? { uri: slide.source } : slide.source} style={[StyleSheet.absoluteFill, imageStyle]} onLoad={onImageLoad}/>)) : null}
125
166
  {slide.content}
126
167
  </Animated.View>);
127
168
  }
169
+ /*** Retain consumer image behavior while observing readiness for adjacent-slide preloading. */
170
+ function renderCarouselImage(image, onImageLoad) {
171
+ if (!React.isValidElement(image))
172
+ return image;
173
+ const existingOnLoad = image.props.onLoad;
174
+ return React.cloneElement(image, {
175
+ onLoad: (event) => {
176
+ existingOnLoad?.(event);
177
+ onImageLoad();
178
+ },
179
+ });
180
+ }
181
+ /*** Return an immutable mounted-key set containing one requested slide. */
182
+ function ensureMountedSlide(mountedSlideKeys, slideKey) {
183
+ if (!slideKey || mountedSlideKeys.has(slideKey))
184
+ return mountedSlideKeys;
185
+ return new Set([...mountedSlideKeys, slideKey]);
186
+ }
187
+ /*** Return the next slide key only after the active slide image is ready. */
188
+ function getPreloadedSlideKey(activeSlideKey, nextSlideKey, readySlideKeys) {
189
+ if (!activeSlideKey || !readySlideKeys.has(activeSlideKey))
190
+ return undefined;
191
+ return nextSlideKey;
192
+ }
193
+ /*** Resolve the slide to preload without wrapping when looping is disabled. */
194
+ function getNextSlideIndex(index, length, loop) {
195
+ if (length < 2 || (!loop && index === length - 1))
196
+ return undefined;
197
+ return (index + 1) % length;
198
+ }
199
+ /*** Clamp the initial server-rendered slide to the available slide collection. */
200
+ function normalizeSlideIndex(index, length) {
201
+ if (length === 0)
202
+ return 0;
203
+ return Math.min(Math.max(Math.trunc(index), 0), length - 1);
204
+ }
128
205
  /*** Render optional previous/next buttons without coupling the slide content to navigation. */
129
206
  function CarouselControls({ activeIndex, canNext, canPrevious, controlBackgroundColor, controlColor, controlledWithoutHandler, controlsStyle, navigate, nextLabel, previousLabel, show, testID, }) {
130
207
  if (!show)
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.js","sourceRoot":"","sources":["../../../src/features/carousel/Carousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OA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AAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE;CACrF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { Animated, Easing, Image, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport type { CarouselProps, CarouselSlide, CarouselTransition } from '../../types/carousel';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { useCarouselPlayback } from './useCarouselPlayback';\n\n/***\n * Present images, arbitrary React content, or both as a cross-platform slideshow.\n * A published web artifact exposes the same API without consumer source imports.\n */\nexport function Carousel({\n slides,\n index,\n defaultIndex,\n onIndexChange,\n autoPlay,\n paused,\n loop,\n intervalMs,\n transition = 'fade',\n enterDurationMs = 1200,\n exitDurationMs = 800,\n initialScale = 1.06,\n animateOnMount = false,\n reducedMotion,\n showProgress = true,\n progressHeight = 4,\n progressTrackColor,\n progressIndicatorColor,\n progressTrackStyle,\n progressIndicatorStyle,\n showArrows = false,\n showIndicators = false,\n previousLabel = 'Previous slide',\n nextLabel = 'Next slide',\n controlColor,\n controlBackgroundColor,\n controlsStyle,\n activeIndicatorColor,\n inactiveIndicatorColor,\n indicatorsStyle,\n resizeMode = 'cover',\n imageStyle,\n style,\n renderImage,\n testID,\n}: CarouselProps) {\n const { theme } = useZoraTheme();\n const [width, setWidth] = React.useState(0);\n const {\n activeIndex,\n controlledWithoutHandler,\n direction,\n loop: enabledLoop,\n navigate,\n progress,\n shouldReduceMotion,\n } = useCarouselPlayback({\n slides,\n index,\n defaultIndex,\n onIndexChange,\n autoPlay,\n paused,\n loop,\n intervalMs,\n reducedMotion,\n });\n\n if (slides.length === 0) return null;\n\n const canPrevious = enabledLoop || activeIndex > 0;\n const canNext = enabledLoop || activeIndex < slides.length - 1;\n const markerColor = activeIndicatorColor ?? theme.colors.primary;\n const idleMarkerColor = inactiveIndicatorColor ?? theme.semantics.neutral.divider;\n\n return (\n <View\n onLayout={(event) => setWidth(event.nativeEvent.layout.width)}\n testID={testID}\n style={[{ position: 'relative', overflow: 'hidden', width: '100%', height: '100%' }, style]}\n >\n {slides.map((slide, slideIndex) => (\n <CarouselLayer\n key={slide.key}\n active={activeIndex === slideIndex}\n animate={slides.length > 1}\n animateOnMount={animateOnMount}\n direction={direction}\n enterDurationMs={enterDurationMs}\n exitDurationMs={exitDurationMs}\n imageStyle={imageStyle}\n initialScale={initialScale}\n reducedMotion={shouldReduceMotion}\n renderImage={renderImage}\n resizeMode={resizeMode}\n slide={slide}\n slideIndex={slideIndex}\n transition={transition}\n width={width}\n />\n ))}\n <CarouselControls\n activeIndex={activeIndex}\n canNext={canNext}\n canPrevious={canPrevious}\n controlBackgroundColor={controlBackgroundColor ?? theme.semantics.surface.raised}\n controlColor={controlColor ?? theme.semantics.content.default}\n controlledWithoutHandler={controlledWithoutHandler}\n controlsStyle={controlsStyle}\n navigate={navigate}\n nextLabel={nextLabel}\n previousLabel={previousLabel}\n show={showArrows && slides.length > 1}\n testID={testID}\n />\n <CarouselIndicators\n activeIndex={activeIndex}\n activeColor={markerColor}\n controlledWithoutHandler={controlledWithoutHandler}\n idleColor={idleMarkerColor}\n indicatorsStyle={indicatorsStyle}\n navigate={navigate}\n show={showIndicators && slides.length > 1}\n slides={slides}\n testID={testID}\n />\n <CarouselProgress\n height={progressHeight}\n indicatorColor={progressIndicatorColor ?? theme.colors.primary}\n indicatorStyle={progressIndicatorStyle}\n progress={progress}\n show={showProgress && slides.length > 1}\n testID={testID}\n trackColor={progressTrackColor ?? theme.semantics.neutral.divider}\n trackStyle={progressTrackStyle}\n />\n </View>\n );\n}\n\ninterface CarouselLayerProps {\n readonly enterDurationMs?: CarouselProps['enterDurationMs'];\n readonly exitDurationMs?: CarouselProps['exitDurationMs'];\n readonly imageStyle: CarouselProps['imageStyle'];\n readonly initialScale?: CarouselProps['initialScale'];\n readonly renderImage: CarouselProps['renderImage'];\n readonly resizeMode: CarouselProps['resizeMode'];\n readonly slide: CarouselSlide;\n readonly slideIndex: number;\n readonly active: boolean;\n readonly animate: boolean;\n readonly animateOnMount: boolean;\n readonly direction: 1 | -1;\n readonly width: number;\n readonly transition: CarouselTransition;\n readonly reducedMotion: boolean;\n}\n\n/*** Keep departing slides mounted for an animated overlap without unmounting content. */\nfunction CarouselLayer({\n slide,\n slideIndex,\n active,\n animate,\n animateOnMount,\n direction,\n enterDurationMs = 1200,\n exitDurationMs = 800,\n initialScale = 1.06,\n reducedMotion,\n renderImage,\n resizeMode,\n imageStyle,\n transition,\n width,\n}: CarouselLayerProps) {\n const [opacity] = React.useState(() => new Animated.Value(active && !animateOnMount ? 1 : 0));\n const [scale] = React.useState(\n () => new Animated.Value(active && animateOnMount ? initialScale : 1),\n );\n const [offset] = React.useState(() => new Animated.Value(0));\n const hasMounted = React.useRef(false);\n\n React.useEffect(() => {\n const firstRender = !hasMounted.current;\n hasMounted.current = true;\n if (firstRender && !animateOnMount) return;\n opacity.stopAnimation();\n scale.stopAnimation();\n offset.stopAnimation();\n if (!animate || reducedMotion || transition === 'none') {\n opacity.setValue(active ? 1 : 0);\n scale.setValue(1);\n offset.setValue(0);\n return;\n }\n if (transition === 'slide') {\n scale.setValue(1);\n if (active) {\n offset.setValue(direction * width);\n opacity.setValue(1);\n }\n Animated.parallel([\n Animated.timing(offset, {\n toValue: active ? 0 : -direction * width,\n duration: Math.max(0, active ? enterDurationMs : exitDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }),\n Animated.timing(opacity, {\n toValue: active ? 1 : 0,\n duration: Math.max(0, active ? enterDurationMs : exitDurationMs),\n easing: Easing.linear,\n useNativeDriver: true,\n }),\n ]).start();\n } else if (active) {\n opacity.setValue(0);\n scale.setValue(initialScale);\n Animated.parallel([\n Animated.timing(opacity, {\n toValue: 1,\n duration: Math.max(0, enterDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }),\n Animated.timing(scale, {\n toValue: 1,\n duration: Math.max(0, enterDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }),\n ]).start();\n } else {\n Animated.timing(opacity, {\n toValue: 0,\n duration: Math.max(0, exitDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n }\n return () => {\n opacity.stopAnimation();\n scale.stopAnimation();\n offset.stopAnimation();\n };\n }, [\n active,\n animate,\n animateOnMount,\n direction,\n enterDurationMs,\n exitDurationMs,\n initialScale,\n offset,\n opacity,\n reducedMotion,\n scale,\n transition,\n width,\n ]);\n\n return (\n <Animated.View\n accessibilityElementsHidden={!active}\n importantForAccessibility={active ? 'auto' : 'no-hide-descendants'}\n pointerEvents={active ? 'auto' : 'none'}\n style={[StyleSheet.absoluteFill, { opacity, transform: [{ scale }, { translateX: offset }] }]}\n >\n {slide.source !== undefined ? (\n renderImage ? (\n renderImage(slide, slideIndex)\n ) : (\n <Image\n accessibilityLabel={slide.alt}\n accessible={Boolean(slide.alt)}\n resizeMode={resizeMode}\n source={typeof slide.source === 'string' ? { uri: slide.source } : slide.source}\n style={[StyleSheet.absoluteFill, imageStyle]}\n />\n )\n ) : null}\n {slide.content}\n </Animated.View>\n );\n}\n\ninterface CarouselNavigationProps {\n readonly activeIndex: number;\n readonly navigate: (index: number, direction: 1 | -1) => void;\n readonly controlledWithoutHandler: boolean;\n readonly testID: CarouselProps['testID'];\n}\n\ninterface CarouselControlsProps extends CarouselNavigationProps {\n readonly show: boolean;\n readonly canPrevious: boolean;\n readonly canNext: boolean;\n readonly previousLabel: string;\n readonly nextLabel: string;\n readonly controlColor: string;\n readonly controlBackgroundColor: string;\n readonly controlsStyle: CarouselProps['controlsStyle'];\n}\n\n/*** Render optional previous/next buttons without coupling the slide content to navigation. */\nfunction CarouselControls({\n activeIndex,\n canNext,\n canPrevious,\n controlBackgroundColor,\n controlColor,\n controlledWithoutHandler,\n controlsStyle,\n navigate,\n nextLabel,\n previousLabel,\n show,\n testID,\n}: CarouselControlsProps) {\n if (!show) return null;\n const buttonStyle = [styles.control, { backgroundColor: controlBackgroundColor }];\n const labelStyle = { color: controlColor, fontSize: 30 };\n return (\n <View pointerEvents=\"box-none\" style={[styles.controls, controlsStyle]}>\n <Pressable\n accessibilityLabel={previousLabel}\n accessibilityRole=\"button\"\n disabled={!canPrevious || controlledWithoutHandler}\n onPress={() => navigate(activeIndex - 1, -1)}\n style={buttonStyle}\n testID={testID ? `${testID}-previous` : undefined}\n >\n <Text style={labelStyle}>{'‹'}</Text>\n </Pressable>\n <Pressable\n accessibilityLabel={nextLabel}\n accessibilityRole=\"button\"\n disabled={!canNext || controlledWithoutHandler}\n onPress={() => navigate(activeIndex + 1, 1)}\n style={buttonStyle}\n testID={testID ? `${testID}-next` : undefined}\n >\n <Text style={labelStyle}>{'›'}</Text>\n </Pressable>\n </View>\n );\n}\n\ninterface CarouselIndicatorsProps extends CarouselNavigationProps {\n readonly show: boolean;\n readonly slides: CarouselProps['slides'];\n readonly activeColor: string;\n readonly idleColor: string;\n readonly indicatorsStyle: CarouselProps['indicatorsStyle'];\n}\n\n/*** Render accessible selection dots for the currently controlled slide. */\nfunction CarouselIndicators({\n activeIndex,\n activeColor,\n controlledWithoutHandler,\n idleColor,\n indicatorsStyle,\n navigate,\n show,\n slides,\n testID,\n}: CarouselIndicatorsProps) {\n if (!show) return null;\n return (\n <View pointerEvents=\"box-none\" style={[styles.indicators, indicatorsStyle]}>\n {slides.map((slide, slideIndex) => (\n <Pressable\n key={slide.key}\n accessibilityLabel={`Go to slide ${slideIndex + 1} of ${slides.length}`}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: slideIndex === activeIndex }}\n disabled={controlledWithoutHandler}\n onPress={() => navigate(slideIndex, slideIndex < activeIndex ? -1 : 1)}\n style={[\n styles.indicator,\n {\n backgroundColor: slideIndex === activeIndex ? activeColor : idleColor,\n width: slideIndex === activeIndex ? 24 : 8,\n },\n ]}\n testID={testID ? `${testID}-indicator-${slideIndex}` : undefined}\n />\n ))}\n </View>\n );\n}\n\ninterface CarouselProgressProps {\n readonly show: boolean;\n readonly height: number;\n readonly trackColor: string;\n readonly indicatorColor: string;\n readonly trackStyle: CarouselProps['progressTrackStyle'];\n readonly indicatorStyle: CarouselProps['progressIndicatorStyle'];\n readonly progress: Animated.Value;\n readonly testID: CarouselProps['testID'];\n}\n\n/*** Render an optional linear autoplay timer without adding any required UI to slides. */\nfunction CarouselProgress({\n height,\n indicatorColor,\n indicatorStyle,\n progress,\n show,\n testID,\n trackColor,\n trackStyle,\n}: CarouselProgressProps) {\n if (!show) return null;\n return (\n <View\n pointerEvents=\"none\"\n style={[styles.progress, { height, backgroundColor: trackColor }, trackStyle]}\n testID={testID ? `${testID}-progress` : undefined}\n >\n <Animated.View\n style={[\n {\n height: '100%',\n width: '100%',\n transformOrigin: 'left center',\n transform: [{ scaleX: progress }],\n backgroundColor: indicatorColor,\n },\n indicatorStyle,\n ]}\n />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n controls: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 14,\n right: 14,\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n },\n control: {\n width: 44,\n height: 44,\n borderRadius: 22,\n justifyContent: 'center',\n alignItems: 'center',\n },\n indicators: {\n position: 'absolute',\n bottom: 24,\n left: 0,\n right: 0,\n flexDirection: 'row',\n gap: 10,\n justifyContent: 'center',\n alignItems: 'center',\n },\n indicator: { height: 8, borderRadius: 8 },\n progress: { position: 'absolute', bottom: 0, left: 0, right: 0, overflow: 'hidden' },\n});\n"]}
1
+ {"version":3,"file":"Carousel.js","sourceRoot":"","sources":["../../../src/features/carousel/Carousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cA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EAAE,CAAC;QACT,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,eAAe;QAC/B,UAAU,EAAE,QAAQ;KACrB;IACD,OAAO,EAAE;QACP,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,EAAE;QAChB,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,aAAa,EAAE,KAAK;QACpB,GAAG,EAAE,EAAE;QACP,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;IACD,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE;IACzC,QAAQ,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE;CACrF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { Animated, Easing, Image, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport type { CarouselProps, CarouselSlide, CarouselTransition } from '../../types/carousel';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { useCarouselPlayback } from './useCarouselPlayback';\n\n/***\n * Present images, arbitrary React content, or both as a cross-platform slideshow.\n * A published web artifact exposes the same API without consumer source imports.\n */\nexport function Carousel({\n slides,\n index,\n defaultIndex,\n onIndexChange,\n autoPlay,\n paused,\n loop,\n intervalMs,\n transition = 'fade',\n enterDurationMs = 1200,\n exitDurationMs = 800,\n initialScale = 1.06,\n animateOnMount = false,\n reducedMotion,\n showProgress = true,\n progressHeight = 4,\n progressTrackColor,\n progressIndicatorColor,\n progressTrackStyle,\n progressIndicatorStyle,\n showArrows = false,\n showIndicators = false,\n previousLabel = 'Previous slide',\n nextLabel = 'Next slide',\n controlColor,\n controlBackgroundColor,\n controlsStyle,\n activeIndicatorColor,\n inactiveIndicatorColor,\n indicatorsStyle,\n resizeMode = 'cover',\n imageStyle,\n style,\n renderImage,\n testID,\n}: CarouselProps) {\n const { theme } = useZoraTheme();\n const [width, setWidth] = React.useState(0);\n const initialIndex = normalizeSlideIndex(index ?? defaultIndex ?? 0, slides.length);\n const initialSlide = slides.at(initialIndex);\n const [mountedSlideKeys, setMountedSlideKeys] = React.useState<ReadonlySet<string>>(() =>\n initialSlide ? new Set([initialSlide.key]) : new Set(),\n );\n const [readySlideKeys, setReadySlideKeys] = React.useState<ReadonlySet<string>>(() => new Set());\n const {\n activeIndex,\n controlledWithoutHandler,\n direction,\n loop: enabledLoop,\n navigate,\n progress,\n shouldReduceMotion,\n } = useCarouselPlayback({\n slides,\n index,\n defaultIndex,\n onIndexChange,\n autoPlay,\n paused,\n loop,\n intervalMs,\n reducedMotion,\n });\n\n const activeSlide = slides.at(activeIndex);\n const nextIndex = getNextSlideIndex(activeIndex, slides.length, enabledLoop);\n const nextSlide = nextIndex === undefined ? undefined : slides.at(nextIndex);\n const activeSlideKey = activeSlide?.key;\n const nextSlideKey = nextSlide?.key;\n const mountedKeys = ensureMountedSlide(\n ensureMountedSlide(mountedSlideKeys, activeSlideKey),\n getPreloadedSlideKey(activeSlideKey, nextSlideKey, readySlideKeys),\n );\n\n const markSlideLoaded = React.useCallback(\n (slideKey: string) => {\n setReadySlideKeys((current) => ensureMountedSlide(current, slideKey));\n if (slideKey === activeSlideKey) {\n setMountedSlideKeys((current) => ensureMountedSlide(current, nextSlideKey));\n }\n },\n [activeSlideKey, nextSlideKey],\n );\n\n const completeTransition = React.useCallback(\n (completedSlideKey: string) => {\n if (!activeSlideKey || completedSlideKey !== activeSlideKey) return;\n const transitionRetentionKeys = [activeSlideKey, nextSlideKey].filter(\n (slideKey): slideKey is string => slideKey !== undefined,\n );\n setMountedSlideKeys(\n (current) =>\n new Set(\n transitionRetentionKeys.filter(\n (slideKey) =>\n slideKey === activeSlideKey ||\n current.has(slideKey) ||\n readySlideKeys.has(activeSlideKey),\n ),\n ),\n );\n },\n [activeSlideKey, nextSlideKey, readySlideKeys],\n );\n\n if (slides.length === 0) return null;\n\n const canPrevious = enabledLoop || activeIndex > 0;\n const canNext = enabledLoop || activeIndex < slides.length - 1;\n const markerColor = activeIndicatorColor ?? theme.colors.primary;\n const idleMarkerColor = inactiveIndicatorColor ?? theme.semantics.neutral.divider;\n\n return (\n <View\n onLayout={(event) => setWidth(event.nativeEvent.layout.width)}\n testID={testID}\n style={[{ position: 'relative', overflow: 'hidden', width: '100%', height: '100%' }, style]}\n >\n {slides.flatMap((slide, slideIndex) =>\n mountedKeys.has(slide.key)\n ? [\n <CarouselLayer\n key={slide.key}\n active={activeIndex === slideIndex}\n animate={slides.length > 1}\n animateOnMount={animateOnMount || activeIndex !== initialIndex}\n direction={direction}\n enterDurationMs={enterDurationMs}\n exitDurationMs={exitDurationMs}\n imageStyle={imageStyle}\n initialScale={initialScale}\n onImageLoad={() => markSlideLoaded(slide.key)}\n onTransitionComplete={completeTransition}\n reducedMotion={shouldReduceMotion}\n renderImage={renderImage}\n resizeMode={resizeMode}\n slide={slide}\n slideIndex={slideIndex}\n transition={transition}\n width={width}\n />,\n ]\n : [],\n )}\n <CarouselControls\n activeIndex={activeIndex}\n canNext={canNext}\n canPrevious={canPrevious}\n controlBackgroundColor={controlBackgroundColor ?? theme.semantics.surface.raised}\n controlColor={controlColor ?? theme.semantics.content.default}\n controlledWithoutHandler={controlledWithoutHandler}\n controlsStyle={controlsStyle}\n navigate={navigate}\n nextLabel={nextLabel}\n previousLabel={previousLabel}\n show={showArrows && slides.length > 1}\n testID={testID}\n />\n <CarouselIndicators\n activeIndex={activeIndex}\n activeColor={markerColor}\n controlledWithoutHandler={controlledWithoutHandler}\n idleColor={idleMarkerColor}\n indicatorsStyle={indicatorsStyle}\n navigate={navigate}\n show={showIndicators && slides.length > 1}\n slides={slides}\n testID={testID}\n />\n <CarouselProgress\n height={progressHeight}\n indicatorColor={progressIndicatorColor ?? theme.colors.primary}\n indicatorStyle={progressIndicatorStyle}\n progress={progress}\n show={showProgress && slides.length > 1}\n testID={testID}\n trackColor={progressTrackColor ?? theme.semantics.neutral.divider}\n trackStyle={progressTrackStyle}\n />\n </View>\n );\n}\n\ninterface CarouselLayerProps {\n readonly enterDurationMs?: CarouselProps['enterDurationMs'];\n readonly exitDurationMs?: CarouselProps['exitDurationMs'];\n readonly imageStyle: CarouselProps['imageStyle'];\n readonly initialScale?: CarouselProps['initialScale'];\n readonly onImageLoad: () => void;\n readonly onTransitionComplete: (slideKey: string) => void;\n readonly renderImage: CarouselProps['renderImage'];\n readonly resizeMode: CarouselProps['resizeMode'];\n readonly slide: CarouselSlide;\n readonly slideIndex: number;\n readonly active: boolean;\n readonly animate: boolean;\n readonly animateOnMount: boolean;\n readonly direction: 1 | -1;\n readonly width: number;\n readonly transition: CarouselTransition;\n readonly reducedMotion: boolean;\n}\n\n/*** Keep departing slides mounted for an animated overlap without unmounting content. */\nfunction CarouselLayer({\n slide,\n slideIndex,\n active,\n animate,\n animateOnMount,\n direction,\n enterDurationMs = 1200,\n exitDurationMs = 800,\n initialScale = 1.06,\n onImageLoad,\n onTransitionComplete,\n reducedMotion,\n renderImage,\n resizeMode,\n imageStyle,\n transition,\n width,\n}: CarouselLayerProps) {\n const [opacity] = React.useState(() => new Animated.Value(active && !animateOnMount ? 1 : 0));\n const [scale] = React.useState(\n () => new Animated.Value(active && animateOnMount ? initialScale : 1),\n );\n const [offset] = React.useState(() => new Animated.Value(0));\n const hasMounted = React.useRef(false);\n const widthRef = React.useRef(width);\n\n React.useEffect(() => {\n widthRef.current = width;\n }, [width]);\n\n React.useEffect(() => {\n const firstRender = !hasMounted.current;\n hasMounted.current = true;\n if (firstRender && !animateOnMount) return;\n opacity.stopAnimation();\n scale.stopAnimation();\n offset.stopAnimation();\n if (!animate || reducedMotion || transition === 'none') {\n opacity.setValue(active ? 1 : 0);\n scale.setValue(1);\n offset.setValue(0);\n if (active) onTransitionComplete(slide.key);\n return;\n }\n if (transition === 'slide') {\n scale.setValue(1);\n if (active) {\n offset.setValue(direction * widthRef.current);\n opacity.setValue(1);\n }\n Animated.parallel([\n Animated.timing(offset, {\n toValue: active ? 0 : -direction * widthRef.current,\n duration: Math.max(0, active ? enterDurationMs : exitDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }),\n Animated.timing(opacity, {\n toValue: active ? 1 : 0,\n duration: Math.max(0, active ? enterDurationMs : exitDurationMs),\n easing: Easing.linear,\n useNativeDriver: true,\n }),\n ]).start(({ finished }) => {\n if (active && finished) onTransitionComplete(slide.key);\n });\n } else if (active) {\n opacity.setValue(0);\n scale.setValue(initialScale);\n Animated.parallel([\n Animated.timing(opacity, {\n toValue: 1,\n duration: Math.max(0, enterDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }),\n Animated.timing(scale, {\n toValue: 1,\n duration: Math.max(0, enterDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }),\n ]).start(({ finished }) => {\n if (finished) onTransitionComplete(slide.key);\n });\n } else {\n Animated.timing(opacity, {\n toValue: 0,\n duration: Math.max(0, exitDurationMs),\n easing: Easing.bezier(0.4, 0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n }\n return () => {\n opacity.stopAnimation();\n scale.stopAnimation();\n offset.stopAnimation();\n };\n }, [\n active,\n animate,\n animateOnMount,\n direction,\n enterDurationMs,\n exitDurationMs,\n initialScale,\n offset,\n opacity,\n reducedMotion,\n scale,\n transition,\n onTransitionComplete,\n slide.key,\n ]);\n\n return (\n <Animated.View\n accessibilityElementsHidden={!active}\n importantForAccessibility={active ? 'auto' : 'no-hide-descendants'}\n pointerEvents={active ? 'auto' : 'none'}\n style={[StyleSheet.absoluteFill, { opacity, transform: [{ scale }, { translateX: offset }] }]}\n >\n {slide.source !== undefined ? (\n renderImage ? (\n renderCarouselImage(renderImage(slide, slideIndex), onImageLoad)\n ) : (\n <Image\n accessibilityLabel={slide.alt}\n accessible={Boolean(slide.alt)}\n resizeMode={resizeMode}\n source={typeof slide.source === 'string' ? { uri: slide.source } : slide.source}\n style={[StyleSheet.absoluteFill, imageStyle]}\n onLoad={onImageLoad}\n />\n )\n ) : null}\n {slide.content}\n </Animated.View>\n );\n}\n\n/*** Retain consumer image behavior while observing readiness for adjacent-slide preloading. */\nfunction renderCarouselImage(image: React.ReactNode, onImageLoad: () => void): React.ReactNode {\n if (!React.isValidElement<{ onLoad?: (event: unknown) => void }>(image)) return image;\n const existingOnLoad = image.props.onLoad;\n return React.cloneElement(image, {\n onLoad: (event: unknown) => {\n existingOnLoad?.(event);\n onImageLoad();\n },\n });\n}\n\n/*** Return an immutable mounted-key set containing one requested slide. */\nfunction ensureMountedSlide(mountedSlideKeys: ReadonlySet<string>, slideKey: string | undefined) {\n if (!slideKey || mountedSlideKeys.has(slideKey)) return mountedSlideKeys;\n return new Set([...mountedSlideKeys, slideKey]);\n}\n\n/*** Return the next slide key only after the active slide image is ready. */\nfunction getPreloadedSlideKey(\n activeSlideKey: string | undefined,\n nextSlideKey: string | undefined,\n readySlideKeys: ReadonlySet<string>,\n) {\n if (!activeSlideKey || !readySlideKeys.has(activeSlideKey)) return undefined;\n return nextSlideKey;\n}\n\n/*** Resolve the slide to preload without wrapping when looping is disabled. */\nfunction getNextSlideIndex(index: number, length: number, loop: boolean): number | undefined {\n if (length < 2 || (!loop && index === length - 1)) return undefined;\n return (index + 1) % length;\n}\n\n/*** Clamp the initial server-rendered slide to the available slide collection. */\nfunction normalizeSlideIndex(index: number, length: number): number {\n if (length === 0) return 0;\n return Math.min(Math.max(Math.trunc(index), 0), length - 1);\n}\n\ninterface CarouselNavigationProps {\n readonly activeIndex: number;\n readonly navigate: (index: number, direction: 1 | -1) => void;\n readonly controlledWithoutHandler: boolean;\n readonly testID: CarouselProps['testID'];\n}\n\ninterface CarouselControlsProps extends CarouselNavigationProps {\n readonly show: boolean;\n readonly canPrevious: boolean;\n readonly canNext: boolean;\n readonly previousLabel: string;\n readonly nextLabel: string;\n readonly controlColor: string;\n readonly controlBackgroundColor: string;\n readonly controlsStyle: CarouselProps['controlsStyle'];\n}\n\n/*** Render optional previous/next buttons without coupling the slide content to navigation. */\nfunction CarouselControls({\n activeIndex,\n canNext,\n canPrevious,\n controlBackgroundColor,\n controlColor,\n controlledWithoutHandler,\n controlsStyle,\n navigate,\n nextLabel,\n previousLabel,\n show,\n testID,\n}: CarouselControlsProps) {\n if (!show) return null;\n const buttonStyle = [styles.control, { backgroundColor: controlBackgroundColor }];\n const labelStyle = { color: controlColor, fontSize: 30 };\n return (\n <View pointerEvents=\"box-none\" style={[styles.controls, controlsStyle]}>\n <Pressable\n accessibilityLabel={previousLabel}\n accessibilityRole=\"button\"\n disabled={!canPrevious || controlledWithoutHandler}\n onPress={() => navigate(activeIndex - 1, -1)}\n style={buttonStyle}\n testID={testID ? `${testID}-previous` : undefined}\n >\n <Text style={labelStyle}>{'‹'}</Text>\n </Pressable>\n <Pressable\n accessibilityLabel={nextLabel}\n accessibilityRole=\"button\"\n disabled={!canNext || controlledWithoutHandler}\n onPress={() => navigate(activeIndex + 1, 1)}\n style={buttonStyle}\n testID={testID ? `${testID}-next` : undefined}\n >\n <Text style={labelStyle}>{'›'}</Text>\n </Pressable>\n </View>\n );\n}\n\ninterface CarouselIndicatorsProps extends CarouselNavigationProps {\n readonly show: boolean;\n readonly slides: CarouselProps['slides'];\n readonly activeColor: string;\n readonly idleColor: string;\n readonly indicatorsStyle: CarouselProps['indicatorsStyle'];\n}\n\n/*** Render accessible selection dots for the currently controlled slide. */\nfunction CarouselIndicators({\n activeIndex,\n activeColor,\n controlledWithoutHandler,\n idleColor,\n indicatorsStyle,\n navigate,\n show,\n slides,\n testID,\n}: CarouselIndicatorsProps) {\n if (!show) return null;\n return (\n <View pointerEvents=\"box-none\" style={[styles.indicators, indicatorsStyle]}>\n {slides.map((slide, slideIndex) => (\n <Pressable\n key={slide.key}\n accessibilityLabel={`Go to slide ${slideIndex + 1} of ${slides.length}`}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: slideIndex === activeIndex }}\n disabled={controlledWithoutHandler}\n onPress={() => navigate(slideIndex, slideIndex < activeIndex ? -1 : 1)}\n style={[\n styles.indicator,\n {\n backgroundColor: slideIndex === activeIndex ? activeColor : idleColor,\n width: slideIndex === activeIndex ? 24 : 8,\n },\n ]}\n testID={testID ? `${testID}-indicator-${slideIndex}` : undefined}\n />\n ))}\n </View>\n );\n}\n\ninterface CarouselProgressProps {\n readonly show: boolean;\n readonly height: number;\n readonly trackColor: string;\n readonly indicatorColor: string;\n readonly trackStyle: CarouselProps['progressTrackStyle'];\n readonly indicatorStyle: CarouselProps['progressIndicatorStyle'];\n readonly progress: Animated.Value;\n readonly testID: CarouselProps['testID'];\n}\n\n/*** Render an optional linear autoplay timer without adding any required UI to slides. */\nfunction CarouselProgress({\n height,\n indicatorColor,\n indicatorStyle,\n progress,\n show,\n testID,\n trackColor,\n trackStyle,\n}: CarouselProgressProps) {\n if (!show) return null;\n return (\n <View\n pointerEvents=\"none\"\n style={[styles.progress, { height, backgroundColor: trackColor }, trackStyle]}\n testID={testID ? `${testID}-progress` : undefined}\n >\n <Animated.View\n style={[\n {\n height: '100%',\n width: '100%',\n transformOrigin: 'left center',\n transform: [{ scaleX: progress }],\n backgroundColor: indicatorColor,\n },\n indicatorStyle,\n ]}\n />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n controls: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 14,\n right: 14,\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n },\n control: {\n width: 44,\n height: 44,\n borderRadius: 22,\n justifyContent: 'center',\n alignItems: 'center',\n },\n indicators: {\n position: 'absolute',\n bottom: 24,\n left: 0,\n right: 0,\n flexDirection: 'row',\n gap: 10,\n justifyContent: 'center',\n alignItems: 'center',\n },\n indicator: { height: 8, borderRadius: 8 },\n progress: { position: 'absolute', bottom: 0, left: 0, right: 0, overflow: 'hidden' },\n});\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/zora",
3
3
  "type": "module",
4
- "version": "28.5.1",
4
+ "version": "28.5.3",
5
5
  "description": "Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.",
6
6
  "homepage": "https://github.com/ankhorage/zora#readme",
7
7
  "bugs": {
@@ -32,7 +32,7 @@
32
32
  "@react-native-vector-icons/ionicons": "^13.1.3 || ^14.0.0",
33
33
  "@react-native-vector-icons/material-design-icons": "^13.1.3 || ^14.0.0",
34
34
  "expo": "~57.0.0",
35
- "react": "19.2.3",
35
+ "react": "19.2.3 || 19.3",
36
36
  "react-native": "0.86.x",
37
37
  "react-native-gesture-handler": "~2.32.0",
38
38
  "react-native-reanimated": "4.5.1",
@@ -50,14 +50,14 @@
50
50
  "@ankhorage/grid-view": "^0.5.0",
51
51
  "@ankhorage/reader": "^0.1.3",
52
52
  "@ankhorage/runtime": "^5.7.5",
53
- "@ankhorage/surface": "^9.8.5",
53
+ "@ankhorage/surface": "^9.8.6",
54
54
  "@ankhorage/utility": "^1.11.0",
55
55
  "expo-asset": "~57.0.21",
56
56
  "expo-audio": "~57.0.5",
57
57
  "expo-document-picker": "~57.0.3",
58
58
  "expo-image-picker": "~57.0.20",
59
59
  "expo-video": "~57.0.5",
60
- "react-native-enriched-html": "1.2.0",
60
+ "react-native-enriched-html": "1.3.0",
61
61
  "xss": "^1.0.17"
62
62
  },
63
63
  "files": [
@@ -193,8 +193,8 @@
193
193
  "version-packages": "ankhorage-changeset version"
194
194
  },
195
195
  "devDependencies": {
196
- "@ankhorage/devtools": "^2.12.5",
197
- "@ankhorage/paradox": "^0.6.1",
196
+ "@ankhorage/devtools": "^2.12.17",
197
+ "@ankhorage/paradox": "^0.6.2",
198
198
  "@react-native-vector-icons/fontawesome": "^14.0.0",
199
199
  "@react-native-vector-icons/fontawesome5": "^14.0.0",
200
200
  "@react-native-vector-icons/fontawesome6": "^14.0.0",
@@ -82,7 +82,8 @@ describe('portable ZORA package boundary', () => {
82
82
 
83
83
  expect(readValue(dependencies, '@ankhorage/surface')).toMatch(SEMVER_PATTERNS.caret);
84
84
  expect(readValue(dependencies, '@ankhorage/contracts')).toMatch(SEMVER_PATTERNS.caret);
85
- expect(peers.react).toMatch(SEMVER_PATTERNS.exact);
85
+ expect(peers.react).toBe('19.2.3 || 19.3');
86
+ expect(development.react).toBe('19.2.3');
86
87
  expect(readValue(peers, 'react-native')).toMatch(SEMVER_PATTERNS.minorWildcard);
87
88
  expect(readValue(peers, 'react-native-svg')).toMatch(SEMVER_PATTERNS.exact);
88
89
  expect(readValue(development, 'react-native-svg')).toMatch(SEMVER_PATTERNS.exact);
@@ -1,9 +1,57 @@
1
- import { Carousel, type CarouselProps } from '@ankhorage/zora/web/carousel';
2
- import { ZoraProvider } from '@ankhorage/zora/web/runtime';
3
- import { expect, test } from 'bun:test';
1
+ import { afterAll, expect, test } from 'bun:test';
2
+ import { Window } from 'happy-dom';
4
3
  import React from 'react';
4
+ import { act } from 'react';
5
+ import { createRoot } from 'react-dom/client';
5
6
  import { renderToStaticMarkup } from 'react-dom/server';
6
7
 
8
+ import type { CarouselProps } from '../../types/carousel';
9
+
10
+ const requestFrame = (callback: (time: number) => void): number =>
11
+ setTimeout(() => callback(Date.now()), 0);
12
+ const cancelFrame = (handle: number): void => clearTimeout(handle);
13
+ const moduleBrowser = new Window();
14
+ Object.assign(moduleBrowser, {
15
+ matchMedia: () => ({
16
+ addEventListener: () => undefined,
17
+ matches: false,
18
+ removeEventListener: () => undefined,
19
+ }),
20
+ });
21
+ const moduleGlobalKeys = [
22
+ 'window',
23
+ 'document',
24
+ 'Node',
25
+ 'navigator',
26
+ 'ShadowRoot',
27
+ 'requestAnimationFrame',
28
+ 'cancelAnimationFrame',
29
+ 'IS_REACT_ACT_ENVIRONMENT',
30
+ ] as const;
31
+ const modulePreviousGlobals = moduleGlobalKeys.map(
32
+ (key) => [key, Object.getOwnPropertyDescriptor(globalThis, key)] as const,
33
+ );
34
+ Object.assign(globalThis, {
35
+ IS_REACT_ACT_ENVIRONMENT: true,
36
+ Node: moduleBrowser.Node,
37
+ ShadowRoot: moduleBrowser.ShadowRoot,
38
+ document: moduleBrowser.document,
39
+ navigator: moduleBrowser.navigator,
40
+ requestAnimationFrame: requestFrame,
41
+ cancelAnimationFrame: cancelFrame,
42
+ window: moduleBrowser,
43
+ });
44
+ const { Carousel } = await import('@ankhorage/zora/web/carousel');
45
+ const { ZoraProvider } = await import('@ankhorage/zora/web/runtime');
46
+
47
+ afterAll(() => {
48
+ moduleBrowser.close();
49
+ for (const [key, descriptor] of modulePreviousGlobals) {
50
+ if (descriptor) Object.defineProperty(globalThis, key, descriptor);
51
+ else Reflect.deleteProperty(globalThis, key);
52
+ }
53
+ });
54
+
7
55
  /*** Render the published browser facade inside its real theme provider. */
8
56
  function renderCarousel(props: CarouselProps): string {
9
57
  return renderToStaticMarkup(
@@ -17,30 +65,37 @@ test('renders no slides or progress with an empty collection', () => {
17
65
  expect(html).not.toContain('progress');
18
66
  });
19
67
 
20
- test('renders images through the consumer renderer without a Next.js dependency', () => {
68
+ test('renders only the initial active image through the consumer renderer', () => {
21
69
  const html = renderCarousel({
22
- slides: [{ key: 'one', source: '/original.jpg', alt: 'Image' }],
70
+ slides: [
71
+ { key: 'one', source: '/original.jpg', alt: 'Image' },
72
+ { key: 'two', source: '/deferred.jpg', alt: 'Deferred image' },
73
+ ],
23
74
  renderImage: (slide) =>
24
75
  React.createElement('img', {
25
76
  src: typeof slide.source === 'string' ? slide.source : '',
26
77
  alt: '',
27
78
  }),
79
+ showProgress: false,
28
80
  testID: 'carousel',
29
81
  });
30
82
  expect(html).toContain('/original.jpg');
83
+ expect(html).not.toContain('/deferred.jpg');
31
84
  expect(html).not.toContain('carousel-progress');
32
85
  });
33
86
 
34
- test('supports arbitrary React content without requiring image sources', () => {
87
+ test('renders the controlled initial content slide without mounting deferred content', () => {
35
88
  const html = renderCarousel({
36
89
  slides: [
37
90
  { key: 'one', content: React.createElement('span', undefined, 'Discover your next idea') },
38
91
  { key: 'two', content: React.createElement('span', undefined, 'Create what matters') },
39
92
  ],
93
+ index: 0,
94
+ defaultIndex: 1,
40
95
  transition: 'none',
41
96
  });
42
97
  expect(html).toContain('Discover your next idea');
43
- expect(html).toContain('Create what matters');
98
+ expect(html).not.toContain('Create what matters');
44
99
  });
45
100
 
46
101
  test('renders configurable accessible arrows, indicators and progress', () => {
@@ -65,3 +120,184 @@ test('renders configurable accessible arrows, indicators and progress', () => {
65
120
  expect(minimal).not.toContain('progress');
66
121
  expect(minimal).not.toContain('indicator-0');
67
122
  });
123
+
124
+ test('preloads a following image only after the active image reports readiness', async () => {
125
+ await withBrowserAsync(async (host, browser) => {
126
+ const root = createRoot(host);
127
+ try {
128
+ await renderCarouselAsync(
129
+ root,
130
+ React.createElement(
131
+ ZoraProvider,
132
+ undefined,
133
+ React.createElement(Carousel, {
134
+ slides: imageSlides,
135
+ autoPlay: false,
136
+ showArrows: true,
137
+ testID: 'carousel',
138
+ transition: 'none',
139
+ renderImage,
140
+ }),
141
+ ),
142
+ );
143
+ expect(renderedImageIndices(host)).toEqual(['0']);
144
+
145
+ await fireLoadAsync(host, browser, '0');
146
+ expect(renderedImageIndices(host)).toEqual(['0', '1']);
147
+
148
+ await clickAsync(host, 'carousel-next');
149
+ expect(renderedImageIndices(host)).toEqual(['1']);
150
+
151
+ await fireLoadAsync(host, browser, '1');
152
+ expect(renderedImageIndices(host)).toEqual(['1', '2']);
153
+ } finally {
154
+ await renderCarouselAsync(root, null);
155
+ }
156
+ });
157
+ });
158
+
159
+ test('preloads the successor when a previously ready image becomes active', async () => {
160
+ await withBrowserAsync(async (host, browser) => {
161
+ const root = createRoot(host);
162
+ try {
163
+ await renderCarouselAsync(
164
+ root,
165
+ React.createElement(
166
+ ZoraProvider,
167
+ undefined,
168
+ React.createElement(Carousel, {
169
+ slides: imageSlides,
170
+ autoPlay: false,
171
+ showArrows: true,
172
+ testID: 'carousel',
173
+ transition: 'none',
174
+ renderImage,
175
+ }),
176
+ ),
177
+ );
178
+ await fireLoadAsync(host, browser, '0');
179
+ await fireLoadAsync(host, browser, '1');
180
+
181
+ await clickAsync(host, 'carousel-next');
182
+
183
+ expect(renderedImageIndices(host)).toEqual(['1', '2']);
184
+ } finally {
185
+ await renderCarouselAsync(root, null);
186
+ }
187
+ });
188
+ });
189
+
190
+ test('keeps outgoing layers mounted through rapid navigation', async () => {
191
+ await withBrowserAsync(async (host, browser) => {
192
+ const root = createRoot(host);
193
+ try {
194
+ await renderCarouselAsync(
195
+ root,
196
+ React.createElement(
197
+ ZoraProvider,
198
+ undefined,
199
+ React.createElement(Carousel, {
200
+ slides: imageSlides,
201
+ autoPlay: false,
202
+ enterDurationMs: 10_000,
203
+ exitDurationMs: 10_000,
204
+ showArrows: true,
205
+ testID: 'carousel',
206
+ transition: 'fade',
207
+ renderImage,
208
+ }),
209
+ ),
210
+ );
211
+ await fireLoadAsync(host, browser, '0');
212
+ await clickAsync(host, 'carousel-next');
213
+ await clickAsync(host, 'carousel-next');
214
+
215
+ expect(renderedImageIndices(host)).toEqual(['0', '1', '2']);
216
+ } finally {
217
+ await renderCarouselAsync(root, null);
218
+ }
219
+ });
220
+ });
221
+
222
+ const imageSlides = [
223
+ { key: 'one', source: '/one.jpg' },
224
+ { key: 'two', source: '/two.jpg' },
225
+ { key: 'three', source: '/three.jpg' },
226
+ ] as const;
227
+
228
+ /*** Render a consumer-owned image so the focused test can observe its load lifecycle. */
229
+ function renderImage(_slide: (typeof imageSlides)[number], index: number): React.ReactNode {
230
+ return React.createElement('img', { 'data-carousel-image': String(index), alt: '' });
231
+ }
232
+
233
+ /*** Flush a Carousel render through React's DOM test boundary. */
234
+ function renderCarouselAsync(
235
+ root: ReturnType<typeof createRoot>,
236
+ element: React.ReactNode,
237
+ ): Promise<void> {
238
+ return act(() => Promise.resolve().then(() => root.render(element)));
239
+ }
240
+
241
+ /*** Dispatch an image readiness signal through the consumer-owned image element. */
242
+ function fireLoadAsync(host: HTMLElement, browser: Window, index: string): Promise<void> {
243
+ const image = host.querySelector<HTMLElement>(`[data-carousel-image="${index}"]`);
244
+ if (!image) throw new Error(`Missing Carousel image ${index}`);
245
+ return act(() =>
246
+ Promise.resolve().then(() => image.dispatchEvent(new browser.Event('load', { bubbles: true }))),
247
+ );
248
+ }
249
+
250
+ /*** Activate an existing Carousel control through the real DOM event boundary. */
251
+ function clickAsync(host: HTMLElement, testID: string): Promise<void> {
252
+ const control = host.querySelector<HTMLElement>(`[data-testid="${testID}"]`);
253
+ if (!control) throw new Error(`Missing Carousel control ${testID}`);
254
+ return act(() => Promise.resolve().then(() => control.click()));
255
+ }
256
+
257
+ /*** Collect mounted consumer image layers in their source order. */
258
+ function renderedImageIndices(host: HTMLElement): string[] {
259
+ return [...host.querySelectorAll<HTMLElement>('[data-carousel-image]')].map(
260
+ (image) => image.dataset.carouselImage ?? '',
261
+ );
262
+ }
263
+
264
+ /*** Execute a focused DOM test while restoring host globals afterward. */
265
+ async function withBrowserAsync(
266
+ callback: (host: HTMLElement, browser: Window) => Promise<void>,
267
+ ): Promise<void> {
268
+ const browser = new Window();
269
+ const keys = [
270
+ 'window',
271
+ 'document',
272
+ 'Node',
273
+ 'navigator',
274
+ 'ShadowRoot',
275
+ 'requestAnimationFrame',
276
+ 'cancelAnimationFrame',
277
+ 'IS_REACT_ACT_ENVIRONMENT',
278
+ ] as const;
279
+ const previous = keys.map(
280
+ (key) => [key, Object.getOwnPropertyDescriptor(globalThis, key)] as const,
281
+ );
282
+ Object.assign(globalThis, {
283
+ IS_REACT_ACT_ENVIRONMENT: true,
284
+ Node: browser.Node,
285
+ ShadowRoot: browser.ShadowRoot,
286
+ document: browser.document,
287
+ navigator: browser.navigator,
288
+ requestAnimationFrame: requestFrame,
289
+ cancelAnimationFrame: cancelFrame,
290
+ window: browser,
291
+ });
292
+ const host = document.createElement('div');
293
+ document.body.append(host);
294
+ try {
295
+ await callback(host, browser);
296
+ } finally {
297
+ browser.close();
298
+ for (const [key, descriptor] of previous) {
299
+ if (descriptor) Object.defineProperty(globalThis, key, descriptor);
300
+ else Reflect.deleteProperty(globalThis, key);
301
+ }
302
+ }
303
+ }
@@ -48,6 +48,12 @@ export function Carousel({
48
48
  }: CarouselProps) {
49
49
  const { theme } = useZoraTheme();
50
50
  const [width, setWidth] = React.useState(0);
51
+ const initialIndex = normalizeSlideIndex(index ?? defaultIndex ?? 0, slides.length);
52
+ const initialSlide = slides.at(initialIndex);
53
+ const [mountedSlideKeys, setMountedSlideKeys] = React.useState<ReadonlySet<string>>(() =>
54
+ initialSlide ? new Set([initialSlide.key]) : new Set(),
55
+ );
56
+ const [readySlideKeys, setReadySlideKeys] = React.useState<ReadonlySet<string>>(() => new Set());
51
57
  const {
52
58
  activeIndex,
53
59
  controlledWithoutHandler,
@@ -68,6 +74,47 @@ export function Carousel({
68
74
  reducedMotion,
69
75
  });
70
76
 
77
+ const activeSlide = slides.at(activeIndex);
78
+ const nextIndex = getNextSlideIndex(activeIndex, slides.length, enabledLoop);
79
+ const nextSlide = nextIndex === undefined ? undefined : slides.at(nextIndex);
80
+ const activeSlideKey = activeSlide?.key;
81
+ const nextSlideKey = nextSlide?.key;
82
+ const mountedKeys = ensureMountedSlide(
83
+ ensureMountedSlide(mountedSlideKeys, activeSlideKey),
84
+ getPreloadedSlideKey(activeSlideKey, nextSlideKey, readySlideKeys),
85
+ );
86
+
87
+ const markSlideLoaded = React.useCallback(
88
+ (slideKey: string) => {
89
+ setReadySlideKeys((current) => ensureMountedSlide(current, slideKey));
90
+ if (slideKey === activeSlideKey) {
91
+ setMountedSlideKeys((current) => ensureMountedSlide(current, nextSlideKey));
92
+ }
93
+ },
94
+ [activeSlideKey, nextSlideKey],
95
+ );
96
+
97
+ const completeTransition = React.useCallback(
98
+ (completedSlideKey: string) => {
99
+ if (!activeSlideKey || completedSlideKey !== activeSlideKey) return;
100
+ const transitionRetentionKeys = [activeSlideKey, nextSlideKey].filter(
101
+ (slideKey): slideKey is string => slideKey !== undefined,
102
+ );
103
+ setMountedSlideKeys(
104
+ (current) =>
105
+ new Set(
106
+ transitionRetentionKeys.filter(
107
+ (slideKey) =>
108
+ slideKey === activeSlideKey ||
109
+ current.has(slideKey) ||
110
+ readySlideKeys.has(activeSlideKey),
111
+ ),
112
+ ),
113
+ );
114
+ },
115
+ [activeSlideKey, nextSlideKey, readySlideKeys],
116
+ );
117
+
71
118
  if (slides.length === 0) return null;
72
119
 
73
120
  const canPrevious = enabledLoop || activeIndex > 0;
@@ -81,26 +128,32 @@ export function Carousel({
81
128
  testID={testID}
82
129
  style={[{ position: 'relative', overflow: 'hidden', width: '100%', height: '100%' }, style]}
83
130
  >
84
- {slides.map((slide, slideIndex) => (
85
- <CarouselLayer
86
- key={slide.key}
87
- active={activeIndex === slideIndex}
88
- animate={slides.length > 1}
89
- animateOnMount={animateOnMount}
90
- direction={direction}
91
- enterDurationMs={enterDurationMs}
92
- exitDurationMs={exitDurationMs}
93
- imageStyle={imageStyle}
94
- initialScale={initialScale}
95
- reducedMotion={shouldReduceMotion}
96
- renderImage={renderImage}
97
- resizeMode={resizeMode}
98
- slide={slide}
99
- slideIndex={slideIndex}
100
- transition={transition}
101
- width={width}
102
- />
103
- ))}
131
+ {slides.flatMap((slide, slideIndex) =>
132
+ mountedKeys.has(slide.key)
133
+ ? [
134
+ <CarouselLayer
135
+ key={slide.key}
136
+ active={activeIndex === slideIndex}
137
+ animate={slides.length > 1}
138
+ animateOnMount={animateOnMount || activeIndex !== initialIndex}
139
+ direction={direction}
140
+ enterDurationMs={enterDurationMs}
141
+ exitDurationMs={exitDurationMs}
142
+ imageStyle={imageStyle}
143
+ initialScale={initialScale}
144
+ onImageLoad={() => markSlideLoaded(slide.key)}
145
+ onTransitionComplete={completeTransition}
146
+ reducedMotion={shouldReduceMotion}
147
+ renderImage={renderImage}
148
+ resizeMode={resizeMode}
149
+ slide={slide}
150
+ slideIndex={slideIndex}
151
+ transition={transition}
152
+ width={width}
153
+ />,
154
+ ]
155
+ : [],
156
+ )}
104
157
  <CarouselControls
105
158
  activeIndex={activeIndex}
106
159
  canNext={canNext}
@@ -145,6 +198,8 @@ interface CarouselLayerProps {
145
198
  readonly exitDurationMs?: CarouselProps['exitDurationMs'];
146
199
  readonly imageStyle: CarouselProps['imageStyle'];
147
200
  readonly initialScale?: CarouselProps['initialScale'];
201
+ readonly onImageLoad: () => void;
202
+ readonly onTransitionComplete: (slideKey: string) => void;
148
203
  readonly renderImage: CarouselProps['renderImage'];
149
204
  readonly resizeMode: CarouselProps['resizeMode'];
150
205
  readonly slide: CarouselSlide;
@@ -169,6 +224,8 @@ function CarouselLayer({
169
224
  enterDurationMs = 1200,
170
225
  exitDurationMs = 800,
171
226
  initialScale = 1.06,
227
+ onImageLoad,
228
+ onTransitionComplete,
172
229
  reducedMotion,
173
230
  renderImage,
174
231
  resizeMode,
@@ -182,6 +239,11 @@ function CarouselLayer({
182
239
  );
183
240
  const [offset] = React.useState(() => new Animated.Value(0));
184
241
  const hasMounted = React.useRef(false);
242
+ const widthRef = React.useRef(width);
243
+
244
+ React.useEffect(() => {
245
+ widthRef.current = width;
246
+ }, [width]);
185
247
 
186
248
  React.useEffect(() => {
187
249
  const firstRender = !hasMounted.current;
@@ -194,17 +256,18 @@ function CarouselLayer({
194
256
  opacity.setValue(active ? 1 : 0);
195
257
  scale.setValue(1);
196
258
  offset.setValue(0);
259
+ if (active) onTransitionComplete(slide.key);
197
260
  return;
198
261
  }
199
262
  if (transition === 'slide') {
200
263
  scale.setValue(1);
201
264
  if (active) {
202
- offset.setValue(direction * width);
265
+ offset.setValue(direction * widthRef.current);
203
266
  opacity.setValue(1);
204
267
  }
205
268
  Animated.parallel([
206
269
  Animated.timing(offset, {
207
- toValue: active ? 0 : -direction * width,
270
+ toValue: active ? 0 : -direction * widthRef.current,
208
271
  duration: Math.max(0, active ? enterDurationMs : exitDurationMs),
209
272
  easing: Easing.bezier(0.4, 0, 0.2, 1),
210
273
  useNativeDriver: true,
@@ -215,7 +278,9 @@ function CarouselLayer({
215
278
  easing: Easing.linear,
216
279
  useNativeDriver: true,
217
280
  }),
218
- ]).start();
281
+ ]).start(({ finished }) => {
282
+ if (active && finished) onTransitionComplete(slide.key);
283
+ });
219
284
  } else if (active) {
220
285
  opacity.setValue(0);
221
286
  scale.setValue(initialScale);
@@ -232,7 +297,9 @@ function CarouselLayer({
232
297
  easing: Easing.bezier(0.4, 0, 0.2, 1),
233
298
  useNativeDriver: true,
234
299
  }),
235
- ]).start();
300
+ ]).start(({ finished }) => {
301
+ if (finished) onTransitionComplete(slide.key);
302
+ });
236
303
  } else {
237
304
  Animated.timing(opacity, {
238
305
  toValue: 0,
@@ -259,7 +326,8 @@ function CarouselLayer({
259
326
  reducedMotion,
260
327
  scale,
261
328
  transition,
262
- width,
329
+ onTransitionComplete,
330
+ slide.key,
263
331
  ]);
264
332
 
265
333
  return (
@@ -271,7 +339,7 @@ function CarouselLayer({
271
339
  >
272
340
  {slide.source !== undefined ? (
273
341
  renderImage ? (
274
- renderImage(slide, slideIndex)
342
+ renderCarouselImage(renderImage(slide, slideIndex), onImageLoad)
275
343
  ) : (
276
344
  <Image
277
345
  accessibilityLabel={slide.alt}
@@ -279,6 +347,7 @@ function CarouselLayer({
279
347
  resizeMode={resizeMode}
280
348
  source={typeof slide.source === 'string' ? { uri: slide.source } : slide.source}
281
349
  style={[StyleSheet.absoluteFill, imageStyle]}
350
+ onLoad={onImageLoad}
282
351
  />
283
352
  )
284
353
  ) : null}
@@ -287,6 +356,46 @@ function CarouselLayer({
287
356
  );
288
357
  }
289
358
 
359
+ /*** Retain consumer image behavior while observing readiness for adjacent-slide preloading. */
360
+ function renderCarouselImage(image: React.ReactNode, onImageLoad: () => void): React.ReactNode {
361
+ if (!React.isValidElement<{ onLoad?: (event: unknown) => void }>(image)) return image;
362
+ const existingOnLoad = image.props.onLoad;
363
+ return React.cloneElement(image, {
364
+ onLoad: (event: unknown) => {
365
+ existingOnLoad?.(event);
366
+ onImageLoad();
367
+ },
368
+ });
369
+ }
370
+
371
+ /*** Return an immutable mounted-key set containing one requested slide. */
372
+ function ensureMountedSlide(mountedSlideKeys: ReadonlySet<string>, slideKey: string | undefined) {
373
+ if (!slideKey || mountedSlideKeys.has(slideKey)) return mountedSlideKeys;
374
+ return new Set([...mountedSlideKeys, slideKey]);
375
+ }
376
+
377
+ /*** Return the next slide key only after the active slide image is ready. */
378
+ function getPreloadedSlideKey(
379
+ activeSlideKey: string | undefined,
380
+ nextSlideKey: string | undefined,
381
+ readySlideKeys: ReadonlySet<string>,
382
+ ) {
383
+ if (!activeSlideKey || !readySlideKeys.has(activeSlideKey)) return undefined;
384
+ return nextSlideKey;
385
+ }
386
+
387
+ /*** Resolve the slide to preload without wrapping when looping is disabled. */
388
+ function getNextSlideIndex(index: number, length: number, loop: boolean): number | undefined {
389
+ if (length < 2 || (!loop && index === length - 1)) return undefined;
390
+ return (index + 1) % length;
391
+ }
392
+
393
+ /*** Clamp the initial server-rendered slide to the available slide collection. */
394
+ function normalizeSlideIndex(index: number, length: number): number {
395
+ if (length === 0) return 0;
396
+ return Math.min(Math.max(Math.trunc(index), 0), length - 1);
397
+ }
398
+
290
399
  interface CarouselNavigationProps {
291
400
  readonly activeIndex: number;
292
401
  readonly navigate: (index: number, direction: 1 | -1) => void;
@@ -0,0 +1,17 @@
1
+ import { readFile } from 'node:fs/promises';
2
+
3
+ import { expect, test } from 'bun:test';
4
+
5
+ test('declares the React versions supported by the web artifact boundary', async () => {
6
+ const packageJson = (await Bun.file('package.json').json()) as {
7
+ readonly peerDependencies: Readonly<Record<string, string>>;
8
+ };
9
+ const webBuild = await readFile(
10
+ new URL('../scripts/web-artifacts/buildWebArtifact.ts', import.meta.url),
11
+ 'utf8',
12
+ );
13
+
14
+ expect(Bun.semver.satisfies('19.2.3', packageJson.peerDependencies.react)).toBe(true);
15
+ expect(Bun.semver.satisfies('19.3.1', packageJson.peerDependencies.react)).toBe(true);
16
+ expect(webBuild).toContain("external: ['react', 'react/*', 'react-dom', 'react-dom/*'");
17
+ });
@@ -136,6 +136,10 @@ function Carousel({
136
136
  }) {
137
137
  const { theme } = useZoraTheme2();
138
138
  const [width, setWidth] = React2.useState(0);
139
+ const initialIndex = normalizeSlideIndex(index ?? defaultIndex ?? 0, slides.length);
140
+ const initialSlide = slides.at(initialIndex);
141
+ const [mountedSlideKeys, setMountedSlideKeys] = React2.useState(() => initialSlide ? new Set([initialSlide.key]) : new Set);
142
+ const [readySlideKeys, setReadySlideKeys] = React2.useState(() => new Set);
139
143
  const {
140
144
  activeIndex,
141
145
  controlledWithoutHandler,
@@ -155,6 +159,24 @@ function Carousel({
155
159
  intervalMs,
156
160
  reducedMotion
157
161
  });
162
+ const activeSlide = slides.at(activeIndex);
163
+ const nextIndex = getNextSlideIndex(activeIndex, slides.length, enabledLoop);
164
+ const nextSlide = nextIndex === undefined ? undefined : slides.at(nextIndex);
165
+ const activeSlideKey = activeSlide?.key;
166
+ const nextSlideKey = nextSlide?.key;
167
+ const mountedKeys = ensureMountedSlide(ensureMountedSlide(mountedSlideKeys, activeSlideKey), getPreloadedSlideKey(activeSlideKey, nextSlideKey, readySlideKeys));
168
+ const markSlideLoaded = React2.useCallback((slideKey) => {
169
+ setReadySlideKeys((current) => ensureMountedSlide(current, slideKey));
170
+ if (slideKey === activeSlideKey) {
171
+ setMountedSlideKeys((current) => ensureMountedSlide(current, nextSlideKey));
172
+ }
173
+ }, [activeSlideKey, nextSlideKey]);
174
+ const completeTransition = React2.useCallback((completedSlideKey) => {
175
+ if (!activeSlideKey || completedSlideKey !== activeSlideKey)
176
+ return;
177
+ const transitionRetentionKeys = [activeSlideKey, nextSlideKey].filter((slideKey) => slideKey !== undefined);
178
+ setMountedSlideKeys((current) => new Set(transitionRetentionKeys.filter((slideKey) => slideKey === activeSlideKey || current.has(slideKey) || readySlideKeys.has(activeSlideKey))));
179
+ }, [activeSlideKey, nextSlideKey, readySlideKeys]);
158
180
  if (slides.length === 0)
159
181
  return null;
160
182
  const canPrevious = enabledLoop || activeIndex > 0;
@@ -166,23 +188,27 @@ function Carousel({
166
188
  testID,
167
189
  style: [{ position: "relative", overflow: "hidden", width: "100%", height: "100%" }, style],
168
190
  children: [
169
- slides.map((slide, slideIndex) => /* @__PURE__ */ jsx(CarouselLayer, {
170
- active: activeIndex === slideIndex,
171
- animate: slides.length > 1,
172
- animateOnMount,
173
- direction,
174
- enterDurationMs,
175
- exitDurationMs,
176
- imageStyle,
177
- initialScale,
178
- reducedMotion: shouldReduceMotion,
179
- renderImage,
180
- resizeMode,
181
- slide,
182
- slideIndex,
183
- transition,
184
- width
185
- }, slide.key)),
191
+ slides.flatMap((slide, slideIndex) => mountedKeys.has(slide.key) ? [
192
+ /* @__PURE__ */ jsx(CarouselLayer, {
193
+ active: activeIndex === slideIndex,
194
+ animate: slides.length > 1,
195
+ animateOnMount: animateOnMount || activeIndex !== initialIndex,
196
+ direction,
197
+ enterDurationMs,
198
+ exitDurationMs,
199
+ imageStyle,
200
+ initialScale,
201
+ onImageLoad: () => markSlideLoaded(slide.key),
202
+ onTransitionComplete: completeTransition,
203
+ reducedMotion: shouldReduceMotion,
204
+ renderImage,
205
+ resizeMode,
206
+ slide,
207
+ slideIndex,
208
+ transition,
209
+ width
210
+ }, slide.key)
211
+ ] : []),
186
212
  /* @__PURE__ */ jsx(CarouselControls, {
187
213
  activeIndex,
188
214
  canNext,
@@ -231,6 +257,8 @@ function CarouselLayer({
231
257
  enterDurationMs = 1200,
232
258
  exitDurationMs = 800,
233
259
  initialScale = 1.06,
260
+ onImageLoad,
261
+ onTransitionComplete,
234
262
  reducedMotion,
235
263
  renderImage,
236
264
  resizeMode,
@@ -242,6 +270,10 @@ function CarouselLayer({
242
270
  const [scale] = React2.useState(() => new import_react_native2.Animated.Value(active && animateOnMount ? initialScale : 1));
243
271
  const [offset] = React2.useState(() => new import_react_native2.Animated.Value(0));
244
272
  const hasMounted = React2.useRef(false);
273
+ const widthRef = React2.useRef(width);
274
+ React2.useEffect(() => {
275
+ widthRef.current = width;
276
+ }, [width]);
245
277
  React2.useEffect(() => {
246
278
  const firstRender = !hasMounted.current;
247
279
  hasMounted.current = true;
@@ -254,17 +286,19 @@ function CarouselLayer({
254
286
  opacity.setValue(active ? 1 : 0);
255
287
  scale.setValue(1);
256
288
  offset.setValue(0);
289
+ if (active)
290
+ onTransitionComplete(slide.key);
257
291
  return;
258
292
  }
259
293
  if (transition === "slide") {
260
294
  scale.setValue(1);
261
295
  if (active) {
262
- offset.setValue(direction * width);
296
+ offset.setValue(direction * widthRef.current);
263
297
  opacity.setValue(1);
264
298
  }
265
299
  import_react_native2.Animated.parallel([
266
300
  import_react_native2.Animated.timing(offset, {
267
- toValue: active ? 0 : -direction * width,
301
+ toValue: active ? 0 : -direction * widthRef.current,
268
302
  duration: Math.max(0, active ? enterDurationMs : exitDurationMs),
269
303
  easing: import_react_native2.Easing.bezier(0.4, 0, 0.2, 1),
270
304
  useNativeDriver: true
@@ -275,7 +309,10 @@ function CarouselLayer({
275
309
  easing: import_react_native2.Easing.linear,
276
310
  useNativeDriver: true
277
311
  })
278
- ]).start();
312
+ ]).start(({ finished }) => {
313
+ if (active && finished)
314
+ onTransitionComplete(slide.key);
315
+ });
279
316
  } else if (active) {
280
317
  opacity.setValue(0);
281
318
  scale.setValue(initialScale);
@@ -292,7 +329,10 @@ function CarouselLayer({
292
329
  easing: import_react_native2.Easing.bezier(0.4, 0, 0.2, 1),
293
330
  useNativeDriver: true
294
331
  })
295
- ]).start();
332
+ ]).start(({ finished }) => {
333
+ if (finished)
334
+ onTransitionComplete(slide.key);
335
+ });
296
336
  } else {
297
337
  import_react_native2.Animated.timing(opacity, {
298
338
  toValue: 0,
@@ -319,7 +359,8 @@ function CarouselLayer({
319
359
  reducedMotion,
320
360
  scale,
321
361
  transition,
322
- width
362
+ onTransitionComplete,
363
+ slide.key
323
364
  ]);
324
365
  return /* @__PURE__ */ jsxs(import_react_native2.Animated.View, {
325
366
  accessibilityElementsHidden: !active,
@@ -327,17 +368,49 @@ function CarouselLayer({
327
368
  pointerEvents: active ? "auto" : "none",
328
369
  style: [import_react_native2.StyleSheet.absoluteFill, { opacity, transform: [{ scale }, { translateX: offset }] }],
329
370
  children: [
330
- slide.source !== undefined ? renderImage ? renderImage(slide, slideIndex) : /* @__PURE__ */ jsx(import_react_native2.Image, {
371
+ slide.source !== undefined ? renderImage ? renderCarouselImage(renderImage(slide, slideIndex), onImageLoad) : /* @__PURE__ */ jsx(import_react_native2.Image, {
331
372
  accessibilityLabel: slide.alt,
332
373
  accessible: Boolean(slide.alt),
333
374
  resizeMode,
334
375
  source: typeof slide.source === "string" ? { uri: slide.source } : slide.source,
335
- style: [import_react_native2.StyleSheet.absoluteFill, imageStyle]
376
+ style: [import_react_native2.StyleSheet.absoluteFill, imageStyle],
377
+ onLoad: onImageLoad
336
378
  }) : null,
337
379
  slide.content
338
380
  ]
339
381
  });
340
382
  }
383
+ function renderCarouselImage(image, onImageLoad) {
384
+ if (!React2.isValidElement(image))
385
+ return image;
386
+ const existingOnLoad = image.props.onLoad;
387
+ return React2.cloneElement(image, {
388
+ onLoad: (event) => {
389
+ existingOnLoad?.(event);
390
+ onImageLoad();
391
+ }
392
+ });
393
+ }
394
+ function ensureMountedSlide(mountedSlideKeys, slideKey) {
395
+ if (!slideKey || mountedSlideKeys.has(slideKey))
396
+ return mountedSlideKeys;
397
+ return new Set([...mountedSlideKeys, slideKey]);
398
+ }
399
+ function getPreloadedSlideKey(activeSlideKey, nextSlideKey, readySlideKeys) {
400
+ if (!activeSlideKey || !readySlideKeys.has(activeSlideKey))
401
+ return;
402
+ return nextSlideKey;
403
+ }
404
+ function getNextSlideIndex(index, length, loop) {
405
+ if (length < 2 || !loop && index === length - 1)
406
+ return;
407
+ return (index + 1) % length;
408
+ }
409
+ function normalizeSlideIndex(index, length) {
410
+ if (length === 0)
411
+ return 0;
412
+ return Math.min(Math.max(Math.trunc(index), 0), length - 1);
413
+ }
341
414
  function CarouselControls({
342
415
  activeIndex,
343
416
  canNext,