@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,899 @@
1
+ import React, { useState, useEffect, useMemo, useCallback } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ TouchableOpacity,
6
+ StyleSheet,
7
+ StyleProp,
8
+ ViewStyle,
9
+ } from 'react-native';
10
+ import type {
11
+ DatePickerTheme,
12
+ DatePickerLocale,
13
+ TimePeriod,
14
+ TimePickerLayout,
15
+ ValidationResult,
16
+ DateFormat,
17
+ } from '../../types';
18
+ import {
19
+ padZero,
20
+ convert12To24,
21
+ setTimeOnDate,
22
+ getTimeFromDate,
23
+ validateTime,
24
+ is24HourFormat,
25
+ TimeValidationOptions,
26
+ } from '../../utils/timeUtils';
27
+ import { WheelTimePicker } from './WheelTimePicker';
28
+ import { ClockDial } from './ClockDial';
29
+ import { Button } from '../common/Button';
30
+ import { DateValidationMessage } from '../ManualDateInput/DateValidationMessage';
31
+
32
+ export interface TimePickerProps {
33
+ value?: Date | null;
34
+ defaultValue?: Date | null;
35
+ onChange?: (date: Date | null) => void;
36
+ is24Hour?: boolean;
37
+ minuteInterval?: number;
38
+ minimumTime?: string | Date;
39
+ maximumTime?: string | Date;
40
+ selectedDate?: Date | null;
41
+ minimumDate?: Date;
42
+ maximumDate?: Date;
43
+ showSeconds?: boolean;
44
+ timePickerLayout?: TimePickerLayout;
45
+ format?: DateFormat;
46
+ theme: DatePickerTheme;
47
+ locale: DatePickerLocale;
48
+ showActionButtons?: boolean;
49
+ showNowButton?: boolean;
50
+ showClearButton?: boolean;
51
+ onConfirm?: (date: Date | null) => void;
52
+ onCancel?: () => void;
53
+ onClear?: () => void;
54
+ autoCloseOnSelect?: boolean;
55
+ onClose?: () => void;
56
+ style?: StyleProp<ViewStyle>;
57
+ }
58
+
59
+ type ActiveTimeUnit = 'hours' | 'minutes';
60
+
61
+ export const TimePicker: React.FC<TimePickerProps> = ({
62
+ value: controlledValue,
63
+ defaultValue = null,
64
+ onChange,
65
+ is24Hour: is24HourProp,
66
+ minuteInterval = 1,
67
+ minimumTime,
68
+ maximumTime,
69
+ selectedDate,
70
+ minimumDate,
71
+ maximumDate,
72
+ showSeconds = false,
73
+ timePickerLayout: layoutProp = 'wheel',
74
+ format,
75
+ theme,
76
+ locale,
77
+ showActionButtons = true,
78
+ showNowButton = true,
79
+ showClearButton = true,
80
+ onConfirm,
81
+ onCancel,
82
+ onClear,
83
+ autoCloseOnSelect = false,
84
+ onClose,
85
+ style,
86
+ }) => {
87
+ // Determine 24-hour mode
88
+ const [is24Hour, setIs24Hour] = useState<boolean>(() => {
89
+ if (is24HourProp !== undefined) return is24HourProp;
90
+ if (format) return is24HourFormat(format);
91
+ return false;
92
+ });
93
+
94
+ useEffect(() => {
95
+ if (is24HourProp !== undefined) {
96
+ setIs24Hour(is24HourProp);
97
+ }
98
+ }, [is24HourProp]);
99
+
100
+ // Layout mode: 'wheel' | 'spinner' (dial/clock) | 'segmented' (steppers)
101
+ const [layout, setLayout] = useState<TimePickerLayout>(layoutProp);
102
+
103
+ useEffect(() => {
104
+ setLayout(layoutProp);
105
+ }, [layoutProp]);
106
+
107
+ // Active focused unit for Clock Dial
108
+ const [activeUnit, setActiveUnit] = useState<ActiveTimeUnit>('hours');
109
+
110
+ // Selected date or baseline
111
+ const activeDate = controlledValue || defaultValue || new Date();
112
+
113
+ // Internal time state
114
+ const initialTime = useMemo(() => {
115
+ return getTimeFromDate(activeDate, is24Hour);
116
+ }, [activeDate, is24Hour]);
117
+
118
+ const [hours, setHours] = useState<number>(initialTime.hours);
119
+ const [minutes, setMinutes] = useState<number>(initialTime.minutes);
120
+ const [seconds, setSeconds] = useState<number>(initialTime.seconds || 0);
121
+ const [period, setPeriod] = useState<TimePeriod>(initialTime.period || 'AM');
122
+ const [validation, setValidation] = useState<ValidationResult>({ isValid: true });
123
+
124
+ // Sync state when controlled value or 24h mode changes
125
+ useEffect(() => {
126
+ if (controlledValue) {
127
+ const parsed = getTimeFromDate(controlledValue, is24Hour);
128
+ setHours(parsed.hours);
129
+ setMinutes(parsed.minutes);
130
+ setSeconds(parsed.seconds || 0);
131
+ if (parsed.period) setPeriod(parsed.period);
132
+ } else if (controlledValue === null) {
133
+ setHours(0);
134
+ setMinutes(0);
135
+ setSeconds(0);
136
+ setPeriod('AM');
137
+ }
138
+ }, [controlledValue, is24Hour]);
139
+
140
+ // Validation options
141
+ const validationOptions: TimeValidationOptions = useMemo(
142
+ () => ({
143
+ minimumTime,
144
+ maximumTime,
145
+ selectedDate,
146
+ minimumDate,
147
+ maximumDate,
148
+ minuteInterval,
149
+ locale,
150
+ }),
151
+ [minimumTime, maximumTime, selectedDate, minimumDate, maximumDate, minuteInterval, locale]
152
+ );
153
+
154
+ // Apply change callback
155
+ const applyTimeChange = useCallback(
156
+ (newH: number, newM: number, newS: number, newP?: TimePeriod) => {
157
+ setHours(newH);
158
+ setMinutes(newM);
159
+ setSeconds(newS);
160
+ if (newP) setPeriod(newP);
161
+
162
+ const valResult = validateTime(
163
+ {
164
+ hours: newH,
165
+ minutes: newM,
166
+ seconds: newS,
167
+ period: newP,
168
+ is24Hour,
169
+ },
170
+ is24Hour,
171
+ validationOptions
172
+ );
173
+
174
+ setValidation(valResult);
175
+
176
+ if (valResult.isValid) {
177
+ const h24 = is24Hour ? newH : (newH === 0 ? 0 : convert12To24(newH, newP || 'AM'));
178
+ const base = activeDate || new Date();
179
+ const updatedDate = setTimeOnDate(base, h24, newM, newS);
180
+ onChange?.(updatedDate);
181
+ }
182
+ },
183
+ [is24Hour, validationOptions, activeDate, onChange]
184
+ );
185
+
186
+ // Steppers
187
+ const stepHour = (delta: number) => {
188
+ if (is24Hour) {
189
+ const nextH = (hours + delta + 24) % 24;
190
+ applyTimeChange(nextH, minutes, seconds, period);
191
+ } else {
192
+ let nextH = hours + delta;
193
+ let nextP = period;
194
+ if (nextH > 12) {
195
+ nextH = 1;
196
+ } else if (nextH < 1) {
197
+ nextH = 12;
198
+ }
199
+ applyTimeChange(nextH, minutes, seconds, nextP);
200
+ }
201
+ };
202
+
203
+ const stepMinute = (delta: number) => {
204
+ const step = delta * (minuteInterval > 1 ? minuteInterval : 1);
205
+ const nextM = (minutes + step + 60) % 60;
206
+ applyTimeChange(hours, nextM, seconds, period);
207
+ };
208
+
209
+ const togglePeriod = (newP: TimePeriod) => {
210
+ if (period !== newP) {
211
+ applyTimeChange(hours, minutes, seconds, newP);
212
+ }
213
+ };
214
+
215
+ const handleNow = () => {
216
+ const now = new Date();
217
+ const t = getTimeFromDate(now, is24Hour);
218
+ applyTimeChange(t.hours, t.minutes, t.seconds || 0, t.period);
219
+ if (autoCloseOnSelect) {
220
+ setTimeout(() => {
221
+ onConfirm?.(now);
222
+ onClose?.();
223
+ }, 200);
224
+ }
225
+ };
226
+
227
+ const handleClear = () => {
228
+ setHours(0);
229
+ setMinutes(0);
230
+ setSeconds(0);
231
+ setPeriod('AM');
232
+ setValidation({ isValid: true });
233
+ onChange?.(null);
234
+ onClear?.();
235
+ };
236
+
237
+ const handleCancel = () => {
238
+ onCancel?.();
239
+ onClose?.();
240
+ };
241
+
242
+ const handleConfirm = () => {
243
+ if (validation.isValid) {
244
+ const h24 = is24Hour ? hours : (hours === 0 ? 0 : convert12To24(hours, period));
245
+ const base = activeDate || new Date();
246
+ const finalDate = setTimeOnDate(base, h24, minutes, seconds);
247
+ onConfirm?.(finalDate);
248
+ onClose?.();
249
+ }
250
+ };
251
+
252
+ return (
253
+ <View
254
+ style={[
255
+ styles.container,
256
+ {
257
+ backgroundColor: theme.surfaceColor,
258
+ borderRadius: 20,
259
+ borderColor: theme.borderColor,
260
+ },
261
+ style,
262
+ ]}
263
+ >
264
+ {/* Sleek Compact Hero Time Display */}
265
+ <View
266
+ style={[
267
+ styles.heroCard,
268
+ {
269
+ backgroundColor: theme.cardColor,
270
+ borderColor: theme.borderColor,
271
+ },
272
+ ]}
273
+ >
274
+ <View style={styles.heroCenterBlock}>
275
+ {/* Hour Unit Box */}
276
+ <TouchableOpacity
277
+ activeOpacity={0.85}
278
+ onPress={() => setActiveUnit('hours')}
279
+ style={[
280
+ styles.heroDigitBox,
281
+ activeUnit === 'hours'
282
+ ? {
283
+ borderColor: theme.primaryColor,
284
+ backgroundColor: `${theme.primaryColor}14`,
285
+ shadowColor: theme.primaryColor,
286
+ shadowOffset: { width: 0, height: 2 },
287
+ shadowOpacity: 0.18,
288
+ shadowRadius: 5,
289
+
290
+ }
291
+ : {
292
+ borderColor: 'transparent',
293
+ backgroundColor: `${theme.textColor}06`,
294
+ },
295
+ ]}
296
+ >
297
+ <Text
298
+ style={[
299
+ styles.heroDigitText,
300
+ {
301
+ color: activeUnit === 'hours' ? theme.primaryColor : theme.textColor,
302
+ fontSize: 34,
303
+ },
304
+ ]}
305
+ >
306
+ {padZero(hours)}
307
+ </Text>
308
+ <Text
309
+ style={[
310
+ styles.heroUnitSubtext,
311
+ { color: activeUnit === 'hours' ? theme.primaryColor : theme.secondaryTextColor },
312
+ ]}
313
+ >
314
+ {locale.hourLabel ? locale.hourLabel.toUpperCase() : 'HOUR'}
315
+ </Text>
316
+ </TouchableOpacity>
317
+
318
+ {/* Colon Separator */}
319
+ <Text style={[styles.heroColon, { color: theme.textColor }]}>:</Text>
320
+
321
+ {/* Minute Unit Box */}
322
+ <TouchableOpacity
323
+ activeOpacity={0.85}
324
+ onPress={() => setActiveUnit('minutes')}
325
+ style={[
326
+ styles.heroDigitBox,
327
+ activeUnit === 'minutes'
328
+ ? {
329
+ borderColor: theme.primaryColor,
330
+ backgroundColor: `${theme.primaryColor}14`,
331
+ shadowColor: theme.primaryColor,
332
+ shadowOffset: { width: 0, height: 2 },
333
+ shadowOpacity: 0.18,
334
+ shadowRadius: 5,
335
+
336
+ }
337
+ : {
338
+ borderColor: 'transparent',
339
+ backgroundColor: `${theme.textColor}06`,
340
+ },
341
+ ]}
342
+ >
343
+ <Text
344
+ style={[
345
+ styles.heroDigitText,
346
+ {
347
+ color: activeUnit === 'minutes' ? theme.primaryColor : theme.textColor,
348
+ fontSize: 34,
349
+ },
350
+ ]}
351
+ >
352
+ {padZero(minutes)}
353
+ </Text>
354
+ <Text
355
+ style={[
356
+ styles.heroUnitSubtext,
357
+ { color: activeUnit === 'minutes' ? theme.primaryColor : theme.secondaryTextColor },
358
+ ]}
359
+ >
360
+ {locale.minuteLabel ? locale.minuteLabel.toUpperCase() : 'MIN'}
361
+ </Text>
362
+ </TouchableOpacity>
363
+
364
+ {/* Optional Seconds */}
365
+ {showSeconds && (
366
+ <>
367
+ <Text style={[styles.heroColon, { color: theme.textColor }]}>:</Text>
368
+ <View
369
+ style={[
370
+ styles.heroDigitBox,
371
+ {
372
+ borderColor: 'transparent',
373
+ backgroundColor: `${theme.textColor}06`,
374
+ minWidth: 54,
375
+ },
376
+ ]}
377
+ >
378
+ <Text style={[styles.heroDigitText, { color: theme.textColor, fontSize: 34 }]}>
379
+ {padZero(seconds)}
380
+ </Text>
381
+ <Text style={[styles.heroUnitSubtext, { color: theme.secondaryTextColor }]}>
382
+ SEC
383
+ </Text>
384
+ </View>
385
+ </>
386
+ )}
387
+
388
+ {/* AM / PM Segmented Capsule (for 12h) */}
389
+ {!is24Hour && (
390
+ <View
391
+ style={[
392
+ styles.heroPeriodPill,
393
+ {
394
+ backgroundColor: `${theme.textColor}0A`,
395
+ borderColor: theme.borderColor,
396
+ },
397
+ ]}
398
+ >
399
+ <TouchableOpacity
400
+ activeOpacity={0.8}
401
+ onPress={() => togglePeriod('AM')}
402
+ style={[
403
+ styles.heroPeriodBtn,
404
+ period === 'AM' && {
405
+ backgroundColor: theme.primaryColor,
406
+ shadowColor: '#000',
407
+ shadowOffset: { width: 0, height: 1 },
408
+ shadowOpacity: 0.2,
409
+ shadowRadius: 2,
410
+ elevation: 2,
411
+ },
412
+ ]}
413
+ >
414
+ <Text
415
+ style={[
416
+ styles.heroPeriodText,
417
+ {
418
+ color: period === 'AM' ? '#FFFFFF' : theme.textColor,
419
+ fontWeight: period === 'AM' ? '800' : '600',
420
+ },
421
+ ]}
422
+ >
423
+ {locale.am || 'AM'}
424
+ </Text>
425
+ </TouchableOpacity>
426
+
427
+ <TouchableOpacity
428
+ activeOpacity={0.8}
429
+ onPress={() => togglePeriod('PM')}
430
+ style={[
431
+ styles.heroPeriodBtn,
432
+ period === 'PM' && {
433
+ backgroundColor: theme.primaryColor,
434
+ shadowColor: '#000',
435
+ shadowOffset: { width: 0, height: 1 },
436
+ shadowOpacity: 0.2,
437
+ shadowRadius: 2,
438
+ elevation: 2,
439
+ },
440
+ ]}
441
+ >
442
+ <Text
443
+ style={[
444
+ styles.heroPeriodText,
445
+ {
446
+ color: period === 'PM' ? '#FFFFFF' : theme.textColor,
447
+ fontWeight: period === 'PM' ? '800' : '600',
448
+ },
449
+ ]}
450
+ >
451
+ {locale.pm || 'PM'}
452
+ </Text>
453
+ </TouchableOpacity>
454
+ </View>
455
+ )}
456
+ </View>
457
+ </View>
458
+
459
+ {/* --- VIEW 1: WHEEL PICKER --- */}
460
+ {layout === 'wheel' && (
461
+ <View style={styles.viewContainer}>
462
+ <WheelTimePicker
463
+ hours={hours}
464
+ minutes={minutes}
465
+ seconds={seconds}
466
+ period={period}
467
+ is24Hour={is24Hour}
468
+ minuteInterval={minuteInterval}
469
+ showSeconds={showSeconds}
470
+ onTimeChange={(t) => {
471
+ applyTimeChange(t.hours, t.minutes, t.seconds, t.period);
472
+ }}
473
+ theme={theme}
474
+ locale={locale}
475
+ validationOptions={validationOptions}
476
+ />
477
+ </View>
478
+ )}
479
+
480
+ {/* --- VIEW 2: CLOCK DIAL PICKER --- */}
481
+ {layout === 'spinner' && (
482
+ <View style={styles.dialContainer}>
483
+ <ClockDial
484
+ size={220}
485
+ mode={activeUnit}
486
+ value={activeUnit === 'hours' ? hours : minutes}
487
+ is24Hour={is24Hour}
488
+ period={period}
489
+ onSelect={(selectedVal) => {
490
+ if (activeUnit === 'hours') {
491
+ applyTimeChange(selectedVal, minutes, seconds, period);
492
+ setActiveUnit('minutes'); // Smoothly advance to minutes
493
+ } else {
494
+ applyTimeChange(hours, selectedVal, seconds, period);
495
+ if (autoCloseOnSelect) {
496
+ const h24 = is24Hour ? hours : (hours === 0 ? 0 : convert12To24(hours, period));
497
+ const base = activeDate || new Date();
498
+ const finalDate = setTimeOnDate(base, h24, selectedVal, seconds);
499
+ setTimeout(() => {
500
+ onConfirm?.(finalDate);
501
+ onClose?.();
502
+ }, 250);
503
+ }
504
+ }
505
+ }}
506
+ theme={theme}
507
+ validationOptions={validationOptions}
508
+ />
509
+
510
+ </View>
511
+ )}
512
+
513
+ {/* --- VIEW 3: PRECISE STEPPERS --- */}
514
+ {layout === 'segmented' && (
515
+ <View style={styles.viewContainer}>
516
+ <View style={styles.stepperRow}>
517
+ {/* Hour Adjuster */}
518
+ <View
519
+ style={[
520
+ styles.stepperUnitCard,
521
+ { backgroundColor: theme.cardColor, borderColor: theme.borderColor },
522
+ ]}
523
+ >
524
+ <Text style={[styles.stepperCardTitle, { color: theme.secondaryTextColor }]}>
525
+ {locale.hourLabel ? locale.hourLabel.toUpperCase() : 'HOURS'}
526
+ </Text>
527
+ <View style={styles.stepperControls}>
528
+ <TouchableOpacity
529
+ activeOpacity={0.8}
530
+ onPress={() => stepHour(-1)}
531
+ style={[styles.stepperCircleBtn, { backgroundColor: `${theme.primaryColor}15` }]}
532
+ >
533
+ <Text style={[styles.stepperCircleText, { color: theme.primaryColor }]}>−</Text>
534
+ </TouchableOpacity>
535
+ <Text style={[styles.stepperValueText, { color: theme.textColor }]}>
536
+ {padZero(hours)}
537
+ </Text>
538
+ <TouchableOpacity
539
+ activeOpacity={0.8}
540
+ onPress={() => stepHour(1)}
541
+ style={[styles.stepperCircleBtn, { backgroundColor: `${theme.primaryColor}15` }]}
542
+ >
543
+ <Text style={[styles.stepperCircleText, { color: theme.primaryColor }]}>+</Text>
544
+ </TouchableOpacity>
545
+ </View>
546
+ </View>
547
+
548
+ {/* Minute Adjuster */}
549
+ <View
550
+ style={[
551
+ styles.stepperUnitCard,
552
+ { backgroundColor: theme.cardColor, borderColor: theme.borderColor },
553
+ ]}
554
+ >
555
+ <Text style={[styles.stepperCardTitle, { color: theme.secondaryTextColor }]}>
556
+ {locale.minuteLabel ? locale.minuteLabel.toUpperCase() : 'MINUTES'}
557
+ </Text>
558
+ <View style={styles.stepperControls}>
559
+ <TouchableOpacity
560
+ activeOpacity={0.8}
561
+ onPress={() => stepMinute(-1)}
562
+ style={[styles.stepperCircleBtn, { backgroundColor: `${theme.primaryColor}15` }]}
563
+ >
564
+ <Text style={[styles.stepperCircleText, { color: theme.primaryColor }]}>−</Text>
565
+ </TouchableOpacity>
566
+ <Text style={[styles.stepperValueText, { color: theme.textColor }]}>
567
+ {padZero(minutes)}
568
+ </Text>
569
+ <TouchableOpacity
570
+ activeOpacity={0.8}
571
+ onPress={() => stepMinute(1)}
572
+ style={[styles.stepperCircleBtn, { backgroundColor: `${theme.primaryColor}15` }]}
573
+ >
574
+ <Text style={[styles.stepperCircleText, { color: theme.primaryColor }]}>+</Text>
575
+ </TouchableOpacity>
576
+ </View>
577
+ </View>
578
+ </View>
579
+ </View>
580
+ )}
581
+
582
+ {/* Quick Jump Shortcuts Strip */}
583
+
584
+
585
+ {/* Validation Message */}
586
+ <DateValidationMessage validation={validation} theme={theme} />
587
+
588
+ {/* Bottom Action Bar */}
589
+ {showActionButtons && (
590
+ <View style={styles.actionsRow}>
591
+ <View style={styles.leftActions}>
592
+ {showNowButton && (
593
+ <Button
594
+ title="Now"
595
+ onPress={handleNow}
596
+ variant="outline"
597
+ size="small"
598
+ theme={theme}
599
+ />
600
+ )}
601
+ {showClearButton && (
602
+ <Button
603
+ title={locale.clear}
604
+ onPress={handleClear}
605
+ variant="text"
606
+ size="small"
607
+ theme={theme}
608
+ />
609
+ )}
610
+ </View>
611
+
612
+ <View style={styles.rightActions}>
613
+ {onCancel && (
614
+ <Button
615
+ title={locale.cancel}
616
+ onPress={handleCancel}
617
+ variant="text"
618
+ size="small"
619
+ theme={theme}
620
+ />
621
+ )}
622
+ {onConfirm && (
623
+ <Button
624
+ title={locale.confirm}
625
+ onPress={handleConfirm}
626
+ variant="primary"
627
+ size="small"
628
+ disabled={!validation.isValid}
629
+ theme={theme}
630
+ />
631
+ )}
632
+ </View>
633
+ </View>
634
+ )}
635
+ </View>
636
+ );
637
+ };
638
+
639
+ const styles = StyleSheet.create({
640
+ container: {
641
+ padding: 12,
642
+ borderWidth: 1,
643
+ flexGrow: 1,
644
+ justifyContent: 'space-between',
645
+ },
646
+ topBar: {
647
+ flexDirection: 'row',
648
+ justifyContent: 'space-between',
649
+ alignItems: 'center',
650
+ marginBottom: 8,
651
+ },
652
+ titleBlock: {
653
+ flexDirection: 'row',
654
+ alignItems: 'center',
655
+ gap: 8,
656
+ },
657
+ mainTitle: {
658
+ fontSize: 15,
659
+ fontWeight: '800',
660
+ letterSpacing: -0.3,
661
+ },
662
+ modeBadge: {
663
+ paddingHorizontal: 7,
664
+ paddingVertical: 2,
665
+ borderRadius: 7,
666
+ borderWidth: 1,
667
+ },
668
+ modeBadgeText: {
669
+ fontSize: 9,
670
+ fontWeight: '800',
671
+ letterSpacing: 0.3,
672
+ },
673
+ layoutPillsContainer: {
674
+ flexDirection: 'row',
675
+ borderRadius: 8,
676
+ padding: 2,
677
+ borderWidth: 1,
678
+ },
679
+ layoutPill: {
680
+ paddingHorizontal: 8,
681
+ paddingVertical: 3,
682
+ borderRadius: 6,
683
+ },
684
+ layoutPillText: {
685
+ fontSize: 10,
686
+ },
687
+ heroCard: {
688
+ borderRadius: 14,
689
+ paddingVertical: 7,
690
+ paddingHorizontal: 10,
691
+ borderWidth: 1,
692
+ marginBottom: 8,
693
+ alignItems: 'center',
694
+ shadowColor: '#000',
695
+ shadowOffset: { width: 0, height: 1 },
696
+ shadowOpacity: 0.04,
697
+ shadowRadius: 3,
698
+ elevation: 1,
699
+ },
700
+ heroCenterBlock: {
701
+ flexDirection: 'row',
702
+ alignItems: 'center',
703
+ justifyContent: 'center',
704
+ },
705
+ heroDigitBox: {
706
+ paddingHorizontal: 12,
707
+ paddingVertical: 4,
708
+ borderRadius: 10,
709
+ borderWidth: 1.5,
710
+ alignItems: 'center',
711
+ minWidth: 66,
712
+ },
713
+ heroDigitText: {
714
+ fontWeight: '900',
715
+ letterSpacing: -0.8,
716
+ },
717
+ heroUnitSubtext: {
718
+ fontSize: 8,
719
+ fontWeight: '800',
720
+ marginTop: -2,
721
+ letterSpacing: 0.5,
722
+ },
723
+ heroColon: {
724
+ fontSize: 26,
725
+ fontWeight: '900',
726
+ marginHorizontal: 4,
727
+ marginTop: -6,
728
+ },
729
+ heroPeriodPill: {
730
+ marginLeft: 10,
731
+ borderRadius: 8,
732
+ borderWidth: 1,
733
+ padding: 2,
734
+ gap: 3,
735
+ },
736
+ heroPeriodBtn: {
737
+ paddingVertical: 5,
738
+ paddingHorizontal: 10,
739
+ borderRadius: 8,
740
+ alignItems: 'center',
741
+ },
742
+ heroPeriodText: {
743
+ fontSize: 11,
744
+ },
745
+ viewContainer: {
746
+ paddingVertical: 4,
747
+ flex: 1,
748
+ justifyContent: 'center',
749
+ },
750
+ dialContainer: {
751
+ alignItems: 'center',
752
+ justifyContent: 'center',
753
+ paddingVertical: 8,
754
+ flex: 1,
755
+ },
756
+ fineMinuteContainer: {
757
+ width: '100%',
758
+ marginTop: 8,
759
+ padding: 8,
760
+ borderRadius: 12,
761
+ borderWidth: 1,
762
+ },
763
+ fineMinuteHeaderRow: {
764
+ flexDirection: 'row',
765
+ justifyContent: 'space-between',
766
+ alignItems: 'center',
767
+ marginBottom: 6,
768
+ },
769
+ fineMinuteTitle: {
770
+ fontSize: 9,
771
+ fontWeight: '800',
772
+ letterSpacing: 0.5,
773
+ },
774
+ fineMinuteStepper: {
775
+ flexDirection: 'row',
776
+ alignItems: 'center',
777
+ gap: 6,
778
+ },
779
+ fineStepBtn: {
780
+ paddingHorizontal: 6,
781
+ paddingVertical: 2,
782
+ borderRadius: 6,
783
+ },
784
+ fineStepText: {
785
+ fontSize: 11,
786
+ fontWeight: '800',
787
+ },
788
+ fineMinuteDisplayBox: {
789
+ paddingHorizontal: 6,
790
+ paddingVertical: 2,
791
+ borderRadius: 6,
792
+ borderWidth: 1,
793
+ },
794
+ fineMinuteDisplay: {
795
+ fontSize: 12,
796
+ fontWeight: '800',
797
+ minWidth: 24,
798
+ textAlign: 'center',
799
+ },
800
+ minutePillsRow: {
801
+ flexDirection: 'row',
802
+ justifyContent: 'space-between',
803
+ gap: 4,
804
+ },
805
+ minutePillChip: {
806
+ flex: 1,
807
+ paddingVertical: 4,
808
+ borderRadius: 6,
809
+ borderWidth: 1,
810
+ alignItems: 'center',
811
+ justifyContent: 'center',
812
+ },
813
+ minutePillChipText: {
814
+ fontSize: 10,
815
+ },
816
+ stepperRow: {
817
+ flexDirection: 'row',
818
+ gap: 10,
819
+ marginTop: 4,
820
+ },
821
+ stepperUnitCard: {
822
+ flex: 1,
823
+ alignItems: 'center',
824
+ padding: 12,
825
+ borderRadius: 14,
826
+ borderWidth: 1,
827
+ },
828
+ stepperCardTitle: {
829
+ fontSize: 10,
830
+ fontWeight: '800',
831
+ letterSpacing: 0.5,
832
+ marginBottom: 8,
833
+ },
834
+ stepperControls: {
835
+ flexDirection: 'row',
836
+ alignItems: 'center',
837
+ gap: 10,
838
+ },
839
+ stepperCircleBtn: {
840
+ width: 38,
841
+ height: 38,
842
+ borderRadius: 19,
843
+ justifyContent: 'center',
844
+ alignItems: 'center',
845
+ },
846
+ stepperCircleText: {
847
+ fontSize: 20,
848
+ fontWeight: '800',
849
+ },
850
+ stepperValueText: {
851
+ fontSize: 24,
852
+ fontWeight: '900',
853
+ minWidth: 38,
854
+ textAlign: 'center',
855
+ },
856
+ presetsRow: {
857
+ marginTop: 10,
858
+ flexDirection: 'row',
859
+ alignItems: 'center',
860
+ },
861
+ presetsTitle: {
862
+ fontSize: 9,
863
+ fontWeight: '800',
864
+ letterSpacing: 0.5,
865
+ marginRight: 6,
866
+ },
867
+ presetsScroll: {
868
+ gap: 6,
869
+ paddingRight: 6,
870
+ },
871
+ presetPill: {
872
+ paddingVertical: 5,
873
+ paddingHorizontal: 10,
874
+ borderRadius: 10,
875
+ borderWidth: 1,
876
+ },
877
+ presetPillText: {
878
+ fontSize: 11,
879
+ },
880
+ actionsRow: {
881
+ flexDirection: 'row',
882
+ justifyContent: 'space-between',
883
+ alignItems: 'center',
884
+ marginTop: 'auto',
885
+ paddingTop: 12,
886
+ borderTopWidth: 1,
887
+ borderTopColor: 'rgba(0,0,0,0.06)',
888
+ },
889
+ leftActions: {
890
+ flexDirection: 'row',
891
+ alignItems: 'center',
892
+ gap: 8,
893
+ },
894
+ rightActions: {
895
+ flexDirection: 'row',
896
+ alignItems: 'center',
897
+ gap: 8,
898
+ },
899
+ });