nwui-cli 0.3.6 → 0.4.0-beta.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 (211) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/build/index.js +15 -3
  3. package/build/install-component.js +117 -32
  4. package/build/utils/env.js +3 -0
  5. package/my-expo-app-2/app/+html.tsx +46 -0
  6. package/my-expo-app-2/app/+not-found.tsx +33 -0
  7. package/my-expo-app-2/app/_layout.tsx +22 -0
  8. package/my-expo-app-2/app/details.tsx +17 -0
  9. package/my-expo-app-2/app/index.tsx +23 -0
  10. package/my-expo-app-2/app-env.d.ts +2 -0
  11. package/my-expo-app-2/app.json +48 -0
  12. package/my-expo-app-2/assets/adaptive-icon.png +0 -0
  13. package/my-expo-app-2/assets/favicon.png +0 -0
  14. package/my-expo-app-2/assets/icon.png +0 -0
  15. package/my-expo-app-2/assets/splash.png +0 -0
  16. package/my-expo-app-2/babel.config.js +18 -0
  17. package/my-expo-app-2/cesconfig.json +35 -0
  18. package/my-expo-app-2/components/Button.tsx +19 -0
  19. package/my-expo-app-2/components/Container.tsx +9 -0
  20. package/my-expo-app-2/components/EditScreenInfo.tsx +34 -0
  21. package/my-expo-app-2/components/ScreenContent.tsx +25 -0
  22. package/my-expo-app-2/components/nativewindui/ActivityIndicator.tsx +13 -0
  23. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
  24. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
  25. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
  26. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
  27. package/my-expo-app-2/components/nativewindui/Alert/Alert.ios.tsx +65 -0
  28. package/my-expo-app-2/components/nativewindui/Alert/Alert.tsx +291 -0
  29. package/my-expo-app-2/components/nativewindui/Alert/index.ts +1 -0
  30. package/my-expo-app-2/components/nativewindui/Alert/types.ts +27 -0
  31. package/my-expo-app-2/components/nativewindui/Badge.tsx +84 -0
  32. package/my-expo-app-2/components/nativewindui/Button.tsx +156 -0
  33. package/my-expo-app-2/components/nativewindui/Checkbox.tsx +61 -0
  34. package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
  35. package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
  36. package/my-expo-app-2/components/nativewindui/ContextMenu/index.ts +1 -0
  37. package/my-expo-app-2/components/nativewindui/ContextMenu/types.ts +91 -0
  38. package/my-expo-app-2/components/nativewindui/ContextMenu/utils.ts +14 -0
  39. package/my-expo-app-2/components/nativewindui/DrawerContent.tsx +145 -0
  40. package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
  41. package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
  42. package/my-expo-app-2/components/nativewindui/DropdownMenu/index.ts +1 -0
  43. package/my-expo-app-2/components/nativewindui/DropdownMenu/types.ts +93 -0
  44. package/my-expo-app-2/components/nativewindui/DropdownMenu/utils.ts +14 -0
  45. package/my-expo-app-2/components/nativewindui/Form.tsx +125 -0
  46. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
  47. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
  48. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/index.ts +1 -0
  49. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/types.ts +89 -0
  50. package/my-expo-app-2/components/nativewindui/List.tsx +433 -0
  51. package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
  52. package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
  53. package/my-expo-app-2/components/nativewindui/SearchInput/index.tsx +1 -0
  54. package/my-expo-app-2/components/nativewindui/SearchInput/types.ts +12 -0
  55. package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
  56. package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
  57. package/my-expo-app-2/components/nativewindui/SegmentedControl/index.ts +1 -0
  58. package/my-expo-app-2/components/nativewindui/SegmentedControl/types.ts +15 -0
  59. package/my-expo-app-2/components/nativewindui/Stepper.tsx +62 -0
  60. package/my-expo-app-2/components/nativewindui/Text.tsx +55 -0
  61. package/my-expo-app-2/components/nativewindui/TextField/TextField.ios.tsx +85 -0
  62. package/my-expo-app-2/components/nativewindui/TextField/TextField.tsx +326 -0
  63. package/my-expo-app-2/components/nativewindui/TextField/index.tsx +1 -0
  64. package/my-expo-app-2/components/nativewindui/TextField/types.ts +26 -0
  65. package/my-expo-app-2/components/nativewindui/Toolbar.tsx +116 -0
  66. package/my-expo-app-2/global.css +3 -0
  67. package/my-expo-app-2/metro.config.js +12 -0
  68. package/my-expo-app-2/package-lock.json +19162 -0
  69. package/my-expo-app-2/package.json +74 -0
  70. package/my-expo-app-2/prettier.config.js +11 -0
  71. package/my-expo-app-2/tailwind.config.js +11 -0
  72. package/my-expo-app-3/app/+html.tsx +46 -0
  73. package/my-expo-app-3/app/+not-found.tsx +33 -0
  74. package/my-expo-app-3/app/_layout.tsx +22 -0
  75. package/my-expo-app-3/app/details.tsx +17 -0
  76. package/my-expo-app-3/app/index.tsx +23 -0
  77. package/my-expo-app-3/app-env.d.ts +2 -0
  78. package/my-expo-app-3/app.json +48 -0
  79. package/my-expo-app-3/assets/adaptive-icon.png +0 -0
  80. package/my-expo-app-3/assets/favicon.png +0 -0
  81. package/my-expo-app-3/assets/icon.png +0 -0
  82. package/my-expo-app-3/assets/splash.png +0 -0
  83. package/my-expo-app-3/babel.config.js +18 -0
  84. package/my-expo-app-3/cesconfig.json +35 -0
  85. package/my-expo-app-3/components/Button.tsx +19 -0
  86. package/my-expo-app-3/components/Container.tsx +9 -0
  87. package/my-expo-app-3/components/EditScreenInfo.tsx +34 -0
  88. package/my-expo-app-3/components/ScreenContent.tsx +25 -0
  89. package/my-expo-app-3/components/nativewindui/ActivityIndicator.tsx +13 -0
  90. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
  91. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
  92. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
  93. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
  94. package/my-expo-app-3/components/nativewindui/Alert/Alert.ios.tsx +65 -0
  95. package/my-expo-app-3/components/nativewindui/Alert/Alert.tsx +291 -0
  96. package/my-expo-app-3/components/nativewindui/Alert/index.ts +1 -0
  97. package/my-expo-app-3/components/nativewindui/Alert/types.ts +27 -0
  98. package/my-expo-app-3/components/nativewindui/Badge.tsx +84 -0
  99. package/my-expo-app-3/components/nativewindui/Button.tsx +156 -0
  100. package/my-expo-app-3/components/nativewindui/Checkbox.tsx +61 -0
  101. package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
  102. package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
  103. package/my-expo-app-3/components/nativewindui/ContextMenu/index.ts +1 -0
  104. package/my-expo-app-3/components/nativewindui/ContextMenu/types.ts +91 -0
  105. package/my-expo-app-3/components/nativewindui/ContextMenu/utils.ts +14 -0
  106. package/my-expo-app-3/components/nativewindui/DrawerContent.tsx +145 -0
  107. package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
  108. package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
  109. package/my-expo-app-3/components/nativewindui/DropdownMenu/index.ts +1 -0
  110. package/my-expo-app-3/components/nativewindui/DropdownMenu/types.ts +93 -0
  111. package/my-expo-app-3/components/nativewindui/DropdownMenu/utils.ts +14 -0
  112. package/my-expo-app-3/components/nativewindui/Form.tsx +125 -0
  113. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
  114. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
  115. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/index.ts +1 -0
  116. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/types.ts +89 -0
  117. package/my-expo-app-3/components/nativewindui/List.tsx +433 -0
  118. package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
  119. package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
  120. package/my-expo-app-3/components/nativewindui/SearchInput/index.tsx +1 -0
  121. package/my-expo-app-3/components/nativewindui/SearchInput/types.ts +12 -0
  122. package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
  123. package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
  124. package/my-expo-app-3/components/nativewindui/SegmentedControl/index.ts +1 -0
  125. package/my-expo-app-3/components/nativewindui/SegmentedControl/types.ts +15 -0
  126. package/my-expo-app-3/components/nativewindui/Stepper.tsx +62 -0
  127. package/my-expo-app-3/components/nativewindui/Text.tsx +55 -0
  128. package/my-expo-app-3/components/nativewindui/TextField/TextField.ios.tsx +85 -0
  129. package/my-expo-app-3/components/nativewindui/TextField/TextField.tsx +326 -0
  130. package/my-expo-app-3/components/nativewindui/TextField/index.tsx +1 -0
  131. package/my-expo-app-3/components/nativewindui/TextField/types.ts +26 -0
  132. package/my-expo-app-3/components/nativewindui/Toolbar.tsx +116 -0
  133. package/my-expo-app-3/components/nativewindui/examples/selectable-text.tsx +43 -0
  134. package/my-expo-app-3/components/nativewindui/examples/text.tsx +43 -0
  135. package/my-expo-app-3/global.css +3 -0
  136. package/my-expo-app-3/metro.config.js +12 -0
  137. package/my-expo-app-3/package-lock.json +19141 -0
  138. package/my-expo-app-3/package.json +73 -0
  139. package/my-expo-app-3/prettier.config.js +11 -0
  140. package/my-expo-app-3/tailwind.config.js +11 -0
  141. package/my-expo-app-test-case/app/+html.tsx +46 -0
  142. package/my-expo-app-test-case/app/+not-found.tsx +33 -0
  143. package/my-expo-app-test-case/app/_layout.tsx +22 -0
  144. package/my-expo-app-test-case/app/details.tsx +17 -0
  145. package/my-expo-app-test-case/app/index.tsx +23 -0
  146. package/my-expo-app-test-case/app-env.d.ts +2 -0
  147. package/my-expo-app-test-case/app.json +48 -0
  148. package/my-expo-app-test-case/assets/adaptive-icon.png +0 -0
  149. package/my-expo-app-test-case/assets/favicon.png +0 -0
  150. package/my-expo-app-test-case/assets/icon.png +0 -0
  151. package/my-expo-app-test-case/assets/splash.png +0 -0
  152. package/my-expo-app-test-case/babel.config.js +18 -0
  153. package/my-expo-app-test-case/cesconfig.json +35 -0
  154. package/my-expo-app-test-case/components/Button.tsx +19 -0
  155. package/my-expo-app-test-case/components/Container.tsx +9 -0
  156. package/my-expo-app-test-case/components/EditScreenInfo.tsx +34 -0
  157. package/my-expo-app-test-case/components/ScreenContent.tsx +25 -0
  158. package/my-expo-app-test-case/components/nativewindui/ActivityIndicator.tsx +13 -0
  159. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
  160. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
  161. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
  162. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
  163. package/my-expo-app-test-case/components/nativewindui/Alert/Alert.ios.tsx +65 -0
  164. package/my-expo-app-test-case/components/nativewindui/Alert/Alert.tsx +291 -0
  165. package/my-expo-app-test-case/components/nativewindui/Alert/index.ts +1 -0
  166. package/my-expo-app-test-case/components/nativewindui/Alert/types.ts +27 -0
  167. package/my-expo-app-test-case/components/nativewindui/Badge.tsx +84 -0
  168. package/my-expo-app-test-case/components/nativewindui/Button.tsx +156 -0
  169. package/my-expo-app-test-case/components/nativewindui/Checkbox.tsx +61 -0
  170. package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
  171. package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
  172. package/my-expo-app-test-case/components/nativewindui/ContextMenu/index.ts +1 -0
  173. package/my-expo-app-test-case/components/nativewindui/ContextMenu/types.ts +91 -0
  174. package/my-expo-app-test-case/components/nativewindui/ContextMenu/utils.ts +14 -0
  175. package/my-expo-app-test-case/components/nativewindui/DrawerContent.tsx +145 -0
  176. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
  177. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
  178. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/index.ts +1 -0
  179. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/types.ts +93 -0
  180. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/utils.ts +14 -0
  181. package/my-expo-app-test-case/components/nativewindui/Form.tsx +125 -0
  182. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
  183. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
  184. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/index.ts +1 -0
  185. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/types.ts +89 -0
  186. package/my-expo-app-test-case/components/nativewindui/List.tsx +433 -0
  187. package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
  188. package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
  189. package/my-expo-app-test-case/components/nativewindui/SearchInput/index.tsx +1 -0
  190. package/my-expo-app-test-case/components/nativewindui/SearchInput/types.ts +12 -0
  191. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
  192. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
  193. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/index.ts +1 -0
  194. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/types.ts +15 -0
  195. package/my-expo-app-test-case/components/nativewindui/Stepper.tsx +62 -0
  196. package/my-expo-app-test-case/components/nativewindui/Text.tsx +55 -0
  197. package/my-expo-app-test-case/components/nativewindui/TextField/TextField.ios.tsx +85 -0
  198. package/my-expo-app-test-case/components/nativewindui/TextField/TextField.tsx +326 -0
  199. package/my-expo-app-test-case/components/nativewindui/TextField/index.tsx +1 -0
  200. package/my-expo-app-test-case/components/nativewindui/TextField/types.ts +26 -0
  201. package/my-expo-app-test-case/components/nativewindui/Toolbar.tsx +116 -0
  202. package/my-expo-app-test-case/components/nativewindui/examples/a-user-created-file.tsx +0 -0
  203. package/my-expo-app-test-case/components/nativewindui/examples/selectable-text.tsx +43 -0
  204. package/my-expo-app-test-case/components/nativewindui/examples/text.tsx +43 -0
  205. package/my-expo-app-test-case/global.css +3 -0
  206. package/my-expo-app-test-case/metro.config.js +12 -0
  207. package/my-expo-app-test-case/package-lock.json +19141 -0
  208. package/my-expo-app-test-case/package.json +73 -0
  209. package/my-expo-app-test-case/prettier.config.js +11 -0
  210. package/my-expo-app-test-case/tailwind.config.js +11 -0
  211. package/package.json +2 -2
@@ -0,0 +1,330 @@
1
+ import * as DropdownMenuPrimitive from '@rn-primitives/dropdown-menu';
2
+ import { useAugmentedRef } from '@rn-primitives/hooks';
3
+ import { Icon } from '@roninoss/icons';
4
+ import * as React from 'react';
5
+ import { Image, LayoutChangeEvent, StyleSheet, View } from 'react-native';
6
+ import Animated, {
7
+ FadeIn,
8
+ FadeInLeft,
9
+ FadeOut,
10
+ FadeOutLeft,
11
+ LayoutAnimationConfig,
12
+ LinearTransition,
13
+ } from 'react-native-reanimated';
14
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
15
+
16
+ import { DropdownItem, DropdownMenuProps, DropdownMenuRef, DropdownSubMenu } from './types';
17
+
18
+ import { ActivityIndicator } from '~/components/nativewindui/ActivityIndicator';
19
+ import { Button } from '~/components/nativewindui/Button';
20
+ import { Text } from '~/components/nativewindui/Text';
21
+ import { cn } from '~/lib/cn';
22
+ import { useColorScheme } from '~/lib/useColorScheme';
23
+
24
+ const DropdownContext = React.createContext<{
25
+ onItemPress: DropdownMenuProps['onItemPress'];
26
+ dismissMenu?: () => void;
27
+ materialLoadingText: string;
28
+ materialSubMenuTitlePlaceholder: string;
29
+ subMenuRefs: React.MutableRefObject<DropdownMenuRef[]>;
30
+ closeSubMenus: () => void;
31
+ } | null>(null);
32
+
33
+ const DropdownMenu = React.forwardRef<DropdownMenuRef, DropdownMenuProps>(
34
+ (
35
+ {
36
+ items,
37
+ title,
38
+ iOSItemSize: _iOSItemSize,
39
+ onItemPress: onItemPressProp,
40
+ enabled = true,
41
+ children,
42
+ materialPortalHost,
43
+ materialSideOffset = 2,
44
+ materialAlignOffset,
45
+ materialAlign = 'center',
46
+ materialWidth,
47
+ materialMinWidth = 200,
48
+ materialLoadingText = 'Loading...',
49
+ materialSubMenuTitlePlaceholder = 'More ...',
50
+ materialOverlayClassName,
51
+ // @ts-expect-error internal prop
52
+ materialIsSubMenu,
53
+ ...props
54
+ },
55
+ ref
56
+ ) => {
57
+ const triggerRef = React.useRef<DropdownMenuPrimitive.DropdownMenuTriggerRef>(null);
58
+ const subMenuRefs = React.useRef<DropdownMenuRef[]>([]);
59
+ const insets = useSafeAreaInsets();
60
+ const rootRef = useAugmentedRef({
61
+ ref,
62
+ methods: {
63
+ presentMenu: () => {
64
+ triggerRef.current?.open();
65
+ },
66
+ dismissMenu,
67
+ },
68
+ deps: [triggerRef.current],
69
+ });
70
+
71
+ function closeSubMenus() {
72
+ for (const subMenuRef of subMenuRefs.current) {
73
+ subMenuRef.dismissMenu?.();
74
+ }
75
+ }
76
+
77
+ function onItemPress(item: Omit<DropdownItem, 'icon'>) {
78
+ closeSubMenus();
79
+ onItemPressProp?.(item);
80
+ }
81
+
82
+ function dismissMenu() {
83
+ triggerRef.current?.close();
84
+ }
85
+ return (
86
+ <DropdownMenuPrimitive.Root ref={rootRef} {...props}>
87
+ <DropdownMenuPrimitive.Trigger ref={triggerRef} asChild>
88
+ {children}
89
+ </DropdownMenuPrimitive.Trigger>
90
+ <DropdownMenuPrimitive.Portal hostName={materialPortalHost}>
91
+ <DropdownContext.Provider
92
+ value={{
93
+ onItemPress,
94
+ dismissMenu,
95
+ materialLoadingText,
96
+ materialSubMenuTitlePlaceholder,
97
+ subMenuRefs,
98
+ closeSubMenus,
99
+ }}>
100
+ <DropdownMenuPrimitive.Overlay
101
+ style={StyleSheet.absoluteFill}
102
+ pointerEvents={materialIsSubMenu ? 'box-none' : undefined}>
103
+ <Animated.View
104
+ style={StyleSheet.absoluteFill}
105
+ entering={FadeIn}
106
+ exiting={FadeOut}
107
+ pointerEvents={materialIsSubMenu ? 'box-none' : undefined}
108
+ className={cn(
109
+ !materialIsSubMenu && 'bg-black/20',
110
+ !materialIsSubMenu && materialOverlayClassName
111
+ )}>
112
+ <DropdownMenuPrimitive.Content
113
+ insets={{
114
+ top: insets.top,
115
+ right: 8,
116
+ bottom: insets.bottom,
117
+ left: 8,
118
+ }}
119
+ sideOffset={materialSideOffset}
120
+ alignOffset={materialAlignOffset}
121
+ align={materialAlign}>
122
+ <Animated.View
123
+ entering={FadeIn}
124
+ exiting={materialIsSubMenu ? undefined : FadeOut}
125
+ style={{ minWidth: materialMinWidth, width: materialWidth }}
126
+ className="border-border/20 bg-card z-50 rounded-md border py-2 shadow-xl">
127
+ {!!title && <DropdownMenuLabel>{title}</DropdownMenuLabel>}
128
+ <DropdownMenuInnerContent items={items} />
129
+ </Animated.View>
130
+ </DropdownMenuPrimitive.Content>
131
+ </Animated.View>
132
+ </DropdownMenuPrimitive.Overlay>
133
+ </DropdownContext.Provider>
134
+ </DropdownMenuPrimitive.Portal>
135
+ </DropdownMenuPrimitive.Root>
136
+ );
137
+ }
138
+ );
139
+
140
+ DropdownMenu.displayName = 'DropdownMenu';
141
+
142
+ export { DropdownMenu };
143
+
144
+ function useDropdownContext() {
145
+ const context = React.useContext(DropdownContext);
146
+ if (!context) {
147
+ throw new Error(
148
+ 'DropdownMenu compound components cannot be rendered outside the DropdownMenu component'
149
+ );
150
+ }
151
+ return context;
152
+ }
153
+
154
+ function DropdownMenuInnerContent({ items }: { items: (DropdownItem | DropdownSubMenu)[] }) {
155
+ const { materialLoadingText } = useDropdownContext();
156
+ const id = React.useId();
157
+
158
+ return (
159
+ <View>
160
+ {items.map((item, index) => {
161
+ if (item.loading) {
162
+ return (
163
+ <DropdownMenuPrimitive.Item key={`loading:${id}-${item.title}-${index}`} asChild>
164
+ <Button
165
+ disabled
166
+ variant="plain"
167
+ className="h-12 justify-between gap-10 rounded-none px-3"
168
+ androidRootClassName="rounded-none ">
169
+ <Text className="font-normal opacity-60">{materialLoadingText}</Text>
170
+ <ActivityIndicator />
171
+ </Button>
172
+ </DropdownMenuPrimitive.Item>
173
+ );
174
+ }
175
+ if ((item as Partial<DropdownSubMenu>)?.items) {
176
+ const subMenu = item as DropdownSubMenu;
177
+ if (subMenu.items.length === 0) return null;
178
+ return (
179
+ <DropdownMenuSubMenu
180
+ title={subMenu.title}
181
+ subTitle={subMenu.subTitle}
182
+ items={subMenu.items}
183
+ key={`${id}-${subMenu.title}-${index}`}
184
+ />
185
+ );
186
+ }
187
+ const dropdownItem = item as DropdownItem;
188
+ return <DropdownMenuItem key={dropdownItem.actionKey} {...dropdownItem} />;
189
+ })}
190
+ </View>
191
+ );
192
+ }
193
+
194
+ function DropdownMenuLabel(props: { children: React.ReactNode }) {
195
+ return (
196
+ <DropdownMenuPrimitive.Label className="text-muted-foreground/80 border-border/25 dark:border-border/80 dark:text-muted-foreground border-b px-3 pb-2 text-sm">
197
+ {props.children}
198
+ </DropdownMenuPrimitive.Label>
199
+ );
200
+ }
201
+
202
+ function DropdownMenuItem(props: Omit<DropdownItem, 'loading'>) {
203
+ const { colors } = useColorScheme();
204
+ const { onItemPress } = useDropdownContext();
205
+
206
+ function onPress() {
207
+ onItemPress?.(props);
208
+ }
209
+
210
+ if (props.hidden) return null;
211
+
212
+ return (
213
+ <LayoutAnimationConfig skipEntering skipExiting>
214
+ <DropdownMenuPrimitive.Item
215
+ asChild
216
+ closeOnPress={!props.keepOpenOnPress}
217
+ role="checkbox"
218
+ accessibilityState={{
219
+ disabled: !!props.disabled,
220
+ checked: props.state?.checked,
221
+ }}>
222
+ <Button
223
+ variant={props.state?.checked ? 'tonal' : 'plain'}
224
+ className={cn(
225
+ 'h-12 justify-between gap-10 rounded-none px-3',
226
+ !props.state && !props.title && 'justify-center px-4'
227
+ )}
228
+ androidRootClassName="rounded-none"
229
+ accessibilityHint={props.subTitle}
230
+ onPress={onPress}>
231
+ {!props.state && !props.title ? null : (
232
+ <View className="flex-row items-center gap-3 py-0.5">
233
+ {props.state?.checked && (
234
+ <Animated.View entering={FadeInLeft} exiting={FadeOutLeft}>
235
+ <Icon name="check" size={21} color={colors.foreground} />
236
+ </Animated.View>
237
+ )}
238
+ <Animated.View layout={LinearTransition}>
239
+ <Text
240
+ numberOfLines={1}
241
+ className={cn(
242
+ 'font-normal',
243
+ props.destructive && 'text-destructive font-medium',
244
+ props.disabled && 'opacity-60'
245
+ )}>
246
+ {props.title}
247
+ </Text>
248
+ </Animated.View>
249
+ {props.state && !props.state?.checked && (
250
+ <Icon name="check" size={21} color="#00000000" />
251
+ )}
252
+ </View>
253
+ )}
254
+ {props.image ? (
255
+ <Image
256
+ source={{ uri: props.image.url }}
257
+ style={{
258
+ width: 22,
259
+ height: 22,
260
+ borderRadius:
261
+ typeof props.image.cornerRadius === 'number' && props.image.cornerRadius > 0
262
+ ? props.image.cornerRadius / 4
263
+ : 0,
264
+ }}
265
+ />
266
+ ) : props.icon ? (
267
+ <Icon color={colors.foreground} {...props.icon} size={22} />
268
+ ) : null}
269
+ </Button>
270
+ </DropdownMenuPrimitive.Item>
271
+ </LayoutAnimationConfig>
272
+ );
273
+ }
274
+
275
+ const DEFAULT_LAYOUT = {
276
+ width: 0,
277
+ height: 0,
278
+ };
279
+
280
+ function DropdownMenuSubMenu({ title, subTitle, items }: Omit<DropdownSubMenu, 'loading'>) {
281
+ const { colors } = useColorScheme();
282
+ const {
283
+ onItemPress: onDropdownItemPress,
284
+ dismissMenu,
285
+ materialSubMenuTitlePlaceholder,
286
+ subMenuRefs,
287
+ closeSubMenus,
288
+ } = useDropdownContext();
289
+ const [triggerLayout, setTriggerLayout] = React.useState<typeof DEFAULT_LAYOUT>(DEFAULT_LAYOUT);
290
+
291
+ function onItemPress(item: Omit<DropdownItem, 'icon'>) {
292
+ dismissMenu?.();
293
+ onDropdownItemPress?.(item);
294
+ }
295
+
296
+ function onLayout(ev: LayoutChangeEvent) {
297
+ setTriggerLayout(ev.nativeEvent.layout);
298
+ }
299
+
300
+ function addSubMenuRef(ref: DropdownMenuRef | null) {
301
+ if (!ref) return;
302
+ subMenuRefs.current.push(ref);
303
+ }
304
+
305
+ return (
306
+ <DropdownMenu
307
+ items={items}
308
+ materialAlign="start"
309
+ materialSideOffset={-triggerLayout.height}
310
+ materialAlignOffset={triggerLayout.width}
311
+ onItemPress={onItemPress}
312
+ materialMinWidth={48}
313
+ // @ts-expect-error internal prop
314
+ materialIsSubMenu
315
+ ref={addSubMenuRef}>
316
+ <Button
317
+ variant="plain"
318
+ className=" justify-between gap-10 rounded-none px-3"
319
+ androidRootClassName="rounded-none"
320
+ onLayout={onLayout}
321
+ accessibilityHint={subTitle}
322
+ onPress={closeSubMenus}>
323
+ <Text numberOfLines={1} className="py-0.5 font-normal">
324
+ {title || materialSubMenuTitlePlaceholder}
325
+ </Text>
326
+ <Icon name="chevron-right" size={21} color={colors.grey} />
327
+ </Button>
328
+ </DropdownMenu>
329
+ );
330
+ }
@@ -0,0 +1 @@
1
+ export * from './DropdownMenu';
@@ -0,0 +1,93 @@
1
+ import type { MaterialIconName, SfSymbolIconName } from '@roninoss/icons';
2
+ import type { View, ViewProps } from 'react-native';
3
+
4
+ type MaterialIcon = {
5
+ name: MaterialIconName;
6
+ namingScheme?: 'material' | undefined;
7
+ color?: string;
8
+ };
9
+
10
+ type SfSymbolIcon = {
11
+ name: SfSymbolIconName;
12
+ namingScheme: 'sfSymbol';
13
+ color?: string;
14
+ };
15
+
16
+ type DropdownIcon = SfSymbolIcon | MaterialIcon;
17
+
18
+ type DropdownItem = {
19
+ actionKey: string;
20
+ title?: string;
21
+ subTitle?: string;
22
+ state?: { checked: boolean };
23
+ keepOpenOnPress?: boolean;
24
+ // iOS 14 and above
25
+ loading?: boolean;
26
+ destructive?: boolean;
27
+ disabled?: boolean;
28
+ hidden?: boolean;
29
+ // icon or image, not both image has higher priority
30
+ icon?: DropdownIcon;
31
+ // icon or image, not both image has higher priority
32
+ image?: { url?: string; cornerRadius?: number; tint?: string };
33
+ };
34
+
35
+ type DropdownSubMenuDropdown = {
36
+ iOSType?: 'dropdown';
37
+ // preferred item size
38
+ iOSItemSize?: 'large';
39
+ destructive?: boolean;
40
+ };
41
+
42
+ type DropdownSubMenuInline = {
43
+ iOSType: 'inline';
44
+ // preferred item size
45
+ iOSItemSize?: 'small' | 'medium';
46
+ };
47
+
48
+ type DropdownSubMenu = (DropdownSubMenuDropdown | DropdownSubMenuInline) & {
49
+ title: string;
50
+ // Displayed on iOS 15 and above only, used as accessibility hint otherwise
51
+ subTitle?: string;
52
+ // iOS 14 and above only
53
+ loading?: boolean;
54
+ // No items shows nothing
55
+ items: (DropdownItem | DropdownSubMenu)[];
56
+ };
57
+
58
+ type DropdownMenuConfig = {
59
+ title?: string;
60
+ items: (DropdownItem | DropdownSubMenu)[];
61
+ // preferred item size
62
+ iOSItemSize?: 'small' | 'medium' | 'large';
63
+ };
64
+
65
+ type DropdownMenuProps = DropdownMenuConfig &
66
+ ViewProps & {
67
+ children: React.ReactNode;
68
+ onItemPress?: (item: Omit<DropdownItem, 'icon'>, isUsingActionSheetFallback?: boolean) => void;
69
+ enabled?: boolean;
70
+ materialPortalHost?: string;
71
+ // defaults to 2
72
+ materialSideOffset?: number;
73
+ materialAlignOffset?: number;
74
+ materialAlign?: 'start' | 'center' | 'end';
75
+ materialWidth?: number;
76
+ materialMinWidth?: number;
77
+ materialLoadingText?: string;
78
+ materialSubMenuTitlePlaceholder?: string;
79
+ materialOverlayClassName?: string;
80
+ };
81
+
82
+ type DropdownMenuRef = React.ElementRef<typeof View> & {
83
+ presentMenu?: () => void;
84
+ dismissMenu?: () => void;
85
+ };
86
+
87
+ export type {
88
+ DropdownMenuProps,
89
+ DropdownMenuConfig,
90
+ DropdownSubMenu,
91
+ DropdownItem,
92
+ DropdownMenuRef,
93
+ };
@@ -0,0 +1,14 @@
1
+ import { DropdownItem, DropdownSubMenu } from './types';
2
+
3
+ function createDropdownSubMenu(
4
+ subMenu: Omit<DropdownSubMenu, 'items'>,
5
+ items: DropdownSubMenu['items']
6
+ ) {
7
+ return Object.assign(subMenu, { items }) as DropdownSubMenu;
8
+ }
9
+
10
+ function createDropdownItem(item: DropdownItem) {
11
+ return item;
12
+ }
13
+
14
+ export { createDropdownSubMenu, createDropdownItem };
@@ -0,0 +1,125 @@
1
+ import { Icon, type IconProps } from '@roninoss/icons';
2
+ import * as React from 'react';
3
+ import { Platform, View, ViewProps, ViewStyle } from 'react-native';
4
+
5
+ import { Text } from '~/components/nativewindui/Text';
6
+ import { cn } from '~/lib/cn';
7
+ import { useColorScheme } from '~/lib/useColorScheme';
8
+
9
+ const Form = React.forwardRef<View, ViewProps>(({ className, ...props }, ref) => {
10
+ return <View ref={ref} className={cn('flex-1 gap-9', className)} {...props} />;
11
+ });
12
+
13
+ // Add as class when possible: https://github.com/marklawlor/nativewind/issues/522
14
+ const BORDER_CURVE: ViewStyle = {
15
+ borderCurve: 'continuous',
16
+ };
17
+
18
+ type FormSectionProps = ViewProps & {
19
+ rootClassName?: string;
20
+ footnote?: string;
21
+ footnoteClassName?: string;
22
+ ios?: {
23
+ title: string;
24
+ titleClassName?: string;
25
+ };
26
+ materialIconProps?: Omit<IconProps<'material'>, 'namingScheme' | 'ios'>;
27
+ };
28
+
29
+ const FormSection = React.forwardRef<React.ElementRef<typeof View>, FormSectionProps>(
30
+ (
31
+ {
32
+ rootClassName,
33
+ className,
34
+ footnote,
35
+ footnoteClassName,
36
+ ios,
37
+ materialIconProps,
38
+ style = BORDER_CURVE,
39
+ children: childrenProps,
40
+ ...props
41
+ },
42
+ ref
43
+ ) => {
44
+ const { colors } = useColorScheme();
45
+ const children = React.useMemo(() => {
46
+ if (Platform.OS !== 'ios') return childrenProps;
47
+ const childrenArray = React.Children.toArray(childrenProps);
48
+ // Add isLast prop to last child
49
+ return React.Children.map(childrenArray, (child, index) => {
50
+ if (!React.isValidElement(child)) return child;
51
+ const isLast = index === childrenArray.length - 1;
52
+ if (typeof child === 'string') {
53
+ console.log('FormSection - Invalid asChild element', child);
54
+ }
55
+ return React.cloneElement<ViewProps & { isLast?: boolean }, View>(
56
+ typeof child === 'string' ? <></> : child,
57
+ { isLast }
58
+ );
59
+ });
60
+ }, [childrenProps]);
61
+
62
+ return (
63
+ <View
64
+ className={cn(
65
+ 'relative',
66
+ Platform.OS !== 'ios' && !!materialIconProps && 'flex-row gap-4',
67
+ rootClassName
68
+ )}>
69
+ {Platform.OS === 'ios' && !!ios?.title && (
70
+ <Text
71
+ variant="footnote"
72
+ className={cn('pb-1 pl-3 uppercase text-muted-foreground', ios?.titleClassName)}>
73
+ {ios.title}
74
+ </Text>
75
+ )}
76
+ {!!materialIconProps && (
77
+ <View className="ios:hidden pt-0.5">
78
+ <Icon color={colors.grey} size={24} {...(materialIconProps as IconProps<'material'>)} />
79
+ </View>
80
+ )}
81
+ <View className="flex-1">
82
+ <View
83
+ ref={ref}
84
+ className={cn(
85
+ 'ios:overflow-hidden ios:rounded-lg ios:bg-card ios:gap-0 ios:pl-1 gap-4',
86
+ className
87
+ )}
88
+ style={style}
89
+ children={children}
90
+ {...props}
91
+ />
92
+ {!!footnote && (
93
+ <Text
94
+ className={cn(
95
+ 'ios:pl-3 ios:pt-1 pl-3 pt-0.5 text-muted-foreground',
96
+ footnoteClassName
97
+ )}
98
+ variant="footnote">
99
+ {footnote}
100
+ </Text>
101
+ )}
102
+ </View>
103
+ </View>
104
+ );
105
+ }
106
+ );
107
+
108
+ const FormItem = React.forwardRef<
109
+ View,
110
+ ViewProps & {
111
+ isLast?: boolean;
112
+ iosSeparatorClassName?: string;
113
+ }
114
+ >(({ className, isLast, iosSeparatorClassName, ...props }, ref) => {
115
+ return (
116
+ <>
117
+ <View ref={ref} className={cn('ios:pr-1', className)} {...props} />
118
+ {Platform.OS === 'ios' && !isLast && (
119
+ <View className={cn('ml-2 h-px flex-1 bg-border', iosSeparatorClassName)} />
120
+ )}
121
+ </>
122
+ );
123
+ });
124
+
125
+ export { Form, FormItem, FormSection };
@@ -0,0 +1,99 @@
1
+ import { useHeaderHeight } from '@react-navigation/elements';
2
+ import { Portal } from '@rn-primitives/portal';
3
+ import { Stack } from 'expo-router';
4
+ import * as React from 'react';
5
+ import { View } from 'react-native';
6
+ import Animated, { FadeIn } from 'react-native-reanimated';
7
+
8
+ import type {
9
+ LargeTitleHeaderProps,
10
+ NativeStackNavigationOptions,
11
+ NativeStackNavigationSearchBarOptions,
12
+ } from './types';
13
+
14
+ import { useColorScheme } from '~/lib/useColorScheme';
15
+
16
+ export function LargeTitleHeader(props: LargeTitleHeaderProps) {
17
+ const id = React.useId();
18
+ const { colors } = useColorScheme();
19
+ const headerHeight = useHeaderHeight();
20
+ const [isFocused, setIsFocused] = React.useState(false);
21
+
22
+ return (
23
+ <>
24
+ <Stack.Screen options={propsToScreenOptions(props, colors.background, setIsFocused)} />
25
+ {props.searchBar?.content && isFocused && (
26
+ <Portal name={`large-title:${id}`}>
27
+ <Animated.View
28
+ entering={FadeIn.delay(100)}
29
+ style={{ top: headerHeight + 6 }}
30
+ className="absolute bottom-0 left-0 right-0">
31
+ {props.searchBar?.content}
32
+ </Animated.View>
33
+ </Portal>
34
+ )}
35
+ </>
36
+ );
37
+ }
38
+
39
+ function propsToScreenOptions(
40
+ props: LargeTitleHeaderProps,
41
+ backgroundColor: string,
42
+ setIsFocused: React.Dispatch<React.SetStateAction<boolean>>
43
+ ): NativeStackNavigationOptions {
44
+ return {
45
+ headerLargeTitle: true,
46
+ headerBackButtonMenuEnabled: props.iosBackButtonMenuEnabled,
47
+ headerBackTitle: props.iosBackButtonTitle,
48
+ headerBackTitleVisible: props.iosBackButtonTitleVisible,
49
+ headerBackVisible: props.backVisible,
50
+ headerLargeTitleShadowVisible: props.shadowVisible,
51
+ headerBlurEffect:
52
+ props.iosBlurEffect === 'none' ? undefined : (props.iosBlurEffect ?? 'systemMaterial'),
53
+ headerShadowVisible: props.shadowVisible,
54
+ headerLeft: props.leftView
55
+ ? (headerProps) => (
56
+ <View className="flex-row justify-center gap-4">{props.leftView!(headerProps)}</View>
57
+ )
58
+ : undefined,
59
+ headerRight: props.rightView
60
+ ? (headerProps) => (
61
+ <View className="flex-row justify-center gap-4">{props.rightView!(headerProps)}</View>
62
+ )
63
+ : undefined,
64
+ headerShown: props.shown,
65
+ headerTitle: props.title,
66
+ headerTransparent: props.iosBlurEffect !== 'none',
67
+ headerLargeStyle: { backgroundColor: props.backgroundColor ?? backgroundColor },
68
+ headerStyle:
69
+ props.iosBlurEffect === 'none'
70
+ ? { backgroundColor: props.backgroundColor ?? backgroundColor }
71
+ : undefined,
72
+ headerSearchBarOptions: props.searchBar
73
+ ? {
74
+ autoCapitalize: props.searchBar?.autoCapitalize,
75
+ cancelButtonText: props.searchBar?.iosCancelButtonText,
76
+ hideWhenScrolling: props.searchBar?.iosHideWhenScrolling ?? false,
77
+ inputType: props.searchBar?.inputType,
78
+ tintColor: props.searchBar?.iosTintColor,
79
+ onBlur: () => {
80
+ setIsFocused(false);
81
+ props.searchBar?.onBlur?.();
82
+ },
83
+ onCancelButtonPress: props.searchBar?.onCancelButtonPress,
84
+ onChangeText: props.searchBar?.onChangeText
85
+ ? (event) => props.searchBar?.onChangeText!(event.nativeEvent.text)
86
+ : undefined,
87
+ onFocus: () => {
88
+ setIsFocused(true);
89
+ props.searchBar?.onFocus?.();
90
+ },
91
+ onSearchButtonPress: props.searchBar?.onSearchButtonPress,
92
+ placeholder: props.searchBar?.placeholder ?? 'Search...',
93
+ ref: props.searchBar?.ref as NativeStackNavigationSearchBarOptions['ref'],
94
+ textColor: props.searchBar?.textColor,
95
+ }
96
+ : undefined,
97
+ ...props.screen,
98
+ };
99
+ }