react-native-nepali-picker 1.0.4-alpha.3 → 1.0.4-alpha.5
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/lib/commonjs/CalendarPicker.js +15 -7
- package/lib/commonjs/CalendarPicker.js.map +1 -1
- package/lib/commonjs/calendar/functions.js +2 -0
- package/lib/commonjs/calendar/functions.js.map +1 -1
- package/lib/commonjs/calendar/settings.js +1 -1
- package/lib/commonjs/calendar/settings.js.map +1 -1
- package/lib/module/CalendarPicker.js +15 -7
- package/lib/module/CalendarPicker.js.map +1 -1
- package/lib/module/calendar/functions.js +2 -0
- package/lib/module/calendar/functions.js.map +1 -1
- package/lib/module/calendar/settings.js +1 -1
- package/lib/module/calendar/settings.js.map +1 -1
- package/lib/typescript/commonjs/src/CalendarPicker.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/calendar/functions.d.ts.map +1 -1
- package/lib/typescript/module/src/CalendarPicker.d.ts.map +1 -1
- package/lib/typescript/module/src/calendar/functions.d.ts.map +1 -1
- package/package.json +2 -761
- package/src/CalendarPicker.tsx +25 -13
- package/src/calendar/functions.ts +2 -0
- package/src/calendar/settings.ts +3 -3
package/src/CalendarPicker.tsx
CHANGED
|
@@ -45,8 +45,8 @@ const CalendarPicker = ({
|
|
|
45
45
|
},
|
|
46
46
|
}: CalendarPickerProps) => {
|
|
47
47
|
const value = validateDate(initialDate);
|
|
48
|
-
console.log('
|
|
49
|
-
const TodayNepaliDate = initialDate;
|
|
48
|
+
console.log('the initial date is ', initialDate);
|
|
49
|
+
const [TodayNepaliDate, setTodayNepaliDate] = useState(initialDate);
|
|
50
50
|
const cYear = parseInt(TodayNepaliDate.split('-')[0], 10);
|
|
51
51
|
const cMonth = parseInt(TodayNepaliDate.split('-')[1], 10);
|
|
52
52
|
const cDay = parseInt(TodayNepaliDate.split('-')[2], 10);
|
|
@@ -57,12 +57,24 @@ const CalendarPicker = ({
|
|
|
57
57
|
const [calendarDate, setCalendarDate] = useState<(number | null)[]>([]);
|
|
58
58
|
|
|
59
59
|
const [yearModal, setYearModal] = useState<boolean>(false);
|
|
60
|
+
|
|
61
|
+
const syncToday = () => {
|
|
62
|
+
setMonth(cMonth);
|
|
63
|
+
setYear(cYear);
|
|
64
|
+
};
|
|
65
|
+
|
|
60
66
|
const handleDateClick = (day: number) => {
|
|
61
67
|
const date = `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
|
|
68
|
+
setTodayNepaliDate(date);
|
|
62
69
|
onDateSelect(date);
|
|
63
70
|
onClose();
|
|
64
71
|
};
|
|
65
72
|
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
setTodayNepaliDate(initialDate);
|
|
75
|
+
}, [initialDate]);
|
|
76
|
+
|
|
77
|
+
//Handle Next Month Click
|
|
66
78
|
const handleNextClick = () => {
|
|
67
79
|
if (month === 12) {
|
|
68
80
|
if (year < 2099) {
|
|
@@ -73,6 +85,8 @@ const CalendarPicker = ({
|
|
|
73
85
|
setMonth((prev) => prev + 1);
|
|
74
86
|
}
|
|
75
87
|
};
|
|
88
|
+
|
|
89
|
+
//Handle Previous Month Click
|
|
76
90
|
const handlePreviousClick = () => {
|
|
77
91
|
if (month === 1) {
|
|
78
92
|
if (year > 2000) {
|
|
@@ -108,12 +122,7 @@ const CalendarPicker = ({
|
|
|
108
122
|
}
|
|
109
123
|
});
|
|
110
124
|
setCalendarDate(calendarCells);
|
|
111
|
-
}, [year, month]);
|
|
112
|
-
|
|
113
|
-
const syncToday = () => {
|
|
114
|
-
setMonth(cMonth);
|
|
115
|
-
setYear(cYear);
|
|
116
|
-
};
|
|
125
|
+
}, [year, month, initialDate]);
|
|
117
126
|
|
|
118
127
|
const handleYearClick = (y: number) => {
|
|
119
128
|
setYear(y);
|
|
@@ -126,7 +135,7 @@ const CalendarPicker = ({
|
|
|
126
135
|
return (
|
|
127
136
|
<Modal visible={visible} onRequestClose={onClose} transparent={true}>
|
|
128
137
|
<Pressable style={styles.outerPressable} onPress={onClose}>
|
|
129
|
-
<Pressable onPress={() => {
|
|
138
|
+
<Pressable onPress={() => {}} style={styles.innerPressable}>
|
|
130
139
|
<View
|
|
131
140
|
style={{
|
|
132
141
|
...styles.innerView,
|
|
@@ -165,7 +174,7 @@ const CalendarPicker = ({
|
|
|
165
174
|
return (
|
|
166
175
|
<Modal visible={visible} onRequestClose={onClose} transparent={true}>
|
|
167
176
|
<Pressable style={styles.outerPressable} onPress={onClose}>
|
|
168
|
-
<Pressable onPress={() => {
|
|
177
|
+
<Pressable onPress={() => {}} style={styles.innerPressable}>
|
|
169
178
|
<View
|
|
170
179
|
style={{
|
|
171
180
|
...styles.innerView,
|
|
@@ -173,7 +182,10 @@ const CalendarPicker = ({
|
|
|
173
182
|
}}
|
|
174
183
|
>
|
|
175
184
|
<Text
|
|
176
|
-
style={{
|
|
185
|
+
style={{
|
|
186
|
+
color: dark ? 'white' : 'black',
|
|
187
|
+
paddingHorizontal: 10,
|
|
188
|
+
}}
|
|
177
189
|
>
|
|
178
190
|
{language === 'np' ? 'आजको मिति ' : "Today's Date"}
|
|
179
191
|
</Text>
|
|
@@ -300,7 +312,7 @@ const CalendarPicker = ({
|
|
|
300
312
|
key={index}
|
|
301
313
|
onPress={
|
|
302
314
|
//execute on day item press, Only execute when dayItem is not null
|
|
303
|
-
dayItem ? () => handleDateClick(dayItem) : () => {
|
|
315
|
+
dayItem ? () => handleDateClick(dayItem) : () => {}
|
|
304
316
|
}
|
|
305
317
|
>
|
|
306
318
|
{dayItem ? (
|
|
@@ -362,7 +374,7 @@ const CalendarPicker = ({
|
|
|
362
374
|
style={styles.outerPressable}
|
|
363
375
|
onPress={() => closeYearView()}
|
|
364
376
|
>
|
|
365
|
-
<Pressable style={styles.YearInnerPressable} onPress={() => {
|
|
377
|
+
<Pressable style={styles.YearInnerPressable} onPress={() => {}}>
|
|
366
378
|
<View
|
|
367
379
|
style={{
|
|
368
380
|
...styles.InnerYearView,
|
|
@@ -114,9 +114,11 @@ const BsToAd = (userDate: DateString): DateString => {
|
|
|
114
114
|
if (userMonth < 1 || userMonth > 12) {
|
|
115
115
|
throw new Error('Month Range is 1 to 12');
|
|
116
116
|
}
|
|
117
|
+
|
|
117
118
|
// if (userMonth < 1 || userMonth > 31) {
|
|
118
119
|
// throw new Error('Month out of supported range');
|
|
119
120
|
// }
|
|
121
|
+
|
|
120
122
|
for (let year = 2000; year < userYear; year++) {
|
|
121
123
|
for (let month = 1; month <= 12; month++) {
|
|
122
124
|
dateDifference += bs[year][month];
|
package/src/calendar/settings.ts
CHANGED
|
@@ -36,9 +36,9 @@ const isToday = (
|
|
|
36
36
|
firstDayOfMonth: number
|
|
37
37
|
) => {
|
|
38
38
|
return (
|
|
39
|
-
parseInt(date.
|
|
40
|
-
currentMonth === parseInt(date.slice(
|
|
41
|
-
currentYear === parseInt(date.slice(0, 4))
|
|
39
|
+
parseInt(date.split('-')[2], 10) - 1 + firstDayOfMonth === index &&
|
|
40
|
+
currentMonth === parseInt(date.slice(5, 7), 10) &&
|
|
41
|
+
currentYear === parseInt(date.slice(0, 4), 10)
|
|
42
42
|
);
|
|
43
43
|
};
|
|
44
44
|
|