react-native-paper-dates 0.4.5 → 0.6.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/README.md +80 -16
- package/lib/commonjs/Date/AnimatedCrossView.js +9 -8
- package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
- package/lib/commonjs/Date/AutoSizer.js +6 -5
- package/lib/commonjs/Date/AutoSizer.js.map +1 -1
- package/lib/commonjs/Date/Calendar.js +46 -39
- package/lib/commonjs/Date/Calendar.js.map +1 -1
- package/lib/commonjs/Date/CalendarEdit.js +35 -110
- package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
- package/lib/commonjs/Date/CalendarHeader.js +19 -12
- package/lib/commonjs/Date/CalendarHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInput.js +93 -20
- package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModal.js +4 -6
- package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContent.js +9 -5
- package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContentHeader.js +42 -34
- package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeader.js +14 -6
- package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +6 -5
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/commonjs/Date/DateRangeInput.js +23 -24
- package/lib/commonjs/Date/DateRangeInput.js.map +1 -1
- package/lib/commonjs/Date/Day.js +7 -3
- package/lib/commonjs/Date/Day.js.map +1 -1
- package/lib/commonjs/Date/DayName.js +6 -5
- package/lib/commonjs/Date/DayName.js.map +1 -1
- package/lib/commonjs/Date/DayNames.js +7 -6
- package/lib/commonjs/Date/DayNames.js.map +1 -1
- package/lib/commonjs/Date/DayRange.js +9 -8
- package/lib/commonjs/Date/DayRange.js.map +1 -1
- package/lib/commonjs/Date/Month.js +57 -49
- package/lib/commonjs/Date/Month.js.map +1 -1
- package/lib/commonjs/Date/Swiper.js +35 -29
- package/lib/commonjs/Date/Swiper.js.map +1 -1
- package/lib/commonjs/Date/Swiper.native.js +29 -23
- package/lib/commonjs/Date/Swiper.native.js.map +1 -1
- package/lib/commonjs/Date/SwiperUtils.js +7 -6
- package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
- package/lib/commonjs/Date/YearPicker.js +28 -20
- package/lib/commonjs/Date/YearPicker.js.map +1 -1
- package/lib/commonjs/Date/dateUtils.js +107 -38
- package/lib/commonjs/Date/dateUtils.js.map +1 -1
- package/lib/commonjs/Date/inputUtils.js +84 -0
- package/lib/commonjs/Date/inputUtils.js.map +1 -0
- package/lib/commonjs/TextInputMask.js +11 -10
- package/lib/commonjs/TextInputMask.js.map +1 -1
- package/lib/commonjs/Time/AmPmSwitcher.js +37 -19
- package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
- package/lib/commonjs/Time/AnalogClock.js +28 -26
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockHours.js +18 -12
- package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockMinutes.js +9 -8
- package/lib/commonjs/Time/AnalogClockMinutes.js.map +1 -1
- package/lib/commonjs/Time/AnimatedClockSwitcher.js +8 -7
- package/lib/commonjs/Time/AnimatedClockSwitcher.js.map +1 -1
- package/lib/commonjs/Time/TimeInput.js +16 -12
- package/lib/commonjs/Time/TimeInput.js.map +1 -1
- package/lib/commonjs/Time/TimeInputs.js +12 -11
- package/lib/commonjs/Time/TimeInputs.js.map +1 -1
- package/lib/commonjs/Time/TimePicker.js +39 -17
- package/lib/commonjs/Time/TimePicker.js.map +1 -1
- package/lib/commonjs/Time/TimePickerModal.js +19 -15
- package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
- package/lib/commonjs/Time/timeUtils.js +17 -9
- package/lib/commonjs/Time/timeUtils.js.map +1 -1
- package/lib/commonjs/index.js +66 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/translations/en.js +20 -0
- package/lib/commonjs/translations/en.js.map +1 -0
- package/lib/commonjs/translations/enGB.js +20 -0
- package/lib/commonjs/translations/enGB.js.map +1 -0
- package/lib/commonjs/translations/nl.js +20 -0
- package/lib/commonjs/translations/nl.js.map +1 -0
- package/lib/commonjs/translations/pl.js +20 -0
- package/lib/commonjs/translations/pl.js.map +1 -0
- package/lib/commonjs/translations/utils.js +31 -0
- package/lib/commonjs/translations/utils.js.map +1 -0
- package/lib/commonjs/utils.js +19 -9
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/Date/AnimatedCrossView.js +7 -6
- package/lib/module/Date/AnimatedCrossView.js.map +1 -1
- package/lib/module/Date/AutoSizer.js +4 -3
- package/lib/module/Date/AutoSizer.js.map +1 -1
- package/lib/module/Date/Calendar.js +46 -39
- package/lib/module/Date/Calendar.js.map +1 -1
- package/lib/module/Date/CalendarEdit.js +31 -103
- package/lib/module/Date/CalendarEdit.js.map +1 -1
- package/lib/module/Date/CalendarHeader.js +16 -9
- package/lib/module/Date/CalendarHeader.js.map +1 -1
- package/lib/module/Date/DatePickerInput.js +88 -18
- package/lib/module/Date/DatePickerInput.js.map +1 -1
- package/lib/module/Date/DatePickerModal.js +3 -5
- package/lib/module/Date/DatePickerModal.js.map +1 -1
- package/lib/module/Date/DatePickerModalContent.js +7 -3
- package/lib/module/Date/DatePickerModalContent.js.map +1 -1
- package/lib/module/Date/DatePickerModalContentHeader.js +37 -30
- package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeader.js +11 -4
- package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeaderBackground.js +4 -3
- package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/module/Date/DateRangeInput.js +22 -22
- package/lib/module/Date/DateRangeInput.js.map +1 -1
- package/lib/module/Date/Day.js +5 -1
- package/lib/module/Date/Day.js.map +1 -1
- package/lib/module/Date/DayName.js +4 -3
- package/lib/module/Date/DayName.js.map +1 -1
- package/lib/module/Date/DayNames.js +5 -4
- package/lib/module/Date/DayNames.js.map +1 -1
- package/lib/module/Date/DayRange.js +7 -6
- package/lib/module/Date/DayRange.js.map +1 -1
- package/lib/module/Date/Month.js +52 -45
- package/lib/module/Date/Month.js.map +1 -1
- package/lib/module/Date/Swiper.js +32 -26
- package/lib/module/Date/Swiper.js.map +1 -1
- package/lib/module/Date/Swiper.native.js +27 -21
- package/lib/module/Date/Swiper.native.js.map +1 -1
- package/lib/module/Date/SwiperUtils.js +5 -4
- package/lib/module/Date/SwiperUtils.js.map +1 -1
- package/lib/module/Date/YearPicker.js +26 -18
- package/lib/module/Date/YearPicker.js.map +1 -1
- package/lib/module/Date/dateUtils.js +79 -30
- package/lib/module/Date/dateUtils.js.map +1 -1
- package/lib/module/Date/inputUtils.js +70 -0
- package/lib/module/Date/inputUtils.js.map +1 -0
- package/lib/module/TextInputMask.js +9 -8
- package/lib/module/TextInputMask.js.map +1 -1
- package/lib/module/Time/AmPmSwitcher.js +35 -18
- package/lib/module/Time/AmPmSwitcher.js.map +1 -1
- package/lib/module/Time/AnalogClock.js +20 -17
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/AnalogClockHours.js +15 -10
- package/lib/module/Time/AnalogClockHours.js.map +1 -1
- package/lib/module/Time/AnalogClockMinutes.js +6 -5
- package/lib/module/Time/AnalogClockMinutes.js.map +1 -1
- package/lib/module/Time/AnimatedClockSwitcher.js +6 -5
- package/lib/module/Time/AnimatedClockSwitcher.js.map +1 -1
- package/lib/module/Time/TimeInput.js +14 -10
- package/lib/module/Time/TimeInput.js.map +1 -1
- package/lib/module/Time/TimeInputs.js +10 -9
- package/lib/module/Time/TimeInputs.js.map +1 -1
- package/lib/module/Time/TimePicker.js +34 -13
- package/lib/module/Time/TimePicker.js.map +1 -1
- package/lib/module/Time/TimePickerModal.js +17 -13
- package/lib/module/Time/TimePickerModal.js.map +1 -1
- package/lib/module/Time/timeUtils.js +8 -2
- package/lib/module/Time/timeUtils.js.map +1 -1
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/translations/en.js +13 -0
- package/lib/module/translations/en.js.map +1 -0
- package/lib/module/translations/enGB.js +13 -0
- package/lib/module/translations/enGB.js.map +1 -0
- package/lib/module/translations/nl.js +13 -0
- package/lib/module/translations/nl.js.map +1 -0
- package/lib/module/translations/pl.js +13 -0
- package/lib/module/translations/pl.js.map +1 -0
- package/lib/module/translations/utils.js +22 -0
- package/lib/module/translations/utils.js.map +1 -0
- package/lib/module/utils.js +11 -5
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/{src/Date → Date}/AnimatedCrossView.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/AutoSizer.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/Calendar.d.ts +5 -3
- package/lib/typescript/{src/Date → Date}/CalendarEdit.d.ts +4 -3
- package/lib/typescript/{src/Date → Date}/CalendarHeader.d.ts +1 -1
- package/lib/typescript/Date/DatePickerInput.d.ts +18 -0
- package/lib/typescript/{src/Date → Date}/DatePickerModal.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/DatePickerModalContent.d.ts +2 -0
- package/lib/typescript/{src/Date → Date}/DatePickerModalContentHeader.d.ts +4 -4
- package/lib/typescript/{src/Date → Date}/DatePickerModalHeader.d.ts +1 -0
- package/lib/typescript/{src/Date → Date}/DatePickerModalHeaderBackground.d.ts +0 -0
- package/lib/typescript/Date/DateRangeInput.d.ts +3 -0
- package/lib/typescript/{src/Date → Date}/Day.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/DayName.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/DayNames.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/DayRange.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/Month.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/Swiper.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/Swiper.native.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/SwiperUtils.d.ts +1 -1
- package/lib/typescript/{src/Date → Date}/Week.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/YearPicker.d.ts +0 -0
- package/lib/typescript/{src/Date → Date}/dateUtils.d.ts +15 -0
- package/lib/typescript/{src/Date → Date}/dateUtils.test.d.ts +0 -0
- package/lib/typescript/Date/inputUtils.d.ts +14 -0
- package/lib/typescript/TextInputMask.d.ts +11 -0
- package/lib/typescript/Time/AmPmSwitcher.d.ts +4 -0
- package/lib/typescript/{src/Time → Time}/AnalogClock.d.ts +1 -2
- package/lib/typescript/{src/Time → Time}/AnalogClockHours.d.ts +0 -0
- package/lib/typescript/{src/Time → Time}/AnalogClockMinutes.d.ts +0 -0
- package/lib/typescript/{src/Time → Time}/AnimatedClockSwitcher.d.ts +0 -0
- package/lib/typescript/{src/Time → Time}/TimeInput.d.ts +0 -0
- package/lib/typescript/{src/Time → Time}/TimeInputs.d.ts +1 -1
- package/lib/typescript/{src/Time → Time}/TimePicker.d.ts +4 -0
- package/lib/typescript/{src/Time → Time}/TimePickerModal.d.ts +1 -1
- package/lib/typescript/{src/Time → Time}/timeUtils.d.ts +1 -0
- package/lib/typescript/index.d.ts +13 -0
- package/lib/typescript/translations/en.d.ts +3 -0
- package/lib/typescript/translations/enGB.d.ts +3 -0
- package/lib/typescript/translations/nl.d.ts +3 -0
- package/lib/typescript/translations/pl.d.ts +3 -0
- package/lib/typescript/translations/utils.d.ts +13 -0
- package/lib/typescript/utils.d.ts +58 -0
- package/package.json +39 -31
- package/src/.DS_Store +0 -0
- package/src/Date/Calendar.tsx +14 -13
- package/src/Date/CalendarEdit.tsx +21 -120
- package/src/Date/CalendarHeader.tsx +15 -3
- package/src/Date/DatePickerInput.tsx +103 -25
- package/src/Date/DatePickerModal.tsx +3 -8
- package/src/Date/DatePickerModalContent.tsx +6 -0
- package/src/Date/DatePickerModalContentHeader.tsx +21 -12
- package/src/Date/DatePickerModalHeader.tsx +13 -2
- package/src/Date/DateRangeInput.tsx +26 -17
- package/src/Date/Day.tsx +4 -0
- package/src/Date/Month.tsx +18 -44
- package/src/Date/Swiper.tsx +1 -0
- package/src/Date/SwiperUtils.ts +1 -1
- package/src/Date/YearPicker.tsx +4 -1
- package/src/Date/dateUtils.tsx +71 -10
- package/src/Date/inputUtils.ts +94 -0
- package/src/TextInputMask.tsx +10 -3
- package/src/Time/AmPmSwitcher.tsx +20 -11
- package/src/Time/AnalogClock.tsx +10 -18
- package/src/Time/AnalogClockHours.tsx +15 -6
- package/src/Time/AnalogClockMinutes.tsx +5 -2
- package/src/Time/TimeInput.tsx +3 -0
- package/src/Time/TimeInputs.tsx +1 -5
- package/src/Time/TimePicker.tsx +46 -23
- package/src/Time/TimePickerModal.tsx +4 -1
- package/src/Time/timeUtils.ts +7 -1
- package/src/index.tsx +7 -0
- package/src/translations/en.ts +15 -0
- package/src/translations/enGB.ts +15 -0
- package/src/translations/nl.ts +15 -0
- package/src/translations/pl.ts +15 -0
- package/src/translations/utils.ts +42 -0
- package/src/utils.ts +13 -5
- package/lib/typescript/src/Date/DatePickerInput.d.ts +0 -1
- package/lib/typescript/src/Date/DateRangeInput.d.ts +0 -1
- package/lib/typescript/src/TextInputMask.d.ts +0 -3
- package/lib/typescript/src/Time/AmPmSwitcher.d.ts +0 -4
- package/lib/typescript/src/index.d.ts +0 -6
- package/lib/typescript/src/utils.d.ts +0 -7
package/src/Time/TimePicker.tsx
CHANGED
|
@@ -9,9 +9,15 @@ import {
|
|
|
9
9
|
toHourOutputFormat,
|
|
10
10
|
} from './timeUtils'
|
|
11
11
|
|
|
12
|
-
import AnalogClock
|
|
12
|
+
import AnalogClock from './AnalogClock'
|
|
13
|
+
import { circleSize } from './timeUtils'
|
|
13
14
|
import TimeInputs from './TimeInputs'
|
|
14
15
|
|
|
16
|
+
export const DisplayModeContext = React.createContext<{
|
|
17
|
+
mode: 'AM' | 'PM' | undefined
|
|
18
|
+
setMode: React.Dispatch<React.SetStateAction<'AM' | 'PM' | undefined>>
|
|
19
|
+
}>({ mode: 'AM', setMode: () => {} })
|
|
20
|
+
|
|
15
21
|
type onChangeFunc = ({
|
|
16
22
|
hours,
|
|
17
23
|
minutes,
|
|
@@ -39,6 +45,9 @@ function TimePicker({
|
|
|
39
45
|
onFocusInput: (type: PossibleClockTypes) => any
|
|
40
46
|
onChange: onChangeFunc
|
|
41
47
|
}) {
|
|
48
|
+
const [displayMode, setDisplayMode] = React.useState<'AM' | 'PM' | undefined>(
|
|
49
|
+
undefined
|
|
50
|
+
)
|
|
42
51
|
const dimensions = useWindowDimensions()
|
|
43
52
|
const isLandscape = dimensions.width > dimensions.height
|
|
44
53
|
|
|
@@ -53,6 +62,16 @@ function TimePicker({
|
|
|
53
62
|
return formatted.includes('23')
|
|
54
63
|
}, [locale])
|
|
55
64
|
|
|
65
|
+
// Initialize display Mode according the hours value
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
if (hours >= 12) {
|
|
68
|
+
setDisplayMode('PM')
|
|
69
|
+
} else {
|
|
70
|
+
setDisplayMode('AM')
|
|
71
|
+
}
|
|
72
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
|
+
}, [])
|
|
74
|
+
|
|
56
75
|
const onInnerChange = React.useCallback<onChangeFunc>(
|
|
57
76
|
(params) => {
|
|
58
77
|
params.hours = toHourOutputFormat(params.hours, hours, is24Hour)
|
|
@@ -62,28 +81,32 @@ function TimePicker({
|
|
|
62
81
|
)
|
|
63
82
|
|
|
64
83
|
return (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
<DisplayModeContext.Provider
|
|
85
|
+
value={{ mode: displayMode, setMode: setDisplayMode }}
|
|
86
|
+
>
|
|
87
|
+
<View style={isLandscape ? styles.rootLandscape : styles.rootPortrait}>
|
|
88
|
+
<TimeInputs
|
|
89
|
+
inputType={inputType}
|
|
90
|
+
hours={hours}
|
|
91
|
+
minutes={minutes}
|
|
92
|
+
is24Hour={is24Hour}
|
|
93
|
+
onChange={onChange}
|
|
94
|
+
onFocusInput={onFocusInput}
|
|
95
|
+
focused={focused}
|
|
96
|
+
/>
|
|
97
|
+
{inputType === inputTypes.picker ? (
|
|
98
|
+
<View style={styles.clockContainer}>
|
|
99
|
+
<AnalogClock
|
|
100
|
+
hours={toHourInputFormat(hours, is24Hour)}
|
|
101
|
+
minutes={minutes}
|
|
102
|
+
focused={focused}
|
|
103
|
+
is24Hour={is24Hour}
|
|
104
|
+
onChange={onInnerChange}
|
|
105
|
+
/>
|
|
106
|
+
</View>
|
|
107
|
+
) : null}
|
|
108
|
+
</View>
|
|
109
|
+
</DisplayModeContext.Provider>
|
|
87
110
|
)
|
|
88
111
|
}
|
|
89
112
|
|
|
@@ -48,7 +48,7 @@ export function TimePickerModal({
|
|
|
48
48
|
minutes?: number | undefined
|
|
49
49
|
visible: boolean | undefined
|
|
50
50
|
onDismiss: () => any
|
|
51
|
-
onConfirm: (
|
|
51
|
+
onConfirm: (hoursAndMinutes: { hours: number; minutes: number }) => any
|
|
52
52
|
animationType?: 'slide' | 'fade' | 'none'
|
|
53
53
|
}) {
|
|
54
54
|
const theme = useTheme()
|
|
@@ -155,6 +155,9 @@ export function TimePickerModal({
|
|
|
155
155
|
size={24}
|
|
156
156
|
style={styles.inputTypeToggle}
|
|
157
157
|
accessibilityLabel="toggle keyboard"
|
|
158
|
+
// RN types bug
|
|
159
|
+
hasTVPreferredFocus={undefined}
|
|
160
|
+
tvParallaxProperties={undefined}
|
|
158
161
|
/>
|
|
159
162
|
<View style={styles.fill} />
|
|
160
163
|
<Button onPress={onDismiss}>{cancelLabel}</Button>
|
package/src/Time/timeUtils.ts
CHANGED
|
@@ -2,6 +2,9 @@ import * as React from 'react'
|
|
|
2
2
|
import Color from 'color'
|
|
3
3
|
import { useTheme } from 'react-native-paper'
|
|
4
4
|
|
|
5
|
+
// 250? when bigger?
|
|
6
|
+
export const circleSize = 215
|
|
7
|
+
|
|
5
8
|
export type PossibleHourTypes = 'am' | 'pm'
|
|
6
9
|
export type HourTypeMap = {
|
|
7
10
|
[hourType in PossibleHourTypes]: PossibleHourTypes
|
|
@@ -196,6 +199,9 @@ export function useInputColors(highlighted: boolean) {
|
|
|
196
199
|
}
|
|
197
200
|
|
|
198
201
|
export function toHourInputFormat(hours: number, is24Hour: boolean): number {
|
|
202
|
+
if (hours === 24) {
|
|
203
|
+
return 0
|
|
204
|
+
}
|
|
199
205
|
if (is24Hour) {
|
|
200
206
|
return hours
|
|
201
207
|
}
|
|
@@ -213,7 +219,7 @@ export function toHourOutputFormat(
|
|
|
213
219
|
if (is24Hour) {
|
|
214
220
|
return newHours
|
|
215
221
|
}
|
|
216
|
-
if (previousHours > 12 && newHours
|
|
222
|
+
if (previousHours > 12 && newHours < 12) {
|
|
217
223
|
return newHours + 12
|
|
218
224
|
}
|
|
219
225
|
return newHours
|
package/src/index.tsx
CHANGED
|
@@ -4,3 +4,10 @@ export * from './Date/DatePickerModal'
|
|
|
4
4
|
export { default as DatePickerModalContent } from './Date/DatePickerModalContent'
|
|
5
5
|
export { default as TimePickerModal } from './Time/TimePickerModal'
|
|
6
6
|
export { default as TimePicker } from './Time/TimePicker'
|
|
7
|
+
export { default as DatePickerInput } from './Date/DatePickerInput'
|
|
8
|
+
export type { TranslationsType } from './translations/utils'
|
|
9
|
+
export { registerTranslation, getTranslation } from './translations/utils'
|
|
10
|
+
export { default as nl } from './translations/nl'
|
|
11
|
+
export { default as en } from './translations/en'
|
|
12
|
+
export { default as pl } from './translations/pl'
|
|
13
|
+
export { default as enGB } from './translations/enGB'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TranslationsType } from './utils'
|
|
2
|
+
|
|
3
|
+
const en: TranslationsType = {
|
|
4
|
+
save: 'Save',
|
|
5
|
+
selectSingle: 'Select date',
|
|
6
|
+
selectMultiple: 'Select dates',
|
|
7
|
+
selectRange: 'Select period',
|
|
8
|
+
notAccordingToDateFormat: (inputFormat: string) =>
|
|
9
|
+
`Date format must be ${inputFormat}`,
|
|
10
|
+
mustBeHigherThan: 'Must be later then',
|
|
11
|
+
mustBeLowerThan: 'Must be earlier then',
|
|
12
|
+
mustBeBetween: 'Must be between',
|
|
13
|
+
dateIsDisabled: 'Day is not allowed',
|
|
14
|
+
}
|
|
15
|
+
export default en
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TranslationsType } from './utils'
|
|
2
|
+
|
|
3
|
+
const enGB: TranslationsType = {
|
|
4
|
+
save: 'Save',
|
|
5
|
+
selectSingle: 'Select date',
|
|
6
|
+
selectMultiple: 'Select dates',
|
|
7
|
+
selectRange: 'Select period',
|
|
8
|
+
notAccordingToDateFormat: (inputFormat: string) =>
|
|
9
|
+
`Date format must be ${inputFormat}`,
|
|
10
|
+
mustBeHigherThan: 'Must be later then',
|
|
11
|
+
mustBeLowerThan: 'Must be earlier then',
|
|
12
|
+
mustBeBetween: 'Must be between',
|
|
13
|
+
dateIsDisabled: 'Day is not allowed',
|
|
14
|
+
}
|
|
15
|
+
export default enGB
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TranslationsType } from './utils'
|
|
2
|
+
|
|
3
|
+
const nl: TranslationsType = {
|
|
4
|
+
save: 'Opslaan',
|
|
5
|
+
selectSingle: 'Selecteer datum',
|
|
6
|
+
selectMultiple: 'Selecteer datums',
|
|
7
|
+
selectRange: 'Selecteer periode',
|
|
8
|
+
notAccordingToDateFormat: (inputFormat: string) =>
|
|
9
|
+
`Datumformaat moet ${inputFormat} zijn`,
|
|
10
|
+
mustBeHigherThan: 'Moet later dan',
|
|
11
|
+
mustBeLowerThan: 'Moet eerder dan',
|
|
12
|
+
mustBeBetween: 'Moet tussen',
|
|
13
|
+
dateIsDisabled: 'Deze dag mag niet',
|
|
14
|
+
}
|
|
15
|
+
export default nl
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TranslationsType } from './utils'
|
|
2
|
+
|
|
3
|
+
const pl: TranslationsType = {
|
|
4
|
+
save: 'Zapisz',
|
|
5
|
+
selectSingle: 'Wybierz datę',
|
|
6
|
+
selectMultiple: 'Wybierz daty',
|
|
7
|
+
selectRange: 'Wybierz zakres',
|
|
8
|
+
notAccordingToDateFormat: (inputFormat: string) =>
|
|
9
|
+
`Data musi mieć format ${inputFormat}`,
|
|
10
|
+
mustBeHigherThan: 'Nie wcześniej niż',
|
|
11
|
+
mustBeLowerThan: 'Nie później niż',
|
|
12
|
+
mustBeBetween: 'Pomiędzy',
|
|
13
|
+
dateIsDisabled: 'Niedozwolona data',
|
|
14
|
+
}
|
|
15
|
+
export default pl
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type TranslationsType = {
|
|
2
|
+
selectSingle: string
|
|
3
|
+
selectMultiple: string
|
|
4
|
+
selectRange: string
|
|
5
|
+
save: string
|
|
6
|
+
notAccordingToDateFormat: (inputFormat: string) => string
|
|
7
|
+
mustBeHigherThan: string
|
|
8
|
+
mustBeLowerThan: string
|
|
9
|
+
mustBeBetween: string
|
|
10
|
+
dateIsDisabled: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let translationsPerLocale: Record<string, TranslationsType> = {}
|
|
14
|
+
|
|
15
|
+
export function getTranslation(
|
|
16
|
+
locale: string | undefined,
|
|
17
|
+
key: keyof TranslationsType,
|
|
18
|
+
fallback?: any
|
|
19
|
+
) {
|
|
20
|
+
const l = locale || 'en'
|
|
21
|
+
const translationForLocale = translationsPerLocale[l]
|
|
22
|
+
if (!translationForLocale) {
|
|
23
|
+
console.warn(
|
|
24
|
+
`[react-native-paper-dates] ${locale} is not registered, key: ${key}`
|
|
25
|
+
)
|
|
26
|
+
return fallback || key
|
|
27
|
+
}
|
|
28
|
+
const translation = translationsPerLocale[l][key]
|
|
29
|
+
if (!translationForLocale) {
|
|
30
|
+
console.warn(
|
|
31
|
+
`[react-native-paper-dates] ${locale} is registered, but ${key} is missing`
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
return translation || fallback || key
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function registerTranslation(
|
|
38
|
+
locale: string,
|
|
39
|
+
translations: TranslationsType
|
|
40
|
+
) {
|
|
41
|
+
translationsPerLocale[locale] = translations
|
|
42
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -3,11 +3,9 @@ import { overlay, useTheme } from 'react-native-paper'
|
|
|
3
3
|
import Color from 'color'
|
|
4
4
|
|
|
5
5
|
export function useLatest<T>(value: T) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, [value])
|
|
10
|
-
return valueRef
|
|
6
|
+
const ref = React.useRef(value)
|
|
7
|
+
ref.current = value
|
|
8
|
+
return ref
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
export function useHeaderBackgroundColor() {
|
|
@@ -42,3 +40,13 @@ export function range(start: number, end: number) {
|
|
|
42
40
|
.fill(null)
|
|
43
41
|
.map((_, i) => start + i)
|
|
44
42
|
}
|
|
43
|
+
|
|
44
|
+
export function lightenBy(color: Color, ratio: number) {
|
|
45
|
+
const lightness = color.lightness()
|
|
46
|
+
return color.lightness(lightness + (100 - lightness) * ratio)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function darkenBy(color: Color, ratio: number) {
|
|
50
|
+
const lightness = color.lightness()
|
|
51
|
+
return color.lightness(lightness - lightness * ratio)
|
|
52
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function DatePickerInput(): JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function DateRangeInput(): JSX.Element;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { default as Calendar } from './Date/Calendar';
|
|
2
|
-
export { default as DatePickerModal } from './Date/DatePickerModal';
|
|
3
|
-
export * from './Date/DatePickerModal';
|
|
4
|
-
export { default as DatePickerModalContent } from './Date/DatePickerModalContent';
|
|
5
|
-
export { default as TimePickerModal } from './Time/TimePickerModal';
|
|
6
|
-
export { default as TimePicker } from './Time/TimePicker';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export declare function useLatest<T>(value: T): React.MutableRefObject<T>;
|
|
3
|
-
export declare function useHeaderBackgroundColor(): string;
|
|
4
|
-
export declare function useHeaderColorIsLight(): boolean;
|
|
5
|
-
export declare function useHeaderTextColor(): "#fff" | "#000";
|
|
6
|
-
export declare function useTextColorOnPrimary(): "#fff" | "#000";
|
|
7
|
-
export declare function range(start: number, end: number): number[];
|