@marktiderman/genesis-ui-native 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +48 -1
  2. package/dist/{chunk-NDXNSSM6.js → chunk-DHONOH6K.js} +24 -211
  3. package/dist/chunk-DHONOH6K.js.map +1 -0
  4. package/dist/{chunk-6PGLX6ET.js → chunk-FGIIBON3.js} +334 -24
  5. package/dist/chunk-FGIIBON3.js.map +1 -0
  6. package/dist/{chunk-ZRQAFFTN.js → chunk-FOJJB6AB.js} +2 -2
  7. package/dist/{chunk-ZRQAFFTN.js.map → chunk-FOJJB6AB.js.map} +1 -1
  8. package/dist/{chunk-SEJ6RBP7.js → chunk-JZ7RAGDQ.js} +117 -60
  9. package/dist/chunk-JZ7RAGDQ.js.map +1 -0
  10. package/dist/chunk-PWS2HLDE.js +137 -0
  11. package/dist/chunk-PWS2HLDE.js.map +1 -0
  12. package/dist/{chunk-AGTBABAH.js → chunk-PWYMRUAK.js} +43 -30
  13. package/dist/chunk-PWYMRUAK.js.map +1 -0
  14. package/dist/{chunk-FUMSL7VZ.js → chunk-T7FEVT62.js} +53 -12
  15. package/dist/chunk-T7FEVT62.js.map +1 -0
  16. package/dist/{chunk-2Z72MYHB.js → chunk-UZCJDMGE.js} +353 -19
  17. package/dist/chunk-UZCJDMGE.js.map +1 -0
  18. package/dist/components/index.d.ts +275 -24
  19. package/dist/components/index.js +5 -5
  20. package/dist/data/index.d.ts +2 -1
  21. package/dist/data/index.js +7 -12
  22. package/dist/data/index.js.map +1 -1
  23. package/dist/hooks/index.d.ts +36 -3
  24. package/dist/hooks/index.js +2 -2
  25. package/dist/icons/lucide.d.ts +1 -1
  26. package/dist/icons/lucide.js +13 -3
  27. package/dist/icons/lucide.js.map +1 -1
  28. package/dist/{inbox-page-B7_Oi2fS.d.ts → inbox-page-BGqR_cBs.d.ts} +4 -1
  29. package/dist/index.d.ts +4 -4
  30. package/dist/index.js +8 -8
  31. package/dist/layouts/index.d.ts +12 -3
  32. package/dist/layouts/index.js +5 -5
  33. package/dist/{native-modules-Cl3zw3kh.d.ts → native-modules-CeAaO2Dh.d.ts} +55 -3
  34. package/package.json +73 -2
  35. package/src/__tests__/doctor-rules.test.ts +27 -0
  36. package/src/__tests__/native-modules-lists.test.tsx +1 -0
  37. package/src/components/__tests__/bulk-bar.test.tsx +36 -0
  38. package/src/components/__tests__/button-haptic.test.tsx +74 -0
  39. package/src/components/__tests__/composer-bar.test.tsx +140 -1
  40. package/src/components/__tests__/gallery-grid.test.tsx +2 -2
  41. package/src/components/__tests__/library-round-5.test.tsx +121 -0
  42. package/src/components/__tests__/share-sheet.test.tsx +47 -0
  43. package/src/components/__tests__/swipe-row-context-menu.test.tsx +215 -0
  44. package/src/components/__tests__/tab-bar.test.tsx +43 -0
  45. package/src/components/__tests__/thread-list.test.tsx +200 -0
  46. package/src/components/__tests__/tier-badge.test.tsx +57 -0
  47. package/src/components/__tests__/whats-new-sheet.test.tsx +29 -0
  48. package/src/components/bulk-bar.tsx +91 -0
  49. package/src/components/button.tsx +81 -25
  50. package/src/components/choice-card.tsx +104 -0
  51. package/src/components/composer-bar.tsx +104 -25
  52. package/src/components/context-menu.tsx +101 -0
  53. package/src/components/gallery-grid.tsx +10 -4
  54. package/src/components/index.ts +19 -2
  55. package/src/components/inline-alert.tsx +36 -1
  56. package/src/components/input.tsx +3 -0
  57. package/src/components/progress.tsx +24 -2
  58. package/src/components/rating.tsx +35 -16
  59. package/src/components/share-sheet.tsx +127 -0
  60. package/src/components/sheet.tsx +9 -1
  61. package/src/components/swipe-row.tsx +74 -0
  62. package/src/components/tab-bar.tsx +133 -0
  63. package/src/components/tabs.tsx +2 -0
  64. package/src/components/text.tsx +3 -0
  65. package/src/components/textarea.tsx +3 -0
  66. package/src/components/thread-list.tsx +78 -23
  67. package/src/components/tier-badge.tsx +74 -0
  68. package/src/components/whats-new-sheet.tsx +89 -0
  69. package/src/data/resource-view/NativeRecordView.tsx +3 -8
  70. package/src/data/resource-view/use-native-resource-view.ts +2 -2
  71. package/src/hooks/__tests__/use-haptics.test.tsx +146 -0
  72. package/src/hooks/index.ts +3 -1
  73. package/src/hooks/use-haptics.ts +64 -0
  74. package/src/hooks/use-press-feedback.ts +87 -0
  75. package/src/hooks/use-theme-roles.ts +3 -0
  76. package/src/icon-names.ts +12 -2
  77. package/src/icons/lucide.ts +27 -7
  78. package/src/layouts/__tests__/inbox-page.test.tsx +26 -7
  79. package/src/layouts/__tests__/thread-page.test.tsx +89 -2
  80. package/src/layouts/inbox-page.tsx +28 -12
  81. package/src/layouts/thread-page.tsx +69 -8
  82. package/src/native-modules.tsx +20 -0
  83. package/dist/chunk-2Z72MYHB.js.map +0 -1
  84. package/dist/chunk-4OQOJ2OC.js +0 -80
  85. package/dist/chunk-4OQOJ2OC.js.map +0 -1
  86. package/dist/chunk-6PGLX6ET.js.map +0 -1
  87. package/dist/chunk-AGTBABAH.js.map +0 -1
  88. package/dist/chunk-FUMSL7VZ.js.map +0 -1
  89. package/dist/chunk-NDXNSSM6.js.map +0 -1
  90. package/dist/chunk-SEJ6RBP7.js.map +0 -1
@@ -1,11 +1,12 @@
1
- import { useThemeRoles, useMotion } from './chunk-4OQOJ2OC.js';
1
+ import { usePressFeedback, useThemeRoles, useGenesisModules, useMotion, useHaptics } from './chunk-PWS2HLDE.js';
2
2
  import { cn } from './chunk-OHZD7KRO.js';
3
3
  import { cva } from 'class-variance-authority';
4
- import { Text, Pressable, ActivityIndicator, View, Platform, RefreshControl, TextInput, Animated, Easing } from 'react-native';
4
+ import { Text, Pressable, Animated, View, ActivityIndicator, ScrollView, Dimensions, Platform, Modal, KeyboardAvoidingView, RefreshControl, TextInput, Easing, AccessibilityInfo } from 'react-native';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import { createContext, useContext, useMemo, createElement, useEffect, useRef } from 'react';
6
+ import { useOptionalTheme, brandGradientCss } from '@marktiderman/genesis-design-system';
7
+ import { createContext, useState, useEffect, useContext, useRef, useCallback } from 'react';
8
+ import { SafeAreaProvider, useSafeAreaInsets, SafeAreaView } from 'react-native-safe-area-context';
7
9
  import { nativeColors } from '@marktiderman/genesis-design-system/tokens/native';
8
- import { SafeAreaView } from 'react-native-safe-area-context';
9
10
 
10
11
  var textVariants = cva("text-foreground", {
11
12
  variants: {
@@ -48,7 +49,8 @@ var buttonVariants = cva(
48
49
  secondary: "bg-secondary",
49
50
  outline: "border border-input bg-transparent",
50
51
  ghost: "bg-transparent",
51
- destructive: "bg-destructive"
52
+ destructive: "bg-destructive",
53
+ gradient: "bg-primary"
52
54
  },
53
55
  size: {
54
56
  sm: "h-9 px-3 gap-1.5",
@@ -69,7 +71,8 @@ var buttonTextVariants = cva("font-medium text-center", {
69
71
  secondary: "text-secondary-foreground",
70
72
  outline: "text-foreground",
71
73
  ghost: "text-foreground",
72
- destructive: "text-destructive-foreground"
74
+ destructive: "text-destructive-foreground",
75
+ gradient: "text-primary-foreground"
73
76
  },
74
77
  size: {
75
78
  sm: "text-sm",
@@ -82,6 +85,11 @@ var buttonTextVariants = cva("font-medium text-center", {
82
85
  size: "md"
83
86
  }
84
87
  });
88
+ var contentVariants = cva("flex-row items-center justify-center", {
89
+ variants: { size: { sm: "gap-1.5", md: "gap-2", lg: "gap-2" } },
90
+ defaultVariants: { size: "md" }
91
+ });
92
+ var contentClasses = (className) => className?.split(/\s+/).filter((c) => /^(flex-(row|col)|justify-|items-|gap-)/.test(c)).join(" ");
85
93
  function NativeButton({
86
94
  className,
87
95
  textClassName,
@@ -92,10 +100,20 @@ function NativeButton({
92
100
  disabled,
93
101
  loading,
94
102
  accessibilityState,
103
+ haptic,
104
+ style,
95
105
  ...props
96
106
  }) {
97
107
  const isDisabled = disabled || loading;
98
- return /* @__PURE__ */ jsxs(
108
+ const theme = useOptionalTheme();
109
+ const gradient = variant === "gradient" && theme ? brandGradientCss(theme.brand) : void 0;
110
+ const gradientStyle = gradient ? { experimental_backgroundImage: gradient } : void 0;
111
+ const feedback = usePressFeedback({ haptic: onPress ? haptic ?? false : false, disabled: Boolean(isDisabled) });
112
+ const press = onPress ? () => {
113
+ feedback.confirm();
114
+ onPress();
115
+ } : void 0;
116
+ return /* @__PURE__ */ jsx(
99
117
  Pressable,
100
118
  {
101
119
  className: cn(
@@ -103,12 +121,15 @@ function NativeButton({
103
121
  isDisabled && "opacity-50",
104
122
  className
105
123
  ),
106
- onPress,
124
+ onPress: press,
125
+ onPressIn: feedback.onPressIn,
126
+ onPressOut: feedback.onPressOut,
107
127
  disabled: isDisabled,
108
128
  accessibilityRole: "button",
109
- accessibilityState: { ...accessibilityState, disabled: isDisabled, busy: loading },
129
+ accessibilityState: { ...accessibilityState, disabled: isDisabled, busy: loading ?? accessibilityState?.busy },
110
130
  ...props,
111
- children: [
131
+ style: gradientStyle ? style ? [gradientStyle, style] : gradientStyle : style,
132
+ children: /* @__PURE__ */ jsx(Animated.View, { style: [{ flexGrow: 1 }, feedback.style], children: /* @__PURE__ */ jsxs(View, { className: cn(contentVariants({ size }), contentClasses(className)), children: [
112
133
  loading ? /* @__PURE__ */ jsx(
113
134
  ActivityIndicator,
114
135
  {
@@ -126,19 +147,214 @@ function NativeButton({
126
147
  children
127
148
  }
128
149
  ) : children
129
- ]
150
+ ] }) })
151
+ }
152
+ );
153
+ }
154
+ var REQUIRED_EXPORTS = ["BottomSheetModal", "BottomSheetView", "BottomSheetBackdrop", "BottomSheetModalProvider"];
155
+ var SheetLibraryContext = createContext(null);
156
+ function NativeSheetProvider({ bottomSheet, children }) {
157
+ const [library] = useState(() => isSheetLibrary(bottomSheet) ? bottomSheet : null);
158
+ const [problem] = useState(() => library ? null : invalidLibraryMessage(bottomSheet));
159
+ useEffect(() => {
160
+ if (problem) console.error(problem);
161
+ }, [problem]);
162
+ if (!library) return /* @__PURE__ */ jsx(Fragment, { children });
163
+ const Provider = library.BottomSheetModalProvider;
164
+ return /* @__PURE__ */ jsx(SheetLibraryContext.Provider, { value: library, children: /* @__PURE__ */ jsx(Provider, { children }) });
165
+ }
166
+ function isSheetLibrary(value) {
167
+ if (!value || typeof value !== "object") return false;
168
+ const mod = value;
169
+ return REQUIRED_EXPORTS.every((name) => mod[name] != null);
170
+ }
171
+ function invalidLibraryMessage(value) {
172
+ const mod = value && typeof value === "object" ? value : {};
173
+ const missing = REQUIRED_EXPORTS.filter((name) => mod[name] == null);
174
+ return `NativeSheetProvider: \`bottomSheet\` is missing ${missing.join(", ")}, so sheets use the native modal. Pass the whole module: \`import * as BottomSheet from "@gorhom/bottom-sheet"\`.`;
175
+ }
176
+ function NativeSheet(props) {
177
+ const library = useContext(SheetLibraryContext);
178
+ if (library) return /* @__PURE__ */ jsx(LibrarySheet, { library, ...props });
179
+ return /* @__PURE__ */ jsx(ModalSheet, { ...props });
180
+ }
181
+ function NativeSheetScrollView({ style, ...props }) {
182
+ const library = useContext(SheetLibraryContext);
183
+ const Scroll = library?.BottomSheetScrollView ?? ScrollView;
184
+ const own = { flexGrow: 0 };
185
+ return /* @__PURE__ */ jsx(Scroll, { style: [own, ...Array.isArray(style) ? style : style ? [style] : []], ...props });
186
+ }
187
+ function LibrarySheet({
188
+ library,
189
+ open,
190
+ onOpenChange,
191
+ snapPoints = ["50%", "90%"],
192
+ initialSnapIndex = 0,
193
+ disableBackdropDismiss = false,
194
+ fitContent = false,
195
+ onDismissed,
196
+ testID,
197
+ children
198
+ }) {
199
+ const sheet = useRef(null);
200
+ const wanted = useRef(open);
201
+ const onOpenChangeRef = useRef(onOpenChange);
202
+ onOpenChangeRef.current = onOpenChange;
203
+ const onDismissedRef = useRef(onDismissed);
204
+ onDismissedRef.current = onDismissed;
205
+ useEffect(() => {
206
+ wanted.current = open;
207
+ if (open) sheet.current?.present();
208
+ else sheet.current?.dismiss();
209
+ }, [open]);
210
+ const BottomSheetModal = library.BottomSheetModal;
211
+ const BottomSheetView = library.BottomSheetView;
212
+ const BottomSheetBackdrop = library.BottomSheetBackdrop;
213
+ const onDismiss = useCallback(() => {
214
+ if (wanted.current) {
215
+ wanted.current = false;
216
+ onOpenChangeRef.current(false);
217
+ }
218
+ onDismissedRef.current?.();
219
+ }, []);
220
+ const backdrop = useCallback(
221
+ (p) => /* @__PURE__ */ jsx(
222
+ BottomSheetBackdrop,
223
+ {
224
+ ...p,
225
+ appearsOnIndex: 0,
226
+ disappearsOnIndex: -1,
227
+ pressBehavior: disableBackdropDismiss ? "none" : "close"
228
+ }
229
+ ),
230
+ [BottomSheetBackdrop, disableBackdropDismiss]
231
+ );
232
+ return /* @__PURE__ */ jsx(
233
+ BottomSheetModal,
234
+ {
235
+ ref: sheet,
236
+ snapPoints: fitContent ? void 0 : snapPoints,
237
+ index: fitContent ? 0 : initialSnapIndex,
238
+ enableDynamicSizing: fitContent,
239
+ ...fitContent ? { maxDynamicContentSize: Math.round(Dimensions.get("window").height * 0.9) } : {},
240
+ onDismiss,
241
+ enablePanDownToClose: !disableBackdropDismiss,
242
+ backdropComponent: backdrop,
243
+ children: /* @__PURE__ */ jsx(BottomSheetView, { testID: testID ?? "native-sheet", children })
244
+ }
245
+ );
246
+ }
247
+ function useReduceMotionAnswer() {
248
+ const [reduced, setReduced] = useState(null);
249
+ useEffect(() => {
250
+ let mounted = true;
251
+ AccessibilityInfo.isReduceMotionEnabled().then(
252
+ (value) => mounted && setReduced(value),
253
+ () => mounted && setReduced(false)
254
+ );
255
+ const sub = AccessibilityInfo.addEventListener("reduceMotionChanged", (value) => setReduced(value));
256
+ return () => {
257
+ mounted = false;
258
+ sub?.remove?.();
259
+ };
260
+ }, []);
261
+ return reduced;
262
+ }
263
+ function ModalSheet({ open, onOpenChange, disableBackdropDismiss = false, fitContent = false, onDismissed, testID, children }) {
264
+ const reducedMotion = useReduceMotionAnswer();
265
+ const roles = useThemeRoles();
266
+ const requestClose = () => {
267
+ if (!disableBackdropDismiss) onOpenChange(false);
268
+ };
269
+ const visible = open && reducedMotion !== null;
270
+ const animationType = reducedMotion ? "none" : "slide";
271
+ const id = testID ?? "native-sheet";
272
+ const ios = Platform.OS === "ios";
273
+ if (ios && !fitContent) {
274
+ return /* @__PURE__ */ jsx(
275
+ Modal,
276
+ {
277
+ visible,
278
+ animationType,
279
+ presentationStyle: "pageSheet",
280
+ allowSwipeDismissal: !disableBackdropDismiss,
281
+ backdropColor: roles.background,
282
+ onRequestClose: requestClose,
283
+ onDismiss: onDismissed,
284
+ children: /* @__PURE__ */ jsx(SafeAreaProvider, { children: /* @__PURE__ */ jsx(
285
+ SheetBody,
286
+ {
287
+ testID: id,
288
+ onAccessibilityEscape: disableBackdropDismiss ? void 0 : requestClose,
289
+ style: { flex: 1, backgroundColor: roles.background },
290
+ children
291
+ }
292
+ ) })
293
+ }
294
+ );
295
+ }
296
+ return /* @__PURE__ */ jsx(
297
+ Modal,
298
+ {
299
+ visible,
300
+ transparent: true,
301
+ animationType,
302
+ statusBarTranslucent: true,
303
+ navigationBarTranslucent: true,
304
+ onRequestClose: requestClose,
305
+ onDismiss: onDismissed,
306
+ children: /* @__PURE__ */ jsx(SafeAreaProvider, { children: /* @__PURE__ */ jsxs(KeyboardPanel, { ios, children: [
307
+ /* @__PURE__ */ jsx(
308
+ Pressable,
309
+ {
310
+ testID: `${id}-backdrop`,
311
+ accessibilityRole: "button",
312
+ accessibilityLabel: "Close",
313
+ disabled: disableBackdropDismiss,
314
+ importantForAccessibility: disableBackdropDismiss ? "no-hide-descendants" : "auto",
315
+ onPress: requestClose,
316
+ style: { position: "absolute", top: 0, right: 0, bottom: 0, left: 0, backgroundColor: "rgba(0,0,0,0.4)" }
317
+ }
318
+ ),
319
+ /* @__PURE__ */ jsxs(
320
+ SheetBody,
321
+ {
322
+ testID: id,
323
+ onAccessibilityEscape: disableBackdropDismiss ? void 0 : requestClose,
324
+ style: {
325
+ maxHeight: "90%",
326
+ borderTopLeftRadius: 28,
327
+ borderTopRightRadius: 28,
328
+ backgroundColor: roles.surface,
329
+ paddingTop: 12
330
+ },
331
+ children: [
332
+ /* @__PURE__ */ jsx(
333
+ View,
334
+ {
335
+ style: { alignSelf: "center", width: 32, height: 4, borderRadius: 2, marginBottom: 8, backgroundColor: roles.tertiaryLabel }
336
+ }
337
+ ),
338
+ children
339
+ ]
340
+ }
341
+ )
342
+ ] }) })
130
343
  }
131
344
  );
132
345
  }
133
- var EMPTY = Object.freeze({});
134
- var GenesisModulesContext = createContext(EMPTY);
135
- function GenesisModulesProvider({ modules, children }) {
136
- const outer = useContext(GenesisModulesContext);
137
- const value = useMemo(() => outer === EMPTY ? modules : { ...outer, ...modules }, [outer, modules]);
138
- return createElement(GenesisModulesContext.Provider, { value }, children);
346
+ function KeyboardPanel({ ios, children }) {
347
+ const insets = useSafeAreaInsets();
348
+ return /* @__PURE__ */ jsx(KeyboardAvoidingView, { behavior: ios ? "padding" : void 0, keyboardVerticalOffset: ios ? -insets.bottom : 0, style: { flex: 1, justifyContent: "flex-end" }, children });
139
349
  }
140
- function useGenesisModules() {
141
- return useContext(GenesisModulesContext);
350
+ function SheetBody({
351
+ testID,
352
+ style,
353
+ onAccessibilityEscape,
354
+ children
355
+ }) {
356
+ const insets = useSafeAreaInsets();
357
+ return /* @__PURE__ */ jsx(View, { testID, accessibilityViewIsModal: true, onAccessibilityEscape, style: { ...style, paddingBottom: insets.bottom }, children });
142
358
  }
143
359
  var defaults = {
144
360
  "first-run": { title: "Nothing here yet", tone: "text-muted-foreground" },
@@ -227,19 +443,19 @@ function NativeEmptyState({
227
443
 
228
444
  // src/icon-names.ts
229
445
  var SF_SYMBOLS = {
446
+ aperture: "camera.aperture",
230
447
  "arrow-left": "arrow.left",
231
448
  "arrow-up": "arrow.up",
232
- aperture: "camera.aperture",
233
449
  bell: "bell",
234
450
  calendar: "calendar",
235
451
  camera: "camera",
236
452
  "camera-flip": "arrow.triangle.2.circlepath.camera",
237
453
  check: "checkmark",
238
- clapperboard: "movieclapper",
239
454
  "chevron-down": "chevron.down",
240
455
  "chevron-left": "chevron.left",
241
456
  "chevron-right": "chevron.right",
242
457
  "chevron-up": "chevron.up",
458
+ clapperboard: "movieclapper",
243
459
  clock: "clock",
244
460
  close: "xmark",
245
461
  compose: "square.and.pencil",
@@ -249,13 +465,18 @@ var SF_SYMBOLS = {
249
465
  error: "xmark.circle",
250
466
  expand: "arrow.up.left.and.arrow.down.right",
251
467
  "external-link": "arrow.up.right.square",
468
+ eye: "eye",
252
469
  file: "doc",
253
470
  filter: "line.3.horizontal.decrease",
254
471
  "folder-plus": "folder.badge.plus",
472
+ grid: "square.grid.2x2",
473
+ grip: "line.3.horizontal",
255
474
  heart: "heart",
256
475
  home: "house",
257
476
  image: "photo",
258
477
  info: "info.circle",
478
+ link: "link",
479
+ list: "list.bullet",
259
480
  lock: "lock",
260
481
  "log-out": "rectangle.portrait.and.arrow.right",
261
482
  mail: "envelope",
@@ -271,6 +492,7 @@ var SF_SYMBOLS = {
271
492
  play: "play.fill",
272
493
  plus: "plus",
273
494
  radio: "dot.radiowaves.left.and.right",
495
+ redo: "arrow.uturn.forward",
274
496
  refresh: "arrow.clockwise",
275
497
  reply: "arrowshape.turn.up.left",
276
498
  search: "magnifyingglass",
@@ -278,10 +500,14 @@ var SF_SYMBOLS = {
278
500
  "settings-2": "slider.horizontal.3",
279
501
  share: "square.and.arrow.up",
280
502
  smile: "face.smiling",
503
+ sort: "arrow.up.arrow.down",
281
504
  star: "star",
282
505
  stop: "stop.fill",
283
506
  success: "checkmark.circle",
507
+ table: "tablecells",
284
508
  trash: "trash",
509
+ undo: "arrow.uturn.backward",
510
+ upload: "tray.and.arrow.up",
285
511
  user: "person",
286
512
  video: "video",
287
513
  volume: "speaker.wave.2.fill",
@@ -633,7 +859,91 @@ function NativeLoadingState({
633
859
  }
634
860
  );
635
861
  }
862
+ var IOS_DISMISS_FALLBACK_MS = 600;
863
+ function NativeContextMenu({ open, onOpenChange, actions, title, cancelLabel = "Cancel", testID = "context-menu" }) {
864
+ const colors = useThemeRoles();
865
+ const play = useHaptics();
866
+ const opened = useRef(false);
867
+ const tapped = useRef(null);
868
+ const ran = useRef(false);
869
+ const fallback = useRef(null);
870
+ useEffect(() => {
871
+ if (open && !opened.current) {
872
+ play("medium");
873
+ ran.current = false;
874
+ }
875
+ opened.current = open;
876
+ }, [open, play]);
877
+ const runTapped = () => {
878
+ if (fallback.current) clearTimeout(fallback.current);
879
+ fallback.current = null;
880
+ const action = tapped.current;
881
+ tapped.current = null;
882
+ action?.();
883
+ };
884
+ const run = (action) => {
885
+ if (ran.current) return;
886
+ ran.current = true;
887
+ tapped.current = action.onPress;
888
+ onOpenChange(false);
889
+ if (Platform.OS === "ios") fallback.current = setTimeout(runTapped, IOS_DISMISS_FALLBACK_MS);
890
+ else runTapped();
891
+ };
892
+ return /* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange, fitContent: true, onDismissed: runTapped, testID, children: /* @__PURE__ */ jsxs(View, { style: { paddingHorizontal: 16, paddingBottom: 8 }, children: [
893
+ title ? /* @__PURE__ */ jsx(NativeText, { testID: `${testID}-title`, accessibilityRole: "header", numberOfLines: 2, style: { paddingVertical: 8, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18, textAlign: "center" }, children: title }) : null,
894
+ actions.map((action) => /* @__PURE__ */ jsx(
895
+ Pressable,
896
+ {
897
+ testID: `${testID}-action-${action.id}`,
898
+ accessibilityRole: "button",
899
+ accessibilityLabel: action.label,
900
+ onPress: () => run(action),
901
+ style: { minHeight: 48, alignItems: "center", justifyContent: "center" },
902
+ children: /* @__PURE__ */ jsx(NativeText, { style: { color: action.destructive ? colors.destructive : colors.tint, fontSize: 17, lineHeight: 22 }, children: action.label })
903
+ },
904
+ action.id
905
+ )),
906
+ /* @__PURE__ */ jsx(Pressable, { testID: `${testID}-cancel`, accessibilityRole: "button", accessibilityLabel: cancelLabel, onPress: () => onOpenChange(false), style: { minHeight: 48, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(NativeText, { style: { color: colors.label, fontSize: 17, lineHeight: 22, fontWeight: "600" }, children: cancelLabel }) })
907
+ ] }) });
908
+ }
909
+ var ACTION_WIDTH = 80;
910
+ function NativeSwipeRow({ actions, children, testID = "swipe-row" }) {
911
+ const { swipeable: Swipeable } = useGenesisModules();
912
+ const colors = useThemeRoles();
913
+ const play = useHaptics();
914
+ const swipe = useRef(null);
915
+ if (!Swipeable || actions.length === 0) return /* @__PURE__ */ jsx(Fragment, { children });
916
+ const leading = actions.filter((a) => a.side === "leading");
917
+ const trailing = actions.filter((a) => a.side !== "leading");
918
+ const group = (list) => () => /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { flexDirection: "row" }, children: list.map((action) => /* @__PURE__ */ jsx(
919
+ Pressable,
920
+ {
921
+ testID: `${testID}-action-${action.id}`,
922
+ onPress: () => {
923
+ swipe.current?.close?.();
924
+ action.onPress();
925
+ },
926
+ style: { width: ACTION_WIDTH, alignItems: "center", justifyContent: "center", backgroundColor: action.destructive ? colors.destructive : colors.tint },
927
+ children: /* @__PURE__ */ jsx(NativeText, { className: action.destructive ? "text-destructive-foreground" : "text-primary-foreground", preset: "label", children: action.label })
928
+ },
929
+ action.id
930
+ )) });
931
+ return /* @__PURE__ */ jsx(
932
+ Swipeable,
933
+ {
934
+ ref: swipe,
935
+ testID,
936
+ friction: 2,
937
+ overshootLeft: false,
938
+ overshootRight: false,
939
+ onSwipeableWillOpen: () => play("medium"),
940
+ renderLeftActions: leading.length ? group(leading) : void 0,
941
+ renderRightActions: trailing.length ? group(trailing) : void 0,
942
+ children
943
+ }
944
+ );
945
+ }
636
946
 
637
- export { GenesisModulesProvider, NATIVE_ICON_NAMES, NativeBadge, NativeButton, NativeEmptyState, NativeIcon, NativeInput, NativeListItem, NativeListItemDivider, NativeLoadingState, NativeRefreshControl, NativeSectionListHeader, NativeSkeleton, NativeText, SF_SYMBOLS, badgeTextVariants, badgeVariants, buttonTextVariants, buttonVariants, textVariants, useGenesisModules };
638
- //# sourceMappingURL=chunk-6PGLX6ET.js.map
639
- //# sourceMappingURL=chunk-6PGLX6ET.js.map
947
+ export { NATIVE_ICON_NAMES, NativeBadge, NativeButton, NativeContextMenu, NativeEmptyState, NativeIcon, NativeInput, NativeListItem, NativeListItemDivider, NativeLoadingState, NativeRefreshControl, NativeSectionListHeader, NativeSheet, NativeSheetProvider, NativeSheetScrollView, NativeSkeleton, NativeSwipeRow, NativeText, SF_SYMBOLS, badgeTextVariants, badgeVariants, buttonTextVariants, buttonVariants, textVariants };
948
+ //# sourceMappingURL=chunk-FGIIBON3.js.map
949
+ //# sourceMappingURL=chunk-FGIIBON3.js.map