react-native-molecules 0.5.0-beta.19 → 0.5.0-beta.20
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.
|
@@ -22,6 +22,10 @@ type Props = {
|
|
|
22
22
|
focused: PossibleClockTypes;
|
|
23
23
|
hours: number;
|
|
24
24
|
minutes: number;
|
|
25
|
+
hourLabel: string;
|
|
26
|
+
minuteLabel: string;
|
|
27
|
+
hourErrorText: string;
|
|
28
|
+
minuteErrorText: string;
|
|
25
29
|
onFocusInput: (type: PossibleClockTypes) => any;
|
|
26
30
|
onChange: (hoursMinutesAndFocused: {
|
|
27
31
|
hours: number;
|
|
@@ -34,6 +38,10 @@ type Props = {
|
|
|
34
38
|
function TimeInputs({
|
|
35
39
|
hours,
|
|
36
40
|
minutes,
|
|
41
|
+
hourLabel,
|
|
42
|
+
minuteLabel,
|
|
43
|
+
hourErrorText,
|
|
44
|
+
minuteErrorText,
|
|
37
45
|
onFocusInput,
|
|
38
46
|
focused,
|
|
39
47
|
inputType,
|
|
@@ -76,8 +84,6 @@ function TimeInputs({
|
|
|
76
84
|
|
|
77
85
|
const minutesRef = useLatest(minutes);
|
|
78
86
|
const isPm = hours >= 12;
|
|
79
|
-
const hourErrorText = is24Hour ? 'Hour must be 0-23' : 'Hour must be 1-12';
|
|
80
|
-
const minuteErrorText = 'Minute must be 0-59';
|
|
81
87
|
const onChangeHours = useCallback(
|
|
82
88
|
(newHours: number) => {
|
|
83
89
|
onChange({
|
|
@@ -205,7 +211,7 @@ function TimeInputs({
|
|
|
205
211
|
timePickerInputsStyles.supportingText,
|
|
206
212
|
hourError ? timePickerInputsStyles.supportingTextError : null,
|
|
207
213
|
]}>
|
|
208
|
-
{hourError ? hourErrorText :
|
|
214
|
+
{hourError ? hourErrorText : hourLabel}
|
|
209
215
|
</Text>
|
|
210
216
|
</View>
|
|
211
217
|
<View style={timePickerInputsStyles.hoursAndMinutesSeparator} />
|
|
@@ -215,7 +221,7 @@ function TimeInputs({
|
|
|
215
221
|
timePickerInputsStyles.supportingText,
|
|
216
222
|
minuteError ? timePickerInputsStyles.supportingTextError : null,
|
|
217
223
|
]}>
|
|
218
|
-
{minuteError ? minuteErrorText :
|
|
224
|
+
{minuteError ? minuteErrorText : minuteLabel}
|
|
219
225
|
</Text>
|
|
220
226
|
</View>
|
|
221
227
|
{!is24Hour && (
|
|
@@ -41,6 +41,10 @@ export type Props = {
|
|
|
41
41
|
onFocusInput?: (type: PossibleClockTypes) => any;
|
|
42
42
|
isLandscape?: boolean;
|
|
43
43
|
style?: StyleProp<ViewStyle>;
|
|
44
|
+
hourLabel?: string;
|
|
45
|
+
minuteLabel?: string;
|
|
46
|
+
hourErrorText?: string;
|
|
47
|
+
minuteErrorText?: string;
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
const toTimeString = (value: Date | null | undefined): string => {
|
|
@@ -68,6 +72,10 @@ function TimePicker({
|
|
|
68
72
|
inputType: inputTypeProp,
|
|
69
73
|
isLandscape = false,
|
|
70
74
|
style,
|
|
75
|
+
hourLabel = 'Hour',
|
|
76
|
+
minuteLabel = 'Minute',
|
|
77
|
+
hourErrorText,
|
|
78
|
+
minuteErrorText = 'Minute must be 0-59',
|
|
71
79
|
}: Props) {
|
|
72
80
|
const ctx = useOptionalDatePickerContext();
|
|
73
81
|
const tpCtx = useOptionalTimePickerContext();
|
|
@@ -153,6 +161,12 @@ function TimePicker({
|
|
|
153
161
|
onChange={onChange}
|
|
154
162
|
onFocusInput={onFocusInput}
|
|
155
163
|
focused={focused}
|
|
164
|
+
hourLabel={hourLabel}
|
|
165
|
+
minuteLabel={minuteLabel}
|
|
166
|
+
hourErrorText={
|
|
167
|
+
hourErrorText ?? (is24Hour ? 'Hour must be 0-23' : 'Hour must be 1-12')
|
|
168
|
+
}
|
|
169
|
+
minuteErrorText={minuteErrorText}
|
|
156
170
|
/>
|
|
157
171
|
<>
|
|
158
172
|
{inputType === inputTypes.picker ? (
|