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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/DateTimePickerKit.podspec +22 -0
  2. package/LICENSE +20 -0
  3. package/README.md +532 -2
  4. package/android/build.gradle +36 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/datetimepickerkit/DatePickerHelper.kt +185 -0
  7. package/android/src/main/java/com/datetimepickerkit/DateTimePickerHelper.kt +214 -0
  8. package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitModule.kt +258 -0
  9. package/android/src/main/java/com/datetimepickerkit/DateTimePickerKitPackage.kt +30 -0
  10. package/android/src/main/java/com/datetimepickerkit/TimePickerHelper.kt +208 -0
  11. package/ios/DateTimePickerKit.h +11 -0
  12. package/ios/DateTimePickerKit.mm +84 -0
  13. package/ios/DateTimePickerModule.swift +474 -0
  14. package/lib/module/NativeDateTimePickerKit.js +5 -0
  15. package/lib/module/NativeDateTimePickerKit.js.map +1 -0
  16. package/lib/module/components/CalendarPicker.js +414 -0
  17. package/lib/module/components/CalendarPicker.js.map +1 -0
  18. package/lib/module/components/ClockPicker.js +273 -0
  19. package/lib/module/components/ClockPicker.js.map +1 -0
  20. package/lib/module/components/DatePicker.js +174 -0
  21. package/lib/module/components/DatePicker.js.map +1 -0
  22. package/lib/module/components/DateRangePicker.js +154 -0
  23. package/lib/module/components/DateRangePicker.js.map +1 -0
  24. package/lib/module/components/DateTimePicker.js +598 -0
  25. package/lib/module/components/DateTimePicker.js.map +1 -0
  26. package/lib/module/components/MonthPicker.js +145 -0
  27. package/lib/module/components/MonthPicker.js.map +1 -0
  28. package/lib/module/components/TimePicker.js +140 -0
  29. package/lib/module/components/TimePicker.js.map +1 -0
  30. package/lib/module/components/TimeSlotPicker.js +118 -0
  31. package/lib/module/components/TimeSlotPicker.js.map +1 -0
  32. package/lib/module/components/WheelPicker.js +138 -0
  33. package/lib/module/components/WheelPicker.js.map +1 -0
  34. package/lib/module/components/YearPicker.js +151 -0
  35. package/lib/module/components/YearPicker.js.map +1 -0
  36. package/lib/module/components/common/ModalWrapper.js +130 -0
  37. package/lib/module/components/common/ModalWrapper.js.map +1 -0
  38. package/lib/module/components/common/PickerHeader.js +82 -0
  39. package/lib/module/components/common/PickerHeader.js.map +1 -0
  40. package/lib/module/components/common/PresetsBar.js +66 -0
  41. package/lib/module/components/common/PresetsBar.js.map +1 -0
  42. package/lib/module/errors/DateTimePickerError.js +12 -0
  43. package/lib/module/errors/DateTimePickerError.js.map +1 -0
  44. package/lib/module/hooks/useDateTimePicker.js +73 -0
  45. package/lib/module/hooks/useDateTimePicker.js.map +1 -0
  46. package/lib/module/index.js +40 -0
  47. package/lib/module/index.js.map +1 -0
  48. package/lib/module/localization/index.js +6 -0
  49. package/lib/module/localization/index.js.map +1 -0
  50. package/lib/module/localization/locales.js +186 -0
  51. package/lib/module/localization/locales.js.map +1 -0
  52. package/lib/module/localization/types.js +2 -0
  53. package/lib/module/localization/types.js.map +1 -0
  54. package/lib/module/localization/useLocale.js +126 -0
  55. package/lib/module/localization/useLocale.js.map +1 -0
  56. package/lib/module/native/NativeDateTimePicker.js +110 -0
  57. package/lib/module/native/NativeDateTimePicker.js.map +1 -0
  58. package/lib/module/package.json +1 -0
  59. package/lib/module/presets/datePresets.js +75 -0
  60. package/lib/module/presets/datePresets.js.map +1 -0
  61. package/lib/module/presets/index.js +4 -0
  62. package/lib/module/presets/index.js.map +1 -0
  63. package/lib/module/slots/index.js +4 -0
  64. package/lib/module/slots/index.js.map +1 -0
  65. package/lib/module/slots/timeSlots.js +59 -0
  66. package/lib/module/slots/timeSlots.js.map +1 -0
  67. package/lib/module/theme/defaultTheme.js +91 -0
  68. package/lib/module/theme/defaultTheme.js.map +1 -0
  69. package/lib/module/theme/index.js +6 -0
  70. package/lib/module/theme/index.js.map +1 -0
  71. package/lib/module/theme/types.js +2 -0
  72. package/lib/module/theme/types.js.map +1 -0
  73. package/lib/module/theme/useTheme.js +59 -0
  74. package/lib/module/theme/useTheme.js.map +1 -0
  75. package/lib/module/types/events.js +4 -0
  76. package/lib/module/types/events.js.map +1 -0
  77. package/lib/module/types/index.js +7 -0
  78. package/lib/module/types/index.js.map +1 -0
  79. package/lib/module/types/native.js +2 -0
  80. package/lib/module/types/native.js.map +1 -0
  81. package/lib/module/types/presentation.js +2 -0
  82. package/lib/module/types/presentation.js.map +1 -0
  83. package/lib/module/types/props.js +4 -0
  84. package/lib/module/types/props.js.map +1 -0
  85. package/lib/module/utils/constants.js +14 -0
  86. package/lib/module/utils/constants.js.map +1 -0
  87. package/lib/module/utils/dateConversion.js +115 -0
  88. package/lib/module/utils/dateConversion.js.map +1 -0
  89. package/lib/module/utils/dateFormatting.js +102 -0
  90. package/lib/module/utils/dateFormatting.js.map +1 -0
  91. package/lib/module/utils/dateValidation.js +161 -0
  92. package/lib/module/utils/dateValidation.js.map +1 -0
  93. package/lib/module/utils/index.js +7 -0
  94. package/lib/module/utils/index.js.map +1 -0
  95. package/lib/typescript/package.json +1 -0
  96. package/lib/typescript/src/NativeDateTimePickerKit.d.ts +17 -0
  97. package/lib/typescript/src/NativeDateTimePickerKit.d.ts.map +1 -0
  98. package/lib/typescript/src/components/CalendarPicker.d.ts +35 -0
  99. package/lib/typescript/src/components/CalendarPicker.d.ts.map +1 -0
  100. package/lib/typescript/src/components/ClockPicker.d.ts +22 -0
  101. package/lib/typescript/src/components/ClockPicker.d.ts.map +1 -0
  102. package/lib/typescript/src/components/DatePicker.d.ts +32 -0
  103. package/lib/typescript/src/components/DatePicker.d.ts.map +1 -0
  104. package/lib/typescript/src/components/DateRangePicker.d.ts +41 -0
  105. package/lib/typescript/src/components/DateRangePicker.d.ts.map +1 -0
  106. package/lib/typescript/src/components/DateTimePicker.d.ts +7 -0
  107. package/lib/typescript/src/components/DateTimePicker.d.ts.map +1 -0
  108. package/lib/typescript/src/components/MonthPicker.d.ts +21 -0
  109. package/lib/typescript/src/components/MonthPicker.d.ts.map +1 -0
  110. package/lib/typescript/src/components/TimePicker.d.ts +25 -0
  111. package/lib/typescript/src/components/TimePicker.d.ts.map +1 -0
  112. package/lib/typescript/src/components/TimeSlotPicker.d.ts +18 -0
  113. package/lib/typescript/src/components/TimeSlotPicker.d.ts.map +1 -0
  114. package/lib/typescript/src/components/WheelPicker.d.ts +17 -0
  115. package/lib/typescript/src/components/WheelPicker.d.ts.map +1 -0
  116. package/lib/typescript/src/components/YearPicker.d.ts +14 -0
  117. package/lib/typescript/src/components/YearPicker.d.ts.map +1 -0
  118. package/lib/typescript/src/components/common/ModalWrapper.d.ts +10 -0
  119. package/lib/typescript/src/components/common/ModalWrapper.d.ts.map +1 -0
  120. package/lib/typescript/src/components/common/PickerHeader.d.ts +13 -0
  121. package/lib/typescript/src/components/common/PickerHeader.d.ts.map +1 -0
  122. package/lib/typescript/src/components/common/PresetsBar.d.ts +12 -0
  123. package/lib/typescript/src/components/common/PresetsBar.d.ts.map +1 -0
  124. package/lib/typescript/src/errors/DateTimePickerError.d.ts +7 -0
  125. package/lib/typescript/src/errors/DateTimePickerError.d.ts.map +1 -0
  126. package/lib/typescript/src/hooks/useDateTimePicker.d.ts +17 -0
  127. package/lib/typescript/src/hooks/useDateTimePicker.d.ts.map +1 -0
  128. package/lib/typescript/src/index.d.ts +23 -0
  129. package/lib/typescript/src/index.d.ts.map +1 -0
  130. package/lib/typescript/src/localization/index.d.ts +4 -0
  131. package/lib/typescript/src/localization/index.d.ts.map +1 -0
  132. package/lib/typescript/src/localization/locales.d.ts +12 -0
  133. package/lib/typescript/src/localization/locales.d.ts.map +1 -0
  134. package/lib/typescript/src/localization/types.d.ts +23 -0
  135. package/lib/typescript/src/localization/types.d.ts.map +1 -0
  136. package/lib/typescript/src/localization/useLocale.d.ts +31 -0
  137. package/lib/typescript/src/localization/useLocale.d.ts.map +1 -0
  138. package/lib/typescript/src/native/NativeDateTimePicker.d.ts +14 -0
  139. package/lib/typescript/src/native/NativeDateTimePicker.d.ts.map +1 -0
  140. package/lib/typescript/src/presets/datePresets.d.ts +8 -0
  141. package/lib/typescript/src/presets/datePresets.d.ts.map +1 -0
  142. package/lib/typescript/src/presets/index.d.ts +2 -0
  143. package/lib/typescript/src/presets/index.d.ts.map +1 -0
  144. package/lib/typescript/src/slots/index.d.ts +2 -0
  145. package/lib/typescript/src/slots/index.d.ts.map +1 -0
  146. package/lib/typescript/src/slots/timeSlots.d.ts +18 -0
  147. package/lib/typescript/src/slots/timeSlots.d.ts.map +1 -0
  148. package/lib/typescript/src/theme/defaultTheme.d.ts +9 -0
  149. package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
  150. package/lib/typescript/src/theme/index.d.ts +4 -0
  151. package/lib/typescript/src/theme/index.d.ts.map +1 -0
  152. package/lib/typescript/src/theme/types.d.ts +65 -0
  153. package/lib/typescript/src/theme/types.d.ts.map +1 -0
  154. package/lib/typescript/src/theme/useTheme.d.ts +4 -0
  155. package/lib/typescript/src/theme/useTheme.d.ts.map +1 -0
  156. package/lib/typescript/src/types/events.d.ts +8 -0
  157. package/lib/typescript/src/types/events.d.ts.map +1 -0
  158. package/lib/typescript/src/types/index.d.ts +5 -0
  159. package/lib/typescript/src/types/index.d.ts.map +1 -0
  160. package/lib/typescript/src/types/native.d.ts +26 -0
  161. package/lib/typescript/src/types/native.d.ts.map +1 -0
  162. package/lib/typescript/src/types/presentation.d.ts +19 -0
  163. package/lib/typescript/src/types/presentation.d.ts.map +1 -0
  164. package/lib/typescript/src/types/props.d.ts +68 -0
  165. package/lib/typescript/src/types/props.d.ts.map +1 -0
  166. package/lib/typescript/src/utils/constants.d.ts +12 -0
  167. package/lib/typescript/src/utils/constants.d.ts.map +1 -0
  168. package/lib/typescript/src/utils/dateConversion.d.ts +27 -0
  169. package/lib/typescript/src/utils/dateConversion.d.ts.map +1 -0
  170. package/lib/typescript/src/utils/dateFormatting.d.ts +8 -0
  171. package/lib/typescript/src/utils/dateFormatting.d.ts.map +1 -0
  172. package/lib/typescript/src/utils/dateValidation.d.ts +46 -0
  173. package/lib/typescript/src/utils/dateValidation.d.ts.map +1 -0
  174. package/lib/typescript/src/utils/index.d.ts +5 -0
  175. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  176. package/package.json +183 -4
  177. package/src/NativeDateTimePickerKit.ts +19 -0
  178. package/src/components/CalendarPicker.tsx +593 -0
  179. package/src/components/ClockPicker.tsx +403 -0
  180. package/src/components/DatePicker.tsx +246 -0
  181. package/src/components/DateRangePicker.tsx +226 -0
  182. package/src/components/DateTimePicker.tsx +862 -0
  183. package/src/components/MonthPicker.tsx +216 -0
  184. package/src/components/TimePicker.tsx +190 -0
  185. package/src/components/TimeSlotPicker.tsx +163 -0
  186. package/src/components/WheelPicker.tsx +199 -0
  187. package/src/components/YearPicker.tsx +228 -0
  188. package/src/components/common/ModalWrapper.tsx +184 -0
  189. package/src/components/common/PickerHeader.tsx +121 -0
  190. package/src/components/common/PresetsBar.tsx +104 -0
  191. package/src/errors/DateTimePickerError.ts +29 -0
  192. package/src/hooks/useDateTimePicker.ts +100 -0
  193. package/src/index.tsx +92 -0
  194. package/src/localization/index.ts +3 -0
  195. package/src/localization/locales.ts +499 -0
  196. package/src/localization/types.ts +21 -0
  197. package/src/localization/useLocale.ts +137 -0
  198. package/src/native/NativeDateTimePicker.ts +154 -0
  199. package/src/presets/datePresets.ts +97 -0
  200. package/src/presets/index.ts +1 -0
  201. package/src/slots/index.ts +1 -0
  202. package/src/slots/timeSlots.ts +89 -0
  203. package/src/theme/defaultTheme.ts +102 -0
  204. package/src/theme/index.ts +3 -0
  205. package/src/theme/types.ts +70 -0
  206. package/src/theme/useTheme.ts +75 -0
  207. package/src/types/events.ts +8 -0
  208. package/src/types/index.ts +4 -0
  209. package/src/types/native.ts +28 -0
  210. package/src/types/presentation.ts +21 -0
  211. package/src/types/props.ts +104 -0
  212. package/src/utils/constants.ts +15 -0
  213. package/src/utils/dateConversion.ts +127 -0
  214. package/src/utils/dateFormatting.ts +166 -0
  215. package/src/utils/dateValidation.ts +178 -0
  216. package/src/utils/index.ts +4 -0
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+ import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
+ import type { ResolvedTheme } from '../../theme';
4
+
5
+ export interface PickerHeaderProps {
6
+ title?: string;
7
+ cancelText?: string;
8
+ confirmText?: string;
9
+ onCancel?: () => void;
10
+ onConfirm?: () => void;
11
+ theme: ResolvedTheme;
12
+ isRTL?: boolean;
13
+ }
14
+
15
+ export const PickerHeader: React.FC<PickerHeaderProps> = React.memo(
16
+ ({
17
+ title,
18
+ cancelText = 'Cancel',
19
+ confirmText = 'Confirm',
20
+ onCancel,
21
+ onConfirm,
22
+ theme,
23
+ isRTL = false,
24
+ }) => {
25
+ return (
26
+ <View
27
+ style={[
28
+ styles.container,
29
+ {
30
+ borderBottomColor: theme.colors.border,
31
+ flexDirection: isRTL ? 'row-reverse' : 'row',
32
+ backgroundColor: theme.colors.headerBackground,
33
+ },
34
+ ]}
35
+ >
36
+ {onCancel ? (
37
+ <TouchableOpacity
38
+ accessibilityRole="button"
39
+ accessibilityLabel={cancelText}
40
+ onPress={onCancel}
41
+ style={styles.actionButton}
42
+ >
43
+ <Text
44
+ style={[
45
+ styles.cancelText,
46
+ {
47
+ color: theme.colors.textSecondary,
48
+ fontSize: theme.typography.fontSizeMedium,
49
+ },
50
+ ]}
51
+ >
52
+ {cancelText}
53
+ </Text>
54
+ </TouchableOpacity>
55
+ ) : (
56
+ <View style={styles.actionButton} />
57
+ )}
58
+
59
+ <Text
60
+ numberOfLines={1}
61
+ style={[
62
+ styles.titleText,
63
+ {
64
+ color: theme.colors.text,
65
+ fontSize: theme.typography.fontSizeLarge,
66
+ fontWeight: theme.typography.fontWeightMedium,
67
+ },
68
+ ]}
69
+ >
70
+ {title || ''}
71
+ </Text>
72
+
73
+ {onConfirm ? (
74
+ <TouchableOpacity
75
+ accessibilityRole="button"
76
+ accessibilityLabel={confirmText}
77
+ onPress={onConfirm}
78
+ style={styles.actionButton}
79
+ >
80
+ <Text
81
+ style={[
82
+ styles.confirmText,
83
+ {
84
+ color: theme.colors.primary,
85
+ fontSize: theme.typography.fontSizeMedium,
86
+ fontWeight: theme.typography.fontWeightMedium,
87
+ },
88
+ ]}
89
+ >
90
+ {confirmText}
91
+ </Text>
92
+ </TouchableOpacity>
93
+ ) : (
94
+ <View style={styles.actionButton} />
95
+ )}
96
+ </View>
97
+ );
98
+ }
99
+ );
100
+
101
+ const styles = StyleSheet.create({
102
+ container: {
103
+ height: 54,
104
+ alignItems: 'center',
105
+ justifyContent: 'space-between',
106
+ paddingHorizontal: 16,
107
+ borderBottomWidth: StyleSheet.hairlineWidth,
108
+ },
109
+ actionButton: {
110
+ minWidth: 64,
111
+ height: 40,
112
+ justifyContent: 'center',
113
+ alignItems: 'center',
114
+ },
115
+ titleText: {
116
+ flex: 1,
117
+ textAlign: 'center',
118
+ },
119
+ cancelText: {},
120
+ confirmText: {},
121
+ });
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import {
3
+ ScrollView,
4
+ StyleSheet,
5
+ Text,
6
+ TouchableOpacity,
7
+ View,
8
+ } from 'react-native';
9
+ import type { DatePreset } from '../../presets';
10
+ import type { ResolvedTheme } from '../../theme';
11
+
12
+ export interface PresetsBarProps {
13
+ presets: DatePreset[];
14
+ activePresetId?: string;
15
+ onSelectPreset: (preset: DatePreset) => void;
16
+ theme: ResolvedTheme;
17
+ isRTL?: boolean;
18
+ }
19
+
20
+ export const PresetsBar: React.FC<PresetsBarProps> = React.memo(
21
+ ({ presets, activePresetId, onSelectPreset, theme, isRTL = false }) => {
22
+ if (!presets || presets.length === 0) {
23
+ return null;
24
+ }
25
+
26
+ return (
27
+ <View
28
+ style={[
29
+ styles.container,
30
+ {
31
+ borderBottomColor: theme.colors.border,
32
+ backgroundColor: theme.colors.card,
33
+ },
34
+ ]}
35
+ >
36
+ <ScrollView
37
+ horizontal
38
+ showsHorizontalScrollIndicator={false}
39
+ contentContainerStyle={[
40
+ styles.scrollContent,
41
+ { flexDirection: isRTL ? 'row-reverse' : 'row' },
42
+ ]}
43
+ >
44
+ {presets.map((preset) => {
45
+ const isActive = preset.id === activePresetId;
46
+ return (
47
+ <TouchableOpacity
48
+ key={preset.id}
49
+ onPress={() => onSelectPreset(preset)}
50
+ style={[
51
+ styles.chip,
52
+ {
53
+ backgroundColor: isActive
54
+ ? theme.colors.primary
55
+ : theme.colors.background,
56
+ borderColor: isActive
57
+ ? theme.colors.primary
58
+ : theme.colors.border,
59
+ borderRadius: theme.borderRadius.full,
60
+ },
61
+ ]}
62
+ >
63
+ <Text
64
+ style={[
65
+ styles.chipText,
66
+ {
67
+ color: isActive
68
+ ? theme.colors.primaryText
69
+ : theme.colors.textSecondary,
70
+ fontSize: theme.typography.fontSizeSmall,
71
+ fontWeight: isActive
72
+ ? theme.typography.fontWeightMedium
73
+ : theme.typography.fontWeightRegular,
74
+ },
75
+ ]}
76
+ >
77
+ {preset.label}
78
+ </Text>
79
+ </TouchableOpacity>
80
+ );
81
+ })}
82
+ </ScrollView>
83
+ </View>
84
+ );
85
+ }
86
+ );
87
+
88
+ const styles = StyleSheet.create({
89
+ container: {
90
+ paddingVertical: 8,
91
+ borderBottomWidth: StyleSheet.hairlineWidth,
92
+ },
93
+ scrollContent: {
94
+ paddingHorizontal: 12,
95
+ alignItems: 'center',
96
+ gap: 8,
97
+ },
98
+ chip: {
99
+ paddingHorizontal: 14,
100
+ paddingVertical: 6,
101
+ borderWidth: 1,
102
+ },
103
+ chipText: {},
104
+ });
@@ -0,0 +1,29 @@
1
+ export type DateTimePickerErrorCode =
2
+ | 'NATIVE_MODULE_NOT_FOUND'
3
+ | 'PICKER_ALREADY_OPEN'
4
+ | 'PICKER_NOT_OPEN'
5
+ | 'INVALID_DATE'
6
+ | 'INVALID_MODE'
7
+ | 'INVALID_MINUTE_INTERVAL'
8
+ | 'DATE_OUT_OF_RANGE'
9
+ | 'UNSUPPORTED_FEATURE'
10
+ | 'ACTIVITY_UNAVAILABLE'
11
+ | 'PRESENTATION_FAILED'
12
+ | 'UNKNOWN_ERROR';
13
+
14
+ export class DateTimePickerError extends Error {
15
+ readonly code: DateTimePickerErrorCode;
16
+ readonly details?: unknown;
17
+
18
+ constructor(
19
+ code: DateTimePickerErrorCode,
20
+ message: string,
21
+ details?: unknown
22
+ ) {
23
+ super(message);
24
+ this.name = 'DateTimePickerError';
25
+ this.code = code;
26
+ this.details = details;
27
+ Object.setPrototypeOf(this, DateTimePickerError.prototype);
28
+ }
29
+ }
@@ -0,0 +1,100 @@
1
+ import { useCallback, useRef, useState } from 'react';
2
+ import type { DateTimePickerProps, DateTimePickerRef } from '../types';
3
+ import type { DateTimePickerError } from '../errors/DateTimePickerError';
4
+ import { parseDate } from '../utils/dateConversion';
5
+
6
+ export interface UseDateTimePickerResult {
7
+ ref: React.RefObject<DateTimePickerRef | null>;
8
+ isOpen: boolean;
9
+ value: Date;
10
+ error: DateTimePickerError | null;
11
+ open: () => Promise<Date | null>;
12
+ close: () => Promise<boolean>;
13
+ confirm: () => Promise<Date | null>;
14
+ cancel: () => Promise<boolean>;
15
+ reset: () => void;
16
+ getValue: () => Date | null;
17
+ setValue: (date: Date | number | string) => void;
18
+ }
19
+
20
+ export function useDateTimePicker(
21
+ options: Partial<DateTimePickerProps> = {}
22
+ ): UseDateTimePickerResult {
23
+ const pickerRef = useRef<DateTimePickerRef>(null);
24
+ const [isOpen, setIsOpen] = useState<boolean>(false);
25
+ const [value, setValueState] = useState<Date>(
26
+ () =>
27
+ parseDate(options.value) || parseDate(options.defaultValue) || new Date()
28
+ );
29
+ const [error, setError] = useState<DateTimePickerError | null>(null);
30
+
31
+ const open = useCallback(async (): Promise<Date | null> => {
32
+ setIsOpen(true);
33
+ setError(null);
34
+ try {
35
+ const selected = await pickerRef.current?.open();
36
+ if (selected) {
37
+ setValueState(selected);
38
+ }
39
+ return selected ?? null;
40
+ } catch (err) {
41
+ setError(err as DateTimePickerError);
42
+ return null;
43
+ } finally {
44
+ setIsOpen(false);
45
+ }
46
+ }, []);
47
+
48
+ const close = useCallback(async (): Promise<boolean> => {
49
+ const closed = (await pickerRef.current?.close()) ?? false;
50
+ setIsOpen(false);
51
+ return closed;
52
+ }, []);
53
+
54
+ const confirm = useCallback(async (): Promise<Date | null> => {
55
+ const confirmed = await pickerRef.current?.confirm();
56
+ if (confirmed) {
57
+ setValueState(confirmed);
58
+ setIsOpen(false);
59
+ }
60
+ return confirmed ?? null;
61
+ }, []);
62
+
63
+ const cancel = useCallback(async (): Promise<boolean> => {
64
+ const cancelled = (await pickerRef.current?.cancel()) ?? false;
65
+ setIsOpen(false);
66
+ return cancelled;
67
+ }, []);
68
+
69
+ const reset = useCallback(() => {
70
+ pickerRef.current?.reset();
71
+ const resetDate = parseDate(options.defaultValue) || new Date();
72
+ setValueState(resetDate);
73
+ }, [options.defaultValue]);
74
+
75
+ const getValue = useCallback((): Date | null => {
76
+ return pickerRef.current?.getValue() ?? value;
77
+ }, [value]);
78
+
79
+ const setValue = useCallback((newDate: Date | number | string) => {
80
+ pickerRef.current?.setValue(newDate);
81
+ const parsed = parseDate(newDate);
82
+ if (parsed) {
83
+ setValueState(parsed);
84
+ }
85
+ }, []);
86
+
87
+ return {
88
+ ref: pickerRef,
89
+ isOpen,
90
+ value,
91
+ error,
92
+ open,
93
+ close,
94
+ confirm,
95
+ cancel,
96
+ reset,
97
+ getValue,
98
+ setValue,
99
+ };
100
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,92 @@
1
+ // Public Components
2
+ export {
3
+ DateTimePicker,
4
+ openDateTimePickerModal,
5
+ } from './components/DateTimePicker';
6
+
7
+ export {
8
+ DatePicker,
9
+ type DatePickerProps,
10
+ type DatePickerRef,
11
+ } from './components/DatePicker';
12
+
13
+ export {
14
+ TimePicker,
15
+ type TimePickerProps,
16
+ type TimePickerRef,
17
+ } from './components/TimePicker';
18
+
19
+ export {
20
+ DateRangePicker,
21
+ type DateRange,
22
+ type DateRangePickerProps,
23
+ type DateRangePickerRef,
24
+ } from './components/DateRangePicker';
25
+
26
+ export {
27
+ CalendarPicker,
28
+ type CalendarPickerProps,
29
+ type MarkedDateConfig,
30
+ type MarkedDatesMap,
31
+ } from './components/CalendarPicker';
32
+
33
+ export { MonthPicker, type MonthPickerProps } from './components/MonthPicker';
34
+
35
+ export { YearPicker, type YearPickerProps } from './components/YearPicker';
36
+
37
+ export {
38
+ WheelPicker,
39
+ type WheelPickerItem,
40
+ type WheelPickerProps,
41
+ } from './components/WheelPicker';
42
+
43
+ export { ClockPicker, type ClockPickerProps } from './components/ClockPicker';
44
+
45
+ export {
46
+ TimeSlotPicker,
47
+ type TimeSlotPickerProps,
48
+ } from './components/TimeSlotPicker';
49
+
50
+ export {
51
+ ModalWrapper,
52
+ type ModalWrapperProps,
53
+ } from './components/common/ModalWrapper';
54
+
55
+ export {
56
+ PickerHeader,
57
+ type PickerHeaderProps,
58
+ } from './components/common/PickerHeader';
59
+
60
+ export {
61
+ PresetsBar,
62
+ type PresetsBarProps,
63
+ } from './components/common/PresetsBar';
64
+
65
+ // Custom Hooks
66
+ export {
67
+ useDateTimePicker,
68
+ type UseDateTimePickerResult,
69
+ } from './hooks/useDateTimePicker';
70
+
71
+ // Theme System
72
+ export * from './theme';
73
+
74
+ // Localization System
75
+ export * from './localization';
76
+
77
+ // Presets & Appointment Time Slots
78
+ export * from './presets';
79
+ export * from './slots';
80
+
81
+ // Native Bridge & TurboModule
82
+ export { NativeDateTimePicker } from './native/NativeDateTimePicker';
83
+
84
+ // Error System
85
+ export {
86
+ DateTimePickerError,
87
+ type DateTimePickerErrorCode,
88
+ } from './errors/DateTimePickerError';
89
+
90
+ // Types & Utilities
91
+ export * from './types';
92
+ export * from './utils';
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './locales';
3
+ export * from './useLocale';