@izonnet-web-solution/react-native-date-time-picker-kit 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/DateTimePickerKit.podspec +22 -0
  2. package/LICENSE +20 -0
  3. package/README.md +652 -2
  4. package/android/build.gradle +36 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/datetimepickerkit/DatePickerHelper.kt +185 -0
  7. package/android/src/main/java/com/datetimepickerkit/DateTimePickerHelper.kt +214 -0
  8. package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitModule.kt +258 -0
  9. package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitPackage.kt +30 -0
  10. package/android/src/main/java/com/datetimepickerkit/TimePickerHelper.kt +208 -0
  11. package/ios/DateTimePickerKit.h +11 -0
  12. package/ios/DateTimePickerKit.mm +84 -0
  13. package/ios/DateTimePickerModule.swift +474 -0
  14. package/lib/module/NativeDateTimePickerKit.js +5 -0
  15. package/lib/module/NativeDateTimePickerKit.js.map +1 -0
  16. package/lib/module/components/CalendarPicker.js +419 -0
  17. package/lib/module/components/CalendarPicker.js.map +1 -0
  18. package/lib/module/components/ClockPicker.js +273 -0
  19. package/lib/module/components/ClockPicker.js.map +1 -0
  20. package/lib/module/components/DatePicker.js +181 -0
  21. package/lib/module/components/DatePicker.js.map +1 -0
  22. package/lib/module/components/DateRangePicker.js +158 -0
  23. package/lib/module/components/DateRangePicker.js.map +1 -0
  24. package/lib/module/components/DateTimePicker.js +674 -0
  25. package/lib/module/components/DateTimePicker.js.map +1 -0
  26. package/lib/module/components/MonthPicker.js +145 -0
  27. package/lib/module/components/MonthPicker.js.map +1 -0
  28. package/lib/module/components/TimePicker.js +142 -0
  29. package/lib/module/components/TimePicker.js.map +1 -0
  30. package/lib/module/components/TimeSlotPicker.js +118 -0
  31. package/lib/module/components/TimeSlotPicker.js.map +1 -0
  32. package/lib/module/components/WheelPicker.js +159 -0
  33. package/lib/module/components/WheelPicker.js.map +1 -0
  34. package/lib/module/components/YearPicker.js +151 -0
  35. package/lib/module/components/YearPicker.js.map +1 -0
  36. package/lib/module/components/common/ModalWrapper.js +136 -0
  37. package/lib/module/components/common/ModalWrapper.js.map +1 -0
  38. package/lib/module/components/common/PickerHeader.js +82 -0
  39. package/lib/module/components/common/PickerHeader.js.map +1 -0
  40. package/lib/module/components/common/PresetsBar.js +66 -0
  41. package/lib/module/components/common/PresetsBar.js.map +1 -0
  42. package/lib/module/errors/DateTimePickerError.js +12 -0
  43. package/lib/module/errors/DateTimePickerError.js.map +1 -0
  44. package/lib/module/hooks/useDateTimePicker.js +73 -0
  45. package/lib/module/hooks/useDateTimePicker.js.map +1 -0
  46. package/lib/module/index.js +40 -0
  47. package/lib/module/index.js.map +1 -0
  48. package/lib/module/localization/index.js +6 -0
  49. package/lib/module/localization/index.js.map +1 -0
  50. package/lib/module/localization/locales.js +186 -0
  51. package/lib/module/localization/locales.js.map +1 -0
  52. package/lib/module/localization/types.js +2 -0
  53. package/lib/module/localization/types.js.map +1 -0
  54. package/lib/module/localization/useLocale.js +176 -0
  55. package/lib/module/localization/useLocale.js.map +1 -0
  56. package/lib/module/native/NativeDateTimePicker.js +110 -0
  57. package/lib/module/native/NativeDateTimePicker.js.map +1 -0
  58. package/lib/module/package.json +1 -0
  59. package/lib/module/presets/datePresets.js +75 -0
  60. package/lib/module/presets/datePresets.js.map +1 -0
  61. package/lib/module/presets/index.js +4 -0
  62. package/lib/module/presets/index.js.map +1 -0
  63. package/lib/module/slots/index.js +4 -0
  64. package/lib/module/slots/index.js.map +1 -0
  65. package/lib/module/slots/timeSlots.js +59 -0
  66. package/lib/module/slots/timeSlots.js.map +1 -0
  67. package/lib/module/theme/defaultTheme.js +91 -0
  68. package/lib/module/theme/defaultTheme.js.map +1 -0
  69. package/lib/module/theme/index.js +6 -0
  70. package/lib/module/theme/index.js.map +1 -0
  71. package/lib/module/theme/types.js +2 -0
  72. package/lib/module/theme/types.js.map +1 -0
  73. package/lib/module/theme/useTheme.js +81 -0
  74. package/lib/module/theme/useTheme.js.map +1 -0
  75. package/lib/module/types/events.js +4 -0
  76. package/lib/module/types/events.js.map +1 -0
  77. package/lib/module/types/index.js +7 -0
  78. package/lib/module/types/index.js.map +1 -0
  79. package/lib/module/types/native.js +2 -0
  80. package/lib/module/types/native.js.map +1 -0
  81. package/lib/module/types/presentation.js +2 -0
  82. package/lib/module/types/presentation.js.map +1 -0
  83. package/lib/module/types/props.js +4 -0
  84. package/lib/module/types/props.js.map +1 -0
  85. package/lib/module/utils/constants.js +14 -0
  86. package/lib/module/utils/constants.js.map +1 -0
  87. package/lib/module/utils/dateConversion.js +224 -0
  88. package/lib/module/utils/dateConversion.js.map +1 -0
  89. package/lib/module/utils/dateFormatting.js +102 -0
  90. package/lib/module/utils/dateFormatting.js.map +1 -0
  91. package/lib/module/utils/dateValidation.js +161 -0
  92. package/lib/module/utils/dateValidation.js.map +1 -0
  93. package/lib/module/utils/index.js +7 -0
  94. package/lib/module/utils/index.js.map +1 -0
  95. package/lib/typescript/package.json +1 -0
  96. package/lib/typescript/src/NativeDateTimePickerKit.d.ts +17 -0
  97. package/lib/typescript/src/NativeDateTimePickerKit.d.ts.map +1 -0
  98. package/lib/typescript/src/components/CalendarPicker.d.ts +51 -0
  99. package/lib/typescript/src/components/CalendarPicker.d.ts.map +1 -0
  100. package/lib/typescript/src/components/ClockPicker.d.ts +22 -0
  101. package/lib/typescript/src/components/ClockPicker.d.ts.map +1 -0
  102. package/lib/typescript/src/components/DatePicker.d.ts +44 -0
  103. package/lib/typescript/src/components/DatePicker.d.ts.map +1 -0
  104. package/lib/typescript/src/components/DateRangePicker.d.ts +56 -0
  105. package/lib/typescript/src/components/DateRangePicker.d.ts.map +1 -0
  106. package/lib/typescript/src/components/DateTimePicker.d.ts +7 -0
  107. package/lib/typescript/src/components/DateTimePicker.d.ts.map +1 -0
  108. package/lib/typescript/src/components/MonthPicker.d.ts +21 -0
  109. package/lib/typescript/src/components/MonthPicker.d.ts.map +1 -0
  110. package/lib/typescript/src/components/TimePicker.d.ts +31 -0
  111. package/lib/typescript/src/components/TimePicker.d.ts.map +1 -0
  112. package/lib/typescript/src/components/TimeSlotPicker.d.ts +18 -0
  113. package/lib/typescript/src/components/TimeSlotPicker.d.ts.map +1 -0
  114. package/lib/typescript/src/components/WheelPicker.d.ts +17 -0
  115. package/lib/typescript/src/components/WheelPicker.d.ts.map +1 -0
  116. package/lib/typescript/src/components/YearPicker.d.ts +14 -0
  117. package/lib/typescript/src/components/YearPicker.d.ts.map +1 -0
  118. package/lib/typescript/src/components/common/ModalWrapper.d.ts +11 -0
  119. package/lib/typescript/src/components/common/ModalWrapper.d.ts.map +1 -0
  120. package/lib/typescript/src/components/common/PickerHeader.d.ts +13 -0
  121. package/lib/typescript/src/components/common/PickerHeader.d.ts.map +1 -0
  122. package/lib/typescript/src/components/common/PresetsBar.d.ts +12 -0
  123. package/lib/typescript/src/components/common/PresetsBar.d.ts.map +1 -0
  124. package/lib/typescript/src/errors/DateTimePickerError.d.ts +7 -0
  125. package/lib/typescript/src/errors/DateTimePickerError.d.ts.map +1 -0
  126. package/lib/typescript/src/hooks/useDateTimePicker.d.ts +17 -0
  127. package/lib/typescript/src/hooks/useDateTimePicker.d.ts.map +1 -0
  128. package/lib/typescript/src/index.d.ts +23 -0
  129. package/lib/typescript/src/index.d.ts.map +1 -0
  130. package/lib/typescript/src/localization/index.d.ts +4 -0
  131. package/lib/typescript/src/localization/index.d.ts.map +1 -0
  132. package/lib/typescript/src/localization/locales.d.ts +12 -0
  133. package/lib/typescript/src/localization/locales.d.ts.map +1 -0
  134. package/lib/typescript/src/localization/types.d.ts +23 -0
  135. package/lib/typescript/src/localization/types.d.ts.map +1 -0
  136. package/lib/typescript/src/localization/useLocale.d.ts +31 -0
  137. package/lib/typescript/src/localization/useLocale.d.ts.map +1 -0
  138. package/lib/typescript/src/native/NativeDateTimePicker.d.ts +14 -0
  139. package/lib/typescript/src/native/NativeDateTimePicker.d.ts.map +1 -0
  140. package/lib/typescript/src/presets/datePresets.d.ts +8 -0
  141. package/lib/typescript/src/presets/datePresets.d.ts.map +1 -0
  142. package/lib/typescript/src/presets/index.d.ts +2 -0
  143. package/lib/typescript/src/presets/index.d.ts.map +1 -0
  144. package/lib/typescript/src/slots/index.d.ts +2 -0
  145. package/lib/typescript/src/slots/index.d.ts.map +1 -0
  146. package/lib/typescript/src/slots/timeSlots.d.ts +18 -0
  147. package/lib/typescript/src/slots/timeSlots.d.ts.map +1 -0
  148. package/lib/typescript/src/theme/defaultTheme.d.ts +9 -0
  149. package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
  150. package/lib/typescript/src/theme/index.d.ts +4 -0
  151. package/lib/typescript/src/theme/index.d.ts.map +1 -0
  152. package/lib/typescript/src/theme/types.d.ts +76 -0
  153. package/lib/typescript/src/theme/types.d.ts.map +1 -0
  154. package/lib/typescript/src/theme/useTheme.d.ts +4 -0
  155. package/lib/typescript/src/theme/useTheme.d.ts.map +1 -0
  156. package/lib/typescript/src/types/events.d.ts +8 -0
  157. package/lib/typescript/src/types/events.d.ts.map +1 -0
  158. package/lib/typescript/src/types/index.d.ts +5 -0
  159. package/lib/typescript/src/types/index.d.ts.map +1 -0
  160. package/lib/typescript/src/types/native.d.ts +26 -0
  161. package/lib/typescript/src/types/native.d.ts.map +1 -0
  162. package/lib/typescript/src/types/presentation.d.ts +26 -0
  163. package/lib/typescript/src/types/presentation.d.ts.map +1 -0
  164. package/lib/typescript/src/types/props.d.ts +221 -0
  165. package/lib/typescript/src/types/props.d.ts.map +1 -0
  166. package/lib/typescript/src/utils/constants.d.ts +12 -0
  167. package/lib/typescript/src/utils/constants.d.ts.map +1 -0
  168. package/lib/typescript/src/utils/dateConversion.d.ts +46 -0
  169. package/lib/typescript/src/utils/dateConversion.d.ts.map +1 -0
  170. package/lib/typescript/src/utils/dateFormatting.d.ts +8 -0
  171. package/lib/typescript/src/utils/dateFormatting.d.ts.map +1 -0
  172. package/lib/typescript/src/utils/dateValidation.d.ts +46 -0
  173. package/lib/typescript/src/utils/dateValidation.d.ts.map +1 -0
  174. package/lib/typescript/src/utils/index.d.ts +5 -0
  175. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  176. package/package.json +191 -4
  177. package/src/NativeDateTimePickerKit.ts +19 -0
  178. package/src/components/CalendarPicker.tsx +623 -0
  179. package/src/components/ClockPicker.tsx +403 -0
  180. package/src/components/DatePicker.tsx +276 -0
  181. package/src/components/DateRangePicker.tsx +251 -0
  182. package/src/components/DateTimePicker.tsx +1028 -0
  183. package/src/components/MonthPicker.tsx +216 -0
  184. package/src/components/TimePicker.tsx +203 -0
  185. package/src/components/TimeSlotPicker.tsx +163 -0
  186. package/src/components/WheelPicker.tsx +229 -0
  187. package/src/components/YearPicker.tsx +228 -0
  188. package/src/components/common/ModalWrapper.tsx +192 -0
  189. package/src/components/common/PickerHeader.tsx +121 -0
  190. package/src/components/common/PresetsBar.tsx +104 -0
  191. package/src/errors/DateTimePickerError.ts +29 -0
  192. package/src/hooks/useDateTimePicker.ts +100 -0
  193. package/src/index.tsx +92 -0
  194. package/src/localization/index.ts +3 -0
  195. package/src/localization/locales.ts +499 -0
  196. package/src/localization/types.ts +21 -0
  197. package/src/localization/useLocale.ts +197 -0
  198. package/src/native/NativeDateTimePicker.ts +154 -0
  199. package/src/presets/datePresets.ts +97 -0
  200. package/src/presets/index.ts +1 -0
  201. package/src/slots/index.ts +1 -0
  202. package/src/slots/timeSlots.ts +89 -0
  203. package/src/theme/defaultTheme.ts +102 -0
  204. package/src/theme/index.ts +3 -0
  205. package/src/theme/types.ts +82 -0
  206. package/src/theme/useTheme.ts +98 -0
  207. package/src/types/events.ts +8 -0
  208. package/src/types/index.ts +4 -0
  209. package/src/types/native.ts +28 -0
  210. package/src/types/presentation.ts +28 -0
  211. package/src/types/props.ts +291 -0
  212. package/src/utils/constants.ts +15 -0
  213. package/src/utils/dateConversion.ts +273 -0
  214. package/src/utils/dateFormatting.ts +166 -0
  215. package/src/utils/dateValidation.ts +178 -0
  216. package/src/utils/index.ts +4 -0
@@ -0,0 +1,154 @@
1
+ import NativeDateTimePickerKit from '../NativeDateTimePickerKit';
2
+ import {
3
+ DateTimePickerError,
4
+ type DateTimePickerErrorCode,
5
+ } from '../errors/DateTimePickerError';
6
+ import type { NativePickerOptions, NativePickerResult } from '../types/native';
7
+
8
+ function getNativeModule() {
9
+ if (!NativeDateTimePickerKit) {
10
+ throw new DateTimePickerError(
11
+ 'NATIVE_MODULE_NOT_FOUND',
12
+ 'The native module DateTimePickerKit was not found. Please ensure the library is linked correctly.'
13
+ );
14
+ }
15
+ return NativeDateTimePickerKit;
16
+ }
17
+
18
+ function normalizeError(error: unknown): DateTimePickerError {
19
+ if (error instanceof DateTimePickerError) {
20
+ return error;
21
+ }
22
+
23
+ const err = error as { code?: string; message?: string } | null;
24
+ const rawCode = err?.code || 'UNKNOWN_ERROR';
25
+ const message = err?.message || 'An unknown error occurred in DateTimePicker';
26
+
27
+ const validCodes: DateTimePickerErrorCode[] = [
28
+ 'NATIVE_MODULE_NOT_FOUND',
29
+ 'PICKER_ALREADY_OPEN',
30
+ 'PICKER_NOT_OPEN',
31
+ 'INVALID_DATE',
32
+ 'INVALID_MODE',
33
+ 'INVALID_MINUTE_INTERVAL',
34
+ 'DATE_OUT_OF_RANGE',
35
+ 'UNSUPPORTED_FEATURE',
36
+ 'ACTIVITY_UNAVAILABLE',
37
+ 'PRESENTATION_FAILED',
38
+ 'UNKNOWN_ERROR',
39
+ ];
40
+
41
+ const code: DateTimePickerErrorCode = validCodes.includes(
42
+ rawCode as DateTimePickerErrorCode
43
+ )
44
+ ? (rawCode as DateTimePickerErrorCode)
45
+ : 'UNKNOWN_ERROR';
46
+
47
+ return new DateTimePickerError(code, message, error);
48
+ }
49
+
50
+ export const NativeDateTimePicker = {
51
+ async openDatePicker(
52
+ options: NativePickerOptions
53
+ ): Promise<NativePickerResult> {
54
+ try {
55
+ const module = getNativeModule();
56
+ const res = await module.openDatePicker(options as Object);
57
+ return res as unknown as NativePickerResult;
58
+ } catch (err) {
59
+ throw normalizeError(err);
60
+ }
61
+ },
62
+
63
+ async openTimePicker(
64
+ options: NativePickerOptions
65
+ ): Promise<NativePickerResult> {
66
+ try {
67
+ const module = getNativeModule();
68
+ const res = await module.openTimePicker(options as Object);
69
+ return res as unknown as NativePickerResult;
70
+ } catch (err) {
71
+ throw normalizeError(err);
72
+ }
73
+ },
74
+
75
+ async openDateTimePicker(
76
+ options: NativePickerOptions
77
+ ): Promise<NativePickerResult> {
78
+ try {
79
+ const module = getNativeModule();
80
+ const res = await module.openDateTimePicker(options as Object);
81
+ return res as unknown as NativePickerResult;
82
+ } catch (err) {
83
+ throw normalizeError(err);
84
+ }
85
+ },
86
+
87
+ async openCountdownPicker(
88
+ options: NativePickerOptions
89
+ ): Promise<NativePickerResult> {
90
+ try {
91
+ const module = getNativeModule();
92
+ const res = await module.openCountdownPicker(options as Object);
93
+ return res as unknown as NativePickerResult;
94
+ } catch (err) {
95
+ throw normalizeError(err);
96
+ }
97
+ },
98
+
99
+ async closePicker(): Promise<boolean> {
100
+ try {
101
+ const module = getNativeModule();
102
+ return await module.closePicker();
103
+ } catch (err) {
104
+ throw normalizeError(err);
105
+ }
106
+ },
107
+
108
+ async confirmPicker(): Promise<NativePickerResult> {
109
+ try {
110
+ const module = getNativeModule();
111
+ const res = await module.confirmPicker();
112
+ return res as unknown as NativePickerResult;
113
+ } catch (err) {
114
+ throw normalizeError(err);
115
+ }
116
+ },
117
+
118
+ async cancelPicker(): Promise<boolean> {
119
+ try {
120
+ const module = getNativeModule();
121
+ return await module.cancelPicker();
122
+ } catch (err) {
123
+ throw normalizeError(err);
124
+ }
125
+ },
126
+
127
+ async setSelectedDate(timestamp: number): Promise<boolean> {
128
+ try {
129
+ const module = getNativeModule();
130
+ return await module.setSelectedDate(timestamp);
131
+ } catch (err) {
132
+ throw normalizeError(err);
133
+ }
134
+ },
135
+
136
+ async getSelectedDate(): Promise<NativePickerResult> {
137
+ try {
138
+ const module = getNativeModule();
139
+ const res = await module.getSelectedDate();
140
+ return res as unknown as NativePickerResult;
141
+ } catch (err) {
142
+ throw normalizeError(err);
143
+ }
144
+ },
145
+
146
+ async resetPicker(): Promise<boolean> {
147
+ try {
148
+ const module = getNativeModule();
149
+ return await module.resetPicker();
150
+ } catch (err) {
151
+ throw normalizeError(err);
152
+ }
153
+ },
154
+ };
@@ -0,0 +1,97 @@
1
+ export interface DatePreset {
2
+ id: string;
3
+ label: string;
4
+ getValue: () => [Date, Date] | Date;
5
+ }
6
+
7
+ export function getStandardRangePresets(
8
+ today: Date = new Date()
9
+ ): DatePreset[] {
10
+ const startOfDay = (d: Date) =>
11
+ new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
12
+ const endOfDay = (d: Date) =>
13
+ new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);
14
+
15
+ return [
16
+ {
17
+ id: 'today',
18
+ label: 'Today',
19
+ getValue: () => [startOfDay(today), endOfDay(today)],
20
+ },
21
+ {
22
+ id: 'yesterday',
23
+ label: 'Yesterday',
24
+ getValue: () => {
25
+ const y = new Date(today);
26
+ y.setDate(y.getDate() - 1);
27
+ return [startOfDay(y), endOfDay(y)];
28
+ },
29
+ },
30
+ {
31
+ id: 'last7days',
32
+ label: 'Last 7 Days',
33
+ getValue: () => {
34
+ const past = new Date(today);
35
+ past.setDate(past.getDate() - 6);
36
+ return [startOfDay(past), endOfDay(today)];
37
+ },
38
+ },
39
+ {
40
+ id: 'last30days',
41
+ label: 'Last 30 Days',
42
+ getValue: () => {
43
+ const past = new Date(today);
44
+ past.setDate(past.getDate() - 29);
45
+ return [startOfDay(past), endOfDay(today)];
46
+ },
47
+ },
48
+ {
49
+ id: 'thisMonth',
50
+ label: 'This Month',
51
+ getValue: () => {
52
+ const first = new Date(today.getFullYear(), today.getMonth(), 1);
53
+ const last = new Date(today.getFullYear(), today.getMonth() + 1, 0);
54
+ return [startOfDay(first), endOfDay(last)];
55
+ },
56
+ },
57
+ {
58
+ id: 'nextMonth',
59
+ label: 'Next Month',
60
+ getValue: () => {
61
+ const first = new Date(today.getFullYear(), today.getMonth() + 1, 1);
62
+ const last = new Date(today.getFullYear(), today.getMonth() + 2, 0);
63
+ return [startOfDay(first), endOfDay(last)];
64
+ },
65
+ },
66
+ ];
67
+ }
68
+
69
+ export function getStandardSinglePresets(
70
+ today: Date = new Date()
71
+ ): DatePreset[] {
72
+ return [
73
+ {
74
+ id: 'today',
75
+ label: 'Today',
76
+ getValue: () => new Date(today),
77
+ },
78
+ {
79
+ id: 'tomorrow',
80
+ label: 'Tomorrow',
81
+ getValue: () => {
82
+ const t = new Date(today);
83
+ t.setDate(t.getDate() + 1);
84
+ return t;
85
+ },
86
+ },
87
+ {
88
+ id: 'nextWeek',
89
+ label: 'In 1 Week',
90
+ getValue: () => {
91
+ const w = new Date(today);
92
+ w.setDate(w.getDate() + 7);
93
+ return w;
94
+ },
95
+ },
96
+ ];
97
+ }
@@ -0,0 +1 @@
1
+ export * from './datePresets';
@@ -0,0 +1 @@
1
+ export * from './timeSlots';
@@ -0,0 +1,89 @@
1
+ export interface TimeSlot {
2
+ id: string;
3
+ startTime: string; // "09:00"
4
+ endTime: string; // "09:30"
5
+ formattedStart: string; // "9:00 AM" or "09:00"
6
+ formattedEnd: string; // "9:30 AM" or "09:30"
7
+ available: boolean;
8
+ label?: string;
9
+ }
10
+
11
+ export interface GenerateTimeSlotsOptions {
12
+ startTime?: string; // "HH:mm", defaults to "09:00"
13
+ endTime?: string; // "HH:mm", defaults to "18:00"
14
+ intervalMinutes?: number; // defaults to 30
15
+ disabledSlots?: string[]; // IDs or start times like ["12:00", "13:00"]
16
+ is24Hour?: boolean;
17
+ }
18
+
19
+ function parseTimeToMinutes(timeStr: string): number {
20
+ const [hStr, mStr] = timeStr.split(':');
21
+ const h = parseInt(hStr || '0', 10);
22
+ const m = parseInt(mStr || '0', 10);
23
+ return h * 60 + m;
24
+ }
25
+
26
+ function minutesToTimeString(minutes: number): string {
27
+ const h = Math.floor(minutes / 60) % 24;
28
+ const m = minutes % 60;
29
+ const pad = (n: number) => (n < 10 ? `0${n}` : `${n}`);
30
+ return `${pad(h)}:${pad(m)}`;
31
+ }
32
+
33
+ function formatMinutesDisplay(minutes: number, is24Hour: boolean): string {
34
+ const h = Math.floor(minutes / 60) % 24;
35
+ const m = minutes % 60;
36
+ const pad = (n: number) => (n < 10 ? `0${n}` : `${n}`);
37
+
38
+ if (is24Hour) {
39
+ return `${pad(h)}:${pad(m)}`;
40
+ }
41
+
42
+ const h12 = h % 12 === 0 ? 12 : h % 12;
43
+ const ampm = h >= 12 ? 'PM' : 'AM';
44
+ return `${h12}:${pad(m)} ${ampm}`;
45
+ }
46
+
47
+ export function generateTimeSlots(
48
+ options: GenerateTimeSlotsOptions = {}
49
+ ): TimeSlot[] {
50
+ const {
51
+ startTime = '09:00',
52
+ endTime = '18:00',
53
+ intervalMinutes = 30,
54
+ disabledSlots = [],
55
+ is24Hour = false,
56
+ } = options;
57
+
58
+ const startMin = parseTimeToMinutes(startTime);
59
+ const endMin = parseTimeToMinutes(endTime);
60
+
61
+ if (startMin >= endMin || intervalMinutes <= 0) {
62
+ return [];
63
+ }
64
+
65
+ const slots: TimeSlot[] = [];
66
+ const disabledSet = new Set(disabledSlots);
67
+
68
+ let current = startMin;
69
+ while (current + intervalMinutes <= endMin) {
70
+ const slotStartStr = minutesToTimeString(current);
71
+ const slotEndStr = minutesToTimeString(current + intervalMinutes);
72
+ const id = slotStartStr;
73
+
74
+ const isAvailable = !disabledSet.has(id) && !disabledSet.has(slotStartStr);
75
+
76
+ slots.push({
77
+ id,
78
+ startTime: slotStartStr,
79
+ endTime: slotEndStr,
80
+ formattedStart: formatMinutesDisplay(current, is24Hour),
81
+ formattedEnd: formatMinutesDisplay(current + intervalMinutes, is24Hour),
82
+ available: isAvailable,
83
+ });
84
+
85
+ current += intervalMinutes;
86
+ }
87
+
88
+ return slots;
89
+ }
@@ -0,0 +1,102 @@
1
+ import type {
2
+ ResolvedTheme,
3
+ ThemeBorderRadius,
4
+ ThemeColors,
5
+ ThemeSpacing,
6
+ ThemeTypography,
7
+ } from './types';
8
+
9
+ export const defaultTypography: ThemeTypography = {
10
+ fontSizeSmall: 12,
11
+ fontSizeMedium: 14,
12
+ fontSizeLarge: 16,
13
+ fontSizeTitle: 18,
14
+ fontWeightRegular: '400',
15
+ fontWeightMedium: '600',
16
+ fontWeightBold: '700',
17
+ };
18
+
19
+ export const defaultSpacing: ThemeSpacing = {
20
+ xs: 4,
21
+ sm: 8,
22
+ md: 12,
23
+ lg: 16,
24
+ xl: 24,
25
+ };
26
+
27
+ export const defaultBorderRadius: ThemeBorderRadius = {
28
+ sm: 6,
29
+ md: 10,
30
+ lg: 16,
31
+ full: 9999,
32
+ };
33
+
34
+ export const lightColors: ThemeColors = {
35
+ background: '#FFFFFF',
36
+ card: '#F8FAFC',
37
+ modalOverlay: 'rgba(0, 0, 0, 0.45)',
38
+ modalBackground: '#FFFFFF',
39
+ modalHandle: '#CBD5E1',
40
+ text: '#0F172A',
41
+ textSecondary: '#475569',
42
+ textMuted: '#94A3B8',
43
+ primary: '#2563EB',
44
+ primaryText: '#FFFFFF',
45
+ accent: '#3B82F6',
46
+ border: '#E2E8F0',
47
+ divider: '#F1F5F9',
48
+ selected: '#2563EB',
49
+ selectedText: '#FFFFFF',
50
+ rangeHighlight: '#DBEAFE',
51
+ rangeHighlightText: '#1D4ED8',
52
+ todayIndicator: '#2563EB',
53
+ disabled: '#F1F5F9',
54
+ disabledText: '#CBD5E1',
55
+ error: '#EF4444',
56
+ errorText: '#FFFFFF',
57
+ headerBackground: '#FFFFFF',
58
+ footerBackground: '#F8FAFC',
59
+ };
60
+
61
+ export const darkColors: ThemeColors = {
62
+ background: '#0F172A',
63
+ card: '#1E293B',
64
+ modalOverlay: 'rgba(0, 0, 0, 0.7)',
65
+ modalBackground: '#1E293B',
66
+ modalHandle: '#475569',
67
+ text: '#F8FAFC',
68
+ textSecondary: '#CBD5E1',
69
+ textMuted: '#64748B',
70
+ primary: '#3B82F6',
71
+ primaryText: '#FFFFFF',
72
+ accent: '#60A5FA',
73
+ border: '#334155',
74
+ divider: '#1E293B',
75
+ selected: '#3B82F6',
76
+ selectedText: '#FFFFFF',
77
+ rangeHighlight: '#1E3A8A',
78
+ rangeHighlightText: '#93C5FD',
79
+ todayIndicator: '#60A5FA',
80
+ disabled: '#1E293B',
81
+ disabledText: '#475569',
82
+ error: '#F87171',
83
+ errorText: '#FFFFFF',
84
+ headerBackground: '#1E293B',
85
+ footerBackground: '#0F172A',
86
+ };
87
+
88
+ export const defaultLightTheme: ResolvedTheme = {
89
+ mode: 'light',
90
+ colors: lightColors,
91
+ typography: defaultTypography,
92
+ spacing: defaultSpacing,
93
+ borderRadius: defaultBorderRadius,
94
+ };
95
+
96
+ export const defaultDarkTheme: ResolvedTheme = {
97
+ mode: 'dark',
98
+ colors: darkColors,
99
+ typography: defaultTypography,
100
+ spacing: defaultSpacing,
101
+ borderRadius: defaultBorderRadius,
102
+ };
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './defaultTheme';
3
+ export * from './useTheme';
@@ -0,0 +1,82 @@
1
+ export type ThemeMode = 'light' | 'dark' | 'auto';
2
+
3
+ export interface ThemeColors {
4
+ background: string;
5
+ card: string;
6
+ modalOverlay: string;
7
+ modalBackground: string;
8
+ modalHandle: string;
9
+ text: string;
10
+ textSecondary: string;
11
+ textMuted: string;
12
+ primary: string;
13
+ primaryText: string;
14
+ accent: string;
15
+ border: string;
16
+ divider: string;
17
+ selected: string;
18
+ selectedText: string;
19
+ rangeHighlight: string;
20
+ rangeHighlightText: string;
21
+ todayIndicator: string;
22
+ disabled: string;
23
+ disabledText: string;
24
+ error: string;
25
+ errorText: string;
26
+ headerBackground: string;
27
+ footerBackground: string;
28
+ }
29
+
30
+ export interface ThemeTypography {
31
+ fontSizeSmall: number;
32
+ fontSizeMedium: number;
33
+ fontSizeLarge: number;
34
+ fontSizeTitle: number;
35
+ fontWeightRegular: '400' | 'normal';
36
+ fontWeightMedium: '500' | '600';
37
+ fontWeightBold: '700' | 'bold';
38
+ fontFamily?: string;
39
+ }
40
+
41
+ export interface ThemeSpacing {
42
+ xs: number;
43
+ sm: number;
44
+ md: number;
45
+ lg: number;
46
+ xl: number;
47
+ }
48
+
49
+ export interface ThemeBorderRadius {
50
+ sm: number;
51
+ md: number;
52
+ lg: number;
53
+ full: number;
54
+ }
55
+
56
+ export interface ThemeColorsOverride {
57
+ backgroundColor?: string;
58
+ textColor?: string;
59
+ selectedTextColor?: string;
60
+ accentColor?: string;
61
+ dividerColor?: string;
62
+ headerBackground?: string;
63
+ cardBackground?: string;
64
+ borderColor?: string;
65
+ }
66
+
67
+ export interface ThemeConfig {
68
+ mode?: ThemeMode;
69
+ colors?: Partial<ThemeColors>;
70
+ themeColors?: ThemeColorsOverride;
71
+ typography?: Partial<ThemeTypography>;
72
+ spacing?: Partial<ThemeSpacing>;
73
+ borderRadius?: Partial<ThemeBorderRadius>;
74
+ }
75
+
76
+ export interface ResolvedTheme {
77
+ mode: 'light' | 'dark';
78
+ colors: ThemeColors;
79
+ typography: ThemeTypography;
80
+ spacing: ThemeSpacing;
81
+ borderRadius: ThemeBorderRadius;
82
+ }
@@ -0,0 +1,98 @@
1
+ import { useMemo } from 'react';
2
+ import { useColorScheme } from 'react-native';
3
+ import {
4
+ defaultBorderRadius,
5
+ defaultDarkTheme,
6
+ defaultLightTheme,
7
+ defaultSpacing,
8
+ defaultTypography,
9
+ } from './defaultTheme';
10
+ import type { ResolvedTheme, ThemeConfig, ThemeMode } from './types';
11
+
12
+ export function resolveTheme(
13
+ themeInput?: ThemeMode | ThemeConfig | null,
14
+ systemScheme?: 'light' | 'dark' | null
15
+ ): ResolvedTheme {
16
+ let mode: 'light' | 'dark' = 'light';
17
+ let config: ThemeConfig | undefined;
18
+
19
+ if (typeof themeInput === 'string') {
20
+ if (themeInput === 'dark') {
21
+ mode = 'dark';
22
+ } else if (themeInput === 'light') {
23
+ mode = 'light';
24
+ } else {
25
+ mode = systemScheme === 'dark' ? 'dark' : 'light';
26
+ }
27
+ } else if (themeInput && typeof themeInput === 'object') {
28
+ config = themeInput;
29
+ if (config.mode === 'dark') {
30
+ mode = 'dark';
31
+ } else if (config.mode === 'light') {
32
+ mode = 'light';
33
+ } else {
34
+ mode = systemScheme === 'dark' ? 'dark' : 'light';
35
+ }
36
+ } else {
37
+ mode = systemScheme === 'dark' ? 'dark' : 'light';
38
+ }
39
+
40
+ const baseTheme = mode === 'dark' ? defaultDarkTheme : defaultLightTheme;
41
+
42
+ if (!config) {
43
+ return baseTheme;
44
+ }
45
+
46
+ const mappedColors = {
47
+ ...config?.colors,
48
+ ...(config?.themeColors?.backgroundColor && {
49
+ background: config.themeColors.backgroundColor,
50
+ modalBackground: config.themeColors.backgroundColor,
51
+ }),
52
+ ...(config?.themeColors?.textColor && {
53
+ text: config.themeColors.textColor,
54
+ }),
55
+ ...(config?.themeColors?.selectedTextColor && {
56
+ selectedText: config.themeColors.selectedTextColor,
57
+ }),
58
+ ...(config?.themeColors?.accentColor && {
59
+ accent: config.themeColors.accentColor,
60
+ primary: config.themeColors.accentColor,
61
+ selected: config.themeColors.accentColor,
62
+ }),
63
+ ...(config?.themeColors?.dividerColor && {
64
+ divider: config.themeColors.dividerColor,
65
+ border: config.themeColors.dividerColor,
66
+ }),
67
+ };
68
+
69
+ return {
70
+ mode,
71
+ colors: {
72
+ ...baseTheme.colors,
73
+ ...mappedColors,
74
+ },
75
+ typography: {
76
+ ...defaultTypography,
77
+ ...config.typography,
78
+ },
79
+ spacing: {
80
+ ...defaultSpacing,
81
+ ...config.spacing,
82
+ },
83
+ borderRadius: {
84
+ ...defaultBorderRadius,
85
+ ...config.borderRadius,
86
+ },
87
+ };
88
+ }
89
+
90
+ export function useTheme(
91
+ themeInput?: ThemeMode | ThemeConfig | null
92
+ ): ResolvedTheme {
93
+ const systemScheme = useColorScheme();
94
+
95
+ return useMemo(() => {
96
+ return resolveTheme(themeInput, systemScheme);
97
+ }, [themeInput, systemScheme]);
98
+ }
@@ -0,0 +1,8 @@
1
+ import type { DateTimePickerError } from '../errors/DateTimePickerError';
2
+
3
+ export type DateTimePickerChangeEvent = (date: Date) => void;
4
+ export type DateTimePickerConfirmEvent = (date: Date) => void;
5
+ export type DateTimePickerCancelEvent = () => void;
6
+ export type DateTimePickerDismissEvent = () => void;
7
+ export type DateTimePickerOpenEvent = () => void;
8
+ export type DateTimePickerErrorEvent = (error: DateTimePickerError) => void;
@@ -0,0 +1,4 @@
1
+ export * from './props';
2
+ export * from './native';
3
+ export * from './events';
4
+ export * from './presentation';
@@ -0,0 +1,28 @@
1
+ export type NativePickerMode = 'date' | 'time' | 'datetime' | 'countdown';
2
+ export type NativePickerDisplay =
3
+ 'default' | 'spinner' | 'calendar' | 'clock' | 'compact' | 'inline';
4
+ export type NativePickerTheme = 'light' | 'dark' | 'auto';
5
+ export type NativePickerAction = 'confirmed' | 'cancelled' | 'dismissed';
6
+
7
+ export interface NativePickerOptions {
8
+ value?: number;
9
+ minimumDate?: number;
10
+ maximumDate?: number;
11
+ display?: NativePickerDisplay;
12
+ locale?: string;
13
+ timeZoneOffsetInMinutes?: number;
14
+ is24Hour?: boolean;
15
+ minuteInterval?: number;
16
+ title?: string;
17
+ confirmText?: string;
18
+ cancelText?: string;
19
+ theme?: NativePickerTheme;
20
+ accentColor?: string;
21
+ textColor?: string;
22
+ backgroundColor?: string;
23
+ }
24
+
25
+ export interface NativePickerResult {
26
+ action: NativePickerAction;
27
+ timestamp: number;
28
+ }
@@ -0,0 +1,28 @@
1
+ export type PresentationMode =
2
+ 'native' | 'inline' | 'modal' | 'bottom-sheet' | 'fullscreen';
3
+
4
+ export type ModalAnimationType = 'slide' | 'fade' | 'none';
5
+
6
+ export interface BaseModalProps {
7
+ /**
8
+ * Visibility flag for modal presentation.
9
+ */
10
+ visible?: boolean;
11
+ /**
12
+ * Alias for `visible`.
13
+ */
14
+ isVisible?: boolean;
15
+ onClose?: () => void;
16
+ title?: string;
17
+ confirmText?: string;
18
+ cancelText?: string;
19
+ onConfirm?: () => void;
20
+ onCancel?: () => void;
21
+ backdropOpacity?: number;
22
+ animationType?: ModalAnimationType;
23
+ showHandle?: boolean; // For bottom-sheet
24
+ closeOnBackdropPress?: boolean;
25
+ customHeader?: React.ReactNode;
26
+ customFooter?: React.ReactNode;
27
+ testID?: string;
28
+ }