react-native-paper-dates 0.9.2 → 0.10.1
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/README.md +1 -1
- package/lib/commonjs/Date/AnimatedCrossView.js +1 -4
- package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
- package/lib/commonjs/Date/Calendar.js +1 -1
- package/lib/commonjs/Date/Calendar.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInput.js +4 -2
- package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInput.shared.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInputWithoutModal.js +17 -13
- package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContentHeader.js +5 -2
- package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeader.js +11 -12
- package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +7 -8
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/commonjs/Date/Day.js +5 -4
- package/lib/commonjs/Date/Day.js.map +1 -1
- package/lib/commonjs/Date/DayName.js +3 -1
- package/lib/commonjs/Date/DayName.js.map +1 -1
- package/lib/commonjs/Date/Month.js +3 -1
- package/lib/commonjs/Date/Month.js.map +1 -1
- package/lib/commonjs/Date/Swiper.js +1 -2
- package/lib/commonjs/Date/Swiper.js.map +1 -1
- package/lib/commonjs/Date/YearPicker.js +4 -2
- package/lib/commonjs/Date/YearPicker.js.map +1 -1
- package/lib/commonjs/TextInputMask.js +9 -4
- package/lib/commonjs/TextInputMask.js.map +1 -1
- package/lib/commonjs/Time/AmPmSwitcher.js +3 -2
- package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
- package/lib/commonjs/Time/AnalogClock.js +1 -1
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/TimeInputs.js +7 -4
- package/lib/commonjs/Time/TimeInputs.js.map +1 -1
- package/lib/commonjs/Time/TimePicker.js +4 -1
- package/lib/commonjs/Time/TimePicker.js.map +1 -1
- package/lib/commonjs/Time/TimePickerModal.js +15 -4
- package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
- package/lib/commonjs/Time/timeUtils.js +35 -3
- package/lib/commonjs/Time/timeUtils.js.map +1 -1
- package/lib/commonjs/translations/utils.js +2 -2
- package/lib/commonjs/translations/utils.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/Date/AnimatedCrossView.js +1 -3
- package/lib/module/Date/AnimatedCrossView.js.map +1 -1
- package/lib/module/Date/Calendar.js +1 -1
- package/lib/module/Date/Calendar.js.map +1 -1
- package/lib/module/Date/DatePickerInput.js +4 -2
- package/lib/module/Date/DatePickerInput.js.map +1 -1
- package/lib/module/Date/DatePickerInput.shared.js.map +1 -1
- package/lib/module/Date/DatePickerInputWithoutModal.js +17 -13
- package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
- package/lib/module/Date/DatePickerModalContentHeader.js +6 -3
- package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeader.js +11 -13
- package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeaderBackground.js +7 -9
- package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/module/Date/Day.js +5 -4
- package/lib/module/Date/Day.js.map +1 -1
- package/lib/module/Date/DayName.js +3 -1
- package/lib/module/Date/DayName.js.map +1 -1
- package/lib/module/Date/Month.js +3 -1
- package/lib/module/Date/Month.js.map +1 -1
- package/lib/module/Date/Swiper.js +1 -2
- package/lib/module/Date/Swiper.js.map +1 -1
- package/lib/module/Date/YearPicker.js +4 -2
- package/lib/module/Date/YearPicker.js.map +1 -1
- package/lib/module/TextInputMask.js +9 -4
- package/lib/module/TextInputMask.js.map +1 -1
- package/lib/module/Time/AmPmSwitcher.js +3 -2
- package/lib/module/Time/AmPmSwitcher.js.map +1 -1
- package/lib/module/Time/AnalogClock.js +1 -1
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/TimeInputs.js +6 -4
- package/lib/module/Time/TimeInputs.js.map +1 -1
- package/lib/module/Time/TimePicker.js +4 -1
- package/lib/module/Time/TimePicker.js.map +1 -1
- package/lib/module/Time/TimePickerModal.js +15 -4
- package/lib/module/Time/TimePickerModal.js.map +1 -1
- package/lib/module/Time/timeUtils.js +35 -3
- package/lib/module/Time/timeUtils.js.map +1 -1
- package/lib/module/translations/utils.js +2 -2
- package/lib/module/translations/utils.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/Date/AutoSizer.d.ts +1 -1
- package/lib/typescript/Date/Calendar.d.ts +10 -10
- package/lib/typescript/Date/DatePickerInput.d.ts +1 -1
- package/lib/typescript/Date/DatePickerInput.shared.d.ts +2 -1
- package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +10 -4
- package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -1
- package/lib/typescript/Date/Day.d.ts +2 -2
- package/lib/typescript/Date/SwiperUtils.d.ts +2 -2
- package/lib/typescript/Date/dateUtils.d.ts +1 -1
- package/lib/typescript/TextInputMask.d.ts +9 -4
- package/lib/typescript/Time/TimePicker.d.ts +1 -1
- package/lib/typescript/Time/timeUtils.d.ts +7 -7
- package/lib/typescript/translations/utils.d.ts +1 -1
- package/lib/typescript/utils.d.ts +2 -0
- package/package.json +9 -8
- package/src/Date/AnimatedCrossView.tsx +0 -4
- package/src/Date/Calendar.tsx +2 -2
- package/src/Date/DatePickerInput.shared.tsx +1 -0
- package/src/Date/DatePickerInput.tsx +2 -1
- package/src/Date/DatePickerInputWithoutModal.tsx +36 -35
- package/src/Date/DatePickerModalContentHeader.tsx +9 -4
- package/src/Date/DatePickerModalHeader.tsx +35 -37
- package/src/Date/DatePickerModalHeaderBackground.tsx +6 -7
- package/src/Date/Day.tsx +12 -4
- package/src/Date/DayName.tsx +7 -5
- package/src/Date/Month.tsx +12 -2
- package/src/Date/Swiper.tsx +0 -1
- package/src/Date/YearPicker.tsx +16 -4
- package/src/TextInputMask.tsx +8 -4
- package/src/Time/AmPmSwitcher.tsx +11 -3
- package/src/Time/AnalogClock.tsx +3 -1
- package/src/Time/TimeInputs.tsx +32 -4
- package/src/Time/TimePicker.tsx +4 -1
- package/src/Time/TimePickerModal.tsx +29 -3
- package/src/Time/timeUtils.ts +31 -4
- package/src/translations/utils.ts +2 -2
- package/src/utils.ts +8 -1
- package/lib/commonjs/Date/DateRangeInput.js +0 -86
- package/lib/commonjs/Date/DateRangeInput.js.map +0 -1
- package/lib/module/Date/DateRangeInput.js +0 -69
- package/lib/module/Date/DateRangeInput.js.map +0 -1
- package/lib/typescript/Date/DateRangeInput.d.ts +0 -4
- package/src/Date/DateRangeInput.tsx +0 -75
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { DefaultTheme, MD3DarkTheme } from 'react-native-paper';
|
|
2
3
|
import Color from 'color';
|
|
4
|
+
export type PaperTheme = typeof MD3DarkTheme | typeof DefaultTheme;
|
|
3
5
|
export declare function useLatest<T>(value: T): React.MutableRefObject<T>;
|
|
4
6
|
export declare function useHeaderBackgroundColor(): string;
|
|
5
7
|
export declare function useHeaderColorIsLight(): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-paper-dates",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Performant Date Picker for React Native Paper",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -51,25 +51,26 @@
|
|
|
51
51
|
"@react-native-community/eslint-config": "^3.1.0",
|
|
52
52
|
"@release-it/conventional-changelog": "^5.1.0",
|
|
53
53
|
"@types/color": "^3.0.3",
|
|
54
|
-
"@types/jest": "^
|
|
55
|
-
"@types/react": "^18.0.
|
|
56
|
-
"@types/react-native": "^0.
|
|
54
|
+
"@types/jest": "^29.2.4",
|
|
55
|
+
"@types/react": "^18.0.26",
|
|
56
|
+
"@types/react-native": "^0.70.8",
|
|
57
57
|
"babel-loader": "^8.2.5",
|
|
58
58
|
"commitlint": "^17.0.3",
|
|
59
59
|
"eslint": "^8.22.0",
|
|
60
60
|
"eslint-config-prettier": "^8.5.0",
|
|
61
61
|
"eslint-plugin-prettier": "^4.2.1",
|
|
62
|
-
"expo-cli": "^6.0.
|
|
62
|
+
"expo-cli": "^6.0.8",
|
|
63
63
|
"husky": "^8.0.1",
|
|
64
64
|
"jest": "^29.0.0",
|
|
65
65
|
"pod-install": "^0.1.38",
|
|
66
66
|
"prettier": "^2.7.1",
|
|
67
67
|
"react": "^18.2.0",
|
|
68
|
-
"react-native": "^0.
|
|
68
|
+
"react-native": "^0.70.6",
|
|
69
69
|
"react-native-builder-bob": "^0.18.3",
|
|
70
|
-
"react-native-paper": "^
|
|
70
|
+
"react-native-paper": "^5.0.2",
|
|
71
|
+
"react-native-safe-area-context": "^4.4.1",
|
|
71
72
|
"release-it": "^15.4.0",
|
|
72
|
-
"typescript": "^4.
|
|
73
|
+
"typescript": "^4.9.4"
|
|
73
74
|
},
|
|
74
75
|
"peerDependencies": {
|
|
75
76
|
"react": "*",
|
|
@@ -3,14 +3,12 @@ import { Animated, StyleSheet, View } from 'react-native'
|
|
|
3
3
|
import { useTheme } from 'react-native-paper'
|
|
4
4
|
|
|
5
5
|
export default function AnimatedCrossView({
|
|
6
|
-
// visible,
|
|
7
6
|
collapsed,
|
|
8
7
|
calendar,
|
|
9
8
|
calendarEdit,
|
|
10
9
|
}: {
|
|
11
10
|
calendar: any
|
|
12
11
|
calendarEdit: any
|
|
13
|
-
// visible: boolean
|
|
14
12
|
collapsed: boolean
|
|
15
13
|
}) {
|
|
16
14
|
const theme = useTheme()
|
|
@@ -18,13 +16,11 @@ export default function AnimatedCrossView({
|
|
|
18
16
|
new Animated.Value(collapsed ? 1 : 0)
|
|
19
17
|
)
|
|
20
18
|
React.useEffect(() => {
|
|
21
|
-
// if (visible) {
|
|
22
19
|
Animated.timing(calendarOpacity.current, {
|
|
23
20
|
toValue: collapsed ? 1 : 0,
|
|
24
21
|
duration: 250,
|
|
25
22
|
useNativeDriver: true,
|
|
26
23
|
}).start()
|
|
27
|
-
// }
|
|
28
24
|
}, [collapsed])
|
|
29
25
|
|
|
30
26
|
return (
|
package/src/Date/Calendar.tsx
CHANGED
|
@@ -34,7 +34,7 @@ export type BaseCalendarProps = {
|
|
|
34
34
|
startYear?: number
|
|
35
35
|
endYear?: number
|
|
36
36
|
|
|
37
|
-
// here they are optional but in final
|
|
37
|
+
// here they are optional but in final implementation they are required
|
|
38
38
|
date?: CalendarDate
|
|
39
39
|
dates?: CalendarDates
|
|
40
40
|
startDate?: CalendarDate
|
|
@@ -101,7 +101,7 @@ function Calendar(
|
|
|
101
101
|
|
|
102
102
|
const selectColor = useMemo<string>(() => {
|
|
103
103
|
if (theme.dark) {
|
|
104
|
-
return darkenBy(Color(theme.colors.primary), 0.
|
|
104
|
+
return darkenBy(Color(theme.colors.primary), 0.1).hex()
|
|
105
105
|
}
|
|
106
106
|
return lightenBy(Color(theme.colors.primary), 0.9).hex()
|
|
107
107
|
}, [theme])
|
|
@@ -42,7 +42,7 @@ function DatePickerInput(
|
|
|
42
42
|
/>
|
|
43
43
|
) : null
|
|
44
44
|
}
|
|
45
|
-
modal={({ value, locale, inputMode, validRange }) =>
|
|
45
|
+
modal={({ value, locale, inputMode, validRange, saveLabel }) =>
|
|
46
46
|
withModal ? (
|
|
47
47
|
<DatePickerModal
|
|
48
48
|
date={value}
|
|
@@ -53,6 +53,7 @@ function DatePickerInput(
|
|
|
53
53
|
locale={locale}
|
|
54
54
|
dateMode={inputMode}
|
|
55
55
|
validRange={validRange}
|
|
56
|
+
saveLabel={saveLabel}
|
|
56
57
|
/>
|
|
57
58
|
) : null
|
|
58
59
|
}
|
|
@@ -18,6 +18,7 @@ function DatePickerInputWithoutModal(
|
|
|
18
18
|
withDateFormatInLabel = true,
|
|
19
19
|
modal,
|
|
20
20
|
inputButtons,
|
|
21
|
+
saveLabel,
|
|
21
22
|
...rest
|
|
22
23
|
}: DatePickerInputProps & {
|
|
23
24
|
modal?: (params: {
|
|
@@ -25,6 +26,7 @@ function DatePickerInputWithoutModal(
|
|
|
25
26
|
locale: DatePickerInputProps['locale']
|
|
26
27
|
inputMode: DatePickerInputProps['inputMode']
|
|
27
28
|
validRange: DatePickerInputProps['validRange']
|
|
29
|
+
saveLabel: DatePickerInputProps['saveLabel']
|
|
28
30
|
}) => any
|
|
29
31
|
inputButtons?: any
|
|
30
32
|
},
|
|
@@ -42,38 +44,34 @@ function DatePickerInputWithoutModal(
|
|
|
42
44
|
return (
|
|
43
45
|
<>
|
|
44
46
|
<View style={styles.root}>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
>
|
|
71
|
-
{error}
|
|
72
|
-
</HelperText>
|
|
73
|
-
</View>
|
|
47
|
+
<View style={styles.inputContainer}>
|
|
48
|
+
<TextInputWithMask
|
|
49
|
+
{...rest}
|
|
50
|
+
ref={ref}
|
|
51
|
+
label={getLabel({
|
|
52
|
+
// TODO: support label components?
|
|
53
|
+
label: label as any,
|
|
54
|
+
inputFormat,
|
|
55
|
+
withDateFormatInLabel,
|
|
56
|
+
})}
|
|
57
|
+
value={formattedValue}
|
|
58
|
+
keyboardType={'number-pad'}
|
|
59
|
+
placeholder={inputFormat}
|
|
60
|
+
mask={inputFormat}
|
|
61
|
+
onChangeText={onChangeText}
|
|
62
|
+
keyboardAppearance={theme.dark ? 'dark' : 'default'}
|
|
63
|
+
error={!!error}
|
|
64
|
+
style={[styles.input, style]}
|
|
65
|
+
/>
|
|
66
|
+
{inputButtons}
|
|
67
|
+
</View>
|
|
68
|
+
{error ? (
|
|
69
|
+
<HelperText style={styles.helperText} type="error" visible={!!error}>
|
|
70
|
+
{error}
|
|
71
|
+
</HelperText>
|
|
74
72
|
) : null}
|
|
75
73
|
</View>
|
|
76
|
-
{modal?.({ value, locale, inputMode, validRange })}
|
|
74
|
+
{modal?.({ value, locale, inputMode, validRange, saveLabel })}
|
|
77
75
|
</>
|
|
78
76
|
)
|
|
79
77
|
}
|
|
@@ -95,16 +93,19 @@ function getLabel({
|
|
|
95
93
|
|
|
96
94
|
const styles = StyleSheet.create({
|
|
97
95
|
root: {
|
|
98
|
-
minWidth: 150,
|
|
99
96
|
flexGrow: 1,
|
|
100
|
-
justifyContent: 'center',
|
|
101
97
|
},
|
|
102
|
-
|
|
98
|
+
inputContainer: {
|
|
99
|
+
flexGrow: 1,
|
|
103
100
|
flexDirection: 'row',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
justifyContent: 'flex-start',
|
|
103
|
+
},
|
|
104
|
+
input: {
|
|
105
|
+
flexGrow: 1,
|
|
104
106
|
},
|
|
105
107
|
helperText: {
|
|
106
|
-
flex: 1,
|
|
108
|
+
// flex: 1,
|
|
107
109
|
},
|
|
108
|
-
input: {},
|
|
109
110
|
})
|
|
110
111
|
export default React.forwardRef(DatePickerInputWithoutModal)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { View, StyleSheet } from 'react-native'
|
|
3
|
-
import { IconButton, Text } from 'react-native-paper'
|
|
3
|
+
import { IconButton, MD2Theme, Text, useTheme } from 'react-native-paper'
|
|
4
4
|
import type { ModeType } from './Calendar'
|
|
5
5
|
import type { LocalState } from './DatePickerModalContent'
|
|
6
6
|
import { useHeaderTextColor } from '../utils'
|
|
@@ -61,15 +61,20 @@ export default function DatePickerModalContentHeader(
|
|
|
61
61
|
editIcon = 'pencil',
|
|
62
62
|
calendarIcon = 'calendar',
|
|
63
63
|
} = props
|
|
64
|
-
|
|
64
|
+
const theme = useTheme()
|
|
65
65
|
const label = getLabel(props.locale, props.mode, props.label)
|
|
66
66
|
|
|
67
67
|
const color = useHeaderTextColor()
|
|
68
68
|
const allowEditing = mode !== 'multiple'
|
|
69
|
+
|
|
70
|
+
let textFont = theme?.isV3
|
|
71
|
+
? theme.fonts.bodyLarge
|
|
72
|
+
: (theme as any as MD2Theme).fonts.medium
|
|
73
|
+
|
|
69
74
|
return (
|
|
70
75
|
<View style={[styles.header]}>
|
|
71
76
|
<View>
|
|
72
|
-
<Text style={[styles.label, { color }]}>
|
|
77
|
+
<Text style={[styles.label, { color, ...textFont }]}>
|
|
73
78
|
{uppercase ? label.toUpperCase() : label}
|
|
74
79
|
</Text>
|
|
75
80
|
<View style={styles.headerContentContainer}>
|
|
@@ -97,7 +102,7 @@ export default function DatePickerModalContentHeader(
|
|
|
97
102
|
? getTranslation(props.locale, 'typeInDate')
|
|
98
103
|
: getTranslation(props.locale, 'pickDateFromCalendar')
|
|
99
104
|
}
|
|
100
|
-
|
|
105
|
+
iconColor={color}
|
|
101
106
|
onPress={onToggle}
|
|
102
107
|
/>
|
|
103
108
|
) : null}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { Animated, StyleSheet
|
|
2
|
+
import { Animated, StyleSheet } from 'react-native'
|
|
3
3
|
import { Appbar, Button } from 'react-native-paper'
|
|
4
4
|
|
|
5
5
|
import { useHeaderTextColor } from '../utils'
|
|
6
6
|
import { getTranslation } from '../translations/utils'
|
|
7
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
7
8
|
|
|
8
9
|
export interface DatePickerModalHeaderProps {
|
|
9
10
|
disableSafeTop?: boolean
|
|
@@ -22,37 +23,40 @@ export default function DatePickerModalHeader(
|
|
|
22
23
|
const { disableSafeTop, locale, closeIcon = 'close' } = props
|
|
23
24
|
const saveLabel = props.saveLabel || getTranslation(locale, 'save')
|
|
24
25
|
const color = useHeaderTextColor()
|
|
26
|
+
const insets = useSafeAreaInsets()
|
|
27
|
+
|
|
25
28
|
return (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
<Animated.View
|
|
30
|
+
style={[
|
|
31
|
+
styles.animated,
|
|
32
|
+
{
|
|
33
|
+
paddingTop: disableSafeTop ? 0 : insets.top,
|
|
34
|
+
paddingLeft: insets.left,
|
|
35
|
+
paddingRight: insets.right,
|
|
36
|
+
},
|
|
37
|
+
]}
|
|
38
|
+
>
|
|
39
|
+
<Appbar style={styles.appbarHeader}>
|
|
40
|
+
<Appbar.Action
|
|
41
|
+
icon={closeIcon}
|
|
42
|
+
accessibilityLabel={getTranslation(locale, 'close')}
|
|
43
|
+
onPress={props.onDismiss}
|
|
44
|
+
color={color}
|
|
45
|
+
testID="react-native-paper-dates-close"
|
|
46
|
+
/>
|
|
47
|
+
<Appbar.Content title={''} />
|
|
48
|
+
<Button
|
|
49
|
+
color={color}
|
|
50
|
+
textColor={color}
|
|
51
|
+
onPress={props.onSave}
|
|
52
|
+
disabled={props.saveLabelDisabled || false}
|
|
53
|
+
uppercase={props.uppercase || true}
|
|
54
|
+
testID="react-native-paper-dates-save"
|
|
33
55
|
>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
onPress={props.onDismiss}
|
|
39
|
-
color={color}
|
|
40
|
-
testID="react-native-paper-dates-close"
|
|
41
|
-
/>
|
|
42
|
-
<Appbar.Content title={''} />
|
|
43
|
-
<Button
|
|
44
|
-
color={color}
|
|
45
|
-
onPress={props.onSave}
|
|
46
|
-
disabled={props.saveLabelDisabled || false}
|
|
47
|
-
uppercase={props.uppercase || true}
|
|
48
|
-
testID="react-native-paper-dates-save"
|
|
49
|
-
>
|
|
50
|
-
{saveLabel}
|
|
51
|
-
</Button>
|
|
52
|
-
</Appbar>
|
|
53
|
-
</SafeAreaView>
|
|
54
|
-
</Animated.View>
|
|
55
|
-
</>
|
|
56
|
+
{saveLabel}
|
|
57
|
+
</Button>
|
|
58
|
+
</Appbar>
|
|
59
|
+
</Animated.View>
|
|
56
60
|
)
|
|
57
61
|
}
|
|
58
62
|
|
|
@@ -61,15 +65,9 @@ const styles = StyleSheet.create({
|
|
|
61
65
|
flex: 1,
|
|
62
66
|
},
|
|
63
67
|
animated: {
|
|
64
|
-
paddingBottom: 0,
|
|
65
68
|
elevation: 4,
|
|
66
69
|
},
|
|
67
|
-
|
|
68
|
-
paddingBottom: 0,
|
|
69
|
-
},
|
|
70
|
-
safeContentNoTop: {
|
|
71
|
-
paddingTop: 0,
|
|
72
|
-
},
|
|
70
|
+
|
|
73
71
|
header: {
|
|
74
72
|
height: 75,
|
|
75
73
|
alignItems: 'center',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Animated,
|
|
1
|
+
import { Animated, StyleSheet } from 'react-native'
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
import { useHeaderBackgroundColor } from '../utils'
|
|
4
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
4
5
|
|
|
5
6
|
export default function DatePickerModalHeaderBackground({
|
|
6
7
|
children,
|
|
@@ -8,27 +9,25 @@ export default function DatePickerModalHeaderBackground({
|
|
|
8
9
|
children: any
|
|
9
10
|
}) {
|
|
10
11
|
const backgroundColor = useHeaderBackgroundColor()
|
|
11
|
-
|
|
12
|
+
const insets = useSafeAreaInsets()
|
|
12
13
|
return (
|
|
13
14
|
<Animated.View
|
|
14
15
|
style={[
|
|
15
16
|
styles.animated,
|
|
16
17
|
{
|
|
17
18
|
backgroundColor,
|
|
19
|
+
paddingLeft: insets.left,
|
|
20
|
+
paddingRight: insets.right,
|
|
18
21
|
},
|
|
19
22
|
]}
|
|
20
23
|
>
|
|
21
|
-
|
|
24
|
+
{children}
|
|
22
25
|
</Animated.View>
|
|
23
26
|
)
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
const styles = StyleSheet.create({
|
|
27
30
|
animated: {
|
|
28
|
-
paddingBottom: 0,
|
|
29
31
|
elevation: 4,
|
|
30
32
|
},
|
|
31
|
-
safeContent: {
|
|
32
|
-
paddingBottom: 0,
|
|
33
|
-
},
|
|
34
33
|
})
|
package/src/Date/Day.tsx
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { MD2Theme, Text, TouchableRipple } from 'react-native-paper'
|
|
3
3
|
import { StyleSheet, View } from 'react-native'
|
|
4
4
|
import DayRange from './DayRange'
|
|
5
5
|
import { daySize } from './dateUtils'
|
|
6
6
|
|
|
7
|
+
import type { PaperTheme } from '../utils'
|
|
8
|
+
|
|
7
9
|
function EmptyDayPure() {
|
|
8
10
|
return <View style={styles.empty} />
|
|
9
11
|
}
|
|
10
12
|
export const EmptyDay = React.memo(EmptyDayPure)
|
|
11
13
|
|
|
12
14
|
function Day(props: {
|
|
13
|
-
theme:
|
|
15
|
+
theme: PaperTheme
|
|
14
16
|
textColorOnPrimary: string
|
|
15
17
|
day: number
|
|
16
18
|
month: number
|
|
@@ -41,7 +43,6 @@ function Day(props: {
|
|
|
41
43
|
textColorOnPrimary,
|
|
42
44
|
theme,
|
|
43
45
|
} = props
|
|
44
|
-
// console.log(month, { day })
|
|
45
46
|
const onPress = React.useCallback(() => {
|
|
46
47
|
onPressDate(new Date(year, month, day))
|
|
47
48
|
}, [onPressDate, year, month, day])
|
|
@@ -55,6 +56,10 @@ function Day(props: {
|
|
|
55
56
|
const textColor =
|
|
56
57
|
selected || (inRange && theme.dark) ? textColorOnPrimary : undefined
|
|
57
58
|
|
|
59
|
+
let textFont = theme?.isV3
|
|
60
|
+
? theme.fonts.bodyMedium
|
|
61
|
+
: (theme as any as MD2Theme).fonts.medium
|
|
62
|
+
|
|
58
63
|
return (
|
|
59
64
|
<View style={[styles.root, disabled && styles.disabled]}>
|
|
60
65
|
<DayRange
|
|
@@ -83,7 +88,10 @@ function Day(props: {
|
|
|
83
88
|
]}
|
|
84
89
|
>
|
|
85
90
|
<Text
|
|
86
|
-
style={
|
|
91
|
+
style={[
|
|
92
|
+
textColor ? { color: textColor } : undefined,
|
|
93
|
+
{ ...textFont },
|
|
94
|
+
]}
|
|
87
95
|
selectable={false}
|
|
88
96
|
>
|
|
89
97
|
{day}
|
package/src/Date/DayName.tsx
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { StyleSheet, View } from 'react-native'
|
|
3
|
-
import { Text, useTheme } from 'react-native-paper'
|
|
3
|
+
import { MD2Theme, Text, useTheme } from 'react-native-paper'
|
|
4
4
|
|
|
5
5
|
function DayName({ label }: { label: string }) {
|
|
6
6
|
const theme = useTheme()
|
|
7
|
+
|
|
8
|
+
let textFont = theme?.isV3
|
|
9
|
+
? theme.fonts.bodyMedium
|
|
10
|
+
: (theme as any as MD2Theme).fonts.medium
|
|
11
|
+
|
|
7
12
|
return (
|
|
8
13
|
<View style={styles.dayName}>
|
|
9
|
-
<Text
|
|
10
|
-
style={[styles.dayNameLabel, theme.fonts.medium]}
|
|
11
|
-
selectable={false}
|
|
12
|
-
>
|
|
14
|
+
<Text style={[styles.dayNameLabel, { ...textFont }]} selectable={false}>
|
|
13
15
|
{label}
|
|
14
16
|
</Text>
|
|
15
17
|
</View>
|
package/src/Date/Month.tsx
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { StyleSheet, View } from 'react-native'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IconButton,
|
|
5
|
+
Text,
|
|
6
|
+
useTheme,
|
|
7
|
+
TouchableRipple,
|
|
8
|
+
MD2Theme,
|
|
9
|
+
} from 'react-native-paper'
|
|
4
10
|
import Day, { EmptyDay } from './Day'
|
|
5
11
|
|
|
6
12
|
import {
|
|
@@ -244,6 +250,10 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
244
250
|
date,
|
|
245
251
|
])
|
|
246
252
|
|
|
253
|
+
let textFont = theme?.isV3
|
|
254
|
+
? theme.fonts.bodyMedium
|
|
255
|
+
: (theme as any as MD2Theme).fonts.medium
|
|
256
|
+
|
|
247
257
|
return (
|
|
248
258
|
<View style={[styles.month, { height: getMonthHeight(scrollMode, index) }]}>
|
|
249
259
|
<View
|
|
@@ -278,7 +288,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
278
288
|
]}
|
|
279
289
|
>
|
|
280
290
|
<Text
|
|
281
|
-
style={[styles.monthLabel,
|
|
291
|
+
style={[styles.monthLabel, { ...textFont }]}
|
|
282
292
|
selectable={false}
|
|
283
293
|
>
|
|
284
294
|
{monthName} {year}
|
package/src/Date/Swiper.tsx
CHANGED
package/src/Date/YearPicker.tsx
CHANGED
|
@@ -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(
|
|
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={[
|
|
97
|
+
style={[
|
|
98
|
+
styles.yearLabel,
|
|
99
|
+
selected ? styles.selectedYear : null,
|
|
100
|
+
{ ...textFont },
|
|
101
|
+
]}
|
|
90
102
|
selectable={false}
|
|
91
103
|
>
|
|
92
104
|
{year}
|
package/src/TextInputMask.tsx
CHANGED
|
@@ -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(
|
|
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
|
-
...
|
|
103
|
+
...textFont,
|
|
96
104
|
color: color,
|
|
97
105
|
},
|
|
98
106
|
]}
|
package/src/Time/AnalogClock.tsx
CHANGED
|
@@ -128,7 +128,9 @@ function AnalogClock({
|
|
|
128
128
|
styles.clock,
|
|
129
129
|
{
|
|
130
130
|
backgroundColor: theme.dark
|
|
131
|
-
? Color(theme.colors.surface).lighten(1.
|
|
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
|
]}
|