@izonnet-web-solution/react-native-date-picker-kit 0.0.0-stage → 1.0.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/CHANGELOG.md +35 -0
- package/LICENSE +5 -0
- package/README.md +942 -2
- package/assets/screenshots/calendar-picker-blue.jpg +0 -0
- package/assets/screenshots/calendar-picker.jpg +0 -0
- package/assets/screenshots/datetime-picker-date.jpg +0 -0
- package/assets/screenshots/datetime-picker-time-blue.jpg +0 -0
- package/assets/screenshots/input-modal-picker.jpg +0 -0
- package/assets/screenshots/manual-entry-single.jpg +0 -0
- package/assets/screenshots/manual-entry-split.jpg +0 -0
- package/assets/screenshots/month-year-selector-modal.jpg +0 -0
- package/assets/screenshots/range-picker.jpg +0 -0
- package/assets/screenshots/time-12h-wheel.jpg +0 -0
- package/assets/screenshots/time-24h-military-blue.jpg +0 -0
- package/assets/screenshots/wheel-date-picker.jpg +0 -0
- package/lib/components/Calendar/Calendar.d.ts +35 -0
- package/lib/components/Calendar/Calendar.d.ts.map +1 -0
- package/lib/components/Calendar/Calendar.js +126 -0
- package/lib/components/Calendar/Calendar.js.map +1 -0
- package/lib/components/Calendar/CalendarGrid.d.ts +11 -0
- package/lib/components/Calendar/CalendarGrid.d.ts.map +1 -0
- package/lib/components/Calendar/CalendarGrid.js +22 -0
- package/lib/components/Calendar/CalendarGrid.js.map +1 -0
- package/lib/components/Calendar/CalendarHeader.d.ts +23 -0
- package/lib/components/Calendar/CalendarHeader.d.ts.map +1 -0
- package/lib/components/Calendar/CalendarHeader.js +62 -0
- package/lib/components/Calendar/CalendarHeader.js.map +1 -0
- package/lib/components/Calendar/DateCell.d.ts +11 -0
- package/lib/components/Calendar/DateCell.d.ts.map +1 -0
- package/lib/components/Calendar/DateCell.js +71 -0
- package/lib/components/Calendar/DateCell.js.map +1 -0
- package/lib/components/Calendar/MonthYearSelectorModal.d.ts +17 -0
- package/lib/components/Calendar/MonthYearSelectorModal.d.ts.map +1 -0
- package/lib/components/Calendar/MonthYearSelectorModal.js +253 -0
- package/lib/components/Calendar/MonthYearSelectorModal.js.map +1 -0
- package/lib/components/Calendar/WeekDays.d.ts +13 -0
- package/lib/components/Calendar/WeekDays.d.ts.map +1 -0
- package/lib/components/Calendar/WeekDays.js +34 -0
- package/lib/components/Calendar/WeekDays.js.map +1 -0
- package/lib/components/Calendar/index.d.ts +7 -0
- package/lib/components/Calendar/index.d.ts.map +1 -0
- package/lib/components/Calendar/index.js +23 -0
- package/lib/components/Calendar/index.js.map +1 -0
- package/lib/components/DatePicker.d.ts +4 -0
- package/lib/components/DatePicker.d.ts.map +1 -0
- package/lib/components/DatePicker.js +498 -0
- package/lib/components/DatePicker.js.map +1 -0
- package/lib/components/Input/CalendarPopup.d.ts +26 -0
- package/lib/components/Input/CalendarPopup.d.ts.map +1 -0
- package/lib/components/Input/CalendarPopup.js +60 -0
- package/lib/components/Input/CalendarPopup.js.map +1 -0
- package/lib/components/Input/DateInput.d.ts +29 -0
- package/lib/components/Input/DateInput.d.ts.map +1 -0
- package/lib/components/Input/DateInput.js +110 -0
- package/lib/components/Input/DateInput.js.map +1 -0
- package/lib/components/Input/index.d.ts +3 -0
- package/lib/components/Input/index.d.ts.map +1 -0
- package/lib/components/Input/index.js +19 -0
- package/lib/components/Input/index.js.map +1 -0
- package/lib/components/ManualDateInput/DateInputField.d.ts +19 -0
- package/lib/components/ManualDateInput/DateInputField.d.ts.map +1 -0
- package/lib/components/ManualDateInput/DateInputField.js +345 -0
- package/lib/components/ManualDateInput/DateInputField.js.map +1 -0
- package/lib/components/ManualDateInput/DateValidationMessage.d.ts +8 -0
- package/lib/components/ManualDateInput/DateValidationMessage.d.ts.map +1 -0
- package/lib/components/ManualDateInput/DateValidationMessage.js +45 -0
- package/lib/components/ManualDateInput/DateValidationMessage.js.map +1 -0
- package/lib/components/ManualDateInput/ManualDateInput.d.ts +19 -0
- package/lib/components/ManualDateInput/ManualDateInput.d.ts.map +1 -0
- package/lib/components/ManualDateInput/ManualDateInput.js +18 -0
- package/lib/components/ManualDateInput/ManualDateInput.js.map +1 -0
- package/lib/components/ManualDateInput/index.d.ts +4 -0
- package/lib/components/ManualDateInput/index.d.ts.map +1 -0
- package/lib/components/ManualDateInput/index.js +20 -0
- package/lib/components/ManualDateInput/index.js.map +1 -0
- package/lib/components/Range/RangeDateCell.d.ts +11 -0
- package/lib/components/Range/RangeDateCell.d.ts.map +1 -0
- package/lib/components/Range/RangeDateCell.js +107 -0
- package/lib/components/Range/RangeDateCell.js.map +1 -0
- package/lib/components/Range/RangePicker.d.ts +29 -0
- package/lib/components/Range/RangePicker.d.ts.map +1 -0
- package/lib/components/Range/RangePicker.js +261 -0
- package/lib/components/Range/RangePicker.js.map +1 -0
- package/lib/components/Range/index.d.ts +3 -0
- package/lib/components/Range/index.d.ts.map +1 -0
- package/lib/components/Range/index.js +19 -0
- package/lib/components/Range/index.js.map +1 -0
- package/lib/components/Time/ClockDial.d.ts +15 -0
- package/lib/components/Time/ClockDial.d.ts.map +1 -0
- package/lib/components/Time/ClockDial.js +347 -0
- package/lib/components/Time/ClockDial.js.map +1 -0
- package/lib/components/Time/DateTimePicker.d.ts +31 -0
- package/lib/components/Time/DateTimePicker.d.ts.map +1 -0
- package/lib/components/Time/DateTimePicker.js +197 -0
- package/lib/components/Time/DateTimePicker.js.map +1 -0
- package/lib/components/Time/TimePicker.d.ts +31 -0
- package/lib/components/Time/TimePicker.d.ts.map +1 -0
- package/lib/components/Time/TimePicker.js +550 -0
- package/lib/components/Time/TimePicker.js.map +1 -0
- package/lib/components/Time/WheelTimePicker.d.ts +27 -0
- package/lib/components/Time/WheelTimePicker.d.ts.map +1 -0
- package/lib/components/Time/WheelTimePicker.js +203 -0
- package/lib/components/Time/WheelTimePicker.js.map +1 -0
- package/lib/components/Time/index.d.ts +5 -0
- package/lib/components/Time/index.d.ts.map +1 -0
- package/lib/components/Time/index.js +21 -0
- package/lib/components/Time/index.js.map +1 -0
- package/lib/components/Wheel/WheelColumn.d.ts +17 -0
- package/lib/components/Wheel/WheelColumn.d.ts.map +1 -0
- package/lib/components/Wheel/WheelColumn.js +192 -0
- package/lib/components/Wheel/WheelColumn.js.map +1 -0
- package/lib/components/Wheel/WheelPicker.d.ts +26 -0
- package/lib/components/Wheel/WheelPicker.d.ts.map +1 -0
- package/lib/components/Wheel/WheelPicker.js +123 -0
- package/lib/components/Wheel/WheelPicker.js.map +1 -0
- package/lib/components/Wheel/index.d.ts +3 -0
- package/lib/components/Wheel/index.d.ts.map +1 -0
- package/lib/components/Wheel/index.js +19 -0
- package/lib/components/Wheel/index.js.map +1 -0
- package/lib/components/common/Button.d.ts +17 -0
- package/lib/components/common/Button.d.ts.map +1 -0
- package/lib/components/common/Button.js +77 -0
- package/lib/components/common/Button.js.map +1 -0
- package/lib/components/common/IconButton.d.ts +14 -0
- package/lib/components/common/IconButton.d.ts.map +1 -0
- package/lib/components/common/IconButton.js +150 -0
- package/lib/components/common/IconButton.js.map +1 -0
- package/lib/components/common/Modal.d.ts +13 -0
- package/lib/components/common/Modal.d.ts.map +1 -0
- package/lib/components/common/Modal.js +65 -0
- package/lib/components/common/Modal.js.map +1 -0
- package/lib/components/common/index.d.ts +4 -0
- package/lib/components/common/index.d.ts.map +1 -0
- package/lib/components/common/index.js +20 -0
- package/lib/components/common/index.js.map +1 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +25 -0
- package/lib/components/index.js.map +1 -0
- package/lib/hooks/index.d.ts +4 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/index.js +20 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useCalendar.d.ts +34 -0
- package/lib/hooks/useCalendar.d.ts.map +1 -0
- package/lib/hooks/useCalendar.js +93 -0
- package/lib/hooks/useCalendar.js.map +1 -0
- package/lib/hooks/useDatePicker.d.ts +28 -0
- package/lib/hooks/useDatePicker.d.ts.map +1 -0
- package/lib/hooks/useDatePicker.js +150 -0
- package/lib/hooks/useDatePicker.js.map +1 -0
- package/lib/hooks/useDateRange.d.ts +23 -0
- package/lib/hooks/useDateRange.d.ts.map +1 -0
- package/lib/hooks/useDateRange.js +82 -0
- package/lib/hooks/useDateRange.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +29 -0
- package/lib/index.js.map +1 -0
- package/lib/localization/en.d.ts +3 -0
- package/lib/localization/en.d.ts.map +1 -0
- package/lib/localization/en.js +80 -0
- package/lib/localization/en.js.map +1 -0
- package/lib/localization/gu.d.ts +3 -0
- package/lib/localization/gu.d.ts.map +1 -0
- package/lib/localization/gu.js +80 -0
- package/lib/localization/gu.js.map +1 -0
- package/lib/localization/hi.d.ts +3 -0
- package/lib/localization/hi.d.ts.map +1 -0
- package/lib/localization/hi.js +80 -0
- package/lib/localization/hi.js.map +1 -0
- package/lib/localization/index.d.ts +8 -0
- package/lib/localization/index.d.ts.map +1 -0
- package/lib/localization/index.js +32 -0
- package/lib/localization/index.js.map +1 -0
- package/lib/themes/dark.d.ts +3 -0
- package/lib/themes/dark.d.ts.map +1 -0
- package/lib/themes/dark.js +30 -0
- package/lib/themes/dark.js.map +1 -0
- package/lib/themes/index.d.ts +16 -0
- package/lib/themes/index.d.ts.map +1 -0
- package/lib/themes/index.js +56 -0
- package/lib/themes/index.js.map +1 -0
- package/lib/themes/light.d.ts +3 -0
- package/lib/themes/light.d.ts.map +1 -0
- package/lib/themes/light.js +30 -0
- package/lib/themes/light.js.map +1 -0
- package/lib/types/index.d.ts +344 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +3 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/calendarUtils.d.ts +27 -0
- package/lib/utils/calendarUtils.d.ts.map +1 -0
- package/lib/utils/calendarUtils.js +108 -0
- package/lib/utils/calendarUtils.js.map +1 -0
- package/lib/utils/dateFormatting.d.ts +29 -0
- package/lib/utils/dateFormatting.d.ts.map +1 -0
- package/lib/utils/dateFormatting.js +114 -0
- package/lib/utils/dateFormatting.js.map +1 -0
- package/lib/utils/dateParsing.d.ts +23 -0
- package/lib/utils/dateParsing.d.ts.map +1 -0
- package/lib/utils/dateParsing.js +289 -0
- package/lib/utils/dateParsing.js.map +1 -0
- package/lib/utils/dateUtils.d.ts +20 -0
- package/lib/utils/dateUtils.d.ts.map +1 -0
- package/lib/utils/dateUtils.js +115 -0
- package/lib/utils/dateUtils.js.map +1 -0
- package/lib/utils/dateValidation.d.ts +36 -0
- package/lib/utils/dateValidation.d.ts.map +1 -0
- package/lib/utils/dateValidation.js +196 -0
- package/lib/utils/dateValidation.js.map +1 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +23 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/timeUtils.d.ts +78 -0
- package/lib/utils/timeUtils.d.ts.map +1 -0
- package/lib/utils/timeUtils.js +335 -0
- package/lib/utils/timeUtils.js.map +1 -0
- package/package.json +92 -3
- package/src/components/Calendar/Calendar.tsx +314 -0
- package/src/components/Calendar/CalendarGrid.tsx +47 -0
- package/src/components/Calendar/CalendarHeader.tsx +176 -0
- package/src/components/Calendar/DateCell.tsx +118 -0
- package/src/components/Calendar/MonthYearSelectorModal.tsx +407 -0
- package/src/components/Calendar/WeekDays.tsx +49 -0
- package/src/components/Calendar/index.ts +6 -0
- package/src/components/DatePicker.tsx +834 -0
- package/src/components/Input/CalendarPopup.tsx +168 -0
- package/src/components/Input/DateInput.tsx +259 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/ManualDateInput/DateInputField.tsx +493 -0
- package/src/components/ManualDateInput/DateValidationMessage.tsx +65 -0
- package/src/components/ManualDateInput/ManualDateInput.tsx +66 -0
- package/src/components/ManualDateInput/index.ts +3 -0
- package/src/components/Range/RangeDateCell.tsx +174 -0
- package/src/components/Range/RangePicker.tsx +484 -0
- package/src/components/Range/index.ts +2 -0
- package/src/components/Time/ClockDial.tsx +450 -0
- package/src/components/Time/DateTimePicker.tsx +395 -0
- package/src/components/Time/TimePicker.tsx +899 -0
- package/src/components/Time/WheelTimePicker.tsx +356 -0
- package/src/components/Time/index.ts +4 -0
- package/src/components/Wheel/WheelColumn.tsx +300 -0
- package/src/components/Wheel/WheelPicker.tsx +265 -0
- package/src/components/Wheel/index.ts +2 -0
- package/src/components/common/Button.tsx +125 -0
- package/src/components/common/IconButton.tsx +237 -0
- package/src/components/common/Modal.tsx +137 -0
- package/src/components/common/index.ts +3 -0
- package/src/components/index.ts +8 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useCalendar.ts +153 -0
- package/src/hooks/useDatePicker.ts +216 -0
- package/src/hooks/useDateRange.ts +135 -0
- package/src/index.ts +17 -0
- package/src/localization/en.ts +78 -0
- package/src/localization/gu.ts +78 -0
- package/src/localization/hi.ts +78 -0
- package/src/localization/index.ts +31 -0
- package/src/themes/dark.ts +28 -0
- package/src/themes/index.ts +73 -0
- package/src/themes/light.ts +28 -0
- package/src/types/index.ts +452 -0
- package/src/utils/calendarUtils.ts +152 -0
- package/src/utils/dateFormatting.ts +125 -0
- package/src/utils/dateParsing.ts +335 -0
- package/src/utils/dateUtils.ts +117 -0
- package/src/utils/dateValidation.ts +276 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/timeUtils.ts +416 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import React, { useRef, useState, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
TextInput,
|
|
5
|
+
Text,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
TextStyle,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import type {
|
|
13
|
+
DateFormat,
|
|
14
|
+
DatePickerTheme,
|
|
15
|
+
DatePickerLocale,
|
|
16
|
+
} from '../../types';
|
|
17
|
+
import { getPlaceholderForFormat } from '../../utils/dateFormatting';
|
|
18
|
+
import { parseDateStrict } from '../../utils/dateParsing';
|
|
19
|
+
|
|
20
|
+
export interface DateInputFieldProps {
|
|
21
|
+
value: string;
|
|
22
|
+
onChangeText: (text: string) => void;
|
|
23
|
+
format?: DateFormat;
|
|
24
|
+
theme: DatePickerTheme;
|
|
25
|
+
locale: DatePickerLocale;
|
|
26
|
+
isError?: boolean;
|
|
27
|
+
type?: 'single' | 'split';
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
editable?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const DateInputField: React.FC<DateInputFieldProps> = ({
|
|
36
|
+
value,
|
|
37
|
+
onChangeText,
|
|
38
|
+
format = 'DD/MM/YYYY',
|
|
39
|
+
theme,
|
|
40
|
+
locale,
|
|
41
|
+
isError = false,
|
|
42
|
+
type = 'single',
|
|
43
|
+
style,
|
|
44
|
+
inputStyle,
|
|
45
|
+
placeholder,
|
|
46
|
+
label,
|
|
47
|
+
editable = true,
|
|
48
|
+
}) => {
|
|
49
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
50
|
+
const [activeSplitField, setActiveSplitField] = useState<'D' | 'M' | 'Y' | null>(null);
|
|
51
|
+
|
|
52
|
+
// Split inputs refs
|
|
53
|
+
const dayRef = useRef<TextInput>(null);
|
|
54
|
+
const monthRef = useRef<TextInput>(null);
|
|
55
|
+
const yearRef = useRef<TextInput>(null);
|
|
56
|
+
|
|
57
|
+
const defaultPlaceholder = placeholder || getPlaceholderForFormat(format);
|
|
58
|
+
const separator = format.includes('-') ? '-' : '/';
|
|
59
|
+
|
|
60
|
+
// Compute live validation feedback
|
|
61
|
+
const parseResult = useMemo(() => {
|
|
62
|
+
if (!value || !value.trim()) return null;
|
|
63
|
+
return parseDateStrict(value, format, locale);
|
|
64
|
+
}, [value, format, locale]);
|
|
65
|
+
|
|
66
|
+
const isValidDate = parseResult?.validation.isValid === true;
|
|
67
|
+
const hasError = isError || (Boolean(value && value.trim()) && !isValidDate);
|
|
68
|
+
|
|
69
|
+
const getBorderColor = () => {
|
|
70
|
+
if (hasError) return theme.errorColor;
|
|
71
|
+
if (isFocused || activeSplitField !== null) return theme.primaryColor;
|
|
72
|
+
return theme.borderColor;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// --- SPLIT MODE IMPLEMENTATION ---
|
|
76
|
+
if (type === 'split') {
|
|
77
|
+
const rawParts = value.split(separator);
|
|
78
|
+
const formatParts = format.split(separator);
|
|
79
|
+
|
|
80
|
+
// Determine ordering of Day ('D'), Month ('M'), Year ('Y') from format
|
|
81
|
+
const fieldOrder = (formatParts.length === 3 ? formatParts : ['DD', 'MM', 'YYYY']).map((p) => {
|
|
82
|
+
const u = p.trim().toUpperCase();
|
|
83
|
+
if (u.startsWith('Y')) return 'Y';
|
|
84
|
+
if (u.startsWith('M')) return 'M';
|
|
85
|
+
return 'D';
|
|
86
|
+
}) as ('D' | 'M' | 'Y')[];
|
|
87
|
+
|
|
88
|
+
let dayVal = '';
|
|
89
|
+
let monthVal = '';
|
|
90
|
+
let yearVal = '';
|
|
91
|
+
|
|
92
|
+
fieldOrder.forEach((fType, idx) => {
|
|
93
|
+
const v = rawParts[idx] || '';
|
|
94
|
+
if (fType === 'D') dayVal = v;
|
|
95
|
+
if (fType === 'M') monthVal = v;
|
|
96
|
+
if (fType === 'Y') yearVal = v;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const updateCombined = (newD: string, newM: string, newY: string) => {
|
|
100
|
+
const combined = fieldOrder.map((fType) => {
|
|
101
|
+
if (fType === 'D') return newD;
|
|
102
|
+
if (fType === 'M') return newM;
|
|
103
|
+
return newY;
|
|
104
|
+
});
|
|
105
|
+
onChangeText(combined.join(separator));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const handleDayChange = (d: string) => {
|
|
109
|
+
const clean = d.replace(/\D/g, '').slice(0, 2);
|
|
110
|
+
updateCombined(clean, monthVal, yearVal);
|
|
111
|
+
if (clean.length === 2) {
|
|
112
|
+
const nextIdx = fieldOrder.indexOf('D') + 1;
|
|
113
|
+
if (nextIdx < 3) {
|
|
114
|
+
if (fieldOrder[nextIdx] === 'M') monthRef.current?.focus();
|
|
115
|
+
else if (fieldOrder[nextIdx] === 'Y') yearRef.current?.focus();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const handleMonthChange = (m: string) => {
|
|
121
|
+
const clean = m.replace(/\D/g, '').slice(0, 2);
|
|
122
|
+
updateCombined(dayVal, clean, yearVal);
|
|
123
|
+
if (clean.length === 2) {
|
|
124
|
+
const nextIdx = fieldOrder.indexOf('M') + 1;
|
|
125
|
+
if (nextIdx < 3) {
|
|
126
|
+
if (fieldOrder[nextIdx] === 'D') dayRef.current?.focus();
|
|
127
|
+
else if (fieldOrder[nextIdx] === 'Y') yearRef.current?.focus();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const handleYearChange = (y: string) => {
|
|
133
|
+
const clean = y.replace(/\D/g, '').slice(0, 4);
|
|
134
|
+
updateCombined(dayVal, monthVal, clean);
|
|
135
|
+
if (clean.length === 4) {
|
|
136
|
+
const nextIdx = fieldOrder.indexOf('Y') + 1;
|
|
137
|
+
if (nextIdx < 3) {
|
|
138
|
+
if (fieldOrder[nextIdx] === 'D') dayRef.current?.focus();
|
|
139
|
+
else if (fieldOrder[nextIdx] === 'M') monthRef.current?.focus();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const renderSplitPod = (fType: 'D' | 'M' | 'Y', index: number) => {
|
|
145
|
+
const isActive = activeSplitField === fType;
|
|
146
|
+
const ref = fType === 'D' ? dayRef : (fType === 'M' ? monthRef : yearRef);
|
|
147
|
+
const val = fType === 'D' ? dayVal : (fType === 'M' ? monthVal : yearVal);
|
|
148
|
+
const onChangeHandler = fType === 'D' ? handleDayChange : (fType === 'M' ? handleMonthChange : handleYearChange);
|
|
149
|
+
const titleLabel = fType === 'D' ? (locale.dayLabel || 'DAY') : (fType === 'M' ? (locale.monthLabel || 'MONTH') : (locale.yearLabel || 'YEAR'));
|
|
150
|
+
const maxLen = fType === 'Y' ? 4 : 2;
|
|
151
|
+
const placeHolderStr = fType === 'Y' ? 'YYYY' : (fType === 'M' ? 'MM' : 'DD');
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<React.Fragment key={fType}>
|
|
155
|
+
{index > 0 && (
|
|
156
|
+
<View style={styles.separatorContainer}>
|
|
157
|
+
<Text style={[styles.separatorText, { color: theme.secondaryTextColor }]}>
|
|
158
|
+
{separator}
|
|
159
|
+
</Text>
|
|
160
|
+
</View>
|
|
161
|
+
)}
|
|
162
|
+
|
|
163
|
+
<TouchableOpacity
|
|
164
|
+
activeOpacity={0.9}
|
|
165
|
+
onPress={() => ref.current?.focus()}
|
|
166
|
+
style={[
|
|
167
|
+
styles.splitPodCard,
|
|
168
|
+
{
|
|
169
|
+
backgroundColor: isActive ? `${theme.primaryColor}0C` : theme.cardColor,
|
|
170
|
+
borderColor: isActive ? theme.primaryColor : (hasError ? theme.errorColor : theme.borderColor),
|
|
171
|
+
shadowColor: isActive ? theme.primaryColor : '#000',
|
|
172
|
+
shadowOpacity: isActive ? 0.18 : 0.04,
|
|
173
|
+
flex: fType === 'Y' ? 1.35 : 1,
|
|
174
|
+
},
|
|
175
|
+
]}
|
|
176
|
+
>
|
|
177
|
+
{/* Mini Segment Badge */}
|
|
178
|
+
<View
|
|
179
|
+
style={[
|
|
180
|
+
styles.splitPodBadge,
|
|
181
|
+
{
|
|
182
|
+
backgroundColor: isActive ? theme.primaryColor : `${theme.textColor}08`,
|
|
183
|
+
},
|
|
184
|
+
]}
|
|
185
|
+
>
|
|
186
|
+
<Text
|
|
187
|
+
style={[
|
|
188
|
+
styles.splitPodBadgeText,
|
|
189
|
+
{
|
|
190
|
+
color: isActive ? '#FFFFFF' : theme.secondaryTextColor,
|
|
191
|
+
},
|
|
192
|
+
]}
|
|
193
|
+
>
|
|
194
|
+
{titleLabel.toUpperCase()}
|
|
195
|
+
</Text>
|
|
196
|
+
</View>
|
|
197
|
+
|
|
198
|
+
{/* Large Prominent Digits Input */}
|
|
199
|
+
<TextInput
|
|
200
|
+
ref={ref}
|
|
201
|
+
value={val}
|
|
202
|
+
onChangeText={onChangeHandler}
|
|
203
|
+
onFocus={() => setActiveSplitField(fType)}
|
|
204
|
+
onBlur={() => setActiveSplitField(null)}
|
|
205
|
+
keyboardType="number-pad"
|
|
206
|
+
maxLength={maxLen}
|
|
207
|
+
placeholder={placeHolderStr}
|
|
208
|
+
placeholderTextColor={theme.disabledTextColor}
|
|
209
|
+
style={[
|
|
210
|
+
styles.splitPodInput,
|
|
211
|
+
{
|
|
212
|
+
color: isActive ? theme.primaryColor : theme.textColor,
|
|
213
|
+
},
|
|
214
|
+
inputStyle,
|
|
215
|
+
]}
|
|
216
|
+
editable={editable}
|
|
217
|
+
/>
|
|
218
|
+
</TouchableOpacity>
|
|
219
|
+
</React.Fragment>
|
|
220
|
+
);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<View style={[styles.container, style]}>
|
|
225
|
+
{/* Sleek Top Status & Label Bar */}
|
|
226
|
+
<View style={styles.topStatusRow}>
|
|
227
|
+
<View style={styles.topBadgeGroup}>
|
|
228
|
+
<View style={[styles.pillBadge, { backgroundColor: `${theme.primaryColor}14` }]}>
|
|
229
|
+
<Text style={[styles.pillBadgeText, { color: theme.primaryColor }]}>
|
|
230
|
+
📑 SPLIT PODS
|
|
231
|
+
</Text>
|
|
232
|
+
</View>
|
|
233
|
+
</View>
|
|
234
|
+
|
|
235
|
+
{value.length > 0 && (
|
|
236
|
+
<View
|
|
237
|
+
style={[
|
|
238
|
+
styles.statusIndicator,
|
|
239
|
+
{
|
|
240
|
+
backgroundColor: isValidDate ? '#10B98118' : '#EF444418',
|
|
241
|
+
borderColor: isValidDate ? '#10B98140' : '#EF444440',
|
|
242
|
+
},
|
|
243
|
+
]}
|
|
244
|
+
>
|
|
245
|
+
<Text
|
|
246
|
+
style={[
|
|
247
|
+
styles.statusIndicatorText,
|
|
248
|
+
{ color: isValidDate ? '#10B981' : '#EF4444' },
|
|
249
|
+
]}
|
|
250
|
+
>
|
|
251
|
+
{isValidDate ? '✓ Complete' : '⚠ Incomplete'}
|
|
252
|
+
</Text>
|
|
253
|
+
</View>
|
|
254
|
+
)}
|
|
255
|
+
</View>
|
|
256
|
+
|
|
257
|
+
{label && (
|
|
258
|
+
<Text style={[styles.fieldLabel, { color: theme.textColor }]}>
|
|
259
|
+
{label}
|
|
260
|
+
</Text>
|
|
261
|
+
)}
|
|
262
|
+
|
|
263
|
+
{/* The 3 Modern Split Pods */}
|
|
264
|
+
<View style={styles.splitRowContainer}>
|
|
265
|
+
{fieldOrder.map((fType, idx) => renderSplitPod(fType, idx))}
|
|
266
|
+
</View>
|
|
267
|
+
</View>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// --- SINGLE BOX MODE IMPLEMENTATION (UNIQUE MODERN HERO CARD) ---
|
|
272
|
+
return (
|
|
273
|
+
<View style={[styles.container, style]}>
|
|
274
|
+
{/* Sleek Top Header Badge Bar */}
|
|
275
|
+
<View style={styles.topStatusRow}>
|
|
276
|
+
<View style={styles.topBadgeGroup}>
|
|
277
|
+
<View style={[styles.pillBadge, { backgroundColor: `${theme.primaryColor}14` }]}>
|
|
278
|
+
<Text style={[styles.pillBadgeText, { color: theme.primaryColor }]}>
|
|
279
|
+
⌨️ SINGLE BOX
|
|
280
|
+
</Text>
|
|
281
|
+
</View>
|
|
282
|
+
</View>
|
|
283
|
+
|
|
284
|
+
{value.length > 0 && (
|
|
285
|
+
<View
|
|
286
|
+
style={[
|
|
287
|
+
styles.statusIndicator,
|
|
288
|
+
{
|
|
289
|
+
backgroundColor: isValidDate ? '#10B98118' : '#EF444418',
|
|
290
|
+
borderColor: isValidDate ? '#10B98140' : '#EF444440',
|
|
291
|
+
},
|
|
292
|
+
]}
|
|
293
|
+
>
|
|
294
|
+
<Text
|
|
295
|
+
style={[
|
|
296
|
+
styles.statusIndicatorText,
|
|
297
|
+
{ color: isValidDate ? '#10B981' : '#EF4444' },
|
|
298
|
+
]}
|
|
299
|
+
>
|
|
300
|
+
{isValidDate ? '✓ Valid Date' : '⚠ Invalid'}
|
|
301
|
+
</Text>
|
|
302
|
+
</View>
|
|
303
|
+
)}
|
|
304
|
+
</View>
|
|
305
|
+
|
|
306
|
+
{label && (
|
|
307
|
+
<Text style={[styles.fieldLabel, { color: theme.textColor }]}>
|
|
308
|
+
{label}
|
|
309
|
+
</Text>
|
|
310
|
+
)}
|
|
311
|
+
|
|
312
|
+
{/* Hero Interactive Input Frame */}
|
|
313
|
+
<View
|
|
314
|
+
style={[
|
|
315
|
+
styles.heroInputFrame,
|
|
316
|
+
{
|
|
317
|
+
backgroundColor: isFocused ? `${theme.primaryColor}06` : theme.cardColor,
|
|
318
|
+
borderColor: getBorderColor(),
|
|
319
|
+
shadowColor: isFocused ? theme.primaryColor : '#000',
|
|
320
|
+
shadowOpacity: isFocused ? 0.16 : 0.04,
|
|
321
|
+
},
|
|
322
|
+
]}
|
|
323
|
+
>
|
|
324
|
+
<View style={[styles.heroInputIconBadge, { backgroundColor: `${theme.primaryColor}12` }]}>
|
|
325
|
+
<Text style={styles.heroInputIcon}>📅</Text>
|
|
326
|
+
</View>
|
|
327
|
+
|
|
328
|
+
<TextInput
|
|
329
|
+
value={value}
|
|
330
|
+
onChangeText={onChangeText}
|
|
331
|
+
onFocus={() => setIsFocused(true)}
|
|
332
|
+
onBlur={() => setIsFocused(false)}
|
|
333
|
+
placeholder={defaultPlaceholder}
|
|
334
|
+
placeholderTextColor={theme.disabledTextColor}
|
|
335
|
+
keyboardType="numeric"
|
|
336
|
+
maxLength={10}
|
|
337
|
+
editable={editable}
|
|
338
|
+
style={[
|
|
339
|
+
styles.heroDigitsInput,
|
|
340
|
+
{
|
|
341
|
+
color: isFocused ? theme.primaryColor : theme.textColor,
|
|
342
|
+
},
|
|
343
|
+
inputStyle,
|
|
344
|
+
]}
|
|
345
|
+
accessibilityLabel={label || defaultPlaceholder}
|
|
346
|
+
/>
|
|
347
|
+
|
|
348
|
+
{value.length > 0 && editable && (
|
|
349
|
+
<TouchableOpacity
|
|
350
|
+
activeOpacity={0.7}
|
|
351
|
+
onPress={() => onChangeText('')}
|
|
352
|
+
style={[styles.heroClearBtn, { backgroundColor: `${theme.textColor}12` }]}
|
|
353
|
+
>
|
|
354
|
+
<Text style={[styles.heroClearText, { color: theme.secondaryTextColor }]}>✕</Text>
|
|
355
|
+
</TouchableOpacity>
|
|
356
|
+
)}
|
|
357
|
+
</View>
|
|
358
|
+
</View>
|
|
359
|
+
);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const styles = StyleSheet.create({
|
|
363
|
+
container: {
|
|
364
|
+
width: '100%',
|
|
365
|
+
marginVertical: 0,
|
|
366
|
+
},
|
|
367
|
+
topStatusRow: {
|
|
368
|
+
flexDirection: 'row',
|
|
369
|
+
justifyContent: 'space-between',
|
|
370
|
+
alignItems: 'center',
|
|
371
|
+
marginBottom: 6,
|
|
372
|
+
},
|
|
373
|
+
topBadgeGroup: {
|
|
374
|
+
flexDirection: 'row',
|
|
375
|
+
alignItems: 'center',
|
|
376
|
+
gap: 6,
|
|
377
|
+
},
|
|
378
|
+
pillBadge: {
|
|
379
|
+
paddingHorizontal: 8,
|
|
380
|
+
paddingVertical: 3,
|
|
381
|
+
borderRadius: 6,
|
|
382
|
+
},
|
|
383
|
+
pillBadgeText: {
|
|
384
|
+
fontSize: 10,
|
|
385
|
+
fontWeight: '800',
|
|
386
|
+
letterSpacing: 0.5,
|
|
387
|
+
},
|
|
388
|
+
statusIndicator: {
|
|
389
|
+
paddingHorizontal: 8,
|
|
390
|
+
paddingVertical: 2,
|
|
391
|
+
borderRadius: 6,
|
|
392
|
+
borderWidth: 1,
|
|
393
|
+
},
|
|
394
|
+
statusIndicatorText: {
|
|
395
|
+
fontSize: 10,
|
|
396
|
+
fontWeight: '700',
|
|
397
|
+
},
|
|
398
|
+
fieldLabel: {
|
|
399
|
+
fontSize: 12,
|
|
400
|
+
fontWeight: '700',
|
|
401
|
+
marginBottom: 6,
|
|
402
|
+
letterSpacing: -0.2,
|
|
403
|
+
},
|
|
404
|
+
heroInputFrame: {
|
|
405
|
+
flexDirection: 'row',
|
|
406
|
+
alignItems: 'center',
|
|
407
|
+
borderWidth: 1.5,
|
|
408
|
+
borderRadius: 14,
|
|
409
|
+
paddingHorizontal: 12,
|
|
410
|
+
height: 48,
|
|
411
|
+
shadowOffset: { width: 0, height: 2 },
|
|
412
|
+
shadowRadius: 4,
|
|
413
|
+
// elevation: 2,
|
|
414
|
+
},
|
|
415
|
+
heroInputIconBadge: {
|
|
416
|
+
width: 30,
|
|
417
|
+
height: 30,
|
|
418
|
+
borderRadius: 8,
|
|
419
|
+
justifyContent: 'center',
|
|
420
|
+
alignItems: 'center',
|
|
421
|
+
marginRight: 8,
|
|
422
|
+
},
|
|
423
|
+
heroInputIcon: {
|
|
424
|
+
fontSize: 15,
|
|
425
|
+
},
|
|
426
|
+
heroDigitsInput: {
|
|
427
|
+
flex: 1,
|
|
428
|
+
height: '100%',
|
|
429
|
+
padding: 0,
|
|
430
|
+
fontSize: 18,
|
|
431
|
+
fontWeight: '800',
|
|
432
|
+
letterSpacing: 2,
|
|
433
|
+
},
|
|
434
|
+
heroClearBtn: {
|
|
435
|
+
width: 24,
|
|
436
|
+
height: 24,
|
|
437
|
+
borderRadius: 12,
|
|
438
|
+
justifyContent: 'center',
|
|
439
|
+
alignItems: 'center',
|
|
440
|
+
marginLeft: 6,
|
|
441
|
+
},
|
|
442
|
+
heroClearText: {
|
|
443
|
+
fontSize: 11,
|
|
444
|
+
fontWeight: '800',
|
|
445
|
+
},
|
|
446
|
+
splitRowContainer: {
|
|
447
|
+
flexDirection: 'row',
|
|
448
|
+
alignItems: 'center',
|
|
449
|
+
justifyContent: 'space-between',
|
|
450
|
+
width: '100%',
|
|
451
|
+
},
|
|
452
|
+
splitPodCard: {
|
|
453
|
+
borderRadius: 12,
|
|
454
|
+
borderWidth: 1.5,
|
|
455
|
+
paddingVertical: 6,
|
|
456
|
+
paddingHorizontal: 6,
|
|
457
|
+
alignItems: 'center',
|
|
458
|
+
justifyContent: 'center',
|
|
459
|
+
shadowOffset: { width: 0, height: 2 },
|
|
460
|
+
shadowRadius: 4,
|
|
461
|
+
elevation: 2,
|
|
462
|
+
minHeight: 62,
|
|
463
|
+
},
|
|
464
|
+
splitPodBadge: {
|
|
465
|
+
paddingHorizontal: 6,
|
|
466
|
+
paddingVertical: 2,
|
|
467
|
+
borderRadius: 5,
|
|
468
|
+
marginBottom: 2,
|
|
469
|
+
},
|
|
470
|
+
splitPodBadgeText: {
|
|
471
|
+
fontSize: 9,
|
|
472
|
+
fontWeight: '800',
|
|
473
|
+
letterSpacing: 0.5,
|
|
474
|
+
},
|
|
475
|
+
splitPodInput: {
|
|
476
|
+
width: '100%',
|
|
477
|
+
textAlign: 'center',
|
|
478
|
+
fontSize: 20,
|
|
479
|
+
fontWeight: '800',
|
|
480
|
+
padding: 0,
|
|
481
|
+
letterSpacing: 1,
|
|
482
|
+
},
|
|
483
|
+
separatorContainer: {
|
|
484
|
+
paddingHorizontal: 3,
|
|
485
|
+
justifyContent: 'center',
|
|
486
|
+
alignItems: 'center',
|
|
487
|
+
},
|
|
488
|
+
separatorText: {
|
|
489
|
+
fontSize: 20,
|
|
490
|
+
fontWeight: '300',
|
|
491
|
+
opacity: 0.6,
|
|
492
|
+
},
|
|
493
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import type { ValidationResult, DatePickerTheme } from '../../types';
|
|
4
|
+
|
|
5
|
+
export interface DateValidationMessageProps {
|
|
6
|
+
validation: ValidationResult;
|
|
7
|
+
theme: DatePickerTheme;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const DateValidationMessage: React.FC<DateValidationMessageProps> = ({
|
|
11
|
+
validation,
|
|
12
|
+
theme,
|
|
13
|
+
}) => {
|
|
14
|
+
if (validation.isValid || !validation.error) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<View
|
|
20
|
+
style={[
|
|
21
|
+
styles.container,
|
|
22
|
+
{
|
|
23
|
+
backgroundColor: theme.errorBackgroundColor,
|
|
24
|
+
borderColor: theme.errorColor,
|
|
25
|
+
borderRadius: Math.max(theme.borderRadius - 4, 6),
|
|
26
|
+
},
|
|
27
|
+
]}
|
|
28
|
+
accessibilityRole="alert"
|
|
29
|
+
accessibilityLiveRegion="assertive"
|
|
30
|
+
>
|
|
31
|
+
<Text style={[styles.icon, { color: theme.errorColor }]}>⚠</Text>
|
|
32
|
+
<Text
|
|
33
|
+
style={[
|
|
34
|
+
styles.text,
|
|
35
|
+
{
|
|
36
|
+
color: theme.errorColor,
|
|
37
|
+
fontSize: theme.fontSize.small,
|
|
38
|
+
},
|
|
39
|
+
]}
|
|
40
|
+
>
|
|
41
|
+
{validation.error}
|
|
42
|
+
</Text>
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const styles = StyleSheet.create({
|
|
48
|
+
container: {
|
|
49
|
+
flexDirection: 'row',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
paddingHorizontal: 10,
|
|
52
|
+
paddingVertical: 6,
|
|
53
|
+
borderWidth: 1,
|
|
54
|
+
marginTop: 6,
|
|
55
|
+
marginBottom: 2,
|
|
56
|
+
},
|
|
57
|
+
icon: {
|
|
58
|
+
fontSize: 13,
|
|
59
|
+
marginRight: 6,
|
|
60
|
+
},
|
|
61
|
+
text: {
|
|
62
|
+
flex: 1,
|
|
63
|
+
fontWeight: '600',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, StyleSheet, StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
DateFormat,
|
|
5
|
+
DatePickerTheme,
|
|
6
|
+
DatePickerLocale,
|
|
7
|
+
ValidationResult,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
import { DateInputField } from './DateInputField';
|
|
10
|
+
import { DateValidationMessage } from './DateValidationMessage';
|
|
11
|
+
|
|
12
|
+
export interface ManualDateInputProps {
|
|
13
|
+
value: string;
|
|
14
|
+
onChangeText: (text: string) => void;
|
|
15
|
+
validation: ValidationResult;
|
|
16
|
+
format?: DateFormat;
|
|
17
|
+
theme: DatePickerTheme;
|
|
18
|
+
locale: DatePickerLocale;
|
|
19
|
+
type?: 'single' | 'split';
|
|
20
|
+
label?: string;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
editable?: boolean;
|
|
23
|
+
style?: StyleProp<ViewStyle>;
|
|
24
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ManualDateInput: React.FC<ManualDateInputProps> = ({
|
|
28
|
+
value,
|
|
29
|
+
onChangeText,
|
|
30
|
+
validation,
|
|
31
|
+
format = 'DD/MM/YYYY',
|
|
32
|
+
theme,
|
|
33
|
+
locale,
|
|
34
|
+
type = 'single',
|
|
35
|
+
label,
|
|
36
|
+
placeholder,
|
|
37
|
+
editable = true,
|
|
38
|
+
style,
|
|
39
|
+
inputStyle,
|
|
40
|
+
}) => {
|
|
41
|
+
return (
|
|
42
|
+
<View style={[styles.container, style]}>
|
|
43
|
+
<DateInputField
|
|
44
|
+
value={value}
|
|
45
|
+
onChangeText={onChangeText}
|
|
46
|
+
format={format}
|
|
47
|
+
theme={theme}
|
|
48
|
+
locale={locale}
|
|
49
|
+
isError={!validation.isValid}
|
|
50
|
+
type={type}
|
|
51
|
+
label={label}
|
|
52
|
+
placeholder={placeholder}
|
|
53
|
+
editable={editable}
|
|
54
|
+
inputStyle={inputStyle}
|
|
55
|
+
/>
|
|
56
|
+
<DateValidationMessage validation={validation} theme={theme} />
|
|
57
|
+
</View>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const styles = StyleSheet.create({
|
|
62
|
+
container: {
|
|
63
|
+
width: '100%',
|
|
64
|
+
paddingVertical: 2,
|
|
65
|
+
},
|
|
66
|
+
});
|