@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,407 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
ScrollView,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import type { DatePickerTheme, DatePickerLocale } from '../../types';
|
|
10
|
+
import { Modal } from '../common/Modal';
|
|
11
|
+
|
|
12
|
+
export interface MonthYearSelectorModalProps {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
currentYear: number;
|
|
16
|
+
currentMonth: number;
|
|
17
|
+
theme: DatePickerTheme;
|
|
18
|
+
locale: DatePickerLocale;
|
|
19
|
+
onSelectMonth?: (monthIndex: number) => void;
|
|
20
|
+
onSelectYear?: (year: number) => void;
|
|
21
|
+
onConfirm?: (year: number, month: number) => void;
|
|
22
|
+
minYear?: number;
|
|
23
|
+
maxYear?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const MonthYearSelectorModal: React.FC<MonthYearSelectorModalProps> = ({
|
|
27
|
+
visible,
|
|
28
|
+
onClose,
|
|
29
|
+
currentYear,
|
|
30
|
+
currentMonth,
|
|
31
|
+
theme,
|
|
32
|
+
locale,
|
|
33
|
+
onSelectMonth,
|
|
34
|
+
onSelectYear,
|
|
35
|
+
onConfirm,
|
|
36
|
+
minYear = 1970,
|
|
37
|
+
maxYear = 2050,
|
|
38
|
+
}) => {
|
|
39
|
+
const [selectedMonth, setSelectedMonth] = useState<number>(currentMonth);
|
|
40
|
+
const [selectedYear, setSelectedYear] = useState<number>(currentYear);
|
|
41
|
+
|
|
42
|
+
const monthScrollRef = useRef<ScrollView>(null);
|
|
43
|
+
const yearScrollRef = useRef<ScrollView>(null);
|
|
44
|
+
|
|
45
|
+
const years: number[] = [];
|
|
46
|
+
for (let y = minYear; y <= maxYear; y++) {
|
|
47
|
+
years.push(y);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Sync internal selected month and year when modal opens
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (visible) {
|
|
53
|
+
setSelectedMonth(currentMonth);
|
|
54
|
+
setSelectedYear(currentYear);
|
|
55
|
+
}
|
|
56
|
+
}, [visible, currentMonth, currentYear]);
|
|
57
|
+
|
|
58
|
+
// Auto-scroll to current/selected month and year when modal opens
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!visible) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const timer = setTimeout(() => {
|
|
64
|
+
const ITEM_HEIGHT = 40;
|
|
65
|
+
if (monthScrollRef.current && selectedMonth > 1) {
|
|
66
|
+
monthScrollRef.current.scrollTo({
|
|
67
|
+
y: Math.max(0, (selectedMonth - 1) * ITEM_HEIGHT),
|
|
68
|
+
animated: false,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const yearIndex = years.indexOf(selectedYear);
|
|
72
|
+
if (yearScrollRef.current && yearIndex > 1) {
|
|
73
|
+
yearScrollRef.current.scrollTo({
|
|
74
|
+
y: Math.max(0, (yearIndex - 1) * ITEM_HEIGHT),
|
|
75
|
+
animated: false,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, 100);
|
|
79
|
+
return () => clearTimeout(timer);
|
|
80
|
+
}, [visible, selectedMonth, selectedYear, years]);
|
|
81
|
+
|
|
82
|
+
const handleMonthPress = (idx: number) => {
|
|
83
|
+
setSelectedMonth(idx);
|
|
84
|
+
onSelectMonth?.(idx);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleYearPress = (yearNum: number) => {
|
|
88
|
+
setSelectedYear(yearNum);
|
|
89
|
+
onSelectYear?.(yearNum);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const handleConfirmPress = () => {
|
|
93
|
+
if (onConfirm) {
|
|
94
|
+
onConfirm(selectedYear, selectedMonth);
|
|
95
|
+
} else {
|
|
96
|
+
onSelectMonth?.(selectedMonth);
|
|
97
|
+
onSelectYear?.(selectedYear);
|
|
98
|
+
onClose();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<Modal
|
|
104
|
+
visible={visible}
|
|
105
|
+
onClose={onClose}
|
|
106
|
+
theme={theme}
|
|
107
|
+
contentStyle={styles.selectorModalCard}
|
|
108
|
+
>
|
|
109
|
+
<View style={styles.selectorContainer}>
|
|
110
|
+
{/* Header with Title & Close Icon */}
|
|
111
|
+
<View style={styles.selectorHeader}>
|
|
112
|
+
<View style={styles.titleBadgeRow}>
|
|
113
|
+
<Text style={styles.calendarIcon}>📅</Text>
|
|
114
|
+
<Text
|
|
115
|
+
style={[
|
|
116
|
+
styles.selectorTitle,
|
|
117
|
+
{ color: theme.textColor, fontSize: theme.fontSize.title },
|
|
118
|
+
]}
|
|
119
|
+
>
|
|
120
|
+
{locale.selectDate}
|
|
121
|
+
</Text>
|
|
122
|
+
</View>
|
|
123
|
+
<TouchableOpacity
|
|
124
|
+
activeOpacity={0.7}
|
|
125
|
+
onPress={onClose}
|
|
126
|
+
style={[styles.closeButton, { backgroundColor: `${theme.textColor}12` }]}
|
|
127
|
+
accessibilityRole="button"
|
|
128
|
+
accessibilityLabel="Close"
|
|
129
|
+
>
|
|
130
|
+
<Text style={[styles.closeIcon, { color: theme.secondaryTextColor }]}>✕</Text>
|
|
131
|
+
</TouchableOpacity>
|
|
132
|
+
</View>
|
|
133
|
+
|
|
134
|
+
{/* Two Structured Columns: Month & Year */}
|
|
135
|
+
<View style={styles.selectorColumns}>
|
|
136
|
+
{/* Months List Column */}
|
|
137
|
+
<View
|
|
138
|
+
style={[
|
|
139
|
+
styles.columnCard,
|
|
140
|
+
{
|
|
141
|
+
backgroundColor: `${theme.primaryColor}06`,
|
|
142
|
+
borderColor: theme.borderColor,
|
|
143
|
+
},
|
|
144
|
+
]}
|
|
145
|
+
>
|
|
146
|
+
<View
|
|
147
|
+
style={[
|
|
148
|
+
styles.columnHeader,
|
|
149
|
+
{
|
|
150
|
+
borderBottomColor: theme.borderColor,
|
|
151
|
+
backgroundColor: `${theme.primaryColor}0A`,
|
|
152
|
+
},
|
|
153
|
+
]}
|
|
154
|
+
>
|
|
155
|
+
<Text
|
|
156
|
+
style={[
|
|
157
|
+
styles.columnLabel,
|
|
158
|
+
{ color: theme.secondaryTextColor },
|
|
159
|
+
]}
|
|
160
|
+
>
|
|
161
|
+
{locale.monthLabel}
|
|
162
|
+
</Text>
|
|
163
|
+
</View>
|
|
164
|
+
<ScrollView
|
|
165
|
+
ref={monthScrollRef}
|
|
166
|
+
style={styles.columnScroll}
|
|
167
|
+
contentContainerStyle={styles.columnScrollContent}
|
|
168
|
+
nestedScrollEnabled={true}
|
|
169
|
+
showsVerticalScrollIndicator={false}
|
|
170
|
+
>
|
|
171
|
+
{locale.months.map((monthName, idx) => {
|
|
172
|
+
const isSelected = idx === selectedMonth;
|
|
173
|
+
return (
|
|
174
|
+
<TouchableOpacity
|
|
175
|
+
key={monthName}
|
|
176
|
+
activeOpacity={0.7}
|
|
177
|
+
style={[
|
|
178
|
+
styles.pickerItem,
|
|
179
|
+
isSelected && [
|
|
180
|
+
styles.pickerItemSelected,
|
|
181
|
+
{
|
|
182
|
+
backgroundColor: theme.primaryColor,
|
|
183
|
+
shadowColor: theme.primaryColor,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
]}
|
|
187
|
+
onPress={() => handleMonthPress(idx)}
|
|
188
|
+
>
|
|
189
|
+
<Text
|
|
190
|
+
style={[
|
|
191
|
+
styles.pickerItemText,
|
|
192
|
+
{
|
|
193
|
+
color: isSelected ? '#FFFFFF' : theme.textColor,
|
|
194
|
+
fontWeight: isSelected ? '800' : '500',
|
|
195
|
+
},
|
|
196
|
+
]}
|
|
197
|
+
>
|
|
198
|
+
{monthName}
|
|
199
|
+
</Text>
|
|
200
|
+
</TouchableOpacity>
|
|
201
|
+
);
|
|
202
|
+
})}
|
|
203
|
+
</ScrollView>
|
|
204
|
+
</View>
|
|
205
|
+
|
|
206
|
+
{/* Years List Column */}
|
|
207
|
+
<View
|
|
208
|
+
style={[
|
|
209
|
+
styles.columnCard,
|
|
210
|
+
{
|
|
211
|
+
backgroundColor: `${theme.primaryColor}06`,
|
|
212
|
+
borderColor: theme.borderColor,
|
|
213
|
+
},
|
|
214
|
+
]}
|
|
215
|
+
>
|
|
216
|
+
<View
|
|
217
|
+
style={[
|
|
218
|
+
styles.columnHeader,
|
|
219
|
+
{
|
|
220
|
+
borderBottomColor: theme.borderColor,
|
|
221
|
+
backgroundColor: `${theme.primaryColor}0A`,
|
|
222
|
+
},
|
|
223
|
+
]}
|
|
224
|
+
>
|
|
225
|
+
<Text
|
|
226
|
+
style={[
|
|
227
|
+
styles.columnLabel,
|
|
228
|
+
{ color: theme.secondaryTextColor },
|
|
229
|
+
]}
|
|
230
|
+
>
|
|
231
|
+
{locale.yearLabel}
|
|
232
|
+
</Text>
|
|
233
|
+
</View>
|
|
234
|
+
<ScrollView
|
|
235
|
+
ref={yearScrollRef}
|
|
236
|
+
style={styles.columnScroll}
|
|
237
|
+
contentContainerStyle={styles.columnScrollContent}
|
|
238
|
+
nestedScrollEnabled={true}
|
|
239
|
+
showsVerticalScrollIndicator={false}
|
|
240
|
+
>
|
|
241
|
+
{years.map((yearNum) => {
|
|
242
|
+
const isSelected = yearNum === selectedYear;
|
|
243
|
+
return (
|
|
244
|
+
<TouchableOpacity
|
|
245
|
+
key={yearNum}
|
|
246
|
+
activeOpacity={0.7}
|
|
247
|
+
style={[
|
|
248
|
+
styles.pickerItem,
|
|
249
|
+
isSelected && [
|
|
250
|
+
styles.pickerItemSelected,
|
|
251
|
+
{
|
|
252
|
+
backgroundColor: theme.primaryColor,
|
|
253
|
+
shadowColor: theme.primaryColor,
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
]}
|
|
257
|
+
onPress={() => handleYearPress(yearNum)}
|
|
258
|
+
>
|
|
259
|
+
<Text
|
|
260
|
+
style={[
|
|
261
|
+
styles.pickerItemText,
|
|
262
|
+
{
|
|
263
|
+
color: isSelected ? '#FFFFFF' : theme.textColor,
|
|
264
|
+
fontWeight: isSelected ? '800' : '500',
|
|
265
|
+
},
|
|
266
|
+
]}
|
|
267
|
+
>
|
|
268
|
+
{yearNum}
|
|
269
|
+
</Text>
|
|
270
|
+
</TouchableOpacity>
|
|
271
|
+
);
|
|
272
|
+
})}
|
|
273
|
+
</ScrollView>
|
|
274
|
+
</View>
|
|
275
|
+
</View>
|
|
276
|
+
|
|
277
|
+
{/* Confirm / Done Action Button */}
|
|
278
|
+
<TouchableOpacity
|
|
279
|
+
activeOpacity={0.85}
|
|
280
|
+
onPress={handleConfirmPress}
|
|
281
|
+
style={[
|
|
282
|
+
styles.doneButton,
|
|
283
|
+
{
|
|
284
|
+
backgroundColor: theme.primaryColor,
|
|
285
|
+
shadowColor: theme.primaryColor,
|
|
286
|
+
},
|
|
287
|
+
]}
|
|
288
|
+
>
|
|
289
|
+
<Text style={[styles.doneButtonText, { color: theme.primaryTextColor || '#FFFFFF' }]}>
|
|
290
|
+
{locale.confirm || 'Confirm'}
|
|
291
|
+
</Text>
|
|
292
|
+
</TouchableOpacity>
|
|
293
|
+
</View>
|
|
294
|
+
</Modal>
|
|
295
|
+
);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const styles = StyleSheet.create({
|
|
299
|
+
selectorModalCard: {
|
|
300
|
+
maxHeight: 460,
|
|
301
|
+
minHeight: 400,
|
|
302
|
+
width: '92%',
|
|
303
|
+
maxWidth: 380,
|
|
304
|
+
paddingHorizontal: 16,
|
|
305
|
+
paddingVertical: 14,
|
|
306
|
+
},
|
|
307
|
+
selectorContainer: {
|
|
308
|
+
width: '100%',
|
|
309
|
+
flex: 1,
|
|
310
|
+
paddingVertical: 4,
|
|
311
|
+
},
|
|
312
|
+
selectorHeader: {
|
|
313
|
+
flexDirection: 'row',
|
|
314
|
+
justifyContent: 'space-between',
|
|
315
|
+
alignItems: 'center',
|
|
316
|
+
marginBottom: 12,
|
|
317
|
+
paddingHorizontal: 2,
|
|
318
|
+
},
|
|
319
|
+
titleBadgeRow: {
|
|
320
|
+
flexDirection: 'row',
|
|
321
|
+
alignItems: 'center',
|
|
322
|
+
gap: 8,
|
|
323
|
+
},
|
|
324
|
+
calendarIcon: {
|
|
325
|
+
fontSize: 18,
|
|
326
|
+
},
|
|
327
|
+
selectorTitle: {
|
|
328
|
+
fontWeight: '700',
|
|
329
|
+
},
|
|
330
|
+
closeButton: {
|
|
331
|
+
width: 28,
|
|
332
|
+
height: 28,
|
|
333
|
+
borderRadius: 14,
|
|
334
|
+
justifyContent: 'center',
|
|
335
|
+
alignItems: 'center',
|
|
336
|
+
},
|
|
337
|
+
closeIcon: {
|
|
338
|
+
fontSize: 13,
|
|
339
|
+
fontWeight: '700',
|
|
340
|
+
},
|
|
341
|
+
selectorColumns: {
|
|
342
|
+
flexDirection: 'row',
|
|
343
|
+
justifyContent: 'space-between',
|
|
344
|
+
height: 260,
|
|
345
|
+
gap: 12,
|
|
346
|
+
marginBottom: 12,
|
|
347
|
+
},
|
|
348
|
+
columnCard: {
|
|
349
|
+
flex: 1,
|
|
350
|
+
borderRadius: 14,
|
|
351
|
+
borderWidth: 1.5,
|
|
352
|
+
overflow: 'hidden',
|
|
353
|
+
},
|
|
354
|
+
columnHeader: {
|
|
355
|
+
paddingVertical: 9,
|
|
356
|
+
alignItems: 'center',
|
|
357
|
+
justifyContent: 'center',
|
|
358
|
+
borderBottomWidth: 1,
|
|
359
|
+
},
|
|
360
|
+
columnLabel: {
|
|
361
|
+
fontSize: 11,
|
|
362
|
+
fontWeight: '800',
|
|
363
|
+
letterSpacing: 0.8,
|
|
364
|
+
textTransform: 'uppercase',
|
|
365
|
+
textAlign: 'center',
|
|
366
|
+
},
|
|
367
|
+
columnScroll: {
|
|
368
|
+
flex: 1,
|
|
369
|
+
},
|
|
370
|
+
columnScrollContent: {
|
|
371
|
+
paddingVertical: 4,
|
|
372
|
+
paddingHorizontal: 4,
|
|
373
|
+
},
|
|
374
|
+
pickerItem: {
|
|
375
|
+
paddingVertical: 9,
|
|
376
|
+
paddingHorizontal: 6,
|
|
377
|
+
marginVertical: 2,
|
|
378
|
+
borderRadius: 9,
|
|
379
|
+
alignItems: 'center',
|
|
380
|
+
justifyContent: 'center',
|
|
381
|
+
},
|
|
382
|
+
pickerItemSelected: {
|
|
383
|
+
shadowOffset: { width: 0, height: 2 },
|
|
384
|
+
shadowOpacity: 0.25,
|
|
385
|
+
shadowRadius: 4,
|
|
386
|
+
elevation: 3,
|
|
387
|
+
},
|
|
388
|
+
pickerItemText: {
|
|
389
|
+
fontSize: 14,
|
|
390
|
+
textAlign: 'center',
|
|
391
|
+
},
|
|
392
|
+
doneButton: {
|
|
393
|
+
width: '100%',
|
|
394
|
+
height: 44,
|
|
395
|
+
borderRadius: 12,
|
|
396
|
+
justifyContent: 'center',
|
|
397
|
+
alignItems: 'center',
|
|
398
|
+
shadowOffset: { width: 0, height: 2 },
|
|
399
|
+
shadowOpacity: 0.25,
|
|
400
|
+
shadowRadius: 4,
|
|
401
|
+
elevation: 3,
|
|
402
|
+
},
|
|
403
|
+
doneButtonText: {
|
|
404
|
+
fontSize: 15,
|
|
405
|
+
fontWeight: '700',
|
|
406
|
+
},
|
|
407
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
3
|
+
import type { DatePickerTheme } from '../../types';
|
|
4
|
+
|
|
5
|
+
export interface WeekDaysProps {
|
|
6
|
+
weekdays: { index: number; name: string; short: string; min: string }[];
|
|
7
|
+
theme: DatePickerTheme;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const WeekDays: React.FC<WeekDaysProps> = ({ weekdays, theme }) => {
|
|
11
|
+
return (
|
|
12
|
+
<View style={styles.container}>
|
|
13
|
+
{weekdays.map((day) => (
|
|
14
|
+
<View key={day.index} style={styles.cell}>
|
|
15
|
+
<Text
|
|
16
|
+
style={[
|
|
17
|
+
styles.text,
|
|
18
|
+
{
|
|
19
|
+
color: theme.secondaryTextColor,
|
|
20
|
+
fontSize: theme.fontSize.small,
|
|
21
|
+
},
|
|
22
|
+
]}
|
|
23
|
+
>
|
|
24
|
+
{day.min || day.short}
|
|
25
|
+
</Text>
|
|
26
|
+
</View>
|
|
27
|
+
))}
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
container: {
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
width: '100%',
|
|
36
|
+
paddingVertical: 8,
|
|
37
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
38
|
+
borderBottomColor: 'rgba(0,0,0,0.06)',
|
|
39
|
+
},
|
|
40
|
+
cell: {
|
|
41
|
+
flex: 1,
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
},
|
|
45
|
+
text: {
|
|
46
|
+
fontWeight: '600',
|
|
47
|
+
textTransform: 'uppercase',
|
|
48
|
+
},
|
|
49
|
+
});
|