react-native-paper-dates 0.22.57 → 0.23.2
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.
- package/lib/commonjs/Date/Calendar.js +1 -10
- package/lib/commonjs/Date/Calendar.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContent.js +1 -3
- package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContentHeader.js +9 -11
- package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeader.js +1 -1
- package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/commonjs/Date/Day.js +12 -30
- package/lib/commonjs/Date/Day.js.map +1 -1
- package/lib/commonjs/Date/DayName.js +1 -1
- package/lib/commonjs/Date/DayName.js.map +1 -1
- package/lib/commonjs/Date/Month.js +4 -6
- package/lib/commonjs/Date/Month.js.map +1 -1
- package/lib/commonjs/Date/YearPicker.js +4 -6
- package/lib/commonjs/Date/YearPicker.js.map +1 -1
- package/lib/commonjs/Time/AmPmSwitcher.js +2 -9
- package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
- package/lib/commonjs/Time/AnalogClock.js +1 -4
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/TimeInput.js +3 -3
- package/lib/commonjs/Time/TimeInput.js.map +1 -1
- package/lib/commonjs/Time/TimeInputs.js +2 -2
- package/lib/commonjs/Time/TimeInputs.js.map +1 -1
- package/lib/commonjs/Time/TimePickerModal.js +6 -17
- package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
- package/lib/commonjs/Time/timeUtils.js +13 -38
- package/lib/commonjs/Time/timeUtils.js.map +1 -1
- package/lib/commonjs/shared/utils.js +5 -22
- package/lib/commonjs/shared/utils.js.map +1 -1
- package/lib/module/Date/Calendar.js +3 -12
- package/lib/module/Date/Calendar.js.map +1 -1
- package/lib/module/Date/DatePickerModal.js.map +1 -1
- package/lib/module/Date/DatePickerModalContent.js +1 -3
- package/lib/module/Date/DatePickerModalContent.js.map +1 -1
- package/lib/module/Date/DatePickerModalContentHeader.js +9 -11
- package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeader.js +1 -1
- package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/module/Date/Day.js +12 -30
- package/lib/module/Date/Day.js.map +1 -1
- package/lib/module/Date/DayName.js +1 -1
- package/lib/module/Date/DayName.js.map +1 -1
- package/lib/module/Date/Month.js +4 -6
- package/lib/module/Date/Month.js.map +1 -1
- package/lib/module/Date/YearPicker.js +4 -6
- package/lib/module/Date/YearPicker.js.map +1 -1
- package/lib/module/Time/AmPmSwitcher.js +3 -9
- package/lib/module/Time/AmPmSwitcher.js.map +1 -1
- package/lib/module/Time/AnalogClock.js +1 -4
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/TimeInput.js +3 -3
- package/lib/module/Time/TimeInput.js.map +1 -1
- package/lib/module/Time/TimeInputs.js +2 -2
- package/lib/module/Time/TimeInputs.js.map +1 -1
- package/lib/module/Time/TimePickerModal.js +7 -18
- package/lib/module/Time/TimePickerModal.js.map +1 -1
- package/lib/module/Time/timeUtils.js +13 -37
- package/lib/module/Time/timeUtils.js.map +1 -1
- package/lib/module/shared/utils.js +6 -22
- package/lib/module/shared/utils.js.map +1 -1
- package/lib/typescript/Date/Calendar.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModal.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContent.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContentHeader.d.ts.map +1 -1
- package/lib/typescript/Date/Day.d.ts.map +1 -1
- package/lib/typescript/Date/DayName.d.ts.map +1 -1
- package/lib/typescript/Date/Month.d.ts.map +1 -1
- package/lib/typescript/Time/AmPmSwitcher.d.ts.map +1 -1
- package/lib/typescript/Time/AnalogClock.d.ts.map +1 -1
- package/lib/typescript/Time/TimeInput.d.ts.map +1 -1
- package/lib/typescript/Time/TimeInputs.d.ts.map +1 -1
- package/lib/typescript/Time/TimePickerModal.d.ts.map +1 -1
- package/lib/typescript/Time/timeUtils.d.ts.map +1 -1
- package/lib/typescript/shared/utils.d.ts +2 -51
- package/lib/typescript/shared/utils.d.ts.map +1 -1
- package/package.json +22 -22
- package/src/Date/Calendar.tsx +3 -12
- package/src/Date/DatePickerModal.tsx +3 -6
- package/src/Date/DatePickerModalContent.tsx +4 -12
- package/src/Date/DatePickerModalContentHeader.tsx +10 -22
- package/src/Date/DatePickerModalHeader.tsx +1 -1
- package/src/Date/Day.tsx +13 -34
- package/src/Date/DayName.tsx +2 -4
- package/src/Date/Month.tsx +5 -19
- package/src/Date/YearPicker.tsx +4 -11
- package/src/Time/AmPmSwitcher.tsx +4 -18
- package/src/Time/AnalogClock.tsx +1 -6
- package/src/Time/TimeInput.tsx +10 -11
- package/src/Time/TimeInputs.tsx +3 -7
- package/src/Time/TimePickerModal.tsx +9 -33
- package/src/Time/timeUtils.ts +14 -51
- package/src/shared/utils.ts +8 -36
|
@@ -9,13 +9,7 @@ import {
|
|
|
9
9
|
View,
|
|
10
10
|
} from 'react-native'
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
Button,
|
|
14
|
-
IconButton,
|
|
15
|
-
MD2Theme,
|
|
16
|
-
overlay,
|
|
17
|
-
useTheme,
|
|
18
|
-
} from 'react-native-paper'
|
|
12
|
+
import { Button, IconButton, useTheme } from 'react-native-paper'
|
|
19
13
|
|
|
20
14
|
import TimePicker from './TimePicker'
|
|
21
15
|
import {
|
|
@@ -102,29 +96,17 @@ export function TimePickerModal({
|
|
|
102
96
|
[setFocused, setLocalHours, setLocalMinutes]
|
|
103
97
|
)
|
|
104
98
|
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
let textFont
|
|
99
|
+
const uppercase = _uppercase ?? false
|
|
100
|
+
const textFont = theme.fonts.labelMedium
|
|
108
101
|
let labelText = label
|
|
109
102
|
|
|
110
|
-
if (theme.isV3) {
|
|
111
|
-
textFont = theme.fonts.labelMedium
|
|
112
|
-
} else {
|
|
113
|
-
textFont = (theme as any as MD2Theme)?.fonts.medium
|
|
114
|
-
}
|
|
115
|
-
|
|
116
103
|
if (inputType === inputTypes.keyboard && !label) {
|
|
117
104
|
labelText = 'Enter time'
|
|
118
105
|
}
|
|
119
106
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
} else {
|
|
124
|
-
color = theme.dark
|
|
125
|
-
? overlay(10, theme.colors.surface)
|
|
126
|
-
: theme.colors.surface
|
|
127
|
-
}
|
|
107
|
+
const color = theme.dark
|
|
108
|
+
? theme.colors.elevation.level3
|
|
109
|
+
: theme.colors.surface
|
|
128
110
|
|
|
129
111
|
return (
|
|
130
112
|
<Modal
|
|
@@ -157,7 +139,7 @@ export function TimePickerModal({
|
|
|
157
139
|
// eslint-disable-next-line react-native/no-inline-styles
|
|
158
140
|
{
|
|
159
141
|
backgroundColor: color,
|
|
160
|
-
borderRadius:
|
|
142
|
+
borderRadius: 28,
|
|
161
143
|
},
|
|
162
144
|
]}
|
|
163
145
|
>
|
|
@@ -168,9 +150,7 @@ export function TimePickerModal({
|
|
|
168
150
|
styles.label,
|
|
169
151
|
{
|
|
170
152
|
...textFont,
|
|
171
|
-
color: theme
|
|
172
|
-
? theme.colors.onSurfaceVariant
|
|
173
|
-
: (theme as any as MD2Theme).colors.text,
|
|
153
|
+
color: theme.colors.onSurfaceVariant,
|
|
174
154
|
},
|
|
175
155
|
]}
|
|
176
156
|
>
|
|
@@ -192,11 +172,7 @@ export function TimePickerModal({
|
|
|
192
172
|
</View>
|
|
193
173
|
<View style={styles.bottom}>
|
|
194
174
|
<IconButton
|
|
195
|
-
iconColor={
|
|
196
|
-
theme?.isV3
|
|
197
|
-
? theme.colors.onBackground
|
|
198
|
-
: (theme as any as MD2Theme).colors.text
|
|
199
|
-
}
|
|
175
|
+
iconColor={theme.colors.onBackground}
|
|
200
176
|
icon={getTimeInputTypeIcon(inputType, {
|
|
201
177
|
keyboard: keyboardIcon,
|
|
202
178
|
picker: clockIcon,
|
package/src/Time/timeUtils.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Color from 'color'
|
|
2
1
|
import { useMemo } from 'react'
|
|
3
|
-
import {
|
|
2
|
+
import { useTheme } from 'react-native-paper'
|
|
4
3
|
|
|
5
4
|
export const circleSize = 256
|
|
6
5
|
|
|
@@ -159,37 +158,25 @@ export function useSwitchColors(highlighted: boolean) {
|
|
|
159
158
|
const backgroundColor = useMemo<string>(() => {
|
|
160
159
|
if (theme.dark) {
|
|
161
160
|
if (highlighted) {
|
|
162
|
-
return theme.
|
|
163
|
-
? theme.colors.tertiaryContainer
|
|
164
|
-
: Color(theme.colors.primary).hex()
|
|
161
|
+
return theme.colors.tertiaryContainer
|
|
165
162
|
}
|
|
166
163
|
return theme.colors.backdrop
|
|
167
164
|
}
|
|
168
165
|
|
|
169
166
|
if (highlighted) {
|
|
170
|
-
|
|
171
|
-
return theme.colors.primaryContainer
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return Color(theme.colors.primary).lighten(1).hex()
|
|
167
|
+
return theme.colors.primaryContainer
|
|
175
168
|
}
|
|
176
169
|
return theme.colors.surface
|
|
177
170
|
}, [highlighted, theme])
|
|
178
171
|
|
|
179
172
|
const color = useMemo<string>(() => {
|
|
180
173
|
if (highlighted && !theme.dark) {
|
|
181
|
-
return theme.
|
|
174
|
+
return theme.colors.onSurfaceVariant
|
|
182
175
|
}
|
|
183
176
|
if (highlighted && theme.dark) {
|
|
184
|
-
return theme.
|
|
185
|
-
? theme.colors.onTertiaryContainer
|
|
186
|
-
: theme.colors.background
|
|
187
|
-
}
|
|
188
|
-
if (theme.isV3) {
|
|
189
|
-
return theme.colors.onSurfaceVariant
|
|
190
|
-
} else {
|
|
191
|
-
return (theme as any as MD2Theme).colors.placeholder
|
|
177
|
+
return theme.colors.onTertiaryContainer
|
|
192
178
|
}
|
|
179
|
+
return theme.colors.onSurfaceVariant
|
|
193
180
|
}, [highlighted, theme])
|
|
194
181
|
|
|
195
182
|
return { backgroundColor, color }
|
|
@@ -200,47 +187,23 @@ export function useInputColors(highlighted: boolean) {
|
|
|
200
187
|
const backgroundColor = useMemo<string>(() => {
|
|
201
188
|
if (theme.dark) {
|
|
202
189
|
if (highlighted) {
|
|
203
|
-
return theme.
|
|
204
|
-
? theme.colors.primaryContainer
|
|
205
|
-
: Color(theme.colors.primary).hex()
|
|
190
|
+
return theme.colors.primaryContainer
|
|
206
191
|
}
|
|
207
|
-
return theme.
|
|
208
|
-
? theme.colors.surfaceVariant
|
|
209
|
-
: Color(theme.colors.surface).lighten(1.4).hex()
|
|
192
|
+
return theme.colors.surfaceVariant
|
|
210
193
|
}
|
|
211
194
|
|
|
212
195
|
if (highlighted) {
|
|
213
|
-
|
|
214
|
-
return theme.colors.secondaryContainer
|
|
215
|
-
}
|
|
216
|
-
return Color(theme.colors.primary).lighten(1).hex()
|
|
217
|
-
}
|
|
218
|
-
if (theme.isV3) {
|
|
219
|
-
return theme.colors.surfaceVariant
|
|
196
|
+
return theme.colors.secondaryContainer
|
|
220
197
|
}
|
|
221
|
-
return
|
|
198
|
+
return theme.colors.surfaceVariant
|
|
222
199
|
}, [highlighted, theme])
|
|
223
200
|
|
|
224
201
|
const color = useMemo<string>(() => {
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
return theme.isV3 ? theme.colors.onSurface : theme.colors.onBackground
|
|
228
|
-
}
|
|
229
|
-
return theme.isV3
|
|
230
|
-
? theme.colors.onPrimaryContainer
|
|
231
|
-
: theme.colors.onBackground
|
|
232
|
-
} else {
|
|
233
|
-
const t = theme as any as MD2Theme
|
|
234
|
-
if (highlighted && !theme.dark) {
|
|
235
|
-
const primary = Color(t.colors.primary)
|
|
236
|
-
const background = Color(backgroundColor)
|
|
237
|
-
return background.isDark() && primary.isDark()
|
|
238
|
-
? '#ffffffff'
|
|
239
|
-
: t.colors.primary
|
|
240
|
-
}
|
|
241
|
-
return (theme as any as MD2Theme).colors.text
|
|
202
|
+
if (!highlighted) {
|
|
203
|
+
return theme.colors.onSurface
|
|
242
204
|
}
|
|
243
|
-
|
|
205
|
+
return theme.colors.onPrimaryContainer
|
|
206
|
+
}, [highlighted, theme])
|
|
244
207
|
|
|
245
208
|
return { backgroundColor, color }
|
|
246
209
|
}
|
package/src/shared/utils.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { useRef } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
DefaultTheme,
|
|
4
|
-
MD3DarkTheme,
|
|
5
|
-
overlay,
|
|
6
|
-
useTheme,
|
|
7
|
-
} from 'react-native-paper'
|
|
2
|
+
import { DefaultTheme, MD3DarkTheme, useTheme } from 'react-native-paper'
|
|
8
3
|
import Color from 'color'
|
|
9
4
|
|
|
10
5
|
export const supportedOrientations: (
|
|
@@ -31,45 +26,22 @@ export function useLatest<T>(value: T) {
|
|
|
31
26
|
|
|
32
27
|
export function useHeaderBackgroundColor() {
|
|
33
28
|
const theme = useTheme()
|
|
34
|
-
|
|
35
|
-
return theme.colors.surface
|
|
36
|
-
}
|
|
37
|
-
return theme.dark && theme.mode === 'adaptive'
|
|
38
|
-
? overlay(4, theme.colors.surface)
|
|
39
|
-
: theme.colors.primary
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function useHeaderColorIsLight() {
|
|
43
|
-
const theme = useTheme()
|
|
44
|
-
const background =
|
|
45
|
-
theme.dark && theme.mode === 'adaptive'
|
|
46
|
-
? theme.colors.surface
|
|
47
|
-
: theme.colors.primary
|
|
48
|
-
return Color(background).isLight()
|
|
29
|
+
return theme.colors.surface
|
|
49
30
|
}
|
|
50
31
|
|
|
51
32
|
export function useHeaderTextColor() {
|
|
52
33
|
const theme = useTheme()
|
|
53
|
-
|
|
54
|
-
if (theme.isV3) {
|
|
55
|
-
return theme.colors.onSurfaceVariant
|
|
56
|
-
}
|
|
57
|
-
return !isLight ? '#fff' : '#000'
|
|
34
|
+
return theme.colors.onSurfaceVariant
|
|
58
35
|
}
|
|
59
36
|
|
|
60
37
|
export function useTextColorOnPrimary() {
|
|
61
38
|
const theme = useTheme()
|
|
62
39
|
const isDark = !Color(theme.colors.primary).isLight()
|
|
63
40
|
|
|
64
|
-
if (theme.
|
|
65
|
-
|
|
66
|
-
return theme.colors.onSurface
|
|
67
|
-
} else {
|
|
68
|
-
return theme.colors.onPrimary
|
|
69
|
-
}
|
|
41
|
+
if (isDark && theme.dark) {
|
|
42
|
+
return theme.colors.onSurface
|
|
70
43
|
}
|
|
71
|
-
|
|
72
|
-
return isDark ? '#fff' : '#000'
|
|
44
|
+
return theme.colors.onPrimary
|
|
73
45
|
}
|
|
74
46
|
|
|
75
47
|
export function range(start: number, end: number) {
|
|
@@ -78,12 +50,12 @@ export function range(start: number, end: number) {
|
|
|
78
50
|
.map((_, i) => start + i)
|
|
79
51
|
}
|
|
80
52
|
|
|
81
|
-
export function lightenBy(color: Color
|
|
53
|
+
export function lightenBy(color: InstanceType<typeof Color>, ratio: number) {
|
|
82
54
|
const lightness = color.lightness()
|
|
83
55
|
return color.lightness(lightness + (100 - lightness) * ratio)
|
|
84
56
|
}
|
|
85
57
|
|
|
86
|
-
export function darkenBy(color: Color
|
|
58
|
+
export function darkenBy(color: InstanceType<typeof Color>, ratio: number) {
|
|
87
59
|
const lightness = color.lightness()
|
|
88
60
|
return color.lightness(lightness - lightness * ratio)
|
|
89
61
|
}
|