react-native-paper-dates 0.4.6 → 0.7.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 (245) hide show
  1. package/README.md +79 -22
  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 +32 -111
  9. package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
  10. package/lib/commonjs/Date/CalendarHeader.js +23 -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 +2 -2
  15. package/lib/commonjs/Date/DatePickerModalContent.js +7 -4
  16. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  17. package/lib/commonjs/Date/DatePickerModalContentHeader.js +43 -34
  18. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  19. package/lib/commonjs/Date/DatePickerModalHeader.js +12 -5
  20. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  21. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +6 -5
  22. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
  23. package/lib/commonjs/Date/DateRangeInput.js +23 -24
  24. package/lib/commonjs/Date/DateRangeInput.js.map +1 -1
  25. package/lib/commonjs/Date/Day.js +7 -3
  26. package/lib/commonjs/Date/Day.js.map +1 -1
  27. package/lib/commonjs/Date/DayName.js +6 -5
  28. package/lib/commonjs/Date/DayName.js.map +1 -1
  29. package/lib/commonjs/Date/DayNames.js +7 -6
  30. package/lib/commonjs/Date/DayNames.js.map +1 -1
  31. package/lib/commonjs/Date/DayRange.js +9 -8
  32. package/lib/commonjs/Date/DayRange.js.map +1 -1
  33. package/lib/commonjs/Date/Month.js +59 -49
  34. package/lib/commonjs/Date/Month.js.map +1 -1
  35. package/lib/commonjs/Date/Swiper.js +35 -29
  36. package/lib/commonjs/Date/Swiper.js.map +1 -1
  37. package/lib/commonjs/Date/Swiper.native.js +29 -23
  38. package/lib/commonjs/Date/Swiper.native.js.map +1 -1
  39. package/lib/commonjs/Date/SwiperUtils.js +7 -6
  40. package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
  41. package/lib/commonjs/Date/YearPicker.js +30 -20
  42. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  43. package/lib/commonjs/Date/dateUtils.js +106 -37
  44. package/lib/commonjs/Date/dateUtils.js.map +1 -1
  45. package/lib/commonjs/Date/inputUtils.js +84 -0
  46. package/lib/commonjs/Date/inputUtils.js.map +1 -0
  47. package/lib/commonjs/TextInputMask.js +11 -10
  48. package/lib/commonjs/TextInputMask.js.map +1 -1
  49. package/lib/commonjs/Time/AmPmSwitcher.js +37 -19
  50. package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
  51. package/lib/commonjs/Time/AnalogClock.js +25 -15
  52. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  53. package/lib/commonjs/Time/AnalogClockHours.js +17 -11
  54. package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
  55. package/lib/commonjs/Time/AnalogClockMinutes.js +7 -6
  56. package/lib/commonjs/Time/AnalogClockMinutes.js.map +1 -1
  57. package/lib/commonjs/Time/AnimatedClockSwitcher.js +8 -7
  58. package/lib/commonjs/Time/AnimatedClockSwitcher.js.map +1 -1
  59. package/lib/commonjs/Time/TimeInput.js +16 -12
  60. package/lib/commonjs/Time/TimeInput.js.map +1 -1
  61. package/lib/commonjs/Time/TimeInputs.js +12 -11
  62. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  63. package/lib/commonjs/Time/TimePicker.js +37 -15
  64. package/lib/commonjs/Time/TimePicker.js.map +1 -1
  65. package/lib/commonjs/Time/TimePickerModal.js +19 -15
  66. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  67. package/lib/commonjs/Time/timeUtils.js +14 -9
  68. package/lib/commonjs/Time/timeUtils.js.map +1 -1
  69. package/lib/commonjs/index.js +66 -5
  70. package/lib/commonjs/index.js.map +1 -1
  71. package/lib/commonjs/translations/en.js +25 -0
  72. package/lib/commonjs/translations/en.js.map +1 -0
  73. package/lib/commonjs/translations/enGB.js +25 -0
  74. package/lib/commonjs/translations/enGB.js.map +1 -0
  75. package/lib/commonjs/translations/nl.js +25 -0
  76. package/lib/commonjs/translations/nl.js.map +1 -0
  77. package/lib/commonjs/translations/pl.js +25 -0
  78. package/lib/commonjs/translations/pl.js.map +1 -0
  79. package/lib/commonjs/translations/utils.js +31 -0
  80. package/lib/commonjs/translations/utils.js.map +1 -0
  81. package/lib/commonjs/utils.js +19 -9
  82. package/lib/commonjs/utils.js.map +1 -1
  83. package/lib/module/Date/AnimatedCrossView.js +7 -6
  84. package/lib/module/Date/AnimatedCrossView.js.map +1 -1
  85. package/lib/module/Date/AutoSizer.js +4 -3
  86. package/lib/module/Date/AutoSizer.js.map +1 -1
  87. package/lib/module/Date/Calendar.js +46 -39
  88. package/lib/module/Date/Calendar.js.map +1 -1
  89. package/lib/module/Date/CalendarEdit.js +28 -104
  90. package/lib/module/Date/CalendarEdit.js.map +1 -1
  91. package/lib/module/Date/CalendarHeader.js +19 -9
  92. package/lib/module/Date/CalendarHeader.js.map +1 -1
  93. package/lib/module/Date/DatePickerInput.js +88 -18
  94. package/lib/module/Date/DatePickerInput.js.map +1 -1
  95. package/lib/module/Date/DatePickerModalContent.js +5 -2
  96. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  97. package/lib/module/Date/DatePickerModalContentHeader.js +38 -30
  98. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  99. package/lib/module/Date/DatePickerModalHeader.js +9 -3
  100. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  101. package/lib/module/Date/DatePickerModalHeaderBackground.js +4 -3
  102. package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
  103. package/lib/module/Date/DateRangeInput.js +22 -22
  104. package/lib/module/Date/DateRangeInput.js.map +1 -1
  105. package/lib/module/Date/Day.js +5 -1
  106. package/lib/module/Date/Day.js.map +1 -1
  107. package/lib/module/Date/DayName.js +4 -3
  108. package/lib/module/Date/DayName.js.map +1 -1
  109. package/lib/module/Date/DayNames.js +5 -4
  110. package/lib/module/Date/DayNames.js.map +1 -1
  111. package/lib/module/Date/DayRange.js +7 -6
  112. package/lib/module/Date/DayRange.js.map +1 -1
  113. package/lib/module/Date/Month.js +54 -45
  114. package/lib/module/Date/Month.js.map +1 -1
  115. package/lib/module/Date/Swiper.js +32 -26
  116. package/lib/module/Date/Swiper.js.map +1 -1
  117. package/lib/module/Date/Swiper.native.js +27 -21
  118. package/lib/module/Date/Swiper.native.js.map +1 -1
  119. package/lib/module/Date/SwiperUtils.js +5 -4
  120. package/lib/module/Date/SwiperUtils.js.map +1 -1
  121. package/lib/module/Date/YearPicker.js +28 -18
  122. package/lib/module/Date/YearPicker.js.map +1 -1
  123. package/lib/module/Date/dateUtils.js +78 -29
  124. package/lib/module/Date/dateUtils.js.map +1 -1
  125. package/lib/module/Date/inputUtils.js +70 -0
  126. package/lib/module/Date/inputUtils.js.map +1 -0
  127. package/lib/module/TextInputMask.js +9 -8
  128. package/lib/module/TextInputMask.js.map +1 -1
  129. package/lib/module/Time/AmPmSwitcher.js +35 -18
  130. package/lib/module/Time/AmPmSwitcher.js.map +1 -1
  131. package/lib/module/Time/AnalogClock.js +23 -14
  132. package/lib/module/Time/AnalogClock.js.map +1 -1
  133. package/lib/module/Time/AnalogClockHours.js +14 -9
  134. package/lib/module/Time/AnalogClockHours.js.map +1 -1
  135. package/lib/module/Time/AnalogClockMinutes.js +5 -4
  136. package/lib/module/Time/AnalogClockMinutes.js.map +1 -1
  137. package/lib/module/Time/AnimatedClockSwitcher.js +6 -5
  138. package/lib/module/Time/AnimatedClockSwitcher.js.map +1 -1
  139. package/lib/module/Time/TimeInput.js +14 -10
  140. package/lib/module/Time/TimeInput.js.map +1 -1
  141. package/lib/module/Time/TimeInputs.js +10 -9
  142. package/lib/module/Time/TimeInputs.js.map +1 -1
  143. package/lib/module/Time/TimePicker.js +32 -12
  144. package/lib/module/Time/TimePicker.js.map +1 -1
  145. package/lib/module/Time/TimePickerModal.js +17 -13
  146. package/lib/module/Time/TimePickerModal.js.map +1 -1
  147. package/lib/module/Time/timeUtils.js +5 -1
  148. package/lib/module/Time/timeUtils.js.map +1 -1
  149. package/lib/module/index.js +6 -0
  150. package/lib/module/index.js.map +1 -1
  151. package/lib/module/translations/en.js +18 -0
  152. package/lib/module/translations/en.js.map +1 -0
  153. package/lib/module/translations/enGB.js +18 -0
  154. package/lib/module/translations/enGB.js.map +1 -0
  155. package/lib/module/translations/nl.js +18 -0
  156. package/lib/module/translations/nl.js.map +1 -0
  157. package/lib/module/translations/pl.js +18 -0
  158. package/lib/module/translations/pl.js.map +1 -0
  159. package/lib/module/translations/utils.js +22 -0
  160. package/lib/module/translations/utils.js.map +1 -0
  161. package/lib/module/utils.js +11 -5
  162. package/lib/module/utils.js.map +1 -1
  163. package/lib/typescript/{src/Date → Date}/AnimatedCrossView.d.ts +0 -0
  164. package/lib/typescript/{src/Date → Date}/AutoSizer.d.ts +0 -0
  165. package/lib/typescript/{src/Date → Date}/Calendar.d.ts +5 -3
  166. package/lib/typescript/{src/Date → Date}/CalendarEdit.d.ts +3 -3
  167. package/lib/typescript/{src/Date → Date}/CalendarHeader.d.ts +1 -1
  168. package/lib/typescript/Date/DatePickerInput.d.ts +18 -0
  169. package/lib/typescript/{src/Date → Date}/DatePickerModal.d.ts +0 -0
  170. package/lib/typescript/{src/Date → Date}/DatePickerModalContent.d.ts +2 -1
  171. package/lib/typescript/{src/Date → Date}/DatePickerModalContentHeader.d.ts +4 -4
  172. package/lib/typescript/{src/Date → Date}/DatePickerModalHeader.d.ts +1 -0
  173. package/lib/typescript/{src/Date → Date}/DatePickerModalHeaderBackground.d.ts +0 -0
  174. package/lib/typescript/Date/DateRangeInput.d.ts +3 -0
  175. package/lib/typescript/{src/Date → Date}/Day.d.ts +0 -0
  176. package/lib/typescript/{src/Date → Date}/DayName.d.ts +0 -0
  177. package/lib/typescript/{src/Date → Date}/DayNames.d.ts +0 -0
  178. package/lib/typescript/{src/Date → Date}/DayRange.d.ts +0 -0
  179. package/lib/typescript/{src/Date → Date}/Month.d.ts +0 -0
  180. package/lib/typescript/{src/Date → Date}/Swiper.d.ts +0 -0
  181. package/lib/typescript/{src/Date → Date}/Swiper.native.d.ts +0 -0
  182. package/lib/typescript/{src/Date → Date}/SwiperUtils.d.ts +1 -1
  183. package/lib/typescript/{src/Date → Date}/Week.d.ts +0 -0
  184. package/lib/typescript/{src/Date → Date}/YearPicker.d.ts +0 -0
  185. package/lib/typescript/{src/Date → Date}/dateUtils.d.ts +15 -0
  186. package/lib/typescript/{src/Date → Date}/dateUtils.test.d.ts +0 -0
  187. package/lib/typescript/Date/inputUtils.d.ts +14 -0
  188. package/lib/typescript/TextInputMask.d.ts +11 -0
  189. package/lib/typescript/Time/AmPmSwitcher.d.ts +4 -0
  190. package/lib/typescript/{src/Time → Time}/AnalogClock.d.ts +1 -1
  191. package/lib/typescript/{src/Time → Time}/AnalogClockHours.d.ts +0 -0
  192. package/lib/typescript/{src/Time → Time}/AnalogClockMinutes.d.ts +0 -0
  193. package/lib/typescript/{src/Time → Time}/AnimatedClockSwitcher.d.ts +0 -0
  194. package/lib/typescript/{src/Time → Time}/TimeInput.d.ts +0 -0
  195. package/lib/typescript/{src/Time → Time}/TimeInputs.d.ts +1 -1
  196. package/lib/typescript/{src/Time → Time}/TimePicker.d.ts +4 -0
  197. package/lib/typescript/{src/Time → Time}/TimePickerModal.d.ts +1 -1
  198. package/lib/typescript/{src/Time → Time}/timeUtils.d.ts +0 -0
  199. package/lib/typescript/index.d.ts +13 -0
  200. package/lib/typescript/translations/en.d.ts +3 -0
  201. package/lib/typescript/translations/enGB.d.ts +3 -0
  202. package/lib/typescript/translations/nl.d.ts +3 -0
  203. package/lib/typescript/translations/pl.d.ts +3 -0
  204. package/lib/typescript/translations/utils.d.ts +18 -0
  205. package/lib/typescript/utils.d.ts +58 -0
  206. package/package.json +39 -38
  207. package/src/.DS_Store +0 -0
  208. package/src/Date/Calendar.tsx +14 -13
  209. package/src/Date/CalendarEdit.tsx +17 -121
  210. package/src/Date/CalendarHeader.tsx +18 -3
  211. package/src/Date/DatePickerInput.tsx +103 -25
  212. package/src/Date/DatePickerModalContent.tsx +5 -1
  213. package/src/Date/DatePickerModalContentHeader.tsx +26 -12
  214. package/src/Date/DatePickerModalHeader.tsx +8 -1
  215. package/src/Date/DateRangeInput.tsx +26 -17
  216. package/src/Date/Day.tsx +4 -0
  217. package/src/Date/Month.tsx +20 -44
  218. package/src/Date/Swiper.tsx +1 -0
  219. package/src/Date/SwiperUtils.ts +1 -1
  220. package/src/Date/YearPicker.tsx +6 -1
  221. package/src/Date/dateUtils.tsx +70 -9
  222. package/src/Date/inputUtils.ts +94 -0
  223. package/src/TextInputMask.tsx +10 -3
  224. package/src/Time/AmPmSwitcher.tsx +20 -11
  225. package/src/Time/AnalogClock.tsx +12 -14
  226. package/src/Time/AnalogClockHours.tsx +14 -5
  227. package/src/Time/AnalogClockMinutes.tsx +4 -1
  228. package/src/Time/TimeInput.tsx +3 -0
  229. package/src/Time/TimeInputs.tsx +1 -5
  230. package/src/Time/TimePicker.tsx +44 -22
  231. package/src/Time/TimePickerModal.tsx +4 -1
  232. package/src/Time/timeUtils.ts +4 -1
  233. package/src/index.tsx +7 -0
  234. package/src/translations/en.ts +20 -0
  235. package/src/translations/enGB.ts +20 -0
  236. package/src/translations/nl.ts +20 -0
  237. package/src/translations/pl.ts +21 -0
  238. package/src/translations/utils.ts +47 -0
  239. package/src/utils.ts +13 -5
  240. package/lib/typescript/src/Date/DatePickerInput.d.ts +0 -1
  241. package/lib/typescript/src/Date/DateRangeInput.d.ts +0 -1
  242. package/lib/typescript/src/TextInputMask.d.ts +0 -3
  243. package/lib/typescript/src/Time/AmPmSwitcher.d.ts +0 -4
  244. package/lib/typescript/src/index.d.ts +0 -6
  245. 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;
@@ -5,7 +5,7 @@ declare function AnalogClock({ hours, minutes, focused, is24Hour, onChange, }: {
5
5
  minutes: number;
6
6
  focused: PossibleClockTypes;
7
7
  is24Hour: boolean;
8
- onChange: ({ hours, minutes, focused, }: {
8
+ onChange: (hoursMinutesAndFocused: {
9
9
  hours: number;
10
10
  minutes: number;
11
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;
File without changes
@@ -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,18 @@
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
+ previous: string;
12
+ next: string;
13
+ typeInDate: string;
14
+ pickDateFromCalendar: string;
15
+ close: string;
16
+ };
17
+ export declare function getTranslation(locale: string | undefined, key: keyof TranslationsType, fallback?: any): any;
18
+ 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.6",
3
+ "version": "0.7.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": "*",
@@ -77,13 +75,6 @@
77
75
  "react-native-paper": "*",
78
76
  "react-native-vector-icons": "*"
79
77
  },
80
- "jest": {
81
- "preset": "react-native",
82
- "modulePathIgnorePatterns": [
83
- "<rootDir>/example/node_modules",
84
- "<rootDir>/lib/"
85
- ]
86
- },
87
78
  "husky": {
88
79
  "hooks": {
89
80
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
@@ -113,6 +104,7 @@
113
104
  }
114
105
  },
115
106
  "eslintConfig": {
107
+ "root": true,
116
108
  "extends": [
117
109
  "@react-native-community",
118
110
  "prettier"
@@ -134,7 +126,8 @@
134
126
  "eslintIgnore": [
135
127
  "node_modules/",
136
128
  "lib/",
137
- "example/"
129
+ "example/node_modules",
130
+ "example/web-build"
138
131
  ],
139
132
  "prettier": {
140
133
  "quoteProps": "consistent",
@@ -144,13 +137,21 @@
144
137
  "useTabs": false,
145
138
  "semi": false
146
139
  },
147
- "@react-native-community/bob": {
140
+ "react-native-builder-bob": {
148
141
  "source": "src",
149
142
  "output": "lib",
150
143
  "targets": [
151
144
  "commonjs",
152
145
  "module",
153
- "typescript"
146
+ [
147
+ "typescript",
148
+ {
149
+ "project": "tsconfig.build.json"
150
+ }
151
+ ]
154
152
  ]
153
+ },
154
+ "dependencies": {
155
+ "color": "^3.2.1"
155
156
  }
156
157
  }
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