nwui-cli 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) 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/no-install/app/+html.tsx +46 -0
  212. package/no-install/app/+not-found.tsx +25 -0
  213. package/no-install/app/_layout.tsx +7 -0
  214. package/no-install/app/details.tsx +20 -0
  215. package/no-install/app/index.tsx +19 -0
  216. package/no-install/app-env.d.ts +2 -0
  217. package/no-install/app.json +41 -0
  218. package/no-install/assets/adaptive-icon.png +0 -0
  219. package/no-install/assets/favicon.png +0 -0
  220. package/no-install/assets/icon.png +0 -0
  221. package/no-install/assets/splash.png +0 -0
  222. package/no-install/babel.config.js +13 -0
  223. package/no-install/cesconfig.json +35 -0
  224. package/no-install/components/Button.tsx +25 -0
  225. package/no-install/components/Container.tsx +9 -0
  226. package/no-install/components/EditScreenInfo.tsx +31 -0
  227. package/no-install/components/ScreenContent.tsx +29 -0
  228. package/no-install/components/nativewindui/Slider.tsx +26 -0
  229. package/no-install/global.css +3 -0
  230. package/no-install/metro.config.js +10 -0
  231. package/no-install/package-lock.json +17505 -0
  232. package/no-install/package.json +59 -0
  233. package/no-install/prettier.config.js +10 -0
  234. package/no-install/tailwind.config.js +14 -0
  235. package/package.json +2 -2
@@ -0,0 +1,31 @@
1
+ import RNSegmentedControl from '@react-native-segmented-control/segmented-control';
2
+
3
+ import { SegmentControlProps } from './types';
4
+
5
+ function SegmentedControl({
6
+ values,
7
+ selectedIndex,
8
+ onIndexChange,
9
+ onValueChange: onValueChangeProp,
10
+ enabled = true,
11
+ iosMomentary: _iosMomentary,
12
+ }: SegmentControlProps) {
13
+ function onChange(event: { nativeEvent: { selectedSegmentIndex: number } }) {
14
+ onIndexChange?.(event.nativeEvent.selectedSegmentIndex);
15
+ }
16
+
17
+ function onValueChange(value: string) {
18
+ onValueChangeProp?.(value);
19
+ }
20
+ return (
21
+ <RNSegmentedControl
22
+ enabled={enabled}
23
+ values={values}
24
+ selectedIndex={selectedIndex}
25
+ onChange={onChange}
26
+ onValueChange={onValueChange}
27
+ />
28
+ );
29
+ }
30
+
31
+ export { SegmentedControl };
@@ -0,0 +1,55 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+
4
+ import { SegmentControlProps } from './types';
5
+
6
+ import { Text } from '~/components/nativewindui/Text';
7
+ import { Button } from '~/components/nativewindui/Button';
8
+ import { cn } from '~/lib/cn';
9
+
10
+ function SegmentedControl({
11
+ values,
12
+ selectedIndex,
13
+ onIndexChange,
14
+ onValueChange,
15
+ enabled = true,
16
+ iosMomentary: _iosMomentary,
17
+ }: SegmentControlProps) {
18
+ const id = React.useId();
19
+
20
+ function onPress(index: number, value: string) {
21
+ return () => {
22
+ onIndexChange?.(index);
23
+ onValueChange?.(value);
24
+ };
25
+ }
26
+ return (
27
+ <View className="border-foreground/50 flex-row rounded-full border">
28
+ {values.map((value, index) => {
29
+ return (
30
+ <View key={`segment:${id}-${index}-${value}`} className="flex-1">
31
+ <Button
32
+ disabled={!enabled}
33
+ size="sm"
34
+ variant={selectedIndex === index ? 'tonal' : 'plain'}
35
+ androidRootClassName={cn(
36
+ 'rounded-none',
37
+ index === 0 && 'rounded-l-full',
38
+ index === values?.length - 1 && 'rounded-r-full'
39
+ )}
40
+ className={cn(
41
+ 'rounded-none py-2.5',
42
+ index === 0 && 'rounded-l-full',
43
+ index === values?.length - 1 ? 'rounded-r-full' : 'border-foreground/50 border-r'
44
+ )}
45
+ onPress={onPress(index, value)}>
46
+ <Text>{value}</Text>
47
+ </Button>
48
+ </View>
49
+ );
50
+ })}
51
+ </View>
52
+ );
53
+ }
54
+
55
+ export { SegmentedControl };
@@ -0,0 +1 @@
1
+ export * from './SegmentedControl';
@@ -0,0 +1,15 @@
1
+ type SegmentControlProps = {
2
+ enabled?: boolean;
3
+ onIndexChange?: (index: number) => void;
4
+ onValueChange?: (value: string) => void;
5
+ selectedIndex?: number;
6
+
7
+ values: string[];
8
+
9
+ /**
10
+ * If true, then selecting a segment won't persist visually. The onValueChange callback will still work as expected.
11
+ */
12
+ iosMomentary?: boolean;
13
+ };
14
+
15
+ export type { SegmentControlProps };
@@ -0,0 +1,62 @@
1
+ import { Icon } from '@roninoss/icons';
2
+ import { Pressable, View, type PressableProps, type ViewProps, type ViewStyle } from 'react-native';
3
+
4
+ import { cn } from '~/lib/cn';
5
+ import { useColorScheme } from '~/lib/useColorScheme';
6
+
7
+ // Add as class when possible: https://github.com/marklawlor/nativewind/issues/522
8
+ const BORDER_CURVE: ViewStyle = {
9
+ borderCurve: 'continuous',
10
+ };
11
+
12
+ type withoutChildren<T> = Omit<T, 'children'>;
13
+
14
+ type StepperProps = withoutChildren<ViewProps> & {
15
+ subtractButton?: withoutChildren<PressableProps>;
16
+ addButton?: withoutChildren<PressableProps>;
17
+ };
18
+
19
+ function Stepper({ className, subtractButton, addButton, ...props }: StepperProps) {
20
+ const { colors } = useColorScheme();
21
+ return (
22
+ <View
23
+ style={BORDER_CURVE}
24
+ className={cn(
25
+ 'ios:bg-card ios:rounded-md ios:border-0 flex-row items-center overflow-hidden rounded-full border border-border',
26
+ className
27
+ )}
28
+ {...props}>
29
+ <Pressable
30
+ {...subtractButton}
31
+ className={cn(
32
+ 'ios:active:bg-border/30 active:bg-primary/10 dark:active:bg-primary/15 dark:ios:active:bg-border/30 ios:px-3 ios:h-[30px] h-[38px] justify-center px-5',
33
+ subtractButton?.disabled && 'bg-border/20 opacity-70 dark:opacity-50',
34
+ subtractButton?.className
35
+ )}>
36
+ <Icon
37
+ name="minus"
38
+ size={21}
39
+ color={colors.foreground}
40
+ materialIcon={{ style: { opacity: 0.6 } }}
41
+ />
42
+ </Pressable>
43
+ <View className="ios:h-5 ios:bg-border h-[38px] w-px rounded-full bg-border" />
44
+ <Pressable
45
+ {...addButton}
46
+ className={cn(
47
+ 'ios:active:bg-border/30 active:bg-primary/10 dark:active:bg-primary/15 dark:ios:active:bg-border/30 ios:px-3 ios:h-[30px] h-[38px] justify-center px-5',
48
+ addButton?.disabled && 'bg-border/20 opacity-70 dark:opacity-50',
49
+ addButton?.className
50
+ )}>
51
+ <Icon
52
+ name="plus"
53
+ size={21}
54
+ color={colors.foreground}
55
+ materialIcon={{ style: { opacity: 0.6 } }}
56
+ />
57
+ </Pressable>
58
+ </View>
59
+ );
60
+ }
61
+
62
+ export { Stepper };
@@ -0,0 +1,55 @@
1
+ import { VariantProps, cva } from 'class-variance-authority';
2
+ import { cssInterop } from 'nativewind';
3
+ import * as React from 'react';
4
+ import { UITextView } from 'react-native-uitextview';
5
+
6
+ import { cn } from '~/lib/cn';
7
+
8
+ cssInterop(UITextView, { className: 'style' });
9
+
10
+ const textVariants = cva('text-foreground', {
11
+ variants: {
12
+ variant: {
13
+ largeTitle: 'text-4xl',
14
+ title1: 'text-2xl',
15
+ title2: 'text-[22px] leading-7',
16
+ title3: 'text-xl',
17
+ heading: 'text-[17px] leading-6 font-semibold',
18
+ body: 'text-[17px] leading-6',
19
+ callout: 'text-base',
20
+ subhead: 'text-[15px] leading-6',
21
+ footnote: 'text-[13px] leading-5',
22
+ caption1: 'text-xs',
23
+ caption2: 'text-[11px] leading-4',
24
+ },
25
+ color: {
26
+ primary: '',
27
+ secondary: 'text-secondary-foreground/90',
28
+ tertiary: 'text-muted-foreground/90',
29
+ quarternary: 'text-muted-foreground/50',
30
+ },
31
+ },
32
+ defaultVariants: {
33
+ variant: 'body',
34
+ color: 'primary',
35
+ },
36
+ });
37
+
38
+ const TextClassContext = React.createContext<string | undefined>(undefined);
39
+
40
+ function Text({
41
+ className,
42
+ variant,
43
+ color,
44
+ ...props
45
+ }: React.ComponentPropsWithoutRef<typeof UITextView> & VariantProps<typeof textVariants>) {
46
+ const textClassName = React.useContext(TextClassContext);
47
+ return (
48
+ <UITextView
49
+ className={cn(textVariants({ variant, color }), textClassName, className)}
50
+ {...props}
51
+ />
52
+ );
53
+ }
54
+
55
+ export { Text, TextClassContext, textVariants };
@@ -0,0 +1,85 @@
1
+ import { useAugmentedRef, useControllableState } from '@rn-primitives/hooks';
2
+ import * as React from 'react';
3
+ import { Pressable, TextInput, View } from 'react-native';
4
+
5
+ import type { TextFieldProps, TextFieldRef } from './types';
6
+
7
+ import { Text } from '~/components/nativewindui/Text';
8
+ import { cn } from '~/lib/cn';
9
+
10
+ const TextField = React.forwardRef<TextFieldRef, TextFieldProps>(
11
+ (
12
+ {
13
+ value: valueProp,
14
+ onChangeText: onChangeTextProp,
15
+ editable,
16
+ className,
17
+ children,
18
+ leftView,
19
+ rightView,
20
+ label,
21
+ labelClassName,
22
+ containerClassName,
23
+ accessibilityHint,
24
+ errorMessage,
25
+ materialVariant: _materialVariant,
26
+ ...props
27
+ },
28
+ ref
29
+ ) => {
30
+ const inputRef = useAugmentedRef({ ref, methods: { focus, blur, clear } });
31
+
32
+ const [value = '', onChangeText] = useControllableState({
33
+ prop: valueProp,
34
+ defaultProp: valueProp ?? '',
35
+ onChange: onChangeTextProp,
36
+ });
37
+
38
+ function focus() {
39
+ inputRef.current?.focus();
40
+ }
41
+
42
+ function blur() {
43
+ inputRef.current?.blur();
44
+ }
45
+
46
+ function clear() {
47
+ onChangeText('');
48
+ }
49
+
50
+ return (
51
+ <Pressable
52
+ className={cn(editable === false && 'opacity-50', containerClassName)}
53
+ disabled={editable === false}
54
+ onPress={focus}>
55
+ {!!label && (
56
+ <View className={cn('flex-row pt-2', !leftView ? 'pl-1.5' : 'pl-2')}>
57
+ {leftView}
58
+ <Text
59
+ className={cn('text-muted-foreground', !leftView ? 'pl-1' : 'pl-2', labelClassName)}>
60
+ {label}
61
+ </Text>
62
+ </View>
63
+ )}
64
+ <View className="flex-row">
65
+ {!!leftView && !label && leftView}
66
+ <TextInput
67
+ ref={inputRef}
68
+ editable={editable}
69
+ className={cn('flex-1 px-2.5 py-3 text-[17px] text-foreground', className)}
70
+ onChangeText={onChangeText}
71
+ value={value}
72
+ clearButtonMode="while-editing"
73
+ accessibilityHint={accessibilityHint ?? errorMessage}
74
+ {...props}
75
+ />
76
+ {rightView}
77
+ </View>
78
+ </Pressable>
79
+ );
80
+ }
81
+ );
82
+
83
+ TextField.displayName = 'iOSTextField';
84
+
85
+ export { TextField };
@@ -0,0 +1,326 @@
1
+ import { useAugmentedRef, useControllableState } from '@rn-primitives/hooks';
2
+ import { Icon } from '@roninoss/icons';
3
+ import { cva } from 'class-variance-authority';
4
+ import * as React from 'react';
5
+ import {
6
+ Pressable,
7
+ TextInput,
8
+ View,
9
+ ViewProps,
10
+ ViewStyle,
11
+ type NativeSyntheticEvent,
12
+ type TextInputFocusEventData,
13
+ } from 'react-native';
14
+ import Animated, {
15
+ FadeIn,
16
+ FadeOut,
17
+ useAnimatedStyle,
18
+ useDerivedValue,
19
+ withTiming,
20
+ } from 'react-native-reanimated';
21
+
22
+ import type { TextFieldProps, TextFieldRef } from './types';
23
+
24
+ import { cn } from '~/lib/cn';
25
+ import { useColorScheme } from '~/lib/useColorScheme';
26
+
27
+ const TextField = React.forwardRef<TextFieldRef, TextFieldProps>(
28
+ (
29
+ {
30
+ value: valueProp,
31
+ defaultValue: defaultValueProp,
32
+ onChangeText: onChangeTextProp,
33
+ onFocus: onFocusProp,
34
+ onBlur: onBlurProp,
35
+ placeholder,
36
+ editable,
37
+ className,
38
+ children,
39
+ leftView,
40
+ rightView,
41
+ label,
42
+ labelClassName,
43
+ containerClassName,
44
+ accessibilityHint,
45
+ errorMessage,
46
+ materialVariant = 'outlined',
47
+ ...props
48
+ },
49
+ ref
50
+ ) => {
51
+ const inputRef = useAugmentedRef({ ref, methods: { focus, blur, clear } });
52
+ const [isFocused, setIsFocused] = React.useState(false);
53
+
54
+ const [value = '', onChangeText] = useControllableState({
55
+ prop: valueProp,
56
+ defaultProp: valueProp ?? '',
57
+ onChange: onChangeTextProp,
58
+ });
59
+
60
+ function focus() {
61
+ inputRef.current?.focus();
62
+ }
63
+
64
+ function blur() {
65
+ inputRef.current?.blur();
66
+ }
67
+
68
+ function clear() {
69
+ onChangeText('');
70
+ }
71
+
72
+ function onFocus(e: NativeSyntheticEvent<TextInputFocusEventData>) {
73
+ setIsFocused(true);
74
+ onFocusProp?.(e);
75
+ }
76
+
77
+ function onBlur(e: NativeSyntheticEvent<TextInputFocusEventData>) {
78
+ setIsFocused(false);
79
+ onBlurProp?.(e);
80
+ }
81
+
82
+ const InputWrapper = materialVariant === 'filled' ? FilledWrapper : FilledWrapper;
83
+
84
+ return (
85
+ <Pressable
86
+ className={rootVariants({
87
+ variant: materialVariant,
88
+ state: getInputState({
89
+ isFocused,
90
+ hasError: !!errorMessage,
91
+ editable,
92
+ }),
93
+ className: containerClassName,
94
+ })}
95
+ disabled={editable === false}
96
+ onPress={focus}>
97
+ <View
98
+ className={innerRootVariants({
99
+ variant: materialVariant,
100
+ state: getInputState({
101
+ isFocused,
102
+ hasError: !!errorMessage,
103
+ editable,
104
+ }),
105
+ })}>
106
+ {leftView}
107
+ <InputWrapper>
108
+ {!!label && (
109
+ <MaterialLabel
110
+ materialVariant={materialVariant}
111
+ isFocused={isFocused}
112
+ value={value}
113
+ materialLabel={label}
114
+ hasLeftView={!!leftView}
115
+ className={labelClassName}
116
+ hasError={!!errorMessage}
117
+ />
118
+ )}
119
+ <TextInput
120
+ ref={inputRef}
121
+ editable={editable}
122
+ className={cn(
123
+ 'flex-1 rounded py-3 pl-2.5 text-[17px] text-foreground dark:placeholder:text-white/30',
124
+ materialVariant === 'filled' && !!label && 'pb-2 pt-5',
125
+ className
126
+ )}
127
+ placeholder={isFocused || !label ? placeholder : ''}
128
+ onFocus={onFocus}
129
+ onBlur={onBlur}
130
+ onChangeText={onChangeText}
131
+ value={value}
132
+ accessibilityHint={accessibilityHint ?? errorMessage}
133
+ {...props}
134
+ />
135
+ </InputWrapper>
136
+ {!!errorMessage ? (
137
+ <MaterialErrorIcon />
138
+ ) : (
139
+ !!value && isFocused && <MaterialClearIcon clearText={clear} editable={editable} />
140
+ )}
141
+ {rightView}
142
+ </View>
143
+ </Pressable>
144
+ );
145
+ }
146
+ );
147
+
148
+ TextField.displayName = 'TextField';
149
+
150
+ export { TextField };
151
+
152
+ type InputState = 'idle' | 'focused' | 'error' | 'errorAndFocused' | 'disabled';
153
+
154
+ type GetInputArgs = {
155
+ isFocused: boolean;
156
+ hasError?: boolean;
157
+ editable?: boolean;
158
+ };
159
+
160
+ function getInputState(args: GetInputArgs): InputState {
161
+ if (args.editable === false) return 'disabled';
162
+ if (args.hasError && args.isFocused) return 'errorAndFocused';
163
+ if (args.isFocused) return 'focused';
164
+ return 'idle';
165
+ }
166
+
167
+ const rootVariants = cva('relative rounded-[5px]', {
168
+ variants: {
169
+ variant: {
170
+ outlined: 'border',
171
+ filled: 'border-b rounded-b-none',
172
+ },
173
+ state: {
174
+ idle: 'border-transparent',
175
+ error: 'border-transparent',
176
+ focused: 'border-primary',
177
+ errorAndFocused: 'border-destructive',
178
+ disabled: 'opacity-50',
179
+ },
180
+ },
181
+ defaultVariants: {
182
+ variant: 'outlined',
183
+ state: 'idle',
184
+ },
185
+ });
186
+
187
+ const innerRootVariants = cva('flex-row rounded', {
188
+ variants: {
189
+ variant: {
190
+ outlined: 'border border-border',
191
+ filled: 'border-b bg-border/70 rounded-b-none ',
192
+ },
193
+ state: {
194
+ idle: 'border-foreground/30',
195
+ error: 'border-destructive',
196
+ focused: 'border-primary',
197
+ errorAndFocused: 'border-destructive',
198
+ disabled: 'border-foreground/30',
199
+ },
200
+ },
201
+ defaultVariants: {
202
+ variant: 'outlined',
203
+ state: 'idle',
204
+ },
205
+ });
206
+
207
+ function FilledWrapper(props: ViewProps) {
208
+ return <View className="relative flex-1 flex-row" {...props} />;
209
+ }
210
+
211
+ type MaterialLabelProps = {
212
+ isFocused: boolean;
213
+ value: string;
214
+ materialLabel: string;
215
+ hasLeftView: boolean;
216
+ hasError?: boolean;
217
+ className?: string;
218
+ materialVariant: 'outlined' | 'filled';
219
+ };
220
+
221
+ const DEFAULT_TEXT_FIELD_HEIGHT = 56;
222
+
223
+ function MaterialLabel(props: MaterialLabelProps) {
224
+ const isLifted = props.isFocused || !!props.value;
225
+ const isLiftedDerived = useDerivedValue(() => isLifted);
226
+ const hasLeftViewDerived = useDerivedValue(() => props.hasLeftView);
227
+ const variantDerived = useDerivedValue(() => props.materialVariant);
228
+ const animatedRootStyle = useAnimatedStyle(() => {
229
+ const style: ViewStyle = {
230
+ position: 'absolute',
231
+ alignSelf: 'center',
232
+ };
233
+ if (variantDerived.value === 'outlined') {
234
+ style.paddingLeft = withTiming(hasLeftViewDerived.value && isLiftedDerived.value ? 0 : 12, {
235
+ duration: 200,
236
+ });
237
+ style.transform = [
238
+ {
239
+ translateY: withTiming(isLiftedDerived.value ? -DEFAULT_TEXT_FIELD_HEIGHT / 2 : 0, {
240
+ duration: 200,
241
+ }),
242
+ },
243
+ {
244
+ translateX: withTiming(hasLeftViewDerived.value && isLiftedDerived.value ? -12 : 0, {
245
+ duration: 200,
246
+ }),
247
+ },
248
+ ];
249
+ }
250
+ if (variantDerived.value === 'filled') {
251
+ style.paddingLeft = 8;
252
+ style.transform = [
253
+ {
254
+ translateY: withTiming(isLiftedDerived.value ? -DEFAULT_TEXT_FIELD_HEIGHT / 4 : 0, {
255
+ duration: 200,
256
+ }),
257
+ },
258
+ {
259
+ translateX: 0,
260
+ },
261
+ ];
262
+ }
263
+ return style;
264
+ });
265
+ const animatedTextStyle = useAnimatedStyle(() => {
266
+ return {
267
+ fontSize: withTiming(isLiftedDerived.value ? 10 : 17, { duration: 200 }),
268
+ };
269
+ });
270
+ return (
271
+ <Animated.View style={animatedRootStyle} pointerEvents="none">
272
+ <Animated.Text
273
+ className={cn(
274
+ 'bg-card/0 text-foreground/70 rounded',
275
+ isLifted && 'px-0.5',
276
+ isLifted && props.materialVariant === 'outlined' && 'bg-background',
277
+ props.isFocused && 'text-primary/60 dark:text-primary',
278
+ props.hasError && 'text-destructive dark:text-destructive',
279
+ props.className
280
+ )}
281
+ style={animatedTextStyle}>
282
+ {props.materialLabel}
283
+ </Animated.Text>
284
+ </Animated.View>
285
+ );
286
+ }
287
+
288
+ type MaterialClearIconProps = {
289
+ editable?: boolean;
290
+ clearText: () => void;
291
+ };
292
+
293
+ function MaterialClearIcon(props: MaterialClearIconProps) {
294
+ const { colors } = useColorScheme();
295
+ return (
296
+ <Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(200)}>
297
+ <Pressable
298
+ disabled={props.editable === false}
299
+ className="flex-1 justify-center px-2 active:opacity-65"
300
+ onPress={props.clearText}>
301
+ <Icon color={colors.grey2} name="close-circle-outline" size={24} />
302
+ </Pressable>
303
+ </Animated.View>
304
+ );
305
+ }
306
+
307
+ function MaterialErrorIcon() {
308
+ const { colors } = useColorScheme();
309
+ return (
310
+ <Animated.View
311
+ pointerEvents="none"
312
+ entering={FadeIn.duration(200)}
313
+ exiting={FadeOut.duration(200)}
314
+ className="justify-center pr-2">
315
+ <Icon
316
+ color={colors.destructive}
317
+ name="close-circle-outline"
318
+ materialIcon={{
319
+ name: 'alert-circle',
320
+ type: 'MaterialCommunityIcons',
321
+ }}
322
+ size={24}
323
+ />
324
+ </Animated.View>
325
+ );
326
+ }
@@ -0,0 +1 @@
1
+ export * from './TextField';
@@ -0,0 +1,26 @@
1
+ import type { TextInput, TextInputProps } from 'react-native';
2
+
3
+ type TextFieldProps = TextInputProps & {
4
+ children?: React.ReactNode;
5
+ leftView?: React.ReactNode;
6
+ rightView?: React.ReactNode;
7
+ label?: string;
8
+ labelClassName?: string;
9
+ containerClassName?: string;
10
+ /**
11
+ * For accessibility, can be overridden by accessibilityHint
12
+ * @Material - shows error state with destructive color and icon
13
+ * @iOS - No visual change
14
+ */
15
+ errorMessage?: string;
16
+ /**
17
+ * @MaterialOnly
18
+ * @default outlined
19
+ * Material variant for the input.
20
+ */
21
+ materialVariant?: 'outlined' | 'filled';
22
+ };
23
+
24
+ type TextFieldRef = TextInput;
25
+
26
+ export type { TextFieldProps, TextFieldRef };