@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,395 @@
|
|
|
1
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
StyleProp,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import type {
|
|
11
|
+
DatePickerTheme,
|
|
12
|
+
DatePickerLocale,
|
|
13
|
+
DateFormat,
|
|
14
|
+
DisabledDateCheck,
|
|
15
|
+
TimePickerLayout,
|
|
16
|
+
} from '../../types';
|
|
17
|
+
import { setTimeOnDate } from '../../utils/timeUtils';
|
|
18
|
+
import { validateDate } from '../../utils/dateValidation';
|
|
19
|
+
import { Calendar } from '../Calendar/Calendar';
|
|
20
|
+
import { TimePicker } from './TimePicker';
|
|
21
|
+
import { Button } from '../common/Button';
|
|
22
|
+
|
|
23
|
+
export interface DateTimePickerComponentProps {
|
|
24
|
+
value?: Date | null;
|
|
25
|
+
defaultValue?: Date | null;
|
|
26
|
+
onChange?: (date: Date | null) => void;
|
|
27
|
+
format?: DateFormat;
|
|
28
|
+
is24Hour?: boolean;
|
|
29
|
+
minuteInterval?: number;
|
|
30
|
+
minimumTime?: string | Date;
|
|
31
|
+
maximumTime?: string | Date;
|
|
32
|
+
minimumDate?: Date;
|
|
33
|
+
maximumDate?: Date;
|
|
34
|
+
disabledDates?: (Date | string)[] | DisabledDateCheck;
|
|
35
|
+
disabledWeekdays?: number[];
|
|
36
|
+
firstDayOfWeek?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
37
|
+
showSeconds?: boolean;
|
|
38
|
+
timePickerLayout?: TimePickerLayout;
|
|
39
|
+
allowManualEntry?: boolean;
|
|
40
|
+
theme: DatePickerTheme;
|
|
41
|
+
locale: DatePickerLocale;
|
|
42
|
+
initialTab?: 'date' | 'time';
|
|
43
|
+
showActionButtons?: boolean;
|
|
44
|
+
onConfirm?: (date: Date | null) => void;
|
|
45
|
+
onCancel?: () => void;
|
|
46
|
+
onClear?: () => void;
|
|
47
|
+
style?: StyleProp<ViewStyle>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const DateTimePicker: React.FC<DateTimePickerComponentProps> = ({
|
|
51
|
+
value: controlledValue,
|
|
52
|
+
defaultValue = null,
|
|
53
|
+
onChange,
|
|
54
|
+
format,
|
|
55
|
+
is24Hour = false,
|
|
56
|
+
minuteInterval = 1,
|
|
57
|
+
minimumTime,
|
|
58
|
+
maximumTime,
|
|
59
|
+
minimumDate,
|
|
60
|
+
maximumDate,
|
|
61
|
+
disabledDates,
|
|
62
|
+
disabledWeekdays,
|
|
63
|
+
firstDayOfWeek = 0,
|
|
64
|
+
showSeconds = false,
|
|
65
|
+
timePickerLayout = 'wheel',
|
|
66
|
+
allowManualEntry = false,
|
|
67
|
+
theme,
|
|
68
|
+
locale,
|
|
69
|
+
initialTab = 'date',
|
|
70
|
+
showActionButtons = true,
|
|
71
|
+
onConfirm,
|
|
72
|
+
onCancel,
|
|
73
|
+
onClear,
|
|
74
|
+
style,
|
|
75
|
+
}) => {
|
|
76
|
+
const [activeTab, setActiveTab] = useState<'date' | 'time'>(initialTab);
|
|
77
|
+
const [currentDate, setCurrentDate] = useState<Date>(
|
|
78
|
+
controlledValue || defaultValue || new Date()
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const displayFormat =
|
|
82
|
+
format || (is24Hour ? 'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY hh:mm A');
|
|
83
|
+
|
|
84
|
+
// Handle Date Selection from Calendar
|
|
85
|
+
const handleDateSelect = useCallback(
|
|
86
|
+
(newDate: Date | null) => {
|
|
87
|
+
if (!newDate) {
|
|
88
|
+
onChange?.(null);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Preserve existing hours and minutes
|
|
92
|
+
const combined = setTimeOnDate(
|
|
93
|
+
newDate,
|
|
94
|
+
currentDate.getHours(),
|
|
95
|
+
currentDate.getMinutes(),
|
|
96
|
+
currentDate.getSeconds()
|
|
97
|
+
);
|
|
98
|
+
setCurrentDate(combined);
|
|
99
|
+
onChange?.(combined);
|
|
100
|
+
},
|
|
101
|
+
[currentDate, onChange]
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Handle Time Selection from TimePicker
|
|
105
|
+
const handleTimeSelect = useCallback(
|
|
106
|
+
(newDateWithTime: Date | null) => {
|
|
107
|
+
if (!newDateWithTime) {
|
|
108
|
+
onChange?.(null);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
setCurrentDate(newDateWithTime);
|
|
112
|
+
onChange?.(newDateWithTime);
|
|
113
|
+
},
|
|
114
|
+
[onChange]
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// Global validation check
|
|
118
|
+
const isValid = useMemo(() => {
|
|
119
|
+
const val = validateDate(currentDate, {
|
|
120
|
+
minimumDate,
|
|
121
|
+
maximumDate,
|
|
122
|
+
disabledDates,
|
|
123
|
+
disabledWeekdays,
|
|
124
|
+
minimumTime,
|
|
125
|
+
maximumTime,
|
|
126
|
+
is24Hour,
|
|
127
|
+
validateTimeComponent: true,
|
|
128
|
+
locale,
|
|
129
|
+
});
|
|
130
|
+
return val.isValid;
|
|
131
|
+
}, [
|
|
132
|
+
currentDate,
|
|
133
|
+
minimumDate,
|
|
134
|
+
maximumDate,
|
|
135
|
+
disabledDates,
|
|
136
|
+
disabledWeekdays,
|
|
137
|
+
minimumTime,
|
|
138
|
+
maximumTime,
|
|
139
|
+
is24Hour,
|
|
140
|
+
locale,
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<View
|
|
145
|
+
style={[
|
|
146
|
+
styles.container,
|
|
147
|
+
{
|
|
148
|
+
backgroundColor: theme.surfaceColor,
|
|
149
|
+
borderRadius: 20,
|
|
150
|
+
borderColor: theme.borderColor,
|
|
151
|
+
},
|
|
152
|
+
style,
|
|
153
|
+
]}
|
|
154
|
+
>
|
|
155
|
+
{/* Segmented Tab Switcher: [ 📅 Date ] [ ⏰ Time ] */}
|
|
156
|
+
<View
|
|
157
|
+
style={[
|
|
158
|
+
styles.tabBar,
|
|
159
|
+
{
|
|
160
|
+
backgroundColor: `${theme.textColor}0A`,
|
|
161
|
+
borderColor: theme.borderColor,
|
|
162
|
+
},
|
|
163
|
+
]}
|
|
164
|
+
>
|
|
165
|
+
<TouchableOpacity
|
|
166
|
+
activeOpacity={0.8}
|
|
167
|
+
onPress={() => setActiveTab('date')}
|
|
168
|
+
style={[
|
|
169
|
+
styles.tabItem,
|
|
170
|
+
activeTab === 'date' && {
|
|
171
|
+
backgroundColor: theme.cardColor,
|
|
172
|
+
shadowColor: '#000',
|
|
173
|
+
shadowOffset: { width: 0, height: 1 },
|
|
174
|
+
shadowOpacity: 0.1,
|
|
175
|
+
shadowRadius: 3,
|
|
176
|
+
elevation: 2,
|
|
177
|
+
},
|
|
178
|
+
]}
|
|
179
|
+
>
|
|
180
|
+
<Text
|
|
181
|
+
style={[
|
|
182
|
+
styles.tabText,
|
|
183
|
+
{
|
|
184
|
+
color: activeTab === 'date' ? theme.primaryColor : theme.secondaryTextColor,
|
|
185
|
+
fontWeight: activeTab === 'date' ? '800' : '600',
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
>
|
|
189
|
+
📅 {locale.selectDate || 'Calendar Date'}
|
|
190
|
+
</Text>
|
|
191
|
+
</TouchableOpacity>
|
|
192
|
+
|
|
193
|
+
<TouchableOpacity
|
|
194
|
+
activeOpacity={0.8}
|
|
195
|
+
onPress={() => setActiveTab('time')}
|
|
196
|
+
style={[
|
|
197
|
+
styles.tabItem,
|
|
198
|
+
activeTab === 'time' && {
|
|
199
|
+
backgroundColor: theme.cardColor,
|
|
200
|
+
shadowColor: '#000',
|
|
201
|
+
shadowOffset: { width: 0, height: 1 },
|
|
202
|
+
shadowOpacity: 0.1,
|
|
203
|
+
shadowRadius: 3,
|
|
204
|
+
elevation: 2,
|
|
205
|
+
},
|
|
206
|
+
]}
|
|
207
|
+
>
|
|
208
|
+
<Text
|
|
209
|
+
style={[
|
|
210
|
+
styles.tabText,
|
|
211
|
+
{
|
|
212
|
+
color: activeTab === 'time' ? theme.primaryColor : theme.secondaryTextColor,
|
|
213
|
+
fontWeight: activeTab === 'time' ? '800' : '600',
|
|
214
|
+
},
|
|
215
|
+
]}
|
|
216
|
+
>
|
|
217
|
+
⏰ {locale.timeLabel || 'Clock Time'}
|
|
218
|
+
</Text>
|
|
219
|
+
</TouchableOpacity>
|
|
220
|
+
</View>
|
|
221
|
+
|
|
222
|
+
{/* Tab 1: Date (Calendar) */}
|
|
223
|
+
{activeTab === 'date' && (
|
|
224
|
+
<Calendar
|
|
225
|
+
selectedDate={currentDate}
|
|
226
|
+
onSelectDate={handleDateSelect}
|
|
227
|
+
format={displayFormat}
|
|
228
|
+
theme={theme}
|
|
229
|
+
locale={locale}
|
|
230
|
+
minimumDate={minimumDate}
|
|
231
|
+
maximumDate={maximumDate}
|
|
232
|
+
disabledDates={disabledDates}
|
|
233
|
+
disabledWeekdays={disabledWeekdays}
|
|
234
|
+
firstDayOfWeek={firstDayOfWeek}
|
|
235
|
+
allowManualEntry={allowManualEntry}
|
|
236
|
+
showActionButtons={false}
|
|
237
|
+
/>
|
|
238
|
+
)}
|
|
239
|
+
|
|
240
|
+
{/* Tab 2: Time (TimePicker) */}
|
|
241
|
+
{activeTab === 'time' && (
|
|
242
|
+
<TimePicker
|
|
243
|
+
value={currentDate}
|
|
244
|
+
onChange={handleTimeSelect}
|
|
245
|
+
format={displayFormat}
|
|
246
|
+
is24Hour={is24Hour}
|
|
247
|
+
minuteInterval={minuteInterval}
|
|
248
|
+
minimumTime={minimumTime}
|
|
249
|
+
maximumTime={maximumTime}
|
|
250
|
+
selectedDate={currentDate}
|
|
251
|
+
minimumDate={minimumDate}
|
|
252
|
+
maximumDate={maximumDate}
|
|
253
|
+
showSeconds={showSeconds}
|
|
254
|
+
timePickerLayout={timePickerLayout}
|
|
255
|
+
theme={theme}
|
|
256
|
+
locale={locale}
|
|
257
|
+
showActionButtons={false}
|
|
258
|
+
/>
|
|
259
|
+
)}
|
|
260
|
+
|
|
261
|
+
{/* Bottom Action Buttons */}
|
|
262
|
+
{showActionButtons && (
|
|
263
|
+
<View style={styles.actionsRow}>
|
|
264
|
+
<View style={styles.leftActions}>
|
|
265
|
+
<Button
|
|
266
|
+
title="Today/Now"
|
|
267
|
+
onPress={() => {
|
|
268
|
+
const now = new Date();
|
|
269
|
+
setCurrentDate(now);
|
|
270
|
+
onChange?.(now);
|
|
271
|
+
}}
|
|
272
|
+
variant="outline"
|
|
273
|
+
size="small"
|
|
274
|
+
theme={theme}
|
|
275
|
+
/>
|
|
276
|
+
{onClear && (
|
|
277
|
+
<Button
|
|
278
|
+
title={locale.clear}
|
|
279
|
+
onPress={() => {
|
|
280
|
+
onChange?.(null);
|
|
281
|
+
onClear();
|
|
282
|
+
}}
|
|
283
|
+
variant="text"
|
|
284
|
+
size="small"
|
|
285
|
+
theme={theme}
|
|
286
|
+
/>
|
|
287
|
+
)}
|
|
288
|
+
</View>
|
|
289
|
+
<View style={styles.rightActions}>
|
|
290
|
+
{onCancel && (
|
|
291
|
+
<Button
|
|
292
|
+
title={locale.cancel}
|
|
293
|
+
onPress={onCancel}
|
|
294
|
+
variant="text"
|
|
295
|
+
size="small"
|
|
296
|
+
theme={theme}
|
|
297
|
+
/>
|
|
298
|
+
)}
|
|
299
|
+
{onConfirm && (
|
|
300
|
+
<Button
|
|
301
|
+
title={locale.confirm}
|
|
302
|
+
onPress={() => onConfirm(currentDate)}
|
|
303
|
+
variant="primary"
|
|
304
|
+
size="small"
|
|
305
|
+
disabled={!isValid}
|
|
306
|
+
theme={theme}
|
|
307
|
+
/>
|
|
308
|
+
)}
|
|
309
|
+
</View>
|
|
310
|
+
</View>
|
|
311
|
+
)}
|
|
312
|
+
</View>
|
|
313
|
+
);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const styles = StyleSheet.create({
|
|
317
|
+
container: {
|
|
318
|
+
padding: 16,
|
|
319
|
+
borderWidth: 1,
|
|
320
|
+
flexGrow: 1,
|
|
321
|
+
justifyContent: 'space-between',
|
|
322
|
+
},
|
|
323
|
+
previewBanner: {
|
|
324
|
+
padding: 14,
|
|
325
|
+
borderRadius: 16,
|
|
326
|
+
borderWidth: 1,
|
|
327
|
+
marginBottom: 14,
|
|
328
|
+
shadowColor: '#000',
|
|
329
|
+
shadowOffset: { width: 0, height: 2 },
|
|
330
|
+
shadowOpacity: 0.04,
|
|
331
|
+
shadowRadius: 4,
|
|
332
|
+
elevation: 1,
|
|
333
|
+
},
|
|
334
|
+
previewHeaderRow: {
|
|
335
|
+
flexDirection: 'row',
|
|
336
|
+
justifyContent: 'space-between',
|
|
337
|
+
alignItems: 'center',
|
|
338
|
+
marginBottom: 4,
|
|
339
|
+
},
|
|
340
|
+
previewLabel: {
|
|
341
|
+
fontSize: 10,
|
|
342
|
+
fontWeight: '800',
|
|
343
|
+
letterSpacing: 0.6,
|
|
344
|
+
},
|
|
345
|
+
statusBadge: {
|
|
346
|
+
paddingHorizontal: 8,
|
|
347
|
+
paddingVertical: 3,
|
|
348
|
+
borderRadius: 8,
|
|
349
|
+
},
|
|
350
|
+
statusBadgeText: {
|
|
351
|
+
fontSize: 10,
|
|
352
|
+
fontWeight: '700',
|
|
353
|
+
},
|
|
354
|
+
previewValue: {
|
|
355
|
+
fontSize: 18,
|
|
356
|
+
fontWeight: '900',
|
|
357
|
+
letterSpacing: -0.4,
|
|
358
|
+
},
|
|
359
|
+
tabBar: {
|
|
360
|
+
flexDirection: 'row',
|
|
361
|
+
borderRadius: 12,
|
|
362
|
+
borderWidth: 1,
|
|
363
|
+
padding: 4,
|
|
364
|
+
marginBottom: 14,
|
|
365
|
+
},
|
|
366
|
+
tabItem: {
|
|
367
|
+
flex: 1,
|
|
368
|
+
paddingVertical: 9,
|
|
369
|
+
alignItems: 'center',
|
|
370
|
+
justifyContent: 'center',
|
|
371
|
+
borderRadius: 9,
|
|
372
|
+
},
|
|
373
|
+
tabText: {
|
|
374
|
+
fontSize: 13,
|
|
375
|
+
},
|
|
376
|
+
actionsRow: {
|
|
377
|
+
flexDirection: 'row',
|
|
378
|
+
justifyContent: 'space-between',
|
|
379
|
+
alignItems: 'center',
|
|
380
|
+
marginTop: 'auto',
|
|
381
|
+
paddingTop: 12,
|
|
382
|
+
borderTopWidth: 1,
|
|
383
|
+
borderTopColor: 'rgba(0,0,0,0.06)',
|
|
384
|
+
},
|
|
385
|
+
leftActions: {
|
|
386
|
+
flexDirection: 'row',
|
|
387
|
+
alignItems: 'center',
|
|
388
|
+
gap: 8,
|
|
389
|
+
},
|
|
390
|
+
rightActions: {
|
|
391
|
+
flexDirection: 'row',
|
|
392
|
+
alignItems: 'center',
|
|
393
|
+
gap: 8,
|
|
394
|
+
},
|
|
395
|
+
});
|