@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.
- package/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/dist/features/carousel/Carousel.d.ts +8 -0
- package/dist/features/carousel/Carousel.d.ts.map +1 -0
- package/dist/features/carousel/Carousel.js +203 -0
- package/dist/features/carousel/Carousel.js.map +1 -0
- package/dist/features/carousel/public.d.ts +3 -0
- package/dist/features/carousel/public.d.ts.map +1 -0
- package/dist/features/carousel/public.js +2 -0
- package/dist/features/carousel/public.js.map +1 -0
- package/dist/features/carousel/useCarouselPlayback.d.ts +15 -0
- package/dist/features/carousel/useCarouselPlayback.d.ts.map +1 -0
- package/dist/features/carousel/useCarouselPlayback.js +74 -0
- package/dist/features/carousel/useCarouselPlayback.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/carousel.d.ts +52 -0
- package/dist/types/carousel.d.ts.map +1 -0
- package/dist/types/carousel.js +2 -0
- package/dist/types/carousel.js.map +1 -0
- package/package.json +1 -1
- package/src/features/carousel/Carousel.test.ts +66 -0
- package/src/features/carousel/Carousel.tsx +470 -0
- package/src/features/carousel/public.ts +2 -0
- package/src/features/carousel/useCarouselPlayback.ts +103 -0
- package/src/index.ts +2 -0
- package/src/types/carousel.ts +60 -0
- package/web-dist/chunks/{Accordion-9d3rd7ne.js → Accordion-19zt3dyq.js} +1 -1
- package/web-dist/chunks/{Accordion-8j7t77tf.js → Accordion-1j50tne9.js} +5 -5
- package/web-dist/chunks/{Accordion-sxzts6bj.js → Accordion-1k7pyxdd.js} +2 -2
- package/web-dist/chunks/{Accordion-fbehwpr1.js → Accordion-1ty4zrzd.js} +7 -7
- package/web-dist/chunks/{Accordion-r86ce0wj.js → Accordion-291hyjee.js} +4 -4
- package/web-dist/chunks/{Accordion-m3xb7z7j.js → Accordion-396cm5m0.js} +8 -8
- package/web-dist/chunks/{Accordion-p2f0e4pn.js → Accordion-3dk0s8hz.js} +6 -6
- package/web-dist/chunks/{Accordion-260pyaxy.js → Accordion-54417vp7.js} +5 -5
- package/web-dist/chunks/{Accordion-5pbvgvqc.js → Accordion-67a2a09x.js} +2 -2
- package/web-dist/chunks/{Accordion-j6bs1yfn.js → Accordion-6tfr02mw.js} +2 -2
- package/web-dist/chunks/{Accordion-e8dg1z2s.js → Accordion-6y42ws4p.js} +2 -2
- package/web-dist/chunks/{Accordion-w0prbwy0.js → Accordion-7j05jjqn.js} +8 -8
- package/web-dist/chunks/{Accordion-252dr90x.js → Accordion-7tg3cabd.js} +4 -4
- package/web-dist/chunks/{Accordion-8vcs6nz6.js → Accordion-9cpm8x92.js} +1 -1
- package/web-dist/chunks/{Accordion-ms1y70gq.js → Accordion-c1btejmf.js} +4 -4
- package/web-dist/chunks/{Accordion-yb4as6wc.js → Accordion-db40jsp6.js} +5 -5
- package/web-dist/chunks/{Accordion-wx0jp5cn.js → Accordion-dmkygw9c.js} +7 -7
- package/web-dist/chunks/{Accordion-vq8zrnwh.js → Accordion-dr8k9txz.js} +4 -4
- package/web-dist/chunks/{Accordion-jx9tc6p1.js → Accordion-e8r2qt0n.js} +4 -4
- package/web-dist/chunks/{Accordion-tnt1txfq.js → Accordion-ephzqa3t.js} +4 -4
- package/web-dist/chunks/{Accordion-4kmh6s2k.js → Accordion-fcpadcrg.js} +2 -2
- package/web-dist/chunks/{Accordion-0j4xzcwz.js → Accordion-gaevp89v.js} +3 -3
- package/web-dist/chunks/{Accordion-r6zvzrkd.js → Accordion-gwq0xkp9.js} +3 -3
- package/web-dist/chunks/{Accordion-9hcbf56f.js → Accordion-h4928ex8.js} +2 -2
- package/web-dist/chunks/{Accordion-mrhkw8n6.js → Accordion-hqg1zbxk.js} +6 -4
- package/web-dist/chunks/{Accordion-gysa24fk.js → Accordion-j5wsx41j.js} +1 -1
- package/web-dist/chunks/{Accordion-wvghkwxx.js → Accordion-jj6sg99e.js} +9 -9
- package/web-dist/chunks/{Accordion-7mnan4q4.js → Accordion-jqjnzjmt.js} +6 -6
- package/web-dist/chunks/{Accordion-b4yr6yq3.js → Accordion-jsdjgfn2.js} +2 -2
- package/web-dist/chunks/{Accordion-8ac6dkcs.js → Accordion-k058095e.js} +1 -1
- package/web-dist/chunks/Accordion-kcx57mk5.js +39 -0
- package/web-dist/chunks/{Accordion-mpebzjby.js → Accordion-kmbw4fe7.js} +4 -4
- package/web-dist/chunks/{Accordion-yrzm02g2.js → Accordion-kn52vs02.js} +5 -5
- package/web-dist/chunks/{Accordion-nnhznqgf.js → Accordion-n8dksapd.js} +2 -2
- package/web-dist/chunks/{Accordion-tpd1vvy9.js → Accordion-ng79nxzz.js} +1 -38
- package/web-dist/chunks/{Accordion-np16p9mh.js → Accordion-psxc0zjs.js} +4 -4
- package/web-dist/chunks/{Accordion-4c7hqeg3.js → Accordion-q3wk945k.js} +2 -2
- package/web-dist/chunks/{Accordion-t2cvrn0r.js → Accordion-qjp8bp5y.js} +8 -8
- package/web-dist/chunks/{Accordion-a8k3cvj0.js → Accordion-qyf0e72g.js} +1 -1
- package/web-dist/chunks/{Accordion-rcs75kj4.js → Accordion-r6gwemh9.js} +3 -3
- package/web-dist/chunks/{Accordion-hh48jjhk.js → Accordion-rbtgfrn4.js} +7 -7
- package/web-dist/chunks/{Accordion-kcca65d8.js → Accordion-rqh7264g.js} +5 -5
- package/web-dist/chunks/{Accordion-ew2cebyd.js → Accordion-rxc2p9md.js} +3 -3
- package/web-dist/chunks/{Accordion-f2n2zz1x.js → Accordion-scvx38z0.js} +6 -6
- package/web-dist/chunks/{Accordion-hf4nfkn0.js → Accordion-vayww2ec.js} +13 -13
- package/web-dist/chunks/{Accordion-vzgpdtr2.js → Accordion-wdby2v5r.js} +1 -1
- package/web-dist/chunks/{Accordion-7788ybcs.js → Accordion-wswm0zxe.js} +4 -4
- package/web-dist/chunks/{Accordion-rwc34cn2.js → Accordion-xjxam647.js} +5 -5
- package/web-dist/chunks/{Accordion-c44m1q0m.js → Accordion-xkewtxac.js} +2 -2
- package/web-dist/chunks/{Accordion-001ymezm.js → Accordion-y524ph0g.js} +1 -1
- package/web-dist/chunks/{Accordion-5z8pbn4z.js → Accordion-y7z4v31b.js} +3 -3
- package/web-dist/chunks/{Accordion-6jsea4e0.js → Accordion-yrs9sd97.js} +8 -8
- package/web-dist/chunks/{Accordion-jh94mg56.js → Accordion-ytvjnaz3.js} +9 -9
- package/web-dist/chunks/{Accordion-s9nbkzky.js → Accordion-zmee9h36.js} +2 -2
- package/web-dist/chunks/{Accordion-p7mxkxhs.js → Accordion-zx1qd2tf.js} +9 -9
- package/web-dist/components/accordion/Accordion.js +11 -10
- package/web-dist/components/accordion-item/AccordionItem.js +11 -10
- package/web-dist/components/activity-indicator/ActivityIndicator.js +4 -3
- package/web-dist/components/app-bar/AppBar.js +17 -16
- package/web-dist/components/app-header/AppHeader.js +17 -16
- package/web-dist/components/app-shell/AppShell.js +5 -4
- package/web-dist/components/auth-screen/AuthScreen.js +22 -21
- package/web-dist/components/avatar/Avatar.js +11 -10
- package/web-dist/components/avatar-group/AvatarGroup.js +11 -10
- package/web-dist/components/badge/Badge.js +6 -5
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +20 -19
- package/web-dist/components/bottom-sheet/BottomSheet.js +7 -6
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +7 -6
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +7 -6
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +7 -6
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +7 -6
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +7 -6
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +14 -13
- package/web-dist/components/button/Button.js +12 -11
- package/web-dist/components/button-group/ButtonGroup.js +12 -11
- package/web-dist/components/calendar/Calendar.js +14 -13
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +20 -19
- package/web-dist/components/card/Card.js +19 -18
- package/web-dist/components/card-back/CardBack.js +5 -4
- package/web-dist/components/card-hand/CardHand.js +5 -4
- package/web-dist/components/carousel/Carousel.d.ts +10 -0
- package/web-dist/components/carousel/Carousel.js +483 -0
- package/web-dist/components/carousel/Carousel.types-0.d.ts +55 -0
- package/web-dist/components/carousel/index.d.ts +2 -0
- package/web-dist/components/carousel/index.js +2 -0
- package/web-dist/components/chat-list-item/ChatListItem.js +15 -14
- package/web-dist/components/checkbox/Checkbox.js +11 -10
- package/web-dist/components/checkbox-group/CheckboxGroup.js +11 -10
- package/web-dist/components/chess-board/ChessBoard.js +5 -4
- package/web-dist/components/chip/Chip.js +12 -11
- package/web-dist/components/chip-group/ChipGroup.js +12 -11
- package/web-dist/components/collection-editor/CollectionEditor.js +19 -18
- package/web-dist/components/color-hue-scale/ColorHueScale.js +15 -14
- package/web-dist/components/color-picker/ColorPicker.js +15 -14
- package/web-dist/components/color-tone/ColorTone.js +15 -14
- package/web-dist/components/color-wheel/ColorWheel.js +15 -14
- package/web-dist/components/content-rail/ContentRail.js +13 -12
- package/web-dist/components/data-table/DataTable.js +25 -24
- package/web-dist/components/date-picker/DatePicker.js +18 -17
- package/web-dist/components/dialog/Dialog.js +10 -9
- package/web-dist/components/divider/Divider.js +5 -4
- package/web-dist/components/empty-state/EmptyState.js +20 -19
- package/web-dist/components/explorer/Explorer.js +12 -11
- package/web-dist/components/field/Field.js +11 -10
- package/web-dist/components/file-explorer/FileExplorer.js +12 -11
- package/web-dist/components/flat-list/FlatList.js +12 -11
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +22 -21
- package/web-dist/components/form/Form.js +16 -15
- package/web-dist/components/form-actions/FormActions.js +16 -15
- package/web-dist/components/form-error/FormError.js +16 -15
- package/web-dist/components/game/Game.js +6 -5
- package/web-dist/components/game-entity/GameEntity.js +6 -5
- package/web-dist/components/game-field/GameField.js +6 -5
- package/web-dist/components/game-input-zone/GameInputZone.js +6 -5
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +6 -5
- package/web-dist/components/game-overlay/GameOverlay.js +6 -5
- package/web-dist/components/gradient/Gradient.js +6 -5
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +6 -5
- package/web-dist/components/grid/Grid.js +5 -4
- package/web-dist/components/grid-line-overlay/GridLineOverlay.js +5 -4
- package/web-dist/components/grid-ruler/GridRuler.js +5 -4
- package/web-dist/components/heading/Heading.js +6 -5
- package/web-dist/components/hero/Hero.js +19 -18
- package/web-dist/components/icon/Icon.js +5 -4
- package/web-dist/components/icon-button/IconButton.js +12 -11
- package/web-dist/components/image/Image.js +9 -8
- package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +4 -3
- package/web-dist/components/list/List.js +12 -11
- package/web-dist/components/list-item/ListItem.js +12 -11
- package/web-dist/components/list-section/ListSection.js +12 -11
- package/web-dist/components/matrix-grid/MatrixGrid.js +5 -4
- package/web-dist/components/media-card/MediaCard.js +19 -18
- package/web-dist/components/media-explorer/MediaExplorer.js +12 -11
- package/web-dist/components/message-bubble/MessageBubble.js +15 -14
- package/web-dist/components/metric-card/MetricCard.js +19 -18
- package/web-dist/components/missing-element/MissingElement.js +10 -9
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +22 -21
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +22 -21
- package/web-dist/components/opening-book/OpeningBook.js +5 -4
- package/web-dist/components/otp-form/OtpForm.js +22 -21
- package/web-dist/components/pagination/Pagination.js +13 -12
- package/web-dist/components/palette-item/PaletteItem.js +19 -18
- package/web-dist/components/playing-card/PlayingCard.js +5 -4
- package/web-dist/components/poker-training-table/PokerTrainingTable.js +5 -4
- package/web-dist/components/popover-menu/PopoverMenu.js +11 -10
- package/web-dist/components/post-card/PostCard.js +19 -18
- package/web-dist/components/product-card/ProductCard.js +19 -18
- package/web-dist/components/progress/Progress.js +9 -8
- package/web-dist/components/progress-ring/ProgressRing.js +9 -8
- package/web-dist/components/radio/Radio.js +13 -12
- package/web-dist/components/radio-group/RadioGroup.js +13 -12
- package/web-dist/components/rating/Rating.js +8 -7
- package/web-dist/components/reader/Reader.js +20 -19
- package/web-dist/components/scan-overlay/ScanOverlay.js +20 -19
- package/web-dist/components/screen/Screen.js +5 -4
- package/web-dist/components/screen-section/ScreenSection.js +9 -8
- package/web-dist/components/scroll-view/ScrollView.js +5 -4
- package/web-dist/components/search-input/SearchInput.js +14 -13
- package/web-dist/components/section-header/SectionHeader.js +9 -8
- package/web-dist/components/section-list/SectionList.js +12 -11
- package/web-dist/components/select/Select.js +15 -14
- package/web-dist/components/selectable-item/SelectableItem.js +4 -3
- package/web-dist/components/selection-provider/SelectionProvider.js +4 -3
- package/web-dist/components/sign-in-form/SignInForm.js +22 -21
- package/web-dist/components/sign-up-form/SignUpForm.js +22 -21
- package/web-dist/components/skeleton/Skeleton.js +22 -21
- package/web-dist/components/skeleton-card/SkeletonCard.js +22 -21
- package/web-dist/components/skeleton-list/SkeletonList.js +22 -21
- package/web-dist/components/skeleton-text/SkeletonText.js +22 -21
- package/web-dist/components/surface/Surface.js +6 -5
- package/web-dist/components/switch/Switch.js +6 -5
- package/web-dist/components/tab/Tab.js +6 -5
- package/web-dist/components/tab-list/TabList.js +6 -5
- package/web-dist/components/tab-panel/TabPanel.js +6 -5
- package/web-dist/components/tabletop-table/TabletopTable.js +5 -4
- package/web-dist/components/tabs/Tabs.js +6 -5
- package/web-dist/components/text/Text.js +6 -5
- package/web-dist/components/text-input/TextInput.js +14 -13
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +12 -11
- package/web-dist/components/time-picker/TimePicker.js +17 -16
- package/web-dist/components/timeline/Timeline.js +11 -10
- package/web-dist/components/toast/Toast.js +8 -7
- package/web-dist/components/toast-provider/ToastProvider.js +8 -7
- package/web-dist/components/toolbar/Toolbar.js +19 -18
- package/web-dist/components/tree-item/TreeItem.js +17 -16
- package/web-dist/components/uploader/Uploader.js +22 -21
- package/web-dist/components/view/View.js +5 -4
- package/web-dist/manifest.json +1638 -1493
- package/web-dist/runtime/ZoraProvider.js +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 27.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a72113b: Add the reusable React Native and React Native Web `Carousel` with images or arbitrary slide content, fade/slide/none transitions, controls, timing, progress, controlled index, and a public browser artifact.
|
|
8
|
+
|
|
3
9
|
## 27.7.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# ZORA
|
|
5
5
|
|
|
6
|
-
         
|
|
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
|
|
|
@@ -42,7 +42,7 @@ export default function BasicApp() {
|
|
|
42
42
|
}
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
This package contains
|
|
45
|
+
This package contains 7 additional examples. See the generated documentation for the complete set.
|
|
46
46
|
|
|
47
47
|
## Documentation
|
|
48
48
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CarouselProps } from '../../types/carousel';
|
|
3
|
+
/***
|
|
4
|
+
* Present images, arbitrary React content, or both as a cross-platform slideshow.
|
|
5
|
+
* A published web artifact exposes the same API without consumer source imports.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Carousel({ slides, index, defaultIndex, onIndexChange, autoPlay, paused, loop, intervalMs, transition, enterDurationMs, exitDurationMs, initialScale, animateOnMount, reducedMotion, showProgress, progressHeight, progressTrackColor, progressIndicatorColor, progressTrackStyle, progressIndicatorStyle, showArrows, showIndicators, previousLabel, nextLabel, controlColor, controlBackgroundColor, controlsStyle, activeIndicatorColor, inactiveIndicatorColor, indicatorsStyle, resizeMode, imageStyle, style, renderImage, testID, }: CarouselProps): React.JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=Carousel.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Animated, Easing, Image, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
4
|
+
import { useCarouselPlayback } from './useCarouselPlayback';
|
|
5
|
+
/***
|
|
6
|
+
* Present images, arbitrary React content, or both as a cross-platform slideshow.
|
|
7
|
+
* A published web artifact exposes the same API without consumer source imports.
|
|
8
|
+
*/
|
|
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
|
+
const { theme } = useZoraTheme();
|
|
11
|
+
const [width, setWidth] = React.useState(0);
|
|
12
|
+
const { activeIndex, controlledWithoutHandler, direction, loop: enabledLoop, navigate, progress, shouldReduceMotion, } = useCarouselPlayback({
|
|
13
|
+
slides,
|
|
14
|
+
index,
|
|
15
|
+
defaultIndex,
|
|
16
|
+
onIndexChange,
|
|
17
|
+
autoPlay,
|
|
18
|
+
paused,
|
|
19
|
+
loop,
|
|
20
|
+
intervalMs,
|
|
21
|
+
reducedMotion,
|
|
22
|
+
});
|
|
23
|
+
if (slides.length === 0)
|
|
24
|
+
return null;
|
|
25
|
+
const canPrevious = enabledLoop || activeIndex > 0;
|
|
26
|
+
const canNext = enabledLoop || activeIndex < slides.length - 1;
|
|
27
|
+
const markerColor = activeIndicatorColor ?? theme.colors.primary;
|
|
28
|
+
const idleMarkerColor = inactiveIndicatorColor ?? theme.semantics.neutral.divider;
|
|
29
|
+
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}/>))}
|
|
31
|
+
<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
|
+
<CarouselIndicators activeIndex={activeIndex} activeColor={markerColor} controlledWithoutHandler={controlledWithoutHandler} idleColor={idleMarkerColor} indicatorsStyle={indicatorsStyle} navigate={navigate} show={showIndicators && slides.length > 1} slides={slides} testID={testID}/>
|
|
33
|
+
<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
|
+
</View>);
|
|
35
|
+
}
|
|
36
|
+
/*** 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, }) {
|
|
38
|
+
const [opacity] = React.useState(() => new Animated.Value(active && !animateOnMount ? 1 : 0));
|
|
39
|
+
const [scale] = React.useState(() => new Animated.Value(active && animateOnMount ? initialScale : 1));
|
|
40
|
+
const [offset] = React.useState(() => new Animated.Value(0));
|
|
41
|
+
const hasMounted = React.useRef(false);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
const firstRender = !hasMounted.current;
|
|
44
|
+
hasMounted.current = true;
|
|
45
|
+
if (firstRender && !animateOnMount)
|
|
46
|
+
return;
|
|
47
|
+
opacity.stopAnimation();
|
|
48
|
+
scale.stopAnimation();
|
|
49
|
+
offset.stopAnimation();
|
|
50
|
+
if (!animate || reducedMotion || transition === 'none') {
|
|
51
|
+
opacity.setValue(active ? 1 : 0);
|
|
52
|
+
scale.setValue(1);
|
|
53
|
+
offset.setValue(0);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (transition === 'slide') {
|
|
57
|
+
scale.setValue(1);
|
|
58
|
+
if (active) {
|
|
59
|
+
offset.setValue(direction * width);
|
|
60
|
+
opacity.setValue(1);
|
|
61
|
+
}
|
|
62
|
+
Animated.parallel([
|
|
63
|
+
Animated.timing(offset, {
|
|
64
|
+
toValue: active ? 0 : -direction * width,
|
|
65
|
+
duration: Math.max(0, active ? enterDurationMs : exitDurationMs),
|
|
66
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
67
|
+
useNativeDriver: true,
|
|
68
|
+
}),
|
|
69
|
+
Animated.timing(opacity, {
|
|
70
|
+
toValue: active ? 1 : 0,
|
|
71
|
+
duration: Math.max(0, active ? enterDurationMs : exitDurationMs),
|
|
72
|
+
easing: Easing.linear,
|
|
73
|
+
useNativeDriver: true,
|
|
74
|
+
}),
|
|
75
|
+
]).start();
|
|
76
|
+
}
|
|
77
|
+
else if (active) {
|
|
78
|
+
opacity.setValue(0);
|
|
79
|
+
scale.setValue(initialScale);
|
|
80
|
+
Animated.parallel([
|
|
81
|
+
Animated.timing(opacity, {
|
|
82
|
+
toValue: 1,
|
|
83
|
+
duration: Math.max(0, enterDurationMs),
|
|
84
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
85
|
+
useNativeDriver: true,
|
|
86
|
+
}),
|
|
87
|
+
Animated.timing(scale, {
|
|
88
|
+
toValue: 1,
|
|
89
|
+
duration: Math.max(0, enterDurationMs),
|
|
90
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
91
|
+
useNativeDriver: true,
|
|
92
|
+
}),
|
|
93
|
+
]).start();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
Animated.timing(opacity, {
|
|
97
|
+
toValue: 0,
|
|
98
|
+
duration: Math.max(0, exitDurationMs),
|
|
99
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
100
|
+
useNativeDriver: true,
|
|
101
|
+
}).start();
|
|
102
|
+
}
|
|
103
|
+
return () => {
|
|
104
|
+
opacity.stopAnimation();
|
|
105
|
+
scale.stopAnimation();
|
|
106
|
+
offset.stopAnimation();
|
|
107
|
+
};
|
|
108
|
+
}, [
|
|
109
|
+
active,
|
|
110
|
+
animate,
|
|
111
|
+
animateOnMount,
|
|
112
|
+
direction,
|
|
113
|
+
enterDurationMs,
|
|
114
|
+
exitDurationMs,
|
|
115
|
+
initialScale,
|
|
116
|
+
offset,
|
|
117
|
+
opacity,
|
|
118
|
+
reducedMotion,
|
|
119
|
+
scale,
|
|
120
|
+
transition,
|
|
121
|
+
width,
|
|
122
|
+
]);
|
|
123
|
+
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}
|
|
125
|
+
{slide.content}
|
|
126
|
+
</Animated.View>);
|
|
127
|
+
}
|
|
128
|
+
/*** Render optional previous/next buttons without coupling the slide content to navigation. */
|
|
129
|
+
function CarouselControls({ activeIndex, canNext, canPrevious, controlBackgroundColor, controlColor, controlledWithoutHandler, controlsStyle, navigate, nextLabel, previousLabel, show, testID, }) {
|
|
130
|
+
if (!show)
|
|
131
|
+
return null;
|
|
132
|
+
const buttonStyle = [styles.control, { backgroundColor: controlBackgroundColor }];
|
|
133
|
+
const labelStyle = { color: controlColor, fontSize: 30 };
|
|
134
|
+
return (<View pointerEvents="box-none" style={[styles.controls, controlsStyle]}>
|
|
135
|
+
<Pressable accessibilityLabel={previousLabel} accessibilityRole="button" disabled={!canPrevious || controlledWithoutHandler} onPress={() => navigate(activeIndex - 1, -1)} style={buttonStyle} testID={testID ? `${testID}-previous` : undefined}>
|
|
136
|
+
<Text style={labelStyle}>{'‹'}</Text>
|
|
137
|
+
</Pressable>
|
|
138
|
+
<Pressable accessibilityLabel={nextLabel} accessibilityRole="button" disabled={!canNext || controlledWithoutHandler} onPress={() => navigate(activeIndex + 1, 1)} style={buttonStyle} testID={testID ? `${testID}-next` : undefined}>
|
|
139
|
+
<Text style={labelStyle}>{'›'}</Text>
|
|
140
|
+
</Pressable>
|
|
141
|
+
</View>);
|
|
142
|
+
}
|
|
143
|
+
/*** Render accessible selection dots for the currently controlled slide. */
|
|
144
|
+
function CarouselIndicators({ activeIndex, activeColor, controlledWithoutHandler, idleColor, indicatorsStyle, navigate, show, slides, testID, }) {
|
|
145
|
+
if (!show)
|
|
146
|
+
return null;
|
|
147
|
+
return (<View pointerEvents="box-none" style={[styles.indicators, indicatorsStyle]}>
|
|
148
|
+
{slides.map((slide, slideIndex) => (<Pressable key={slide.key} accessibilityLabel={`Go to slide ${slideIndex + 1} of ${slides.length}`} accessibilityRole="button" accessibilityState={{ selected: slideIndex === activeIndex }} disabled={controlledWithoutHandler} onPress={() => navigate(slideIndex, slideIndex < activeIndex ? -1 : 1)} style={[
|
|
149
|
+
styles.indicator,
|
|
150
|
+
{
|
|
151
|
+
backgroundColor: slideIndex === activeIndex ? activeColor : idleColor,
|
|
152
|
+
width: slideIndex === activeIndex ? 24 : 8,
|
|
153
|
+
},
|
|
154
|
+
]} testID={testID ? `${testID}-indicator-${slideIndex}` : undefined}/>))}
|
|
155
|
+
</View>);
|
|
156
|
+
}
|
|
157
|
+
/*** Render an optional linear autoplay timer without adding any required UI to slides. */
|
|
158
|
+
function CarouselProgress({ height, indicatorColor, indicatorStyle, progress, show, testID, trackColor, trackStyle, }) {
|
|
159
|
+
if (!show)
|
|
160
|
+
return null;
|
|
161
|
+
return (<View pointerEvents="none" style={[styles.progress, { height, backgroundColor: trackColor }, trackStyle]} testID={testID ? `${testID}-progress` : undefined}>
|
|
162
|
+
<Animated.View style={[
|
|
163
|
+
{
|
|
164
|
+
height: '100%',
|
|
165
|
+
width: progress.interpolate({ inputRange: [0, 1], outputRange: ['0%', '100%'] }),
|
|
166
|
+
backgroundColor: indicatorColor,
|
|
167
|
+
},
|
|
168
|
+
indicatorStyle,
|
|
169
|
+
]}/>
|
|
170
|
+
</View>);
|
|
171
|
+
}
|
|
172
|
+
const styles = StyleSheet.create({
|
|
173
|
+
controls: {
|
|
174
|
+
position: 'absolute',
|
|
175
|
+
top: 0,
|
|
176
|
+
bottom: 0,
|
|
177
|
+
left: 14,
|
|
178
|
+
right: 14,
|
|
179
|
+
flexDirection: 'row',
|
|
180
|
+
justifyContent: 'space-between',
|
|
181
|
+
alignItems: 'center',
|
|
182
|
+
},
|
|
183
|
+
control: {
|
|
184
|
+
width: 44,
|
|
185
|
+
height: 44,
|
|
186
|
+
borderRadius: 22,
|
|
187
|
+
justifyContent: 'center',
|
|
188
|
+
alignItems: 'center',
|
|
189
|
+
},
|
|
190
|
+
indicators: {
|
|
191
|
+
position: 'absolute',
|
|
192
|
+
bottom: 24,
|
|
193
|
+
left: 0,
|
|
194
|
+
right: 0,
|
|
195
|
+
flexDirection: 'row',
|
|
196
|
+
gap: 10,
|
|
197
|
+
justifyContent: 'center',
|
|
198
|
+
alignItems: 'center',
|
|
199
|
+
},
|
|
200
|
+
indicator: { height: 8, borderRadius: 8 },
|
|
201
|
+
progress: { position: 'absolute', bottom: 0, left: 0, right: 0, overflow: 'hidden' },
|
|
202
|
+
});
|
|
203
|
+
//# sourceMappingURL=Carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MA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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 {\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: progress.interpolate({ inputRange: [0, 1], outputRange: ['0%', '100%'] }),\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/features/carousel/public.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/features/carousel/public.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { CarouselProps, CarouselSlide, CarouselTransition } from '../../types/carousel';\nexport { Carousel } from './Carousel';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
import type { CarouselProps } from '../../types/carousel';
|
|
3
|
+
/*** Own controlled/uncontrolled slide navigation, autoplay, and progress lifecycle. */
|
|
4
|
+
export declare function useCarouselPlayback({ slides, index, defaultIndex, onIndexChange, autoPlay, paused, loop, intervalMs, reducedMotion, }: CarouselPlaybackOptions): {
|
|
5
|
+
readonly activeIndex: number;
|
|
6
|
+
readonly controlledWithoutHandler: boolean;
|
|
7
|
+
readonly direction: 1 | -1;
|
|
8
|
+
readonly loop: boolean;
|
|
9
|
+
readonly navigate: (target: number, nextDirection: 1 | -1) => void;
|
|
10
|
+
readonly progress: Animated.Value;
|
|
11
|
+
readonly shouldReduceMotion: boolean;
|
|
12
|
+
};
|
|
13
|
+
type CarouselPlaybackOptions = Pick<CarouselProps, 'slides' | 'index' | 'defaultIndex' | 'onIndexChange' | 'autoPlay' | 'paused' | 'loop' | 'intervalMs' | 'reducedMotion'>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=useCarouselPlayback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCarouselPlayback.d.ts","sourceRoot":"","sources":["../../../src/features/carousel/useCarouselPlayback.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,QAAQ,EAAU,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,KAAK,EACL,YAAgB,EAChB,aAAa,EACb,QAAe,EACf,MAAc,EACd,IAAW,EACX,UAAiB,EACjB,aAAa,GACd,EAAE,uBAAuB;;;;;gCAcb,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;;;EA0CzC;AAED,KAAK,uBAAuB,GAAG,IAAI,CACjC,aAAa,EACX,QAAQ,GACR,OAAO,GACP,cAAc,GACd,eAAe,GACf,UAAU,GACV,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,eAAe,CAClB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AccessibilityInfo, Animated, Easing } from 'react-native';
|
|
3
|
+
/*** Own controlled/uncontrolled slide navigation, autoplay, and progress lifecycle. */
|
|
4
|
+
export function useCarouselPlayback({ slides, index, defaultIndex = 0, onIndexChange, autoPlay = true, paused = false, loop = true, intervalMs = 6000, reducedMotion, }) {
|
|
5
|
+
const [uncontrolledIndex, setUncontrolledIndex] = React.useState(defaultIndex);
|
|
6
|
+
const [direction, setDirection] = React.useState(1);
|
|
7
|
+
const [progress] = React.useState(() => new Animated.Value(0));
|
|
8
|
+
const systemReducedMotion = useSystemReducedMotion();
|
|
9
|
+
const shouldReduceMotion = reducedMotion ?? systemReducedMotion;
|
|
10
|
+
const activeIndex = normalizeIndex(index ?? uncontrolledIndex, slides.length);
|
|
11
|
+
const duration = Math.max(1, intervalMs);
|
|
12
|
+
const controlledWithoutHandler = index !== undefined && onIndexChange === undefined;
|
|
13
|
+
const canAdvance = loop || activeIndex < slides.length - 1;
|
|
14
|
+
const shouldPlay = autoPlay && !paused && slides.length > 1 && canAdvance && !controlledWithoutHandler;
|
|
15
|
+
const navigate = React.useCallback((target, nextDirection) => {
|
|
16
|
+
if (slides.length < 2 || controlledWithoutHandler)
|
|
17
|
+
return;
|
|
18
|
+
const next = loop
|
|
19
|
+
? (target + slides.length) % slides.length
|
|
20
|
+
: normalizeIndex(target, slides.length);
|
|
21
|
+
if (next === activeIndex)
|
|
22
|
+
return;
|
|
23
|
+
setDirection(nextDirection);
|
|
24
|
+
if (index === undefined)
|
|
25
|
+
setUncontrolledIndex(next);
|
|
26
|
+
onIndexChange?.(next);
|
|
27
|
+
}, [activeIndex, controlledWithoutHandler, index, loop, onIndexChange, slides.length]);
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
if (!shouldPlay)
|
|
30
|
+
return;
|
|
31
|
+
const timeout = setTimeout(() => navigate(activeIndex + 1, 1), duration);
|
|
32
|
+
return () => clearTimeout(timeout);
|
|
33
|
+
}, [activeIndex, duration, navigate, shouldPlay]);
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
progress.stopAnimation();
|
|
36
|
+
progress.setValue(0);
|
|
37
|
+
if (!shouldPlay || shouldReduceMotion)
|
|
38
|
+
return;
|
|
39
|
+
const animation = Animated.timing(progress, {
|
|
40
|
+
toValue: 1,
|
|
41
|
+
duration,
|
|
42
|
+
easing: Easing.linear,
|
|
43
|
+
useNativeDriver: false,
|
|
44
|
+
});
|
|
45
|
+
animation.start();
|
|
46
|
+
return () => animation.stop();
|
|
47
|
+
}, [activeIndex, duration, progress, shouldPlay, shouldReduceMotion]);
|
|
48
|
+
return {
|
|
49
|
+
activeIndex,
|
|
50
|
+
controlledWithoutHandler,
|
|
51
|
+
direction,
|
|
52
|
+
loop,
|
|
53
|
+
navigate,
|
|
54
|
+
progress,
|
|
55
|
+
shouldReduceMotion,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/*** Clamp a controlled index whenever the consumer changes the slide collection. */
|
|
59
|
+
function normalizeIndex(value, count) {
|
|
60
|
+
if (count <= 0 || !Number.isFinite(value))
|
|
61
|
+
return 0;
|
|
62
|
+
return Math.min(Math.max(Math.trunc(value), 0), count - 1);
|
|
63
|
+
}
|
|
64
|
+
/*** Observe reduced-motion preferences without adding browser-only imports. */
|
|
65
|
+
function useSystemReducedMotion() {
|
|
66
|
+
const [reduced, setReduced] = React.useState(false);
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
void AccessibilityInfo.isReduceMotionEnabled().then(setReduced);
|
|
69
|
+
const listener = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduced);
|
|
70
|
+
return () => listener.remove();
|
|
71
|
+
}, []);
|
|
72
|
+
return reduced;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=useCarouselPlayback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCarouselPlayback.js","sourceRoot":"","sources":["../../../src/features/carousel/useCarouselPlayback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAInE,uFAAuF;AACvF,MAAM,UAAU,mBAAmB,CAAC,EAClC,MAAM,EACN,KAAK,EACL,YAAY,GAAG,CAAC,EAChB,aAAa,EACb,QAAQ,GAAG,IAAI,EACf,MAAM,GAAG,KAAK,EACd,IAAI,GAAG,IAAI,EACX,UAAU,GAAG,IAAI,EACjB,aAAa,GACW;IACxB,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/E,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAC;IACrD,MAAM,kBAAkB,GAAG,aAAa,IAAI,mBAAmB,CAAC;IAChE,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,IAAI,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9E,MAAM,QAA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,KAAK,CAAC,CAAC;IACpD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,KAAK,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC;QACvF,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import React from 'react';\nimport { AccessibilityInfo, Animated, Easing } from 'react-native';\n\nimport type { CarouselProps } from '../../types/carousel';\n\n/*** Own controlled/uncontrolled slide navigation, autoplay, and progress lifecycle. */\nexport function useCarouselPlayback({\n slides,\n index,\n defaultIndex = 0,\n onIndexChange,\n autoPlay = true,\n paused = false,\n loop = true,\n intervalMs = 6000,\n reducedMotion,\n}: CarouselPlaybackOptions) {\n const [uncontrolledIndex, setUncontrolledIndex] = React.useState(defaultIndex);\n const [direction, setDirection] = React.useState<1 | -1>(1);\n const [progress] = React.useState(() => new Animated.Value(0));\n const systemReducedMotion = useSystemReducedMotion();\n const shouldReduceMotion = reducedMotion ?? systemReducedMotion;\n const activeIndex = normalizeIndex(index ?? uncontrolledIndex, slides.length);\n const duration = Math.max(1, intervalMs);\n const controlledWithoutHandler = index !== undefined && onIndexChange === undefined;\n const canAdvance = loop || activeIndex < slides.length - 1;\n const shouldPlay =\n autoPlay && !paused && slides.length > 1 && canAdvance && !controlledWithoutHandler;\n\n const navigate = React.useCallback(\n (target: number, nextDirection: 1 | -1) => {\n if (slides.length < 2 || controlledWithoutHandler) return;\n const next = loop\n ? (target + slides.length) % slides.length\n : normalizeIndex(target, slides.length);\n if (next === activeIndex) return;\n setDirection(nextDirection);\n if (index === undefined) setUncontrolledIndex(next);\n onIndexChange?.(next);\n },\n [activeIndex, controlledWithoutHandler, index, loop, onIndexChange, slides.length],\n );\n\n React.useEffect(() => {\n if (!shouldPlay) return;\n const timeout = setTimeout(() => navigate(activeIndex + 1, 1), duration);\n return () => clearTimeout(timeout);\n }, [activeIndex, duration, navigate, shouldPlay]);\n\n React.useEffect(() => {\n progress.stopAnimation();\n progress.setValue(0);\n if (!shouldPlay || shouldReduceMotion) return;\n const animation = Animated.timing(progress, {\n toValue: 1,\n duration,\n easing: Easing.linear,\n useNativeDriver: false,\n });\n animation.start();\n return () => animation.stop();\n }, [activeIndex, duration, progress, shouldPlay, shouldReduceMotion]);\n\n return {\n activeIndex,\n controlledWithoutHandler,\n direction,\n loop,\n navigate,\n progress,\n shouldReduceMotion,\n } as const;\n}\n\ntype CarouselPlaybackOptions = Pick<\n CarouselProps,\n | 'slides'\n | 'index'\n | 'defaultIndex'\n | 'onIndexChange'\n | 'autoPlay'\n | 'paused'\n | 'loop'\n | 'intervalMs'\n | 'reducedMotion'\n>;\n\n/*** Clamp a controlled index whenever the consumer changes the slide collection. */\nfunction normalizeIndex(value: number, count: number): number {\n if (count <= 0 || !Number.isFinite(value)) return 0;\n return Math.min(Math.max(Math.trunc(value), 0), count - 1);\n}\n\n/*** Observe reduced-motion preferences without adding browser-only imports. */\nfunction useSystemReducedMotion(): boolean {\n const [reduced, setReduced] = React.useState(false);\n React.useEffect(() => {\n void AccessibilityInfo.isReduceMotionEnabled().then(setReduced);\n const listener = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduced);\n return () => listener.remove();\n }, []);\n return reduced;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type { AuthoringBindingControlState, AuthoringBindingEditorAdapterProps, AuthoringPropertyControlState, AuthoringPropertyInspectorAdapterProps, AuthoringSelectionAdapterProps, AuthoringSelectionItemState, ThemeEditorAdapterProps, ThemeRecipeFieldControlState, } from './authoring';
|
|
2
2
|
export { AuthoringBindingEditorAdapter, AuthoringPropertyInspectorAdapter, AuthoringSelectionAdapter, ThemeEditorAdapter, } from './authoring';
|
|
3
|
+
export type { CarouselProps, CarouselSlide, CarouselTransition } from './features/carousel/public';
|
|
4
|
+
export { Carousel } from './features/carousel/public';
|
|
3
5
|
export type { ColorHueScaleProps, ColorPickerProps, ColorPickerSelection, ColorPickerTab, ColorPickerValue, ColorToneDefinition, ColorToneProps, ColorToneSelection, ColorToneTarget, ColorWheelProps, ColorWheelSelection, } from './features/color/public';
|
|
4
6
|
export { ColorHueScale, ColorPicker, ColorTone, ColorWheel } from './features/color/public';
|
|
5
7
|
export type { ReaderColorScheme, ReaderDocumentFormat, ReaderErrorCode, ReaderErrorEvent, ReaderExternalLinkEvent, ReaderLineHeight, ReaderLocationChangeEvent, ReaderNavigationTrigger, ReaderProps, ReaderResolvedSource, ReaderStatus, } from './features/reader/public';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,4BAA4B,EAC5B,kCAAkC,EAClC,6BAA6B,EAC7B,sCAAsC,EACtC,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC5F,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB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AE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AuthoringBindingEditorAdapter, AuthoringPropertyInspectorAdapter, AuthoringSelectionAdapter, ThemeEditorAdapter, } from './authoring';
|
|
2
|
+
export { Carousel } from './features/carousel/public';
|
|
2
3
|
export { ColorHueScale, ColorPicker, ColorTone, ColorWheel } from './features/color/public';
|
|
3
4
|
export { Reader, resolveReaderProgress } from './features/reader/public';
|
|
4
5
|
export { ZORA_COMPONENT_REGISTRY } from './features/registry/public';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AActD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc5F,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,cAAc,cAAc,CAAC","sourcesContent":["export type {\n AuthoringBindingControlState,\n AuthoringBindingEditorAdapterProps,\n AuthoringPropertyControlState,\n AuthoringPropertyInspectorAdapterProps,\n AuthoringSelectionAdapterProps,\n AuthoringSelectionItemState,\n ThemeEditorAdapterProps,\n ThemeRecipeFieldControlState,\n} from './authoring';\nexport {\n AuthoringBindingEditorAdapter,\n AuthoringPropertyInspectorAdapter,\n AuthoringSelectionAdapter,\n ThemeEditorAdapter,\n} from './authoring';\nexport type { CarouselProps, CarouselSlide, CarouselTransition } from './features/carousel/public';\nexport { Carousel } from './features/carousel/public';\nexport type {\n ColorHueScaleProps,\n ColorPickerProps,\n ColorPickerSelection,\n ColorPickerTab,\n ColorPickerValue,\n ColorToneDefinition,\n ColorToneProps,\n ColorToneSelection,\n ColorToneTarget,\n ColorWheelProps,\n ColorWheelSelection,\n} from './features/color/public';\nexport { ColorHueScale, ColorPicker, ColorTone, ColorWheel } from './features/color/public';\nexport type {\n ReaderColorScheme,\n ReaderDocumentFormat,\n ReaderErrorCode,\n ReaderErrorEvent,\n ReaderExternalLinkEvent,\n ReaderLineHeight,\n ReaderLocationChangeEvent,\n ReaderNavigationTrigger,\n ReaderProps,\n ReaderResolvedSource,\n ReaderStatus,\n} from './features/reader/public';\nexport { Reader, resolveReaderProgress } from './features/reader/public';\nexport { ZORA_COMPONENT_REGISTRY } from './features/registry/public';\nexport * from './readerFree';\nexport type { ZoraComponentRegistry } from './types/registry';\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ImageResizeMode, ImageSourcePropType, ImageStyle, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export type CarouselTransition = 'fade' | 'slide' | 'none';
|
|
4
|
+
/** One presentation frame: an image, arbitrary React content, or both. */
|
|
5
|
+
export interface CarouselSlide {
|
|
6
|
+
key: string;
|
|
7
|
+
source?: string | ImageSourcePropType;
|
|
8
|
+
alt?: string;
|
|
9
|
+
content?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** Configurable cross-platform carousel; the consumer owns slide content. */
|
|
12
|
+
export interface CarouselProps {
|
|
13
|
+
slides: readonly CarouselSlide[];
|
|
14
|
+
/** Controlled index. If omitted, Carousel manages its own position. */
|
|
15
|
+
index?: number;
|
|
16
|
+
defaultIndex?: number;
|
|
17
|
+
onIndexChange?: (index: number) => void;
|
|
18
|
+
autoPlay?: boolean;
|
|
19
|
+
paused?: boolean;
|
|
20
|
+
loop?: boolean;
|
|
21
|
+
intervalMs?: number;
|
|
22
|
+
transition?: CarouselTransition;
|
|
23
|
+
enterDurationMs?: number;
|
|
24
|
+
exitDurationMs?: number;
|
|
25
|
+
initialScale?: number;
|
|
26
|
+
animateOnMount?: boolean;
|
|
27
|
+
/** Overrides the host OS preference when explicitly supplied. */
|
|
28
|
+
reducedMotion?: boolean;
|
|
29
|
+
showProgress?: boolean;
|
|
30
|
+
progressHeight?: number;
|
|
31
|
+
progressTrackColor?: string;
|
|
32
|
+
progressIndicatorColor?: string;
|
|
33
|
+
progressTrackStyle?: StyleProp<ViewStyle>;
|
|
34
|
+
progressIndicatorStyle?: StyleProp<ViewStyle>;
|
|
35
|
+
showArrows?: boolean;
|
|
36
|
+
showIndicators?: boolean;
|
|
37
|
+
previousLabel?: string;
|
|
38
|
+
nextLabel?: string;
|
|
39
|
+
controlColor?: string;
|
|
40
|
+
controlBackgroundColor?: string;
|
|
41
|
+
controlsStyle?: StyleProp<ViewStyle>;
|
|
42
|
+
activeIndicatorColor?: string;
|
|
43
|
+
inactiveIndicatorColor?: string;
|
|
44
|
+
indicatorsStyle?: StyleProp<ViewStyle>;
|
|
45
|
+
resizeMode?: ImageResizeMode;
|
|
46
|
+
imageStyle?: StyleProp<ImageStyle>;
|
|
47
|
+
style?: StyleProp<ViewStyle>;
|
|
48
|
+
/** Enables Next/Image or another consumer-specific image optimization. */
|
|
49
|
+
renderImage?: (slide: CarouselSlide, index: number) => ReactNode;
|
|
50
|
+
testID?: string;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=carousel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"car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,CAAC;IAChC,kBAAkB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,sBAAsB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,0EAA0E;IAC1E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../../src/types/carousel.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode } from 'react';\nimport type {\n ImageResizeMode,\n ImageSourcePropType,\n ImageStyle,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nexport type CarouselTransition = 'fade' | 'slide' | 'none';\n\n/** One presentation frame: an image, arbitrary React content, or both. */\nexport interface CarouselSlide {\n key: string;\n source?: string | ImageSourcePropType;\n alt?: string;\n content?: ReactNode;\n}\n\n/** Configurable cross-platform carousel; the consumer owns slide content. */\nexport interface CarouselProps {\n slides: readonly CarouselSlide[];\n /** Controlled index. If omitted, Carousel manages its own position. */\n index?: number;\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n autoPlay?: boolean;\n paused?: boolean;\n loop?: boolean;\n intervalMs?: number;\n transition?: CarouselTransition;\n enterDurationMs?: number;\n exitDurationMs?: number;\n initialScale?: number;\n animateOnMount?: boolean;\n /** Overrides the host OS preference when explicitly supplied. */\n reducedMotion?: boolean;\n showProgress?: boolean;\n progressHeight?: number;\n progressTrackColor?: string;\n progressIndicatorColor?: string;\n progressTrackStyle?: StyleProp<ViewStyle>;\n progressIndicatorStyle?: StyleProp<ViewStyle>;\n showArrows?: boolean;\n showIndicators?: boolean;\n previousLabel?: string;\n nextLabel?: string;\n controlColor?: string;\n controlBackgroundColor?: string;\n controlsStyle?: StyleProp<ViewStyle>;\n activeIndicatorColor?: string;\n inactiveIndicatorColor?: string;\n indicatorsStyle?: StyleProp<ViewStyle>;\n resizeMode?: ImageResizeMode;\n imageStyle?: StyleProp<ImageStyle>;\n style?: StyleProp<ViewStyle>;\n /** Enables Next/Image or another consumer-specific image optimization. */\n renderImage?: (slide: CarouselSlide, index: number) => ReactNode;\n testID?: string;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "27.
|
|
4
|
+
"version": "27.8.0",
|
|
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": {
|
|
@@ -0,0 +1,66 @@
|
|
|
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';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
6
|
+
|
|
7
|
+
/*** Render the published browser facade inside its real theme provider. */
|
|
8
|
+
function renderCarousel(props: CarouselProps): string {
|
|
9
|
+
return renderToStaticMarkup(
|
|
10
|
+
React.createElement(ZoraProvider, undefined, React.createElement(Carousel, props)),
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
test('renders no slides or progress with an empty collection', () => {
|
|
15
|
+
const html = renderCarousel({ slides: [] });
|
|
16
|
+
expect(html).not.toContain('<img');
|
|
17
|
+
expect(html).not.toContain('progress');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('renders images through the consumer renderer without a Next.js dependency', () => {
|
|
21
|
+
const html = renderCarousel({
|
|
22
|
+
slides: [{ key: 'one', source: '/original.jpg', alt: 'Image' }],
|
|
23
|
+
renderImage: (slide) =>
|
|
24
|
+
React.createElement('img', {
|
|
25
|
+
src: typeof slide.source === 'string' ? slide.source : '',
|
|
26
|
+
alt: '',
|
|
27
|
+
}),
|
|
28
|
+
testID: 'carousel',
|
|
29
|
+
});
|
|
30
|
+
expect(html).toContain('/original.jpg');
|
|
31
|
+
expect(html).not.toContain('carousel-progress');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('supports arbitrary React content without requiring image sources', () => {
|
|
35
|
+
const html = renderCarousel({
|
|
36
|
+
slides: [
|
|
37
|
+
{ key: 'one', content: React.createElement('span', undefined, 'Discover your next idea') },
|
|
38
|
+
{ key: 'two', content: React.createElement('span', undefined, 'Create what matters') },
|
|
39
|
+
],
|
|
40
|
+
transition: 'none',
|
|
41
|
+
});
|
|
42
|
+
expect(html).toContain('Discover your next idea');
|
|
43
|
+
expect(html).toContain('Create what matters');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('renders configurable accessible arrows, indicators and progress', () => {
|
|
47
|
+
const slides = [
|
|
48
|
+
{ key: 'one', source: '/one.jpg' },
|
|
49
|
+
{ key: 'two', source: '/two.jpg' },
|
|
50
|
+
];
|
|
51
|
+
const html = renderCarousel({
|
|
52
|
+
slides,
|
|
53
|
+
showArrows: true,
|
|
54
|
+
showIndicators: true,
|
|
55
|
+
testID: 'carousel',
|
|
56
|
+
});
|
|
57
|
+
expect(html).toContain('carousel-previous');
|
|
58
|
+
expect(html).toContain('carousel-next');
|
|
59
|
+
expect(html).toContain('carousel-indicator-0');
|
|
60
|
+
expect(html).toContain('carousel-indicator-1');
|
|
61
|
+
expect(html).toContain('carousel-progress');
|
|
62
|
+
expect(html).toContain('Go to slide 1 of 2');
|
|
63
|
+
const minimal = renderCarousel({ slides, showProgress: false });
|
|
64
|
+
expect(minimal).not.toContain('progress');
|
|
65
|
+
expect(minimal).not.toContain('indicator-0');
|
|
66
|
+
});
|