@react-native-reusables/cli 0.0.18 → 0.1.1

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