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
@@ -13,6 +13,11 @@ import AnalogClock from './AnalogClock'
13
13
  import { circleSize } from './timeUtils'
14
14
  import TimeInputs from './TimeInputs'
15
15
 
16
+ export const DisplayModeContext = React.createContext<{
17
+ mode: 'AM' | 'PM' | undefined
18
+ setMode: React.Dispatch<React.SetStateAction<'AM' | 'PM' | undefined>>
19
+ }>({ mode: 'AM', setMode: () => {} })
20
+
16
21
  type onChangeFunc = ({
17
22
  hours,
18
23
  minutes,
@@ -40,6 +45,9 @@ function TimePicker({
40
45
  onFocusInput: (type: PossibleClockTypes) => any
41
46
  onChange: onChangeFunc
42
47
  }) {
48
+ const [displayMode, setDisplayMode] = React.useState<'AM' | 'PM' | undefined>(
49
+ undefined
50
+ )
43
51
  const dimensions = useWindowDimensions()
44
52
  const isLandscape = dimensions.width > dimensions.height
45
53
 
@@ -54,6 +62,16 @@ function TimePicker({
54
62
  return formatted.includes('23')
55
63
  }, [locale])
56
64
 
65
+ // Initialize display Mode according the hours value
66
+ React.useEffect(() => {
67
+ if (hours >= 12) {
68
+ setDisplayMode('PM')
69
+ } else {
70
+ setDisplayMode('AM')
71
+ }
72
+ // eslint-disable-next-line react-hooks/exhaustive-deps
73
+ }, [])
74
+
57
75
  const onInnerChange = React.useCallback<onChangeFunc>(
58
76
  (params) => {
59
77
  params.hours = toHourOutputFormat(params.hours, hours, is24Hour)
@@ -63,28 +81,32 @@ function TimePicker({
63
81
  )
64
82
 
65
83
  return (
66
- <View style={isLandscape ? styles.rootLandscape : styles.rootPortrait}>
67
- <TimeInputs
68
- inputType={inputType}
69
- hours={hours}
70
- minutes={minutes}
71
- is24Hour={is24Hour}
72
- onChange={onChange}
73
- onFocusInput={onFocusInput}
74
- focused={focused}
75
- />
76
- {inputType === inputTypes.picker ? (
77
- <View style={styles.clockContainer}>
78
- <AnalogClock
79
- hours={toHourInputFormat(hours, is24Hour)}
80
- minutes={minutes}
81
- focused={focused}
82
- is24Hour={is24Hour}
83
- onChange={onInnerChange}
84
- />
85
- </View>
86
- ) : null}
87
- </View>
84
+ <DisplayModeContext.Provider
85
+ value={{ mode: displayMode, setMode: setDisplayMode }}
86
+ >
87
+ <View style={isLandscape ? styles.rootLandscape : styles.rootPortrait}>
88
+ <TimeInputs
89
+ inputType={inputType}
90
+ hours={hours}
91
+ minutes={minutes}
92
+ is24Hour={is24Hour}
93
+ onChange={onChange}
94
+ onFocusInput={onFocusInput}
95
+ focused={focused}
96
+ />
97
+ {inputType === inputTypes.picker ? (
98
+ <View style={styles.clockContainer}>
99
+ <AnalogClock
100
+ hours={toHourInputFormat(hours, is24Hour)}
101
+ minutes={minutes}
102
+ focused={focused}
103
+ is24Hour={is24Hour}
104
+ onChange={onInnerChange}
105
+ />
106
+ </View>
107
+ ) : null}
108
+ </View>
109
+ </DisplayModeContext.Provider>
88
110
  )
89
111
  }
90
112
 
@@ -48,7 +48,7 @@ export function TimePickerModal({
48
48
  minutes?: number | undefined
49
49
  visible: boolean | undefined
50
50
  onDismiss: () => any
51
- onConfirm: ({ hours, minutes }: { hours: number; minutes: number }) => any
51
+ onConfirm: (hoursAndMinutes: { hours: number; minutes: number }) => any
52
52
  animationType?: 'slide' | 'fade' | 'none'
53
53
  }) {
54
54
  const theme = useTheme()
@@ -155,6 +155,9 @@ export function TimePickerModal({
155
155
  size={24}
156
156
  style={styles.inputTypeToggle}
157
157
  accessibilityLabel="toggle keyboard"
158
+ // RN types bug
159
+ hasTVPreferredFocus={undefined}
160
+ tvParallaxProperties={undefined}
158
161
  />
159
162
  <View style={styles.fill} />
160
163
  <Button onPress={onDismiss}>{cancelLabel}</Button>
@@ -199,6 +199,9 @@ export function useInputColors(highlighted: boolean) {
199
199
  }
200
200
 
201
201
  export function toHourInputFormat(hours: number, is24Hour: boolean): number {
202
+ if (hours === 24) {
203
+ return 0
204
+ }
202
205
  if (is24Hour) {
203
206
  return hours
204
207
  }
@@ -216,7 +219,7 @@ export function toHourOutputFormat(
216
219
  if (is24Hour) {
217
220
  return newHours
218
221
  }
219
- if (previousHours > 12 && newHours <= 12) {
222
+ if (previousHours > 12 && newHours < 12) {
220
223
  return newHours + 12
221
224
  }
222
225
  return newHours
package/src/index.tsx CHANGED
@@ -4,3 +4,10 @@ export * from './Date/DatePickerModal'
4
4
  export { default as DatePickerModalContent } from './Date/DatePickerModalContent'
5
5
  export { default as TimePickerModal } from './Time/TimePickerModal'
6
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,20 @@
1
+ import type { TranslationsType } from './utils'
2
+
3
+ const en: TranslationsType = {
4
+ save: 'Save',
5
+ selectSingle: 'Select date',
6
+ selectMultiple: 'Select dates',
7
+ selectRange: 'Select period',
8
+ notAccordingToDateFormat: (inputFormat: string) =>
9
+ `Date format must be ${inputFormat}`,
10
+ mustBeHigherThan: 'Must be later then',
11
+ mustBeLowerThan: 'Must be earlier then',
12
+ mustBeBetween: 'Must be between',
13
+ dateIsDisabled: 'Day is not allowed',
14
+ previous: 'Previous',
15
+ next: 'Next',
16
+ typeInDate: 'Type in date',
17
+ pickDateFromCalendar: 'Pick date from calendar',
18
+ close: 'Close',
19
+ }
20
+ export default en
@@ -0,0 +1,20 @@
1
+ import type { TranslationsType } from './utils'
2
+
3
+ const enGB: TranslationsType = {
4
+ save: 'Save',
5
+ selectSingle: 'Select date',
6
+ selectMultiple: 'Select dates',
7
+ selectRange: 'Select period',
8
+ notAccordingToDateFormat: (inputFormat: string) =>
9
+ `Date format must be ${inputFormat}`,
10
+ mustBeHigherThan: 'Must be later then',
11
+ mustBeLowerThan: 'Must be earlier then',
12
+ mustBeBetween: 'Must be between',
13
+ dateIsDisabled: 'Day is not allowed',
14
+ previous: 'Previous',
15
+ next: 'Next',
16
+ typeInDate: 'Type in date',
17
+ pickDateFromCalendar: 'Pick date from calendar',
18
+ close: 'Close',
19
+ }
20
+ export default enGB
@@ -0,0 +1,20 @@
1
+ import type { TranslationsType } from './utils'
2
+
3
+ const nl: TranslationsType = {
4
+ save: 'Opslaan',
5
+ selectSingle: 'Selecteer datum',
6
+ selectMultiple: 'Selecteer datums',
7
+ selectRange: 'Selecteer periode',
8
+ notAccordingToDateFormat: (inputFormat: string) =>
9
+ `Datumformaat moet ${inputFormat} zijn`,
10
+ mustBeHigherThan: 'Moet later dan',
11
+ mustBeLowerThan: 'Moet eerder dan',
12
+ mustBeBetween: 'Moet tussen',
13
+ dateIsDisabled: 'Deze dag mag niet',
14
+ previous: 'Vorige',
15
+ next: 'Volgende',
16
+ typeInDate: 'Typ datum',
17
+ pickDateFromCalendar: 'Kies datum van kalender',
18
+ close: 'Sluit',
19
+ }
20
+ export default nl
@@ -0,0 +1,21 @@
1
+ import type { TranslationsType } from './utils'
2
+
3
+ const pl: TranslationsType = {
4
+ save: 'Zapisz',
5
+ selectSingle: 'Wybierz datę',
6
+ selectMultiple: 'Wybierz daty',
7
+ selectRange: 'Wybierz zakres',
8
+ notAccordingToDateFormat: (inputFormat: string) =>
9
+ `Data musi mieć format ${inputFormat}`,
10
+ mustBeHigherThan: 'Nie wcześniej niż',
11
+ mustBeLowerThan: 'Nie później niż',
12
+ mustBeBetween: 'Pomiędzy',
13
+ dateIsDisabled: 'Niedozwolona data',
14
+
15
+ previous: 'Poprzedni',
16
+ next: 'Dalej',
17
+ typeInDate: 'Wpisz datę',
18
+ pickDateFromCalendar: 'Wybierz datę z kalendarza',
19
+ close: 'Zamknij',
20
+ }
21
+ export default pl
@@ -0,0 +1,47 @@
1
+ export 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
+
18
+ let translationsPerLocale: Record<string, TranslationsType> = {}
19
+
20
+ export function getTranslation(
21
+ locale: string | undefined,
22
+ key: keyof TranslationsType,
23
+ fallback?: any
24
+ ) {
25
+ const l = locale || 'en'
26
+ const translationForLocale = translationsPerLocale[l]
27
+ if (!translationForLocale) {
28
+ console.warn(
29
+ `[react-native-paper-dates] ${locale} is not registered, key: ${key}`
30
+ )
31
+ return fallback || key
32
+ }
33
+ const translation = translationsPerLocale[l][key]
34
+ if (!translationForLocale) {
35
+ console.warn(
36
+ `[react-native-paper-dates] ${locale} is registered, but ${key} is missing`
37
+ )
38
+ }
39
+ return translation || fallback || key
40
+ }
41
+
42
+ export function registerTranslation(
43
+ locale: string,
44
+ translations: TranslationsType
45
+ ) {
46
+ translationsPerLocale[locale] = translations
47
+ }
package/src/utils.ts CHANGED
@@ -3,11 +3,9 @@ import { overlay, useTheme } from 'react-native-paper'
3
3
  import Color from 'color'
4
4
 
5
5
  export function useLatest<T>(value: T) {
6
- const valueRef = React.useRef<T>(value)
7
- React.useEffect(() => {
8
- valueRef.current = value
9
- }, [value])
10
- return valueRef
6
+ const ref = React.useRef(value)
7
+ ref.current = value
8
+ return ref
11
9
  }
12
10
 
13
11
  export function useHeaderBackgroundColor() {
@@ -42,3 +40,13 @@ export function range(start: number, end: number) {
42
40
  .fill(null)
43
41
  .map((_, i) => start + i)
44
42
  }
43
+
44
+ export function lightenBy(color: Color, ratio: number) {
45
+ const lightness = color.lightness()
46
+ return color.lightness(lightness + (100 - lightness) * ratio)
47
+ }
48
+
49
+ export function darkenBy(color: Color, ratio: number) {
50
+ const lightness = color.lightness()
51
+ return color.lightness(lightness - lightness * ratio)
52
+ }
@@ -1 +0,0 @@
1
- export default function DatePickerInput(): JSX.Element;
@@ -1 +0,0 @@
1
- export default function DateRangeInput(): JSX.Element;
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const _default: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
3
- export default _default;
@@ -1,4 +0,0 @@
1
- export default function AmPmSwitcher({ hours, onChange, }: {
2
- hours: number;
3
- onChange: (hours: number) => any;
4
- }): JSX.Element;
@@ -1,6 +0,0 @@
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';
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- export declare function useLatest<T>(value: T): React.MutableRefObject<T>;
3
- export declare function useHeaderBackgroundColor(): string;
4
- export declare function useHeaderColorIsLight(): boolean;
5
- export declare function useHeaderTextColor(): "#fff" | "#000";
6
- export declare function useTextColorOnPrimary(): "#fff" | "#000";
7
- export declare function range(start: number, end: number): number[];