react-native-paper-dates 0.4.5 → 0.6.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 (249) hide show
  1. package/README.md +80 -16
  2. package/lib/commonjs/Date/AnimatedCrossView.js +9 -8
  3. package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
  4. package/lib/commonjs/Date/AutoSizer.js +6 -5
  5. package/lib/commonjs/Date/AutoSizer.js.map +1 -1
  6. package/lib/commonjs/Date/Calendar.js +46 -39
  7. package/lib/commonjs/Date/Calendar.js.map +1 -1
  8. package/lib/commonjs/Date/CalendarEdit.js +35 -110
  9. package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
  10. package/lib/commonjs/Date/CalendarHeader.js +19 -12
  11. package/lib/commonjs/Date/CalendarHeader.js.map +1 -1
  12. package/lib/commonjs/Date/DatePickerInput.js +93 -20
  13. package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
  14. package/lib/commonjs/Date/DatePickerModal.js +4 -6
  15. package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
  16. package/lib/commonjs/Date/DatePickerModalContent.js +9 -5
  17. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  18. package/lib/commonjs/Date/DatePickerModalContentHeader.js +42 -34
  19. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  20. package/lib/commonjs/Date/DatePickerModalHeader.js +14 -6
  21. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  22. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +6 -5
  23. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
  24. package/lib/commonjs/Date/DateRangeInput.js +23 -24
  25. package/lib/commonjs/Date/DateRangeInput.js.map +1 -1
  26. package/lib/commonjs/Date/Day.js +7 -3
  27. package/lib/commonjs/Date/Day.js.map +1 -1
  28. package/lib/commonjs/Date/DayName.js +6 -5
  29. package/lib/commonjs/Date/DayName.js.map +1 -1
  30. package/lib/commonjs/Date/DayNames.js +7 -6
  31. package/lib/commonjs/Date/DayNames.js.map +1 -1
  32. package/lib/commonjs/Date/DayRange.js +9 -8
  33. package/lib/commonjs/Date/DayRange.js.map +1 -1
  34. package/lib/commonjs/Date/Month.js +57 -49
  35. package/lib/commonjs/Date/Month.js.map +1 -1
  36. package/lib/commonjs/Date/Swiper.js +35 -29
  37. package/lib/commonjs/Date/Swiper.js.map +1 -1
  38. package/lib/commonjs/Date/Swiper.native.js +29 -23
  39. package/lib/commonjs/Date/Swiper.native.js.map +1 -1
  40. package/lib/commonjs/Date/SwiperUtils.js +7 -6
  41. package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
  42. package/lib/commonjs/Date/YearPicker.js +28 -20
  43. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  44. package/lib/commonjs/Date/dateUtils.js +107 -38
  45. package/lib/commonjs/Date/dateUtils.js.map +1 -1
  46. package/lib/commonjs/Date/inputUtils.js +84 -0
  47. package/lib/commonjs/Date/inputUtils.js.map +1 -0
  48. package/lib/commonjs/TextInputMask.js +11 -10
  49. package/lib/commonjs/TextInputMask.js.map +1 -1
  50. package/lib/commonjs/Time/AmPmSwitcher.js +37 -19
  51. package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
  52. package/lib/commonjs/Time/AnalogClock.js +28 -26
  53. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  54. package/lib/commonjs/Time/AnalogClockHours.js +18 -12
  55. package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
  56. package/lib/commonjs/Time/AnalogClockMinutes.js +9 -8
  57. package/lib/commonjs/Time/AnalogClockMinutes.js.map +1 -1
  58. package/lib/commonjs/Time/AnimatedClockSwitcher.js +8 -7
  59. package/lib/commonjs/Time/AnimatedClockSwitcher.js.map +1 -1
  60. package/lib/commonjs/Time/TimeInput.js +16 -12
  61. package/lib/commonjs/Time/TimeInput.js.map +1 -1
  62. package/lib/commonjs/Time/TimeInputs.js +12 -11
  63. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  64. package/lib/commonjs/Time/TimePicker.js +39 -17
  65. package/lib/commonjs/Time/TimePicker.js.map +1 -1
  66. package/lib/commonjs/Time/TimePickerModal.js +19 -15
  67. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  68. package/lib/commonjs/Time/timeUtils.js +17 -9
  69. package/lib/commonjs/Time/timeUtils.js.map +1 -1
  70. package/lib/commonjs/index.js +66 -5
  71. package/lib/commonjs/index.js.map +1 -1
  72. package/lib/commonjs/translations/en.js +20 -0
  73. package/lib/commonjs/translations/en.js.map +1 -0
  74. package/lib/commonjs/translations/enGB.js +20 -0
  75. package/lib/commonjs/translations/enGB.js.map +1 -0
  76. package/lib/commonjs/translations/nl.js +20 -0
  77. package/lib/commonjs/translations/nl.js.map +1 -0
  78. package/lib/commonjs/translations/pl.js +20 -0
  79. package/lib/commonjs/translations/pl.js.map +1 -0
  80. package/lib/commonjs/translations/utils.js +31 -0
  81. package/lib/commonjs/translations/utils.js.map +1 -0
  82. package/lib/commonjs/utils.js +19 -9
  83. package/lib/commonjs/utils.js.map +1 -1
  84. package/lib/module/Date/AnimatedCrossView.js +7 -6
  85. package/lib/module/Date/AnimatedCrossView.js.map +1 -1
  86. package/lib/module/Date/AutoSizer.js +4 -3
  87. package/lib/module/Date/AutoSizer.js.map +1 -1
  88. package/lib/module/Date/Calendar.js +46 -39
  89. package/lib/module/Date/Calendar.js.map +1 -1
  90. package/lib/module/Date/CalendarEdit.js +31 -103
  91. package/lib/module/Date/CalendarEdit.js.map +1 -1
  92. package/lib/module/Date/CalendarHeader.js +16 -9
  93. package/lib/module/Date/CalendarHeader.js.map +1 -1
  94. package/lib/module/Date/DatePickerInput.js +88 -18
  95. package/lib/module/Date/DatePickerInput.js.map +1 -1
  96. package/lib/module/Date/DatePickerModal.js +3 -5
  97. package/lib/module/Date/DatePickerModal.js.map +1 -1
  98. package/lib/module/Date/DatePickerModalContent.js +7 -3
  99. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  100. package/lib/module/Date/DatePickerModalContentHeader.js +37 -30
  101. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  102. package/lib/module/Date/DatePickerModalHeader.js +11 -4
  103. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  104. package/lib/module/Date/DatePickerModalHeaderBackground.js +4 -3
  105. package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
  106. package/lib/module/Date/DateRangeInput.js +22 -22
  107. package/lib/module/Date/DateRangeInput.js.map +1 -1
  108. package/lib/module/Date/Day.js +5 -1
  109. package/lib/module/Date/Day.js.map +1 -1
  110. package/lib/module/Date/DayName.js +4 -3
  111. package/lib/module/Date/DayName.js.map +1 -1
  112. package/lib/module/Date/DayNames.js +5 -4
  113. package/lib/module/Date/DayNames.js.map +1 -1
  114. package/lib/module/Date/DayRange.js +7 -6
  115. package/lib/module/Date/DayRange.js.map +1 -1
  116. package/lib/module/Date/Month.js +52 -45
  117. package/lib/module/Date/Month.js.map +1 -1
  118. package/lib/module/Date/Swiper.js +32 -26
  119. package/lib/module/Date/Swiper.js.map +1 -1
  120. package/lib/module/Date/Swiper.native.js +27 -21
  121. package/lib/module/Date/Swiper.native.js.map +1 -1
  122. package/lib/module/Date/SwiperUtils.js +5 -4
  123. package/lib/module/Date/SwiperUtils.js.map +1 -1
  124. package/lib/module/Date/YearPicker.js +26 -18
  125. package/lib/module/Date/YearPicker.js.map +1 -1
  126. package/lib/module/Date/dateUtils.js +79 -30
  127. package/lib/module/Date/dateUtils.js.map +1 -1
  128. package/lib/module/Date/inputUtils.js +70 -0
  129. package/lib/module/Date/inputUtils.js.map +1 -0
  130. package/lib/module/TextInputMask.js +9 -8
  131. package/lib/module/TextInputMask.js.map +1 -1
  132. package/lib/module/Time/AmPmSwitcher.js +35 -18
  133. package/lib/module/Time/AmPmSwitcher.js.map +1 -1
  134. package/lib/module/Time/AnalogClock.js +20 -17
  135. package/lib/module/Time/AnalogClock.js.map +1 -1
  136. package/lib/module/Time/AnalogClockHours.js +15 -10
  137. package/lib/module/Time/AnalogClockHours.js.map +1 -1
  138. package/lib/module/Time/AnalogClockMinutes.js +6 -5
  139. package/lib/module/Time/AnalogClockMinutes.js.map +1 -1
  140. package/lib/module/Time/AnimatedClockSwitcher.js +6 -5
  141. package/lib/module/Time/AnimatedClockSwitcher.js.map +1 -1
  142. package/lib/module/Time/TimeInput.js +14 -10
  143. package/lib/module/Time/TimeInput.js.map +1 -1
  144. package/lib/module/Time/TimeInputs.js +10 -9
  145. package/lib/module/Time/TimeInputs.js.map +1 -1
  146. package/lib/module/Time/TimePicker.js +34 -13
  147. package/lib/module/Time/TimePicker.js.map +1 -1
  148. package/lib/module/Time/TimePickerModal.js +17 -13
  149. package/lib/module/Time/TimePickerModal.js.map +1 -1
  150. package/lib/module/Time/timeUtils.js +8 -2
  151. package/lib/module/Time/timeUtils.js.map +1 -1
  152. package/lib/module/index.js +6 -0
  153. package/lib/module/index.js.map +1 -1
  154. package/lib/module/translations/en.js +13 -0
  155. package/lib/module/translations/en.js.map +1 -0
  156. package/lib/module/translations/enGB.js +13 -0
  157. package/lib/module/translations/enGB.js.map +1 -0
  158. package/lib/module/translations/nl.js +13 -0
  159. package/lib/module/translations/nl.js.map +1 -0
  160. package/lib/module/translations/pl.js +13 -0
  161. package/lib/module/translations/pl.js.map +1 -0
  162. package/lib/module/translations/utils.js +22 -0
  163. package/lib/module/translations/utils.js.map +1 -0
  164. package/lib/module/utils.js +11 -5
  165. package/lib/module/utils.js.map +1 -1
  166. package/lib/typescript/{src/Date → Date}/AnimatedCrossView.d.ts +0 -0
  167. package/lib/typescript/{src/Date → Date}/AutoSizer.d.ts +0 -0
  168. package/lib/typescript/{src/Date → Date}/Calendar.d.ts +5 -3
  169. package/lib/typescript/{src/Date → Date}/CalendarEdit.d.ts +4 -3
  170. package/lib/typescript/{src/Date → Date}/CalendarHeader.d.ts +1 -1
  171. package/lib/typescript/Date/DatePickerInput.d.ts +18 -0
  172. package/lib/typescript/{src/Date → Date}/DatePickerModal.d.ts +0 -0
  173. package/lib/typescript/{src/Date → Date}/DatePickerModalContent.d.ts +2 -0
  174. package/lib/typescript/{src/Date → Date}/DatePickerModalContentHeader.d.ts +4 -4
  175. package/lib/typescript/{src/Date → Date}/DatePickerModalHeader.d.ts +1 -0
  176. package/lib/typescript/{src/Date → Date}/DatePickerModalHeaderBackground.d.ts +0 -0
  177. package/lib/typescript/Date/DateRangeInput.d.ts +3 -0
  178. package/lib/typescript/{src/Date → Date}/Day.d.ts +0 -0
  179. package/lib/typescript/{src/Date → Date}/DayName.d.ts +0 -0
  180. package/lib/typescript/{src/Date → Date}/DayNames.d.ts +0 -0
  181. package/lib/typescript/{src/Date → Date}/DayRange.d.ts +0 -0
  182. package/lib/typescript/{src/Date → Date}/Month.d.ts +0 -0
  183. package/lib/typescript/{src/Date → Date}/Swiper.d.ts +0 -0
  184. package/lib/typescript/{src/Date → Date}/Swiper.native.d.ts +0 -0
  185. package/lib/typescript/{src/Date → Date}/SwiperUtils.d.ts +1 -1
  186. package/lib/typescript/{src/Date → Date}/Week.d.ts +0 -0
  187. package/lib/typescript/{src/Date → Date}/YearPicker.d.ts +0 -0
  188. package/lib/typescript/{src/Date → Date}/dateUtils.d.ts +15 -0
  189. package/lib/typescript/{src/Date → Date}/dateUtils.test.d.ts +0 -0
  190. package/lib/typescript/Date/inputUtils.d.ts +14 -0
  191. package/lib/typescript/TextInputMask.d.ts +11 -0
  192. package/lib/typescript/Time/AmPmSwitcher.d.ts +4 -0
  193. package/lib/typescript/{src/Time → Time}/AnalogClock.d.ts +1 -2
  194. package/lib/typescript/{src/Time → Time}/AnalogClockHours.d.ts +0 -0
  195. package/lib/typescript/{src/Time → Time}/AnalogClockMinutes.d.ts +0 -0
  196. package/lib/typescript/{src/Time → Time}/AnimatedClockSwitcher.d.ts +0 -0
  197. package/lib/typescript/{src/Time → Time}/TimeInput.d.ts +0 -0
  198. package/lib/typescript/{src/Time → Time}/TimeInputs.d.ts +1 -1
  199. package/lib/typescript/{src/Time → Time}/TimePicker.d.ts +4 -0
  200. package/lib/typescript/{src/Time → Time}/TimePickerModal.d.ts +1 -1
  201. package/lib/typescript/{src/Time → Time}/timeUtils.d.ts +1 -0
  202. package/lib/typescript/index.d.ts +13 -0
  203. package/lib/typescript/translations/en.d.ts +3 -0
  204. package/lib/typescript/translations/enGB.d.ts +3 -0
  205. package/lib/typescript/translations/nl.d.ts +3 -0
  206. package/lib/typescript/translations/pl.d.ts +3 -0
  207. package/lib/typescript/translations/utils.d.ts +13 -0
  208. package/lib/typescript/utils.d.ts +58 -0
  209. package/package.json +39 -31
  210. package/src/.DS_Store +0 -0
  211. package/src/Date/Calendar.tsx +14 -13
  212. package/src/Date/CalendarEdit.tsx +21 -120
  213. package/src/Date/CalendarHeader.tsx +15 -3
  214. package/src/Date/DatePickerInput.tsx +103 -25
  215. package/src/Date/DatePickerModal.tsx +3 -8
  216. package/src/Date/DatePickerModalContent.tsx +6 -0
  217. package/src/Date/DatePickerModalContentHeader.tsx +21 -12
  218. package/src/Date/DatePickerModalHeader.tsx +13 -2
  219. package/src/Date/DateRangeInput.tsx +26 -17
  220. package/src/Date/Day.tsx +4 -0
  221. package/src/Date/Month.tsx +18 -44
  222. package/src/Date/Swiper.tsx +1 -0
  223. package/src/Date/SwiperUtils.ts +1 -1
  224. package/src/Date/YearPicker.tsx +4 -1
  225. package/src/Date/dateUtils.tsx +71 -10
  226. package/src/Date/inputUtils.ts +94 -0
  227. package/src/TextInputMask.tsx +10 -3
  228. package/src/Time/AmPmSwitcher.tsx +20 -11
  229. package/src/Time/AnalogClock.tsx +10 -18
  230. package/src/Time/AnalogClockHours.tsx +15 -6
  231. package/src/Time/AnalogClockMinutes.tsx +5 -2
  232. package/src/Time/TimeInput.tsx +3 -0
  233. package/src/Time/TimeInputs.tsx +1 -5
  234. package/src/Time/TimePicker.tsx +46 -23
  235. package/src/Time/TimePickerModal.tsx +4 -1
  236. package/src/Time/timeUtils.ts +7 -1
  237. package/src/index.tsx +7 -0
  238. package/src/translations/en.ts +15 -0
  239. package/src/translations/enGB.ts +15 -0
  240. package/src/translations/nl.ts +15 -0
  241. package/src/translations/pl.ts +15 -0
  242. package/src/translations/utils.ts +42 -0
  243. package/src/utils.ts +13 -5
  244. package/lib/typescript/src/Date/DatePickerInput.d.ts +0 -1
  245. package/lib/typescript/src/Date/DateRangeInput.d.ts +0 -1
  246. package/lib/typescript/src/TextInputMask.d.ts +0 -3
  247. package/lib/typescript/src/Time/AmPmSwitcher.d.ts +0 -4
  248. package/lib/typescript/src/index.d.ts +0 -6
  249. package/lib/typescript/src/utils.d.ts +0 -7
@@ -1,3 +1,4 @@
1
+ import type { ValidRangeType } from './Calendar';
1
2
  export declare type DisableWeekDaysType = number[];
2
3
  export declare function showWeekDay(dayIndex: number, disableWeekDays?: DisableWeekDaysType): boolean;
3
4
  export declare function dateToUnix(d: Date): number;
@@ -10,6 +11,12 @@ export declare function getFirstDayOfMonth({ year, month, }: {
10
11
  year: number;
11
12
  month: number;
12
13
  }): number;
14
+ export declare function useRangeChecker(validRange: ValidRangeType | undefined): {
15
+ isDisabled: (day: Date) => boolean;
16
+ isWithinValidRange: (day: Date) => boolean;
17
+ validStart: Date | undefined;
18
+ validEnd: Date | undefined;
19
+ };
13
20
  export declare function areDatesOnSameDay(a: Date, b?: Date | null | undefined): boolean;
14
21
  export declare function isDateBetween(date: Date, { startDate, endDate, }: {
15
22
  startDate?: Date | null | undefined;
@@ -37,4 +44,12 @@ export declare function getGridCount(index: number): number;
37
44
  export declare function getGridCountForDate(date: Date): number;
38
45
  export declare function getRealIndex(index: number): number;
39
46
  export declare function getInitialIndex(date: Date | undefined): number;
47
+ export declare function useInputFormatter({ locale }: {
48
+ locale: string | undefined;
49
+ }): Intl.DateTimeFormat;
50
+ export declare function getStartOfDay(d: Date): Date;
51
+ export declare function getEndOfDay(d: Date): Date;
52
+ export declare function useInputFormat({ formatter, }: {
53
+ formatter: Intl.DateTimeFormat;
54
+ }): string;
40
55
  export declare function differenceInMonths(firstDate: Date, secondDate: Date): number;
@@ -0,0 +1,14 @@
1
+ import type { ValidRangeType } from './Calendar';
2
+ export default function useDateInput({ locale, value, validRange, inputMode, onChange, }: {
3
+ onChange: (d: Date) => void;
4
+ locale: undefined | string;
5
+ value: Date | undefined;
6
+ validRange: ValidRangeType | undefined;
7
+ inputMode: 'start' | 'end';
8
+ }): {
9
+ onChange: (d: Date) => void;
10
+ error: string | null;
11
+ formattedValue: string;
12
+ onChangeText: (date: string) => void;
13
+ inputFormat: string;
14
+ };
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ declare const _default: React.ForwardRefExoticComponent<Pick<((Pick<import("react-native-paper/lib/typescript/components/TextInput/TextInput").TextInputProps, "allowFontScaling" | "autoCapitalize" | "autoCorrect" | "autoFocus" | "blurOnSubmit" | "caretHidden" | "contextMenuHidden" | "defaultValue" | "editable" | "keyboardType" | "maxLength" | "multiline" | "onBlur" | "onChange" | "onChangeText" | "onContentSizeChange" | "onEndEditing" | "onPressIn" | "onPressOut" | "onFocus" | "onSelectionChange" | "onSubmitEditing" | "onTextInput" | "onScroll" | "onKeyPress" | "placeholder" | "placeholderTextColor" | "returnKeyType" | "secureTextEntry" | "selectTextOnFocus" | "selection" | "selectionColor" | "style" | "textAlign" | "testID" | "inputAccessoryViewID" | "value" | "maxFontSizeMultiplier" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "clearButtonMode" | "clearTextOnFocus" | "dataDetectorTypes" | "enablesReturnKeyAutomatically" | "keyboardAppearance" | "passwordRules" | "rejectResponderTermination" | "selectionState" | "spellCheck" | "textContentType" | "scrollEnabled" | "importantForAutofill" | "disableFullscreenUI" | "inlineImageLeft" | "inlineImagePadding" | "numberOfLines" | "returnKeyLabel" | "textBreakStrategy" | "underlineColorAndroid" | "textAlignVertical" | "showSoftInputOnFocus" | "ref" | "label" | "key" | "render" | "left" | "right" | "disabled" | "mode" | "error" | "autoCompleteType" | "underlineColor" | "activeUnderlineColor" | "outlineColor" | "activeOutlineColor" | "dense"> & {
3
+ theme?: import("@callstack/react-theme-provider").$DeepPartial<ReactNativePaper.Theme> | undefined;
4
+ }) | (Pick<import("react-native-paper/lib/typescript/components/TextInput/TextInput").TextInputProps, "allowFontScaling" | "autoCapitalize" | "autoCorrect" | "autoFocus" | "blurOnSubmit" | "caretHidden" | "contextMenuHidden" | "defaultValue" | "editable" | "keyboardType" | "maxLength" | "multiline" | "onBlur" | "onChange" | "onChangeText" | "onContentSizeChange" | "onEndEditing" | "onPressIn" | "onPressOut" | "onFocus" | "onSelectionChange" | "onSubmitEditing" | "onTextInput" | "onScroll" | "onKeyPress" | "placeholder" | "placeholderTextColor" | "returnKeyType" | "secureTextEntry" | "selectTextOnFocus" | "selection" | "selectionColor" | "style" | "textAlign" | "testID" | "inputAccessoryViewID" | "value" | "maxFontSizeMultiplier" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "clearButtonMode" | "clearTextOnFocus" | "dataDetectorTypes" | "enablesReturnKeyAutomatically" | "keyboardAppearance" | "passwordRules" | "rejectResponderTermination" | "selectionState" | "spellCheck" | "textContentType" | "scrollEnabled" | "importantForAutofill" | "disableFullscreenUI" | "inlineImageLeft" | "inlineImagePadding" | "numberOfLines" | "returnKeyLabel" | "textBreakStrategy" | "underlineColorAndroid" | "textAlignVertical" | "showSoftInputOnFocus" | "ref" | "label" | "key" | "render" | "left" | "right" | "disabled" | "mode" | "error" | "autoCompleteType" | "underlineColor" | "activeUnderlineColor" | "outlineColor" | "activeOutlineColor" | "dense"> & {
5
+ theme?: import("@callstack/react-theme-provider").$DeepPartial<ReactNativePaper.Theme> | undefined;
6
+ } & {
7
+ children?: React.ReactNode;
8
+ })) & {
9
+ mask: string;
10
+ }, "allowFontScaling" | "autoCapitalize" | "autoCorrect" | "autoFocus" | "blurOnSubmit" | "caretHidden" | "contextMenuHidden" | "defaultValue" | "editable" | "keyboardType" | "maxLength" | "multiline" | "onBlur" | "onChange" | "onChangeText" | "onContentSizeChange" | "onEndEditing" | "onPressIn" | "onPressOut" | "onFocus" | "onSelectionChange" | "onSubmitEditing" | "onTextInput" | "onScroll" | "onKeyPress" | "placeholder" | "placeholderTextColor" | "returnKeyType" | "secureTextEntry" | "selectTextOnFocus" | "selection" | "selectionColor" | "style" | "textAlign" | "testID" | "inputAccessoryViewID" | "value" | "maxFontSizeMultiplier" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "clearButtonMode" | "clearTextOnFocus" | "dataDetectorTypes" | "enablesReturnKeyAutomatically" | "keyboardAppearance" | "passwordRules" | "rejectResponderTermination" | "selectionState" | "spellCheck" | "textContentType" | "scrollEnabled" | "importantForAutofill" | "disableFullscreenUI" | "inlineImageLeft" | "inlineImagePadding" | "numberOfLines" | "returnKeyLabel" | "textBreakStrategy" | "underlineColorAndroid" | "textAlignVertical" | "showSoftInputOnFocus" | "label" | "key" | "render" | "left" | "right" | "disabled" | "mode" | "error" | "autoCompleteType" | "underlineColor" | "activeUnderlineColor" | "outlineColor" | "activeOutlineColor" | "dense" | "mask" | "theme"> & React.RefAttributes<unknown>>;
11
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export default function AmPmSwitcher({ onChange, hours, }: {
2
+ hours: number;
3
+ onChange: (newHours: number) => any;
4
+ }): JSX.Element;
@@ -1,12 +1,11 @@
1
1
  import { PossibleClockTypes } from './timeUtils';
2
2
  import * as React from 'react';
3
- export declare const circleSize = 215;
4
3
  declare function AnalogClock({ hours, minutes, focused, is24Hour, onChange, }: {
5
4
  hours: number;
6
5
  minutes: number;
7
6
  focused: PossibleClockTypes;
8
7
  is24Hour: boolean;
9
- onChange: ({ hours, minutes, focused, }: {
8
+ onChange: (hoursMinutesAndFocused: {
10
9
  hours: number;
11
10
  minutes: number;
12
11
  focused?: undefined | PossibleClockTypes;
File without changes
@@ -6,7 +6,7 @@ declare function TimeInputs({ hours, minutes, onFocusInput, focused, inputType,
6
6
  hours: number;
7
7
  minutes: number;
8
8
  onFocusInput: (type: PossibleClockTypes) => any;
9
- onChange: ({ hours, minutes, focused, }: {
9
+ onChange: (hoursMinutesAndFocused: {
10
10
  hours: number;
11
11
  minutes: number;
12
12
  focused?: undefined | PossibleClockTypes;
@@ -1,5 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { PossibleClockTypes, PossibleInputTypes } from './timeUtils';
3
+ export declare const DisplayModeContext: React.Context<{
4
+ mode: 'AM' | 'PM' | undefined;
5
+ setMode: React.Dispatch<React.SetStateAction<'AM' | 'PM' | undefined>>;
6
+ }>;
3
7
  declare type onChangeFunc = ({ hours, minutes, focused, }: {
4
8
  hours: number;
5
9
  minutes: number;
@@ -8,7 +8,7 @@ export declare function TimePickerModal({ visible, onDismiss, onConfirm, hours,
8
8
  minutes?: number | undefined;
9
9
  visible: boolean | undefined;
10
10
  onDismiss: () => any;
11
- onConfirm: ({ hours, minutes }: {
11
+ onConfirm: (hoursAndMinutes: {
12
12
  hours: number;
13
13
  minutes: number;
14
14
  }) => any;
@@ -1,3 +1,4 @@
1
+ export declare const circleSize = 215;
1
2
  export declare type PossibleHourTypes = 'am' | 'pm';
2
3
  export declare type HourTypeMap = {
3
4
  [hourType in PossibleHourTypes]: PossibleHourTypes;
@@ -0,0 +1,13 @@
1
+ export { default as Calendar } from './Date/Calendar';
2
+ export { default as DatePickerModal } from './Date/DatePickerModal';
3
+ export * from './Date/DatePickerModal';
4
+ export { default as DatePickerModalContent } from './Date/DatePickerModalContent';
5
+ export { default as TimePickerModal } from './Time/TimePickerModal';
6
+ export { default as TimePicker } from './Time/TimePicker';
7
+ export { default as DatePickerInput } from './Date/DatePickerInput';
8
+ export type { TranslationsType } from './translations/utils';
9
+ export { registerTranslation, getTranslation } from './translations/utils';
10
+ export { default as nl } from './translations/nl';
11
+ export { default as en } from './translations/en';
12
+ export { default as pl } from './translations/pl';
13
+ export { default as enGB } from './translations/enGB';
@@ -0,0 +1,3 @@
1
+ import type { TranslationsType } from './utils';
2
+ declare const en: TranslationsType;
3
+ export default en;
@@ -0,0 +1,3 @@
1
+ import type { TranslationsType } from './utils';
2
+ declare const enGB: TranslationsType;
3
+ export default enGB;
@@ -0,0 +1,3 @@
1
+ import type { TranslationsType } from './utils';
2
+ declare const nl: TranslationsType;
3
+ export default nl;
@@ -0,0 +1,3 @@
1
+ import type { TranslationsType } from './utils';
2
+ declare const pl: TranslationsType;
3
+ export default pl;
@@ -0,0 +1,13 @@
1
+ export declare type TranslationsType = {
2
+ selectSingle: string;
3
+ selectMultiple: string;
4
+ selectRange: string;
5
+ save: string;
6
+ notAccordingToDateFormat: (inputFormat: string) => string;
7
+ mustBeHigherThan: string;
8
+ mustBeLowerThan: string;
9
+ mustBeBetween: string;
10
+ dateIsDisabled: string;
11
+ };
12
+ export declare function getTranslation(locale: string | undefined, key: keyof TranslationsType, fallback?: any): any;
13
+ export declare function registerTranslation(locale: string, translations: TranslationsType): void;
@@ -0,0 +1,58 @@
1
+ import * as React from 'react';
2
+ import Color from 'color';
3
+ export declare function useLatest<T>(value: T): React.MutableRefObject<T>;
4
+ export declare function useHeaderBackgroundColor(): string;
5
+ export declare function useHeaderColorIsLight(): boolean;
6
+ export declare function useHeaderTextColor(): "#fff" | "#000";
7
+ export declare function useTextColorOnPrimary(): "#fff" | "#000";
8
+ export declare function range(start: number, end: number): number[];
9
+ export declare function lightenBy(color: Color, ratio: number): Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | any | ArrayLike<number> | {
10
+ [key: string]: any;
11
+ }> | ArrayLike<number> | {
12
+ [key: string]: any;
13
+ }> | ArrayLike<number> | {
14
+ [key: string]: any;
15
+ }> | ArrayLike<number> | {
16
+ [key: string]: any;
17
+ }> | ArrayLike<number> | {
18
+ [key: string]: any;
19
+ }> | ArrayLike<number> | {
20
+ [key: string]: any;
21
+ }> | ArrayLike<number> | {
22
+ [key: string]: any;
23
+ }> | ArrayLike<number> | {
24
+ [key: string]: any;
25
+ }> | ArrayLike<number> | {
26
+ [key: string]: any;
27
+ }> | ArrayLike<number> | {
28
+ [key: string]: any;
29
+ }> | ArrayLike<number> | {
30
+ [key: string]: any;
31
+ }> | ArrayLike<number> | {
32
+ [key: string]: any;
33
+ }>;
34
+ export declare function darkenBy(color: Color, ratio: number): Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | any | ArrayLike<number> | {
35
+ [key: string]: any;
36
+ }> | ArrayLike<number> | {
37
+ [key: string]: any;
38
+ }> | ArrayLike<number> | {
39
+ [key: string]: any;
40
+ }> | ArrayLike<number> | {
41
+ [key: string]: any;
42
+ }> | ArrayLike<number> | {
43
+ [key: string]: any;
44
+ }> | ArrayLike<number> | {
45
+ [key: string]: any;
46
+ }> | ArrayLike<number> | {
47
+ [key: string]: any;
48
+ }> | ArrayLike<number> | {
49
+ [key: string]: any;
50
+ }> | ArrayLike<number> | {
51
+ [key: string]: any;
52
+ }> | ArrayLike<number> | {
53
+ [key: string]: any;
54
+ }> | ArrayLike<number> | {
55
+ [key: string]: any;
56
+ }> | ArrayLike<number> | {
57
+ [key: string]: any;
58
+ }>;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "react-native-paper-dates",
3
- "version": "0.4.5",
3
+ "version": "0.6.0",
4
4
  "description": "Performant Date Picker for React Native Paper",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
- "types": "lib/typescript/src/index.d.ts",
7
+ "types": "lib/typescript/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
@@ -15,6 +15,8 @@
15
15
  "cpp",
16
16
  "react-native-paper-dates.podspec",
17
17
  "!lib/typescript/example",
18
+ "!android/build",
19
+ "!ios/build",
18
20
  "!**/__tests__",
19
21
  "!**/__fixtures__",
20
22
  "!**/__mocks__"
@@ -23,9 +25,8 @@
23
25
  "test": "jest",
24
26
  "typescript": "tsc --noEmit",
25
27
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
26
- "build": "bob build",
27
28
  "prepare": "bob build",
28
- "release": "bob build && dotenv release-it --",
29
+ "release": "release-it",
29
30
  "example": "yarn --cwd example",
30
31
  "pods": "cd example && pod-install --quiet",
31
32
  "bootstrap": "yarn example && yarn && yarn pods"
@@ -42,34 +43,31 @@
42
43
  "url": "https://github.com/web-ridge/react-native-paper-dates/issues"
43
44
  },
44
45
  "homepage": "https://github.com/web-ridge/react-native-paper-dates#readme",
46
+ "publishConfig": {
47
+ "registry": "https://registry.npmjs.org/"
48
+ },
45
49
  "devDependencies": {
46
- "@commitlint/config-conventional": "^8.3.4",
47
- "@react-native-community/bob": "^0.16.2",
48
- "@react-native-community/eslint-config": "^2.0.0",
50
+ "@commitlint/config-conventional": "^11.0.0",
51
+ "@react-native-community/eslint-config": "^3.0.1",
49
52
  "@release-it/conventional-changelog": "^2.0.0",
50
- "@types/color": "^3.0.1",
51
- "@types/jest": "^26.0.0",
52
- "@types/react": "^16.9.19",
53
- "@types/react-dom": "^16.9.8",
54
- "@types/react-native": "0.63.40",
55
- "@types/react-native-vector-icons": "^6.4.6",
56
- "color": "^3.1.2",
57
- "commitlint": "^8.3.5",
58
- "dotenv-cli": "^4.0.0",
59
- "eslint": "^7.2.0",
60
- "eslint-config-prettier": "^6.11.0",
61
- "eslint-plugin-prettier": "^3.1.3",
53
+ "@types/color": "^3.0.2",
54
+ "@types/jest": "^26.0.24",
55
+ "@types/react": "^16.14.20",
56
+ "@types/react-native": "^0.66.1",
57
+ "commitlint": "^11.0.0",
58
+ "eslint": "^7.32.0",
59
+ "eslint-config-prettier": "^8.3.0",
60
+ "eslint-plugin-prettier": "^4.0.0",
62
61
  "husky": "^4.2.5",
63
62
  "jest": "^26.0.1",
64
- "pod-install": "^0.1.0",
65
- "prettier": "^2.0.5",
66
- "react": "^17.0.1",
67
- "react-dom": "^17.0.1",
68
- "react-native": "0.63.2",
69
- "react-native-paper": "^4.7.2",
70
- "react-native-web": "^0.15.5",
71
- "release-it": "^14.2.2",
72
- "typescript": "^4.1.0"
63
+ "pod-install": "^0.1.28",
64
+ "prettier": "^2.4.1",
65
+ "react": "16.13.1",
66
+ "react-native": "^0.64.2",
67
+ "react-native-builder-bob": "latest",
68
+ "react-native-paper": "^4.10.0",
69
+ "release-it": "^14.11.6",
70
+ "typescript": "^4.4.4"
73
71
  },
74
72
  "peerDependencies": {
75
73
  "react": "*",
@@ -113,6 +111,7 @@
113
111
  }
114
112
  },
115
113
  "eslintConfig": {
114
+ "root": true,
116
115
  "extends": [
117
116
  "@react-native-community",
118
117
  "prettier"
@@ -134,7 +133,8 @@
134
133
  "eslintIgnore": [
135
134
  "node_modules/",
136
135
  "lib/",
137
- "example/"
136
+ "example/node_modules",
137
+ "example/web-build"
138
138
  ],
139
139
  "prettier": {
140
140
  "quoteProps": "consistent",
@@ -144,13 +144,21 @@
144
144
  "useTabs": false,
145
145
  "semi": false
146
146
  },
147
- "@react-native-community/bob": {
147
+ "react-native-builder-bob": {
148
148
  "source": "src",
149
149
  "output": "lib",
150
150
  "targets": [
151
151
  "commonjs",
152
152
  "module",
153
- "typescript"
153
+ [
154
+ "typescript",
155
+ {
156
+ "project": "tsconfig.build.json"
157
+ }
158
+ ]
154
159
  ]
160
+ },
161
+ "dependencies": {
162
+ "color": "^3.2.1"
155
163
  }
156
164
  }
package/src/.DS_Store ADDED
Binary file
@@ -1,13 +1,12 @@
1
1
  import * as React from 'react'
2
2
  import { StyleSheet, View } from 'react-native'
3
-
4
3
  import Swiper from './Swiper'
5
-
6
4
  import Month from './Month'
7
5
  import {
8
6
  areDatesOnSameDay,
9
7
  dateToUnix,
10
8
  DisableWeekDaysType,
9
+ getEndOfDay,
11
10
  getInitialIndex,
12
11
  } from './dateUtils'
13
12
 
@@ -16,7 +15,7 @@ import { useCallback, useMemo } from 'react'
16
15
  import YearPicker from './YearPicker'
17
16
  import Color from 'color'
18
17
  import { useTheme } from 'react-native-paper'
19
- import { useLatest } from '../utils'
18
+ import { useLatest, lightenBy, darkenBy } from '../utils'
20
19
 
21
20
  export type ModeType = 'single' | 'range' | 'multiple'
22
21
 
@@ -25,10 +24,11 @@ export type ScrollModeType = 'horizontal' | 'vertical'
25
24
  export type ValidRangeType = {
26
25
  startDate?: Date
27
26
  endDate?: Date
27
+ disabledDates?: Date[]
28
28
  }
29
29
 
30
30
  export type BaseCalendarProps = {
31
- locale?: undefined | string
31
+ locale: string
32
32
  disableWeekDays?: DisableWeekDaysType
33
33
  validRange?: ValidRangeType
34
34
 
@@ -37,6 +37,7 @@ export type BaseCalendarProps = {
37
37
  dates?: CalendarDates
38
38
  startDate?: CalendarDate
39
39
  endDate?: CalendarDate
40
+ dateMode?: 'start' | 'end'
40
41
  }
41
42
 
42
43
  export type CalendarDate = Date | undefined
@@ -47,7 +48,7 @@ export type RangeChange = (params: {
47
48
  endDate: CalendarDate
48
49
  }) => any
49
50
 
50
- export type SingleChange = (params: { date: CalendarDate }) => any
51
+ export type SingleChange = (params: { date: CalendarDate }) => void
51
52
 
52
53
  export type MultiChange = (params: {
53
54
  dates: CalendarDates
@@ -55,7 +56,7 @@ export type MultiChange = (params: {
55
56
  change: 'added' | 'removed'
56
57
  }) => any
57
58
 
58
- export type MultiConfirm = (params: { dates: Date[] }) => any
59
+ export type MultiConfirm = (params: { dates: Date[] }) => void
59
60
 
60
61
  export interface CalendarSingleProps extends BaseCalendarProps {
61
62
  mode: 'single'
@@ -89,15 +90,16 @@ function Calendar(
89
90
  disableWeekDays,
90
91
  dates,
91
92
  validRange,
93
+ dateMode,
92
94
  } = props
93
95
 
94
96
  const theme = useTheme()
95
97
 
96
98
  const selectColor = useMemo<string>(() => {
97
99
  if (theme.dark) {
98
- return Color(theme.colors.primary).hex()
100
+ return darkenBy(Color(theme.colors.primary), 0.9).hex()
99
101
  }
100
- return Color(theme.colors.primary).lighten(0.9).hex()
102
+ return lightenBy(Color(theme.colors.primary), 0.9).hex()
101
103
  }, [theme])
102
104
 
103
105
  const scrollMode =
@@ -128,7 +130,7 @@ function Calendar(
128
130
  (d: Date) => {
129
131
  if (mode === 'single') {
130
132
  ;(onChangeRef.current as SingleChange)({
131
- date: d,
133
+ date: dateMode === 'start' ? d : getEndOfDay(d),
132
134
  })
133
135
  } else if (mode === 'range') {
134
136
  const sd = startDateRef.current
@@ -139,9 +141,7 @@ function Calendar(
139
141
  }
140
142
  ;(onChangeRef.current as RangeChange)({
141
143
  startDate: isStart ? d : sd,
142
- endDate: !isStart
143
- ? new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59)
144
- : undefined,
144
+ endDate: !isStart ? getEndOfDay(d) : undefined,
145
145
  })
146
146
  } else if (mode === 'multiple') {
147
147
  datesRef.current = datesRef.current || []
@@ -159,10 +159,11 @@ function Calendar(
159
159
  })
160
160
  }
161
161
  },
162
- [mode, onChangeRef, startDateRef, endDateRef, datesRef]
162
+ [mode, dateMode, onChangeRef, startDateRef, endDateRef, datesRef]
163
163
  )
164
164
 
165
165
  const firstDate = startDate || date || dates?.[0]
166
+
166
167
  return (
167
168
  <View style={styles.root}>
168
169
  <Swiper