@izonnet-web-solution/react-native-date-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 (271) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE +5 -0
  3. package/README.md +942 -2
  4. package/assets/screenshots/calendar-picker-blue.jpg +0 -0
  5. package/assets/screenshots/calendar-picker.jpg +0 -0
  6. package/assets/screenshots/datetime-picker-date.jpg +0 -0
  7. package/assets/screenshots/datetime-picker-time-blue.jpg +0 -0
  8. package/assets/screenshots/input-modal-picker.jpg +0 -0
  9. package/assets/screenshots/manual-entry-single.jpg +0 -0
  10. package/assets/screenshots/manual-entry-split.jpg +0 -0
  11. package/assets/screenshots/month-year-selector-modal.jpg +0 -0
  12. package/assets/screenshots/range-picker.jpg +0 -0
  13. package/assets/screenshots/time-12h-wheel.jpg +0 -0
  14. package/assets/screenshots/time-24h-military-blue.jpg +0 -0
  15. package/assets/screenshots/wheel-date-picker.jpg +0 -0
  16. package/lib/components/Calendar/Calendar.d.ts +35 -0
  17. package/lib/components/Calendar/Calendar.d.ts.map +1 -0
  18. package/lib/components/Calendar/Calendar.js +126 -0
  19. package/lib/components/Calendar/Calendar.js.map +1 -0
  20. package/lib/components/Calendar/CalendarGrid.d.ts +11 -0
  21. package/lib/components/Calendar/CalendarGrid.d.ts.map +1 -0
  22. package/lib/components/Calendar/CalendarGrid.js +22 -0
  23. package/lib/components/Calendar/CalendarGrid.js.map +1 -0
  24. package/lib/components/Calendar/CalendarHeader.d.ts +23 -0
  25. package/lib/components/Calendar/CalendarHeader.d.ts.map +1 -0
  26. package/lib/components/Calendar/CalendarHeader.js +62 -0
  27. package/lib/components/Calendar/CalendarHeader.js.map +1 -0
  28. package/lib/components/Calendar/DateCell.d.ts +11 -0
  29. package/lib/components/Calendar/DateCell.d.ts.map +1 -0
  30. package/lib/components/Calendar/DateCell.js +71 -0
  31. package/lib/components/Calendar/DateCell.js.map +1 -0
  32. package/lib/components/Calendar/MonthYearSelectorModal.d.ts +17 -0
  33. package/lib/components/Calendar/MonthYearSelectorModal.d.ts.map +1 -0
  34. package/lib/components/Calendar/MonthYearSelectorModal.js +253 -0
  35. package/lib/components/Calendar/MonthYearSelectorModal.js.map +1 -0
  36. package/lib/components/Calendar/WeekDays.d.ts +13 -0
  37. package/lib/components/Calendar/WeekDays.d.ts.map +1 -0
  38. package/lib/components/Calendar/WeekDays.js +34 -0
  39. package/lib/components/Calendar/WeekDays.js.map +1 -0
  40. package/lib/components/Calendar/index.d.ts +7 -0
  41. package/lib/components/Calendar/index.d.ts.map +1 -0
  42. package/lib/components/Calendar/index.js +23 -0
  43. package/lib/components/Calendar/index.js.map +1 -0
  44. package/lib/components/DatePicker.d.ts +4 -0
  45. package/lib/components/DatePicker.d.ts.map +1 -0
  46. package/lib/components/DatePicker.js +498 -0
  47. package/lib/components/DatePicker.js.map +1 -0
  48. package/lib/components/Input/CalendarPopup.d.ts +26 -0
  49. package/lib/components/Input/CalendarPopup.d.ts.map +1 -0
  50. package/lib/components/Input/CalendarPopup.js +60 -0
  51. package/lib/components/Input/CalendarPopup.js.map +1 -0
  52. package/lib/components/Input/DateInput.d.ts +29 -0
  53. package/lib/components/Input/DateInput.d.ts.map +1 -0
  54. package/lib/components/Input/DateInput.js +110 -0
  55. package/lib/components/Input/DateInput.js.map +1 -0
  56. package/lib/components/Input/index.d.ts +3 -0
  57. package/lib/components/Input/index.d.ts.map +1 -0
  58. package/lib/components/Input/index.js +19 -0
  59. package/lib/components/Input/index.js.map +1 -0
  60. package/lib/components/ManualDateInput/DateInputField.d.ts +19 -0
  61. package/lib/components/ManualDateInput/DateInputField.d.ts.map +1 -0
  62. package/lib/components/ManualDateInput/DateInputField.js +345 -0
  63. package/lib/components/ManualDateInput/DateInputField.js.map +1 -0
  64. package/lib/components/ManualDateInput/DateValidationMessage.d.ts +8 -0
  65. package/lib/components/ManualDateInput/DateValidationMessage.d.ts.map +1 -0
  66. package/lib/components/ManualDateInput/DateValidationMessage.js +45 -0
  67. package/lib/components/ManualDateInput/DateValidationMessage.js.map +1 -0
  68. package/lib/components/ManualDateInput/ManualDateInput.d.ts +19 -0
  69. package/lib/components/ManualDateInput/ManualDateInput.d.ts.map +1 -0
  70. package/lib/components/ManualDateInput/ManualDateInput.js +18 -0
  71. package/lib/components/ManualDateInput/ManualDateInput.js.map +1 -0
  72. package/lib/components/ManualDateInput/index.d.ts +4 -0
  73. package/lib/components/ManualDateInput/index.d.ts.map +1 -0
  74. package/lib/components/ManualDateInput/index.js +20 -0
  75. package/lib/components/ManualDateInput/index.js.map +1 -0
  76. package/lib/components/Range/RangeDateCell.d.ts +11 -0
  77. package/lib/components/Range/RangeDateCell.d.ts.map +1 -0
  78. package/lib/components/Range/RangeDateCell.js +107 -0
  79. package/lib/components/Range/RangeDateCell.js.map +1 -0
  80. package/lib/components/Range/RangePicker.d.ts +29 -0
  81. package/lib/components/Range/RangePicker.d.ts.map +1 -0
  82. package/lib/components/Range/RangePicker.js +261 -0
  83. package/lib/components/Range/RangePicker.js.map +1 -0
  84. package/lib/components/Range/index.d.ts +3 -0
  85. package/lib/components/Range/index.d.ts.map +1 -0
  86. package/lib/components/Range/index.js +19 -0
  87. package/lib/components/Range/index.js.map +1 -0
  88. package/lib/components/Time/ClockDial.d.ts +15 -0
  89. package/lib/components/Time/ClockDial.d.ts.map +1 -0
  90. package/lib/components/Time/ClockDial.js +347 -0
  91. package/lib/components/Time/ClockDial.js.map +1 -0
  92. package/lib/components/Time/DateTimePicker.d.ts +31 -0
  93. package/lib/components/Time/DateTimePicker.d.ts.map +1 -0
  94. package/lib/components/Time/DateTimePicker.js +197 -0
  95. package/lib/components/Time/DateTimePicker.js.map +1 -0
  96. package/lib/components/Time/TimePicker.d.ts +31 -0
  97. package/lib/components/Time/TimePicker.d.ts.map +1 -0
  98. package/lib/components/Time/TimePicker.js +550 -0
  99. package/lib/components/Time/TimePicker.js.map +1 -0
  100. package/lib/components/Time/WheelTimePicker.d.ts +27 -0
  101. package/lib/components/Time/WheelTimePicker.d.ts.map +1 -0
  102. package/lib/components/Time/WheelTimePicker.js +203 -0
  103. package/lib/components/Time/WheelTimePicker.js.map +1 -0
  104. package/lib/components/Time/index.d.ts +5 -0
  105. package/lib/components/Time/index.d.ts.map +1 -0
  106. package/lib/components/Time/index.js +21 -0
  107. package/lib/components/Time/index.js.map +1 -0
  108. package/lib/components/Wheel/WheelColumn.d.ts +17 -0
  109. package/lib/components/Wheel/WheelColumn.d.ts.map +1 -0
  110. package/lib/components/Wheel/WheelColumn.js +192 -0
  111. package/lib/components/Wheel/WheelColumn.js.map +1 -0
  112. package/lib/components/Wheel/WheelPicker.d.ts +26 -0
  113. package/lib/components/Wheel/WheelPicker.d.ts.map +1 -0
  114. package/lib/components/Wheel/WheelPicker.js +123 -0
  115. package/lib/components/Wheel/WheelPicker.js.map +1 -0
  116. package/lib/components/Wheel/index.d.ts +3 -0
  117. package/lib/components/Wheel/index.d.ts.map +1 -0
  118. package/lib/components/Wheel/index.js +19 -0
  119. package/lib/components/Wheel/index.js.map +1 -0
  120. package/lib/components/common/Button.d.ts +17 -0
  121. package/lib/components/common/Button.d.ts.map +1 -0
  122. package/lib/components/common/Button.js +77 -0
  123. package/lib/components/common/Button.js.map +1 -0
  124. package/lib/components/common/IconButton.d.ts +14 -0
  125. package/lib/components/common/IconButton.d.ts.map +1 -0
  126. package/lib/components/common/IconButton.js +150 -0
  127. package/lib/components/common/IconButton.js.map +1 -0
  128. package/lib/components/common/Modal.d.ts +13 -0
  129. package/lib/components/common/Modal.d.ts.map +1 -0
  130. package/lib/components/common/Modal.js +65 -0
  131. package/lib/components/common/Modal.js.map +1 -0
  132. package/lib/components/common/index.d.ts +4 -0
  133. package/lib/components/common/index.d.ts.map +1 -0
  134. package/lib/components/common/index.js +20 -0
  135. package/lib/components/common/index.js.map +1 -0
  136. package/lib/components/index.d.ts +9 -0
  137. package/lib/components/index.d.ts.map +1 -0
  138. package/lib/components/index.js +25 -0
  139. package/lib/components/index.js.map +1 -0
  140. package/lib/hooks/index.d.ts +4 -0
  141. package/lib/hooks/index.d.ts.map +1 -0
  142. package/lib/hooks/index.js +20 -0
  143. package/lib/hooks/index.js.map +1 -0
  144. package/lib/hooks/useCalendar.d.ts +34 -0
  145. package/lib/hooks/useCalendar.d.ts.map +1 -0
  146. package/lib/hooks/useCalendar.js +93 -0
  147. package/lib/hooks/useCalendar.js.map +1 -0
  148. package/lib/hooks/useDatePicker.d.ts +28 -0
  149. package/lib/hooks/useDatePicker.d.ts.map +1 -0
  150. package/lib/hooks/useDatePicker.js +150 -0
  151. package/lib/hooks/useDatePicker.js.map +1 -0
  152. package/lib/hooks/useDateRange.d.ts +23 -0
  153. package/lib/hooks/useDateRange.d.ts.map +1 -0
  154. package/lib/hooks/useDateRange.js +82 -0
  155. package/lib/hooks/useDateRange.js.map +1 -0
  156. package/lib/index.d.ts +7 -0
  157. package/lib/index.d.ts.map +1 -0
  158. package/lib/index.js +29 -0
  159. package/lib/index.js.map +1 -0
  160. package/lib/localization/en.d.ts +3 -0
  161. package/lib/localization/en.d.ts.map +1 -0
  162. package/lib/localization/en.js +80 -0
  163. package/lib/localization/en.js.map +1 -0
  164. package/lib/localization/gu.d.ts +3 -0
  165. package/lib/localization/gu.d.ts.map +1 -0
  166. package/lib/localization/gu.js +80 -0
  167. package/lib/localization/gu.js.map +1 -0
  168. package/lib/localization/hi.d.ts +3 -0
  169. package/lib/localization/hi.d.ts.map +1 -0
  170. package/lib/localization/hi.js +80 -0
  171. package/lib/localization/hi.js.map +1 -0
  172. package/lib/localization/index.d.ts +8 -0
  173. package/lib/localization/index.d.ts.map +1 -0
  174. package/lib/localization/index.js +32 -0
  175. package/lib/localization/index.js.map +1 -0
  176. package/lib/themes/dark.d.ts +3 -0
  177. package/lib/themes/dark.d.ts.map +1 -0
  178. package/lib/themes/dark.js +30 -0
  179. package/lib/themes/dark.js.map +1 -0
  180. package/lib/themes/index.d.ts +16 -0
  181. package/lib/themes/index.d.ts.map +1 -0
  182. package/lib/themes/index.js +56 -0
  183. package/lib/themes/index.js.map +1 -0
  184. package/lib/themes/light.d.ts +3 -0
  185. package/lib/themes/light.d.ts.map +1 -0
  186. package/lib/themes/light.js +30 -0
  187. package/lib/themes/light.js.map +1 -0
  188. package/lib/types/index.d.ts +344 -0
  189. package/lib/types/index.d.ts.map +1 -0
  190. package/lib/types/index.js +3 -0
  191. package/lib/types/index.js.map +1 -0
  192. package/lib/utils/calendarUtils.d.ts +27 -0
  193. package/lib/utils/calendarUtils.d.ts.map +1 -0
  194. package/lib/utils/calendarUtils.js +108 -0
  195. package/lib/utils/calendarUtils.js.map +1 -0
  196. package/lib/utils/dateFormatting.d.ts +29 -0
  197. package/lib/utils/dateFormatting.d.ts.map +1 -0
  198. package/lib/utils/dateFormatting.js +114 -0
  199. package/lib/utils/dateFormatting.js.map +1 -0
  200. package/lib/utils/dateParsing.d.ts +23 -0
  201. package/lib/utils/dateParsing.d.ts.map +1 -0
  202. package/lib/utils/dateParsing.js +289 -0
  203. package/lib/utils/dateParsing.js.map +1 -0
  204. package/lib/utils/dateUtils.d.ts +20 -0
  205. package/lib/utils/dateUtils.d.ts.map +1 -0
  206. package/lib/utils/dateUtils.js +115 -0
  207. package/lib/utils/dateUtils.js.map +1 -0
  208. package/lib/utils/dateValidation.d.ts +36 -0
  209. package/lib/utils/dateValidation.d.ts.map +1 -0
  210. package/lib/utils/dateValidation.js +196 -0
  211. package/lib/utils/dateValidation.js.map +1 -0
  212. package/lib/utils/index.d.ts +7 -0
  213. package/lib/utils/index.d.ts.map +1 -0
  214. package/lib/utils/index.js +23 -0
  215. package/lib/utils/index.js.map +1 -0
  216. package/lib/utils/timeUtils.d.ts +78 -0
  217. package/lib/utils/timeUtils.d.ts.map +1 -0
  218. package/lib/utils/timeUtils.js +335 -0
  219. package/lib/utils/timeUtils.js.map +1 -0
  220. package/package.json +92 -3
  221. package/src/components/Calendar/Calendar.tsx +314 -0
  222. package/src/components/Calendar/CalendarGrid.tsx +47 -0
  223. package/src/components/Calendar/CalendarHeader.tsx +176 -0
  224. package/src/components/Calendar/DateCell.tsx +118 -0
  225. package/src/components/Calendar/MonthYearSelectorModal.tsx +407 -0
  226. package/src/components/Calendar/WeekDays.tsx +49 -0
  227. package/src/components/Calendar/index.ts +6 -0
  228. package/src/components/DatePicker.tsx +834 -0
  229. package/src/components/Input/CalendarPopup.tsx +168 -0
  230. package/src/components/Input/DateInput.tsx +259 -0
  231. package/src/components/Input/index.ts +2 -0
  232. package/src/components/ManualDateInput/DateInputField.tsx +493 -0
  233. package/src/components/ManualDateInput/DateValidationMessage.tsx +65 -0
  234. package/src/components/ManualDateInput/ManualDateInput.tsx +66 -0
  235. package/src/components/ManualDateInput/index.ts +3 -0
  236. package/src/components/Range/RangeDateCell.tsx +174 -0
  237. package/src/components/Range/RangePicker.tsx +484 -0
  238. package/src/components/Range/index.ts +2 -0
  239. package/src/components/Time/ClockDial.tsx +450 -0
  240. package/src/components/Time/DateTimePicker.tsx +395 -0
  241. package/src/components/Time/TimePicker.tsx +899 -0
  242. package/src/components/Time/WheelTimePicker.tsx +356 -0
  243. package/src/components/Time/index.ts +4 -0
  244. package/src/components/Wheel/WheelColumn.tsx +300 -0
  245. package/src/components/Wheel/WheelPicker.tsx +265 -0
  246. package/src/components/Wheel/index.ts +2 -0
  247. package/src/components/common/Button.tsx +125 -0
  248. package/src/components/common/IconButton.tsx +237 -0
  249. package/src/components/common/Modal.tsx +137 -0
  250. package/src/components/common/index.ts +3 -0
  251. package/src/components/index.ts +8 -0
  252. package/src/hooks/index.ts +3 -0
  253. package/src/hooks/useCalendar.ts +153 -0
  254. package/src/hooks/useDatePicker.ts +216 -0
  255. package/src/hooks/useDateRange.ts +135 -0
  256. package/src/index.ts +17 -0
  257. package/src/localization/en.ts +78 -0
  258. package/src/localization/gu.ts +78 -0
  259. package/src/localization/hi.ts +78 -0
  260. package/src/localization/index.ts +31 -0
  261. package/src/themes/dark.ts +28 -0
  262. package/src/themes/index.ts +73 -0
  263. package/src/themes/light.ts +28 -0
  264. package/src/types/index.ts +452 -0
  265. package/src/utils/calendarUtils.ts +152 -0
  266. package/src/utils/dateFormatting.ts +125 -0
  267. package/src/utils/dateParsing.ts +335 -0
  268. package/src/utils/dateUtils.ts +117 -0
  269. package/src/utils/dateValidation.ts +276 -0
  270. package/src/utils/index.ts +6 -0
  271. package/src/utils/timeUtils.ts +416 -0
@@ -0,0 +1,356 @@
1
+ import React, { useMemo } from 'react';
2
+ import { View, Text, StyleSheet, TouchableOpacity, StyleProp, ViewStyle } from 'react-native';
3
+ import type {
4
+ DatePickerTheme,
5
+ DatePickerLocale,
6
+ TimePeriod,
7
+ } from '../../types';
8
+ import { WheelColumn, WheelItem } from '../Wheel/WheelColumn';
9
+ import {
10
+ padZero,
11
+ isHourDisabled,
12
+ isMinuteDisabled,
13
+ TimeValidationOptions,
14
+ } from '../../utils/timeUtils';
15
+
16
+ export interface WheelTimePickerProps {
17
+ hours: number; // 0..23 if 24h, 1..12 if 12h
18
+ minutes: number; // 0..59
19
+ seconds?: number; // 0..59
20
+ period?: TimePeriod; // 'AM' | 'PM'
21
+ is24Hour?: boolean;
22
+ minuteInterval?: number;
23
+ showSeconds?: boolean;
24
+ onTimeChange: (time: {
25
+ hours: number;
26
+ minutes: number;
27
+ seconds: number;
28
+ period?: TimePeriod;
29
+ }) => void;
30
+ theme: DatePickerTheme;
31
+ locale: DatePickerLocale;
32
+ itemHeight?: number;
33
+ visibleItems?: number;
34
+ validationOptions?: TimeValidationOptions;
35
+ style?: StyleProp<ViewStyle>;
36
+ }
37
+
38
+ export const WheelTimePicker: React.FC<WheelTimePickerProps> = ({
39
+ hours,
40
+ minutes,
41
+ seconds = 0,
42
+ period = 'AM',
43
+ is24Hour = false,
44
+ minuteInterval = 1,
45
+ showSeconds = false,
46
+ onTimeChange,
47
+ theme,
48
+ locale,
49
+ itemHeight = 44,
50
+ visibleItems = 5,
51
+ validationOptions,
52
+ style,
53
+ }) => {
54
+ // Ensure minutes snaps to valid minuteItems interval
55
+ const interval = Math.max(1, Math.min(30, minuteInterval));
56
+ const normalizedMinutes = useMemo(() => {
57
+ if (interval <= 1) return minutes;
58
+ const rounded = Math.round(minutes / interval) * interval;
59
+ return rounded >= 60 ? 0 : rounded;
60
+ }, [minutes, interval]);
61
+
62
+ // 1. Hours items
63
+ const hourItems: WheelItem[] = useMemo(() => {
64
+ const list: WheelItem[] = [];
65
+ if (is24Hour) {
66
+ for (let h = 0; h <= 23; h++) {
67
+ const disabled = isHourDisabled(h, true, undefined, validationOptions);
68
+ list.push({
69
+ label: `${padZero(h)}${disabled ? ' ✕' : ''}`,
70
+ value: h,
71
+ });
72
+ }
73
+ } else {
74
+ const startH = hours === 0 ? 0 : 1;
75
+ for (let h = startH; h <= 12; h++) {
76
+ const disabled = h === 0 ? false : isHourDisabled(h, false, period, validationOptions);
77
+ list.push({
78
+ label: `${padZero(h)}${disabled ? ' ✕' : ''}`,
79
+ value: h,
80
+ });
81
+ }
82
+ }
83
+ return list;
84
+ }, [is24Hour, hours, period, validationOptions]);
85
+
86
+ // 2. Minutes items
87
+ const minuteItems: WheelItem[] = useMemo(() => {
88
+ const list: WheelItem[] = [];
89
+ for (let m = 0; m <= 59; m += interval) {
90
+ const disabled = isMinuteDisabled(m, hours, is24Hour, period, validationOptions);
91
+ list.push({
92
+ label: `${padZero(m)}${disabled ? ' ✕' : ''}`,
93
+ value: m,
94
+ });
95
+ }
96
+ return list;
97
+ }, [interval, hours, is24Hour, period, validationOptions]);
98
+
99
+ // 3. Seconds items
100
+ const secondItems: WheelItem[] = useMemo(() => {
101
+ const list: WheelItem[] = [];
102
+ for (let s = 0; s <= 59; s += 5) {
103
+ list.push({
104
+ label: padZero(s),
105
+ value: s,
106
+ });
107
+ }
108
+ return list;
109
+ }, []);
110
+
111
+ return (
112
+ <View style={[styles.wrapper, style]}>
113
+ {/* Column Labels */}
114
+ <View style={styles.labelsRow}>
115
+ <Text style={[styles.columnLabel, { color: theme.secondaryTextColor }]}>
116
+ {locale.hourLabel ? locale.hourLabel.toUpperCase() : 'HOUR'}
117
+ </Text>
118
+ <Text style={[styles.columnLabel, { color: theme.secondaryTextColor }]}>
119
+ {locale.minuteLabel ? locale.minuteLabel.toUpperCase() : 'MIN'}
120
+ </Text>
121
+ {showSeconds && (
122
+ <Text style={[styles.columnLabel, { color: theme.secondaryTextColor }]}>
123
+ {locale.secondLabel ? locale.secondLabel.toUpperCase() : 'SEC'}
124
+ </Text>
125
+ )}
126
+ {!is24Hour && (
127
+ <Text style={[styles.columnLabel, { color: theme.secondaryTextColor }]}>
128
+ PERIOD
129
+ </Text>
130
+ )}
131
+ </View>
132
+
133
+ <View style={styles.wheelsRow}>
134
+ {/* Hours Wheel Column */}
135
+ <View style={styles.wheelColContainer}>
136
+ <WheelColumn
137
+ items={hourItems}
138
+ selectedValue={hours}
139
+ onValueChange={(newHour) => {
140
+ onTimeChange({
141
+ hours: newHour,
142
+ minutes: normalizedMinutes,
143
+ seconds,
144
+ period,
145
+ });
146
+ }}
147
+ theme={theme}
148
+ itemHeight={itemHeight}
149
+ visibleItems={visibleItems}
150
+ accessibilityLabel={locale.hourLabel}
151
+ />
152
+ </View>
153
+
154
+ {/* Colon separator */}
155
+ <View style={styles.colonContainer}>
156
+ <Text style={[styles.colonText, { color: theme.textColor }]}>:</Text>
157
+ </View>
158
+
159
+ {/* Minutes Wheel Column */}
160
+ <View style={styles.wheelColContainer}>
161
+ <WheelColumn
162
+ items={minuteItems}
163
+ selectedValue={normalizedMinutes}
164
+ onValueChange={(newMinute) => {
165
+ onTimeChange({
166
+ hours,
167
+ minutes: newMinute,
168
+ seconds,
169
+ period,
170
+ });
171
+ }}
172
+ theme={theme}
173
+ itemHeight={itemHeight}
174
+ visibleItems={visibleItems}
175
+ accessibilityLabel={locale.minuteLabel}
176
+ />
177
+ </View>
178
+
179
+ {/* Optional Seconds Column */}
180
+ {showSeconds && (
181
+ <>
182
+ <View style={styles.colonContainer}>
183
+ <Text style={[styles.colonText, { color: theme.textColor }]}>:</Text>
184
+ </View>
185
+ <View style={styles.wheelColContainer}>
186
+ <WheelColumn
187
+ items={secondItems}
188
+ selectedValue={seconds}
189
+ onValueChange={(newSecond) => {
190
+ onTimeChange({
191
+ hours,
192
+ minutes: normalizedMinutes,
193
+ seconds: newSecond,
194
+ period,
195
+ });
196
+ }}
197
+ theme={theme}
198
+ itemHeight={itemHeight}
199
+ visibleItems={visibleItems}
200
+ accessibilityLabel={locale.secondLabel}
201
+ />
202
+ </View>
203
+ </>
204
+ )}
205
+
206
+ {/* AM / PM Segmented Selector (12-hour only) */}
207
+ {!is24Hour && (
208
+ <View style={styles.periodContainer}>
209
+ <TouchableOpacity
210
+ activeOpacity={0.8}
211
+ onPress={() => {
212
+ if (period !== 'AM') {
213
+ onTimeChange({
214
+ hours,
215
+ minutes: normalizedMinutes,
216
+ seconds,
217
+ period: 'AM',
218
+ });
219
+ }
220
+ }}
221
+ style={[
222
+ styles.periodBtn,
223
+ period === 'AM'
224
+ ? {
225
+ backgroundColor: theme.primaryColor,
226
+ borderColor: theme.primaryColor,
227
+ }
228
+ : {
229
+ backgroundColor: theme.cardColor,
230
+ borderColor: theme.borderColor,
231
+ },
232
+ ]}
233
+ accessibilityRole="button"
234
+ accessibilityState={{ selected: period === 'AM' }}
235
+ >
236
+ <Text
237
+ style={[
238
+ styles.periodBtnText,
239
+ {
240
+ color: period === 'AM' ? '#FFFFFF' : theme.textColor,
241
+ fontWeight: period === 'AM' ? '800' : '600',
242
+ },
243
+ ]}
244
+ >
245
+ {locale.am || 'AM'}
246
+ </Text>
247
+ </TouchableOpacity>
248
+
249
+ <TouchableOpacity
250
+ activeOpacity={0.8}
251
+ onPress={() => {
252
+ if (period !== 'PM') {
253
+ onTimeChange({
254
+ hours,
255
+ minutes: normalizedMinutes,
256
+ seconds,
257
+ period: 'PM',
258
+ });
259
+ }
260
+ }}
261
+ style={[
262
+ styles.periodBtn,
263
+ period === 'PM'
264
+ ? {
265
+ backgroundColor: theme.primaryColor,
266
+ borderColor: theme.primaryColor,
267
+ }
268
+ : {
269
+ backgroundColor: theme.cardColor,
270
+ borderColor: theme.borderColor,
271
+ },
272
+ ]}
273
+ accessibilityRole="button"
274
+ accessibilityState={{ selected: period === 'PM' }}
275
+ >
276
+ <Text
277
+ style={[
278
+ styles.periodBtnText,
279
+ {
280
+ color: period === 'PM' ? '#FFFFFF' : theme.textColor,
281
+ fontWeight: period === 'PM' ? '800' : '600',
282
+ },
283
+ ]}
284
+ >
285
+ {locale.pm || 'PM'}
286
+ </Text>
287
+ </TouchableOpacity>
288
+ </View>
289
+ )}
290
+ </View>
291
+ </View>
292
+ );
293
+ };
294
+
295
+ const styles = StyleSheet.create({
296
+ wrapper: {
297
+ width: '100%',
298
+ paddingVertical: 8,
299
+ },
300
+ labelsRow: {
301
+ flexDirection: 'row',
302
+ justifyContent: 'space-around',
303
+ marginBottom: 6,
304
+ paddingHorizontal: 8,
305
+ },
306
+ columnLabel: {
307
+ fontSize: 11,
308
+ fontWeight: '700',
309
+ letterSpacing: 0.5,
310
+ textAlign: 'center',
311
+ flex: 1,
312
+ },
313
+ wheelsRow: {
314
+ flexDirection: 'row',
315
+ alignItems: 'center',
316
+ justifyContent: 'center',
317
+ position: 'relative',
318
+ },
319
+ wheelColContainer: {
320
+ flex: 1,
321
+ maxWidth: 90,
322
+ },
323
+ colonContainer: {
324
+ width: 20,
325
+ alignItems: 'center',
326
+ justifyContent: 'center',
327
+ zIndex: 3,
328
+ },
329
+ colonText: {
330
+ fontSize: 24,
331
+ fontWeight: '800',
332
+ },
333
+ periodContainer: {
334
+ marginLeft: 12,
335
+ justifyContent: 'center',
336
+ alignItems: 'center',
337
+ gap: 8,
338
+ },
339
+ periodBtn: {
340
+ paddingVertical: 12,
341
+ paddingHorizontal: 16,
342
+ borderRadius: 12,
343
+ borderWidth: 1.5,
344
+ minWidth: 58,
345
+ alignItems: 'center',
346
+ justifyContent: 'center',
347
+ elevation: 1,
348
+ shadowColor: '#000',
349
+ shadowOffset: { width: 0, height: 1 },
350
+ shadowOpacity: 0.08,
351
+ shadowRadius: 2,
352
+ },
353
+ periodBtnText: {
354
+ fontSize: 14,
355
+ },
356
+ });
@@ -0,0 +1,4 @@
1
+ export * from './WheelTimePicker';
2
+ export * from './ClockDial';
3
+ export * from './TimePicker';
4
+ export * from './DateTimePicker';
@@ -0,0 +1,300 @@
1
+ import React, { useRef, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ FlatList,
6
+ StyleSheet,
7
+ TouchableOpacity,
8
+ NativeSyntheticEvent,
9
+ NativeScrollEvent,
10
+ } from 'react-native';
11
+ import type { DatePickerTheme } from '../../types';
12
+
13
+ export interface WheelItem {
14
+ label: string;
15
+ value: number;
16
+ }
17
+
18
+ export interface WheelColumnProps {
19
+ items: WheelItem[];
20
+ selectedValue: number;
21
+ onValueChange: (value: number) => void;
22
+ theme: DatePickerTheme;
23
+ itemHeight?: number;
24
+ visibleItems?: number;
25
+ accessibilityLabel?: string;
26
+ }
27
+
28
+ export const WheelColumn: React.FC<WheelColumnProps> = ({
29
+ items,
30
+ selectedValue,
31
+ onValueChange,
32
+ theme,
33
+ itemHeight = 44,
34
+ visibleItems = 5,
35
+ accessibilityLabel,
36
+ }) => {
37
+ const flatListRef = useRef<FlatList<WheelItem>>(null);
38
+ const isUserScrolling = useRef(false);
39
+ const isMomentumScrolling = useRef(false);
40
+ const scrollTimeoutRef = useRef<any>(null);
41
+ const isSelfTriggered = useRef(false);
42
+
43
+ const containerHeight = itemHeight * visibleItems;
44
+ const paddingVertical = (containerHeight - itemHeight) / 2;
45
+
46
+ // Find index of selected item, defaulting to closest or 0
47
+ const selectedIndex = items.findIndex((item) => item.value === selectedValue);
48
+
49
+ // Guarantee correct scroll position on initial mount (especially inside Modal)
50
+ useEffect(() => {
51
+ const timer = setTimeout(() => {
52
+ if (flatListRef.current && selectedIndex >= 0) {
53
+ flatListRef.current.scrollToOffset({
54
+ offset: selectedIndex * itemHeight,
55
+ animated: false,
56
+ });
57
+ }
58
+ }, 60);
59
+ return () => clearTimeout(timer);
60
+ }, []);
61
+
62
+ // Sync scroll position when selectedValue changes externally
63
+ useEffect(() => {
64
+ if (isSelfTriggered.current) {
65
+ isSelfTriggered.current = false;
66
+ return;
67
+ }
68
+
69
+ if (
70
+ !isUserScrolling.current &&
71
+ !isMomentumScrolling.current &&
72
+ selectedIndex >= 0 &&
73
+ flatListRef.current
74
+ ) {
75
+ flatListRef.current.scrollToOffset({
76
+ offset: selectedIndex * itemHeight,
77
+ animated: true,
78
+ });
79
+ }
80
+ }, [selectedIndex, itemHeight]);
81
+
82
+ const snapToOffset = (offsetY: number) => {
83
+ const index = Math.round(offsetY / itemHeight);
84
+ const clampedIndex = Math.max(0, Math.min(index, items.length - 1));
85
+ const targetItem = items[clampedIndex];
86
+
87
+ if (flatListRef.current) {
88
+ flatListRef.current.scrollToOffset({
89
+ offset: clampedIndex * itemHeight,
90
+ animated: true,
91
+ });
92
+ }
93
+
94
+ if (targetItem && targetItem.value !== selectedValue) {
95
+ isSelfTriggered.current = true;
96
+ onValueChange(targetItem.value);
97
+ }
98
+
99
+ isUserScrolling.current = false;
100
+ isMomentumScrolling.current = false;
101
+ };
102
+
103
+ const handleScrollBegin = () => {
104
+ isUserScrolling.current = true;
105
+ if (scrollTimeoutRef.current) {
106
+ clearTimeout(scrollTimeoutRef.current);
107
+ }
108
+ };
109
+
110
+ const handleScrollEndDrag = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
111
+ const offsetY = e.nativeEvent.contentOffset.y;
112
+ const velocity = Math.abs(e.nativeEvent.velocity?.y || 0);
113
+
114
+ if (scrollTimeoutRef.current) {
115
+ clearTimeout(scrollTimeoutRef.current);
116
+ }
117
+
118
+ // If momentum is active with high velocity, let onMomentumScrollEnd handle the snap
119
+ if (velocity > 0.1) {
120
+ return;
121
+ }
122
+
123
+ // For stationary release or small drag, snap smoothly
124
+ scrollTimeoutRef.current = setTimeout(() => {
125
+ if (!isMomentumScrolling.current) {
126
+ snapToOffset(offsetY);
127
+ }
128
+ }, 50);
129
+ };
130
+
131
+ const handleMomentumScrollBegin = () => {
132
+ isMomentumScrolling.current = true;
133
+ };
134
+
135
+ const handleMomentumScrollEnd = (
136
+ e: NativeSyntheticEvent<NativeScrollEvent>
137
+ ) => {
138
+ if (scrollTimeoutRef.current) {
139
+ clearTimeout(scrollTimeoutRef.current);
140
+ }
141
+ isMomentumScrolling.current = false;
142
+ snapToOffset(e.nativeEvent.contentOffset.y);
143
+ };
144
+
145
+ const renderItem = ({ item, index }: { item: WheelItem; index: number }) => {
146
+ const isSelected = item.value === selectedValue;
147
+ const distance = Math.abs(index - (selectedIndex >= 0 ? selectedIndex : 0));
148
+ const opacity = isSelected ? 1 : Math.max(0.25, 1 - distance * 0.3);
149
+ const scale = isSelected ? 1.08 : 0.92;
150
+
151
+ return (
152
+ <TouchableOpacity
153
+ activeOpacity={0.7}
154
+ onPress={() => {
155
+ isUserScrolling.current = false;
156
+ isMomentumScrolling.current = false;
157
+ snapToOffset(index * itemHeight);
158
+ }}
159
+ style={[styles.itemContainer, { height: itemHeight }]}
160
+ >
161
+ <Text
162
+ style={[
163
+ styles.itemText,
164
+ {
165
+ color: isSelected ? theme.primaryColor : theme.textColor,
166
+ fontSize: isSelected
167
+ ? theme.fontSize.large + 2
168
+ : theme.fontSize.medium,
169
+ fontWeight: isSelected ? '700' : '500',
170
+ opacity,
171
+ transform: [{ scale }],
172
+ },
173
+ ]}
174
+ >
175
+ {item.label}
176
+ </Text>
177
+ </TouchableOpacity>
178
+ );
179
+ };
180
+
181
+ return (
182
+ <View
183
+ style={[styles.container, { height: containerHeight }]}
184
+ accessibilityRole="adjustable"
185
+ accessibilityLabel={accessibilityLabel}
186
+ >
187
+ {/* Center highlight lens */}
188
+ <View
189
+ pointerEvents="none"
190
+ style={[
191
+ styles.highlightIndicator,
192
+ {
193
+ top: paddingVertical,
194
+ height: itemHeight,
195
+ borderColor: `${theme.primaryColor}40`,
196
+ backgroundColor: `${theme.primaryColor}14`,
197
+ borderRadius: 8,
198
+ },
199
+ ]}
200
+ />
201
+
202
+ {/* Top subtle fade overlay */}
203
+ <View
204
+ pointerEvents="none"
205
+ style={[
206
+ styles.fadeOverlay,
207
+ styles.topFade,
208
+ {
209
+ height: paddingVertical,
210
+ backgroundColor: theme.surfaceColor,
211
+ opacity: 0.75,
212
+ },
213
+ ]}
214
+ />
215
+
216
+ {/* Bottom subtle fade overlay */}
217
+ <View
218
+ pointerEvents="none"
219
+ style={[
220
+ styles.fadeOverlay,
221
+ styles.bottomFade,
222
+ {
223
+ height: paddingVertical,
224
+ backgroundColor: theme.surfaceColor,
225
+ opacity: 0.75,
226
+ },
227
+ ]}
228
+ />
229
+
230
+ <FlatList
231
+ ref={flatListRef}
232
+ data={items}
233
+ renderItem={renderItem}
234
+ keyExtractor={(item) => String(item.value)}
235
+ showsVerticalScrollIndicator={false}
236
+ snapToInterval={itemHeight}
237
+ snapToAlignment="start"
238
+ decelerationRate="fast"
239
+ nestedScrollEnabled={true}
240
+ overScrollMode="never"
241
+ onScrollBeginDrag={handleScrollBegin}
242
+ onScrollEndDrag={handleScrollEndDrag}
243
+ onMomentumScrollBegin={handleMomentumScrollBegin}
244
+ onMomentumScrollEnd={handleMomentumScrollEnd}
245
+ contentContainerStyle={{
246
+ paddingVertical,
247
+ }}
248
+ getItemLayout={(_, index) => ({
249
+ length: itemHeight,
250
+ offset: itemHeight * index,
251
+ index,
252
+ })}
253
+ initialScrollIndex={selectedIndex >= 0 ? selectedIndex : 0}
254
+ onScrollToIndexFailed={(info) => {
255
+ setTimeout(() => {
256
+ flatListRef.current?.scrollToOffset({
257
+ offset: info.index * itemHeight,
258
+ animated: false,
259
+ });
260
+ }, 50);
261
+ }}
262
+ />
263
+ </View>
264
+ );
265
+ };
266
+
267
+ const styles = StyleSheet.create({
268
+ container: {
269
+ flex: 1,
270
+ overflow: 'hidden',
271
+ position: 'relative',
272
+ },
273
+ highlightIndicator: {
274
+ position: 'absolute',
275
+ left: 2,
276
+ right: 2,
277
+ borderTopWidth: 1.5,
278
+ borderBottomWidth: 1.5,
279
+ zIndex: 1,
280
+ },
281
+ fadeOverlay: {
282
+ position: 'absolute',
283
+ left: 0,
284
+ right: 0,
285
+ zIndex: 2,
286
+ },
287
+ topFade: {
288
+ top: 0,
289
+ },
290
+ bottomFade: {
291
+ bottom: 0,
292
+ },
293
+ itemContainer: {
294
+ justifyContent: 'center',
295
+ alignItems: 'center',
296
+ },
297
+ itemText: {
298
+ textAlign: 'center',
299
+ },
300
+ });