@izonnet-web-solution/react-native-date-time-picker-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 (216) hide show
  1. package/DateTimePickerKit.podspec +22 -0
  2. package/LICENSE +20 -0
  3. package/README.md +532 -2
  4. package/android/build.gradle +36 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/datetimepickerkit/DatePickerHelper.kt +185 -0
  7. package/android/src/main/java/com/datetimepickerkit/DateTimePickerHelper.kt +214 -0
  8. package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitModule.kt +258 -0
  9. package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitPackage.kt +30 -0
  10. package/android/src/main/java/com/datetimepickerkit/TimePickerHelper.kt +208 -0
  11. package/ios/DateTimePickerKit.h +11 -0
  12. package/ios/DateTimePickerKit.mm +84 -0
  13. package/ios/DateTimePickerModule.swift +474 -0
  14. package/lib/module/NativeDateTimePickerKit.js +5 -0
  15. package/lib/module/NativeDateTimePickerKit.js.map +1 -0
  16. package/lib/module/components/CalendarPicker.js +414 -0
  17. package/lib/module/components/CalendarPicker.js.map +1 -0
  18. package/lib/module/components/ClockPicker.js +273 -0
  19. package/lib/module/components/ClockPicker.js.map +1 -0
  20. package/lib/module/components/DatePicker.js +174 -0
  21. package/lib/module/components/DatePicker.js.map +1 -0
  22. package/lib/module/components/DateRangePicker.js +154 -0
  23. package/lib/module/components/DateRangePicker.js.map +1 -0
  24. package/lib/module/components/DateTimePicker.js +598 -0
  25. package/lib/module/components/DateTimePicker.js.map +1 -0
  26. package/lib/module/components/MonthPicker.js +145 -0
  27. package/lib/module/components/MonthPicker.js.map +1 -0
  28. package/lib/module/components/TimePicker.js +140 -0
  29. package/lib/module/components/TimePicker.js.map +1 -0
  30. package/lib/module/components/TimeSlotPicker.js +118 -0
  31. package/lib/module/components/TimeSlotPicker.js.map +1 -0
  32. package/lib/module/components/WheelPicker.js +138 -0
  33. package/lib/module/components/WheelPicker.js.map +1 -0
  34. package/lib/module/components/YearPicker.js +151 -0
  35. package/lib/module/components/YearPicker.js.map +1 -0
  36. package/lib/module/components/common/ModalWrapper.js +130 -0
  37. package/lib/module/components/common/ModalWrapper.js.map +1 -0
  38. package/lib/module/components/common/PickerHeader.js +82 -0
  39. package/lib/module/components/common/PickerHeader.js.map +1 -0
  40. package/lib/module/components/common/PresetsBar.js +66 -0
  41. package/lib/module/components/common/PresetsBar.js.map +1 -0
  42. package/lib/module/errors/DateTimePickerError.js +12 -0
  43. package/lib/module/errors/DateTimePickerError.js.map +1 -0
  44. package/lib/module/hooks/useDateTimePicker.js +73 -0
  45. package/lib/module/hooks/useDateTimePicker.js.map +1 -0
  46. package/lib/module/index.js +40 -0
  47. package/lib/module/index.js.map +1 -0
  48. package/lib/module/localization/index.js +6 -0
  49. package/lib/module/localization/index.js.map +1 -0
  50. package/lib/module/localization/locales.js +186 -0
  51. package/lib/module/localization/locales.js.map +1 -0
  52. package/lib/module/localization/types.js +2 -0
  53. package/lib/module/localization/types.js.map +1 -0
  54. package/lib/module/localization/useLocale.js +126 -0
  55. package/lib/module/localization/useLocale.js.map +1 -0
  56. package/lib/module/native/NativeDateTimePicker.js +110 -0
  57. package/lib/module/native/NativeDateTimePicker.js.map +1 -0
  58. package/lib/module/package.json +1 -0
  59. package/lib/module/presets/datePresets.js +75 -0
  60. package/lib/module/presets/datePresets.js.map +1 -0
  61. package/lib/module/presets/index.js +4 -0
  62. package/lib/module/presets/index.js.map +1 -0
  63. package/lib/module/slots/index.js +4 -0
  64. package/lib/module/slots/index.js.map +1 -0
  65. package/lib/module/slots/timeSlots.js +59 -0
  66. package/lib/module/slots/timeSlots.js.map +1 -0
  67. package/lib/module/theme/defaultTheme.js +91 -0
  68. package/lib/module/theme/defaultTheme.js.map +1 -0
  69. package/lib/module/theme/index.js +6 -0
  70. package/lib/module/theme/index.js.map +1 -0
  71. package/lib/module/theme/types.js +2 -0
  72. package/lib/module/theme/types.js.map +1 -0
  73. package/lib/module/theme/useTheme.js +59 -0
  74. package/lib/module/theme/useTheme.js.map +1 -0
  75. package/lib/module/types/events.js +4 -0
  76. package/lib/module/types/events.js.map +1 -0
  77. package/lib/module/types/index.js +7 -0
  78. package/lib/module/types/index.js.map +1 -0
  79. package/lib/module/types/native.js +2 -0
  80. package/lib/module/types/native.js.map +1 -0
  81. package/lib/module/types/presentation.js +2 -0
  82. package/lib/module/types/presentation.js.map +1 -0
  83. package/lib/module/types/props.js +4 -0
  84. package/lib/module/types/props.js.map +1 -0
  85. package/lib/module/utils/constants.js +14 -0
  86. package/lib/module/utils/constants.js.map +1 -0
  87. package/lib/module/utils/dateConversion.js +115 -0
  88. package/lib/module/utils/dateConversion.js.map +1 -0
  89. package/lib/module/utils/dateFormatting.js +102 -0
  90. package/lib/module/utils/dateFormatting.js.map +1 -0
  91. package/lib/module/utils/dateValidation.js +161 -0
  92. package/lib/module/utils/dateValidation.js.map +1 -0
  93. package/lib/module/utils/index.js +7 -0
  94. package/lib/module/utils/index.js.map +1 -0
  95. package/lib/typescript/package.json +1 -0
  96. package/lib/typescript/src/NativeDateTimePickerKit.d.ts +17 -0
  97. package/lib/typescript/src/NativeDateTimePickerKit.d.ts.map +1 -0
  98. package/lib/typescript/src/components/CalendarPicker.d.ts +35 -0
  99. package/lib/typescript/src/components/CalendarPicker.d.ts.map +1 -0
  100. package/lib/typescript/src/components/ClockPicker.d.ts +22 -0
  101. package/lib/typescript/src/components/ClockPicker.d.ts.map +1 -0
  102. package/lib/typescript/src/components/DatePicker.d.ts +32 -0
  103. package/lib/typescript/src/components/DatePicker.d.ts.map +1 -0
  104. package/lib/typescript/src/components/DateRangePicker.d.ts +41 -0
  105. package/lib/typescript/src/components/DateRangePicker.d.ts.map +1 -0
  106. package/lib/typescript/src/components/DateTimePicker.d.ts +7 -0
  107. package/lib/typescript/src/components/DateTimePicker.d.ts.map +1 -0
  108. package/lib/typescript/src/components/MonthPicker.d.ts +21 -0
  109. package/lib/typescript/src/components/MonthPicker.d.ts.map +1 -0
  110. package/lib/typescript/src/components/TimePicker.d.ts +25 -0
  111. package/lib/typescript/src/components/TimePicker.d.ts.map +1 -0
  112. package/lib/typescript/src/components/TimeSlotPicker.d.ts +18 -0
  113. package/lib/typescript/src/components/TimeSlotPicker.d.ts.map +1 -0
  114. package/lib/typescript/src/components/WheelPicker.d.ts +17 -0
  115. package/lib/typescript/src/components/WheelPicker.d.ts.map +1 -0
  116. package/lib/typescript/src/components/YearPicker.d.ts +14 -0
  117. package/lib/typescript/src/components/YearPicker.d.ts.map +1 -0
  118. package/lib/typescript/src/components/common/ModalWrapper.d.ts +10 -0
  119. package/lib/typescript/src/components/common/ModalWrapper.d.ts.map +1 -0
  120. package/lib/typescript/src/components/common/PickerHeader.d.ts +13 -0
  121. package/lib/typescript/src/components/common/PickerHeader.d.ts.map +1 -0
  122. package/lib/typescript/src/components/common/PresetsBar.d.ts +12 -0
  123. package/lib/typescript/src/components/common/PresetsBar.d.ts.map +1 -0
  124. package/lib/typescript/src/errors/DateTimePickerError.d.ts +7 -0
  125. package/lib/typescript/src/errors/DateTimePickerError.d.ts.map +1 -0
  126. package/lib/typescript/src/hooks/useDateTimePicker.d.ts +17 -0
  127. package/lib/typescript/src/hooks/useDateTimePicker.d.ts.map +1 -0
  128. package/lib/typescript/src/index.d.ts +23 -0
  129. package/lib/typescript/src/index.d.ts.map +1 -0
  130. package/lib/typescript/src/localization/index.d.ts +4 -0
  131. package/lib/typescript/src/localization/index.d.ts.map +1 -0
  132. package/lib/typescript/src/localization/locales.d.ts +12 -0
  133. package/lib/typescript/src/localization/locales.d.ts.map +1 -0
  134. package/lib/typescript/src/localization/types.d.ts +23 -0
  135. package/lib/typescript/src/localization/types.d.ts.map +1 -0
  136. package/lib/typescript/src/localization/useLocale.d.ts +31 -0
  137. package/lib/typescript/src/localization/useLocale.d.ts.map +1 -0
  138. package/lib/typescript/src/native/NativeDateTimePicker.d.ts +14 -0
  139. package/lib/typescript/src/native/NativeDateTimePicker.d.ts.map +1 -0
  140. package/lib/typescript/src/presets/datePresets.d.ts +8 -0
  141. package/lib/typescript/src/presets/datePresets.d.ts.map +1 -0
  142. package/lib/typescript/src/presets/index.d.ts +2 -0
  143. package/lib/typescript/src/presets/index.d.ts.map +1 -0
  144. package/lib/typescript/src/slots/index.d.ts +2 -0
  145. package/lib/typescript/src/slots/index.d.ts.map +1 -0
  146. package/lib/typescript/src/slots/timeSlots.d.ts +18 -0
  147. package/lib/typescript/src/slots/timeSlots.d.ts.map +1 -0
  148. package/lib/typescript/src/theme/defaultTheme.d.ts +9 -0
  149. package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
  150. package/lib/typescript/src/theme/index.d.ts +4 -0
  151. package/lib/typescript/src/theme/index.d.ts.map +1 -0
  152. package/lib/typescript/src/theme/types.d.ts +65 -0
  153. package/lib/typescript/src/theme/types.d.ts.map +1 -0
  154. package/lib/typescript/src/theme/useTheme.d.ts +4 -0
  155. package/lib/typescript/src/theme/useTheme.d.ts.map +1 -0
  156. package/lib/typescript/src/types/events.d.ts +8 -0
  157. package/lib/typescript/src/types/events.d.ts.map +1 -0
  158. package/lib/typescript/src/types/index.d.ts +5 -0
  159. package/lib/typescript/src/types/index.d.ts.map +1 -0
  160. package/lib/typescript/src/types/native.d.ts +26 -0
  161. package/lib/typescript/src/types/native.d.ts.map +1 -0
  162. package/lib/typescript/src/types/presentation.d.ts +19 -0
  163. package/lib/typescript/src/types/presentation.d.ts.map +1 -0
  164. package/lib/typescript/src/types/props.d.ts +68 -0
  165. package/lib/typescript/src/types/props.d.ts.map +1 -0
  166. package/lib/typescript/src/utils/constants.d.ts +12 -0
  167. package/lib/typescript/src/utils/constants.d.ts.map +1 -0
  168. package/lib/typescript/src/utils/dateConversion.d.ts +27 -0
  169. package/lib/typescript/src/utils/dateConversion.d.ts.map +1 -0
  170. package/lib/typescript/src/utils/dateFormatting.d.ts +8 -0
  171. package/lib/typescript/src/utils/dateFormatting.d.ts.map +1 -0
  172. package/lib/typescript/src/utils/dateValidation.d.ts +46 -0
  173. package/lib/typescript/src/utils/dateValidation.d.ts.map +1 -0
  174. package/lib/typescript/src/utils/index.d.ts +5 -0
  175. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  176. package/package.json +183 -4
  177. package/src/NativeDateTimePickerKit.ts +19 -0
  178. package/src/components/CalendarPicker.tsx +593 -0
  179. package/src/components/ClockPicker.tsx +403 -0
  180. package/src/components/DatePicker.tsx +246 -0
  181. package/src/components/DateRangePicker.tsx +226 -0
  182. package/src/components/DateTimePicker.tsx +862 -0
  183. package/src/components/MonthPicker.tsx +216 -0
  184. package/src/components/TimePicker.tsx +190 -0
  185. package/src/components/TimeSlotPicker.tsx +163 -0
  186. package/src/components/WheelPicker.tsx +199 -0
  187. package/src/components/YearPicker.tsx +228 -0
  188. package/src/components/common/ModalWrapper.tsx +184 -0
  189. package/src/components/common/PickerHeader.tsx +121 -0
  190. package/src/components/common/PresetsBar.tsx +104 -0
  191. package/src/errors/DateTimePickerError.ts +29 -0
  192. package/src/hooks/useDateTimePicker.ts +100 -0
  193. package/src/index.tsx +92 -0
  194. package/src/localization/index.ts +3 -0
  195. package/src/localization/locales.ts +499 -0
  196. package/src/localization/types.ts +21 -0
  197. package/src/localization/useLocale.ts +137 -0
  198. package/src/native/NativeDateTimePicker.ts +154 -0
  199. package/src/presets/datePresets.ts +97 -0
  200. package/src/presets/index.ts +1 -0
  201. package/src/slots/index.ts +1 -0
  202. package/src/slots/timeSlots.ts +89 -0
  203. package/src/theme/defaultTheme.ts +102 -0
  204. package/src/theme/index.ts +3 -0
  205. package/src/theme/types.ts +70 -0
  206. package/src/theme/useTheme.ts +75 -0
  207. package/src/types/events.ts +8 -0
  208. package/src/types/index.ts +4 -0
  209. package/src/types/native.ts +28 -0
  210. package/src/types/presentation.ts +21 -0
  211. package/src/types/props.ts +104 -0
  212. package/src/utils/constants.ts +15 -0
  213. package/src/utils/dateConversion.ts +127 -0
  214. package/src/utils/dateFormatting.ts +166 -0
  215. package/src/utils/dateValidation.ts +178 -0
  216. package/src/utils/index.ts +4 -0
@@ -0,0 +1,199 @@
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
+ import {
3
+ type NativeScrollEvent,
4
+ type NativeSyntheticEvent,
5
+ ScrollView,
6
+ StyleSheet,
7
+ Text,
8
+ TouchableOpacity,
9
+ View,
10
+ } from 'react-native';
11
+ import { useTheme } from '../theme';
12
+ import type { ThemeConfig, ThemeMode } from '../theme/types';
13
+
14
+ export interface WheelPickerItem<T = any> {
15
+ label: string;
16
+ value: T;
17
+ }
18
+
19
+ export interface WheelPickerProps<T = any> {
20
+ items: WheelPickerItem<T>[];
21
+ selectedValue?: T;
22
+ onChange?: (value: T, index: number) => void;
23
+ itemHeight?: number;
24
+ visibleItems?: number; // e.g. 5
25
+ theme?: ThemeMode | ThemeConfig;
26
+ testID?: string;
27
+ }
28
+
29
+ export function WheelPicker<T = any>({
30
+ items,
31
+ selectedValue,
32
+ onChange,
33
+ itemHeight = 44,
34
+ visibleItems = 5,
35
+ theme: propTheme,
36
+ testID,
37
+ }: WheelPickerProps<T>): React.ReactElement {
38
+ const theme = useTheme(propTheme);
39
+ const scrollRef = useRef<any>(null);
40
+ const isScrollingRef = useRef(false);
41
+
42
+ const halfVisible = Math.floor(visibleItems / 2);
43
+ const totalHeight = itemHeight * visibleItems;
44
+
45
+ const selectedIndex = items.findIndex((it) => it.value === selectedValue);
46
+ const activeIndex = selectedIndex >= 0 ? selectedIndex : 0;
47
+
48
+ // Scroll to position when selectedValue changes externally
49
+ useEffect(() => {
50
+ if (!isScrollingRef.current && scrollRef.current && activeIndex >= 0) {
51
+ scrollRef.current.scrollTo({
52
+ y: activeIndex * itemHeight,
53
+ animated: false,
54
+ });
55
+ }
56
+ }, [activeIndex, itemHeight]);
57
+
58
+ const handleMomentumScrollEnd = useCallback(
59
+ (e: NativeSyntheticEvent<NativeScrollEvent>) => {
60
+ isScrollingRef.current = false;
61
+ const offsetY = e.nativeEvent.contentOffset.y;
62
+ const index = Math.round(offsetY / itemHeight);
63
+ const clampedIndex = Math.max(0, Math.min(items.length - 1, index));
64
+ const item = items[clampedIndex];
65
+ if (item && onChange) {
66
+ onChange(item.value, clampedIndex);
67
+ }
68
+ },
69
+ [itemHeight, items, onChange]
70
+ );
71
+
72
+ const handleScrollBeginDrag = useCallback(() => {
73
+ isScrollingRef.current = true;
74
+ }, []);
75
+
76
+ const handleItemPress = useCallback(
77
+ (index: number) => {
78
+ scrollRef.current?.scrollTo({
79
+ y: index * itemHeight,
80
+ animated: true,
81
+ });
82
+ const item = items[index];
83
+ if (item && onChange) {
84
+ onChange(item.value, index);
85
+ }
86
+ },
87
+ [itemHeight, items, onChange]
88
+ );
89
+
90
+ return (
91
+ <View
92
+ testID={testID}
93
+ style={[
94
+ styles.container,
95
+ {
96
+ height: totalHeight,
97
+ backgroundColor: theme.colors.background,
98
+ },
99
+ ]}
100
+ >
101
+ {/* Center Highlight Indicator */}
102
+ <View
103
+ pointerEvents="none"
104
+ style={[
105
+ styles.selectionIndicator,
106
+ {
107
+ top: halfVisible * itemHeight,
108
+ height: itemHeight,
109
+ borderColor: theme.colors.border,
110
+ backgroundColor: theme.colors.card,
111
+ },
112
+ ]}
113
+ />
114
+
115
+ {/* Wheel ScrollView */}
116
+ <ScrollView
117
+ ref={scrollRef}
118
+ showsVerticalScrollIndicator={false}
119
+ snapToInterval={itemHeight}
120
+ snapToAlignment="center"
121
+ decelerationRate="fast"
122
+ onScrollBeginDrag={handleScrollBeginDrag}
123
+ onMomentumScrollEnd={handleMomentumScrollEnd}
124
+ contentContainerStyle={{
125
+ paddingTop: halfVisible * itemHeight,
126
+ paddingBottom: halfVisible * itemHeight,
127
+ }}
128
+ >
129
+ {items.map((item, index) => {
130
+ const isSelected = index === activeIndex;
131
+ return (
132
+ <TouchableOpacity
133
+ key={`wheel-${index}-${String(item.value)}`}
134
+ accessibilityRole="button"
135
+ accessibilityLabel={item.label}
136
+ accessibilityState={{ selected: isSelected }}
137
+ activeOpacity={0.8}
138
+ onPress={() => handleItemPress(index)}
139
+ style={[
140
+ styles.itemRow,
141
+ {
142
+ height: itemHeight,
143
+ },
144
+ ]}
145
+ >
146
+ <Text
147
+ numberOfLines={1}
148
+ style={[
149
+ styles.itemText,
150
+ {
151
+ color: isSelected
152
+ ? theme.colors.text
153
+ : theme.colors.textMuted,
154
+ fontSize: isSelected
155
+ ? theme.typography.fontSizeLarge
156
+ : theme.typography.fontSizeMedium,
157
+ fontWeight: isSelected
158
+ ? theme.typography.fontWeightBold
159
+ : theme.typography.fontWeightRegular,
160
+ transform: isSelected
161
+ ? [{ scale: 1.05 }]
162
+ : [{ scale: 0.95 }],
163
+ },
164
+ ]}
165
+ >
166
+ {item.label}
167
+ </Text>
168
+ </TouchableOpacity>
169
+ );
170
+ })}
171
+ </ScrollView>
172
+ </View>
173
+ );
174
+ }
175
+
176
+ const styles = StyleSheet.create({
177
+ container: {
178
+ position: 'relative',
179
+ overflow: 'hidden',
180
+ width: '100%',
181
+ },
182
+ selectionIndicator: {
183
+ position: 'absolute',
184
+ left: 8,
185
+ right: 8,
186
+ borderTopWidth: 1,
187
+ borderBottomWidth: 1,
188
+ borderRadius: 8,
189
+ zIndex: 0,
190
+ },
191
+ itemRow: {
192
+ justifyContent: 'center',
193
+ alignItems: 'center',
194
+ zIndex: 1,
195
+ },
196
+ itemText: {
197
+ textAlign: 'center',
198
+ },
199
+ });
@@ -0,0 +1,228 @@
1
+ import React, { useCallback, useMemo, useState } from 'react';
2
+ import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
+ import { useLocale } from '../localization';
4
+ import type { PartialLocaleData } from '../localization/types';
5
+ import { useTheme } from '../theme';
6
+ import type { ThemeConfig, ThemeMode } from '../theme/types';
7
+
8
+ export interface YearPickerProps {
9
+ value?: number | Date;
10
+ onChange?: (year: number) => void;
11
+ minYear?: number;
12
+ maxYear?: number;
13
+ locale?: string | PartialLocaleData;
14
+ theme?: ThemeMode | ThemeConfig;
15
+ testID?: string;
16
+ }
17
+
18
+ const PAGE_SIZE = 12; // 12 years per view (3x4 grid)
19
+
20
+ export const YearPicker: React.FC<YearPickerProps> = ({
21
+ value,
22
+ onChange,
23
+ minYear = 1900,
24
+ maxYear = 2100,
25
+ locale: propLocale,
26
+ theme: propTheme,
27
+ testID,
28
+ }) => {
29
+ const theme = useTheme(propTheme);
30
+ const locale = useLocale(propLocale);
31
+
32
+ const initialYear =
33
+ value instanceof Date
34
+ ? value.getFullYear()
35
+ : typeof value === 'number'
36
+ ? value
37
+ : new Date().getFullYear();
38
+
39
+ const [selectedYear, setSelectedYear] = useState<number>(initialYear);
40
+ // Base start year for current page (e.g. 2020..2031)
41
+ const [pageStartYear, setPageStartYear] = useState<number>(() => {
42
+ return Math.floor(initialYear / PAGE_SIZE) * PAGE_SIZE;
43
+ });
44
+
45
+ const pageYears = useMemo(() => {
46
+ const list: number[] = [];
47
+ for (let i = 0; i < PAGE_SIZE; i++) {
48
+ const yr = pageStartYear + i;
49
+ if (yr >= minYear && yr <= maxYear) {
50
+ list.push(yr);
51
+ }
52
+ }
53
+ return list;
54
+ }, [pageStartYear, minYear, maxYear]);
55
+
56
+ const prevPage = useCallback(() => {
57
+ setPageStartYear((p) => Math.max(minYear, p - PAGE_SIZE));
58
+ }, [minYear]);
59
+
60
+ const nextPage = useCallback(() => {
61
+ setPageStartYear((p) => (p + PAGE_SIZE <= maxYear ? p + PAGE_SIZE : p));
62
+ }, [maxYear]);
63
+
64
+ const handleSelectYear = useCallback(
65
+ (yr: number) => {
66
+ setSelectedYear(yr);
67
+ onChange?.(yr);
68
+ },
69
+ [onChange]
70
+ );
71
+
72
+ const pageRangeLabel = `${pageStartYear} - ${Math.min(
73
+ maxYear,
74
+ pageStartYear + PAGE_SIZE - 1
75
+ )}`;
76
+
77
+ return (
78
+ <View
79
+ testID={testID}
80
+ style={[styles.container, { backgroundColor: theme.colors.background }]}
81
+ >
82
+ {/* Decade Header */}
83
+ <View
84
+ style={[
85
+ styles.headerRow,
86
+ { flexDirection: locale.isRTL ? 'row-reverse' : 'row' },
87
+ ]}
88
+ >
89
+ <TouchableOpacity
90
+ accessibilityRole="button"
91
+ accessibilityLabel="Previous Years"
92
+ onPress={prevPage}
93
+ disabled={pageStartYear <= minYear}
94
+ style={styles.navButton}
95
+ >
96
+ <Text
97
+ style={[
98
+ styles.navArrow,
99
+ {
100
+ color:
101
+ pageStartYear <= minYear
102
+ ? theme.colors.disabledText
103
+ : theme.colors.primary,
104
+ },
105
+ ]}
106
+ >
107
+ {locale.isRTL ? '›' : '‹'}
108
+ </Text>
109
+ </TouchableOpacity>
110
+
111
+ <Text
112
+ style={[
113
+ styles.rangeTitle,
114
+ {
115
+ color: theme.colors.text,
116
+ fontSize: theme.typography.fontSizeLarge,
117
+ fontWeight: theme.typography.fontWeightBold,
118
+ },
119
+ ]}
120
+ >
121
+ {pageRangeLabel}
122
+ </Text>
123
+
124
+ <TouchableOpacity
125
+ accessibilityRole="button"
126
+ accessibilityLabel="Next Years"
127
+ onPress={nextPage}
128
+ disabled={pageStartYear + PAGE_SIZE > maxYear}
129
+ style={styles.navButton}
130
+ >
131
+ <Text
132
+ style={[
133
+ styles.navArrow,
134
+ {
135
+ color:
136
+ pageStartYear + PAGE_SIZE > maxYear
137
+ ? theme.colors.disabledText
138
+ : theme.colors.primary,
139
+ },
140
+ ]}
141
+ >
142
+ {locale.isRTL ? '‹' : '›'}
143
+ </Text>
144
+ </TouchableOpacity>
145
+ </View>
146
+
147
+ {/* 3x4 Years Grid */}
148
+ <View
149
+ style={[
150
+ styles.yearsGrid,
151
+ { flexDirection: locale.isRTL ? 'row-reverse' : 'row' },
152
+ ]}
153
+ >
154
+ {pageYears.map((yr) => {
155
+ const isSelected = selectedYear === yr;
156
+ return (
157
+ <TouchableOpacity
158
+ key={`yr-${yr}`}
159
+ onPress={() => handleSelectYear(yr)}
160
+ style={[
161
+ styles.yearCell,
162
+ isSelected && {
163
+ backgroundColor: theme.colors.selected,
164
+ borderRadius: theme.borderRadius.md,
165
+ },
166
+ ]}
167
+ >
168
+ <Text
169
+ style={[
170
+ styles.yearText,
171
+ {
172
+ color: isSelected
173
+ ? theme.colors.selectedText
174
+ : theme.colors.text,
175
+ fontSize: theme.typography.fontSizeMedium,
176
+ fontWeight: isSelected
177
+ ? theme.typography.fontWeightBold
178
+ : theme.typography.fontWeightRegular,
179
+ },
180
+ ]}
181
+ >
182
+ {yr}
183
+ </Text>
184
+ </TouchableOpacity>
185
+ );
186
+ })}
187
+ </View>
188
+ </View>
189
+ );
190
+ };
191
+
192
+ const styles = StyleSheet.create({
193
+ container: {
194
+ padding: 16,
195
+ },
196
+ headerRow: {
197
+ alignItems: 'center',
198
+ justifyContent: 'space-between',
199
+ marginBottom: 16,
200
+ },
201
+ rangeTitle: {
202
+ textAlign: 'center',
203
+ },
204
+ navButton: {
205
+ width: 36,
206
+ height: 36,
207
+ justifyContent: 'center',
208
+ alignItems: 'center',
209
+ },
210
+ navArrow: {
211
+ fontSize: 24,
212
+ lineHeight: 26,
213
+ },
214
+ yearsGrid: {
215
+ flexWrap: 'wrap',
216
+ justifyContent: 'space-between',
217
+ rowGap: 12,
218
+ },
219
+ yearCell: {
220
+ width: '31%',
221
+ height: 48,
222
+ justifyContent: 'center',
223
+ alignItems: 'center',
224
+ },
225
+ yearText: {
226
+ textAlign: 'center',
227
+ },
228
+ });
@@ -0,0 +1,184 @@
1
+ import React from 'react';
2
+ import {
3
+ KeyboardAvoidingView,
4
+ Modal,
5
+ Platform,
6
+ Pressable,
7
+ SafeAreaView,
8
+ StyleSheet,
9
+ View,
10
+ } from 'react-native';
11
+ import type { ResolvedTheme } from '../../theme';
12
+ import type {
13
+ BaseModalProps,
14
+ PresentationMode,
15
+ } from '../../types/presentation';
16
+
17
+ export interface ModalWrapperProps extends BaseModalProps {
18
+ presentation?: PresentationMode;
19
+ children: React.ReactNode;
20
+ theme: ResolvedTheme;
21
+ }
22
+
23
+ export const ModalWrapper: React.FC<ModalWrapperProps> = ({
24
+ presentation = 'modal',
25
+ visible = false,
26
+ onClose,
27
+ children,
28
+ theme,
29
+ backdropOpacity,
30
+ animationType,
31
+ showHandle = true,
32
+ closeOnBackdropPress = true,
33
+ }) => {
34
+ if (presentation === 'inline') {
35
+ return (
36
+ <View
37
+ style={[
38
+ styles.inlineContainer,
39
+ {
40
+ backgroundColor: theme.colors.background,
41
+ borderColor: theme.colors.border,
42
+ borderRadius: theme.borderRadius.lg,
43
+ },
44
+ ]}
45
+ >
46
+ {children}
47
+ </View>
48
+ );
49
+ }
50
+
51
+ const effectiveAnim =
52
+ animationType ||
53
+ (presentation === 'bottom-sheet'
54
+ ? 'slide'
55
+ : presentation === 'fullscreen'
56
+ ? 'slide'
57
+ : 'fade');
58
+
59
+ const overlayBg =
60
+ backdropOpacity !== undefined
61
+ ? `rgba(0, 0, 0, ${backdropOpacity})`
62
+ : theme.colors.modalOverlay;
63
+
64
+ const isBottomSheet = presentation === 'bottom-sheet';
65
+ const isFullscreen = presentation === 'fullscreen';
66
+
67
+ return (
68
+ <Modal
69
+ transparent={!isFullscreen}
70
+ visible={visible}
71
+ animationType={effectiveAnim}
72
+ onRequestClose={onClose}
73
+ statusBarTranslucent
74
+ >
75
+ <KeyboardAvoidingView
76
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}
77
+ style={styles.keyboardAvoid}
78
+ >
79
+ {isFullscreen ? (
80
+ <SafeAreaView
81
+ style={[
82
+ styles.fullscreenContainer,
83
+ { backgroundColor: theme.colors.background },
84
+ ]}
85
+ >
86
+ {children}
87
+ </SafeAreaView>
88
+ ) : (
89
+ <View style={styles.modalBackdrop}>
90
+ <Pressable
91
+ style={[StyleSheet.absoluteFill, { backgroundColor: overlayBg }]}
92
+ onPress={closeOnBackdropPress ? onClose : undefined}
93
+ />
94
+
95
+ <View
96
+ style={[
97
+ isBottomSheet
98
+ ? styles.bottomSheetContainer
99
+ : styles.centerModalContainer,
100
+ {
101
+ backgroundColor: theme.colors.modalBackground,
102
+ borderColor: theme.colors.border,
103
+ borderRadius: isBottomSheet
104
+ ? theme.borderRadius.lg
105
+ : theme.borderRadius.lg,
106
+ borderBottomLeftRadius: isBottomSheet
107
+ ? 0
108
+ : theme.borderRadius.lg,
109
+ borderBottomRightRadius: isBottomSheet
110
+ ? 0
111
+ : theme.borderRadius.lg,
112
+ },
113
+ ]}
114
+ >
115
+ {isBottomSheet && showHandle && (
116
+ <View style={styles.handleContainer}>
117
+ <View
118
+ style={[
119
+ styles.handleBar,
120
+ { backgroundColor: theme.colors.modalHandle },
121
+ ]}
122
+ />
123
+ </View>
124
+ )}
125
+ {children}
126
+ </View>
127
+ </View>
128
+ )}
129
+ </KeyboardAvoidingView>
130
+ </Modal>
131
+ );
132
+ };
133
+
134
+ const styles = StyleSheet.create({
135
+ inlineContainer: {
136
+ borderWidth: 1,
137
+ overflow: 'hidden',
138
+ },
139
+ keyboardAvoid: {
140
+ flex: 1,
141
+ },
142
+ modalBackdrop: {
143
+ flex: 1,
144
+ justifyContent: 'center',
145
+ alignItems: 'center',
146
+ },
147
+ centerModalContainer: {
148
+ width: '90%',
149
+ maxWidth: 420,
150
+ borderWidth: StyleSheet.hairlineWidth,
151
+ overflow: 'hidden',
152
+ shadowColor: '#000',
153
+ shadowOffset: { width: 0, height: 8 },
154
+ shadowOpacity: 0.25,
155
+ shadowRadius: 16,
156
+ elevation: 10,
157
+ },
158
+ bottomSheetContainer: {
159
+ position: 'absolute',
160
+ bottom: 0,
161
+ left: 0,
162
+ right: 0,
163
+ borderTopWidth: StyleSheet.hairlineWidth,
164
+ shadowColor: '#000',
165
+ shadowOffset: { width: 0, height: -4 },
166
+ shadowOpacity: 0.15,
167
+ shadowRadius: 12,
168
+ elevation: 12,
169
+ },
170
+ fullscreenContainer: {
171
+ flex: 1,
172
+ },
173
+ handleContainer: {
174
+ width: '100%',
175
+ height: 20,
176
+ justifyContent: 'center',
177
+ alignItems: 'center',
178
+ },
179
+ handleBar: {
180
+ width: 36,
181
+ height: 4,
182
+ borderRadius: 2,
183
+ },
184
+ });