@ankhorage/zora 27.7.1 → 27.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/dist/features/carousel/Carousel.d.ts +8 -0
  4. package/dist/features/carousel/Carousel.d.ts.map +1 -0
  5. package/dist/features/carousel/Carousel.js +203 -0
  6. package/dist/features/carousel/Carousel.js.map +1 -0
  7. package/dist/features/carousel/public.d.ts +3 -0
  8. package/dist/features/carousel/public.d.ts.map +1 -0
  9. package/dist/features/carousel/public.js +2 -0
  10. package/dist/features/carousel/public.js.map +1 -0
  11. package/dist/features/carousel/useCarouselPlayback.d.ts +15 -0
  12. package/dist/features/carousel/useCarouselPlayback.d.ts.map +1 -0
  13. package/dist/features/carousel/useCarouselPlayback.js +74 -0
  14. package/dist/features/carousel/useCarouselPlayback.js.map +1 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/types/carousel.d.ts +52 -0
  20. package/dist/types/carousel.d.ts.map +1 -0
  21. package/dist/types/carousel.js +2 -0
  22. package/dist/types/carousel.js.map +1 -0
  23. package/package.json +1 -1
  24. package/src/features/carousel/Carousel.test.ts +66 -0
  25. package/src/features/carousel/Carousel.tsx +470 -0
  26. package/src/features/carousel/public.ts +2 -0
  27. package/src/features/carousel/useCarouselPlayback.ts +103 -0
  28. package/src/index.ts +2 -0
  29. package/src/types/carousel.ts +60 -0
  30. package/web-dist/chunks/{Accordion-9d3rd7ne.js → Accordion-19zt3dyq.js} +1 -1
  31. package/web-dist/chunks/{Accordion-8j7t77tf.js → Accordion-1j50tne9.js} +5 -5
  32. package/web-dist/chunks/{Accordion-sxzts6bj.js → Accordion-1k7pyxdd.js} +2 -2
  33. package/web-dist/chunks/{Accordion-fbehwpr1.js → Accordion-1ty4zrzd.js} +7 -7
  34. package/web-dist/chunks/{Accordion-r86ce0wj.js → Accordion-291hyjee.js} +4 -4
  35. package/web-dist/chunks/{Accordion-m3xb7z7j.js → Accordion-396cm5m0.js} +8 -8
  36. package/web-dist/chunks/{Accordion-p2f0e4pn.js → Accordion-3dk0s8hz.js} +6 -6
  37. package/web-dist/chunks/{Accordion-260pyaxy.js → Accordion-54417vp7.js} +5 -5
  38. package/web-dist/chunks/{Accordion-5pbvgvqc.js → Accordion-67a2a09x.js} +2 -2
  39. package/web-dist/chunks/{Accordion-j6bs1yfn.js → Accordion-6tfr02mw.js} +2 -2
  40. package/web-dist/chunks/{Accordion-e8dg1z2s.js → Accordion-6y42ws4p.js} +2 -2
  41. package/web-dist/chunks/{Accordion-w0prbwy0.js → Accordion-7j05jjqn.js} +8 -8
  42. package/web-dist/chunks/{Accordion-252dr90x.js → Accordion-7tg3cabd.js} +4 -4
  43. package/web-dist/chunks/{Accordion-8vcs6nz6.js → Accordion-9cpm8x92.js} +1 -1
  44. package/web-dist/chunks/{Accordion-ms1y70gq.js → Accordion-c1btejmf.js} +4 -4
  45. package/web-dist/chunks/{Accordion-yb4as6wc.js → Accordion-db40jsp6.js} +5 -5
  46. package/web-dist/chunks/{Accordion-wx0jp5cn.js → Accordion-dmkygw9c.js} +7 -7
  47. package/web-dist/chunks/{Accordion-vq8zrnwh.js → Accordion-dr8k9txz.js} +4 -4
  48. package/web-dist/chunks/{Accordion-jx9tc6p1.js → Accordion-e8r2qt0n.js} +4 -4
  49. package/web-dist/chunks/{Accordion-tnt1txfq.js → Accordion-ephzqa3t.js} +4 -4
  50. package/web-dist/chunks/{Accordion-4kmh6s2k.js → Accordion-fcpadcrg.js} +2 -2
  51. package/web-dist/chunks/{Accordion-0j4xzcwz.js → Accordion-gaevp89v.js} +3 -3
  52. package/web-dist/chunks/{Accordion-r6zvzrkd.js → Accordion-gwq0xkp9.js} +3 -3
  53. package/web-dist/chunks/{Accordion-9hcbf56f.js → Accordion-h4928ex8.js} +2 -2
  54. package/web-dist/chunks/{Accordion-mrhkw8n6.js → Accordion-hqg1zbxk.js} +6 -4
  55. package/web-dist/chunks/{Accordion-gysa24fk.js → Accordion-j5wsx41j.js} +1 -1
  56. package/web-dist/chunks/{Accordion-wvghkwxx.js → Accordion-jj6sg99e.js} +9 -9
  57. package/web-dist/chunks/{Accordion-7mnan4q4.js → Accordion-jqjnzjmt.js} +6 -6
  58. package/web-dist/chunks/{Accordion-b4yr6yq3.js → Accordion-jsdjgfn2.js} +2 -2
  59. package/web-dist/chunks/{Accordion-8ac6dkcs.js → Accordion-k058095e.js} +1 -1
  60. package/web-dist/chunks/Accordion-kcx57mk5.js +39 -0
  61. package/web-dist/chunks/{Accordion-mpebzjby.js → Accordion-kmbw4fe7.js} +4 -4
  62. package/web-dist/chunks/{Accordion-yrzm02g2.js → Accordion-kn52vs02.js} +5 -5
  63. package/web-dist/chunks/{Accordion-nnhznqgf.js → Accordion-n8dksapd.js} +2 -2
  64. package/web-dist/chunks/{Accordion-tpd1vvy9.js → Accordion-ng79nxzz.js} +1 -38
  65. package/web-dist/chunks/{Accordion-np16p9mh.js → Accordion-psxc0zjs.js} +4 -4
  66. package/web-dist/chunks/{Accordion-4c7hqeg3.js → Accordion-q3wk945k.js} +2 -2
  67. package/web-dist/chunks/{Accordion-t2cvrn0r.js → Accordion-qjp8bp5y.js} +8 -8
  68. package/web-dist/chunks/{Accordion-a8k3cvj0.js → Accordion-qyf0e72g.js} +1 -1
  69. package/web-dist/chunks/{Accordion-rcs75kj4.js → Accordion-r6gwemh9.js} +3 -3
  70. package/web-dist/chunks/{Accordion-hh48jjhk.js → Accordion-rbtgfrn4.js} +7 -7
  71. package/web-dist/chunks/{Accordion-kcca65d8.js → Accordion-rqh7264g.js} +5 -5
  72. package/web-dist/chunks/{Accordion-ew2cebyd.js → Accordion-rxc2p9md.js} +3 -3
  73. package/web-dist/chunks/{Accordion-f2n2zz1x.js → Accordion-scvx38z0.js} +6 -6
  74. package/web-dist/chunks/{Accordion-hf4nfkn0.js → Accordion-vayww2ec.js} +13 -13
  75. package/web-dist/chunks/{Accordion-vzgpdtr2.js → Accordion-wdby2v5r.js} +1 -1
  76. package/web-dist/chunks/{Accordion-7788ybcs.js → Accordion-wswm0zxe.js} +4 -4
  77. package/web-dist/chunks/{Accordion-rwc34cn2.js → Accordion-xjxam647.js} +5 -5
  78. package/web-dist/chunks/{Accordion-c44m1q0m.js → Accordion-xkewtxac.js} +2 -2
  79. package/web-dist/chunks/{Accordion-001ymezm.js → Accordion-y524ph0g.js} +1 -1
  80. package/web-dist/chunks/{Accordion-5z8pbn4z.js → Accordion-y7z4v31b.js} +3 -3
  81. package/web-dist/chunks/{Accordion-6jsea4e0.js → Accordion-yrs9sd97.js} +8 -8
  82. package/web-dist/chunks/{Accordion-jh94mg56.js → Accordion-ytvjnaz3.js} +9 -9
  83. package/web-dist/chunks/{Accordion-s9nbkzky.js → Accordion-zmee9h36.js} +2 -2
  84. package/web-dist/chunks/{Accordion-p7mxkxhs.js → Accordion-zx1qd2tf.js} +9 -9
  85. package/web-dist/components/accordion/Accordion.js +11 -10
  86. package/web-dist/components/accordion-item/AccordionItem.js +11 -10
  87. package/web-dist/components/activity-indicator/ActivityIndicator.js +4 -3
  88. package/web-dist/components/app-bar/AppBar.js +17 -16
  89. package/web-dist/components/app-header/AppHeader.js +17 -16
  90. package/web-dist/components/app-shell/AppShell.js +5 -4
  91. package/web-dist/components/auth-screen/AuthScreen.js +22 -21
  92. package/web-dist/components/avatar/Avatar.js +11 -10
  93. package/web-dist/components/avatar-group/AvatarGroup.js +11 -10
  94. package/web-dist/components/badge/Badge.js +6 -5
  95. package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +20 -19
  96. package/web-dist/components/bottom-sheet/BottomSheet.js +7 -6
  97. package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +7 -6
  98. package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +7 -6
  99. package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +7 -6
  100. package/web-dist/components/bottom-sheet-view/BottomSheetView.js +7 -6
  101. package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +7 -6
  102. package/web-dist/components/breadcrumbs/Breadcrumbs.js +14 -13
  103. package/web-dist/components/button/Button.js +12 -11
  104. package/web-dist/components/button-group/ButtonGroup.js +12 -11
  105. package/web-dist/components/calendar/Calendar.js +14 -13
  106. package/web-dist/components/camera-permission-view/CameraPermissionView.js +20 -19
  107. package/web-dist/components/card/Card.js +19 -18
  108. package/web-dist/components/card-back/CardBack.js +5 -4
  109. package/web-dist/components/card-hand/CardHand.js +5 -4
  110. package/web-dist/components/carousel/Carousel.d.ts +10 -0
  111. package/web-dist/components/carousel/Carousel.js +483 -0
  112. package/web-dist/components/carousel/Carousel.types-0.d.ts +55 -0
  113. package/web-dist/components/carousel/index.d.ts +2 -0
  114. package/web-dist/components/carousel/index.js +2 -0
  115. package/web-dist/components/chat-list-item/ChatListItem.js +15 -14
  116. package/web-dist/components/checkbox/Checkbox.js +11 -10
  117. package/web-dist/components/checkbox-group/CheckboxGroup.js +11 -10
  118. package/web-dist/components/chess-board/ChessBoard.js +5 -4
  119. package/web-dist/components/chip/Chip.js +12 -11
  120. package/web-dist/components/chip-group/ChipGroup.js +12 -11
  121. package/web-dist/components/collection-editor/CollectionEditor.js +19 -18
  122. package/web-dist/components/color-hue-scale/ColorHueScale.js +15 -14
  123. package/web-dist/components/color-picker/ColorPicker.js +15 -14
  124. package/web-dist/components/color-tone/ColorTone.js +15 -14
  125. package/web-dist/components/color-wheel/ColorWheel.js +15 -14
  126. package/web-dist/components/content-rail/ContentRail.js +13 -12
  127. package/web-dist/components/data-table/DataTable.js +25 -24
  128. package/web-dist/components/date-picker/DatePicker.js +18 -17
  129. package/web-dist/components/dialog/Dialog.js +10 -9
  130. package/web-dist/components/divider/Divider.js +5 -4
  131. package/web-dist/components/empty-state/EmptyState.js +20 -19
  132. package/web-dist/components/explorer/Explorer.js +12 -11
  133. package/web-dist/components/field/Field.js +11 -10
  134. package/web-dist/components/file-explorer/FileExplorer.js +12 -11
  135. package/web-dist/components/flat-list/FlatList.js +12 -11
  136. package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +22 -21
  137. package/web-dist/components/form/Form.js +16 -15
  138. package/web-dist/components/form-actions/FormActions.js +16 -15
  139. package/web-dist/components/form-error/FormError.js +16 -15
  140. package/web-dist/components/game/Game.js +6 -5
  141. package/web-dist/components/game-entity/GameEntity.js +6 -5
  142. package/web-dist/components/game-field/GameField.js +6 -5
  143. package/web-dist/components/game-input-zone/GameInputZone.js +6 -5
  144. package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +6 -5
  145. package/web-dist/components/game-overlay/GameOverlay.js +6 -5
  146. package/web-dist/components/gradient/Gradient.js +6 -5
  147. package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +6 -5
  148. package/web-dist/components/grid/Grid.js +5 -4
  149. package/web-dist/components/grid-line-overlay/GridLineOverlay.js +5 -4
  150. package/web-dist/components/grid-ruler/GridRuler.js +5 -4
  151. package/web-dist/components/heading/Heading.js +6 -5
  152. package/web-dist/components/hero/Hero.js +19 -18
  153. package/web-dist/components/icon/Icon.js +5 -4
  154. package/web-dist/components/icon-button/IconButton.js +12 -11
  155. package/web-dist/components/image/Image.js +9 -8
  156. package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +4 -3
  157. package/web-dist/components/list/List.js +12 -11
  158. package/web-dist/components/list-item/ListItem.js +12 -11
  159. package/web-dist/components/list-section/ListSection.js +12 -11
  160. package/web-dist/components/matrix-grid/MatrixGrid.js +5 -4
  161. package/web-dist/components/media-card/MediaCard.js +19 -18
  162. package/web-dist/components/media-explorer/MediaExplorer.js +12 -11
  163. package/web-dist/components/message-bubble/MessageBubble.js +15 -14
  164. package/web-dist/components/metric-card/MetricCard.js +19 -18
  165. package/web-dist/components/missing-element/MissingElement.js +10 -9
  166. package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +22 -21
  167. package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +22 -21
  168. package/web-dist/components/opening-book/OpeningBook.js +5 -4
  169. package/web-dist/components/otp-form/OtpForm.js +22 -21
  170. package/web-dist/components/pagination/Pagination.js +13 -12
  171. package/web-dist/components/palette-item/PaletteItem.js +19 -18
  172. package/web-dist/components/playing-card/PlayingCard.js +5 -4
  173. package/web-dist/components/poker-training-table/PokerTrainingTable.js +5 -4
  174. package/web-dist/components/popover-menu/PopoverMenu.js +11 -10
  175. package/web-dist/components/post-card/PostCard.js +19 -18
  176. package/web-dist/components/product-card/ProductCard.js +19 -18
  177. package/web-dist/components/progress/Progress.js +9 -8
  178. package/web-dist/components/progress-ring/ProgressRing.js +9 -8
  179. package/web-dist/components/radio/Radio.js +13 -12
  180. package/web-dist/components/radio-group/RadioGroup.js +13 -12
  181. package/web-dist/components/rating/Rating.js +8 -7
  182. package/web-dist/components/reader/Reader.js +20 -19
  183. package/web-dist/components/scan-overlay/ScanOverlay.js +20 -19
  184. package/web-dist/components/screen/Screen.js +5 -4
  185. package/web-dist/components/screen-section/ScreenSection.js +9 -8
  186. package/web-dist/components/scroll-view/ScrollView.js +5 -4
  187. package/web-dist/components/search-input/SearchInput.js +14 -13
  188. package/web-dist/components/section-header/SectionHeader.js +9 -8
  189. package/web-dist/components/section-list/SectionList.js +12 -11
  190. package/web-dist/components/select/Select.js +15 -14
  191. package/web-dist/components/selectable-item/SelectableItem.js +4 -3
  192. package/web-dist/components/selection-provider/SelectionProvider.js +4 -3
  193. package/web-dist/components/sign-in-form/SignInForm.js +22 -21
  194. package/web-dist/components/sign-up-form/SignUpForm.js +22 -21
  195. package/web-dist/components/skeleton/Skeleton.js +22 -21
  196. package/web-dist/components/skeleton-card/SkeletonCard.js +22 -21
  197. package/web-dist/components/skeleton-list/SkeletonList.js +22 -21
  198. package/web-dist/components/skeleton-text/SkeletonText.js +22 -21
  199. package/web-dist/components/surface/Surface.js +6 -5
  200. package/web-dist/components/switch/Switch.js +6 -5
  201. package/web-dist/components/tab/Tab.js +6 -5
  202. package/web-dist/components/tab-list/TabList.js +6 -5
  203. package/web-dist/components/tab-panel/TabPanel.js +6 -5
  204. package/web-dist/components/tabletop-table/TabletopTable.js +5 -4
  205. package/web-dist/components/tabs/Tabs.js +6 -5
  206. package/web-dist/components/text/Text.js +6 -5
  207. package/web-dist/components/text-input/TextInput.js +14 -13
  208. package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +12 -11
  209. package/web-dist/components/time-picker/TimePicker.js +17 -16
  210. package/web-dist/components/timeline/Timeline.js +11 -10
  211. package/web-dist/components/toast/Toast.js +8 -7
  212. package/web-dist/components/toast-provider/ToastProvider.js +8 -7
  213. package/web-dist/components/toolbar/Toolbar.js +19 -18
  214. package/web-dist/components/tree-item/TreeItem.js +17 -16
  215. package/web-dist/components/uploader/Uploader.js +22 -21
  216. package/web-dist/components/view/View.js +5 -4
  217. package/web-dist/manifest.json +1638 -1493
  218. package/web-dist/runtime/ZoraProvider.js +11 -9
@@ -0,0 +1,470 @@
1
+ import React from 'react';
2
+ import { Animated, Easing, Image, Pressable, StyleSheet, Text, View } from 'react-native';
3
+
4
+ import type { CarouselProps, CarouselSlide, CarouselTransition } from '../../types/carousel';
5
+ import { useZoraTheme } from '../theme/composition/useZoraTheme';
6
+ import { useCarouselPlayback } from './useCarouselPlayback';
7
+
8
+ /***
9
+ * Present images, arbitrary React content, or both as a cross-platform slideshow.
10
+ * A published web artifact exposes the same API without consumer source imports.
11
+ */
12
+ export function Carousel({
13
+ slides,
14
+ index,
15
+ defaultIndex,
16
+ onIndexChange,
17
+ autoPlay,
18
+ paused,
19
+ loop,
20
+ intervalMs,
21
+ transition = 'fade',
22
+ enterDurationMs = 1200,
23
+ exitDurationMs = 800,
24
+ initialScale = 1.06,
25
+ animateOnMount = false,
26
+ reducedMotion,
27
+ showProgress = true,
28
+ progressHeight = 4,
29
+ progressTrackColor,
30
+ progressIndicatorColor,
31
+ progressTrackStyle,
32
+ progressIndicatorStyle,
33
+ showArrows = false,
34
+ showIndicators = false,
35
+ previousLabel = 'Previous slide',
36
+ nextLabel = 'Next slide',
37
+ controlColor,
38
+ controlBackgroundColor,
39
+ controlsStyle,
40
+ activeIndicatorColor,
41
+ inactiveIndicatorColor,
42
+ indicatorsStyle,
43
+ resizeMode = 'cover',
44
+ imageStyle,
45
+ style,
46
+ renderImage,
47
+ testID,
48
+ }: CarouselProps) {
49
+ const { theme } = useZoraTheme();
50
+ const [width, setWidth] = React.useState(0);
51
+ const {
52
+ activeIndex,
53
+ controlledWithoutHandler,
54
+ direction,
55
+ loop: enabledLoop,
56
+ navigate,
57
+ progress,
58
+ shouldReduceMotion,
59
+ } = useCarouselPlayback({
60
+ slides,
61
+ index,
62
+ defaultIndex,
63
+ onIndexChange,
64
+ autoPlay,
65
+ paused,
66
+ loop,
67
+ intervalMs,
68
+ reducedMotion,
69
+ });
70
+
71
+ if (slides.length === 0) return null;
72
+
73
+ const canPrevious = enabledLoop || activeIndex > 0;
74
+ const canNext = enabledLoop || activeIndex < slides.length - 1;
75
+ const markerColor = activeIndicatorColor ?? theme.colors.primary;
76
+ const idleMarkerColor = inactiveIndicatorColor ?? theme.semantics.neutral.divider;
77
+
78
+ return (
79
+ <View
80
+ onLayout={(event) => setWidth(event.nativeEvent.layout.width)}
81
+ testID={testID}
82
+ style={[{ position: 'relative', overflow: 'hidden', width: '100%', height: '100%' }, style]}
83
+ >
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
+ ))}
104
+ <CarouselControls
105
+ activeIndex={activeIndex}
106
+ canNext={canNext}
107
+ canPrevious={canPrevious}
108
+ controlBackgroundColor={controlBackgroundColor ?? theme.semantics.surface.raised}
109
+ controlColor={controlColor ?? theme.semantics.content.default}
110
+ controlledWithoutHandler={controlledWithoutHandler}
111
+ controlsStyle={controlsStyle}
112
+ navigate={navigate}
113
+ nextLabel={nextLabel}
114
+ previousLabel={previousLabel}
115
+ show={showArrows && slides.length > 1}
116
+ testID={testID}
117
+ />
118
+ <CarouselIndicators
119
+ activeIndex={activeIndex}
120
+ activeColor={markerColor}
121
+ controlledWithoutHandler={controlledWithoutHandler}
122
+ idleColor={idleMarkerColor}
123
+ indicatorsStyle={indicatorsStyle}
124
+ navigate={navigate}
125
+ show={showIndicators && slides.length > 1}
126
+ slides={slides}
127
+ testID={testID}
128
+ />
129
+ <CarouselProgress
130
+ height={progressHeight}
131
+ indicatorColor={progressIndicatorColor ?? theme.colors.primary}
132
+ indicatorStyle={progressIndicatorStyle}
133
+ progress={progress}
134
+ show={showProgress && slides.length > 1}
135
+ testID={testID}
136
+ trackColor={progressTrackColor ?? theme.semantics.neutral.divider}
137
+ trackStyle={progressTrackStyle}
138
+ />
139
+ </View>
140
+ );
141
+ }
142
+
143
+ interface CarouselLayerProps {
144
+ readonly enterDurationMs?: CarouselProps['enterDurationMs'];
145
+ readonly exitDurationMs?: CarouselProps['exitDurationMs'];
146
+ readonly imageStyle: CarouselProps['imageStyle'];
147
+ readonly initialScale?: CarouselProps['initialScale'];
148
+ readonly renderImage: CarouselProps['renderImage'];
149
+ readonly resizeMode: CarouselProps['resizeMode'];
150
+ readonly slide: CarouselSlide;
151
+ readonly slideIndex: number;
152
+ readonly active: boolean;
153
+ readonly animate: boolean;
154
+ readonly animateOnMount: boolean;
155
+ readonly direction: 1 | -1;
156
+ readonly width: number;
157
+ readonly transition: CarouselTransition;
158
+ readonly reducedMotion: boolean;
159
+ }
160
+
161
+ /*** Keep departing slides mounted for an animated overlap without unmounting content. */
162
+ function CarouselLayer({
163
+ slide,
164
+ slideIndex,
165
+ active,
166
+ animate,
167
+ animateOnMount,
168
+ direction,
169
+ enterDurationMs = 1200,
170
+ exitDurationMs = 800,
171
+ initialScale = 1.06,
172
+ reducedMotion,
173
+ renderImage,
174
+ resizeMode,
175
+ imageStyle,
176
+ transition,
177
+ width,
178
+ }: CarouselLayerProps) {
179
+ const [opacity] = React.useState(() => new Animated.Value(active && !animateOnMount ? 1 : 0));
180
+ const [scale] = React.useState(
181
+ () => new Animated.Value(active && animateOnMount ? initialScale : 1),
182
+ );
183
+ const [offset] = React.useState(() => new Animated.Value(0));
184
+ const hasMounted = React.useRef(false);
185
+
186
+ React.useEffect(() => {
187
+ const firstRender = !hasMounted.current;
188
+ hasMounted.current = true;
189
+ if (firstRender && !animateOnMount) return;
190
+ opacity.stopAnimation();
191
+ scale.stopAnimation();
192
+ offset.stopAnimation();
193
+ if (!animate || reducedMotion || transition === 'none') {
194
+ opacity.setValue(active ? 1 : 0);
195
+ scale.setValue(1);
196
+ offset.setValue(0);
197
+ return;
198
+ }
199
+ if (transition === 'slide') {
200
+ scale.setValue(1);
201
+ if (active) {
202
+ offset.setValue(direction * width);
203
+ opacity.setValue(1);
204
+ }
205
+ Animated.parallel([
206
+ Animated.timing(offset, {
207
+ toValue: active ? 0 : -direction * width,
208
+ duration: Math.max(0, active ? enterDurationMs : exitDurationMs),
209
+ easing: Easing.bezier(0.4, 0, 0.2, 1),
210
+ useNativeDriver: true,
211
+ }),
212
+ Animated.timing(opacity, {
213
+ toValue: active ? 1 : 0,
214
+ duration: Math.max(0, active ? enterDurationMs : exitDurationMs),
215
+ easing: Easing.linear,
216
+ useNativeDriver: true,
217
+ }),
218
+ ]).start();
219
+ } else if (active) {
220
+ opacity.setValue(0);
221
+ scale.setValue(initialScale);
222
+ Animated.parallel([
223
+ Animated.timing(opacity, {
224
+ toValue: 1,
225
+ duration: Math.max(0, enterDurationMs),
226
+ easing: Easing.bezier(0.4, 0, 0.2, 1),
227
+ useNativeDriver: true,
228
+ }),
229
+ Animated.timing(scale, {
230
+ toValue: 1,
231
+ duration: Math.max(0, enterDurationMs),
232
+ easing: Easing.bezier(0.4, 0, 0.2, 1),
233
+ useNativeDriver: true,
234
+ }),
235
+ ]).start();
236
+ } else {
237
+ Animated.timing(opacity, {
238
+ toValue: 0,
239
+ duration: Math.max(0, exitDurationMs),
240
+ easing: Easing.bezier(0.4, 0, 0.2, 1),
241
+ useNativeDriver: true,
242
+ }).start();
243
+ }
244
+ return () => {
245
+ opacity.stopAnimation();
246
+ scale.stopAnimation();
247
+ offset.stopAnimation();
248
+ };
249
+ }, [
250
+ active,
251
+ animate,
252
+ animateOnMount,
253
+ direction,
254
+ enterDurationMs,
255
+ exitDurationMs,
256
+ initialScale,
257
+ offset,
258
+ opacity,
259
+ reducedMotion,
260
+ scale,
261
+ transition,
262
+ width,
263
+ ]);
264
+
265
+ return (
266
+ <Animated.View
267
+ accessibilityElementsHidden={!active}
268
+ importantForAccessibility={active ? 'auto' : 'no-hide-descendants'}
269
+ pointerEvents={active ? 'auto' : 'none'}
270
+ style={[StyleSheet.absoluteFill, { opacity, transform: [{ scale }, { translateX: offset }] }]}
271
+ >
272
+ {slide.source !== undefined ? (
273
+ renderImage ? (
274
+ renderImage(slide, slideIndex)
275
+ ) : (
276
+ <Image
277
+ accessibilityLabel={slide.alt}
278
+ accessible={Boolean(slide.alt)}
279
+ resizeMode={resizeMode}
280
+ source={typeof slide.source === 'string' ? { uri: slide.source } : slide.source}
281
+ style={[StyleSheet.absoluteFill, imageStyle]}
282
+ />
283
+ )
284
+ ) : null}
285
+ {slide.content}
286
+ </Animated.View>
287
+ );
288
+ }
289
+
290
+ interface CarouselNavigationProps {
291
+ readonly activeIndex: number;
292
+ readonly navigate: (index: number, direction: 1 | -1) => void;
293
+ readonly controlledWithoutHandler: boolean;
294
+ readonly testID: CarouselProps['testID'];
295
+ }
296
+
297
+ interface CarouselControlsProps extends CarouselNavigationProps {
298
+ readonly show: boolean;
299
+ readonly canPrevious: boolean;
300
+ readonly canNext: boolean;
301
+ readonly previousLabel: string;
302
+ readonly nextLabel: string;
303
+ readonly controlColor: string;
304
+ readonly controlBackgroundColor: string;
305
+ readonly controlsStyle: CarouselProps['controlsStyle'];
306
+ }
307
+
308
+ /*** Render optional previous/next buttons without coupling the slide content to navigation. */
309
+ function CarouselControls({
310
+ activeIndex,
311
+ canNext,
312
+ canPrevious,
313
+ controlBackgroundColor,
314
+ controlColor,
315
+ controlledWithoutHandler,
316
+ controlsStyle,
317
+ navigate,
318
+ nextLabel,
319
+ previousLabel,
320
+ show,
321
+ testID,
322
+ }: CarouselControlsProps) {
323
+ if (!show) return null;
324
+ const buttonStyle = [styles.control, { backgroundColor: controlBackgroundColor }];
325
+ const labelStyle = { color: controlColor, fontSize: 30 };
326
+ return (
327
+ <View pointerEvents="box-none" style={[styles.controls, controlsStyle]}>
328
+ <Pressable
329
+ accessibilityLabel={previousLabel}
330
+ accessibilityRole="button"
331
+ disabled={!canPrevious || controlledWithoutHandler}
332
+ onPress={() => navigate(activeIndex - 1, -1)}
333
+ style={buttonStyle}
334
+ testID={testID ? `${testID}-previous` : undefined}
335
+ >
336
+ <Text style={labelStyle}>{'‹'}</Text>
337
+ </Pressable>
338
+ <Pressable
339
+ accessibilityLabel={nextLabel}
340
+ accessibilityRole="button"
341
+ disabled={!canNext || controlledWithoutHandler}
342
+ onPress={() => navigate(activeIndex + 1, 1)}
343
+ style={buttonStyle}
344
+ testID={testID ? `${testID}-next` : undefined}
345
+ >
346
+ <Text style={labelStyle}>{'›'}</Text>
347
+ </Pressable>
348
+ </View>
349
+ );
350
+ }
351
+
352
+ interface CarouselIndicatorsProps extends CarouselNavigationProps {
353
+ readonly show: boolean;
354
+ readonly slides: CarouselProps['slides'];
355
+ readonly activeColor: string;
356
+ readonly idleColor: string;
357
+ readonly indicatorsStyle: CarouselProps['indicatorsStyle'];
358
+ }
359
+
360
+ /*** Render accessible selection dots for the currently controlled slide. */
361
+ function CarouselIndicators({
362
+ activeIndex,
363
+ activeColor,
364
+ controlledWithoutHandler,
365
+ idleColor,
366
+ indicatorsStyle,
367
+ navigate,
368
+ show,
369
+ slides,
370
+ testID,
371
+ }: CarouselIndicatorsProps) {
372
+ if (!show) return null;
373
+ return (
374
+ <View pointerEvents="box-none" style={[styles.indicators, indicatorsStyle]}>
375
+ {slides.map((slide, slideIndex) => (
376
+ <Pressable
377
+ key={slide.key}
378
+ accessibilityLabel={`Go to slide ${slideIndex + 1} of ${slides.length}`}
379
+ accessibilityRole="button"
380
+ accessibilityState={{ selected: slideIndex === activeIndex }}
381
+ disabled={controlledWithoutHandler}
382
+ onPress={() => navigate(slideIndex, slideIndex < activeIndex ? -1 : 1)}
383
+ style={[
384
+ styles.indicator,
385
+ {
386
+ backgroundColor: slideIndex === activeIndex ? activeColor : idleColor,
387
+ width: slideIndex === activeIndex ? 24 : 8,
388
+ },
389
+ ]}
390
+ testID={testID ? `${testID}-indicator-${slideIndex}` : undefined}
391
+ />
392
+ ))}
393
+ </View>
394
+ );
395
+ }
396
+
397
+ interface CarouselProgressProps {
398
+ readonly show: boolean;
399
+ readonly height: number;
400
+ readonly trackColor: string;
401
+ readonly indicatorColor: string;
402
+ readonly trackStyle: CarouselProps['progressTrackStyle'];
403
+ readonly indicatorStyle: CarouselProps['progressIndicatorStyle'];
404
+ readonly progress: Animated.Value;
405
+ readonly testID: CarouselProps['testID'];
406
+ }
407
+
408
+ /*** Render an optional linear autoplay timer without adding any required UI to slides. */
409
+ function CarouselProgress({
410
+ height,
411
+ indicatorColor,
412
+ indicatorStyle,
413
+ progress,
414
+ show,
415
+ testID,
416
+ trackColor,
417
+ trackStyle,
418
+ }: CarouselProgressProps) {
419
+ if (!show) return null;
420
+ return (
421
+ <View
422
+ pointerEvents="none"
423
+ style={[styles.progress, { height, backgroundColor: trackColor }, trackStyle]}
424
+ testID={testID ? `${testID}-progress` : undefined}
425
+ >
426
+ <Animated.View
427
+ style={[
428
+ {
429
+ height: '100%',
430
+ width: progress.interpolate({ inputRange: [0, 1], outputRange: ['0%', '100%'] }),
431
+ backgroundColor: indicatorColor,
432
+ },
433
+ indicatorStyle,
434
+ ]}
435
+ />
436
+ </View>
437
+ );
438
+ }
439
+
440
+ const styles = StyleSheet.create({
441
+ controls: {
442
+ position: 'absolute',
443
+ top: 0,
444
+ bottom: 0,
445
+ left: 14,
446
+ right: 14,
447
+ flexDirection: 'row',
448
+ justifyContent: 'space-between',
449
+ alignItems: 'center',
450
+ },
451
+ control: {
452
+ width: 44,
453
+ height: 44,
454
+ borderRadius: 22,
455
+ justifyContent: 'center',
456
+ alignItems: 'center',
457
+ },
458
+ indicators: {
459
+ position: 'absolute',
460
+ bottom: 24,
461
+ left: 0,
462
+ right: 0,
463
+ flexDirection: 'row',
464
+ gap: 10,
465
+ justifyContent: 'center',
466
+ alignItems: 'center',
467
+ },
468
+ indicator: { height: 8, borderRadius: 8 },
469
+ progress: { position: 'absolute', bottom: 0, left: 0, right: 0, overflow: 'hidden' },
470
+ });
@@ -0,0 +1,2 @@
1
+ export type { CarouselProps, CarouselSlide, CarouselTransition } from '../../types/carousel';
2
+ export { Carousel } from './Carousel';
@@ -0,0 +1,103 @@
1
+ import React from 'react';
2
+ import { AccessibilityInfo, Animated, Easing } from 'react-native';
3
+
4
+ import type { CarouselProps } from '../../types/carousel';
5
+
6
+ /*** Own controlled/uncontrolled slide navigation, autoplay, and progress lifecycle. */
7
+ export function useCarouselPlayback({
8
+ slides,
9
+ index,
10
+ defaultIndex = 0,
11
+ onIndexChange,
12
+ autoPlay = true,
13
+ paused = false,
14
+ loop = true,
15
+ intervalMs = 6000,
16
+ reducedMotion,
17
+ }: CarouselPlaybackOptions) {
18
+ const [uncontrolledIndex, setUncontrolledIndex] = React.useState(defaultIndex);
19
+ const [direction, setDirection] = React.useState<1 | -1>(1);
20
+ const [progress] = React.useState(() => new Animated.Value(0));
21
+ const systemReducedMotion = useSystemReducedMotion();
22
+ const shouldReduceMotion = reducedMotion ?? systemReducedMotion;
23
+ const activeIndex = normalizeIndex(index ?? uncontrolledIndex, slides.length);
24
+ const duration = Math.max(1, intervalMs);
25
+ const controlledWithoutHandler = index !== undefined && onIndexChange === undefined;
26
+ const canAdvance = loop || activeIndex < slides.length - 1;
27
+ const shouldPlay =
28
+ autoPlay && !paused && slides.length > 1 && canAdvance && !controlledWithoutHandler;
29
+
30
+ const navigate = React.useCallback(
31
+ (target: number, nextDirection: 1 | -1) => {
32
+ if (slides.length < 2 || controlledWithoutHandler) return;
33
+ const next = loop
34
+ ? (target + slides.length) % slides.length
35
+ : normalizeIndex(target, slides.length);
36
+ if (next === activeIndex) return;
37
+ setDirection(nextDirection);
38
+ if (index === undefined) setUncontrolledIndex(next);
39
+ onIndexChange?.(next);
40
+ },
41
+ [activeIndex, controlledWithoutHandler, index, loop, onIndexChange, slides.length],
42
+ );
43
+
44
+ React.useEffect(() => {
45
+ if (!shouldPlay) return;
46
+ const timeout = setTimeout(() => navigate(activeIndex + 1, 1), duration);
47
+ return () => clearTimeout(timeout);
48
+ }, [activeIndex, duration, navigate, shouldPlay]);
49
+
50
+ React.useEffect(() => {
51
+ progress.stopAnimation();
52
+ progress.setValue(0);
53
+ if (!shouldPlay || shouldReduceMotion) return;
54
+ const animation = Animated.timing(progress, {
55
+ toValue: 1,
56
+ duration,
57
+ easing: Easing.linear,
58
+ useNativeDriver: false,
59
+ });
60
+ animation.start();
61
+ return () => animation.stop();
62
+ }, [activeIndex, duration, progress, shouldPlay, shouldReduceMotion]);
63
+
64
+ return {
65
+ activeIndex,
66
+ controlledWithoutHandler,
67
+ direction,
68
+ loop,
69
+ navigate,
70
+ progress,
71
+ shouldReduceMotion,
72
+ } as const;
73
+ }
74
+
75
+ type CarouselPlaybackOptions = Pick<
76
+ CarouselProps,
77
+ | 'slides'
78
+ | 'index'
79
+ | 'defaultIndex'
80
+ | 'onIndexChange'
81
+ | 'autoPlay'
82
+ | 'paused'
83
+ | 'loop'
84
+ | 'intervalMs'
85
+ | 'reducedMotion'
86
+ >;
87
+
88
+ /*** Clamp a controlled index whenever the consumer changes the slide collection. */
89
+ function normalizeIndex(value: number, count: number): number {
90
+ if (count <= 0 || !Number.isFinite(value)) return 0;
91
+ return Math.min(Math.max(Math.trunc(value), 0), count - 1);
92
+ }
93
+
94
+ /*** Observe reduced-motion preferences without adding browser-only imports. */
95
+ function useSystemReducedMotion(): boolean {
96
+ const [reduced, setReduced] = React.useState(false);
97
+ React.useEffect(() => {
98
+ void AccessibilityInfo.isReduceMotionEnabled().then(setReduced);
99
+ const listener = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduced);
100
+ return () => listener.remove();
101
+ }, []);
102
+ return reduced;
103
+ }
package/src/index.ts CHANGED
@@ -14,6 +14,8 @@ export {
14
14
  AuthoringSelectionAdapter,
15
15
  ThemeEditorAdapter,
16
16
  } from './authoring';
17
+ export type { CarouselProps, CarouselSlide, CarouselTransition } from './features/carousel/public';
18
+ export { Carousel } from './features/carousel/public';
17
19
  export type {
18
20
  ColorHueScaleProps,
19
21
  ColorPickerProps,
@@ -0,0 +1,60 @@
1
+ import type { ReactNode } from 'react';
2
+ import type {
3
+ ImageResizeMode,
4
+ ImageSourcePropType,
5
+ ImageStyle,
6
+ StyleProp,
7
+ ViewStyle,
8
+ } from 'react-native';
9
+
10
+ export type CarouselTransition = 'fade' | 'slide' | 'none';
11
+
12
+ /** One presentation frame: an image, arbitrary React content, or both. */
13
+ export interface CarouselSlide {
14
+ key: string;
15
+ source?: string | ImageSourcePropType;
16
+ alt?: string;
17
+ content?: ReactNode;
18
+ }
19
+
20
+ /** Configurable cross-platform carousel; the consumer owns slide content. */
21
+ export interface CarouselProps {
22
+ slides: readonly CarouselSlide[];
23
+ /** Controlled index. If omitted, Carousel manages its own position. */
24
+ index?: number;
25
+ defaultIndex?: number;
26
+ onIndexChange?: (index: number) => void;
27
+ autoPlay?: boolean;
28
+ paused?: boolean;
29
+ loop?: boolean;
30
+ intervalMs?: number;
31
+ transition?: CarouselTransition;
32
+ enterDurationMs?: number;
33
+ exitDurationMs?: number;
34
+ initialScale?: number;
35
+ animateOnMount?: boolean;
36
+ /** Overrides the host OS preference when explicitly supplied. */
37
+ reducedMotion?: boolean;
38
+ showProgress?: boolean;
39
+ progressHeight?: number;
40
+ progressTrackColor?: string;
41
+ progressIndicatorColor?: string;
42
+ progressTrackStyle?: StyleProp<ViewStyle>;
43
+ progressIndicatorStyle?: StyleProp<ViewStyle>;
44
+ showArrows?: boolean;
45
+ showIndicators?: boolean;
46
+ previousLabel?: string;
47
+ nextLabel?: string;
48
+ controlColor?: string;
49
+ controlBackgroundColor?: string;
50
+ controlsStyle?: StyleProp<ViewStyle>;
51
+ activeIndicatorColor?: string;
52
+ inactiveIndicatorColor?: string;
53
+ indicatorsStyle?: StyleProp<ViewStyle>;
54
+ resizeMode?: ImageResizeMode;
55
+ imageStyle?: StyleProp<ImageStyle>;
56
+ style?: StyleProp<ViewStyle>;
57
+ /** Enables Next/Image or another consumer-specific image optimization. */
58
+ renderImage?: (slide: CarouselSlide, index: number) => ReactNode;
59
+ testID?: string;
60
+ }
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import {
3
3
  useZoraTheme2
4
- } from "./Accordion-gysa24fk.js";
4
+ } from "./Accordion-j5wsx41j.js";
5
5
 
6
6
  // src/features/theme/utils/resolveZoraThemeRecipe.ts
7
7
  function resolveZoraThemeRecipe(theme, meta) {
@@ -1,19 +1,19 @@
1
1
  'use client';
2
2
  import {
3
3
  Icon3
4
- } from "./Accordion-vzgpdtr2.js";
4
+ } from "./Accordion-wdby2v5r.js";
5
5
  import {
6
6
  useTheme
7
- } from "./Accordion-tpd1vvy9.js";
7
+ } from "./Accordion-ng79nxzz.js";
8
8
  import {
9
9
  View3
10
- } from "./Accordion-a8k3cvj0.js";
10
+ } from "./Accordion-qyf0e72g.js";
11
11
  import {
12
12
  Pressable
13
- } from "./Accordion-c44m1q0m.js";
13
+ } from "./Accordion-xkewtxac.js";
14
14
  import {
15
15
  Text2
16
- } from "./Accordion-8vcs6nz6.js";
16
+ } from "./Accordion-9cpm8x92.js";
17
17
  import {
18
18
  resolveControlSize,
19
19
  resolveIconSize2,
@@ -4,10 +4,10 @@ import {
4
4
  } from "./Accordion-neg1cgeh.js";
5
5
  import {
6
6
  withZoraThemeScope
7
- } from "./Accordion-mrhkw8n6.js";
7
+ } from "./Accordion-hqg1zbxk.js";
8
8
  import {
9
9
  useZoraTheme2
10
- } from "./Accordion-gysa24fk.js";
10
+ } from "./Accordion-j5wsx41j.js";
11
11
  import {
12
12
  require_cjs
13
13
  } from "./Accordion-xgpzh4wq.js";