@fabricator-ui/react-native 0.0.0-stage → 0.10.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 (46) hide show
  1. package/README.md +8 -2
  2. package/dist/LICENSE.md +25 -0
  3. package/dist/NOTICE.md +24 -0
  4. package/dist/lib/data-variants.ts +23 -0
  5. package/dist/lib/density-scale.ts +208 -0
  6. package/dist/lib/fabricator/css-object.ts +2 -0
  7. package/dist/lib/fabricator/density-scale.ts +210 -0
  8. package/dist/lib/fabricator/density-variables.ts +37 -0
  9. package/dist/lib/fabricator/motion-speeds.ts +566 -0
  10. package/dist/lib/fabricator/radius.ts +240 -0
  11. package/dist/lib/feedback.ts +124 -0
  12. package/dist/lib/field-frame.ts +53 -0
  13. package/dist/lib/field-model.ts +112 -0
  14. package/dist/lib/fluid-hover-model.ts +142 -0
  15. package/dist/lib/fluid-hover.tsx +788 -0
  16. package/dist/lib/icon-stroke.ts +38 -0
  17. package/dist/lib/motion-tokens.ts +97 -0
  18. package/dist/lib/motion.ts +292 -0
  19. package/dist/lib/overlay-model.ts +205 -0
  20. package/dist/lib/press-wash.tsx +73 -0
  21. package/dist/lib/render.tsx +53 -0
  22. package/dist/lib/select-model.ts +87 -0
  23. package/dist/lib/sheet-model.ts +101 -0
  24. package/dist/lib/sheet-surface.tsx +429 -0
  25. package/dist/lib/sound-recipes.ts +449 -0
  26. package/dist/lib/spring-model.ts +214 -0
  27. package/dist/lib/surface-color.tsx +27 -0
  28. package/dist/lib/text-children.ts +43 -0
  29. package/dist/styles.css +610 -0
  30. package/dist/ui/badge.tsx +108 -0
  31. package/dist/ui/button.tsx +285 -0
  32. package/dist/ui/card.tsx +365 -0
  33. package/dist/ui/checkbox.tsx +230 -0
  34. package/dist/ui/collapsible.tsx +194 -0
  35. package/dist/ui/density.tsx +79 -0
  36. package/dist/ui/dialog.tsx +232 -0
  37. package/dist/ui/dropdown-menu.tsx +687 -0
  38. package/dist/ui/fabricator-root.tsx +68 -0
  39. package/dist/ui/input.tsx +63 -0
  40. package/dist/ui/label.tsx +22 -0
  41. package/dist/ui/select.tsx +616 -0
  42. package/dist/ui/switch.tsx +177 -0
  43. package/dist/ui/tabs.tsx +272 -0
  44. package/dist/ui/text.tsx +125 -0
  45. package/dist/ui/textarea.tsx +65 -0
  46. package/package.json +54 -4
@@ -0,0 +1,687 @@
1
+ import * as React from "react"
2
+ import {
3
+ CheckIcon,
4
+ ChevronRightIcon,
5
+ IconProvider,
6
+ } from "@fabricator-ui/icons-react-native"
7
+ import * as DropdownMenuPrimitive from "@rn-primitives/dropdown-menu"
8
+ import { useControllableState } from "@rn-primitives/hooks"
9
+ import { cva } from "class-variance-authority"
10
+ import { cn } from "cn"
11
+ import {
12
+ useWindowDimensions,
13
+ View,
14
+ type GestureResponderEvent,
15
+ } from "react-native"
16
+ import Animated, {
17
+ useAnimatedStyle,
18
+ useSharedValue,
19
+ withTiming,
20
+ } from "react-native-reanimated"
21
+ import { useSafeAreaInsets } from "react-native-safe-area-context"
22
+
23
+ import {
24
+ useFeedback,
25
+ useMountFeedback,
26
+ useSurfaceFeedback,
27
+ } from "../lib/feedback"
28
+ import {
29
+ FluidHoverScrollList,
30
+ useFluidRemeasure,
31
+ useFluidRow,
32
+ } from "../lib/fluid-hover"
33
+ import {
34
+ useChevronIcon,
35
+ useIconStroke,
36
+ } from "../lib/icon-stroke"
37
+ import { useMotion, useSurfaceAnimation } from "../lib/motion"
38
+ import {
39
+ COLLISION_INSETS,
40
+ getFittedSide,
41
+ getMenuAvailableSpace,
42
+ getMenuMaxHeight,
43
+ getMenuMinWidth,
44
+ getSafeInsets,
45
+ getVerticalSide,
46
+ useTriggerOpen,
47
+ } from "../lib/overlay-model"
48
+ import { resolveRender, type RenderProps } from "../lib/render"
49
+ import { DisclosurePanel } from "./collapsible"
50
+ import { DensityScope, useDensity } from "./density"
51
+ import { renderTextChildren, Text, TextStyle } from "./text"
52
+
53
+ type DropdownMenuTriggerRef =
54
+ React.RefObject<DropdownMenuPrimitive.TriggerRef | null>
55
+
56
+ const DropdownMenuContext = React.createContext<DropdownMenuTriggerRef | null>(
57
+ null
58
+ )
59
+ // A submenu expands inline, so a portal inside the content is already home.
60
+ const DropdownMenuInsideContext = React.createContext(false)
61
+ const DropdownMenuRadioContext = React.createContext<{
62
+ value: string | undefined
63
+ onValueChange: (value: string) => void
64
+ } | null>(null)
65
+
66
+ // Letting go over a row after a drag runs this too, with no press to pass on.
67
+ type DropdownMenuRowPress = (event?: GestureResponderEvent) => void
68
+
69
+ const dropdownMenuItemTextVariants = cva("text-muted-foreground text-(length:--density-text-13)", {
70
+ variants: {
71
+ variant: {
72
+ default: "",
73
+ destructive: "text-destructive-text",
74
+ },
75
+ },
76
+ defaultVariants: {
77
+ variant: "default",
78
+ },
79
+ })
80
+
81
+ /** Turns toward the rows it opens, on the disclosure timing. */
82
+ function SubmenuChevron({ isOpen }: { isOpen: boolean }) {
83
+ const chevron = useChevronIcon()
84
+ const motion = useMotion("disclosure")
85
+ const turn = useSharedValue(isOpen ? 1 : 0)
86
+ React.useEffect(() => {
87
+ turn.value = withTiming(isOpen ? 1 : 0, {
88
+ duration: motion.isReduced ? 0 : motion.enterMs,
89
+ easing: motion.enterEasing,
90
+ })
91
+ }, [isOpen, motion, turn])
92
+ const style = useAnimatedStyle(() => ({
93
+ transform: [{ rotate: `${turn.value * 90}deg` }],
94
+ }))
95
+ return (
96
+ <Animated.View style={style}>
97
+ <ChevronRightIcon {...chevron} />
98
+ </Animated.View>
99
+ )
100
+ }
101
+
102
+ /** What the primitive does when one of its rows closes the menu. */
103
+ function useCloseMenu() {
104
+ const { onOpenChange, setTriggerPosition, setContentLayout } =
105
+ DropdownMenuPrimitive.useRootContext()
106
+ return () => {
107
+ setTriggerPosition(null)
108
+ setContentLayout(null)
109
+ onOpenChange(false)
110
+ }
111
+ }
112
+
113
+ // The primitive's portal renders this only while the menu is open.
114
+ function DropdownMenuFeedback() {
115
+ useMountFeedback("popup")
116
+ return null
117
+ }
118
+
119
+ function DropdownMenu({
120
+ open,
121
+ defaultOpen,
122
+ onOpenChange,
123
+ ...props
124
+ }: Omit<DropdownMenuPrimitive.RootProps, "onOpenChange"> & {
125
+ open?: boolean
126
+ defaultOpen?: boolean
127
+ onOpenChange?: (open: boolean) => void
128
+ }) {
129
+ const trigger = useTriggerOpen<DropdownMenuPrimitive.TriggerRef>({
130
+ open,
131
+ defaultOpen,
132
+ onOpenChange,
133
+ })
134
+ return (
135
+ <DropdownMenuContext value={trigger.triggerRef}>
136
+ <DropdownMenuPrimitive.Root
137
+ data-slot="dropdown-menu"
138
+ onOpenChange={trigger.onOpenChange}
139
+ {...props}
140
+ />
141
+ </DropdownMenuContext>
142
+ )
143
+ }
144
+
145
+ function DropdownMenuPortal({
146
+ children,
147
+ ...props
148
+ }: DropdownMenuPrimitive.PortalProps) {
149
+ const isInside = React.use(DropdownMenuInsideContext)
150
+ if (isInside) return children
151
+ return (
152
+ <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props}>
153
+ {children}
154
+ </DropdownMenuPrimitive.Portal>
155
+ )
156
+ }
157
+
158
+ function DropdownMenuTrigger({
159
+ render,
160
+ asChild,
161
+ children,
162
+ ...props
163
+ }: Omit<DropdownMenuPrimitive.TriggerProps, "children"> &
164
+ RenderProps & { children?: React.ReactNode }) {
165
+ const triggerRef = React.use(DropdownMenuContext)
166
+ const resolved = resolveRender({ render, asChild, children })
167
+ return (
168
+ <DropdownMenuPrimitive.Trigger
169
+ ref={triggerRef}
170
+ data-slot="dropdown-menu-trigger"
171
+ {...props}
172
+ asChild={resolved.asChild}
173
+ >
174
+ {resolved.asChild
175
+ ? resolved.children
176
+ : renderTextChildren(resolved.children)}
177
+ </DropdownMenuPrimitive.Trigger>
178
+ )
179
+ }
180
+
181
+ function DropdownMenuContent({
182
+ align = "start",
183
+ alignOffset = 0,
184
+ side = "bottom",
185
+ sideOffset = 4,
186
+ insets = COLLISION_INSETS,
187
+ className,
188
+ children,
189
+ onLayout,
190
+ ...props
191
+ }: Omit<DropdownMenuPrimitive.ContentProps, "side" | "children"> & {
192
+ side?: "top" | "right" | "bottom" | "left"
193
+ children?: React.ReactNode
194
+ }) {
195
+ const density = useDensity()
196
+ const { width, height } = useWindowDimensions()
197
+ const safeArea = useSafeAreaInsets()
198
+ const { triggerPosition } = DropdownMenuPrimitive.useRootContext()
199
+ const [contentHeight, setContentHeight] = React.useState<number | null>(null)
200
+ const fittedInsets = getSafeInsets(insets, safeArea)
201
+ const verticalSide = getFittedSide({
202
+ side: getVerticalSide(side),
203
+ triggerY: triggerPosition?.pageY,
204
+ triggerHeight: triggerPosition?.height,
205
+ contentHeight,
206
+ offset: sideOffset,
207
+ windowHeight: height,
208
+ insets: fittedInsets,
209
+ })
210
+ const maxHeight = getMenuMaxHeight(
211
+ height,
212
+ width,
213
+ getMenuAvailableSpace({
214
+ side: verticalSide,
215
+ triggerY: triggerPosition?.pageY,
216
+ triggerHeight: triggerPosition?.height,
217
+ offset: sideOffset,
218
+ windowHeight: height,
219
+ insets: fittedInsets,
220
+ })
221
+ )
222
+ const { entering, exiting, origin } = useSurfaceAnimation("popup", {
223
+ side: verticalSide,
224
+ align,
225
+ })
226
+ return (
227
+ <DropdownMenuPortal>
228
+ <DensityScope density={density}>
229
+ <DropdownMenuPrimitive.Overlay aria-modal className={"fab:absolute fab:inset-0"}>
230
+ <DropdownMenuPrimitive.Content
231
+ align={align}
232
+ alignOffset={alignOffset}
233
+ side={verticalSide}
234
+ sideOffset={sideOffset}
235
+ insets={fittedInsets}
236
+ {...props}
237
+ onLayout={(event) => {
238
+ setContentHeight(event.nativeEvent.layout.height)
239
+ onLayout?.(event)
240
+ }}
241
+ >
242
+ <Animated.View
243
+ data-slot="dropdown-menu-content"
244
+ entering={entering}
245
+ exiting={exiting}
246
+ style={[
247
+ origin,
248
+ { minWidth: getMenuMinWidth(triggerPosition?.width, width) },
249
+ ]}
250
+ className={cn(
251
+ "bg-surface-3 shadow-surface-3 rounded-(--radius-surface) p-1 corner-curve min-w-32",
252
+ className
253
+ )}
254
+ >
255
+ <DropdownMenuFeedback />
256
+ <DropdownMenuInsideContext value={true}>
257
+ <TextStyle className={"fab:text-popover-foreground fab:text-(length:--density-text-13)"}>
258
+ <FluidHoverScrollList style={{ maxHeight }}>
259
+ {renderTextChildren(children)}
260
+ </FluidHoverScrollList>
261
+ </TextStyle>
262
+ </DropdownMenuInsideContext>
263
+ </Animated.View>
264
+ </DropdownMenuPrimitive.Content>
265
+ </DropdownMenuPrimitive.Overlay>
266
+ </DensityScope>
267
+ </DropdownMenuPortal>
268
+ )
269
+ }
270
+
271
+ function DropdownMenuGroup(props: DropdownMenuPrimitive.GroupProps) {
272
+ return (
273
+ <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
274
+ )
275
+ }
276
+
277
+ function DropdownMenuLabel({
278
+ className,
279
+ inset,
280
+ ...props
281
+ }: React.ComponentProps<typeof Text> & {
282
+ inset?: boolean
283
+ }) {
284
+ return (
285
+ <Text
286
+ data-slot="dropdown-menu-label"
287
+ data-inset={inset}
288
+ className={cn("text-muted-foreground px-(--density-8) py-(--density-6) text-(length:--density-text-12) font-normal data-[inset=true]:pl-[calc(var(--density-8)*2+var(--density-icon-16))]", className)}
289
+ {...props}
290
+ />
291
+ )
292
+ }
293
+
294
+ function DropdownMenuItem({
295
+ className,
296
+ inset,
297
+ variant = "default",
298
+ closeOnClick = true,
299
+ render,
300
+ asChild,
301
+ children,
302
+ onPress,
303
+ ...props
304
+ }: Omit<DropdownMenuPrimitive.ItemProps, "children" | "onPress"> &
305
+ RenderProps & {
306
+ inset?: boolean
307
+ variant?: "default" | "destructive"
308
+ closeOnClick?: boolean
309
+ onPress?: DropdownMenuRowPress
310
+ children?: React.ReactNode
311
+ }) {
312
+ const resolved = resolveRender({ render, asChild, children })
313
+ const feedback = useFeedback()
314
+ const closeMenu = useCloseMenu()
315
+ const { isLit, rowProps } = useFluidRow({
316
+ ...props,
317
+ onActivate: () => {
318
+ feedback("tick")
319
+ if (closeOnClick) closeMenu()
320
+ onPress?.()
321
+ },
322
+ })
323
+ return (
324
+ // A destructive row stays destructive under the highlight.
325
+ <TextStyle
326
+ eases
327
+ className={
328
+ isLit && variant === "default"
329
+ ? cn("text-foreground text-(length:--density-text-13)")
330
+ : dropdownMenuItemTextVariants({ variant })
331
+ }
332
+ >
333
+ <IconProvider strokeWidth={useIconStroke(isLit)}>
334
+ <DropdownMenuPrimitive.Item
335
+ data-slot="dropdown-menu-item"
336
+ data-inset={inset}
337
+ data-variant={variant}
338
+ closeOnPress={closeOnClick}
339
+ className={cn(
340
+ "h-(--density-36) gap-(--density-8) rounded-(--radius-nested) px-(--density-8) data-[inset=true]:pl-[calc(var(--density-8)*2+var(--density-icon-16))] corner-curve relative flex-row items-center disabled:opacity-50",
341
+ className
342
+ )}
343
+ onPress={(event) => {
344
+ feedback("tick")
345
+ onPress?.(event)
346
+ }}
347
+ {...props}
348
+ {...rowProps}
349
+ asChild={resolved.asChild}
350
+ >
351
+ {resolved.asChild
352
+ ? resolved.children
353
+ : renderTextChildren(resolved.children)}
354
+ </DropdownMenuPrimitive.Item>
355
+ </IconProvider>
356
+ </TextStyle>
357
+ )
358
+ }
359
+
360
+ function DropdownMenuSub(props: DropdownMenuPrimitive.SubProps) {
361
+ return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
362
+ }
363
+
364
+ function DropdownMenuSubTrigger({
365
+ className,
366
+ inset,
367
+ children,
368
+ onPress,
369
+ ...props
370
+ }: Omit<DropdownMenuPrimitive.SubTriggerProps, "children" | "onPress"> & {
371
+ inset?: boolean
372
+ onPress?: DropdownMenuRowPress
373
+ children?: React.ReactNode
374
+ }) {
375
+ const { open, onOpenChange } = DropdownMenuPrimitive.useSubContext()
376
+ // Silent, like every trigger: the submenu sounds as it opens.
377
+ const { isLit, rowProps } = useFluidRow({
378
+ ...props,
379
+ onActivate: () => {
380
+ onOpenChange(!open)
381
+ onPress?.()
382
+ },
383
+ })
384
+ return (
385
+ <TextStyle
386
+ eases
387
+ className={
388
+ isLit || open
389
+ ? cn("text-foreground text-(length:--density-text-13)")
390
+ : dropdownMenuItemTextVariants()
391
+ }
392
+ >
393
+ <IconProvider strokeWidth={useIconStroke(isLit)}>
394
+ <DropdownMenuPrimitive.SubTrigger
395
+ data-slot="dropdown-menu-sub-trigger"
396
+ data-inset={inset}
397
+ data-state={open ? "open" : "closed"}
398
+ data-lit={isLit}
399
+ className={cn(
400
+ "h-(--density-36) gap-(--density-8) rounded-(--radius-nested) px-(--density-8) data-[inset=true]:pl-[calc(var(--density-8)*2+var(--density-icon-16))] data-[state=open]:data-[lit=false]:bg-hover corner-curve flex-row items-center disabled:opacity-50",
401
+ className
402
+ )}
403
+ onPress={onPress}
404
+ {...props}
405
+ {...rowProps}
406
+ >
407
+ {renderTextChildren(children)}
408
+ <View className={"fab:ml-auto"}>
409
+ <SubmenuChevron isOpen={open} />
410
+ </View>
411
+ </DropdownMenuPrimitive.SubTrigger>
412
+ </IconProvider>
413
+ </TextStyle>
414
+ )
415
+ }
416
+
417
+ function DropdownMenuSubContent({
418
+ align: _align,
419
+ alignOffset: _alignOffset,
420
+ side: _side,
421
+ sideOffset: _sideOffset,
422
+ className,
423
+ children,
424
+ ...props
425
+ }: Omit<DropdownMenuPrimitive.SubContentProps, "children"> &
426
+ Pick<
427
+ React.ComponentProps<typeof DropdownMenuContent>,
428
+ "align" | "alignOffset" | "side" | "sideOffset"
429
+ > & { children?: React.ReactNode }) {
430
+ const { open } = DropdownMenuPrimitive.useSubContext()
431
+ const remeasure = useFluidRemeasure()
432
+ useSurfaceFeedback("popup", open)
433
+ // Inline on a phone: the rows open like a disclosure, and those below follow.
434
+ return (
435
+ <DisclosurePanel isOpen={open} onLayout={() => remeasure?.()}>
436
+ <DropdownMenuPrimitive.SubContent
437
+ forceMount
438
+ data-slot="dropdown-menu-sub-content"
439
+ className={cn("border-border/60 my-1 ml-(--density-8) border-l pl-1", className)}
440
+ {...props}
441
+ >
442
+ {renderTextChildren(children)}
443
+ </DropdownMenuPrimitive.SubContent>
444
+ </DisclosurePanel>
445
+ )
446
+ }
447
+
448
+ // A chosen row reads foreground and semibold; a lit one foreground, with a heavier icon.
449
+ function DropdownMenuChoiceText({
450
+ isChecked,
451
+ isLit,
452
+ children,
453
+ }: {
454
+ isChecked: boolean
455
+ isLit: boolean
456
+ children?: React.ReactNode
457
+ }) {
458
+ return (
459
+ <TextStyle
460
+ eases
461
+ className={
462
+ isChecked
463
+ ? cn(
464
+ "text-(length:--density-text-13) text-foreground font-semibold"
465
+ )
466
+ : isLit
467
+ ? cn(
468
+ "text-(length:--density-text-13) text-foreground"
469
+ )
470
+ : cn("text-muted-foreground text-(length:--density-text-13)")
471
+ }
472
+ >
473
+ <IconProvider strokeWidth={useIconStroke(isLit)}>{children}</IconProvider>
474
+ </TextStyle>
475
+ )
476
+ }
477
+
478
+ function DropdownMenuCheckboxItem({
479
+ className,
480
+ children,
481
+ checked,
482
+ defaultChecked = false,
483
+ onCheckedChange,
484
+ inset,
485
+ closeOnClick = false,
486
+ onPress,
487
+ ...props
488
+ }: Omit<
489
+ DropdownMenuPrimitive.CheckboxItemProps,
490
+ "children" | "checked" | "onCheckedChange" | "onPress"
491
+ > & {
492
+ checked?: boolean
493
+ defaultChecked?: boolean
494
+ onCheckedChange?: (checked: boolean) => void
495
+ inset?: boolean
496
+ closeOnClick?: boolean
497
+ onPress?: DropdownMenuRowPress
498
+ children?: React.ReactNode
499
+ }) {
500
+ const [isChecked = false, setIsChecked] = useControllableState({
501
+ prop: checked,
502
+ defaultProp: defaultChecked,
503
+ onChange: onCheckedChange,
504
+ })
505
+ const feedback = useFeedback()
506
+ const closeMenu = useCloseMenu()
507
+ const { isLit, rowProps } = useFluidRow({
508
+ ...props,
509
+ onActivate: () => {
510
+ feedback(isChecked ? "uncheck" : "check")
511
+ setIsChecked(!isChecked)
512
+ if (closeOnClick) closeMenu()
513
+ onPress?.()
514
+ },
515
+ })
516
+ return (
517
+ <DropdownMenuChoiceText isChecked={isChecked} isLit={isLit}>
518
+ <DropdownMenuPrimitive.CheckboxItem
519
+ data-slot="dropdown-menu-checkbox-item"
520
+ data-inset={inset}
521
+ data-checked={isChecked}
522
+ checked={isChecked}
523
+ onCheckedChange={setIsChecked}
524
+ closeOnPress={closeOnClick}
525
+ className={cn(
526
+ "h-(--density-36) gap-(--density-8) rounded-(--radius-nested) py-0 pr-[calc(var(--density-8)*2+var(--density-icon-16))] pl-(--density-8) data-[inset=true]:pl-[calc(var(--density-8)*2+var(--density-icon-16))] corner-curve relative flex-row items-center disabled:opacity-50",
527
+ className
528
+ )}
529
+ onPress={(event) => {
530
+ feedback(isChecked ? "uncheck" : "check")
531
+ onPress?.(event)
532
+ }}
533
+ {...props}
534
+ {...rowProps}
535
+ >
536
+ <View
537
+ data-slot="dropdown-menu-checkbox-item-indicator"
538
+ pointerEvents="none"
539
+ className={"fab:right-(--density-8) fab:absolute fab:items-center fab:justify-center"}
540
+ >
541
+ <TextStyle className={"fab:text-foreground"}>
542
+ <DropdownMenuPrimitive.ItemIndicator>
543
+ <CheckIcon />
544
+ </DropdownMenuPrimitive.ItemIndicator>
545
+ </TextStyle>
546
+ </View>
547
+ {renderTextChildren(children)}
548
+ </DropdownMenuPrimitive.CheckboxItem>
549
+ </DropdownMenuChoiceText>
550
+ )
551
+ }
552
+
553
+ function DropdownMenuRadioGroup({
554
+ value,
555
+ defaultValue,
556
+ onValueChange,
557
+ ...props
558
+ }: Omit<DropdownMenuPrimitive.RadioGroupProps, "value" | "onValueChange"> & {
559
+ value?: string
560
+ defaultValue?: string
561
+ onValueChange?: (value: string) => void
562
+ }) {
563
+ const [current, setCurrent] = useControllableState({
564
+ prop: value,
565
+ defaultProp: defaultValue,
566
+ onChange: onValueChange,
567
+ })
568
+ return (
569
+ <DropdownMenuRadioContext
570
+ value={{ value: current, onValueChange: setCurrent }}
571
+ >
572
+ <DropdownMenuPrimitive.RadioGroup
573
+ data-slot="dropdown-menu-radio-group"
574
+ value={current}
575
+ onValueChange={setCurrent}
576
+ {...props}
577
+ />
578
+ </DropdownMenuRadioContext>
579
+ )
580
+ }
581
+
582
+ function DropdownMenuRadioItem({
583
+ className,
584
+ children,
585
+ inset,
586
+ value,
587
+ closeOnClick = false,
588
+ onPress,
589
+ ...props
590
+ }: Omit<DropdownMenuPrimitive.RadioItemProps, "children" | "onPress"> & {
591
+ inset?: boolean
592
+ closeOnClick?: boolean
593
+ onPress?: DropdownMenuRowPress
594
+ children?: React.ReactNode
595
+ }) {
596
+ const radio = React.use(DropdownMenuRadioContext)
597
+ const isChecked = radio?.value === value
598
+ const feedback = useFeedback()
599
+ const closeMenu = useCloseMenu()
600
+ const { isLit, rowProps } = useFluidRow({
601
+ ...props,
602
+ onActivate: () => {
603
+ feedback("pick")
604
+ radio?.onValueChange(value)
605
+ if (closeOnClick) closeMenu()
606
+ onPress?.()
607
+ },
608
+ })
609
+ return (
610
+ <DropdownMenuChoiceText isChecked={isChecked} isLit={isLit}>
611
+ <DropdownMenuPrimitive.RadioItem
612
+ data-slot="dropdown-menu-radio-item"
613
+ data-inset={inset}
614
+ data-checked={isChecked}
615
+ value={value}
616
+ closeOnPress={closeOnClick}
617
+ className={cn(
618
+ "h-(--density-36) gap-(--density-8) rounded-(--radius-nested) py-0 pr-[calc(var(--density-8)*2+var(--density-icon-16))] pl-(--density-8) data-[inset=true]:pl-[calc(var(--density-8)*2+var(--density-icon-16))] corner-curve relative flex-row items-center disabled:opacity-50",
619
+ className
620
+ )}
621
+ onPress={(event) => {
622
+ feedback("pick")
623
+ onPress?.(event)
624
+ }}
625
+ {...props}
626
+ {...rowProps}
627
+ >
628
+ <View
629
+ data-slot="dropdown-menu-radio-item-indicator"
630
+ pointerEvents="none"
631
+ className={"fab:right-(--density-8) fab:absolute fab:items-center fab:justify-center"}
632
+ >
633
+ <TextStyle className={"fab:text-foreground"}>
634
+ <DropdownMenuPrimitive.ItemIndicator>
635
+ <CheckIcon />
636
+ </DropdownMenuPrimitive.ItemIndicator>
637
+ </TextStyle>
638
+ </View>
639
+ {renderTextChildren(children)}
640
+ </DropdownMenuPrimitive.RadioItem>
641
+ </DropdownMenuChoiceText>
642
+ )
643
+ }
644
+
645
+ function DropdownMenuSeparator({
646
+ className,
647
+ ...props
648
+ }: DropdownMenuPrimitive.SeparatorProps) {
649
+ return (
650
+ <DropdownMenuPrimitive.Separator
651
+ data-slot="dropdown-menu-separator"
652
+ className={cn("bg-border/60 -mx-1 my-1 h-px", className)}
653
+ {...props}
654
+ />
655
+ )
656
+ }
657
+
658
+ function DropdownMenuShortcut({
659
+ className,
660
+ ...props
661
+ }: React.ComponentProps<typeof Text>) {
662
+ return (
663
+ <Text
664
+ data-slot="dropdown-menu-shortcut"
665
+ className={cn("hidden sm:flex text-muted-foreground ml-auto text-(length:--density-text-11) tracking-normal", className)}
666
+ {...props}
667
+ />
668
+ )
669
+ }
670
+
671
+ export {
672
+ DropdownMenu,
673
+ DropdownMenuCheckboxItem,
674
+ DropdownMenuContent,
675
+ DropdownMenuGroup,
676
+ DropdownMenuItem,
677
+ DropdownMenuLabel,
678
+ DropdownMenuPortal,
679
+ DropdownMenuRadioGroup,
680
+ DropdownMenuRadioItem,
681
+ DropdownMenuSeparator,
682
+ DropdownMenuShortcut,
683
+ DropdownMenuSub,
684
+ DropdownMenuSubContent,
685
+ DropdownMenuSubTrigger,
686
+ DropdownMenuTrigger,
687
+ }