react-native-paper-dates 0.11.14 → 0.12.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.
- package/lib/commonjs/Date/DatePickerInput.js +1 -0
- package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
- package/lib/commonjs/Time/AnalogClock.js +7 -3
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockHours.js +4 -9
- package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
- package/lib/commonjs/Time/TimeInput.js +2 -1
- package/lib/commonjs/Time/TimeInput.js.map +1 -1
- package/lib/commonjs/Time/TimeInputs.js +4 -1
- package/lib/commonjs/Time/TimeInputs.js.map +1 -1
- package/lib/commonjs/Time/TimePicker.js +9 -2
- package/lib/commonjs/Time/TimePicker.js.map +1 -1
- package/lib/commonjs/Time/TimePickerModal.js +5 -1
- package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
- package/lib/module/Date/DatePickerInput.js +1 -0
- package/lib/module/Date/DatePickerInput.js.map +1 -1
- package/lib/module/Time/AnalogClock.js +7 -3
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/AnalogClockHours.js +4 -8
- package/lib/module/Time/AnalogClockHours.js.map +1 -1
- package/lib/module/Time/TimeInput.js +2 -1
- package/lib/module/Time/TimeInput.js.map +1 -1
- package/lib/module/Time/TimeInputs.js +4 -1
- package/lib/module/Time/TimeInputs.js.map +1 -1
- package/lib/module/Time/TimePicker.js +9 -2
- package/lib/module/Time/TimePicker.js.map +1 -1
- package/lib/module/Time/TimePickerModal.js +5 -1
- package/lib/module/Time/TimePickerModal.js.map +1 -1
- package/lib/typescript/Time/TimeInput.d.ts +1 -0
- package/lib/typescript/Time/TimeInputs.d.ts +2 -1
- package/lib/typescript/Time/TimePicker.d.ts +3 -1
- package/lib/typescript/Time/TimePickerModal.d.ts +3 -1
- package/package.json +1 -1
- package/src/Date/DatePickerInput.tsx +1 -0
- package/src/Time/AnalogClock.tsx +7 -6
- package/src/Time/AnalogClockHours.tsx +10 -6
- package/src/Time/TimeInput.tsx +3 -1
- package/src/Time/TimeInputs.tsx +4 -0
- package/src/Time/TimePicker.tsx +9 -1
- package/src/Time/TimePickerModal.tsx +6 -0
package/src/Time/AnalogClock.tsx
CHANGED
|
@@ -43,7 +43,7 @@ function AnalogClock({
|
|
|
43
43
|
const theme = useTheme()
|
|
44
44
|
const { mode } = React.useContext(DisplayModeContext)
|
|
45
45
|
// used to make pointer shorter if hours are selected and above 12
|
|
46
|
-
const shortPointer =
|
|
46
|
+
const shortPointer = hours >= 12 && is24Hour
|
|
47
47
|
const clockRef = React.useRef<View | null>(null)
|
|
48
48
|
// Hooks are nice, sometimes... :-)..
|
|
49
49
|
// We need the latest values, since the onPointerMove uses a closure to the function
|
|
@@ -74,17 +74,18 @@ function AnalogClock({
|
|
|
74
74
|
if (hours12AndPm || hours24AndPM) {
|
|
75
75
|
pickedHours += 12
|
|
76
76
|
}
|
|
77
|
-
if (modeRef.current === 'AM' && pickedHours === 12) {
|
|
77
|
+
if ((modeRef.current === 'AM' || hours24) && pickedHours === 12) {
|
|
78
78
|
pickedHours = 0
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
if (
|
|
82
|
-
(!hours24 && modeRef.current === 'AM' && pickedHours === 12) ||
|
|
83
|
-
pickedHours === 24
|
|
84
|
-
) {
|
|
81
|
+
if (!hours24 && modeRef.current === 'AM' && pickedHours === 12) {
|
|
85
82
|
pickedHours = 0
|
|
86
83
|
}
|
|
87
84
|
|
|
85
|
+
if (pickedHours === 24) {
|
|
86
|
+
pickedHours = 12
|
|
87
|
+
}
|
|
88
|
+
|
|
88
89
|
if (hoursRef.current !== pickedHours || final) {
|
|
89
90
|
onChangeRef.current({
|
|
90
91
|
hours: pickedHours,
|
|
@@ -3,7 +3,6 @@ import { View, StyleSheet } from 'react-native'
|
|
|
3
3
|
import { Text } from 'react-native-paper'
|
|
4
4
|
import { circleSize } from './timeUtils'
|
|
5
5
|
import { useTextColorOnPrimary } from '../utils'
|
|
6
|
-
import { DisplayModeContext } from './TimePicker'
|
|
7
6
|
|
|
8
7
|
function AnalogClockHours({
|
|
9
8
|
is24Hour,
|
|
@@ -12,7 +11,6 @@ function AnalogClockHours({
|
|
|
12
11
|
is24Hour: boolean
|
|
13
12
|
hours: number
|
|
14
13
|
}) {
|
|
15
|
-
const { mode } = React.useContext(DisplayModeContext)
|
|
16
14
|
const outerRange = getHourNumbers(false, circleSize, 12, 12)
|
|
17
15
|
const innerRange = getHourNumbers(true, circleSize, 12, 12)
|
|
18
16
|
const color = useTextColorOnPrimary()
|
|
@@ -34,11 +32,17 @@ function AnalogClockHours({
|
|
|
34
32
|
<View style={styles.outerHourInner}>
|
|
35
33
|
{/* Display 00 instead of 12 for AM hours */}
|
|
36
34
|
<Text
|
|
37
|
-
style={
|
|
35
|
+
style={
|
|
36
|
+
(!is24Hour && i + 1 === hours) ||
|
|
37
|
+
(hours === i + 1 && hours !== 12) ||
|
|
38
|
+
(i + 1 === 12 && hours === 0)
|
|
39
|
+
? { color }
|
|
40
|
+
: null
|
|
41
|
+
}
|
|
38
42
|
variant="bodyLarge"
|
|
39
43
|
selectable={false}
|
|
40
44
|
>
|
|
41
|
-
{
|
|
45
|
+
{is24Hour && i + 1 === 12 ? '00' : i + 1}
|
|
42
46
|
</Text>
|
|
43
47
|
</View>
|
|
44
48
|
</View>
|
|
@@ -60,13 +64,13 @@ function AnalogClockHours({
|
|
|
60
64
|
<Text
|
|
61
65
|
selectable={false}
|
|
62
66
|
style={[
|
|
63
|
-
i + 13 === hours || (i + 13 === 24 && hours ===
|
|
67
|
+
i + 13 === hours || (i + 13 === 24 && hours === 12)
|
|
64
68
|
? { color }
|
|
65
69
|
: null,
|
|
66
70
|
]}
|
|
67
71
|
variant="bodyLarge"
|
|
68
72
|
>
|
|
69
|
-
{i + 13 === 24 ? '
|
|
73
|
+
{i + 13 === 24 ? '12' : i + 13}
|
|
70
74
|
</Text>
|
|
71
75
|
</View>
|
|
72
76
|
</View>
|
package/src/Time/TimeInput.tsx
CHANGED
|
@@ -24,6 +24,7 @@ interface TimeInputProps
|
|
|
24
24
|
pressed: boolean
|
|
25
25
|
onChanged: (n: number) => any
|
|
26
26
|
inputType: PossibleInputTypes
|
|
27
|
+
inputFontSize?: number
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
function TimeInput(
|
|
@@ -34,6 +35,7 @@ function TimeInput(
|
|
|
34
35
|
onPress,
|
|
35
36
|
onChanged,
|
|
36
37
|
inputType,
|
|
38
|
+
inputFontSize = 57,
|
|
37
39
|
...rest
|
|
38
40
|
}: TimeInputProps,
|
|
39
41
|
ref: any
|
|
@@ -77,6 +79,7 @@ function TimeInput(
|
|
|
77
79
|
// eslint-disable-next-line react-native/no-inline-styles
|
|
78
80
|
{
|
|
79
81
|
color,
|
|
82
|
+
fontSize: inputFontSize,
|
|
80
83
|
backgroundColor,
|
|
81
84
|
borderRadius: theme.roundness * 2,
|
|
82
85
|
borderColor:
|
|
@@ -123,7 +126,6 @@ function TimeInput(
|
|
|
123
126
|
const styles = StyleSheet.create({
|
|
124
127
|
root: { position: 'relative', height: 80, width: 96 },
|
|
125
128
|
input: {
|
|
126
|
-
fontSize: 57,
|
|
127
129
|
textAlign: 'center',
|
|
128
130
|
textAlignVertical: 'center',
|
|
129
131
|
width: 96,
|
package/src/Time/TimeInputs.tsx
CHANGED
|
@@ -27,6 +27,7 @@ function TimeInputs({
|
|
|
27
27
|
inputType,
|
|
28
28
|
onChange,
|
|
29
29
|
is24Hour,
|
|
30
|
+
inputFontSize,
|
|
30
31
|
}: {
|
|
31
32
|
inputType: PossibleInputTypes
|
|
32
33
|
focused: PossibleClockTypes
|
|
@@ -39,6 +40,7 @@ function TimeInputs({
|
|
|
39
40
|
focused?: undefined | PossibleClockTypes
|
|
40
41
|
}) => any
|
|
41
42
|
is24Hour: boolean
|
|
43
|
+
inputFontSize?: number
|
|
42
44
|
}) {
|
|
43
45
|
const startInput = React.useRef<TextInputNative | null>(null)
|
|
44
46
|
const endInput = React.useRef<TextInputNative | null>(null)
|
|
@@ -78,6 +80,7 @@ function TimeInputs({
|
|
|
78
80
|
<View style={styles.column}>
|
|
79
81
|
<TimeInput
|
|
80
82
|
ref={startInput}
|
|
83
|
+
inputFontSize={inputFontSize}
|
|
81
84
|
placeholder={'00'}
|
|
82
85
|
value={toHourInputFormat(hours, is24Hour)}
|
|
83
86
|
clockType={clockTypes.hours}
|
|
@@ -145,6 +148,7 @@ function TimeInputs({
|
|
|
145
148
|
<View style={styles.column}>
|
|
146
149
|
<TimeInput
|
|
147
150
|
ref={endInput}
|
|
151
|
+
inputFontSize={inputFontSize}
|
|
148
152
|
placeholder={'00'}
|
|
149
153
|
value={minutes}
|
|
150
154
|
clockType={clockTypes.minutes}
|
package/src/Time/TimePicker.tsx
CHANGED
|
@@ -36,6 +36,8 @@ function TimePicker({
|
|
|
36
36
|
inputType,
|
|
37
37
|
onChange,
|
|
38
38
|
locale,
|
|
39
|
+
use24HourClock,
|
|
40
|
+
inputFontSize,
|
|
39
41
|
}: {
|
|
40
42
|
locale?: undefined | string
|
|
41
43
|
inputType: PossibleInputTypes
|
|
@@ -44,6 +46,8 @@ function TimePicker({
|
|
|
44
46
|
minutes: number
|
|
45
47
|
onFocusInput: (type: PossibleClockTypes) => any
|
|
46
48
|
onChange: onChangeFunc
|
|
49
|
+
use24HourClock?: boolean
|
|
50
|
+
inputFontSize?: number
|
|
47
51
|
}) {
|
|
48
52
|
const [displayMode, setDisplayMode] = React.useState<'AM' | 'PM' | undefined>(
|
|
49
53
|
undefined
|
|
@@ -53,6 +57,9 @@ function TimePicker({
|
|
|
53
57
|
|
|
54
58
|
// method to check whether we have 24 hours in clock or 12
|
|
55
59
|
const is24Hour = React.useMemo(() => {
|
|
60
|
+
if (use24HourClock !== undefined) {
|
|
61
|
+
return use24HourClock
|
|
62
|
+
}
|
|
56
63
|
const formatter = new Intl.DateTimeFormat(locale, {
|
|
57
64
|
hour: '2-digit',
|
|
58
65
|
minute: '2-digit',
|
|
@@ -60,7 +67,7 @@ function TimePicker({
|
|
|
60
67
|
})
|
|
61
68
|
const formatted = formatter.format(new Date(Date.UTC(2020, 1, 1, 23)))
|
|
62
69
|
return formatted.includes('23')
|
|
63
|
-
}, [locale])
|
|
70
|
+
}, [locale, use24HourClock])
|
|
64
71
|
|
|
65
72
|
// Initialize display Mode according the hours value
|
|
66
73
|
React.useEffect(() => {
|
|
@@ -104,6 +111,7 @@ function TimePicker({
|
|
|
104
111
|
>
|
|
105
112
|
<TimeInputs
|
|
106
113
|
inputType={inputType}
|
|
114
|
+
inputFontSize={inputFontSize}
|
|
107
115
|
hours={hours}
|
|
108
116
|
minutes={minutes}
|
|
109
117
|
is24Hour={is24Hour}
|
|
@@ -55,6 +55,8 @@ export function TimePickerModal({
|
|
|
55
55
|
locale,
|
|
56
56
|
keyboardIcon = 'keyboard-outline',
|
|
57
57
|
clockIcon = 'clock-outline',
|
|
58
|
+
use24HourClock,
|
|
59
|
+
inputFontSize,
|
|
58
60
|
}: {
|
|
59
61
|
locale?: undefined | string
|
|
60
62
|
label?: string
|
|
@@ -69,6 +71,8 @@ export function TimePickerModal({
|
|
|
69
71
|
animationType?: 'slide' | 'fade' | 'none'
|
|
70
72
|
keyboardIcon?: string
|
|
71
73
|
clockIcon?: string
|
|
74
|
+
use24HourClock?: boolean
|
|
75
|
+
inputFontSize?: number
|
|
72
76
|
}) {
|
|
73
77
|
const theme = useTheme()
|
|
74
78
|
|
|
@@ -188,6 +192,8 @@ export function TimePickerModal({
|
|
|
188
192
|
<TimePicker
|
|
189
193
|
locale={locale}
|
|
190
194
|
inputType={inputType}
|
|
195
|
+
use24HourClock={use24HourClock}
|
|
196
|
+
inputFontSize={inputFontSize}
|
|
191
197
|
focused={focused}
|
|
192
198
|
hours={localHours}
|
|
193
199
|
minutes={localMinutes}
|