@react-native-reusables/cli 0.0.9 → 0.0.10

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 (136) hide show
  1. package/dist/generated/components/primitives/accordion/accordion.tsx +216 -0
  2. package/dist/generated/components/primitives/accordion/accordion.web.tsx +295 -0
  3. package/dist/generated/components/primitives/accordion/index.ts +1 -0
  4. package/dist/generated/components/primitives/accordion/types.ts +45 -0
  5. package/dist/generated/components/primitives/alert-dialog/alert-dialog.tsx +237 -0
  6. package/dist/generated/components/primitives/alert-dialog/alert-dialog.web.tsx +256 -0
  7. package/dist/generated/components/primitives/alert-dialog/index.ts +1 -0
  8. package/dist/generated/components/primitives/alert-dialog/types.ts +48 -0
  9. package/dist/generated/components/primitives/aspect-ratio.tsx +23 -0
  10. package/dist/generated/components/primitives/avatar/ types.ts +10 -0
  11. package/dist/generated/components/primitives/avatar/index.tsx +95 -0
  12. package/dist/generated/components/primitives/checkbox/checkbox.tsx +101 -0
  13. package/dist/generated/components/primitives/checkbox/checkbox.web.tsx +114 -0
  14. package/dist/generated/components/primitives/checkbox/index.ts +1 -0
  15. package/dist/generated/components/primitives/checkbox/types.ts +11 -0
  16. package/dist/generated/components/primitives/collapsible/collapsible.tsx +119 -0
  17. package/dist/generated/components/primitives/collapsible/collapsible.web.tsx +157 -0
  18. package/dist/generated/components/primitives/collapsible/index.ts +1 -0
  19. package/dist/generated/components/primitives/collapsible/types.ts +18 -0
  20. package/dist/generated/components/primitives/context-menu/context-menu.tsx +626 -0
  21. package/dist/generated/components/primitives/context-menu/context-menu.web.tsx +504 -0
  22. package/dist/generated/components/primitives/context-menu/index.ts +1 -0
  23. package/dist/generated/components/primitives/context-menu/types.ts +82 -0
  24. package/dist/generated/components/primitives/dialog/dialog.tsx +211 -0
  25. package/dist/generated/components/primitives/dialog/dialog.web.tsx +197 -0
  26. package/dist/generated/components/primitives/dialog/index.ts +1 -0
  27. package/dist/generated/components/primitives/dialog/types.ts +60 -0
  28. package/dist/generated/components/primitives/dropdown-menu/dropdown-menu.tsx +584 -0
  29. package/dist/generated/components/primitives/dropdown-menu/dropdown-menu.web.tsx +521 -0
  30. package/dist/generated/components/primitives/dropdown-menu/index.ts +1 -0
  31. package/dist/generated/components/primitives/dropdown-menu/types.ts +71 -0
  32. package/dist/generated/components/primitives/hooks/index.ts +3 -0
  33. package/dist/generated/components/primitives/hooks/useAugmentedRef.tsx +29 -0
  34. package/dist/generated/components/primitives/hooks/useControllableState.tsx +75 -0
  35. package/dist/generated/components/primitives/hooks/useRelativePosition.tsx +227 -0
  36. package/dist/generated/components/primitives/hover-card/hover-card.tsx +271 -0
  37. package/dist/generated/components/primitives/hover-card/hover-card.web.tsx +145 -0
  38. package/dist/generated/components/primitives/hover-card/index.ts +1 -0
  39. package/dist/generated/components/primitives/hover-card/types.ts +42 -0
  40. package/dist/generated/components/primitives/label/index.ts +1 -0
  41. package/dist/generated/components/primitives/label/label.tsx +31 -0
  42. package/dist/generated/components/primitives/label/label.web.tsx +36 -0
  43. package/dist/generated/components/primitives/label/types.ts +15 -0
  44. package/dist/generated/components/primitives/menubar/index.ts +1 -0
  45. package/dist/generated/components/primitives/menubar/menubar.tsx +624 -0
  46. package/dist/generated/components/primitives/menubar/menubar.web.tsx +543 -0
  47. package/dist/generated/components/primitives/menubar/types.ts +76 -0
  48. package/dist/generated/components/primitives/navigation-menu/index.ts +1 -0
  49. package/dist/generated/components/primitives/navigation-menu/navigation-menu.tsx +315 -0
  50. package/dist/generated/components/primitives/navigation-menu/navigation-menu.web.tsx +264 -0
  51. package/dist/generated/components/primitives/navigation-menu/types.ts +49 -0
  52. package/dist/generated/components/primitives/popover/index.ts +1 -0
  53. package/dist/generated/components/primitives/popover/popover.tsx +286 -0
  54. package/dist/generated/components/primitives/popover/popover.web.tsx +179 -0
  55. package/dist/generated/components/primitives/popover/types.ts +30 -0
  56. package/dist/generated/components/primitives/portal.tsx +67 -0
  57. package/dist/generated/components/primitives/progress/index.ts +1 -0
  58. package/dist/generated/components/primitives/progress/progress.tsx +59 -0
  59. package/dist/generated/components/primitives/progress/progress.web.tsx +36 -0
  60. package/dist/generated/components/primitives/progress/types.ts +7 -0
  61. package/dist/generated/components/primitives/radio-group/index.ts +1 -0
  62. package/dist/generated/components/primitives/radio-group/radio-group.tsx +116 -0
  63. package/dist/generated/components/primitives/radio-group/radio-group.web.tsx +78 -0
  64. package/dist/generated/components/primitives/radio-group/types.ts +15 -0
  65. package/dist/generated/components/primitives/select/index.ts +1 -0
  66. package/dist/generated/components/primitives/select/select.tsx +455 -0
  67. package/dist/generated/components/primitives/select/select.web.tsx +319 -0
  68. package/dist/generated/components/primitives/select/types.ts +87 -0
  69. package/dist/generated/components/primitives/separator/ types.ts +6 -0
  70. package/dist/generated/components/primitives/separator/index.tsx +23 -0
  71. package/dist/generated/components/primitives/slider/index.ts +1 -0
  72. package/dist/generated/components/primitives/slider/slider.tsx +89 -0
  73. package/dist/generated/components/primitives/slider/slider.web.tsx +67 -0
  74. package/dist/generated/components/primitives/slider/types.ts +24 -0
  75. package/dist/generated/components/primitives/slot.tsx +187 -0
  76. package/dist/generated/components/primitives/switch/index.ts +1 -0
  77. package/dist/generated/components/primitives/switch/switch.tsx +65 -0
  78. package/dist/generated/components/primitives/switch/switch.web.tsx +67 -0
  79. package/dist/generated/components/primitives/switch/types.ts +11 -0
  80. package/dist/generated/components/primitives/table.tsx +55 -0
  81. package/dist/generated/components/primitives/tabs/index.ts +1 -0
  82. package/dist/generated/components/primitives/tabs/tabs.tsx +133 -0
  83. package/dist/generated/components/primitives/tabs/tabs.web.tsx +97 -0
  84. package/dist/generated/components/primitives/tabs/types.ts +24 -0
  85. package/dist/generated/components/primitives/toast/ types.ts +7 -0
  86. package/dist/generated/components/primitives/toast/index.tsx +128 -0
  87. package/dist/generated/components/primitives/toggle/index.ts +1 -0
  88. package/dist/generated/components/primitives/toggle/toggle.tsx +37 -0
  89. package/dist/generated/components/primitives/toggle/toggle.web.tsx +26 -0
  90. package/dist/generated/components/primitives/toggle/types.ts +7 -0
  91. package/dist/generated/components/primitives/toggle-group/index.ts +1 -0
  92. package/dist/generated/components/primitives/toggle-group/toggle-group.tsx +125 -0
  93. package/dist/generated/components/primitives/toggle-group/toggle-group.web.tsx +124 -0
  94. package/dist/generated/components/primitives/toggle-group/types.ts +37 -0
  95. package/dist/generated/components/primitives/toolbar/index.ts +1 -0
  96. package/dist/generated/components/primitives/toolbar/toolbar.tsx +125 -0
  97. package/dist/generated/components/primitives/toolbar/toolbar.web.tsx +129 -0
  98. package/dist/generated/components/primitives/toolbar/types.ts +39 -0
  99. package/dist/generated/components/primitives/tooltip/index.ts +1 -0
  100. package/dist/generated/components/primitives/tooltip/tooltip.tsx +271 -0
  101. package/dist/generated/components/primitives/tooltip/tooltip.web.tsx +167 -0
  102. package/dist/generated/components/primitives/tooltip/types.ts +44 -0
  103. package/dist/generated/components/primitives/types.ts +105 -0
  104. package/dist/generated/components/primitives/utils.ts +61 -0
  105. package/dist/generated/components/ui/accordion.tsx +127 -0
  106. package/dist/generated/components/ui/alert-dialog.tsx +167 -0
  107. package/dist/generated/components/ui/aspect-ratio.tsx +5 -0
  108. package/dist/generated/components/ui/avatar.tsx +44 -0
  109. package/dist/generated/components/ui/badge.tsx +51 -0
  110. package/dist/generated/components/ui/button.tsx +88 -0
  111. package/dist/generated/components/ui/card.tsx +67 -0
  112. package/dist/generated/components/ui/checkbox.tsx +34 -0
  113. package/dist/generated/components/ui/collapsible.tsx +9 -0
  114. package/dist/generated/components/ui/context-menu.tsx +244 -0
  115. package/dist/generated/components/ui/dialog.tsx +150 -0
  116. package/dist/generated/components/ui/dropdown-menu.tsx +244 -0
  117. package/dist/generated/components/ui/hover-card.tsx +45 -0
  118. package/dist/generated/components/ui/input.tsx +26 -0
  119. package/dist/generated/components/ui/label.tsx +28 -0
  120. package/dist/generated/components/ui/menubar.tsx +260 -0
  121. package/dist/generated/components/ui/navigation-menu.tsx +177 -0
  122. package/dist/generated/components/ui/popover.tsx +39 -0
  123. package/dist/generated/components/ui/radio-group.tsx +38 -0
  124. package/dist/generated/components/ui/select.tsx +181 -0
  125. package/dist/generated/components/ui/separator.tsx +23 -0
  126. package/dist/generated/components/ui/skeleton.tsx +39 -0
  127. package/dist/generated/components/ui/switch.tsx +97 -0
  128. package/dist/generated/components/ui/table.tsx +99 -0
  129. package/dist/generated/components/ui/tabs.tsx +65 -0
  130. package/dist/generated/components/ui/text.tsx +24 -0
  131. package/dist/generated/components/ui/textarea.tsx +28 -0
  132. package/dist/generated/components/ui/toggle-group.tsx +86 -0
  133. package/dist/generated/components/ui/toggle.tsx +85 -0
  134. package/dist/generated/components/ui/tooltip.tsx +36 -0
  135. package/dist/generated/components/ui/typography.tsx +204 -0
  136. package/package.json +8 -8
@@ -0,0 +1,504 @@
1
+ import * as ContextMenu from '@radix-ui/react-context-menu';
2
+ import * as React from 'react';
3
+ import { GestureResponderEvent, Pressable, Text, View } from 'react-native';
4
+ import * as Slot from '@rnr/slot';
5
+ import { useAugmentedRef } from '@rnr/hooks';
6
+ import type {
7
+ ForceMountable,
8
+ PositionedContentProps,
9
+ PressableRef,
10
+ SlottablePressableProps,
11
+ SlottableTextProps,
12
+ SlottableViewProps,
13
+ TextRef,
14
+ ViewRef,
15
+ } from '@rnr/types';
16
+ import type {
17
+ ContextMenuCheckboxItemProps,
18
+ ContextMenuItemProps,
19
+ ContextMenuOverlayProps,
20
+ ContextMenuPortalProps,
21
+ ContextMenuRadioGroupProps,
22
+ ContextMenuRadioItemProps,
23
+ ContextMenuRootProps,
24
+ ContextMenuSeparatorProps,
25
+ ContextMenuSubProps,
26
+ ContextMenuSubTriggerProps,
27
+ } from './types';
28
+ import { EmptyGestureResponderEvent } from '@rnr/utils';
29
+
30
+ const ContextMenuContext = React.createContext<ContextMenuRootProps | null>(null);
31
+
32
+ const Root = React.forwardRef<ViewRef, SlottableViewProps & ContextMenuRootProps>(
33
+ ({ asChild, open, onOpenChange, ...viewProps }, ref) => {
34
+ const Component = asChild ? Slot.View : View;
35
+ return (
36
+ <ContextMenuContext.Provider value={{ open, onOpenChange }}>
37
+ <ContextMenu.Root onOpenChange={onOpenChange}>
38
+ <Component ref={ref} {...viewProps} />
39
+ </ContextMenu.Root>
40
+ </ContextMenuContext.Provider>
41
+ );
42
+ }
43
+ );
44
+
45
+ Root.displayName = 'RootWebContextMenu';
46
+
47
+ function useRootContext() {
48
+ const context = React.useContext(ContextMenuContext);
49
+ if (!context) {
50
+ throw new Error(
51
+ 'ContextMenu compound components cannot be rendered outside the ContextMenu component'
52
+ );
53
+ }
54
+ return context;
55
+ }
56
+
57
+ const Trigger = React.forwardRef<PressableRef, SlottablePressableProps>(
58
+ ({ asChild, disabled = false, ...props }, ref) => {
59
+ const augmentedRef = useAugmentedRef({ ref });
60
+ const { open } = useRootContext();
61
+
62
+ React.useLayoutEffect(() => {
63
+ if (augmentedRef.current) {
64
+ const augRef = augmentedRef.current as unknown as HTMLDivElement;
65
+ augRef.dataset.state = open ? 'open' : 'closed';
66
+ }
67
+ }, [open]);
68
+
69
+ React.useLayoutEffect(() => {
70
+ if (augmentedRef.current) {
71
+ const augRef = augmentedRef.current as unknown as HTMLDivElement;
72
+ if (disabled) {
73
+ augRef.dataset.disabled = 'true';
74
+ } else {
75
+ augRef.dataset.disabled = undefined;
76
+ }
77
+ }
78
+ }, [disabled]);
79
+
80
+ const Component = asChild ? Slot.Pressable : Pressable;
81
+ return (
82
+ <ContextMenu.Trigger disabled={disabled ?? undefined} asChild>
83
+ <Component ref={augmentedRef} disabled={disabled} {...props} />
84
+ </ContextMenu.Trigger>
85
+ );
86
+ }
87
+ );
88
+
89
+ Trigger.displayName = 'TriggerWebContextMenu';
90
+
91
+ function Portal({ forceMount, container, children }: ContextMenuPortalProps) {
92
+ return <ContextMenu.Portal forceMount={forceMount} container={container} children={children} />;
93
+ }
94
+
95
+ const Overlay = React.forwardRef<PressableRef, SlottablePressableProps & ContextMenuOverlayProps>(
96
+ ({ asChild, ...props }, ref) => {
97
+ const Component = asChild ? Slot.Pressable : Pressable;
98
+ return <Component ref={ref} {...props} />;
99
+ }
100
+ );
101
+
102
+ Overlay.displayName = 'OverlayWebContextMenu';
103
+
104
+ const ContextMenuContentContext = React.createContext<{
105
+ close: () => void;
106
+ } | null>(null);
107
+
108
+ const Content = React.forwardRef<ViewRef, SlottableViewProps & PositionedContentProps>(
109
+ (
110
+ {
111
+ asChild = false,
112
+ forceMount,
113
+ align: _align,
114
+ side: _side,
115
+ sideOffset: _sideOffset,
116
+ alignOffset = 0,
117
+ avoidCollisions = true,
118
+ insets,
119
+ loop = true,
120
+ onCloseAutoFocus,
121
+ onEscapeKeyDown,
122
+ onPointerDownOutside,
123
+ onFocusOutside,
124
+ onInteractOutside,
125
+ collisionBoundary,
126
+ sticky,
127
+ hideWhenDetached,
128
+ ...props
129
+ },
130
+ ref
131
+ ) => {
132
+ const itemRef = React.useRef<HTMLDivElement>(null);
133
+
134
+ function close() {
135
+ itemRef.current?.click();
136
+ }
137
+
138
+ const Component = asChild ? Slot.View : View;
139
+ return (
140
+ <ContextMenuContentContext.Provider value={{ close }}>
141
+ <ContextMenu.Content
142
+ forceMount={forceMount}
143
+ alignOffset={alignOffset}
144
+ avoidCollisions={avoidCollisions}
145
+ collisionPadding={insets}
146
+ loop={loop}
147
+ onCloseAutoFocus={onCloseAutoFocus}
148
+ onEscapeKeyDown={onEscapeKeyDown}
149
+ onPointerDownOutside={onPointerDownOutside}
150
+ onFocusOutside={onFocusOutside}
151
+ onInteractOutside={onInteractOutside}
152
+ collisionBoundary={collisionBoundary}
153
+ sticky={sticky}
154
+ hideWhenDetached={hideWhenDetached}
155
+ >
156
+ <Component ref={ref} {...props} />
157
+ <ContextMenu.Item
158
+ ref={itemRef}
159
+ aria-hidden
160
+ style={{ position: 'fixed', top: 0, left: 0, zIndex: -999999999 }}
161
+ aria-disabled
162
+ tabIndex={-1}
163
+ hidden
164
+ />
165
+ </ContextMenu.Content>
166
+ </ContextMenuContentContext.Provider>
167
+ );
168
+ }
169
+ );
170
+
171
+ Content.displayName = 'ContentWebContextMenu';
172
+
173
+ function useContextMenuContentContext() {
174
+ const context = React.useContext(ContextMenuContentContext);
175
+ if (!context) {
176
+ throw new Error(
177
+ 'ContextMenu compound components cannot be rendered outside the ContextMenu component'
178
+ );
179
+ }
180
+ return context;
181
+ }
182
+
183
+ const Item = React.forwardRef<PressableRef, SlottablePressableProps & ContextMenuItemProps>(
184
+ ({ asChild, textValue, closeOnPress = true, onPress: onPressProp, ...props }, ref) => {
185
+ const { close } = useContextMenuContentContext();
186
+
187
+ function onKeyDown(ev: React.KeyboardEvent) {
188
+ if (ev.key === 'Enter' || ev.key === ' ') {
189
+ onPressProp?.(EmptyGestureResponderEvent);
190
+ if (closeOnPress) {
191
+ close();
192
+ }
193
+ }
194
+ }
195
+
196
+ function onPress(ev: GestureResponderEvent) {
197
+ onPressProp?.(ev);
198
+ if (closeOnPress) {
199
+ close();
200
+ }
201
+ }
202
+
203
+ const Component = asChild ? Slot.Pressable : Pressable;
204
+ return (
205
+ <ContextMenu.Item
206
+ textValue={textValue}
207
+ disabled={props.disabled ?? undefined}
208
+ onSelect={closeOnPress ? undefined : onSelected}
209
+ asChild
210
+ >
211
+ <Component ref={ref} role='button' onPress={onPress} onKeyDown={onKeyDown} {...props} />
212
+ </ContextMenu.Item>
213
+ );
214
+ }
215
+ );
216
+
217
+ Item.displayName = 'ItemWebContextMenu';
218
+
219
+ const Group = React.forwardRef<ViewRef, SlottableViewProps>(({ asChild, ...props }, ref) => {
220
+ const Component = asChild ? Slot.View : View;
221
+ return (
222
+ <ContextMenu.Group asChild>
223
+ <Component ref={ref} {...props} />
224
+ </ContextMenu.Group>
225
+ );
226
+ });
227
+
228
+ Group.displayName = 'GroupWebContextMenu';
229
+
230
+ const Label = React.forwardRef<TextRef, SlottableTextProps>(({ asChild, ...props }, ref) => {
231
+ const Component = asChild ? Slot.Text : Text;
232
+ return (
233
+ <ContextMenu.Label asChild>
234
+ <Component ref={ref} {...props} />
235
+ </ContextMenu.Label>
236
+ );
237
+ });
238
+
239
+ Label.displayName = 'LabelWebContextMenu';
240
+
241
+ const CheckboxItem = React.forwardRef<
242
+ PressableRef,
243
+ SlottablePressableProps & ContextMenuCheckboxItemProps
244
+ >(
245
+ (
246
+ {
247
+ asChild,
248
+ checked,
249
+ onCheckedChange,
250
+ textValue,
251
+ disabled = false,
252
+ closeOnPress = true,
253
+ onPress: onPressProp,
254
+ onKeyDown: onKeyDownProp,
255
+ ...props
256
+ },
257
+ ref
258
+ ) => {
259
+ const { close } = useContextMenuContentContext();
260
+
261
+ function onKeyDown(ev: React.KeyboardEvent) {
262
+ onKeyDownProp?.(ev);
263
+ if (ev.key === 'Enter' || ev.key === ' ') {
264
+ onPressProp?.(EmptyGestureResponderEvent);
265
+ onCheckedChange?.(!checked);
266
+ if (closeOnPress) {
267
+ close();
268
+ }
269
+ }
270
+ }
271
+
272
+ function onPress(ev: GestureResponderEvent) {
273
+ onPressProp?.(ev);
274
+ onCheckedChange?.(!checked);
275
+ if (closeOnPress) {
276
+ close();
277
+ }
278
+ }
279
+
280
+ const Component = asChild ? Slot.Pressable : Pressable;
281
+ return (
282
+ <ContextMenu.CheckboxItem
283
+ textValue={textValue}
284
+ checked={checked}
285
+ onCheckedChange={onCheckedChange}
286
+ onSelect={closeOnPress ? undefined : onSelected}
287
+ disabled={disabled ?? undefined}
288
+ asChild
289
+ >
290
+ <Component
291
+ ref={ref}
292
+ disabled={disabled}
293
+ // @ts-expect-error web only
294
+ onKeyDown={onKeyDown}
295
+ onPress={onPress}
296
+ role='button'
297
+ {...props}
298
+ />
299
+ </ContextMenu.CheckboxItem>
300
+ );
301
+ }
302
+ );
303
+
304
+ CheckboxItem.displayName = 'CheckboxItemWebContextMenu';
305
+
306
+ const ContextMenuRadioGroupContext = React.createContext<{
307
+ value?: string;
308
+ onValueChange?: (value: string) => void;
309
+ } | null>(null);
310
+
311
+ const RadioGroup = React.forwardRef<ViewRef, SlottableViewProps & ContextMenuRadioGroupProps>(
312
+ ({ asChild, value, onValueChange, ...props }, ref) => {
313
+ const Component = asChild ? Slot.View : View;
314
+ return (
315
+ <ContextMenuRadioGroupContext.Provider value={{ value, onValueChange }}>
316
+ <ContextMenu.RadioGroup value={value} onValueChange={onValueChange} asChild>
317
+ <Component ref={ref} {...props} />
318
+ </ContextMenu.RadioGroup>
319
+ </ContextMenuRadioGroupContext.Provider>
320
+ );
321
+ }
322
+ );
323
+
324
+ RadioGroup.displayName = 'RadioGroupWebContextMenu';
325
+
326
+ function useContextMenuRadioGroupContext() {
327
+ const context = React.useContext(ContextMenuRadioGroupContext);
328
+ if (!context) {
329
+ throw new Error(
330
+ 'ContextMenu compound components cannot be rendered outside the ContextMenu component'
331
+ );
332
+ }
333
+ return context;
334
+ }
335
+
336
+ const RadioItem = React.forwardRef<
337
+ PressableRef,
338
+ SlottablePressableProps & ContextMenuRadioItemProps
339
+ >(
340
+ (
341
+ {
342
+ asChild,
343
+ value,
344
+ textValue,
345
+ closeOnPress = true,
346
+ onPress: onPressProp,
347
+ onKeyDown: onKeyDownProp,
348
+ ...props
349
+ },
350
+ ref
351
+ ) => {
352
+ const { onValueChange } = useContextMenuRadioGroupContext();
353
+ const { close } = useContextMenuContentContext();
354
+
355
+ function onKeyDown(ev: React.KeyboardEvent) {
356
+ onKeyDownProp?.(ev);
357
+ if (ev.key === 'Enter' || ev.key === ' ') {
358
+ onValueChange?.(value);
359
+ onPressProp?.(EmptyGestureResponderEvent);
360
+ if (closeOnPress) {
361
+ close();
362
+ }
363
+ }
364
+ }
365
+
366
+ function onPress(ev: GestureResponderEvent) {
367
+ onValueChange?.(value);
368
+ onPressProp?.(ev);
369
+ if (closeOnPress) {
370
+ close();
371
+ }
372
+ }
373
+ const Component = asChild ? Slot.Pressable : Pressable;
374
+ return (
375
+ <ContextMenu.RadioItem
376
+ value={value}
377
+ textValue={textValue}
378
+ disabled={props.disabled ?? undefined}
379
+ onSelect={closeOnPress ? undefined : onSelected}
380
+ asChild
381
+ >
382
+ <Component
383
+ ref={ref}
384
+ // @ts-expect-error web only
385
+ onKeyDown={onKeyDown}
386
+ onPress={onPress}
387
+ {...props}
388
+ />
389
+ </ContextMenu.RadioItem>
390
+ );
391
+ }
392
+ );
393
+
394
+ RadioItem.displayName = 'RadioItemWebContextMenu';
395
+
396
+ const ItemIndicator = React.forwardRef<ViewRef, SlottableViewProps & ForceMountable>(
397
+ ({ asChild, forceMount, ...props }, ref) => {
398
+ const Component = asChild ? Slot.View : View;
399
+ return (
400
+ <ContextMenu.ItemIndicator forceMount={forceMount} asChild>
401
+ <Component ref={ref} {...props} />
402
+ </ContextMenu.ItemIndicator>
403
+ );
404
+ }
405
+ );
406
+
407
+ ItemIndicator.displayName = 'ItemIndicatorWebContextMenu';
408
+
409
+ const Separator = React.forwardRef<ViewRef, SlottableViewProps & ContextMenuSeparatorProps>(
410
+ ({ asChild, decorative, ...props }, ref) => {
411
+ const Component = asChild ? Slot.View : View;
412
+ return (
413
+ <ContextMenu.Separator asChild>
414
+ <Component ref={ref} {...props} />
415
+ </ContextMenu.Separator>
416
+ );
417
+ }
418
+ );
419
+
420
+ Separator.displayName = 'SeparatorWebContextMenu';
421
+
422
+ const ContextMenuSubContext = React.createContext<{
423
+ open: boolean;
424
+ onOpenChange: (open: boolean) => void;
425
+ } | null>(null);
426
+
427
+ const Sub = React.forwardRef<ViewRef, SlottableViewProps & ContextMenuSubProps>(
428
+ ({ asChild, open, onOpenChange, ...props }, ref) => {
429
+ const Component = asChild ? Slot.View : View;
430
+ return (
431
+ <ContextMenuSubContext.Provider value={{ open, onOpenChange }}>
432
+ <ContextMenu.Sub open={open} onOpenChange={onOpenChange}>
433
+ <Component ref={ref} {...props} />
434
+ </ContextMenu.Sub>
435
+ </ContextMenuSubContext.Provider>
436
+ );
437
+ }
438
+ );
439
+
440
+ Sub.displayName = 'SubWebContextMenu';
441
+
442
+ function useSubContext() {
443
+ const context = React.useContext(ContextMenuSubContext);
444
+ if (!context) {
445
+ throw new Error(
446
+ 'ContextMenu compound components cannot be rendered outside the ContextMenu component'
447
+ );
448
+ }
449
+ return context;
450
+ }
451
+
452
+ const SubTrigger = React.forwardRef<
453
+ PressableRef,
454
+ SlottablePressableProps & ContextMenuSubTriggerProps
455
+ >(({ asChild, textValue, disabled = false, ...props }, ref) => {
456
+ const Component = asChild ? Slot.Pressable : Pressable;
457
+ return (
458
+ <ContextMenu.SubTrigger disabled={disabled ?? undefined} textValue={textValue} asChild>
459
+ <Component ref={ref} {...props} />
460
+ </ContextMenu.SubTrigger>
461
+ );
462
+ });
463
+
464
+ SubTrigger.displayName = 'SubTriggerWebContextMenu';
465
+
466
+ const SubContent = React.forwardRef<PressableRef, SlottablePressableProps & ForceMountable>(
467
+ ({ asChild = false, forceMount, ...props }, ref) => {
468
+ const Component = asChild ? Slot.Pressable : Pressable;
469
+ return (
470
+ <ContextMenu.Portal>
471
+ <ContextMenu.SubContent forceMount={forceMount}>
472
+ <Component ref={ref} {...props} />
473
+ </ContextMenu.SubContent>
474
+ </ContextMenu.Portal>
475
+ );
476
+ }
477
+ );
478
+
479
+ Content.displayName = 'ContentWebContextMenu';
480
+
481
+ export {
482
+ CheckboxItem,
483
+ Content,
484
+ Group,
485
+ Item,
486
+ ItemIndicator,
487
+ Label,
488
+ Overlay,
489
+ Portal,
490
+ RadioGroup,
491
+ RadioItem,
492
+ Root,
493
+ Separator,
494
+ Sub,
495
+ SubContent,
496
+ SubTrigger,
497
+ Trigger,
498
+ useSubContext,
499
+ useRootContext,
500
+ };
501
+
502
+ function onSelected(ev: Event) {
503
+ ev.preventDefault();
504
+ }
@@ -0,0 +1 @@
1
+ export * from './context-menu';
@@ -0,0 +1,82 @@
1
+ import { ForceMountable } from '@rnr/types';
2
+
3
+ interface ContextMenuRootProps {
4
+ /**
5
+ * Platform: NATIVE ONLY
6
+ */
7
+ open: boolean;
8
+ onOpenChange: (value: boolean) => void;
9
+
10
+ /**
11
+ * Platform: NATIVE ONLY
12
+ */
13
+ relativeTo?: 'longPress' | 'trigger';
14
+ }
15
+
16
+ interface ContextMenuPortalProps extends ForceMountable {
17
+ children: React.ReactNode;
18
+ /**
19
+ * Platform: NATIVE ONLY
20
+ */
21
+ hostName?: string;
22
+ /**
23
+ * Platform: WEB ONLY
24
+ */
25
+ container?: HTMLElement | null | undefined;
26
+ }
27
+
28
+ interface ContextMenuOverlayProps extends ForceMountable {
29
+ /**
30
+ * Platform: NATIVE ONLY
31
+ */
32
+ closeOnPress?: boolean;
33
+ }
34
+
35
+ interface ContextMenuItemProps {
36
+ textValue?: string;
37
+ closeOnPress?: boolean;
38
+ }
39
+
40
+ interface ContextMenuCheckboxItemProps {
41
+ checked: boolean;
42
+ onCheckedChange: (checked: boolean) => void;
43
+ closeOnPress?: boolean;
44
+ textValue?: string;
45
+ }
46
+
47
+ interface ContextMenuRadioGroupProps {
48
+ value: string | undefined;
49
+ onValueChange: (value: string) => void;
50
+ }
51
+
52
+ interface ContextMenuRadioItemProps {
53
+ value: string;
54
+ textValue?: string;
55
+ closeOnPress?: boolean;
56
+ }
57
+
58
+ interface ContextMenuSeparatorProps {
59
+ decorative?: boolean;
60
+ }
61
+
62
+ interface ContextMenuSubProps {
63
+ open: boolean;
64
+ onOpenChange: (value: boolean) => void;
65
+ }
66
+
67
+ interface ContextMenuSubTriggerProps {
68
+ textValue?: string;
69
+ }
70
+
71
+ export type {
72
+ ContextMenuCheckboxItemProps,
73
+ ContextMenuItemProps,
74
+ ContextMenuOverlayProps,
75
+ ContextMenuPortalProps,
76
+ ContextMenuRadioGroupProps,
77
+ ContextMenuRadioItemProps,
78
+ ContextMenuRootProps,
79
+ ContextMenuSeparatorProps,
80
+ ContextMenuSubProps,
81
+ ContextMenuSubTriggerProps,
82
+ };