@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,499 @@
1
+ import type { LocaleData } from './types';
2
+
3
+ export const enLocale: LocaleData = {
4
+ code: 'en',
5
+ isRTL: false,
6
+ firstDayOfWeek: 0,
7
+ months: [
8
+ 'January',
9
+ 'February',
10
+ 'March',
11
+ 'April',
12
+ 'May',
13
+ 'June',
14
+ 'July',
15
+ 'August',
16
+ 'September',
17
+ 'October',
18
+ 'November',
19
+ 'December',
20
+ ],
21
+ monthsShort: [
22
+ 'Jan',
23
+ 'Feb',
24
+ 'Mar',
25
+ 'Apr',
26
+ 'May',
27
+ 'Jun',
28
+ 'Jul',
29
+ 'Aug',
30
+ 'Sep',
31
+ 'Oct',
32
+ 'Nov',
33
+ 'Dec',
34
+ ],
35
+ weekdays: [
36
+ 'Sunday',
37
+ 'Monday',
38
+ 'Tuesday',
39
+ 'Wednesday',
40
+ 'Thursday',
41
+ 'Friday',
42
+ 'Saturday',
43
+ ],
44
+ weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
45
+ weekdaysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
46
+ am: 'AM',
47
+ pm: 'PM',
48
+ confirmText: 'Confirm',
49
+ cancelText: 'Cancel',
50
+ todayText: 'Today',
51
+ selectDateTitle: 'Select Date',
52
+ selectTimeTitle: 'Select Time',
53
+ selectDateTimeTitle: 'Select Date & Time',
54
+ selectRangeTitle: 'Select Date Range',
55
+ };
56
+
57
+ export const hiLocale: LocaleData = {
58
+ code: 'hi',
59
+ isRTL: false,
60
+ firstDayOfWeek: 0,
61
+ months: [
62
+ 'जनवरी',
63
+ 'फ़रवरी',
64
+ 'मार्च',
65
+ 'अप्रैल',
66
+ 'मई',
67
+ 'जून',
68
+ 'जुलाई',
69
+ 'अगस्त',
70
+ 'सितंबर',
71
+ 'अक्टूबर',
72
+ 'नवंबर',
73
+ 'दिसंबर',
74
+ ],
75
+ monthsShort: [
76
+ 'जन',
77
+ 'फ़र',
78
+ 'मार्च',
79
+ 'अप्रै',
80
+ 'मई',
81
+ 'जून',
82
+ 'जुला',
83
+ 'अग',
84
+ 'सित',
85
+ 'अक्टू',
86
+ 'नव',
87
+ 'दिस',
88
+ ],
89
+ weekdays: [
90
+ 'रविवार',
91
+ 'सोमवार',
92
+ 'मंगलवार',
93
+ 'बुधवार',
94
+ 'गुरुवार',
95
+ 'शुक्रवार',
96
+ 'शनिवार',
97
+ ],
98
+ weekdaysShort: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
99
+ weekdaysMin: ['र', 'सो', 'मं', 'बु', 'गु', 'शु', 'श'],
100
+ am: 'पूर्वाह्न',
101
+ pm: 'अपराह्न',
102
+ confirmText: 'पुष्टि करें',
103
+ cancelText: 'रद्द करें',
104
+ todayText: 'आज',
105
+ selectDateTitle: 'तारीख चुनें',
106
+ selectTimeTitle: 'समय चुनें',
107
+ selectDateTimeTitle: 'तारीख और समय चुनें',
108
+ selectRangeTitle: 'तारीख सीमा चुनें',
109
+ };
110
+
111
+ export const guLocale: LocaleData = {
112
+ code: 'gu',
113
+ isRTL: false,
114
+ firstDayOfWeek: 0,
115
+ months: [
116
+ 'જાન્યુઆરી',
117
+ 'ફેબ્રુઆરી',
118
+ 'માર્ચ',
119
+ 'એપ્રિલ',
120
+ 'મે',
121
+ 'જૂન',
122
+ 'જુલાઈ',
123
+ 'ઑગસ્ટ',
124
+ 'સપ્ટેમ્બર',
125
+ 'ઑક્ટોબર',
126
+ 'નવેમ્બર',
127
+ 'ડિસેમ્બર',
128
+ ],
129
+ monthsShort: [
130
+ 'જાન્યુ',
131
+ 'ફેબ્રુ',
132
+ 'માર્ચ',
133
+ 'એપ્રિ',
134
+ 'મે',
135
+ 'જૂન',
136
+ 'જુલા',
137
+ 'ઑગ',
138
+ 'સપ્ટે',
139
+ 'ઑક્ટો',
140
+ 'નવે',
141
+ 'ડિસે',
142
+ ],
143
+ weekdays: [
144
+ 'રવિવાર',
145
+ 'સોમવાર',
146
+ 'મંગળવાર',
147
+ 'બુધવાર',
148
+ 'ગુરુવાર',
149
+ 'શુક્રવાર',
150
+ 'શનિવાર',
151
+ ],
152
+ weekdaysShort: ['રવિ', 'સોમ', 'મંગળ', 'બુધ', 'ગુરુ', 'શુક્ર', 'શનિ'],
153
+ weekdaysMin: ['ર', 'સો', 'મં', 'બુ', 'ગુ', 'શુ', 'શ'],
154
+ am: 'સવાર',
155
+ pm: 'સાંજ',
156
+ confirmText: 'ખાતરી કરો',
157
+ cancelText: 'રદ કરો',
158
+ todayText: 'આજે',
159
+ selectDateTitle: 'તારીખ પસંદ કરો',
160
+ selectTimeTitle: 'સમય પસંદ કરો',
161
+ selectDateTimeTitle: 'તારીખ અને સમય પસંદ કરો',
162
+ selectRangeTitle: 'તારીખ શ્રેણી પસંદ કરો',
163
+ };
164
+
165
+ export const esLocale: LocaleData = {
166
+ code: 'es',
167
+ isRTL: false,
168
+ firstDayOfWeek: 1,
169
+ months: [
170
+ 'Enero',
171
+ 'Febrero',
172
+ 'Marzo',
173
+ 'Abril',
174
+ 'Mayo',
175
+ 'Junio',
176
+ 'Julio',
177
+ 'Agosto',
178
+ 'Septiembre',
179
+ 'Octubre',
180
+ 'Noviembre',
181
+ 'Diciembre',
182
+ ],
183
+ monthsShort: [
184
+ 'Ene',
185
+ 'Feb',
186
+ 'Mar',
187
+ 'Abr',
188
+ 'May',
189
+ 'Jun',
190
+ 'Jul',
191
+ 'Ago',
192
+ 'Sep',
193
+ 'Oct',
194
+ 'Nov',
195
+ 'Dic',
196
+ ],
197
+ weekdays: [
198
+ 'Domingo',
199
+ 'Lunes',
200
+ 'Martes',
201
+ 'Miércoles',
202
+ 'Jueves',
203
+ 'Viernes',
204
+ 'Sábado',
205
+ ],
206
+ weekdaysShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'],
207
+ weekdaysMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'],
208
+ am: 'AM',
209
+ pm: 'PM',
210
+ confirmText: 'Confirmar',
211
+ cancelText: 'Cancelar',
212
+ todayText: 'Hoy',
213
+ selectDateTitle: 'Seleccionar Fecha',
214
+ selectTimeTitle: 'Seleccionar Hora',
215
+ selectDateTimeTitle: 'Seleccionar Fecha y Hora',
216
+ selectRangeTitle: 'Seleccionar Rango de Fechas',
217
+ };
218
+
219
+ export const frLocale: LocaleData = {
220
+ code: 'fr',
221
+ isRTL: false,
222
+ firstDayOfWeek: 1,
223
+ months: [
224
+ 'Janvier',
225
+ 'Février',
226
+ 'Mars',
227
+ 'Avril',
228
+ 'Mai',
229
+ 'Juin',
230
+ 'Juillet',
231
+ 'Août',
232
+ 'Septembre',
233
+ 'Octobre',
234
+ 'Novembre',
235
+ 'Décembre',
236
+ ],
237
+ monthsShort: [
238
+ 'Janv',
239
+ 'Févr',
240
+ 'Mars',
241
+ 'Avr',
242
+ 'Mai',
243
+ 'Juin',
244
+ 'Juil',
245
+ 'Août',
246
+ 'Sept',
247
+ 'Oct',
248
+ 'Nov',
249
+ 'Déc',
250
+ ],
251
+ weekdays: [
252
+ 'Dimanche',
253
+ 'Lundi',
254
+ 'Mardi',
255
+ 'Mercredi',
256
+ 'Jeudi',
257
+ 'Vendredi',
258
+ 'Samedi',
259
+ ],
260
+ weekdaysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
261
+ weekdaysMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
262
+ am: 'AM',
263
+ pm: 'PM',
264
+ confirmText: 'Confirmer',
265
+ cancelText: 'Annuler',
266
+ todayText: "Aujourd'hui",
267
+ selectDateTitle: 'Sélectionner la Date',
268
+ selectTimeTitle: "Sélectionner l'Heure",
269
+ selectDateTimeTitle: 'Sélectionner Date et Heure',
270
+ selectRangeTitle: 'Sélectionner la Plage de Dates',
271
+ };
272
+
273
+ export const deLocale: LocaleData = {
274
+ code: 'de',
275
+ isRTL: false,
276
+ firstDayOfWeek: 1,
277
+ months: [
278
+ 'Januar',
279
+ 'Februar',
280
+ 'März',
281
+ 'April',
282
+ 'Mai',
283
+ 'Juni',
284
+ 'Juli',
285
+ 'August',
286
+ 'September',
287
+ 'Oktober',
288
+ 'November',
289
+ 'Dezember',
290
+ ],
291
+ monthsShort: [
292
+ 'Jan',
293
+ 'Feb',
294
+ 'Mär',
295
+ 'Apr',
296
+ 'Mai',
297
+ 'Jun',
298
+ 'Jul',
299
+ 'Aug',
300
+ 'Sep',
301
+ 'Okt',
302
+ 'Nov',
303
+ 'Dez',
304
+ ],
305
+ weekdays: [
306
+ 'Sonntag',
307
+ 'Montag',
308
+ 'Dienstag',
309
+ 'Mittwoch',
310
+ 'Donnerstag',
311
+ 'Freitag',
312
+ 'Samstag',
313
+ ],
314
+ weekdaysShort: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
315
+ weekdaysMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
316
+ am: 'Vorm.',
317
+ pm: 'Nachm.',
318
+ confirmText: 'Bestätigen',
319
+ cancelText: 'Abbrechen',
320
+ todayText: 'Heute',
321
+ selectDateTitle: 'Datum auswählen',
322
+ selectTimeTitle: 'Uhrzeit auswählen',
323
+ selectDateTimeTitle: 'Datum & Uhrzeit auswählen',
324
+ selectRangeTitle: 'Datumsbereich auswählen',
325
+ };
326
+
327
+ export const arLocale: LocaleData = {
328
+ code: 'ar',
329
+ isRTL: true,
330
+ firstDayOfWeek: 6, // Saturday
331
+ months: [
332
+ 'يناير',
333
+ 'فبراير',
334
+ 'مارس',
335
+ 'أبريل',
336
+ 'مايو',
337
+ 'يونيو',
338
+ 'يوليو',
339
+ 'أغسطس',
340
+ 'سبتمبر',
341
+ 'أكتوبر',
342
+ 'نوفمبر',
343
+ 'ديسمبر',
344
+ ],
345
+ monthsShort: [
346
+ 'ينا',
347
+ 'فبر',
348
+ 'مار',
349
+ 'أبر',
350
+ 'ماي',
351
+ 'يون',
352
+ 'يول',
353
+ 'أغس',
354
+ 'سبت',
355
+ 'أكت',
356
+ 'نوف',
357
+ 'ديس',
358
+ ],
359
+ weekdays: [
360
+ 'الأحد',
361
+ 'الاثنين',
362
+ 'الثلاثاء',
363
+ 'الأربعاء',
364
+ 'الخميس',
365
+ 'الجمعة',
366
+ 'السبت',
367
+ ],
368
+ weekdaysShort: ['أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
369
+ weekdaysMin: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
370
+ am: 'ص',
371
+ pm: 'م',
372
+ confirmText: 'تأكيد',
373
+ cancelText: 'إلغاء',
374
+ todayText: 'اليوم',
375
+ selectDateTitle: 'اختر التاريخ',
376
+ selectTimeTitle: 'اختر الوقت',
377
+ selectDateTimeTitle: 'اختر التاريخ والوقت',
378
+ selectRangeTitle: 'اختر نطاق التاريخ',
379
+ };
380
+
381
+ export const zhLocale: LocaleData = {
382
+ code: 'zh',
383
+ isRTL: false,
384
+ firstDayOfWeek: 1,
385
+ months: [
386
+ '一月',
387
+ '二月',
388
+ '三月',
389
+ '四月',
390
+ '五月',
391
+ '六月',
392
+ '七月',
393
+ '八月',
394
+ '九月',
395
+ '十月',
396
+ '十一月',
397
+ '十二月',
398
+ ],
399
+ monthsShort: [
400
+ '1月',
401
+ '2月',
402
+ '3月',
403
+ '4月',
404
+ '5月',
405
+ '6月',
406
+ '7月',
407
+ '8月',
408
+ '9月',
409
+ '10月',
410
+ '11月',
411
+ '12月',
412
+ ],
413
+ weekdays: [
414
+ '星期日',
415
+ '星期一',
416
+ '星期二',
417
+ '星期三',
418
+ '星期四',
419
+ '星期五',
420
+ '星期六',
421
+ ],
422
+ weekdaysShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
423
+ weekdaysMin: ['日', '一', '二', '三', '四', '五', '六'],
424
+ am: '上午',
425
+ pm: '下午',
426
+ confirmText: '确认',
427
+ cancelText: '取消',
428
+ todayText: '今天',
429
+ selectDateTitle: '选择日期',
430
+ selectTimeTitle: '选择时间',
431
+ selectDateTimeTitle: '选择日期和时间',
432
+ selectRangeTitle: '选择日期范围',
433
+ };
434
+
435
+ export const jaLocale: LocaleData = {
436
+ code: 'ja',
437
+ isRTL: false,
438
+ firstDayOfWeek: 0,
439
+ months: [
440
+ '1月',
441
+ '2月',
442
+ '3月',
443
+ '4月',
444
+ '5月',
445
+ '6月',
446
+ '7月',
447
+ '8月',
448
+ '9月',
449
+ '10月',
450
+ '11月',
451
+ '12月',
452
+ ],
453
+ monthsShort: [
454
+ '1月',
455
+ '2月',
456
+ '3月',
457
+ '4月',
458
+ '5月',
459
+ '6月',
460
+ '7月',
461
+ '8月',
462
+ '9月',
463
+ '10月',
464
+ '11月',
465
+ '12月',
466
+ ],
467
+ weekdays: [
468
+ '日曜日',
469
+ '月曜日',
470
+ '火曜日',
471
+ '水曜日',
472
+ '木曜日',
473
+ '金曜日',
474
+ '土曜日',
475
+ ],
476
+ weekdaysShort: ['日', '月', '火', '水', '木', '金', '土'],
477
+ weekdaysMin: ['日', '月', '火', '水', '木', '金', '土'],
478
+ am: '午前',
479
+ pm: '午後',
480
+ confirmText: '確定',
481
+ cancelText: 'キャンセル',
482
+ todayText: '今日',
483
+ selectDateTitle: '日付を選択',
484
+ selectTimeTitle: '時間を選択',
485
+ selectDateTimeTitle: '日時を選択',
486
+ selectRangeTitle: '期間を選択',
487
+ };
488
+
489
+ export const BUILTIN_LOCALES: Record<string, LocaleData> = {
490
+ en: enLocale,
491
+ hi: hiLocale,
492
+ gu: guLocale,
493
+ es: esLocale,
494
+ fr: frLocale,
495
+ de: deLocale,
496
+ ar: arLocale,
497
+ zh: zhLocale,
498
+ ja: jaLocale,
499
+ };
@@ -0,0 +1,21 @@
1
+ export interface LocaleData {
2
+ code: string;
3
+ isRTL: boolean;
4
+ firstDayOfWeek: number; // 0 = Sunday, 1 = Monday
5
+ months: string[]; // 12 full month names
6
+ monthsShort: string[]; // 12 short month names
7
+ weekdays: string[]; // 7 full weekday names (Sun-Sat)
8
+ weekdaysShort: string[]; // 7 short weekday names (Sun-Sat)
9
+ weekdaysMin: string[]; // 7 min weekday names (e.g. S, M, T or Su, Mo)
10
+ am: string;
11
+ pm: string;
12
+ confirmText: string;
13
+ cancelText: string;
14
+ todayText: string;
15
+ selectDateTitle: string;
16
+ selectTimeTitle: string;
17
+ selectDateTimeTitle: string;
18
+ selectRangeTitle: string;
19
+ }
20
+
21
+ export type PartialLocaleData = Partial<LocaleData> & { code?: string };
@@ -0,0 +1,137 @@
1
+ import { useMemo } from 'react';
2
+ import { BUILTIN_LOCALES, enLocale } from './locales';
3
+ import type { LocaleData, PartialLocaleData } from './types';
4
+
5
+ export function getDeviceLocale(): string {
6
+ try {
7
+ if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
8
+ const resolved = Intl.DateTimeFormat().resolvedOptions().locale;
9
+ if (resolved) {
10
+ return resolved;
11
+ }
12
+ }
13
+ } catch {
14
+ // ignore
15
+ }
16
+ return 'en';
17
+ }
18
+
19
+ export function resolveLocale(
20
+ localeInput?: string | PartialLocaleData | null
21
+ ): LocaleData {
22
+ if (!localeInput) {
23
+ const devLocale = getDeviceLocale();
24
+ const langCode = devLocale.split('-')[0]?.toLowerCase() || 'en';
25
+ const base = BUILTIN_LOCALES[langCode] || enLocale;
26
+ return { ...base, code: devLocale };
27
+ }
28
+
29
+ if (typeof localeInput === 'string') {
30
+ const langCode = localeInput.split('-')[0]?.toLowerCase() || 'en';
31
+ const base =
32
+ BUILTIN_LOCALES[langCode] || BUILTIN_LOCALES[localeInput] || enLocale;
33
+ return { ...base, code: localeInput };
34
+ }
35
+
36
+ // It's a custom PartialLocaleData object
37
+ const langCode = localeInput.code?.split('-')[0]?.toLowerCase() || 'en';
38
+ const base = BUILTIN_LOCALES[langCode] || enLocale;
39
+
40
+ return {
41
+ ...base,
42
+ ...localeInput,
43
+ code: localeInput.code || base.code,
44
+ months: localeInput.months || base.months,
45
+ monthsShort: localeInput.monthsShort || base.monthsShort,
46
+ weekdays: localeInput.weekdays || base.weekdays,
47
+ weekdaysShort: localeInput.weekdaysShort || base.weekdaysShort,
48
+ weekdaysMin: localeInput.weekdaysMin || base.weekdaysMin,
49
+ };
50
+ }
51
+
52
+ export function useLocale(
53
+ localeInput?: string | PartialLocaleData | null
54
+ ): LocaleData {
55
+ return useMemo(() => resolveLocale(localeInput), [localeInput]);
56
+ }
57
+
58
+ /**
59
+ * Format a Date using a format string and LocaleData
60
+ * Tokens supported:
61
+ * YYYY - Full year (2026)
62
+ * YY - 2-digit year (26)
63
+ * MMMM - Full month name (November / नवंबर)
64
+ * MMM - Short month name (Nov / नव)
65
+ * MM - 2-digit month (01-12)
66
+ * M - 1-digit month (1-12)
67
+ * DD - 2-digit day of month (01-31)
68
+ * D - 1-digit day of month (1-31)
69
+ * dddd - Full weekday name (Thursday / गुरुवार)
70
+ * ddd - Short weekday name (Thu / गुरु)
71
+ * dd - Min weekday name (Th / गु)
72
+ * HH - 24-hour padded (00-23)
73
+ * H - 24-hour unpadded (0-23)
74
+ * hh - 12-hour padded (01-12)
75
+ * h - 12-hour unpadded (1-12)
76
+ * mm - Minutes padded (00-59)
77
+ * m - Minutes unpadded (0-59)
78
+ * ss - Seconds padded (00-59)
79
+ * s - Seconds unpadded (0-59)
80
+ * A - Uppercase AM/PM from locale (AM / PM / पूर्वाह्न)
81
+ * a - Lowercase am/pm
82
+ */
83
+ export function formatLocalized(
84
+ date: Date,
85
+ formatStr: string = 'YYYY-MM-DD',
86
+ locale: LocaleData = enLocale
87
+ ): string {
88
+ if (isNaN(date.getTime())) {
89
+ return '';
90
+ }
91
+
92
+ const year = date.getFullYear();
93
+ const month = date.getMonth(); // 0-11
94
+ const day = date.getDate();
95
+ const dayOfWeek = date.getDay(); // 0-6
96
+ const hours24 = date.getHours();
97
+ const hours12 = hours24 % 12 === 0 ? 12 : hours24 % 12;
98
+ const minutes = date.getMinutes();
99
+ const seconds = date.getSeconds();
100
+ const isPM = hours24 >= 12;
101
+ const ampm = isPM ? locale.pm : locale.am;
102
+
103
+ const pad = (n: number) => (n < 10 ? `0${n}` : `${n}`);
104
+
105
+ const replacements: Record<string, string> = {
106
+ YYYY: String(year),
107
+ YY: String(year).slice(-2),
108
+ MMMM: locale.months[month] || '',
109
+ MMM: locale.monthsShort[month] || '',
110
+ MM: pad(month + 1),
111
+ M: String(month + 1),
112
+ DD: pad(day),
113
+ D: String(day),
114
+ dddd: locale.weekdays[dayOfWeek] || '',
115
+ ddd: locale.weekdaysShort[dayOfWeek] || '',
116
+ dd: locale.weekdaysMin[dayOfWeek] || '',
117
+ HH: pad(hours24),
118
+ H: String(hours24),
119
+ hh: pad(hours12),
120
+ h: String(hours12),
121
+ mm: pad(minutes),
122
+ m: String(minutes),
123
+ ss: pad(seconds),
124
+ s: String(seconds),
125
+ A: ampm,
126
+ a: ampm.toLowerCase(),
127
+ };
128
+
129
+ const regex =
130
+ /(\[[^\]]*\]|YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|dd|HH|H|hh|h|mm|m|ss|s|A|a)/g;
131
+ return formatStr.replace(regex, (match) => {
132
+ if (match.startsWith('[') && match.endsWith(']')) {
133
+ return match.slice(1, -1);
134
+ }
135
+ return replacements[match] ?? match;
136
+ });
137
+ }