react-native-paper-dates 0.9.1 → 0.10.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 (133) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/Date/AnimatedCrossView.js +1 -4
  3. package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
  4. package/lib/commonjs/Date/Calendar.js +1 -1
  5. package/lib/commonjs/Date/Calendar.js.map +1 -1
  6. package/lib/commonjs/Date/DatePickerInput.js +4 -2
  7. package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
  8. package/lib/commonjs/Date/DatePickerInput.shared.js.map +1 -1
  9. package/lib/commonjs/Date/DatePickerInputWithoutModal.js +17 -12
  10. package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
  11. package/lib/commonjs/Date/DatePickerModalContent.js +3 -3
  12. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  13. package/lib/commonjs/Date/DatePickerModalContentHeader.js +5 -2
  14. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  15. package/lib/commonjs/Date/DatePickerModalHeader.js +13 -14
  16. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  17. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +7 -8
  18. package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
  19. package/lib/commonjs/Date/Day.js +5 -4
  20. package/lib/commonjs/Date/Day.js.map +1 -1
  21. package/lib/commonjs/Date/DayName.js +3 -1
  22. package/lib/commonjs/Date/DayName.js.map +1 -1
  23. package/lib/commonjs/Date/Month.js +3 -1
  24. package/lib/commonjs/Date/Month.js.map +1 -1
  25. package/lib/commonjs/Date/Swiper.js +1 -2
  26. package/lib/commonjs/Date/Swiper.js.map +1 -1
  27. package/lib/commonjs/Date/YearPicker.js +4 -2
  28. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  29. package/lib/commonjs/TextInputMask.js +9 -4
  30. package/lib/commonjs/TextInputMask.js.map +1 -1
  31. package/lib/commonjs/Time/AmPmSwitcher.js +3 -2
  32. package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
  33. package/lib/commonjs/Time/AnalogClock.js +1 -1
  34. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  35. package/lib/commonjs/Time/TimeInputs.js +7 -4
  36. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  37. package/lib/commonjs/Time/TimePicker.js +4 -1
  38. package/lib/commonjs/Time/TimePicker.js.map +1 -1
  39. package/lib/commonjs/Time/TimePickerModal.js +15 -4
  40. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  41. package/lib/commonjs/Time/timeUtils.js +35 -3
  42. package/lib/commonjs/Time/timeUtils.js.map +1 -1
  43. package/lib/commonjs/translations/utils.js +2 -2
  44. package/lib/commonjs/translations/utils.js.map +1 -1
  45. package/lib/commonjs/utils.js.map +1 -1
  46. package/lib/module/Date/AnimatedCrossView.js +1 -3
  47. package/lib/module/Date/AnimatedCrossView.js.map +1 -1
  48. package/lib/module/Date/Calendar.js +1 -1
  49. package/lib/module/Date/Calendar.js.map +1 -1
  50. package/lib/module/Date/DatePickerInput.js +4 -2
  51. package/lib/module/Date/DatePickerInput.js.map +1 -1
  52. package/lib/module/Date/DatePickerInput.shared.js.map +1 -1
  53. package/lib/module/Date/DatePickerInputWithoutModal.js +17 -12
  54. package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
  55. package/lib/module/Date/DatePickerModalContent.js +3 -3
  56. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  57. package/lib/module/Date/DatePickerModalContentHeader.js +6 -3
  58. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  59. package/lib/module/Date/DatePickerModalHeader.js +13 -15
  60. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  61. package/lib/module/Date/DatePickerModalHeaderBackground.js +7 -9
  62. package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
  63. package/lib/module/Date/Day.js +5 -4
  64. package/lib/module/Date/Day.js.map +1 -1
  65. package/lib/module/Date/DayName.js +3 -1
  66. package/lib/module/Date/DayName.js.map +1 -1
  67. package/lib/module/Date/Month.js +3 -1
  68. package/lib/module/Date/Month.js.map +1 -1
  69. package/lib/module/Date/Swiper.js +1 -2
  70. package/lib/module/Date/Swiper.js.map +1 -1
  71. package/lib/module/Date/YearPicker.js +4 -2
  72. package/lib/module/Date/YearPicker.js.map +1 -1
  73. package/lib/module/TextInputMask.js +9 -4
  74. package/lib/module/TextInputMask.js.map +1 -1
  75. package/lib/module/Time/AmPmSwitcher.js +3 -2
  76. package/lib/module/Time/AmPmSwitcher.js.map +1 -1
  77. package/lib/module/Time/AnalogClock.js +1 -1
  78. package/lib/module/Time/AnalogClock.js.map +1 -1
  79. package/lib/module/Time/TimeInputs.js +6 -4
  80. package/lib/module/Time/TimeInputs.js.map +1 -1
  81. package/lib/module/Time/TimePicker.js +4 -1
  82. package/lib/module/Time/TimePicker.js.map +1 -1
  83. package/lib/module/Time/TimePickerModal.js +15 -4
  84. package/lib/module/Time/TimePickerModal.js.map +1 -1
  85. package/lib/module/Time/timeUtils.js +35 -3
  86. package/lib/module/Time/timeUtils.js.map +1 -1
  87. package/lib/module/translations/utils.js +2 -2
  88. package/lib/module/translations/utils.js.map +1 -1
  89. package/lib/module/utils.js.map +1 -1
  90. package/lib/typescript/Date/AutoSizer.d.ts +1 -1
  91. package/lib/typescript/Date/Calendar.d.ts +10 -10
  92. package/lib/typescript/Date/DatePickerInput.d.ts +1 -1
  93. package/lib/typescript/Date/DatePickerInput.shared.d.ts +2 -1
  94. package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +10 -4
  95. package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -1
  96. package/lib/typescript/Date/Day.d.ts +2 -2
  97. package/lib/typescript/Date/SwiperUtils.d.ts +2 -2
  98. package/lib/typescript/Date/dateUtils.d.ts +1 -1
  99. package/lib/typescript/TextInputMask.d.ts +9 -4
  100. package/lib/typescript/Time/TimePicker.d.ts +1 -1
  101. package/lib/typescript/Time/timeUtils.d.ts +7 -7
  102. package/lib/typescript/translations/utils.d.ts +1 -1
  103. package/lib/typescript/utils.d.ts +2 -0
  104. package/package.json +9 -8
  105. package/src/Date/AnimatedCrossView.tsx +0 -4
  106. package/src/Date/Calendar.tsx +2 -2
  107. package/src/Date/DatePickerInput.shared.tsx +1 -0
  108. package/src/Date/DatePickerInput.tsx +2 -1
  109. package/src/Date/DatePickerInputWithoutModal.tsx +37 -35
  110. package/src/Date/DatePickerModalContent.tsx +3 -3
  111. package/src/Date/DatePickerModalContentHeader.tsx +9 -4
  112. package/src/Date/DatePickerModalHeader.tsx +35 -37
  113. package/src/Date/DatePickerModalHeaderBackground.tsx +6 -7
  114. package/src/Date/Day.tsx +12 -4
  115. package/src/Date/DayName.tsx +7 -5
  116. package/src/Date/Month.tsx +12 -2
  117. package/src/Date/Swiper.tsx +0 -1
  118. package/src/Date/YearPicker.tsx +16 -4
  119. package/src/TextInputMask.tsx +8 -4
  120. package/src/Time/AmPmSwitcher.tsx +11 -3
  121. package/src/Time/AnalogClock.tsx +3 -1
  122. package/src/Time/TimeInputs.tsx +32 -4
  123. package/src/Time/TimePicker.tsx +4 -1
  124. package/src/Time/TimePickerModal.tsx +29 -3
  125. package/src/Time/timeUtils.ts +31 -4
  126. package/src/translations/utils.ts +2 -2
  127. package/src/utils.ts +8 -1
  128. package/lib/commonjs/Date/DateRangeInput.js +0 -86
  129. package/lib/commonjs/Date/DateRangeInput.js.map +0 -1
  130. package/lib/module/Date/DateRangeInput.js +0 -69
  131. package/lib/module/Date/DateRangeInput.js.map +0 -1
  132. package/lib/typescript/Date/DateRangeInput.d.ts +0 -4
  133. package/src/Date/DateRangeInput.tsx +0 -75
@@ -157,7 +157,6 @@ function VerticalScroller({
157
157
  right: 0,
158
158
  position: 'absolute',
159
159
  height: getMonthHeight('vertical', visibleIndexes[vi]),
160
- // transform: `translateY(${getMonthsOffset('vertical', vi)}px)`,
161
160
  }}
162
161
  >
163
162
  {renderItem({
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import { FlatList, StyleSheet, View } from 'react-native'
3
- import { Text, TouchableRipple, useTheme } from 'react-native-paper'
3
+ import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
4
4
  import { range } from '../utils'
5
5
 
6
6
  const ITEM_HEIGHT = 62
@@ -20,7 +20,10 @@ export default function YearPicker({
20
20
  }) {
21
21
  const theme = useTheme()
22
22
  const flatList = React.useRef<FlatList<number> | null>(null)
23
- const years = range(isNaN(startYear) ? 1800 : startYear, isNaN(endYear) ? 2200 : endYear)
23
+ const years = range(
24
+ isNaN(startYear) ? 1800 : startYear,
25
+ isNaN(endYear) ? 2200 : endYear
26
+ )
24
27
 
25
28
  // scroll to selected year
26
29
  React.useEffect(() => {
@@ -31,7 +34,7 @@ export default function YearPicker({
31
34
  animated: false,
32
35
  })
33
36
  }
34
- }, [flatList, selectedYear])
37
+ }, [flatList, selectedYear, startYear])
35
38
 
36
39
  return (
37
40
  <View
@@ -71,6 +74,11 @@ function YearPure({
71
74
  onPressYear: (newYear: number) => any
72
75
  }) {
73
76
  const theme = useTheme()
77
+
78
+ let textFont = theme?.isV3
79
+ ? theme.fonts.bodyLarge
80
+ : (theme as any as MD2Theme).fonts.medium
81
+
74
82
  return (
75
83
  <View style={styles.year}>
76
84
  <TouchableRipple
@@ -86,7 +94,11 @@ function YearPure({
86
94
  ]}
87
95
  >
88
96
  <Text
89
- style={[styles.yearLabel, selected ? styles.selectedYear : null]}
97
+ style={[
98
+ styles.yearLabel,
99
+ selected ? styles.selectedYear : null,
100
+ { ...textFont },
101
+ ]}
90
102
  selectable={false}
91
103
  >
92
104
  {year}
@@ -72,7 +72,7 @@ function TextInputWithMask(
72
72
  value,
73
73
  mask,
74
74
  ...rest
75
- }: React.ComponentProps<typeof TextInput> & { mask: string },
75
+ }: React.ComponentProps<typeof TextInput> & { mask: string; value: string },
76
76
  ref: any
77
77
  ) {
78
78
  const [controlledValue, setControlledValue] = React.useState<string>(
@@ -80,12 +80,15 @@ function TextInputWithMask(
80
80
  )
81
81
 
82
82
  const onInnerChange = (text: string) => {
83
- const enhancedText = enhanceTextWithMask(text, mask, controlledValue)
84
- setControlledValue(enhancedText)
85
-
86
83
  if (text.length === mask.length) {
87
84
  onChangeText && onChangeText(text)
88
85
  }
86
+ setControlledValue(text)
87
+ }
88
+
89
+ const onInnerBlur = () => {
90
+ const enhancedText = enhanceTextWithMask(value, mask, controlledValue)
91
+ setControlledValue(enhancedText)
89
92
  }
90
93
 
91
94
  React.useEffect(() => {
@@ -98,6 +101,7 @@ function TextInputWithMask(
98
101
  {...rest}
99
102
  value={controlledValue}
100
103
  onChangeText={onInnerChange}
104
+ onBlur={onInnerBlur}
101
105
  />
102
106
  )
103
107
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import { View, StyleSheet } from 'react-native'
3
- import { Text, TouchableRipple, useTheme } from 'react-native-paper'
3
+ import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
4
4
  import { useMemo } from 'react'
5
5
  import Color from 'color'
6
6
  import { useSwitchColors } from './timeUtils'
@@ -19,7 +19,11 @@ export default function AmPmSwitcher({
19
19
  if (theme.dark) {
20
20
  return Color(theme.colors.surface).lighten(1.2).hex()
21
21
  }
22
- return Color(theme.colors.surface).darken(0.1).hex()
22
+ return Color(
23
+ theme.isV3 ? theme.colors.inverseOnSurface : theme.colors.surface
24
+ )
25
+ .darken(0.1)
26
+ .hex()
23
27
  }, [theme])
24
28
 
25
29
  const isAM = mode === 'AM'
@@ -74,6 +78,10 @@ function SwitchButton({
74
78
  const theme = useTheme()
75
79
  const { backgroundColor, color } = useSwitchColors(selected)
76
80
 
81
+ let textFont = theme?.isV3
82
+ ? theme.fonts.bodyMedium
83
+ : (theme as any as MD2Theme).fonts.medium
84
+
77
85
  return (
78
86
  <TouchableRipple
79
87
  onPress={onPress}
@@ -92,7 +100,7 @@ function SwitchButton({
92
100
  selectable={false}
93
101
  style={[
94
102
  {
95
- ...theme.fonts.medium,
103
+ ...textFont,
96
104
  color: color,
97
105
  },
98
106
  ]}
@@ -128,7 +128,9 @@ function AnalogClock({
128
128
  styles.clock,
129
129
  {
130
130
  backgroundColor: theme.dark
131
- ? Color(theme.colors.surface).lighten(1.2).hex()
131
+ ? Color(theme.colors.surface).lighten(1.4).hex()
132
+ : theme.isV3
133
+ ? Color(theme.colors.outline).lighten(0.9).hex()
132
134
  : Color(theme.colors.surface).darken(0.1).hex(),
133
135
  },
134
136
  ]}
@@ -8,7 +8,7 @@ import {
8
8
  useWindowDimensions,
9
9
  TextInput as TextInputNative,
10
10
  } from 'react-native'
11
- import { useTheme } from 'react-native-paper'
11
+ import { MD2Theme, useTheme } from 'react-native-paper'
12
12
 
13
13
  import {
14
14
  clockTypes,
@@ -20,6 +20,7 @@ import {
20
20
  import TimeInput from './TimeInput'
21
21
  import AmPmSwitcher from './AmPmSwitcher'
22
22
  import { useLatest } from '../utils'
23
+ import Color from 'color'
23
24
 
24
25
  function TimeInputs({
25
26
  hours,
@@ -85,6 +86,11 @@ function TimeInputs({
85
86
  pressed={focused === clockTypes.hours}
86
87
  onPress={onFocusInput}
87
88
  inputType={inputType}
89
+ selectionColor={
90
+ theme.dark
91
+ ? Color(theme.colors.primary).darken(0.2).hex()
92
+ : theme.colors.primary
93
+ }
88
94
  returnKeyType={'next'}
89
95
  onSubmitEditing={onSubmitStartInput}
90
96
  blurOnSubmit={false}
@@ -98,13 +104,30 @@ function TimeInputs({
98
104
  minutes,
99
105
  })
100
106
  }}
101
- // onChangeText={onChangeStartInput}
102
107
  />
103
108
  <View style={styles.hoursAndMinutesSeparator}>
104
109
  <View style={styles.spaceDot} />
105
- <View style={[styles.dot, { backgroundColor: theme.colors.text }]} />
110
+ <View
111
+ style={[
112
+ styles.dot,
113
+ {
114
+ backgroundColor: theme?.isV3
115
+ ? theme.colors.onBackground
116
+ : (theme as any as MD2Theme).colors.text,
117
+ },
118
+ ]}
119
+ />
106
120
  <View style={styles.betweenDot} />
107
- <View style={[styles.dot, { backgroundColor: theme.colors.text }]} />
121
+ <View
122
+ style={[
123
+ styles.dot,
124
+ {
125
+ backgroundColor: theme?.isV3
126
+ ? theme.colors.onBackground
127
+ : (theme as any as MD2Theme).colors.text,
128
+ },
129
+ ]}
130
+ />
108
131
  <View style={styles.spaceDot} />
109
132
  </View>
110
133
  <TimeInput
@@ -115,6 +138,11 @@ function TimeInputs({
115
138
  pressed={focused === clockTypes.minutes}
116
139
  onPress={onFocusInput}
117
140
  inputType={inputType}
141
+ selectionColor={
142
+ theme.dark
143
+ ? Color(theme.colors.primary).darken(0.2).hex()
144
+ : theme.colors.primary
145
+ }
118
146
  onSubmitEditing={onSubmitEndInput}
119
147
  onChanged={(newMinutesFromInput) => {
120
148
  let newMinutes = newMinutesFromInput
@@ -117,7 +117,10 @@ const styles = StyleSheet.create({
117
117
  justifyContent: 'center',
118
118
  width: 24 * 3 + 96 * 2 + 52 + circleSize,
119
119
  },
120
- rootPortrait: {},
120
+ rootPortrait: {
121
+ alignItems: 'center',
122
+ justifyContent: 'center',
123
+ },
121
124
  clockContainer: { paddingTop: 36, paddingLeft: 12, paddingRight: 12 },
122
125
  })
123
126
 
@@ -9,7 +9,14 @@ import {
9
9
  KeyboardAvoidingView,
10
10
  } from 'react-native'
11
11
 
12
- import { Button, IconButton, overlay, useTheme } from 'react-native-paper'
12
+ import {
13
+ Button,
14
+ IconButton,
15
+ MD2Theme,
16
+ overlay,
17
+ useTheme,
18
+ } from 'react-native-paper'
19
+
13
20
  import TimePicker from './TimePicker'
14
21
  import {
15
22
  clockTypes,
@@ -59,6 +66,14 @@ export function TimePickerModal({
59
66
  }) {
60
67
  const theme = useTheme()
61
68
 
69
+ let textFont
70
+
71
+ if (theme.isV3) {
72
+ textFont = theme.fonts.bodyMedium
73
+ } else {
74
+ textFont = (theme as any as MD2Theme)?.fonts.medium
75
+ }
76
+
62
77
  const [inputType, setInputType] = React.useState<PossibleInputTypes>(
63
78
  inputTypes.picker
64
79
  )
@@ -114,7 +129,7 @@ export function TimePickerModal({
114
129
  style={[
115
130
  StyleSheet.absoluteFill,
116
131
  styles.modalBackground,
117
- { backgroundColor: theme.colors.backdrop },
132
+ { backgroundColor: theme.colors?.backdrop },
118
133
  ]}
119
134
  />
120
135
  </TouchableWithoutFeedback>
@@ -139,7 +154,17 @@ export function TimePickerModal({
139
154
  ]}
140
155
  >
141
156
  <View style={styles.labelContainer}>
142
- <Text style={[styles.label, { color: theme.colors.text }]}>
157
+ <Text
158
+ style={[
159
+ styles.label,
160
+ {
161
+ ...textFont,
162
+ color: theme?.isV3
163
+ ? theme.colors.onBackground
164
+ : (theme as any as MD2Theme).colors.text,
165
+ },
166
+ ]}
167
+ >
143
168
  {uppercase ? label.toUpperCase() : label}
144
169
  </Text>
145
170
  </View>
@@ -225,6 +250,7 @@ const styles = StyleSheet.create({
225
250
  justifyContent: 'flex-end',
226
251
  paddingLeft: 24,
227
252
  paddingRight: 24,
253
+ marginTop: 8,
228
254
  },
229
255
  label: {
230
256
  letterSpacing: 1,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import Color from 'color'
3
- import { useTheme } from 'react-native-paper'
3
+ import { MD2Theme, useTheme } from 'react-native-paper'
4
4
 
5
5
  // 250? when bigger?
6
6
  export const circleSize = 215
@@ -163,10 +163,17 @@ export function useSwitchColors(highlighted: boolean) {
163
163
  if (highlighted) {
164
164
  return Color(theme.colors.primary).hex()
165
165
  }
166
+ if (theme.isV3) {
167
+ return Color(theme.colors.surface).lighten(1.4).hex()
168
+ }
166
169
  return theme.colors.backdrop
167
170
  }
168
171
 
169
172
  if (highlighted) {
173
+ if (theme.isV3) {
174
+ return theme.colors.primaryContainer
175
+ }
176
+
170
177
  return Color(theme.colors.primary).lighten(1).hex()
171
178
  }
172
179
  return theme.colors.surface
@@ -176,7 +183,14 @@ export function useSwitchColors(highlighted: boolean) {
176
183
  if (highlighted && !theme.dark) {
177
184
  return theme.colors.primary
178
185
  }
179
- return theme.colors.placeholder
186
+ if (highlighted && theme.dark) {
187
+ return theme.colors.background
188
+ }
189
+ if (theme.isV3) {
190
+ return theme.colors.onSurfaceVariant
191
+ } else {
192
+ return (theme as any as MD2Theme).colors.placeholder
193
+ }
180
194
  }, [highlighted, theme])
181
195
 
182
196
  return { backgroundColor, color }
@@ -189,12 +203,18 @@ export function useInputColors(highlighted: boolean) {
189
203
  if (highlighted) {
190
204
  return Color(theme.colors.primary).hex()
191
205
  }
192
- return Color(theme.colors.surface).lighten(1.2).hex()
206
+ return Color(theme.colors.surface).lighten(1.4).hex()
193
207
  }
194
208
 
195
209
  if (highlighted) {
210
+ if (theme.isV3) {
211
+ return Color(theme.colors.primaryContainer).hex()
212
+ }
196
213
  return Color(theme.colors.primary).lighten(1).hex()
197
214
  }
215
+ if (theme.isV3) {
216
+ return Color(theme.colors.outline).lighten(0.9).hex()
217
+ }
198
218
  return Color(theme.colors.surface).darken(0.1).hex()
199
219
  }, [highlighted, theme])
200
220
 
@@ -202,7 +222,14 @@ export function useInputColors(highlighted: boolean) {
202
222
  if (highlighted && !theme.dark) {
203
223
  return theme.colors.primary
204
224
  }
205
- return theme.colors.text
225
+ if (theme.isV3) {
226
+ if (!highlighted) {
227
+ return theme.colors.onBackground
228
+ }
229
+ return theme.colors.background
230
+ } else {
231
+ return (theme as any as MD2Theme).colors.text
232
+ }
206
233
  }, [highlighted, theme])
207
234
 
208
235
  return { backgroundColor, color }
@@ -26,14 +26,14 @@ export function getTranslation<K extends keyof TranslationsType>(
26
26
  const translationForLocale = translationsPerLocale[l]
27
27
  if (!translationForLocale) {
28
28
  console.warn(
29
- `[react-native-paper-dates] ${locale} is not registered, key: ${key}`
29
+ `[react-native-paper-dates] The locale ${locale} is not registered, see README!, key: ${key}`
30
30
  )
31
31
  return fallback || key
32
32
  }
33
33
  const translation = translationsPerLocale[l][key]
34
34
  if (!translation) {
35
35
  console.warn(
36
- `[react-native-paper-dates] ${locale} is registered, but ${key} is missing`
36
+ `[react-native-paper-dates] The locale ${locale} is registered, but ${key} is missing`
37
37
  )
38
38
  }
39
39
  return translation || fallback || key
package/src/utils.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  import * as React from 'react'
2
- import { overlay, useTheme } from 'react-native-paper'
2
+ import {
3
+ DefaultTheme,
4
+ MD3DarkTheme,
5
+ overlay,
6
+ useTheme,
7
+ } from 'react-native-paper'
3
8
  import Color from 'color'
4
9
 
10
+ export type PaperTheme = typeof MD3DarkTheme | typeof DefaultTheme
11
+
5
12
  export function useLatest<T>(value: T) {
6
13
  const ref = React.useRef(value)
7
14
  ref.current = value
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = DateRangeInput;
7
-
8
- var React = _interopRequireWildcard(require("react"));
9
-
10
- var _reactNative = require("react-native");
11
-
12
- var _reactNativePaper = require("react-native-paper");
13
-
14
- var _DatePickerModal = _interopRequireDefault(require("./DatePickerModal"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
- // WORK IN PROGRESS
23
- function DateRangeInput(_ref) {
24
- let {
25
- locale,
26
- calendarIcon = 'calendar'
27
- } = _ref;
28
- const [visible, setVisible] = React.useState(false);
29
- const onDismiss = React.useCallback(() => {
30
- setVisible(false);
31
- }, [setVisible]);
32
- const onConfirm = React.useCallback( // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- _ref2 => {
34
- let {
35
- startDate,
36
- endDate
37
- } = _ref2;
38
- setVisible(false);
39
- console.log({
40
- startDate,
41
- endDate
42
- });
43
- }, [setVisible]);
44
- return /*#__PURE__*/React.createElement(_reactNative.View, {
45
- style: {
46
- flexDirection: 'row',
47
- alignItems: 'center'
48
- }
49
- }, /*#__PURE__*/React.createElement(_reactNative.View, {
50
- style: {
51
- flex: 1
52
- }
53
- }, /*#__PURE__*/React.createElement(_reactNativePaper.Text, null, "Van")), /*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_reactNativePaper.Text, {
54
- style: {
55
- fontSize: 16,
56
- marginLeft: 12,
57
- marginRight: 12
58
- }
59
- }, "to"), /*#__PURE__*/React.createElement(_reactNativePaper.Text, {
60
- style: {
61
- opacity: 0
62
- },
63
- accessible: false
64
- }, "tot")), /*#__PURE__*/React.createElement(_reactNative.View, {
65
- style: {
66
- flex: 1
67
- }
68
- }, /*#__PURE__*/React.createElement(_reactNativePaper.Text, null, "Tot")), /*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_reactNativePaper.IconButton, {
69
- icon: calendarIcon,
70
- onPress: () => setVisible(true)
71
- }), /*#__PURE__*/React.createElement(_reactNativePaper.Text, {
72
- style: {
73
- opacity: 0
74
- },
75
- accessible: false
76
- }, "tot")), /*#__PURE__*/React.createElement(_DatePickerModal.default, {
77
- locale: locale,
78
- mode: "range",
79
- visible: visible,
80
- onDismiss: onDismiss,
81
- onConfirm: onConfirm,
82
- startDate: undefined,
83
- endDate: undefined
84
- }));
85
- }
86
- //# sourceMappingURL=DateRangeInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["DateRangeInput","locale","calendarIcon","visible","setVisible","React","useState","onDismiss","useCallback","onConfirm","startDate","endDate","console","log","flexDirection","alignItems","flex","fontSize","marginLeft","marginRight","opacity","undefined"],"sources":["DateRangeInput.tsx"],"sourcesContent":["import * as React from 'react'\nimport { View } from 'react-native'\nimport { Text, IconButton } from 'react-native-paper'\n\nimport DatePickerModal from './DatePickerModal'\n\n// WORK IN PROGRESS\nexport default function DateRangeInput({\n locale,\n calendarIcon = 'calendar',\n}: {\n locale: string\n calendarIcon?: string\n}) {\n const [visible, setVisible] = React.useState<boolean>(false)\n const onDismiss = React.useCallback(() => {\n setVisible(false)\n }, [setVisible])\n const onConfirm = React.useCallback(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ({ startDate, endDate }: { startDate: any; endDate: any }) => {\n setVisible(false)\n console.log({ startDate, endDate })\n },\n [setVisible]\n )\n\n return (\n <View style={{ flexDirection: 'row', alignItems: 'center' }}>\n <View style={{ flex: 1 }}>\n {/*<DatePickerInput*/}\n {/* value={''}*/}\n {/* keyboardType={'numeric'}*/}\n {/* placeholder={'DD-MM-YYY'}*/}\n {/* mask={'DD-MM-YYY'}*/}\n {/* onChangeText={() => {}}*/}\n {/*/>*/}\n <Text>Van</Text>\n </View>\n <View>\n <Text style={{ fontSize: 16, marginLeft: 12, marginRight: 12 }}>\n to\n </Text>\n <Text style={{ opacity: 0 }} accessible={false}>\n tot\n </Text>\n </View>\n <View style={{ flex: 1 }}>\n {/*<DatePickerInput*/}\n {/* // value={''}*/}\n {/* // keyboardType={'numeric'}*/}\n {/* // placeholder={'DD-MM-YYY'}*/}\n {/* // mask={'DD-MM-YYY'}*/}\n {/* // onChangeText={() => {}}*/}\n {/*/>*/}\n <Text>Tot</Text>\n </View>\n <View>\n <IconButton icon={calendarIcon} onPress={() => setVisible(true)} />\n <Text style={{ opacity: 0 }} accessible={false}>\n tot\n </Text>\n </View>\n <DatePickerModal\n locale={locale}\n mode=\"range\"\n visible={visible}\n onDismiss={onDismiss}\n onConfirm={onConfirm}\n startDate={undefined}\n endDate={undefined}\n />\n </View>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;AAEA;AACe,SAASA,cAAT,OAMZ;EAAA,IANoC;IACrCC,MADqC;IAErCC,YAAY,GAAG;EAFsB,CAMpC;EACD,MAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBC,KAAK,CAACC,QAAN,CAAwB,KAAxB,CAA9B;EACA,MAAMC,SAAS,GAAGF,KAAK,CAACG,WAAN,CAAkB,MAAM;IACxCJ,UAAU,CAAC,KAAD,CAAV;EACD,CAFiB,EAEf,CAACA,UAAD,CAFe,CAAlB;EAGA,MAAMK,SAAS,GAAGJ,KAAK,CAACG,WAAN,EAChB;EACA,SAA8D;IAAA,IAA7D;MAAEE,SAAF;MAAaC;IAAb,CAA6D;IAC5DP,UAAU,CAAC,KAAD,CAAV;IACAQ,OAAO,CAACC,GAAR,CAAY;MAAEH,SAAF;MAAaC;IAAb,CAAZ;EACD,CALe,EAMhB,CAACP,UAAD,CANgB,CAAlB;EASA,oBACE,oBAAC,iBAAD;IAAM,KAAK,EAAE;MAAEU,aAAa,EAAE,KAAjB;MAAwBC,UAAU,EAAE;IAApC;EAAb,gBACE,oBAAC,iBAAD;IAAM,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAR;EAAb,gBAQE,oBAAC,sBAAD,cARF,CADF,eAWE,oBAAC,iBAAD,qBACE,oBAAC,sBAAD;IAAM,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,UAAU,EAAE,EAA5B;MAAgCC,WAAW,EAAE;IAA7C;EAAb,QADF,eAIE,oBAAC,sBAAD;IAAM,KAAK,EAAE;MAAEC,OAAO,EAAE;IAAX,CAAb;IAA6B,UAAU,EAAE;EAAzC,SAJF,CAXF,eAmBE,oBAAC,iBAAD;IAAM,KAAK,EAAE;MAAEJ,IAAI,EAAE;IAAR;EAAb,gBAQE,oBAAC,sBAAD,cARF,CAnBF,eA6BE,oBAAC,iBAAD,qBACE,oBAAC,4BAAD;IAAY,IAAI,EAAEd,YAAlB;IAAgC,OAAO,EAAE,MAAME,UAAU,CAAC,IAAD;EAAzD,EADF,eAEE,oBAAC,sBAAD;IAAM,KAAK,EAAE;MAAEgB,OAAO,EAAE;IAAX,CAAb;IAA6B,UAAU,EAAE;EAAzC,SAFF,CA7BF,eAmCE,oBAAC,wBAAD;IACE,MAAM,EAAEnB,MADV;IAEE,IAAI,EAAC,OAFP;IAGE,OAAO,EAAEE,OAHX;IAIE,SAAS,EAAEI,SAJb;IAKE,SAAS,EAAEE,SALb;IAME,SAAS,EAAEY,SANb;IAOE,OAAO,EAAEA;EAPX,EAnCF,CADF;AA+CD"}
@@ -1,69 +0,0 @@
1
- import * as React from 'react';
2
- import { View } from 'react-native';
3
- import { Text, IconButton } from 'react-native-paper';
4
- import DatePickerModal from './DatePickerModal'; // WORK IN PROGRESS
5
-
6
- export default function DateRangeInput(_ref) {
7
- let {
8
- locale,
9
- calendarIcon = 'calendar'
10
- } = _ref;
11
- const [visible, setVisible] = React.useState(false);
12
- const onDismiss = React.useCallback(() => {
13
- setVisible(false);
14
- }, [setVisible]);
15
- const onConfirm = React.useCallback( // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- _ref2 => {
17
- let {
18
- startDate,
19
- endDate
20
- } = _ref2;
21
- setVisible(false);
22
- console.log({
23
- startDate,
24
- endDate
25
- });
26
- }, [setVisible]);
27
- return /*#__PURE__*/React.createElement(View, {
28
- style: {
29
- flexDirection: 'row',
30
- alignItems: 'center'
31
- }
32
- }, /*#__PURE__*/React.createElement(View, {
33
- style: {
34
- flex: 1
35
- }
36
- }, /*#__PURE__*/React.createElement(Text, null, "Van")), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Text, {
37
- style: {
38
- fontSize: 16,
39
- marginLeft: 12,
40
- marginRight: 12
41
- }
42
- }, "to"), /*#__PURE__*/React.createElement(Text, {
43
- style: {
44
- opacity: 0
45
- },
46
- accessible: false
47
- }, "tot")), /*#__PURE__*/React.createElement(View, {
48
- style: {
49
- flex: 1
50
- }
51
- }, /*#__PURE__*/React.createElement(Text, null, "Tot")), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(IconButton, {
52
- icon: calendarIcon,
53
- onPress: () => setVisible(true)
54
- }), /*#__PURE__*/React.createElement(Text, {
55
- style: {
56
- opacity: 0
57
- },
58
- accessible: false
59
- }, "tot")), /*#__PURE__*/React.createElement(DatePickerModal, {
60
- locale: locale,
61
- mode: "range",
62
- visible: visible,
63
- onDismiss: onDismiss,
64
- onConfirm: onConfirm,
65
- startDate: undefined,
66
- endDate: undefined
67
- }));
68
- }
69
- //# sourceMappingURL=DateRangeInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","View","Text","IconButton","DatePickerModal","DateRangeInput","locale","calendarIcon","visible","setVisible","useState","onDismiss","useCallback","onConfirm","startDate","endDate","console","log","flexDirection","alignItems","flex","fontSize","marginLeft","marginRight","opacity","undefined"],"sources":["DateRangeInput.tsx"],"sourcesContent":["import * as React from 'react'\nimport { View } from 'react-native'\nimport { Text, IconButton } from 'react-native-paper'\n\nimport DatePickerModal from './DatePickerModal'\n\n// WORK IN PROGRESS\nexport default function DateRangeInput({\n locale,\n calendarIcon = 'calendar',\n}: {\n locale: string\n calendarIcon?: string\n}) {\n const [visible, setVisible] = React.useState<boolean>(false)\n const onDismiss = React.useCallback(() => {\n setVisible(false)\n }, [setVisible])\n const onConfirm = React.useCallback(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ({ startDate, endDate }: { startDate: any; endDate: any }) => {\n setVisible(false)\n console.log({ startDate, endDate })\n },\n [setVisible]\n )\n\n return (\n <View style={{ flexDirection: 'row', alignItems: 'center' }}>\n <View style={{ flex: 1 }}>\n {/*<DatePickerInput*/}\n {/* value={''}*/}\n {/* keyboardType={'numeric'}*/}\n {/* placeholder={'DD-MM-YYY'}*/}\n {/* mask={'DD-MM-YYY'}*/}\n {/* onChangeText={() => {}}*/}\n {/*/>*/}\n <Text>Van</Text>\n </View>\n <View>\n <Text style={{ fontSize: 16, marginLeft: 12, marginRight: 12 }}>\n to\n </Text>\n <Text style={{ opacity: 0 }} accessible={false}>\n tot\n </Text>\n </View>\n <View style={{ flex: 1 }}>\n {/*<DatePickerInput*/}\n {/* // value={''}*/}\n {/* // keyboardType={'numeric'}*/}\n {/* // placeholder={'DD-MM-YYY'}*/}\n {/* // mask={'DD-MM-YYY'}*/}\n {/* // onChangeText={() => {}}*/}\n {/*/>*/}\n <Text>Tot</Text>\n </View>\n <View>\n <IconButton icon={calendarIcon} onPress={() => setVisible(true)} />\n <Text style={{ opacity: 0 }} accessible={false}>\n tot\n </Text>\n </View>\n <DatePickerModal\n locale={locale}\n mode=\"range\"\n visible={visible}\n onDismiss={onDismiss}\n onConfirm={onConfirm}\n startDate={undefined}\n endDate={undefined}\n />\n </View>\n )\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,oBAAjC;AAEA,OAAOC,eAAP,MAA4B,mBAA5B,C,CAEA;;AACA,eAAe,SAASC,cAAT,OAMZ;EAAA,IANoC;IACrCC,MADqC;IAErCC,YAAY,GAAG;EAFsB,CAMpC;EACD,MAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBT,KAAK,CAACU,QAAN,CAAwB,KAAxB,CAA9B;EACA,MAAMC,SAAS,GAAGX,KAAK,CAACY,WAAN,CAAkB,MAAM;IACxCH,UAAU,CAAC,KAAD,CAAV;EACD,CAFiB,EAEf,CAACA,UAAD,CAFe,CAAlB;EAGA,MAAMI,SAAS,GAAGb,KAAK,CAACY,WAAN,EAChB;EACA,SAA8D;IAAA,IAA7D;MAAEE,SAAF;MAAaC;IAAb,CAA6D;IAC5DN,UAAU,CAAC,KAAD,CAAV;IACAO,OAAO,CAACC,GAAR,CAAY;MAAEH,SAAF;MAAaC;IAAb,CAAZ;EACD,CALe,EAMhB,CAACN,UAAD,CANgB,CAAlB;EASA,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAES,aAAa,EAAE,KAAjB;MAAwBC,UAAU,EAAE;IAApC;EAAb,gBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAR;EAAb,gBAQE,oBAAC,IAAD,cARF,CADF,eAWE,oBAAC,IAAD,qBACE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,UAAU,EAAE,EAA5B;MAAgCC,WAAW,EAAE;IAA7C;EAAb,QADF,eAIE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEC,OAAO,EAAE;IAAX,CAAb;IAA6B,UAAU,EAAE;EAAzC,SAJF,CAXF,eAmBE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEJ,IAAI,EAAE;IAAR;EAAb,gBAQE,oBAAC,IAAD,cARF,CAnBF,eA6BE,oBAAC,IAAD,qBACE,oBAAC,UAAD;IAAY,IAAI,EAAEb,YAAlB;IAAgC,OAAO,EAAE,MAAME,UAAU,CAAC,IAAD;EAAzD,EADF,eAEE,oBAAC,IAAD;IAAM,KAAK,EAAE;MAAEe,OAAO,EAAE;IAAX,CAAb;IAA6B,UAAU,EAAE;EAAzC,SAFF,CA7BF,eAmCE,oBAAC,eAAD;IACE,MAAM,EAAElB,MADV;IAEE,IAAI,EAAC,OAFP;IAGE,OAAO,EAAEE,OAHX;IAIE,SAAS,EAAEG,SAJb;IAKE,SAAS,EAAEE,SALb;IAME,SAAS,EAAEY,SANb;IAOE,OAAO,EAAEA;EAPX,EAnCF,CADF;AA+CD"}
@@ -1,4 +0,0 @@
1
- export default function DateRangeInput({ locale, calendarIcon, }: {
2
- locale: string;
3
- calendarIcon?: string;
4
- }): JSX.Element;
@@ -1,75 +0,0 @@
1
- import * as React from 'react'
2
- import { View } from 'react-native'
3
- import { Text, IconButton } from 'react-native-paper'
4
-
5
- import DatePickerModal from './DatePickerModal'
6
-
7
- // WORK IN PROGRESS
8
- export default function DateRangeInput({
9
- locale,
10
- calendarIcon = 'calendar',
11
- }: {
12
- locale: string
13
- calendarIcon?: string
14
- }) {
15
- const [visible, setVisible] = React.useState<boolean>(false)
16
- const onDismiss = React.useCallback(() => {
17
- setVisible(false)
18
- }, [setVisible])
19
- const onConfirm = React.useCallback(
20
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
- ({ startDate, endDate }: { startDate: any; endDate: any }) => {
22
- setVisible(false)
23
- console.log({ startDate, endDate })
24
- },
25
- [setVisible]
26
- )
27
-
28
- return (
29
- <View style={{ flexDirection: 'row', alignItems: 'center' }}>
30
- <View style={{ flex: 1 }}>
31
- {/*<DatePickerInput*/}
32
- {/* value={''}*/}
33
- {/* keyboardType={'numeric'}*/}
34
- {/* placeholder={'DD-MM-YYY'}*/}
35
- {/* mask={'DD-MM-YYY'}*/}
36
- {/* onChangeText={() => {}}*/}
37
- {/*/>*/}
38
- <Text>Van</Text>
39
- </View>
40
- <View>
41
- <Text style={{ fontSize: 16, marginLeft: 12, marginRight: 12 }}>
42
- to
43
- </Text>
44
- <Text style={{ opacity: 0 }} accessible={false}>
45
- tot
46
- </Text>
47
- </View>
48
- <View style={{ flex: 1 }}>
49
- {/*<DatePickerInput*/}
50
- {/* // value={''}*/}
51
- {/* // keyboardType={'numeric'}*/}
52
- {/* // placeholder={'DD-MM-YYY'}*/}
53
- {/* // mask={'DD-MM-YYY'}*/}
54
- {/* // onChangeText={() => {}}*/}
55
- {/*/>*/}
56
- <Text>Tot</Text>
57
- </View>
58
- <View>
59
- <IconButton icon={calendarIcon} onPress={() => setVisible(true)} />
60
- <Text style={{ opacity: 0 }} accessible={false}>
61
- tot
62
- </Text>
63
- </View>
64
- <DatePickerModal
65
- locale={locale}
66
- mode="range"
67
- visible={visible}
68
- onDismiss={onDismiss}
69
- onConfirm={onConfirm}
70
- startDate={undefined}
71
- endDate={undefined}
72
- />
73
- </View>
74
- )
75
- }