react-native-paper-dates 0.22.14 → 0.22.16

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 (277) hide show
  1. package/lib/commonjs/Date/AnimatedCrossView.js +41 -42
  2. package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
  3. package/lib/commonjs/Date/AutoSizer.js +10 -14
  4. package/lib/commonjs/Date/AutoSizer.js.map +1 -1
  5. package/lib/commonjs/Date/Calendar.js +69 -76
  6. package/lib/commonjs/Date/Calendar.js.map +1 -1
  7. package/lib/commonjs/Date/CalendarEdit.js +67 -72
  8. package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
  9. package/lib/commonjs/Date/CalendarHeader.js +38 -36
  10. package/lib/commonjs/Date/CalendarHeader.js.map +1 -1
  11. package/lib/commonjs/Date/DatePickerInput.js +15 -15
  12. package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
  13. package/lib/commonjs/Date/DatePickerInputWithoutModal.js +49 -43
  14. package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
  15. package/lib/commonjs/Date/DatePickerModal.js +49 -45
  16. package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
  17. package/lib/commonjs/Date/DatePickerModalContent.js +73 -68
  18. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  19. package/lib/commonjs/Date/DatePickerModalContentHeader.js +86 -101
  20. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  21. package/lib/commonjs/Date/DatePickerModalHeader.js +32 -63
  22. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  23. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +8 -7
  24. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
  25. package/lib/commonjs/Date/DatePickerModalStatusBar.js +16 -13
  26. package/lib/commonjs/Date/DatePickerModalStatusBar.js.map +1 -1
  27. package/lib/commonjs/Date/Day.js +57 -57
  28. package/lib/commonjs/Date/Day.js.map +1 -1
  29. package/lib/commonjs/Date/DayName.js +17 -14
  30. package/lib/commonjs/Date/DayName.js.map +1 -1
  31. package/lib/commonjs/Date/DayNames.js +14 -13
  32. package/lib/commonjs/Date/DayNames.js.map +1 -1
  33. package/lib/commonjs/Date/DayRange.js +25 -26
  34. package/lib/commonjs/Date/DayRange.js.map +1 -1
  35. package/lib/commonjs/Date/Month.js +74 -76
  36. package/lib/commonjs/Date/Month.js.map +1 -1
  37. package/lib/commonjs/Date/Swiper.js +67 -64
  38. package/lib/commonjs/Date/Swiper.js.map +1 -1
  39. package/lib/commonjs/Date/Swiper.native.js +67 -63
  40. package/lib/commonjs/Date/Swiper.native.js.map +1 -1
  41. package/lib/commonjs/Date/SwiperUtils.js +3 -5
  42. package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
  43. package/lib/commonjs/Date/YearPicker.js +58 -58
  44. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  45. package/lib/commonjs/Date/dateUtils.js +13 -11
  46. package/lib/commonjs/Date/dateUtils.js.map +1 -1
  47. package/lib/commonjs/Date/inputUtils.js +8 -10
  48. package/lib/commonjs/Date/inputUtils.js.map +1 -1
  49. package/lib/commonjs/TextInputMask.js +11 -11
  50. package/lib/commonjs/TextInputMask.js.map +1 -1
  51. package/lib/commonjs/Time/AmPmSwitcher.js +51 -49
  52. package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
  53. package/lib/commonjs/Time/AnalogClock.js +69 -64
  54. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  55. package/lib/commonjs/Time/AnalogClockHours.js +46 -53
  56. package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
  57. package/lib/commonjs/Time/AnalogClockMinutes.js +45 -60
  58. package/lib/commonjs/Time/AnalogClockMinutes.js.map +1 -1
  59. package/lib/commonjs/Time/AnimatedClockSwitcher.js +34 -30
  60. package/lib/commonjs/Time/AnimatedClockSwitcher.js.map +1 -1
  61. package/lib/commonjs/Time/TimeInput.js +55 -54
  62. package/lib/commonjs/Time/TimeInput.js.map +1 -1
  63. package/lib/commonjs/Time/TimeInputs.js +118 -114
  64. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  65. package/lib/commonjs/Time/TimePicker.js +40 -36
  66. package/lib/commonjs/Time/TimePicker.js.map +1 -1
  67. package/lib/commonjs/Time/TimePickerModal.js +118 -114
  68. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  69. package/lib/commonjs/Time/timeUtils.js +5 -8
  70. package/lib/commonjs/Time/timeUtils.js.map +1 -1
  71. package/lib/commonjs/contexts/DisplayModeContext.js +2 -4
  72. package/lib/commonjs/contexts/DisplayModeContext.js.map +1 -1
  73. package/lib/commonjs/shared/styles.js +25 -0
  74. package/lib/commonjs/shared/styles.js.map +1 -0
  75. package/lib/commonjs/{utils.js → shared/utils.js} +4 -4
  76. package/lib/commonjs/shared/utils.js.map +1 -0
  77. package/lib/module/Date/AnimatedCrossView.js +43 -42
  78. package/lib/module/Date/AnimatedCrossView.js.map +1 -1
  79. package/lib/module/Date/AutoSizer.js +12 -15
  80. package/lib/module/Date/AutoSizer.js.map +1 -1
  81. package/lib/module/Date/Calendar.js +71 -76
  82. package/lib/module/Date/Calendar.js.map +1 -1
  83. package/lib/module/Date/CalendarEdit.js +68 -71
  84. package/lib/module/Date/CalendarEdit.js.map +1 -1
  85. package/lib/module/Date/CalendarHeader.js +39 -36
  86. package/lib/module/Date/CalendarHeader.js.map +1 -1
  87. package/lib/module/Date/DatePickerInput.js +15 -14
  88. package/lib/module/Date/DatePickerInput.js.map +1 -1
  89. package/lib/module/Date/DatePickerInputWithoutModal.js +50 -42
  90. package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
  91. package/lib/module/Date/DatePickerModal.js +49 -44
  92. package/lib/module/Date/DatePickerModal.js.map +1 -1
  93. package/lib/module/Date/DatePickerModalContent.js +74 -67
  94. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  95. package/lib/module/Date/DatePickerModalContentHeader.js +87 -100
  96. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  97. package/lib/module/Date/DatePickerModalHeader.js +33 -61
  98. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  99. package/lib/module/Date/DatePickerModalHeaderBackground.js +7 -5
  100. package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
  101. package/lib/module/Date/DatePickerModalStatusBar.js +18 -13
  102. package/lib/module/Date/DatePickerModalStatusBar.js.map +1 -1
  103. package/lib/module/Date/Day.js +58 -56
  104. package/lib/module/Date/Day.js.map +1 -1
  105. package/lib/module/Date/DayName.js +17 -14
  106. package/lib/module/Date/DayName.js.map +1 -1
  107. package/lib/module/Date/DayNames.js +13 -12
  108. package/lib/module/Date/DayNames.js.map +1 -1
  109. package/lib/module/Date/DayRange.js +27 -26
  110. package/lib/module/Date/DayRange.js.map +1 -1
  111. package/lib/module/Date/Month.js +76 -76
  112. package/lib/module/Date/Month.js.map +1 -1
  113. package/lib/module/Date/Swiper.js +69 -64
  114. package/lib/module/Date/Swiper.js.map +1 -1
  115. package/lib/module/Date/Swiper.native.js +69 -62
  116. package/lib/module/Date/Swiper.native.js.map +1 -1
  117. package/lib/module/Date/SwiperUtils.js +3 -3
  118. package/lib/module/Date/SwiperUtils.js.map +1 -1
  119. package/lib/module/Date/YearPicker.js +59 -58
  120. package/lib/module/Date/YearPicker.js.map +1 -1
  121. package/lib/module/Date/dateUtils.js +13 -9
  122. package/lib/module/Date/dateUtils.js.map +1 -1
  123. package/lib/module/Date/inputUtils.js +8 -8
  124. package/lib/module/Date/inputUtils.js.map +1 -1
  125. package/lib/module/TextInputMask.js +12 -11
  126. package/lib/module/TextInputMask.js.map +1 -1
  127. package/lib/module/Time/AmPmSwitcher.js +53 -49
  128. package/lib/module/Time/AmPmSwitcher.js.map +1 -1
  129. package/lib/module/Time/AnalogClock.js +71 -64
  130. package/lib/module/Time/AnalogClock.js.map +1 -1
  131. package/lib/module/Time/AnalogClockHours.js +48 -53
  132. package/lib/module/Time/AnalogClockHours.js.map +1 -1
  133. package/lib/module/Time/AnalogClockMinutes.js +46 -60
  134. package/lib/module/Time/AnalogClockMinutes.js.map +1 -1
  135. package/lib/module/Time/AnimatedClockSwitcher.js +35 -30
  136. package/lib/module/Time/AnimatedClockSwitcher.js.map +1 -1
  137. package/lib/module/Time/TimeInput.js +56 -53
  138. package/lib/module/Time/TimeInput.js.map +1 -1
  139. package/lib/module/Time/TimeInputs.js +120 -113
  140. package/lib/module/Time/TimeInputs.js.map +1 -1
  141. package/lib/module/Time/TimePicker.js +42 -36
  142. package/lib/module/Time/TimePicker.js.map +1 -1
  143. package/lib/module/Time/TimePickerModal.js +118 -112
  144. package/lib/module/Time/TimePickerModal.js.map +1 -1
  145. package/lib/module/Time/timeUtils.js +5 -6
  146. package/lib/module/Time/timeUtils.js.map +1 -1
  147. package/lib/module/contexts/DisplayModeContext.js +2 -2
  148. package/lib/module/contexts/DisplayModeContext.js.map +1 -1
  149. package/lib/module/shared/styles.js +19 -0
  150. package/lib/module/shared/styles.js.map +1 -0
  151. package/lib/module/{utils.js → shared/utils.js} +3 -2
  152. package/lib/module/shared/utils.js.map +1 -0
  153. package/lib/typescript/Date/AnimatedCrossView.d.ts +1 -1
  154. package/lib/typescript/Date/AnimatedCrossView.d.ts.map +1 -1
  155. package/lib/typescript/Date/AutoSizer.d.ts +1 -1
  156. package/lib/typescript/Date/AutoSizer.d.ts.map +1 -1
  157. package/lib/typescript/Date/Calendar.d.ts +1 -1
  158. package/lib/typescript/Date/Calendar.d.ts.map +1 -1
  159. package/lib/typescript/Date/CalendarEdit.d.ts +1 -1
  160. package/lib/typescript/Date/CalendarEdit.d.ts.map +1 -1
  161. package/lib/typescript/Date/CalendarHeader.d.ts +1 -1
  162. package/lib/typescript/Date/CalendarHeader.d.ts.map +1 -1
  163. package/lib/typescript/Date/DatePickerInput.d.ts +1 -1
  164. package/lib/typescript/Date/DatePickerInput.d.ts.map +1 -1
  165. package/lib/typescript/Date/DatePickerInput.shared.d.ts +3 -3
  166. package/lib/typescript/Date/DatePickerInput.shared.d.ts.map +1 -1
  167. package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +59 -58
  168. package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts.map +1 -1
  169. package/lib/typescript/Date/DatePickerModal.d.ts +1 -1
  170. package/lib/typescript/Date/DatePickerModal.d.ts.map +1 -1
  171. package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -1
  172. package/lib/typescript/Date/DatePickerModalContent.d.ts.map +1 -1
  173. package/lib/typescript/Date/DatePickerModalContentHeader.d.ts +1 -1
  174. package/lib/typescript/Date/DatePickerModalContentHeader.d.ts.map +1 -1
  175. package/lib/typescript/Date/DatePickerModalHeader.d.ts +1 -1
  176. package/lib/typescript/Date/DatePickerModalHeader.d.ts.map +1 -1
  177. package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts +1 -1
  178. package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts.map +1 -1
  179. package/lib/typescript/Date/DatePickerModalStatusBar.d.ts +1 -1
  180. package/lib/typescript/Date/DatePickerModalStatusBar.d.ts.map +1 -1
  181. package/lib/typescript/Date/Day.d.ts +2 -2
  182. package/lib/typescript/Date/Day.d.ts.map +1 -1
  183. package/lib/typescript/Date/DayName.d.ts +1 -1
  184. package/lib/typescript/Date/DayName.d.ts.map +1 -1
  185. package/lib/typescript/Date/DayNames.d.ts +1 -1
  186. package/lib/typescript/Date/DayNames.d.ts.map +1 -1
  187. package/lib/typescript/Date/DayRange.d.ts +1 -1
  188. package/lib/typescript/Date/DayRange.d.ts.map +1 -1
  189. package/lib/typescript/Date/Month.d.ts +1 -1
  190. package/lib/typescript/Date/Month.d.ts.map +1 -1
  191. package/lib/typescript/Date/Swiper.d.ts +1 -1
  192. package/lib/typescript/Date/Swiper.d.ts.map +1 -1
  193. package/lib/typescript/Date/Swiper.native.d.ts +1 -1
  194. package/lib/typescript/Date/Swiper.native.d.ts.map +1 -1
  195. package/lib/typescript/Date/SwiperUtils.d.ts +1 -1
  196. package/lib/typescript/Date/SwiperUtils.d.ts.map +1 -1
  197. package/lib/typescript/Date/YearPicker.d.ts +1 -1
  198. package/lib/typescript/Date/YearPicker.d.ts.map +1 -1
  199. package/lib/typescript/Date/dateUtils.d.ts.map +1 -1
  200. package/lib/typescript/Date/inputUtils.d.ts.map +1 -1
  201. package/lib/typescript/TextInputMask.d.ts +24 -24
  202. package/lib/typescript/TextInputMask.d.ts.map +1 -1
  203. package/lib/typescript/Time/AmPmSwitcher.d.ts +1 -1
  204. package/lib/typescript/Time/AmPmSwitcher.d.ts.map +1 -1
  205. package/lib/typescript/Time/AnalogClock.d.ts +1 -1
  206. package/lib/typescript/Time/AnalogClock.d.ts.map +1 -1
  207. package/lib/typescript/Time/AnalogClockHours.d.ts +1 -1
  208. package/lib/typescript/Time/AnalogClockHours.d.ts.map +1 -1
  209. package/lib/typescript/Time/AnalogClockMinutes.d.ts +1 -1
  210. package/lib/typescript/Time/AnalogClockMinutes.d.ts.map +1 -1
  211. package/lib/typescript/Time/AnimatedClockSwitcher.d.ts +5 -3
  212. package/lib/typescript/Time/AnimatedClockSwitcher.d.ts.map +1 -1
  213. package/lib/typescript/Time/TimeInput.d.ts +1 -1
  214. package/lib/typescript/Time/TimeInput.d.ts.map +1 -1
  215. package/lib/typescript/Time/TimeInputs.d.ts +1 -1
  216. package/lib/typescript/Time/TimeInputs.d.ts.map +1 -1
  217. package/lib/typescript/Time/TimePicker.d.ts +1 -1
  218. package/lib/typescript/Time/TimePicker.d.ts.map +1 -1
  219. package/lib/typescript/Time/TimePickerModal.d.ts +1 -1
  220. package/lib/typescript/Time/TimePickerModal.d.ts.map +1 -1
  221. package/lib/typescript/Time/timeUtils.d.ts.map +1 -1
  222. package/lib/typescript/contexts/DisplayModeContext.d.ts +4 -4
  223. package/lib/typescript/contexts/DisplayModeContext.d.ts.map +1 -1
  224. package/lib/typescript/shared/styles.d.ts +18 -0
  225. package/lib/typescript/shared/styles.d.ts.map +1 -0
  226. package/lib/typescript/{utils.d.ts → shared/utils.d.ts} +2 -2
  227. package/lib/typescript/shared/utils.d.ts.map +1 -0
  228. package/package.json +17 -17
  229. package/src/Date/AnimatedCrossView.tsx +9 -10
  230. package/src/Date/AutoSizer.tsx +12 -13
  231. package/src/Date/Calendar.tsx +29 -35
  232. package/src/Date/CalendarEdit.tsx +18 -15
  233. package/src/Date/CalendarHeader.tsx +9 -18
  234. package/src/Date/DatePickerInput.shared.tsx +3 -3
  235. package/src/Date/DatePickerInput.tsx +11 -8
  236. package/src/Date/DatePickerInputWithoutModal.tsx +3 -4
  237. package/src/Date/DatePickerModal.tsx +14 -23
  238. package/src/Date/DatePickerModalContent.tsx +10 -13
  239. package/src/Date/DatePickerModalContentHeader.tsx +31 -43
  240. package/src/Date/DatePickerModalHeader.tsx +4 -23
  241. package/src/Date/DatePickerModalHeaderBackground.tsx +3 -2
  242. package/src/Date/DatePickerModalStatusBar.tsx +4 -4
  243. package/src/Date/Day.tsx +22 -24
  244. package/src/Date/DayName.tsx +12 -4
  245. package/src/Date/DayNames.tsx +7 -6
  246. package/src/Date/DayRange.tsx +6 -11
  247. package/src/Date/Month.tsx +24 -21
  248. package/src/Date/Swiper.native.tsx +19 -20
  249. package/src/Date/Swiper.tsx +32 -29
  250. package/src/Date/SwiperUtils.ts +3 -4
  251. package/src/Date/YearPicker.tsx +11 -16
  252. package/src/Date/dateUtils.tsx +18 -11
  253. package/src/Date/inputUtils.ts +7 -5
  254. package/src/TextInputMask.tsx +10 -11
  255. package/src/Time/AmPmSwitcher.tsx +9 -7
  256. package/src/Time/AnalogClock.tsx +38 -24
  257. package/src/Time/AnalogClockHours.tsx +10 -20
  258. package/src/Time/AnalogClockMinutes.tsx +19 -32
  259. package/src/Time/AnimatedClockSwitcher.tsx +9 -5
  260. package/src/Time/TimeInput.tsx +22 -19
  261. package/src/Time/TimeInputs.tsx +28 -34
  262. package/src/Time/TimePicker.tsx +15 -10
  263. package/src/Time/TimePickerModal.tsx +48 -72
  264. package/src/Time/timeUtils.ts +5 -6
  265. package/src/contexts/DisplayModeContext.tsx +3 -3
  266. package/src/shared/styles.tsx +19 -0
  267. package/src/{utils.ts → shared/utils.ts} +16 -2
  268. package/lib/commonjs/Date/Week.js +0 -10
  269. package/lib/commonjs/Date/Week.js.map +0 -1
  270. package/lib/commonjs/utils.js.map +0 -1
  271. package/lib/module/Date/Week.js +0 -4
  272. package/lib/module/Date/Week.js.map +0 -1
  273. package/lib/module/utils.js.map +0 -1
  274. package/lib/typescript/Date/Week.d.ts +0 -2
  275. package/lib/typescript/Date/Week.d.ts.map +0 -1
  276. package/lib/typescript/utils.d.ts.map +0 -1
  277. package/src/Date/Week.tsx +0 -3
@@ -1,4 +1,3 @@
1
- import * as React from 'react'
2
1
  import { StyleSheet, View } from 'react-native'
3
2
  import {
4
3
  Text,
@@ -34,7 +33,10 @@ import type {
34
33
  ValidRangeType,
35
34
  } from './Calendar'
36
35
  import { dayNamesHeight } from './DayNames'
37
- import { useTextColorOnPrimary } from '../utils'
36
+ import { useTextColorOnPrimary } from '../shared/utils'
37
+ import { memo, useMemo } from 'react'
38
+ import React from 'react'
39
+ import { sharedStyles } from '../shared/styles'
38
40
 
39
41
  interface BaseMonthProps {
40
42
  locale: undefined | string
@@ -50,7 +52,6 @@ interface BaseMonthProps {
50
52
  roundness: number
51
53
  validRange?: ValidRangeType
52
54
  startWeekOnMonday: boolean
53
-
54
55
  // some of these should be required in final implementation
55
56
  startDate?: CalendarDate
56
57
  endDate?: CalendarDate
@@ -94,12 +95,14 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
94
95
  validRange,
95
96
  startWeekOnMonday,
96
97
  } = props
98
+ const isHorizontal = scrollMode === 'horizontal'
99
+
97
100
  const theme = useTheme()
98
101
  const textColorOnPrimary = useTextColorOnPrimary()
99
102
  const realIndex = getRealIndex(index)
100
- const isHorizontal = scrollMode === 'horizontal'
101
103
  const { isDisabled, isWithinValidRange } = useRangeChecker(validRange)
102
- const { monthName, month, year } = React.useMemo(() => {
104
+
105
+ const { monthName, month, year } = useMemo(() => {
103
106
  const md = addMonths(new Date(), realIndex)
104
107
  const y = md.getFullYear()
105
108
  const m = md.getMonth()
@@ -109,7 +112,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
109
112
  return { monthName: formatter.format(md), month: m, year: y }
110
113
  }, [realIndex, locale])
111
114
 
112
- const grid = React.useMemo(() => {
115
+ const grid = useMemo(() => {
113
116
  const today = new Date()
114
117
 
115
118
  const daysInMonth = getDaysInMonth({ year, month })
@@ -267,10 +270,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
267
270
 
268
271
  return (
269
272
  <View
270
- style={[
271
- styles.month,
272
- { height: getMonthHeight(scrollMode, index, startWeekOnMonday) },
273
- ]}
273
+ style={{ height: getMonthHeight(scrollMode, index, startWeekOnMonday) }}
274
274
  >
275
275
  <View
276
276
  style={[
@@ -321,7 +321,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
321
321
  <View
322
322
  style={[
323
323
  styles.iconWrapper,
324
- isHorizontal ? styles.opacity1 : styles.opacity0,
324
+ isHorizontal ? sharedStyles.opacity1 : sharedStyles.opacity0,
325
325
  ]}
326
326
  >
327
327
  <Icon size={24} color={iconColor} source={iconSource} />
@@ -374,26 +374,29 @@ const styles = StyleSheet.create({
374
374
  iconWrapper: {
375
375
  padding: 8,
376
376
  },
377
+ monthHeader: {
378
+ height: montHeaderHeight,
379
+ justifyContent: 'center',
380
+ overflow: 'hidden',
381
+ },
382
+ monthLabel: {
383
+ fontSize: 14,
384
+ opacity: 0.7,
385
+ },
377
386
  week: {
378
387
  flexDirection: 'row',
379
388
  marginBottom: weekMargin,
380
389
  height: daySize,
381
390
  },
382
- month: {},
383
- monthHeader: {
384
- height: montHeaderHeight,
385
- justifyContent: 'center',
386
- overflow: 'hidden',
391
+ yearButton: {
392
+ alignSelf: 'flex-start',
393
+ marginLeft: 6,
387
394
  },
388
- monthLabel: { fontSize: 14, opacity: 0.7 },
389
- yearButton: { alignSelf: 'flex-start', marginLeft: 6 },
390
395
  yearButtonInner: {
391
396
  paddingLeft: 16,
392
397
  flexDirection: 'row',
393
398
  alignItems: 'center',
394
399
  },
395
- opacity0: { opacity: 0 },
396
- opacity1: { opacity: 1 },
397
400
  })
398
401
 
399
402
  const monthGrid = (index: number, startWeekOnMonday: boolean) => {
@@ -487,4 +490,4 @@ export function getMonthHeight(
487
490
  return c || 0
488
491
  }
489
492
 
490
- export default React.memo(Month)
493
+ export default memo(Month)
@@ -1,4 +1,3 @@
1
- import * as React from 'react'
2
1
  import {
3
2
  NativeScrollEvent,
4
3
  NativeSyntheticEvent,
@@ -17,15 +16,9 @@ import {
17
16
  import { SwiperProps, useYearChange } from './SwiperUtils'
18
17
  import { beginOffset, estimatedMonthHeight, totalMonths } from './dateUtils'
19
18
  import AutoSizer from './AutoSizer'
20
-
21
- const styles = StyleSheet.create({
22
- viewPager: {
23
- flex: 1,
24
- },
25
- inner: {
26
- position: 'relative',
27
- },
28
- })
19
+ import { memo, useCallback, useRef, useState } from 'react'
20
+ import React from 'react'
21
+ import { sharedStyles } from '../shared/styles'
29
22
 
30
23
  function getVisibleArray(
31
24
  i: number,
@@ -58,15 +51,15 @@ function SwiperInner({
58
51
  height,
59
52
  startWeekOnMonday,
60
53
  }: SwiperProps & { width: number; height: number }) {
61
- const idx = React.useRef<number>(initialIndex)
54
+ const idx = useRef<number>(initialIndex)
62
55
  const isHorizontal = scrollMode === 'horizontal'
63
- const [visibleIndexes, setVisibleIndexes] = React.useState<number[]>(
56
+ const [visibleIndexes, setVisibleIndexes] = useState<number[]>(
64
57
  getVisibleArray(initialIndex, { isHorizontal, height })
65
58
  )
66
59
 
67
- const parentRef = React.useRef<ScrollView | null>(null)
60
+ const parentRef = useRef<ScrollView | null>(null)
68
61
 
69
- const scrollTo = React.useCallback(
62
+ const scrollTo = useCallback(
70
63
  (index: number, animated: boolean) => {
71
64
  idx.current = index
72
65
  setVisibleIndexes(getVisibleArray(index, { isHorizontal, height }))
@@ -95,19 +88,19 @@ function SwiperInner({
95
88
  [parentRef, isHorizontal, width, height, startWeekOnMonday]
96
89
  )
97
90
 
98
- const onPrev = React.useCallback(() => {
91
+ const onPrev = useCallback(() => {
99
92
  scrollTo(idx.current - 1, true)
100
93
  }, [scrollTo, idx])
101
94
 
102
- const onNext = React.useCallback(() => {
95
+ const onNext = useCallback(() => {
103
96
  scrollTo(idx.current + 1, true)
104
97
  }, [scrollTo, idx])
105
98
 
106
- const scrollToInitial = React.useCallback(() => {
99
+ const scrollToInitial = useCallback(() => {
107
100
  scrollTo(idx.current, false)
108
101
  }, [scrollTo])
109
102
 
110
- const onMomentumScrollEnd = React.useCallback(
103
+ const onMomentumScrollEnd = useCallback(
111
104
  (e: NativeSyntheticEvent<NativeScrollEvent>) => {
112
105
  const contentOffset = e.nativeEvent.contentOffset
113
106
  const viewSize = e.nativeEvent.layoutMeasurement
@@ -155,7 +148,7 @@ function SwiperInner({
155
148
  ref={parentRef}
156
149
  horizontal={isHorizontal}
157
150
  pagingEnabled={isHorizontal}
158
- style={styles.viewPager}
151
+ style={sharedStyles.root}
159
152
  onMomentumScrollEnd={onMomentumScrollEnd}
160
153
  onScrollEndDrag={onMomentumScrollEnd}
161
154
  onLayout={scrollToInitial}
@@ -219,4 +212,10 @@ function SwiperInner({
219
212
  )
220
213
  }
221
214
 
222
- export default React.memo(Swiper)
215
+ const styles = StyleSheet.create({
216
+ inner: {
217
+ position: 'relative',
218
+ },
219
+ })
220
+
221
+ export default memo(Swiper)
@@ -1,17 +1,27 @@
1
- import * as React from 'react'
2
- import { StyleSheet, View } from 'react-native'
3
-
1
+ import { View } from 'react-native'
4
2
  import {
5
3
  getIndexFromVerticalOffset,
6
4
  getMonthHeight,
7
5
  getVerticalMonthsOffset,
8
6
  montHeaderHeight,
9
7
  } from './Month'
10
-
11
8
  import { beginOffset, estimatedMonthHeight, totalMonths } from './dateUtils'
12
- import { useLatest } from '../utils'
9
+ import { useLatest } from '../shared/utils'
13
10
  import { RenderProps, SwiperProps, useYearChange } from './SwiperUtils'
14
11
  import AutoSizer from './AutoSizer'
12
+ import React, {
13
+ memo,
14
+ useCallback,
15
+ useEffect,
16
+ useLayoutEffect,
17
+ useRef,
18
+ useState,
19
+ UIEvent,
20
+ } from 'react'
21
+ import { sharedStyles } from '../shared/styles'
22
+
23
+ const useIsomorphicLayoutEffect =
24
+ typeof window !== 'undefined' ? useLayoutEffect : useEffect
15
25
 
16
26
  function Swiper({
17
27
  scrollMode,
@@ -23,13 +33,14 @@ function Swiper({
23
33
  startWeekOnMonday,
24
34
  }: SwiperProps) {
25
35
  const isHorizontal = scrollMode === 'horizontal'
26
- const [index, setIndex] = React.useState(initialIndex)
27
36
 
28
- const onPrev = React.useCallback(() => {
37
+ const [index, setIndex] = useState(initialIndex)
38
+
39
+ const onPrev = useCallback(() => {
29
40
  setIndex((prev) => prev - 1)
30
41
  }, [setIndex])
31
42
 
32
- const onNext = React.useCallback(() => {
43
+ const onNext = useCallback(() => {
33
44
  setIndex((prev) => prev + 1)
34
45
  }, [setIndex])
35
46
 
@@ -55,7 +66,7 @@ function Swiper({
55
66
  <>
56
67
  {renderHeader && renderHeader(renderProps)}
57
68
  {isHorizontal ? (
58
- <View style={styles.flex1}>
69
+ <View style={sharedStyles.root}>
59
70
  {renderItem({ index, onPrev, onNext })}
60
71
  </View>
61
72
  ) : (
@@ -94,11 +105,12 @@ function VerticalScroller({
94
105
  estimatedHeight: number
95
106
  startWeekOnMonday: boolean
96
107
  }) {
97
- const idx = React.useRef<number>(initialIndex)
98
- const [visibleIndexes, setVisibleIndexes] = React.useState<number[]>(
108
+ const [visibleIndexes, setVisibleIndexes] = useState<number[]>(
99
109
  visibleArray(initialIndex)
100
110
  )
101
- const parentRef = React.useRef<HTMLDivElement | null>(null)
111
+
112
+ const idx = useRef<number>(initialIndex)
113
+ const parentRef = useRef<HTMLDivElement | null>(null)
102
114
 
103
115
  useIsomorphicLayoutEffect(() => {
104
116
  const element = parentRef.current
@@ -115,9 +127,9 @@ function VerticalScroller({
115
127
 
116
128
  const setVisibleIndexesThrottled = useDebouncedCallback(setVisibleIndexes)
117
129
 
118
- const onScroll = React.useCallback(
119
- (e: React.UIEvent) => {
120
- const top = e.currentTarget.scrollTop
130
+ const onScroll = useCallback(
131
+ (e: UIEvent) => {
132
+ const top = e.currentTarget?.scrollTop
121
133
  if (top === 0) {
122
134
  return
123
135
  }
@@ -185,18 +197,12 @@ function VerticalScroller({
185
197
 
186
198
  const empty = () => null
187
199
 
188
- const styles = StyleSheet.create({
189
- flex1: {
190
- flex: 1,
191
- },
192
- })
193
-
194
200
  export function useDebouncedCallback(callback: any): any {
195
- const mounted = React.useRef<boolean>(true)
201
+ const mounted = useRef<boolean>(true)
202
+ const timerId = useRef<any>(null)
196
203
  const latest = useLatest(callback)
197
- const timerId = React.useRef<any>(null)
198
204
 
199
- React.useEffect(() => {
205
+ useEffect(() => {
200
206
  return () => {
201
207
  mounted.current = false
202
208
  if (timerId.current) {
@@ -205,7 +211,7 @@ export function useDebouncedCallback(callback: any): any {
205
211
  }
206
212
  }, [mounted, timerId])
207
213
 
208
- return React.useCallback(
214
+ return useCallback(
209
215
  (args: any) => {
210
216
  if (timerId.current) {
211
217
  window.cancelAnimationFrame(timerId.current)
@@ -220,7 +226,4 @@ export function useDebouncedCallback(callback: any): any {
220
226
  )
221
227
  }
222
228
 
223
- const useIsomorphicLayoutEffect =
224
- typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect
225
-
226
- export default React.memo(Swiper)
229
+ export default memo(Swiper)
@@ -1,6 +1,5 @@
1
- import type { MutableRefObject } from 'react'
2
- import { useLatest } from '../utils'
3
- import * as React from 'react'
1
+ import { useEffect, type MutableRefObject } from 'react'
2
+ import { useLatest } from '../shared/utils'
4
3
  import {
5
4
  addMonths,
6
5
  differenceInMonths,
@@ -35,7 +34,7 @@ export function useYearChange(
35
34
  }
36
35
  ) {
37
36
  const onChangeRef = useLatest(onChange)
38
- React.useEffect(() => {
37
+ useEffect(() => {
39
38
  if (selectedYear) {
40
39
  const currentIndex = currentIndexRef.current || 0
41
40
  const currentDate = addMonths(new Date(), getRealIndex(currentIndex))
@@ -1,7 +1,9 @@
1
- import * as React from 'react'
2
1
  import { FlatList, StyleSheet, View, ScrollView } from 'react-native'
3
2
  import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
4
- import { range } from '../utils'
3
+ import { range } from '../shared/utils'
4
+ import { memo, useEffect, useRef } from 'react'
5
+ import React from 'react'
6
+ import { sharedStyles } from '../shared/styles'
5
7
 
6
8
  const ITEM_HEIGHT = 62
7
9
 
@@ -19,14 +21,15 @@ export default function YearPicker({
19
21
  endYear: number
20
22
  }) {
21
23
  const theme = useTheme()
22
- const flatList = React.useRef<FlatList<number> | null>(null)
24
+
25
+ const flatList = useRef<FlatList<number> | null>(null)
23
26
  const years = range(
24
27
  isNaN(startYear) ? 1800 : startYear,
25
28
  isNaN(endYear) ? 2200 : endYear
26
29
  )
27
30
 
28
31
  // scroll to selected year
29
- React.useEffect(() => {
32
+ useEffect(() => {
30
33
  if (flatList.current && selectedYear) {
31
34
  const indexToGo = selectedYear - startYear
32
35
  flatList.current.scrollToOffset({
@@ -42,13 +45,13 @@ export default function YearPicker({
42
45
  StyleSheet.absoluteFill,
43
46
  styles.root,
44
47
  { backgroundColor: theme.colors.surface },
45
- selectingYear ? styles.opacity1 : styles.opacity0,
48
+ selectingYear ? sharedStyles.opacity1 : sharedStyles.opacity0,
46
49
  ]}
47
50
  pointerEvents={selectingYear ? 'auto' : 'none'}
48
51
  >
49
52
  <FlatList<number>
50
53
  ref={flatList}
51
- style={styles.list}
54
+ style={sharedStyles.root}
52
55
  data={years}
53
56
  renderScrollComponent={(sProps) => {
54
57
  return <ScrollView {...sProps} />
@@ -119,7 +122,6 @@ function YearPure({
119
122
  </View>
120
123
  )
121
124
  }
122
- const Year = React.memo(YearPure)
123
125
 
124
126
  const styles = StyleSheet.create({
125
127
  root: {
@@ -127,9 +129,6 @@ const styles = StyleSheet.create({
127
129
  top: 56,
128
130
  zIndex: 100,
129
131
  },
130
- list: {
131
- flex: 1,
132
- },
133
132
  year: {
134
133
  flex: 1,
135
134
  marginLeft: 16,
@@ -150,10 +149,6 @@ const styles = StyleSheet.create({
150
149
  yearLabel: {
151
150
  fontSize: 16,
152
151
  },
153
- opacity0: {
154
- opacity: 0,
155
- },
156
- opacity1: {
157
- opacity: 1,
158
- },
159
152
  })
153
+
154
+ const Year = memo(YearPure)
@@ -1,5 +1,5 @@
1
- import * as React from 'react'
2
- import { useLatest } from '../utils'
1
+ import { useCallback, useMemo } from 'react'
2
+ import { useLatest } from '../shared/utils'
3
3
  import type { ValidRangeType } from './Calendar'
4
4
 
5
5
  export type DisableWeekDaysType = number[]
@@ -86,7 +86,7 @@ export function useRangeChecker(validRange: ValidRangeType | undefined) {
86
86
 
87
87
  const validDisabledDatesRef = useLatest(validRange?.disabledDates)
88
88
 
89
- const isWithinValidRange = React.useCallback(
89
+ const isWithinValidRange = useCallback(
90
90
  (day: Date) => {
91
91
  return isDateWithinOptionalRange(day, {
92
92
  startUnix: startUnix,
@@ -96,7 +96,7 @@ export function useRangeChecker(validRange: ValidRangeType | undefined) {
96
96
  [startUnix, endUnix]
97
97
  )
98
98
 
99
- const isDisabled = React.useCallback(
99
+ const isDisabled = useCallback(
100
100
  (day: Date) => {
101
101
  return validDisabledDatesRef.current
102
102
  ? validDisabledDatesRef.current.some((disabledDate) =>
@@ -116,9 +116,9 @@ export function areDatesOnSameDay(a: Date, b?: Date | null | undefined) {
116
116
  }
117
117
 
118
118
  return (
119
- a.getUTCFullYear() === b.getUTCFullYear() &&
120
- a.getUTCMonth() === b.getUTCMonth() &&
121
- a.getUTCDate() === b.getUTCDate()
119
+ a.getFullYear() === b.getFullYear() &&
120
+ a.getMonth() === b.getMonth() &&
121
+ a.getDate() === b.getDate()
122
122
  )
123
123
  }
124
124
 
@@ -210,7 +210,7 @@ export function getInitialIndex(date: Date | undefined) {
210
210
  }
211
211
 
212
212
  export function useInputFormatter({ locale }: { locale: string | undefined }) {
213
- return React.useMemo(() => {
213
+ return useMemo(() => {
214
214
  return new Intl.DateTimeFormat(locale, {
215
215
  month: '2-digit',
216
216
  day: '2-digit',
@@ -218,12 +218,19 @@ export function useInputFormatter({ locale }: { locale: string | undefined }) {
218
218
  })
219
219
  }, [locale])
220
220
  }
221
+
221
222
  export function getStartOfDay(d: Date): Date {
222
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0)
223
+ const startOfDay = new Date(d)
224
+ startOfDay.setUTCHours(0, 0, 0, 0)
225
+ return startOfDay
223
226
  }
227
+
224
228
  export function getEndOfDay(d: Date): Date {
225
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59)
229
+ const endOfDay = new Date(d)
230
+ endOfDay.setUTCHours(23, 59, 59, 999)
231
+ return endOfDay
226
232
  }
233
+
227
234
  export function useInputFormat({
228
235
  formatter,
229
236
  locale,
@@ -231,7 +238,7 @@ export function useInputFormat({
231
238
  formatter: Intl.DateTimeFormat
232
239
  locale: string | undefined
233
240
  }) {
234
- return React.useMemo(() => {
241
+ return useMemo(() => {
235
242
  // TODO: something cleaner and more universal?
236
243
  const inputDate = formatter.format(new Date(2020, 10 - 1, 1))
237
244
  return inputDate
@@ -1,7 +1,7 @@
1
1
  import { useInputFormat, useInputFormatter, useRangeChecker } from './dateUtils'
2
- import * as React from 'react'
3
2
  import type { ValidRangeType } from './Calendar'
4
3
  import { getTranslation } from '../translations/utils'
4
+ import { useState } from 'react'
5
5
 
6
6
  export default function useDateInput({
7
7
  locale,
@@ -18,12 +18,15 @@ export default function useDateInput({
18
18
  inputMode: 'start' | 'end'
19
19
  onValidationError?: ((error: string | null) => void) | undefined
20
20
  }) {
21
- const { isDisabled, isWithinValidRange, validStart, validEnd } =
22
- useRangeChecker(validRange)
23
- const [error, setError] = React.useState<null | string>(null)
24
21
  const formatter = useInputFormatter({ locale })
25
22
  const inputFormat = useInputFormat({ formatter, locale })
26
23
  const formattedValue = value ? formatter.format(value) : ''
24
+
25
+ const [error, setError] = useState<null | string>(null)
26
+
27
+ const { isDisabled, isWithinValidRange, validStart, validEnd } =
28
+ useRangeChecker(validRange)
29
+
27
30
  const onChangeText = (date: string) => {
28
31
  const dayIndex = inputFormat.indexOf('DD')
29
32
  const monthIndex = inputFormat.indexOf('MM')
@@ -31,7 +34,6 @@ export default function useDateInput({
31
34
  locale === 'pt'
32
35
  ? inputFormat.indexOf('AAAA')
33
36
  : inputFormat.indexOf('YYYY')
34
-
35
37
  const day = Number(date.slice(dayIndex, dayIndex + 2))
36
38
  const year = Number(date.slice(yearIndex, yearIndex + 4))
37
39
  const month = Number(date.slice(monthIndex, monthIndex + 2))
@@ -1,4 +1,5 @@
1
- import * as React from 'react'
1
+ import React, { ComponentProps, ReactNode, useEffect, useState } from 'react'
2
+ import { forwardRef } from 'react'
2
3
  import { TextInput } from 'react-native-paper'
3
4
 
4
5
  const splitCharacters = ['-', '/', '.', '年', ' ']
@@ -20,16 +21,18 @@ function TextInputWithMask(
20
21
  mask,
21
22
  disabled,
22
23
  ...rest
23
- }: React.ComponentProps<typeof TextInput> & {
24
+ }: ComponentProps<typeof TextInput> & {
24
25
  mask: string
25
26
  value: string
26
- inputButton: React.ReactNode
27
+ inputButton: ReactNode
27
28
  },
28
29
  ref: any
29
30
  ) {
30
- const [controlledValue, setControlledValue] = React.useState<string>(
31
- value || ''
32
- )
31
+ const [controlledValue, setControlledValue] = useState(value || '')
32
+
33
+ useEffect(() => {
34
+ setControlledValue(value || '')
35
+ }, [value])
33
36
 
34
37
  const onInnerChange = (text: string) => {
35
38
  const splitCharacter = detectCharacter(mask)
@@ -69,10 +72,6 @@ function TextInputWithMask(
69
72
  setControlledValue(trimmedText)
70
73
  }
71
74
 
72
- React.useEffect(() => {
73
- setControlledValue(value || '')
74
- }, [value])
75
-
76
75
  return (
77
76
  <TextInput
78
77
  ref={ref}
@@ -89,4 +88,4 @@ function TextInputWithMask(
89
88
  )
90
89
  }
91
90
 
92
- export default React.forwardRef(TextInputWithMask)
91
+ export default forwardRef(TextInputWithMask)
@@ -1,10 +1,11 @@
1
- import * as React from 'react'
2
1
  import { View, StyleSheet } from 'react-native'
3
2
  import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
4
- import { useMemo } from 'react'
3
+ import { useContext, useMemo } from 'react'
5
4
  import Color from 'color'
6
5
  import { inputTypes, PossibleInputTypes, useSwitchColors } from './timeUtils'
7
6
  import { DisplayModeContext } from '../contexts/DisplayModeContext'
7
+ import React from 'react'
8
+ import { sharedStyles } from '../shared/styles'
8
9
 
9
10
  export default function AmPmSwitcher({
10
11
  onChange,
@@ -15,8 +16,10 @@ export default function AmPmSwitcher({
15
16
  onChange: (newHours: number) => any
16
17
  inputType: PossibleInputTypes
17
18
  }) {
18
- const { setMode, mode } = React.useContext(DisplayModeContext)
19
19
  const theme = useTheme()
20
+
21
+ const { setMode, mode } = useContext(DisplayModeContext)
22
+
20
23
  const backgroundColor = useMemo<string>(() => {
21
24
  if (theme.isV3) {
22
25
  return theme.colors.outline
@@ -31,6 +34,7 @@ export default function AmPmSwitcher({
31
34
  }, [theme])
32
35
 
33
36
  const isAM = mode === 'AM'
37
+
34
38
  return (
35
39
  <View
36
40
  style={[
@@ -83,6 +87,7 @@ function SwitchButton({
83
87
  disabled: boolean
84
88
  }) {
85
89
  const theme = useTheme()
90
+
86
91
  const { backgroundColor, color } = useSwitchColors(selected)
87
92
 
88
93
  let textFont = theme?.isV3
@@ -92,7 +97,7 @@ function SwitchButton({
92
97
  return (
93
98
  <TouchableRipple
94
99
  onPress={onPress}
95
- style={styles.switchButton}
100
+ style={sharedStyles.root}
96
101
  accessibilityLabel={label}
97
102
  // @ts-ignore old React Native versions
98
103
  accessibilityTraits={disabled ? ['button', 'disabled'] : 'button'}
@@ -130,9 +135,6 @@ const styles = StyleSheet.create({
130
135
  height: 1,
131
136
  width: 52,
132
137
  },
133
- switchButton: {
134
- flex: 1,
135
- },
136
138
  switchButtonInner: {
137
139
  flex: 1,
138
140
  alignItems: 'center',