@flipova/foundation 2.2.1 → 2.4.0-beta.1

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 (109) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +157 -156
  3. package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
  4. package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
  5. package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
  6. package/components/ui/accordion/AnimatedHeight.tsx +3 -15
  7. package/components/ui/accordion/AnimatedIcon.tsx +2 -9
  8. package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
  9. package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
  10. package/components/ui/accordion/index.tsx +71 -139
  11. package/components/ui/actionsheet/index.tsx +63 -105
  12. package/components/ui/alert/index.tsx +20 -50
  13. package/components/ui/alert-dialog/index.tsx +23 -48
  14. package/components/ui/avatar/index.tsx +32 -68
  15. package/components/ui/badge/index.tsx +18 -49
  16. package/components/ui/bottomsheet/index.tsx +20 -52
  17. package/components/ui/box/index.tsx +4 -9
  18. package/components/ui/box/index.web.tsx +3 -9
  19. package/components/ui/button/index.tsx +73 -109
  20. package/components/ui/calendar/creator.tsx +69 -30
  21. package/components/ui/calendar/index.tsx +81 -159
  22. package/components/ui/calendar/styles.tsx +10 -10
  23. package/components/ui/card/index.tsx +8 -9
  24. package/components/ui/card/index.web.tsx +4 -10
  25. package/components/ui/center/index.tsx +6 -11
  26. package/components/ui/center/index.web.tsx +3 -9
  27. package/components/ui/checkbox/index.tsx +46 -107
  28. package/components/ui/date-time-picker/creator.tsx +14 -1
  29. package/components/ui/date-time-picker/index.tsx +107 -156
  30. package/components/ui/date-time-picker/index.web.tsx +11 -33
  31. package/components/ui/date-time-picker/styles.tsx +5 -5
  32. package/components/ui/divider/index.tsx +5 -6
  33. package/components/ui/drawer/index.tsx +108 -128
  34. package/components/ui/fab/index.tsx +25 -68
  35. package/components/ui/flat-list/index.tsx +11 -8
  36. package/components/ui/form-control/index.tsx +49 -90
  37. package/components/ui/gluestack-ui-provider/config.ts +69 -2
  38. package/components/ui/gluestack-ui-provider/index.tsx +32 -12
  39. package/components/ui/gluestack-ui-provider/index.web.tsx +43 -16
  40. package/components/ui/gluestack-ui-provider/script.ts +13 -8
  41. package/components/ui/gluestack-ui-provider/theme-context.ts +36 -1
  42. package/components/ui/gluestack-ui-provider/useGluestackColors.ts +11 -4
  43. package/components/ui/grid/index.tsx +128 -165
  44. package/components/ui/grid/index.web.tsx +17 -19
  45. package/components/ui/grid/styles.tsx +1 -3
  46. package/components/ui/heading/index.tsx +146 -169
  47. package/components/ui/heading/index.web.tsx +7 -28
  48. package/components/ui/heading/styles.tsx +5 -5
  49. package/components/ui/hstack/index.tsx +16 -15
  50. package/components/ui/hstack/index.web.tsx +17 -17
  51. package/components/ui/hstack/styles.tsx +5 -5
  52. package/components/ui/icon/index.tsx +95 -486
  53. package/components/ui/icon/index.web.tsx +79 -439
  54. package/components/ui/image/index.tsx +13 -18
  55. package/components/ui/image-viewer/index.tsx +149 -221
  56. package/components/ui/image-viewer/index.web.tsx +88 -113
  57. package/components/ui/input/index.tsx +20 -33
  58. package/components/ui/link/index.tsx +16 -22
  59. package/components/ui/liquid-glass/index.tsx +19 -25
  60. package/components/ui/menu/index.tsx +44 -66
  61. package/components/ui/modal/index.tsx +70 -91
  62. package/components/ui/popover/index.tsx +102 -121
  63. package/components/ui/portal/index.tsx +5 -6
  64. package/components/ui/pressable/index.tsx +5 -9
  65. package/components/ui/progress/index.tsx +4 -11
  66. package/components/ui/radio/index.tsx +47 -83
  67. package/components/ui/select/index.tsx +38 -59
  68. package/components/ui/select/select-actionsheet.tsx +61 -108
  69. package/components/ui/skeleton/index.tsx +22 -43
  70. package/components/ui/skeleton/index.web.tsx +63 -75
  71. package/components/ui/slider/index.tsx +36 -56
  72. package/components/ui/spinner/index.tsx +1 -10
  73. package/components/ui/switch/index.tsx +6 -13
  74. package/components/ui/table/index.tsx +39 -102
  75. package/components/ui/table/index.web.tsx +41 -79
  76. package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
  77. package/components/ui/tabs/creator.tsx +32 -24
  78. package/components/ui/tabs/index.tsx +253 -309
  79. package/components/ui/text/index.tsx +23 -37
  80. package/components/ui/text/index.web.tsx +33 -35
  81. package/components/ui/text/styles.tsx +5 -5
  82. package/components/ui/textarea/index.tsx +24 -38
  83. package/components/ui/toast/index.tsx +47 -52
  84. package/components/ui/tooltip/index.tsx +12 -28
  85. package/components/ui/vstack/index.tsx +17 -17
  86. package/components/ui/vstack/index.web.tsx +17 -17
  87. package/components/ui/vstack/styles.tsx +5 -5
  88. package/design/canonical.index.txt +15 -1
  89. package/design/manifest.xml +2 -0
  90. package/design/schema.xsd +11 -0
  91. package/design/themes.xml +175 -2
  92. package/design/tools/design.js +15 -12
  93. package/design/tools/npm.js +4 -3
  94. package/design/tools/sources/.generate/config.py +60 -2
  95. package/dist/{chunk-RPLDFHEZ.mjs → chunk-2R66P5X5.mjs} +1907 -3130
  96. package/dist/chunk-2R66P5X5.mjs.map +1 -0
  97. package/dist/{chunk-JVHJUIXV.js → chunk-LCTFQJZM.js} +1909 -3129
  98. package/dist/chunk-LCTFQJZM.js.map +1 -0
  99. package/dist/index.d.mts +1 -1
  100. package/dist/index.d.ts +1 -1
  101. package/dist/index.js +303 -291
  102. package/dist/index.mjs +1 -1
  103. package/dist/ui/index.d.mts +44 -3
  104. package/dist/ui/index.d.ts +44 -3
  105. package/dist/ui/index.js +303 -291
  106. package/dist/ui/index.mjs +1 -1
  107. package/package.json +12 -7
  108. package/dist/chunk-JVHJUIXV.js.map +0 -1
  109. package/dist/chunk-RPLDFHEZ.mjs.map +0 -1
@@ -9,37 +9,32 @@ const imageStyle = tva({
9
9
  variants: {
10
10
  size: {
11
11
  '2xs': 'h-6 w-6',
12
- 'xs': 'h-10 w-10',
13
- 'sm': 'h-16 w-16',
14
- 'md': 'h-20 w-20',
15
- 'lg': 'h-24 w-24',
16
- 'xl': 'h-32 w-32',
12
+ xs: 'h-10 w-10',
13
+ sm: 'h-16 w-16',
14
+ md: 'h-20 w-20',
15
+ lg: 'h-24 w-24',
16
+ xl: 'h-32 w-32',
17
17
  '2xl': 'h-64 w-64',
18
- 'full': 'h-full w-full',
19
- 'none': '',
18
+ full: 'h-full w-full',
19
+ none: '',
20
20
  },
21
21
  },
22
22
  });
23
23
 
24
24
  const UIImage = createImage({ Root: RNImage });
25
25
 
26
- type ImageProps = VariantProps<typeof imageStyle> &
27
- React.ComponentProps<typeof UIImage>;
28
- const Image = React.forwardRef<
29
- React.ComponentRef<typeof UIImage>,
30
- ImageProps & { className?: string }
31
- >(function Image({ size = 'md', className, ...props }, ref) {
26
+ type ImageProps = VariantProps<typeof imageStyle> & React.ComponentProps<typeof UIImage>;
27
+ const Image = React.forwardRef<React.ComponentRef<typeof UIImage>, ImageProps & { className?: string }>(function Image(
28
+ { size = 'md', className, ...props },
29
+ ref,
30
+ ) {
32
31
  return (
33
32
  <UIImage
34
33
  className={imageStyle({ size, class: className })}
35
34
  {...props}
36
35
  ref={ref}
37
36
  // @ts-expect-error : web only
38
- style={
39
- Platform.OS === 'web'
40
- ? { height: 'revert-layer', width: 'revert-layer' }
41
- : undefined
42
- }
37
+ style={Platform.OS === 'web' ? { height: 'revert-layer', width: 'revert-layer' } : undefined}
43
38
  />
44
39
  );
45
40
  });
@@ -1,14 +1,6 @@
1
1
  'use client';
2
2
  import React, { useCallback, useState, useEffect, useRef } from 'react';
3
- import {
4
- View,
5
- Pressable,
6
- Text,
7
- Image as RNImage,
8
- Dimensions,
9
- TouchableOpacity,
10
- FlatList,
11
- } from 'react-native';
3
+ import { View, Pressable, Text, Image as RNImage, Dimensions, TouchableOpacity, FlatList } from 'react-native';
12
4
  import Animated, {
13
5
  useSharedValue,
14
6
  useAnimatedStyle,
@@ -22,11 +14,7 @@ import Animated, {
22
14
  runOnJS,
23
15
  } from 'react-native-reanimated';
24
16
  import { tva } from '@gluestack-ui/utils/nativewind-utils';
25
- import {
26
- Gesture,
27
- GestureDetector,
28
- GestureHandlerRootView,
29
- } from 'react-native-gesture-handler';
17
+ import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler';
30
18
  import { Overlay } from '@gluestack-ui/core/overlay/creator';
31
19
 
32
20
  const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window');
@@ -132,7 +120,7 @@ const ZoomableImage = React.memo(
132
120
  onDismiss: () => void;
133
121
  onZoomChange?: (isZoomed: boolean) => void;
134
122
  },
135
- ref
123
+ ref,
136
124
  ) {
137
125
  const scale = useSharedValue(1);
138
126
  const savedScale = useSharedValue(1);
@@ -203,14 +191,8 @@ const ZoomableImage = React.memo(
203
191
  const newTranslateY = savedTranslateY.value + event.translationY;
204
192
 
205
193
  // Clamp to bounds
206
- translateX.value = Math.max(
207
- -maxTranslateX,
208
- Math.min(maxTranslateX, newTranslateX)
209
- );
210
- translateY.value = Math.max(
211
- -maxTranslateY,
212
- Math.min(maxTranslateY, newTranslateY)
213
- );
194
+ translateX.value = Math.max(-maxTranslateX, Math.min(maxTranslateX, newTranslateX));
195
+ translateY.value = Math.max(-maxTranslateY, Math.min(maxTranslateY, newTranslateY));
214
196
  })
215
197
  .onEnd((event) => {
216
198
  const maxTranslateX = ((scale.value - 1) * SCREEN_WIDTH) / 2;
@@ -221,11 +203,7 @@ const ZoomableImage = React.memo(
221
203
  const swipeThreshold = 50;
222
204
 
223
205
  // If at edge and swiped with enough velocity/distance, navigate
224
- if (
225
- isAtLeftEdge &&
226
- event.translationX > swipeThreshold &&
227
- event.velocityX > 0
228
- ) {
206
+ if (isAtLeftEdge && event.translationX > swipeThreshold && event.velocityX > 0) {
229
207
  // At left edge, swiped right -> go to previous
230
208
  runOnJS(onSwipeRight)();
231
209
  // Reset zoom after navigation
@@ -236,11 +214,7 @@ const ZoomableImage = React.memo(
236
214
  savedTranslateX.value = 0;
237
215
  savedTranslateY.value = 0;
238
216
  if (onZoomChange) runOnJS(onZoomChange)(false);
239
- } else if (
240
- isAtRightEdge &&
241
- event.translationX < -swipeThreshold &&
242
- event.velocityX < 0
243
- ) {
217
+ } else if (isAtRightEdge && event.translationX < -swipeThreshold && event.velocityX < 0) {
244
218
  // At right edge, swiped left -> go to next
245
219
  runOnJS(onSwipeLeft)();
246
220
  // Reset zoom after navigation
@@ -264,15 +238,9 @@ const ZoomableImage = React.memo(
264
238
  .activeOffsetY([-10, 10]) // Activate only for vertical movement
265
239
  .failOffsetX([-20, 20]) // Fail if horizontal movement is too much
266
240
  .onUpdate((event) => {
267
- dismissProgress.value =
268
- Math.abs(event.translationY) / (SCREEN_HEIGHT * 0.3);
241
+ dismissProgress.value = Math.abs(event.translationY) / (SCREEN_HEIGHT * 0.3);
269
242
  translateY.value = event.translationY;
270
- opacity.value = interpolate(
271
- dismissProgress.value,
272
- [0, 1],
273
- [1, 0.3],
274
- Extrapolate.CLAMP
275
- );
243
+ opacity.value = interpolate(dismissProgress.value, [0, 1], [1, 0.3], Extrapolate.CLAMP);
276
244
  })
277
245
  .onEnd((event) => {
278
246
  if (Math.abs(event.translationY) > 120) {
@@ -324,18 +292,11 @@ const ZoomableImage = React.memo(
324
292
 
325
293
  const composedGesture = Gesture.Race(
326
294
  doubleTapGesture,
327
- Gesture.Simultaneous(
328
- pinchGesture,
329
- Gesture.Exclusive(panGesture, dismissGesture)
330
- )
295
+ Gesture.Simultaneous(pinchGesture, Gesture.Exclusive(panGesture, dismissGesture)),
331
296
  );
332
297
 
333
298
  const animatedStyle = useAnimatedStyle(() => ({
334
- transform: [
335
- { translateX: translateX.value },
336
- { translateY: translateY.value },
337
- { scale: scale.value },
338
- ],
299
+ transform: [{ translateX: translateX.value }, { translateY: translateY.value }, { scale: scale.value }],
339
300
  opacity: opacity.value,
340
301
  }));
341
302
 
@@ -345,14 +306,11 @@ const ZoomableImage = React.memo(
345
306
  source={{ uri: image.url }}
346
307
  alt={image.alt}
347
308
  resizeMode="contain"
348
- style={[
349
- { width: SCREEN_WIDTH, height: SCREEN_HEIGHT * 0.8 },
350
- animatedStyle,
351
- ]}
309
+ style={[{ width: SCREEN_WIDTH, height: SCREEN_HEIGHT * 0.8 }, animatedStyle]}
352
310
  />
353
311
  </GestureDetector>
354
312
  );
355
- })
313
+ }),
356
314
  );
357
315
 
358
316
  // FlatList-based Image Gallery Component
@@ -411,17 +369,13 @@ const SlidableImageGallery = React.memo(function SlidableImageGallery({
411
369
  const contentOffsetX = event.nativeEvent.contentOffset.x;
412
370
  const newIndex = Math.round(contentOffsetX / SCREEN_WIDTH);
413
371
 
414
- if (
415
- newIndex !== localIndex &&
416
- newIndex >= 0 &&
417
- newIndex < images.length
418
- ) {
372
+ if (newIndex !== localIndex && newIndex >= 0 && newIndex < images.length) {
419
373
  setLocalIndex(newIndex);
420
374
  prevCurrentIndexRef.current = newIndex; // Update ref to prevent effect from scrolling back
421
375
  onIndexChange(newIndex);
422
376
  }
423
377
  },
424
- [localIndex, images.length, onIndexChange]
378
+ [localIndex, images.length, onIndexChange],
425
379
  );
426
380
 
427
381
  const goNext = useCallback(() => {
@@ -458,7 +412,7 @@ const SlidableImageGallery = React.memo(function SlidableImageGallery({
458
412
  />
459
413
  </View>
460
414
  ),
461
- [localIndex, goNext, goPrevious, onDismiss, handleZoomChange]
415
+ [localIndex, goNext, goPrevious, onDismiss, handleZoomChange],
462
416
  );
463
417
 
464
418
  // Get item layout for better performance
@@ -468,19 +422,13 @@ const SlidableImageGallery = React.memo(function SlidableImageGallery({
468
422
  offset: SCREEN_WIDTH * index,
469
423
  index,
470
424
  }),
471
- []
425
+ [],
472
426
  );
473
427
 
474
- const keyExtractor = useCallback(
475
- (item: ImageItem, index: number) => `image-${index}-${item.url}`,
476
- []
477
- );
428
+ const keyExtractor = useCallback((item: ImageItem, index: number) => `image-${index}-${item.url}`, []);
478
429
 
479
430
  return (
480
- <View
481
- style={{ width: SCREEN_WIDTH, height: SCREEN_HEIGHT * 0.8 }}
482
- className="web:my-auto"
483
- >
431
+ <View style={{ width: SCREEN_WIDTH, height: SCREEN_HEIGHT * 0.8 }} className="web:my-auto">
484
432
  <FlatList
485
433
  ref={flatListRef}
486
434
  data={images}
@@ -506,109 +454,92 @@ const SlidableImageGallery = React.memo(function SlidableImageGallery({
506
454
  });
507
455
 
508
456
  // Main ImageViewer Component
509
- const ImageViewer = React.forwardRef<View, ImageViewerProps>(
510
- function ImageViewer(
511
- {
512
- images,
513
- defaultOpen = false,
514
- isOpen: controlledIsOpen,
515
- onOpenChange,
516
- onIndexChange,
517
- initialIndex = 0,
518
- children,
519
- },
520
- ref
521
- ) {
522
- const [uncontrolledIsOpen, setUncontrolledIsOpen] = useState(defaultOpen);
523
- const [currentIndex, setCurrentIndex] = useState(initialIndex);
457
+ const ImageViewer = React.forwardRef<View, ImageViewerProps>(function ImageViewer(
458
+ { images, defaultOpen = false, isOpen: controlledIsOpen, onOpenChange, onIndexChange, initialIndex = 0, children },
459
+ ref,
460
+ ) {
461
+ const [uncontrolledIsOpen, setUncontrolledIsOpen] = useState(defaultOpen);
462
+ const [currentIndex, setCurrentIndex] = useState(initialIndex);
524
463
 
525
- const isControlled = controlledIsOpen !== undefined;
526
- const isOpen = isControlled ? controlledIsOpen : uncontrolledIsOpen;
464
+ const isControlled = controlledIsOpen !== undefined;
465
+ const isOpen = isControlled ? controlledIsOpen : uncontrolledIsOpen;
527
466
 
528
- useEffect(() => {
529
- onIndexChange?.(currentIndex);
530
- }, [currentIndex, onIndexChange]);
467
+ useEffect(() => {
468
+ onIndexChange?.(currentIndex);
469
+ }, [currentIndex, onIndexChange]);
531
470
 
532
- const open = useCallback(() => {
533
- if (!isControlled) {
534
- setUncontrolledIsOpen(true);
535
- }
536
- onOpenChange?.(true);
537
- }, [isControlled, onOpenChange]);
471
+ const open = useCallback(() => {
472
+ if (!isControlled) {
473
+ setUncontrolledIsOpen(true);
474
+ }
475
+ onOpenChange?.(true);
476
+ }, [isControlled, onOpenChange]);
538
477
 
539
- const close = useCallback(() => {
540
- if (!isControlled) {
541
- setUncontrolledIsOpen(false);
542
- }
543
- onOpenChange?.(false);
544
- }, [isControlled, onOpenChange]);
545
-
546
- const goNext = useCallback(() => {
547
- setCurrentIndex((prev) => Math.min(prev + 1, images.length - 1));
548
- }, [images.length]);
549
-
550
- const goPrevious = useCallback(() => {
551
- setCurrentIndex((prev) => Math.max(prev - 1, 0));
552
- }, []);
553
-
554
- const contextValue = React.useMemo(
555
- () => ({
556
- images,
557
- currentIndex,
558
- isOpen,
559
- open,
560
- close,
561
- goNext,
562
- goPrevious,
563
- }),
564
- [images, currentIndex, isOpen, open, close, goNext, goPrevious]
565
- );
478
+ const close = useCallback(() => {
479
+ if (!isControlled) {
480
+ setUncontrolledIsOpen(false);
481
+ }
482
+ onOpenChange?.(false);
483
+ }, [isControlled, onOpenChange]);
566
484
 
567
- return (
568
- <View ref={ref} className={imageViewerStyle({})}>
569
- <ImageViewerContext.Provider value={contextValue}>
570
- {children}
571
- </ImageViewerContext.Provider>
572
- </View>
573
- );
574
- }
575
- );
485
+ const goNext = useCallback(() => {
486
+ setCurrentIndex((prev) => Math.min(prev + 1, images.length - 1));
487
+ }, [images.length]);
576
488
 
577
- // Trigger Component
578
- const ImageViewerTrigger = React.forwardRef<
579
- React.ElementRef<typeof Pressable>,
580
- ImageViewerTriggerProps
581
- >(function ImageViewerTrigger({ children, onPress, ...props }, ref) {
582
- const { open } = useImageViewerContext();
489
+ const goPrevious = useCallback(() => {
490
+ setCurrentIndex((prev) => Math.max(prev - 1, 0));
491
+ }, []);
583
492
 
584
- const handlePress = useCallback(() => {
585
- onPress?.();
586
- open();
587
- }, [onPress, open]);
493
+ const contextValue = React.useMemo(
494
+ () => ({
495
+ images,
496
+ currentIndex,
497
+ isOpen,
498
+ open,
499
+ close,
500
+ goNext,
501
+ goPrevious,
502
+ }),
503
+ [images, currentIndex, isOpen, open, close, goNext, goPrevious],
504
+ );
588
505
 
589
506
  return (
590
- <Pressable ref={ref} onPress={handlePress} {...props}>
591
- {children}
592
- </Pressable>
507
+ <View ref={ref} className={imageViewerStyle({})}>
508
+ <ImageViewerContext.Provider value={contextValue}>{children}</ImageViewerContext.Provider>
509
+ </View>
593
510
  );
594
511
  });
595
512
 
513
+ // Trigger Component
514
+ const ImageViewerTrigger = React.forwardRef<React.ElementRef<typeof Pressable>, ImageViewerTriggerProps>(
515
+ function ImageViewerTrigger({ children, onPress, ...props }, ref) {
516
+ const { open } = useImageViewerContext();
517
+
518
+ const handlePress = useCallback(() => {
519
+ onPress?.();
520
+ open();
521
+ }, [onPress, open]);
522
+
523
+ return (
524
+ <Pressable ref={ref} onPress={handlePress} {...props}>
525
+ {children}
526
+ </Pressable>
527
+ );
528
+ },
529
+ );
530
+
596
531
  // Content Component (Uses gluestack Overlay for proper portal rendering)
597
532
  // Context provider is placed INSIDE the Overlay so portaled content has access
598
- const ImageViewerContent = React.forwardRef<
599
- View,
600
- { children?: React.ReactNode }
601
- >(function ImageViewerContent({ children }, ref) {
533
+ const ImageViewerContent = React.forwardRef<View, { children?: React.ReactNode }>(function ImageViewerContent(
534
+ { children },
535
+ ref,
536
+ ) {
602
537
  const context = useImageViewerContext();
603
538
  const { images, currentIndex, isOpen, close, goNext, goPrevious } = context;
604
539
  const currentImage = images[currentIndex];
605
540
 
606
541
  return (
607
- <Overlay
608
- isOpen={isOpen}
609
- onRequestClose={close}
610
- isKeyboardDismissable={true}
611
- >
542
+ <Overlay isOpen={isOpen} onRequestClose={close} isKeyboardDismissable={true}>
612
543
  <ImageViewerContext.Provider value={context}>
613
544
  <GestureHandlerRootView style={{ flex: 1 }}>
614
545
  <AnimatedView
@@ -656,80 +587,77 @@ const ImageViewerContent = React.forwardRef<
656
587
  });
657
588
 
658
589
  // Close Button Component
659
- const ImageViewerCloseButton = React.forwardRef<
660
- React.ElementRef<typeof Pressable>,
661
- { className?: string }
662
- >(function ImageViewerCloseButton({ className, ...props }, ref) {
663
- const { close } = useImageViewerContext();
664
-
665
- return (
666
- <TouchableOpacity
667
- ref={ref as any}
668
- onPress={close}
669
- className={imageViewerCloseButtonStyle({ class: className })}
670
- accessibilityLabel="Close image viewer"
671
- accessibilityRole="button"
672
- {...props}
673
- >
674
- <Text className="text-white text-xl font-bold">✕</Text>
675
- </TouchableOpacity>
676
- );
677
- });
678
-
679
- // Navigation Component
680
- const ImageViewerNavigation = React.forwardRef<View, { className?: string }>(
681
- function ImageViewerNavigation({ className }, ref) {
682
- const { goPrevious, goNext, currentIndex, images } =
683
- useImageViewerContext();
684
-
685
- const canGoPrevious = currentIndex > 0;
686
- const canGoNext = currentIndex < images.length - 1;
590
+ const ImageViewerCloseButton = React.forwardRef<React.ElementRef<typeof Pressable>, { className?: string }>(
591
+ function ImageViewerCloseButton({ className, ...props }, ref) {
592
+ const { close } = useImageViewerContext();
687
593
 
688
594
  return (
689
- <View
690
- ref={ref}
691
- className={imageViewerNavigationStyle({ class: className })}
595
+ <TouchableOpacity
596
+ ref={ref as any}
597
+ onPress={close}
598
+ className={imageViewerCloseButtonStyle({ class: className })}
599
+ accessibilityLabel="Close image viewer"
600
+ accessibilityRole="button"
601
+ {...props}
692
602
  >
693
- {canGoPrevious && (
694
- <TouchableOpacity
695
- onPress={goPrevious}
696
- className={imageViewerNavButtonStyle({})}
697
- accessibilityLabel="Previous image"
698
- accessibilityRole="button"
699
- >
700
- <Text className="text-white text-2xl font-bold">‹</Text>
701
- </TouchableOpacity>
702
- )}
703
- <View className="flex-1" />
704
- {canGoNext && (
705
- <TouchableOpacity
706
- onPress={goNext}
707
- className={imageViewerNavButtonStyle({})}
708
- accessibilityLabel="Next image"
709
- accessibilityRole="button"
710
- >
711
- <Text className="text-white text-2xl font-bold">›</Text>
712
- </TouchableOpacity>
713
- )}
714
- </View>
603
+ <Text className="text-white text-xl font-bold">✕</Text>
604
+ </TouchableOpacity>
715
605
  );
716
- }
606
+ },
717
607
  );
718
608
 
609
+ // Navigation Component
610
+ const ImageViewerNavigation = React.forwardRef<View, { className?: string }>(function ImageViewerNavigation(
611
+ { className },
612
+ ref,
613
+ ) {
614
+ const { goPrevious, goNext, currentIndex, images } = useImageViewerContext();
615
+
616
+ const canGoPrevious = currentIndex > 0;
617
+ const canGoNext = currentIndex < images.length - 1;
618
+
619
+ return (
620
+ <View ref={ref} className={imageViewerNavigationStyle({ class: className })}>
621
+ {canGoPrevious && (
622
+ <TouchableOpacity
623
+ onPress={goPrevious}
624
+ className={imageViewerNavButtonStyle({})}
625
+ accessibilityLabel="Previous image"
626
+ accessibilityRole="button"
627
+ >
628
+ <Text className="text-white text-2xl font-bold">‹</Text>
629
+ </TouchableOpacity>
630
+ )}
631
+ <View className="flex-1" />
632
+ {canGoNext && (
633
+ <TouchableOpacity
634
+ onPress={goNext}
635
+ className={imageViewerNavButtonStyle({})}
636
+ accessibilityLabel="Next image"
637
+ accessibilityRole="button"
638
+ >
639
+ <Text className="text-white text-2xl font-bold">›</Text>
640
+ </TouchableOpacity>
641
+ )}
642
+ </View>
643
+ );
644
+ });
645
+
719
646
  // Counter Component
720
- const ImageViewerCounter = React.forwardRef<View, { className?: string }>(
721
- function ImageViewerCounter({ className }, ref) {
722
- const { currentIndex, images } = useImageViewerContext();
647
+ const ImageViewerCounter = React.forwardRef<View, { className?: string }>(function ImageViewerCounter(
648
+ { className },
649
+ ref,
650
+ ) {
651
+ const { currentIndex, images } = useImageViewerContext();
723
652
 
724
- return (
725
- <View ref={ref} className={imageViewerCounterStyle({ class: className })}>
726
- <Text className={imageViewerCounterTextStyle({})}>
727
- {currentIndex + 1} / {images.length}
728
- </Text>
729
- </View>
730
- );
731
- }
732
- );
653
+ return (
654
+ <View ref={ref} className={imageViewerCounterStyle({ class: className })}>
655
+ <Text className={imageViewerCounterTextStyle({})}>
656
+ {currentIndex + 1} / {images.length}
657
+ </Text>
658
+ </View>
659
+ );
660
+ });
733
661
 
734
662
  export {
735
663
  ImageViewer,