farhoudshapouran / react-native-ui-datepicker

Customizable React Native ๐Ÿ“… DatePicker component for Android, iOS, and Web. It includes single, range and multiple modes and supports different locales.
https://farhoudshapouran.github.io/react-native-ui-datepicker/
MIT License
271 stars 28 forks source link

Month, Year select #52

Closed spaske1991 closed 4 months ago

spaske1991 commented 5 months ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch react-native-ui-datepicker@1.0.11 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-ui-datepicker/src/DateTimePicker.tsx b/node_modules/react-native-ui-datepicker/src/DateTimePicker.tsx
index 5a55cf2..3958bdd 100644
--- a/node_modules/react-native-ui-datepicker/src/DateTimePicker.tsx
+++ b/node_modules/react-native-ui-datepicker/src/DateTimePicker.tsx
@@ -137,7 +137,7 @@ const DateTimePicker = ({
   useEffect(() => {
     dispatch({
       type: CalendarActionKind.SET_CALENDAR_VIEW,
-      payload: mode === 'time' ? CalendarViews.time : CalendarViews.day,
+      payload: mode === 'time' ? CalendarViews.time : mode === 'year' ? CalendarViews.year : mode ==='month' ? CalendarViews.month : CalendarViews.day ,
     });
   }, [mode]);

diff --git a/node_modules/react-native-ui-datepicker/src/types.ts b/node_modules/react-native-ui-datepicker/src/types.ts
index 7783b3f..4229093 100644
--- a/node_modules/react-native-ui-datepicker/src/types.ts
+++ b/node_modules/react-native-ui-datepicker/src/types.ts
@@ -5,7 +5,7 @@ import type { ReactNode } from 'react';

 export type DateType = string | number | Dayjs | Date | null | undefined;

-export type CalendarModes = 'datetime' | 'date' | 'time';
+export type CalendarModes = 'datetime' | 'date' | 'time' | 'month' | 'year';

 export type HeaderButtonPositions = 'around' | 'right' | 'left';

This issue body was partially generated by patch-package.

farhoudshapouran commented 4 months ago

this is fixed in this commit 653daa8