@marktiderman/genesis-ui-native 3.5.1 → 3.6.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 (89) hide show
  1. package/README.md +71 -7
  2. package/dist/{chunk-LBVD7XXL.js → chunk-2Z72MYHB.js} +627 -20
  3. package/dist/chunk-2Z72MYHB.js.map +1 -0
  4. package/dist/chunk-4OQOJ2OC.js +80 -0
  5. package/dist/chunk-4OQOJ2OC.js.map +1 -0
  6. package/dist/{chunk-6KWEAGRD.js → chunk-6PGLX6ET.js} +101 -6
  7. package/dist/chunk-6PGLX6ET.js.map +1 -0
  8. package/dist/{chunk-ONH2PCGH.js → chunk-AGTBABAH.js} +9 -15
  9. package/dist/chunk-AGTBABAH.js.map +1 -0
  10. package/dist/{chunk-ABVSSJNT.js → chunk-FUMSL7VZ.js} +198 -168
  11. package/dist/chunk-FUMSL7VZ.js.map +1 -0
  12. package/dist/{chunk-GHYUNNNU.js → chunk-NDXNSSM6.js} +175 -93
  13. package/dist/chunk-NDXNSSM6.js.map +1 -0
  14. package/dist/chunk-SEJ6RBP7.js +361 -0
  15. package/dist/chunk-SEJ6RBP7.js.map +1 -0
  16. package/dist/{chunk-D5RKSPMH.js → chunk-ZRQAFFTN.js} +4 -3
  17. package/dist/chunk-ZRQAFFTN.js.map +1 -0
  18. package/dist/components/index.d.ts +331 -4
  19. package/dist/components/index.js +5 -5
  20. package/dist/data/index.d.ts +68 -4
  21. package/dist/data/index.js +231 -30
  22. package/dist/data/index.js.map +1 -1
  23. package/dist/hooks/index.d.ts +60 -1
  24. package/dist/hooks/index.js +2 -3
  25. package/dist/icons/lucide.d.ts +1 -1
  26. package/dist/icons/lucide.js +7 -1
  27. package/dist/icons/lucide.js.map +1 -1
  28. package/dist/{inbox-page-BEarNEIP.d.ts → inbox-page-B7_Oi2fS.d.ts} +2 -44
  29. package/dist/index.d.ts +8 -5
  30. package/dist/index.js +8 -8
  31. package/dist/layouts/index.d.ts +40 -51
  32. package/dist/layouts/index.js +5 -4
  33. package/dist/{native-modules-PwnGltOU.d.ts → native-modules-Cl3zw3kh.d.ts} +27 -1
  34. package/package.json +78 -4
  35. package/src/__tests__/doctor-rules.test.ts +60 -0
  36. package/src/__tests__/native-modules-lists.test.tsx +1 -0
  37. package/src/components/__tests__/composer-bar.test.tsx +55 -0
  38. package/src/components/__tests__/gallery-card.test.tsx +59 -0
  39. package/src/components/__tests__/gallery-grid.test.tsx +160 -0
  40. package/src/components/__tests__/lightbox-resnap.test.tsx +50 -0
  41. package/src/components/__tests__/lightbox-zoom.test.ts +33 -0
  42. package/src/components/__tests__/lightbox.test.tsx +141 -0
  43. package/src/components/__tests__/live-indicator.test.tsx +72 -0
  44. package/src/components/__tests__/rating.test.tsx +82 -0
  45. package/src/components/__tests__/thread-list.test.tsx +156 -0
  46. package/src/components/composer-bar.tsx +198 -0
  47. package/src/components/drawer.tsx +15 -9
  48. package/src/components/gallery-card.tsx +109 -0
  49. package/src/components/gallery-grid.tsx +285 -0
  50. package/src/components/gallery-layout.ts +2 -0
  51. package/src/components/gallery-types.ts +2 -0
  52. package/src/components/index.ts +44 -0
  53. package/src/components/lightbox-zoom.tsx +282 -0
  54. package/src/components/lightbox.tsx +342 -0
  55. package/src/components/live-indicator.tsx +139 -0
  56. package/src/components/rating.tsx +128 -0
  57. package/src/components/skeleton.tsx +9 -4
  58. package/src/components/thread-list.tsx +427 -0
  59. package/src/components/toast.tsx +7 -4
  60. package/src/data/NativeConflictSheet.tsx +181 -0
  61. package/src/data/NativeResourceForm.tsx +15 -1
  62. package/src/data/index.ts +2 -0
  63. package/src/data/resource-view/NativeRecordView.tsx +85 -8
  64. package/src/data/resource-view/NativeResourceView.tsx +79 -32
  65. package/src/data/resource-view/__tests__/native-record-view.test.tsx +95 -1
  66. package/src/data/resource-view/__tests__/native-resource-gallery.test.tsx +125 -0
  67. package/src/hooks/__tests__/use-motion.test.tsx +106 -0
  68. package/src/hooks/__tests__/use-thread-jump.test.tsx +88 -0
  69. package/src/hooks/index.ts +3 -0
  70. package/src/hooks/use-motion.ts +128 -0
  71. package/src/hooks/use-thread-jump.ts +110 -0
  72. package/src/icon-names.ts +6 -0
  73. package/src/icons/lucide.ts +12 -0
  74. package/src/layouts/__tests__/inbox-page.test.tsx +6 -0
  75. package/src/layouts/__tests__/thread-page.test.tsx +114 -14
  76. package/src/layouts/inbox-page.tsx +6 -55
  77. package/src/layouts/index.ts +2 -0
  78. package/src/layouts/thread-page.tsx +326 -262
  79. package/src/native-modules.tsx +16 -2
  80. package/dist/chunk-6KWEAGRD.js.map +0 -1
  81. package/dist/chunk-7PCWEY6R.js +0 -27
  82. package/dist/chunk-7PCWEY6R.js.map +0 -1
  83. package/dist/chunk-ABVSSJNT.js.map +0 -1
  84. package/dist/chunk-D5RKSPMH.js.map +0 -1
  85. package/dist/chunk-GHYUNNNU.js.map +0 -1
  86. package/dist/chunk-LBVD7XXL.js.map +0 -1
  87. package/dist/chunk-ONH2PCGH.js.map +0 -1
  88. package/dist/chunk-Z3AQYVUA.js +0 -36
  89. package/dist/chunk-Z3AQYVUA.js.map +0 -1
@@ -1,11 +1,12 @@
1
- import { useReducedMotion } from './chunk-7PCWEY6R.js';
2
- import { useGenesisModules } from './chunk-6KWEAGRD.js';
3
- import { useThemeMode, useThemeRoles } from './chunk-Z3AQYVUA.js';
1
+ import { NativeImage } from './chunk-NDXNSSM6.js';
2
+ import { useGenesisModules, NativeIcon, NativeSkeleton } from './chunk-6PGLX6ET.js';
3
+ import { useThemeMode, useMotion, useReducedMotion, useThemeRoles } from './chunk-4OQOJ2OC.js';
4
4
  import { cn } from './chunk-OHZD7KRO.js';
5
- import { View, Text, Platform, AccessibilityInfo, Animated, Pressable, Modal, StatusBar, Dimensions, TextInput, ScrollView, PanResponder } from 'react-native';
6
- import { jsxs, jsx } from 'react/jsx-runtime';
5
+ import { View, Text, Platform, AccessibilityInfo, Animated, Pressable, Modal, StatusBar, Dimensions, TextInput, ScrollView, PanResponder, FlatList, Easing } from 'react-native';
6
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
+ import { MOTION_DURATIONS, MOTION_EASINGS } from '@marktiderman/genesis-design-system/tokens/motion';
7
8
  import { createContext, useState, useEffect, useCallback, useMemo, useRef, useContext, Children, cloneElement, isValidElement } from 'react';
8
- import { SafeAreaProvider, SafeAreaInsetsContext } from 'react-native-safe-area-context';
9
+ import { SafeAreaProvider, SafeAreaInsetsContext, useSafeAreaInsets } from 'react-native-safe-area-context';
9
10
  import { cva } from 'class-variance-authority';
10
11
 
11
12
  function NativeHeaderCard({
@@ -161,7 +162,7 @@ function NativeToastProvider({
161
162
  disableAnimation = false
162
163
  }) {
163
164
  const [queue, setQueue] = useState([]);
164
- const reducedMotion = useReducedMotion();
165
+ const reducedMotion = useMotion().reduced;
165
166
  const dismiss = useCallback((id) => {
166
167
  setQueue((q) => id == null ? q.slice(1) : q.filter((t) => t.id !== id));
167
168
  }, []);
@@ -186,7 +187,7 @@ function NativeToastProvider({
186
187
  ) : null
187
188
  ] });
188
189
  }
189
- var ENTER_MS = 180;
190
+ var ENTER_MS = MOTION_DURATIONS.fast;
190
191
  function ToastView(props) {
191
192
  const { reanimated } = useGenesisModules();
192
193
  const GlassView = useLiquidGlass();
@@ -231,7 +232,7 @@ function ReanimatedToastView({
231
232
  useAutoDismiss(toast, onDismiss);
232
233
  useEffect(() => {
233
234
  if (!animate) return;
234
- const easing = R.Easing.out(R.Easing.cubic);
235
+ const easing = R.Easing.bezier ? R.Easing.bezier(...MOTION_EASINGS.decelerate) : R.Easing.out(R.Easing.cubic);
235
236
  if (fade) opacity.value = R.withTiming(1, { duration: ENTER_MS, easing });
236
237
  offset.value = R.withTiming(0, { duration: ENTER_MS, easing });
237
238
  }, []);
@@ -486,8 +487,6 @@ function NativePopoverContent({
486
487
  }
487
488
  );
488
489
  }
489
- var OPEN_MS = 220;
490
- var SETTLE_MS = 180;
491
490
  function NativeDrawer(props) {
492
491
  const { reanimated } = useGenesisModules();
493
492
  return reanimated ? /* @__PURE__ */ jsx(ReanimatedDrawer, { ...props, reanimated }) : /* @__PURE__ */ jsx(AnimatedDrawer, { ...props });
@@ -515,18 +514,21 @@ function useSwipe(side, drawerWidth, onOpenChange, follow, settle) {
515
514
  function ReanimatedDrawer({ reanimated: R, ...props }) {
516
515
  const { open, side = "left", width } = props;
517
516
  const drawerWidth = width ?? Math.min(Dimensions.get("window").width * 0.8, 360);
518
- const reducedMotion = useReducedMotion();
517
+ const motion = useMotion();
518
+ const reducedMotion = motion.reduced;
519
+ const OPEN_MS = motion.duration.base;
520
+ const SETTLE_MS = motion.duration.fast;
519
521
  const translate = R.useSharedValue(closedOffset(side, drawerWidth));
520
522
  useEffect(() => {
521
523
  const to = open ? 0 : closedOffset(side, drawerWidth);
522
524
  translate.value = reducedMotion ? to : R.withTiming(to, { duration: OPEN_MS });
523
- }, [drawerWidth, open, reducedMotion, side]);
525
+ }, [drawerWidth, open, reducedMotion, side, OPEN_MS]);
524
526
  const follow = useCallback((dx) => {
525
527
  translate.value = dx;
526
528
  }, []);
527
529
  const settle = useCallback(() => {
528
530
  translate.value = reducedMotion ? 0 : R.withTiming(0, { duration: SETTLE_MS });
529
- }, [reducedMotion]);
531
+ }, [reducedMotion, SETTLE_MS]);
530
532
  const panResponder = useSwipe(side, drawerWidth, props.onOpenChange, follow, settle);
531
533
  const animatedStyle = R.useAnimatedStyle(() => {
532
534
  "worklet";
@@ -537,7 +539,10 @@ function ReanimatedDrawer({ reanimated: R, ...props }) {
537
539
  function AnimatedDrawer(props) {
538
540
  const { open, side = "left", width } = props;
539
541
  const drawerWidth = width ?? Math.min(Dimensions.get("window").width * 0.8, 360);
540
- const reducedMotion = useReducedMotion();
542
+ const motion = useMotion();
543
+ const reducedMotion = motion.reduced;
544
+ const OPEN_MS = motion.duration.base;
545
+ const SETTLE_MS = motion.duration.fast;
541
546
  const translate = useRef(new Animated.Value(closedOffset(side, drawerWidth))).current;
542
547
  useEffect(() => {
543
548
  Animated.timing(translate, {
@@ -545,7 +550,7 @@ function AnimatedDrawer(props) {
545
550
  duration: reducedMotion ? 0 : OPEN_MS,
546
551
  useNativeDriver: true
547
552
  }).start();
548
- }, [drawerWidth, open, reducedMotion, side, translate]);
553
+ }, [drawerWidth, open, reducedMotion, side, translate, OPEN_MS]);
549
554
  const follow = useCallback((dx) => translate.setValue(dx), [translate]);
550
555
  const settle = useCallback(
551
556
  () => Animated.timing(translate, {
@@ -553,7 +558,7 @@ function AnimatedDrawer(props) {
553
558
  duration: reducedMotion ? 0 : SETTLE_MS,
554
559
  useNativeDriver: true
555
560
  }).start(),
556
- [reducedMotion, translate]
561
+ [reducedMotion, translate, SETTLE_MS]
557
562
  );
558
563
  const panResponder = useSwipe(side, drawerWidth, props.onOpenChange, follow, settle);
559
564
  return /* @__PURE__ */ jsx(
@@ -1905,7 +1910,609 @@ function Grid({
1905
1910
  Array.from({ length: cols - row.length }).map((_, padIndex) => /* @__PURE__ */ jsx(View, { className: "flex-1" }, `pad-${padIndex}`))
1906
1911
  ] }, `row-${rowIndex}`)) });
1907
1912
  }
1913
+ var STAR_SIZE = { sm: 14, md: 20, lg: 28 };
1914
+ function nextRating(value, star) {
1915
+ return star === value ? 0 : star;
1916
+ }
1917
+ function Star({ on, size, testID }) {
1918
+ const roles = useThemeRoles();
1919
+ const { symbol, icons } = useGenesisModules();
1920
+ const color = on ? roles.warning : roles.secondaryLabel;
1921
+ const Lucide = icons?.star;
1922
+ if (!(Platform.OS === "ios" && symbol) && Lucide) {
1923
+ return /* @__PURE__ */ jsx(Lucide, { size, color, fill: on ? roles.warning : "none", strokeWidth: on ? 2 : 1.5, testID });
1924
+ }
1925
+ return /* @__PURE__ */ jsx(NativeIcon, { name: "star", size, weight: on ? "bold" : "regular", color, testID });
1926
+ }
1927
+ function NativeRating({
1928
+ value,
1929
+ max = 5,
1930
+ onChange,
1931
+ readOnly = false,
1932
+ size = "md",
1933
+ label,
1934
+ getLabel,
1935
+ className,
1936
+ testID = "native-rating"
1937
+ }) {
1938
+ const count = Math.max(1, Math.floor(max));
1939
+ const filled = Math.min(count, Math.max(0, Math.round(Number.isFinite(value) ? value : 0)));
1940
+ const px = STAR_SIZE[size];
1941
+ const starsText = (n) => getLabel ? getLabel(n, count) : `${n} of ${count} stars`;
1942
+ const summary = label ? `${label}: ${starsText(filled)}` : starsText(filled);
1943
+ const stars = Array.from({ length: count }, (_, i) => i + 1);
1944
+ const interactive = Boolean(onChange) && !readOnly;
1945
+ if (!interactive) {
1946
+ return /* @__PURE__ */ jsx(
1947
+ View,
1948
+ {
1949
+ testID,
1950
+ accessible: true,
1951
+ accessibilityRole: "image",
1952
+ accessibilityLabel: summary,
1953
+ className: cn("flex-row items-center gap-0.5", className),
1954
+ children: stars.map((n) => /* @__PURE__ */ jsx(Star, { on: n <= filled, size: px, testID: `${testID}-star-${n}` }, n))
1955
+ }
1956
+ );
1957
+ }
1958
+ return /* @__PURE__ */ jsx(
1959
+ View,
1960
+ {
1961
+ testID,
1962
+ accessibilityRole: "radiogroup",
1963
+ accessibilityLabel: label ?? "Rating",
1964
+ accessibilityValue: { min: 0, max: count, now: filled, text: summary },
1965
+ className: cn("flex-row items-center gap-0.5", className),
1966
+ children: stars.map((n) => {
1967
+ const selected = n === filled;
1968
+ return /* @__PURE__ */ jsx(
1969
+ Pressable,
1970
+ {
1971
+ testID: `${testID}-star-${n}`,
1972
+ accessibilityRole: "radio",
1973
+ accessibilityLabel: starsText(n),
1974
+ accessibilityState: { selected, checked: selected },
1975
+ onPress: () => onChange?.(nextRating(filled, n)),
1976
+ hitSlop: 4,
1977
+ className: "p-0.5",
1978
+ children: /* @__PURE__ */ jsx(Star, { on: n <= filled, size: px })
1979
+ },
1980
+ n
1981
+ );
1982
+ })
1983
+ }
1984
+ );
1985
+ }
1986
+ var LIGHTBOX_DISMISS_DISTANCE = 110;
1987
+ var LIGHTBOX_DISMISS_VELOCITY = 1.1;
1988
+ var LIGHTBOX_MAX_ZOOM = 4;
1989
+ var LIGHTBOX_DOUBLE_TAP_MS = 400;
1990
+ function lightboxShouldDismiss(dy, vy) {
1991
+ return dy > LIGHTBOX_DISMISS_DISTANCE || dy > 24 && vy > LIGHTBOX_DISMISS_VELOCITY;
1992
+ }
1993
+ function lightboxPinchScale(startScale, startDistance, distance) {
1994
+ if (startDistance <= 0) return startScale;
1995
+ return Math.min(LIGHTBOX_MAX_ZOOM, Math.max(0.8, startScale * (distance / startDistance)));
1996
+ }
1997
+ function lightboxTouchDistance(touches) {
1998
+ const [a, b] = touches;
1999
+ if (!a || !b) return 0;
2000
+ return Math.hypot(a.pageX - b.pageX, a.pageY - b.pageY);
2001
+ }
2002
+ function lightboxPanLimit(scale, size) {
2003
+ return Math.max(0, (scale - 1) * size / 2);
2004
+ }
2005
+ var clamp2 = (v, limit) => Math.max(-limit, Math.min(limit, v));
2006
+ function NativeZoomablePhoto(props) {
2007
+ return Platform.OS === "ios" ? /* @__PURE__ */ jsx(ZoomableIos, { ...props }) : /* @__PURE__ */ jsx(ZoomablePan, { ...props });
2008
+ }
2009
+ function Photo({ src, alt, width, height, testID }) {
2010
+ return /* @__PURE__ */ jsx(NativeImage, { src, alt, width, height, contentFit: "contain", className: "bg-transparent", testID });
2011
+ }
2012
+ function useTaps(onSingle, onDouble) {
2013
+ const last = useRef(0);
2014
+ const timer = useRef(null);
2015
+ useEffect(
2016
+ () => () => {
2017
+ if (timer.current) clearTimeout(timer.current);
2018
+ },
2019
+ []
2020
+ );
2021
+ return (e) => {
2022
+ const now = Date.now();
2023
+ const at = { locationX: e.nativeEvent?.locationX ?? 0, locationY: e.nativeEvent?.locationY ?? 0 };
2024
+ if (now - last.current < LIGHTBOX_DOUBLE_TAP_MS) {
2025
+ last.current = 0;
2026
+ if (timer.current) clearTimeout(timer.current);
2027
+ onDouble(at);
2028
+ return;
2029
+ }
2030
+ last.current = now;
2031
+ timer.current = setTimeout(onSingle, LIGHTBOX_DOUBLE_TAP_MS);
2032
+ };
2033
+ }
2034
+ function zoomTo(view, rect, animated) {
2035
+ view?.scrollResponderZoomTo?.({ ...rect, animated }, animated);
2036
+ }
2037
+ function ZoomableIos({ src, alt, width, height, active, onZoomChange, zoomable = true, onPull, onDismiss, onTap, testID }) {
2038
+ const ref = useRef(null);
2039
+ const scale = useRef(1);
2040
+ const reducedMotion = useReducedMotion();
2041
+ useEffect(() => {
2042
+ if (!active && scale.current > 1.01) {
2043
+ zoomTo(ref.current, { x: 0, y: 0, width, height }, false);
2044
+ scale.current = 1;
2045
+ }
2046
+ }, [active, width, height]);
2047
+ const tap = useTaps(onTap, (at) => {
2048
+ if (!zoomable) return;
2049
+ if (scale.current > 1.01) return zoomTo(ref.current, { x: 0, y: 0, width, height }, !reducedMotion);
2050
+ const w = width / 2.5;
2051
+ const h = height / 2.5;
2052
+ zoomTo(ref.current, { x: at.locationX - w / 2, y: at.locationY - h / 2, width: w, height: h }, !reducedMotion);
2053
+ });
2054
+ return /* @__PURE__ */ jsx(
2055
+ ScrollView,
2056
+ {
2057
+ ref,
2058
+ testID,
2059
+ style: { width, height },
2060
+ contentContainerStyle: { width, height },
2061
+ maximumZoomScale: zoomable ? LIGHTBOX_MAX_ZOOM : 1,
2062
+ minimumZoomScale: 1,
2063
+ bouncesZoom: true,
2064
+ centerContent: true,
2065
+ alwaysBounceVertical: Boolean(onPull),
2066
+ showsHorizontalScrollIndicator: false,
2067
+ showsVerticalScrollIndicator: false,
2068
+ scrollEventThrottle: 16,
2069
+ onScroll: (e) => {
2070
+ const z = e.nativeEvent.zoomScale ?? 1;
2071
+ if (z > 1.01 !== scale.current > 1.01) onZoomChange(z > 1.01);
2072
+ scale.current = z;
2073
+ if (z <= 1.01) onPull?.(-e.nativeEvent.contentOffset.y);
2074
+ },
2075
+ onScrollEndDrag: (e) => {
2076
+ if (scale.current > 1.01 || !onPull) return;
2077
+ if (lightboxShouldDismiss(-e.nativeEvent.contentOffset.y, -(e.nativeEvent.velocity?.y ?? 0))) onDismiss();
2078
+ else onPull(0);
2079
+ },
2080
+ children: /* @__PURE__ */ jsx(Pressable, { accessible: false, onPress: tap, style: { width, height }, children: /* @__PURE__ */ jsx(Photo, { src, alt, width, height, testID: `${testID}-image` }) })
2081
+ }
2082
+ );
2083
+ }
2084
+ function ZoomablePan({ src, alt, width, height, active, onZoomChange, zoomable = true, onPull, onDismiss, onTap, testID }) {
2085
+ const reducedMotion = useReducedMotion();
2086
+ const scale = useRef(new Animated.Value(1)).current;
2087
+ const tx = useRef(new Animated.Value(0)).current;
2088
+ const ty = useRef(new Animated.Value(0)).current;
2089
+ const s = useRef({ scale: 1, x: 0, y: 0, startScale: 1, startDistance: 0, startX: 0, startY: 0, pinching: false, dragging: false });
2090
+ const settle = useCallback(
2091
+ (to) => {
2092
+ s.current.scale = to.scale;
2093
+ s.current.x = to.x;
2094
+ s.current.y = to.y;
2095
+ onZoomChange(to.scale > 1.01);
2096
+ if (reducedMotion) {
2097
+ scale.setValue(to.scale);
2098
+ tx.setValue(to.x);
2099
+ ty.setValue(to.y);
2100
+ return;
2101
+ }
2102
+ Animated.parallel([
2103
+ Animated.spring(scale, { toValue: to.scale, useNativeDriver: true }),
2104
+ Animated.spring(tx, { toValue: to.x, useNativeDriver: true }),
2105
+ Animated.spring(ty, { toValue: to.y, useNativeDriver: true })
2106
+ ]).start();
2107
+ },
2108
+ [reducedMotion, onZoomChange, scale, tx, ty]
2109
+ );
2110
+ useEffect(() => {
2111
+ if (!active && s.current.scale > 1.01) settle({ scale: 1, x: 0, y: 0 });
2112
+ }, [active, settle]);
2113
+ const tap = useTaps(onTap, (at) => {
2114
+ if (!zoomable) return;
2115
+ if (s.current.scale > 1.01) return settle({ scale: 1, x: 0, y: 0 });
2116
+ const z = 2.5;
2117
+ settle({
2118
+ scale: z,
2119
+ x: clamp2((width / 2 - at.locationX) * (z - 1), lightboxPanLimit(z, width)),
2120
+ y: clamp2((height / 2 - at.locationY) * (z - 1), lightboxPanLimit(z, height))
2121
+ });
2122
+ });
2123
+ const responder = useMemo(
2124
+ () => PanResponder.create({
2125
+ onStartShouldSetPanResponder: () => false,
2126
+ onMoveShouldSetPanResponder: (e, g) => zoomable && e.nativeEvent.touches.length >= 2 || s.current.scale > 1.01 || Boolean(onPull) && g.dy > 8 && Math.abs(g.dy) > Math.abs(g.dx) * 1.5,
2127
+ onPanResponderTerminationRequest: () => false,
2128
+ onPanResponderGrant: (e) => {
2129
+ const st = s.current;
2130
+ st.pinching = zoomable && e.nativeEvent.touches.length >= 2;
2131
+ st.dragging = !st.pinching && st.scale <= 1.01 && Boolean(onPull);
2132
+ st.startScale = st.scale;
2133
+ st.startDistance = lightboxTouchDistance(e.nativeEvent.touches);
2134
+ st.startX = st.x;
2135
+ st.startY = st.y;
2136
+ },
2137
+ onPanResponderMove: (e, g) => {
2138
+ const st = s.current;
2139
+ const touches = e.nativeEvent.touches;
2140
+ if (zoomable && touches.length >= 2) {
2141
+ if (!st.pinching) {
2142
+ st.pinching = true;
2143
+ st.dragging = false;
2144
+ st.startScale = st.scale;
2145
+ st.startDistance = lightboxTouchDistance(touches);
2146
+ }
2147
+ st.scale = lightboxPinchScale(st.startScale, st.startDistance, lightboxTouchDistance(touches));
2148
+ scale.setValue(st.scale);
2149
+ return;
2150
+ }
2151
+ if (st.dragging) {
2152
+ st.y = Math.max(0, g.dy);
2153
+ ty.setValue(st.y);
2154
+ onPull?.(st.y);
2155
+ return;
2156
+ }
2157
+ if (st.scale > 1.01) {
2158
+ st.x = clamp2(st.startX + g.dx, lightboxPanLimit(st.scale, width));
2159
+ st.y = clamp2(st.startY + g.dy, lightboxPanLimit(st.scale, height));
2160
+ tx.setValue(st.x);
2161
+ ty.setValue(st.y);
2162
+ }
2163
+ },
2164
+ onPanResponderRelease: (_e, g) => {
2165
+ const st = s.current;
2166
+ if (st.dragging) {
2167
+ st.dragging = false;
2168
+ if (lightboxShouldDismiss(g.dy, g.vy)) return onDismiss();
2169
+ onPull?.(0);
2170
+ return settle({ scale: 1, x: 0, y: 0 });
2171
+ }
2172
+ st.pinching = false;
2173
+ const z = Math.max(1, st.scale);
2174
+ settle({ scale: z, x: clamp2(st.x, lightboxPanLimit(z, width)), y: clamp2(st.y, lightboxPanLimit(z, height)) });
2175
+ },
2176
+ onPanResponderTerminate: () => {
2177
+ onPull?.(0);
2178
+ settle({ scale: Math.max(1, s.current.scale), x: 0, y: 0 });
2179
+ }
2180
+ }),
2181
+ [width, height, zoomable, onPull, onDismiss, settle, scale, tx, ty]
2182
+ );
2183
+ return /* @__PURE__ */ jsx(View, { testID, style: { width, height, overflow: "hidden" }, ...responder.panHandlers, children: /* @__PURE__ */ jsx(Animated.View, { style: { width, height, transform: [{ translateX: tx }, { translateY: ty }, { scale }] }, children: /* @__PURE__ */ jsx(Pressable, { accessible: false, onPress: tap, style: { width, height }, children: /* @__PURE__ */ jsx(Photo, { src, alt, width, height, testID: `${testID}-image` }) }) }) });
2184
+ }
2185
+ var defaultNativeLightboxLabels = {
2186
+ close: "Close",
2187
+ position: (n, count) => `${n} of ${count}`,
2188
+ pagerHint: "Swipe up or down for the next or previous one",
2189
+ photo: (n, count) => `Photo ${n} of ${count}`
2190
+ };
2191
+ var CHROME_TINT = "white";
2192
+ function NativeLightbox({
2193
+ open,
2194
+ onOpenChange,
2195
+ items,
2196
+ index,
2197
+ onIndexChange,
2198
+ renderCaption,
2199
+ renderActions,
2200
+ renderMedia,
2201
+ title,
2202
+ description,
2203
+ zoomable = true,
2204
+ swipeToDismiss = true,
2205
+ labels: labelOverrides,
2206
+ testID = "native-lightbox"
2207
+ }) {
2208
+ const labels = { ...defaultNativeLightboxLabels, ...labelOverrides };
2209
+ return /* @__PURE__ */ jsx(NativeFullScreenModal, { open, onOpenChange, tone: "none", testID, children: open ? /* @__PURE__ */ jsx(
2210
+ LightboxBody,
2211
+ {
2212
+ testID,
2213
+ items,
2214
+ index,
2215
+ onIndexChange,
2216
+ onClose: () => onOpenChange(false),
2217
+ renderCaption,
2218
+ renderActions,
2219
+ renderMedia,
2220
+ title,
2221
+ description,
2222
+ zoomable,
2223
+ swipeToDismiss,
2224
+ labels
2225
+ }
2226
+ ) : null });
2227
+ }
2228
+ function LightboxBody({
2229
+ testID,
2230
+ items,
2231
+ index,
2232
+ onIndexChange,
2233
+ onClose,
2234
+ renderCaption,
2235
+ renderActions,
2236
+ renderMedia,
2237
+ title,
2238
+ description,
2239
+ zoomable,
2240
+ swipeToDismiss,
2241
+ labels
2242
+ }) {
2243
+ const insets = useSafeAreaInsets();
2244
+ const reducedMotion = useReducedMotion();
2245
+ const [size, setSize] = useState(() => Dimensions.get("window"));
2246
+ const [zoomed, setZoomed] = useState(false);
2247
+ const [chrome, setChrome] = useState(true);
2248
+ const backdrop = useRef(new Animated.Value(1)).current;
2249
+ const listRef = useRef(null);
2250
+ const width = size.width;
2251
+ const current = Math.min(Math.max(0, index), Math.max(0, items.length - 1));
2252
+ const item = items[current];
2253
+ const many = items.length > 1;
2254
+ const snappedWidth = useRef(width);
2255
+ useEffect(() => {
2256
+ if (items.length === 0) return;
2257
+ const widthChanged = snappedWidth.current !== width;
2258
+ snappedWidth.current = width;
2259
+ listRef.current?.scrollToIndex({ index: current, animated: !widthChanged && !reducedMotion });
2260
+ }, [current, items.length, width, reducedMotion]);
2261
+ useEffect(() => setZoomed(false), [current]);
2262
+ const onLayout = (e) => {
2263
+ const { width: w, height: h } = e.nativeEvent.layout;
2264
+ if (w > 0 && (w !== size.width || h !== size.height)) setSize({ width: w, height: h, scale: 1, fontScale: 1 });
2265
+ };
2266
+ const currentRef = useRef(current);
2267
+ currentRef.current = current;
2268
+ const onMomentumEnd = (e) => {
2269
+ const page = Math.round(e.nativeEvent.contentOffset.x / Math.max(1, width));
2270
+ const clamped = Math.min(Math.max(0, page), items.length - 1);
2271
+ if (clamped === current) return;
2272
+ onIndexChange(clamped);
2273
+ setTimeout(() => {
2274
+ if (currentRef.current !== clamped) listRef.current?.scrollToIndex({ index: currentRef.current, animated: !reducedMotion });
2275
+ }, 0);
2276
+ };
2277
+ const goTo = (i) => {
2278
+ if (i >= 0 && i < items.length && i !== current) onIndexChange(i);
2279
+ };
2280
+ const onPull = useCallback((dy) => backdrop.setValue(Math.max(0.35, 1 - Math.max(0, dy) / 400)), [backdrop]);
2281
+ const toggleChrome = useCallback(() => setChrome((c) => !c), []);
2282
+ const caption = item ? renderCaption ? renderCaption(item, current) : item.caption : null;
2283
+ const position = items.length > 0 ? labels.position(current + 1, items.length) : "";
2284
+ const pagerA11y = {
2285
+ testID: `${testID}-pager-a11y`,
2286
+ accessible: true,
2287
+ accessibilityRole: "adjustable",
2288
+ accessibilityLabel: item ? item.alt ?? labels.photo(current + 1, items.length) : title,
2289
+ accessibilityValue: many ? { text: position } : void 0,
2290
+ accessibilityHint: many ? labels.pagerHint : void 0,
2291
+ accessibilityActions: many ? [{ name: "increment" }, { name: "decrement" }] : [],
2292
+ onAccessibilityAction: (e) => {
2293
+ if (e.nativeEvent.actionName === "increment") goTo(current + 1);
2294
+ if (e.nativeEvent.actionName === "decrement") goTo(current - 1);
2295
+ }
2296
+ };
2297
+ return /* @__PURE__ */ jsxs(View, { testID: `${testID}-content`, accessibilityLabel: title, onLayout, style: { flex: 1 }, children: [
2298
+ /* @__PURE__ */ jsx(Animated.View, { pointerEvents: "none", style: { position: "absolute", top: 0, right: 0, bottom: 0, left: 0, backgroundColor: FULL_SCREEN_DARK, opacity: backdrop } }),
2299
+ /* @__PURE__ */ jsx(View, { style: { flex: 1 }, testID: `${testID}-pages`, ...renderMedia ? {} : pagerA11y, children: /* @__PURE__ */ jsx(
2300
+ FlatList,
2301
+ {
2302
+ ref: listRef,
2303
+ testID: `${testID}-pager`,
2304
+ data: items,
2305
+ horizontal: true,
2306
+ pagingEnabled: true,
2307
+ scrollEnabled: many && !zoomed,
2308
+ showsHorizontalScrollIndicator: false,
2309
+ keyExtractor: (it) => it.id,
2310
+ initialScrollIndex: current,
2311
+ getItemLayout: (_data, i) => ({ length: width, offset: width * i, index: i }),
2312
+ onMomentumScrollEnd: onMomentumEnd,
2313
+ windowSize: 3,
2314
+ initialNumToRender: 1,
2315
+ extraData: current,
2316
+ renderItem: ({ item: it, index: i }) => /* @__PURE__ */ jsx(View, { testID: `${testID}-page-${it.id}`, style: { width, flex: 1 }, className: "items-center justify-center", children: renderMedia ? renderMedia(it, i) : zoomable || swipeToDismiss ? /* @__PURE__ */ jsx(
2317
+ NativeZoomablePhoto,
2318
+ {
2319
+ src: it.src,
2320
+ alt: it.alt ?? labels.photo(i + 1, items.length),
2321
+ width,
2322
+ height: size.height,
2323
+ active: i === current,
2324
+ zoomable,
2325
+ onZoomChange: setZoomed,
2326
+ onPull: swipeToDismiss ? onPull : null,
2327
+ onDismiss: onClose,
2328
+ onTap: toggleChrome,
2329
+ testID: `${testID}-photo-${it.id}`
2330
+ }
2331
+ ) : /* @__PURE__ */ jsx(Pressable, { accessible: false, onPress: toggleChrome, style: { width, flex: 1 }, children: /* @__PURE__ */ jsx(NativeImage, { src: it.src, alt: it.alt ?? labels.photo(i + 1, items.length), className: "h-full w-full", contentFit: "contain" }) }) }),
2332
+ style: { flex: 1 }
2333
+ }
2334
+ ) }),
2335
+ chrome ? /* @__PURE__ */ jsxs(
2336
+ View,
2337
+ {
2338
+ pointerEvents: "box-none",
2339
+ testID: `${testID}-chrome`,
2340
+ className: "absolute left-0 right-0 top-0 flex-row items-center justify-between px-3",
2341
+ style: { paddingTop: insets.top + 8 },
2342
+ children: [
2343
+ /* @__PURE__ */ jsx(
2344
+ Pressable,
2345
+ {
2346
+ testID: `${testID}-close`,
2347
+ accessibilityRole: "button",
2348
+ accessibilityLabel: labels.close,
2349
+ onPress: onClose,
2350
+ hitSlop: 8,
2351
+ className: "h-11 w-11 items-center justify-center rounded-full bg-black/45",
2352
+ children: /* @__PURE__ */ jsx(NativeIcon, { name: "close", size: 20, color: CHROME_TINT })
2353
+ }
2354
+ ),
2355
+ /* @__PURE__ */ jsxs(View, { className: "flex-1 items-center px-2", children: [
2356
+ title ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-title`, accessibilityRole: "header", numberOfLines: 1, className: "text-sm font-semibold text-white", children: title }) : null,
2357
+ description ? typeof description === "string" ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-description`, numberOfLines: 1, className: "text-xs text-white/70", children: description }) : /* @__PURE__ */ jsx(View, { testID: `${testID}-description`, children: description }) : null,
2358
+ renderMedia ? /* @__PURE__ */ jsx(View, { ...pagerA11y, children: many ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-counter`, className: "text-xs font-medium text-white/70", children: `${current + 1} / ${items.length}` }) : null }) : many ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-counter`, importantForAccessibility: "no-hide-descendants", accessibilityElementsHidden: true, className: "text-xs font-medium text-white/70", children: `${current + 1} / ${items.length}` }) : null
2359
+ ] }),
2360
+ /* @__PURE__ */ jsx(View, { testID: `${testID}-actions`, className: "min-w-11 flex-row items-center justify-end gap-1", children: item && renderActions ? renderActions(item, current) : null })
2361
+ ]
2362
+ }
2363
+ ) : null,
2364
+ chrome && caption ? /* @__PURE__ */ jsx(
2365
+ View,
2366
+ {
2367
+ pointerEvents: "box-none",
2368
+ testID: `${testID}-caption`,
2369
+ className: cn("absolute bottom-0 left-0 right-0 px-4 pt-3"),
2370
+ style: { paddingBottom: insets.bottom + 12 },
2371
+ children: typeof caption === "string" ? /* @__PURE__ */ jsx(Text, { className: "text-center text-sm text-white", children: caption }) : caption
2372
+ }
2373
+ ) : null
2374
+ ] });
2375
+ }
2376
+ function NativeGalleryCard({
2377
+ src,
2378
+ alt,
2379
+ title,
2380
+ subtitle,
2381
+ badges,
2382
+ actions,
2383
+ ratio = 4 / 3,
2384
+ loading = false,
2385
+ onPress,
2386
+ className,
2387
+ testID = "native-gallery-card"
2388
+ }) {
2389
+ const aspectRatio = Number.isFinite(ratio) && ratio > 0 ? ratio : 4 / 3;
2390
+ const placeholder = loading || !src;
2391
+ const body = /* @__PURE__ */ jsxs(Fragment, { children: [
2392
+ /* @__PURE__ */ jsxs(View, { testID: `${testID}-cover`, className: "relative w-full overflow-hidden bg-muted", style: { aspectRatio }, children: [
2393
+ placeholder ? /* @__PURE__ */ jsx(NativeSkeleton, { testID: `${testID}-skeleton`, className: "absolute inset-0 h-full w-full rounded-none" }) : /* @__PURE__ */ jsx(NativeImage, { src, alt, className: "h-full w-full" }),
2394
+ badges ? /* @__PURE__ */ jsx(View, { testID: `${testID}-badges`, className: "absolute left-2 top-2 flex-row items-center gap-1", children: badges }) : null,
2395
+ actions ? /* @__PURE__ */ jsx(View, { testID: `${testID}-actions`, className: "absolute right-2 top-2 flex-row items-center gap-1", children: actions }) : null
2396
+ ] }),
2397
+ title || subtitle ? /* @__PURE__ */ jsxs(View, { testID: `${testID}-footer`, className: "gap-0.5 px-3 py-2", children: [
2398
+ title ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-title`, numberOfLines: 1, className: "text-sm font-semibold text-foreground", children: title }) : null,
2399
+ subtitle ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-subtitle`, numberOfLines: 1, className: "text-xs text-muted-foreground", children: subtitle }) : null
2400
+ ] }) : null
2401
+ ] });
2402
+ const classes = cn("overflow-hidden rounded-lg border border-border bg-card", className);
2403
+ if (onPress) {
2404
+ return /* @__PURE__ */ jsx(
2405
+ Pressable,
2406
+ {
2407
+ testID,
2408
+ accessibilityRole: "button",
2409
+ accessibilityLabel: title ?? alt,
2410
+ accessibilityHint: subtitle,
2411
+ accessibilityState: loading ? { busy: true } : void 0,
2412
+ onPress,
2413
+ className: classes,
2414
+ children: body
2415
+ }
2416
+ );
2417
+ }
2418
+ return /* @__PURE__ */ jsx(View, { testID, accessibilityState: loading ? { busy: true } : void 0, className: classes, children: body });
2419
+ }
2420
+ var DEFAULT_LABEL = { live: "Live", idle: "Idle", offline: "Offline" };
2421
+ var DOT_CLASS = {
2422
+ live: "bg-destructive",
2423
+ idle: "bg-muted-foreground",
2424
+ offline: "bg-muted-foreground/50"
2425
+ };
2426
+ function NativeLiveIndicator({
2427
+ live = true,
2428
+ state,
2429
+ label,
2430
+ detail,
2431
+ variant = "pill",
2432
+ className,
2433
+ testID = "native-live-indicator"
2434
+ }) {
2435
+ const resolved = state ?? (live ? "live" : "idle");
2436
+ const isLive = resolved === "live";
2437
+ const reducedMotion = useReducedMotion();
2438
+ const pulse = useRef(new Animated.Value(1)).current;
2439
+ useEffect(() => {
2440
+ if (!isLive || reducedMotion) {
2441
+ pulse.setValue(1);
2442
+ return;
2443
+ }
2444
+ const loop = Animated.loop(
2445
+ Animated.sequence([
2446
+ Animated.timing(pulse, { toValue: 0.3, duration: 700, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
2447
+ Animated.timing(pulse, { toValue: 1, duration: 700, easing: Easing.inOut(Easing.ease), useNativeDriver: true })
2448
+ ])
2449
+ );
2450
+ loop.start();
2451
+ return () => loop.stop();
2452
+ }, [isLive, reducedMotion, pulse]);
2453
+ const shown = label ?? DEFAULT_LABEL[resolved];
2454
+ const stateText = isLive ? shown : label === void 0 ? shown : resolved === "offline" ? `Offline, not ${shown.toLowerCase()}` : `Not ${shown.toLowerCase()}`;
2455
+ const a11yLabel = detail ? `${stateText}, ${detail}` : stateText;
2456
+ const announced = useRef(null);
2457
+ useEffect(() => {
2458
+ const previous = announced.current;
2459
+ announced.current = a11yLabel;
2460
+ if (previous === null || previous === a11yLabel) return;
2461
+ const info = AccessibilityInfo;
2462
+ if (info.announceForAccessibilityWithOptions) info.announceForAccessibilityWithOptions(a11yLabel, { queue: true });
2463
+ else info.announceForAccessibility?.(a11yLabel);
2464
+ }, [a11yLabel]);
2465
+ const dot = /* @__PURE__ */ jsx(
2466
+ Animated.View,
2467
+ {
2468
+ testID: `${testID}-dot`,
2469
+ className: cn("h-2 w-2 rounded-full", DOT_CLASS[resolved]),
2470
+ style: { opacity: pulse }
2471
+ }
2472
+ );
2473
+ if (variant === "dot") {
2474
+ return /* @__PURE__ */ jsx(
2475
+ View,
2476
+ {
2477
+ testID,
2478
+ accessible: true,
2479
+ accessibilityRole: "text",
2480
+ accessibilityLabel: a11yLabel,
2481
+ accessibilityLiveRegion: "polite",
2482
+ className: cn("items-center justify-center", className),
2483
+ children: dot
2484
+ }
2485
+ );
2486
+ }
2487
+ return /* @__PURE__ */ jsxs(
2488
+ View,
2489
+ {
2490
+ testID,
2491
+ accessible: true,
2492
+ accessibilityRole: "text",
2493
+ accessibilityLabel: a11yLabel,
2494
+ accessibilityLiveRegion: "polite",
2495
+ className: cn(
2496
+ "flex-row items-center gap-1.5 self-start rounded-full border px-2 py-0.5",
2497
+ isLive ? "border-transparent bg-destructive/15" : "border-border bg-muted",
2498
+ className
2499
+ ),
2500
+ children: [
2501
+ dot,
2502
+ /* @__PURE__ */ jsx(
2503
+ Text,
2504
+ {
2505
+ testID: `${testID}-label`,
2506
+ className: cn("text-xs font-semibold uppercase tracking-wide", isLive ? "text-foreground" : "text-muted-foreground"),
2507
+ children: shown
2508
+ }
2509
+ ),
2510
+ detail ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-detail`, className: "text-xs text-muted-foreground", children: detail }) : null
2511
+ ]
2512
+ }
2513
+ );
2514
+ }
1908
2515
 
1909
- export { Box, FULL_SCREEN_DARK, Grid, Inline, NativeAccordion, NativeAccordionContent, NativeAccordionItem, NativeAccordionTrigger, NativeChip, NativeChipGroup, NativeCombobox, NativeDialog, NativeDialogContent, NativeDialogDescription, NativeDialogFooter, NativeDialogHeader, NativeDialogTitle, NativeDrawer, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuItem, NativeDropdownMenuTrigger, NativeFullScreenModal, NativeGlassSurface, NativeHeaderCard, NativeNumberInput, NativePagination, NativePopover, NativePopoverContent, NativePopoverTrigger, NativeProgress, NativeRadioGroup, NativeRadioGroupItem, NativeRangeSlider, NativeSlider, NativeStepper, NativeTabs, NativeTabsContent, NativeTabsList, NativeTabsTrigger, NativeToastProvider, NativeToggle, NativeTooltip, NativeTooltipContent, NativeTooltipTrigger, Stack, spaceScale, spacingClass, toggleVariants, useLiquidGlass, useReduceTransparency, useToast };
1910
- //# sourceMappingURL=chunk-LBVD7XXL.js.map
1911
- //# sourceMappingURL=chunk-LBVD7XXL.js.map
2516
+ export { Box, FULL_SCREEN_DARK, Grid, Inline, LIGHTBOX_DISMISS_DISTANCE, LIGHTBOX_DISMISS_VELOCITY, LIGHTBOX_DOUBLE_TAP_MS, LIGHTBOX_MAX_ZOOM, NativeAccordion, NativeAccordionContent, NativeAccordionItem, NativeAccordionTrigger, NativeChip, NativeChipGroup, NativeCombobox, NativeDialog, NativeDialogContent, NativeDialogDescription, NativeDialogFooter, NativeDialogHeader, NativeDialogTitle, NativeDrawer, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuItem, NativeDropdownMenuTrigger, NativeFullScreenModal, NativeGalleryCard, NativeGlassSurface, NativeHeaderCard, NativeLightbox, NativeLiveIndicator, NativeNumberInput, NativePagination, NativePopover, NativePopoverContent, NativePopoverTrigger, NativeProgress, NativeRadioGroup, NativeRadioGroupItem, NativeRangeSlider, NativeRating, NativeSlider, NativeStepper, NativeTabs, NativeTabsContent, NativeTabsList, NativeTabsTrigger, NativeToastProvider, NativeToggle, NativeTooltip, NativeTooltipContent, NativeTooltipTrigger, NativeZoomablePhoto, Stack, defaultNativeLightboxLabels, lightboxPanLimit, lightboxPinchScale, lightboxShouldDismiss, lightboxTouchDistance, nextRating, spaceScale, spacingClass, toggleVariants, useLiquidGlass, useReduceTransparency, useToast };
2517
+ //# sourceMappingURL=chunk-2Z72MYHB.js.map
2518
+ //# sourceMappingURL=chunk-2Z72MYHB.js.map