@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,452 @@
1
+ import type { StyleProp, ViewStyle, TextStyle } from 'react-native';
2
+
3
+ export type DatePickerMode =
4
+ | 'calendar'
5
+ | 'wheel'
6
+ | 'range'
7
+ | 'input'
8
+ | 'time'
9
+ | 'datetime';
10
+
11
+ export type StandardDateFormat =
12
+ | 'DD/MM/YYYY'
13
+ | 'MM/DD/YYYY'
14
+ | 'YYYY/DD/MM'
15
+ | 'YYYY/MM/DD';
16
+
17
+ export type DateFormat =
18
+ | StandardDateFormat
19
+ | 'DD MMMM YYYY'
20
+ | 'YYYY-MM-DD'
21
+ | 'DD-MM-YYYY'
22
+ | 'HH:mm'
23
+ | 'HH:mm:ss'
24
+ | 'hh:mm A'
25
+ | 'hh:mm:ss A'
26
+ | 'DD/MM/YYYY HH:mm'
27
+ | 'DD/MM/YYYY hh:mm A'
28
+ | 'MM/DD/YYYY HH:mm'
29
+ | 'MM/DD/YYYY hh:mm A'
30
+ | 'YYYY-MM-DD HH:mm'
31
+ | (string & {});
32
+
33
+ export type SupportedLocale = 'en' | 'hi' | 'gu';
34
+
35
+ export type TimePeriod = 'AM' | 'PM';
36
+
37
+ export type TimeMode = '12h' | '24h';
38
+
39
+ export type TimePickerLayout = 'wheel' | 'spinner' | 'input' | 'segmented';
40
+
41
+ export interface TimeObject {
42
+ hours: number;
43
+ minutes: number;
44
+ seconds?: number;
45
+ period?: TimePeriod;
46
+ is24Hour?: boolean;
47
+ }
48
+
49
+ export interface DateRange {
50
+ startDate: Date | null;
51
+ endDate: Date | null;
52
+ }
53
+
54
+ export interface CalendarDayCell {
55
+ date: Date;
56
+ dayNumber: number;
57
+ isCurrentMonth: boolean;
58
+ isToday: boolean;
59
+ isSelected: boolean;
60
+ isRangeStart: boolean;
61
+ isRangeEnd: boolean;
62
+ isInRange: boolean;
63
+ isDisabled: boolean;
64
+ }
65
+
66
+ export type DisabledDateCheck = (date: Date) => boolean;
67
+
68
+ export interface DatePickerTheme {
69
+ backgroundColor: string;
70
+ surfaceColor: string;
71
+ cardColor: string;
72
+ primaryColor: string;
73
+ primaryTextColor: string;
74
+ textColor: string;
75
+ secondaryTextColor: string;
76
+ disabledTextColor: string;
77
+ borderColor: string;
78
+ selectedDayBackgroundColor: string;
79
+ selectedDayTextColor: string;
80
+ todayBorderColor: string;
81
+ todayTextColor: string;
82
+ rangeBetweenBackgroundColor: string;
83
+ rangeBetweenTextColor: string;
84
+ errorColor: string;
85
+ errorBackgroundColor: string;
86
+ borderRadius: number;
87
+ fontSize: {
88
+ small: number;
89
+ medium: number;
90
+ large: number;
91
+ title: number;
92
+ };
93
+ }
94
+
95
+ export interface DatePickerLocaleErrors {
96
+ invalidDate: string;
97
+ outOfRange: string;
98
+ minDate: string;
99
+ maxDate: string;
100
+ disabledDate: string;
101
+ disabledWeekday: string;
102
+ startDateAfterEndDate: string;
103
+ maxRangeExceeded: string;
104
+ invalidTime: string;
105
+ minTime: string;
106
+ maxTime: string;
107
+ }
108
+
109
+ export interface DatePickerLocale {
110
+ code: string;
111
+ months: string[];
112
+ monthsShort: string[];
113
+ weekdays: string[];
114
+ weekdaysShort: string[];
115
+ weekdaysMin: string[];
116
+ today: string;
117
+ clear: string;
118
+ cancel: string;
119
+ confirm: string;
120
+ apply: string;
121
+ selectDate: string;
122
+ startDate: string;
123
+ endDate: string;
124
+ placeholder: string;
125
+ dayLabel: string;
126
+ monthLabel: string;
127
+ yearLabel: string;
128
+ switchManual: string;
129
+ switchCalendar: string;
130
+ am: string;
131
+ pm: string;
132
+ hourLabel: string;
133
+ minuteLabel: string;
134
+ secondLabel: string;
135
+ selectTime: string;
136
+ timeLabel: string;
137
+ errors: DatePickerLocaleErrors;
138
+ }
139
+
140
+ export type ValidationErrorCode =
141
+ | 'INVALID_FORMAT'
142
+ | 'INVALID_DAY'
143
+ | 'INVALID_MONTH'
144
+ | 'INVALID_YEAR'
145
+ | 'LEAP_YEAR'
146
+ | 'MIN_DATE'
147
+ | 'MAX_DATE'
148
+ | 'DISABLED_DATE'
149
+ | 'DISABLED_WEEKDAY'
150
+ | 'START_AFTER_END'
151
+ | 'RANGE_EXCEEDED'
152
+ | 'INVALID_TIME'
153
+ | 'INVALID_HOUR'
154
+ | 'INVALID_MINUTE'
155
+ | 'INVALID_SECOND'
156
+ | 'MIN_TIME'
157
+ | 'MAX_TIME';
158
+
159
+ export interface ValidationResult {
160
+ isValid: boolean;
161
+ error?: string;
162
+ errorCode?: ValidationErrorCode;
163
+ }
164
+
165
+ export interface BaseDatePickerProps {
166
+ /**
167
+ * Picker mode: calendar, wheel, range, input, time, or datetime
168
+ * @default 'calendar'
169
+ */
170
+ mode?: DatePickerMode;
171
+
172
+ /**
173
+ * Theme name ('light' | 'dark') or a custom theme object
174
+ * @default 'light'
175
+ */
176
+ theme?: 'light' | 'dark' | Partial<DatePickerTheme>;
177
+
178
+ /**
179
+ * Localization language code ('en' | 'hi' | 'gu') or custom locale definition
180
+ * @default 'en'
181
+ */
182
+ locale?: SupportedLocale | DatePickerLocale;
183
+
184
+ /**
185
+ * Primary accent color override
186
+ */
187
+ accentColor?: string;
188
+
189
+ /**
190
+ * General text color override
191
+ */
192
+ textColor?: string;
193
+
194
+ /**
195
+ * Background color override
196
+ */
197
+ backgroundColor?: string;
198
+
199
+ /**
200
+ * Card / modal container background color override
201
+ */
202
+ cardColor?: string;
203
+
204
+ /**
205
+ * Dedicated modal container background color override
206
+ */
207
+ modalBackgroundColor?: string;
208
+
209
+ /**
210
+ * Custom style for the inner modal card container
211
+ */
212
+ modalContentStyle?: StyleProp<ViewStyle>;
213
+
214
+ /**
215
+ * Border radius override
216
+ */
217
+ borderRadius?: number;
218
+
219
+ /**
220
+ * Minimum allowable date
221
+ */
222
+ minimumDate?: Date;
223
+
224
+ /**
225
+ * Maximum allowable date
226
+ */
227
+ maximumDate?: Date;
228
+
229
+ /**
230
+ * Specific dates to disable or a predicate function
231
+ */
232
+ disabledDates?: (Date | string)[] | DisabledDateCheck;
233
+
234
+ /**
235
+ * Days of the week to disable: 0 (Sunday) to 6 (Saturday)
236
+ */
237
+ disabledWeekdays?: number[];
238
+
239
+ /**
240
+ * First day of the week: 0 (Sunday), 1 (Monday), etc.
241
+ * @default 0
242
+ */
243
+ firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
244
+
245
+ /**
246
+ * Display date format
247
+ * @default 'DD/MM/YYYY'
248
+ */
249
+ format?: DateFormat;
250
+
251
+ /**
252
+ * Whether to display an interactive format selection bar above the picker.
253
+ * Allows users to dynamically switch between formats (DD/MM/YYYY, MM/DD/YYYY, YYYY/DD/MM, YYYY/MM/DD).
254
+ * @default false
255
+ */
256
+ showFormatSelector?: boolean;
257
+
258
+ /**
259
+ * List of supported date formats available in the format selector bar.
260
+ * @default ['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/DD/MM', 'YYYY/MM/DD']
261
+ */
262
+ supportedFormats?: DateFormat[];
263
+
264
+ /**
265
+ * Callback fired when user switches the date format via the format selector bar.
266
+ */
267
+ onFormatChange?: (format: DateFormat) => void;
268
+
269
+ /**
270
+ * 24-hour mode (true) vs 12-hour AM/PM mode (false).
271
+ * If omitted, will be inferred from format string (HH/H -> true, hh/h/A/a -> false) or default to false (12-hour).
272
+ */
273
+ is24Hour?: boolean;
274
+
275
+ /**
276
+ * Step interval for minute selection (e.g. 1, 5, 10, 15, 30).
277
+ * @default 1
278
+ */
279
+ minuteInterval?: number;
280
+
281
+ /**
282
+ * Minimum allowed time. Can be a string ("HH:mm", "hh:mm A") or a Date.
283
+ */
284
+ minimumTime?: string | Date;
285
+
286
+ /**
287
+ * Maximum allowed time. Can be a string ("HH:mm", "hh:mm A") or a Date.
288
+ */
289
+ maximumTime?: string | Date;
290
+
291
+ /**
292
+ * Whether to display seconds in time mode.
293
+ * @default false
294
+ */
295
+ showSeconds?: boolean;
296
+
297
+ /**
298
+ * UI presentation for Time Picker: 'wheel', 'segmented', or 'spinner'.
299
+ * @default 'segmented'
300
+ */
301
+ timePickerLayout?: TimePickerLayout;
302
+
303
+ /**
304
+ * Whether to present the picker inside a modal dialog popup.
305
+ * @default false
306
+ */
307
+ modal?: boolean;
308
+
309
+ /**
310
+ * When modal is true, controls whether the modal dialog is currently open / visible.
311
+ * @default false
312
+ */
313
+ open?: boolean;
314
+
315
+ /**
316
+ * Whether to automatically close the modal when a date or time is selected.
317
+ * If false, selection must be finalized via the Confirm action button.
318
+ * @default false
319
+ */
320
+ autoCloseOnSelect?: boolean;
321
+
322
+ /**
323
+ * Callback fired when modal is closed (either by selecting date/time, tapping backdrop, or cancel)
324
+ */
325
+ onClose?: () => void;
326
+
327
+ /**
328
+ * Enable manual typing mode
329
+ * @default false
330
+ */
331
+ allowManualEntry?: boolean;
332
+
333
+ /**
334
+ * Whether to start directly in manual typing mode when allowManualEntry is enabled
335
+ * @default false
336
+ */
337
+ defaultManualMode?: boolean;
338
+
339
+ /**
340
+ * Manual input layout type ('single' formatted box vs 'split' day/month/year boxes)
341
+ * @default 'single'
342
+ */
343
+ manualEntryType?: 'single' | 'split';
344
+
345
+ /**
346
+ * Show bottom action buttons (Today/Now, Clear, Cancel, Confirm)
347
+ * @default true
348
+ */
349
+ showActionButtons?: boolean;
350
+
351
+ /**
352
+ * Show 'Today' or 'Now' shortcut button
353
+ * @default true
354
+ */
355
+ showTodayButton?: boolean;
356
+
357
+ /**
358
+ * Show 'Clear' button
359
+ * @default true
360
+ */
361
+ showClearButton?: boolean;
362
+
363
+ /**
364
+ * Callback when action cancel is tapped
365
+ */
366
+ onCancel?: () => void;
367
+
368
+ /**
369
+ * Callback when clear is tapped
370
+ */
371
+ onClear?: () => void;
372
+
373
+ /**
374
+ * Style for the outer container
375
+ */
376
+ style?: StyleProp<ViewStyle>;
377
+
378
+ /**
379
+ * Test ID for automation
380
+ */
381
+ testID?: string;
382
+ }
383
+
384
+ export interface SingleDatePickerProps extends BaseDatePickerProps {
385
+ mode?: 'calendar';
386
+ value?: Date | null;
387
+ onChange?: (date: Date | null) => void;
388
+ defaultValue?: Date | null;
389
+ onConfirm?: (date: Date | null) => void;
390
+ }
391
+
392
+ export interface RangeDatePickerProps extends BaseDatePickerProps {
393
+ mode: 'range';
394
+ startDate?: Date | null;
395
+ endDate?: Date | null;
396
+ onRangeChange?: (range: DateRange) => void;
397
+ defaultStartDate?: Date | null;
398
+ defaultEndDate?: Date | null;
399
+ maxRangeDays?: number;
400
+ onConfirm?: (range: DateRange | null) => void;
401
+ }
402
+
403
+ export interface InputDatePickerProps extends BaseDatePickerProps {
404
+ mode: 'input';
405
+ value?: Date | null;
406
+ onChange?: (date: Date | null) => void;
407
+ defaultValue?: Date | null;
408
+ placeholder?: string;
409
+ label?: string;
410
+ editable?: boolean;
411
+ popupTitle?: string;
412
+ inputStyle?: StyleProp<TextStyle>;
413
+ inputContainerStyle?: StyleProp<ViewStyle>;
414
+ onConfirm?: (date: Date | null) => void;
415
+ }
416
+
417
+ export interface WheelDatePickerProps extends BaseDatePickerProps {
418
+ mode: 'wheel';
419
+ value?: Date | null;
420
+ onChange?: (date: Date | null) => void;
421
+ defaultValue?: Date | null;
422
+ minYear?: number;
423
+ maxYear?: number;
424
+ itemHeight?: number;
425
+ visibleItems?: number;
426
+ onConfirm?: (date: Date | null) => void;
427
+ }
428
+
429
+ export interface TimePickerComponentProps extends BaseDatePickerProps {
430
+ mode: 'time';
431
+ value?: Date | null;
432
+ onChange?: (date: Date | null) => void;
433
+ defaultValue?: Date | null;
434
+ onConfirm?: (date: Date | null) => void;
435
+ }
436
+
437
+ export interface DateTimePickerProps extends BaseDatePickerProps {
438
+ mode: 'datetime';
439
+ value?: Date | null;
440
+ onChange?: (date: Date | null) => void;
441
+ defaultValue?: Date | null;
442
+ initialTab?: 'date' | 'time';
443
+ onConfirm?: (date: Date | null) => void;
444
+ }
445
+
446
+ export type DatePickerProps =
447
+ | SingleDatePickerProps
448
+ | RangeDatePickerProps
449
+ | InputDatePickerProps
450
+ | WheelDatePickerProps
451
+ | TimePickerComponentProps
452
+ | DateTimePickerProps;
@@ -0,0 +1,152 @@
1
+ import type {
2
+ DatePickerLocale,
3
+ DisabledDateCheck,
4
+ DateRange,
5
+ CalendarDayCell,
6
+ } from '../types';
7
+ import {
8
+ getDaysInMonth,
9
+ createLocalDate,
10
+ isSameDay,
11
+ isToday,
12
+ isDateInRange,
13
+ stripTime,
14
+ } from './dateUtils';
15
+ import { isDateDisabled, isWeekdayDisabled } from './dateValidation';
16
+
17
+ export interface CalendarGridOptions {
18
+ year: number;
19
+ month: number; // 0-indexed
20
+ firstDayOfWeek?: number; // 0 = Sunday, 1 = Monday
21
+ selectedDate?: Date | null;
22
+ range?: DateRange;
23
+ minimumDate?: Date;
24
+ maximumDate?: Date;
25
+ disabledDates?: (Date | string)[] | DisabledDateCheck;
26
+ disabledWeekdays?: number[];
27
+ }
28
+
29
+ /**
30
+ * Builds an array of 35 or 42 day cells representing the monthly calendar grid,
31
+ * with leading days from the previous month and trailing days from the next month.
32
+ */
33
+ export const buildCalendarGrid = (options: CalendarGridOptions): CalendarDayCell[] => {
34
+ const {
35
+ year,
36
+ month,
37
+ firstDayOfWeek = 0,
38
+ selectedDate,
39
+ range,
40
+ minimumDate,
41
+ maximumDate,
42
+ disabledDates,
43
+ disabledWeekdays,
44
+ } = options;
45
+
46
+ const daysInCurrentMonth = getDaysInMonth(year, month);
47
+ const firstDayInstance = createLocalDate(year, month, 1);
48
+ const firstDayWeekday = firstDayInstance.getDay(); // 0 = Sun ... 6 = Sat
49
+
50
+ // Calculate leading offset
51
+ const leadingOffset = (firstDayWeekday - firstDayOfWeek + 7) % 7;
52
+
53
+ // Previous month info
54
+ const prevMonthIndex = month === 0 ? 11 : month - 1;
55
+ const prevYear = month === 0 ? year - 1 : year;
56
+ const daysInPrevMonth = getDaysInMonth(prevYear, prevMonthIndex);
57
+
58
+ const cells: CalendarDayCell[] = [];
59
+
60
+ // Helper to evaluate disability
61
+ const checkIsDisabled = (date: Date): boolean => {
62
+ if (minimumDate && stripTime(date).getTime() < stripTime(minimumDate).getTime()) {
63
+ return true;
64
+ }
65
+ if (maximumDate && stripTime(date).getTime() > stripTime(maximumDate).getTime()) {
66
+ return true;
67
+ }
68
+ if (isDateDisabled(date, disabledDates)) {
69
+ return true;
70
+ }
71
+ if (isWeekdayDisabled(date, disabledWeekdays)) {
72
+ return true;
73
+ }
74
+ return false;
75
+ };
76
+
77
+ // 1. Leading days from previous month
78
+ for (let i = leadingOffset - 1; i >= 0; i--) {
79
+ const dayNum = daysInPrevMonth - i;
80
+ const date = createLocalDate(prevYear, prevMonthIndex, dayNum);
81
+ cells.push({
82
+ date,
83
+ dayNumber: dayNum,
84
+ isCurrentMonth: false,
85
+ isToday: isToday(date),
86
+ isSelected: isSameDay(date, selectedDate),
87
+ isRangeStart: isSameDay(date, range?.startDate),
88
+ isRangeEnd: isSameDay(date, range?.endDate),
89
+ isInRange: isDateInRange(date, range?.startDate ?? null, range?.endDate ?? null),
90
+ isDisabled: checkIsDisabled(date),
91
+ });
92
+ }
93
+
94
+ // 2. Days of current month
95
+ for (let day = 1; day <= daysInCurrentMonth; day++) {
96
+ const date = createLocalDate(year, month, day);
97
+ cells.push({
98
+ date,
99
+ dayNumber: day,
100
+ isCurrentMonth: true,
101
+ isToday: isToday(date),
102
+ isSelected: isSameDay(date, selectedDate),
103
+ isRangeStart: isSameDay(date, range?.startDate),
104
+ isRangeEnd: isSameDay(date, range?.endDate),
105
+ isInRange: isDateInRange(date, range?.startDate ?? null, range?.endDate ?? null),
106
+ isDisabled: checkIsDisabled(date),
107
+ });
108
+ }
109
+
110
+ // 3. Trailing days from next month to complete 7-day grid rows (35 or 42 total)
111
+ const totalCellsNeeded = cells.length > 35 ? 42 : 35;
112
+ const trailingDaysNeeded = totalCellsNeeded - cells.length;
113
+ const nextMonthIndex = month === 11 ? 0 : month + 1;
114
+ const nextYear = month === 11 ? year + 1 : year;
115
+
116
+ for (let day = 1; day <= trailingDaysNeeded; day++) {
117
+ const date = createLocalDate(nextYear, nextMonthIndex, day);
118
+ cells.push({
119
+ date,
120
+ dayNumber: day,
121
+ isCurrentMonth: false,
122
+ isToday: isToday(date),
123
+ isSelected: isSameDay(date, selectedDate),
124
+ isRangeStart: isSameDay(date, range?.startDate),
125
+ isRangeEnd: isSameDay(date, range?.endDate),
126
+ isInRange: isDateInRange(date, range?.startDate ?? null, range?.endDate ?? null),
127
+ isDisabled: checkIsDisabled(date),
128
+ });
129
+ }
130
+
131
+ return cells;
132
+ };
133
+
134
+ /**
135
+ * Returns ordered weekday headers based on firstDayOfWeek.
136
+ */
137
+ export const getOrderedWeekdays = (
138
+ firstDayOfWeek = 0,
139
+ locale: DatePickerLocale
140
+ ): { index: number; name: string; short: string; min: string }[] => {
141
+ const result = [];
142
+ for (let i = 0; i < 7; i++) {
143
+ const dayIndex = (firstDayOfWeek + i) % 7;
144
+ result.push({
145
+ index: dayIndex,
146
+ name: locale.weekdays[dayIndex],
147
+ short: locale.weekdaysShort[dayIndex],
148
+ min: locale.weekdaysMin[dayIndex],
149
+ });
150
+ }
151
+ return result;
152
+ };