react-native-paper-dates 0.22.15 → 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 +12 -10
  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 +12 -8
  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 +15 -8
  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 {
3
2
  Modal,
4
3
  StyleSheet,
@@ -13,6 +12,9 @@ import DatePickerModalContent, {
13
12
  DatePickerModalContentRangeProps,
14
13
  DatePickerModalContentSingleProps,
15
14
  } from './DatePickerModalContent'
15
+ import React, { memo } from 'react'
16
+ import { sharedStyles } from '../shared/styles'
17
+ import { supportedOrientations } from '../shared/utils'
16
18
 
17
19
  interface DatePickerModalProps {
18
20
  visible: boolean
@@ -41,8 +43,6 @@ export function DatePickerModal(
41
43
  | DatePickerModalSingleProps
42
44
  | DatePickerModalMultiProps
43
45
  ) {
44
- const theme = useTheme()
45
- const dimensions = useWindowDimensions()
46
46
  const {
47
47
  visible,
48
48
  animationType,
@@ -59,11 +59,13 @@ export function DatePickerModal(
59
59
  web: 'none',
60
60
  default: 'slide',
61
61
  })
62
-
63
62
  const isPageSheet = presentationStyle === 'pageSheet' && Platform.OS === 'ios'
64
63
 
64
+ const theme = useTheme()
65
+ const dimensions = useWindowDimensions()
66
+
65
67
  return (
66
- <View style={[StyleSheet.absoluteFill]} pointerEvents="box-none">
68
+ <View style={StyleSheet.absoluteFill} pointerEvents="box-none">
67
69
  <Modal
68
70
  animationType={animationTypeCalculated}
69
71
  transparent={!isPageSheet}
@@ -77,7 +79,7 @@ export function DatePickerModal(
77
79
  <View
78
80
  style={[
79
81
  StyleSheet.absoluteFill,
80
- styles.modalBackground,
82
+ sharedStyles.root,
81
83
  { backgroundColor: theme.colors.backdrop },
82
84
  ]}
83
85
  />
@@ -107,23 +109,7 @@ export function DatePickerModal(
107
109
  )
108
110
  }
109
111
 
110
- const supportedOrientations: any = [
111
- 'portrait',
112
- 'portrait-upside-down',
113
- 'landscape',
114
- 'landscape-left',
115
- 'landscape-right',
116
- ]
117
-
118
112
  const styles = StyleSheet.create({
119
- modalRoot: {
120
- justifyContent: 'center',
121
- alignItems: 'center',
122
- flex: 1,
123
- },
124
- modalBackground: {
125
- flex: 1,
126
- },
127
113
  modalContent: {
128
114
  flex: 1,
129
115
  width: '100%',
@@ -135,6 +121,11 @@ const styles = StyleSheet.create({
135
121
  width: '100%',
136
122
  overflow: 'hidden',
137
123
  },
124
+ modalRoot: {
125
+ justifyContent: 'center',
126
+ alignItems: 'center',
127
+ flex: 1,
128
+ },
138
129
  })
139
130
 
140
- export default React.memo(DatePickerModal)
131
+ export default memo(DatePickerModal)
@@ -1,5 +1,3 @@
1
- import * as React from 'react'
2
-
3
1
  import Calendar, {
4
2
  BaseCalendarProps,
5
3
  CalendarDate,
@@ -19,6 +17,7 @@ import CalendarEdit from './CalendarEdit'
19
17
  import DatePickerModalHeaderBackground from './DatePickerModalHeaderBackground'
20
18
  import { useTheme } from 'react-native-paper'
21
19
  import DatePickerModalStatusBar from './DatePickerModalStatusBar'
20
+ import React, { memo, useCallback, useEffect, useState } from 'react'
22
21
 
23
22
  export type LocalState = {
24
23
  startDate: CalendarDate
@@ -95,18 +94,21 @@ export function DatePickerModalContent(
95
94
  statusBarOnTopOfBackdrop,
96
95
  startWeekOnMonday,
97
96
  } = props
97
+ const theme = useTheme()
98
98
  const anyProps = props as any
99
+ const defaultUppercase = !theme.isV3
99
100
 
100
101
  // use local state to add only onConfirm state changes
101
- const [state, setState] = React.useState<LocalState>({
102
+ const [state, setState] = useState<LocalState>({
102
103
  date: anyProps.date,
103
104
  startDate: anyProps.startDate,
104
105
  endDate: anyProps.endDate,
105
106
  dates: anyProps.dates,
106
107
  })
108
+ const [collapsed, setCollapsed] = useState(true)
107
109
 
108
110
  // update local state if changed from outside or if modal is opened
109
- React.useEffect(() => {
111
+ useEffect(() => {
110
112
  setState({
111
113
  date: anyProps.date,
112
114
  startDate: anyProps.startDate,
@@ -115,9 +117,7 @@ export function DatePickerModalContent(
115
117
  })
116
118
  }, [anyProps.date, anyProps.startDate, anyProps.endDate, anyProps.dates])
117
119
 
118
- const [collapsed, setCollapsed] = React.useState<boolean>(true)
119
-
120
- const onInnerChange = React.useCallback(
120
+ const onInnerChange = useCallback(
121
121
  (params: any) => {
122
122
  onChange && onChange(params)
123
123
  setState((prev) => ({ ...prev, ...params }))
@@ -125,7 +125,7 @@ export function DatePickerModalContent(
125
125
  [onChange, setState]
126
126
  )
127
127
 
128
- const onInnerConfirm = React.useCallback(() => {
128
+ const onInnerConfirm = useCallback(() => {
129
129
  if (mode === 'single') {
130
130
  ;(onConfirm as DatePickerModalContentSingleProps['onConfirm'])({
131
131
  date: state.date,
@@ -142,13 +142,10 @@ export function DatePickerModalContent(
142
142
  }
143
143
  }, [state, mode, onConfirm])
144
144
 
145
- const onToggleCollapse = React.useCallback(() => {
145
+ const onToggleCollapse = useCallback(() => {
146
146
  setCollapsed((prev) => !prev)
147
147
  }, [setCollapsed])
148
148
 
149
- const theme = useTheme()
150
- const defaultUppercase = !theme.isV3
151
-
152
149
  return (
153
150
  <>
154
151
  <DatePickerModalHeaderBackground>
@@ -222,4 +219,4 @@ export function DatePickerModalContent(
222
219
  )
223
220
  }
224
221
 
225
- export default React.memo(DatePickerModalContent)
222
+ export default memo(DatePickerModalContent)
@@ -1,11 +1,12 @@
1
- import * as React from 'react'
2
1
  import { View, StyleSheet } from 'react-native'
3
2
  import { IconButton, MD2Theme, Text, useTheme } from 'react-native-paper'
4
3
  import type { ModeType } from './Calendar'
5
4
  import type { LocalState } from './DatePickerModalContent'
6
- import { useHeaderTextColor } from '../utils'
5
+ import { useHeaderTextColor } from '../shared/utils'
7
6
  import Color from 'color'
8
7
  import { getTranslation } from '../translations/utils'
8
+ import React, { useMemo } from 'react'
9
+ import { sharedStyles } from '../shared/styles'
9
10
 
10
11
  export interface HeaderPickProps {
11
12
  moreLabel?: string
@@ -65,21 +66,17 @@ export default function DatePickerModalContentHeader(
65
66
  } = props
66
67
  const theme = useTheme()
67
68
  const label = getLabel(props.locale, props.mode, props.label)
68
-
69
69
  const color = useHeaderTextColor()
70
-
71
70
  const isEditingEnabled = allowEditing && mode !== 'multiple'
72
-
73
71
  const supportingTextColor = theme.isV3 ? theme.colors.onSurfaceVariant : color
74
-
75
72
  const textFont = theme?.isV3
76
73
  ? theme.fonts.labelMedium
77
74
  : (theme as any as MD2Theme).fonts.medium
78
-
79
75
  const collapsedIcon = theme.isV3 ? 'pencil-outline' : 'pencil'
80
76
  const expandedIcon = theme.isV3 ? 'calendar-blank' : 'calendar'
81
77
  const finalCollapsedIcon = editIcon ?? collapsedIcon
82
78
  const finalExpandedIcon = calendarIcon ?? expandedIcon
79
+
83
80
  return (
84
81
  <View style={styles.header}>
85
82
  <View>
@@ -105,7 +102,7 @@ export default function DatePickerModalContentHeader(
105
102
  ) : null}
106
103
  </View>
107
104
  </View>
108
- <View style={styles.fill} />
105
+ <View style={sharedStyles.root} />
109
106
  {isEditingEnabled ? (
110
107
  <IconButton
111
108
  icon={collapsed ? finalCollapsedIcon : finalExpandedIcon}
@@ -129,6 +126,7 @@ export function HeaderContentSingle({
129
126
  locale,
130
127
  }: HeaderContentProps & { color: string }) {
131
128
  const theme = useTheme()
129
+
132
130
  const lighterColor = Color(color).fade(0.5).rgb().toString()
133
131
  const dateColor = state.date
134
132
  ? theme.isV3
@@ -136,7 +134,7 @@ export function HeaderContentSingle({
136
134
  : color
137
135
  : lighterColor
138
136
 
139
- const formatter = React.useMemo(() => {
137
+ const formatter = useMemo(() => {
140
138
  return new Intl.DateTimeFormat(locale, {
141
139
  month: 'short',
142
140
  day: 'numeric',
@@ -146,7 +144,7 @@ export function HeaderContentSingle({
146
144
  return (
147
145
  <Text
148
146
  maxFontSizeMultiplier={1.5}
149
- style={[styles.singleHeaderText, { color: dateColor }]}
147
+ style={[styles.text, { color: dateColor }]}
150
148
  >
151
149
  {state.date ? formatter.format(state.date) : emptyLabel}
152
150
  </Text>
@@ -161,6 +159,7 @@ export function HeaderContentMulti({
161
159
  locale,
162
160
  }: HeaderContentProps & { color: string; moreLabel: string | undefined }) {
163
161
  const theme = useTheme()
162
+
164
163
  const dateCount = state.dates?.length || 0
165
164
  const lighterColor = Color(color).fade(0.5).rgb().toString()
166
165
  const dateColor = dateCount
@@ -169,7 +168,7 @@ export function HeaderContentMulti({
169
168
  : color
170
169
  : lighterColor
171
170
 
172
- const formatter = React.useMemo(() => {
171
+ const formatter = useMemo(() => {
173
172
  return new Intl.DateTimeFormat(locale, {
174
173
  month: 'short',
175
174
  day: 'numeric',
@@ -189,7 +188,7 @@ export function HeaderContentMulti({
189
188
  return (
190
189
  <Text
191
190
  maxFontSizeMultiplier={1.5}
192
- style={[styles.singleHeaderText, { color: dateColor }]}
191
+ style={[styles.text, { color: dateColor }]}
193
192
  >
194
193
  {label}
195
194
  </Text>
@@ -205,12 +204,6 @@ export function HeaderContentRange({
205
204
  color,
206
205
  }: HeaderContentProps & { color: string }) {
207
206
  const theme = useTheme()
208
- const formatter = React.useMemo(() => {
209
- return new Intl.DateTimeFormat(locale, {
210
- month: 'short',
211
- day: 'numeric',
212
- })
213
- }, [locale])
214
207
 
215
208
  const lighterColor = Color(color).fade(0.5).rgb().toString()
216
209
  const startColorFilled = theme.isV3 ? theme.colors.onSurface : color
@@ -218,11 +211,18 @@ export function HeaderContentRange({
218
211
  const startColor = state.startDate ? startColorFilled : lighterColor
219
212
  const endColor = state.endDate ? endColorFilled : lighterColor
220
213
 
214
+ const formatter = useMemo(() => {
215
+ return new Intl.DateTimeFormat(locale, {
216
+ month: 'short',
217
+ day: 'numeric',
218
+ })
219
+ }, [locale])
220
+
221
221
  return (
222
222
  <>
223
223
  <Text
224
224
  maxFontSizeMultiplier={1.5}
225
- style={[styles.rangeHeaderText, { color: startColor }]}
225
+ style={[styles.text, { color: startColor }]}
226
226
  >
227
227
  {state.startDate ? formatter.format(state.startDate) : startLabel}
228
228
  </Text>
@@ -234,7 +234,7 @@ export function HeaderContentRange({
234
234
  </Text>
235
235
  <Text
236
236
  maxFontSizeMultiplier={1.5}
237
- style={[styles.rangeHeaderText, { color: endColor }]}
237
+ style={[styles.text, { color: endColor }]}
238
238
  >
239
239
  {state.endDate ? formatter.format(state.endDate) : endLabel}
240
240
  </Text>
@@ -243,16 +243,6 @@ export function HeaderContentRange({
243
243
  }
244
244
 
245
245
  const styles = StyleSheet.create({
246
- fill: {
247
- flex: 1,
248
- },
249
- animated: {
250
- paddingBottom: 0,
251
- elevation: 4,
252
- },
253
- safeContent: {
254
- paddingBottom: 0,
255
- },
256
246
  header: {
257
247
  height: 75,
258
248
  alignItems: 'center',
@@ -260,15 +250,9 @@ const styles = StyleSheet.create({
260
250
  paddingLeft: 24,
261
251
  paddingRight: 12,
262
252
  },
263
- headerContentContainer: { marginTop: 5, flexDirection: 'row' },
264
- label: { color: '#fff', letterSpacing: 1, fontSize: 13 },
265
- singleHeaderText: { color: '#fff', fontSize: 25 },
266
- rangeHeaderText: { color: '#fff', fontSize: 25 },
267
- excludeInRangeHeaderText: { fontSize: 25 },
268
- excludeInRangeHeaderTextSmall: {
269
- fontSize: 14,
270
- marginTop: -3,
271
- marginLeft: 3,
253
+ headerContentContainer: {
254
+ flexDirection: 'row',
255
+ marginTop: 5,
272
256
  },
273
257
  headerSeparator: {
274
258
  color: 'rgba(255,255,255,1)',
@@ -276,9 +260,13 @@ const styles = StyleSheet.create({
276
260
  paddingLeft: 6,
277
261
  paddingRight: 6,
278
262
  },
279
- appbarHeader: {
280
- elevation: 0,
263
+ label: {
264
+ color: '#fff',
265
+ fontSize: 13,
266
+ letterSpacing: 1,
267
+ },
268
+ text: {
269
+ color: '#fff',
270
+ fontSize: 25,
281
271
  },
282
- column: { flexDirection: 'column' },
283
- row: { flexDirection: 'row' },
284
272
  })
@@ -1,8 +1,7 @@
1
- import * as React from 'react'
1
+ import React from 'react'
2
2
  import { Animated, StyleSheet } from 'react-native'
3
3
  import { Appbar, Button, useTheme } from 'react-native-paper'
4
-
5
- import { useHeaderTextColor } from '../utils'
4
+ import { useHeaderTextColor } from '../shared/utils'
6
5
  import { getTranslation } from '../translations/utils'
7
6
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
8
7
 
@@ -19,12 +18,13 @@ export interface DatePickerModalHeaderProps {
19
18
  export default function DatePickerModalHeader(
20
19
  props: DatePickerModalHeaderProps
21
20
  ) {
22
- const theme = useTheme()
23
21
  const { locale, closeIcon = 'close' } = props
24
22
  const saveLabel = props.saveLabel || getTranslation(locale, 'save')
25
23
  const color = useHeaderTextColor()
26
24
  const insets = useSafeAreaInsets()
27
25
 
26
+ const theme = useTheme()
27
+
28
28
  return (
29
29
  <>
30
30
  <Animated.View
@@ -64,25 +64,6 @@ const styles = StyleSheet.create({
64
64
  animated: {
65
65
  elevation: 4,
66
66
  },
67
- header: {
68
- height: 75,
69
- alignItems: 'center',
70
- flexDirection: 'row',
71
- paddingLeft: 24,
72
- paddingRight: 12,
73
- },
74
- headerContentContainer: { marginTop: 5, flexDirection: 'row' },
75
- label: { color: '#fff', letterSpacing: 1, fontSize: 13 },
76
- singleHeaderText: { color: '#fff', fontSize: 25 },
77
- rangeHeaderText: { color: '#fff', fontSize: 25 },
78
- headerTextFilled: { color: 'rgba(255,255,255,1)' },
79
- headerTextEmpty: { color: 'rgba(255,255,255,0.5)' },
80
- headerSeparator: {
81
- color: 'rgba(255,255,255,1)',
82
- fontSize: 25,
83
- paddingLeft: 6,
84
- paddingRight: 6,
85
- },
86
67
  appbarHeader: {
87
68
  elevation: 0,
88
69
  backgroundColor: 'transparent',
@@ -1,6 +1,6 @@
1
+ import React from 'react'
1
2
  import { Animated, StyleSheet } from 'react-native'
2
- import * as React from 'react'
3
- import { useHeaderBackgroundColor } from '../utils'
3
+ import { useHeaderBackgroundColor } from '../shared/utils'
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
5
5
 
6
6
  export default function DatePickerModalHeaderBackground({
@@ -10,6 +10,7 @@ export default function DatePickerModalHeaderBackground({
10
10
  }) {
11
11
  const backgroundColor = useHeaderBackgroundColor()
12
12
  const insets = useSafeAreaInsets()
13
+
13
14
  return (
14
15
  <Animated.View
15
16
  style={[
@@ -1,6 +1,6 @@
1
- import * as React from 'react'
1
+ import React, { memo } from 'react'
2
2
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
3
- import { useHeaderBackgroundColor } from '../utils'
3
+ import { useHeaderBackgroundColor } from '../shared/utils'
4
4
  import Color from 'color'
5
5
  import { Animated, StatusBar, StatusBarStyle } from 'react-native'
6
6
 
@@ -15,9 +15,9 @@ function DatePickerModalStatusBar({
15
15
  }) {
16
16
  const insets = useSafeAreaInsets()
17
17
  const headerBackgroundColor = useHeaderBackgroundColor()
18
+
18
19
  const onDarkBackground =
19
20
  Color(headerBackgroundColor).isDark() || statusBarOnTopOfBackdrop
20
-
21
21
  const statusBarTheme: StatusBarStyle = onDarkBackground
22
22
  ? 'light-content'
23
23
  : 'dark-content'
@@ -48,4 +48,4 @@ function DatePickerModalStatusBar({
48
48
  )
49
49
  }
50
50
 
51
- export default React.memo(DatePickerModalStatusBar)
51
+ export default memo(DatePickerModalStatusBar)
package/src/Date/Day.tsx CHANGED
@@ -1,15 +1,17 @@
1
- import * as React from 'react'
2
1
  import { MD2Theme, Text, TouchableRipple } from 'react-native-paper'
3
2
  import { StyleSheet, View } from 'react-native'
4
3
  import DayRange from './DayRange'
5
4
  import { daySize } from './dateUtils'
6
5
 
7
- import type { PaperTheme } from '../utils'
6
+ import type { PaperTheme } from '../shared/utils'
7
+ import { memo, useCallback } from 'react'
8
+ import React from 'react'
8
9
 
9
10
  function EmptyDayPure() {
10
11
  return <View style={styles.empty} />
11
12
  }
12
- export const EmptyDay = React.memo(EmptyDayPure)
13
+
14
+ export const EmptyDay = memo(EmptyDayPure)
13
15
 
14
16
  function Day(props: {
15
17
  theme: PaperTheme
@@ -43,11 +45,6 @@ function Day(props: {
43
45
  textColorOnPrimary,
44
46
  theme,
45
47
  } = props
46
- const onPress = React.useCallback(() => {
47
- onPressDate(new Date(year, month, day))
48
- }, [onPressDate, year, month, day])
49
-
50
- // const borderColorV3 =
51
48
  const borderColorFallback = theme.dark ? '#fff' : '#000'
52
49
  const selectedOrInRangeDarkMode = selected || (inRange && theme.dark)
53
50
  const v2BorderColor = selectedOrInRangeDarkMode
@@ -55,6 +52,10 @@ function Day(props: {
55
52
  : borderColorFallback
56
53
  const borderColor = theme.isV3 ? theme.colors.primary : v2BorderColor
57
54
 
55
+ const onPress = useCallback(() => {
56
+ onPressDate(new Date(year, month, day))
57
+ }, [onPressDate, year, month, day])
58
+
58
59
  // TODO: check if this can be simplified
59
60
  // converted with Chat-GPT for now from enormous conditional to if-else
60
61
  let baseTextColor
@@ -137,20 +138,6 @@ function Day(props: {
137
138
  }
138
139
 
139
140
  const styles = StyleSheet.create({
140
- empty: {
141
- flex: 1,
142
- flexBasis: 0,
143
- },
144
- disabled: {
145
- opacity: 0.3,
146
- },
147
- root: {
148
- flexBasis: 0,
149
- flex: 1,
150
- justifyContent: 'center',
151
- alignItems: 'center',
152
- position: 'relative',
153
- },
154
141
  button: {
155
142
  width: daySize,
156
143
  height: daySize,
@@ -168,9 +155,20 @@ const styles = StyleSheet.create({
168
155
  borderWidth: 1,
169
156
  borderColor: 'transparent',
170
157
  },
171
- flex1: {
158
+ disabled: {
159
+ opacity: 0.3,
160
+ },
161
+ empty: {
162
+ flex: 1,
163
+ flexBasis: 0,
164
+ },
165
+ root: {
166
+ flexBasis: 0,
172
167
  flex: 1,
168
+ justifyContent: 'center',
169
+ alignItems: 'center',
170
+ position: 'relative',
173
171
  },
174
172
  })
175
173
 
176
- export default React.memo(Day)
174
+ export default memo(Day)
@@ -1,4 +1,4 @@
1
- import * as React from 'react'
1
+ import React, { memo } from 'react'
2
2
  import { StyleSheet, View } from 'react-native'
3
3
  import { MD2Theme, Text, useTheme } from 'react-native-paper'
4
4
 
@@ -24,8 +24,16 @@ function DayName({ label }: { label: string }) {
24
24
  </View>
25
25
  )
26
26
  }
27
+
27
28
  const styles = StyleSheet.create({
28
- dayName: { flex: 1, alignItems: 'center' },
29
- dayNameLabel: { fontSize: 14, opacity: 0.7 },
29
+ dayName: {
30
+ alignItems: 'center',
31
+ flex: 1,
32
+ },
33
+ dayNameLabel: {
34
+ fontSize: 14,
35
+ opacity: 0.7,
36
+ },
30
37
  })
31
- export default React.memo(DayName)
38
+
39
+ export default memo(DayName)
@@ -1,8 +1,8 @@
1
- import * as React from 'react'
2
1
  import { StyleSheet, View } from 'react-native'
3
2
  import DayName from './DayName'
4
3
  import { useTheme } from 'react-native-paper'
5
4
  import { DisableWeekDaysType, showWeekDay } from './dateUtils'
5
+ import React, { memo, useMemo } from 'react'
6
6
 
7
7
  export const dayNamesHeight = 44
8
8
 
@@ -16,7 +16,8 @@ function DayNames({
16
16
  startWeekOnMonday: boolean
17
17
  }) {
18
18
  const theme = useTheme()
19
- const shortDayNames = React.useMemo<string[]>(() => {
19
+
20
+ const shortDayNames = useMemo<string[]>(() => {
20
21
  // TODO: wait for a better Intl api ;-)
21
22
  const weekdays = [
22
23
  new Date(2020, 7, 2),
@@ -39,7 +40,7 @@ function DayNames({
39
40
  return (
40
41
  <View
41
42
  style={[styles.dayNames, { backgroundColor: theme.colors.surface }]}
42
- pointerEvents={'none'}
43
+ pointerEvents="none"
43
44
  >
44
45
  {shortDayNames
45
46
  .filter((_, dayIndex) => showWeekDay(dayIndex, disableWeekDays))
@@ -51,10 +52,10 @@ function DayNames({
51
52
  }
52
53
  const styles = StyleSheet.create({
53
54
  dayNames: {
54
- height: dayNamesHeight,
55
- flexDirection: 'row',
56
55
  alignItems: 'center',
57
56
  backgroundColor: '#fff',
57
+ flexDirection: 'row',
58
+ height: dayNamesHeight,
58
59
  },
59
60
  })
60
- export default React.memo(DayNames)
61
+ export default memo(DayNames)
@@ -1,6 +1,7 @@
1
- import * as React from 'react'
2
1
  import { StyleSheet, View } from 'react-native'
3
2
  import { daySize } from './dateUtils'
3
+ import React, { memo } from 'react'
4
+ import { sharedStyles } from '../shared/styles'
4
5
 
5
6
  function DayRange({
6
7
  leftCrop,
@@ -22,7 +23,7 @@ function DayRange({
22
23
  pointerEvents="none"
23
24
  style={[
24
25
  StyleSheet.absoluteFill,
25
- styles.rangeRoot,
26
+ sharedStyles.flexDirectionRow,
26
27
  bothWays && styles.rangeRootBoth,
27
28
  inRange && !isCrop
28
29
  ? {
@@ -35,7 +36,7 @@ function DayRange({
35
36
  <>
36
37
  <View
37
38
  style={[
38
- styles.flex1,
39
+ sharedStyles.root,
39
40
  rightCrop
40
41
  ? {
41
42
  backgroundColor: selectColor,
@@ -56,7 +57,7 @@ function DayRange({
56
57
  />
57
58
  <View
58
59
  style={[
59
- styles.flex1,
60
+ sharedStyles.root,
60
61
  leftCrop
61
62
  ? {
62
63
  backgroundColor: selectColor,
@@ -84,12 +85,6 @@ const styles = StyleSheet.create({
84
85
  rangeRootBoth: {
85
86
  borderRadius: daySize / 2,
86
87
  },
87
- flex1: {
88
- flex: 1,
89
- },
90
- rangeRoot: {
91
- flexDirection: 'row',
92
- },
93
88
  })
94
89
 
95
- export default React.memo(DayRange)
90
+ export default memo(DayRange)