@purjayadi/react-native-datepicker 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # React Native DatePicker
2
+
3
+ A flexible and customizable React Native datepicker component with bottom sheet modal, featuring smooth wheel scrolling.
4
+
5
+ ## Features
6
+
7
+ - 📅 Date and Time Picker support
8
+ - 🎨 Fully customizable styling
9
+ - 📱 Cross-platform (iOS & Android)
10
+ - 🎡 Smooth wheel scrolling animation
11
+ - 🔧 TypeScript support
12
+ - âš¡ Easy to use with ref API
13
+ - 🎯 Min/Max date range support
14
+ - ♿ Safe area support
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @purjayadi/react-native-datepicker
20
+ ```
21
+
22
+ or
23
+
24
+ ```bash
25
+ yarn add @purjayadi/react-native-datepicker
26
+ ```
27
+
28
+ ### Peer Dependencies
29
+
30
+ This package requires the following peer dependencies to be installed:
31
+
32
+ ```bash
33
+ npm install react-native-reanimated react-native-gesture-handler @gorhom/bottom-sheet date-fns react-native-wheel-scrollview-picker react-native-safe-area-context
34
+ ```
35
+
36
+ Make sure to follow the setup instructions for:
37
+
38
+ - [@gorhom/bottom-sheet](https://gorhom.github.io/react-native-bottom-sheet/)
39
+ - [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/)
40
+ - [react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/)
41
+
42
+ ## Why date-fns?
43
+
44
+ This package uses [date-fns](https://date-fns.org/) for date manipulation, offering several advantages:
45
+
46
+ - âš¡ **Tree-shakeable**: Only bundle what you use (~13KB vs ~70KB with Moment.js)
47
+ - 🚀 **Modern**: Works with native JavaScript Date objects
48
+ - 🔧 **Immutable**: Functions always return new date instances
49
+ - 📦 **Modular**: Import only the functions you need
50
+
51
+ ## Usage
52
+
53
+ ### Basic Example
54
+
55
+ ```tsx
56
+ import React, { useRef } from "react";
57
+ import { View, Button } from "react-native";
58
+ import { DatePicker, DatePickerRef } from "@purjayadi/react-native-datepicker";
59
+
60
+ export default function App() {
61
+ const datePickerRef = useRef<DatePickerRef>(null);
62
+ const [selectedDate, setSelectedDate] = React.useState<string>("");
63
+
64
+ return (
65
+ <View style={{ padding: 20 }}>
66
+ <DatePicker
67
+ ref={datePickerRef}
68
+ label="Select Date"
69
+ placeholder="Choose a date"
70
+ currentDate={selectedDate}
71
+ onSetDate={setSelectedDate}
72
+ />
73
+
74
+ <Button
75
+ title="Open Picker"
76
+ onPress={() => datePickerRef.current?.show()}
77
+ />
78
+ </View>
79
+ );
80
+ }
81
+ ```
82
+
83
+ ### With Time Picker
84
+
85
+ ```tsx
86
+ <DatePicker
87
+ ref={datePickerRef}
88
+ label="Select Date & Time"
89
+ value={selectedDateTime}
90
+ onChange={setSelectedDateTime}
91
+ showTimePicker={true}
92
+ />
93
+ ```
94
+
95
+ ### With Min/Max Date
96
+
97
+ ```tsx
98
+ <DatePicker
99
+ ref={datePickerRef}
100
+ label="Select Date"
101
+ value={selectedDate}
102
+ onChange={setSelectedDate}
103
+ minDate="2020-01-01"
104
+ maxDate="2025-12-31"
105
+ />
106
+ ```
107
+
108
+ ### With Custom Styling
109
+
110
+ ```tsx
111
+ <DatePicker
112
+ ref={datePickerRef}
113
+ label="Select Date"
114
+ value={selectedDate}
115
+ onChange={setSelectedDate}
116
+ inputStyle={{
117
+ backgroundColor: "#E8F5E9",
118
+ borderRadius: 12,
119
+ }}
120
+ inputTextStyle={{
121
+ fontSize: 18,
122
+ color: "#1B5E20",
123
+ }}
124
+ highlightColor="#4CAF50"
125
+ buttonStyle={{
126
+ backgroundColor: "#4CAF50",
127
+ }}
128
+ />
129
+ ```
130
+
131
+ ### With Validation Errors
132
+
133
+ ```tsx
134
+ <DatePicker
135
+ ref={datePickerRef}
136
+ label="Birth Date"
137
+ value={birthDate}
138
+ onChange={setBirthDate}
139
+ errors={["Please select your birth date"]}
140
+ />
141
+ ```
142
+
143
+ ## API Reference
144
+
145
+ ### Props
146
+
147
+ | Prop | Type | Default | Description |
148
+ | ----------------------- | --------------------------- | --------------- | ----------------------------------------- |
149
+ | `value` | `string` | `undefined` | Current selected date string |
150
+ | `label` | `string` | `undefined` | Label text above the input |
151
+ | `placeholder` | `string` | `"Select Date"` | Placeholder text when no date is selected |
152
+ | `onChange` | `(date: string) => void` | **required** | Callback when date is selected |
153
+ | `minDate` | `string` | `undefined` | Minimum selectable date (ISO format) |
154
+ | `maxDate` | `string` | `undefined` | Maximum selectable date (ISO format) |
155
+ | `showTimePicker` | `boolean` | `false` | Show time picker in addition to date |
156
+ | `subText` | `string \| React.ReactNode` | `undefined` | Subtitle text below label |
157
+ | `errors` | `string[]` | `undefined` | Array of error messages |
158
+ | `inputStyle` | `ViewStyle` | `undefined` | Custom style for input container |
159
+ | `inputTextStyle` | `TextStyle` | `undefined` | Custom style for input text |
160
+ | `labelStyle` | `TextStyle` | `undefined` | Custom style for label |
161
+ | `errorStyle` | `TextStyle` | `undefined` | Custom style for error text |
162
+ | `subTextStyle` | `TextStyle` | `undefined` | Custom style for subtitle text |
163
+ | `highlightColor` | `string` | `"#E5E5E5"` | Color of the picker highlight |
164
+ | `buttonStyle` | `ViewStyle` | `undefined` | Custom style for save button |
165
+ | `buttonTextStyle` | `TextStyle` | `undefined` | Custom style for save button text |
166
+ | `cancelButtonStyle` | `ViewStyle` | `undefined` | Custom style for cancel button |
167
+ | `cancelButtonTextStyle` | `TextStyle` | `undefined` | Custom style for cancel button text |
168
+
169
+ ### Ref Methods
170
+
171
+ | Method | Parameters | Description |
172
+ | ------ | ---------------------- | --------------------------- |
173
+ | `show` | `initialDate?: string` | Opens the date picker modal |
174
+
175
+ ## Example App
176
+
177
+ Check out the [example](./example) directory for a complete working Expo app demonstrating all features.
178
+
179
+ ### Run the Example
180
+
181
+ ```bash
182
+ cd example
183
+ npm install
184
+ npm start
185
+ ```
186
+
187
+ Scan the QR code with Expo Go app or press `i` for iOS simulator / `a` for Android emulator.
188
+
189
+ ## Contributing
190
+
191
+ Contributions are welcome! Please feel free to submit a Pull Request.
192
+
193
+ ## License
194
+
195
+ MIT © [Your Name]
196
+
197
+ ## Credits
198
+
199
+ Built with:
200
+
201
+ - [@gorhom/bottom-sheet](https://github.com/gorhom/react-native-bottom-sheet)
202
+ - [react-native-wheel-scrollview-picker](https://github.com/yasemincidem/react-native-wheel-scrollview-picker)
203
+ - [date-fns](https://date-fns.org/)
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+
4
+ interface DatePickerRef {
5
+ show: (initialDate?: string) => void;
6
+ }
7
+ interface DatePickerProps {
8
+ value?: string;
9
+ label?: string;
10
+ placeholder?: string;
11
+ onChange: (date: string) => void;
12
+ minDate?: string;
13
+ maxDate?: string;
14
+ showTimePicker?: boolean;
15
+ subText?: string | React.ReactNode;
16
+ errors?: string[];
17
+ inputStyle?: ViewStyle;
18
+ inputTextStyle?: TextStyle;
19
+ labelStyle?: TextStyle;
20
+ errorStyle?: TextStyle;
21
+ subTextStyle?: TextStyle;
22
+ highlightColor?: string;
23
+ buttonStyle?: ViewStyle;
24
+ buttonTextStyle?: TextStyle;
25
+ cancelButtonStyle?: ViewStyle;
26
+ cancelButtonTextStyle?: TextStyle;
27
+ }
28
+ declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<DatePickerRef>>;
29
+
30
+ export { DatePicker, type DatePickerProps, type DatePickerRef };
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+
4
+ interface DatePickerRef {
5
+ show: (initialDate?: string) => void;
6
+ }
7
+ interface DatePickerProps {
8
+ value?: string;
9
+ label?: string;
10
+ placeholder?: string;
11
+ onChange: (date: string) => void;
12
+ minDate?: string;
13
+ maxDate?: string;
14
+ showTimePicker?: boolean;
15
+ subText?: string | React.ReactNode;
16
+ errors?: string[];
17
+ inputStyle?: ViewStyle;
18
+ inputTextStyle?: TextStyle;
19
+ labelStyle?: TextStyle;
20
+ errorStyle?: TextStyle;
21
+ subTextStyle?: TextStyle;
22
+ highlightColor?: string;
23
+ buttonStyle?: ViewStyle;
24
+ buttonTextStyle?: TextStyle;
25
+ cancelButtonStyle?: ViewStyle;
26
+ cancelButtonTextStyle?: TextStyle;
27
+ }
28
+ declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<DatePickerRef>>;
29
+
30
+ export { DatePicker, type DatePickerProps, type DatePickerRef };