react-native-paper-dates 0.4.6 → 0.7.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 +79 -22
- 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 +32 -111
- package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
- package/lib/commonjs/Date/CalendarHeader.js +23 -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 +2 -2
- package/lib/commonjs/Date/DatePickerModalContent.js +7 -4
- package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContentHeader.js +43 -34
- package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeader.js +12 -5
- 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 +59 -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 +30 -20
- package/lib/commonjs/Date/YearPicker.js.map +1 -1
- package/lib/commonjs/Date/dateUtils.js +106 -37
- 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 +25 -15
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockHours.js +17 -11
- package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockMinutes.js +7 -6
- 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 +37 -15
- 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 +14 -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 +25 -0
- package/lib/commonjs/translations/en.js.map +1 -0
- package/lib/commonjs/translations/enGB.js +25 -0
- package/lib/commonjs/translations/enGB.js.map +1 -0
- package/lib/commonjs/translations/nl.js +25 -0
- package/lib/commonjs/translations/nl.js.map +1 -0
- package/lib/commonjs/translations/pl.js +25 -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 +28 -104
- package/lib/module/Date/CalendarEdit.js.map +1 -1
- package/lib/module/Date/CalendarHeader.js +19 -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/DatePickerModalContent.js +5 -2
- package/lib/module/Date/DatePickerModalContent.js.map +1 -1
- package/lib/module/Date/DatePickerModalContentHeader.js +38 -30
- package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeader.js +9 -3
- 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 +54 -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 +28 -18
- package/lib/module/Date/YearPicker.js.map +1 -1
- package/lib/module/Date/dateUtils.js +78 -29
- 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 +23 -14
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/AnalogClockHours.js +14 -9
- package/lib/module/Time/AnalogClockHours.js.map +1 -1
- package/lib/module/Time/AnalogClockMinutes.js +5 -4
- 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 +32 -12
- 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 +5 -1
- 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 +18 -0
- package/lib/module/translations/en.js.map +1 -0
- package/lib/module/translations/enGB.js +18 -0
- package/lib/module/translations/enGB.js.map +1 -0
- package/lib/module/translations/nl.js +18 -0
- package/lib/module/translations/nl.js.map +1 -0
- package/lib/module/translations/pl.js +18 -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 +3 -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 -1
- 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 -1
- 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 +0 -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 +18 -0
- package/lib/typescript/utils.d.ts +58 -0
- package/package.json +39 -38
- package/src/.DS_Store +0 -0
- package/src/Date/Calendar.tsx +14 -13
- package/src/Date/CalendarEdit.tsx +17 -121
- package/src/Date/CalendarHeader.tsx +18 -3
- package/src/Date/DatePickerInput.tsx +103 -25
- package/src/Date/DatePickerModalContent.tsx +5 -1
- package/src/Date/DatePickerModalContentHeader.tsx +26 -12
- package/src/Date/DatePickerModalHeader.tsx +8 -1
- package/src/Date/DateRangeInput.tsx +26 -17
- package/src/Date/Day.tsx +4 -0
- package/src/Date/Month.tsx +20 -44
- package/src/Date/Swiper.tsx +1 -0
- package/src/Date/SwiperUtils.ts +1 -1
- package/src/Date/YearPicker.tsx +6 -1
- package/src/Date/dateUtils.tsx +70 -9
- 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 +12 -14
- package/src/Time/AnalogClockHours.tsx +14 -5
- package/src/Time/AnalogClockMinutes.tsx +4 -1
- package/src/Time/TimeInput.tsx +3 -0
- package/src/Time/TimeInputs.tsx +1 -5
- package/src/Time/TimePicker.tsx +44 -22
- package/src/Time/TimePickerModal.tsx +4 -1
- package/src/Time/timeUtils.ts +4 -1
- package/src/index.tsx +7 -0
- package/src/translations/en.ts +20 -0
- package/src/translations/enGB.ts +20 -0
- package/src/translations/nl.ts +20 -0
- package/src/translations/pl.ts +21 -0
- package/src/translations/utils.ts +47 -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
|
@@ -13,6 +13,11 @@ import AnalogClock from './AnalogClock'
|
|
|
13
13
|
import { circleSize } from './timeUtils'
|
|
14
14
|
import TimeInputs from './TimeInputs'
|
|
15
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
|
+
|
|
16
21
|
type onChangeFunc = ({
|
|
17
22
|
hours,
|
|
18
23
|
minutes,
|
|
@@ -40,6 +45,9 @@ function TimePicker({
|
|
|
40
45
|
onFocusInput: (type: PossibleClockTypes) => any
|
|
41
46
|
onChange: onChangeFunc
|
|
42
47
|
}) {
|
|
48
|
+
const [displayMode, setDisplayMode] = React.useState<'AM' | 'PM' | undefined>(
|
|
49
|
+
undefined
|
|
50
|
+
)
|
|
43
51
|
const dimensions = useWindowDimensions()
|
|
44
52
|
const isLandscape = dimensions.width > dimensions.height
|
|
45
53
|
|
|
@@ -54,6 +62,16 @@ function TimePicker({
|
|
|
54
62
|
return formatted.includes('23')
|
|
55
63
|
}, [locale])
|
|
56
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
|
+
|
|
57
75
|
const onInnerChange = React.useCallback<onChangeFunc>(
|
|
58
76
|
(params) => {
|
|
59
77
|
params.hours = toHourOutputFormat(params.hours, hours, is24Hour)
|
|
@@ -63,28 +81,32 @@ function TimePicker({
|
|
|
63
81
|
)
|
|
64
82
|
|
|
65
83
|
return (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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>
|
|
88
110
|
)
|
|
89
111
|
}
|
|
90
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
|
@@ -199,6 +199,9 @@ export function useInputColors(highlighted: boolean) {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
export function toHourInputFormat(hours: number, is24Hour: boolean): number {
|
|
202
|
+
if (hours === 24) {
|
|
203
|
+
return 0
|
|
204
|
+
}
|
|
202
205
|
if (is24Hour) {
|
|
203
206
|
return hours
|
|
204
207
|
}
|
|
@@ -216,7 +219,7 @@ export function toHourOutputFormat(
|
|
|
216
219
|
if (is24Hour) {
|
|
217
220
|
return newHours
|
|
218
221
|
}
|
|
219
|
-
if (previousHours > 12 && newHours
|
|
222
|
+
if (previousHours > 12 && newHours < 12) {
|
|
220
223
|
return newHours + 12
|
|
221
224
|
}
|
|
222
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,20 @@
|
|
|
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
|
+
previous: 'Previous',
|
|
15
|
+
next: 'Next',
|
|
16
|
+
typeInDate: 'Type in date',
|
|
17
|
+
pickDateFromCalendar: 'Pick date from calendar',
|
|
18
|
+
close: 'Close',
|
|
19
|
+
}
|
|
20
|
+
export default en
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
previous: 'Previous',
|
|
15
|
+
next: 'Next',
|
|
16
|
+
typeInDate: 'Type in date',
|
|
17
|
+
pickDateFromCalendar: 'Pick date from calendar',
|
|
18
|
+
close: 'Close',
|
|
19
|
+
}
|
|
20
|
+
export default enGB
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
previous: 'Vorige',
|
|
15
|
+
next: 'Volgende',
|
|
16
|
+
typeInDate: 'Typ datum',
|
|
17
|
+
pickDateFromCalendar: 'Kies datum van kalender',
|
|
18
|
+
close: 'Sluit',
|
|
19
|
+
}
|
|
20
|
+
export default nl
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
previous: 'Poprzedni',
|
|
16
|
+
next: 'Dalej',
|
|
17
|
+
typeInDate: 'Wpisz datę',
|
|
18
|
+
pickDateFromCalendar: 'Wybierz datę z kalendarza',
|
|
19
|
+
close: 'Zamknij',
|
|
20
|
+
}
|
|
21
|
+
export default pl
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
previous: string
|
|
12
|
+
next: string
|
|
13
|
+
typeInDate: string
|
|
14
|
+
pickDateFromCalendar: string
|
|
15
|
+
close: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let translationsPerLocale: Record<string, TranslationsType> = {}
|
|
19
|
+
|
|
20
|
+
export function getTranslation(
|
|
21
|
+
locale: string | undefined,
|
|
22
|
+
key: keyof TranslationsType,
|
|
23
|
+
fallback?: any
|
|
24
|
+
) {
|
|
25
|
+
const l = locale || 'en'
|
|
26
|
+
const translationForLocale = translationsPerLocale[l]
|
|
27
|
+
if (!translationForLocale) {
|
|
28
|
+
console.warn(
|
|
29
|
+
`[react-native-paper-dates] ${locale} is not registered, key: ${key}`
|
|
30
|
+
)
|
|
31
|
+
return fallback || key
|
|
32
|
+
}
|
|
33
|
+
const translation = translationsPerLocale[l][key]
|
|
34
|
+
if (!translationForLocale) {
|
|
35
|
+
console.warn(
|
|
36
|
+
`[react-native-paper-dates] ${locale} is registered, but ${key} is missing`
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
return translation || fallback || key
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function registerTranslation(
|
|
43
|
+
locale: string,
|
|
44
|
+
translations: TranslationsType
|
|
45
|
+
) {
|
|
46
|
+
translationsPerLocale[locale] = translations
|
|
47
|
+
}
|
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[];
|