create-react-native-starter-kit 0.0.0-stage → 1.0.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 (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +378 -2
  3. package/bin/create-react-native-starter-kit.js +95 -0
  4. package/lib/copy-src.js +127 -0
  5. package/lib/creator.js +211 -0
  6. package/lib/deps.js +58 -0
  7. package/lib/patch-configs.js +318 -0
  8. package/lib/patch-native.js +387 -0
  9. package/package.json +47 -4
  10. package/scripts/sync-template.js +52 -0
  11. package/template/.env.example +3 -0
  12. package/template/patches/react-native-element-dropdown+2.12.4.patch +67 -0
  13. package/template/src/app/App.tsx +25 -0
  14. package/template/src/app/navigation/root.tsx +24 -0
  15. package/template/src/app/navigation/stacks/app.stack.tsx +67 -0
  16. package/template/src/app/navigation/stacks/app.tab.tsx +72 -0
  17. package/template/src/app/navigation/stacks/auth.stack.tsx +56 -0
  18. package/template/src/app/providers.tsx +43 -0
  19. package/template/src/assets/fonts/InterTight-Black.ttf +0 -0
  20. package/template/src/assets/fonts/InterTight-BlackItalic.ttf +0 -0
  21. package/template/src/assets/fonts/InterTight-Bold.ttf +0 -0
  22. package/template/src/assets/fonts/InterTight-BoldItalic.ttf +0 -0
  23. package/template/src/assets/fonts/InterTight-ExtraBold.ttf +0 -0
  24. package/template/src/assets/fonts/InterTight-ExtraBoldItalic.ttf +0 -0
  25. package/template/src/assets/fonts/InterTight-ExtraLight.ttf +0 -0
  26. package/template/src/assets/fonts/InterTight-ExtraLightItalic.ttf +0 -0
  27. package/template/src/assets/fonts/InterTight-Italic.ttf +0 -0
  28. package/template/src/assets/fonts/InterTight-Light.ttf +0 -0
  29. package/template/src/assets/fonts/InterTight-LightItalic.ttf +0 -0
  30. package/template/src/assets/fonts/InterTight-Medium.ttf +0 -0
  31. package/template/src/assets/fonts/InterTight-MediumItalic.ttf +0 -0
  32. package/template/src/assets/fonts/InterTight-Regular.ttf +0 -0
  33. package/template/src/assets/fonts/InterTight-SemiBold.ttf +0 -0
  34. package/template/src/assets/fonts/InterTight-SemiBoldItalic.ttf +0 -0
  35. package/template/src/assets/fonts/InterTight-Thin.ttf +0 -0
  36. package/template/src/assets/fonts/InterTight-ThinItalic.ttf +0 -0
  37. package/template/src/assets/icons/back.svg +3 -0
  38. package/template/src/assets/icons/calendar.svg +3 -0
  39. package/template/src/assets/icons/claim_upload.svg +3 -0
  40. package/template/src/assets/icons/clock.svg +1 -0
  41. package/template/src/assets/icons/downArrow.svg +3 -0
  42. package/template/src/assets/icons/edit.svg +3 -0
  43. package/template/src/assets/icons/eye.svg +4 -0
  44. package/template/src/assets/icons/eyeClose.svg +7 -0
  45. package/template/src/assets/icons/folder.svg +5 -0
  46. package/template/src/assets/icons/home.svg +4 -0
  47. package/template/src/assets/icons/index.ts +33 -0
  48. package/template/src/assets/icons/setting.svg +4 -0
  49. package/template/src/assets/icons/tabs/home/filled_dark.svg +3 -0
  50. package/template/src/assets/icons/tabs/home/filled_light.svg +3 -0
  51. package/template/src/assets/icons/tabs/home/outline.svg +4 -0
  52. package/template/src/assets/icons/tabs/index.ts +31 -0
  53. package/template/src/assets/icons/tabs/profile/filled_dark.svg +6 -0
  54. package/template/src/assets/icons/tabs/profile/filled_light.svg +6 -0
  55. package/template/src/assets/icons/tabs/profile/outline.svg +3 -0
  56. package/template/src/assets/icons/tooltip_dark.svg +1 -0
  57. package/template/src/assets/icons/tooltip_light.svg +1 -0
  58. package/template/src/assets/icons/upArrow.svg +3 -0
  59. package/template/src/assets/images/back.png +0 -0
  60. package/template/src/assets/images/index.ts +7 -0
  61. package/template/src/assets/images/placeholder/profile.png +0 -0
  62. package/template/src/components/shared/AppImage.tsx +190 -0
  63. package/template/src/components/shared/AvatarPicker.tsx +175 -0
  64. package/template/src/components/shared/CustomButton.tsx +273 -0
  65. package/template/src/components/shared/DocumentPicker.tsx +86 -0
  66. package/template/src/components/shared/GlobalLoader.tsx +47 -0
  67. package/template/src/components/shared/Icon.tsx +28 -0
  68. package/template/src/components/shared/PressableIcon.tsx +104 -0
  69. package/template/src/components/shared/bottom-sheet/BaseBottomSheet.tsx +30 -0
  70. package/template/src/components/shared/bottom-sheet/BaseBottomSheetModal.tsx +50 -0
  71. package/template/src/components/shared/bottom-sheet/sheets/ImagePickerSheet.tsx +310 -0
  72. package/template/src/components/shared/bottom-sheet/types.ts +4 -0
  73. package/template/src/components/shared/form-input/FormInput.tsx +139 -0
  74. package/template/src/components/shared/form-input/FormInputRenderer.tsx +82 -0
  75. package/template/src/components/shared/form-input/FullNameInput.tsx +243 -0
  76. package/template/src/components/shared/form-input/formFieldStyles.ts +43 -0
  77. package/template/src/components/shared/form-input/type.ts +188 -0
  78. package/template/src/components/shared/form-input/variants/CountryPhoneVariant.tsx +289 -0
  79. package/template/src/components/shared/form-input/variants/DateTimeVariant.tsx +280 -0
  80. package/template/src/components/shared/form-input/variants/DropdownVariant.tsx +221 -0
  81. package/template/src/components/shared/form-input/variants/TextInputVariant.tsx +300 -0
  82. package/template/src/components/shared/form-input/variants/ToggleVariant.tsx +194 -0
  83. package/template/src/components/shared/modal/BaseModal.tsx +83 -0
  84. package/template/src/components/shared/modal/common/AlertModal.tsx +173 -0
  85. package/template/src/components/shared/navigation/AnimatedTabIcon.tsx +37 -0
  86. package/template/src/components/shared/navigation/HeaderActionButton.tsx +70 -0
  87. package/template/src/components/shared/navigation/HeaderBackButton.tsx +38 -0
  88. package/template/src/components/shared/navigation/StackHeader.tsx +105 -0
  89. package/template/src/components/shared/navigation/tabIconRender.tsx +14 -0
  90. package/template/src/components/shared/offline/OfflineQueryBoundary.tsx +25 -0
  91. package/template/src/components/shared/offline/OfflineState.tsx +229 -0
  92. package/template/src/components/shared/offline/index.ts +6 -0
  93. package/template/src/components/shared/offline/types.ts +15 -0
  94. package/template/src/components/shared/offline/wifi-icon-animation/BrokenWifiAnimation.tsx +116 -0
  95. package/template/src/components/shared/offline/wifi-icon-animation/WifiPiece.tsx +80 -0
  96. package/template/src/components/shared/offline/wifi-icon-animation/geometry.ts +163 -0
  97. package/template/src/components/shared/offline/wifi-icon-animation/useWifiIconAnimationActive.ts +37 -0
  98. package/template/src/components/shared/skelton/BaseSkelton.tsx +71 -0
  99. package/template/src/components/shared/skelton/ShimmerHolder.ts +6 -0
  100. package/template/src/components/shared/skelton/holders/HomeShimmer.tsx +25 -0
  101. package/template/src/components/shared/skelton/holders/index.ts +1 -0
  102. package/template/src/components/shared/skelton/layouts/avatar.layout.ts +18 -0
  103. package/template/src/components/shared/skelton/layouts/home.layout.ts +26 -0
  104. package/template/src/components/shared/skelton/layouts/index.ts +3 -0
  105. package/template/src/components/shared/skelton/layouts/text.layout.ts +18 -0
  106. package/template/src/components/shared/text/CustomText.tsx +85 -0
  107. package/template/src/components/shared/text/ShimmerText.tsx +159 -0
  108. package/template/src/components/shared/text/types.ts +40 -0
  109. package/template/src/constants/device.ts +12 -0
  110. package/template/src/constants/endpoint.ts +11 -0
  111. package/template/src/constants/keyExtractor.ts +6 -0
  112. package/template/src/constants/limits.ts +9 -0
  113. package/template/src/constants/queryKey.ts +3 -0
  114. package/template/src/constants/regex.ts +7 -0
  115. package/template/src/context/NetworkContext.tsx +102 -0
  116. package/template/src/context/ThemeContext.tsx +56 -0
  117. package/template/src/hooks/app/index.ts +2 -0
  118. package/template/src/hooks/app/useGetProfile.ts +38 -0
  119. package/template/src/hooks/app/useUpdateProfile.ts +21 -0
  120. package/template/src/hooks/useAppDispatch.ts +6 -0
  121. package/template/src/hooks/useAppSelector.ts +4 -0
  122. package/template/src/hooks/useDebounce.ts +15 -0
  123. package/template/src/hooks/useDocumentPicker.ts +102 -0
  124. package/template/src/hooks/useImagePicker.ts +83 -0
  125. package/template/src/i18n/i18next.d.ts +9 -0
  126. package/template/src/i18n/index.ts +16 -0
  127. package/template/src/i18n/locales/en.json +274 -0
  128. package/template/src/i18n/locales/ru.json +165 -0
  129. package/template/src/i18n/resources.ts +11 -0
  130. package/template/src/redux/selectors/auth.selectors.ts +4 -0
  131. package/template/src/redux/slice/auth.slice.ts +23 -0
  132. package/template/src/redux/slice/loader.slice.ts +25 -0
  133. package/template/src/redux/slice/settings.slice.ts +26 -0
  134. package/template/src/redux/slice/user.slice.ts +25 -0
  135. package/template/src/screens/app/main-tab/index.tsx +73 -0
  136. package/template/src/screens/app/main-tab/style.ts +0 -0
  137. package/template/src/screens/app/profile-setup/index.tsx +161 -0
  138. package/template/src/screens/app/profile-setup/styles.ts +3 -0
  139. package/template/src/screens/auth/forgot-password/index.tsx +59 -0
  140. package/template/src/screens/auth/forgot-password/styles.ts +0 -0
  141. package/template/src/screens/auth/index.ts +4 -0
  142. package/template/src/screens/auth/login/index.tsx +137 -0
  143. package/template/src/screens/auth/login/styles.ts +3 -0
  144. package/template/src/screens/auth/signup/index.tsx +110 -0
  145. package/template/src/screens/auth/signup/styles.ts +3 -0
  146. package/template/src/screens/auth/verify-email/index.tsx +15 -0
  147. package/template/src/screens/auth/verify-email/styles.ts +3 -0
  148. package/template/src/screens/tab/home/index.tsx +49 -0
  149. package/template/src/screens/tab/home/styles.ts +3 -0
  150. package/template/src/screens/tab/index.ts +2 -0
  151. package/template/src/screens/tab/profile/index.tsx +50 -0
  152. package/template/src/screens/tab/profile/styles.ts +3 -0
  153. package/template/src/services/api/auth/auth.api.ts +22 -0
  154. package/template/src/services/api/auth/auth.endpoints.ts +7 -0
  155. package/template/src/services/api/auth/auth.types.ts +9 -0
  156. package/template/src/services/api/auth/index.ts +3 -0
  157. package/template/src/services/api/axios/axios.instance.ts +15 -0
  158. package/template/src/services/api/axios/axios.interceptors.ts +43 -0
  159. package/template/src/services/api/axios/index.ts +2 -0
  160. package/template/src/services/api/mock/mockAdapter.ts +97 -0
  161. package/template/src/services/api/user/index.ts +2 -0
  162. package/template/src/services/api/user/user.api.ts +67 -0
  163. package/template/src/services/api/user/user.endpoints.ts +0 -0
  164. package/template/src/services/api/user/user.types.ts +0 -0
  165. package/template/src/services/errors/backendErrorCodes.ts +7 -0
  166. package/template/src/services/errors/errorHandler.ts +94 -0
  167. package/template/src/services/errors/firebaseErrorMap.ts +61 -0
  168. package/template/src/services/errors/httpStatusMap.ts +47 -0
  169. package/template/src/services/errors/index.ts +4 -0
  170. package/template/src/services/network/index.ts +1 -0
  171. package/template/src/services/network/onlineManager.ts +22 -0
  172. package/template/src/services/query/index.ts +1 -0
  173. package/template/src/services/query/queryClient.ts +23 -0
  174. package/template/src/services/toast/ToastCard.tsx +137 -0
  175. package/template/src/services/toast/ToastConfig.tsx +32 -0
  176. package/template/src/services/toast/index.ts +3 -0
  177. package/template/src/services/toast/toast.ts +68 -0
  178. package/template/src/storage/mmkvAdapter.ts +3 -0
  179. package/template/src/storage/mmkvInstance.ts +16 -0
  180. package/template/src/store/index.ts +15 -0
  181. package/template/src/store/mmkv.ts +6 -0
  182. package/template/src/store/persist.ts +10 -0
  183. package/template/src/store/rootReducer.ts +26 -0
  184. package/template/src/theme/dark.ts +40 -0
  185. package/template/src/theme/fonts.ts +20 -0
  186. package/template/src/theme/index.ts +6 -0
  187. package/template/src/theme/layout.ts +22 -0
  188. package/template/src/theme/light.ts +41 -0
  189. package/template/src/theme/palette.ts +32 -0
  190. package/template/src/theme/spacing.ts +7 -0
  191. package/template/src/theme/typography.ts +80 -0
  192. package/template/src/types/api.types.ts +34 -0
  193. package/template/src/types/env.d.ts +6 -0
  194. package/template/src/types/index.ts +2 -0
  195. package/template/src/types/navigation.types.ts +94 -0
  196. package/template/src/utils/clearAppSession.ts +10 -0
  197. package/template/src/utils/date.ts +19 -0
  198. package/template/src/utils/documentPickerHandler.ts +96 -0
  199. package/template/src/utils/getFileNameFromUri.ts +18 -0
  200. package/template/src/utils/getInitials.ts +13 -0
  201. package/template/src/utils/hindiText.ts +33 -0
  202. package/template/src/utils/imageCompress.ts +97 -0
  203. package/template/src/utils/imagePickerHandler.ts +200 -0
  204. package/template/src/utils/maskPhone.ts +17 -0
  205. package/template/src/utils/normalize.ts +12 -0
  206. package/template/src/validation/messages.ts +11 -0
  207. package/template/src/validation/rules.ts +44 -0
  208. package/template/src/validation/schema/auth.schema.ts +53 -0
  209. package/template/src/validation/schema/user.schema.ts +46 -0
  210. package/template/src/validation/tValError.ts +13 -0
@@ -0,0 +1,243 @@
1
+ import React, { memo, useCallback, useMemo } from 'react';
2
+ import { Control, Controller, FieldValues, Path } from 'react-hook-form';
3
+ import { StyleProp, StyleSheet, TextStyle, View, ViewStyle } from 'react-native';
4
+ import FormInput from './FormInput';
5
+ import DropdownVariant from './variants/DropdownVariant';
6
+ import Icon from '../Icon';
7
+ import CustomText from '@/components/shared/text/CustomText';
8
+ import { useAppTheme } from '@/context/ThemeContext';
9
+ import { ColorType, FontFamily } from '@/theme';
10
+ import { FontWeight, TextVariant } from '@/theme/typography';
11
+ import { normalize } from '@/utils/normalize';
12
+ import { DropdownItem, TextInputVariantProps } from './type';
13
+ import { FORM_FIELD } from './formFieldStyles';
14
+
15
+ export interface FullNameInputProps<T extends FieldValues> {
16
+ control: Control<T>;
17
+ titleName: Path<T>;
18
+ name: Path<T>;
19
+ titleOptions: DropdownItem[];
20
+ label?: string;
21
+ placeholder?: string;
22
+ error?: string;
23
+ disabled?: boolean;
24
+ labelVariant?: TextVariant;
25
+ labelWeight?: FontWeight;
26
+ containerStyle?: StyleProp<ViewStyle>;
27
+ labelStyle?: StyleProp<TextStyle>;
28
+ labelContainerStyle?: StyleProp<ViewStyle>;
29
+ inputContainerStyle?: StyleProp<ViewStyle>;
30
+ inputStyle?: StyleProp<TextStyle>;
31
+ titleDropdownStyle?: StyleProp<ViewStyle>;
32
+ titleDropdownListStyle?: StyleProp<ViewStyle>;
33
+ textInputProps?: TextInputVariantProps['textInputProps'];
34
+ }
35
+
36
+ const TITLE_DROPDOWN_WIDTH = normalize(64);
37
+ const TITLE_DROPDOWN_HEIGHT = normalize(32);
38
+
39
+ const FullNameInput = <T extends FieldValues>({
40
+ control,
41
+ titleName,
42
+ name,
43
+ titleOptions,
44
+ label,
45
+ placeholder,
46
+ error,
47
+ disabled,
48
+ labelVariant,
49
+ labelWeight,
50
+ containerStyle,
51
+ labelStyle,
52
+ labelContainerStyle,
53
+ inputContainerStyle,
54
+ inputStyle,
55
+ titleDropdownStyle,
56
+ titleDropdownListStyle,
57
+ textInputProps,
58
+ }: FullNameInputProps<T>) => {
59
+ const { color } = useAppTheme();
60
+ const styles = useMemo(() => makeStyles(color), [color]);
61
+
62
+ const renderTitleIcon = useCallback(
63
+ (visible?: boolean) => (
64
+ <View style={styles.titleDropdownIcon}>
65
+ <Icon
66
+ name={visible ? 'upArrow' : 'downArrow'}
67
+ width={normalize(10)}
68
+ height={normalize(6)}
69
+ color={color.text_primary}
70
+ />
71
+ </View>
72
+ ),
73
+ [styles.titleDropdownIcon, color.text_primary],
74
+ );
75
+
76
+ const renderTitleItem = useCallback(
77
+ (item: DropdownItem) => (
78
+ <View style={styles.titleDropdownItem}>
79
+ <CustomText
80
+ variant="subtitle"
81
+ weight="500"
82
+ style={styles.titleDropdownItemText}
83
+ >
84
+ {item.label}
85
+ </CustomText>
86
+ </View>
87
+ ),
88
+ [styles.titleDropdownItem, styles.titleDropdownItemText],
89
+ );
90
+
91
+ const titleDropdown = useMemo(
92
+ () => (
93
+ <Controller
94
+ control={control}
95
+ name={titleName}
96
+ render={({ field }) => (
97
+ <DropdownVariant
98
+ mode="form"
99
+ field={field}
100
+ dropdownData={titleOptions}
101
+ disabled={disabled}
102
+ dropdownStyle={[styles.titleDropdown, titleDropdownStyle]}
103
+ dropdownListStyle={[
104
+ styles.titleDropdownList,
105
+ titleDropdownListStyle,
106
+ ]}
107
+ dropdownProps={{
108
+ renderRightIcon: renderTitleIcon,
109
+ renderItem: renderTitleItem,
110
+ selectedTextStyle: styles.titleDropdownText,
111
+ placeholderStyle: styles.titleDropdownText,
112
+ }}
113
+ />
114
+ )}
115
+ />
116
+ ),
117
+ [
118
+ control,
119
+ titleName,
120
+ titleOptions,
121
+ disabled,
122
+ styles.titleDropdown,
123
+ styles.titleDropdownList,
124
+ styles.titleDropdownText,
125
+ titleDropdownStyle,
126
+ titleDropdownListStyle,
127
+ renderTitleIcon,
128
+ renderTitleItem,
129
+ ],
130
+ );
131
+
132
+ return (
133
+ <FormInput
134
+ control={control}
135
+ name={name}
136
+ label={label}
137
+ placeholder={placeholder}
138
+ error={error}
139
+ variant="text"
140
+ disabled={disabled}
141
+ labelVariant={labelVariant}
142
+ labelWeight={labelWeight}
143
+ containerStyle={containerStyle}
144
+ labelStyle={labelStyle}
145
+ labelContainerStyle={labelContainerStyle}
146
+ inputContainerStyle={[styles.inputContainer, inputContainerStyle]}
147
+ inputStyle={[styles.inputText, inputStyle]}
148
+ leftAdornment={titleDropdown}
149
+ focusOnContainerPress={false}
150
+ textInputProps={{
151
+ autoCapitalize: 'words',
152
+ ...textInputProps,
153
+ }}
154
+ />
155
+ );
156
+ };
157
+
158
+ export default memo(FullNameInput) as typeof FullNameInput;
159
+
160
+ const makeStyles = (color: ColorType) =>
161
+ StyleSheet.create({
162
+ inputContainer: {
163
+ backgroundColor: color.background_primary,
164
+ borderColor: color.border,
165
+ borderRadius: FORM_FIELD.radius,
166
+ height: FORM_FIELD.height,
167
+ paddingHorizontal: normalize(8),
168
+ paddingVertical: normalize(8),
169
+ gap: normalize(8),
170
+ alignItems: 'center',
171
+ },
172
+ inputText: {
173
+ flex: 1,
174
+ width: '100%',
175
+ fontFamily: FontFamily.InterTightRegular,
176
+ fontSize: FORM_FIELD.fontSize,
177
+ lineHeight: FORM_FIELD.lineHeight,
178
+ height: TITLE_DROPDOWN_HEIGHT,
179
+ paddingHorizontal: 0,
180
+ paddingTop: 0,
181
+ paddingBottom: 0,
182
+ margin: 0,
183
+ minWidth: 0,
184
+ includeFontPadding: false,
185
+ textAlignVertical: 'center',
186
+ },
187
+ titleDropdown: {
188
+ width: TITLE_DROPDOWN_WIDTH,
189
+ height: TITLE_DROPDOWN_HEIGHT,
190
+ minHeight: TITLE_DROPDOWN_HEIGHT,
191
+ maxHeight: TITLE_DROPDOWN_HEIGHT,
192
+ borderRadius: normalize(8),
193
+ paddingHorizontal: normalize(6),
194
+ paddingVertical: 0,
195
+ paddingLeft: normalize(6),
196
+ paddingRight: normalize(6),
197
+ backgroundColor: color.background_soft,
198
+ borderColor: color.border,
199
+ justifyContent: 'center',
200
+ alignItems: 'center',
201
+ overflow: 'visible',
202
+ },
203
+ titleDropdownText: {
204
+ fontFamily: FontFamily.InterTightMedium,
205
+ fontSize: FORM_FIELD.fontSize,
206
+ lineHeight: FORM_FIELD.lineHeight,
207
+ color: color.text_primary,
208
+ marginTop: 0,
209
+ marginBottom: 0,
210
+ paddingTop: 0,
211
+ paddingBottom: 0,
212
+ includeFontPadding: false,
213
+ textAlignVertical: 'center',
214
+ },
215
+ titleDropdownIcon: {
216
+ justifyContent: 'center',
217
+ alignItems: 'center',
218
+ marginLeft: normalize(2),
219
+ },
220
+ titleDropdownList: {
221
+ width: TITLE_DROPDOWN_WIDTH,
222
+ minWidth: TITLE_DROPDOWN_WIDTH,
223
+ maxWidth: TITLE_DROPDOWN_WIDTH,
224
+ marginTop: normalize(4),
225
+ borderRadius: normalize(8),
226
+ overflow: 'hidden',
227
+ },
228
+ titleDropdownItem: {
229
+ height: normalize(36),
230
+ width: TITLE_DROPDOWN_WIDTH,
231
+ paddingHorizontal: normalize(6),
232
+ justifyContent: 'center',
233
+ alignItems: 'center',
234
+ },
235
+ titleDropdownItemText: {
236
+ fontFamily: FontFamily.InterTightMedium,
237
+ fontSize: FORM_FIELD.fontSize,
238
+ lineHeight: FORM_FIELD.lineHeight,
239
+ color: color.text_primary,
240
+ textAlign: 'center',
241
+ includeFontPadding: false,
242
+ },
243
+ });
@@ -0,0 +1,43 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { FontFamily } from '@/theme';
3
+ import { normalize } from '@/utils/normalize';
4
+
5
+ /** Shared Figma field chrome — used by FormInput variants as defaults. */
6
+ export const FORM_FIELD = {
7
+ height: normalize(48),
8
+ radius: normalize(10),
9
+ paddingH: normalize(14),
10
+ fontSize: normalize(13),
11
+ lineHeight: normalize(18),
12
+ labelGap: normalize(6),
13
+ iconSize: normalize(20),
14
+ } as const;
15
+
16
+ export const formFieldText = StyleSheet.create({
17
+ input: {
18
+ flex: 1,
19
+ width: '100%',
20
+ fontFamily: FontFamily.InterTightRegular,
21
+ fontSize: FORM_FIELD.fontSize,
22
+ paddingHorizontal: 0,
23
+ paddingTop: 0,
24
+ paddingBottom: 0,
25
+ paddingVertical: 0,
26
+ margin: 0,
27
+ includeFontPadding: false,
28
+ textAlignVertical: 'center',
29
+ },
30
+ /** Hindi-only — applied after `input` so English metrics stay unchanged. */
31
+ inputHindi: {
32
+ includeFontPadding: true,
33
+ },
34
+ dropdownText: {
35
+ fontFamily: FontFamily.InterTightRegular,
36
+ fontSize: FORM_FIELD.fontSize,
37
+ lineHeight: FORM_FIELD.lineHeight,
38
+ },
39
+ dropdownTextHindi: {
40
+ lineHeight: Math.ceil(FORM_FIELD.fontSize * 1.35),
41
+ includeFontPadding: true,
42
+ },
43
+ });
@@ -0,0 +1,188 @@
1
+ import { IconName } from '@/assets/icons';
2
+ import {
3
+ AndroidNativeProps,
4
+ IOSNativeProps,
5
+ } from '@react-native-community/datetimepicker';
6
+ import { ReactNode } from 'react';
7
+ import { Control, FieldValues, Path } from 'react-hook-form';
8
+ import { StyleProp, TextInputProps, TextStyle, ViewStyle } from 'react-native';
9
+ import { DropdownProps } from 'react-native-element-dropdown/lib/typescript/components/Dropdown/model';
10
+ import {
11
+ ICountry,
12
+ ICountryCca2,
13
+ PhoneInputProps,
14
+ } from 'rn-international-phone-number';
15
+ import type { FontWeight, TextVariant } from '@/theme/typography';
16
+
17
+ export type FormInputVariant =
18
+ | 'text'
19
+ | 'dropdown'
20
+ | 'date'
21
+ | 'time'
22
+ | 'country-phone'
23
+ | 'toggle';
24
+
25
+ export type DropdownItem = {
26
+ label: string;
27
+ value: string;
28
+ };
29
+
30
+ export interface BaseFormInputProps<T extends FieldValues> {
31
+ control: Control<T>;
32
+ name: Path<T>;
33
+ rules?: object;
34
+ label?: string;
35
+ error?: string;
36
+
37
+ /** Styles */
38
+ containerStyle?: StyleProp<ViewStyle>;
39
+ labelStyle?: StyleProp<TextStyle>;
40
+ labelContainerStyle?: StyleProp<ViewStyle>;
41
+ labelVariant?: TextVariant;
42
+ labelWeight?: FontWeight;
43
+
44
+ /** Tooltip */
45
+ isTooltip?: boolean;
46
+ tooltipMessage?: string;
47
+ }
48
+
49
+ //Text Input Variant Props
50
+ export interface TextInputVariantProps {
51
+ leftIcon?: ReactNode;
52
+ leftAdornment?: ReactNode;
53
+ leftAdornmentStyle?: StyleProp<ViewStyle>;
54
+ rightIcon?: ReactNode;
55
+ isPassword?: boolean;
56
+ focusOnContainerPress?: boolean;
57
+ inputContainerStyle?: StyleProp<ViewStyle>;
58
+ inputStyle?: StyleProp<TextStyle>;
59
+ disabled?: boolean;
60
+ placeholder?: string;
61
+ /** Replaces the field with a shimmer bone while true */
62
+ isLoading?: boolean;
63
+ /** Keep digits only (like phone / OTP) */
64
+ digitsOnly?: boolean;
65
+ textInputProps?: Partial<
66
+ Omit<TextInputProps, 'onChangeText' | 'value' | 'placeholder' | 'editable'>
67
+ >;
68
+ }
69
+
70
+ //Dropdown Variant Props
71
+ export interface DropdownVariantProps {
72
+ dropdownData: DropdownItem[];
73
+ disabled?: boolean;
74
+ placeholder?: string;
75
+ isLoading?: boolean;
76
+ onLoadMore?: () => void;
77
+ onListFooterLoading?: () => React.ReactElement | null;
78
+ search?: boolean;
79
+ onSearchTextChange?: (text: string) => void;
80
+ onDropdownSelect?: (item: DropdownItem) => void;
81
+ /** Styles the closed dropdown trigger (maps to Dropdown `style`) */
82
+ dropdownStyle?: StyleProp<ViewStyle>;
83
+ /** Styles the open options list (maps to Dropdown `containerStyle`) */
84
+ dropdownListStyle?: StyleProp<ViewStyle>;
85
+ dropdownProps?: Partial<
86
+ Omit<
87
+ DropdownProps<any>,
88
+ | 'data'
89
+ | 'value'
90
+ | 'onChange'
91
+ | 'labelField'
92
+ | 'valueField'
93
+ | 'placeholder'
94
+ | 'disable'
95
+ >
96
+ >;
97
+ }
98
+
99
+ //DateTime Variant Props
100
+
101
+ type Display = 'spinner' | 'default' | 'clock' | 'calendar';
102
+ type IOSDisplay = 'default' | 'compact' | 'inline' | 'spinner';
103
+ export interface DateTimeVariantProps {
104
+ minimumDate?: Date;
105
+ maximumDate?: Date;
106
+ dateTimeContainerStyle?: StyleProp<ViewStyle>;
107
+ disabled?: boolean;
108
+ display?: Display | IOSDisplay;
109
+ placeholder?: string;
110
+ inputStyle?: StyleProp<TextStyle>;
111
+ showIcon?: boolean;
112
+ iconName?: IconName;
113
+ placeholderTextColor?: string;
114
+
115
+ dateTimePickerProps?: Partial<
116
+ Omit<
117
+ IOSNativeProps | AndroidNativeProps,
118
+ | 'value'
119
+ | 'onChange'
120
+ | 'onValueChange'
121
+ | 'onDismiss'
122
+ | 'onNeutralButtonPress'
123
+ | 'mode'
124
+ | 'display'
125
+ | 'minimumDate'
126
+ | 'maximumDate'
127
+ | 'disabled'
128
+ | 'children'
129
+ >
130
+ >;
131
+ }
132
+
133
+ //Toggle Variant Props
134
+ type ToggleSize = 'sm' | 'md';
135
+
136
+ type ToggleStyles = {
137
+ wrapper?: ViewStyle;
138
+ track?: ViewStyle;
139
+ thumb?: ViewStyle;
140
+ label?: TextStyle;
141
+ };
142
+ export interface ToggleVariantProps {
143
+ disabled?: boolean;
144
+ size?: ToggleSize;
145
+ showLabel?: boolean;
146
+ onLabel?: string;
147
+ offLabel?: string;
148
+ activeColor?: string;
149
+ inactiveColor?: string;
150
+ thumbColor?: string;
151
+ styles?: ToggleStyles;
152
+ }
153
+
154
+ //Country Phone Variant Props
155
+ export type CountryPhoneAppearance = 'login' | 'field';
156
+
157
+ export interface CountryPhoneVariantProps {
158
+ showFlag?: boolean;
159
+ defaultCountry?: ICountryCca2;
160
+ disabled?: boolean;
161
+ modalDisabled?: boolean;
162
+ /** `login` keeps the grey, taller input. `field` matches other form fields. */
163
+ appearance?: CountryPhoneAppearance;
164
+ countryContainerStyle?: StyleProp<ViewStyle>;
165
+ placeholder?: string;
166
+ onChangeSelectedCountry?: (country: ICountry) => void;
167
+ phoneInputProps?: Partial<
168
+ Omit<
169
+ PhoneInputProps,
170
+ | 'defaultValue'
171
+ | 'onChangePhoneNumber'
172
+ | 'defaultCountry'
173
+ | 'onChangeCountry'
174
+ | 'placeholder'
175
+ | 'disabled'
176
+ | 'modalDisabled'
177
+ >
178
+ >;
179
+ }
180
+
181
+ export type FormInputProps<T extends FieldValues> = BaseFormInputProps<T> &
182
+ (
183
+ | (TextInputVariantProps & { variant: 'text' })
184
+ | (DropdownVariantProps & { variant: 'dropdown' })
185
+ | (DateTimeVariantProps & { variant: 'date' | 'time' })
186
+ | (CountryPhoneVariantProps & { variant: 'country-phone' })
187
+ | (ToggleVariantProps & { variant: 'toggle' })
188
+ );